@strapi/upgrade 5.0.0-rc.1 → 5.0.0-rc.10

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 CHANGED
@@ -1444,7 +1444,7 @@ When executed on a Strapi plugin project, it shows every codemods.
1444
1444
  return listCodemods(options);
1445
1445
  });
1446
1446
  };
1447
- const version = "5.0.0-rc.1";
1447
+ const version = "5.0.0-rc.10";
1448
1448
  register$1(commander.program);
1449
1449
  register(commander.program);
1450
1450
  commander.program.usage("<command> [options]").on("command:*", ([invalidCmd]) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/upgrade",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.10",
4
4
  "description": "CLI to upgrade Strapi applications effortless",
5
5
  "keywords": [
6
6
  "strapi",
@@ -59,7 +59,7 @@
59
59
  "watch": "pack-up watch"
60
60
  },
61
61
  "dependencies": {
62
- "@strapi/utils": "5.0.0-rc.1",
62
+ "@strapi/utils": "5.0.0-rc.10",
63
63
  "chalk": "4.1.2",
64
64
  "cli-table3": "0.6.2",
65
65
  "commander": "8.3.0",
@@ -76,15 +76,15 @@
76
76
  },
77
77
  "devDependencies": {
78
78
  "@strapi/pack-up": "5.0.0",
79
- "@strapi/types": "5.0.0-rc.1",
79
+ "@strapi/types": "5.0.0-rc.10",
80
80
  "@types/fs-extra": "11.0.4",
81
81
  "@types/jscodeshift": "0.11.10",
82
- "eslint-config-custom": "5.0.0-rc.1",
82
+ "eslint-config-custom": "5.0.0-rc.10",
83
83
  "rimraf": "5.0.5"
84
84
  },
85
85
  "engines": {
86
86
  "node": ">=18.0.0 <=20.x.x",
87
87
  "npm": ">=6.0.0"
88
88
  },
89
- "gitHead": "603c6d2b0ff8a7f655eae18706a2214eb17be2d7"
89
+ "gitHead": "4f54945deb1266d47424b46aa1462f66e4e32e58"
90
90
  }
@@ -0,0 +1,67 @@
1
+ import path from 'node:path';
2
+ import semver from 'semver';
3
+
4
+ import type { modules } from '../../../dist';
5
+
6
+ const REACT_DEP_NAME = 'react';
7
+ const REACT_DEP_PATH = `dependencies.${REACT_DEP_NAME}`;
8
+
9
+ const REACT_DOM_DEP_NAME = 'react-dom';
10
+ const REACT_DOM_DEP_PATH = `dependencies.${REACT_DOM_DEP_NAME}`;
11
+
12
+ const DEP_NEW_VERSION_RANGE = '^18.0.0';
13
+
14
+ /**
15
+ * Specifically targets the root package.json and updates the react and react-dom dependency version.
16
+ *
17
+ * We first check if the react and react-dom dependency is listed in the package.json. If the dependency is
18
+ * found, we verify its version.
19
+ *
20
+ * If the detected version does not satisfy the new version range, we replace it with the new one.
21
+ *
22
+ * Conversely, if no react or react-dom dependency is listed, we add it with the new version range.
23
+ */
24
+ const transform: modules.runner.json.JSONTransform = (file, params) => {
25
+ const { cwd, json } = params;
26
+
27
+ const rootPackageJsonPath = path.join(cwd, 'package.json');
28
+
29
+ if (file.path !== rootPackageJsonPath) {
30
+ return file.json;
31
+ }
32
+
33
+ const j = json(file.json);
34
+
35
+ if (j.has(REACT_DEP_PATH) && j.has(REACT_DOM_DEP_PATH)) {
36
+ const currentReactVersion = j.get(REACT_DEP_PATH);
37
+ const currentReactDOMVersion = j.get(REACT_DOM_DEP_PATH);
38
+
39
+ // If the current version is not a string, then something is wrong, abort
40
+ if (typeof currentReactVersion !== 'string' || typeof currentReactDOMVersion !== 'string') {
41
+ return j.root();
42
+ }
43
+
44
+ const currentSatisfiesNew =
45
+ semver.satisfies(currentReactVersion, DEP_NEW_VERSION_RANGE) &&
46
+ semver.satisfies(currentReactDOMVersion, DEP_NEW_VERSION_RANGE);
47
+
48
+ // if the current version satisfies the new range, keep it as is and abort
49
+ if (currentSatisfiesNew) {
50
+ return j.root();
51
+ }
52
+
53
+ // else, update the version with the new one
54
+ j.set(REACT_DEP_PATH, DEP_NEW_VERSION_RANGE);
55
+ j.set(REACT_DOM_DEP_PATH, DEP_NEW_VERSION_RANGE);
56
+ }
57
+
58
+ // If the dependency is not listed yet, add it
59
+ else {
60
+ j.set(REACT_DEP_PATH, DEP_NEW_VERSION_RANGE);
61
+ j.set(REACT_DOM_DEP_PATH, DEP_NEW_VERSION_RANGE);
62
+ }
63
+
64
+ return j.root();
65
+ };
66
+
67
+ export default transform;
@@ -0,0 +1,49 @@
1
+ import path from 'node:path';
2
+ import semver from 'semver';
3
+
4
+ import type { modules } from '../../../dist';
5
+
6
+ const DEP_NAME = 'styled-components';
7
+ const DEP_PATH = `dependencies.${DEP_NAME}`;
8
+
9
+ const DEP_NEW_VERSION_RANGE = '^6.0.0';
10
+
11
+ const transform: modules.runner.json.JSONTransform = (file, params) => {
12
+ const { cwd, json } = params;
13
+
14
+ const rootPackageJsonPath = path.join(cwd, 'package.json');
15
+
16
+ if (file.path !== rootPackageJsonPath) {
17
+ return file.json;
18
+ }
19
+
20
+ const j = json(file.json);
21
+
22
+ if (j.has(DEP_PATH)) {
23
+ const currentVersion = j.get(DEP_PATH);
24
+
25
+ // If the current version is not a string, then something is wrong, abort
26
+ if (typeof currentVersion !== 'string') {
27
+ return j.root();
28
+ }
29
+
30
+ const currentSatisfiesNew = semver.satisfies(currentVersion, DEP_NEW_VERSION_RANGE);
31
+
32
+ // if the current version satisfies the new range, keep it as is and abort
33
+ if (currentSatisfiesNew) {
34
+ return j.root();
35
+ }
36
+
37
+ // else, update the version with the new one
38
+ j.set(DEP_PATH, DEP_NEW_VERSION_RANGE);
39
+ }
40
+
41
+ // If the dependency is not listed yet, add it
42
+ else {
43
+ j.set(DEP_PATH, DEP_NEW_VERSION_RANGE);
44
+ }
45
+
46
+ return j.root();
47
+ };
48
+
49
+ export default transform;