chore: configure pre-commit stages and add build hook #83
Reference in New Issue
Block a user
Delete Branch "feature/pre-commit-build"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
rebuild-distributionhook, it is recommended to addgit add dist/or similar to theentryor via a separate hook. Currently,npm run buildgenerates files indist/, but these modified files are not automatically staged. This means the built distribution might not be included in the commit that triggered the build, defeating the purpose of an automated pre-commit build hook.monitor.jsto thepackage.jsonbuild script or verifying if it should be an entry point, as it is listed in thefilesfilter for the pre-commit hook but typicallyncc(used in your build script) bundles everything from a single entry point.readme.mde$from theend-of-file-fixerexclusion; this is a good cleanup.The PR correctly sets up
default_stagesto allow manual execution of hooks and introduces a local build hook to keep the distribution in sync with the source.@@ -47,0 +51,4 @@- id: buildname: rebuild-distributionentry: npm run buildlanguage: systemYou've added
monitor.jsto the list of files that trigger a rebuild. However, looking atpackage.json, the build script only targetsindex.js. Ifmonitor.jsis not imported byindex.js, changes to it won't be reflected in thedist/folder via the current build command.@@ -47,0 +52,4 @@name: rebuild-distributionentry: npm run buildlanguage: systemfiles: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$Since
npm run buildupdates thedist/directory, these changes won't be included in the current commit unless they are staged.You might want to change the entry to:
entry: /bin/bash -c "npm run build && git add dist/"Or ensure that developers are aware they need to stage
dist/if the hook fails (though usually, pre-commit hooks should ideally handle the staging if they modify files).Summary
monitor.jsfile is included in the pre-commit trigger for the build hook, but it is not found in the repository root and is not referenced in thenpm run buildcommand (which targetsindex.js).readme.mde$).The author has successfully addressed previous feedback regarding the need to stage
dist/changes automatically by adding theadd-disthook. Althoughmonitor.jsis still missing from the root or build command, this isn't a blocking issue since the primaryindex.jsandpackage.jsonlogic is correct.@@ -47,0 +54,4 @@language: systemfiles: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$pass_filenames: falsestages: [pre-commit]The file
monitor.jsis not present in the repository root. If this is a future file, keep it; otherwise, this entry will never trigger the hook for that specific file. Additionally, thebuildscript inpackage.jsononly compilesindex.js.@@ -47,0 +61,4 @@language: systemfiles: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$pass_filenames: falsestages: [pre-commit]This is a good solution to ensure the compiled distribution is always included in the commit that modified the source.
Summary
monitor.jsin thefilesregex for therebuild-distributionandstage-distributionhooks is redundant as the file does not exist in the repository root and is not part of thenpm run buildcommand (which only targetsindex.js).The PR addresses previous feedback by automating the staging of the
dist/directory after a build, ensuring that compiled assets stay in sync with source changes during the commit process. Whilemonitor.jsis missing, it does not impede the functionality of the existing hooks.@@ -47,0 +55,4 @@language: systemfiles: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$pass_filenames: falsestages: [pre-commit]monitor.jsdoes not exist in the repository root. If this is not a planned file, it should be removed from the regex to avoid confusion. Additionally, thebuildscript inpackage.jsoncurrently only processesindex.js.@@ -47,0 +62,4 @@language: systemfiles: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$pass_filenames: falsestages: [pre-commit]Same as above,
monitor.jsis referenced here but is missing from the file tree.Summary
rebuild-distributionandstage-distributionhooks includesmonitor.js, which does not exist in the repository root. While harmless, it should be removed to avoid confusion. Additionally, as noted in previous reviews, thenpm run buildcommand only targetsindex.js.The PR effectively addresses the need to ensure the
dist/folder is updated and staged automatically whenever source files are changed, preventing desynchronization between the source code and the compiled action. Previous feedback regarding the staging of files has been addressed by adding theadd-disthook.@@ -47,0 +54,4 @@- id: buildname: rebuild-distributionentry: npm run buildlanguage: systemmonitor.jsis included in the file filter but does not exist in the repository. If there are no plans to add this file, it should be removed from the regex.@@ -47,0 +61,4 @@- id: add-distname: stage-distributionentry: git add dist/language: systemSame here,
monitor.jsis referenced but does not exist in the file tree.Summary
.pre-commit-config.yaml, the hooksbuildandadd-distreferencemonitor.jsin thefilesregex, but this file does not exist in the repository root. This has been noted in previous reviews but remains unaddressed.buildscript inpackage.jsononly processesindex.js. Ifmonitor.jsis intended to be a source file, it should be added to the repository or the regex should be cleaned up to avoid confusion.The PR effectively sets up pre-commit stages to distinguish between fast local checks and manual/CI checks, and ensures the
dist/folder is updated and staged automatically upon changes to source files. Since the core functionality is correct and themonitor.jsissue is non-breaking, I am approving the changes.@@ -45,2 +49,4 @@- id: mixed-line-endingargs: [--fix=lf]- repo: localmonitor.jsis still included in the regex but does not exist in the repository. As noted in previous reviews, if there are no immediate plans for this file, it's cleaner to remove it.@@ -47,0 +56,4 @@entry: npm run buildlanguage: systemfiles: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$pass_filenames: falseSame as above,
monitor.jsis referenced here but is missing from the file tree.Pull request closed