@rancher/create-extension 3.0.3 → 3.0.5

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 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
- ['@types/jest', '^29.5.2'],
73
- ['@typescript-eslint/eslint-plugin', '~5.4.0'],
74
- ['@typescript-eslint/parser', '~5.4.0'],
75
- ['@vue/cli-plugin-babel', '~5.0.0'],
76
- ['@vue/cli-plugin-e2e-cypress', '~5.0.0'],
77
- ['@vue/cli-plugin-eslint', '~5.0.0'],
78
- ['@vue/cli-plugin-router', '~5.0.0'],
79
- ['@vue/cli-plugin-typescript', '~5.0.0'],
80
- ['@vue/cli-plugin-unit-jest', '~5.0.0'],
81
- ['@vue/cli-plugin-vuex', '~5.0.0'],
82
- ['@vue/cli-service', '~5.0.0'],
83
- ['@vue/eslint-config-typescript', '~9.1.0'],
84
- ['@vue/vue2-jest', '@vue/vue3-jest', '^27.0.0-alpha.1'],
85
- ['@vue/test-utils', '~2.0.0-0'],
86
- ['core-js', '3.25.3'],
87
- ['cache-loader', '^4.1.0'],
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
- if (parsedJson[type][library]) {
106
- const version = semver.coerce(parsedJson[type][library]);
107
-
108
- if (newVersion === removePlaceholder) {
109
- // Remove library
110
- replaceLibraries.push([library, [parsedJson[type][library], removePlaceholder]]);
111
- delete parsedJson[type][library];
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', '^5.0.0'],
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 {
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "@rancher/create-extension",
3
3
  "description": "Rancher UI Extension generator",
4
- "version": "3.0.3",
4
+ "version": "3.0.5",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SUSE",
7
7
  "packageManager": "yarn@4.5.0",
package/update/upgrade CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env sh
1
+ #!/usr/bin/env bash
2
2
 
3
3
  SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4
4
  BASE_DIR="$(cd $SCRIPT_DIR && cd .. && pwd)"