skuba 7.4.0-master-20240206030206 → 7.4.0-master-20240207024454

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/lib/cli/configure/modules/eslint.js +2 -2
  2. package/lib/cli/configure/modules/eslint.js.map +2 -2
  3. package/lib/cli/configure/modules/ignore.js +3 -3
  4. package/lib/cli/configure/modules/ignore.js.map +1 -1
  5. package/lib/cli/configure/modules/prettier.js +2 -2
  6. package/lib/cli/configure/modules/prettier.js.map +2 -2
  7. package/lib/cli/configure/processing/configFile.d.ts +9 -0
  8. package/lib/cli/configure/processing/{ignoreFile.js → configFile.js} +29 -11
  9. package/lib/cli/configure/processing/configFile.js.map +7 -0
  10. package/lib/cli/configure/upgrade/patches/7.3.1/index.js +6 -2
  11. package/lib/cli/configure/upgrade/patches/7.3.1/index.js.map +2 -2
  12. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.d.ts +2 -0
  13. package/lib/cli/configure/upgrade/patches/7.3.1/{moveNpmrcOutOfGitignoreManagedSection.js → moveNpmrcOutOfIgnoreManagedSection.js} +17 -16
  14. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js.map +7 -0
  15. package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +9 -0
  16. package/lib/cli/lint/internalLints/refreshConfigFiles.js +31 -12
  17. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
  18. package/lib/utils/npmrc.d.ts +1 -0
  19. package/lib/utils/npmrc.js +3 -0
  20. package/lib/utils/npmrc.js.map +2 -2
  21. package/package.json +10 -10
  22. package/template/express-rest-api/.buildkite/pipeline.yml +7 -5
  23. package/template/express-rest-api/Dockerfile +1 -1
  24. package/template/express-rest-api/Dockerfile.dev-deps +1 -0
  25. package/template/express-rest-api/README.md +5 -5
  26. package/template/express-rest-api/package.json +2 -1
  27. package/template/greeter/.buildkite/pipeline.yml +7 -5
  28. package/template/greeter/Dockerfile +1 -0
  29. package/template/greeter/README.md +5 -5
  30. package/template/greeter/package.json +2 -1
  31. package/template/koa-rest-api/.buildkite/pipeline.yml +7 -5
  32. package/template/koa-rest-api/Dockerfile +1 -1
  33. package/template/koa-rest-api/Dockerfile.dev-deps +1 -0
  34. package/template/koa-rest-api/README.md +5 -5
  35. package/template/koa-rest-api/package.json +2 -1
  36. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +9 -7
  37. package/template/lambda-sqs-worker/Dockerfile +1 -0
  38. package/template/lambda-sqs-worker/README.md +6 -6
  39. package/template/lambda-sqs-worker/package.json +2 -1
  40. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +7 -5
  41. package/template/lambda-sqs-worker-cdk/Dockerfile +1 -0
  42. package/template/lambda-sqs-worker-cdk/package.json +3 -2
  43. package/template/oss-npm-package/.github/workflows/release.yml +1 -1
  44. package/template/oss-npm-package/.github/workflows/validate.yml +2 -2
  45. package/template/oss-npm-package/README.md +5 -5
  46. package/template/oss-npm-package/_package.json +1 -1
  47. package/template/private-npm-package/README.md +5 -5
  48. package/template/private-npm-package/_package.json +3 -2
  49. package/lib/cli/configure/processing/ignoreFile.d.ts +0 -8
  50. package/lib/cli/configure/processing/ignoreFile.js.map +0 -7
  51. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.d.ts +0 -2
  52. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +0 -7
@@ -22,8 +22,8 @@ __export(eslint_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(eslint_exports);
24
24
  var import_template = require("../../../utils/template");
25
+ var import_configFile = require("../processing/configFile");
25
26
  var import_deleteFiles = require("../processing/deleteFiles");
26
- var import_ignoreFile = require("../processing/ignoreFile");
27
27
  var import_package = require("../processing/package");
28
28
  var import_prettier = require("../processing/prettier");
29
29
  const eslintModule = async () => {
@@ -50,7 +50,7 @@ const eslintModule = async () => {
50
50
  }
51
51
  return configFile;
52
52
  },
53
- ".eslintignore": (0, import_ignoreFile.mergeWithIgnoreFile)(ignoreFile),
53
+ ".eslintignore": (0, import_configFile.mergeWithConfigFile)(ignoreFile),
54
54
  "package.json": (0, import_package.withPackage)(({ eslintConfig, ...data }) => data)
55
55
  };
