skuba 7.4.0-horrible-hacks-20240206024353 → 7.4.0-master-20240206223029

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 (43) 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/index.js +10 -2
  11. package/lib/cli/configure/upgrade/index.js.map +2 -2
  12. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js +2 -1
  13. package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfGitignoreManagedSection.js.map +2 -2
  14. package/lib/cli/lint/internalLints/refreshConfigFiles.js +23 -12
  15. package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
  16. package/lib/utils/npmrc.d.ts +1 -0
  17. package/lib/utils/npmrc.js +3 -0
  18. package/lib/utils/npmrc.js.map +2 -2
  19. package/package.json +10 -10
  20. package/template/express-rest-api/.buildkite/pipeline.yml +4 -4
  21. package/template/express-rest-api/Dockerfile +1 -1
  22. package/template/express-rest-api/README.md +5 -5
  23. package/template/express-rest-api/package.json +2 -1
  24. package/template/greeter/.buildkite/pipeline.yml +4 -4
  25. package/template/greeter/README.md +5 -5
  26. package/template/greeter/package.json +2 -1
  27. package/template/koa-rest-api/.buildkite/pipeline.yml +4 -4
  28. package/template/koa-rest-api/Dockerfile +1 -1
  29. package/template/koa-rest-api/README.md +5 -5
  30. package/template/koa-rest-api/package.json +2 -1
  31. package/template/lambda-sqs-worker/.buildkite/pipeline.yml +6 -6
  32. package/template/lambda-sqs-worker/README.md +6 -6
  33. package/template/lambda-sqs-worker/package.json +2 -1
  34. package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +4 -4
  35. package/template/lambda-sqs-worker-cdk/package.json +3 -2
  36. package/template/oss-npm-package/.github/workflows/release.yml +1 -1
  37. package/template/oss-npm-package/.github/workflows/validate.yml +2 -2
  38. package/template/oss-npm-package/README.md +5 -5
  39. package/template/oss-npm-package/_package.json +1 -1
  40. package/template/private-npm-package/README.md +5 -5
  41. package/template/private-npm-package/_package.json +3 -2
  42. package/lib/cli/configure/processing/ignoreFile.d.ts +0 -8
  43. package/lib/cli/configure/processing/ignoreFile.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;AA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ACxB;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
+ }
@@ -39,9 +39,17 @@ var import_packageManager = require("../../../utils/packageManager");
39
39
  var import_version = require("../../../utils/version");
40
40
  var import_package = require("../processing/package");
