@strapi/upgrade 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3
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 +19 -4
- package/dist/cli.js +64 -34
- package/dist/cli.js.map +1 -1
- package/dist/index.js +70 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -38
- package/dist/index.mjs.map +1 -1
- package/dist/modules/format/formats.d.ts +2 -1
- package/dist/modules/format/formats.d.ts.map +1 -1
- package/dist/modules/project/constants.d.ts +6 -5
- package/dist/modules/project/constants.d.ts.map +1 -1
- package/dist/modules/project/project.d.ts +16 -2
- package/dist/modules/project/project.d.ts.map +1 -1
- package/dist/modules/project/types.d.ts +3 -0
- package/dist/modules/project/types.d.ts.map +1 -1
- package/dist/modules/runner/json/transform.d.ts.map +1 -1
- package/dist/tasks/upgrade/upgrade.d.ts.map +1 -1
- package/package.json +5 -5
- package/resources/codemods/5.0.0/change-useAPIErrorHandler-import.code.ts +21 -0
- package/resources/codemods/5.0.0/comment-out-lifecycle-files.code.ts +63 -0
- package/resources/codemods/5.0.0/dependency-upgrade-react-and-react-dom.json.ts +67 -0
- package/resources/codemods/5.0.0/dependency-upgrade-styled-components.json.ts +49 -0
- package/resources/codemods/5.0.0/nocontent-migrate-to-emptystatelayout.code.ts +30 -0
- package/resources/codemods/5.0.0/useRBAC-hook-import-change.code.ts +21 -0
- package/resources/utils/change-import.ts +105 -0
- package/resources/utils/replace-jsx.ts +49 -0
package/LICENSE
CHANGED
|
@@ -2,9 +2,23 @@ Copyright (c) 2015-present Strapi Solutions SAS
|
|
|
2
2
|
|
|
3
3
|
Portions of the Strapi software are licensed as follows:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Enterprise License
|
|
8
|
+
|
|
9
|
+
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
|
|
10
|
+
https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
|
|
11
|
+
represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
|
|
12
|
+
agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
|
|
13
|
+
Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
|
|
14
|
+
|
|
15
|
+
BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
|
|
16
|
+
IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
|
|
17
|
+
HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
|
|
18
|
+
THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
|
|
19
|
+
IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
|
|
20
|
+
|
|
21
|
+
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
22
|
|
|
9
23
|
MIT Expat License
|
|
10
24
|
|
|
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
|
|
|
18
32
|
The above copyright notice and this permission notice shall be included in all
|
|
19
33
|
copies or substantial portions of the Software.
|
|
20
34
|
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
36
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
37
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/cli.js
CHANGED
|
@@ -380,7 +380,11 @@ const transformJSON = async (codemodPath, paths, config) => {
|
|
|
380
380
|
timeElapsed: "",
|
|
381
381
|
stats: {}
|
|
382
382
|
};
|
|
383
|
-
const esbuildOptions = {
|
|
383
|
+
const esbuildOptions = {
|
|
384
|
+
extensions: [".js", ".mjs", ".ts"],
|
|
385
|
+
hookIgnoreNodeModules: false,
|
|
386
|
+
hookMatcher: fp.isEqual(codemodPath)
|
|
387
|
+
};
|
|
384
388
|
const { unregister } = node.register(esbuildOptions);
|
|
385
389
|
const module = require(codemodPath);
|
|
386
390
|
unregister();
|
|
@@ -421,8 +425,10 @@ const jsonRunnerFactory = (paths, configuration) => {
|
|
|
421
425
|
return new JSONRunner(paths, configuration);
|
|
422
426
|
};
|
|
423
427
|
const PROJECT_PACKAGE_JSON = "package.json";
|
|
424
|
-
const
|
|
425
|
-
const
|
|
428
|
+
const PROJECT_APP_ALLOWED_ROOT_PATHS = ["src", "config", "public"];
|
|
429
|
+
const PROJECT_PLUGIN_ALLOWED_ROOT_PATHS = ["admin", "server"];
|
|
430
|
+
const PROJECT_PLUGIN_ROOT_FILES = ["strapi-admin.js", "strapi-server.js"];
|
|
431
|
+
const PROJECT_CODE_EXTENSIONS = [
|
|
426
432
|
// Source files
|
|
427
433
|
"js",
|
|
428
434
|
"mjs",
|
|
@@ -431,12 +437,8 @@ const PROJECT_DEFAULT_CODE_EXTENSIONS = [
|
|
|
431
437
|
"jsx",
|
|
432
438
|
"tsx"
|
|
433
439
|
];
|
|
434
|
-
const
|
|
435
|
-
const
|
|
436
|
-
...PROJECT_DEFAULT_CODE_EXTENSIONS,
|
|
437
|
-
...PROJECT_DEFAULT_JSON_EXTENSIONS
|
|
438
|
-
];
|
|
439
|
-
const PROJECT_DEFAULT_PATTERNS = ["package.json"];
|
|
440
|
+
const PROJECT_JSON_EXTENSIONS = ["json"];
|
|
441
|
+
const PROJECT_ALLOWED_EXTENSIONS = [...PROJECT_CODE_EXTENSIONS, ...PROJECT_JSON_EXTENSIONS];
|
|
440
442
|
const SCOPED_STRAPI_PACKAGE_PREFIX = "@strapi/";
|
|
441
443
|
const STRAPI_DEPENDENCY_NAME = `${SCOPED_STRAPI_PACKAGE_PREFIX}strapi`;
|
|
442
444
|
class Project {
|
|
@@ -445,11 +447,13 @@ class Project {
|
|
|
445
447
|
files;
|
|
446
448
|
packageJSONPath;
|
|
447
449
|
packageJSON;
|
|
448
|
-
|
|
450
|
+
paths;
|
|
451
|
+
constructor(cwd, config) {
|
|
449
452
|
if (!fse__default.default.pathExistsSync(cwd)) {
|
|
450
453
|
throw new Error(`ENOENT: no such file or directory, access '${cwd}'`);
|
|
451
454
|
}
|
|
452
455
|
this.cwd = cwd;
|
|
456
|
+
this.paths = config.paths;
|
|
453
457
|
this.refresh();
|
|
454
458
|
}
|
|
455
459
|
getFilesByExtensions(extensions) {
|
|
@@ -477,12 +481,8 @@ class Project {
|
|
|
477
481
|
return reports2;
|
|
478
482
|
}
|
|
479
483
|
createProjectCodemodsRunners(dry = false) {
|
|
480
|
-
const jsonExtensions =
|
|
481
|
-
|
|
482
|
-
);
|
|
483
|
-
const codeExtensions = PROJECT_DEFAULT_CODE_EXTENSIONS.map(
|
|
484
|
-
(ext) => `.${ext}`
|
|
485
|
-
);
|
|
484
|
+
const jsonExtensions = PROJECT_JSON_EXTENSIONS.map((ext) => `.${ext}`);
|
|
485
|
+
const codeExtensions = PROJECT_CODE_EXTENSIONS.map((ext) => `.${ext}`);
|
|
486
486
|
const jsonFiles = this.getFilesByExtensions(jsonExtensions);
|
|
487
487
|
const codeFiles = this.getFilesByExtensions(codeExtensions);
|
|
488
488
|
const codeRunner = codeRunnerFactory(codeFiles, {
|
|
@@ -490,7 +490,7 @@ class Project {
|
|
|
490
490
|
parser: "ts",
|
|
491
491
|
runInBand: true,
|
|
492
492
|
babel: true,
|
|
493
|
-
extensions:
|
|
493
|
+
extensions: PROJECT_CODE_EXTENSIONS.join(","),
|
|
494
494
|
// Don't output any log coming from the runner
|
|
495
495
|
print: false,
|
|
496
496
|
silent: true,
|
|
@@ -511,23 +511,30 @@ class Project {
|
|
|
511
511
|
this.packageJSON = JSON.parse(packageJSONBuffer.toString());
|
|
512
512
|
}
|
|
513
513
|
refreshProjectFiles() {
|
|
514
|
-
const allowedRootPaths = formatGlobCollectionPattern(
|
|
515
|
-
PROJECT_DEFAULT_ALLOWED_ROOT_PATHS
|
|
516
|
-
);
|
|
517
|
-
const allowedExtensions = formatGlobCollectionPattern(
|
|
518
|
-
PROJECT_DEFAULT_ALLOWED_EXTENSIONS
|
|
519
|
-
);
|
|
520
|
-
const projectFilesPattern = `./${allowedRootPaths}/**/*.${allowedExtensions}`;
|
|
521
|
-
const patterns = [projectFilesPattern, ...PROJECT_DEFAULT_PATTERNS];
|
|
522
514
|
const scanner = fileScannerFactory(this.cwd);
|
|
523
|
-
this.files = scanner.scan(
|
|
515
|
+
this.files = scanner.scan(this.paths);
|
|
524
516
|
}
|
|
525
517
|
}
|
|
526
518
|
class AppProject extends Project {
|
|
527
519
|
strapiVersion;
|
|
528
520
|
type = "application";
|
|
521
|
+
/**
|
|
522
|
+
* Returns an array of allowed file paths for a Strapi application
|
|
523
|
+
*
|
|
524
|
+
* The resulting paths include app default files and the root package.json file.
|
|
525
|
+
*/
|
|
526
|
+
static get paths() {
|
|
527
|
+
const allowedRootPaths = formatGlobCollectionPattern(PROJECT_APP_ALLOWED_ROOT_PATHS);
|
|
528
|
+
const allowedExtensions = formatGlobCollectionPattern(PROJECT_ALLOWED_EXTENSIONS);
|
|
529
|
+
return [
|
|
530
|
+
// App default files
|
|
531
|
+
`./${allowedRootPaths}/**/*.${allowedExtensions}`,
|
|
532
|
+
// Root package.json file
|
|
533
|
+
PROJECT_PACKAGE_JSON
|
|
534
|
+
];
|
|
535
|
+
}
|
|
529
536
|
constructor(cwd) {
|
|
530
|
-
super(cwd);
|
|
537
|
+
super(cwd, { paths: AppProject.paths });
|
|
531
538
|
this.refreshStrapiVersion();
|
|
532
539
|
}
|
|
533
540
|
refresh() {
|
|
@@ -582,6 +589,28 @@ const formatGlobCollectionPattern = (collection) => {
|
|
|
582
589
|
};
|
|
583
590
|
class PluginProject extends Project {
|
|
584
591
|
type = "plugin";
|
|
592
|
+
/**
|
|
593
|
+
* Returns an array of allowed file paths for a Strapi plugin
|
|
594
|
+
*
|
|
595
|
+
* The resulting paths include plugin default files, the root package.json file, and plugin-specific files.
|
|
596
|
+
*/
|
|
597
|
+
static get paths() {
|
|
598
|
+
const allowedRootPaths = formatGlobCollectionPattern(
|
|
599
|
+
PROJECT_PLUGIN_ALLOWED_ROOT_PATHS
|
|
600
|
+
);
|
|
601
|
+
const allowedExtensions = formatGlobCollectionPattern(PROJECT_ALLOWED_EXTENSIONS);
|
|
602
|
+
return [
|
|
603
|
+
// Plugin default files
|
|
604
|
+
`./${allowedRootPaths}/**/*.${allowedExtensions}`,
|
|
605
|
+
// Root package.json file
|
|
606
|
+
PROJECT_PACKAGE_JSON,
|
|
607
|
+
// Plugin root files
|
|
608
|
+
...PROJECT_PLUGIN_ROOT_FILES
|
|
609
|
+
];
|
|
610
|
+
}
|
|
611
|
+
constructor(cwd) {
|
|
612
|
+
super(cwd, { paths: PluginProject.paths });
|
|
613
|
+
}
|
|
585
614
|
}
|
|
586
615
|
const isPlugin = (cwd) => {
|
|
587
616
|
const packageJSONPath = path__default.default.join(cwd, PROJECT_PACKAGE_JSON);
|
|
@@ -596,10 +625,7 @@ const isPlugin = (cwd) => {
|
|
|
596
625
|
};
|
|
597
626
|
const projectFactory = (cwd) => {
|
|
598
627
|
fse__default.default.accessSync(cwd);
|
|
599
|
-
|
|
600
|
-
return new PluginProject(cwd);
|
|
601
|
-
}
|
|
602
|
-
return new AppProject(cwd);
|
|
628
|
+
return isPlugin(cwd) ? new PluginProject(cwd) : new AppProject(cwd);
|
|
603
629
|
};
|
|
604
630
|
const isApplicationProject = (project) => {
|
|
605
631
|
return project instanceof AppProject;
|
|
@@ -625,6 +651,9 @@ const version$1 = (version2) => {
|
|
|
625
651
|
const codemodUID = (uid) => {
|
|
626
652
|
return chalk__default.default.bold.cyan(uid);
|
|
627
653
|
};
|
|
654
|
+
const projectDetails = (project) => {
|
|
655
|
+
return `Project: TYPE=${projectType(project.type)}; CWD=${path(project.cwd)}; PATHS=${project.paths.map(path)}`;
|
|
656
|
+
};
|
|
628
657
|
const projectType = (type) => chalk__default.default.cyan(type);
|
|
629
658
|
const versionRange = (range) => chalk__default.default.italic.yellow(range.raw);
|
|
630
659
|
const highlight = (arg) => chalk__default.default.bold.underline(arg);
|
|
@@ -1180,6 +1209,7 @@ const upgrade$1 = async (options) => {
|
|
|
1180
1209
|
const { logger, codemodsTarget } = options;
|
|
1181
1210
|
const cwd = path__default.default.resolve(options.cwd ?? process.cwd());
|
|
1182
1211
|
const project = projectFactory(cwd);
|
|
1212
|
+
logger.debug(projectDetails(project));
|
|
1183
1213
|
if (!isApplicationProject(project)) {
|
|
1184
1214
|
throw new Error(
|
|
1185
1215
|
`The "${options.target}" upgrade can only be run on a Strapi project; for plugins, please use "codemods".`
|
|
@@ -1234,7 +1264,7 @@ const runCodemods$1 = async (options) => {
|
|
|
1234
1264
|
const cwd = resolvePath(options.cwd);
|
|
1235
1265
|
const project = projectFactory(cwd);
|
|
1236
1266
|
const range = findRangeFromTarget(project, options.target);
|
|
1237
|
-
logger.debug(
|
|
1267
|
+
logger.debug(projectDetails(project));
|
|
1238
1268
|
logger.debug(`Range: set to ${versionRange(range)}`);
|
|
1239
1269
|
const codemodRunner = codemodRunnerFactory(project, range).dry(options.dry ?? false).onSelectCodemods(options.selectCodemods ?? null).setLogger(logger);
|
|
1240
1270
|
let report;
|
|
@@ -1255,7 +1285,7 @@ const listCodemods$1 = async (options) => {
|
|
|
1255
1285
|
const cwd = resolvePath(options.cwd);
|
|
1256
1286
|
const project = projectFactory(cwd);
|
|
1257
1287
|
const range = findRangeFromTarget(project, target);
|
|
1258
|
-
logger.debug(
|
|
1288
|
+
logger.debug(projectDetails(project));
|
|
1259
1289
|
logger.debug(`Range: set to ${versionRange(range)}`);
|
|
1260
1290
|
const repo = codemodRepositoryFactory();
|
|
1261
1291
|
repo.refresh();
|
|
@@ -1440,7 +1470,7 @@ When executed on a Strapi plugin project, it shows every codemods.
|
|
|
1440
1470
|
return listCodemods(options);
|
|
1441
1471
|
});
|
|
1442
1472
|
};
|
|
1443
|
-
const version = "0.0.0-experimental.
|
|
1473
|
+
const version = "0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3";
|
|
1444
1474
|
register$1(commander.program);
|
|
1445
1475
|
register(commander.program);
|
|
1446
1476
|
commander.program.usage("<command> [options]").on("command:*", ([invalidCmd]) => {
|