@strapi/upgrade 0.0.0-experimental.fc1ac2acd58c8a5a858679956b6d102ac5ee4011 → 0.0.0-next.ce84fada19d58a7dfbdd553035e6558f8befcba4

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.
Files changed (83) hide show
  1. package/LICENSE +19 -4
  2. package/dist/cli.js +1489 -5
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.js +375 -107
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +375 -108
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/modules/codemod/codemod.d.ts +4 -2
  9. package/dist/modules/codemod/codemod.d.ts.map +1 -1
  10. package/dist/modules/codemod/types.d.ts +8 -1
  11. package/dist/modules/codemod/types.d.ts.map +1 -1
  12. package/dist/modules/codemod-repository/constants.d.ts.map +1 -1
  13. package/dist/modules/codemod-repository/repository.d.ts +6 -5
  14. package/dist/modules/codemod-repository/repository.d.ts.map +1 -1
  15. package/dist/modules/codemod-repository/types.d.ts +7 -3
  16. package/dist/modules/codemod-repository/types.d.ts.map +1 -1
  17. package/dist/modules/codemod-runner/codemod-runner.d.ts +3 -0
  18. package/dist/modules/codemod-runner/codemod-runner.d.ts.map +1 -1
  19. package/dist/modules/codemod-runner/index.d.ts +1 -0
  20. package/dist/modules/codemod-runner/index.d.ts.map +1 -1
  21. package/dist/modules/codemod-runner/types.d.ts +1 -0
  22. package/dist/modules/codemod-runner/types.d.ts.map +1 -1
  23. package/dist/modules/file-scanner/scanner.d.ts.map +1 -1
  24. package/dist/modules/format/formats.d.ts +6 -0
  25. package/dist/modules/format/formats.d.ts.map +1 -1
  26. package/dist/modules/project/constants.d.ts +6 -3
  27. package/dist/modules/project/constants.d.ts.map +1 -1
  28. package/dist/modules/project/index.d.ts +2 -0
  29. package/dist/modules/project/index.d.ts.map +1 -1
  30. package/dist/modules/project/project.d.ts +27 -5
  31. package/dist/modules/project/project.d.ts.map +1 -1
  32. package/dist/modules/project/types.d.ts +3 -10
  33. package/dist/modules/project/types.d.ts.map +1 -1
  34. package/dist/modules/project/utils.d.ts +6 -0
  35. package/dist/modules/project/utils.d.ts.map +1 -0
  36. package/dist/modules/report/report.d.ts.map +1 -1
  37. package/dist/modules/requirement/types.d.ts +2 -2
  38. package/dist/modules/requirement/types.d.ts.map +1 -1
  39. package/dist/modules/runner/json/transform.d.ts.map +1 -1
  40. package/dist/modules/upgrader/upgrader.d.ts +3 -3
  41. package/dist/modules/upgrader/upgrader.d.ts.map +1 -1
  42. package/dist/modules/version/range.d.ts +2 -0
  43. package/dist/modules/version/range.d.ts.map +1 -1
  44. package/dist/tasks/codemods/index.d.ts +2 -1
  45. package/dist/tasks/codemods/index.d.ts.map +1 -1
  46. package/dist/tasks/codemods/list-codemods.d.ts +3 -0
  47. package/dist/tasks/codemods/list-codemods.d.ts.map +1 -0
  48. package/dist/tasks/codemods/run-codemods.d.ts +3 -0
  49. package/dist/tasks/codemods/run-codemods.d.ts.map +1 -0
  50. package/dist/tasks/codemods/types.d.ts +9 -3
  51. package/dist/tasks/codemods/types.d.ts.map +1 -1
  52. package/dist/tasks/codemods/utils.d.ts +6 -0
  53. package/dist/tasks/codemods/utils.d.ts.map +1 -0
  54. package/dist/tasks/index.d.ts +1 -1
  55. package/dist/tasks/index.d.ts.map +1 -1
  56. package/dist/tasks/upgrade/upgrade.d.ts.map +1 -1
  57. package/package.json +10 -9
  58. package/resources/codemods/5.0.0/comment-out-lifecycle-files.code.ts +63 -0
  59. package/resources/codemods/5.0.0/dependency-remove-strapi-plugin-i18n.json.ts +31 -0
  60. package/resources/codemods/5.0.0/dependency-upgrade-react-and-react-dom.json.ts +67 -0
  61. package/resources/codemods/5.0.0/dependency-upgrade-react-router-dom.json.ts +59 -0
  62. package/resources/codemods/5.0.0/dependency-upgrade-styled-components.json.ts +49 -0
  63. package/resources/codemods/5.0.0/deprecate-helper-plugin.code.ts +186 -0
  64. package/resources/codemods/5.0.0/entity-service-document-service.code.ts +437 -0
  65. package/resources/codemods/5.0.0/s3-keys-wrapped-in-credentials.code.ts +1 -1
  66. package/resources/codemods/5.0.0/sqlite3-to-better-sqlite3.json.ts +5 -2
  67. package/resources/codemods/5.0.0/strapi-public-interface.code.ts +126 -0
  68. package/resources/codemods/5.0.0/use-uid-for-config-namespace.code.ts +1 -1
  69. package/resources/codemods/5.0.0/utils-public-interface.code.ts +320 -0
  70. package/resources/examples/console.log-to-console.info.code.ts +1 -1
  71. package/resources/examples/disable-jsx-buttons.code.ts +42 -0
  72. package/resources/utils/change-import.ts +118 -0
  73. package/resources/utils/replace-jsx.ts +49 -0
  74. package/dist/_chunks/codemod-runner-oPpELfwO.js +0 -730
  75. package/dist/_chunks/codemod-runner-oPpELfwO.js.map +0 -1
  76. package/dist/_chunks/codemods-qc8_QMWD.js +0 -108
  77. package/dist/_chunks/codemods-qc8_QMWD.js.map +0 -1
  78. package/dist/_chunks/index-GHKaxdhJ.js +0 -103
  79. package/dist/_chunks/index-GHKaxdhJ.js.map +0 -1
  80. package/dist/_chunks/upgrade-4SxXG3Oe.js +0 -357
  81. package/dist/_chunks/upgrade-4SxXG3Oe.js.map +0 -1
  82. package/dist/tasks/codemods/codemods.d.ts +0 -3
  83. package/dist/tasks/codemods/codemods.d.ts.map +0 -1
