@rancher/create-extension 3.0.2 → 3.0.4
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/migrate/init +2 -1
- package/migrate/tasks/packageUpdates.js +58 -62
- package/migrate/utils/content.js +8 -0
- package/package.json +2 -2
- package/pkg/package.json +0 -22
- package/pkg/pkg.package.json +7 -21
package/migrate/init
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { setParams, printLog, printUsage } = require('./utils/content');
|
|
3
|
+
const { setParams, printLog, printUsage, printCompletion } = require('./utils/content');
|
|
4
4
|
const {
|
|
5
5
|
packageUpdates,
|
|
6
6
|
nvmUpdates,
|
|
@@ -32,4 +32,5 @@ const params = require('./params');
|
|
|
32
32
|
stylesUpdates(params);
|
|
33
33
|
|
|
34
34
|
printLog();
|
|
35
|
+
printCompletion();
|
|
35
36
|
})();
|
|
@@ -64,74 +64,66 @@ function packageUpdatesLibraries(file, oldContent) {
|
|
|
64
64
|
const replaceLibraries = [];
|
|
65
65
|
const types = ['dependencies', 'devDependencies', 'peerDependencies'];
|
|
66
66
|
|
|
67
|
-
// [Library name, new version or new library, new library version]
|
|
67
|
+
// [Where to apply, Library name, new version or new library, new library version]
|
|
68
68
|
const librariesUpdates = [
|
|
69
|
-
['@rancher/shell', '^3.0.0'],
|
|
70
|
-
['@rancher/components', '^0.3.0-alpha.1'],
|
|
71
|
-
['@nuxt/babel-preset-app', removePlaceholder],
|
|
72
|
-
['
|
|
73
|
-
['@typescript-eslint/
|
|
74
|
-
['@
|
|
75
|
-
['@vue/cli-
|
|
76
|
-
['@vue/cli-plugin-
|
|
77
|
-
['@vue/
|
|
78
|
-
['
|
|
79
|
-
['
|
|
80
|
-
['
|
|
81
|
-
['
|
|
82
|
-
['
|
|
83
|
-
['
|
|
84
|
-
['
|
|
85
|
-
['
|
|
86
|
-
['
|
|
87
|
-
['
|
|
88
|
-
['node-polyfill-webpack-plugin', '^3.0.0'],
|
|
89
|
-
['portal-vue', '~3.0.0'],
|
|
90
|
-
['require-extension-hooks-babel', '1.0.0'],
|
|
91
|
-
['require-extension-hooks-vue', '3.0.0'],
|
|
92
|
-
['require-extension-hooks', '0.3.3'],
|
|
93
|
-
['sass-loader', '~12.0.0'],
|
|
94
|
-
['typescript', '~4.5.5'],
|
|
95
|
-
['vue-router', '~4.0.3'],
|
|
96
|
-
['vue-virtual-scroll-list', 'vue3-virtual-scroll-list', '0.2.1'],
|
|
97
|
-
['vue', '~3.2.13'],
|
|
98
|
-
['vuex', '~4.0.0'],
|
|
99
|
-
['xterm', '5.2.1'],
|
|
69
|
+
[['root', 'dependencies'], '@rancher/shell', '^3.0.0'],
|
|
70
|
+
[['root', 'dependencies'], '@rancher/components', '^0.3.0-alpha.1'],
|
|
71
|
+
[['root', 'dependencies'], '@nuxt/babel-preset-app', removePlaceholder],
|
|
72
|
+
[['root', 'dependencies'], '@typescript-eslint/eslint-plugin', removePlaceholder],
|
|
73
|
+
[['root', 'dependencies'], '@typescript-eslint/parser', removePlaceholder],
|
|
74
|
+
[['pkg', 'devDependencies'], '@vue/cli-plugin-babel', '~5.0.0'],
|
|
75
|
+
[['pkg', 'devDependencies'], '@vue/cli-service', '~5.0.0'],
|
|
76
|
+
[['pkg', 'devDependencies'], '@vue/cli-plugin-typescript', '~5.0.0'],
|
|
77
|
+
[['root', 'dependencies'], '@vue/test-utils', removePlaceholder],
|
|
78
|
+
[['root', 'dependencies'], 'core-js', removePlaceholder],
|
|
79
|
+
[['root', 'dependencies'], 'cache-loader', removePlaceholder],
|
|
80
|
+
[['root', 'dependencies'], 'node-polyfill-webpack-plugin', removePlaceholder],
|
|
81
|
+
[['root', 'dependencies'], 'portal-vue', removePlaceholder],
|
|
82
|
+
[['root', 'dependencies'], 'sass-loader', removePlaceholder],
|
|
83
|
+
[['root', 'dependencies'], 'typescript', removePlaceholder],
|
|
84
|
+
[['root', 'dependencies'], 'vue-router', removePlaceholder],
|
|
85
|
+
[['root', 'dependencies'], 'vue', removePlaceholder],
|
|
86
|
+
[['root', 'dependencies'], 'vuex', removePlaceholder],
|
|
87
|
+
[['root', 'dependencies'], 'xterm', removePlaceholder],
|
|
100
88
|
];
|
|
101
89
|
|
|
102
90
|
types.forEach((type) => {
|
|
103
91
|
if (parsedJson[type]) {
|
|
104
|
-
librariesUpdates.forEach(([library, newVersion, newLibraryVersion]) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
librariesUpdates.forEach(([[fileType, place], library, newVersion, newLibraryVersion]) => {
|
|
93
|
+
const currFileType = parsedJson.scripts && parsedJson.scripts.dev && parsedJson.scripts.build ? 'root' : 'pkg';
|
|
94
|
+
|
|
95
|
+
if (currFileType === fileType && type === place) {
|
|
96
|
+
if (parsedJson[type][library]) {
|
|
97
|
+
const version = semver.coerce(parsedJson[type][library]);
|
|
98
|
+
|
|
99
|
+
if (newVersion === removePlaceholder) {
|
|
100
|
+
// Remove library
|
|
101
|
+
replaceLibraries.push([library, [parsedJson[type][library], removePlaceholder]]);
|
|
102
|
+
delete parsedJson[type][library];
|
|
103
|
+
content = JSON.stringify(parsedJson, null, 2);
|
|
104
|
+
} else if (newLibraryVersion) {
|
|
105
|
+
// Replace with a new library
|
|
106
|
+
replaceLibraries.push([library, [parsedJson[type][library], newVersion, newLibraryVersion]]);
|
|
107
|
+
content = content.replace(
|
|
108
|
+
`"${ library }": "${ parsedJson[type][library] }"`,
|
|
109
|
+
`"${ newVersion }": "${ newLibraryVersion }"`
|
|
110
|
+
);
|
|
111
|
+
parsedJson = JSON.parse(content);
|
|
112
|
+
} else if (version && semver.lt(version, semver.coerce(newVersion))) {
|
|
113
|
+
// Update library version if outdated
|
|
114
|
+
replaceLibraries.push([library, [parsedJson[type][library], newVersion]]);
|
|
115
|
+
content = content.replace(
|
|
116
|
+
`"${ library }": "${ parsedJson[type][library] }"`,
|
|
117
|
+
`"${ library }": "${ newVersion }"`
|
|
118
|
+
);
|
|
119
|
+
parsedJson = JSON.parse(content);
|
|
120
|
+
}
|
|
121
|
+
} else if (newLibraryVersion && library === newVersion) {
|
|
122
|
+
// Add new library if it doesn't exist
|
|
123
|
+
parsedJson[type][library] = newLibraryVersion;
|
|
124
|
+
replaceLibraries.push([library, [null, newLibraryVersion]]);
|
|
112
125
|
content = JSON.stringify(parsedJson, null, 2);
|
|
113
|
-
} else if (newLibraryVersion) {
|
|
114
|
-
// Replace with a new library
|
|
115
|
-
replaceLibraries.push([library, [parsedJson[type][library], newVersion, newLibraryVersion]]);
|
|
116
|
-
content = content.replace(
|
|
117
|
-
`"${ library }": "${ parsedJson[type][library] }"`,
|
|
118
|
-
`"${ newVersion }": "${ newLibraryVersion }"`
|
|
119
|
-
);
|
|
120
|
-
parsedJson = JSON.parse(content);
|
|
121
|
-
} else if (version && semver.lt(version, semver.coerce(newVersion))) {
|
|
122
|
-
// Update library version if outdated
|
|
123
|
-
replaceLibraries.push([library, [parsedJson[type][library], newVersion]]);
|
|
124
|
-
content = content.replace(
|
|
125
|
-
`"${ library }": "${ parsedJson[type][library] }"`,
|
|
126
|
-
`"${ library }": "${ newVersion }"`
|
|
127
|
-
);
|
|
128
|
-
parsedJson = JSON.parse(content);
|
|
129
126
|
}
|
|
130
|
-
} else if (newLibraryVersion && library === newVersion) {
|
|
131
|
-
// Add new library if it doesn't exist
|
|
132
|
-
parsedJson[type][library] = newLibraryVersion;
|
|
133
|
-
replaceLibraries.push([library, [null, newLibraryVersion]]);
|
|
134
|
-
content = JSON.stringify(parsedJson, null, 2);
|
|
135
127
|
}
|
|
136
128
|
});
|
|
137
129
|
}
|
|
@@ -166,18 +158,22 @@ function packageUpdatesResolution(file, oldContent) {
|
|
|
166
158
|
let parsedJson = JSON.parse(content);
|
|
167
159
|
const replaceResolution = [];
|
|
168
160
|
const resolutions = [
|
|
169
|
-
['@vue/cli-service/html-webpack-plugin',
|
|
161
|
+
['@vue/cli-service/html-webpack-plugin', removePlaceholder],
|
|
170
162
|
['**/webpack', removePlaceholder],
|
|
163
|
+
['@types/node', '~20.10.0'],
|
|
164
|
+
['@types/lodash', '4.17.5'],
|
|
171
165
|
];
|
|
172
166
|
|
|
173
167
|
if (parsedJson.resolutions) {
|
|
174
168
|
resolutions.forEach(([library, newVersion]) => {
|
|
175
169
|
if (newVersion === removePlaceholder) {
|
|
170
|
+
replaceResolution.push([library, [parsedJson.resolutions[library], removePlaceholder]]);
|
|
176
171
|
delete parsedJson.resolutions[library];
|
|
177
172
|
content = JSON.stringify(parsedJson, null, 2);
|
|
178
173
|
parsedJson = JSON.parse(content);
|
|
179
174
|
} else if (!parsedJson.resolutions[library]) {
|
|
180
175
|
parsedJson.resolutions[library] = newVersion;
|
|
176
|
+
replaceResolution.push([library, [null, newVersion]]);
|
|
181
177
|
content = JSON.stringify(parsedJson, null, 2);
|
|
182
178
|
parsedJson = JSON.parse(content);
|
|
183
179
|
} else {
|
package/migrate/utils/content.js
CHANGED
|
@@ -106,6 +106,13 @@ function printLog() {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
function printCompletion() {
|
|
110
|
+
if (!isSuggest || !isDry) {
|
|
111
|
+
console.log('\nMigration completed.\n');
|
|
112
|
+
console.log(`You will need to reinstall the dependencies, run the following command:\n\n\tyarn install\n`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
109
116
|
function replaceCases(fileType, files, replacementCases, printText, params) {
|
|
110
117
|
files.forEach((file) => {
|
|
111
118
|
const originalContent = fs.readFileSync(file, 'utf8');
|
|
@@ -161,5 +168,6 @@ module.exports = {
|
|
|
161
168
|
escapeRegExp,
|
|
162
169
|
setParams,
|
|
163
170
|
printLog,
|
|
171
|
+
printCompletion,
|
|
164
172
|
replaceCases
|
|
165
173
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rancher/create-extension",
|
|
3
3
|
"description": "Rancher UI Extension generator",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.4",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SUSE",
|
|
7
7
|
"packageManager": "yarn@4.5.0",
|
|
8
8
|
"bin": {
|
|
9
|
-
"create-extension": "
|
|
9
|
+
"create-extension": "init"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"**/*",
|
package/pkg/package.json
CHANGED
|
@@ -10,31 +10,9 @@
|
|
|
10
10
|
"**/*.*",
|
|
11
11
|
"init"
|
|
12
12
|
],
|
|
13
|
-
"rancher": {
|
|
14
|
-
"annotations": {
|
|
15
|
-
"catalog.cattle.io/rancher-version": ">= 2.10.0",
|
|
16
|
-
"catalog.cattle.io/ui-extensions-version": ">= 3.0.0 < 4.0.0"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
13
|
"engines": {
|
|
20
14
|
"node": ">=20.0.0"
|
|
21
15
|
},
|
|
22
|
-
"resolutions": {
|
|
23
|
-
"d3-color": "3.1.0",
|
|
24
|
-
"ejs": "3.1.9",
|
|
25
|
-
"follow-redirects": "1.15.2",
|
|
26
|
-
"glob": "7.2.3",
|
|
27
|
-
"glob-parent": "6.0.2",
|
|
28
|
-
"json5": "2.2.3",
|
|
29
|
-
"@types/lodash": "4.17.5",
|
|
30
|
-
"merge": "2.1.1",
|
|
31
|
-
"node-forge": "1.3.1",
|
|
32
|
-
"nth-check": "2.1.1",
|
|
33
|
-
"qs": "6.11.1",
|
|
34
|
-
"roarr": "7.0.4",
|
|
35
|
-
"semver": "7.5.4",
|
|
36
|
-
"@vue/cli-service/html-webpack-plugin": "^5.0.0"
|
|
37
|
-
},
|
|
38
16
|
"dependencies": {
|
|
39
17
|
"fs-extra": "^10.0.0"
|
|
40
18
|
}
|
package/pkg/pkg.package.json
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
"description": "NAME plugin",
|
|
4
4
|
"version": "0.1.0",
|
|
5
5
|
"private": false,
|
|
6
|
-
"rancher":
|
|
6
|
+
"rancher": {
|
|
7
|
+
"annotations": {
|
|
8
|
+
"catalog.cattle.io/rancher-version": ">= 2.10.0",
|
|
9
|
+
"catalog.cattle.io/ui-extensions-version": ">= 3.0.0 < 4.0.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
7
12
|
"scripts": {},
|
|
8
13
|
"engines": {
|
|
9
14
|
"node": ">=16"
|
|
@@ -11,26 +16,7 @@
|
|
|
11
16
|
"devDependencies": {
|
|
12
17
|
"@vue/cli-plugin-babel": "~5.0.0",
|
|
13
18
|
"@vue/cli-service": "~5.0.0",
|
|
14
|
-
"@vue/cli-plugin-typescript": "~5.0.0"
|
|
15
|
-
"cache-loader": "^4.1.0",
|
|
16
|
-
"color": "4.2.3",
|
|
17
|
-
"ip": "2.0.1",
|
|
18
|
-
"node-polyfill-webpack-plugin": "^3.0.0"
|
|
19
|
-
},
|
|
20
|
-
"resolutions": {
|
|
21
|
-
"d3-color": "3.1.0",
|
|
22
|
-
"ejs": "3.1.9",
|
|
23
|
-
"follow-redirects": "1.15.2",
|
|
24
|
-
"glob": "7.2.3",
|
|
25
|
-
"glob-parent": "6.0.2",
|
|
26
|
-
"json5": "2.2.3",
|
|
27
|
-
"merge": "2.1.1",
|
|
28
|
-
"node-forge": "1.3.1",
|
|
29
|
-
"nth-check": "2.1.1",
|
|
30
|
-
"qs": "6.11.1",
|
|
31
|
-
"roarr": "7.0.4",
|
|
32
|
-
"semver": "7.5.4",
|
|
33
|
-
"@vue/cli-service/html-webpack-plugin": "^5.0.0"
|
|
19
|
+
"@vue/cli-plugin-typescript": "~5.0.0"
|
|
34
20
|
},
|
|
35
21
|
"browserslist": [
|
|
36
22
|
"> 1%",
|