skuba 14.0.0-rfc-pnpm-config-skuba-20260107235318 → 14.0.0-test-private-templates-20260107032413
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/lib/cli/configure/processing/configFile.d.ts +1 -1
- package/lib/cli/configure/processing/configFile.js +51 -6
- package/lib/cli/configure/processing/configFile.js.map +2 -2
- package/lib/cli/init/getConfig.js +11 -2
- package/lib/cli/init/getConfig.js.map +2 -2
- package/lib/cli/init/git.d.ts +1 -0
- package/lib/cli/init/git.js +37 -0
- package/lib/cli/init/git.js.map +2 -2
- package/lib/cli/init/index.js +2 -15
- package/lib/cli/init/index.js.map +3 -3
- package/lib/cli/init/prompts.d.ts +2 -1
- package/lib/cli/init/prompts.js +6 -0
- package/lib/cli/init/prompts.js.map +2 -2
- package/lib/cli/lint/internalLints/refreshConfigFiles.d.ts +1 -1
- package/lib/cli/lint/internalLints/refreshConfigFiles.js +11 -3
- package/lib/cli/lint/internalLints/refreshConfigFiles.js.map +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js +0 -5
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/index.js.map +2 -2
- package/lib/utils/template.d.ts +1 -1
- package/lib/utils/template.js +5 -1
- package/lib/utils/template.js.map +2 -2
- package/package.json +4 -5
- package/template/base/_pnpm-workspace.yaml +24 -0
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/package.json +3 -3
- package/template/koa-rest-api/package.json +1 -1
- package/template/lambda-sqs-worker-cdk/package.json +3 -3
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/_package.json +1 -1
- package/lib/cli/init/installPnpmPlugin.d.ts +0 -2
- package/lib/cli/init/installPnpmPlugin.js +0 -34
- package/lib/cli/init/installPnpmPlugin.js.map +0 -7
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.d.ts +0 -3
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.js +0 -134
- package/lib/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.js.map +0 -7
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const generateIgnoreFileSimpleVariants: (patterns: string[]) => Set<string>;
|
|
8
8
|
export declare const replaceManagedSection: (input: string, template: string) => string;
|
|
9
|
-
export declare const mergeWithConfigFile: (rawTemplateFile: string, fileType?: "ignore") => (rawInputFile?: string) => string;
|
|
9
|
+
export declare const mergeWithConfigFile: (rawTemplateFile: string, fileType?: "ignore" | "pnpm-workspace", packageJson?: string) => (rawInputFile?: string) => string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var configFile_exports = {};
|
|
20
30
|
__export(configFile_exports, {
|
|
@@ -23,6 +33,7 @@ __export(configFile_exports, {
|
|
|
23
33
|
replaceManagedSection: () => replaceManagedSection
|
|
24
34
|
});
|
|
25
35
|
module.exports = __toCommonJS(configFile_exports);
|
|
36
|
+
var z = __toESM(require("zod"));
|
|
26
37
|
const OUTDATED_PATTERNS = ["node_modules_bak/", "tmp-*/"];
|
|
27
38
|
const ASTERISKS = /\*/g;
|
|
28
39
|
const LEADING_SLASH = /^\//;
|
|
@@ -46,19 +57,53 @@ const generateIgnoreFileSimpleVariants = (patterns) => {
|
|
|
46
57
|
set.delete("");
|
|
47
58
|
return set;
|
|
48
59
|
};
|
|
60
|
+
const amendPnpmWorkspaceTemplate = (templateFile, packageJson) => {
|
|
61
|
+
if (!packageJson) {
|
|
62
|
+
return templateFile;
|
|
63
|
+
}
|
|
64
|
+
let rawJSON;
|
|
65
|
+
try {
|
|
66
|
+
rawJSON = JSON.parse(packageJson);
|
|
67
|
+
} catch {
|
|
68
|
+
throw new Error("package.json is not valid JSON");
|
|
69
|
+
}
|
|
70
|
+
const parsed = z.object({
|
|
71
|
+
minimumReleaseAgeExcludeOverload: z.array(z.string()).optional()
|
|
72
|
+
}).safeParse(rawJSON);
|
|
73
|
+
const excludes = parsed.data?.minimumReleaseAgeExcludeOverload;
|
|
74
|
+
if (!excludes || Array.isArray(excludes) === false || excludes.some((e) => typeof e !== "string")) {
|
|
75
|
+
return templateFile;
|
|
76
|
+
}
|
|
77
|
+
const targetKey = "minimumReleaseAgeExclude:";
|
|
78
|
+
const index = templateFile.indexOf(targetKey);
|
|
79
|
+
if (index === -1) {
|
|
80
|
+
return templateFile;
|
|
81
|
+
}
|
|
82
|
+
const beforeKey = templateFile.substring(0, index);
|
|
83
|
+
const afterKey = templateFile.substring(index + targetKey.length);
|
|
84
|
+
const excludeLines = excludes.map((exclude) => ` - '${exclude}'`).join("\n");
|
|
85
|
+
return `${beforeKey + targetKey}
|
|
86
|
+
${excludeLines}${afterKey}`;
|
|
87
|
+
};
|
|
49
88
|
const replaceManagedSection = (input, template) => input.replace(/# managed by skuba[\s\S]*# end managed by skuba/, template);
|
|
50
|
-
const mergeWithConfigFile = (rawTemplateFile, fileType = "ignore") => {
|
|
51
|
-
const templateFile = rawTemplateFile.trim();
|
|
89
|
+
const mergeWithConfigFile = (rawTemplateFile, fileType = "ignore", packageJson) => {
|
|
90
|
+
const templateFile = fileType === "pnpm-workspace" ? amendPnpmWorkspaceTemplate(rawTemplateFile.trim(), packageJson) : rawTemplateFile.trim();
|
|
52
91
|
let generator;
|
|
53
92
|
switch (fileType) {
|
|
54
93
|
case "ignore":
|
|
55
94
|
generator = generateIgnoreFileSimpleVariants;
|
|
56
95
|
break;
|
|
96
|
+
case "pnpm-workspace":
|
|
97
|
+
generator = () => /* @__PURE__ */ new Set();
|
|
98
|
+
break;
|
|
57
99
|
}
|
|
58
|
-
const templatePatterns = generator(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
100
|
+
const templatePatterns = generator(
|
|
101
|
+
[
|
|
102
|
+
...OUTDATED_PATTERNS,
|
|
103
|
+
...templateFile.split("\n").map((line) => line.trim())
|
|
104
|
+
],
|
|
105
|
+
packageJson
|
|
106
|
+
);
|
|
62
107
|
return (rawInputFile) => {
|
|
63
108
|
if (rawInputFile === void 0) {
|
|
64
109
|
return `${templateFile}
|
|
@@ -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 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' = 'ignore',\n) => {\n const templateFile
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\n\n/**\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\nconst amendPnpmWorkspaceTemplate = (\n templateFile: string,\n packageJson?: string,\n) => {\n if (!packageJson) {\n return templateFile;\n }\n let rawJSON;\n try {\n rawJSON = JSON.parse(packageJson) as unknown;\n } catch {\n throw new Error('package.json is not valid JSON');\n }\n const parsed = z\n .object({\n minimumReleaseAgeExcludeOverload: z.array(z.string()).optional(),\n })\n .safeParse(rawJSON);\n\n const excludes = parsed.data?.minimumReleaseAgeExcludeOverload;\n if (\n !excludes ||\n Array.isArray(excludes) === false ||\n excludes.some((e) => typeof e !== 'string')\n ) {\n return templateFile;\n }\n\n const targetKey = 'minimumReleaseAgeExclude:';\n const index = templateFile.indexOf(targetKey);\n\n if (index === -1) {\n return templateFile;\n }\n\n const beforeKey = templateFile.substring(0, index);\n const afterKey = templateFile.substring(index + targetKey.length);\n const excludeLines = excludes.map((exclude) => ` - '${exclude}'`).join('\\n');\n\n return `${beforeKey + targetKey}\\n${excludeLines}${afterKey}`;\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 packageJson?: string,\n) => {\n const templateFile =\n fileType === 'pnpm-workspace'\n ? amendPnpmWorkspaceTemplate(rawTemplateFile.trim(), packageJson)\n : rawTemplateFile.trim();\n\n let generator: (s: string[], packageJson?: 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 [\n ...OUTDATED_PATTERNS,\n ...templateFile.split('\\n').map((line) => line.trim()),\n ],\n packageJson,\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;AAAA;AAAA;AAAA;AAAA;AAAA,QAAmB;AAMnB,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;AAEA,MAAM,6BAA6B,CACjC,cACA,gBACG;AACH,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT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IACA;AAAA,EACF;AAEA,SAAO,CAAC,iBAA0B;AAChC,QAAI,iBAAiB,QAAW;AAC9B,aAAO,GAAG,YAAY;AAAA;AAAA,IACxB;AAEA,UAAM,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
|
}
|
|
@@ -89,10 +89,15 @@ const createDirectory = async (dir) => {
|
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
const cloneTemplate = async (templateName, destinationDir) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const isGitHubTemplate = templateName.startsWith("github:");
|
|
93
|
+
const isPrivateSeekTemplate = templateName.startsWith("seek:");
|
|
94
|
+
const isCustomTemplate = isGitHubTemplate || isPrivateSeekTemplate;
|
|
95
|
+
if (isGitHubTemplate) {
|
|
94
96
|
const gitHubPath = templateName.slice("github:".length);
|
|
95
97
|
await (0, import_git.downloadGitHubTemplate)(gitHubPath, destinationDir);
|
|
98
|
+
} else if (isPrivateSeekTemplate) {
|
|
99
|
+
const privateName = templateName.slice("seek:".length);
|
|
100
|
+
await (0, import_git.downloadPrivateTemplate)(privateName, destinationDir);
|
|
96
101
|
} else {
|
|
97
102
|
const templateDir = import_path.default.join(import_template.TEMPLATE_DIR, templateName);
|
|
98
103
|
await (0, import_copy.copyFiles)({
|
|
@@ -126,6 +131,10 @@ const selectTemplateName = async () => {
|
|
|
126
131
|
const gitHubPath = await (0, import_prompts2.getGitPath)();
|
|
127
132
|
return `github:${gitHubPath}`;
|
|
128
133
|
}
|
|
134
|
+
if (templateSelection === "seek \u2192") {
|
|
135
|
+
const privateName = await (0, import_prompts2.getPrivateTemplateName)();
|
|
136
|
+
return `seek:${privateName}`;
|
|
137
|
+
}
|
|
129
138
|
return templateSelection;
|
|
130
139
|
};
|
|
131
140
|
const generatePlaceholders = (choices) => Object.fromEntries(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/getConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import { styleText } from 'node:util';\nimport path from 'path';\n\nimport { input } from '@inquirer/prompts';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy.js';\nimport { isErrorWithCode } from '../../utils/error.js';\nimport { log } from '../../utils/logging.js';\nimport {\n DEFAULT_PACKAGE_MANAGER,\n configForPackageManager,\n} from '../../utils/packageManager.js';\nimport { getRandomPort } from '../../utils/port.js';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template.js';\n\nimport { downloadGitHubTemplate } from './git.js';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n type Choice,\n getGitPath,\n getTemplateName,\n shouldContinue,\n} from './prompts.js';\nimport { type InitConfig, initConfigInputSchema } from './types.js';\n\nexport const runForm = async <T = Record<string, string>>(props: {\n choices: readonly Choice[];\n message: string;\n name: string;\n}): Promise<T> => {\n const { message } = props;\n log.plain(message);\n\n const result: Record<string, string> = {};\n\n for (const choice of props.choices) {\n const inputValue = await input({\n message: choice.message,\n default: choice.initial,\n validate: async (inputText: string) => {\n if (\n !inputText ||\n inputText === '' ||\n (inputText === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(inputText) ?? true;\n },\n });\n\n result[choice.name] = inputValue;\n }\n\n return result as T;\n};\n\nconst confirmShouldContinue = async (choices: readonly Choice[]) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await shouldContinue();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (\n templateName: string,\n destinationDir: string,\n): Promise<TemplateConfig> => {\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B;AAC1B,kBAAiB;AAEjB,qBAAsB;AACtB,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,4BAGO;AACP,kBAA8B;AAC9B,sBAKO;AAEP,
|
|
4
|
+
"sourcesContent": ["import { styleText } from 'node:util';\nimport path from 'path';\n\nimport { input } from '@inquirer/prompts';\nimport fs from 'fs-extra';\n\nimport { copyFiles } from '../../utils/copy.js';\nimport { isErrorWithCode } from '../../utils/error.js';\nimport { log } from '../../utils/logging.js';\nimport {\n DEFAULT_PACKAGE_MANAGER,\n configForPackageManager,\n} from '../../utils/packageManager.js';\nimport { getRandomPort } from '../../utils/port.js';\nimport {\n TEMPLATE_CONFIG_FILENAME,\n TEMPLATE_DIR,\n type TemplateConfig,\n templateConfigSchema,\n} from '../../utils/template.js';\n\nimport { downloadGitHubTemplate, downloadPrivateTemplate } from './git.js';\nimport {\n BASE_PROMPT_PROPS,\n type BaseFields,\n type Choice,\n getGitPath,\n getPrivateTemplateName,\n getTemplateName,\n shouldContinue,\n} from './prompts.js';\nimport { type InitConfig, initConfigInputSchema } from './types.js';\n\nexport const runForm = async <T = Record<string, string>>(props: {\n choices: readonly Choice[];\n message: string;\n name: string;\n}): Promise<T> => {\n const { message } = props;\n log.plain(message);\n\n const result: Record<string, string> = {};\n\n for (const choice of props.choices) {\n const inputValue = await input({\n message: choice.message,\n default: choice.initial,\n validate: async (inputText: string) => {\n if (\n !inputText ||\n inputText === '' ||\n (inputText === choice.initial && !choice.allowInitial)\n ) {\n return 'Form is not complete';\n }\n\n return choice.validate?.(inputText) ?? true;\n },\n });\n\n result[choice.name] = inputValue;\n }\n\n return result as T;\n};\n\nconst confirmShouldContinue = async (choices: readonly Choice[]) => {\n const fieldsList = choices.map((choice) => choice.message);\n\n log.newline();\n log.plain('This template uses the following information:');\n log.newline();\n fieldsList.forEach((message) => log.subtle(`- ${message}`));\n\n log.newline();\n const result = await shouldContinue();\n\n return result === 'yes';\n};\n\nconst createDirectory = async (dir: string) => {\n try {\n await fs.promises.mkdir(dir);\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n log.err(`The directory '${dir}' already exists.`);\n process.exit(1);\n }\n\n throw err;\n }\n};\n\nconst cloneTemplate = async (\n templateName: string,\n destinationDir: string,\n): Promise<TemplateConfig> => {\n const isGitHubTemplate = templateName.startsWith('github:');\n const isPrivateSeekTemplate = templateName.startsWith('seek:');\n const isCustomTemplate = isGitHubTemplate || isPrivateSeekTemplate;\n\n if (isGitHubTemplate) {\n const gitHubPath = templateName.slice('github:'.length);\n\n await downloadGitHubTemplate(gitHubPath, destinationDir);\n } else if (isPrivateSeekTemplate) {\n const privateName = templateName.slice('seek:'.length);\n\n await downloadPrivateTemplate(privateName, destinationDir);\n } else {\n const templateDir = path.join(TEMPLATE_DIR, templateName);\n\n await copyFiles({\n // assume built-in templates have no extraneous files\n include: () => true,\n sourceRoot: templateDir,\n destinationRoot: destinationDir,\n processors: [],\n // built-in templates have files like _package.json\n stripUnderscorePrefix: true,\n });\n }\n\n const templateConfig = getTemplateConfig(\n path.join(process.cwd(), destinationDir),\n );\n\n if (isCustomTemplate) {\n log.newline();\n log.warn(\n 'You may need to run',\n log.bold(\n `${configForPackageManager(templateConfig.packageManager).print.exec} skuba configure`,\n ),\n 'once this is done.',\n );\n }\n\n return templateConfig;\n};\n\nconst selectTemplateName = async () => {\n const templateSelection = await getTemplateName();\n\n if (templateSelection === 'github \u2192') {\n const gitHubPath = await getGitPath();\n return `github:${gitHubPath}`;\n }\n\n if (templateSelection === 'seek \u2192') {\n const privateName = await getPrivateTemplateName();\n return `seek:${privateName}`;\n }\n\n return templateSelection;\n};\n\nconst generatePlaceholders = (choices: Choice[]) =>\n Object.fromEntries(\n choices.map(({ name }) => [name, `<%- ${name} %>`] as const),\n );\n\nexport const getTemplateConfig = (dir: string): TemplateConfig => {\n const templateConfigPath = path.join(dir, TEMPLATE_CONFIG_FILENAME);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const templateConfig = require(templateConfigPath) as unknown;\n\n return templateConfigSchema.parse(templateConfig);\n } catch (err) {\n if (isErrorWithCode(err, 'MODULE_NOT_FOUND')) {\n return {\n entryPoint: undefined,\n fields: [],\n packageManager: DEFAULT_PACKAGE_MANAGER,\n type: undefined,\n };\n }\n\n throw err;\n }\n};\n\nconst baseToTemplateData = async ({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n}: BaseFields) => {\n const [orgName, teamName] = ownerName.split('/');\n\n const port = String(await getRandomPort());\n\n if (!orgName) {\n throw new Error(`Invalid format for owner name: ${ownerName}`);\n }\n\n return {\n orgName,\n ownerName,\n repoName,\n defaultBranch,\n // Use standalone username in `teamName` contexts\n teamName: teamName ?? orgName,\n\n port,\n\n platformName,\n lambdaCdkArchitecture: platformName === 'amd64' ? 'X86_64' : 'ARM_64',\n lambdaServerlessArchitecture:\n platformName === 'amd64' ? 'x86_64' : platformName,\n };\n};\n\nexport const configureFromPrompt = async (): Promise<InitConfig> => {\n const { ownerName, platformName, repoName, defaultBranch } =\n await runForm<BaseFields>(BASE_PROMPT_PROPS);\n log.plain(styleText('cyan', repoName), 'by', styleText('cyan', ownerName));\n\n const templateData = await baseToTemplateData({\n ownerName,\n platformName,\n repoName,\n defaultBranch,\n });\n\n const destinationDir = repoName;\n\n await createDirectory(destinationDir);\n\n log.newline();\n const templateName = await selectTemplateName();\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (fields.length === 0) {\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData,\n templateName,\n type,\n };\n }\n\n const shouldContinueWithTemplate = noSkip\n ? true\n : await confirmShouldContinue(fields);\n\n if (shouldContinueWithTemplate) {\n log.newline();\n const customAnswers = await runForm({\n choices: fields,\n message: styleText(\n 'bold',\n `Complete ${styleText('cyan', templateName)}:`,\n ),\n name: 'customAnswers',\n });\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: true,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n }\n\n log.newline();\n log.warn(\n `Resume this later with ${styleText('bold', `${configForPackageManager(packageManager).print.exec} skuba configure`)}.`,\n );\n\n const customAnswers = generatePlaceholders(fields);\n\n return {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete: false,\n templateData: { ...templateData, ...customAnswers },\n templateName,\n type,\n };\n};\n\nexport const readJSONFromStdIn = async () => {\n let text = '';\n\n await new Promise((resolve) =>\n process.stdin\n .on('data', (chunk) => (text += chunk.toString()))\n .once('end', resolve),\n );\n\n text = text.trim();\n\n if (text === '') {\n log.err('No data from stdin.');\n process.exit(1);\n }\n\n let value: unknown;\n\n try {\n value = JSON.parse(text) as unknown;\n } catch {\n log.err('Invalid JSON from stdin.');\n process.exit(1);\n }\n\n return value;\n};\n\nconst configureFromPipe = async (): Promise<InitConfig> => {\n const value = await readJSONFromStdIn();\n\n const result = initConfigInputSchema.safeParse(value);\n\n if (!result.success) {\n log.err('Invalid data from stdin:');\n log.err(result.error);\n process.exit(1);\n }\n\n const { destinationDir, templateComplete, templateName } = result.data;\n\n const templateData = {\n ...(await baseToTemplateData(result.data.templateData)),\n ...result.data.templateData,\n };\n\n await createDirectory(destinationDir);\n\n const { entryPoint, fields, noSkip, packageManager, type } =\n await cloneTemplate(templateName, destinationDir);\n\n if (!templateComplete) {\n if (noSkip) {\n log.err('Templating for', log.bold(templateName), 'cannot be skipped.');\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData: {\n ...templateData,\n ...generatePlaceholders(fields),\n },\n type,\n };\n }\n\n const required = fields.map(({ name }) => name);\n\n const provided = new Set(Object.keys(templateData));\n\n const missing = required.filter((name) => !provided.has(name));\n\n if (missing.length > 0) {\n log.err('This template uses the following information:');\n log.newline();\n missing.forEach((name) => log.err(`- ${name}`));\n process.exit(1);\n }\n\n return {\n ...result.data,\n entryPoint,\n packageManager,\n templateData,\n type,\n };\n};\n\nexport const getConfig = () =>\n process.stdin.isTTY ? configureFromPrompt() : configureFromPipe();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B;AAC1B,kBAAiB;AAEjB,qBAAsB;AACtB,sBAAe;AAEf,kBAA0B;AAC1B,mBAAgC;AAChC,qBAAoB;AACpB,4BAGO;AACP,kBAA8B;AAC9B,sBAKO;AAEP,iBAAgE;AAChE,IAAAA,kBAQO;AACP,mBAAuD;AAEhD,MAAM,UAAU,OAAmC,UAIxC;AAChB,QAAM,EAAE,QAAQ,IAAI;AACpB,qBAAI,MAAM,OAAO;AAEjB,QAAM,SAAiC,CAAC;AAExC,aAAW,UAAU,MAAM,SAAS;AAClC,UAAM,aAAa,UAAM,sBAAM;AAAA,MAC7B,SAAS,OAAO;AAAA,MAChB,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO,cAAsB;AACrC,YACE,CAAC,aACD,cAAc,MACb,cAAc,OAAO,WAAW,CAAC,OAAO,cACzC;AACA,iBAAO;AAAA,QACT;AAEA,eAAO,OAAO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MAAM,mBAAmB,OAAO,KAAK,YAAY;AAAA,IACrD,GAAG,OAAO,KAAK;AAAA,EACjB;AAEA,QAAM,gBAAgB,cAAc;AAEpC,QAAM,EAAE,YAAY,QAAQ,QAAQ,gBAAgB,KAAK,IACvD,MAAM,cAAc,cAAc,cAAc;AAElD,MAAI,CAAC,kBAAkB;AACrB,QAAI,QAAQ;AACV,yBAAI,IAAI,kBAAkB,mBAAI,KAAK,YAAY,GAAG,oBAAoB;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,WAAO;AAAA,MACL,GAAG,OAAO;AAAA,MACV;AAAA,MACA;AAAA,MACA,cAAc;AAAA,QACZ,GAAG;AAAA,QACH,GAAG,qBAAqB,MAAM;AAAA,MAChC;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,WAAW,OAAO,IAAI,CAAC,EAAE,KAAK,MAAM,IAAI;AAE9C,QAAM,WAAW,IAAI,IAAI,OAAO,KAAK,YAAY,CAAC;AAElD,QAAM,UAAU,SAAS,OAAO,CAAC,SAAS,CAAC,SAAS,IAAI,IAAI,CAAC;AAE7D,MAAI,QAAQ,SAAS,GAAG;AACtB,uBAAI,IAAI,+CAA+C;AACvD,uBAAI,QAAQ;AACZ,YAAQ,QAAQ,CAAC,SAAS,mBAAI,IAAI,KAAK,IAAI,EAAE,CAAC;AAC9C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO;AAAA,IACL,GAAG,OAAO;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,YAAY,MACvB,QAAQ,MAAM,QAAQ,oBAAoB,IAAI,kBAAkB;",
|
|
6
6
|
"names": ["import_prompts", "fs", "path", "customAnswers"]
|
|
7
7
|
}
|
package/lib/cli/init/git.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ interface GitHubProject {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const initialiseRepo: (dir: string, { orgName, repoName, defaultBranch }: GitHubProject) => Promise<void>;
|
|
7
7
|
export declare const downloadGitHubTemplate: (gitHubPath: string, destinationDir: string) => Promise<void>;
|
|
8
|
+
export declare const downloadPrivateTemplate: (templateName: string, destinationDir: string) => Promise<void>;
|
|
8
9
|
export {};
|
package/lib/cli/init/git.js
CHANGED
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var git_exports = {};
|
|
30
30
|
__export(git_exports, {
|
|
31
31
|
downloadGitHubTemplate: () => downloadGitHubTemplate,
|
|
32
|
+
downloadPrivateTemplate: () => downloadPrivateTemplate,
|
|
32
33
|
initialiseRepo: () => initialiseRepo
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(git_exports);
|
|
@@ -67,9 +68,45 @@ const downloadGitHubTemplate = async (gitHubPath, destinationDir) => {
|
|
|
67
68
|
recursive: true
|
|
68
69
|
});
|
|
69
70
|
};
|
|
71
|
+
const downloadPrivateTemplate = async (templateName, destinationDir) => {
|
|
72
|
+
import_logging.log.newline();
|
|
73
|
+
import_logging.log.plain(
|
|
74
|
+
"Downloading",
|
|
75
|
+
import_logging.log.bold(templateName),
|
|
76
|
+
"from SEEK-Jobs/skuba-templates"
|
|
77
|
+
);
|
|
78
|
+
const repoUrl = "git@github.com:SEEK-Jobs/skuba-templates.git";
|
|
79
|
+
const folderPath = `templates/${templateName}`;
|
|
80
|
+
const tempDir = `${destinationDir}_temp`;
|
|
81
|
+
try {
|
|
82
|
+
const sparseCheckoutPath = import_path.default.join(
|
|
83
|
+
tempDir,
|
|
84
|
+
".git",
|
|
85
|
+
"info",
|
|
86
|
+
"sparse-checkout"
|
|
87
|
+
);
|
|
88
|
+
await import_fs_extra.default.promises.writeFile(sparseCheckoutPath, `${folderPath}/*
|
|
89
|
+
`);
|
|
90
|
+
await (0, import_simple_git.simpleGit)().raw(["init", tempDir]);
|
|
91
|
+
await (0, import_simple_git.simpleGit)(tempDir).raw(["config", "core.sparseCheckout", "true"]).addRemote("origin", repoUrl).raw(["pull", "origin", "main", "--depth", "1", "--quiet"]);
|
|
92
|
+
const templatePath = import_path.default.join(tempDir, folderPath);
|
|
93
|
+
try {
|
|
94
|
+
await import_fs_extra.default.promises.access(templatePath);
|
|
95
|
+
} catch {
|
|
96
|
+
throw new Error(`Template "${templateName}" not found in repository`);
|
|
97
|
+
}
|
|
98
|
+
await import_fs_extra.default.ensureDir(destinationDir);
|
|
99
|
+
await import_fs_extra.default.copy(templatePath, destinationDir);
|
|
100
|
+
await import_fs_extra.default.promises.rm(tempDir, { force: true, recursive: true });
|
|
101
|
+
} catch (error) {
|
|
102
|
+
await import_fs_extra.default.promises.rm(tempDir, { force: true, recursive: true });
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
70
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71
107
|
0 && (module.exports = {
|
|
72
108
|
downloadGitHubTemplate,
|
|
109
|
+
downloadPrivateTemplate,
|
|
73
110
|
initialiseRepo
|
|
74
111
|
});
|
|
75
112
|
//# sourceMappingURL=git.js.map
|
package/lib/cli/init/git.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/git.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport { simpleGit } from 'simple-git';\n\nimport { log } from '../../utils/logging.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,4BAAgB;AAChB,wBAA0B;AAE1B,qBAAoB;AAEpB,UAAqB;AAQd,MAAM,iBAAiB,OAC5B,KACA,EAAE,SAAS,UAAU,cAAc,MAChC;AACH,QAAM,sBAAAA,QAAI,KAAK;AAAA,IACb;AAAA,IACA;AAAA,IACA,oBAAAC;AAAA,EACF,CAAC;AAED,QAAM,IAAI,OAAO;AAAA,IACf;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,sBAAAD,QAAI,UAAU;AAAA,IAClB;AAAA,IACA,oBAAAC;AAAA,IACA,QAAQ;AAAA,IACR,KAAK,kBAAkB,OAAO,IAAI,QAAQ;AAAA,EAC5C,CAAC;AACH;AAEO,MAAM,yBAAyB,OACpC,YACA,mBACG;AACH,qBAAI,QAAQ;AACZ,qBAAI,MAAM,eAAe,mBAAI,KAAK,UAAU,GAAG,gBAAgB;AAE/D,YAAM,6BAAU,EAAE,MAAM,kBAAkB,UAAU,QAAQ,gBAAgB;AAAA,IAC1E;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,gBAAAA,QAAG,SAAS,GAAG,YAAAC,QAAK,KAAK,gBAAgB,MAAM,GAAG;AAAA,IACtD,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AACH;",
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport git from 'isomorphic-git';\nimport { simpleGit } from 'simple-git';\n\nimport { log } from '../../utils/logging.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\ninterface GitHubProject {\n orgName: string;\n repoName: string;\n defaultBranch: string;\n}\n\nexport const initialiseRepo = async (\n dir: string,\n { orgName, repoName, defaultBranch }: GitHubProject,\n) => {\n await git.init({\n defaultBranch,\n dir,\n fs,\n });\n\n await Git.commit({\n dir,\n message: 'Initial commit',\n });\n\n await git.addRemote({\n dir,\n fs,\n remote: 'origin',\n url: `git@github.com:${orgName}/${repoName}.git`,\n });\n};\n\nexport const downloadGitHubTemplate = async (\n gitHubPath: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain('Downloading', log.bold(gitHubPath), 'from GitHub...');\n\n await simpleGit().clone(`git@github.com:${gitHubPath}.git`, destinationDir, [\n '--depth=1',\n '--quiet',\n ]);\n\n await fs.promises.rm(path.join(destinationDir, '.git'), {\n force: true,\n recursive: true,\n });\n};\n\nexport const downloadPrivateTemplate = async (\n templateName: string,\n destinationDir: string,\n) => {\n log.newline();\n log.plain(\n 'Downloading',\n log.bold(templateName),\n 'from SEEK-Jobs/skuba-templates',\n );\n\n const repoUrl = 'git@github.com:SEEK-Jobs/skuba-templates.git';\n const folderPath = `templates/${templateName}`;\n const tempDir = `${destinationDir}_temp`;\n\n try {\n const sparseCheckoutPath = path.join(\n tempDir,\n '.git',\n 'info',\n 'sparse-checkout',\n );\n await fs.promises.writeFile(sparseCheckoutPath, `${folderPath}/*\\n`);\n await simpleGit().raw(['init', tempDir]);\n\n await simpleGit(tempDir)\n .raw(['config', 'core.sparseCheckout', 'true'])\n .addRemote('origin', repoUrl)\n .raw(['pull', 'origin', 'main', '--depth', '1', '--quiet']);\n\n const templatePath = path.join(tempDir, folderPath);\n\n try {\n await fs.promises.access(templatePath);\n } catch {\n throw new Error(`Template \"${templateName}\" not found in repository`);\n }\n\n await fs.ensureDir(destinationDir);\n await fs.copy(templatePath, destinationDir);\n\n await fs.promises.rm(tempDir, { force: true, recursive: true });\n } catch (error) {\n await f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A;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,UAAM,gBAAAD,QAAG,SAAS,UAAU,oBAAoB,GAAG,UAAU;AAAA,CAAM;AACnE,cAAM,6BAAU,EAAE,IAAI,CAAC,QAAQ,OAAO,CAAC;AAEvC,cAAM,6BAAU,OAAO,EACpB,IAAI,CAAC,UAAU,uBAAuB,MAAM,CAAC,EAC7C,UAAU,UAAU,OAAO,EAC3B,IAAI,CAAC,QAAQ,UAAU,QAAQ,WAAW,KAAK,SAAS,CAAC;AAE5D,UAAM,eAAe,YAAAC,QAAK,KAAK,SAAS,UAAU;AAElD,QAAI;AACF,YAAM,gBAAAD,QAAG,SAAS,OAAO,YAAY;AAAA,IACvC,QAAQ;AACN,YAAM,IAAI,MAAM,aAAa,YAAY,2BAA2B;AAAA,IACtE;AAEA,UAAM,gBAAAA,QAAG,UAAU,cAAc;AACjC,UAAM,gBAAAA,QAAG,KAAK,cAAc,cAAc;AAE1C,UAAM,gBAAAA,QAAG,SAAS,GAAG,SAAS,EAAE,OAAO,MAAM,WAAW,KAAK,CAAC;AAAA,EAChE,SAAS,OAAO;AACd,UAAM,gBAAAA,QAAG,SAAS,GAAG,SAAS,EAAE,OAAO,MAAM,WAAW,KAAK,CAAC;AAC9D,UAAM;AAAA,EACR;AACF;",
|
|
6
6
|
"names": ["git", "fs", "path"]
|
|
7
7
|
}
|
package/lib/cli/init/index.js
CHANGED
|
@@ -33,7 +33,6 @@ __export(init_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(init_exports);
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_util = require("util");
|
|
36
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
36
|
var import_args = require("../../utils/args.js");
|
|
38
37
|
var import_copy = require("../../utils/copy.js");
|
|
39
38
|
var import_dir = require("../../utils/dir.js");
|
|
@@ -47,7 +46,6 @@ var import_prettier = require("../adapter/prettier.js");
|
|
|
47
46
|
var import_patchRenovateConfig = require("../lint/internalLints/patchRenovateConfig.js");
|
|
48
47
|
var import_getConfig = require("./getConfig.js");
|
|
49
48
|
var import_git = require("./git.js");
|
|
50
|
-
var import_installPnpmPlugin = require("./installPnpmPlugin.js");
|
|
51
49
|
var import_writePackageJson = require("./writePackageJson.js");
|
|
52
50
|
var Git = __toESM(require("@skuba-lib/api/git"));
|
|
53
51
|
const init = async (args = process.argv.slice(2)) => {
|
|
@@ -103,24 +101,13 @@ const init = async (args = process.argv.slice(2)) => {
|
|
|
103
101
|
});
|
|
104
102
|
import_logging.log.newline();
|
|
105
103
|
await (0, import_git.initialiseRepo)(destinationDir, templateData);
|
|
106
|
-
const [manifest, packageManagerConfig
|
|
104
|
+
const [manifest, packageManagerConfig] = await Promise.all([
|
|
107
105
|
(0, import_manifest.getConsumerManifest)(destinationDir),
|
|
108
|
-
(0, import_packageManager.detectPackageManager)(destinationDir)
|
|
109
|
-
(0, import_manifest.getSkubaManifest)()
|
|
106
|
+
(0, import_packageManager.detectPackageManager)(destinationDir)
|
|
110
107
|
]);
|
|
111
108
|
if (!manifest) {
|
|
112
109
|
throw new Error("Repository doesn't contain a package.json file.");
|
|
113
110
|
}
|
|
114
|
-
if (packageManager === "pnpm") {
|
|
115
|
-
if (process.env.SKUBA_INTEGRATION_TEST === "true") {
|
|
116
|
-
await import_fs_extra.default.promises.symlink(
|
|
117
|
-
import_path.default.resolve("../skuba/packages/pnpm-plugin-skuba/pnpmfile.cjs"),
|
|
118
|
-
import_path.default.join(destinationDir, ".pnpmfile.cjs")
|
|
119
|
-
);
|
|
120
|
-
} else {
|
|
121
|
-
await (0, import_installPnpmPlugin.installPnpmPlugin)(skubaManifest);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
111
|
await (0, import_patchRenovateConfig.tryPatchRenovateConfig)({
|
|
125
112
|
mode: "format",
|
|
126
113
|
dir: destinationDir,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/index.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,
|
|
6
|
-
"names": ["path"
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { hasDebugFlag } from '../../utils/args.js';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy.js';\nimport { createInclusionFilter } from '../../utils/dir.js';\nimport { createExec, ensureCommands } from '../../utils/exec.js';\nimport { createLogger, log } from '../../utils/logging.js';\nimport { showLogoAndVersionInfo } from '../../utils/logo.js';\nimport { getConsumerManifest } from '../../utils/manifest.js';\nimport { detectPackageManager } from '../../utils/packageManager.js';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template.js';\nimport { runPrettier } from '../adapter/prettier.js';\nimport { tryPatchRenovateConfig } from '../lint/internalLints/patchRenovateConfig.js';\n\nimport { getConfig } from './getConfig.js';\nimport { initialiseRepo } from './git.js';\nimport type { Input } from './types.js';\nimport { writePackageJson } from './writePackageJson.js';\n\nimport * as Git from '@skuba-lib/api/git';\n\nexport const init = async (args = process.argv.slice(2)) => {\n const opts: Input = {\n debug: hasDebugFlag(args),\n };\n\n const skubaVersionInfo = await showLogoAndVersionInfo();\n\n const {\n destinationDir,\n entryPoint,\n packageManager,\n templateComplete,\n templateData,\n templateName,\n type,\n } = await getConfig();\n\n await ensureCommands(packageManager);\n\n const include = await createInclusionFilter([\n path.join(destinationDir, '.gitignore'),\n path.join(BASE_TEMPLATE_DIR, '_.gitignore'),\n ]);\n\n const processors = [createEjsRenderer(templateData)];\n\n await copyFiles({\n sourceRoot: BASE_TEMPLATE_DIR,\n destinationRoot: destinationDir,\n include,\n // prefer template-specific files\n overwrite: false,\n processors,\n // base template has files like _eslint.config.js\n stripUnderscorePrefix: true,\n });\n\n await copyFiles({\n sourceRoot: destinationDir,\n destinationRoot: destinationDir,\n include,\n processors,\n });\n\n await Promise.all([\n templateComplete\n ? ensureTemplateConfigDeletion(destinationDir)\n : Promise.resolve(),\n\n writePackageJson({\n cwd: destinationDir,\n entryPoint,\n template: templateName,\n type,\n version: skubaVersionInfo.local,\n }),\n ]);\n\n const exec = createExec({\n cwd: destinationDir,\n stdio: 'pipe',\n streamStdio: packageManager,\n });\n\n log.newline();\n await initialiseRepo(destinationDir, templateData);\n\n const [manifest, packageManagerConfig] = await Promise.all([\n getConsumerManifest(destinationDir),\n detectPackageManager(destinationDir),\n ]);\n\n if (!manifest) {\n throw new Error(\"Repository doesn't contain a package.json file.\");\n }\n\n // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig({\n mode: 'format',\n dir: destinationDir,\n manifest,\n packageManager: packageManagerConfig,\n });\n\n const skubaSlug = `skuba@${skubaVersionInfo.local}`;\n\n let depsInstalled = false;\n try {\n // The `-D` shorthand is portable across our package managers.\n await exec(packageManager, 'add', '-D', skubaSlug);\n\n // Templating can initially leave certain files in an unformatted state;\n // consider a Markdown table with columns sized based on content length.\n await runPrettier(\n 'format',\n createLogger({ debug: opts.debug }),\n destinationDir,\n );\n\n depsInstalled = true;\n } catch (err) {\n log.warn(inspect(err));\n }\n\n await Git.commitAllChanges({\n dir: destinationDir,\n message: `Clone ${templateName}`,\n });\n\n const logGitHubRepoCreation = () => {\n log.plain(\n 'Next, create an empty',\n log.bold(`${templateData.orgName}/${templateData.repoName}`),\n 'repository:',\n );\n log.ok('https://github.com/new');\n };\n\n if (!depsInstalled) {\n log.newline();\n log.warn(log.bold('\u2717 Failed to install dependencies.'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, resume initialisation:');\n log.ok('cd', destinationDir);\n // The `-D` shorthand is portable across our package managers.\n log.ok(packageManager, 'add', '-D', skubaSlug);\n log.ok(packageManager, 'run', 'format');\n log.ok('git add --all');\n log.ok('git commit --message', `'Pin ${skubaSlug}'`);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n process.exitCode = 1;\n return;\n }\n\n log.newline();\n log.ok(log.bold('\u2714 Project initialised!'));\n\n log.newline();\n logGitHubRepoCreation();\n\n log.newline();\n log.plain('Then, push your local changes:');\n log.ok('cd', destinationDir);\n log.ok(`git push --set-upstream origin ${templateData.defaultBranch}`);\n\n log.newline();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,kBAA6B;AAC7B,kBAA6C;AAC7C,iBAAsC;AACtC,kBAA2C;AAC3C,qBAAkC;AAClC,kBAAuC;AACvC,sBAAoC;AACpC,4BAAqC;AACrC,sBAGO;AACP,sBAA4B;AAC5B,iCAAuC;AAEvC,uBAA0B;AAC1B,iBAA+B;AAE/B,8BAAiC;AAEjC,UAAqB;AAEd,MAAM,OAAO,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC1D,QAAM,OAAc;AAAA,IAClB,WAAO,0BAAa,IAAI;AAAA,EAC1B;AAEA,QAAM,mBAAmB,UAAM,oCAAuB;AAEtD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,UAAM,4BAAU;AAEpB,YAAM,4BAAe,cAAc;AAEnC,QAAM,UAAU,UAAM,kCAAsB;AAAA,IAC1C,YAAAA,QAAK,KAAK,gBAAgB,YAAY;AAAA,IACtC,YAAAA,QAAK,KAAK,mCAAmB,aAAa;AAAA,EAC5C,CAAC;AAED,QAAM,aAAa,KAAC,+BAAkB,YAAY,CAAC;AAEnD,YAAM,uBAAU;AAAA,IACd,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB;AAAA;AAAA,IAEA,WAAW;AAAA,IACX;A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;AAAA,MACF;AAAA,MACA,mBAAI,KAAK,GAAG,aAAa,OAAO,IAAI,aAAa,QAAQ,EAAE;AAAA,MAC3D;AAAA,IACF;AACA,uBAAI,GAAG,wBAAwB;AAAA,EACjC;AAEA,MAAI,CAAC,eAAe;AAClB,uBAAI,QAAQ;AACZ,uBAAI,KAAK,mBAAI,KAAK,wCAAmC,CAAC;AAEtD,uBAAI,QAAQ;AACZ,0BAAsB;AAEtB,uBAAI,QAAQ;AACZ,uBAAI,MAAM,8BAA8B;AACxC,uBAAI,GAAG,MAAM,cAAc;AAE3B,uBAAI,GAAG,gBAAgB,OAAO,MAAM,SAAS;AAC7C,uBAAI,GAAG,gBAAgB,OAAO,QAAQ;AACtC,uBAAI,GAAG,eAAe;AACtB,uBAAI,GAAG,wBAAwB,QAAQ,SAAS,GAAG;AACnD,uBAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,uBAAI,QAAQ;AACZ,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,qBAAI,QAAQ;AACZ,qBAAI,GAAG,mBAAI,KAAK,6BAAwB,CAAC;AAEzC,qBAAI,QAAQ;AACZ,wBAAsB;AAEtB,qBAAI,QAAQ;AACZ,qBAAI,MAAM,gCAAgC;AAC1C,qBAAI,GAAG,MAAM,cAAc;AAC3B,qBAAI,GAAG,kCAAkC,aAAa,aAAa,EAAE;AAErE,qBAAI,QAAQ;AACd;",
|
|
6
|
+
"names": ["path"]
|
|
7
7
|
}
|
|
@@ -66,5 +66,6 @@ export declare const BASE_PROMPT_PROPS: {
|
|
|
66
66
|
};
|
|
67
67
|
export declare const shouldContinue: () => Promise<string>;
|
|
68
68
|
export declare const getGitPath: () => Promise<string>;
|
|
69
|
-
export declare const getTemplateName: () => Promise<"express-rest-api" | "greeter" | "koa-rest-api" | "lambda-sqs-worker-cdk" | "oss-npm-package" | "private-npm-package" | "github →">;
|
|
69
|
+
export declare const getTemplateName: () => Promise<"express-rest-api" | "greeter" | "koa-rest-api" | "lambda-sqs-worker-cdk" | "oss-npm-package" | "private-npm-package" | "github →" | "seek →">;
|
|
70
|
+
export declare const getPrivateTemplateName: () => Promise<string>;
|
|
70
71
|
export {};
|
package/lib/cli/init/prompts.js
CHANGED
|
@@ -20,6 +20,7 @@ var prompts_exports = {};
|
|
|
20
20
|
__export(prompts_exports, {
|
|
21
21
|
BASE_PROMPT_PROPS: () => BASE_PROMPT_PROPS,
|
|
22
22
|
getGitPath: () => getGitPath,
|
|
23
|
+
getPrivateTemplateName: () => getPrivateTemplateName,
|
|
23
24
|
getTemplateName: () => getTemplateName,
|
|
24
25
|
shouldContinue: () => shouldContinue
|
|
25
26
|
});
|
|
@@ -95,10 +96,15 @@ const getTemplateName = async () => (0, import_prompts.select)({
|
|
|
95
96
|
message: "Select a template:",
|
|
96
97
|
choices: import_template.TEMPLATE_NAMES_WITH_BYO.map((name) => ({ name, value: name }))
|
|
97
98
|
});
|
|
99
|
+
const getPrivateTemplateName = async () => (0, import_prompts.input)({
|
|
100
|
+
message: "Private SEEK template name",
|
|
101
|
+
validate: (value) => value.length > 0 || "Must be a valid template name"
|
|
102
|
+
});
|
|
98
103
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
104
|
0 && (module.exports = {
|
|
100
105
|
BASE_PROMPT_PROPS,
|
|
101
106
|
getGitPath,
|
|
107
|
+
getPrivateTemplateName,
|
|
102
108
|
getTemplateName,
|
|
103
109
|
shouldContinue
|
|
104
110
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/init/prompts.ts"],
|
|
4
|
-
"sourcesContent": ["import { input, select } from '@inquirer/prompts';\n\nimport { pathExists } from '../../utils/fs.js';\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template.js';\n\nimport {\n PLATFORM_OPTIONS,\n type Platform,\n isGitHubOrg,\n isGitHubRepo,\n isGitHubTeam,\n isPlatform,\n} from './validation.js';\n\nexport interface Choice {\n name: string;\n message: string;\n initial?: string;\n validate?: (value: string) => boolean | string | Promise<boolean | string>;\n /**\n * Whether the user is allowed to skip field entry and use the initial value.\n *\n * Defaults to `false`.\n */\n allowInitial?: boolean;\n}\n\nexport type BaseFields = Record<\n (typeof BASE_CHOICES)[number]['name'],\n string\n> & {\n platformName: Platform;\n};\n\nconst BASE_CHOICES = [\n {\n name: 'ownerName',\n message: 'Owner',\n initial: 'SEEK-Jobs/my-team',\n validate: (value: unknown) => {\n if (typeof value !== 'string') {\n return 'Required';\n }\n\n const [org, team] = value.split('/');\n\n if (!org || !isGitHubOrg(org)) {\n return 'Must contain a valid GitHub org name';\n }\n\n return (\n team === undefined ||\n isGitHubTeam(team) ||\n 'Must contain a valid GitHub team name'\n );\n },\n },\n {\n name: 'repoName',\n message: 'Repo',\n initial: 'my-repo',\n validate: async (value: unknown) => {\n if (typeof value !== 'string') {\n return 'Required';\n }\n\n if (!isGitHubRepo(value)) {\n return 'Must be a valid GitHub repo name';\n }\n\n const exists = await pathExists(value);\n\n return !exists || `'${value}' is an existing directory`;\n },\n },\n {\n name: 'platformName',\n message: 'Platform',\n initial: 'arm64',\n allowInitial: true,\n validate: (value: unknown) =>\n isPlatform(value) || `Must be ${PLATFORM_OPTIONS}`,\n },\n {\n name: 'defaultBranch',\n message: 'Default Branch',\n initial: 'main',\n allowInitial: true,\n validate: (value: unknown) =>\n typeof value === 'string' && value.length > 0 ? true : 'Required',\n },\n] as const;\n\nexport const BASE_PROMPT_PROPS = {\n choices: BASE_CHOICES,\n message: 'For starters, some project details:',\n name: 'baseAnswers',\n};\n\nexport const shouldContinue = async () =>\n select({\n message: 'Fill this in now?',\n choices: [\n { name: 'Yes', value: 'yes' },\n { name: 'No', value: 'no' },\n ],\n });\n\nexport const getGitPath = async () =>\n input({\n message: 'Git path',\n default: 'seek-oss/skuba',\n validate: (value: string) =>\n /[^/]+\\/[^/]+/.test(value) || 'Must be a valid path',\n });\n\nexport const getTemplateName = async () =>\n select({\n message: 'Select a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AAAA,EACT,SAAS;AAAA,EACT,MAAM;AACR;AAEO,MAAM,iBAAiB,gBAC5B,uBAAO;AAAA,EACL,SAAS;AAAA,EACT,SAAS;AAAA,IACP,EAAE,MAAM,OAAO,OAAO,MAAM;AAAA,IAC5B,EAAE,MAAM,MAAM,OAAO,KAAK;AAAA,EAC5B;AACF,CAAC;AAEI,MAAM,aAAa,gBACxB,sBAAM;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU,CAAC,UACT,eAAe,KAAK,KAAK,KAAK;AAClC,CAAC;AAEI,MAAM,kBAAkB,gBAC7B,uBAAO;AAAA,EACL,SAAS;AAAA,EACT,SAAS,wCAAwB,IAAI,CAAC,UAAU,EAAE,MAAM,OAAO,KAAK,EAAE;AACxE,CAAC;",
|
|
4
|
+
"sourcesContent": ["import { input, select } from '@inquirer/prompts';\n\nimport { pathExists } from '../../utils/fs.js';\nimport { TEMPLATE_NAMES_WITH_BYO } from '../../utils/template.js';\n\nimport {\n PLATFORM_OPTIONS,\n type Platform,\n isGitHubOrg,\n isGitHubRepo,\n isGitHubTeam,\n isPlatform,\n} from './validation.js';\n\nexport interface Choice {\n name: string;\n message: string;\n initial?: string;\n validate?: (value: string) => boolean | string | Promise<boolean | string>;\n /**\n * Whether the user is allowed to skip field entry and use the initial value.\n *\n * Defaults to `false`.\n */\n allowInitial?: boolean;\n}\n\nexport type BaseFields = Record<\n (typeof BASE_CHOICES)[number]['name'],\n string\n> & {\n platformName: Platform;\n};\n\nconst BASE_CHOICES = [\n {\n name: 'ownerName',\n message: 'Owner',\n initial: 'SEEK-Jobs/my-team',\n validate: (value: unknown) => {\n if (typeof value !== 'string') {\n return 'Required';\n }\n\n const [org, team] = value.split('/');\n\n if (!org || !isGitHubOrg(org)) {\n return 'Must contain a valid GitHub org name';\n }\n\n return (\n team === undefined ||\n isGitHubTeam(team) ||\n 'Must contain a valid GitHub team name'\n );\n },\n },\n {\n name: 'repoName',\n message: 'Repo',\n initial: 'my-repo',\n validate: async (value: unknown) => {\n if (typeof value !== 'string') {\n return 'Required';\n }\n\n if (!isGitHubRepo(value)) {\n return 'Must be a valid GitHub repo name';\n }\n\n const exists = await pathExists(value);\n\n return !exists || `'${value}' is an existing directory`;\n },\n },\n {\n name: 'platformName',\n message: 'Platform',\n initial: 'arm64',\n allowInitial: true,\n validate: (value: unknown) =>\n isPlatform(value) || `Must be ${PLATFORM_OPTIONS}`,\n },\n {\n name: 'defaultBranch',\n message: 'Default Branch',\n initial: 'main',\n allowInitial: true,\n validate: (value: unknown) =>\n typeof value === 'string' && value.length > 0 ? true : 'Required',\n },\n] as const;\n\nexport const BASE_PROMPT_PROPS = {\n choices: BASE_CHOICES,\n message: 'For starters, some project details:',\n name: 'baseAnswers',\n};\n\nexport const shouldContinue = async () =>\n select({\n message: 'Fill this in now?',\n choices: [\n { name: 'Yes', value: 'yes' },\n { name: 'No', value: 'no' },\n ],\n });\n\nexport const getGitPath = async () =>\n input({\n message: 'Git path',\n default: 'seek-oss/skuba',\n validate: (value: string) =>\n /[^/]+\\/[^/]+/.test(value) || 'Must be a valid path',\n });\n\nexport const getTemplateName = async () =>\n select({\n message: 'Select a template:',\n choices: TEMPLATE_NAMES_WITH_BYO.map((name) => ({ name, value: name })),\n });\n\nexport const getPrivateTemplateName = async () =>\n input({\n message: 'Private SEEK template name',\n validate: (value: string) =>\n value.length > 0 || 'Must be a valid template name',\n });\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA8B;AAE9B,gBAA2B;AAC3B,sBAAwC;AAExC,wBAOO;AAsBP,MAAM,eAAe;AAAA,EACnB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,UAAU,CAAC,UAAmB;AAC5B,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO;AAAA,MACT;AAEA,YAAM,CAAC,KAAK,IAAI,IA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,SAAS,wCAAwB,IAAI,CAAC,UAAU,EAAE,MAAM,OAAO,KAAK,EAAE;AACxE,CAAC;AAEI,MAAM,yBAAyB,gBACpC,sBAAM;AAAA,EACJ,SAAS;AAAA,EACT,UAAU,CAAC,UACT,MAAM,SAAS,KAAK;AACxB,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ type ConditionOptions = {
|
|
|
7
7
|
};
|
|
8
8
|
type RefreshableConfigFile = {
|
|
9
9
|
name: string;
|
|
10
|
-
type: 'ignore';
|
|
10
|
+
type: 'ignore' | 'pnpm-workspace';
|
|
11
11
|
additionalMapping?: (s: string, packageManager: PackageManagerConfig) => string;
|
|
12
12
|
if?: (options: ConditionOptions) => boolean;
|
|
13
13
|
};
|
|
@@ -58,6 +58,11 @@ const REFRESHABLE_CONFIG_FILES = [
|
|
|
58
58
|
additionalMapping: removeOldWarning
|
|
59
59
|
},
|
|
60
60
|
{ name: ".prettierignore", type: "ignore" },
|
|
61
|
+
{
|
|
62
|
+
name: "pnpm-workspace.yaml",
|
|
63
|
+
type: "pnpm-workspace",
|
|
64
|
+
if: ({ packageManager, isInWorkspaceRoot }) => isInWorkspaceRoot && packageManager.command === "pnpm"
|
|
65
|
+
},
|
|
61
66
|
{
|
|
62
67
|
name: ".dockerignore",
|
|
63
68
|
type: "ignore",
|
|
@@ -75,25 +80,28 @@ const refreshConfigFiles = async (mode, logger) => {
|
|
|
75
80
|
const readDestinationFile = (0, import_project.createDestinationFileReader)(destinationRoot);
|
|
76
81
|
const refreshConfigFile = async ({
|
|
77
82
|
name: filename,
|
|
83
|
+
type: fileType,
|
|
78
84
|
additionalMapping = (s) => s,
|
|
79
85
|
if: condition = () => true
|
|
80
86
|
}, conditionOptions) => {
|
|
81
87
|
if (!condition(conditionOptions)) {
|
|
82
88
|
return { needsChange: false };
|
|
83
89
|
}
|
|
84
|
-
const
|
|
90
|
+
const maybeReadPackageJson = async (type) => type === "pnpm-workspace" ? await readDestinationFile("package.json") : void 0;
|
|
91
|
+
const [inputFile, templateFile, isGitIgnored, packageJson] = await Promise.all([
|
|
85
92
|
readDestinationFile(filename),
|
|
86
93
|
(0, import_template.readBaseTemplateFile)(`_${filename}`),
|
|
87
94
|
gitRoot ? import__.Git.isFileGitIgnored({
|
|
88
95
|
gitRoot,
|
|
89
96
|
absolutePath: import_path.default.join(destinationRoot, filename)
|
|
90
|
-
}) : false
|
|
97
|
+
}) : false,
|
|
98
|
+
maybeReadPackageJson(fileType)
|
|
91
99
|
]);
|
|
92
100
|
if (inputFile === void 0 && isGitIgnored) {
|
|
93
101
|
return { needsChange: false };
|
|
94
102
|
}
|
|
95
103
|
const data = additionalMapping(
|
|
96
|
-
inputFile ? (0, import_configFile.mergeWithConfigFile)(templateFile)(inputFile) : templateFile,
|
|
104
|
+
inputFile ? (0, import_configFile.mergeWithConfigFile)(templateFile, fileType, packageJson)(inputFile) : templateFile,
|
|
97
105
|
packageManager
|
|
98
106
|
);
|
|
99
107
|
const filepath = import_path.default.join(destinationRoot, filename);
|
|
@@ -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 fs from 'fs-extra';\n\nimport { Git } from '../../../index.js';\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../utils/dir.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager.js';\nimport { readBaseTemplateFile } from '../../../utils/template.js';\nimport { getDestinationManifest } from '../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport { mergeWithConfigFile } from '../../configure/processing/configFile.js';\nimport type { InternalLintResult } from '../internal.js';\n\ntype ConditionOptions = {\n packageManager: PackageManagerConfig;\n isInWorkspaceRoot: boolean;\n};\n\ntype RefreshableConfigFile = {\n name: string;\n type: 'ignore';\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: '.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 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]
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA+D;AAE/D,sBAAe;AAEf,eAAoB;AACpB,iBAGO;AAEP,4BAGO;AACP,sBAAqC;AACrC,qBAAuC;AACvC,qBAA4C;AAC5C,wBAAoC;AAkBpC,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3B,MAAM,mBAAmB,CAAC,aACxB,SAAS,SAAS,kBAAkB,IAChC,GAAG,SAAS,QAAQ,oBAAoB,EAAE,EAAE,KAAK,CAAC;AAAA,IAClD;AAEC,MAAM,2BAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB;AAAA,EACrB;AAAA,EACA,EAAE,MAAM,mBAAmB,MAAM,SAAS;AAAA,EAC1C;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB;AAAA,EACrB;AACF;AAEO,MAAM,qBAAqB,OAChC,MACA,WACG;AACH,QAAM,CAAC,UAAU,SAAS,eAAe,2BAA2B,IAClE,MAAM,QAAQ,IAAI;AAAA,QAChB,uCAAuB;AAAA,IACvB,aAAI,SAAS,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AAAA,QACnC,8BAAkB;AAAA,QAClB,4CAAgC;AAAA,EAClC,CAAC;AAEH,QAAM,kBAAkB,YAAAA,QAAK,QAAQ,SAAS,IAAI;AAElD,QAAM,0BAAsB,4CAA4B,eAAe;AAEvE,QAAM,oBAAoB,OACxB;AAAA,IACE,MAAM;AAAA,IACN,oBAAoB,CAAC,MAAM;AAAA,IAC3B,IAAI,YAAY,MAAM;AAAA,EACxB,GACA,qBACG;AACH,QAAI,CAAC,UAAU,gBAAgB,GAAG;AAChC,aAAO,EAAE,aAAa,MAAM;AAAA,IAC9B;AAEA,UAAM,CAAC,WAAW,cAAc,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect, stripVTControlCharacters as stripAnsi } from 'util';\n\nimport fs from 'fs-extra';\n\nimport { Git } from '../../../index.js';\nimport {\n findCurrentWorkspaceProjectRoot,\n findWorkspaceRoot,\n} from '../../../utils/dir.js';\nimport type { Logger } from '../../../utils/logging.js';\nimport {\n type PackageManagerConfig,\n detectPackageManager,\n} from '../../../utils/packageManager.js';\nimport { readBaseTemplateFile } from '../../../utils/template.js';\nimport { getDestinationManifest } from '../../configure/analysis/package.js';\nimport { createDestinationFileReader } from '../../configure/analysis/project.js';\nimport { mergeWithConfigFile } from '../../configure/processing/configFile.js';\nimport type { InternalLintResult } from '../internal.js';\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 maybeReadPackageJson = async (type: RefreshableConfigFile['type']) =>\n type === 'pnpm-workspace'\n ? await readDestinationFile('package.json')\n : undefined;\n\n const [inputFile, templateFile, isGitIgnored, packageJson] =\n 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 maybeReadPackageJson(fileType),\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, packageJson)(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 fs.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} skuba 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,sBAAe;AAEf,eAAoB;AACpB,iBAGO;AAEP,4BAGO;AACP,sBAAqC;AACrC,qBAAuC;AACvC,qBAA4C;AAC5C,wBAAoC;AAkBpC,MAAM,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO3B,MAAM,mBAAmB,CAAC,aACxB,SAAS,SAAS,kBAAkB,IAChC,GAAG,SAAS,QAAQ,oBAAoB,EAAE,EAAE,KAAK,CAAC;AAAA,IAClD;AAEC,MAAM,2BAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB;AAAA,EACrB;AAAA,EACA,EAAE,MAAM,mBAAmB,MAAM,SAAS;AAAA,EAC1C;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,IAAI,CAAC,EAAE,gBAAgB,kBAAkB,MACvC,qBAAqB,eAAe,YAAY;AAAA,EACpD;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,mBAAmB;AA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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", "fs", "stripAnsi"]
|
|
7
7
|
}
|
|
@@ -21,14 +21,9 @@ __export(__exports, {
|
|
|
21
21
|
patches: () => patches
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(__exports);
|
|
24
|
-
var import_migrateToPnpmConfig = require("./migrateToPnpmConfig.js");
|
|
25
24
|
var import_patchRootTsconfig = require("./patchRootTsconfig.js");
|
|
26
25
|
var import_upgradeNode = require("./upgradeNode.js");
|
|
27
26
|
const patches = [
|
|
28
|
-
{
|
|
29
|
-
apply: import_migrateToPnpmConfig.tryMigrateToPnpmConfig,
|
|
30
|
-
description: "Migrate pnpm workspace to pnpm-plugin-skuba"
|
|
31
|
-
},
|
|
32
27
|
{
|
|
33
28
|
apply: import_upgradeNode.tryUpgradeNode,
|
|
34
29
|
description: "Upgrade Node.js version to 24 and package targets to Node.js 20"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/13.1.1/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA
|
|
4
|
+
"sourcesContent": ["import type { Patches } from '../../index.js';\n\nimport { tryPatchRootTsConfig } from './patchRootTsconfig.js';\nimport { tryUpgradeNode } from './upgradeNode.js';\n\nexport const patches: Patches = [\n {\n apply: tryUpgradeNode,\n description:\n 'Upgrade Node.js version to 24 and package targets to Node.js 20',\n },\n {\n apply: tryPatchRootTsConfig,\n description: \"Add 'rootDir' to root tsconfig.json compilerOptions\",\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,+BAAqC;AACrC,yBAA+B;AAExB,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/lib/utils/template.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
2
|
export declare const TEMPLATE_NAMES: readonly ["express-rest-api", "greeter", "koa-rest-api", "lambda-sqs-worker-cdk", "oss-npm-package", "private-npm-package"];
|
|
3
3
|
export type TemplateName = (typeof TEMPLATE_NAMES)[number];
|
|
4
|
-
export declare const TEMPLATE_NAMES_WITH_BYO: readonly ["express-rest-api", "greeter", "koa-rest-api", "lambda-sqs-worker-cdk", "oss-npm-package", "private-npm-package", "github →"];
|
|
4
|
+
export declare const TEMPLATE_NAMES_WITH_BYO: readonly ["express-rest-api", "greeter", "koa-rest-api", "lambda-sqs-worker-cdk", "oss-npm-package", "private-npm-package", "github →", "seek →"];
|
|
5
5
|
interface TemplateDocumentationConfig {
|
|
6
6
|
/**
|
|
7
7
|
* The semantic version in which the template was first added.
|
package/lib/utils/template.js
CHANGED
|
@@ -52,7 +52,11 @@ const TEMPLATE_NAMES = [
|
|
|
52
52
|
"oss-npm-package",
|
|
53
53
|
"private-npm-package"
|
|
54
54
|
];
|
|
55
|
-
const TEMPLATE_NAMES_WITH_BYO = [
|
|
55
|
+
const TEMPLATE_NAMES_WITH_BYO = [
|
|
56
|
+
...TEMPLATE_NAMES,
|
|
57
|
+
"github \u2192",
|
|
58
|
+
"seek \u2192"
|
|
59
|
+
];
|
|
56
60
|
const TEMPLATE_DOCUMENTATION_CONFIG = {
|
|
57
61
|
"express-rest-api": {
|
|
58
62
|
added: "3.8.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/template.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport * as z from 'zod/v4';\n\nimport { projectTypeSchema } from './manifest.js';\nimport { packageManagerSchema } from './packageManager.js';\n\nexport const TEMPLATE_NAMES = [\n 'express-rest-api',\n 'greeter',\n 'koa-rest-api',\n 'lambda-sqs-worker-cdk',\n 'oss-npm-package',\n 'private-npm-package',\n] as const;\n\nexport type TemplateName = (typeof TEMPLATE_NAMES)[number];\n\nexport const TEMPLATE_NAMES_WITH_BYO = [...TEMPLATE_NAMES
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AACf,QAAmB;AAEnB,sBAAkC;AAClC,4BAAqC;AAE9B,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,0BAA0B,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport * as z from 'zod/v4';\n\nimport { projectTypeSchema } from './manifest.js';\nimport { packageManagerSchema } from './packageManager.js';\n\nexport const TEMPLATE_NAMES = [\n 'express-rest-api',\n 'greeter',\n 'koa-rest-api',\n 'lambda-sqs-worker-cdk',\n 'oss-npm-package',\n 'private-npm-package',\n] as const;\n\nexport type TemplateName = (typeof TEMPLATE_NAMES)[number];\n\nexport const TEMPLATE_NAMES_WITH_BYO = [\n ...TEMPLATE_NAMES,\n 'github \u2192',\n 'seek \u2192',\n] as const;\n\ninterface TemplateDocumentationConfig {\n /**\n * The semantic version in which the template was first added.\n *\n * This is used to filter out historical changelogs.\n */\n added: string;\n\n /**\n * The Markdown file for the template in our `/docs`.\n *\n * This is used to compile per-template changelogs for our documentation site.\n */\n filename: string;\n}\n\nexport const TEMPLATE_DOCUMENTATION_CONFIG: Record<\n TemplateName,\n TemplateDocumentationConfig\n> = {\n 'express-rest-api': {\n added: '3.8.0',\n filename: 'api.md',\n },\n greeter: {\n added: '3.4.1',\n filename: 'barebones.md',\n },\n 'koa-rest-api': {\n added: '3.4.1',\n filename: 'api.md',\n },\n 'lambda-sqs-worker-cdk': {\n added: '3.13.0',\n filename: 'worker.md',\n },\n 'oss-npm-package': {\n added: '3.7.0',\n filename: 'package.md',\n },\n 'private-npm-package': {\n added: '3.6.0',\n filename: 'package.md',\n },\n};\n\nexport type TemplateConfig = z.infer<typeof templateConfigSchema>;\n\n// https://github.com/colinhacks/zod/issues/4143#issuecomment-2845134912\n// https://github.com/colinhacks/zod/issues/4143#issuecomment-2931729793\nconst functionSchema = <T extends z.core.$ZodFunction>(schema: T) =>\n z.custom<Parameters<T['implement']>[0]>().transform((arg, ctx) => {\n if (typeof arg !== 'function') {\n ctx.addIssue('Must be function');\n return z.NEVER;\n }\n return schema.implement(arg);\n });\n\nexport const templateConfigSchema = z.object({\n fields: z.array(\n z.object({\n name: z.string(),\n message: z.string(),\n initial: z.string(),\n validate: functionSchema(\n z.function({\n input: [z.string()],\n output: z.union([z.boolean(), z.string()]),\n }),\n ).optional(),\n }),\n ),\n entryPoint: z.string().optional(),\n noSkip: z.boolean().optional(),\n packageManager: packageManagerSchema,\n type: projectTypeSchema.optional(),\n});\n\nexport const TEMPLATE_CONFIG_FILENAME = 'skuba.template.js';\n\nexport const TEMPLATE_DIR = path.join(__dirname, '..', '..', 'template');\n\nexport const BASE_TEMPLATE_DIR = path.join(TEMPLATE_DIR, 'base');\n\nexport const ensureTemplateConfigDeletion = (dir: string): Promise<void> =>\n fs.promises.rm(path.join(dir, TEMPLATE_CONFIG_FILENAME));\n\nexport const readBaseTemplateFile = (src: string): Promise<string> =>\n fs.promises.readFile(path.join(BASE_TEMPLATE_DIR, src), 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,EAAE,OAAO,CAAC;AAAA,UAClB,QAAQ,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAC;AAAA,QAC3C,CAAC;AAAA,MACH,EAAE,SAAS;AAAA,IACb,CAAC;AAAA,EACH;AAAA,EACA,YAAY,EAAE,OAAO,EAAE,SAAS;AAAA,EAChC,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,gBAAgB;AAAA,EAChB,MAAM,kCAAkB,SAAS;AACnC,CAAC;AAEM,MAAM,2BAA2B;AAEjC,MAAM,eAAe,YAAAA,QAAK,KAAK,WAAW,MAAM,MAAM,UAAU;AAEhE,MAAM,oBAAoB,YAAAA,QAAK,KAAK,cAAc,MAAM;AAExD,MAAM,+BAA+B,CAAC,QAC3C,gBAAAC,QAAG,SAAS,GAAG,YAAAD,QAAK,KAAK,KAAK,wBAAwB,CAAC;AAElD,MAAM,uBAAuB,CAAC,QACnC,gBAAAC,QAAG,SAAS,SAAS,YAAAD,QAAK,KAAK,mBAAmB,GAAG,GAAG,MAAM;",
|
|
6
6
|
"names": ["path", "fs"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skuba",
|
|
3
|
-
"version": "14.0.0-
|
|
3
|
+
"version": "14.0.0-test-private-templates-20260107032413",
|
|
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",
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
"tsx": "^4.21.0",
|
|
103
103
|
"typescript": "~5.9.0",
|
|
104
104
|
"zod": "^4.0.0",
|
|
105
|
-
"@skuba-lib/api": "^2.0.0-
|
|
106
|
-
"eslint-config-skuba": "8.0.0-
|
|
105
|
+
"@skuba-lib/api": "^2.0.0-test-private-templates-20260107032413",
|
|
106
|
+
"eslint-config-skuba": "8.0.0-test-private-templates-20260107032413"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@changesets/cli": "2.29.8",
|
|
@@ -133,8 +133,7 @@
|
|
|
133
133
|
"remark-preset-lint-recommended": "7.0.1",
|
|
134
134
|
"semver": "7.7.3",
|
|
135
135
|
"supertest": "7.1.4",
|
|
136
|
-
"type-fest": "2.19.0"
|
|
137
|
-
"pnpm-plugin-skuba": "2.0.0-rfc-pnpm-config-skuba-20260107235318"
|
|
136
|
+
"type-fest": "2.19.0"
|
|
138
137
|
},
|
|
139
138
|
"engines": {
|
|
140
139
|
"node": ">=22.14.0"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# managed by skuba
|
|
2
|
+
ignorePatchFailures: false
|
|
3
|
+
minimumReleaseAge: 4320 # 3 days
|
|
4
|
+
minimumReleaseAgeExclude:
|
|
5
|
+
- '@seek/*'
|
|
6
|
+
- '@skuba-lib/*'
|
|
7
|
+
- eslint-config-seek
|
|
8
|
+
- eslint-config-skuba
|
|
9
|
+
- eslint-plugin-skuba
|
|
10
|
+
- skuba
|
|
11
|
+
- skuba-dive
|
|
12
|
+
- tsconfig-seek
|
|
13
|
+
packageManagerStrictVersion: true
|
|
14
|
+
publicHoistPattern:
|
|
15
|
+
- '@eslint/*'
|
|
16
|
+
- '@types*'
|
|
17
|
+
- eslint
|
|
18
|
+
- eslint-config-skuba
|
|
19
|
+
- prettier
|
|
20
|
+
- esbuild
|
|
21
|
+
- jest
|
|
22
|
+
- tsconfig-seek
|
|
23
|
+
- typescript
|
|
24
|
+
# end managed by skuba
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"test:watch": "skuba test --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"skuba-dive": "4.0.0-
|
|
22
|
+
"skuba-dive": "4.0.0-test-private-templates-20260107032413"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.13.10",
|
|
26
|
-
"skuba": "14.0.0-
|
|
26
|
+
"skuba": "14.0.0-test-private-templates-20260107032413"
|
|
27
27
|
},
|
|
28
|
-
"packageManager": "pnpm@10.
|
|
28
|
+
"packageManager": "pnpm@10.26.2",
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=24"
|
|
31
31
|
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@aws-sdk/client-sns": "^3.363.0",
|
|
25
25
|
"@seek/aws-codedeploy-hooks": "^2.0.0",
|
|
26
26
|
"@seek/logger": "^11.1.0",
|
|
27
|
-
"skuba-dive": "4.0.0-
|
|
27
|
+
"skuba-dive": "4.0.0-test-private-templates-20260107032413",
|
|
28
28
|
"zod": "^4.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"datadog-lambda-js": "^12.0.0",
|
|
43
43
|
"dd-trace": "^5.0.0",
|
|
44
44
|
"pino-pretty": "^13.0.0",
|
|
45
|
-
"skuba": "14.0.0-
|
|
45
|
+
"skuba": "14.0.0-test-private-templates-20260107032413"
|
|
46
46
|
},
|
|
47
|
-
"packageManager": "pnpm@10.
|
|
47
|
+
"packageManager": "pnpm@10.26.2",
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=24"
|
|
50
50
|
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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 installPnpmPlugin_exports = {};
|
|
20
|
-
__export(installPnpmPlugin_exports, {
|
|
21
|
-
installPnpmPlugin: () => installPnpmPlugin
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(installPnpmPlugin_exports);
|
|
24
|
-
var import_exec = require("../../utils/exec.js");
|
|
25
|
-
const installPnpmPlugin = async (skubaManifest) => {
|
|
26
|
-
const version = skubaManifest.devDependencies?.["pnpm-plugin-skuba"] || "latest";
|
|
27
|
-
await (0, import_exec.exec)("pnpm", "add", "--config", `pnpm-plugin-skuba@${version}`);
|
|
28
|
-
await (0, import_exec.exec)("pnpm", "install", "--lockfile-only", "--prefer-offline");
|
|
29
|
-
};
|
|
30
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 && (module.exports = {
|
|
32
|
-
installPnpmPlugin
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=installPnpmPlugin.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/cli/init/installPnpmPlugin.ts"],
|
|
4
|
-
"sourcesContent": ["import type { NormalizedPackageJson } from 'read-pkg-up';\n\nimport { exec } from '../../utils/exec.js';\n\nexport const installPnpmPlugin = async (\n skubaManifest: NormalizedPackageJson,\n): Promise<void> => {\n const version =\n skubaManifest.devDependencies?.['pnpm-plugin-skuba'] || 'latest';\n\n await exec('pnpm', 'add', '--config', `pnpm-plugin-skuba@${version}`);\n\n // Run install to ensure that the pnpmfileChecksum gets written\n await exec('pnpm', 'install', '--lockfile-only', '--prefer-offline');\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAqB;AAEd,MAAM,oBAAoB,OAC/B,kBACkB;AAClB,QAAM,UACJ,cAAc,kBAAkB,mBAAmB,KAAK;AAE1D,YAAM,kBAAK,QAAQ,OAAO,YAAY,qBAAqB,OAAO,EAAE;AAGpE,YAAM,kBAAK,QAAQ,WAAW,mBAAmB,kBAAkB;AACrE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var migrateToPnpmConfig_exports = {};
|
|
30
|
-
__export(migrateToPnpmConfig_exports, {
|
|
31
|
-
migrateToPnpmConfig: () => migrateToPnpmConfig,
|
|
32
|
-
tryMigrateToPnpmConfig: () => tryMigrateToPnpmConfig
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(migrateToPnpmConfig_exports);
|
|
35
|
-
var import_util = require("util");
|
|
36
|
-
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
-
var import_semver = require("semver");
|
|
38
|
-
var import_exec = require("../../../../../../utils/exec.js");
|
|
39
|
-
var import_logging = require("../../../../../../utils/logging.js");
|
|
40
|
-
var import_manifest = require("../../../../../../utils/manifest.js");
|
|
41
|
-
var import_installPnpmPlugin = require("../../../../../init/installPnpmPlugin.js");
|
|
42
|
-
const migrateToPnpmConfig = async ({
|
|
43
|
-
mode
|
|
44
|
-
}) => {
|
|
45
|
-
let pnpmWorkSpaceFile;
|
|
46
|
-
try {
|
|
47
|
-
pnpmWorkSpaceFile = await import_fs_extra.default.promises.readFile(
|
|
48
|
-
"pnpm-workspace.yaml",
|
|
49
|
-
"utf8"
|
|
50
|
-
);
|
|
51
|
-
} catch {
|
|
52
|
-
return {
|
|
53
|
-
result: "skip",
|
|
54
|
-
reason: "no pnpm-workspace.yaml found"
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const startingIndexText = "# managed by skuba";
|
|
58
|
-
const endOfSectionIndexText = "# end managed by skuba\n";
|
|
59
|
-
const startingIndex = pnpmWorkSpaceFile.indexOf(startingIndexText);
|
|
60
|
-
const endOfSectionIndex = pnpmWorkSpaceFile.indexOf(endOfSectionIndexText);
|
|
61
|
-
if (startingIndex === -1 || endOfSectionIndex === -1) {
|
|
62
|
-
return {
|
|
63
|
-
result: "skip",
|
|
64
|
-
reason: "no managed by skuba comment block found"
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const endSection = pnpmWorkSpaceFile.slice(
|
|
68
|
-
endOfSectionIndex + endOfSectionIndexText.length
|
|
69
|
-
);
|
|
70
|
-
let modifiedPnpmWorkspace = pnpmWorkSpaceFile.slice(0, startingIndex) + endSection;
|
|
71
|
-
const brokenYamlPatternRegex = /^\s*-\s+[^#]/;
|
|
72
|
-
const firstNonEmptyNonCommentLine = endSection.split("\n").find((line) => line.trim() && !line.trim().startsWith("#"));
|
|
73
|
-
if (firstNonEmptyNonCommentLine && brokenYamlPatternRegex.exec(firstNonEmptyNonCommentLine)) {
|
|
74
|
-
modifiedPnpmWorkspace = modifiedPnpmWorkspace.replace(
|
|
75
|
-
endSection,
|
|
76
|
-
`publicHoistPattern:
|
|
77
|
-
${endSection}`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
const [packageJson, skubaPackageJson] = await Promise.all([
|
|
81
|
-
(0, import_manifest.getConsumerManifest)(),
|
|
82
|
-
(0, import_manifest.getSkubaManifest)()
|
|
83
|
-
]);
|
|
84
|
-
if (packageJson?.packageJson.minimumReleaseAgeExcludeOverload && Array.isArray(packageJson.packageJson.minimumReleaseAgeExcludeOverload)) {
|
|
85
|
-
modifiedPnpmWorkspace += `
|
|
86
|
-
minimumReleaseAgeExclude:
|
|
87
|
-
${packageJson.packageJson.minimumReleaseAgeExcludeOverload.map((item) => ` - '${item}'`).join("\n")}
|
|
88
|
-
`;
|
|
89
|
-
delete packageJson.packageJson.minimumReleaseAgeExcludeOverload;
|
|
90
|
-
}
|
|
91
|
-
if (typeof packageJson?.packageJson.packageManager === "string") {
|
|
92
|
-
const version = packageJson.packageJson.packageManager.split("@")?.[1]?.split("+")?.[0];
|
|
93
|
-
if (typeof version === "string" && (0, import_semver.lt)(new import_semver.SemVer(version), new import_semver.SemVer("10.26.1"))) {
|
|
94
|
-
packageJson.packageJson.packageManager = "pnpm@10.26.1";
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (modifiedPnpmWorkspace === pnpmWorkSpaceFile) {
|
|
98
|
-
return {
|
|
99
|
-
result: "skip",
|
|
100
|
-
reason: "no changes needed to pnpm-workspace.yaml"
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (mode === "lint") {
|
|
104
|
-
return {
|
|
105
|
-
result: "apply"
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const stringifiedPackageJson = packageJson && `${JSON.stringify(packageJson.packageJson, null, 2)}
|
|
109
|
-
`;
|
|
110
|
-
await Promise.all([
|
|
111
|
-
import_fs_extra.default.promises.writeFile("pnpm-workspace.yaml", modifiedPnpmWorkspace, "utf8"),
|
|
112
|
-
stringifiedPackageJson && import_fs_extra.default.promises.writeFile(packageJson.path, stringifiedPackageJson, "utf8")
|
|
113
|
-
]);
|
|
114
|
-
await (0, import_installPnpmPlugin.installPnpmPlugin)(skubaPackageJson);
|
|
115
|
-
await (0, import_exec.exec)("pnpm", "install", "--offline");
|
|
116
|
-
return {
|
|
117
|
-
result: "apply"
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
const tryMigrateToPnpmConfig = async (config) => {
|
|
121
|
-
try {
|
|
122
|
-
return await migrateToPnpmConfig(config);
|
|
123
|
-
} catch (err) {
|
|
124
|
-
import_logging.log.warn("Failed to migrate to pnpm-plugin-skuba");
|
|
125
|
-
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
126
|
-
return { result: "skip", reason: "due to an error" };
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
-
0 && (module.exports = {
|
|
131
|
-
migrateToPnpmConfig,
|
|
132
|
-
tryMigrateToPnpmConfig
|
|
133
|
-
});
|
|
134
|
-
//# sourceMappingURL=migrateToPnpmConfig.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/13.1.1/migrateToPnpmConfig.ts"],
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\nimport { SemVer, lt } from 'semver';\n\nimport { exec } from '../../../../../../utils/exec.js';\nimport { log } from '../../../../../../utils/logging.js';\nimport {\n getConsumerManifest,\n getSkubaManifest,\n} from '../../../../../../utils/manifest.js';\nimport { installPnpmPlugin } from '../../../../../init/installPnpmPlugin.js';\nimport type { PatchFunction, PatchReturnType } from '../../index.js';\n\nexport const migrateToPnpmConfig: PatchFunction = async ({\n mode,\n}): Promise<PatchReturnType> => {\n let pnpmWorkSpaceFile: string;\n try {\n pnpmWorkSpaceFile = await fs.promises.readFile(\n 'pnpm-workspace.yaml',\n 'utf8',\n );\n } catch {\n return {\n result: 'skip',\n reason: 'no pnpm-workspace.yaml found',\n };\n }\n\n // Remove entire # managed by skuba comments block\n\n const startingIndexText = '# managed by skuba';\n const endOfSectionIndexText = '# end managed by skuba\\n';\n\n const startingIndex = pnpmWorkSpaceFile.indexOf(startingIndexText);\n const endOfSectionIndex = pnpmWorkSpaceFile.indexOf(endOfSectionIndexText);\n\n if (startingIndex === -1 || endOfSectionIndex === -1) {\n return {\n result: 'skip',\n reason: 'no managed by skuba comment block found',\n };\n }\n\n const endSection = pnpmWorkSpaceFile.slice(\n endOfSectionIndex + endOfSectionIndexText.length,\n );\n\n let modifiedPnpmWorkspace =\n pnpmWorkSpaceFile.slice(0, startingIndex) + endSection;\n\n // Check if consumers have extended the publicHoistPattern section\n // Only match if the first non-empty, non-comment line is a list item without a preceding key\n const brokenYamlPatternRegex = /^\\s*-\\s+[^#]/;\n const firstNonEmptyNonCommentLine = endSection\n .split('\\n')\n .find((line) => line.trim() && !line.trim().startsWith('#'));\n if (\n firstNonEmptyNonCommentLine &&\n brokenYamlPatternRegex.exec(firstNonEmptyNonCommentLine)\n ) {\n modifiedPnpmWorkspace = modifiedPnpmWorkspace.replace(\n endSection,\n `publicHoistPattern:\\n${endSection}`,\n );\n }\n\n // Migrate minimumReleaseAgeExcludeOverload\n const [packageJson, skubaPackageJson] = await Promise.all([\n getConsumerManifest(),\n getSkubaManifest(),\n ]);\n\n if (\n packageJson?.packageJson.minimumReleaseAgeExcludeOverload &&\n Array.isArray(packageJson.packageJson.minimumReleaseAgeExcludeOverload)\n ) {\n modifiedPnpmWorkspace += `\\nminimumReleaseAgeExclude:\\n${packageJson.packageJson.minimumReleaseAgeExcludeOverload.map((item) => ` - '${item}'`).join('\\n')}\\n`;\n delete packageJson.packageJson.minimumReleaseAgeExcludeOverload;\n }\n\n if (typeof packageJson?.packageJson.packageManager === 'string') {\n const version = packageJson.packageJson.packageManager\n .split('@')?.[1] // strip name\n ?.split('+')?.[0]; // strip sha\n\n if (\n typeof version === 'string' &&\n lt(new SemVer(version), new SemVer('10.26.1'))\n ) {\n packageJson.packageJson.packageManager = 'pnpm@10.26.1';\n }\n }\n\n if (modifiedPnpmWorkspace === pnpmWorkSpaceFile) {\n return {\n result: 'skip',\n reason: 'no changes needed to pnpm-workspace.yaml',\n };\n }\n\n if (mode === 'lint') {\n return {\n result: 'apply',\n };\n }\n\n const stringifiedPackageJson =\n packageJson && `${JSON.stringify(packageJson.packageJson, null, 2)}\\n`;\n\n await Promise.all([\n fs.promises.writeFile('pnpm-workspace.yaml', modifiedPnpmWorkspace, 'utf8'),\n stringifiedPackageJson &&\n fs.promises.writeFile(packageJson.path, stringifiedPackageJson, 'utf8'),\n ]);\n\n await installPnpmPlugin(skubaPackageJson);\n\n // Run pnpm install to ensure hoisting/build scripts are run\n await exec('pnpm', 'install', '--offline');\n\n return {\n result: 'apply',\n };\n};\n\nexport const tryMigrateToPnpmConfig: PatchFunction = async (config) => {\n try {\n return await migrateToPnpmConfig(config);\n } catch (err) {\n log.warn('Failed to migrate to pnpm-plugin-skuba');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error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