41
41
  const getPatches = async (manifestVersion) => {
42
- const patches = await (0, import_fs_extra.readdir)(import_path.default.join(__dirname, "patches"));
42
+ const patches = await (0, import_fs_extra.readdir)(import_path.default.join(__dirname, "patches"), {
43
+ withFileTypes: true
44
+ });
43
45
  const patchesForVersion = (0, import_semver.sort)(
44
- patches.filter((filename) => (0, import_semver.gte)(filename, manifestVersion))
46
+ patches.flatMap(
47
+ (patch) => (
48
+ // Is a directory rather than a JavaScript source file
49
+ patch.isDirectory() && // Has been added since the last patch run on the project
50
+ (0, import_semver.gte)(patch.name, manifestVersion) ? patch.name : []
51
+ )
52
+ )
45
53
  );
46
54
  return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();
47
55
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/cli/configure/upgrade/index.ts"],
4
- "sourcesContent": ["import path from 'path';\n\nimport { readdir, writeFile } from 'fs-extra';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../utils/logging';\nimport { getConsumerManifest } from '../../../utils/manifest';\nimport { detectPackageManager } from '../../../utils/packageManager';\nimport { getSkubaVersion } from '../../../utils/version';\nimport type { SkubaPackageJson } from '../../init/writePackageJson';\nimport type { InternalLintResult } from '../../lint/internal';\nimport { formatPackage } from '../processing/package';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\nexport type PatchFunction = (\n mode: 'format' | 'lint',\n) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await readdir(path.join(__dirname, 'patches'));\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.filter((filename) => gte(filename, manifestVersion)),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = (manifest.packageJson.skuba as SkubaPackageJson)\n .version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(async ({ apply }) => await apply(mode)),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n const packageManager = await detectPackageManager();\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )} to run them. ${logger.dim('skuba-patches')}`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply(mode);\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n (manifest.packageJson.skuba as SkubaPackageJson).version = currentVersion;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await writeFile(manifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAmC;AACnC,oBAA0B;AAG1B,sBAAoC;AACpC,4BAAqC;AACrC,qBAAgC;AAGhC,qBAA8B;AAc9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,UAAM,yBAAQ,YAAAA,QAAK,KAAK,WAAW,SAAS,CAAC;AAI7D,QAAM,wBAAoB;AAAA,IACxB,QAAQ,OAAO,CAAC,iBAAa,mBAAI,UAAU,eAAe,CAAC;AAAA,EAC7D;AAEA,UAAQ,MAAM,QAAQ,IAAI,kBAAkB,IAAI,cAAc,CAA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AC/C;AAEA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA;AAAA;AAAA,UAGE,MAAM,SAAS;AAAA,UACf,SAAS,mCAAmC,eAAe,IAAI;AAAA,QACjE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,mBAAmB;AAGhC,aAAW,EAAE,OAAO,YAAY,KAAK,SAAS;AAC5C,UAAM,SAAS,MAAM,MAAM,IAAI;AAC/B,WAAO,QAAQ;AACf,QAAI,OAAO,WAAW,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,EAAC,SAAS,YAAY,MAA2B,UAAU;AAE3D,QAAM,qBAAqB,UAAM,8BAAc,SAAS,WAAW;AAEnE,YAAM,2BAAU,SAAS,MAAM,kBAAkB;AACjD,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
4
+ "sourcesContent": ["import path from 'path';\n\nimport { readdir, writeFile } from 'fs-extra';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../utils/logging';\nimport { getConsumerManifest } from '../../../utils/manifest';\nimport { detectPackageManager } from '../../../utils/packageManager';\nimport { getSkubaVersion } from '../../../utils/version';\nimport type { SkubaPackageJson } from '../../init/writePackageJson';\nimport type { InternalLintResult } from '../../lint/internal';\nimport { formatPackage } from '../processing/package';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\nexport type PatchFunction = (\n mode: 'format' | 'lint',\n) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await readdir(path.join(__dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = (manifest.packageJson.skuba as SkubaPackageJson)\n .version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(async ({ apply }) => await apply(mode)),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n const packageManager = await detectPackageManager();\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )} to run them. ${logger.dim('skuba-patches')}`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply(mode);\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n (manifest.packageJson.skuba as SkubaPackageJson).version = currentVersion;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await writeFile(manifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAmC;AACnC,oBAA0B;AAG1B,sBAAoC;AACpC,4BAAqC;AACrC,qBAAgC;AAGhC,qBAA8B;AAc9B,MAAM,aAAa,OAAO,oBAA8C;AACtE,QAAM,UAAU,UAAM,yBAAQ,YAAAA,QAAK,KAAK,WAAW,SAAS,GAAG;AAAA,IAC7D,eAAe;AAAA,EACjB,CAAC;AAID,QAAM,wBAAoB;AAAA,IACxB,QAAQ;AAAA,MAAQ,CAAC;AAAA;AAAA,QAEf,MAAM,YAAY;AAAA,YAElB,mBAAI,MAAM,MAAM,eAAe,IAC3B,MAAM,OACN,CAAC;AAAA;AAAA,IACP;AAAA,EACF;AAEA,UAAQ,MAAM,QAAQ,IAAI,kBAAkB,IAAI,cAAc,CAAC,GAAG,KAAK;AACzE;AAEA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ACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa;AAAA,QACX;AAAA;AAAA;AAAA,UAGE,MAAM,SAAS;AAAA,UACf,SAAS,mCAAmC,eAAe,IAAI;AAAA,QACjE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,mBAAmB;AAGhC,aAAW,EAAE,OAAO,YAAY,KAAK,SAAS;AAC5C,UAAM,SAAS,MAAM,MAAM,IAAI;AAC/B,WAAO,QAAQ;AACf,QAAI,OAAO,WAAW,QAAQ;AAC5B,aAAO;AAAA,QACL,kBAAkB,WAAW,GAC3B,OAAO,SAAS,MAAM,OAAO,MAAM,KAAK,EAC1C;AAAA,MACF;AAAA,IACF,OAAO;AACL,aAAO,MAAM,kBAAkB,WAAW,EAAE;AAAA,IAC9C;AAAA,EACF;AAEA,EAAC,SAAS,YAAY,MAA2B,UAAU;AAE3D,QAAM,qBAAqB,UAAM,8BAAc,SAAS,WAAW;AAEnE,YAAM,2BAAU,SAAS,MAAM,kBAAkB;AACjD,SAAO,QAAQ;AACf,SAAO,MAAM,wBAAwB;AACrC,SAAO,QAAQ;AAEf,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS;AAAA,EACX;AACF;",
6
6
  "names": ["path"]
7
7
  }
@@ -35,6 +35,7 @@ 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
 
@@ -74,7 +75,7 @@ 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
+ const newGitignore = gitignore.split("\n").filter((line) => !import_npmrc.NPMRC_LINES.includes(line.trim())).join("\n").trim() + NPMRC_IGNORE_SECTION;
78
79
  await import_fs_extra.default.promises.writeFile(import_path.default.join(dir, ".gitignore"), newGitignore);
79
80
  return { result: "apply" };
80
81
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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;",
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 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) => !NPMRC_LINES.includes(line.trim()))\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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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
6
  "names": ["fs", "path"]