56
56
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/configure/modules/eslint.ts"],
4
- "sourcesContent": ["import { readBaseTemplateFile } from '../../../utils/template';\nimport { deleteFiles } from '../processing/deleteFiles';\nimport { mergeWithIgnoreFile } from '../processing/ignoreFile';\nimport { withPackage } from '../processing/package';\nimport { formatPrettier } from '../processing/prettier';\nimport type { Module } from '../types';\n\nexport const eslintModule = async (): Promise<Module> => {\n const [configFile, ignoreFile] = await Promise.all([\n readBaseTemplateFile('_.eslintrc.js'),\n readBaseTemplateFile('_.eslintignore'),\n ]);\n\n return {\n ...deleteFiles(\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintrc',\n ),\n\n // allow customised ESLint configs that extend skuba\n '.eslintrc.js': (inputFile) => {\n if (inputFile?.includes('skuba')) {\n const processedFile = inputFile.replace(\n /require.resolve\\(['\"](@seek\\/)?skuba\\/config\\/eslint['\"]\\)/,\n \"'skuba'\",\n );\n\n return formatPrettier(processedFile, { parser: 'typescript' });\n }\n\n return configFile;\n },\n\n '.eslintignore': mergeWithIgnoreFile(ignoreFile),\n\n 'package.json': withPackage(({ eslintConfig, ...data }) => data),\n };\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqC;AACrC,yBAA4B;AAC5B,wBAAoC;AACpC,qBAA4B;AAC5B,sBAA+B;AAGxB,MAAM,eAAe,YAA6B;AACvD,QAAM,CAAC,YAAY,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,QACjD,sCAAqB,eAAe;AAAA,QACpC,sCAAqB,gBAAgB;AAAA,EACvC,CAAC;AAED,SAAO;AAAA,IACL,OAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA;AAAA,IAGA,gBAAgB,CAAC,cAAc;AAC7B,UAAI,WAAW,SAAS,OAAO,GAAG;AAChC,cAAM,gBAAgB,UAAU;AAAA,UAC9B;AAAA,UACA;AAAA,QACF;AAEA,mBAAO,gCAAe,eAAe,EAAE,QAAQ,aAAa,CAAC;AAAA,MAC/D;AAEA,aAAO;AAAA,IACT;AAAA,IAEA,qBAAiB,uCAAoB,UAAU;AAAA,IAE/C,oBAAgB,4BAAY,CAAC,EAAE,cAAc,GAAG,KAAK,MAAM,IAAI;AAAA,EACjE;AACF;",
4
+ "sourcesContent": ["import { readBaseTemplateFile } from '../../../utils/template';\nimport { mergeWithConfigFile } from '../processing/configFile';\nimport { deleteFiles } from '../processing/deleteFiles';\nimport { withPackage } from '../processing/package';\nimport { formatPrettier } from '../processing/prettier';\nimport type { Module } from '../types';\n\nexport const eslintModule = async (): Promise<Module> => {\n const [configFile, ignoreFile] = await Promise.all([\n readBaseTemplateFile('_.eslintrc.js'),\n readBaseTemplateFile('_.eslintignore'),\n ]);\n\n return {\n ...deleteFiles(\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintrc',\n ),\n\n // allow customised ESLint configs that extend skuba\n '.eslintrc.js': (inputFile) => {\n if (inputFile?.includes('skuba')) {\n const processedFile = inputFile.replace(\n /require.resolve\\(['\"](@seek\\/)?skuba\\/config\\/eslint['\"]\\)/,\n \"'skuba'\",\n );\n\n return formatPrettier(processedFile, { parser: 'typescript' });\n }\n\n return configFile;\n },\n\n '.eslintignore': mergeWithConfigFile(ignoreFile),\n\n 'package.json': withPackage(({ eslintConfig, ...data }) => data),\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqC;AACrC,wBAAoC;AACpC,yBAA4B;AAC5B,qBAA4B;AAC5B,sBAA+B;AAGxB,MAAM,eAAe,YAA6B;AACvD,QAAM,CAAC,YAAY,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,QACjD,sCAAqB,eAAe;AAAA,QACpC,sCAAqB,gBAAgB;AAAA,EACvC,CAAC;AAED,SAAO;AAAA,IACL,OAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA;AAAA,IAGA,gBAAgB,CAAC,cAAc;AAC7B,UAAI,WAAW,SAAS,OAAO,GAAG;AAChC,cAAM,gBAAgB,UAAU;AAAA,UAC9B;AAAA,UACA;AAAA,QACF;AAEA,mBAAO,gCAAe,eAAe,EAAE,QAAQ,aAAa,CAAC;AAAA,MAC/D;AAEA,aAAO;AAAA,IACT;AAAA,IAEA,qBAAiB,uCAAoB,UAAU;AAAA,IAE/C,oBAAgB,4BAAY,CAAC,EAAE,cAAc,GAAG,KAAK,MAAM,IAAI;AAAA,EACjE;AACF;",
6
6
  "names": []
7
7
  }
@@ -22,15 +22,15 @@ __export(ignore_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(ignore_exports);
24
24
  var import_template = require("../../../utils/template");
25
- var import_ignoreFile = require("../processing/ignoreFile");
25
+ var import_configFile = require("../processing/configFile");
26
26
  const ignoreModule = async () => {
27
27
  const [dockerFile, gitFile] = await Promise.all([
28
28
  (0, import_template.readBaseTemplateFile)("_.dockerignore"),
29
29
  (0, import_template.readBaseTemplateFile)("_.gitignore")
30
30
  ]);
31
31
  return {
32
- ".dockerignore": (0, import_ignoreFile.mergeWithIgnoreFile)(dockerFile),
33
- ".gitignore": (0, import_ignoreFile.mergeWithIgnoreFile)(gitFile)
32
+ ".dockerignore": (0, import_configFile.mergeWithConfigFile)(dockerFile),
33
+ ".gitignore": (0, import_configFile.mergeWithConfigFile)(gitFile)
34
34
  };
35
35
  };
36
36
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/configure/modules/ignore.ts"],
4
- "sourcesContent": ["import { readBaseTemplateFile } from '../../../utils/template';\nimport { mergeWithIgnoreFile } from '../processing/ignoreFile';\nimport type { Module } from '../types';\n\nexport const ignoreModule = async (): Promise<Module> => {\n const [dockerFile, gitFile] = await Promise.all([\n readBaseTemplateFile('_.dockerignore'),\n readBaseTemplateFile('_.gitignore'),\n ]);\n\n return {\n '.dockerignore': mergeWithIgnoreFile(dockerFile),\n\n '.gitignore': mergeWithIgnoreFile(gitFile),\n };\n};\n"],
4
+ "sourcesContent": ["import { readBaseTemplateFile } from '../../../utils/template';\nimport { mergeWithConfigFile } from '../processing/configFile';\nimport type { Module } from '../types';\n\nexport const ignoreModule = async (): Promise<Module> => {\n const [dockerFile, gitFile] = await Promise.all([\n readBaseTemplateFile('_.dockerignore'),\n readBaseTemplateFile('_.gitignore'),\n ]);\n\n return {\n '.dockerignore': mergeWithConfigFile(dockerFile),\n\n '.gitignore': mergeWithConfigFile(gitFile),\n };\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqC;AACrC,wBAAoC;AAG7B,MAAM,eAAe,YAA6B;AACvD,QAAM,CAAC,YAAY,OAAO,IAAI,MAAM,QAAQ,IAAI;AAAA,QAC9C,sCAAqB,gBAAgB;AAAA,QACrC,sCAAqB,aAAa;AAAA,EACpC,CAAC;AAED,SAAO;AAAA,IACL,qBAAiB,uCAAoB,UAAU;AAAA,IAE/C,kBAAc,uCAAoB,OAAO;AAAA,EAC3C;AACF;",
6
6
  "names": []
7
7
  }
@@ -22,8 +22,8 @@ __export(prettier_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(prettier_exports);
24
24
  var import_template = require("../../../utils/template");
25
+ var import_configFile = require("../processing/configFile");
25
26
  var import_deleteFiles = require("../processing/deleteFiles");
26
- var import_ignoreFile = require("../processing/ignoreFile");
27
27
  var import_package = require("../processing/package");
28
28
  const prettierModule = async () => {
29
29
  const [configFile, ignoreFile] = await Promise.all([
@@ -39,7 +39,7 @@ const prettierModule = async () => {
39
39
  ".prettierrc.yml",
40
40
  "prettier.config.js"
41
41
  ),
42
- ".prettierignore": (0, import_ignoreFile.mergeWithIgnoreFile)(ignoreFile),
42
+ ".prettierignore": (0, import_configFile.mergeWithConfigFile)(ignoreFile),
43
43
  // enforce skuba opinions as there's no value in customising Prettier configs
44
44
  ".prettierrc.js": () => configFile,
45
45
  "package.json": (0, import_package.withPackage)(({ prettier, ...data }) => data)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/configure/modules/prettier.ts"],
4
- "sourcesContent": ["import { readBaseTemplateFile } from '../../../utils/template';\nimport { deleteFiles } from '../processing/deleteFiles';\nimport { mergeWithIgnoreFile } from '../processing/ignoreFile';\nimport { withPackage } from '../processing/package';\nimport type { Module } from '../types';\n\nexport const prettierModule = async (): Promise<Module> => {\n const [configFile, ignoreFile] = await Promise.all([\n readBaseTemplateFile('_.prettierrc.js'),\n readBaseTemplateFile('_.prettierignore'),\n ]);\n\n return {\n ...deleteFiles(\n '.prettierrc',\n '.prettierrc.json',\n '.prettierrc.toml',\n '.prettierrc.yaml',\n '.prettierrc.yml',\n 'prettier.config.js',\n ),\n\n '.prettierignore': mergeWithIgnoreFile(ignoreFile),\n\n // enforce skuba opinions as there's no value in customising Prettier configs\n '.prettierrc.js': () => configFile,\n\n 'package.json': withPackage(({ prettier, ...data }) => data),\n };\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqC;AACrC,yBAA4B;AAC5B,wBAAoC;AACpC,qBAA4B;AAGrB,MAAM,iBAAiB,YAA6B;AACzD,QAAM,CAAC,YAAY,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,QACjD,sCAAqB,iBAAiB;AAAA,QACtC,sCAAqB,kBAAkB;AAAA,EACzC,CAAC;AAED,SAAO;AAAA,IACL,OAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IAEA,uBAAmB,uCAAoB,UAAU;AAAA;AAAA,IAGjD,kBAAkB,MAAM;AAAA,IAExB,oBAAgB,4BAAY,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,EAC7D;AACF;",
4
+ "sourcesContent": ["import { readBaseTemplateFile } from '../../../utils/template';\nimport { mergeWithConfigFile } from '../processing/configFile';\nimport { deleteFiles } from '../processing/deleteFiles';\nimport { withPackage } from '../processing/package';\nimport type { Module } from '../types';\n\nexport const prettierModule = async (): Promise<Module> => {\n const [configFile, ignoreFile] = await Promise.all([\n readBaseTemplateFile('_.prettierrc.js'),\n readBaseTemplateFile('_.prettierignore'),\n ]);\n\n return {\n ...deleteFiles(\n '.prettierrc',\n '.prettierrc.json',\n '.prettierrc.toml',\n '.prettierrc.yaml',\n '.prettierrc.yml',\n 'prettier.config.js',\n ),\n\n '.prettierignore': mergeWithConfigFile(ignoreFile),\n\n // enforce skuba opinions as there's no value in customising Prettier configs\n '.prettierrc.js': () => configFile,\n\n 'package.json': withPackage(({ prettier, ...data }) => data),\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqC;AACrC,wBAAoC;AACpC,yBAA4B;AAC5B,qBAA4B;AAGrB,MAAM,iBAAiB,YAA6B;AACzD,QAAM,CAAC,YAAY,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,QACjD,sCAAqB,iBAAiB;AAAA,QACtC,sCAAqB,kBAAkB;AAAA,EACzC,CAAC;AAED,SAAO;AAAA,IACL,OAAG;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IAEA,uBAAmB,uCAAoB,UAAU;AAAA;AAAA,IAGjD,kBAAkB,MAAM;AAAA,IAExB,oBAAgB,4BAAY,CAAC,EAAE,UAAU,GAAG,KAAK,MAAM,IAAI;AAAA,EAC7D;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generate simple variants of an ignore pattern for exact matching purposes.
3
+ *
4
+ * Note that these patterns are not actually equivalent (e.g. `lib` matches more
5
+ * than `lib/`) but they generally represent the same _intent_.
6
+ */
7
+ export declare const generateIgnoreFileSimpleVariants: (patterns: string[]) => Set<string>;
8
+ export declare const generateNpmrcSimpleVariants: (patterns: string[]) => Set<string>;
9
+ export declare const mergeWithConfigFile: (rawTemplateFile: string, fileType?: 'ignore' | 'npmrc') => (rawInputFile?: string) => string;
@@ -16,17 +16,18 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var ignoreFile_exports = {};
20
- __export(ignoreFile_exports, {
21
- generateSimpleVariants: () => generateSimpleVariants,
22
- mergeWithIgnoreFile: () => mergeWithIgnoreFile
19
+ var configFile_exports = {};
20
+ __export(configFile_exports, {
21
+ generateIgnoreFileSimpleVariants: () => generateIgnoreFileSimpleVariants,
22
+ generateNpmrcSimpleVariants: () => generateNpmrcSimpleVariants,
23
+ mergeWithConfigFile: () => mergeWithConfigFile
23
24
  });
24
- module.exports = __toCommonJS(ignoreFile_exports);
25
+ module.exports = __toCommonJS(configFile_exports);
25
26
  const OUTDATED_PATTERNS = ["node_modules_bak/", "tmp-*/"];
26
27
  const ASTERISKS = /\*/g;
27
28
  const LEADING_SLASH = /^\//;
28
29
  const TRAILING_SLASH = /\/$/;
29
- const generateSimpleVariants = (patterns) => {
30
+ const generateIgnoreFileSimpleVariants = (patterns) => {
30
31
  const set = /* @__PURE__ */ new Set();
31
32
  for (const pattern of patterns) {
32
33
  const deAsterisked = pattern.replace(ASTERISKS, "");
@@ -45,9 +46,25 @@ const generateSimpleVariants = (patterns) => {
45
46
  set.delete("");
46
47
  return set;
47
48
  };
48
- const mergeWithIgnoreFile = (rawTemplateFile) => {
49
+ const generateNpmrcSimpleVariants = (patterns) => {
50
+ const set = /* @__PURE__ */ new Set();
51
+ for (const pattern of patterns) {
52
+ set.add(pattern);
53
+ const match = pattern.match(/^(?<key>[^"=]+)="?(?<value>[^"=]+)"?$/);
54
+ if (!match?.groups) {
55
+ continue;
56
+ }
57
+ const { key, value } = match.groups;
58
+ set.add(`${key}=${value}`);
59
+ set.add(`${key}="${value}"`);
60
+ }
61
+ set.delete("");
62
+ return set;
63
+ };
64
+ const mergeWithConfigFile = (rawTemplateFile, fileType = "ignore") => {
49
65
  const templateFile = rawTemplateFile.trim();
50
- const templatePatterns = generateSimpleVariants([
66
+ const generator = fileType === "ignore" ? generateIgnoreFileSimpleVariants : generateNpmrcSimpleVariants;
67
+ const templatePatterns = generator([
51
68
  ...OUTDATED_PATTERNS,
52
69
  ...templateFile.split("\n").map((line) => line.trim())
53
70
  ]);
@@ -68,7 +85,8 @@ const mergeWithIgnoreFile = (rawTemplateFile) => {
68
85
  };
69
86
  // Annotate the CommonJS export names for ESM import in node:
70
87
  0 && (module.exports = {
71
- generateSimpleVariants,
72
- mergeWithIgnoreFile
88
+ generateIgnoreFileSimpleVariants,
89
+ generateNpmrcSimpleVariants,
90
+ mergeWithConfigFile
73
91
  });
74
- //# sourceMappingURL=ignoreFile.js.map
92
+ //# sourceMappingURL=configFile.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/cli/configure/processing/configFile.ts"],
4
+ "sourcesContent": ["/**\n * Patterns that are superseded by skuba's bundled ignore file patterns and are\n * non-trivial to derive using e.g. `generateSimpleVariants`.\n */\nconst OUTDATED_PATTERNS = ['node_modules_bak/', 'tmp-*/'];\n\nconst ASTERISKS = /\\*/g;\nconst LEADING_SLASH = /^\\//;\nconst TRAILING_SLASH = /\\/$/;\n\n/**\n * Generate simple variants of an ignore pattern for exact matching purposes.\n *\n * Note that these patterns are not actually equivalent (e.g. `lib` matches more\n * than `lib/`) but they generally represent the same _intent_.\n */\nexport const generateIgnoreFileSimpleVariants = (patterns: string[]) => {\n const set = new Set<string>();\n\n for (const pattern of patterns) {\n const deAsterisked = pattern.replace(ASTERISKS, '');\n const stripped = deAsterisked\n .replace(LEADING_SLASH, '')\n .replace(TRAILING_SLASH, '');\n\n set.add(pattern);\n set.add(deAsterisked);\n set.add(deAsterisked.replace(LEADING_SLASH, ''));\n set.add(deAsterisked.replace(TRAILING_SLASH, ''));\n set.add(stripped);\n\n if (stripped !== '') {\n set.add(`/${stripped}`);\n set.add(`${stripped}/`);\n set.add(`/${stripped}/`);\n }\n }\n\n set.delete('');\n\n return set;\n};\n\nexport const generateNpmrcSimpleVariants = (patterns: string[]) => {\n const set = new Set<string>();\n\n for (const pattern of patterns) {\n set.add(pattern);\n\n const match = pattern.match(/^(?<key>[^\"=]+)=\"?(?<value>[^\"=]+)\"?$/);\n if (!match?.groups) {\n continue;\n }\n\n const { key, value } = match.groups;\n\n set.add(`${key}=${value}`);\n set.add(`${key}=\"${value}\"`);\n }\n\n set.delete('');\n\n return set;\n};\n\nexport const mergeWithConfigFile = (\n rawTemplateFile: string,\n fileType: 'ignore' | 'npmrc' = 'ignore',\n) => {\n const templateFile = rawTemplateFile.trim();\n\n const generator =\n fileType === 'ignore'\n ? generateIgnoreFileSimpleVariants\n : generateNpmrcSimpleVariants;\n\n const templatePatterns = generator([\n ...OUTDATED_PATTERNS,\n ...templateFile.split('\\n').map((line) => line.trim()),\n ]);\n\n return (rawInputFile?: string) => {\n if (rawInputFile === undefined) {\n return `${templateFile}\\n`;\n }\n\n const replacedFile = rawInputFile\n .replace(/\\r?\\n/g, '\\n')\n .replace(/# managed by skuba[\\s\\S]*# end managed by skuba/, templateFile);\n\n if (replacedFile.includes(templateFile)) {\n return replacedFile;\n }\n\n // Crunch the existing lines of a non-skuba config.\n const migratedFile = replacedFile\n .split('\\n')\n .filter((line) => !templatePatterns.has(line))\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n\n const outputFile = [templateFile, migratedFile].join('\\n\\n').trim();\n\n return `${outputFile}\\n`;\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,MAAM,oBAAoB,CAAC,qBAAqB,QAAQ;AAExD,MAAM,YAAY;AAClB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAQhB,MAAM,mCAAmC,CAAC,aAAuB;AACtE,QAAM,MAAM,oBAAI,IAAY;AAE5B,aAAW,WAAW,UAAU;AAC9B,UAAM,eAAe,QAAQ,QAAQ,WAAW,EAAE;AAClD,UAAM,WAAW,aACd,QAAQ,eAAe,EAAE,EACzB,QAAQ,gBAAgB,EAAE;AAE7B,QAAI,IAAI,OAAO;AACf,QAAI,IAAI,YAAY;AACpB,QAAI,IAAI,aAAa,QAAQ,eAAe,EAAE,CAAC;AAC/C,QAAI,IAAI,aAAa,QAAQ,gBAAgB,EAAE,CAAC;AAChD,QAAI,IAAI,QAAQ;AAEhB,QAAI,aAAa,IAAI;AACnB,UAAI,IAAI,IAAI,QAAQ,EAAE;AACtB,UAAI,IAAI,GAAG,QAAQ,GAAG;AACtB,UAAI,IAAI,IAAI,QAAQ,GAAG;AAAA,IACzB;AAAA,EACF;AAEA,MAAI,OAAO,EAAE;AAEb,SAAO;AACT;AAEO,MAAM,8BAA8B,CAAC,aAAuB;AACjE,QAAM,MAAM,oBAAI,IAAY;AAE5B,aAAW,WAAW,UAAU;AAC9B,QAAI,IAAI,OAAO;AAEf,UAAM,QAAQ,QAAQ,MAAM,uCAAuC;AACnE,QAAI,CAAC,OAAO,QAAQ;AAClB;AAAA,IACF;AAEA,UAAM,EAAE,KAAK,MAAM,IAAI,MAAM;AAE7B,QAAI,IAAI,GAAG,GAAG,IAAI,KAAK,EAAE;AACzB,QAAI,IAAI,GAAG,GAAG,KAAK,KAAK,GAAG;AAAA,EAC7B;AAEA,MAAI,OAAO,EAAE;AAEb,SAAO;AACT;AAEO,MAAM,sBAAsB,CACjC,iBACA,WAA+B,aAC5B;AACH,QAAM,eAAe,gBAAgB,KAAK;AAE1C,QAAM,YACJ,aAAa,WACT,mCACA;AAEN,QAAM,mBAAmB,UAAU;AAAA,IACjC,GAAG;AAAA,IACH,GAAG,aAAa,MAAM,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AAAA,EACvD,CAAC;AAED,SAAO,CAAC,iBAA0B;AAChC,QAAI,iBAAiB,QAAW;AAC9B,aAAO,GAAG,YAAY;AAAA;AAAA,IACxB;AAEA,UAAM,eAAe,aAClB,QAAQ,UAAU,IAAI,EACtB,QAAQ,mDAAmD,YAAY;AAE1E,QAAI,aAAa,SAAS,YAAY,GAAG;AACvC,aAAO;AAAA,IACT;AAGA,UAAM,eAAe,aAClB,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,CAAC,iBAAiB,IAAI,IAAI,CAAC,EAC5C,KAAK,IAAI,EACT,QAAQ,WAAW,MAAM,EACzB,KAAK;AAER,UAAM,aAAa,CAAC,cAAc,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK;AAElE,WAAO,GAAG,UAAU;AAAA;AAAA,EACtB;AACF;",
6
+ "names": []
7
+ }
@@ -23,7 +23,7 @@ __export(__exports, {
23
23
  module.exports = __toCommonJS(__exports);
24
24
  var import_patchRenovateConfig = require("../../../patchRenovateConfig");
25
25
  var import_addEmptyExports = require("./addEmptyExports");
26
- var import_moveNpmrcOutOfGitignoreManagedSection = require("./moveNpmrcOutOfGitignoreManagedSection");
26
+ var import_moveNpmrcOutOfIgnoreManagedSection = require("./moveNpmrcOutOfIgnoreManagedSection");
27
27
  var import_patchDockerfile = require("./patchDockerfile");
28
28
  var import_patchServerListener = require("./patchServerListener");
29
29
  const patches = [
@@ -44,8 +44,12 @@ const patches = [
44
44
  description: "Add keepAliveTimeout to server listener"
45
45
  },
46
46
  {
47
- apply: import_moveNpmrcOutOfGitignoreManagedSection.tryMoveNpmrcOutOfGitignoreManagedSection,
47
+ apply: (0, import_moveNpmrcOutOfIgnoreManagedSection.tryMoveNpmrcOutOfIgnoreManagedSection)(".gitignore"),
48
48
  description: "Move .npmrc out of the .gitignore managed section"
49
+ },
50
+ {
51
+ apply: (0, import_moveNpmrcOutOfIgnoreManagedSection.tryMoveNpmrcOutOfIgnoreManagedSection)(".dockerignore"),
52
+ description: "Move .npmrc out of the .dockerignore managed section"
49
53
  }
50
54
  ];
51
55
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/index.ts"],
4
- "sourcesContent": ["import type { Patches } from '../..';\nimport { tryPatchRenovateConfig } from '../../../patchRenovateConfig';\n\nimport { tryAddEmptyExports } from './addEmptyExports';\nimport { tryMoveNpmrcOutOfGitignoreManagedSection } from './moveNpmrcOutOfGitignoreManagedSection';\nimport { tryPatchDockerfile } from './patchDockerfile';\nimport { tryPatchServerListener } from './patchServerListener';\n\nexport const patches: Patches = [\n {\n apply: tryAddEmptyExports,\n description:\n 'Add empty exports to Jest files for compliance with TypeScript isolated modules',\n },\n {\n apply: tryPatchRenovateConfig,\n description: 'Update Renovate config to support private SEEK packages',\n },\n {\n apply: tryPatchDockerfile,\n description: 'Upgrade Node.js Distroless Docker image to -debian12 variant',\n },\n {\n apply: tryPatchServerListener,\n description: 'Add keepAliveTimeout to server listener',\n },\n {\n apply: tryMoveNpmrcOutOfGitignoreManagedSection,\n description: 'Move .npmrc out of the .gitignore managed section',\n },\n];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAAuC;AAEvC,6BAAmC;AACnC,mDAAyD;AACzD,6BAAmC;AACnC,iCAAuC;AAEhC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
4
+ "sourcesContent": ["import type { Patches } from '../..';\nimport { tryPatchRenovateConfig } from '../../../patchRenovateConfig';\n\nimport { tryAddEmptyExports } from './addEmptyExports';\nimport { tryMoveNpmrcOutOfIgnoreManagedSection } from './moveNpmrcOutOfIgnoreManagedSection';\nimport { tryPatchDockerfile } from './patchDockerfile';\nimport { tryPatchServerListener } from './patchServerListener';\n\nexport const patches: Patches = [\n {\n apply: tryAddEmptyExports,\n description:\n 'Add empty exports to Jest files for compliance with TypeScript isolated modules',\n },\n {\n apply: tryPatchRenovateConfig,\n description: 'Update Renovate config to support private SEEK packages',\n },\n {\n apply: tryPatchDockerfile,\n description: 'Upgrade Node.js Distroless Docker image to -debian12 variant',\n },\n {\n apply: tryPatchServerListener,\n description: 'Add keepAliveTimeout to server listener',\n },\n {\n apply: tryMoveNpmrcOutOfIgnoreManagedSection('.gitignore'),\n description: 'Move .npmrc out of the .gitignore managed section',\n },\n {\n apply: tryMoveNpmrcOutOfIgnoreManagedSection('.dockerignore'),\n description: 'Move .npmrc out of the .dockerignore managed section',\n },\n];\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAAuC;AAEvC,6BAAmC;AACnC,gDAAsD;AACtD,6BAAmC;AACnC,iCAAuC;AAEhC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,WAAO,iFAAsC,YAAY;AAAA,IACzD,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,WAAO,iFAAsC,eAAe;AAAA,IAC5D,aAAa;AAAA,EACf;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,2 @@
1
+ import type { PatchReturnType } from '../..';
2
+ export declare const tryMoveNpmrcOutOfIgnoreManagedSection: (type: '.gitignore' | '.dockerignore') => (mode: 'format' | 'lint', dir?: string) => Promise<PatchReturnType>;
@@ -26,15 +26,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var moveNpmrcOutOfGitignoreManagedSection_exports = {};
30
- __export(moveNpmrcOutOfGitignoreManagedSection_exports, {
31
- tryMoveNpmrcOutOfGitignoreManagedSection: () => tryMoveNpmrcOutOfGitignoreManagedSection
29
+ var moveNpmrcOutOfIgnoreManagedSection_exports = {};
30
+ __export(moveNpmrcOutOfIgnoreManagedSection_exports, {
31
+ tryMoveNpmrcOutOfIgnoreManagedSection: () => tryMoveNpmrcOutOfIgnoreManagedSection
32
32
  });
33
- module.exports = __toCommonJS(moveNpmrcOutOfGitignoreManagedSection_exports);
33
+ module.exports = __toCommonJS(moveNpmrcOutOfIgnoreManagedSection_exports);
34
34
  var import_path = __toESM(require("path"));
35
35
  var import_util = require("util");
36
36
  var import_fs_extra = __toESM(require("fs-extra"));
37
37
  var import_logging = require("../../../../../utils/logging");
38
+ var import_npmrc = require("../../../../../utils/npmrc");
38
39
  var import_project = require("../../../analysis/project");
39
40
  const NPMRC_IGNORE_SECTION = `
40
41
 
@@ -44,15 +45,15 @@ const NPMRC_IGNORE_SECTION = `
44
45
  # Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.
45
46
  .npmrc
46
47
  `;
47
- const moveNpmrcOutOfGitignoreManagedSection = async (mode, dir) => {
48
+ const moveNpmrcOutOfIgnoreManagedSection = async (mode, dir, fileName) => {
48
49
  const readFile = (0, import_project.createDestinationFileReader)(dir);
49
- const gitignore = await readFile(".gitignore");
50
- if (!gitignore) {
51
- return { result: "skip", reason: "no .gitignore file found" };
50
+ const ignoreFile = await readFile(fileName);
51
+ if (!ignoreFile) {
52
+ return { result: "skip", reason: `no ${fileName} file found` };
52
53
  }
53
54
  let isIgnored;
54
55
  let currentlyInManagedSection = false;
55
- for (const line of gitignore.split("\n")) {
56
+ for (const line of ignoreFile.split("\n")) {
56
57
  if (line.trim() === "# managed by skuba") {
57
58
  currentlyInManagedSection = true;
58
59
  } else if (line.trim() === "# end managed by skuba") {
@@ -74,21 +75,21 @@ const moveNpmrcOutOfGitignoreManagedSection = async (mode, dir) => {
74
75
  if (mode === "lint") {
75
76
  return { result: "apply" };
76
77
  }
77
- const newGitignore = gitignore.split("\n").filter((line) => line.trim().replace(/^[!/]+/g, "") !== ".npmrc").join("\n").trim() + NPMRC_IGNORE_SECTION;
78
- await import_fs_extra.default.promises.writeFile(import_path.default.join(dir, ".gitignore"), newGitignore);
78
+ const newIgnoreFile = ignoreFile.split("\n").filter((line) => !import_npmrc.NPMRC_LINES.includes(line.trim())).join("\n").trim() + NPMRC_IGNORE_SECTION;
79
+ await import_fs_extra.default.promises.writeFile(import_path.default.join(dir, fileName), newIgnoreFile);
79
80
  return { result: "apply" };
80
81
  };
81
- const tryMoveNpmrcOutOfGitignoreManagedSection = async (mode, dir = process.cwd()) => {
82
+ const tryMoveNpmrcOutOfIgnoreManagedSection = (type) => async (mode, dir = process.cwd()) => {
82
83
  try {
83
- return await moveNpmrcOutOfGitignoreManagedSection(mode, dir);
84
+ return await moveNpmrcOutOfIgnoreManagedSection(mode, dir, type);
84
85
  } catch (err) {
85
- import_logging.log.warn("Failed to move .npmrc out of .gitignore managed section.");
86
+ import_logging.log.warn(`Failed to move .npmrc out of ${type} managed sections.`);
86
87
  import_logging.log.subtle((0, import_util.inspect)(err));
87
88
  return { result: "skip", reason: "due to an error" };
88
89
  }
89
90
  };
90
91
  // Annotate the CommonJS export names for ESM import in node:
91
92
  0 && (module.exports = {
92
- tryMoveNpmrcOutOfGitignoreManagedSection
93
+ tryMoveNpmrcOutOfIgnoreManagedSection
93
94
  });
94
- //# sourceMappingURL=moveNpmrcOutOfGitignoreManagedSection.js.map
95
+ //# sourceMappingURL=moveNpmrcOutOfIgnoreManagedSection.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.ts"],
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { NPMRC_LINES } from '../../../../../utils/npmrc';\nimport { createDestinationFileReader } from '../../../analysis/project';\n\nconst NPMRC_IGNORE_SECTION = `\n\n# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst moveNpmrcOutOfIgnoreManagedSection = async (\n mode: 'format' | 'lint',\n dir: string,\n fileName: '.gitignore' | '.dockerignore',\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const ignoreFile = await readFile(fileName);\n\n if (!ignoreFile) {\n return { result: 'skip', reason: `no ${fileName} file found` };\n }\n\n let isIgnored: { inManaged: boolean } | undefined;\n let currentlyInManagedSection = false;\n\n for (const line of ignoreFile.split('\\n')) {\n if (line.trim() === '# managed by skuba') {\n currentlyInManagedSection = true;\n } else if (line.trim() === '# end managed by skuba') {\n currentlyInManagedSection = false;\n }\n\n if (line.trim() === '.npmrc' || line.trim() === '/.npmrc') {\n isIgnored = { inManaged: currentlyInManagedSection };\n }\n\n if (line.trim() === '!.npmrc' || line.trim() === '!/.npmrc') {\n isIgnored = undefined;\n }\n }\n\n if (isIgnored && !isIgnored.inManaged) {\n return { result: 'skip', reason: 'already ignored in unmanaged section' };\n }\n\n if (!isIgnored) {\n return { result: 'skip', reason: 'not ignored' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const newIgnoreFile =\n ignoreFile\n .split('\\n')\n .filter((line) => !NPMRC_LINES.includes(line.trim()))\n .join('\\n')\n .trim() + NPMRC_IGNORE_SECTION;\n\n await fs.promises.writeFile(path.join(dir, fileName), newIgnoreFile);\n\n return { result: 'apply' };\n};\n\nexport const tryMoveNpmrcOutOfIgnoreManagedSection = (\n type: '.gitignore' | '.dockerignore',\n) =>\n (async (mode: 'format' | 'lint', dir = process.cwd()) => {\n try {\n return await moveNpmrcOutOfIgnoreManagedSection(mode, dir, type);\n } catch (err) {\n log.warn(`Failed to move .npmrc out of ${type} managed sections.`);\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n }) satisfies PatchFunction;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,mBAA4B;AAC5B,qBAA4C;AAE5C,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B,MAAM,qCAAqC,OACzC,MACA,KACA,aAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,aAAa,MAAM,SAAS,QAAQ;AAE1C,MAAI,CAAC,YAAY;AACf,WAAO,EAAE,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,cAAc;AAAA,EAC/D;AAEA,MAAI;AACJ,MAAI,4BAA4B;AAEhC,aAAW,QAAQ,WAAW,MAAM,IAAI,GAAG;AACzC,QAAI,KAAK,KAAK,MAAM,sBAAsB;AACxC,kCAA4B;AAAA,IAC9B,WAAW,KAAK,KAAK,MAAM,0BAA0B;AACnD,kCAA4B;AAAA,IAC9B;AAEA,QAAI,KAAK,KAAK,MAAM,YAAY,KAAK,KAAK,MAAM,WAAW;AACzD,kBAAY,EAAE,WAAW,0BAA0B;AAAA,IACrD;AAEA,QAAI,KAAK,KAAK,MAAM,aAAa,KAAK,KAAK,MAAM,YAAY;AAC3D,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI,aAAa,CAAC,UAAU,WAAW;AACrC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,uCAAuC;AAAA,EAC1E;AAEA,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,QAAQ,QAAQ,QAAQ,cAAc;AAAA,EACjD;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,gBACJ,WACG,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,CAAC,yBAAY,SAAS,KAAK,KAAK,CAAC,CAAC,EACnD,KAAK,IAAI,EACT,KAAK,IAAI;AAEd,QAAM,gBAAAA,QAAG,SAAS,UAAU,YAAAC,QAAK,KAAK,KAAK,QAAQ,GAAG,aAAa;AAEnE,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,wCAAwC,CACnD,SAEC,OAAO,MAAyB,MAAM,QAAQ,IAAI,MAAM;AACvD,MAAI;AACF,WAAO,MAAM,mCAAmC,MAAM,KAAK,IAAI;AAAA,EACjE,SAAS,KAAK;AACZ,uBAAI,KAAK,gCAAgC,IAAI,oBAAoB;AACjE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
+ "names": ["fs", "path"]
7
+ }
@@ -1,5 +1,13 @@
1
1
  import type { Logger } from '../../../utils/logging';
2
+ import { type PackageManagerConfig } from '../../../utils/packageManager';
2
3
  import type { InternalLintResult } from '../internal';
4
+ type RefreshableConfigFile = {
5
+ name: string;
6
+ type: 'ignore' | 'npmrc';
7
+ additionalMapping?: (s: string, packageManager: PackageManagerConfig) => string;
8
+ if?: (packageManager: PackageManagerConfig) => boolean;
9
+ };
10
+ export declare const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[];
3
11
  export declare const refreshConfigFiles: (mode: 'format' | 'lint', logger: Logger) => Promise<{
4
12
  ok: boolean;
5
13
  fixable: boolean;
@@ -9,3 +17,4 @@ export declare const refreshConfigFiles: (mode: 'format' | 'lint', logger: Logge
9
17
  }[];
10
18
  }>;
11
19
  export declare const tryRefreshConfigFiles: (mode: 'format' | 'lint', logger: Logger) => Promise<InternalLintResult>;
20
+ export {};
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var refreshConfigFiles_exports = {};
30
30
  __export(refreshConfigFiles_exports, {
31
+ REFRESHABLE_CONFIG_FILES: () => REFRESHABLE_CONFIG_FILES,
31
32
  refreshConfigFiles: () => refreshConfigFiles,
32
33
  tryRefreshConfigFiles: () => tryRefreshConfigFiles
33
34
  });
@@ -41,23 +42,45 @@ var import_packageManager = require("../../../utils/packageManager");
41
42
  var import_template = require("../../../utils/template");
42
43
  var import_package = require("../../configure/analysis/package");
43
44
  var import_project = require("../../configure/analysis/project");
44
- var import_ignoreFile = require("../../configure/processing/ignoreFile");
45
+ var import_configFile = require("../../configure/processing/configFile");
45
46
  const ensureNoAuthToken = (fileContents) => fileContents.split("\n").filter((line) => !(0, import_npmrc.hasNpmrcSecret)(line)).join("\n");
47
+ const removeRedundantNpmrc = (contents) => {
48
+ const npmrcLines = contents.split("\n").filter((line) => import_npmrc.NPMRC_LINES.includes(line.trim()));
49
+ if (npmrcLines.length > 0 && npmrcLines.every((line) => line.includes("!"))) {
50
+ return contents.split("\n").filter((line) => !import_npmrc.NPMRC_LINES.includes(line.trim())).join("\n");
51
+ }
52
+ return contents;
53
+ };
46
54
  const REFRESHABLE_CONFIG_FILES = [
47
- { name: ".eslintignore" },
48
- { name: ".gitignore" },
49
- { name: ".prettierignore" },
55
+ { name: ".eslintignore", type: "ignore" },
56
+ {
57
+ name: ".gitignore",
58
+ type: "ignore",
59
+ additionalMapping: removeRedundantNpmrc
60
+ },
61
+ { name: ".prettierignore", type: "ignore" },
50
62
  {
51
63
  name: ".npmrc",
64
+ type: "npmrc",
52
65
  additionalMapping: ensureNoAuthToken,
53
66
  if: (packageManager) => packageManager.command === "pnpm"
67
+ },
68
+ {
69
+ name: ".dockerignore",
70
+ type: "ignore",
71
+ additionalMapping: removeRedundantNpmrc
54
72
  }
55
73
  ];
56
74
  const refreshConfigFiles = async (mode, logger) => {
57
75
  const manifest = await (0, import_package.getDestinationManifest)();
58
76
  const destinationRoot = import_path.default.dirname(manifest.path);
59
77
  const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
60
- const refreshConfigFile = async (filename, packageManager2, additionalMapping = (s) => s, condition = () => true) => {
78
+ const refreshConfigFile = async ({
79
+ name: filename,
80
+ type: fileType,
81
+ additionalMapping = (s) => s,
82
+ if: condition = () => true
83
+ }, packageManager2) => {
61
84
  if (!condition(packageManager2)) {
62
85
  return { needsChange: false };
63
86
  }
@@ -66,7 +89,7 @@ const refreshConfigFiles = async (mode, logger) => {
66
89
  (0, import_template.readBaseTemplateFile)(`_${filename}`)
67
90
  ]);
68
91
  const data = additionalMapping(
69
- inputFile ? (0, import_ignoreFile.mergeWithIgnoreFile)(templateFile)(inputFile) : templateFile,
92
+ inputFile ? (0, import_configFile.mergeWithConfigFile)(templateFile, fileType)(inputFile) : templateFile,
70
93
  packageManager2
71
94
  );
72
95
  const filepath = import_path.default.join(destinationRoot, filename);
@@ -99,12 +122,7 @@ const refreshConfigFiles = async (mode, logger) => {
99
122
  const packageManager = await (0, import_packageManager.detectPackageManager)(destinationRoot);
100
123
  const results = await Promise.all(
101
124
  REFRESHABLE_CONFIG_FILES.map(
102
- (conf) => refreshConfigFile(
103
- conf.name,
104
- packageManager,
105
- conf.additionalMapping,
106
- conf.if
107
- )
125
+ (conf) => refreshConfigFile(conf, packageManager)
108
126
  )
109
127
  );
110
128
  results.forEach((result) => {
@@ -141,6 +159,7 @@ const tryRefreshConfigFiles = async (mode, logger) => {
141
159
  };
142
160
  // Annotate the CommonJS export names for ESM import in node:
143
161
  0 && (module.exports = {
162
+ REFRESHABLE_CONFIG_FILES,
144
163
  refreshConfigFiles,
145
164
  tryRefreshConfigFiles
146
165
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/lint/internalLints/refreshConfigFiles.ts"],
4
- "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { writeFile } from 'fs-extra';\nimport stripAnsi from 'strip-ansi';\n\nimport type { Logger } from '../../../utils/logging';\nimport { hasNpmrcSecret } from '../../../utils/npmrc';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager';\nimport { readBaseTemplateFile } from '../../../utils/template';\nimport { getDestinationManifest } from '../../configure/analysis/package';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\nimport { mergeWithIgnoreFile } from '../../configure/processing/ignoreFile';\nimport type { InternalLintResult } from '../internal';\n\nconst ensureNoAuthToken = (fileContents: string) =>\n fileContents\n .split('\\n')\n .filter((line) => !hasNpmrcSecret(line))\n .join('\\n');\n\nconst REFRESHABLE_CONFIG_FILES = [\n { name: '.eslintignore' },\n { name: '.gitignore' },\n { name: '.prettierignore' },\n {\n name: '.npmrc',\n additionalMapping: ensureNoAuthToken,\n if: (packageManager: PackageManagerConfig) =>\n packageManager.command === 'pnpm',\n },\n];\n\nexport const refreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n) => {\n const manifest = await getDestinationManifest();\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const refreshConfigFile = async (\n filename: string,\n packageManager: PackageManagerConfig,\n additionalMapping: (\n s: string,\n packageManager: PackageManagerConfig,\n ) => string = (s) => s,\n condition: (packageManager: PackageManagerConfig) => boolean = () => true,\n ) => {\n if (!condition(packageManager)) {\n return { needsChange: false };\n }\n\n const [inputFile, templateFile] = await Promise.all([\n readDestinationFile(filename),\n readBaseTemplateFile(`_${filename}`),\n ]);\n\n const data = additionalMapping(\n inputFile ? mergeWithIgnoreFile(templateFile)(inputFile) : templateFile,\n packageManager,\n );\n\n const filepath = path.join(destinationRoot, filename);\n\n if (mode === 'format') {\n if (data === inputFile) {\n return { needsChange: false };\n }\n\n await writeFile(filepath, data);\n return {\n needsChange: false,\n msg: `Refreshed ${logger.bold(filename)}.`,\n filename,\n };\n }\n\n if (data !== inputFile) {\n return {\n needsChange: true,\n msg: `The ${logger.bold(\n filename,\n )} file is out of date. Run \\`${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )}\\` to update it.`,\n filename,\n };\n }\n\n return { needsChange: false };\n };\n\n const packageManager = await detectPackageManager(destinationRoot);\n\n const results = await Promise.all(\n REFRESHABLE_CONFIG_FILES.map((conf) =>\n refreshConfigFile(\n conf.name,\n packageManager,\n conf.additionalMapping,\n conf.if,\n ),\n ),\n );\n\n // Log after for reproducible test output ordering\n results.forEach((result) => {\n if (result.msg) {\n logger.warn(result.msg, logger.dim('refresh-config-files'));\n }\n });\n\n const anyNeedChanging = results.some(({ needsChange }) => needsChange);\n\n return {\n ok: !anyNeedChanging,\n fixable: anyNeedChanging,\n annotations: results.flatMap(({ needsChange, filename, msg }) =>\n needsChange && msg\n ? [\n {\n path: filename,\n message: stripAnsi(msg),\n },\n ]\n : [],\n ),\n };\n};\n\nexport const tryRefreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await refreshConfigFiles(mode, logger);\n } catch (err) {\n logger.warn('Failed to refresh config files.');\n logger.subtle(inspect(err));\n\n return {\n ok: false,\n fixable: false,\n annotations: [],\n };\n }\n};\n"],
5
- "mappings": "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",
4
+ "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { writeFile } from 'fs-extra';\nimport stripAnsi from 'strip-ansi';\n\nimport type { Logger } from '../../../utils/logging';\nimport { NPMRC_LINES, hasNpmrcSecret } from '../../../utils/npmrc';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager';\nimport { readBaseTemplateFile } from '../../../utils/template';\nimport { getDestinationManifest } from '../../configure/analysis/package';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\nimport { mergeWithConfigFile } from '../../configure/processing/configFile';\nimport type { InternalLintResult } from '../internal';\n\nconst ensureNoAuthToken = (fileContents: string) =>\n fileContents\n .split('\\n')\n .filter((line) => !hasNpmrcSecret(line))\n .join('\\n');\n\ntype RefreshableConfigFile = {\n name: string;\n type: 'ignore' | 'npmrc';\n additionalMapping?: (\n s: string,\n packageManager: PackageManagerConfig,\n ) => string;\n if?: (packageManager: PackageManagerConfig) => boolean;\n};\n\nconst removeRedundantNpmrc = (contents: string) => {\n const npmrcLines = contents\n .split('\\n')\n .filter((line) => NPMRC_LINES.includes(line.trim()));\n\n // If we're only left with !.npmrc line we can remove it\n // TODO: Consider if we should generalise this\n if (npmrcLines.length > 0 && npmrcLines.every((line) => line.includes('!'))) {\n return contents\n .split('\\n')\n .filter((line) => !NPMRC_LINES.includes(line.trim()))\n .join('\\n');\n }\n return contents;\n};\n\nexport const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[] = [\n { name: '.eslintignore', type: 'ignore' },\n {\n name: '.gitignore',\n type: 'ignore',\n additionalMapping: removeRedundantNpmrc,\n },\n { name: '.prettierignore', type: 'ignore' },\n {\n name: '.npmrc',\n type: 'npmrc',\n additionalMapping: ensureNoAuthToken,\n if: (packageManager: PackageManagerConfig) =>\n packageManager.command === 'pnpm',\n },\n {\n name: '.dockerignore',\n type: 'ignore',\n additionalMapping: removeRedundantNpmrc,\n },\n];\n\nexport const refreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n) => {\n const manifest = await getDestinationManifest();\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const refreshConfigFile = async (\n {\n name: filename,\n type: fileType,\n additionalMapping = (s) => s,\n if: condition = () => true,\n }: RefreshableConfigFile,\n packageManager: PackageManagerConfig,\n ) => {\n if (!condition(packageManager)) {\n return { needsChange: false };\n }\n\n const [inputFile, templateFile] = await Promise.all([\n readDestinationFile(filename),\n readBaseTemplateFile(`_${filename}`),\n ]);\n\n const data = additionalMapping(\n inputFile\n ? mergeWithConfigFile(templateFile, fileType)(inputFile)\n : templateFile,\n packageManager,\n );\n\n const filepath = path.join(destinationRoot, filename);\n\n if (mode === 'format') {\n if (data === inputFile) {\n return { needsChange: false };\n }\n\n await writeFile(filepath, data);\n return {\n needsChange: false,\n msg: `Refreshed ${logger.bold(filename)}.`,\n filename,\n };\n }\n\n if (data !== inputFile) {\n return {\n needsChange: true,\n msg: `The ${logger.bold(\n filename,\n )} file is out of date. Run \\`${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )}\\` to update it.`,\n filename,\n };\n }\n\n return { needsChange: false };\n };\n\n const packageManager = await detectPackageManager(destinationRoot);\n\n const results = await Promise.all(\n REFRESHABLE_CONFIG_FILES.map((conf) =>\n refreshConfigFile(conf, packageManager),\n ),\n );\n\n // Log after for reproducible test output ordering\n results.forEach((result) => {\n if (result.msg) {\n logger.warn(result.msg, logger.dim('refresh-config-files'));\n }\n });\n\n const anyNeedChanging = results.some(({ needsChange }) => needsChange);\n\n return {\n ok: !anyNeedChanging,\n fixable: anyNeedChanging,\n annotations: results.flatMap(({ needsChange, filename, msg }) =>\n needsChange && msg\n ? [\n {\n path: filename,\n message: stripAnsi(msg),\n },\n ]\n : [],\n ),\n };\n};\n\nexport const tryRefreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await refreshConfigFiles(mode, logger);\n } catch (err) {\n logger.warn('Failed to refresh config files.');\n logger.subtle(inspect(err));\n\n return {\n ok: false,\n fixable: false,\n annotations: [],\n };\n }\n};\n"],
5
+ "mappings": "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",
6
6
  "names": ["path", "packageManager", "stripAnsi"]
7
7
  }
@@ -1 +1,2 @@
1
+ export declare const NPMRC_LINES: string[];
1
2
  export declare const hasNpmrcSecret: (lineOrFullFileContents: string) => boolean;
@@ -18,12 +18,15 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var npmrc_exports = {};
20
20
  __export(npmrc_exports, {
21
+ NPMRC_LINES: () => NPMRC_LINES,
21
22
  hasNpmrcSecret: () => hasNpmrcSecret
22
23
  });
23
24
  module.exports = __toCommonJS(npmrc_exports);
25
+ const NPMRC_LINES = [".npmrc", "!.npmrc", "/.npmrc", "!/.npmrc"];
24
26
  const hasNpmrcSecret = (lineOrFullFileContents) => lineOrFullFileContents.includes("_auth") || lineOrFullFileContents.includes("_password");
25
27
  // Annotate the CommonJS export names for ESM import in node:
26
28
  0 && (module.exports = {
29
+ NPMRC_LINES,
27
30
  hasNpmrcSecret
28
31
  });
29
32
  //# sourceMappingURL=npmrc.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/npmrc.ts"],
4
- "sourcesContent": ["// Preventing against _auth, _authToken, _password\n// https://docs.npmjs.com/cli/v10/configuring-npm/npmrc#auth-related-configuration\n\nexport const hasNpmrcSecret = (lineOrFullFileContents: string): boolean =>\n lineOrFullFileContents.includes('_auth') ||\n lineOrFullFileContents.includes('_password');\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,iBAAiB,CAAC,2BAC7B,uBAAuB,SAAS,OAAO,KACvC,uBAAuB,SAAS,WAAW;",
4
+ "sourcesContent": ["export const NPMRC_LINES = ['.npmrc', '!.npmrc', '/.npmrc', '!/.npmrc'];\n\n// Preventing against _auth, _authToken, _password\n// https://docs.npmjs.com/cli/v10/configuring-npm/npmrc#auth-related-configuration\nexport const hasNpmrcSecret = (lineOrFullFileContents: string): boolean =>\n lineOrFullFileContents.includes('_auth') ||\n lineOrFullFileContents.includes('_password');\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc,CAAC,UAAU,WAAW,WAAW,UAAU;AAI/D,MAAM,iBAAiB,CAAC,2BAC7B,uBAAuB,SAAS,OAAO,KACvC,uBAAuB,SAAS,WAAW;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skuba",
3
- "version": "7.4.0-master-20240206030206",
3
+ "version": "7.4.0-master-20240207024454",
4
4
  "private": false,
5
5
  "description": "SEEK development toolkit for backend applications and packages",
6
6
  "homepage": "https://github.com/seek-oss/skuba#readme",
@@ -157,17 +157,17 @@
157
157
  "build": "scripts/build.sh",
158
158
  "changeset": "changeset",
159
159
  "deploy": "scripts/deploy.sh",
160
- "format": "pnpm run --silent skuba format",
161
- "lint": "pnpm run --silent skuba lint && pnpm run --silent lint:md",
160
+ "format": "pnpm --silent skuba format",
161
+ "lint": "pnpm --silent skuba lint && pnpm --silent lint:md",
162
162
  "lint:md": "remark --frail --quiet .",
163
- "release": "pnpm run --silent build && changeset publish",
164
- "skuba": "pnpm run --silent build && pnpm run --silent skuba:exec",
163
+ "release": "pnpm --silent build && changeset publish",
164
+ "skuba": "pnpm --silent build && pnpm --silent skuba:exec",
165
165
  "skuba:exec": "node --env-file=.env lib/skuba",
166
- "stage": "changeset version && node ./.changeset/inject.js && pnpm run format",
167
- "test": "pnpm run --silent skuba test --selectProjects unit",
168
- "test:ci": "pnpm run --silent skuba test --runInBand",
169
- "test:int": "pnpm run --silent skuba test --runInBand --selectProjects integration",
166
+ "stage": "changeset version && node ./.changeset/inject.js && pnpm format",
167
+ "test": "pnpm --silent skuba test --selectProjects unit",
168
+ "test:ci": "pnpm --silent skuba test --runInBand",
169
+ "test:int": "pnpm --silent skuba test --runInBand --selectProjects integration",
170
170
  "test:template": "scripts/test-template.sh",
171
- "test:watch": "pnpm run --silent skuba test --runInBand --watch"
171
+ "test:watch": "pnpm --silent skuba test --runInBand --watch"
172
172
  }
173
173
  }
@@ -10,7 +10,9 @@ configs:
10
10
 
11
11
  - &docker-ecr-cache
12
12
  seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
13
- cache-on: pnpm-lock.yaml
13
+ cache-on:
14
+ - .npmrc
15
+ - pnpm-lock.yaml
14
16
  dockerfile: Dockerfile.dev-deps
15
17
  secrets: id=npm,src=tmp/.npmrc
16
18
 
@@ -43,10 +45,10 @@ steps:
43
45
  commands:
44
46
  - echo '--- pnpm install --offline'
45
47
  - pnpm install --offline
46
- - echo '+++ pnpm run test:ci'
47
- - pnpm run test:ci
48
- - echo '--- pnpm run lint'
49
- - pnpm run lint
48
+ - echo '+++ pnpm test:ci'
49
+ - pnpm test:ci
50
+ - echo '--- pnpm lint'
51
+ - pnpm lint
50
52
  depends_on: warm-prod
51
53
  env:
52
54
  GET_GITHUB_TOKEN: please
@@ -7,7 +7,7 @@ FROM ${BASE_IMAGE} AS build
7
7
  COPY . .
8
8
 
9
9
  RUN pnpm install --offline
10
- RUN pnpm run build
10
+ RUN pnpm build
11
11
  RUN pnpm install --offline --prod
12
12
 
13
13
  ###
@@ -8,5 +8,6 @@ RUN pnpm config set store-dir /root/.pnpm-store
8
8
  WORKDIR /workdir
9
9
 
10
10
  RUN --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
11
+ --mount=type=bind,source=.npmrc,target=.npmrc \
11
12
  --mount=type=secret,id=npm,dst=/root/.npmrc,required=true \
12
13
  pnpm fetch
@@ -43,27 +43,27 @@ This defaults to an HTTP request to the `GET /smoke` endpoint.
43
43
  ### Test
44
44
 
45
45
  ```shell
46
- pnpm run test
46
+ pnpm test
47
47
  ```
48
48
 
49
49
  ### Lint
50
50
 
51
51
  ```shell
52
52
  # fix
53
- pnpm run format
53
+ pnpm format
54
54
 
55
55
  # check
56
- pnpm run lint
56
+ pnpm lint
57
57
  ```
58
58
 
59
59
  ### Start
60
60
 
61
61
  ```shell
62
62
  # Start a local HTTP server
63
- pnpm run start
63
+ pnpm start
64
64
 
65
65
  # Start with Node.js Inspector enabled
66
- pnpm run start:debug
66
+ pnpm start:debug
67
67
  ```
68
68
 
69
69
  ### Deploy
@@ -6,7 +6,7 @@
6
6
  "format": "skuba format",
7
7
  "lint": "skuba lint",
8
8
  "start": "skuba start --port <%- port %>",
9
- "start:debug": "pnpm run --silent start --inspect-brk",
9
+ "start:debug": "pnpm --silent start --inspect-brk",
10
10
  "test": "skuba test",
11
11
  "test:ci": "skuba test --coverage",
12
12
  "test:watch": "skuba test --watch"
@@ -24,6 +24,7 @@
24
24
  "skuba": "*",
25
25
  "supertest": "^6.1.6"
26
26
  },
27
+ "packageManager": "pnpm@8.15.1",
27
28
  "engines": {
28
29
  "node": ">=20"
29
30
  }
@@ -10,7 +10,9 @@ configs:
10
10
 
11
11
  - &docker-ecr-cache
12
12
  seek-oss/docker-ecr-cache#v2.1.1:
13
- cache-on: pnpm-lock.yaml
13
+ cache-on:
14
+ - .npmrc
15
+ - pnpm-lock.yaml
14
16
  secrets: id=npm,src=tmp/.npmrc
15
17
 
16
18
  - &private-npm
@@ -23,10 +25,10 @@ steps:
23
25
  commands:
24
26
  - echo '--- pnpm install --offline'
25
27
  - pnpm install --offline
26
- - echo '+++ pnpm run test:ci'
27
- - pnpm run test:ci
28
- - echo '--- pnpm run lint'
29
- - pnpm run lint
28
+ - echo '+++ pnpm test:ci'
29
+ - pnpm test:ci
30
+ - echo '--- pnpm lint'
31
+ - pnpm lint
30
32
  env:
31
33
  GET_GITHUB_TOKEN: please
32
34
  plugins:
@@ -8,5 +8,6 @@ RUN pnpm config set store-dir /root/.pnpm-store
8
8
  WORKDIR /workdir
9
9
 
10
10
  RUN --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
11
+ --mount=type=bind,source=.npmrc,target=.npmrc \
11
12
  --mount=type=secret,id=npm,dst=/root/.npmrc,required=true \
12
13
  pnpm fetch
@@ -36,27 +36,27 @@ It's a barebones Node.js application that comprises:
36
36
  ### Test
37
37
 
38
38
  ```shell
39
- pnpm run test
39
+ pnpm test
40
40
  ```
41
41
 
42
42
  ### Lint
43
43
 
44
44
  ```shell
45
45
  # Fix issues
46
- pnpm run format
46
+ pnpm format
47
47
 
48
48
  # Check for issues
49
- pnpm run lint
49
+ pnpm lint
50
50
  ```
51
51
 
52
52
  ### Start
53
53
 
54
54
  ```shell
55
55
  # Start a live-reloading process
56
- pnpm run start
56
+ pnpm start
57
57
 
58
58
  # Start with Node.js Inspector enabled
59
- pnpm run start:debug
59
+ pnpm start:debug
60
60
  ```
61
61
 
62
62
  This runs a live-reloading Node.js process pointing to the [src/app.ts](src/app.ts) entrypoint.
@@ -6,7 +6,7 @@
6
6
  "format": "skuba format",
7
7
  "lint": "skuba lint",
8
8
  "start": "skuba start",
9
- "start:debug": "pnpm run --silent start --inspect-brk",
9
+ "start:debug": "pnpm --silent start --inspect-brk",
10
10
  "test": "skuba test",
11
11
  "test:ci": "skuba test --coverage",
12
12
  "test:watch": "skuba test --watch"
@@ -18,6 +18,7 @@
18
18
  "@types/node": "^20.9.0",
19
19
  "skuba": "*"
20
20
  },
21
+ "packageManager": "pnpm@8.15.1",
21
22
  "engines": {
22
23
  "node": ">=20"
23
24
  }
@@ -10,7 +10,9 @@ configs:
10
10
 
11
11
  - &docker-ecr-cache
12
12
  seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
13
- cache-on: pnpm-lock.yaml
13
+ cache-on:
14
+ - .npmrc
15
+ - pnpm-lock.yaml
14
16
  dockerfile: Dockerfile.dev-deps
15
17
  secrets: id=npm,src=tmp/.npmrc
16
18
 
@@ -43,10 +45,10 @@ steps:
43
45
  commands:
44
46
  - echo '--- pnpm install --offline'
45
47
  - pnpm install --offline
46
- - echo '+++ pnpm run test:ci'
47
- - pnpm run test:ci
48
- - echo '--- pnpm run lint'
49
- - pnpm run lint
48
+ - echo '+++ pnpm test:ci'
49
+ - pnpm test:ci
50
+ - echo '--- pnpm lint'
51
+ - pnpm lint
50
52
  depends_on: warm-prod
51
53
  env:
52
54
  GET_GITHUB_TOKEN: please
@@ -7,7 +7,7 @@ FROM ${BASE_IMAGE} AS build
7
7
  COPY . .
8
8
 
9
9
  RUN pnpm install --offline
10
- RUN pnpm run build
10
+ RUN pnpm build
11
11
  RUN pnpm install --offline --prod
12
12
 
13
13
  ###
@@ -8,5 +8,6 @@ RUN pnpm config set store-dir /root/.pnpm-store
8
8
  WORKDIR /workdir
9
9
 
10
10
  RUN --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
11
+ --mount=type=bind,source=.npmrc,target=.npmrc \
11
12
  --mount=type=secret,id=npm,dst=/root/.npmrc,required=true \
12
13
  pnpm fetch
@@ -48,27 +48,27 @@ This defaults to an HTTP request to the `GET /smoke` endpoint.
48
48
  ### Test
49
49
 
50
50
  ```shell
51
- pnpm run test
51
+ pnpm test
52
52
  ```
53
53
 
54
54
  ### Lint
55
55
 
56
56
  ```shell
57
57
  # Fix issues
58
- pnpm run format
58
+ pnpm format
59
59
 
60
60
  # Check for issues
61
- pnpm run lint
61
+ pnpm lint
62
62
  ```
63
63
 
64
64
  ### Start
65
65
 
66
66
  ```shell
67
67
  # Start a local HTTP server
68
- pnpm run start
68
+ pnpm start
69
69
 
70
70
  # Start with Node.js Inspector enabled
71
- pnpm run start:debug
71
+ pnpm start:debug
72
72
  ```
73
73
 
74
74
  ### Deploy
@@ -6,7 +6,7 @@
6
6
  "format": "skuba format",
7
7
  "lint": "skuba lint",
8
8
  "start": "skuba start --port <%- port %>",
9
- "start:debug": "pnpm run --silent start --inspect-brk",
9
+ "start:debug": "pnpm --silent start --inspect-brk",
10
10
  "test": "skuba test",
11
11
  "test:ci": "skuba test --coverage",
12
12
  "test:watch": "skuba test --watch"
@@ -43,6 +43,7 @@
43
43
  "skuba": "*",
44
44
  "supertest": "^6.1.6"
45
45
  },
46
+ "packageManager": "pnpm@8.15.1",
46
47
  "engines": {
47
48
  "node": ">=20"
48
49
  }
@@ -10,7 +10,9 @@ configs:
10
10
 
11
11
  - &docker-ecr-cache
12
12
  seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
13
- cache-on: pnpm-lock.yaml
13
+ cache-on:
14
+ - .npmrc
15
+ - pnpm-lock.yaml
14
16
  secrets: id=npm,src=tmp/.npmrc
15
17
 
16
18
  - &private-npm
@@ -52,12 +54,12 @@ steps:
52
54
  commands:
53
55
  - echo '--- pnpm install --offline'
54
56
  - pnpm install --offline
55
- - echo '+++ pnpm run test:ci'
56
- - pnpm run test:ci
57
- - echo '--- pnpm run lint'
58
- - pnpm run lint
59
- - echo '--- pnpm run build'
60
- - pnpm run build
57
+ - echo '+++ pnpm test:ci'
58
+ - pnpm test:ci
59
+ - echo '--- pnpm lint'
60
+ - pnpm lint
61
+ - echo '--- pnpm build'
62
+ - pnpm build
61
63
  env:
62
64
  GET_GITHUB_TOKEN: please
63
65
  plugins:
@@ -8,5 +8,6 @@ RUN pnpm config set store-dir /root/.pnpm-store
8
8
  WORKDIR /workdir
9
9
 
10
10
  RUN --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
11
+ --mount=type=bind,source=.npmrc,target=.npmrc \
11
12
  --mount=type=secret,id=npm,dst=/root/.npmrc,required=true \
12
13
  pnpm fetch
@@ -47,33 +47,33 @@ This defaults to an invocation with an empty object `{}`, per [src/hooks.ts](src
47
47
 
48
48
  ```shell
49
49
  # Run Jest tests locally
50
- pnpm run test
50
+ pnpm test
51
51
 
52
52
  # Authenticate to dev account
53
53
  awsauth
54
54
 
55
55
  # Run smoke test against deployed application
56
- ENVIRONMENT=dev pnpm run smoke
56
+ ENVIRONMENT=dev pnpm smoke
57
57
  ```
58
58
 
59
59
  ### Lint
60
60
 
61
61
  ```shell
62
62
  # Fix issues
63
- pnpm run format
63
+ pnpm format
64
64
 
65
65
  # Check for issues
66
- pnpm run lint
66
+ pnpm lint
67
67
  ```
68
68
 
69
69
  ### Start
70
70
 
71
71
  ```shell
72
72
  # Start a local HTTP server
73
- pnpm run start
73
+ pnpm start
74
74
 
75
75
  # Start with Node.js Inspector enabled
76
- pnpm run start:debug
76
+ pnpm start:debug
77
77
  ```
78
78
 
79
79
  This serves the Lambda application over HTTP.
@@ -8,7 +8,7 @@
8
8
  "lint": "skuba lint",
9
9
  "smoke": "serverless invoke --data '{}' --function Worker",
10
10
  "start": "skuba start --port <%- port %>",
11
- "start:debug": "pnpm run --silent start --inspect-brk",
11
+ "start:debug": "pnpm --silent start --inspect-brk",
12
12
  "test": "skuba test",
13
13
  "test:ci": "skuba test --coverage",
14
14
  "test:watch": "skuba test --watch"
@@ -37,6 +37,7 @@
37
37
  "serverless-prune-plugin": "^2.0.0",
38
38
  "skuba": "*"
39
39
  },
40
+ "packageManager": "pnpm@8.15.1",
40
41
  "engines": {
41
42
  "node": ">=20"
42
43
  }
@@ -10,7 +10,9 @@ configs:
10
10
 
11
11
  - &docker-ecr-cache
12
12
  seek-oss/docker-ecr-cache#v2.1.1: &docker-ecr-cache-defaults
13
- cache-on: pnpm-lock.yaml
13
+ cache-on:
14
+ - .npmrc
15
+ - pnpm-lock.yaml
14
16
  secrets: id=npm,src=tmp/.npmrc
15
17
 
16
18
  - &private-npm
@@ -50,10 +52,10 @@ steps:
50
52
  commands:
51
53
  - echo '--- pnpm install --offline'
52
54
  - pnpm install --offline
53
- - echo '+++ pnpm run test:ci'
54
- - pnpm run test
55
- - echo '--- pnpm run lint'
56
- - pnpm run lint
55
+ - echo '+++ pnpm test:ci'
56
+ - pnpm test
57
+ - echo '--- pnpm lint'
58
+ - pnpm lint
57
59
  env:
58
60
  GET_GITHUB_TOKEN: please
59
61
  plugins:
@@ -11,5 +11,6 @@ RUN pnpm config set store-dir /root/.pnpm-store
11
11
  WORKDIR /workdir
12
12
 
13
13
  RUN --mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \
14
+ --mount=type=bind,source=.npmrc,target=.npmrc \
14
15
  --mount=type=secret,id=npm,dst=/root/.npmrc,required=true \
15
16
  pnpm fetch
@@ -3,8 +3,8 @@
3
3
  "license": "UNLICENSED",
4
4
  "scripts": {
5
5
  "deploy": "cdk deploy appStack --require-approval never --context stage=${ENVIRONMENT}",
6
- "deploy:hotswap": "pnpm run --silent deploy --hotswap",
7
- "deploy:watch": "pnpm run --silent deploy:hotswap --watch",
6
+ "deploy:hotswap": "pnpm --silent deploy --hotswap",
7
+ "deploy:watch": "pnpm --silent deploy:hotswap --watch",
8
8
  "format": "skuba format",
9
9
  "lint": "skuba lint",
10
10
  "test": "skuba test",
@@ -26,6 +26,7 @@
26
26
  "constructs": "^10.0.17",
27
27
  "skuba": "*"
28
28
  },
29
+ "packageManager": "pnpm@8.15.1",
29
30
  "engines": {
30
31
  "node": ">=20"
31
32
  }
@@ -33,7 +33,7 @@ jobs:
33
33
  run: pnpm install --frozen-lockfile
34
34
 
35
35
  - name: Publish to npm
36
- run: pnpm run release
36
+ run: pnpm release
37
37
  env:
38
38
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
39
  NPM_TOKEN: ${{ secrets.SEEK_OSS_CI_NPM_TOKEN }}
@@ -28,7 +28,7 @@ jobs:
28
28
  run: pnpm install --frozen-lockfile
29
29
 
30
30
  - name: Test
31
- run: pnpm run test:ci
31
+ run: pnpm test:ci
32
32
 
33
33
  - name: Lint
34
- run: pnpm run lint
34
+ run: pnpm lint
@@ -48,24 +48,24 @@ pnpm install
48
48
  ### Test
49
49
 
50
50
  ```shell
51
- pnpm run test
51
+ pnpm test
52
52
  ```
53
53
 
54
54
  ### Lint
55
55
 
56
56
  ```shell
57
57
  # Fix issues
58
- pnpm run format
58
+ pnpm format
59
59
 
60
60
  # Check for issues
61
- pnpm run lint
61
+ pnpm lint
62
62
  ```
63
63
 
64
64
  ### Package
65
65
 
66
66
  ```shell
67
67
  # Compile source
68
- pnpm run build
68
+ pnpm build
69
69
 
70
70
  # Review bundle
71
71
  npm pack
@@ -94,7 +94,7 @@ To set up this repo for publishing, follow the instructions in our [OSS npm pack
94
94
  ### Commit messages
95
95
 
96
96
  This package is published with **[semantic-release]**, which requires a particular commit format to manage semantic versioning.
97
- You can run the interactive `pnpm run commit` command in place of `git commit` to generate a compliant commit title and message.
97
+ You can run the interactive `pnpm commit` command in place of `git commit` to generate a compliant commit title and message.
98
98
  If you use the `Squash and merge` option on pull requests, take extra care to format the squashed commit in the GitHub UI before merging.
99
99
 
100
100
  ### Releasing latest
@@ -22,7 +22,7 @@
22
22
  "commit": "cz",
23
23
  "format": "skuba format",
24
24
  "lint": "skuba lint",
25
- "release": "pnpm run --silent build && skuba release",
25
+ "release": "pnpm --silent build && skuba release",
26
26
  "test": "skuba test",
27
27
  "test:ci": "skuba test --coverage",
28
28
  "test:watch": "skuba test --watch"
@@ -44,24 +44,24 @@ pnpm install
44
44
  ### Test
45
45
 
46
46
  ```shell
47
- pnpm run test
47
+ pnpm test
48
48
  ```
49
49
 
50
50
  ### Lint
51
51
 
52
52
  ```shell
53
53
  # Fix issues
54
- pnpm run format
54
+ pnpm format
55
55
 
56
56
  # Check for issues
57
- pnpm run lint
57
+ pnpm lint
58
58
  ```
59
59
 
60
60
  ### Package
61
61
 
62
62
  ```shell
63
63
  # Compile source
64
- pnpm run build
64
+ pnpm build
65
65
 
66
66
  # Review bundle
67
67
  npm pack
@@ -76,7 +76,7 @@ It depends on this repo being hosted on [SEEK-Jobs] with appropriate access.
76
76
  ### Commit messages
77
77
 
78
78
  This package is published with **[semantic-release]**, which requires a particular commit format to manage semantic versioning.
79
- You can run the interactive `pnpm run commit` command in place of `git commit` to generate a compliant commit title and message.
79
+ You can run the interactive `pnpm commit` command in place of `git commit` to generate a compliant commit title and message.
80
80
  If you use the `Squash and merge` option on pull requests, take extra care to format the squashed commit in the GitHub UI before merging.
81
81
 
82
82
  ### Releasing latest
@@ -22,9 +22,9 @@
22
22
  "commit": "cz",
23
23
  "format": "skuba format",
24
24
  "lint": "skuba lint",
25
- "release": "pnpm run --silent build && skuba release",
25
+ "release": "pnpm --silent build && skuba release",
26
26
  "test": "skuba test --coverage",
27
- "test:ci": "pnpm run --silent test",
27
+ "test:ci": "pnpm --silent test",
28
28
  "test:watch": "skuba test --watch"
29
29
  },
30
30
  "config": {
@@ -38,6 +38,7 @@
38
38
  "commitizen": "^4.2.4",
39
39
  "skuba": "*"
40
40
  },
41
+ "packageManager": "pnpm@8.15.1",
41
42
  "engines": {
42
43
  "node": ">=18.12"
43
44
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * Generate simple variants of an ignore pattern for exact matching purposes.
3
- *
4
- * Note that these patterns are not actually equivalent (e.g. `lib` matches more
5
- * than `lib/`) but they generally represent the same _intent_.
6
- */
7
- export declare const generateSimpleVariants: (patterns: string[]) => Set<string>;
8
- export declare const mergeWithIgnoreFile: (rawTemplateFile: string) => (rawInputFile?: string) => string;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/cli/configure/processing/ignoreFile.ts"],
4
- "sourcesContent": ["/**\n * Patterns that are superseded by skuba's bundled ignore file patterns and are\n * non-trivial to derive using e.g. `generateSimpleVariants`.\n */\nconst OUTDATED_PATTERNS = ['node_modules_bak/', 'tmp-*/'];\n\nconst ASTERISKS = /\\*/g;\nconst LEADING_SLASH = /^\\//;\nconst TRAILING_SLASH = /\\/$/;\n\n/**\n * Generate simple variants of an ignore pattern for exact matching purposes.\n *\n * Note that these patterns are not actually equivalent (e.g. `lib` matches more\n * than `lib/`) but they generally represent the same _intent_.\n */\nexport const generateSimpleVariants = (patterns: string[]) => {\n const set = new Set<string>();\n\n for (const pattern of patterns) {\n const deAsterisked = pattern.replace(ASTERISKS, '');\n const stripped = deAsterisked\n .replace(LEADING_SLASH, '')\n .replace(TRAILING_SLASH, '');\n\n set.add(pattern);\n set.add(deAsterisked);\n set.add(deAsterisked.replace(LEADING_SLASH, ''));\n set.add(deAsterisked.replace(TRAILING_SLASH, ''));\n set.add(stripped);\n\n if (stripped !== '') {\n set.add(`/${stripped}`);\n set.add(`${stripped}/`);\n set.add(`/${stripped}/`);\n }\n }\n\n set.delete('');\n\n return set;\n};\n\nexport const mergeWithIgnoreFile = (rawTemplateFile: string) => {\n const templateFile = rawTemplateFile.trim();\n\n const templatePatterns = generateSimpleVariants([\n ...OUTDATED_PATTERNS,\n ...templateFile.split('\\n').map((line) => line.trim()),\n ]);\n\n return (rawInputFile?: string) => {\n if (rawInputFile === undefined) {\n return `${templateFile}\\n`;\n }\n\n const replacedFile = rawInputFile\n .replace(/\\r?\\n/g, '\\n')\n .replace(/# managed by skuba[\\s\\S]*# end managed by skuba/, templateFile);\n\n if (replacedFile.includes(templateFile)) {\n return replacedFile;\n }\n\n // Crunch the existing lines of a non-skuba config.\n const migratedFile = replacedFile\n .split('\\n')\n .filter((line) => !templatePatterns.has(line))\n .join('\\n')\n .replace(/\\n{3,}/g, '\\n\\n')\n .trim();\n\n const outputFile = [templateFile, migratedFile].join('\\n\\n').trim();\n\n return `${outputFile}\\n`;\n };\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,MAAM,oBAAoB,CAAC,qBAAqB,QAAQ;AAExD,MAAM,YAAY;AAClB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAQhB,MAAM,yBAAyB,CAAC,aAAuB;AAC5D,QAAM,MAAM,oBAAI,IAAY;AAE5B,aAAW,WAAW,UAAU;AAC9B,UAAM,eAAe,QAAQ,QAAQ,WAAW,EAAE;AAClD,UAAM,WAAW,aACd,QAAQ,eAAe,EAAE,EACzB,QAAQ,gBAAgB,EAAE;AAE7B,QAAI,IAAI,OAAO;AACf,QAAI,IAAI,YAAY;AACpB,QAAI,IAAI,aAAa,QAAQ,eAAe,EAAE,CAAC;AAC/C,QAAI,IAAI,aAAa,QAAQ,gBAAgB,EAAE,CAAC;AAChD,QAAI,IAAI,QAAQ;AAEhB,QAAI,aAAa,IAAI;AACnB,UAAI,IAAI,IAAI,QAAQ,EAAE;AACtB,UAAI,IAAI,GAAG,QAAQ,GAAG;AACtB,UAAI,IAAI,IAAI,QAAQ,GAAG;AAAA,IACzB;AAAA,EACF;AAEA,MAAI,OAAO,EAAE;AAEb,SAAO;AACT;AAEO,MAAM,sBAAsB,CAAC,oBAA4B;AAC9D,QAAM,eAAe,gBAAgB,KAAK;AAE1C,QAAM,mBAAmB,uBAAuB;AAAA,IAC9C,GAAG;AAAA,IACH,GAAG,aAAa,MAAM,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC;AAAA,EACvD,CAAC;AAED,SAAO,CAAC,iBAA0B;AAChC,QAAI,iBAAiB,QAAW;AAC9B,aAAO,GAAG,YAAY;AAAA;AAAA,IACxB;AAEA,UAAM,eAAe,aAClB,QAAQ,UAAU,IAAI,EACtB,QAAQ,mDAAmD,YAAY;AAE1E,QAAI,aAAa,SAAS,YAAY,GAAG;AACvC,aAAO;AAAA,IACT;AAGA,UAAM,eAAe,aAClB,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,CAAC,iBAAiB,IAAI,IAAI,CAAC,EAC5C,KAAK,IAAI,EACT,QAAQ,WAAW,MAAM,EACzB,KAAK;AAER,UAAM,aAAa,CAAC,cAAc,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK;AAElE,WAAO,GAAG,UAAU;AAAA;AAAA,EACtB;AACF;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import type { PatchReturnType } from '../..';
2
- export declare const tryMoveNpmrcOutOfGitignoreManagedSection: (mode: 'format' | 'lint', dir?: string) => Promise<PatchReturnType>;
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../src/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.ts"],
4
- "sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../analysis/project';\n\nconst NPMRC_IGNORE_SECTION = `\n\n# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst moveNpmrcOutOfGitignoreManagedSection = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const gitignore = await readFile('.gitignore');\n\n if (!gitignore) {\n return { result: 'skip', reason: 'no .gitignore file found' };\n }\n\n let isIgnored: { inManaged: boolean } | undefined;\n let currentlyInManagedSection = false;\n\n for (const line of gitignore.split('\\n')) {\n if (line.trim() === '# managed by skuba') {\n currentlyInManagedSection = true;\n } else if (line.trim() === '# end managed by skuba') {\n currentlyInManagedSection = false;\n }\n\n if (line.trim() === '.npmrc' || line.trim() === '/.npmrc') {\n isIgnored = { inManaged: currentlyInManagedSection };\n }\n\n if (line.trim() === '!.npmrc' || line.trim() === '!/.npmrc') {\n isIgnored = undefined;\n }\n }\n\n if (isIgnored && !isIgnored.inManaged) {\n return { result: 'skip', reason: 'already ignored in unmanaged section' };\n }\n\n if (!isIgnored) {\n return { result: 'skip', reason: 'not ignored' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const newGitignore =\n gitignore\n .split('\\n')\n .filter((line) => line.trim().replace(/^[!/]+/g, '') !== '.npmrc')\n .join('\\n')\n .trim() + NPMRC_IGNORE_SECTION;\n\n await fs.promises.writeFile(path.join(dir, '.gitignore'), newGitignore);\n\n return { result: 'apply' };\n};\n\nexport const tryMoveNpmrcOutOfGitignoreManagedSection = (async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await moveNpmrcOutOfGitignoreManagedSection(mode, dir);\n } catch (err) {\n log.warn('Failed to move .npmrc out of .gitignore managed section.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n}) satisfies PatchFunction;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAE5C,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B,MAAM,wCAAwC,OAC5C,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,YAAY,MAAM,SAAS,YAAY;AAE7C,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,MAAI;AACJ,MAAI,4BAA4B;AAEhC,aAAW,QAAQ,UAAU,MAAM,IAAI,GAAG;AACxC,QAAI,KAAK,KAAK,MAAM,sBAAsB;AACxC,kCAA4B;AAAA,IAC9B,WAAW,KAAK,KAAK,MAAM,0BAA0B;AACnD,kCAA4B;AAAA,IAC9B;AAEA,QAAI,KAAK,KAAK,MAAM,YAAY,KAAK,KAAK,MAAM,WAAW;AACzD,kBAAY,EAAE,WAAW,0BAA0B;AAAA,IACrD;AAEA,QAAI,KAAK,KAAK,MAAM,aAAa,KAAK,KAAK,MAAM,YAAY;AAC3D,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI,aAAa,CAAC,UAAU,WAAW;AACrC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,uCAAuC;AAAA,EAC1E;AAEA,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,QAAQ,QAAQ,QAAQ,cAAc;AAAA,EACjD;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,eACJ,UACG,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,KAAK,KAAK,EAAE,QAAQ,WAAW,EAAE,MAAM,QAAQ,EAChE,KAAK,IAAI,EACT,KAAK,IAAI;AAEd,QAAM,gBAAAA,QAAG,SAAS,UAAU,YAAAC,QAAK,KAAK,KAAK,YAAY,GAAG,YAAY;AAEtE,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,2CAA4C,OACvD,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,sCAAsC,MAAM,GAAG;AAAA,EAC9D,SAAS,KAAK;AACZ,uBAAI,KAAK,0DAA0D;AACnE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
6
- "names": ["fs", "path"]
7
- }