@@ -0,0 +1,59 @@
1
+ import path from 'node:path';
2
+ import semver from 'semver';
3
+
4
+ import type { modules } from '../../../dist';
5
+
6
+ const REACT_ROUTER_DEP_NAME = 'react-router-dom';
7
+ const REACT_ROUTER_DEP_PATH = `dependencies.${REACT_ROUTER_DEP_NAME}`;
8
+
9
+ const DEP_NEW_VERSION_RANGE = '^6.0.0';
10
+
11
+ /**
12
+ * Specifically targets the root package.json and updates the react-router-dom dependency version.
13
+ *
14
+ * We first check if the react-router-dom dependency is listed in the package.json. If the dependency is
15
+ * found, we verify its version.
16
+ *
17
+ * If the detected version does not satisfy the new version range, we replace it with the new one.
18
+ *
19
+ * Conversely, if no react-router-dom dependency is listed, we add it with the new version range.
20
+ */
21
+ const transform: modules.runner.json.JSONTransform = (file, params) => {
22
+ const { cwd, json } = params;
23
+
24
+ const rootPackageJsonPath = path.join(cwd, 'package.json');
25
+
26
+ if (file.path !== rootPackageJsonPath) {
27
+ return file.json;
28
+ }
29
+
30
+ const j = json(file.json);
31
+
32
+ if (j.has(REACT_ROUTER_DEP_PATH)) {
33
+ const currentVersion = j.get(REACT_ROUTER_DEP_PATH);
34
+
35
+ // If the current version is not a string, then something is wrong, abort
36
+ if (typeof currentVersion !== 'string') {
37
+ return j.root();
38
+ }
39
+
40
+ const currentSatisfiesNew = semver.satisfies(currentVersion, DEP_NEW_VERSION_RANGE);
41
+
42
+ // if the current version satisfies the new range, keep it as is and abort
43
+ if (currentSatisfiesNew) {
44
+ return j.root();
45
+ }
46
+
47
+ // else, update the version with the new one
48
+ j.set(REACT_ROUTER_DEP_PATH, DEP_NEW_VERSION_RANGE);
49
+ }
50
+
51
+ // If the dependency is not listed yet, add it
52
+ else {
53
+ j.set(REACT_ROUTER_DEP_PATH, DEP_NEW_VERSION_RANGE);
54
+ }
55
+
56
+ return j.root();
57
+ };
58
+
59
+ 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;
@@ -0,0 +1,186 @@
1
+ import type { Transform } from 'jscodeshift';
2
+ import { changeImportSpecifier } from '../../utils/change-import';
3
+ import { replaceJSXElement } from '../../utils/replace-jsx';
4
+
5
+ /**
6
+ * This codemods automates all the imports and naming changes
7
+ * for methods or components that used to be imported from '@strapi/helper-plugin'
8
+ */
9
+ const transform: Transform = (file, api) => {
10
+ const { j } = api;
11
+
12
+ const root = j.withParser('tsx')(file.source);
13
+
14
+ type Replacement = {
15
+ oldName: string;
16
+ oldDependency: string;
17
+ toReplace: boolean;
18
+ toChangeImportSpecifier: boolean;
19
+ newDependency?: string;
20
+ newName?: string;
21
+ };
22
+
23
+ const replacements: Replacement[] = [
24
+ {
25
+ oldName: 'AnErrorOccurred',
26
+ newName: 'Page.Error',
27
+ oldDependency: '@strapi/helper-plugin',
28
+ newDependency: '@strapi/strapi/admin',
29
+ toReplace: true,
30
+ toChangeImportSpecifier: true,
31
+ },
32
+ {
33
+ oldName: 'CheckPagePermissions',
34
+ newName: 'Page.Protect',
35
+ oldDependency: '@strapi/helper-plugin',
36
+ newDependency: '@strapi/strapi/admin',
37
+ toReplace: true,
38
+ toChangeImportSpecifier: true,
39
+ },
40
+ {
41
+ oldName: 'ConfirmDialog',
42
+ oldDependency: '@strapi/helper-plugin',
43
+ newDependency: '@strapi/strapi/admin',
44
+ toChangeImportSpecifier: true,
45
+ toReplace: false,
46
+ },
47
+ {
48
+ oldName: 'DateTimePicker',
49
+ oldDependency: '@strapi/helper-plugin',
50
+ newDependency: '@strapi/design-system',
51
+ toChangeImportSpecifier: true,
52
+ toReplace: false,
53
+ },
54
+ {
55
+ oldName: 'getFetchClient',
56
+ oldDependency: '@strapi/helper-plugin',
57
+ newDependency: '@strapi/strapi/admin',
58
+ toChangeImportSpecifier: true,
59
+ toReplace: false,
60
+ },
61
+ {
62
+ oldName: 'LoadingIndicatorPage',
63
+ newName: 'Page.Loading',
64
+ oldDependency: '@strapi/helper-plugin',
65
+ newDependency: '@strapi/strapi/admin',
66
+ toReplace: true,
67
+ toChangeImportSpecifier: true,
68
+ },
69
+ {
70
+ oldName: 'NoContent',
71
+ newName: 'EmptyStateLayout',
72
+ oldDependency: '@strapi/helper-plugin',
73
+ newDependency: '@strapi/design-system',
74
+ toReplace: true,
75
+ toChangeImportSpecifier: true,
76
+ },
77
+ {
78
+ oldName: 'NoPermissions',
79
+ newName: 'Page.NoPermissions',
80
+ oldDependency: '@strapi/helper-plugin',
81
+ newDependency: '@strapi/strapi/admin',
82
+ toReplace: true,
83
+ toChangeImportSpecifier: true,
84
+ },
85
+ {
86
+ oldName: 'Status',
87
+ oldDependency: '@strapi/helper-plugin',
88
+ newDependency: '@strapi/design-system',
89
+ toChangeImportSpecifier: true,
90
+ toReplace: false,
91
+ },
92
+ {
93
+ oldName: 'translatedErrors',
94
+ oldDependency: '@strapi/helper-plugin',
95
+ newDependency: '@strapi/strapi/admin',
96
+ toChangeImportSpecifier: true,
97
+ toReplace: false,
98
+ },
99
+ {
100
+ oldName: 'useAPIErrorHandler',
101
+ oldDependency: '@strapi/helper-plugin',
102
+ newDependency: '@strapi/strapi/admin',
103
+ toChangeImportSpecifier: true,
104
+ toReplace: false,
105
+ },
106
+ {
107
+ oldName: 'useCallbackRef',
108
+ oldDependency: '@strapi/helper-plugin',
109
+ newDependency: '@strapi/design-system',
110
+ toChangeImportSpecifier: true,
111
+ toReplace: false,
112
+ },
113
+ {
114
+ oldName: 'useCollator',
115
+ oldDependency: '@strapi/helper-plugin',
116
+ newDependency: '@strapi/design-system',
117
+ toChangeImportSpecifier: true,
118
+ toReplace: false,
119
+ },
120
+ {
121
+ oldName: 'useFetchClient',
122
+ oldDependency: '@strapi/helper-plugin',
123
+ newDependency: '@strapi/strapi/admin',
124
+ toChangeImportSpecifier: true,
125
+ toReplace: false,
126
+ },
127
+ {
128
+ oldName: 'useFilter',
129
+ oldDependency: '@strapi/helper-plugin',
130
+ newDependency: '@strapi/design-system',
131
+ toChangeImportSpecifier: true,
132
+ toReplace: false,
133
+ },
134
+ {
135
+ oldName: 'useQueryParams',
136
+ oldDependency: '@strapi/helper-plugin',
137
+ newDependency: '@strapi/strapi/admin',
138
+ toChangeImportSpecifier: true,
139
+ toReplace: false,
140
+ },
141
+ {
142
+ oldName: 'useRBAC',
143
+ oldDependency: '@strapi/helper-plugin',
144
+ newDependency: '@strapi/strapi/admin',
145
+ toChangeImportSpecifier: true,
146
+ toReplace: false,
147
+ },
148
+ {
149
+ oldName: 'SearchURLQuery',
150
+ oldDependency: '@strapi/helper-plugin',
151
+ newDependency: '@strapi/strapi/admin',
152
+ toChangeImportSpecifier: true,
153
+ toReplace: false,
154
+ },
155
+ {
156
+ oldName: 'useSettingsForm',
157
+ oldDependency: '@strapi/helper-plugin',
158
+ newDependency: '@strapi/strapi/admin',
159
+ toChangeImportSpecifier: true,
160
+ toReplace: false,
161
+ },
162
+ ];
163
+
164
+ replacements.forEach((replacement) => {
165
+ if (replacement.toReplace && replacement.newName) {
166
+ replaceJSXElement(root, j, {
167
+ oldElementName: replacement.oldName,
168
+ newElementName: replacement.newName,
169
+ oldDependency: replacement.oldDependency,
170
+ });
171
+ }
172
+
173
+ if (replacement.toChangeImportSpecifier && replacement.newDependency) {
174
+ changeImportSpecifier(root, j, {
175
+ oldMethodName: replacement.oldName,
176
+ newMethodName: replacement.newName,
177
+ oldDependency: replacement.oldDependency,
178
+ newDependency: replacement.newDependency,
179
+ });
180
+ }
181
+ });
182
+
183
+ return root.toSource();
184
+ };
185
+
186
+ export default transform;