skuba 11.0.0-main-20250511022834 → 11.0.1-lint-subdir-20250515033605
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.
- package/jest/transform.js +5 -1
- package/lib/cli/adapter/prettier.js +7 -3
- package/lib/cli/adapter/prettier.js.map +2 -2
- package/lib/cli/configure/processing/configFile.d.ts +2 -2
- package/lib/cli/configure/processing/configFile.js +18 -21
- package/lib/cli/configure/processing/configFile.js.map +2 -2
- package/lib/cli/init/types.d.ts +3 -3
- package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +6 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +26 -22
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js +5 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/index.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.d.ts +2 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js +167 -0
- package/lib/cli/lint/internalLints/upgrade/patches/10.1.0/migrateNpmrcToPnpmWorkspace.js.map +7 -0
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js +0 -9
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/index.js.map +2 -2
- package/lib/utils/copy.js +1 -1
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/dir.d.ts +10 -0
- package/lib/utils/dir.js +74 -2
- package/lib/utils/dir.js.map +3 -3
- package/lib/utils/npmrc.d.ts +0 -1
- package/lib/utils/npmrc.js +0 -3
- package/lib/utils/npmrc.js.map +2 -2
- package/package.json +4 -4
- package/template/base/_.gitignore +2 -0
- package/template/base/_pnpm-workspace.yaml +10 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +2 -2
- package/template/express-rest-api/Dockerfile.dev-deps +2 -2
- package/template/greeter/.buildkite/pipeline.yml +2 -2
- package/template/greeter/Dockerfile +2 -2
- package/template/greeter/package.json +1 -1
- package/template/koa-rest-api/.buildkite/pipeline.yml +2 -2
- package/template/koa-rest-api/Dockerfile.dev-deps +2 -2
- package/template/koa-rest-api/package.json +1 -1
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +3 -3
- package/template/lambda-sqs-worker-cdk/Dockerfile +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +1 -1
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/_package.json +1 -1
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.d.ts +0 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js +0 -95
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js.map +0 -7
- package/template/base/_.npmrc +0 -9
package/jest/transform.js
CHANGED
|
@@ -38,7 +38,11 @@ const tsconfig = BROKEN_MODULE_RESOLUTIONS.has(
|
|
|
38
38
|
? { tsconfig: { moduleResolution: 'Node' } }
|
|
39
39
|
: undefined;
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Rewrite `ts-jest` transformations using our resolved `TS_JEST_PATH`.
|
|
43
|
+
*
|
|
44
|
+
* @type {import ('@jest/types').Config.InitialOptions['transform']}
|
|
45
|
+
*/
|
|
42
46
|
module.exports.transform = Object.fromEntries(
|
|
43
47
|
Object.entries(defaults.transform).map(([key, value]) => {
|
|
44
48
|
if (typeof value === 'string') {
|
|
@@ -109,10 +109,14 @@ const runPrettier = async (mode, logger, cwd = process.cwd()) => {
|
|
|
109
109
|
directory
|
|
110
110
|
);
|
|
111
111
|
logger.debug("Discovering files...");
|
|
112
|
-
const
|
|
113
|
-
".gitignore",
|
|
114
|
-
".prettierignore"
|
|
112
|
+
const ignoreFilepaths = await Promise.all([
|
|
113
|
+
(0, import_dir.locateNearestFile)({ cwd, filename: ".gitignore" }),
|
|
114
|
+
(0, import_dir.locateNearestFile)({ cwd, filename: ".prettierignore" })
|
|
115
115
|
]);
|
|
116
|
+
const ignoreFilenames = ignoreFilepaths.flatMap(
|
|
117
|
+
(filepath) => filepath ? import_path.default.relative(cwd, filepath) : []
|
|
118
|
+
);
|
|
119
|
+
const relativeFilepaths = await (0, import_dir.crawlDirectory)(directory, ignoreFilenames);
|
|
116
120
|
logger.debug(`Discovered ${(0, import_logging.pluralise)(relativeFilepaths.length, "file")}.`);
|
|
117
121
|
const result = {
|
|
118
122
|
count: relativeFilepaths.length,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/adapter/prettier.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport {\n type Options,\n type SupportLanguage,\n check,\n format,\n getSupportInfo,\n resolveConfig,\n} from 'prettier';\n\nimport { crawlDirectory } from '../../utils/dir';\nimport { type Logger, pluralise } from '../../utils/logging';\nimport { getConsumerManifest } from '../../utils/manifest';\nimport { formatPackage, parsePackage } from '../configure/processing/package';\n\nlet languages: SupportLanguage[] | undefined;\n\n/**\n * Infers a parser for the specified filepath.\n *\n * This is a cut-down version of Prettier's built-in function of the same name;\n * ours operates purely on the `filepath` string and does not perform file I/O.\n * Prettier's internal `getInterpreter` function can open a file to read the\n * shebang, and its file descriptor usage can throw warnings on worker threads:\n *\n * ```console\n * Warning: File descriptor 123 closed but not opened in unmanaged mode\n * at Object.closeSync (node:fs:530:11)\n * at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)\n * ...\n * ```\n *\n * References:\n *\n * - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167\n * - seek-oss/skuba#659\n */\nexport const inferParser = async (\n filepath: string,\n): Promise<string | undefined> => {\n const filename = path.basename(filepath).toLowerCase();\n\n languages ??= (await getSupportInfo()).languages;\n\n const firstLanguage = languages.find(\n (language) =>\n language.extensions?.some((extension) => filename.endsWith(extension)) ||\n language.filenames?.some((name) => name.toLowerCase() === filename),\n );\n\n return firstLanguage?.parsers[0];\n};\n\nconst isPackageJsonOk = async ({\n data,\n filepath,\n}: {\n data: string;\n filepath: string;\n}): Promise<boolean> => {\n if (path.basename(filepath) !== 'package.json') {\n return true;\n }\n\n try {\n const packageJson = parsePackage(data);\n\n return !packageJson || (await formatPackage(packageJson)) === data;\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n return true;\n};\n\ninterface File {\n data: string;\n options: Options;\n filepath: string;\n}\n\ninterface Result {\n count: number;\n errored: Array<{ err?: unknown; filepath: string }>;\n touched: string[];\n unparsed: string[];\n}\n\nexport const formatOrLintFile = async (\n { data, filepath, options }: File,\n mode: 'format' | 'lint',\n result: Result | null,\n): Promise<string | undefined> => {\n if (mode === 'lint') {\n let ok: boolean;\n try {\n ok =\n (await check(data, options)) &&\n (await isPackageJsonOk({ data, filepath }));\n } catch (err) {\n result?.errored.push({ err, filepath });\n return;\n }\n\n if (!ok) {\n result?.errored.push({ filepath });\n }\n\n return;\n }\n\n let formatted: string;\n try {\n formatted = await format(data, options);\n } catch (err) {\n result?.errored.push({ err, filepath });\n return;\n }\n\n // Perform additional formatting (i.e. sorting) on a `package.json` manifest.\n try {\n if (path.basename(filepath) === 'package.json') {\n const packageJson = parsePackage(formatted);\n if (packageJson) {\n formatted = await formatPackage(packageJson);\n }\n }\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n if (formatted === data) {\n return;\n }\n\n result?.touched.push(filepath);\n return formatted;\n};\n\nexport interface PrettierOutput {\n ok: boolean;\n result: Result;\n}\n\n/**\n * Formats/lints files with Prettier.\n *\n * Prettier doesn't provide a higher-level Node.js API that replicates the\n * behaviour of its CLI, so we have to plumb together its lower-level functions.\n * On the other hand, this affords more flexibility in how we track and report\n * on progress and results.\n */\nexport const runPrettier = async (\n mode: 'format' | 'lint',\n logger: Logger,\n cwd = process.cwd(),\n): Promise<PrettierOutput> => {\n logger.debug('Initialising Prettier...');\n\n const start = process.hrtime.bigint();\n\n const manifest = await getConsumerManifest(cwd);\n\n const directory = manifest ? path.dirname(manifest.path) : cwd;\n\n logger.debug(\n manifest ? 'Detected project root:' : 'Detected working directory:',\n directory,\n );\n\n logger.debug('Discovering files...');\n\n // Match Prettier's opinion of respecting `.gitignore`.\n // This avoids exhibiting different behaviour than a Prettier IDE integration,\n // though it may present headaches if `.gitignore` and `.prettierignore` rules\n // conflict.\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,sBAOO;AAEP,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport {\n type Options,\n type SupportLanguage,\n check,\n format,\n getSupportInfo,\n resolveConfig,\n} from 'prettier';\n\nimport { crawlDirectory, locateNearestFile } from '../../utils/dir';\nimport { type Logger, pluralise } from '../../utils/logging';\nimport { getConsumerManifest } from '../../utils/manifest';\nimport { formatPackage, parsePackage } from '../configure/processing/package';\n\nlet languages: SupportLanguage[] | undefined;\n\n/**\n * Infers a parser for the specified filepath.\n *\n * This is a cut-down version of Prettier's built-in function of the same name;\n * ours operates purely on the `filepath` string and does not perform file I/O.\n * Prettier's internal `getInterpreter` function can open a file to read the\n * shebang, and its file descriptor usage can throw warnings on worker threads:\n *\n * ```console\n * Warning: File descriptor 123 closed but not opened in unmanaged mode\n * at Object.closeSync (node:fs:530:11)\n * at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)\n * ...\n * ```\n *\n * References:\n *\n * - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167\n * - seek-oss/skuba#659\n */\nexport const inferParser = async (\n filepath: string,\n): Promise<string | undefined> => {\n const filename = path.basename(filepath).toLowerCase();\n\n languages ??= (await getSupportInfo()).languages;\n\n const firstLanguage = languages.find(\n (language) =>\n language.extensions?.some((extension) => filename.endsWith(extension)) ||\n language.filenames?.some((name) => name.toLowerCase() === filename),\n );\n\n return firstLanguage?.parsers[0];\n};\n\nconst isPackageJsonOk = async ({\n data,\n filepath,\n}: {\n data: string;\n filepath: string;\n}): Promise<boolean> => {\n if (path.basename(filepath) !== 'package.json') {\n return true;\n }\n\n try {\n const packageJson = parsePackage(data);\n\n return !packageJson || (await formatPackage(packageJson)) === data;\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n return true;\n};\n\ninterface File {\n data: string;\n options: Options;\n filepath: string;\n}\n\ninterface Result {\n count: number;\n errored: Array<{ err?: unknown; filepath: string }>;\n touched: string[];\n unparsed: string[];\n}\n\nexport const formatOrLintFile = async (\n { data, filepath, options }: File,\n mode: 'format' | 'lint',\n result: Result | null,\n): Promise<string | undefined> => {\n if (mode === 'lint') {\n let ok: boolean;\n try {\n ok =\n (await check(data, options)) &&\n (await isPackageJsonOk({ data, filepath }));\n } catch (err) {\n result?.errored.push({ err, filepath });\n return;\n }\n\n if (!ok) {\n result?.errored.push({ filepath });\n }\n\n return;\n }\n\n let formatted: string;\n try {\n formatted = await format(data, options);\n } catch (err) {\n result?.errored.push({ err, filepath });\n return;\n }\n\n // Perform additional formatting (i.e. sorting) on a `package.json` manifest.\n try {\n if (path.basename(filepath) === 'package.json') {\n const packageJson = parsePackage(formatted);\n if (packageJson) {\n formatted = await formatPackage(packageJson);\n }\n }\n } catch {\n // Be more lenient about our custom formatting and don't throw if it errors.\n }\n\n if (formatted === data) {\n return;\n }\n\n result?.touched.push(filepath);\n return formatted;\n};\n\nexport interface PrettierOutput {\n ok: boolean;\n result: Result;\n}\n\n/**\n * Formats/lints files with Prettier.\n *\n * Prettier doesn't provide a higher-level Node.js API that replicates the\n * behaviour of its CLI, so we have to plumb together its lower-level functions.\n * On the other hand, this affords more flexibility in how we track and report\n * on progress and results.\n */\nexport const runPrettier = async (\n mode: 'format' | 'lint',\n logger: Logger,\n cwd = process.cwd(),\n): Promise<PrettierOutput> => {\n logger.debug('Initialising Prettier...');\n\n const start = process.hrtime.bigint();\n\n const manifest = await getConsumerManifest(cwd);\n\n const directory = manifest ? path.dirname(manifest.path) : cwd;\n\n logger.debug(\n manifest ? 'Detected project root:' : 'Detected working directory:',\n directory,\n );\n\n logger.debug('Discovering files...');\n\n // Match Prettier's opinion of respecting `.gitignore`.\n // This avoids exhibiting different behaviour than a Prettier IDE integration,\n // though it may present headaches if `.gitignore` and `.prettierignore` rules\n // conflict.\n // TODO: should these bottom out at the project root?\n const ignoreFilepaths = await Promise.all([\n locateNearestFile({ cwd, filename: '.gitignore' }),\n locateNearestFile({ cwd, filename: '.prettierignore' }),\n ]);\n\n const ignoreFilenames = ignoreFilepaths.flatMap((filepath) =>\n filepath ? path.relative(cwd, filepath) : [],\n );\n\n const relativeFilepaths = await crawlDirectory(directory, ignoreFilenames);\n\n logger.debug(`Discovered ${pluralise(relativeFilepaths.length, 'file')}.`);\n\n const result: Result = {\n count: relativeFilepaths.length,\n errored: [],\n touched: [],\n unparsed: [],\n };\n\n logger.debug(mode === 'format' ? 'Formatting' : 'Linting', 'files...');\n\n for (const relativeFilepath of relativeFilepaths) {\n // Use relative paths to keep log output cleaner, particularly in the common\n // case where we are executing against the current working directory.\n const filepath = path.relative(\n process.cwd(),\n path.join(directory, relativeFilepath),\n );\n\n // Infer parser upfront so we can skip unsupported files.\n const parser = await inferParser(filepath);\n\n logger.debug(filepath);\n logger.debug(' parser:', parser ?? '-');\n\n if (!parser) {\n result.unparsed.push(filepath);\n continue;\n }\n\n const [config, data] = await Promise.all([\n resolveConfig(filepath),\n fs.promises.readFile(filepath, 'utf-8'),\n ]);\n\n const file: File = {\n data,\n filepath,\n options: { ...config, filepath },\n };\n\n const formatted = await formatOrLintFile(file, mode, result);\n\n if (typeof formatted === 'string') {\n await fs.promises.writeFile(filepath, formatted);\n }\n }\n\n const end = process.hrtime.bigint();\n\n logger.plain(\n `Processed ${pluralise(\n result.count - result.unparsed.length,\n 'file',\n )} in ${logger.timing(start, end)}.`,\n );\n\n if (result.touched.length) {\n logger.plain(`Formatted ${pluralise(result.touched.length, 'file')}:`);\n for (const filepath of result.touched) {\n logger.warn(filepath);\n }\n }\n\n if (result.errored.length) {\n logger.plain(`Flagged ${pluralise(result.errored.length, 'file')}:`);\n for (const { err, filepath } of result.errored) {\n logger.warn(\n filepath,\n ...(typeof err === 'string' || err instanceof Error\n ? [String(err)]\n : []),\n );\n }\n }\n\n return { ok: result.errored.length === 0, result };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,sBAOO;AAEP,iBAAkD;AAClD,qBAAuC;AACvC,sBAAoC;AACpC,qBAA4C;AAE5C,IAAI;AAsBG,MAAM,cAAc,OACzB,aACgC;AAChC,QAAM,WAAW,YAAAA,QAAK,SAAS,QAAQ,EAAE,YAAY;AAErD,iBAAe,UAAM,gCAAe,GAAG;AAEvC,QAAM,gBAAgB,UAAU;AAAA,IAC9B,CAAC,aACC,SAAS,YAAY,KAAK,CAAC,cAAc,SAAS,SAAS,SAAS,CAAC,KACrE,SAAS,WAAW,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,QAAQ;AAAA,EACtE;AAEA,SAAO,eAAe,QAAQ,CAAC;AACjC;AAEA,MAAM,kBAAkB,OAAO;AAAA,EAC7B;AAAA,EACA;AACF,MAGwB;AACtB,MAAI,YAAAA,QAAK,SAAS,QAAQ,MAAM,gBAAgB;AAC9C,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,kBAAc,6BAAa,IAAI;AAErC,WAAO,CAAC,eAAgB,UAAM,8BAAc,WAAW,MAAO;AAAA,EAChE,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAeO,MAAM,mBAAmB,OAC9B,EAAE,MAAM,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Aa;AAAA,MACX,OAAO,QAAQ,OAAO,SAAS;AAAA,MAC/B;AAAA,IACF,CAAC,OAAO,OAAO,OAAO,OAAO,GAAG,CAAC;AAAA,EACnC;AAEA,MAAI,OAAO,QAAQ,QAAQ;AACzB,WAAO,MAAM,iBAAa,0BAAU,OAAO,QAAQ,QAAQ,MAAM,CAAC,GAAG;AACrE,eAAW,YAAY,OAAO,SAAS;AACrC,aAAO,KAAK,QAAQ;AAAA,IACtB;AAAA,EACF;AAEA,MAAI,OAAO,QAAQ,QAAQ;AACzB,WAAO,MAAM,eAAW,0BAAU,OAAO,QAAQ,QAAQ,MAAM,CAAC,GAAG;AACnE,eAAW,EAAE,KAAK,SAAS,KAAK,OAAO,SAAS;AAC9C,aAAO;AAAA,QACL;AAAA,QACA,GAAI,OAAO,QAAQ,YAAY,eAAe,QAC1C,CAAC,OAAO,GAAG,CAAC,IACZ,CAAC;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,IAAI,OAAO,QAAQ,WAAW,GAAG,OAAO;AACnD;",
|
|
6
6
|
"names": ["path", "fs"]
|
|
7
7
|
}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* than `lib/`) but they generally represent the same _intent_.
|
|
6
6
|
*/
|
|
7
7
|
export declare const generateIgnoreFileSimpleVariants: (patterns: string[]) => Set<string>;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const mergeWithConfigFile: (rawTemplateFile: string, fileType?: "ignore" | "
|
|
8
|
+
export declare const replaceManagedSection: (input: string, template: string) => string;
|
|
9
|
+
export declare const mergeWithConfigFile: (rawTemplateFile: string, fileType?: "ignore" | "pnpm-workspace") => (rawInputFile?: string) => string;
|
|
@@ -19,8 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var configFile_exports = {};
|
|
20
20
|
__export(configFile_exports, {
|
|
21
21
|
generateIgnoreFileSimpleVariants: () => generateIgnoreFileSimpleVariants,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
mergeWithConfigFile: () => mergeWithConfigFile,
|
|
23
|
+
replaceManagedSection: () => replaceManagedSection
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(configFile_exports);
|
|
26
26
|
const OUTDATED_PATTERNS = ["node_modules_bak/", "tmp-*/"];
|
|
@@ -46,24 +46,18 @@ const generateIgnoreFileSimpleVariants = (patterns) => {
|
|
|
46
46
|
set.delete("");
|
|
47
47
|
return set;
|
|
48
48
|
};
|
|
49
|
-
const
|
|
50
|
-
const set = /* @__PURE__ */ new Set();
|
|
51
|
-
for (const pattern of patterns) {
|
|
52
|
-
set.add(pattern);
|
|
53
|
-
const match = /^(?<key>[^"=]+)="?(?<value>[^"=]+)"?$/.exec(pattern);
|
|
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
|
-
};
|
|
49
|
+
const replaceManagedSection = (input, template) => input.replace(/# managed by skuba[\s\S]*# end managed by skuba/, template);
|
|
64
50
|
const mergeWithConfigFile = (rawTemplateFile, fileType = "ignore") => {
|
|
65
51
|
const templateFile = rawTemplateFile.trim();
|
|
66
|
-
|
|
52
|
+
let generator;
|
|
53
|
+
switch (fileType) {
|
|
54
|
+
case "ignore":
|
|
55
|
+
generator = generateIgnoreFileSimpleVariants;
|
|
56
|
+
break;
|
|
57
|
+
case "pnpm-workspace":
|
|
58
|
+
generator = () => /* @__PURE__ */ new Set();
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
67
61
|
const templatePatterns = generator([
|
|
68
62
|
...OUTDATED_PATTERNS,
|
|
69
63
|
...templateFile.split("\n").map((line) => line.trim())
|
|
@@ -73,7 +67,10 @@ const mergeWithConfigFile = (rawTemplateFile, fileType = "ignore") => {
|
|
|
73
67
|
return `${templateFile}
|
|
74
68
|
`;
|
|
75
69
|
}
|
|
76
|
-
const replacedFile =
|
|
70
|
+
const replacedFile = replaceManagedSection(
|
|
71
|
+
rawInputFile.replace(/\r?\n/g, "\n"),
|
|
72
|
+
templateFile
|
|
73
|
+
);
|
|
77
74
|
if (replacedFile.includes(templateFile)) {
|
|
78
75
|
return replacedFile;
|
|
79
76
|
}
|
|
@@ -86,7 +83,7 @@ const mergeWithConfigFile = (rawTemplateFile, fileType = "ignore") => {
|
|
|
86
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
87
84
|
0 && (module.exports = {
|
|
88
85
|
generateIgnoreFileSimpleVariants,
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
mergeWithConfigFile,
|
|
87
|
+
replaceManagedSection
|
|
91
88
|
});
|
|
92
89
|
//# sourceMappingURL=configFile.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,MAAM,oBAAoB,CAAC,qBAAqB,QAAQ;AAExD,MAAM,YAAY;AAClB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AAQhB,MAAM,mCAAmC,CAAC,aAAuB;AACtE,QAAM,MAAM,oBAAI,IAAY;AAE5B,aAAW,WAAW,UAAU;AAC9B,UAAM,eAAe,QAAQ,QAAQ,WAAW,EAAE;AAClD,UAAM,WAAW,aACd,QAAQ,eAAe,EAAE,EACzB,QAAQ,gBAAgB,EAAE;AAE7B,QAAI,IAAI,OAAO;AACf,QAAI,IAAI,YAAY;AACpB,QAAI,IAAI,aAAa,QAAQ,eAAe,EAAE,CAAC;AAC/C,QAAI,IAAI,aAAa,QAAQ,gBAAgB,EAAE,CAAC;AAChD,QAAI,IAAI,QAAQ;AAEhB,QAAI,aAAa,IAAI;AACnB,UAAI,IAAI,IAAI,QAAQ,EAAE;AACtB,UAAI,IAAI,GAAG,QAAQ,GAAG;AACtB,UAAI,IAAI,IAAI,QAAQ,GAAG;AAAA,IACzB;AAAA,EACF;AAEA,MAAI,OAAO,EAAE;AAEb,SAAO;AACT;AAEO,MAAM,
|
|
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 replaceManagedSection = (input: string, template: string) =>\n input.replace(/# managed by skuba[\\s\\S]*# end managed by skuba/, template);\n\nexport const mergeWithConfigFile = (\n rawTemplateFile: string,\n fileType: 'ignore' | 'pnpm-workspace' = 'ignore',\n) => {\n const templateFile = rawTemplateFile.trim();\n\n let generator: (s: string[]) => Set<string>;\n\n switch (fileType) {\n case 'ignore':\n generator = generateIgnoreFileSimpleVariants;\n break;\n case 'pnpm-workspace':\n generator = () => new Set<string>();\n break;\n }\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 = replaceManagedSection(\n rawInputFile.replace(/\\r?\\n/g, '\\n'),\n templateFile,\n );\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;AAA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,eAAe;AAAA,MACnB,aAAa,QAAQ,UAAU,IAAI;AAAA,MACnC;AAAA,IACF;AAEA,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
6
|
"names": []
|
|
7
7
|
}
|
package/lib/cli/init/types.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare const initConfigInputSchema: z.ZodObject<{
|
|
|
54
54
|
};
|
|
55
55
|
}>;
|
|
56
56
|
export type InitConfig = z.infer<typeof initConfigSchema>;
|
|
57
|
-
declare const initConfigSchema: z.ZodObject<
|
|
57
|
+
declare const initConfigSchema: z.ZodObject<Omit<{
|
|
58
58
|
destinationDir: z.ZodString;
|
|
59
59
|
templateComplete: z.ZodBoolean;
|
|
60
60
|
templateData: z.ZodObject<{
|
|
@@ -74,7 +74,7 @@ declare const initConfigSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
74
74
|
defaultBranch: z.ZodString;
|
|
75
75
|
}, z.ZodString, "strip">>;
|
|
76
76
|
templateName: z.ZodString;
|
|
77
|
-
}, "templateData"
|
|
77
|
+
}, "templateData"> & {
|
|
78
78
|
templateData: z.ZodObject<{
|
|
79
79
|
ownerName: z.ZodString;
|
|
80
80
|
repoName: z.ZodString;
|
|
@@ -100,7 +100,7 @@ declare const initConfigSchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
|
|
|
100
100
|
entryPoint: z.ZodOptional<z.ZodString>;
|
|
101
101
|
packageManager: z.ZodDefault<z.ZodEnum<["pnpm", "yarn"]>>;
|
|
102
102
|
type: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"application">, z.ZodLiteral<"package">]>>;
|
|
103
|
-
}
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
104
|
packageManager: "yarn" | "pnpm";
|
|
105
105
|
templateName: string;
|
|
106
106
|
destinationDir: string;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Logger } from '../../../utils/logging';
|
|
2
2
|
import { type PackageManagerConfig } from '../../../utils/packageManager';
|
|
3
3
|
import type { InternalLintResult } from '../internal';
|
|
4
|
+
type ConditionOptions = {
|
|
5
|
+
packageManager: PackageManagerConfig;
|
|
6
|
+
isInWorkspaceRoot: boolean;
|
|
7
|
+
};
|
|
4
8
|
type RefreshableConfigFile = {
|
|
5
9
|
name: string;
|
|
6
|
-
type: 'ignore' | '
|
|
10
|
+
type: 'ignore' | 'pnpm-workspace';
|
|
7
11
|
additionalMapping?: (s: string, packageManager: PackageManagerConfig) => string;
|
|
8
|
-
if?: (
|
|
12
|
+
if?: (options: ConditionOptions) => boolean;
|
|
9
13
|
};
|
|
10
14
|
export declare const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[];
|
|
11
15
|
export declare const refreshConfigFiles: (mode: "format" | "lint", logger: Logger) => Promise<{
|
|
@@ -37,43 +37,44 @@ var import_path = __toESM(require("path"));
|
|
|
37
37
|
var import_util = require("util");
|
|
38
38
|
var import_fs_extra = require("fs-extra");
|
|
39
39
|
var import__ = require("../../..");
|
|
40
|
-
var
|
|
40
|
+
var import_dir = require("../../../utils/dir");
|
|
41
41
|
var import_packageManager = require("../../../utils/packageManager");
|
|
42
42
|
var import_template = require("../../../utils/template");
|
|
43
43
|
var import_package = require("../../configure/analysis/package");
|
|
44
44
|
var import_project = require("../../configure/analysis/project");
|
|
45
45
|
var import_configFile = require("../../configure/processing/configFile");
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
const OLD_IGNORE_WARNING = `# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.
|
|
47
|
+
# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.
|
|
48
|
+
# You can use \`skuba format\` to generate the file or otherwise commit an empty file.
|
|
49
|
+
# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.
|
|
50
|
+
.npmrc
|
|
51
|
+
`;
|
|
52
|
+
const removeOldWarning = (contents) => contents.includes(OLD_IGNORE_WARNING) ? `${contents.replace(OLD_IGNORE_WARNING, "").trim()}
|
|
53
|
+
` : contents;
|
|
54
54
|
const REFRESHABLE_CONFIG_FILES = [
|
|
55
55
|
{
|
|
56
56
|
name: ".gitignore",
|
|
57
57
|
type: "ignore",
|
|
58
|
-
additionalMapping:
|
|
58
|
+
additionalMapping: removeOldWarning
|
|
59
59
|
},
|
|
60
60
|
{ name: ".prettierignore", type: "ignore" },
|
|
61
61
|
{
|
|
62
|
-
name: ".
|
|
63
|
-
type: "
|
|
64
|
-
|
|
65
|
-
if: (packageManager) => packageManager.command === "pnpm"
|
|
62
|
+
name: "pnpm-workspace.yaml",
|
|
63
|
+
type: "pnpm-workspace",
|
|
64
|
+
if: ({ packageManager, isInWorkspaceRoot }) => isInWorkspaceRoot && packageManager.command === "pnpm"
|
|
66
65
|
},
|
|
67
66
|
{
|
|
68
67
|
name: ".dockerignore",
|
|
69
68
|
type: "ignore",
|
|
70
|
-
additionalMapping:
|
|
69
|
+
additionalMapping: removeOldWarning
|
|
71
70
|
}
|
|
72
71
|
];
|
|
73
72
|
const refreshConfigFiles = async (mode, logger) => {
|
|
74
|
-
const [manifest, gitRoot] = await Promise.all([
|
|
73
|
+
const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([
|
|
75
74
|
(0, import_package.getDestinationManifest)(),
|
|
76
|
-
import__.Git.findRoot({ dir: process.cwd() })
|
|
75
|
+
import__.Git.findRoot({ dir: process.cwd() }),
|
|
76
|
+
(0, import_dir.findWorkspaceRoot)(),
|
|
77
|
+
(0, import_dir.findCurrentWorkspaceProjectRoot)()
|
|
77
78
|
]);
|
|
78
79
|
const destinationRoot = import_path.default.dirname(manifest.path);
|
|
79
80
|
const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
|
|
@@ -82,8 +83,8 @@ const refreshConfigFiles = async (mode, logger) => {
|
|
|
82
83
|
type: fileType,
|
|
83
84
|
additionalMapping = (s) => s,
|
|
84
85
|
if: condition = () => true
|
|
85
|
-
},
|
|
86
|
-
if (!condition(
|
|
86
|
+
}, conditionOptions) => {
|
|
87
|
+
if (!condition(conditionOptions)) {
|
|
87
88
|
return { needsChange: false };
|
|
88
89
|
}
|
|
89
90
|
const [inputFile, templateFile, isGitIgnored] = await Promise.all([
|
|
@@ -99,7 +100,7 @@ const refreshConfigFiles = async (mode, logger) => {
|
|
|
99
100
|
}
|
|
100
101
|
const data = additionalMapping(
|
|
101
102
|
inputFile ? (0, import_configFile.mergeWithConfigFile)(templateFile, fileType)(inputFile) : templateFile,
|
|
102
|
-
|
|
103
|
+
packageManager
|
|
103
104
|
);
|
|
104
105
|
const filepath = import_path.default.join(destinationRoot, filename);
|
|
105
106
|
if (mode === "format") {
|
|
@@ -119,7 +120,7 @@ const refreshConfigFiles = async (mode, logger) => {
|
|
|
119
120
|
msg: `The ${logger.bold(
|
|
120
121
|
filename
|
|
121
122
|
)} file is out of date. Run \`${logger.bold(
|
|
122
|
-
|
|
123
|
+
packageManager.print.exec,
|
|
123
124
|
"skuba",
|
|
124
125
|
"format"
|
|
125
126
|
)}\` to update it.`,
|
|
@@ -131,7 +132,10 @@ const refreshConfigFiles = async (mode, logger) => {
|
|
|
131
132
|
const packageManager = await (0, import_packageManager.detectPackageManager)(destinationRoot);
|
|
132
133
|
const results = await Promise.all(
|
|
133
134
|
REFRESHABLE_CONFIG_FILES.map(
|
|
134
|
-
(conf) => refreshConfigFile(conf,
|
|
135
|
+
(conf) => refreshConfigFile(conf, {
|
|
136
|
+
packageManager,
|
|
137
|
+
isInWorkspaceRoot: workspaceRoot === currentWorkspaceProjectRoot
|
|
138
|
+
})
|
|
135
139
|
)
|
|
136
140
|
);
|
|
137
141
|
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, stripVTControlCharacters as stripAnsi } from 'util';\n\nimport { writeFile } from 'fs-extra';\n\nimport { Git } from '../../..';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA+D;AAE/D,sBAA0B;AAE1B,eAAoB;
|
|
6
|
-
"names": ["path", "
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect, stripVTControlCharacters as stripAnsi } from 'util';\n\nimport { writeFile } from 'fs-extra';\n\nimport { Git } from '../../..';\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../utils/dir';\nimport type { Logger } from '../../../utils/logging';\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\ntype ConditionOptions = {\n packageManager: PackageManagerConfig;\n isInWorkspaceRoot: boolean;\n};\n\ntype RefreshableConfigFile = {\n name: string;\n type: 'ignore' | 'pnpm-workspace';\n additionalMapping?: (\n s: string,\n packageManager: PackageManagerConfig,\n ) => string;\n if?: (options: ConditionOptions) => boolean;\n};\n\nconst OLD_IGNORE_WARNING = `# 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 removeOldWarning = (contents: string) =>\n contents.includes(OLD_IGNORE_WARNING)\n ? `${contents.replace(OLD_IGNORE_WARNING, '').trim()}\\n`\n : contents;\n\nexport const REFRESHABLE_CONFIG_FILES: RefreshableConfigFile[] = [\n {\n name: '.gitignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n { name: '.prettierignore', type: 'ignore' },\n {\n name: 'pnpm-workspace.yaml',\n type: 'pnpm-workspace',\n if: ({ packageManager, isInWorkspaceRoot }) =>\n isInWorkspaceRoot && packageManager.command === 'pnpm',\n },\n {\n name: '.dockerignore',\n type: 'ignore',\n additionalMapping: removeOldWarning,\n },\n];\n\nexport const refreshConfigFiles = async (\n mode: 'format' | 'lint',\n logger: Logger,\n) => {\n const [manifest, gitRoot, workspaceRoot, currentWorkspaceProjectRoot] =\n await Promise.all([\n getDestinationManifest(),\n Git.findRoot({ dir: process.cwd() }),\n findWorkspaceRoot(),\n findCurrentWorkspaceProjectRoot(),\n ]);\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 conditionOptions: ConditionOptions,\n ) => {\n if (!condition(conditionOptions)) {\n return { needsChange: false };\n }\n\n const [inputFile, templateFile, isGitIgnored] = await Promise.all([\n readDestinationFile(filename),\n readBaseTemplateFile(`_${filename}`),\n gitRoot\n ? Git.isFileGitIgnored({\n gitRoot,\n absolutePath: path.join(destinationRoot, filename),\n })\n : false,\n ]);\n\n // If the file is gitignored and doesn't exist, don't make it\n if (inputFile === undefined && isGitIgnored) {\n return { needsChange: false };\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.print.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, {\n packageManager,\n isInWorkspaceRoot: workspaceRoot === currentWorkspaceProjectRoot,\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);\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,kBAA+D;AAE/D,sBAA0B;AAE1B,eAAoB;AACpB,iBAGO;AAEP,4BAGO;A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AAC;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,YAAAC,0BAAU,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
|
+
"names": ["path", "stripAnsi"]
|
|
7
7
|
}
|
|
@@ -21,11 +21,16 @@ __export(__exports, {
|
|
|
21
21
|
patches: () => patches
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(__exports);
|
|
24
|
+
var import_migrateNpmrcToPnpmWorkspace = require("./migrateNpmrcToPnpmWorkspace");
|
|
24
25
|
var import_stopBundlingInCDKTests = require("./stopBundlingInCDKTests");
|
|
25
26
|
const patches = [
|
|
26
27
|
{
|
|
27
28
|
apply: import_stopBundlingInCDKTests.tryStopBundlingInCDKTests,
|
|
28
29
|
description: "Stop bundling inside CDK unit tests"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
apply: import_migrateNpmrcToPnpmWorkspace.tryMigrateNpmrcToPnpmWorkspace,
|
|
33
|
+
description: "Move .npmrc config to pnpm-workspace.yaml"
|
|
29
34
|
}
|
|
30
35
|
];
|
|
31
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/lint/internalLints/upgrade/patches/10.1.0/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryStopBundlingInCDKTests } from './stopBundlingInCDKTests';\n\nexport const patches: Patches = [\n {\n apply: tryStopBundlingInCDKTests,\n description: 'Stop bundling inside CDK unit tests',\n },\n];\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oCAA0C;AAEnC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../..';\n\nimport { tryMigrateNpmrcToPnpmWorkspace } from './migrateNpmrcToPnpmWorkspace';\nimport { tryStopBundlingInCDKTests } from './stopBundlingInCDKTests';\n\nexport const patches: Patches = [\n {\n apply: tryStopBundlingInCDKTests,\n description: 'Stop bundling inside CDK unit tests',\n },\n {\n apply: tryMigrateNpmrcToPnpmWorkspace,\n description: 'Move .npmrc config to pnpm-workspace.yaml',\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yCAA+C;AAC/C,oCAA0C;AAEnC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var migrateNpmrcToPnpmWorkspace_exports = {};
|
|
20
|
+
__export(migrateNpmrcToPnpmWorkspace_exports, {
|
|
21
|
+
tryMigrateNpmrcToPnpmWorkspace: () => tryMigrateNpmrcToPnpmWorkspace
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(migrateNpmrcToPnpmWorkspace_exports);
|
|
24
|
+
var import_util = require("util");
|
|
25
|
+
var import_fast_glob = require("fast-glob");
|
|
26
|
+
var import_fs_extra = require("fs-extra");
|
|
27
|
+
var import_dir = require("../../../../../../utils/dir");
|
|
28
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
29
|
+
var import_npmrc = require("../../../../../../utils/npmrc");
|
|
30
|
+
var import_configFile = require("../../../../../configure/processing/configFile");
|
|
31
|
+
const NPMRC = ".npmrc";
|
|
32
|
+
const checkFileExists = async (filePath) => {
|
|
33
|
+
try {
|
|
34
|
+
await import_fs_extra.promises.access(filePath);
|
|
35
|
+
return true;
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const migrateCustomNpmrcSettings = async () => {
|
|
41
|
+
const contents = await import_fs_extra.promises.readFile(NPMRC, "utf-8");
|
|
42
|
+
const remainderLines = (0, import_configFile.replaceManagedSection)(contents, "").split("\n").map((line) => line.trim()).filter((line) => line.length > 0).filter((line) => !line.startsWith("#")).filter((line) => !(0, import_npmrc.hasNpmrcSecret)(line));
|
|
43
|
+
if (remainderLines.length === 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const pnpmWorkspaceFile = "pnpm-workspace.yaml";
|
|
47
|
+
const pnpmWorkspaceExists = await checkFileExists(pnpmWorkspaceFile);
|
|
48
|
+
if (!pnpmWorkspaceExists) {
|
|
49
|
+
await import_fs_extra.promises.writeFile(pnpmWorkspaceFile, "");
|
|
50
|
+
}
|
|
51
|
+
const pnpmWorkspaceContents = await import_fs_extra.promises.readFile(pnpmWorkspaceFile, "utf-8");
|
|
52
|
+
const commentedLines = remainderLines.map((line) => `# ${line}`).join("\n");
|
|
53
|
+
const newContents = `# TODO: Translate these settings to the required format for pnpm-workspace.yaml.
|
|
54
|
+
# skuba moved these from .npmrc, but doesn't know what they mean.
|
|
55
|
+
# See: https://pnpm.io/settings
|
|
56
|
+
#
|
|
57
|
+
${commentedLines}
|
|
58
|
+
|
|
59
|
+
${pnpmWorkspaceContents}`;
|
|
60
|
+
await import_fs_extra.promises.writeFile(pnpmWorkspaceFile, newContents);
|
|
61
|
+
};
|
|
62
|
+
const fixDockerfiles = async () => {
|
|
63
|
+
const fileNames = await (0, import_fast_glob.glob)(["**/Dockerfile*"]);
|
|
64
|
+
await Promise.all(
|
|
65
|
+
fileNames.map(async (fileName) => {
|
|
66
|
+
const contents = await import_fs_extra.promises.readFile(fileName, "utf8");
|
|
67
|
+
const patched = contents.replaceAll(
|
|
68
|
+
"--mount=type=bind,source=.npmrc,target=.npmrc",
|
|
69
|
+
"--mount=type=bind,source=pnpm-workspace.yaml,target=pnpm-workspace.yaml"
|
|
70
|
+
);
|
|
71
|
+
if (patched !== contents) {
|
|
72
|
+
await import_fs_extra.promises.writeFile(fileName, patched);
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
const fixBuildkitePipelines = async () => {
|
|
78
|
+
const fileNames = await (0, import_fast_glob.glob)(["**/.buildkite/**.{yml,yaml}"]);
|
|
79
|
+
await Promise.all(
|
|
80
|
+
fileNames.map(async (fileName) => {
|
|
81
|
+
const contents = await import_fs_extra.promises.readFile(fileName, "utf8");
|
|
82
|
+
const patched = contents.replace(
|
|
83
|
+
/(cache-on:[\s\S]*?)([ \t]+-[ \t]+\.npmrc)([\s\S]*?)(?=\n[ \t]*\S|$)/g,
|
|
84
|
+
(_, before, npmrcLine, after) => before + npmrcLine.replace(".npmrc", "pnpm-workspace.yaml") + after
|
|
85
|
+
);
|
|
86
|
+
if (patched !== contents) {
|
|
87
|
+
await import_fs_extra.promises.writeFile(fileName, patched);
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
const forceUpgradeToPnpm10 = async () => {
|
|
93
|
+
const fileNames = await (0, import_fast_glob.glob)(["**/package.json"]);
|
|
94
|
+
await Promise.all(
|
|
95
|
+
fileNames.map(async (fileName) => {
|
|
96
|
+
const contents = await import_fs_extra.promises.readFile(fileName, "utf8");
|
|
97
|
+
const packageManagerMatch = /"packageManager"\s*:\s*"pnpm@([^"]+)"/.exec(
|
|
98
|
+
contents
|
|
99
|
+
);
|
|
100
|
+
if (!packageManagerMatch) return;
|
|
101
|
+
const currentVersion = packageManagerMatch[1] ?? "";
|
|
102
|
+
const majorVersion = parseInt(currentVersion.split(".")?.[0] ?? "0", 10);
|
|
103
|
+
if (!isNaN(majorVersion) && majorVersion < 10) {
|
|
104
|
+
const patched = contents.replace(
|
|
105
|
+
/"packageManager"(\s*):(\s*)"pnpm@[^"]+"/,
|
|
106
|
+
'"packageManager"$1:$2"pnpm@10.8.1"'
|
|
107
|
+
);
|
|
108
|
+
await import_fs_extra.promises.writeFile(fileName, patched);
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
const migrateNpmrcToPnpmWorkspace = async ({
|
|
114
|
+
mode,
|
|
115
|
+
packageManager
|
|
116
|
+
}) => {
|
|
117
|
+
if (packageManager.command !== "pnpm") {
|
|
118
|
+
return {
|
|
119
|
+
result: "skip",
|
|
120
|
+
reason: "not using pnpm"
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const [workspaceRoot, currentWorkspaceProjectRoot] = await Promise.all([
|
|
124
|
+
(0, import_dir.findWorkspaceRoot)(),
|
|
125
|
+
(0, import_dir.findCurrentWorkspaceProjectRoot)()
|
|
126
|
+
]);
|
|
127
|
+
if (workspaceRoot !== currentWorkspaceProjectRoot) {
|
|
128
|
+
return {
|
|
129
|
+
result: "skip",
|
|
130
|
+
reason: "not running in the workspace root"
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const npmrcExists = await checkFileExists(NPMRC);
|
|
134
|
+
if (!npmrcExists) {
|
|
135
|
+
return {
|
|
136
|
+
result: "skip",
|
|
137
|
+
reason: "no .npmrc found"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (mode === "lint") {
|
|
141
|
+
return {
|
|
142
|
+
result: "apply"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
await Promise.all([
|
|
146
|
+
migrateCustomNpmrcSettings(),
|
|
147
|
+
fixDockerfiles(),
|
|
148
|
+
fixBuildkitePipelines(),
|
|
149
|
+
forceUpgradeToPnpm10()
|
|
150
|
+
]);
|
|
151
|
+
await import_fs_extra.promises.rm(NPMRC);
|
|
152
|
+
return { result: "apply" };
|
|
153
|
+
};
|
|
154
|
+
const tryMigrateNpmrcToPnpmWorkspace = async (config) => {
|
|
155
|
+
try {
|
|
156
|
+
return await migrateNpmrcToPnpmWorkspace(config);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
import_logging.log.warn("Failed to migrate .npmrc to pnpm-workspace.yaml");
|
|
159
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
160
|
+
return { result: "skip", reason: "due to an error" };
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
tryMigrateNpmrcToPnpmWorkspace
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=migrateNpmrcToPnpmWorkspace.js.map
|