skuba 10.0.0-node-22-20250219000751 → 10.0.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/configure/analyseDependencies.js +4 -1
- package/lib/cli/configure/analyseDependencies.js.map +2 -2
- package/lib/cli/lint/internal.js +2 -1
- package/lib/cli/lint/internal.js.map +2 -2
- package/lib/cli/lint/internalLints/detectBadCodeowners.d.ts +4 -0
- package/lib/cli/lint/internalLints/detectBadCodeowners.js +72 -0
- package/lib/cli/lint/internalLints/detectBadCodeowners.js.map +7 -0
- package/lib/cli/migrate/nodeVersion/checks.d.ts +10 -1
- package/lib/cli/migrate/nodeVersion/checks.js +58 -21
- package/lib/cli/migrate/nodeVersion/checks.js.map +2 -2
- package/lib/cli/migrate/nodeVersion/getNodeTypesVersion.js +18 -35
- package/lib/cli/migrate/nodeVersion/getNodeTypesVersion.js.map +3 -3
- package/lib/cli/migrate/nodeVersion/index.js +52 -66
- package/lib/cli/migrate/nodeVersion/index.js.map +2 -2
- package/lib/utils/copy.d.ts +1 -1
- package/lib/utils/copy.js +11 -3
- package/lib/utils/copy.js.map +2 -2
- package/lib/utils/version.d.ts +17 -1
- package/lib/utils/version.js +48 -18
- package/lib/utils/version.js.map +3 -3
- package/package.json +6 -10
- package/template/express-rest-api/.gantry/common.yml +0 -1
- package/template/express-rest-api/Dockerfile.dev-deps +1 -1
- package/template/express-rest-api/package.json +2 -2
- package/template/greeter/Dockerfile +1 -1
- package/template/greeter/package.json +3 -3
- package/template/koa-rest-api/.gantry/common.yml +0 -1
- package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
- package/template/koa-rest-api/package.json +2 -2
- package/template/lambda-sqs-worker-cdk/Dockerfile +1 -1
- package/template/lambda-sqs-worker-cdk/infra/appStack.ts +2 -2
- package/template/lambda-sqs-worker-cdk/package.json +5 -5
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/_package.json +1 -1
|
@@ -53,7 +53,10 @@ const logDiff = (diff) => {
|
|
|
53
53
|
const pinUnspecifiedVersions = async (dependencies) => {
|
|
54
54
|
const updates = await Promise.all(
|
|
55
55
|
Object.entries(dependencies).filter(([, version]) => version === "*").map(async ([name]) => {
|
|
56
|
-
const version = await (name === "skuba" ? (0, import_version.getSkubaVersion)() : (0, import_version.
|
|
56
|
+
const version = await (name === "skuba" ? (0, import_version.getSkubaVersion)() : (0, import_version.getLatestNpmVersion)(name));
|
|
57
|
+
if (version === null) {
|
|
58
|
+
throw new Error(`Failed to fetch latest version of ${name}`);
|
|
59
|
+
}
|
|
57
60
|
return [name, version];
|
|
58
61
|
})
|
|
59
62
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/cli/configure/analyseDependencies.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport type { NormalizedReadResult } from 'read-pkg-up';\n\nimport { type TextProcessor, copyFiles } from '../../utils/copy';\nimport { log } from '../../utils/logging';\nimport type { ProjectType } from '../../utils/manifest';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AAGf,kBAA8C;AAC9C,qBAAoB;AAEpB,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport fs from 'fs-extra';\nimport type { NormalizedReadResult } from 'read-pkg-up';\n\nimport { type TextProcessor, copyFiles } from '../../utils/copy';\nimport { log } from '../../utils/logging';\nimport type { ProjectType } from '../../utils/manifest';\nimport { getLatestNpmVersion, getSkubaVersion } from '../../utils/version';\n\nimport { diffDependencies } from './analysis/package';\nimport * as dependencyMutators from './dependencies';\nimport { formatPackage } from './processing/package';\nimport type { DependencyDiff } from './types';\n\nconst logDiff = (diff: DependencyDiff): boolean => {\n const entries = Object.entries(diff);\n\n if (entries.length === 0) {\n log.ok('\u2714 No changes');\n\n return false;\n }\n\n Object.entries(diff)\n .sort(([nameA], [nameB]) => nameA.localeCompare(nameB))\n .forEach(([name, { operation, version }]) =>\n log.plain(operation, name, log.formatSubtle(version)),\n );\n\n return true;\n};\n\nconst pinUnspecifiedVersions = async (\n dependencies: Record<string, string>,\n): Promise<void> => {\n const updates = await Promise.all(\n Object.entries(dependencies)\n .filter(([, version]) => version === '*')\n .map(async ([name]) => {\n const version = await (name === 'skuba'\n ? getSkubaVersion()\n : getLatestNpmVersion(name));\n\n if (version === null) {\n throw new Error(`Failed to fetch latest version of ${name}`);\n }\n\n return [name, version] as const;\n }),\n );\n\n updates.forEach(([name, version]) => {\n dependencies[name] = version;\n });\n};\n\ninterface Props {\n destinationRoot: string;\n include: (pathname: string) => boolean;\n manifest: NormalizedReadResult;\n type: ProjectType;\n}\n\nexport const analyseDependencies = async ({\n destinationRoot,\n include,\n manifest: { packageJson },\n type,\n}: Props): Promise<undefined | (() => Promise<void>)> => {\n const input = {\n dependencies: packageJson.dependencies ?? {},\n devDependencies: packageJson.devDependencies ?? {},\n type,\n };\n\n const output = {\n dependencies: { ...input.dependencies },\n devDependencies: { ...input.devDependencies },\n type,\n };\n\n const processors = Object.values(dependencyMutators).reduce<TextProcessor[]>(\n (acc, mutate) => {\n const newProcessors = mutate(output);\n acc.push(...newProcessors);\n return acc;\n },\n [],\n );\n\n await Promise.all([\n pinUnspecifiedVersions(output.dependencies),\n pinUnspecifiedVersions(output.devDependencies),\n ]);\n\n const dependencyDiff = diffDependencies({\n old: input.dependencies,\n new: output.dependencies,\n });\n\n log.newline();\n log.plain(log.bold('Dependencies:'));\n\n log.newline();\n const hasDependencyDiff = logDiff(dependencyDiff);\n\n const devDependencyDiff = diffDependencies({\n old: input.devDependencies,\n new: output.devDependencies,\n });\n\n log.newline();\n log.plain(log.bold('Dev dependencies:'));\n\n log.newline();\n const hasDevDependencyDiff = logDiff(devDependencyDiff);\n\n const packageJsonFilepath = path.join(destinationRoot, 'package.json');\n\n if (!hasDependencyDiff && !hasDevDependencyDiff) {\n return;\n }\n\n return async () => {\n const updatedPackageJson = await formatPackage({\n ...packageJson,\n dependencies: output.dependencies,\n devDependencies: output.devDependencies,\n });\n\n await fs.promises.writeFile(packageJsonFilepath, updatedPackageJson);\n\n if (processors.length === 0) {\n return;\n }\n\n await copyFiles({\n sourceRoot: destinationRoot,\n destinationRoot,\n include,\n processors,\n });\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,sBAAe;AAGf,kBAA8C;AAC9C,qBAAoB;AAEpB,qBAAqD;AAErD,qBAAiC;AACjC,yBAAoC;AACpC,IAAAA,kBAA8B;AAG9B,MAAM,UAAU,CAAC,SAAkC;AACjD,QAAM,UAAU,OAAO,QAAQ,IAAI;AAEnC,MAAI,QAAQ,WAAW,GAAG;AACxB,uBAAI,GAAG,mBAAc;AAErB,WAAO;AAAA,EACT;AAEA,SAAO,QAAQ,IAAI,EAChB,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,MAAM,MAAM,cAAc,KAAK,CAAC,EACrD;AAAA,IAAQ,CAAC,CAAC,MAAM,EAAE,WAAW,QAAQ,CAAC,MACrC,mBAAI,MAAM,WAAW,MAAM,mBAAI,aAAa,OAAO,CAAC;AAAA,EACtD;AAEF,SAAO;AACT;AAEA,MAAM,yBAAyB,OAC7B,iBACkB;AAClB,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,OAAO,QAAQ,YAAY,EACxB,OAAO,CAAC,CAAC,EAAE,OAAO,MAAM,YAAY,GAAG,EACvC,IAAI,OAAO,CAAC,IAAI,MAAM;AACrB,YAAM,UAAU,OAAO,SAAS,cAC5B,gCAAgB,QAChB,oCAAoB,IAAI;AAE5B,UAAI,YAAY,MAAM;AACpB,cAAM,IAAI,MAAM,qCAAqC,IAAI,EAAE;AAAA,MAC7D;AAEA,aAAO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,QAAM,sBAAsB,YAAAC,QAAK,KAAK,iBAAiB,cAAc;AAErE,MAAI,CAAC,qBAAqB,CAAC,sBAAsB;AAC/C;AAAA,EACF;AAEA,SAAO,YAAY;AACjB,UAAM,qBAAqB,UAAM,+BAAc;AAAA,MAC7C,GAAG;AAAA,MACH,cAAc,OAAO;AAAA,MACrB,iBAAiB,OAAO;AAAA,IAC1B,CAAC;AAED,UAAM,gBAAAC,QAAG,SAAS,UAAU,qBAAqB,kBAAkB;AAEnE,QAAI,WAAW,WAAW,GAAG;AAC3B;AAAA,IACF;AAEA,cAAM,uBAAU;AAAA,MACd,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": ["import_package", "path", "fs"]
|
|
7
7
|
}
|
package/lib/cli/lint/internal.js
CHANGED
|
@@ -34,12 +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_detectBadCodeowners = require("./internalLints/detectBadCodeowners");
|
|
37
38
|
var import_noSkubaTemplateJs = require("./internalLints/noSkubaTemplateJs");
|
|
38
39
|
var import_refreshConfigFiles = require("./internalLints/refreshConfigFiles");
|
|
39
40
|
var import_upgrade = require("./internalLints/upgrade");
|
|
40
41
|
const lints = [
|
|
41
42
|
// Run upgradeSkuba before refreshConfigFiles for npmrc handling
|
|
42
|
-
[import_upgrade.upgradeSkuba],
|
|
43
|
+
[import_upgrade.upgradeSkuba, import_detectBadCodeowners.tryDetectBadCodeowners],
|
|
43
44
|
[import_noSkubaTemplateJs.noSkubaTemplateJs, import_refreshConfigFiles.tryRefreshConfigFiles]
|
|
44
45
|
];
|
|
45
46
|
const lintSerially = async (mode, logger) => {
|
|
@@ -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';\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,kBAAwB;AAExB,mBAAkB;AAElB,qBAA0C;AAE1C,+BAAkC;AAClC,gCAAsC;AACtC,qBAA6B;AAc7B,MAAM,QAIF;AAAA;AAAA,EAEF,CAAC,
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport chalk from 'chalk';\n\nimport { type Logger, createLogger } from '../../utils/logging';\n\nimport { tryDetectBadCodeowners } from './internalLints/detectBadCodeowners';\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, tryDetectBadCodeowners],\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,kBAAwB;AAExB,mBAAkB;AAElB,qBAA0C;AAE1C,iCAAuC;AACvC,+BAAkC;AAClC,gCAAsC;AACtC,qBAA6B;AAc7B,MAAM,QAIF;AAAA;AAAA,EAEF,CAAC,6BAAc,iDAAsB;AAAA,EACrC,CAAC,4CAAmB,+CAAqB;AAC3C;AAEA,MAAM,eAAe,OAAO,MAAyB,WAAmB;AACtE,QAAM,UAAgC,CAAC;AACvC,aAAW,aAAa,OAAO;AAC7B,eAAW,QAAQ,WAAW;AAC5B,cAAQ,KAAK,MAAM,KAAK,MAAM,MAAM,CAAC;AAAA,IACvC;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,mBAAmB,OAAO,MAAyB,W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|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Logger } from '../../../utils/logging';
|
|
2
|
+
import type { InternalLintResult } from '../internal';
|
|
3
|
+
export declare const detectBadCodeowners: () => Promise<InternalLintResult>;
|
|
4
|
+
export declare const tryDetectBadCodeowners: (_mode: "format" | "lint", logger: Logger) => Promise<InternalLintResult>;
|
|
@@ -0,0 +1,72 @@
|
|
|
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 detectBadCodeowners_exports = {};
|
|
20
|
+
__export(detectBadCodeowners_exports, {
|
|
21
|
+
detectBadCodeowners: () => detectBadCodeowners,
|
|
22
|
+
tryDetectBadCodeowners: () => tryDetectBadCodeowners
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(detectBadCodeowners_exports);
|
|
25
|
+
var import_util = require("util");
|
|
26
|
+
var import__ = require("../../..");
|
|
27
|
+
var import_project = require("../../configure/analysis/project");
|
|
28
|
+
const detectBadCodeowners = async () => {
|
|
29
|
+
const gitRoot = await import__.Git.findRoot({ dir: process.cwd() });
|
|
30
|
+
const reader = (0, import_project.createDestinationFileReader)(gitRoot ?? process.cwd());
|
|
31
|
+
const annotations = (await Promise.all(
|
|
32
|
+
[".github/CODEOWNERS", "CODEOWNERS", "docs/CODEOWNERS"].map(
|
|
33
|
+
async (filename) => {
|
|
34
|
+
const lines = (await reader(filename))?.split("\n");
|
|
35
|
+
if (lines?.some((line) => line.startsWith("- "))) {
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
message: "CODEOWNERS file has a line starting with `- `. This is probably an autoformatting mistake, where your editor thinks this file is a markdown file and is trying to format a list item. Did you mean to use `*` instead?",
|
|
39
|
+
path: filename
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
)).flat();
|
|
47
|
+
annotations.sort((a, b) => a.path.localeCompare(b.path));
|
|
48
|
+
return {
|
|
49
|
+
ok: annotations.length === 0,
|
|
50
|
+
fixable: false,
|
|
51
|
+
annotations
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const tryDetectBadCodeowners = async (_mode, logger) => {
|
|
55
|
+
try {
|
|
56
|
+
return await detectBadCodeowners();
|
|
57
|
+
} catch (err) {
|
|
58
|
+
logger.warn("Failed to detect bad CODEOWNERS.");
|
|
59
|
+
logger.subtle((0, import_util.inspect)(err));
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
fixable: false,
|
|
63
|
+
annotations: []
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
detectBadCodeowners,
|
|
70
|
+
tryDetectBadCodeowners
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=detectBadCodeowners.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cli/lint/internalLints/detectBadCodeowners.ts"],
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { Git } from '../../..';\nimport type { Logger } from '../../../utils/logging';\nimport { createDestinationFileReader } from '../../configure/analysis/project';\nimport type { InternalLintResult } from '../internal';\n\nexport const detectBadCodeowners = async (): Promise<InternalLintResult> => {\n const gitRoot = await Git.findRoot({ dir: process.cwd() });\n const reader = createDestinationFileReader(gitRoot ?? process.cwd());\n\n const annotations = (\n await Promise.all(\n ['.github/CODEOWNERS', 'CODEOWNERS', 'docs/CODEOWNERS'].map(\n async (filename) => {\n const lines = (await reader(filename))?.split('\\n');\n\n if (lines?.some((line) => line.startsWith('- '))) {\n return [\n {\n message:\n 'CODEOWNERS file has a line starting with `- `. This is probably an autoformatting mistake, where your editor thinks this file is a markdown file and is trying to format a list item. Did you mean to use `*` instead?',\n path: filename,\n },\n ];\n }\n\n return [];\n },\n ),\n )\n ).flat();\n\n // TODO: Use `toSorted` once we drop support for Node 18.\n annotations.sort((a, b) => a.path.localeCompare(b.path));\n\n return {\n ok: annotations.length === 0,\n fixable: false,\n annotations,\n };\n};\n\nexport const tryDetectBadCodeowners = async (\n _mode: 'format' | 'lint',\n logger: Logger,\n): Promise<InternalLintResult> => {\n try {\n return await detectBadCodeowners();\n } catch (err) {\n logger.warn('Failed to detect bad CODEOWNERS.');\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,kBAAwB;AAExB,eAAoB;AAEpB,qBAA4C;AAGrC,MAAM,sBAAsB,YAAyC;AAC1E,QAAM,UAAU,MAAM,aAAI,SAAS,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AACzD,QAAM,aAAS,4CAA4B,WAAW,QAAQ,IAAI,CAAC;AAEnE,QAAM,eACJ,MAAM,QAAQ;AAAA,IACZ,CAAC,sBAAsB,cAAc,iBAAiB,EAAE;AAAA,MACtD,OAAO,aAAa;AAClB,cAAM,SAAS,MAAM,OAAO,QAAQ,IAAI,MAAM,IAAI;AAElD,YAAI,OAAO,KAAK,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,GAAG;AAChD,iBAAO;AAAA,YACL;AAAA,cACE,SACE;AAAA,cACF,MAAM;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF,GACA,KAAK;AAGP,cAAY,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAEvD,SAAO;AAAA,IACL,IAAI,YAAY,WAAW;AAAA,IAC3B,SAAS;AAAA,IACT;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,OACpC,OACA,WACgC;AAChC,MAAI;AACF,WAAO,MAAM,oBAAoB;AAAA,EACnC,SAAS,KAAK;AACZ,WAAO,KAAK,kCAAkC;AAC9C,WAAO,WAAO,qBAAQ,GAAG,CAAC;AAE1B,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS;AAAA,MACT,aAAa,CAAC;AAAA,IAChB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { type ZodRawShape, z } from 'zod';
|
|
2
|
-
export declare const extractFromParentPackageJson: <T extends ZodRawShape>(schema: z.ZodObject<T>) => Promise<
|
|
2
|
+
export declare const extractFromParentPackageJson: <T extends ZodRawShape>(schema: z.ZodObject<T>) => Promise<{
|
|
3
|
+
packageJson: undefined;
|
|
4
|
+
packageJsonRelativePath: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
packageJson: undefined;
|
|
7
|
+
packageJsonRelativePath: string;
|
|
8
|
+
} | {
|
|
9
|
+
packageJson: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never;
|
|
10
|
+
packageJsonRelativePath: string;
|
|
11
|
+
}>;
|
|
3
12
|
export declare const isPatchableServerlessVersion: () => Promise<boolean>;
|
|
4
13
|
export declare const isPatchableSkubaType: () => Promise<boolean>;
|
|
5
14
|
export declare const isPatchableNodeVersion: (targetNodeVersion: number) => Promise<boolean>;
|
|
@@ -42,80 +42,117 @@ var import_logging = require("../../../utils/logging");
|
|
|
42
42
|
const getParentFile = async (file) => {
|
|
43
43
|
const path = await (0, import_find_up.default)(file, { cwd: process.cwd() });
|
|
44
44
|
if (!path) {
|
|
45
|
-
|
|
45
|
+
return void 0;
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return {
|
|
48
|
+
fileContent: await import_fs_extra.default.readFile(path, "utf-8"),
|
|
49
|
+
path
|
|
50
|
+
};
|
|
48
51
|
};
|
|
49
52
|
const extractFromParentPackageJson = async (schema) => {
|
|
50
|
-
const
|
|
53
|
+
const file = await getParentFile("package.json");
|
|
54
|
+
if (!file) {
|
|
55
|
+
return { packageJson: void 0, packageJsonRelativePath: void 0 };
|
|
56
|
+
}
|
|
57
|
+
const { fileContent: packageJson, path } = file;
|
|
51
58
|
let rawJSON;
|
|
52
59
|
try {
|
|
53
60
|
rawJSON = JSON.parse(packageJson);
|
|
54
61
|
} catch {
|
|
55
|
-
throw new Error(
|
|
62
|
+
throw new Error(`${path} is not valid JSON`);
|
|
56
63
|
}
|
|
57
64
|
const result = schema.safeParse(rawJSON);
|
|
58
65
|
if (!result.success) {
|
|
59
|
-
return void 0;
|
|
66
|
+
return { packageJson: void 0, packageJsonRelativePath: path };
|
|
60
67
|
}
|
|
61
|
-
return result.data;
|
|
68
|
+
return { packageJson: result.data, packageJsonRelativePath: path };
|
|
62
69
|
};
|
|
63
70
|
const isPatchableServerlessVersion = async () => {
|
|
64
|
-
const
|
|
71
|
+
const { packageJson, packageJsonRelativePath } = await extractFromParentPackageJson(
|
|
65
72
|
import_zod.z.object({
|
|
66
73
|
devDependencies: import_zod.z.object({
|
|
67
|
-
serverless: import_zod.z.string()
|
|
74
|
+
serverless: import_zod.z.string().optional()
|
|
68
75
|
})
|
|
69
76
|
})
|
|
70
|
-
)
|
|
77
|
+
);
|
|
78
|
+
if (!packageJson) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
"package.json not found, ensure it is in the correct location"
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const serverlessVersion = packageJson?.devDependencies.serverless;
|
|
71
84
|
if (!serverlessVersion) {
|
|
72
|
-
import_logging.log.subtle(
|
|
85
|
+
import_logging.log.subtle(
|
|
86
|
+
`Serverless version not found in ${packageJsonRelativePath}, assuming it is not a dependency`
|
|
87
|
+
);
|
|
73
88
|
return true;
|
|
74
89
|
}
|
|
75
90
|
if (!(0, import_semver.satisfies)(serverlessVersion, "4.x.x")) {
|
|
76
91
|
import_logging.log.warn(
|
|
77
|
-
|
|
92
|
+
`Serverless version ${serverlessVersion} cannot be migrated; use Serverless 4.x to automatically migrate Serverless files`
|
|
78
93
|
);
|
|
79
94
|
return false;
|
|
80
95
|
}
|
|
81
|
-
import_logging.log.ok(
|
|
96
|
+
import_logging.log.ok(
|
|
97
|
+
`Proceeding with migration of Serverless version ${serverlessVersion}`
|
|
98
|
+
);
|
|
82
99
|
return true;
|
|
83
100
|
};
|
|
84
101
|
const isPatchableSkubaType = async () => {
|
|
85
|
-
const
|
|
102
|
+
const { packageJson, packageJsonRelativePath } = await extractFromParentPackageJson(
|
|
86
103
|
import_zod.z.object({
|
|
87
104
|
skuba: import_zod.z.object({
|
|
88
|
-
type: import_zod.z.string()
|
|
105
|
+
type: import_zod.z.string().optional()
|
|
89
106
|
})
|
|
90
107
|
})
|
|
91
|
-
)
|
|
108
|
+
);
|
|
109
|
+
if (!packageJson) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
"package.json not found, ensure it is in the correct location"
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const type = packageJson?.skuba.type;
|
|
92
115
|
if (!type) {
|
|
93
116
|
import_logging.log.warn(
|
|
94
|
-
|
|
117
|
+
`skuba project type not found in ${packageJsonRelativePath}; add a package.json#/skuba/type to ensure the correct migration can be applied`
|
|
95
118
|
);
|
|
96
119
|
return false;
|
|
97
120
|
}
|
|
98
121
|
if (type === "package") {
|
|
99
122
|
import_logging.log.warn(
|
|
100
|
-
"
|
|
123
|
+
"Migrations are not supported for packages; update manually to ensure major runtime deprecations are intended"
|
|
101
124
|
);
|
|
102
125
|
return false;
|
|
103
126
|
}
|
|
104
|
-
import_logging.log.ok(
|
|
127
|
+
import_logging.log.ok(`Proceeding with migration of skuba project type ${type}`);
|
|
105
128
|
return true;
|
|
106
129
|
};
|
|
107
130
|
const isPatchableNodeVersion = async (targetNodeVersion) => {
|
|
108
|
-
const
|
|
131
|
+
const nvmrcFile = await getParentFile(".nvmrc");
|
|
132
|
+
const nodeVersionFile = await getParentFile(".node-version");
|
|
133
|
+
const { packageJson } = await extractFromParentPackageJson(
|
|
134
|
+
import_zod.z.object({
|
|
135
|
+
engines: import_zod.z.object({
|
|
136
|
+
node: import_zod.z.string()
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
const nvmrcNodeVersion = nvmrcFile?.fileContent;
|
|
141
|
+
const nodeVersion = nodeVersionFile?.fileContent;
|
|
142
|
+
const engineVersion = packageJson?.engines.node;
|
|
143
|
+
const currentNodeVersion = nvmrcNodeVersion || nodeVersion || engineVersion;
|
|
109
144
|
const coercedTargetVersion = (0, import_semver.coerce)(targetNodeVersion.toString())?.version;
|
|
110
145
|
const coercedCurrentVersion = (0, import_semver.coerce)(currentNodeVersion)?.version;
|
|
111
146
|
const isNodeVersionValid = coercedTargetVersion && coercedCurrentVersion && (0, import_semver.lte)(coercedCurrentVersion, coercedTargetVersion);
|
|
112
147
|
if (!isNodeVersionValid) {
|
|
113
148
|
import_logging.log.warn(
|
|
114
|
-
`Node
|
|
149
|
+
`Node.js version ${coercedCurrentVersion ?? "unknown"} cannot be migrated to ${coercedTargetVersion}`
|
|
115
150
|
);
|
|
116
151
|
return false;
|
|
117
152
|
}
|
|
118
|
-
import_logging.log.ok(
|
|
153
|
+
import_logging.log.ok(
|
|
154
|
+
`Proceeding with migration from Node.js ${coercedCurrentVersion} to ${coercedTargetVersion}`
|
|
155
|
+
);
|
|
119
156
|
return true;
|
|
120
157
|
};
|
|
121
158
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/migrate/nodeVersion/checks.ts"],
|
|
4
|
-
"sourcesContent": ["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport { coerce, lte, satisfies } from 'semver';\nimport { type ZodRawShape, z } from 'zod';\n\nimport { log } from '../../../utils/logging';\n\nconst getParentFile = async (file: string) => {\n const path = await findUp(file, { cwd: process.cwd() });\n if (!path) {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,sBAAe;AACf,oBAAuC;AACvC,iBAAoC;AAEpC,qBAAoB;AAEpB,MAAM,gBAAgB,OAAO,SAAiB;AAC5C,QAAM,OAAO,UAAM,eAAAA,SAAO,MAAM,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AACtD,MAAI,CAAC,MAAM;AACT,
|
|
4
|
+
"sourcesContent": ["import findUp from 'find-up';\nimport fs from 'fs-extra';\nimport { coerce, lte, satisfies } from 'semver';\nimport { type ZodRawShape, z } from 'zod';\n\nimport { log } from '../../../utils/logging';\n\nconst getParentFile = async (file: string) => {\n const path = await findUp(file, { cwd: process.cwd() });\n if (!path) {\n return undefined;\n }\n return {\n fileContent: await fs.readFile(path, 'utf-8'),\n path,\n };\n};\n\nexport const extractFromParentPackageJson = async <T extends ZodRawShape>(\n schema: z.ZodObject<T>,\n) => {\n const file = await getParentFile('package.json');\n if (!file) {\n return { packageJson: undefined, packageJsonRelativePath: undefined };\n }\n const { fileContent: packageJson, path } = file;\n let rawJSON;\n try {\n rawJSON = JSON.parse(packageJson) as unknown;\n } catch {\n throw new Error(`${path} is not valid JSON`);\n }\n const result = schema.safeParse(rawJSON);\n if (!result.success) {\n return { packageJson: undefined, packageJsonRelativePath: path };\n }\n\n return { packageJson: result.data, packageJsonRelativePath: path };\n};\n\nexport const isPatchableServerlessVersion = async (): Promise<boolean> => {\n const { packageJson, packageJsonRelativePath } =\n await extractFromParentPackageJson(\n z.object({\n devDependencies: z.object({\n serverless: z.string().optional(),\n }),\n }),\n );\n if (!packageJson) {\n throw new Error(\n 'package.json not found, ensure it is in the correct location',\n );\n }\n\n const serverlessVersion = packageJson?.devDependencies.serverless;\n\n if (!serverlessVersion) {\n log.subtle(\n `Serverless version not found in ${packageJsonRelativePath}, assuming it is not a dependency`,\n );\n return true;\n }\n\n if (!satisfies(serverlessVersion, '4.x.x')) {\n log.warn(\n `Serverless version ${serverlessVersion} cannot be migrated; use Serverless 4.x to automatically migrate Serverless files`,\n );\n return false;\n }\n\n log.ok(\n `Proceeding with migration of Serverless version ${serverlessVersion}`,\n );\n return true;\n};\n\nexport const isPatchableSkubaType = async (): Promise<boolean> => {\n const { packageJson, packageJsonRelativePath } =\n await extractFromParentPackageJson(\n z.object({\n skuba: z.object({\n type: z.string().optional(),\n }),\n }),\n );\n\n if (!packageJson) {\n throw new Error(\n 'package.json not found, ensure it is in the correct location',\n );\n }\n\n const type = packageJson?.skuba.type;\n\n if (!type) {\n log.warn(\n `skuba project type not found in ${packageJsonRelativePath}; add a package.json#/skuba/type to ensure the correct migration can be applied`,\n );\n return false;\n }\n if (type === 'package') {\n log.warn(\n 'Migrations are not supported for packages; update manually to ensure major runtime deprecations are intended',\n );\n return false;\n }\n\n log.ok(`Proceeding with migration of skuba project type ${type}`);\n return true;\n};\n\nexport const isPatchableNodeVersion = async (\n targetNodeVersion: number,\n): Promise<boolean> => {\n const nvmrcFile = await getParentFile('.nvmrc');\n const nodeVersionFile = await getParentFile('.node-version');\n const { packageJson } = await extractFromParentPackageJson(\n z.object({\n engines: z.object({\n node: z.string(),\n }),\n }),\n );\n\n const nvmrcNodeVersion = nvmrcFile?.fileContent;\n const nodeVersion = nodeVersionFile?.fileContent;\n const engineVersion = packageJson?.engines.node;\n\n const currentNodeVersion = nvmrcNodeVersion || nodeVersion || engineVersion;\n\n const coercedTargetVersion = coerce(targetNodeVersion.toString())?.version;\n const coercedCurrentVersion = coerce(currentNodeVersion)?.version;\n\n const isNodeVersionValid =\n coercedTargetVersion &&\n coercedCurrentVersion &&\n lte(coercedCurrentVersion, coercedTargetVersion);\n\n if (!isNodeVersionValid) {\n log.warn(\n `Node.js version ${coercedCurrentVersion ?? 'unknown'} cannot be migrated to ${coercedTargetVersion}`,\n );\n return false;\n }\n\n log.ok(\n `Proceeding with migration from Node.js ${coercedCurrentVersion} to ${coercedTargetVersion}`,\n );\n return true;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,sBAAe;AACf,oBAAuC;AACvC,iBAAoC;AAEpC,qBAAoB;AAEpB,MAAM,gBAAgB,OAAO,SAAiB;AAC5C,QAAM,OAAO,UAAM,eAAAA,SAAO,MAAM,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC;AACtD,MAAI,CAAC,MAAM;AACT,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,aAAa,MAAM,gBAAAC,QAAG,SAAS,MAAM,OAAO;AAAA,IAC5C;AAAA,EACF;AACF;AAEO,MAAM,+BAA+B,OAC1C,WACG;AACH,QAAM,OAAO,MAAM,cAAc,cAAc;AAC/C,MAAI,CAAC,MAAM;AACT,WAAO,E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= Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,54 +15,39 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var getNodeTypesVersion_exports = {};
|
|
30
20
|
__export(getNodeTypesVersion_exports, {
|
|
31
21
|
getNodeTypesVersion: () => getNodeTypesVersion
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(getNodeTypesVersion_exports);
|
|
34
|
-
var
|
|
24
|
+
var import_util = require("util");
|
|
35
25
|
var import_semver = require("semver");
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
versions: import_zod.z.record(
|
|
39
|
-
import_zod.z.string(),
|
|
40
|
-
import_zod.z.object({
|
|
41
|
-
name: import_zod.z.string(),
|
|
42
|
-
version: import_zod.z.string(),
|
|
43
|
-
deprecated: import_zod.z.string().optional()
|
|
44
|
-
})
|
|
45
|
-
)
|
|
46
|
-
});
|
|
26
|
+
var import_logging = require("../../../utils/logging");
|
|
27
|
+
var import_version = require("../../../utils/version");
|
|
47
28
|
const getNodeTypesVersion = async (major, defaultVersion) => {
|
|
48
29
|
try {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
Accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
const parsedVersions = NpmFetchResponse.safeParse(response);
|
|
55
|
-
if (!parsedVersions.success) {
|
|
56
|
-
throw new Error("Failed to parse response");
|
|
57
|
-
}
|
|
58
|
-
const version = Object.values(parsedVersions.data.versions).filter(
|
|
30
|
+
const versions = await (0, import_version.getNpmVersions)("@types/node");
|
|
31
|
+
const matchingVersions = Object.values(versions ?? {}).filter(
|
|
59
32
|
(v) => (0, import_semver.valid)(v.version) && (0, import_semver.satisfies)(v.version, `${major}.x.x`) && !v.deprecated
|
|
60
|
-
)
|
|
33
|
+
);
|
|
34
|
+
if (!matchingVersions.length) {
|
|
35
|
+
return {
|
|
36
|
+
version: defaultVersion,
|
|
37
|
+
err: `No matching @types/node versions for Node.js ${major}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const { version } = matchingVersions.reduce(
|
|
41
|
+
(a, b) => (0, import_semver.gt)(a.version, b.version) ? a : b
|
|
42
|
+
);
|
|
61
43
|
return {
|
|
62
44
|
version
|
|
63
45
|
};
|
|
64
|
-
} catch {
|
|
46
|
+
} catch (err) {
|
|
47
|
+
import_logging.log.subtle((0, import_util.inspect)(err));
|
|
65
48
|
return {
|
|
66
49
|
version: defaultVersion,
|
|
67
|
-
err:
|
|
50
|
+
err: `Failed to fetch latest @types/node version, using fallback version ${defaultVersion}`
|
|
68
51
|
};
|
|
69
52
|
}
|
|
70
53
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/cli/migrate/nodeVersion/getNodeTypesVersion.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { inspect } from 'util';\n\nimport { gt, satisfies, valid } from 'semver';\n\nimport { log } from '../../../utils/logging';\nimport { getNpmVersions } from '../../../utils/version';\n\ntype VersionResult = {\n version: string;\n err?: string;\n};\n\nexport const getNodeTypesVersion = async (\n major: number,\n defaultVersion: string,\n): Promise<VersionResult> => {\n try {\n const versions = await getNpmVersions('@types/node');\n\n const matchingVersions = Object.values(versions ?? {}).filter(\n (v) =>\n valid(v.version) &&\n satisfies(v.version, `${major}.x.x`) &&\n !v.deprecated,\n );\n\n if (!matchingVersions.length) {\n return {\n version: defaultVersion,\n err: `No matching @types/node versions for Node.js ${major}`,\n };\n }\n\n const { version } = matchingVersions.reduce((a, b) =>\n gt(a.version, b.version) ? a : b,\n );\n\n return {\n version,\n };\n } catch (err) {\n log.subtle(inspect(err));\n return {\n version: defaultVersion,\n err: `Failed to fetch latest @types/node version, using fallback version ${defaultVersion}`,\n };\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,oBAAqC;AAErC,qBAAoB;AACpB,qBAA+B;AAOxB,MAAM,sBAAsB,OACjC,OACA,mBAC2B;AAC3B,MAAI;AACF,UAAM,WAAW,UAAM,+BAAe,aAAa;AAEnD,UAAM,mBAAmB,OAAO,OAAO,YAAY,CAAC,CAAC,EAAE;AAAA,MACrD,CAAC,UACC,qBAAM,EAAE,OAAO,SACf,yBAAU,EAAE,SAAS,GAAG,KAAK,MAAM,KACnC,CAAC,EAAE;AAAA,IACP;AAEA,QAAI,CAAC,iBAAiB,QAAQ;AAC5B,aAAO;AAAA,QACL,SAAS;AAAA,QACT,KAAK,gDAAgD,KAAK;AAAA,MAC5D;AAAA,IACF;AAEA,UAAM,EAAE,QAAQ,IAAI,iBAAiB;AAAA,MAAO,CAAC,GAAG,UAC9C,kBAAG,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI;AAAA,IACjC;AAEA,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF,SAAS,KAAK;AACZ,uBAAI,WAAO,qBAAQ,GAAG,CAAC;AACvB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,KAAK,sEAAsE,cAAc;AAAA,IAC3F;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -55,32 +55,28 @@ const subPatches = ({
|
|
|
55
55
|
regex: /^FROM(.*) gcr.io\/distroless\/nodejs\d+-debian(\d+)(@sha256:[a-f0-9]{64})?(\.[^- \n]+)?(-[^ \n]+)?( .+|)$/gm,
|
|
56
56
|
replace: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$2$4$5$6`
|
|
57
57
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
regex: /(target:\s*'node)(\d+)(.+)$/gm,
|
|
81
|
-
replace: `$1${nodeVersion}$3`
|
|
82
|
-
}
|
|
83
|
-
],
|
|
58
|
+
{
|
|
59
|
+
files: "**/serverless*.y*ml",
|
|
60
|
+
regex: /\bnodejs\d+.x\b/gm,
|
|
61
|
+
tests: [import_checks.isPatchableServerlessVersion],
|
|
62
|
+
replace: `nodejs${nodeVersion}.x`
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
files: "**/serverless*.y*ml",
|
|
66
|
+
regex: /\bnode\d+\b/gm,
|
|
67
|
+
tests: [import_checks.isPatchableServerlessVersion],
|
|
68
|
+
replace: `node${nodeVersion}`
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
files: "**/infra/**/*.ts",
|
|
72
|
+
regex: /NODEJS_\d+_X/g,
|
|
73
|
+
replace: `NODEJS_${nodeVersion}_X`
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
files: "**/infra/**/*.ts",
|
|
77
|
+
regex: /(target:\s*'node)(\d+)(.+)$/gm,
|
|
78
|
+
replace: `$1${nodeVersion}$3`
|
|
79
|
+
},
|
|
84
80
|
{
|
|
85
81
|
files: "**/.buildkite/*",
|
|
86
82
|
regex: /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
@@ -88,37 +84,33 @@ const subPatches = ({
|
|
|
88
84
|
},
|
|
89
85
|
{
|
|
90
86
|
files: ".node-version*",
|
|
91
|
-
regex: /(
|
|
92
|
-
replace: `$
|
|
87
|
+
regex: /(\d+(?:\.\d+)*)/g,
|
|
88
|
+
replace: `${nodeVersion}`
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
files: "**/package.json",
|
|
92
|
+
regex: /("@types\/node":\s*")(\^)?(\d+\.\d+\.\d+)(")/gm,
|
|
93
|
+
tests: [import_checks.isPatchableServerlessVersion],
|
|
94
|
+
replace: `$1$2${nodeTypesVersion}$4`
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
files: "**/package.json",
|
|
98
|
+
regex: /(["']engines["']:\s*{[\s\S]*?["']node["']:\s*["']>=)(\d+(?:\.\d+)*)(['"]\s*})/gm,
|
|
99
|
+
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
100
|
+
replace: `$1${nodeVersion}$3`
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
files: "**/tsconfig*.json",
|
|
104
|
+
regex: /("target":\s*")(ES\d+)"/gim,
|
|
105
|
+
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
106
|
+
replace: `$1${ECMAScriptVersion}"`
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
files: "**/tsconfig*.json",
|
|
110
|
+
regex: /("lib":\s*\[)([\S\s]*?)(ES\d+)([\S\s]*?)(\])/gim,
|
|
111
|
+
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
112
|
+
replace: `$1$2${ECMAScriptVersion}$4$5`
|
|
93
113
|
},
|
|
94
|
-
[
|
|
95
|
-
{
|
|
96
|
-
files: "**/package.json",
|
|
97
|
-
regex: /(\\?"@types\/node\\?": \\?")(\^)?[0-9.]+(\\?(",?)\\?n?)/gm,
|
|
98
|
-
tests: [import_checks.isPatchableServerlessVersion],
|
|
99
|
-
replace: `$1$2${nodeTypesVersion}$4`
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
files: "**/package.json",
|
|
103
|
-
regex: /(\\?"engines\\?":\s*{\\?n?[^}]*\\?"node\\?":\s*\\?">=)(\d+)\\?("[^}]*})(?![^}]*\\?"skuba\\?":\s*{\\?n?[^}]*\\?"type\\?":\s*\\?"package\\?")/gm,
|
|
104
|
-
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
105
|
-
replace: `$1${nodeVersion}$3`
|
|
106
|
-
}
|
|
107
|
-
],
|
|
108
|
-
[
|
|
109
|
-
{
|
|
110
|
-
files: "**/tsconfig*.json",
|
|
111
|
-
regex: /("target":\s*")(ES\d+)"/gim,
|
|
112
|
-
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
113
|
-
replace: `$1${ECMAScriptVersion}"`
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
files: "**/tsconfig*.json",
|
|
117
|
-
regex: /("lib":\s*\[)([\S\s]*?)(ES\d+)([\S\s]*?)(\])/gim,
|
|
118
|
-
tests: [import_checks.isPatchableServerlessVersion, import_checks.isPatchableSkubaType],
|
|
119
|
-
replace: `$1$2${ECMAScriptVersion}$4$5`
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
114
|
{
|
|
123
115
|
files: "**/docker-compose*.y*ml",
|
|
124
116
|
regex: /(image: )(public.ecr.aws\/docker\/library\/)?(node:)[0-9.]+(\.[^- \n]+)?(-[^ \n]+)?$/gm,
|
|
@@ -126,12 +118,6 @@ const subPatches = ({
|
|
|
126
118
|
}
|
|
127
119
|
];
|
|
128
120
|
const runSubPatch = async (dir, patch) => {
|
|
129
|
-
if (Array.isArray(patch)) {
|
|
130
|
-
for (const subPatch of patch) {
|
|
131
|
-
await runSubPatch(dir, subPatch);
|
|
132
|
-
}
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
121
|
const readFile = (0, import_project.createDestinationFileReader)(dir);
|
|
136
122
|
const paths = patch.file ? [patch.file] : await (0, import_fast_glob.glob)(patch.files ?? [], { cwd: dir });
|
|
137
123
|
await Promise.all(
|
|
@@ -171,9 +157,9 @@ const writePatchedContents = async ({
|
|
|
171
157
|
regex ? contents.replaceAll(regex, templated) : templated
|
|
172
158
|
);
|
|
173
159
|
const upgrade = async (versions, dir) => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
160
|
+
for (const subPatch of subPatches(versions)) {
|
|
161
|
+
await runSubPatch(dir, subPatch);
|
|
162
|
+
}
|
|
177
163
|
};
|
|
178
164
|
const nodeVersionMigration = async ({
|
|
179
165
|
nodeVersion,
|
|
@@ -183,7 +169,7 @@ const nodeVersionMigration = async ({
|
|
|
183
169
|
import_logging.log.ok(`Upgrading to Node.js ${nodeVersion}`);
|
|
184
170
|
try {
|
|
185
171
|
if (!await (0, import_checks.isPatchableNodeVersion)(nodeVersion)) {
|
|
186
|
-
throw new Error("Node version is not patchable");
|
|
172
|
+
throw new Error("Node.js version is not patchable");
|
|
187
173
|
}
|
|
188
174
|
const { version: nodeTypesVersion, err } = await (0, import_getNodeTypesVersion.getNodeTypesVersion)(
|
|
189
175
|
nodeVersion,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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\nimport {\n isPatchableNodeVersion,\n isPatchableServerlessVersion,\n isPatchableSkubaType,\n} from './checks';\nimport { getNodeTypesVersion } from './getNodeTypesVersion';\n\ntype FileSelector =\n | { files: string; file?: never }\n | { file: string; files?: never };\n\ntype SubPatch = FileSelector & {\n tests?: Array<() => Promise<boolean>>;\n regex?: RegExp;\n replace: string;\n};\n\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AACpB,qBAA4C;AAE5C,oBAIO;AACP,iCAAoC;
|
|
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\nimport {\n isPatchableNodeVersion,\n isPatchableServerlessVersion,\n isPatchableSkubaType,\n} from './checks';\nimport { getNodeTypesVersion } from './getNodeTypesVersion';\n\ntype FileSelector =\n | { files: string; file?: never }\n | { file: string; files?: never };\n\ntype SubPatch = FileSelector & {\n tests?: Array<() => Promise<boolean>>;\n regex?: RegExp;\n replace: string;\n};\n\nconst subPatches = ({\n nodeVersion,\n nodeTypesVersion,\n ECMAScriptVersion,\n}: Versions): SubPatch[] => [\n { file: '.nvmrc', replace: `${nodeVersion}\\n` },\n {\n files: '**/Dockerfile*',\n\n regex:\n /^FROM(.*) (public.ecr.aws\\/docker\\/library\\/)?node:([0-9]+(?:\\.[0-9]+(?:\\.[0-9]+)?)?)(-[a-z0-9]+)?(@sha256:[a-f0-9]{64})?( .*)?$/gm,\n replace: `FROM$1 $2node:${nodeVersion}$4$6`,\n },\n {\n files: '**/Dockerfile*',\n regex:\n /^FROM(.*) gcr.io\\/distroless\\/nodejs\\d+-debian(\\d+)(@sha256:[a-f0-9]{64})?(\\.[^- \\n]+)?(-[^ \\n]+)?( .+|)$/gm,\n replace: `FROM$1 gcr.io/distroless/nodejs${nodeVersion}-debian$2$4$5$6`,\n },\n\n {\n files: '**/serverless*.y*ml',\n regex: /\\bnodejs\\d+.x\\b/gm,\n tests: [isPatchableServerlessVersion],\n replace: `nodejs${nodeVersion}.x`,\n },\n {\n files: '**/serverless*.y*ml',\n regex: /\\bnode\\d+\\b/gm,\n tests: [isPatchableServerlessVersion],\n replace: `node${nodeVersion}`,\n },\n\n {\n files: '**/infra/**/*.ts',\n regex: /NODEJS_\\d+_X/g,\n replace: `NODEJS_${nodeVersion}_X`,\n },\n {\n files: '**/infra/**/*.ts',\n regex: /(target:\\s*'node)(\\d+)(.+)$/gm,\n replace: `$1${nodeVersion}$3`,\n },\n\n {\n files: '**/.buildkite/*',\n regex:\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n replace: `$1$2$3${nodeVersion}$5`,\n },\n {\n files: '.node-version*',\n regex: /(\\d+(?:\\.\\d+)*)/g,\n replace: `${nodeVersion}`,\n },\n\n {\n files: '**/package.json',\n regex: /(\"@types\\/node\":\\s*\")(\\^)?(\\d+\\.\\d+\\.\\d+)(\")/gm,\n tests: [isPatchableServerlessVersion],\n replace: `$1$2${nodeTypesVersion}$4`,\n },\n {\n files: '**/package.json',\n regex:\n /([\"']engines[\"']:\\s*{[\\s\\S]*?[\"']node[\"']:\\s*[\"']>=)(\\d+(?:\\.\\d+)*)(['\"]\\s*})/gm,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1${nodeVersion}$3`,\n },\n\n {\n files: '**/tsconfig*.json',\n regex: /(\"target\":\\s*\")(ES\\d+)\"/gim,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1${ECMAScriptVersion}\"`,\n },\n {\n files: '**/tsconfig*.json',\n regex: /(\"lib\":\\s*\\[)([\\S\\s]*?)(ES\\d+)([\\S\\s]*?)(\\])/gim,\n tests: [isPatchableServerlessVersion, isPatchableSkubaType],\n replace: `$1$2${ECMAScriptVersion}$4$5`,\n },\n\n {\n files: '**/docker-compose*.y*ml',\n regex:\n /(image: )(public.ecr.aws\\/docker\\/library\\/)?(node:)[0-9.]+(\\.[^- \\n]+)?(-[^ \\n]+)?$/gm,\n\n replace: `$1$2$3${nodeVersion}$5`,\n },\n];\n\ntype Versions = {\n nodeVersion: number;\n nodeTypesVersion: string;\n ECMAScriptVersion: string;\n};\n\nconst runSubPatch = async (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 if (path.includes('node_modules')) {\n return;\n }\n const contents = await readFile(path);\n if (!contents) {\n return;\n }\n\n if (patch.regex && !patch.regex.test(contents)) {\n return;\n }\n\n if (patch.tests) {\n const results = await Promise.all(patch.tests.map((test) => test()));\n if (!results.every(Boolean)) {\n return;\n }\n }\n\n await writePatchedContents({\n path,\n contents,\n templated: patch.replace,\n regex: patch.regex,\n });\n }),\n );\n};\n\nconst writePatchedContents = async ({\n path,\n contents,\n templated,\n regex,\n}: {\n path: string;\n contents: string;\n templated: string;\n regex?: RegExp;\n}) =>\n await fs.promises.writeFile(\n path,\n regex ? contents.replaceAll(regex, templated) : templated,\n );\n\nconst upgrade = async (versions: Versions, dir: string) => {\n for (const subPatch of subPatches(versions)) {\n await runSubPatch(dir, subPatch);\n }\n};\n\nexport const nodeVersionMigration = async (\n {\n nodeVersion,\n ECMAScriptVersion,\n defaultNodeTypesVersion,\n }: {\n nodeVersion: number;\n ECMAScriptVersion: string;\n defaultNodeTypesVersion: string;\n },\n dir = process.cwd(),\n) => {\n log.ok(`Upgrading to Node.js ${nodeVersion}`);\n try {\n if (!(await isPatchableNodeVersion(nodeVersion))) {\n throw new Error('Node.js version is not patchable');\n }\n\n const { version: nodeTypesVersion, err } = await getNodeTypesVersion(\n nodeVersion,\n defaultNodeTypesVersion,\n );\n if (err) {\n log.warn(err);\n }\n await upgrade({ nodeVersion, nodeTypesVersion, ECMAScriptVersion }, dir);\n log.ok('Upgraded to Node.js', nodeVersion);\n } catch (error) {\n log.err('Failed to upgrade');\n log.subtle(inspect(error));\n process.exitCode = 1;\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAExB,uBAAqB;AACrB,sBAAe;AAEf,qBAAoB;AACpB,qBAA4C;AAE5C,oBAIO;AACP,iCAAoC;AAYpC,MAAM,aAAa,CAAC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF,MAA4B;AAAA,EAC1B,EAAE,MAAM,UAAU,SAAS,GAAG,WAAW;AAAA,EAAK;AAAA,EAC9C;AAAA,IACE,OAAO;AAAA,IAEP,OACE;AAAA,IACF,SAAS,iBAAiB,WAAW;AAAA,EACvC;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OACE;AAAA,IACF,SAAS,kCAAkC,WAAW;AAAA,EACxD;AAAA,EAEA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO,CAAC,0CAA4B;AAAA,IACpC,SAAS,SAAS,WAAW;AAAA,EAC/B;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,OAAO,CAAC,0CAA4B;AAAA,IACpC,SAAS,OAAO,WAAW;AAAA,EAC7B;AAAA,EAEA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS,UAAU,WAAW;AAAA,EAChC;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS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|
|
6
6
|
"names": ["fs"]
|
|
7
7
|
}
|
package/lib/utils/copy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type TextProcessor = (contents: string) => string;
|
|
1
|
+
export type TextProcessor = (sourcePath: string, contents: string) => string;
|
|
2
2
|
export declare const copyFile: (sourcePath: string, destinationPath: string, { overwrite, processors, }: Pick<CopyFilesOptions, "overwrite" | "processors">) => Promise<void>;
|
|
3
3
|
interface CopyFilesOptions {
|
|
4
4
|
sourceRoot: string;
|
package/lib/utils/copy.js
CHANGED
|
@@ -45,7 +45,7 @@ const copyFile = async (sourcePath, destinationPath, {
|
|
|
45
45
|
}) => {
|
|
46
46
|
const oldContents = await import_fs_extra.default.promises.readFile(sourcePath, "utf8");
|
|
47
47
|
const newContents = processors.reduce(
|
|
48
|
-
(contents, process) => process(contents),
|
|
48
|
+
(contents, process) => process(sourcePath, contents),
|
|
49
49
|
oldContents
|
|
50
50
|
);
|
|
51
51
|
if (oldContents === newContents && sourcePath === destinationPath) {
|
|
@@ -62,8 +62,16 @@ const copyFile = async (sourcePath, destinationPath, {
|
|
|
62
62
|
throw err;
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
const createEjsRenderer = (templateData) => (contents) =>
|
|
66
|
-
|
|
65
|
+
const createEjsRenderer = (templateData) => (sourcePath, contents) => {
|
|
66
|
+
try {
|
|
67
|
+
return import_ejs.default.render(contents, templateData, { strict: false });
|
|
68
|
+
} catch (err) {
|
|
69
|
+
import_logging.log.err("Failed to render", import_logging.log.bold(sourcePath));
|
|
70
|
+
import_logging.log.subtle(err);
|
|
71
|
+
return contents;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const createStringReplacer = (replacements) => (_sourcePath, contents) => replacements.reduce(
|
|
67
75
|
(newContents, { input, output }) => newContents.replace(input, output),
|
|
68
76
|
contents
|
|
69
77
|
);
|
package/lib/utils/copy.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/copy.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\n\nimport ejs from 'ejs';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from './error';\nimport { log } from './logging';\n\nexport type TextProcessor = (contents: string) => string;\n\nexport const copyFile = async (\n sourcePath: string,\n destinationPath: string,\n {\n overwrite = true,\n processors,\n }: Pick<CopyFilesOptions, 'overwrite' | 'processors'>,\n) => {\n const oldContents = await fs.promises.readFile(sourcePath, 'utf8');\n\n const newContents = processors.reduce(\n (contents, process) => process(contents),\n oldContents,\n );\n\n if (oldContents === newContents && sourcePath === destinationPath) {\n return;\n }\n\n try {\n await fs.promises.writeFile(destinationPath, newContents, {\n flag: overwrite ? 'w' : 'wx',\n });\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n return;\n }\n\n throw err;\n }\n};\n\ninterface CopyFilesOptions {\n sourceRoot: string;\n destinationRoot: string;\n\n include: (pathname: string) => boolean;\n overwrite?: boolean;\n processors: TextProcessor[];\n stripUnderscorePrefix?: boolean;\n}\n\nexport const createEjsRenderer =\n (templateData: Record<string, unknown>): TextProcessor =>\n (contents)
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAAgB;AAChB,sBAAe;AAEf,mBAAgC;AAChC,qBAAoB;AAIb,MAAM,WAAW,OACtB,YACA,iBACA;AAAA,EACE,YAAY;AAAA,EACZ;AACF,MACG;AACH,QAAM,cAAc,MAAM,gBAAAA,QAAG,SAAS,SAAS,YAAY,MAAM;AAEjE,QAAM,cAAc,WAAW;AAAA,IAC7B,CAAC,UAAU,YAAY,QAAQ,QAAQ;AAAA,
|
|
4
|
+
"sourcesContent": ["import path from 'path';\n\nimport ejs from 'ejs';\nimport fs from 'fs-extra';\n\nimport { isErrorWithCode } from './error';\nimport { log } from './logging';\n\nexport type TextProcessor = (sourcePath: string, contents: string) => string;\n\nexport const copyFile = async (\n sourcePath: string,\n destinationPath: string,\n {\n overwrite = true,\n processors,\n }: Pick<CopyFilesOptions, 'overwrite' | 'processors'>,\n) => {\n const oldContents = await fs.promises.readFile(sourcePath, 'utf8');\n\n const newContents = processors.reduce(\n (contents, process) => process(sourcePath, contents),\n oldContents,\n );\n\n if (oldContents === newContents && sourcePath === destinationPath) {\n return;\n }\n\n try {\n await fs.promises.writeFile(destinationPath, newContents, {\n flag: overwrite ? 'w' : 'wx',\n });\n } catch (err) {\n if (isErrorWithCode(err, 'EEXIST')) {\n return;\n }\n\n throw err;\n }\n};\n\ninterface CopyFilesOptions {\n sourceRoot: string;\n destinationRoot: string;\n\n include: (pathname: string) => boolean;\n overwrite?: boolean;\n processors: TextProcessor[];\n stripUnderscorePrefix?: boolean;\n}\n\nexport const createEjsRenderer =\n (templateData: Record<string, unknown>): TextProcessor =>\n (sourcePath: string, contents) => {\n try {\n return ejs.render(contents, templateData, { strict: false });\n } catch (err) {\n log.err('Failed to render', log.bold(sourcePath));\n log.subtle(err);\n return contents;\n }\n };\n\nexport const createStringReplacer =\n (\n replacements: Array<{\n input: RegExp;\n output: string;\n }>,\n ): TextProcessor =>\n (_sourcePath: string, contents) =>\n replacements.reduce(\n (newContents, { input, output }) => newContents.replace(input, output),\n contents,\n );\n\nexport const copyFiles = async (\n opts: CopyFilesOptions,\n currentSourceDir: string = opts.sourceRoot,\n currentDestinationDir: string = opts.destinationRoot,\n) => {\n const filenames = await fs.promises.readdir(currentSourceDir);\n\n const toDestinationPath = (filename: string) =>\n path.join(\n currentDestinationDir,\n opts.stripUnderscorePrefix\n ? filename\n .replace(/^_\\./, '.')\n .replace(/^_package\\.json/, 'package.json')\n .replace(/^_eslint\\.config\\.js/, 'eslint.config.js')\n : filename,\n );\n\n const filteredFilenames = filenames.filter((filename) =>\n opts.include(\n path.relative(opts.destinationRoot, toDestinationPath(filename)),\n ),\n );\n\n await Promise.all(\n filteredFilenames.map(async (filename) => {\n const sourcePath = path.join(currentSourceDir, filename);\n const destinationPath = toDestinationPath(filename);\n\n try {\n await copyFile(sourcePath, destinationPath, opts);\n } catch (err) {\n if (isErrorWithCode(err, 'EISDIR')) {\n await fs.promises.mkdir(destinationPath, { recursive: true });\n return copyFiles(opts, sourcePath, destinationPath);\n }\n\n log.err('Failed to render', log.bold(sourcePath));\n\n throw err;\n }\n }),\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,iBAAgB;AAChB,sBAAe;AAEf,mBAAgC;AAChC,qBAAoB;AAIb,MAAM,WAAW,OACtB,YACA,iBACA;AAAA,EACE,YAAY;AAAA,EACZ;AACF,MACG;AACH,QAAM,cAAc,MAAM,gBAAAA,QAAG,SAAS,SAAS,YAAY,MAAM;AAEjE,QAAM,cAAc,WAAW;AAAA,IAC7B,CAAC,UAAU,YAAY,QAAQ,YAAY,QAAQ;AAAA,IACnD;AAAA,EACF;AAEA,MAAI,gBAAgB,eAAe,eAAe,iBAAiB;AACjE;AAAA,EACF;AAEA,MAAI;AACF,UAAM,gBAAAA,QAAG,SAAS,UAAU,iBAAiB,aAAa;AAAA,MACxD,MAAM,YAAY,MAAM;AAAA,IAC1B,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,YAAI,8BAAgB,KAAK,QAAQ,GAAG;AAClC;AAAA,IACF;AAEA,UAAM;AAAA,EACR;AACF;AAYO,MAAM,oBACX,CAAC,iBACD,CAAC,YAAoB,aAAa;AAChC,MAAI;AACF,WAAO,WAAAC,QAAI,OAAO,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC7D,SAAS,KAAK;AACZ,uBAAI,IAAI,oBAAoB,mBAAI,KAAK,UAAU,CAAC;AAChD,uBAAI,OAAO,GAAG;AACd,WAAO;AAAA,EACT;AACF;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';
|
|
2
|
+
declare const NpmVersions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
version: z.ZodString;
|
|
5
|
+
deprecated: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
deprecated?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
deprecated?: string | undefined;
|
|
14
|
+
}>>;
|
|
15
|
+
export type NpmVersions = z.infer<typeof NpmVersions>;
|
|
16
|
+
export declare const getNpmVersions: (packageName: string) => Promise<NpmVersions | null>;
|
|
17
|
+
export declare const getLatestNpmVersion: (packageName: string) => Promise<string | null>;
|
|
2
18
|
export declare const getSkubaVersion: () => Promise<string>;
|
|
3
19
|
type SkubaVersionInfo = {
|
|
4
20
|
isStale: true;
|
package/lib/utils/version.js
CHANGED
|
@@ -28,31 +28,60 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var version_exports = {};
|
|
30
30
|
__export(version_exports, {
|
|
31
|
+
getLatestNpmVersion: () => getLatestNpmVersion,
|
|
32
|
+
getNpmVersions: () => getNpmVersions,
|
|
31
33
|
getSkubaVersion: () => getSkubaVersion,
|
|
32
|
-
getSkubaVersionInfo: () => getSkubaVersionInfo
|
|
33
|
-
latestNpmVersion: () => latestNpmVersion
|
|
34
|
+
getSkubaVersionInfo: () => getSkubaVersionInfo
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(version_exports);
|
|
36
|
-
var
|
|
37
|
-
var
|
|
37
|
+
var import_npm_registry_fetch = __toESM(require("npm-registry-fetch"));
|
|
38
|
+
var import_zod = require("zod");
|
|
38
39
|
var import_manifest = require("./manifest");
|
|
39
40
|
var import_wait = require("./wait");
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
const NpmVersions = import_zod.z.record(
|
|
42
|
+
import_zod.z.string(),
|
|
43
|
+
import_zod.z.object({
|
|
44
|
+
name: import_zod.z.string(),
|
|
45
|
+
version: import_zod.z.string(),
|
|
46
|
+
deprecated: import_zod.z.string().optional()
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
const PackageResponse = import_zod.z.object({
|
|
50
|
+
"dist-tags": import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional(),
|
|
51
|
+
versions: NpmVersions
|
|
52
|
+
});
|
|
53
|
+
const getNpmPackage = async (packageName) => {
|
|
54
|
+
try {
|
|
55
|
+
const response = await import_npm_registry_fetch.default.json(packageName, {
|
|
56
|
+
headers: {
|
|
57
|
+
Accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const parsedResponse = PackageResponse.safeParse(response);
|
|
61
|
+
if (!parsedResponse.success) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Failed to parse package response from npm for package ${packageName}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return parsedResponse.data;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error instanceof Error && "statusCode" in error && error.statusCode === 404) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
throw error;
|
|
50
72
|
}
|
|
51
|
-
|
|
73
|
+
};
|
|
74
|
+
const getNpmVersions = async (packageName) => {
|
|
75
|
+
const response = await getNpmPackage(packageName);
|
|
76
|
+
return response?.versions ?? null;
|
|
77
|
+
};
|
|
78
|
+
const getLatestNpmVersion = async (packageName) => {
|
|
79
|
+
const response = await getNpmPackage(packageName);
|
|
80
|
+
return response?.["dist-tags"]?.latest ?? null;
|
|
52
81
|
};
|
|
53
82
|
const latestSkubaVersion = async () => {
|
|
54
83
|
try {
|
|
55
|
-
const result = await (0, import_wait.withTimeout)(
|
|
84
|
+
const result = await (0, import_wait.withTimeout)(getLatestNpmVersion("skuba"), { s: 2 });
|
|
56
85
|
return result.ok ? result.value : null;
|
|
57
86
|
} catch {
|
|
58
87
|
return null;
|
|
@@ -82,8 +111,9 @@ const getSkubaVersionInfo = async () => {
|
|
|
82
111
|
};
|
|
83
112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
113
|
0 && (module.exports = {
|
|
114
|
+
getLatestNpmVersion,
|
|
115
|
+
getNpmVersions,
|
|
85
116
|
getSkubaVersion,
|
|
86
|
-
getSkubaVersionInfo
|
|
87
|
-
latestNpmVersion
|
|
117
|
+
getSkubaVersionInfo
|
|
88
118
|
});
|
|
89
119
|
//# sourceMappingURL=version.js.map
|
package/lib/utils/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/version.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import npmFetch from 'npm-registry-fetch';\nimport { z } from 'zod';\n\nimport { getSkubaManifest } from './manifest';\nimport { withTimeout } from './wait';\n\nconst NpmVersions = z.record(\n z.string(),\n z.object({\n name: z.string(),\n version: z.string(),\n deprecated: z.string().optional(),\n }),\n);\n\nexport type NpmVersions = z.infer<typeof NpmVersions>;\n\nconst PackageResponse = z.object({\n 'dist-tags': z.record(z.string(), z.string()).optional(),\n versions: NpmVersions,\n});\n\nconst getNpmPackage = async (packageName: string) => {\n try {\n const response = await npmFetch.json(packageName, {\n headers: {\n Accept:\n 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',\n },\n });\n\n const parsedResponse = PackageResponse.safeParse(response);\n if (!parsedResponse.success) {\n throw new Error(\n `Failed to parse package response from npm for package ${packageName}`,\n );\n }\n\n return parsedResponse.data;\n } catch (error) {\n if (\n error instanceof Error &&\n 'statusCode' in error &&\n error.statusCode === 404\n ) {\n return null;\n }\n throw error;\n }\n};\n\nexport const getNpmVersions = async (\n packageName: string,\n): Promise<NpmVersions | null> => {\n const response = await getNpmPackage(packageName);\n return response?.versions ?? null;\n};\n\nexport const getLatestNpmVersion = async (\n packageName: string,\n): Promise<string | null> => {\n const response = await getNpmPackage(packageName);\n return response?.['dist-tags']?.latest ?? null;\n};\n\nconst latestSkubaVersion = async (): Promise<string | null> => {\n try {\n const result = await withTimeout(getLatestNpmVersion('skuba'), { s: 2 });\n\n return result.ok ? result.value : null;\n } catch {\n return null;\n }\n};\n\nexport const getSkubaVersion = async (): Promise<string> => {\n const { version } = await getSkubaManifest();\n\n return version;\n};\n\ntype SkubaVersionInfo =\n | {\n isStale: true;\n\n local: string;\n latest: string;\n }\n | {\n isStale: false;\n\n local: string;\n latest: string | null;\n };\n\nexport const getSkubaVersionInfo = async (): Promise<SkubaVersionInfo> => {\n const [local, latest] = await Promise.all([\n getSkubaVersion(),\n latestSkubaVersion(),\n ]);\n\n if (latest === null) {\n // Assume we're up to date if we can't reach the npm registry\n return {\n isStale: false,\n local,\n latest,\n };\n }\n\n return {\n isStale: latest !== local,\n local,\n latest,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAqB;AACrB,iBAAkB;AAElB,sBAAiC;AACjC,kBAA4B;AAE5B,MAAM,cAAc,aAAE;AAAA,EACpB,aAAE,OAAO;AAAA,EACT,aAAE,OAAO;AAAA,IACP,MAAM,aAAE,OAAO;AAAA,IACf,SAAS,aAAE,OAAO;AAAA,IAClB,YAAY,aAAE,OAAO,EAAE,SAAS;AAAA,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AmB;AAAA,EACrB,CAAC;AAED,MAAI,WAAW,MAAM;AAEnB,WAAO;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,SAAS,WAAW;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["npmFetch"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skuba",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
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",
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"isomorphic-git": "^1.11.1",
|
|
79
79
|
"jest": "^29.0.1",
|
|
80
80
|
"jest-watch-typeahead": "^2.1.1",
|
|
81
|
-
"libnpmsearch": "^8.0.0",
|
|
82
81
|
"lodash.mergewith": "^4.6.2",
|
|
83
82
|
"minimist": "^1.2.6",
|
|
84
83
|
"normalize-package-data": "^7.0.0",
|
|
@@ -97,13 +96,12 @@
|
|
|
97
96
|
"tsconfig-paths": "^4.0.0",
|
|
98
97
|
"tsconfig-seek": "2.0.0",
|
|
99
98
|
"tsx": "^4.16.2",
|
|
100
|
-
"typescript": "~5.
|
|
101
|
-
"validate-npm-package-name": "^6.0.0",
|
|
99
|
+
"typescript": "~5.8.0",
|
|
102
100
|
"zod": "^3.22.4",
|
|
103
|
-
"eslint-config-skuba": "5.1.0
|
|
101
|
+
"eslint-config-skuba": "5.1.0"
|
|
104
102
|
},
|
|
105
103
|
"devDependencies": {
|
|
106
|
-
"@changesets/cli": "2.
|
|
104
|
+
"@changesets/cli": "2.28.1",
|
|
107
105
|
"@changesets/get-github-info": "0.6.0",
|
|
108
106
|
"@jest/reporters": "29.7.0",
|
|
109
107
|
"@jest/test-result": "29.7.0",
|
|
@@ -111,7 +109,6 @@
|
|
|
111
109
|
"@types/express": "5.0.0",
|
|
112
110
|
"@types/fs-extra": "11.0.4",
|
|
113
111
|
"@types/koa": "2.15.0",
|
|
114
|
-
"@types/libnpmsearch": "2.0.7",
|
|
115
112
|
"@types/lodash.mergewith": "4.6.9",
|
|
116
113
|
"@types/minimist": "1.2.5",
|
|
117
114
|
"@types/module-alias": "2.0.4",
|
|
@@ -120,13 +117,12 @@
|
|
|
120
117
|
"@types/picomatch": "3.0.2",
|
|
121
118
|
"@types/semver": "7.5.8",
|
|
122
119
|
"@types/supertest": "6.0.2",
|
|
123
|
-
"@types/validate-npm-package-name": "4.0.2",
|
|
124
120
|
"enhanced-resolve": "5.18.1",
|
|
125
121
|
"express": "5.0.1",
|
|
126
122
|
"fastify": "5.2.1",
|
|
127
123
|
"jest-diff": "29.7.0",
|
|
128
124
|
"jsonfile": "6.1.0",
|
|
129
|
-
"koa": "2.
|
|
125
|
+
"koa": "2.16.0",
|
|
130
126
|
"memfs": "4.17.0",
|
|
131
127
|
"remark-cli": "12.0.1",
|
|
132
128
|
"remark-preset-lint-recommended": "7.0.1",
|
|
@@ -153,7 +149,7 @@
|
|
|
153
149
|
"entryPoint": "src/index.ts",
|
|
154
150
|
"template": null,
|
|
155
151
|
"type": "package",
|
|
156
|
-
"version": "
|
|
152
|
+
"version": "10.0.0"
|
|
157
153
|
},
|
|
158
154
|
"scripts": {
|
|
159
155
|
"build": "scripts/build.sh",
|
|
@@ -9,5 +9,4 @@ image: '{{values "prodAccountId"}}.dkr.ecr.<%- region %>.amazonaws.com/{{values
|
|
|
9
9
|
# datadogSecretId: arn:aws:secretsmanager:<%- region %>:<aws-account-id>:secret:<secret-name>
|
|
10
10
|
|
|
11
11
|
tags:
|
|
12
|
-
seek:source:url: 'https://github.com/SEEK-Jobs/<%- repoName %>'
|
|
13
12
|
# seek:system:name: 'TODO: https://rfc.skinfra.xyz/RFC051-AWS-Tagging-Standard.html#tagging-schema'
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/express": "^5.0.0",
|
|
24
|
-
"@types/node": "^22.13.
|
|
24
|
+
"@types/node": "^22.13.10",
|
|
25
25
|
"@types/supertest": "^6.0.0",
|
|
26
26
|
"mime": "^4.0.1",
|
|
27
27
|
"pino-pretty": "^13.0.0",
|
|
28
28
|
"skuba": "*",
|
|
29
29
|
"supertest": "^7.0.0"
|
|
30
30
|
},
|
|
31
|
-
"packageManager": "pnpm@
|
|
31
|
+
"packageManager": "pnpm@10.6.2",
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=22"
|
|
34
34
|
}
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"skuba-dive": "^2.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@types/node": "^22.13.
|
|
20
|
-
"skuba": "
|
|
19
|
+
"@types/node": "^22.13.10",
|
|
20
|
+
"skuba": "*"
|
|
21
21
|
},
|
|
22
|
-
"packageManager": "pnpm@
|
|
22
|
+
"packageManager": "pnpm@10.6.2",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22"
|
|
25
25
|
}
|
|
@@ -9,5 +9,4 @@ image: '{{values "prodAccountId"}}.dkr.ecr.<%- region %>.amazonaws.com/{{values
|
|
|
9
9
|
# datadogSecretId: arn:aws:secretsmanager:<%- region %>:<aws-account-id>:secret:<secret-name>
|
|
10
10
|
|
|
11
11
|
tags:
|
|
12
|
-
seek:source:url: 'https://github.com/SEEK-Jobs/<%- repoName %>'
|
|
13
12
|
# seek:system:name: 'TODO: https://rfc.skinfra.xyz/RFC051-AWS-Tagging-Standard.html#tagging-schema'
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/co-body": "^6.1.3",
|
|
37
37
|
"@types/koa": "^2.13.4",
|
|
38
38
|
"@types/koa__router": "^12.0.0",
|
|
39
|
-
"@types/node": "^22.13.
|
|
39
|
+
"@types/node": "^22.13.10",
|
|
40
40
|
"@types/supertest": "^6.0.0",
|
|
41
41
|
"chance": "^1.1.8",
|
|
42
42
|
"mime": "^4.0.1",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"skuba": "*",
|
|
45
45
|
"supertest": "^7.0.0"
|
|
46
46
|
},
|
|
47
|
-
"packageManager": "pnpm@
|
|
47
|
+
"packageManager": "pnpm@10.6.2",
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=22"
|
|
50
50
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
aws_sqs,
|
|
14
14
|
} from 'aws-cdk-lib';
|
|
15
15
|
import type { Construct } from 'constructs';
|
|
16
|
-
import {
|
|
16
|
+
import { DatadogLambda } from 'datadog-cdk-constructs-v2';
|
|
17
17
|
|
|
18
18
|
import { config } from './config';
|
|
19
19
|
|
|
@@ -117,7 +117,7 @@ export class AppStack extends Stack {
|
|
|
117
117
|
config.datadogApiKeySecretArn,
|
|
118
118
|
);
|
|
119
119
|
|
|
120
|
-
const datadog = new
|
|
120
|
+
const datadog = new DatadogLambda(this, 'datadog', {
|
|
121
121
|
apiKeySecret: datadogSecret,
|
|
122
122
|
addLayers: false,
|
|
123
123
|
enableDatadogLogs: false,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@aws-sdk/client-lambda": "^3.363.0",
|
|
19
19
|
"@aws-sdk/client-sns": "^3.363.0",
|
|
20
20
|
"@seek/logger": "^9.0.0",
|
|
21
|
-
"datadog-lambda-js": "^
|
|
21
|
+
"datadog-lambda-js": "^10.0.0",
|
|
22
22
|
"dd-trace": "^5.0.0",
|
|
23
23
|
"skuba-dive": "^2.0.0",
|
|
24
24
|
"zod": "^3.19.1"
|
|
@@ -27,18 +27,18 @@
|
|
|
27
27
|
"@seek/aws-codedeploy-infra": "^2.1.0",
|
|
28
28
|
"@types/aws-lambda": "^8.10.82",
|
|
29
29
|
"@types/chance": "^1.1.3",
|
|
30
|
-
"@types/node": "^22.13.
|
|
30
|
+
"@types/node": "^22.13.10",
|
|
31
31
|
"aws-cdk": "^2.167.1",
|
|
32
32
|
"aws-cdk-lib": "^2.167.1",
|
|
33
33
|
"aws-sdk-client-mock": "^4.0.0",
|
|
34
34
|
"aws-sdk-client-mock-jest": "^4.0.0",
|
|
35
35
|
"chance": "^1.1.8",
|
|
36
36
|
"constructs": "^10.0.17",
|
|
37
|
-
"datadog-cdk-constructs-v2": "^
|
|
37
|
+
"datadog-cdk-constructs-v2": "^2.0.0",
|
|
38
38
|
"pino-pretty": "^13.0.0",
|
|
39
|
-
"skuba": "
|
|
39
|
+
"skuba": "*"
|
|
40
40
|
},
|
|
41
|
-
"packageManager": "pnpm@
|
|
41
|
+
"packageManager": "pnpm@10.6.2",
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=22"
|
|
44
44
|
}
|