skuba 7.5.0-timeout-20240210035306 → 7.5.0
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/init/index.js +1 -1
- package/lib/cli/init/index.js.map +1 -1
- package/lib/cli/lint/internal.js +2 -3
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/{configure → lint/internalLints}/patchRenovateConfig.js +5 -5
- package/lib/cli/lint/internalLints/patchRenovateConfig.js.map +7 -0
- package/lib/cli/{configure → lint/internalLints}/upgrade/index.d.ts +2 -2
- package/lib/cli/{configure → lint/internalLints}/upgrade/index.js +4 -4
- package/lib/cli/lint/internalLints/upgrade/index.js.map +7 -0
- package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/addEmptyExports.js +4 -4
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.js.map +7 -0
- package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/index.js.map +1 -1
- package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js +3 -3
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js.map +7 -0
- package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/patchDockerfile.js +2 -2
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.js.map +7 -0
- package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/patchServerListener.js +4 -4
- package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.js.map +7 -0
- package/lib/cli/migrate/index.d.ts +1 -0
- package/lib/cli/migrate/index.js +59 -0
- package/lib/cli/migrate/index.js.map +7 -0
- package/lib/cli/migrate/nodeVersion/index.d.ts +1 -0
- package/lib/cli/migrate/nodeVersion/index.js +110 -0
- package/lib/cli/migrate/nodeVersion/index.js.map +7 -0
- package/lib/cli/node.d.ts +1 -0
- package/lib/cli/node.js +3 -0
- package/lib/cli/node.js.map +2 -2
- package/lib/skuba.js +3 -0
- package/lib/skuba.js.map +2 -2
- package/lib/utils/command.d.ts +1 -1
- package/lib/utils/command.js +1 -0
- package/lib/utils/command.js.map +2 -2
- package/lib/why-is-node-running.d.js +2 -0
- package/lib/why-is-node-running.d.js.map +7 -0
- package/package.json +6 -5
- package/template/express-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/express-rest-api/package.json +1 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/package.json +1 -1
- package/template/koa-rest-api/.buildkite/pipeline.yml +1 -1
- package/template/koa-rest-api/package.json +1 -1
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/infra/__snapshots__/appStack.test.ts.snap +4 -4
- package/template/lambda-sqs-worker-cdk/infra/appStack.test.ts +9 -4
- package/template/lambda-sqs-worker-cdk/package.json +1 -1
- package/lib/cli/configure/patchRenovateConfig.js.map +0 -7
- package/lib/cli/configure/upgrade/index.js.map +0 -7
- package/lib/cli/configure/upgrade/patches/7.3.1/addEmptyExports.js.map +0 -7
- package/lib/cli/configure/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js.map +0 -7
- package/lib/cli/configure/upgrade/patches/7.3.1/patchDockerfile.js.map +0 -7
- package/lib/cli/configure/upgrade/patches/7.3.1/patchServerListener.js.map +0 -7
- package/lib/cli/lint/internalLints/deleteFiles.d.ts +0 -3
- package/lib/cli/lint/internalLints/deleteFiles.js +0 -108
- package/lib/cli/lint/internalLints/deleteFiles.js.map +0 -7
- /package/lib/cli/{configure → lint/internalLints}/patchRenovateConfig.d.ts +0 -0
- /package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/addEmptyExports.d.ts +0 -0
- /package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/index.d.ts +0 -0
- /package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/index.js +0 -0
- /package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.d.ts +0 -0
- /package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/patchDockerfile.d.ts +0 -0
- /package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/patchServerListener.d.ts +0 -0
package/lib/cli/init/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var import_logging = require("../../utils/logging");
|
|
|
42
42
|
var import_logo = require("../../utils/logo");
|
|
43
43
|
var import_template = require("../../utils/template");
|
|
44
44
|
var import_prettier = require("../adapter/prettier");
|
|
45
|
-
var import_patchRenovateConfig = require("../
|
|
45
|
+
var import_patchRenovateConfig = require("../lint/internalLints/patchRenovateConfig");
|
|
46
46
|
var import_getConfig = require("./getConfig");
|
|
47
47
|
var import_git2 = require("./git");
|
|
48
48
|
var import_writePackageJson = require("./writePackageJson");
|
|
@@ -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 { commitAllChanges } from '../../api/git';\nimport { hasDebugFlag } from '../../utils/args';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy';\nimport { createInclusionFilter } from '../../utils/dir';\nimport { createExec, ensureCommands } from '../../utils/exec';\nimport { createLogger, log } from '../../utils/logging';\nimport { showLogoAndVersionInfo } from '../../utils/logo';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template';\nimport { runPrettier } from '../adapter/prettier';\nimport { tryPatchRenovateConfig } from '../
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport { commitAllChanges } from '../../api/git';\nimport { hasDebugFlag } from '../../utils/args';\nimport { copyFiles, createEjsRenderer } from '../../utils/copy';\nimport { createInclusionFilter } from '../../utils/dir';\nimport { createExec, ensureCommands } from '../../utils/exec';\nimport { createLogger, log } from '../../utils/logging';\nimport { showLogoAndVersionInfo } from '../../utils/logo';\nimport {\n BASE_TEMPLATE_DIR,\n ensureTemplateConfigDeletion,\n} from '../../utils/template';\nimport { runPrettier } from '../adapter/prettier';\nimport { tryPatchRenovateConfig } from '../lint/internalLints/patchRenovateConfig';\n\nimport { getConfig } from './getConfig';\nimport { initialiseRepo } from './git';\nimport type { Input } from './types';\nimport { writePackageJson } from './writePackageJson';\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 _.eslintrc.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 // Patch in a baseline Renovate preset based on the configured Git owner.\n await tryPatchRenovateConfig('format', destinationDir);\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('format', createLogger(opts.debug), destinationDir);\n\n depsInstalled = true;\n } catch (err) {\n log.warn(inspect(err));\n }\n\n await 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
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,iBAAiC;AACjC,kBAA6B;AAC7B,kBAA6C;AAC7C,iBAAsC;AACtC,kBAA2C;AAC3C,qBAAkC;AAClC,kBAAuC;AACvC,sBAGO;AACP,sBAA4B;AAC5B,iCAAuC;AAEvC,uBAA0B;AAC1B,IAAAA,cAA+B;AAE/B,8BAAiC;AAE1B,MAAM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 -34,14 +34,13 @@ module.exports = __toCommonJS(internal_exports);
|
|
|
34
34
|
var import_util = require("util");
|
|
35
35
|
var import_chalk = __toESM(require("chalk"));
|
|
36
36
|
var import_logging = require("../../utils/logging");
|
|
37
|
-
var import_upgrade = require("../configure/upgrade");
|
|
38
|
-
var import_deleteFiles = require("./internalLints/deleteFiles");
|
|
39
37
|
var import_noSkubaTemplateJs = require("./internalLints/noSkubaTemplateJs");
|
|
40
38
|
var import_refreshConfigFiles = require("./internalLints/refreshConfigFiles");
|
|
39
|
+
var import_upgrade = require("./internalLints/upgrade");
|
|
41
40
|
const lints = [
|
|
42
41
|
// Run upgradeSkuba before refreshConfigFiles for npmrc handling
|
|
43
42
|
[import_upgrade.upgradeSkuba],
|
|
44
|
-
[
|
|
43
|
+
[import_noSkubaTemplateJs.noSkubaTemplateJs, import_refreshConfigFiles.tryRefreshConfigFiles]
|
|
45
44
|
];
|
|
46
45
|
const lintSerially = async (mode, logger) => {
|
|
47
46
|
const results = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/lint/internal.ts"],
|
|
4
|
-
"sourcesContent": ["import { inspect } from 'util';\n\nimport chalk from 'chalk';\n\nimport { type Logger, createLogger } from '../../utils/logging';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,mBAAkB;AAElB,qBAA0C;
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport chalk from 'chalk';\n\nimport { type Logger, createLogger } from '../../utils/logging';\n\nimport { noSkubaTemplateJs } from './internalLints/noSkubaTemplateJs';\nimport { tryRefreshConfigFiles } from './internalLints/refreshConfigFiles';\nimport { upgradeSkuba } from './internalLints/upgrade';\nimport type { Input } from './types';\n\nexport type InternalLintResult = {\n ok: boolean;\n fixable: boolean;\n annotations?: Array<{\n start_line?: number;\n end_line?: number;\n path: string;\n message: string;\n }>;\n};\n\nconst lints: Array<\n Array<\n (mode: 'format' | 'lint', logger: Logger) => Promise<InternalLintResult>\n >\n> = [\n // Run upgradeSkuba before refreshConfigFiles for npmrc handling\n [upgradeSkuba],\n [noSkubaTemplateJs, tryRefreshConfigFiles],\n];\n\nconst lintSerially = async (mode: 'format' | 'lint', logger: Logger) => {\n const results: InternalLintResult[] = [];\n for (const lintGroup of lints) {\n for (const lint of lintGroup) {\n results.push(await lint(mode, logger));\n }\n }\n return results;\n};\n\nconst lintConcurrently = async (mode: 'format' | 'lint', logger: Logger) => {\n const results: InternalLintResult[] = [];\n\n for (const lintGroup of lints) {\n results.push(\n ...(await Promise.all(lintGroup.map((lint) => lint(mode, logger)))),\n );\n }\n\n return results;\n};\n\nconst selectLintFunction = (input?: Input) => {\n const isSerial = input?.debug || input?.serial;\n return isSerial ? lintSerially : lintConcurrently;\n};\n\nexport const internalLint = async (\n mode: 'format' | 'lint',\n input?: Input,\n): Promise<InternalLintResult> => {\n const start = process.hrtime.bigint();\n const logger = createLogger(\n input?.debug ?? false,\n ...(mode === 'lint' ? [chalk.blueBright('skuba \u2502')] : []),\n );\n\n try {\n const lint = selectLintFunction(input);\n const results = await lint(mode, logger);\n const result = combineResults(results);\n const end = process.hrtime.bigint();\n logger.plain(`Processed skuba lints in ${logger.timing(start, end)}.`);\n return result;\n } catch (err) {\n logger.err(logger.bold('Failed to run skuba lints.'));\n logger.subtle(inspect(err));\n\n process.exitCode = 1;\n\n return { ok: false, fixable: false, annotations: [] };\n }\n};\n\nconst combineResults = (results: InternalLintResult[]): InternalLintResult =>\n results.reduce(\n (cur, next) => ({\n ok: cur.ok && next.ok,\n fixable: cur.fixable || next.fixable,\n annotations: [...(cur.annotations ?? []), ...(next.annotations ?? [])],\n }),\n { ok: true, fixable: false },\n );\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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AAO,qBAAQ,GAAG,CAAC;AAE1B,YAAQ,WAAW;AAEnB,WAAO,EAAE,IAAI,OAAO,SAAS,OAAO,aAAa,CAAC,EAAE;AAAA,EACtD;AACF;AAEA,MAAM,iBAAiB,CAAC,YACtB,QAAQ;AAAA,EACN,CAAC,KAAK,UAAU;AAAA,IACd,IAAI,IAAI,MAAM,KAAK;AAAA,IACnB,SAAS,IAAI,WAAW,KAAK;AAAA,IAC7B,aAAa,CAAC,GAAI,IAAI,eAAe,CAAC,GAAI,GAAI,KAAK,eAAe,CAAC,CAAE;AAAA,EACvE;AAAA,EACA,EAAE,IAAI,MAAM,SAAS,MAAM;AAC7B;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -36,11 +36,11 @@ var import_util = require("util");
|
|
|
36
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
37
|
var fleece = __toESM(require("golden-fleece"));
|
|
38
38
|
var import_zod = require("zod");
|
|
39
|
-
var Git = __toESM(require("
|
|
40
|
-
var import_logging = require("
|
|
41
|
-
var import_project = require("
|
|
42
|
-
var import_renovate = require("
|
|
43
|
-
var import_prettier = require("
|
|
39
|
+
var Git = __toESM(require("../../../api/git"));
|
|
40
|
+
var import_logging = require("../../../utils/logging");
|
|
41
|
+
var import_project = require("../../configure/analysis/project");
|
|
42
|
+
var import_renovate = require("../../configure/modules/renovate");
|
|
43
|
+
var import_prettier = require("../../configure/processing/prettier");
|
|
44
44
|
const RENOVATE_PRESETS = [
|
|
45
45
|
"local>seekasia/renovate-config",
|
|
46
46
|
"local>seek-jobs/renovate-config"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/lint/internalLints/patchRenovateConfig.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\nimport * as fleece from 'golden-fleece';\nimport { z } from 'zod';\n\nimport * as Git from '../../../api/git';\nimport { log } from '../../../utils/logging';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\nimport { RENOVATE_CONFIG_FILENAMES } from '../../configure/modules/renovate';\nimport { formatPrettier } from '../../configure/processing/prettier';\n\nimport type { PatchFunction, PatchReturnType } from './upgrade';\n\nconst RENOVATE_PRESETS = [\n 'local>seekasia/renovate-config',\n 'local>seek-jobs/renovate-config',\n] as const;\n\nconst EXISTING_REPO_PRESET_REGEX = /(github|local)>(seek-jobs|seekasia)\\//;\n\ntype RenovateFiletype = 'json' | 'json5';\n\ntype RenovatePreset = (typeof RENOVATE_PRESETS)[number];\n\nconst renovateConfigSchema = z.object({\n extends: z.array(z.string()),\n});\n\nconst ownerToRenovatePreset = (owner: string): RenovatePreset | undefined => {\n const lowercaseOwner = owner.toLowerCase();\n\n switch (lowercaseOwner) {\n case 'seekasia':\n return 'local>seekasia/renovate-config';\n\n case 'seek-jobs':\n return 'local>seek-jobs/renovate-config';\n\n default:\n return;\n }\n};\n\ntype PatchFile = (props: {\n filepath: string;\n input: string;\n presetToAdd: RenovatePreset;\n}) => Promise<void>;\n\nconst patchJson: PatchFile = async ({ filepath, input, presetToAdd }) => {\n const json: unknown = JSON.parse(input);\n\n const config = renovateConfigSchema.safeParse(json);\n\n if (!config.success) {\n return;\n }\n\n config.data.extends.unshift(presetToAdd);\n\n await fs.promises.writeFile(\n filepath,\n await formatPrettier(JSON.stringify(config.data), { parser: 'json' }),\n );\n\n return;\n};\n\nconst patchJson5: PatchFile = async ({ filepath, input, presetToAdd }) => {\n const json: unknown = fleece.evaluate(input);\n\n const config = renovateConfigSchema.safeParse(json);\n\n if (!config.success) {\n return;\n }\n\n config.data.extends.unshift(presetToAdd);\n\n await fs.promises.writeFile(\n filepath,\n await formatPrettier(fleece.patch(input, config.data), { parser: 'json5' }),\n );\n\n return;\n};\n\nconst patchByFiletype: Record<RenovateFiletype, PatchFile> = {\n json: patchJson,\n json5: patchJson5,\n};\n\nconst patchRenovateConfig = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const { owner } = await Git.getOwnerAndRepo({ dir });\n\n const presetToAdd = ownerToRenovatePreset(owner);\n\n if (!presetToAdd) {\n return {\n result: 'skip',\n reason: 'owner does not map to a SEEK preset',\n };\n }\n\n const maybeConfigs = await Promise.all(\n RENOVATE_CONFIG_FILENAMES.map(async (filepath) => ({\n input: await readFile(filepath),\n filepath,\n })),\n );\n\n const config = maybeConfigs.find((maybeConfig) => Boolean(maybeConfig.input));\n if (!config?.input) {\n return { result: 'skip', reason: 'no config found' };\n }\n\n if (\n // The file appears to mention the baseline preset for the configured Git\n // owner. This is a naive check for simplicity.\n config.input.includes(presetToAdd) ||\n // Ignore any renovate configuration which already extends a SEEK-Jobs or seekasia config\n EXISTING_REPO_PRESET_REGEX.exec(config.input)\n ) {\n return {\n result: 'skip',\n reason: 'config already has a SEEK preset',\n };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const filetype: RenovateFiletype = config.filepath\n .toLowerCase()\n .endsWith('.json5')\n ? 'json5'\n : 'json';\n\n const patchFile = patchByFiletype[filetype];\n\n await patchFile({\n filepath: path.resolve(dir, config.filepath),\n input: config.input,\n presetToAdd,\n });\n\n return { result: 'apply' };\n};\n\nexport const tryPatchRenovateConfig = (async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n // In a monorepo we may be invoked within a subdirectory, but we are working\n // with Renovate config that should be relative to the repository root.\n const gitRoot = await Git.findRoot({ dir });\n if (!gitRoot) {\n return { result: 'skip', reason: 'no Git root found' };\n }\n\n return await patchRenovateConfig(mode, gitRoot);\n } catch (err) {\n log.warn('Failed to patch Renovate config.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n}) satisfies PatchFunction;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kB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AM,IAAI,SAAS,EAAE,IAAI,CAAC;AAC1C,QAAI,CAAC,SAAS;AACZ,aAAO,EAAE,QAAQ,QAAQ,QAAQ,oBAAoB;AAAA,IACvD;AAEA,WAAO,MAAM,oBAAoB,MAAM,OAAO;AAAA,EAChD,SAAS,KAAK;AACZ,uBAAI,KAAK,kCAAkC;AAC3C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs", "path"]
|
|
7
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Logger } from '
|
|
2
|
-
import type { InternalLintResult } from '../../
|
|
1
|
+
import type { Logger } from '../../../../utils/logging';
|
|
2
|
+
import type { InternalLintResult } from '../../internal';
|
|
3
3
|
export type Patches = Patch[];
|
|
4
4
|
export type Patch = {
|
|
5
5
|
apply: PatchFunction;
|
|
@@ -34,10 +34,10 @@ module.exports = __toCommonJS(upgrade_exports);
|
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_fs_extra = require("fs-extra");
|
|
36
36
|
var import_semver = require("semver");
|
|
37
|
-
var import_manifest = require("
|
|
38
|
-
var import_packageManager = require("
|
|
39
|
-
var import_version = require("
|
|
40
|
-
var import_package = require("
|
|
37
|
+
var import_manifest = require("../../../../utils/manifest");
|
|
38
|
+
var import_packageManager = require("../../../../utils/packageManager");
|
|
39
|
+
var import_version = require("../../../../utils/version");
|
|
40
|
+
var import_package = require("../../../configure/processing/package");
|
|
41
41
|
const getPatches = async (manifestVersion) => {
|
|
42
42
|
const patches = await (0, import_fs_extra.readdir)(import_path.default.join(__dirname, "patches"), {
|
|
43
43
|
withFileTypes: true
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/cli/lint/internalLints/upgrade/index.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport { readdir, writeFile } from 'fs-extra';\nimport { gte, sort } from 'semver';\n\nimport type { Logger } from '../../../../utils/logging';\nimport { getConsumerManifest } from '../../../../utils/manifest';\nimport { detectPackageManager } from '../../../../utils/packageManager';\nimport { getSkubaVersion } from '../../../../utils/version';\nimport { formatPackage } from '../../../configure/processing/package';\nimport type { SkubaPackageJson } from '../../../init/writePackageJson';\nimport type { InternalLintResult } from '../../internal';\n\nexport type Patches = Patch[];\nexport type Patch = {\n apply: PatchFunction;\n description: string;\n};\nexport type PatchReturnType =\n | { result: 'apply' }\n | { result: 'skip'; reason?: string };\nexport type PatchFunction = (\n mode: 'format' | 'lint',\n) => Promise<PatchReturnType>;\n\nconst getPatches = async (manifestVersion: string): Promise<Patches> => {\n const patches = await readdir(path.join(__dirname, 'patches'), {\n withFileTypes: true,\n });\n\n // The patches are sorted by the version they were added from.\n // Only return patches that are newer or equal to the current version.\n const patchesForVersion = sort(\n patches.flatMap((patch) =>\n // Is a directory rather than a JavaScript source file\n patch.isDirectory() &&\n // Has been added since the last patch run on the project\n gte(patch.name, manifestVersion)\n ? patch.name\n : [],\n ),\n );\n\n return (await Promise.all(patchesForVersion.map(resolvePatches))).flat();\n};\n\nconst fileExtensions = ['js', 'ts'];\n\n// Hack to allow our Jest environment/transform to resolve the patches\n// In normal scenarios this will resolve immediately after the .js import\nconst resolvePatches = async (version: string): Promise<Patches> => {\n for (const extension of fileExtensions) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (await import(`./patches/${version}/index.${extension}`)).patches;\n } catch {\n // Ignore\n }\n }\n throw new Error(`Could not resolve patches for ${version}`);\n};\n\nexport const upgradeSkuba = async (\n mode: 'lint' | 'format',\n logger: Logger,\n): Promise<InternalLintResult> => {\n const [currentVersion, manifest] = await Promise.all([\n getSkubaVersion(),\n getConsumerManifest(),\n ]);\n\n if (!manifest) {\n throw new Error('Could not find a package json for this project');\n }\n\n manifest.packageJson.skuba ??= { version: '1.0.0' };\n\n const manifestVersion = (manifest.packageJson.skuba as SkubaPackageJson)\n .version;\n\n // We are up to date, skip patches\n if (gte(manifestVersion, currentVersion)) {\n return { ok: true, fixable: false };\n }\n\n const patches = await getPatches(manifestVersion);\n // No patches to apply even if version out of date. Early exit to avoid unnecessary commits.\n if (patches.length === 0) {\n return { ok: true, fixable: false };\n }\n\n if (mode === 'lint') {\n const results = await Promise.all(\n patches.map(async ({ apply }) => await apply(mode)),\n );\n\n // No patches are applicable. Early exit to avoid unnecessary commits.\n if (results.every(({ result }) => result === 'skip')) {\n return { ok: true, fixable: false };\n }\n\n const packageManager = await detectPackageManager();\n\n logger.warn(\n `skuba has patches to apply. Run ${logger.bold(\n packageManager.exec,\n 'skuba',\n 'format',\n )} to run them. ${logger.dim('skuba-patches')}`,\n );\n\n return {\n ok: false,\n fixable: true,\n annotations: [\n {\n // package.json as likely skuba version has changed\n // TODO: locate the \"skuba\": {} config in the package.json and annotate on the version property\n path: manifest.path,\n message: `skuba has patches to apply. Run ${packageManager.exec} skuba format to run them.`,\n },\n ],\n };\n }\n\n logger.plain('Updating skuba...');\n\n // Run these in series in case a subsequent patch relies on a previous patch\n for (const { apply, description } of patches) {\n const result = await apply(mode);\n logger.newline();\n if (result.result === 'skip') {\n logger.plain(\n `Patch skipped: ${description}${\n result.reason ? ` - ${result.reason}` : ''\n }`,\n );\n } else {\n logger.plain(`Patch applied: ${description}`);\n }\n }\n\n (manifest.packageJson.skuba as SkubaPackageJson).version = currentVersion;\n\n const updatedPackageJson = await formatPackage(manifest.packageJson);\n\n await writeFile(manifest.path, updatedPackageJson);\n logger.newline();\n logger.plain('skuba update complete.');\n logger.newline();\n\n return {\n ok: true,\n fixable: false,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAmC;AACnC,oBAA0B;AAG1B,sBAAoC;AACpC,4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+
}
|
|
@@ -34,10 +34,10 @@ module.exports = __toCommonJS(addEmptyExports_exports);
|
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_util = require("util");
|
|
36
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
-
var import_logging = require("
|
|
38
|
-
var import_package = require("
|
|
39
|
-
var import_project = require("
|
|
40
|
-
var import_prettier = require("
|
|
37
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
38
|
+
var import_package = require("../../../../../configure/analysis/package");
|
|
39
|
+
var import_project = require("../../../../../configure/analysis/project");
|
|
40
|
+
var import_prettier = require("../../../../../configure/processing/prettier");
|
|
41
41
|
const JEST_SETUP_FILES = ["jest.setup.ts", "jest.setup.int.ts"];
|
|
42
42
|
const addEmptyExports = async (mode) => {
|
|
43
43
|
const manifest = await (0, import_package.getDestinationManifest)();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/addEmptyExports.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction } from '../..';\nimport { log } from '../../../../../../utils/logging';\nimport { getDestinationManifest } from '../../../../../configure/analysis/package';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project';\nimport { formatPrettier } from '../../../../../configure/processing/prettier';\n\nconst JEST_SETUP_FILES = ['jest.setup.ts', 'jest.setup.int.ts'];\n\nconst addEmptyExports = async (mode: 'format' | 'lint') => {\n const manifest = await getDestinationManifest();\n\n const destinationRoot = path.dirname(manifest.path);\n\n const readDestinationFile = createDestinationFileReader(destinationRoot);\n\n const addEmptyExport = async (filename: string) => {\n const inputFile = await readDestinationFile(filename);\n\n if (\n !inputFile ||\n // The file appears to have an import or export so it should be compatible\n // with isolated modules. This is a very naive check that we don't want to\n // overcomplicate because it is invoked before many skuba commands.\n inputFile.includes('import ') ||\n inputFile.includes('export ')\n ) {\n return 'skip';\n }\n\n if (mode === 'lint') {\n return 'apply';\n }\n\n const data = await formatPrettier([inputFile, 'export {}'].join('\\n\\n'), {\n parser: 'typescript',\n });\n\n const filepath = path.join(destinationRoot, filename);\n\n await fs.promises.writeFile(filepath, data);\n\n return 'apply';\n };\n\n const results = await Promise.all(JEST_SETUP_FILES.map(addEmptyExport));\n return results.every((result) => result === 'skip') ? 'skip' : 'apply';\n};\n\n/**\n * Tries to add an empty `export {}` statement to the bottom of Jest setup files\n * for compliance with TypeScript isolated modules.\n */\nexport const tryAddEmptyExports: PatchFunction = async (\n mode: 'format' | 'lint',\n) => {\n try {\n return { result: await addEmptyExports(mode) };\n } catch (err) {\n log.warn('Failed to convert Jest setup files to isolated modules.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAAuC;AACvC,qBAA4C;AAC5C,sBAA+B;AAE/B,MAAM,mBAAmB,CAAC,iBAAiB,mBAAmB;AAE9D,MAAM,kBAAkB,OAAO,SAA4B;AACzD,QAAM,WAAW,UAAM,uCAAuB;AAE9C,QAAM,kBAAkB,YAAAA,QAAK,QAAQ,SAAS,IAAI;AAElD,QAAM,0BAAsB,4CAA4B,eAAe;AAEvE,QAAM,iBAAiB,OAAO,aAAqB;AACjD,UAAM,YAAY,MAAM,oBAAoB,QAAQ;AAEpD,QACE,CAAC;AAAA;AAAA;AAAA,IAID,UAAU,SAAS,SAAS,KAC5B,UAAU,SAAS,SAAS,GAC5B;AACA,aAAO;AAAA,IACT;AAEA,QAAI,SAAS,QAAQ;AACnB,aAAO;AAAA,IACT;AAEA,UAAM,OAAO,UAAM,gCAAe,CAAC,WAAW,WAAW,EAAE,KAAK,MAAM,GAAG;AAAA,MACvE,QAAQ;AAAA,IACV,CAAC;AAED,UAAM,WAAW,YAAAA,QAAK,KAAK,iBAAiB,QAAQ;AAEpD,UAAM,gBAAAC,QAAG,SAAS,UAAU,UAAU,IAAI;AAE1C,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,MAAM,QAAQ,IAAI,iBAAiB,IAAI,cAAc,CAAC;AACtE,SAAO,QAAQ,MAAM,CAAC,WAAW,WAAW,MAAM,IAAI,SAAS;AACjE;AAMO,MAAM,qBAAoC,OAC/C,SACG;AACH,MAAI;AACF,WAAO,EAAE,QAAQ,MAAM,gBAAgB,IAAI,EAAE;AAAA,EAC/C,SAAS,KAAK;AACZ,uBAAI,KAAK,yDAAyD;AAClE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["path", "fs"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/index.ts"],
|
|
4
4
|
"sourcesContent": ["import type { Patches } from '../..';\nimport { tryPatchRenovateConfig } from '../../../patchRenovateConfig';\n\nimport { tryAddEmptyExports } from './addEmptyExports';\nimport { tryMoveNpmrcOutOfIgnoreManagedSection } from './moveNpmrcOutOfIgnoreManagedSection';\nimport { tryPatchDockerfile } from './patchDockerfile';\nimport { tryPatchServerListener } from './patchServerListener';\n\nexport const patches: Patches = [\n {\n apply: tryAddEmptyExports,\n description:\n 'Add empty exports to Jest files for compliance with TypeScript isolated modules',\n },\n {\n apply: tryPatchRenovateConfig,\n description: 'Update Renovate config to support private SEEK packages',\n },\n {\n apply: tryPatchDockerfile,\n description: 'Upgrade Node.js Distroless Docker image to -debian12 variant',\n },\n {\n apply: tryPatchServerListener,\n description: 'Add keepAliveTimeout to server listener',\n },\n {\n apply: tryMoveNpmrcOutOfIgnoreManagedSection('.gitignore'),\n description: 'Move .npmrc out of the .gitignore managed section',\n },\n {\n apply: tryMoveNpmrcOutOfIgnoreManagedSection('.dockerignore'),\n description: 'Move .npmrc out of the .dockerignore managed section',\n },\n];\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAAuC;AAEvC,6BAAmC;AACnC,gDAAsD;AACtD,6BAAmC;AACnC,iCAAuC;AAEhC,MAAM,UAAmB;AAAA,EAC9B;AAAA,IACE,OAAO;AAAA,IACP,aACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,WAAO,iFAAsC,YAAY;AAAA,IACzD,aAAa;AAAA,EACf;AAAA,EACA;AAAA,IACE,WAAO,iFAAsC,eAAe;AAAA,IAC5D,aAAa;AAAA,EACf;AACF;",
|
|
6
6
|
"names": []
|
|
@@ -34,9 +34,9 @@ module.exports = __toCommonJS(moveNpmrcOutOfIgnoreManagedSection_exports);
|
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
35
|
var import_util = require("util");
|
|
36
36
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
-
var import_logging = require("
|
|
38
|
-
var import_npmrc = require("
|
|
39
|
-
var import_project = require("
|
|
37
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
38
|
+
var import_npmrc = require("../../../../../../utils/npmrc");
|
|
39
|
+
var import_project = require("../../../../../configure/analysis/project");
|
|
40
40
|
const NPMRC_IGNORE_SECTION = `
|
|
41
41
|
|
|
42
42
|
# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.
|
package/lib/cli/lint/internalLints/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/moveNpmrcOutOfIgnoreManagedSection.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\nimport { NPMRC_LINES } from '../../../../../../utils/npmrc';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project';\n\nconst NPMRC_IGNORE_SECTION = `\n\n# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc.\n# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT.\n# You can use \\`skuba format\\` to generate the file or otherwise commit an empty file.\n# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets.\n.npmrc\n`;\n\nconst moveNpmrcOutOfIgnoreManagedSection = async (\n mode: 'format' | 'lint',\n dir: string,\n fileName: '.gitignore' | '.dockerignore',\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const ignoreFile = await readFile(fileName);\n\n if (!ignoreFile) {\n return { result: 'skip', reason: `no ${fileName} file found` };\n }\n\n let isIgnored: { inManaged: boolean } | undefined;\n let currentlyInManagedSection = false;\n\n for (const line of ignoreFile.split('\\n')) {\n if (line.trim() === '# managed by skuba') {\n currentlyInManagedSection = true;\n } else if (line.trim() === '# end managed by skuba') {\n currentlyInManagedSection = false;\n }\n\n if (line.trim() === '.npmrc' || line.trim() === '/.npmrc') {\n isIgnored = { inManaged: currentlyInManagedSection };\n }\n\n if (line.trim() === '!.npmrc' || line.trim() === '!/.npmrc') {\n isIgnored = undefined;\n }\n }\n\n if (isIgnored && !isIgnored.inManaged) {\n return { result: 'skip', reason: 'already ignored in unmanaged section' };\n }\n\n if (!isIgnored) {\n return { result: 'skip', reason: 'not ignored' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n const newIgnoreFile =\n ignoreFile\n .split('\\n')\n .filter((line) => !NPMRC_LINES.includes(line.trim()))\n .join('\\n')\n .trim() + NPMRC_IGNORE_SECTION;\n\n await fs.promises.writeFile(path.join(dir, fileName), newIgnoreFile);\n\n return { result: 'apply' };\n};\n\nexport const tryMoveNpmrcOutOfIgnoreManagedSection = (\n type: '.gitignore' | '.dockerignore',\n) =>\n (async (mode: 'format' | 'lint', dir = process.cwd()) => {\n try {\n return await moveNpmrcOutOfIgnoreManagedSection(mode, dir, type);\n } catch (err) {\n log.warn(`Failed to move .npmrc out of ${type} managed sections.`);\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n }) satisfies PatchFunction;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,mBAA4B;AAC5B,qBAA4C;AAE5C,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS7B,MAAM,qCAAqC,OACzC,MACA,KACA,aAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,aAAa,MAAM,SAAS,QAAQ;AAE1C,MAAI,CAAC,YAAY;AACf,WAAO,EAAE,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,cAAc;AAAA,EAC/D;AAEA,MAAI;AACJ,MAAI,4BAA4B;AAEhC,aAAW,QAAQ,WAAW,MAAM,IAAI,GAAG;AACzC,QAAI,KAAK,KAAK,MAAM,sBAAsB;AACxC,kCAA4B;AAAA,IAC9B,WAAW,KAAK,KAAK,MAAM,0BAA0B;AACnD,kCAA4B;AAAA,IAC9B;AAEA,QAAI,KAAK,KAAK,MAAM,YAAY,KAAK,KAAK,MAAM,WAAW;AACzD,kBAAY,EAAE,WAAW,0BAA0B;AAAA,IACrD;AAEA,QAAI,KAAK,KAAK,MAAM,aAAa,KAAK,KAAK,MAAM,YAAY;AAC3D,kBAAY;AAAA,IACd;AAAA,EACF;AAEA,MAAI,aAAa,CAAC,UAAU,WAAW;AACrC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,uCAAuC;AAAA,EAC1E;AAEA,MAAI,CAAC,WAAW;AACd,WAAO,EAAE,QAAQ,QAAQ,QAAQ,cAAc;AAAA,EACjD;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,gBACJ,WACG,MAAM,IAAI,EACV,OAAO,CAAC,SAAS,CAAC,yBAAY,SAAS,KAAK,KAAK,CAAC,CAAC,EACnD,KAAK,IAAI,EACT,KAAK,IAAI;AAEd,QAAM,gBAAAA,QAAG,SAAS,UAAU,YAAAC,QAAK,KAAK,KAAK,QAAQ,GAAG,aAAa;AAEnE,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,wCAAwC,CACnD,SAEC,OAAO,MAAyB,MAAM,QAAQ,IAAI,MAAM;AACvD,MAAI;AACF,WAAO,MAAM,mCAAmC,MAAM,KAAK,IAAI;AAAA,EACjE,SAAS,KAAK;AACZ,uBAAI,KAAK,gCAAgC,IAAI,oBAAoB;AACjE,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs", "path"]
|
|
7
|
+
}
|
|
@@ -33,8 +33,8 @@ __export(patchDockerfile_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(patchDockerfile_exports);
|
|
34
34
|
var import_util = require("util");
|
|
35
35
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
-
var import_logging = require("
|
|
37
|
-
var import_project = require("
|
|
36
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
37
|
+
var import_project = require("../../../../../configure/analysis/project");
|
|
38
38
|
const DOCKERFILE_FILENAME = "Dockerfile";
|
|
39
39
|
const NON_DEBIAN_REGEX = /gcr.io\/distroless\/nodejs:(18|20)/g;
|
|
40
40
|
const DEBIAN_REGEX = /gcr.io\/distroless\/nodejs(18|20)-debian11/g;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/patchDockerfile.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project';\n\nconst DOCKERFILE_FILENAME = 'Dockerfile';\n\nconst NON_DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs:(18|20)/g;\nconst DEBIAN_REGEX = /gcr.io\\/distroless\\/nodejs(18|20)-debian11/g;\nconst VERSION_DEBIAN_REPLACE = 'gcr.io/distroless/nodejs$1-debian12';\n\nconst patchDockerfile = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n const maybeDockerfile = await readFile(DOCKERFILE_FILENAME);\n\n if (!maybeDockerfile) {\n return { result: 'skip', reason: 'no Dockerfile found' };\n }\n\n const patched = maybeDockerfile\n .replaceAll(NON_DEBIAN_REGEX, VERSION_DEBIAN_REPLACE)\n .replaceAll(DEBIAN_REGEX, VERSION_DEBIAN_REPLACE);\n\n if (patched === maybeDockerfile) {\n return { result: 'skip' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n await fs.promises.writeFile(DOCKERFILE_FILENAME, patched);\n\n return { result: 'apply' };\n};\n\nexport const tryPatchDockerfile: PatchFunction = async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await patchDockerfile(mode, dir);\n } catch (err) {\n log.warn('Failed to patch Dockerfile.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAE5C,MAAM,sBAAsB;AAE5B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAE/B,MAAM,kBAAkB,OACtB,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,QAAM,kBAAkB,MAAM,SAAS,mBAAmB;AAE1D,MAAI,CAAC,iBAAiB;AACpB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sBAAsB;AAAA,EACzD;AAEA,QAAM,UAAU,gBACb,WAAW,kBAAkB,sBAAsB,EACnD,WAAW,cAAc,sBAAsB;AAElD,MAAI,YAAY,iBAAiB;AAC/B,WAAO,EAAE,QAAQ,OAAO;AAAA,EAC1B;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,QAAM,gBAAAA,QAAG,SAAS,UAAU,qBAAqB,OAAO;AAExD,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,qBAAoC,OAC/C,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,gBAAgB,MAAM,GAAG;AAAA,EACxC,SAAS,KAAK;AACZ,uBAAI,KAAK,6BAA6B;AACtC,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs"]
|
|
7
|
+
}
|
package/lib/cli/{configure → lint/internalLints}/upgrade/patches/7.3.1/patchServerListener.js
RENAMED
|
@@ -33,13 +33,13 @@ __export(patchServerListener_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(patchServerListener_exports);
|
|
34
34
|
var import_util = require("util");
|
|
35
35
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
-
var import_logging = require("
|
|
37
|
-
var import_project = require("
|
|
38
|
-
var import_prettier = require("
|
|
36
|
+
var import_logging = require("../../../../../../utils/logging");
|
|
37
|
+
var import_project = require("../../../../../configure/analysis/project");
|
|
38
|
+
var import_prettier = require("../../../../../configure/processing/prettier");
|
|
39
39
|
const SERVER_LISTENER_FILENAME = "src/listen.ts";
|
|
40
40
|
const KEEP_ALIVE_CODE = `
|
|
41
41
|
// Gantry ALB default idle timeout is 30 seconds
|
|
42
|
-
// https://nodejs.org/docs/latest-
|
|
42
|
+
// https://nodejs.org/docs/latest-v20.x/api/http.html#serverkeepalivetimeout
|
|
43
43
|
// Node default is 5 seconds
|
|
44
44
|
// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout
|
|
45
45
|
// AWS recommends setting an application timeout larger than the load balancer
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/cli/lint/internalLints/upgrade/patches/7.3.1/patchServerListener.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport fs from 'fs-extra';\n\nimport type { PatchFunction, PatchReturnType } from '../..';\nimport { log } from '../../../../../../utils/logging';\nimport { createDestinationFileReader } from '../../../../../configure/analysis/project';\nimport { formatPrettier } from '../../../../../configure/processing/prettier';\n\nconst SERVER_LISTENER_FILENAME = 'src/listen.ts';\n\nconst KEEP_ALIVE_CODE = `\n// Gantry ALB default idle timeout is 30 seconds\n// https://nodejs.org/docs/latest-v20.x/api/http.html#serverkeepalivetimeout\n// Node default is 5 seconds\n// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout\n// AWS recommends setting an application timeout larger than the load balancer\nlistener.keepAliveTimeout = 31000;\n`;\n\nconst patchServerListener = async (\n mode: 'format' | 'lint',\n dir: string,\n): Promise<PatchReturnType> => {\n const readFile = createDestinationFileReader(dir);\n\n let listener = await readFile(SERVER_LISTENER_FILENAME);\n if (!listener) {\n return { result: 'skip', reason: 'no listener file found' };\n }\n\n if (listener.includes('keepAliveTimeout')) {\n return { result: 'skip', reason: 'keepAliveTimeout already configured' };\n }\n\n if (listener.includes('\\napp.listen(')) {\n listener = listener.replace(\n '\\napp.listen(',\n '\\nconst listener = app.listen(',\n );\n }\n\n if (!listener.includes('\\nconst listener = app.listen(')) {\n return { result: 'skip', reason: 'no server listener found' };\n }\n\n if (mode === 'lint') {\n return { result: 'apply' };\n }\n\n listener = `${listener}${KEEP_ALIVE_CODE}`;\n\n await fs.promises.writeFile(\n SERVER_LISTENER_FILENAME,\n await formatPrettier(listener, {\n parser: 'typescript',\n }),\n );\n\n return { result: 'apply' };\n};\n\nexport const tryPatchServerListener: PatchFunction = async (\n mode: 'format' | 'lint',\n dir = process.cwd(),\n) => {\n try {\n return await patchServerListener(mode, dir);\n } catch (err) {\n log.warn('Failed to patch server listener.');\n log.subtle(inspect(err));\n return { result: 'skip', reason: 'due to an error' };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,sBAAe;AAGf,qBAAoB;AACpB,qBAA4C;AAC5C,sBAA+B;AAE/B,MAAM,2BAA2B;AAEjC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASxB,MAAM,sBAAsB,OAC1B,MACA,QAC6B;AAC7B,QAAM,eAAW,4CAA4B,GAAG;AAEhD,MAAI,WAAW,MAAM,SAAS,wBAAwB;AACtD,MAAI,CAAC,UAAU;AACb,WAAO,EAAE,QAAQ,QAAQ,QAAQ,yBAAyB;AAAA,EAC5D;AAEA,MAAI,SAAS,SAAS,kBAAkB,GAAG;AACzC,WAAO,EAAE,QAAQ,QAAQ,QAAQ,sCAAsC;AAAA,EACzE;AAEA,MAAI,SAAS,SAAS,eAAe,GAAG;AACtC,eAAW,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,SAAS,gCAAgC,GAAG;AACxD,WAAO,EAAE,QAAQ,QAAQ,QAAQ,2BAA2B;AAAA,EAC9D;AAEA,MAAI,SAAS,QAAQ;AACnB,WAAO,EAAE,QAAQ,QAAQ;AAAA,EAC3B;AAEA,aAAW,GAAG,QAAQ,GAAG,eAAe;AAExC,QAAM,gBAAAA,QAAG,SAAS;AAAA,IAChB;AAAA,IACA,UAAM,gCAAe,UAAU;AAAA,MAC7B,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,QAAQ,QAAQ;AAC3B;AAEO,MAAM,yBAAwC,OACnD,MACA,MAAM,QAAQ,IAAI,MACf;AACH,MAAI;AACF,WAAO,MAAM,oBAAoB,MAAM,GAAG;AAAA,EAC5C,SAAS,KAAK;AACZ,uBAAI,KAAK,kCAAkC;AAC3C,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO,EAAE,QAAQ,QAAQ,QAAQ,kBAAkB;AAAA,EACrD;AACF;",
|
|
6
|
+
"names": ["fs"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const migrate: (args?: string[]) => Promise<void>;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 migrate_exports = {};
|
|
20
|
+
__export(migrate_exports, {
|
|
21
|
+
migrate: () => migrate
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(migrate_exports);
|
|
24
|
+
var import_logging = require("../../utils/logging");
|
|
25
|
+
var import_nodeVersion = require("./nodeVersion");
|
|
26
|
+
const migrations = {
|
|
27
|
+
node20: () => (0, import_nodeVersion.nodeVersionMigration)(20)
|
|
28
|
+
};
|
|
29
|
+
const logAvailableMigrations = () => {
|
|
30
|
+
import_logging.log.ok("Available migrations:");
|
|
31
|
+
Object.keys(migrations).forEach((migration) => {
|
|
32
|
+
import_logging.log.ok(`- ${migration}`);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const migrate = async (args = process.argv.slice(2)) => {
|
|
36
|
+
if (!args[0]) {
|
|
37
|
+
import_logging.log.err("Provide a migration to run.");
|
|
38
|
+
logAvailableMigrations();
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (args.includes("--help") || args.includes("-h") || args[0] === "help") {
|
|
43
|
+
logAvailableMigrations();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const migration = migrations[args[0]];
|
|
47
|
+
if (!migration) {
|
|
48
|
+
import_logging.log.err(`Migration "${args[0]}" is not a valid option.`);
|
|
49
|
+
logAvailableMigrations();
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
await migration();
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
migrate
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/cli/migrate/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { log } from '../../utils/logging';\n\nimport { nodeVersionMigration } from './nodeVersion';\n\nconst migrations: Record<string, () => Promise<void>> = {\n node20: () => nodeVersionMigration(20),\n};\n\nconst logAvailableMigrations = () => {\n log.ok('Available migrations:');\n Object.keys(migrations).forEach((migration) => {\n log.ok(`- ${migration}`);\n });\n};\n\nexport const migrate = async (args = process.argv.slice(2)) => {\n if (!args[0]) {\n log.err('Provide a migration to run.');\n logAvailableMigrations();\n process.exitCode = 1;\n return;\n }\n\n if (args.includes('--help') || args.includes('-h') || args[0] === 'help') {\n logAvailableMigrations();\n return;\n }\n\n const migration = migrations[args[0]];\n\n if (!migration) {\n log.err(`Migration \"${args[0]}\" is not a valid option.`);\n logAvailableMigrations();\n process.exitCode = 1;\n return;\n }\n\n await migration();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AAEpB,yBAAqC;AAErC,MAAM,aAAkD;AAAA,EACtD,QAAQ,UAAM,yCAAqB,EAAE;AACvC;AAEA,MAAM,yBAAyB,MAAM;AACnC,qBAAI,GAAG,uBAAuB;AAC9B,SAAO,KAAK,UAAU,EAAE,QAAQ,CAAC,cAAc;AAC7C,uBAAI,GAAG,KAAK,SAAS,EAAE;AAAA,EACzB,CAAC;AACH;AAEO,MAAM,UAAU,OAAO,OAAO,QAAQ,KAAK,MAAM,CAAC,MAAM;AAC7D,MAAI,CAAC,KAAK,CAAC,GAAG;AACZ,uBAAI,IAAI,6BAA6B;AACrC,2BAAuB;AACvB,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,MAAI,KAAK,SAAS,QAAQ,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,CAAC,MAAM,QAAQ;AACxE,2BAAuB;AACvB;AAAA,EACF;AAEA,QAAM,YAAY,WAAW,KAAK,CAAC,CAAC;AAEpC,MAAI,CAAC,WAAW;AACd,uBAAI,IAAI,cAAc,KAAK,CAAC,CAAC,0BAA0B;AACvD,2BAAuB;AACvB,YAAQ,WAAW;AACnB;AAAA,EACF;AAEA,QAAM,UAAU;AAClB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const nodeVersionMigration: (version: number, dir?: string) => Promise<void>;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 nodeVersion_exports = {};
|
|
30
|
+
__export(nodeVersion_exports, {
|
|
31
|
+
nodeVersionMigration: () => nodeVersionMigration
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(nodeVersion_exports);
|
|
34
|
+
var import_util = require("util");
|
|
35
|
+
var import_fast_glob = require("fast-glob");
|
|
36
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
+
var import_logging = require("../../../utils/logging");
|
|
38
|
+
var import_project = require("../../configure/analysis/project");
|
|
39
|
+
const subPatches = [
|
|
40
|
+
{ file: ".nvmrc", replace: "<%- version %>\n" },
|
|
41
|
+
{
|
|
42
|
+
files: "Dockerfile*",
|
|
43
|
+
test: /^FROM(.*) node:[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?( .+|)$/gm,
|
|
44
|
+
replace: "FROM$1 node:<%- version %>$3$4"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
files: "Dockerfile*",
|
|
48
|
+
test: /^FROM(.*) gcr.io\/distroless\/nodejs\d+-debian(.+)$/gm,
|
|
49
|
+
replace: "FROM$1 gcr.io/distroless/nodejs<%- version %>-debian$2"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
files: "serverless*.y*ml",
|
|
53
|
+
test: /nodejs\d+.x/gm,
|
|
54
|
+
replace: "nodejs<%- version %>.x"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: "infra/**/*.ts",
|
|
58
|
+
test: /NODEJS_\d+_X/g,
|
|
59
|
+
replace: "NODEJS_<%- version %>_X"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
files: ".buildkite/*",
|
|
63
|
+
test: /image: node:[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
64
|
+
replace: "image: node:<%- version %>$2"
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
const runSubPatch = async (version, dir, patch) => {
|
|
68
|
+
const readFile = (0, import_project.createDestinationFileReader)(dir);
|
|
69
|
+
const paths = patch.file ? [patch.file] : await (0, import_fast_glob.glob)(patch.files ?? [], { cwd: dir });
|
|
70
|
+
await Promise.all(
|
|
71
|
+
paths.map(async (path) => {
|
|
72
|
+
const contents = await readFile(path);
|
|
73
|
+
if (!contents) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (patch.test && !patch.test.test(contents)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const templated = patch.replace.replaceAll(
|
|
80
|
+
"<%- version %>",
|
|
81
|
+
version.toString()
|
|
82
|
+
);
|
|
83
|
+
await import_fs_extra.default.promises.writeFile(
|
|
84
|
+
path,
|
|
85
|
+
patch.test ? contents.replaceAll(patch.test, templated) : templated
|
|
86
|
+
);
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
const upgrade = async (version, dir) => {
|
|
91
|
+
await Promise.all(
|
|
92
|
+
subPatches.map((subPatch) => runSubPatch(version, dir, subPatch))
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
const nodeVersionMigration = async (version, dir = process.cwd()) => {
|
|
96
|
+
import_logging.log.ok(`Upgrading to Node.js ${version}`);
|
|
97
|
+
try {
|
|
98
|
+
await upgrade(version, dir);
|
|
99
|
+
import_logging.log.ok("Upgraded to Node.js", version);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
import_logging.log.err("Failed to upgrade");
|
|
102
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
103
|
+
process.exitCode = 1;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
nodeVersionMigration
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/migrate/nodeVersion/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { glob } from 'fast-glob';\nimport fs from 'fs-extra';\n\nimport { log } from '../../../utils/logging';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\n\ntype SubPatch = (\n | { files: string; file?: never }\n | { file: string; files?: never }\n) & {\n test?: RegExp;\n replace: string;\n};\n\nconst subPatches: SubPatch[] = [\n { file: '.nvmrc', replace: '<%- version %>\\n' },\n {\n files: 'Dockerfile*',\n test: /^FROM(.*) node:[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?( .+|)$/gm,\n replace: 'FROM$1 node:<%- version %>$3$4',\n },\n {\n files: 'Dockerfile*',\n test: /^FROM(.*) gcr.io\\/distroless\\/nodejs\\d+-debian(.+)$/gm,\n replace: 'FROM$1 gcr.io/distroless/nodejs<%- version %>-debian$2',\n },\n {\n files: 'serverless*.y*ml',\n test: /nodejs\\d+.x/gm,\n replace: 'nodejs<%- version %>.x',\n },\n {\n files: 'infra/**/*.ts',\n test: /NODEJS_\\d+_X/g,\n replace: 'NODEJS_<%- version %>_X',\n },\n {\n files: '.buildkite/*',\n test: /image: node:[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n replace: 'image: node:<%- version %>$2',\n },\n];\n\nconst runSubPatch = async (version: number, dir: string, patch: SubPatch) => {\n const readFile = createDestinationFileReader(dir);\n const paths = patch.file\n ? [patch.file]\n : await glob(patch.files ?? [], { cwd: dir });\n\n await Promise.all(\n paths.map(async (path) => {\n const contents = await readFile(path);\n if (!contents) {\n return;\n }\n\n if (patch.test && !patch.test.test(contents)) {\n return;\n }\n\n const templated = patch.replace.replaceAll(\n '<%- version %>',\n version.toString(),\n );\n\n await fs.promises.writeFile(\n path,\n patch.test ? contents.replaceAll(patch.test, templated) : templated,\n );\n }),\n );\n};\n\nconst upgrade = async (version: number, dir: string) => {\n await Promise.all(\n subPatches.map((subPatch) => runSubPatch(version, dir, subPatch)),\n );\n};\n\nexport const nodeVersionMigration = async (\n version: number,\n dir = process.cwd(),\n) => {\n log.ok(`Upgrading to Node.js ${version}`);\n try {\n await upgrade(version, dir);\n log.ok('Upgraded to Node.js', version);\n } catch (err) {\n log.err('Failed to upgrade');\n log.subtle(inspect(err));\n process.exitCode = 1;\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AACpB,qBAA4C;AAU5C,MAAM,aAAyB;AAAA,EAC7B,EAAE,MAAM,UAAU,SAAS,mBAAmB;AAAA,EAC9C;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AACF;AAEA,MAAM,cAAc,OAAO,SAAiB,KAAa,UAAoB;AAC3E,QAAM,eAAW,4CAA4B,GAAG;AAChD,QAAM,QAAQ,MAAM,OAChB,CAAC,MAAM,IAAI,IACX,UAAM,uBAAK,MAAM,SAAS,CAAC,GAAG,EAAE,KAAK,IAAI,CAAC;AAE9C,QAAM,QAAQ;AAAA,IACZ,MAAM,IAAI,OAAO,SAAS;AACxB,YAAM,WAAW,MAAM,SAAS,IAAI;AACpC,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AAEA,UAAI,MAAM,QAAQ,CAAC,MAAM,KAAK,KAAK,QAAQ,GAAG;AAC5C;AAAA,MACF;AAEA,YAAM,YAAY,MAAM,QAAQ;AAAA,QAC9B;AAAA,QACA,QAAQ,SAAS;AAAA,MACnB;AAEA,YAAM,gBAAAA,QAAG,SAAS;AAAA,QAChB;AAAA,QACA,MAAM,OAAO,SAAS,WAAW,MAAM,MAAM,SAAS,IAAI;AAAA,MAC5D;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEA,MAAM,UAAU,OAAO,SAAiB,QAAgB;AACtD,QAAM,QAAQ;AAAA,IACZ,WAAW,IAAI,CAAC,aAAa,YAAY,SAAS,KAAK,QAAQ,CAAC;AAAA,EAClE;AACF;AAEO,MAAM,uBAAuB,OAClC,SACA,MAAM,QAAQ,IAAI,MACf;AACH,qBAAI,GAAG,wBAAwB,OAAO,EAAE;AACxC,MAAI;AACF,UAAM,QAAQ,SAAS,GAAG;AAC1B,uBAAI,GAAG,uBAAuB,OAAO;AAAA,EACvC,SAAS,KAAK;AACZ,uBAAI,IAAI,mBAAmB;AAC3B,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,YAAQ,WAAW;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": ["fs"]
|
|
7
|
+
}
|
package/lib/cli/node.d.ts
CHANGED
package/lib/cli/node.js
CHANGED
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
|
+
longRunning: () => longRunning,
|
|
31
32
|
node: () => node
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(node_exports);
|
|
@@ -37,6 +38,7 @@ var tsNode = __toESM(require("ts-node"));
|
|
|
37
38
|
var import_args = require("../utils/args");
|
|
38
39
|
var import_exec = require("../utils/exec");
|
|
39
40
|
var import_validation = require("../utils/validation");
|
|
41
|
+
const longRunning = true;
|
|
40
42
|
const node = async () => {
|
|
41
43
|
const args = (0, import_args.parseRunArgs)(process.argv.slice(2));
|
|
42
44
|
const availablePort = await (0, import_get_port.default)();
|
|
@@ -72,6 +74,7 @@ const node = async () => {
|
|
|
72
74
|
};
|
|
73
75
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
76
|
0 && (module.exports = {
|
|
77
|
+
longRunning,
|
|
75
78
|
node
|
|
76
79
|
});
|
|
77
80
|
//# sourceMappingURL=node.js.map
|
package/lib/cli/node.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/cli/node.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport getPort from 'get-port';\nimport * as tsNode from 'ts-node';\n\nimport { parseRunArgs } from '../utils/args';\nimport { createExec } from '../utils/exec';\nimport { isIpPort } from '../utils/validation';\n\nexport const node = async () => {\n const args = parseRunArgs(process.argv.slice(2));\n\n const availablePort = await getPort();\n\n if (args.entryPoint) {\n const exec = createExec({\n env: {\n __SKUBA_ENTRY_POINT: args.entryPoint,\n __SKUBA_PORT: String(isIpPort(args.port) ? args.port : availablePort),\n },\n });\n\n // Run a script with plain `node` to support inspector options.\n // https://github.com/TypeStrong/ts-node#programmatic\n return exec(\n 'node',\n ...args.node,\n '--require',\n 'dotenv/config',\n '--require',\n 'tsconfig-paths/register',\n '--require',\n 'ts-node/register/transpile-only',\n // Override dangerously warn-only default on Node.js <15 so that we\n // predictably return a non-zero exit code on an unhandled rejection.\n '--unhandled-rejections=throw',\n path.join(__dirname, '..', 'wrapper'),\n ...args.script,\n );\n }\n\n // REPL with `ts-node` to support import statements.\n return tsNode\n .createRepl({\n service: tsNode.register({\n require: ['dotenv/config', 'tsconfig-paths/register'],\n transpileOnly: true,\n }),\n })\n .start();\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAoB;AACpB,aAAwB;AAExB,kBAA6B;AAC7B,kBAA2B;AAC3B,wBAAyB;AAElB,MAAM,OAAO,YAAY;AAC9B,QAAM,WAAO,0BAAa,QAAQ,KAAK,MAAM,CAAC,CAAC;AAE/C,QAAM,gBAAgB,UAAM,gBAAAA,SAAQ;AAEpC,MAAI,KAAK,YAAY;AACnB,UAAM,WAAO,wBAAW;AAAA,MACtB,KAAK;AAAA,QACH,qBAAqB,KAAK;AAAA,QAC1B,cAAc,WAAO,4BAAS,KAAK,IAAI,IAAI,KAAK,OAAO,aAAa;AAAA,MACtE;AAAA,IACF,CAAC;AAID,WAAO;AAAA,MACL;AAAA,MACA,GAAG,KAAK;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,MAGA;AAAA,MACA,YAAAC,QAAK,KAAK,WAAW,MAAM,SAAS;AAAA,MACpC,GAAG,KAAK;AAAA,IACV;AAAA,EACF;AAGA,SAAO,OACJ,WAAW;AAAA,IACV,SAAS,OAAO,SAAS;AAAA,MACvB,SAAS,CAAC,iBAAiB,yBAAyB;AAAA,MACpD,eAAe;AAAA,IACjB,CAAC;AAAA,EACH,CAAC,EACA,MAAM;AACX;",
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport getPort from 'get-port';\nimport * as tsNode from 'ts-node';\n\nimport { parseRunArgs } from '../utils/args';\nimport { createExec } from '../utils/exec';\nimport { isIpPort } from '../utils/validation';\n\nexport const longRunning = true;\n\nexport const node = async () => {\n const args = parseRunArgs(process.argv.slice(2));\n\n const availablePort = await getPort();\n\n if (args.entryPoint) {\n const exec = createExec({\n env: {\n __SKUBA_ENTRY_POINT: args.entryPoint,\n __SKUBA_PORT: String(isIpPort(args.port) ? args.port : availablePort),\n },\n });\n\n // Run a script with plain `node` to support inspector options.\n // https://github.com/TypeStrong/ts-node#programmatic\n return exec(\n 'node',\n ...args.node,\n '--require',\n 'dotenv/config',\n '--require',\n 'tsconfig-paths/register',\n '--require',\n 'ts-node/register/transpile-only',\n // Override dangerously warn-only default on Node.js <15 so that we\n // predictably return a non-zero exit code on an unhandled rejection.\n '--unhandled-rejections=throw',\n path.join(__dirname, '..', 'wrapper'),\n ...args.script,\n );\n }\n\n // REPL with `ts-node` to support import statements.\n return tsNode\n .createRepl({\n service: tsNode.register({\n require: ['dotenv/config', 'tsconfig-paths/register'],\n transpileOnly: true,\n }),\n })\n .start();\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAoB;AACpB,aAAwB;AAExB,kBAA6B;AAC7B,kBAA2B;AAC3B,wBAAyB;AAElB,MAAM,cAAc;AAEpB,MAAM,OAAO,YAAY;AAC9B,QAAM,WAAO,0BAAa,QAAQ,KAAK,MAAM,CAAC,CAAC;AAE/C,QAAM,gBAAgB,UAAM,gBAAAA,SAAQ;AAEpC,MAAI,KAAK,YAAY;AACnB,UAAM,WAAO,wBAAW;AAAA,MACtB,KAAK;AAAA,QACH,qBAAqB,KAAK;AAAA,QAC1B,cAAc,WAAO,4BAAS,KAAK,IAAI,IAAI,KAAK,OAAO,aAAa;AAAA,MACtE;AAAA,IACF,CAAC;AAID,WAAO;AAAA,MACL;AAAA,MACA,GAAG,KAAK;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA,MAGA;AAAA,MACA,YAAAC,QAAK,KAAK,WAAW,MAAM,SAAS;AAAA,MACpC,GAAG,KAAK;AAAA,IACV;AAAA,EACF;AAGA,SAAO,OACJ,WAAW;AAAA,IACV,SAAS,OAAO,SAAS;AAAA,MACvB,SAAS,CAAC,iBAAiB,yBAAyB;AAAA,MACpD,eAAe;AAAA,IACjB,CAAC;AAAA,EACH,CAAC,EACA,MAAM;AACX;",
|
|
6
6
|
"names": ["getPort", "path"]
|
|
7
7
|
}
|
package/lib/skuba.js
CHANGED