@modern-js/upgrade-generator 3.2.6 → 3.2.7
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/index.js +54028 -124447
- package/package.json +12 -10
- package/src/index.ts +35 -10
package/package.json
CHANGED
|
@@ -15,27 +15,29 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.2.
|
|
18
|
+
"version": "3.2.7",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"files": [
|
|
22
22
|
"/templates",
|
|
23
23
|
"/dist/index.js"
|
|
24
24
|
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@modern-js/utils": "2.38.0"
|
|
27
|
+
},
|
|
25
28
|
"devDependencies": {
|
|
26
|
-
"@modern-js/codesmith": "2.
|
|
27
|
-
"@modern-js/codesmith-api-app": "2.
|
|
28
|
-
"@modern-js/codesmith-api-json": "2.
|
|
29
|
+
"@modern-js/codesmith": "2.3.0",
|
|
30
|
+
"@modern-js/codesmith-api-app": "2.3.0",
|
|
31
|
+
"@modern-js/codesmith-api-json": "2.3.0",
|
|
29
32
|
"@types/jest": "^29",
|
|
30
33
|
"@types/node": "^14",
|
|
31
34
|
"jest": "^29",
|
|
32
35
|
"typescript": "^5",
|
|
33
|
-
"@modern-js/generator-common": "3.2.
|
|
34
|
-
"@modern-js/generator-utils": "3.2.
|
|
35
|
-
"@modern-js/plugin-i18n": "2.
|
|
36
|
-
"@
|
|
37
|
-
"@scripts/
|
|
38
|
-
"@scripts/jest-config": "2.37.2"
|
|
36
|
+
"@modern-js/generator-common": "3.2.7",
|
|
37
|
+
"@modern-js/generator-utils": "3.2.7",
|
|
38
|
+
"@modern-js/plugin-i18n": "2.38.0",
|
|
39
|
+
"@scripts/build": "2.38.0",
|
|
40
|
+
"@scripts/jest-config": "2.38.0"
|
|
39
41
|
},
|
|
40
42
|
"sideEffects": false,
|
|
41
43
|
"publishConfig": {
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
execa,
|
|
12
12
|
semver,
|
|
13
13
|
fs,
|
|
14
|
+
isPackageExist,
|
|
15
|
+
getPackageVersion,
|
|
14
16
|
} from '@modern-js/generator-utils';
|
|
15
17
|
import {
|
|
16
18
|
PackageManager,
|
|
@@ -20,6 +22,17 @@ import {
|
|
|
20
22
|
} from '@modern-js/generator-common';
|
|
21
23
|
import { i18n, localeKeys } from './locale';
|
|
22
24
|
|
|
25
|
+
// Special modern.js dependencies, the plugin version maybe not same with other modern.js plugin
|
|
26
|
+
const SpecialModernDeps = ['@modern-js/plugin-storybook'];
|
|
27
|
+
|
|
28
|
+
const handleSpecialModernDeps = async (dep: string, modernVersion: string) => {
|
|
29
|
+
const version = await getAvailableVersion(dep, modernVersion);
|
|
30
|
+
if (!(await isPackageExist(`${dep}@${version}`))) {
|
|
31
|
+
return getPackageVersion(dep);
|
|
32
|
+
}
|
|
33
|
+
return version;
|
|
34
|
+
};
|
|
35
|
+
|
|
23
36
|
export const handleTemplateFile = async (
|
|
24
37
|
context: GeneratorContext,
|
|
25
38
|
generator: GeneratorCore,
|
|
@@ -124,23 +137,35 @@ export const handleTemplateFile = async (
|
|
|
124
137
|
}).start();
|
|
125
138
|
|
|
126
139
|
await Promise.all(
|
|
127
|
-
modernDeps.map(
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
modernDeps.map(async dep => {
|
|
141
|
+
if (SpecialModernDeps.includes(dep)) {
|
|
142
|
+
updateInfo[`dependencies.${dep}`] = await handleSpecialModernDeps(
|
|
143
|
+
dep,
|
|
144
|
+
modernVersion,
|
|
145
|
+
);
|
|
146
|
+
} else {
|
|
147
|
+
updateInfo[`dependencies.${dep}`] = await getAvailableVersion(
|
|
130
148
|
dep,
|
|
131
149
|
modernVersion,
|
|
132
|
-
)
|
|
133
|
-
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
134
153
|
);
|
|
135
154
|
|
|
136
155
|
await Promise.all(
|
|
137
|
-
modernDevDeps.map(
|
|
138
|
-
|
|
139
|
-
|
|
156
|
+
modernDevDeps.map(async dep => {
|
|
157
|
+
if (SpecialModernDeps.includes(dep)) {
|
|
158
|
+
updateInfo[`devDependencies.${dep}`] = await handleSpecialModernDeps(
|
|
140
159
|
dep,
|
|
141
160
|
modernVersion,
|
|
142
|
-
)
|
|
143
|
-
|
|
161
|
+
);
|
|
162
|
+
} else {
|
|
163
|
+
updateInfo[`devDependencies.${dep}`] = await getAvailableVersion(
|
|
164
|
+
dep,
|
|
165
|
+
modernVersion,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
144
169
|
);
|
|
145
170
|
await jsonAPI.update(
|
|
146
171
|
context.materials.default.get(path.join(appDir, 'package.json')),
|