@strapi/upgrade 0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28
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/LICENSE +22 -0
- package/README.md +171 -0
- package/bin/upgrade.js +2 -0
- package/dist/_chunks/codemod-runner-6FtEoXzL.js +729 -0
- package/dist/_chunks/codemod-runner-6FtEoXzL.js.map +1 -0
- package/dist/_chunks/codemods-1SG_Nr9F.js +108 -0
- package/dist/_chunks/codemods-1SG_Nr9F.js.map +1 -0
- package/dist/_chunks/index-lX2ZsI17.js +103 -0
- package/dist/_chunks/index-lX2ZsI17.js.map +1 -0
- package/dist/_chunks/upgrade-Qf1t7dYA.js +357 -0
- package/dist/_chunks/upgrade-Qf1t7dYA.js.map +1 -0
- package/dist/cli.js +7 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1199 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1191 -0
- package/dist/index.mjs.map +1 -0
- package/dist/modules/codemod/codemod.d.ts +15 -0
- package/dist/modules/codemod/codemod.d.ts.map +1 -0
- package/dist/modules/codemod/constants.d.ts +6 -0
- package/dist/modules/codemod/constants.d.ts.map +1 -0
- package/dist/modules/codemod/index.d.ts +4 -0
- package/dist/modules/codemod/index.d.ts.map +1 -0
- package/dist/modules/codemod/types.d.ts +19 -0
- package/dist/modules/codemod/types.d.ts.map +1 -0
- package/dist/modules/codemod-repository/constants.d.ts +2 -0
- package/dist/modules/codemod-repository/constants.d.ts.map +1 -0
- package/dist/modules/codemod-repository/index.d.ts +4 -0
- package/dist/modules/codemod-repository/index.d.ts.map +1 -0
- package/dist/modules/codemod-repository/repository.d.ts +21 -0
- package/dist/modules/codemod-repository/repository.d.ts.map +1 -0
- package/dist/modules/codemod-repository/types.d.ts +12 -0
- package/dist/modules/codemod-repository/types.d.ts.map +1 -0
- package/dist/modules/codemod-runner/codemod-runner.d.ts +19 -0
- package/dist/modules/codemod-runner/codemod-runner.d.ts.map +1 -0
- package/dist/modules/codemod-runner/index.d.ts +2 -0
- package/dist/modules/codemod-runner/index.d.ts.map +1 -0
- package/dist/modules/codemod-runner/types.d.ts +19 -0
- package/dist/modules/codemod-runner/types.d.ts.map +1 -0
- package/dist/modules/common/types.d.ts +3 -0
- package/dist/modules/common/types.d.ts.map +1 -0
- package/dist/modules/error/index.d.ts +2 -0
- package/dist/modules/error/index.d.ts.map +1 -0
- package/dist/modules/error/utils.d.ts +5 -0
- package/dist/modules/error/utils.d.ts.map +1 -0
- package/dist/modules/file-scanner/index.d.ts +3 -0
- package/dist/modules/file-scanner/index.d.ts.map +1 -0
- package/dist/modules/file-scanner/scanner.d.ts +8 -0
- package/dist/modules/file-scanner/scanner.d.ts.map +1 -0
- package/dist/modules/file-scanner/types.d.ts +5 -0
- package/dist/modules/file-scanner/types.d.ts.map +1 -0
- package/dist/modules/format/formats.d.ts +11 -0
- package/dist/modules/format/formats.d.ts.map +1 -0
- package/dist/modules/format/index.d.ts +2 -0
- package/dist/modules/format/index.d.ts.map +1 -0
- package/dist/modules/index.d.ts +14 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/json/file.d.ts +4 -0
- package/dist/modules/json/file.d.ts.map +1 -0
- package/dist/modules/json/index.d.ts +4 -0
- package/dist/modules/json/index.d.ts.map +1 -0
- package/dist/modules/json/transform-api.d.ts +15 -0
- package/dist/modules/json/transform-api.d.ts.map +1 -0
- package/dist/modules/json/types.d.ts +11 -0
- package/dist/modules/json/types.d.ts.map +1 -0
- package/dist/modules/logger/index.d.ts +3 -0
- package/dist/modules/logger/index.d.ts.map +1 -0
- package/dist/modules/logger/logger.d.ts +27 -0
- package/dist/modules/logger/logger.d.ts.map +1 -0
- package/dist/modules/logger/types.d.ts +25 -0
- package/dist/modules/logger/types.d.ts.map +1 -0
- package/dist/modules/npm/constants.d.ts +2 -0
- package/dist/modules/npm/constants.d.ts.map +1 -0
- package/dist/modules/npm/index.d.ts +4 -0
- package/dist/modules/npm/index.d.ts.map +1 -0
- package/dist/modules/npm/package.d.ts +18 -0
- package/dist/modules/npm/package.d.ts.map +1 -0
- package/dist/modules/npm/types.d.ts +103 -0
- package/dist/modules/npm/types.d.ts.map +1 -0
- package/dist/modules/project/constants.d.ts +7 -0
- package/dist/modules/project/constants.d.ts.map +1 -0
- package/dist/modules/project/index.d.ts +4 -0
- package/dist/modules/project/index.d.ts.map +1 -0
- package/dist/modules/project/project.d.ts +23 -0
- package/dist/modules/project/project.d.ts.map +1 -0
- package/dist/modules/project/types.d.ts +26 -0
- package/dist/modules/project/types.d.ts.map +1 -0
- package/dist/modules/report/index.d.ts +3 -0
- package/dist/modules/report/index.d.ts.map +1 -0
- package/dist/modules/report/report.d.ts +5 -0
- package/dist/modules/report/report.d.ts.map +1 -0
- package/dist/modules/report/types.d.ts +15 -0
- package/dist/modules/report/types.d.ts.map +1 -0
- package/dist/modules/requirement/index.d.ts +3 -0
- package/dist/modules/requirement/index.d.ts.map +1 -0
- package/dist/modules/requirement/requirement.d.ts +15 -0
- package/dist/modules/requirement/requirement.d.ts.map +1 -0
- package/dist/modules/requirement/types.d.ts +47 -0
- package/dist/modules/requirement/types.d.ts.map +1 -0
- package/dist/modules/runner/code/code.d.ts +10 -0
- package/dist/modules/runner/code/code.d.ts.map +1 -0
- package/dist/modules/runner/code/index.d.ts +3 -0
- package/dist/modules/runner/code/index.d.ts.map +1 -0
- package/dist/modules/runner/code/types.d.ts +11 -0
- package/dist/modules/runner/code/types.d.ts.map +1 -0
- package/dist/modules/runner/index.d.ts +4 -0
- package/dist/modules/runner/index.d.ts.map +1 -0
- package/dist/modules/runner/json/index.d.ts +3 -0
- package/dist/modules/runner/json/index.d.ts.map +1 -0
- package/dist/modules/runner/json/json.d.ts +9 -0
- package/dist/modules/runner/json/json.d.ts.map +1 -0
- package/dist/modules/runner/json/transform.d.ts +4 -0
- package/dist/modules/runner/json/transform.d.ts.map +1 -0
- package/dist/modules/runner/json/types.d.ts +16 -0
- package/dist/modules/runner/json/types.d.ts.map +1 -0
- package/dist/modules/runner/runner.d.ts +11 -0
- package/dist/modules/runner/runner.d.ts.map +1 -0
- package/dist/modules/runner/types.d.ts +14 -0
- package/dist/modules/runner/types.d.ts.map +1 -0
- package/dist/modules/timer/constants.d.ts +2 -0
- package/dist/modules/timer/constants.d.ts.map +1 -0
- package/dist/modules/timer/index.d.ts +4 -0
- package/dist/modules/timer/index.d.ts.map +1 -0
- package/dist/modules/timer/timer.d.ts +12 -0
- package/dist/modules/timer/timer.d.ts.map +1 -0
- package/dist/modules/timer/types.d.ts +12 -0
- package/dist/modules/timer/types.d.ts.map +1 -0
- package/dist/modules/upgrader/constants.d.ts +2 -0
- package/dist/modules/upgrader/constants.d.ts.map +1 -0
- package/dist/modules/upgrader/index.d.ts +4 -0
- package/dist/modules/upgrader/index.d.ts.map +1 -0
- package/dist/modules/upgrader/types.d.ts +23 -0
- package/dist/modules/upgrader/types.d.ts.map +1 -0
- package/dist/modules/upgrader/upgrader.d.ts +36 -0
- package/dist/modules/upgrader/upgrader.d.ts.map +1 -0
- package/dist/modules/version/index.d.ts +4 -0
- package/dist/modules/version/index.d.ts.map +1 -0
- package/dist/modules/version/range.d.ts +6 -0
- package/dist/modules/version/range.d.ts.map +1 -0
- package/dist/modules/version/semver.d.ts +8 -0
- package/dist/modules/version/semver.d.ts.map +1 -0
- package/dist/modules/version/types.d.ts +10 -0
- package/dist/modules/version/types.d.ts.map +1 -0
- package/dist/tasks/codemods/codemods.d.ts +3 -0
- package/dist/tasks/codemods/codemods.d.ts.map +1 -0
- package/dist/tasks/codemods/index.d.ts +2 -0
- package/dist/tasks/codemods/index.d.ts.map +1 -0
- package/dist/tasks/codemods/types.d.ts +13 -0
- package/dist/tasks/codemods/types.d.ts.map +1 -0
- package/dist/tasks/index.d.ts +4 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/upgrade/index.d.ts +4 -0
- package/dist/tasks/upgrade/index.d.ts.map +1 -0
- package/dist/tasks/upgrade/requirements/common.d.ts +5 -0
- package/dist/tasks/upgrade/requirements/common.d.ts.map +1 -0
- package/dist/tasks/upgrade/requirements/index.d.ts +3 -0
- package/dist/tasks/upgrade/requirements/index.d.ts.map +1 -0
- package/dist/tasks/upgrade/requirements/major.d.ts +3 -0
- package/dist/tasks/upgrade/requirements/major.d.ts.map +1 -0
- package/dist/tasks/upgrade/types.d.ts +12 -0
- package/dist/tasks/upgrade/types.d.ts.map +1 -0
- package/dist/tasks/upgrade/upgrade.d.ts +3 -0
- package/dist/tasks/upgrade/upgrade.d.ts.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +89 -0
- package/resources/codemods/5.0.0/.gitkeep +0 -0
- package/resources/codemods/5.0.0/s3-keys-wrapped-in-credentials.code.ts +169 -0
- package/resources/codemods/5.0.0/sqlite3-to-better-sqlite3.json.ts +37 -0
- package/resources/examples/console.log-to-console.info.code.ts +37 -0
- package/resources/examples/upgrade-strapi-version.json.ts +29 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Version } from '../version';
|
|
2
|
+
import type { Requirement } from '../requirement';
|
|
3
|
+
import type { Logger } from '../logger';
|
|
4
|
+
import type { ConfirmationCallback } from '../common/types';
|
|
5
|
+
export interface Upgrader {
|
|
6
|
+
setTarget(target: Version.SemVer): this;
|
|
7
|
+
setRequirements(requirements: Requirement.Requirement[]): this;
|
|
8
|
+
setLogger(logger: Logger): this;
|
|
9
|
+
overrideCodemodsTarget(target: Version.SemVer): this;
|
|
10
|
+
syncCodemodsTarget(): this;
|
|
11
|
+
dry(enabled?: boolean): this;
|
|
12
|
+
onConfirm(callback: ConfirmationCallback | null): this;
|
|
13
|
+
addRequirement(requirement: Requirement.Requirement): this;
|
|
14
|
+
upgrade(): Promise<UpgradeReport>;
|
|
15
|
+
}
|
|
16
|
+
export type UpgradeReport = {
|
|
17
|
+
success: true;
|
|
18
|
+
error: null;
|
|
19
|
+
} | {
|
|
20
|
+
success: false;
|
|
21
|
+
error: Error;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/upgrader/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,WAAW,QAAQ;IACvB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IACxC,eAAe,CAAC,YAAY,EAAE,WAAW,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC;IAC/D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhC,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IACrD,kBAAkB,IAAI,IAAI,CAAC;IAE3B,GAAG,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;IAEvD,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW,GAAG,IAAI,CAAC;IAE3D,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,aAAa,GACrB;IACE,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Upgrader as UpgraderInterface, UpgradeReport } from './types';
|
|
2
|
+
import type { Version } from '../version';
|
|
3
|
+
import type { Logger } from '../logger';
|
|
4
|
+
import type { Requirement } from '../requirement';
|
|
5
|
+
import type { NPM } from '../npm';
|
|
6
|
+
import type { Project } from '../project';
|
|
7
|
+
import type { ConfirmationCallback } from '../common/types';
|
|
8
|
+
export declare class Upgrader implements UpgraderInterface {
|
|
9
|
+
private readonly project;
|
|
10
|
+
private readonly npmPackage;
|
|
11
|
+
private target;
|
|
12
|
+
private codemodsTarget;
|
|
13
|
+
private isDry;
|
|
14
|
+
private logger;
|
|
15
|
+
private requirements;
|
|
16
|
+
private confirmationCallback;
|
|
17
|
+
constructor(project: Project, target: Version.SemVer, npmPackage: NPM.Package);
|
|
18
|
+
setRequirements(requirements: Requirement.Requirement[]): this;
|
|
19
|
+
setTarget(target: Version.SemVer): this;
|
|
20
|
+
syncCodemodsTarget(): this;
|
|
21
|
+
overrideCodemodsTarget(target: Version.SemVer): this;
|
|
22
|
+
setLogger(logger: Logger): this;
|
|
23
|
+
onConfirm(callback: ConfirmationCallback | null): this;
|
|
24
|
+
dry(enabled?: boolean): this;
|
|
25
|
+
addRequirement(requirement: Requirement.Requirement): this;
|
|
26
|
+
upgrade(): Promise<UpgradeReport>;
|
|
27
|
+
private checkRequirements;
|
|
28
|
+
private onSuccessfulRequirement;
|
|
29
|
+
private onFailedRequirement;
|
|
30
|
+
private updateDependencies;
|
|
31
|
+
private getScopedStrapiDependencies;
|
|
32
|
+
private installDependencies;
|
|
33
|
+
private runCodemods;
|
|
34
|
+
}
|
|
35
|
+
export declare const upgraderFactory: (project: Project, target: Version.ReleaseType | Version.SemVer, npmPackage: NPM.Package) => Upgrader;
|
|
36
|
+
//# sourceMappingURL=upgrader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrader.d.ts","sourceRoot":"","sources":["../../../src/modules/upgrader/upgrader.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,QAAQ,IAAI,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAI5D,qBAAa,QAAS,YAAW,iBAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAElC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IAEzC,OAAO,CAAC,MAAM,CAAiB;IAE/B,OAAO,CAAC,cAAc,CAAkB;IAExC,OAAO,CAAC,KAAK,CAAU;IAEvB,OAAO,CAAC,MAAM,CAAgB;IAE9B,OAAO,CAAC,YAAY,CAA4B;IAEhD,OAAO,CAAC,oBAAoB,CAA8B;gBAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO;IAe7E,eAAe,CAAC,YAAY,EAAE,WAAW,CAAC,WAAW,EAAE;IAKvD,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM;IAKhC,kBAAkB;IAqBlB,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM;IAU7C,SAAS,CAAC,MAAM,EAAE,MAAM;IAKxB,SAAS,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;IAK/C,GAAG,CAAC,OAAO,GAAE,OAAc;IAK3B,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW;IAW7C,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;YA2CzB,iBAAiB;YAejB,uBAAuB;YAWvB,mBAAmB;YAyBnB,kBAAkB;IA6BhC,OAAO,CAAC,2BAA2B;YAkBrB,mBAAmB;YAkBnB,WAAW;CAQ1B;AA6BD,eAAO,MAAM,eAAe,YACjB,OAAO,UACR,QAAQ,WAAW,GAAG,QAAQ,MAAM,cAChC,IAAI,OAAO,aAcxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/version/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAIxB,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import * as Version from './types';
|
|
3
|
+
export declare const rangeFactory: (range: string) => Version.Range;
|
|
4
|
+
export declare const rangeFromReleaseType: (current: Version.SemVer, identifier: Version.ReleaseType) => semver.Range;
|
|
5
|
+
export declare const rangeFromVersions: (currentVersion: Version.SemVer, target: Version.ReleaseType | Version.SemVer) => semver.Range;
|
|
6
|
+
//# sourceMappingURL=range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["../../../src/modules/version/range.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,aAE5C,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAa,QAAQ,MAAM,cAAc,QAAQ,WAAW,iBAwB5F,CAAC;AAEF,eAAO,MAAM,iBAAiB,mBACZ,QAAQ,MAAM,UACtB,QAAQ,WAAW,GAAG,QAAQ,MAAM,iBAW7C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import * as Version from './types';
|
|
3
|
+
export declare const semVerFactory: (version: string) => Version.SemVer;
|
|
4
|
+
export declare const isLiteralSemVer: (str: string) => str is `${number}.${number}.${number}`;
|
|
5
|
+
export declare const isValidSemVer: (str: string) => boolean;
|
|
6
|
+
export declare const isSemverInstance: (value: unknown) => value is semver.SemVer;
|
|
7
|
+
export declare const isSemVerReleaseType: (str: string) => str is Version.ReleaseType;
|
|
8
|
+
//# sourceMappingURL=semver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../../src/modules/version/semver.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,eAAO,MAAM,aAAa,YAAa,MAAM,KAAG,QAAQ,MAEvD,CAAC;AAEF,eAAO,MAAM,eAAe,QAAS,MAAM,2CAO1C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,MAAM,YAA+B,CAAC;AAEzE,eAAO,MAAM,gBAAgB,UAAW,OAAO,2BAE9C,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAS,MAAM,+BAE9C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Version = number;
|
|
2
|
+
export type LiteralVersion = `${Version}` | `${Version}.${Version}` | `${Version}.${Version}.${Version}`;
|
|
3
|
+
export type LiteralSemVer = `${Version}.${Version}.${Version}`;
|
|
4
|
+
export type { SemVer, Range } from 'semver';
|
|
5
|
+
export declare enum ReleaseType {
|
|
6
|
+
Major = "major",
|
|
7
|
+
Minor = "minor",
|
|
8
|
+
Patch = "patch"
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/version/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,MAAM,cAAc,GACtB,GAAG,OAAO,EAAE,GACZ,GAAG,OAAO,IAAI,OAAO,EAAE,GACvB,GAAG,OAAO,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,GAAG,OAAO,IAAI,OAAO,IAAI,OAAO,EAAE,CAAC;AAE/D,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE5C,oBAAY,WAAW;IACrB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemods.d.ts","sourceRoot":"","sources":["../../../src/tasks/codemods/codemods.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIlD,eAAO,MAAM,QAAQ,YAAmB,kBAAkB,kBAuBzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tasks/codemods/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SelectCodemodsCallback } from '../../modules/codemod-runner/types';
|
|
2
|
+
import { ConfirmationCallback } from '../../modules/common/types';
|
|
3
|
+
import type { Logger } from '../../modules/logger';
|
|
4
|
+
import type { Version } from '../../modules/version';
|
|
5
|
+
export interface RunCodemodsOptions {
|
|
6
|
+
logger: Logger;
|
|
7
|
+
confirm?: ConfirmationCallback;
|
|
8
|
+
selectCodemods: SelectCodemodsCallback;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
dry?: boolean;
|
|
11
|
+
target: Version.ReleaseType | Version.LiteralSemVer;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tasks/codemods/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,cAAc,EAAE,sBAAsB,CAAC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tasks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tasks/upgrade/index.ts"],"names":[],"mappings":"AAAA,YAAY,KAAK,OAAO,MAAM,SAAS,CAAC;AAExC,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const REQUIRE_GIT_CLEAN_REPOSITORY: import("../../../modules/requirement/requirement").Requirement;
|
|
2
|
+
export declare const REQUIRE_GIT_REPOSITORY: import("../../../modules/requirement/requirement").Requirement;
|
|
3
|
+
export declare const REQUIRE_GIT_INSTALLED: import("../../../modules/requirement/requirement").Requirement;
|
|
4
|
+
export declare const REQUIRE_GIT: import("../../../modules/requirement/requirement").Requirement;
|
|
5
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/tasks/upgrade/requirements/common.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,gEAaxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,gEAWkB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,gEAWa,CAAC;AAEhD,eAAO,MAAM,WAAW,gEAEvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tasks/upgrade/requirements/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"major.d.ts","sourceRoot":"","sources":["../../../../src/tasks/upgrade/requirements/major.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B,gEAYxC,CAAC;AAEF,eAAO,MAAM,gCAAgC,gEAgB5C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Version } from '../../modules/version';
|
|
2
|
+
import type { Logger } from '../../modules/logger';
|
|
3
|
+
import type { ConfirmationCallback } from '../../modules/common/types';
|
|
4
|
+
export interface UpgradeOptions {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
confirm?: ConfirmationCallback;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
dry?: boolean;
|
|
9
|
+
target: Version.ReleaseType | Version.SemVer;
|
|
10
|
+
codemodsTarget?: Version.SemVer;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tasks/upgrade/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7C,cAAc,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../src/tasks/upgrade/upgrade.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,eAAO,MAAM,OAAO,YAAmB,cAAc,kBA6CpD,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@strapi/upgrade",
|
|
3
|
+
"version": "0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28",
|
|
4
|
+
"description": "CLI to upgrade Strapi applications effortless",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"strapi",
|
|
7
|
+
"package",
|
|
8
|
+
"tool",
|
|
9
|
+
"upgrade",
|
|
10
|
+
"migrate",
|
|
11
|
+
"version"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/strapi/strapi.git",
|
|
16
|
+
"directory": "packages/utils/upgrade"
|
|
17
|
+
},
|
|
18
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Strapi Solutions SAS",
|
|
21
|
+
"email": "hi@strapi.io",
|
|
22
|
+
"url": "https://strapi.io"
|
|
23
|
+
},
|
|
24
|
+
"maintainers": [
|
|
25
|
+
{
|
|
26
|
+
"name": "Strapi Solutions SAS",
|
|
27
|
+
"email": "hi@strapi.io",
|
|
28
|
+
"url": "https://strapi.io"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"source": "./src/index.ts",
|
|
35
|
+
"import": "./dist/index.mjs",
|
|
36
|
+
"require": "./dist/index.js",
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"main": "./dist/index.js",
|
|
42
|
+
"module": "./dist/index.mjs",
|
|
43
|
+
"source": "./src/index.ts",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"bin": "./bin/upgrade.js",
|
|
46
|
+
"files": [
|
|
47
|
+
"bin",
|
|
48
|
+
"dist",
|
|
49
|
+
"resources"
|
|
50
|
+
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "pack-up build",
|
|
53
|
+
"clean": "run -T rimraf ./dist",
|
|
54
|
+
"lint": "run -T eslint .",
|
|
55
|
+
"prepublishOnly": "yarn clean && yarn build",
|
|
56
|
+
"test:ts": "run -T tsc --noEmit",
|
|
57
|
+
"test:unit": "run -T jest",
|
|
58
|
+
"test:unit:watch": "run -T jest --watch",
|
|
59
|
+
"watch": "pack-up watch"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@strapi/utils": "0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28",
|
|
63
|
+
"chalk": "4.1.2",
|
|
64
|
+
"cli-table3": "0.6.2",
|
|
65
|
+
"commander": "8.3.0",
|
|
66
|
+
"esbuild-register": "3.5.0",
|
|
67
|
+
"fs-extra": "10.1.0",
|
|
68
|
+
"glob": "10.3.10",
|
|
69
|
+
"jscodeshift": "0.15.1",
|
|
70
|
+
"lodash": "4.17.21",
|
|
71
|
+
"memfs": "4.6.0",
|
|
72
|
+
"ora": "5.4.1",
|
|
73
|
+
"prompts": "2.4.2",
|
|
74
|
+
"semver": "7.5.4",
|
|
75
|
+
"simple-git": "3.21.0"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@strapi/pack-up": "0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28",
|
|
79
|
+
"@strapi/types": "0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28",
|
|
80
|
+
"@types/jscodeshift": "0.11.10",
|
|
81
|
+
"eslint-config-custom": "0.0.0-experimental.22e8a4f31c0b65da00cc6c524a94de53fabc7a28",
|
|
82
|
+
"rimraf": "3.0.2"
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=18.0.0 <=20.x.x",
|
|
86
|
+
"npm": ">=6.0.0"
|
|
87
|
+
},
|
|
88
|
+
"gitHead": "22e8a4f31c0b65da00cc6c524a94de53fabc7a28"
|
|
89
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import core, {
|
|
2
|
+
Transform,
|
|
3
|
+
ASTPath,
|
|
4
|
+
Property,
|
|
5
|
+
ArrowFunctionExpression,
|
|
6
|
+
ObjectExpression,
|
|
7
|
+
} from 'jscodeshift';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
|
|
10
|
+
const findUploadPropertyInBody = (j: core.JSCodeshift, body: ObjectExpression) => {
|
|
11
|
+
return body.properties.find(
|
|
12
|
+
(prop: any) =>
|
|
13
|
+
j.Property.check(prop) && j.Identifier.check(prop.key) && prop.key.name === 'upload'
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const findConfigInUpload = (j: core.JSCodeshift, upload: ObjectExpression) => {
|
|
18
|
+
return upload.properties.find(
|
|
19
|
+
(prop) => j.Property.check(prop) && j.Identifier.check(prop.key) && prop.key.name === 'config'
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const getProviderProperty = (j: core.JSCodeshift, config: ObjectExpression) => {
|
|
24
|
+
return config.properties.find(
|
|
25
|
+
(prop) =>
|
|
26
|
+
j.Property.check(prop) &&
|
|
27
|
+
j.Identifier.check(prop.key) &&
|
|
28
|
+
prop.key.name === 'provider' &&
|
|
29
|
+
j.Literal.check(prop.value) &&
|
|
30
|
+
prop.value.value === 'aws-s3'
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getProviderOptions = (j: core.JSCodeshift, config: ObjectExpression) => {
|
|
35
|
+
return config.properties.find(
|
|
36
|
+
(prop) =>
|
|
37
|
+
j.Property.check(prop) && j.Identifier.check(prop.key) && prop.key.name === 'providerOptions'
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getPropertyByKeyName = (j: core.JSCodeshift, object: ObjectExpression, keyName: string) => {
|
|
42
|
+
return object.properties.find(
|
|
43
|
+
(prop) => j.Property.check(prop) && j.Identifier.check(prop.key) && prop.key.name === keyName
|
|
44
|
+
) as Property;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This codemod only affects users that are using the `aws-s3` provider.
|
|
49
|
+
* It will wrap the `accessKeyId` and `secretAccessKey` properties inside a `credentials` object.
|
|
50
|
+
*/
|
|
51
|
+
const transform: Transform = (file, api) => {
|
|
52
|
+
// Check if the current file is 'config/plugins.js'
|
|
53
|
+
const cwd = process.cwd();
|
|
54
|
+
const jsPluginsPath = path.join(cwd, 'config/plugins.js');
|
|
55
|
+
const tsPluginsPath = path.join(cwd, 'config/plugins.ts');
|
|
56
|
+
|
|
57
|
+
if (file.path !== jsPluginsPath && file.path !== tsPluginsPath) {
|
|
58
|
+
return file.source;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { j } = api;
|
|
62
|
+
const root = j(file.source);
|
|
63
|
+
|
|
64
|
+
root
|
|
65
|
+
.find(j.ArrowFunctionExpression)
|
|
66
|
+
.forEach((arrowFunctionPath: ASTPath<ArrowFunctionExpression>) => {
|
|
67
|
+
const body = arrowFunctionPath.node.body;
|
|
68
|
+
|
|
69
|
+
// Check that the body of the arrow function is an object
|
|
70
|
+
if (!j.ObjectExpression.check(body)) {
|
|
71
|
+
return file.source;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const uploadProperty = findUploadPropertyInBody(j, body);
|
|
75
|
+
|
|
76
|
+
// Check that we found an upload property and that it is an object
|
|
77
|
+
if (!j.Property.check(uploadProperty) || !j.ObjectExpression.check(uploadProperty.value)) {
|
|
78
|
+
return file.source;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const configProperty = findConfigInUpload(j, uploadProperty.value);
|
|
82
|
+
|
|
83
|
+
if (!j.Property.check(configProperty) || !j.ObjectExpression.check(configProperty.value)) {
|
|
84
|
+
return file.source;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const providerProperty = getProviderProperty(j, configProperty.value);
|
|
88
|
+
|
|
89
|
+
// If there is not a provider property or it is not 'aws-s3', return the source
|
|
90
|
+
if (!providerProperty) {
|
|
91
|
+
return file.source;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const providerOptions = getProviderOptions(j, configProperty.value);
|
|
95
|
+
|
|
96
|
+
if (!j.Property.check(providerOptions) || !j.ObjectExpression.check(providerOptions.value)) {
|
|
97
|
+
return file.source;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let accessKeyId: Property | undefined;
|
|
101
|
+
let secretAccessKey: Property | undefined;
|
|
102
|
+
|
|
103
|
+
// Check for accessKeyId and secretAccessKey directly under providerOptions
|
|
104
|
+
const directAccessKeyId = getPropertyByKeyName(j, providerOptions.value, 'accessKeyId');
|
|
105
|
+
|
|
106
|
+
const directSecretAccessKey = getPropertyByKeyName(
|
|
107
|
+
j,
|
|
108
|
+
providerOptions.value,
|
|
109
|
+
'secretAccessKey'
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
let s3Options = getPropertyByKeyName(j, providerOptions.value, 's3Options');
|
|
113
|
+
|
|
114
|
+
if (!s3Options) {
|
|
115
|
+
// Create s3Options if it doesn't exist
|
|
116
|
+
s3Options = j.property('init', j.identifier('s3Options'), j.objectExpression([]));
|
|
117
|
+
providerOptions.value.properties.push(s3Options);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (directAccessKeyId && directSecretAccessKey) {
|
|
121
|
+
accessKeyId = directAccessKeyId;
|
|
122
|
+
secretAccessKey = directSecretAccessKey;
|
|
123
|
+
|
|
124
|
+
// Remove these properties from providerOptions
|
|
125
|
+
providerOptions.value.properties = providerOptions.value.properties.filter(
|
|
126
|
+
(prop) =>
|
|
127
|
+
j.Property.check(prop) &&
|
|
128
|
+
j.Identifier.check(prop.key) &&
|
|
129
|
+
prop.key.name !== 'accessKeyId' &&
|
|
130
|
+
prop.key.name !== 'secretAccessKey'
|
|
131
|
+
);
|
|
132
|
+
} else if (j.Property.check(s3Options) && j.ObjectExpression.check(s3Options.value)) {
|
|
133
|
+
// Look inside s3Options
|
|
134
|
+
accessKeyId = getPropertyByKeyName(j, s3Options.value, 'accessKeyId');
|
|
135
|
+
secretAccessKey = getPropertyByKeyName(j, s3Options.value, 'secretAccessKey');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (
|
|
139
|
+
accessKeyId &&
|
|
140
|
+
secretAccessKey &&
|
|
141
|
+
j.Property.check(s3Options) &&
|
|
142
|
+
j.ObjectExpression.check(s3Options.value)
|
|
143
|
+
) {
|
|
144
|
+
// Create the credentials object
|
|
145
|
+
const credentials = j.objectExpression([
|
|
146
|
+
j.property('init', j.identifier('accessKeyId'), accessKeyId.value),
|
|
147
|
+
j.property('init', j.identifier('secretAccessKey'), secretAccessKey.value),
|
|
148
|
+
]);
|
|
149
|
+
|
|
150
|
+
// Remove the old properties from s3Options
|
|
151
|
+
s3Options.value.properties = s3Options.value.properties.filter(
|
|
152
|
+
(prop) =>
|
|
153
|
+
j.Property.check(prop) &&
|
|
154
|
+
j.Identifier.check(prop.key) &&
|
|
155
|
+
prop.key.name !== 'accessKeyId' &&
|
|
156
|
+
prop.key.name !== 'secretAccessKey'
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// Add the new credentials object to s3Options
|
|
160
|
+
s3Options.value.properties.push(
|
|
161
|
+
j.property('init', j.identifier('credentials'), credentials)
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
return root.toSource();
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export default transform;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import type { modules } from '../../../dist';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This codemod runs on the package.json of the Strapi project and updates
|
|
7
|
+
* the sqlite dependency to better-sqlite3
|
|
8
|
+
*/
|
|
9
|
+
const transform: modules.runner.json.JSONTransform = (file, params) => {
|
|
10
|
+
const { cwd, json } = params;
|
|
11
|
+
|
|
12
|
+
const rootPackageJsonPath = path.join(cwd, 'package.json');
|
|
13
|
+
|
|
14
|
+
if (file.path !== rootPackageJsonPath) {
|
|
15
|
+
return file.json;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const j = json(file.json);
|
|
19
|
+
|
|
20
|
+
const targetProperties = ['sqlite3', '@vscode/sqlite3'];
|
|
21
|
+
|
|
22
|
+
targetProperties.forEach((targetProperty) => {
|
|
23
|
+
const oldSqliteDependency = `dependencies.${targetProperty}`;
|
|
24
|
+
if (j.has(oldSqliteDependency)) {
|
|
25
|
+
j.remove(oldSqliteDependency);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (!j.has('dependencies.better-sqlite3')) {
|
|
30
|
+
// TODO check this version when releasing V5
|
|
31
|
+
j.set('dependencies.better-sqlite3', '9.0.0');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return j.root();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default transform;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Transform } from 'jscodeshift';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Note: This codemod is only for development purposes and should be deleted before releasing
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const transform: Transform = (file, api) => {
|
|
8
|
+
// Extract the jscodeshift API
|
|
9
|
+
const { j } = api;
|
|
10
|
+
// Parse the file content
|
|
11
|
+
const root = j(file.source);
|
|
12
|
+
|
|
13
|
+
root
|
|
14
|
+
// Find console.log calls expressions
|
|
15
|
+
.find(j.CallExpression, {
|
|
16
|
+
callee: { object: { name: 'console' }, property: { name: 'log' } },
|
|
17
|
+
})
|
|
18
|
+
// For each call expression
|
|
19
|
+
.forEach((path) => {
|
|
20
|
+
const { callee } = path.node;
|
|
21
|
+
|
|
22
|
+
if (
|
|
23
|
+
// Make sure the callee is a member expression (object/property)
|
|
24
|
+
j.MemberExpression.check(callee) &&
|
|
25
|
+
// Make sure the property is an actual identifier (contains a name property)
|
|
26
|
+
j.Identifier.check(callee.property)
|
|
27
|
+
) {
|
|
28
|
+
// Update the property's identifier name
|
|
29
|
+
callee.property.name = 'info';
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Return the updated file content
|
|
34
|
+
return root.toSource();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default transform;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import type { modules } from '../../dist';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Note: This transform file is only for development purposes and should be deleted before releasing
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const transform: modules.runner.json.JSONTransform = (file, params) => {
|
|
10
|
+
const { cwd, json } = params;
|
|
11
|
+
|
|
12
|
+
// Ignore files that are not the root package.json
|
|
13
|
+
// Note: We could also find every file named package.json and update the dependencies for all of them
|
|
14
|
+
const rootPackageJsonPath = path.join(cwd, 'package.json');
|
|
15
|
+
if (file.path !== rootPackageJsonPath) {
|
|
16
|
+
return file.json;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const j = json(file.json);
|
|
20
|
+
const strapiDepAddress = 'dependencies.@strapi/strapi';
|
|
21
|
+
|
|
22
|
+
if (j.has(strapiDepAddress)) {
|
|
23
|
+
j.set(strapiDepAddress, '5.0.0');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return j.root();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default transform;
|