skuba 7.4.0-master-20240206223029 → 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.
@@ -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,11 +26,11 @@ 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"));
@@ -45,15 +45,15 @@ const NPMRC_IGNORE_SECTION = `
45
45
  # Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.
46
46
  .npmrc
47
47
  `;
48
- const moveNpmrcOutOfGitignoreManagedSection = async (mode, dir) => {
48
+ const moveNpmrcOutOfIgnoreManagedSection = async (mode, dir, fileName) => {
49
49
  const readFile = (0, import_project.createDestinationFileReader)(dir);
50
- const gitignore = await readFile(".gitignore");
51
- if (!gitignore) {
52
- 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` };
53
53
  }
54
54
  let isIgnored;
55
55
  let currentlyInManagedSection = false;
56
- for (const line of gitignore.split("\n")) {
56
+ for (const line of ignoreFile.split("\n")) {
57
57
  if (line.trim() === "# managed by skuba") {
58
58
  currentlyInManagedSection = true;
59
59
  } else if (line.trim() === "# end managed by skuba") {
@@ -75,21 +75,21 @@ const moveNpmrcOutOfGitignoreManagedSection = async (mode, dir) => {
75
75
  if (mode === "lint") {
76
76
  return { result: "apply" };
77
77
  }
78
- const newGitignore = gitignore.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, ".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);
80
80
  return { result: "apply" };
81
81
  };
82
- const tryMoveNpmrcOutOfGitignoreManagedSection = async (mode, dir = process.cwd()) => {
82
+ const tryMoveNpmrcOutOfIgnoreManagedSection = (type) => async (mode, dir = process.cwd()) => {
83
83
  try {
84
- return await moveNpmrcOutOfGitignoreManagedSection(mode, dir);
84
+ return await moveNpmrcOutOfIgnoreManagedSection(mode, dir, type);
85
85
  } catch (err) {
86
- 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.`);
87
87
  import_logging.log.subtle((0, import_util.inspect)(err));
88
88
  return { result: "skip", reason: "due to an error" };
89
89
  }
90
90
  };
91
91
  // Annotate the CommonJS export names for ESM import in node:
92
92
  0 && (module.exports = {
93
- tryMoveNpmrcOutOfGitignoreManagedSection
93
+ tryMoveNpmrcOutOfIgnoreManagedSection
94
94
  });
95
- //# 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;A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AK,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
  });
@@ -43,18 +44,19 @@ var import_package = require("../../configure/analysis/package");
43
44
  var import_project = require("../../configure/analysis/project");
44
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
55
  { name: ".eslintignore", type: "ignore" },
48
56
  {
49
57
  name: ".gitignore",
50
58
  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
- }
59
+ additionalMapping: removeRedundantNpmrc
58
60
  },
59
61
  { name: ".prettierignore", type: "ignore" },
60
62
  {
@@ -62,6 +64,11 @@ const REFRESHABLE_CONFIG_FILES = [
62
64
  type: "npmrc",
63
65
  additionalMapping: ensureNoAuthToken,
64
66
  if: (packageManager) => packageManager.command === "pnpm"
67
+ },
68
+ {
69
+ name: ".dockerignore",
70
+ type: "ignore",
71
+ additionalMapping: removeRedundantNpmrc
65
72
  }
66
73
  ];
67
74
  const refreshConfigFiles = async (mode, logger) => {
@@ -152,6 +159,7 @@ const tryRefreshConfigFiles = async (mode, logger) => {
152
159
  };
153
160
  // Annotate the CommonJS export names for ESM import in node:
154
161
  0 && (module.exports = {
162
+ REFRESHABLE_CONFIG_FILES,
155
163
  refreshConfigFiles,
156
164
  tryRefreshConfigFiles
157
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 { 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,IAAI,EACV,OAAO,CAAC,SAAS,yBAAY,SAAS,KAAK,KAAK,CAAC,CAAC;AAIrD,UACE,WAAW,SAAS,KACpB,WAAW,MAAM,CAAC,SAAS,KAAK,SAAS,GAAG,CAAC,GAC7C;AACA,eAAO,UACJ,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,CAAC,yBAAY,SAAS,KAAK,KAAK,CAAC,CAAC,EACnD,KAAK,IAAI;AAAA,MACd;AACA,aAAO;AAAA,IACT;AAAA,EACF;AAAA,EACA,EAAE,MAAM,mBAAmB,MAAM,SAAS;AAAA,EAC1C;AAAA,IACE,MAAM;AAAA,IACN,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;AAE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AAM,cAAc;AAAA,IACxC;AAAA,EACF;AAGA,UAAQ,QAAQ,CAAC,WAAW;AAC1B,QAAI,OAAO,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 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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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,M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AAAC,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;",
6
6
  "names": ["path", "packageManager", "stripAnsi"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skuba",
3
- "version": "7.4.0-master-20240206223029",
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",
@@ -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
 
@@ -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
@@ -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
@@ -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
@@ -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
 
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 { 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;AAGf,qBAAoB;AACpB,mBAA4B;AAC5B,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,MA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