@storm-software/git-tools
Version:
Tools for managing Git repositories within a Nx workspace.
1 lines • 2.3 kB
Source Map (JSON)
{"version":3,"sources":["../../src/utilities/check-package-version.ts"],"names":[],"mappings":";;;AAMO,IAAM,uBAAA,GAA0B,CAAC,KAAA,KACtC,KAAA,EAAO,IAAA;AAAA,EACL,CAAA,GAAA,KACE,IAAI,QAAA,CAAS,mBAAmB,KAChC,GAAA,CAAI,QAAA,CAAS,WAAW,CAAA,IACxB,GAAA,CAAI,QAAA,CAAS,gBAAgB,CAAA,IAC7B,GAAA,CAAI,QAAA,CAAS,gBAAgB,CAAA,IAC7B,GAAA,CAAI,SAAS,eAAe,CAAA,IAC5B,GAAA,CAAI,QAAA,CAAS,WAAW;AAC5B;AAOK,IAAM,mBAAA,GAAsB,CAAC,KAAA,KAAoB;AACtD,EAAA,IAAI,uBAAA,CAAwB,KAAK,CAAA,EAAG;AAClC,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,QACE,qHAAA;AAAA,QACA,qHAAA;AAAA,QACA;AAAA,OACF,CAAE,KAAK,IAAI;AAAA,KACb;AAAA,EACF;AACF","file":"chunk-YHZNDNCW.cjs","sourcesContent":["/**\n * Checks if the package version has changed by looking for changes in lock files.\n *\n * @param files - An array of file paths to check for changes. Typically, this would be the list of files changed in a git commit or checkout.\n * @returns true if any of the lock files have changed, indicating a potential change in package versions; otherwise, false.\n */\nexport const isPackageVersionChanged = (files: string[]) =>\n files?.some(\n arg =>\n arg.includes(\"package-lock.json\") ||\n arg.includes(\"yarn.lock\") ||\n arg.includes(\"pnpm-lock.json\") ||\n arg.includes(\"pnpm-lock.yaml\") ||\n arg.includes(\"pnpm-lock.yml\") ||\n arg.includes(\"bun.lockb\")\n );\n\n/**\n * Checks if the package version has changed and logs a warning if it has. This function is typically used in git hooks to alert developers to run `pnpm i` when lock files have changed, ensuring that their local environment is up to date with the latest dependencies.\n *\n * @param files - An array of file paths to check for changes. Typically, this would be the list of files changed in a git commit or checkout.\n */\nexport const checkPackageVersion = (files: string[]) => {\n if (isPackageVersionChanged(files)) {\n console.warn(\n [\n \"⚠️ ----------------------------------------------------------------------------------------- ⚠️\",\n \"⚠️ The pnpm-lock file changed! Please run `pnpm i` to ensure your packages are up to date. ⚠️\",\n \"⚠️ ----------------------------------------------------------------------------------------- ⚠️\"\n ].join(\"\\n\")\n );\n }\n};\n"]}