@strapi/upgrade 5.12.1 → 5.12.2
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/dist/cli.js +6 -203
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +5 -202
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +4 -155
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -157
- package/dist/index.mjs.map +1 -1
- package/dist/package.json.js +6 -0
- package/dist/package.json.js.map +1 -0
- package/dist/package.json.mjs +4 -0
- package/dist/package.json.mjs.map +1 -0
- package/dist/src/cli/commands/codemods.js +120 -0
- package/dist/src/cli/commands/codemods.js.map +1 -0
- package/dist/src/cli/commands/codemods.mjs +116 -0
- package/dist/src/cli/commands/codemods.mjs.map +1 -0
- package/dist/src/cli/commands/upgrade.js +99 -0
- package/dist/src/cli/commands/upgrade.js.map +1 -0
- package/dist/src/cli/commands/upgrade.mjs +96 -0
- package/dist/src/cli/commands/upgrade.mjs.map +1 -0
- package/dist/src/cli/errors.js +18 -0
- package/dist/src/cli/errors.js.map +1 -0
- package/dist/src/cli/errors.mjs +16 -0
- package/dist/src/cli/errors.mjs.map +1 -0
- package/dist/src/cli/options.js +26 -0
- package/dist/src/cli/options.js.map +1 -0
- package/dist/src/cli/options.mjs +19 -0
- package/dist/src/cli/options.mjs.map +1 -0
- package/dist/src/modules/codemod/codemod.js +44 -0
- package/dist/src/modules/codemod/codemod.js.map +1 -0
- package/dist/src/modules/codemod/codemod.mjs +41 -0
- package/dist/src/modules/codemod/codemod.mjs.map +1 -0
- package/dist/src/modules/codemod/constants.js +17 -0
- package/dist/src/modules/codemod/constants.js.map +1 -0
- package/dist/src/modules/codemod/constants.mjs +11 -0
- package/dist/src/modules/codemod/constants.mjs.map +1 -0
- package/dist/src/modules/codemod/index.js +10 -0
- package/dist/src/modules/codemod/index.js.map +1 -0
- package/dist/src/modules/codemod/index.mjs +4 -0
- package/dist/src/modules/codemod/index.mjs.map +1 -0
- package/dist/src/modules/codemod-repository/constants.js +9 -0
- package/dist/src/modules/codemod-repository/constants.js.map +1 -0
- package/dist/src/modules/codemod-repository/constants.mjs +7 -0
- package/dist/src/modules/codemod-repository/constants.mjs.map +1 -0
- package/dist/src/modules/codemod-repository/index.js +10 -0
- package/dist/src/modules/codemod-repository/index.js.map +1 -0
- package/dist/src/modules/codemod-repository/index.mjs +4 -0
- package/dist/src/modules/codemod-repository/index.mjs.map +1 -0
- package/dist/src/modules/codemod-repository/repository.js +127 -0
- package/dist/src/modules/codemod-repository/repository.js.map +1 -0
- package/dist/src/modules/codemod-repository/repository.mjs +123 -0
- package/dist/src/modules/codemod-repository/repository.mjs.map +1 -0
- package/dist/src/modules/codemod-runner/codemod-runner.js +113 -0
- package/dist/src/modules/codemod-runner/codemod-runner.js.map +1 -0
- package/dist/src/modules/codemod-runner/codemod-runner.mjs +110 -0
- package/dist/src/modules/codemod-runner/codemod-runner.mjs.map +1 -0
- package/dist/src/modules/error/index.js +11 -0
- package/dist/src/modules/error/index.js.map +1 -0
- package/dist/src/modules/error/index.mjs +2 -0
- package/dist/src/modules/error/index.mjs.map +1 -0
- package/dist/src/modules/error/utils.js +33 -0
- package/dist/src/modules/error/utils.js.map +1 -0
- package/dist/src/modules/error/utils.mjs +28 -0
- package/dist/src/modules/error/utils.mjs.map +1 -0
- package/dist/src/modules/file-scanner/index.js +8 -0
- package/dist/src/modules/file-scanner/index.js.map +1 -0
- package/dist/src/modules/file-scanner/index.mjs +2 -0
- package/dist/src/modules/file-scanner/index.mjs.map +1 -0
- package/dist/src/modules/file-scanner/scanner.js +23 -0
- package/dist/src/modules/file-scanner/scanner.js.map +1 -0
- package/dist/src/modules/file-scanner/scanner.mjs +20 -0
- package/dist/src/modules/file-scanner/scanner.mjs.map +1 -0
- package/dist/src/modules/format/formats.js +107 -0
- package/dist/src/modules/format/formats.js.map +1 -0
- package/dist/src/modules/format/formats.mjs +94 -0
- package/dist/src/modules/format/formats.mjs.map +1 -0
- package/dist/src/modules/format/index.js +19 -0
- package/dist/src/modules/format/index.js.map +1 -0
- package/dist/src/modules/format/index.mjs +2 -0
- package/dist/src/modules/format/index.mjs.map +1 -0
- package/dist/src/modules/index.js +32 -0
- package/dist/src/modules/index.js.map +1 -0
- package/dist/src/modules/index.mjs +27 -0
- package/dist/src/modules/index.mjs.map +1 -0
- package/dist/src/modules/json/file.js +16 -0
- package/dist/src/modules/json/file.js.map +1 -0
- package/dist/src/modules/json/file.mjs +13 -0
- package/dist/src/modules/json/file.mjs.map +1 -0
- package/dist/src/modules/json/transform-api.js +38 -0
- package/dist/src/modules/json/transform-api.js.map +1 -0
- package/dist/src/modules/json/transform-api.mjs +35 -0
- package/dist/src/modules/json/transform-api.mjs.map +1 -0
- package/dist/src/modules/logger/index.js +8 -0
- package/dist/src/modules/logger/index.js.map +1 -0
- package/dist/src/modules/logger/index.mjs +2 -0
- package/dist/src/modules/logger/index.mjs.map +1 -0
- package/dist/src/modules/logger/logger.js +76 -0
- package/dist/src/modules/logger/logger.js.map +1 -0
- package/dist/src/modules/logger/logger.mjs +73 -0
- package/dist/src/modules/logger/logger.mjs.map +1 -0
- package/dist/src/modules/npm/constants.js +6 -0
- package/dist/src/modules/npm/constants.js.map +1 -0
- package/dist/src/modules/npm/constants.mjs +4 -0
- package/dist/src/modules/npm/constants.mjs.map +1 -0
- package/dist/src/modules/npm/package.js +55 -0
- package/dist/src/modules/npm/package.js.map +1 -0
- package/dist/src/modules/npm/package.mjs +52 -0
- package/dist/src/modules/npm/package.mjs.map +1 -0
- package/dist/src/modules/project/constants.js +45 -0
- package/dist/src/modules/project/constants.js.map +1 -0
- package/dist/src/modules/project/constants.mjs +35 -0
- package/dist/src/modules/project/constants.mjs.map +1 -0
- package/dist/src/modules/project/index.js +15 -0
- package/dist/src/modules/project/index.js.map +1 -0
- package/dist/src/modules/project/index.mjs +5 -0
- package/dist/src/modules/project/index.mjs.map +1 -0
- package/dist/src/modules/project/project.js +208 -0
- package/dist/src/modules/project/project.js.map +1 -0
- package/dist/src/modules/project/project.mjs +203 -0
- package/dist/src/modules/project/project.mjs.map +1 -0
- package/dist/src/modules/project/utils.js +26 -0
- package/dist/src/modules/project/utils.js.map +1 -0
- package/dist/src/modules/project/utils.mjs +21 -0
- package/dist/src/modules/project/utils.mjs.map +1 -0
- package/dist/src/modules/report/index.js +9 -0
- package/dist/src/modules/report/index.js.map +1 -0
- package/dist/src/modules/report/index.mjs +2 -0
- package/dist/src/modules/report/index.mjs.map +1 -0
- package/dist/src/modules/report/report.js +13 -0
- package/dist/src/modules/report/report.js.map +1 -0
- package/dist/src/modules/report/report.mjs +10 -0
- package/dist/src/modules/report/report.mjs.map +1 -0
- package/dist/src/modules/requirement/index.js +8 -0
- package/dist/src/modules/requirement/index.js.map +1 -0
- package/dist/src/modules/requirement/index.mjs +2 -0
- package/dist/src/modules/requirement/index.mjs.map +1 -0
- package/dist/src/modules/requirement/requirement.js +55 -0
- package/dist/src/modules/requirement/requirement.js.map +1 -0
- package/dist/src/modules/requirement/requirement.mjs +52 -0
- package/dist/src/modules/requirement/requirement.mjs.map +1 -0
- package/dist/src/modules/runner/code/code.js +21 -0
- package/dist/src/modules/runner/code/code.js.map +1 -0
- package/dist/src/modules/runner/code/code.mjs +18 -0
- package/dist/src/modules/runner/code/code.mjs.map +1 -0
- package/dist/src/modules/runner/code/index.js +8 -0
- package/dist/src/modules/runner/code/index.js.map +1 -0
- package/dist/src/modules/runner/code/index.mjs +2 -0
- package/dist/src/modules/runner/code/index.mjs.map +1 -0
- package/dist/src/modules/runner/index.js +10 -0
- package/dist/src/modules/runner/index.js.map +1 -0
- package/dist/src/modules/runner/index.mjs +5 -0
- package/dist/src/modules/runner/index.mjs.map +1 -0
- package/dist/src/modules/runner/json/index.js +8 -0
- package/dist/src/modules/runner/json/index.js.map +1 -0
- package/dist/src/modules/runner/json/index.mjs +2 -0
- package/dist/src/modules/runner/json/index.mjs.map +1 -0
- package/dist/src/modules/runner/json/json.js +21 -0
- package/dist/src/modules/runner/json/json.js.map +1 -0
- package/dist/src/modules/runner/json/json.mjs +18 -0
- package/dist/src/modules/runner/json/json.mjs.map +1 -0
- package/dist/src/modules/runner/json/transform.js +85 -0
- package/dist/src/modules/runner/json/transform.js.map +1 -0
- package/dist/src/modules/runner/json/transform.mjs +83 -0
- package/dist/src/modules/runner/json/transform.mjs.map +1 -0
- package/dist/src/modules/runner/runner.js +22 -0
- package/dist/src/modules/runner/runner.js.map +1 -0
- package/dist/src/modules/runner/runner.mjs +20 -0
- package/dist/src/modules/runner/runner.mjs.map +1 -0
- package/dist/src/modules/timer/constants.js +6 -0
- package/dist/src/modules/timer/constants.js.map +1 -0
- package/dist/src/modules/timer/constants.mjs +4 -0
- package/dist/src/modules/timer/constants.mjs.map +1 -0
- package/dist/src/modules/timer/index.js +10 -0
- package/dist/src/modules/timer/index.js.map +1 -0
- package/dist/src/modules/timer/index.mjs +4 -0
- package/dist/src/modules/timer/index.mjs.map +1 -0
- package/dist/src/modules/timer/timer.js +33 -0
- package/dist/src/modules/timer/timer.js.map +1 -0
- package/dist/src/modules/timer/timer.mjs +30 -0
- package/dist/src/modules/timer/timer.mjs.map +1 -0
- package/dist/src/modules/upgrader/constants.js +6 -0
- package/dist/src/modules/upgrader/constants.js.map +1 -0
- package/dist/src/modules/upgrader/constants.mjs +4 -0
- package/dist/src/modules/upgrader/constants.mjs.map +1 -0
- package/dist/src/modules/upgrader/index.js +10 -0
- package/dist/src/modules/upgrader/index.js.map +1 -0
- package/dist/src/modules/upgrader/index.mjs +4 -0
- package/dist/src/modules/upgrader/index.mjs.map +1 -0
- package/dist/src/modules/upgrader/upgrader.js +266 -0
- package/dist/src/modules/upgrader/upgrader.js.map +1 -0
- package/dist/src/modules/upgrader/upgrader.mjs +263 -0
- package/dist/src/modules/upgrader/upgrader.mjs.map +1 -0
- package/dist/src/modules/version/index.js +20 -0
- package/dist/src/modules/version/index.js.map +1 -0
- package/dist/src/modules/version/index.mjs +5 -0
- package/dist/src/modules/version/index.mjs.map +1 -0
- package/dist/src/modules/version/range.js +81 -0
- package/dist/src/modules/version/range.js.map +1 -0
- package/dist/src/modules/version/range.mjs +75 -0
- package/dist/src/modules/version/range.mjs.map +1 -0
- package/dist/src/modules/version/semver.js +26 -0
- package/dist/src/modules/version/semver.js.map +1 -0
- package/dist/src/modules/version/semver.mjs +20 -0
- package/dist/src/modules/version/semver.mjs.map +1 -0
- package/dist/src/modules/version/types.js +12 -0
- package/dist/src/modules/version/types.js.map +1 -0
- package/dist/src/modules/version/types.mjs +12 -0
- package/dist/src/modules/version/types.mjs.map +1 -0
- package/dist/src/tasks/codemods/list-codemods.js +40 -0
- package/dist/src/tasks/codemods/list-codemods.js.map +1 -0
- package/dist/src/tasks/codemods/list-codemods.mjs +38 -0
- package/dist/src/tasks/codemods/list-codemods.mjs.map +1 -0
- package/dist/src/tasks/codemods/run-codemods.js +36 -0
- package/dist/src/tasks/codemods/run-codemods.js.map +1 -0
- package/dist/src/tasks/codemods/run-codemods.mjs +34 -0
- package/dist/src/tasks/codemods/run-codemods.mjs.map +1 -0
- package/dist/src/tasks/codemods/utils.js +54 -0
- package/dist/src/tasks/codemods/utils.js.map +1 -0
- package/dist/src/tasks/codemods/utils.mjs +50 -0
- package/dist/src/tasks/codemods/utils.mjs.map +1 -0
- package/dist/src/tasks/index.js +15 -0
- package/dist/src/tasks/index.js.map +1 -0
- package/dist/src/tasks/index.mjs +7 -0
- package/dist/src/tasks/index.mjs.map +1 -0
- package/dist/src/tasks/upgrade/prompts/latest.js +48 -0
- package/dist/src/tasks/upgrade/prompts/latest.js.map +1 -0
- package/dist/src/tasks/upgrade/prompts/latest.mjs +46 -0
- package/dist/src/tasks/upgrade/prompts/latest.mjs.map +1 -0
- package/dist/src/tasks/upgrade/requirements/common.js +40 -0
- package/dist/src/tasks/upgrade/requirements/common.js.map +1 -0
- package/dist/src/tasks/upgrade/requirements/common.mjs +35 -0
- package/dist/src/tasks/upgrade/requirements/common.mjs.map +1 -0
- package/dist/src/tasks/upgrade/requirements/major.js +29 -0
- package/dist/src/tasks/upgrade/requirements/major.js.map +1 -0
- package/dist/src/tasks/upgrade/requirements/major.mjs +26 -0
- package/dist/src/tasks/upgrade/requirements/major.mjs.map +1 -0
- package/dist/src/tasks/upgrade/upgrade.js +69 -0
- package/dist/src/tasks/upgrade/upgrade.js.map +1 -0
- package/dist/src/tasks/upgrade/upgrade.mjs +67 -0
- package/dist/src/tasks/upgrade/upgrade.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/chunks/logger-DGi224NW.js +0 -1649
- package/dist/chunks/logger-DGi224NW.js.map +0 -1
- package/dist/chunks/logger-np_r7rTc.mjs +0 -1599
- package/dist/chunks/logger-np_r7rTc.mjs.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class UnexpectedError extends Error {
|
|
2
|
+
constructor(){
|
|
3
|
+
super('Unexpected Error');
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
class NPMCandidateNotFoundError extends Error {
|
|
7
|
+
constructor(target, message = `Couldn't find a valid NPM candidate for "${target}"`){
|
|
8
|
+
super(message);
|
|
9
|
+
this.target = target;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class AbortedError extends Error {
|
|
13
|
+
constructor(message = 'Upgrade aborted'){
|
|
14
|
+
super(message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const unknownToError = (e)=>{
|
|
18
|
+
if (e instanceof Error) {
|
|
19
|
+
return e;
|
|
20
|
+
}
|
|
21
|
+
if (typeof e === 'string') {
|
|
22
|
+
return new Error(e);
|
|
23
|
+
}
|
|
24
|
+
return new UnexpectedError();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { AbortedError, NPMCandidateNotFoundError, UnexpectedError, unknownToError };
|
|
28
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../../../src/modules/error/utils.ts"],"sourcesContent":["import type { Version } from '../version';\n\nexport class UnexpectedError extends Error {\n constructor() {\n super('Unexpected Error');\n }\n}\n\nexport class NPMCandidateNotFoundError extends Error {\n target: Version.SemVer | Version.Range | Version.ReleaseType;\n\n constructor(\n target: Version.SemVer | Version.Range | Version.ReleaseType,\n message: string = `Couldn't find a valid NPM candidate for \"${target}\"`\n ) {\n super(message);\n\n this.target = target;\n }\n}\n\nexport class AbortedError extends Error {\n constructor(message: string = 'Upgrade aborted') {\n super(message);\n }\n}\n\nexport const unknownToError = (e: unknown): Error => {\n if (e instanceof Error) {\n return e;\n }\n\n if (typeof e === 'string') {\n return new Error(e);\n }\n\n return new UnexpectedError();\n};\n"],"names":["UnexpectedError","Error","constructor","NPMCandidateNotFoundError","target","message","AbortedError","unknownToError","e"],"mappings":"AAEO,MAAMA,eAAwBC,SAAAA,KAAAA,CAAAA;IACnCC,WAAc,EAAA;AACZ,QAAA,KAAK,CAAC,kBAAA,CAAA;AACR;AACF;AAEO,MAAMC,yBAAkCF,SAAAA,KAAAA,CAAAA;IAG7CC,WACEE,CAAAA,MAA4D,EAC5DC,OAAkB,GAAA,CAAC,yCAAyC,EAAED,MAAAA,CAAO,CAAC,CAAC,CACvE;AACA,QAAA,KAAK,CAACC,OAAAA,CAAAA;QAEN,IAAI,CAACD,MAAM,GAAGA,MAAAA;AAChB;AACF;AAEO,MAAME,YAAqBL,SAAAA,KAAAA,CAAAA;IAChCC,WAAYG,CAAAA,OAAAA,GAAkB,iBAAiB,CAAE;AAC/C,QAAA,KAAK,CAACA,OAAAA,CAAAA;AACR;AACF;AAEO,MAAME,iBAAiB,CAACC,CAAAA,GAAAA;AAC7B,IAAA,IAAIA,aAAaP,KAAO,EAAA;QACtB,OAAOO,CAAAA;AACT;IAEA,IAAI,OAAOA,MAAM,QAAU,EAAA;AACzB,QAAA,OAAO,IAAIP,KAAMO,CAAAA,CAAAA,CAAAA;AACnB;AAEA,IAAA,OAAO,IAAIR,eAAAA,EAAAA;AACb;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var fastglob = require('fast-glob');
|
|
5
|
+
|
|
6
|
+
class FileScanner {
|
|
7
|
+
scan(patterns) {
|
|
8
|
+
// we use fastglob instead of glob because it supports negation patterns
|
|
9
|
+
const filenames = fastglob.sync(patterns, {
|
|
10
|
+
cwd: this.cwd
|
|
11
|
+
});
|
|
12
|
+
// Resolve the full paths for every filename
|
|
13
|
+
return filenames.map((filename)=>path.join(this.cwd, filename));
|
|
14
|
+
}
|
|
15
|
+
constructor(cwd){
|
|
16
|
+
this.cwd = cwd;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const fileScannerFactory = (cwd)=>new FileScanner(cwd);
|
|
20
|
+
|
|
21
|
+
exports.FileScanner = FileScanner;
|
|
22
|
+
exports.fileScannerFactory = fileScannerFactory;
|
|
23
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sources":["../../../../src/modules/file-scanner/scanner.ts"],"sourcesContent":["import path from 'node:path';\nimport fastglob from 'fast-glob';\n\nimport type { FileScanner as FileScannerInterface } from './types';\n\nexport class FileScanner implements FileScannerInterface {\n public cwd: string;\n\n constructor(cwd: string) {\n this.cwd = cwd;\n }\n\n scan(patterns: string[]) {\n // we use fastglob instead of glob because it supports negation patterns\n const filenames = fastglob.sync(patterns, {\n cwd: this.cwd,\n });\n\n // Resolve the full paths for every filename\n return filenames.map((filename) => path.join(this.cwd, filename));\n }\n}\n\nexport const fileScannerFactory = (cwd: string) => new FileScanner(cwd);\n"],"names":["FileScanner","scan","patterns","filenames","fastglob","sync","cwd","map","filename","path","join","constructor","fileScannerFactory"],"mappings":";;;;;AAKO,MAAMA,WAAAA,CAAAA;AAOXC,IAAAA,IAAAA,CAAKC,QAAkB,EAAE;;AAEvB,QAAA,MAAMC,SAAYC,GAAAA,QAAAA,CAASC,IAAI,CAACH,QAAU,EAAA;YACxCI,GAAK,EAAA,IAAI,CAACA;AACZ,SAAA,CAAA;;QAGA,OAAOH,SAAAA,CAAUI,GAAG,CAAC,CAACC,QAAAA,GAAaC,IAAKC,CAAAA,IAAI,CAAC,IAAI,CAACJ,GAAG,EAAEE,QAAAA,CAAAA,CAAAA;AACzD;AAZAG,IAAAA,WAAAA,CAAYL,GAAW,CAAE;QACvB,IAAI,CAACA,GAAG,GAAGA,GAAAA;AACb;AAWF;MAEaM,kBAAqB,GAAA,CAACN,GAAgB,GAAA,IAAIN,YAAYM,GAAK;;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fastglob from 'fast-glob';
|
|
3
|
+
|
|
4
|
+
class FileScanner {
|
|
5
|
+
scan(patterns) {
|
|
6
|
+
// we use fastglob instead of glob because it supports negation patterns
|
|
7
|
+
const filenames = fastglob.sync(patterns, {
|
|
8
|
+
cwd: this.cwd
|
|
9
|
+
});
|
|
10
|
+
// Resolve the full paths for every filename
|
|
11
|
+
return filenames.map((filename)=>path.join(this.cwd, filename));
|
|
12
|
+
}
|
|
13
|
+
constructor(cwd){
|
|
14
|
+
this.cwd = cwd;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const fileScannerFactory = (cwd)=>new FileScanner(cwd);
|
|
18
|
+
|
|
19
|
+
export { FileScanner, fileScannerFactory };
|
|
20
|
+
//# sourceMappingURL=scanner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.mjs","sources":["../../../../src/modules/file-scanner/scanner.ts"],"sourcesContent":["import path from 'node:path';\nimport fastglob from 'fast-glob';\n\nimport type { FileScanner as FileScannerInterface } from './types';\n\nexport class FileScanner implements FileScannerInterface {\n public cwd: string;\n\n constructor(cwd: string) {\n this.cwd = cwd;\n }\n\n scan(patterns: string[]) {\n // we use fastglob instead of glob because it supports negation patterns\n const filenames = fastglob.sync(patterns, {\n cwd: this.cwd,\n });\n\n // Resolve the full paths for every filename\n return filenames.map((filename) => path.join(this.cwd, filename));\n }\n}\n\nexport const fileScannerFactory = (cwd: string) => new FileScanner(cwd);\n"],"names":["FileScanner","scan","patterns","filenames","fastglob","sync","cwd","map","filename","path","join","constructor","fileScannerFactory"],"mappings":";;;AAKO,MAAMA,WAAAA,CAAAA;AAOXC,IAAAA,IAAAA,CAAKC,QAAkB,EAAE;;AAEvB,QAAA,MAAMC,SAAYC,GAAAA,QAAAA,CAASC,IAAI,CAACH,QAAU,EAAA;YACxCI,GAAK,EAAA,IAAI,CAACA;AACZ,SAAA,CAAA;;QAGA,OAAOH,SAAAA,CAAUI,GAAG,CAAC,CAACC,QAAAA,GAAaC,IAAKC,CAAAA,IAAI,CAAC,IAAI,CAACJ,GAAG,EAAEE,QAAAA,CAAAA,CAAAA;AACzD;AAZAG,IAAAA,WAAAA,CAAYL,GAAW,CAAE;QACvB,IAAI,CAACA,GAAG,GAAGA,GAAAA;AACb;AAWF;MAEaM,kBAAqB,GAAA,CAACN,GAAgB,GAAA,IAAIN,YAAYM,GAAK;;;;"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CliTable3 = require('cli-table3');
|
|
4
|
+
var chalk = require('chalk');
|
|
5
|
+
var constants = require('../timer/constants.js');
|
|
6
|
+
|
|
7
|
+
const path = (path)=>chalk.blue(path);
|
|
8
|
+
const version = (version)=>{
|
|
9
|
+
return chalk.italic.yellow(`v${version}`);
|
|
10
|
+
};
|
|
11
|
+
const codemodUID = (uid)=>{
|
|
12
|
+
return chalk.bold.cyan(uid);
|
|
13
|
+
};
|
|
14
|
+
const projectDetails = (project)=>{
|
|
15
|
+
return `Project: TYPE=${projectType(project.type)}; CWD=${path(project.cwd)}; PATHS=${project.paths.map(path)}`;
|
|
16
|
+
};
|
|
17
|
+
const projectType = (type)=>chalk.cyan(type);
|
|
18
|
+
const versionRange = (range)=>chalk.italic.yellow(range.raw);
|
|
19
|
+
const transform = (transformFilePath)=>chalk.cyan(transformFilePath);
|
|
20
|
+
const highlight = (arg)=>chalk.bold.underline(arg);
|
|
21
|
+
const upgradeStep = (text, step)=>{
|
|
22
|
+
return chalk.bold(`(${step[0]}/${step[1]}) ${text}...`);
|
|
23
|
+
};
|
|
24
|
+
const reports = (reports)=>{
|
|
25
|
+
const rows = reports.map(({ codemod, report }, i)=>{
|
|
26
|
+
const fIndex = chalk.grey(i);
|
|
27
|
+
const fVersion = chalk.magenta(codemod.version);
|
|
28
|
+
const fKind = chalk.yellow(codemod.kind);
|
|
29
|
+
const fFormattedTransformPath = chalk.cyan(codemod.format());
|
|
30
|
+
const fTimeElapsed = i === 0 ? `${report.timeElapsed}s ${chalk.dim.italic('(cold start)')}` : `${report.timeElapsed}s`;
|
|
31
|
+
const fAffected = report.ok > 0 ? chalk.green(report.ok) : chalk.grey(0);
|
|
32
|
+
const fUnchanged = report.ok === 0 ? chalk.red(report.nochange) : chalk.grey(report.nochange);
|
|
33
|
+
return [
|
|
34
|
+
fIndex,
|
|
35
|
+
fVersion,
|
|
36
|
+
fKind,
|
|
37
|
+
fFormattedTransformPath,
|
|
38
|
+
fAffected,
|
|
39
|
+
fUnchanged,
|
|
40
|
+
fTimeElapsed
|
|
41
|
+
];
|
|
42
|
+
});
|
|
43
|
+
const table = new CliTable3({
|
|
44
|
+
style: {
|
|
45
|
+
compact: true
|
|
46
|
+
},
|
|
47
|
+
head: [
|
|
48
|
+
chalk.bold.grey('N°'),
|
|
49
|
+
chalk.bold.magenta('Version'),
|
|
50
|
+
chalk.bold.yellow('Kind'),
|
|
51
|
+
chalk.bold.cyan('Name'),
|
|
52
|
+
chalk.bold.green('Affected'),
|
|
53
|
+
chalk.bold.red('Unchanged'),
|
|
54
|
+
chalk.bold.blue('Duration')
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
table.push(...rows);
|
|
58
|
+
return table.toString();
|
|
59
|
+
};
|
|
60
|
+
const codemodList = (codemods)=>{
|
|
61
|
+
const rows = codemods.map((codemod, index)=>{
|
|
62
|
+
const fIndex = chalk.grey(index);
|
|
63
|
+
const fVersion = chalk.magenta(codemod.version);
|
|
64
|
+
const fKind = chalk.yellow(codemod.kind);
|
|
65
|
+
const fName = chalk.blue(codemod.format());
|
|
66
|
+
const fUID = codemodUID(codemod.uid);
|
|
67
|
+
return [
|
|
68
|
+
fIndex,
|
|
69
|
+
fVersion,
|
|
70
|
+
fKind,
|
|
71
|
+
fName,
|
|
72
|
+
fUID
|
|
73
|
+
];
|
|
74
|
+
});
|
|
75
|
+
const table = new CliTable3({
|
|
76
|
+
style: {
|
|
77
|
+
compact: true
|
|
78
|
+
},
|
|
79
|
+
head: [
|
|
80
|
+
chalk.bold.grey('N°'),
|
|
81
|
+
chalk.bold.magenta('Version'),
|
|
82
|
+
chalk.bold.yellow('Kind'),
|
|
83
|
+
chalk.bold.blue('Name'),
|
|
84
|
+
chalk.bold.cyan('UID')
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
table.push(...rows);
|
|
88
|
+
return table.toString();
|
|
89
|
+
};
|
|
90
|
+
const durationMs = (elapsedMs)=>{
|
|
91
|
+
const elapsedSeconds = (elapsedMs / constants.ONE_SECOND_MS).toFixed(3);
|
|
92
|
+
return `${elapsedSeconds}s`;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
exports.codemodList = codemodList;
|
|
96
|
+
exports.codemodUID = codemodUID;
|
|
97
|
+
exports.durationMs = durationMs;
|
|
98
|
+
exports.highlight = highlight;
|
|
99
|
+
exports.path = path;
|
|
100
|
+
exports.projectDetails = projectDetails;
|
|
101
|
+
exports.projectType = projectType;
|
|
102
|
+
exports.reports = reports;
|
|
103
|
+
exports.transform = transform;
|
|
104
|
+
exports.upgradeStep = upgradeStep;
|
|
105
|
+
exports.version = version;
|
|
106
|
+
exports.versionRange = versionRange;
|
|
107
|
+
//# sourceMappingURL=formats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.js","sources":["../../../../src/modules/format/formats.ts"],"sourcesContent":["import CliTable3 from 'cli-table3';\nimport chalk from 'chalk';\n\nimport { constants as timerConstants } from '../timer';\n\nimport type { AppProject, PluginProject, ProjectType } from '../project';\nimport type { Codemod } from '../codemod';\nimport type { Version } from '../version';\nimport type { Report } from '../report';\n\nexport const path = (path: string) => chalk.blue(path);\n\nexport const version = (version: Version.LiteralVersion | Version.SemVer) => {\n return chalk.italic.yellow(`v${version}`);\n};\n\nexport const codemodUID = (uid: string) => {\n return chalk.bold.cyan(uid);\n};\n\nexport const projectDetails = (project: AppProject | PluginProject) => {\n return `Project: TYPE=${projectType(project.type)}; CWD=${path(project.cwd)}; PATHS=${project.paths.map(path)}`;\n};\n\nexport const projectType = (type: ProjectType) => chalk.cyan(type);\n\nexport const versionRange = (range: Version.Range) => chalk.italic.yellow(range.raw);\n\nexport const transform = (transformFilePath: string) => chalk.cyan(transformFilePath);\n\nexport const highlight = (arg: unknown) => chalk.bold.underline(arg);\n\nexport const upgradeStep = (text: string, step: [current: number, total: number]) => {\n return chalk.bold(`(${step[0]}/${step[1]}) ${text}...`);\n};\n\nexport const reports = (reports: Report.CodemodReport[]) => {\n const rows = reports.map(({ codemod, report }, i) => {\n const fIndex = chalk.grey(i);\n const fVersion = chalk.magenta(codemod.version);\n const fKind = chalk.yellow(codemod.kind);\n const fFormattedTransformPath = chalk.cyan(codemod.format());\n const fTimeElapsed =\n i === 0\n ? `${report.timeElapsed}s ${chalk.dim.italic('(cold start)')}`\n : `${report.timeElapsed}s`;\n const fAffected = report.ok > 0 ? chalk.green(report.ok) : chalk.grey(0);\n const fUnchanged = report.ok === 0 ? chalk.red(report.nochange) : chalk.grey(report.nochange);\n\n return [fIndex, fVersion, fKind, fFormattedTransformPath, fAffected, fUnchanged, fTimeElapsed];\n });\n\n const table = new CliTable3({\n style: { compact: true },\n head: [\n chalk.bold.grey('N°'),\n chalk.bold.magenta('Version'),\n chalk.bold.yellow('Kind'),\n chalk.bold.cyan('Name'),\n chalk.bold.green('Affected'),\n chalk.bold.red('Unchanged'),\n chalk.bold.blue('Duration'),\n ],\n });\n\n table.push(...rows);\n\n return table.toString();\n};\n\nexport const codemodList = (codemods: Codemod.List) => {\n type Row = [index: string, version: string, kind: string, name: string, uid: string];\n\n const rows = codemods.map<Row>((codemod, index) => {\n const fIndex = chalk.grey(index);\n const fVersion = chalk.magenta(codemod.version);\n const fKind = chalk.yellow(codemod.kind);\n const fName = chalk.blue(codemod.format());\n const fUID = codemodUID(codemod.uid);\n\n return [fIndex, fVersion, fKind, fName, fUID] satisfies Row;\n });\n\n const table = new CliTable3({\n style: { compact: true },\n head: [\n chalk.bold.grey('N°'),\n chalk.bold.magenta('Version'),\n chalk.bold.yellow('Kind'),\n chalk.bold.blue('Name'),\n chalk.bold.cyan('UID'),\n ],\n });\n\n table.push(...rows);\n\n return table.toString();\n};\n\nexport const durationMs = (elapsedMs: number) => {\n const elapsedSeconds = (elapsedMs / timerConstants.ONE_SECOND_MS).toFixed(3);\n\n return `${elapsedSeconds}s`;\n};\n"],"names":["path","chalk","blue","version","italic","yellow","codemodUID","uid","bold","cyan","projectDetails","project","projectType","type","cwd","paths","map","versionRange","range","raw","transform","transformFilePath","highlight","arg","underline","upgradeStep","text","step","reports","rows","codemod","report","i","fIndex","grey","fVersion","magenta","fKind","kind","fFormattedTransformPath","format","fTimeElapsed","timeElapsed","dim","fAffected","ok","green","fUnchanged","red","nochange","table","CliTable3","style","compact","head","push","toString","codemodList","codemods","index","fName","fUID","durationMs","elapsedMs","elapsedSeconds","timerConstants","toFixed"],"mappings":";;;;;;MAUaA,IAAO,GAAA,CAACA,OA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YAAAA,KAAAA;AAAOC,YAAAA;AAAK,SAAA;AAC/C,KAAA,CAAA;IAEA,MAAMX,KAAAA,GAAQ,IAAIC,SAAU,CAAA;QAC1BC,KAAO,EAAA;YAAEC,OAAS,EAAA;AAAK,SAAA;QACvBC,IAAM,EAAA;YACJrD,KAAMO,CAAAA,IAAI,CAAC0B,IAAI,CAAC,IAAA,CAAA;YAChBjC,KAAMO,CAAAA,IAAI,CAAC4B,OAAO,CAAC,SAAA,CAAA;YACnBnC,KAAMO,CAAAA,IAAI,CAACH,MAAM,CAAC,MAAA,CAAA;YAClBJ,KAAMO,CAAAA,IAAI,CAACN,IAAI,CAAC,MAAA,CAAA;YAChBD,KAAMO,CAAAA,IAAI,CAACC,IAAI,CAAC,KAAA;AACjB;AACH,KAAA,CAAA;AAEAyC,IAAAA,KAAAA,CAAMK,IAAI,CAAI1B,GAAAA,IAAAA,CAAAA;AAEd,IAAA,OAAOqB,MAAMM,QAAQ,EAAA;AACvB;AAEO,MAAMM,aAAa,CAACC,SAAAA,GAAAA;IACzB,MAAMC,cAAAA,GAAiB,CAACD,SAAAA,GAAYE,uBAA2B,EAAGC,OAAO,CAAC,CAAA,CAAA;AAE1E,IAAA,OAAO,CAAC,EAAEF,cAAe,CAAA,CAAC,CAAC;AAC7B;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import CliTable3 from 'cli-table3';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { ONE_SECOND_MS } from '../timer/constants.mjs';
|
|
4
|
+
|
|
5
|
+
const path = (path)=>chalk.blue(path);
|
|
6
|
+
const version = (version)=>{
|
|
7
|
+
return chalk.italic.yellow(`v${version}`);
|
|
8
|
+
};
|
|
9
|
+
const codemodUID = (uid)=>{
|
|
10
|
+
return chalk.bold.cyan(uid);
|
|
11
|
+
};
|
|
12
|
+
const projectDetails = (project)=>{
|
|
13
|
+
return `Project: TYPE=${projectType(project.type)}; CWD=${path(project.cwd)}; PATHS=${project.paths.map(path)}`;
|
|
14
|
+
};
|
|
15
|
+
const projectType = (type)=>chalk.cyan(type);
|
|
16
|
+
const versionRange = (range)=>chalk.italic.yellow(range.raw);
|
|
17
|
+
const transform = (transformFilePath)=>chalk.cyan(transformFilePath);
|
|
18
|
+
const highlight = (arg)=>chalk.bold.underline(arg);
|
|
19
|
+
const upgradeStep = (text, step)=>{
|
|
20
|
+
return chalk.bold(`(${step[0]}/${step[1]}) ${text}...`);
|
|
21
|
+
};
|
|
22
|
+
const reports = (reports)=>{
|
|
23
|
+
const rows = reports.map(({ codemod, report }, i)=>{
|
|
24
|
+
const fIndex = chalk.grey(i);
|
|
25
|
+
const fVersion = chalk.magenta(codemod.version);
|
|
26
|
+
const fKind = chalk.yellow(codemod.kind);
|
|
27
|
+
const fFormattedTransformPath = chalk.cyan(codemod.format());
|
|
28
|
+
const fTimeElapsed = i === 0 ? `${report.timeElapsed}s ${chalk.dim.italic('(cold start)')}` : `${report.timeElapsed}s`;
|
|
29
|
+
const fAffected = report.ok > 0 ? chalk.green(report.ok) : chalk.grey(0);
|
|
30
|
+
const fUnchanged = report.ok === 0 ? chalk.red(report.nochange) : chalk.grey(report.nochange);
|
|
31
|
+
return [
|
|
32
|
+
fIndex,
|
|
33
|
+
fVersion,
|
|
34
|
+
fKind,
|
|
35
|
+
fFormattedTransformPath,
|
|
36
|
+
fAffected,
|
|
37
|
+
fUnchanged,
|
|
38
|
+
fTimeElapsed
|
|
39
|
+
];
|
|
40
|
+
});
|
|
41
|
+
const table = new CliTable3({
|
|
42
|
+
style: {
|
|
43
|
+
compact: true
|
|
44
|
+
},
|
|
45
|
+
head: [
|
|
46
|
+
chalk.bold.grey('N°'),
|
|
47
|
+
chalk.bold.magenta('Version'),
|
|
48
|
+
chalk.bold.yellow('Kind'),
|
|
49
|
+
chalk.bold.cyan('Name'),
|
|
50
|
+
chalk.bold.green('Affected'),
|
|
51
|
+
chalk.bold.red('Unchanged'),
|
|
52
|
+
chalk.bold.blue('Duration')
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
table.push(...rows);
|
|
56
|
+
return table.toString();
|
|
57
|
+
};
|
|
58
|
+
const codemodList = (codemods)=>{
|
|
59
|
+
const rows = codemods.map((codemod, index)=>{
|
|
60
|
+
const fIndex = chalk.grey(index);
|
|
61
|
+
const fVersion = chalk.magenta(codemod.version);
|
|
62
|
+
const fKind = chalk.yellow(codemod.kind);
|
|
63
|
+
const fName = chalk.blue(codemod.format());
|
|
64
|
+
const fUID = codemodUID(codemod.uid);
|
|
65
|
+
return [
|
|
66
|
+
fIndex,
|
|
67
|
+
fVersion,
|
|
68
|
+
fKind,
|
|
69
|
+
fName,
|
|
70
|
+
fUID
|
|
71
|
+
];
|
|
72
|
+
});
|
|
73
|
+
const table = new CliTable3({
|
|
74
|
+
style: {
|
|
75
|
+
compact: true
|
|
76
|
+
},
|
|
77
|
+
head: [
|
|
78
|
+
chalk.bold.grey('N°'),
|
|
79
|
+
chalk.bold.magenta('Version'),
|
|
80
|
+
chalk.bold.yellow('Kind'),
|
|
81
|
+
chalk.bold.blue('Name'),
|
|
82
|
+
chalk.bold.cyan('UID')
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
table.push(...rows);
|
|
86
|
+
return table.toString();
|
|
87
|
+
};
|
|
88
|
+
const durationMs = (elapsedMs)=>{
|
|
89
|
+
const elapsedSeconds = (elapsedMs / ONE_SECOND_MS).toFixed(3);
|
|
90
|
+
return `${elapsedSeconds}s`;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { codemodList, codemodUID, durationMs, highlight, path, projectDetails, projectType, reports, transform, upgradeStep, version, versionRange };
|
|
94
|
+
//# sourceMappingURL=formats.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formats.mjs","sources":["../../../../src/modules/format/formats.ts"],"sourcesContent":["import CliTable3 from 'cli-table3';\nimport chalk from 'chalk';\n\nimport { constants as timerConstants } from '../timer';\n\nimport type { AppProject, PluginProject, ProjectType } from '../project';\nimport type { Codemod } from '../codemod';\nimport type { Version } from '../version';\nimport type { Report } from '../report';\n\nexport const path = (path: string) => chalk.blue(path);\n\nexport const version = (version: Version.LiteralVersion | Version.SemVer) => {\n return chalk.italic.yellow(`v${version}`);\n};\n\nexport const codemodUID = (uid: string) => {\n return chalk.bold.cyan(uid);\n};\n\nexport const projectDetails = (project: AppProject | PluginProject) => {\n return `Project: TYPE=${projectType(project.type)}; CWD=${path(project.cwd)}; PATHS=${project.paths.map(path)}`;\n};\n\nexport const projectType = (type: ProjectType) => chalk.cyan(type);\n\nexport const versionRange = (range: Version.Range) => chalk.italic.yellow(range.raw);\n\nexport const transform = (transformFilePath: string) => chalk.cyan(transformFilePath);\n\nexport const highlight = (arg: unknown) => chalk.bold.underline(arg);\n\nexport const upgradeStep = (text: string, step: [current: number, total: number]) => {\n return chalk.bold(`(${step[0]}/${step[1]}) ${text}...`);\n};\n\nexport const reports = (reports: Report.CodemodReport[]) => {\n const rows = reports.map(({ codemod, report }, i) => {\n const fIndex = chalk.grey(i);\n const fVersion = chalk.magenta(codemod.version);\n const fKind = chalk.yellow(codemod.kind);\n const fFormattedTransformPath = chalk.cyan(codemod.format());\n const fTimeElapsed =\n i === 0\n ? `${report.timeElapsed}s ${chalk.dim.italic('(cold start)')}`\n : `${report.timeElapsed}s`;\n const fAffected = report.ok > 0 ? chalk.green(report.ok) : chalk.grey(0);\n const fUnchanged = report.ok === 0 ? chalk.red(report.nochange) : chalk.grey(report.nochange);\n\n return [fIndex, fVersion, fKind, fFormattedTransformPath, fAffected, fUnchanged, fTimeElapsed];\n });\n\n const table = new CliTable3({\n style: { compact: true },\n head: [\n chalk.bold.grey('N°'),\n chalk.bold.magenta('Version'),\n chalk.bold.yellow('Kind'),\n chalk.bold.cyan('Name'),\n chalk.bold.green('Affected'),\n chalk.bold.red('Unchanged'),\n chalk.bold.blue('Duration'),\n ],\n });\n\n table.push(...rows);\n\n return table.toString();\n};\n\nexport const codemodList = (codemods: Codemod.List) => {\n type Row = [index: string, version: string, kind: string, name: string, uid: string];\n\n const rows = codemods.map<Row>((codemod, index) => {\n const fIndex = chalk.grey(index);\n const fVersion = chalk.magenta(codemod.version);\n const fKind = chalk.yellow(codemod.kind);\n const fName = chalk.blue(codemod.format());\n const fUID = codemodUID(codemod.uid);\n\n return [fIndex, fVersion, fKind, fName, fUID] satisfies Row;\n });\n\n const table = new CliTable3({\n style: { compact: true },\n head: [\n chalk.bold.grey('N°'),\n chalk.bold.magenta('Version'),\n chalk.bold.yellow('Kind'),\n chalk.bold.blue('Name'),\n chalk.bold.cyan('UID'),\n ],\n });\n\n table.push(...rows);\n\n return table.toString();\n};\n\nexport const durationMs = (elapsedMs: number) => {\n const elapsedSeconds = (elapsedMs / timerConstants.ONE_SECOND_MS).toFixed(3);\n\n return `${elapsedSeconds}s`;\n};\n"],"names":["path","chalk","blue","version","italic","yellow","codemodUID","uid","bold","cyan","projectDetails","project","projectType","type","cwd","paths","map","versionRange","range","raw","transform","transformFilePath","highlight","arg","underline","upgradeStep","text","step","reports","rows","codemod","report","i","fIndex","grey","fVersion","magenta","fKind","kind","fFormattedTransformPath","format","fTimeElapsed","timeElapsed","dim","fAffected","ok","green","fUnchanged","red","nochange","table","CliTable3","style","compact","head","push","toString","codemodList","codemods","index","fName","fUID","durationMs","elapsedMs","elapsedSeconds","timerConstants","toFixed"],"mappings":";;;;MAUaA,IAAO,GAAA,CAACA,OAAiBC,KAAMC,CAAAA,IAAI,CAACF,IAAM;AAEhD,MAAMG,UAAU,CAACA,OAAAA,GAAAA;IACtB,OAAOF,KAAAA,CAAMG,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEF,OAAAA,CAAQ,CAAC,CAAA;AAC1C;AAEO,MAAMG,aAAa,CAACC,GAAAA,GAAAA;AACzB,IAAA,OAAON,KAAMO,CAAAA,IAAI,CAACC,IAAI,CAACF,GAAAA,CAAAA;AACzB;AAEO,MAAMG,iBAAiB,CAACC,OAAAA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MAAM,CAAC,MAAA,CAAA;YAClBJ,KAAMO,CAAAA,IAAI,CAACN,IAAI,CAAC,MAAA,CAAA;YAChBD,KAAMO,CAAAA,IAAI,CAACC,IAAI,CAAC,KAAA;AACjB;AACH,KAAA,CAAA;AAEAyC,IAAAA,KAAAA,CAAMK,IAAI,CAAI1B,GAAAA,IAAAA,CAAAA;AAEd,IAAA,OAAOqB,MAAMM,QAAQ,EAAA;AACvB;AAEO,MAAMM,aAAa,CAACC,SAAAA,GAAAA;IACzB,MAAMC,cAAAA,GAAiB,CAACD,SAAAA,GAAYE,aAA2B,EAAGC,OAAO,CAAC,CAAA,CAAA;AAE1E,IAAA,OAAO,CAAC,EAAEF,cAAe,CAAA,CAAC,CAAC;AAC7B;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var formats = require('./formats.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.codemodList = formats.codemodList;
|
|
8
|
+
exports.codemodUID = formats.codemodUID;
|
|
9
|
+
exports.durationMs = formats.durationMs;
|
|
10
|
+
exports.highlight = formats.highlight;
|
|
11
|
+
exports.path = formats.path;
|
|
12
|
+
exports.projectDetails = formats.projectDetails;
|
|
13
|
+
exports.projectType = formats.projectType;
|
|
14
|
+
exports.reports = formats.reports;
|
|
15
|
+
exports.transform = formats.transform;
|
|
16
|
+
exports.upgradeStep = formats.upgradeStep;
|
|
17
|
+
exports.version = formats.version;
|
|
18
|
+
exports.versionRange = formats.versionRange;
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./codemod/index.js');
|
|
4
|
+
var index$1 = require('./codemod-repository/index.js');
|
|
5
|
+
var index$2 = require('./error/index.js');
|
|
6
|
+
var index$3 = require('./file-scanner/index.js');
|
|
7
|
+
var index$4 = require('./format/index.js');
|
|
8
|
+
var index$5 = require('./logger/index.js');
|
|
9
|
+
var index$6 = require('./project/index.js');
|
|
10
|
+
var index$7 = require('./report/index.js');
|
|
11
|
+
var index$8 = require('./requirement/index.js');
|
|
12
|
+
var index$9 = require('./runner/index.js');
|
|
13
|
+
var index$a = require('./timer/index.js');
|
|
14
|
+
var index$b = require('./upgrader/index.js');
|
|
15
|
+
var index$c = require('./version/index.js');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.codemod = index;
|
|
20
|
+
exports.codemodRepository = index$1;
|
|
21
|
+
exports.error = index$2;
|
|
22
|
+
exports.fileScanner = index$3;
|
|
23
|
+
exports.f = index$4;
|
|
24
|
+
exports.logger = index$5;
|
|
25
|
+
exports.project = index$6;
|
|
26
|
+
exports.report = index$7;
|
|
27
|
+
exports.requirement = index$8;
|
|
28
|
+
exports.runner = index$9;
|
|
29
|
+
exports.timer = index$a;
|
|
30
|
+
exports.upgrader = index$b;
|
|
31
|
+
exports.version = index$c;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as index from './codemod/index.mjs';
|
|
2
|
+
export { index as codemod };
|
|
3
|
+
import * as index$1 from './codemod-repository/index.mjs';
|
|
4
|
+
export { index$1 as codemodRepository };
|
|
5
|
+
import * as index$2 from './error/index.mjs';
|
|
6
|
+
export { index$2 as error };
|
|
7
|
+
import * as index$3 from './file-scanner/index.mjs';
|
|
8
|
+
export { index$3 as fileScanner };
|
|
9
|
+
import * as index$4 from './format/index.mjs';
|
|
10
|
+
export { index$4 as f };
|
|
11
|
+
import * as index$5 from './logger/index.mjs';
|
|
12
|
+
export { index$5 as logger };
|
|
13
|
+
import * as index$6 from './project/index.mjs';
|
|
14
|
+
export { index$6 as project };
|
|
15
|
+
import * as index$7 from './report/index.mjs';
|
|
16
|
+
export { index$7 as report };
|
|
17
|
+
import * as index$8 from './requirement/index.mjs';
|
|
18
|
+
export { index$8 as requirement };
|
|
19
|
+
import * as index$9 from './runner/index.mjs';
|
|
20
|
+
export { index$9 as runner };
|
|
21
|
+
import * as index$a from './timer/index.mjs';
|
|
22
|
+
export { index$a as timer };
|
|
23
|
+
import * as index$b from './upgrader/index.mjs';
|
|
24
|
+
export { index$b as upgrader };
|
|
25
|
+
import * as index$c from './version/index.mjs';
|
|
26
|
+
export { index$c as version };
|
|
27
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fse = require('fs-extra');
|
|
4
|
+
|
|
5
|
+
const readJSON = async (path)=>{
|
|
6
|
+
const buffer = await fse.readFile(path);
|
|
7
|
+
return JSON.parse(buffer.toString());
|
|
8
|
+
};
|
|
9
|
+
const saveJSON = async (path, json)=>{
|
|
10
|
+
const jsonAsString = `${JSON.stringify(json, null, 2)}\n`;
|
|
11
|
+
await fse.writeFile(path, jsonAsString);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.readJSON = readJSON;
|
|
15
|
+
exports.saveJSON = saveJSON;
|
|
16
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sources":["../../../../src/modules/json/file.ts"],"sourcesContent":["import fse from 'fs-extra';\n\nimport type { Utils } from '@strapi/types';\n\nexport const readJSON = async (path: string): Promise<Utils.JSONValue> => {\n const buffer = await fse.readFile(path);\n\n return JSON.parse(buffer.toString());\n};\n\nexport const saveJSON = async (path: string, json: Utils.JSONValue): Promise<void> => {\n const jsonAsString = `${JSON.stringify(json, null, 2)}\\n`;\n\n await fse.writeFile(path, jsonAsString);\n};\n"],"names":["readJSON","path","buffer","fse","readFile","JSON","parse","toString","saveJSON","json","jsonAsString","stringify","writeFile"],"mappings":";;;;AAIO,MAAMA,WAAW,OAAOC,IAAAA,GAAAA;AAC7B,IAAA,MAAMC,MAAS,GAAA,MAAMC,GAAIC,CAAAA,QAAQ,CAACH,IAAAA,CAAAA;AAElC,IAAA,OAAOI,IAAKC,CAAAA,KAAK,CAACJ,MAAAA,CAAOK,QAAQ,EAAA,CAAA;AACnC;AAEO,MAAMC,QAAW,GAAA,OAAOP,IAAcQ,EAAAA,IAAAA,GAAAA;IAC3C,MAAMC,YAAAA,GAAe,CAAC,EAAEL,IAAKM,CAAAA,SAAS,CAACF,IAAM,EAAA,IAAA,EAAM,CAAG,CAAA,CAAA,EAAE,CAAC;IAEzD,MAAMN,GAAAA,CAAIS,SAAS,CAACX,IAAMS,EAAAA,YAAAA,CAAAA;AAC5B;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
|
|
3
|
+
const readJSON = async (path)=>{
|
|
4
|
+
const buffer = await fse.readFile(path);
|
|
5
|
+
return JSON.parse(buffer.toString());
|
|
6
|
+
};
|
|
7
|
+
const saveJSON = async (path, json)=>{
|
|
8
|
+
const jsonAsString = `${JSON.stringify(json, null, 2)}\n`;
|
|
9
|
+
await fse.writeFile(path, jsonAsString);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { readJSON, saveJSON };
|
|
13
|
+
//# sourceMappingURL=file.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.mjs","sources":["../../../../src/modules/json/file.ts"],"sourcesContent":["import fse from 'fs-extra';\n\nimport type { Utils } from '@strapi/types';\n\nexport const readJSON = async (path: string): Promise<Utils.JSONValue> => {\n const buffer = await fse.readFile(path);\n\n return JSON.parse(buffer.toString());\n};\n\nexport const saveJSON = async (path: string, json: Utils.JSONValue): Promise<void> => {\n const jsonAsString = `${JSON.stringify(json, null, 2)}\\n`;\n\n await fse.writeFile(path, jsonAsString);\n};\n"],"names":["readJSON","path","buffer","fse","readFile","JSON","parse","toString","saveJSON","json","jsonAsString","stringify","writeFile"],"mappings":";;AAIO,MAAMA,WAAW,OAAOC,IAAAA,GAAAA;AAC7B,IAAA,MAAMC,MAAS,GAAA,MAAMC,GAAIC,CAAAA,QAAQ,CAACH,IAAAA,CAAAA;AAElC,IAAA,OAAOI,IAAKC,CAAAA,KAAK,CAACJ,MAAAA,CAAOK,QAAQ,EAAA,CAAA;AACnC;AAEO,MAAMC,QAAW,GAAA,OAAOP,IAAcQ,EAAAA,IAAAA,GAAAA;IAC3C,MAAMC,YAAAA,GAAe,CAAC,EAAEL,IAAKM,CAAAA,SAAS,CAACF,IAAM,EAAA,IAAA,EAAM,CAAG,CAAA,CAAA,EAAE,CAAC;IAEzD,MAAMN,GAAAA,CAAIS,SAAS,CAACX,IAAMS,EAAAA,YAAAA,CAAAA;AAC5B;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
|
|
5
|
+
class JSONTransformAPI {
|
|
6
|
+
get(path, defaultValue) {
|
|
7
|
+
if (!path) {
|
|
8
|
+
return this.root();
|
|
9
|
+
}
|
|
10
|
+
return fp.cloneDeep(fp.get(path, this.json) ?? defaultValue);
|
|
11
|
+
}
|
|
12
|
+
has(path) {
|
|
13
|
+
return fp.has(path, this.json);
|
|
14
|
+
}
|
|
15
|
+
merge(other) {
|
|
16
|
+
this.json = fp.merge(other, this.json);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
root() {
|
|
20
|
+
return fp.cloneDeep(this.json);
|
|
21
|
+
}
|
|
22
|
+
set(path, value) {
|
|
23
|
+
this.json = fp.set(path, value, this.json);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
remove(path) {
|
|
27
|
+
this.json = fp.omit(path, this.json);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
constructor(json){
|
|
31
|
+
this.json = fp.cloneDeep(json);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const createJSONTransformAPI = (object)=>new JSONTransformAPI(object);
|
|
35
|
+
|
|
36
|
+
exports.JSONTransformAPI = JSONTransformAPI;
|
|
37
|
+
exports.createJSONTransformAPI = createJSONTransformAPI;
|
|
38
|
+
//# sourceMappingURL=transform-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-api.js","sources":["../../../../src/modules/json/transform-api.ts"],"sourcesContent":["import { cloneDeep, get, has, set, merge, omit } from 'lodash/fp';\n\nimport type { Utils } from '@strapi/types';\n\nimport type { JSONTransformAPI as JSONTransformAPIInterface } from './types';\n\nexport class JSONTransformAPI implements JSONTransformAPIInterface {\n private json: Utils.JSONObject;\n\n constructor(json: Utils.JSONObject) {\n this.json = cloneDeep(json);\n }\n\n get<T extends Utils.JSONValue>(path: string): T | undefined;\n get<T extends Utils.JSONValue>(path: string, defaultValue: T): T;\n get<T extends Utils.JSONValue>(path?: string, defaultValue?: T) {\n if (!path) {\n return this.root() as T;\n }\n\n return cloneDeep(get(path, this.json) ?? defaultValue) as T;\n }\n\n has(path: string) {\n return has(path, this.json);\n }\n\n merge(other: Utils.JSONObject) {\n this.json = merge(other, this.json);\n\n return this;\n }\n\n root(): Utils.JSONObject {\n return cloneDeep(this.json);\n }\n\n set(path: string, value: Utils.JSONValue) {\n this.json = set(path, value, this.json);\n\n return this;\n }\n\n remove(path: string) {\n this.json = omit(path, this.json);\n return this;\n }\n}\n\nexport const createJSONTransformAPI = (object: Utils.JSONObject) => new JSONTransformAPI(object);\n"],"names":["JSONTransformAPI","get","path","defaultValue","root","cloneDeep","json","has","merge","other","set","value","remove","omit","constructor","createJSONTransformAPI","object"],"mappings":";;;;AAMO,MAAMA,gBAAAA,CAAAA;IASXC,GAA+BC,CAAAA,IAAa,EAAEC,YAAgB,EAAE;AAC9D,QAAA,IAAI,CAACD,IAAM,EAAA;YACT,OAAO,IAAI,CAACE,IAAI,EAAA;AAClB;AAEA,QAAA,OAAOC,aAAUJ,MAAIC,CAAAA,IAAAA,EAAM,IAAI,CAACI,IAAI,CAAKH,IAAAA,YAAAA,CAAAA;AAC3C;AAEAI,IAAAA,GAAAA,CAAIL,IAAY,EAAE;AAChB,QAAA,OAAOK,MAAIL,CAAAA,IAAAA,EAAM,IAAI,CAACI,IAAI,CAAA;AAC5B;AAEAE,IAAAA,KAAAA,CAAMC,KAAuB,EAAE;AAC7B,QAAA,IAAI,CAACH,IAAI,GAAGE,SAAMC,KAAO,EAAA,IAAI,CAACH,IAAI,CAAA;AAElC,QAAA,OAAO,IAAI;AACb;IAEAF,IAAyB,GAAA;QACvB,OAAOC,YAAAA,CAAU,IAAI,CAACC,IAAI,CAAA;AAC5B;IAEAI,GAAIR,CAAAA,IAAY,EAAES,KAAsB,EAAE;QACxC,IAAI,CAACL,IAAI,GAAGI,MAAAA,CAAIR,MAAMS,KAAO,EAAA,IAAI,CAACL,IAAI,CAAA;AAEtC,QAAA,OAAO,IAAI;AACb;AAEAM,IAAAA,MAAAA,CAAOV,IAAY,EAAE;AACnB,QAAA,IAAI,CAACI,IAAI,GAAGO,QAAKX,IAAM,EAAA,IAAI,CAACI,IAAI,CAAA;AAChC,QAAA,OAAO,IAAI;AACb;AArCAQ,IAAAA,WAAAA,CAAYR,IAAsB,CAAE;QAClC,IAAI,CAACA,IAAI,GAAGD,YAAUC,CAAAA,IAAAA,CAAAA;AACxB;AAoCF;MAEaS,sBAAyB,GAAA,CAACC,MAA6B,GAAA,IAAIhB,iBAAiBgB,MAAQ;;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cloneDeep, get, has, merge, set, omit } from 'lodash/fp';
|
|
2
|
+
|
|
3
|
+
class JSONTransformAPI {
|
|
4
|
+
get(path, defaultValue) {
|
|
5
|
+
if (!path) {
|
|
6
|
+
return this.root();
|
|
7
|
+
}
|
|
8
|
+
return cloneDeep(get(path, this.json) ?? defaultValue);
|
|
9
|
+
}
|
|
10
|
+
has(path) {
|
|
11
|
+
return has(path, this.json);
|
|
12
|
+
}
|
|
13
|
+
merge(other) {
|
|
14
|
+
this.json = merge(other, this.json);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
root() {
|
|
18
|
+
return cloneDeep(this.json);
|
|
19
|
+
}
|
|
20
|
+
set(path, value) {
|
|
21
|
+
this.json = set(path, value, this.json);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
remove(path) {
|
|
25
|
+
this.json = omit(path, this.json);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
constructor(json){
|
|
29
|
+
this.json = cloneDeep(json);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const createJSONTransformAPI = (object)=>new JSONTransformAPI(object);
|
|
33
|
+
|
|
34
|
+
export { JSONTransformAPI, createJSONTransformAPI };
|
|
35
|
+
//# sourceMappingURL=transform-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-api.mjs","sources":["../../../../src/modules/json/transform-api.ts"],"sourcesContent":["import { cloneDeep, get, has, set, merge, omit } from 'lodash/fp';\n\nimport type { Utils } from '@strapi/types';\n\nimport type { JSONTransformAPI as JSONTransformAPIInterface } from './types';\n\nexport class JSONTransformAPI implements JSONTransformAPIInterface {\n private json: Utils.JSONObject;\n\n constructor(json: Utils.JSONObject) {\n this.json = cloneDeep(json);\n }\n\n get<T extends Utils.JSONValue>(path: string): T | undefined;\n get<T extends Utils.JSONValue>(path: string, defaultValue: T): T;\n get<T extends Utils.JSONValue>(path?: string, defaultValue?: T) {\n if (!path) {\n return this.root() as T;\n }\n\n return cloneDeep(get(path, this.json) ?? defaultValue) as T;\n }\n\n has(path: string) {\n return has(path, this.json);\n }\n\n merge(other: Utils.JSONObject) {\n this.json = merge(other, this.json);\n\n return this;\n }\n\n root(): Utils.JSONObject {\n return cloneDeep(this.json);\n }\n\n set(path: string, value: Utils.JSONValue) {\n this.json = set(path, value, this.json);\n\n return this;\n }\n\n remove(path: string) {\n this.json = omit(path, this.json);\n return this;\n }\n}\n\nexport const createJSONTransformAPI = (object: Utils.JSONObject) => new JSONTransformAPI(object);\n"],"names":["JSONTransformAPI","get","path","defaultValue","root","cloneDeep","json","has","merge","other","set","value","remove","omit","constructor","createJSONTransformAPI","object"],"mappings":";;AAMO,MAAMA,gBAAAA,CAAAA;IASXC,GAA+BC,CAAAA,IAAa,EAAEC,YAAgB,EAAE;AAC9D,QAAA,IAAI,CAACD,IAAM,EAAA;YACT,OAAO,IAAI,CAACE,IAAI,EAAA;AAClB;AAEA,QAAA,OAAOC,UAAUJ,GAAIC,CAAAA,IAAAA,EAAM,IAAI,CAACI,IAAI,CAAKH,IAAAA,YAAAA,CAAAA;AAC3C;AAEAI,IAAAA,GAAAA,CAAIL,IAAY,EAAE;AAChB,QAAA,OAAOK,GAAIL,CAAAA,IAAAA,EAAM,IAAI,CAACI,IAAI,CAAA;AAC5B;AAEAE,IAAAA,KAAAA,CAAMC,KAAuB,EAAE;AAC7B,QAAA,IAAI,CAACH,IAAI,GAAGE,MAAMC,KAAO,EAAA,IAAI,CAACH,IAAI,CAAA;AAElC,QAAA,OAAO,IAAI;AACb;IAEAF,IAAyB,GAAA;QACvB,OAAOC,SAAAA,CAAU,IAAI,CAACC,IAAI,CAAA;AAC5B;IAEAI,GAAIR,CAAAA,IAAY,EAAES,KAAsB,EAAE;QACxC,IAAI,CAACL,IAAI,GAAGI,GAAAA,CAAIR,MAAMS,KAAO,EAAA,IAAI,CAACL,IAAI,CAAA;AAEtC,QAAA,OAAO,IAAI;AACb;AAEAM,IAAAA,MAAAA,CAAOV,IAAY,EAAE;AACnB,QAAA,IAAI,CAACI,IAAI,GAAGO,KAAKX,IAAM,EAAA,IAAI,CAACI,IAAI,CAAA;AAChC,QAAA,OAAO,IAAI;AACb;AArCAQ,IAAAA,WAAAA,CAAYR,IAAsB,CAAE;QAClC,IAAI,CAACA,IAAI,GAAGD,SAAUC,CAAAA,IAAAA,CAAAA;AACxB;AAoCF;MAEaS,sBAAyB,GAAA,CAACC,MAA6B,GAAA,IAAIhB,iBAAiBgB,MAAQ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|