7
7
  }
@@ -41,14 +41,25 @@ var import_packageManager = require("../../../utils/packageManager");
41
41
  var import_template = require("../../../utils/template");
42
42
  var import_package = require("../../configure/analysis/package");
43
43
  var import_project = require("../../configure/analysis/project");
44
- var import_ignoreFile = require("../../configure/processing/ignoreFile");
44
+ var import_configFile = require("../../configure/processing/configFile");
45
45
  const ensureNoAuthToken = (fileContents) => fileContents.split("\n").filter((line) => !(0, import_npmrc.hasNpmrcSecret)(line)).join("\n");
46
46
  const REFRESHABLE_CONFIG_FILES = [
47
- { name: ".eslintignore" },
48
- { name: ".gitignore" },
49
- { name: ".prettierignore" },
47
+ { name: ".eslintignore", type: "ignore" },
48
+ {
49
+ name: ".gitignore",
50
+ type: "ignore",
51
+ additionalMapping: (gitignore) => {
52
+ const npmrcLines = gitignore.split("\n").filter((line) => import_npmrc.NPMRC_LINES.includes(line.trim()));
53
+ if (npmrcLines.length > 0 && npmrcLines.every((line) => line.includes("!"))) {
54
+ return gitignore.split("\n").filter((line) => !import_npmrc.NPMRC_LINES.includes(line.trim())).join("\n");
55
+ }
56
+ return gitignore;
57
+ }
58
+ },
59
+ { name: ".prettierignore", type: "ignore" },
50
60
  {
51
61
  name: ".npmrc",
62
+ type: "npmrc",
52
63
  additionalMapping: ensureNoAuthToken,
53
64
  if: (packageManager) => packageManager.command === "pnpm"
54
65
  }
@@ -57,7 +68,12 @@ const refreshConfigFiles = async (mode, logger) => {
57
68
  const manifest = await (0, import_package.getDestinationManifest)();
58
69
  const destinationRoot = import_path.default.dirname(manifest.path);
59
70
  const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
60
- const refreshConfigFile = async (filename, packageManager2, additionalMapping = (s) => s, condition = () => true) => {
71
+ const refreshConfigFile = async ({
72
+ name: filename,
73
+ type: fileType,
74
+ additionalMapping = (s) => s,
75
+ if: condition = () => true
76
+ }, packageManager2) => {
61
77
  if (!condition(packageManager2)) {
62
78
  return { needsChange: false };
63
79
  }
@@ -66,7 +82,7 @@ const refreshConfigFiles = async (mode, logger) => {
66
82
  (0, import_template.readBaseTemplateFile)(`_${filename}`)
67
83
  ]);
68
84
  const data = additionalMapping(
69
- inputFile ? (0, import_ignoreFile.mergeWithIgnoreFile)(templateFile)(inputFile) : templateFile,
85
+ inputFile ? (0, import_configFile.mergeWithConfigFile)(templateFile, fileType)(inputFile) : templateFile,
70
86
  packageManager2
71
87
  );
72
88
  const filepath = import_path.default.join(destinationRoot, filename);
@@ -99,12 +115,7 @@ const refreshConfigFiles = async (mode, logger) => {
99
115
  const packageManager = await (0, import_packageManager.detectPackageManager)(destinationRoot);
100
116
  const results = await Promise.all(
101
117
  REFRESHABLE_CONFIG_FILES.map(
102
- (conf) => refreshConfigFile(
103
- conf.name,
104
- packageManager,
105
- conf.additionalMapping,
106
- conf.if
107
- )
118
+ (conf) => refreshConfigFile(conf, packageManager)
108
119
  )
109
120
  );
110
121
  results.forEach((result) => {
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAA0B;AAC1B,wBAAsB;AAGtB,mBAA+B;AAC/B,4BAGO;AACP,sBAAqC;AACrC,qBAAuC;AACvC,qBAA4C;AAC5C,wBAAoC;AAGpC,MAAM,oBAAoB,CAAC,iBACzB,aACG,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,KAAC,6BAAe,IAAI,CAAC,EACtC,KAAK,IAAI;AAEd,MAAM,2BAA2B;AAAA,EAC/B,EAAE,MAAM,gBAAgB;AAAA,EACxB,EAAE,MAAM,aAAa;AAAA,EACrB,EAAE,MAAM,kBAAkB;AAAA,EAC1B;AAAA,IACE,MAAM;AAAA,IACN,mBAAmB;AAAA,IACnB,IAAI,CAAC,mBACH,eAAe,YAAY;AAAA,EAC/B;AACF;AAEO,MAAM,qBAAqB,OAChC,MACA,WACG;AACH,QAAM,WAAW,UAAM,uCAAuB;AAE9C,QAAM,kBAAkB,YAAAA,QAAK,QAAQ,SAAS,IAAI;AAElD,QAAM,0BA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O,KAAK;AACd,aAAO,KAAK,OAAO,KAAK,OAAO,IAAI,sBAAsB,CAAC;AAAA,IAC5D;AAAA,EACF,CAAC;AAED,QAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,YAAY,MAAM,WAAW;AAErE,SAAO;AAAA,IACL,IAAI,CAAC;AAAA,IACL,SAAS;AAAA,IACT,aAAa,QAAQ;AAAA,MAAQ,CAAC,EAAE,aAAa,UAAU,IAAI,MACzD,eAAe,MACX;AAAA,QACE;AAAA,UACE,MAAM;AAAA,UACN,aAAS,kBAAAC,SAAU,GAAG;AAAA,QACxB;AAAA,MACF,IACA,CAAC;AAAA,IACP;AAAA,EACF;AACF;AAEO,MAAM,wBAAwB,OACnC,MACA,WACgC;AAChC,MAAI;AACF,WAAO,MAAM,mBAAmB,MAAM,MAAM;AAAA,EAC9C,SAAS,KAAK;AACZ,WAAO,KAAK,iCAAiC;AAC7C,WAAO,WAAO,qBAAQ,GAAG,CAAC;AAE1B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
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 REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[] = [\n { name: '.eslintignore', type: 'ignore' },\n {\n name: '.gitignore',\n type: 'ignore',\n additionalMapping: (gitignore: string) => {\n const npmrcLines = gitignore\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 (\n npmrcLines.length > 0 &&\n npmrcLines.every((line) => line.includes('!'))\n ) {\n return gitignore\n .split('\\n')\n .filter((line) => !NPMRC_LINES.includes(line.trim()))\n .join('\\n');\n }\n return gitignore;\n },\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\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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAA0B;AAC1B,wBAAsB;AAGtB,mBAA4C;AAC5C,4BAGO;AACP,sBAAqC;AACrC,qBAAuC;AACvC,qBAA4C;AAC5C,wBAAoC;AAGpC,MAAM,oBAAoB,CAAC,iBACzB,aACG,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,KAAC,6BAAe,IAAI,CAAC,EACtC,KAAK,IAAI;AAYd,MAAM,2BAAoD;AAAA,EACxD,EAAE,MAAM,iBAAiB,MAAM,SAAS;AAAA,EACxC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB,CAAC,cAAsB;AACxC,YAAM,aAAa,UAChB,MAAM,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B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
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-horrible-hacks-20240206024353",
3
+ "version": "7.4.0-master-20240206223029",
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
  }
@@ -43,10 +43,10 @@ steps:
43
43
  commands:
44
44
  - echo '--- pnpm install --offline'
45
45
  - pnpm install --offline
46
- - echo '+++ pnpm run test:ci'
47
- - pnpm run test:ci
48
- - echo '--- pnpm run lint'
49
- - pnpm run lint
46
+ - echo '+++ pnpm test:ci'
47
+ - pnpm test:ci
48
+ - echo '--- pnpm lint'
49
+ - pnpm lint
50
50
  depends_on: warm-prod
51
51
  env:
52
52
  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
  ###
@@ -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
  }
@@ -23,10 +23,10 @@ steps:
23
23
  commands:
24
24
  - echo '--- pnpm install --offline'
25
25
  - pnpm install --offline
26
- - echo '+++ pnpm run test:ci'
27
- - pnpm run test:ci
28
- - echo '--- pnpm run lint'
29
- - pnpm run lint
26
+ - echo '+++ pnpm test:ci'
27
+ - pnpm test:ci
28
+ - echo '--- pnpm lint'
29
+ - pnpm lint
30
30
  env:
31
31
  GET_GITHUB_TOKEN: please
32
32
  plugins:
@@ -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
  }
@@ -43,10 +43,10 @@ steps:
43
43
  commands:
44
44
  - echo '--- pnpm install --offline'
45
45
  - pnpm install --offline
46
- - echo '+++ pnpm run test:ci'
47
- - pnpm run test:ci
48
- - echo '--- pnpm run lint'
49
- - pnpm run lint
46
+ - echo '+++ pnpm test:ci'
47
+ - pnpm test:ci
48
+ - echo '--- pnpm lint'
49
+ - pnpm lint
50
50
  depends_on: warm-prod
51
51
  env:
52
52
  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
  ###
@@ -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
  }
@@ -52,12 +52,12 @@ steps:
52
52
  commands:
53
53
  - echo '--- pnpm install --offline'
54
54
  - 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
55
+ - echo '+++ pnpm test:ci'
56
+ - pnpm test:ci
57
+ - echo '--- pnpm lint'
58
+ - pnpm lint
59
+ - echo '--- pnpm build'
60
+ - pnpm build
61
61
  env:
62
62
  GET_GITHUB_TOKEN: please
63
63
  plugins:
@@ -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
  }
@@ -50,10 +50,10 @@ steps:
50
50
  commands:
51
51
  - echo '--- pnpm install --offline'
52
52
  - pnpm install --offline
53
- - echo '+++ pnpm run test:ci'
54
- - pnpm run test
55
- - echo '--- pnpm run lint'
56
- - pnpm run lint
53
+ - echo '+++ pnpm test:ci'
54
+ - pnpm test
55
+ - echo '--- pnpm lint'
56
+ - pnpm lint
57
57
  env:
58
58
  GET_GITHUB_TOKEN: please
59
59
  plugins:
@@ -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,MA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