@rancher/create-extension 1.0.0-rc.2 → 1.0.1
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/app/app.package.json +1 -2
- package/app/files/.eslintignore +2 -0
- package/app/files/.github/workflows/build-extension-catalog.yml +6 -2
- package/app/files/.github/workflows/build-extension-charts.yml +3 -2
- package/app/files/.vscode/settings.json +1 -0
- package/app/files/gitignore +4 -1
- package/app/files/tsconfig.json +2 -2
- package/app/init +3 -33
- package/app/package.json +1 -1
- package/init +21 -49
- package/package.json +6 -10
- package/pkg/init +57 -68
- package/pkg/package.json +7 -1
- package/update/init +11 -16
- package/update/package.json +1 -1
- package/update/upgrade +4 -4
- package/migrate/config.js +0 -7
- package/migrate/ignore.js +0 -14
- package/migrate/init +0 -35
- package/migrate/package.json +0 -23
- package/migrate/params.js +0 -7
- package/migrate/stats.js +0 -13
- package/migrate/tasks/eslintUpdates.js +0 -70
- package/migrate/tasks/index.js +0 -19
- package/migrate/tasks/nvmUpdates.js +0 -51
- package/migrate/tasks/packageUpdates.js +0 -242
- package/migrate/tasks/routerUpdates.js +0 -23
- package/migrate/tasks/stylesUpdates.js +0 -19
- package/migrate/tasks/tsUpdates.js +0 -19
- package/migrate/tasks/vueConfigUpdates.js +0 -30
- package/migrate/tasks/vueSyntaxUpdates.js +0 -148
- package/migrate/utils/content.js +0 -165
- package/migrate/utils/index.js +0 -4
- package/migrate/utils/vueSyntax.js +0 -126
package/update/upgrade
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env sh
|
|
2
2
|
|
|
3
|
-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
|
|
3
|
+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
4
4
|
|
|
5
5
|
echo "Upgrading Rancher Shell"
|
|
6
6
|
|
|
@@ -19,13 +19,13 @@ fi
|
|
|
19
19
|
# Check for a clean git repository
|
|
20
20
|
if [ ! -d ".git" ] && [ "${FORCE}" == "false" ]; then
|
|
21
21
|
echo "Not runnning in a git repository. Re-run with -f to ignore this check"
|
|
22
|
-
echo "Note: This action will update
|
|
22
|
+
echo "Note: This action will update yuor files - running in a git repsository will ensure you have visibility over changes made"
|
|
23
23
|
exit 1
|
|
24
24
|
fi
|
|
25
25
|
|
|
26
26
|
if [[ $(git diff --stat) != '' ]] && [ "${FORCE}" == "false" ]; then
|
|
27
27
|
echo "Git repository is not clean. Re-run with -f to ignore this check"
|
|
28
|
-
echo "Note: This action will update
|
|
28
|
+
echo "Note: This action will update yuor files - running in a clean git repsository will ensure you have visibility over changes made"
|
|
29
29
|
exit 1
|
|
30
30
|
fi
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ if [ "${HAS_SHELL}" != "1" ]; then
|
|
|
42
42
|
fi
|
|
43
43
|
|
|
44
44
|
# Copy files for the top-level folder (from the app creator)
|
|
45
|
-
rsync ${SCRIPT_DIR}/app/files/* .
|
|
45
|
+
rsync --exclude nuxt.config.js ${SCRIPT_DIR}/app/files/* .
|
|
46
46
|
|
|
47
47
|
# Go through each folder in the pkg folder and update their files
|
|
48
48
|
for pkg in ./pkg/*
|
package/migrate/config.js
DELETED
package/migrate/ignore.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module.exports = [
|
|
2
|
-
'**/node_modules/**',
|
|
3
|
-
'**/dist/**',
|
|
4
|
-
'**/dist-pkg/**',
|
|
5
|
-
'**/.vscode/**',
|
|
6
|
-
'**/assets/**',
|
|
7
|
-
'**/charts/**',
|
|
8
|
-
'**/extensions/**',
|
|
9
|
-
'**/scripts/vue-migrate.js',
|
|
10
|
-
'docusaurus/**',
|
|
11
|
-
'storybook-static/**',
|
|
12
|
-
'storybook/**',
|
|
13
|
-
'migration/**',
|
|
14
|
-
];
|
package/migrate/init
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { setParams, printLog, printUsage } = require('./utils/content');
|
|
4
|
-
const {
|
|
5
|
-
packageUpdates,
|
|
6
|
-
nvmUpdates,
|
|
7
|
-
vueConfigUpdates,
|
|
8
|
-
vueSyntaxUpdates,
|
|
9
|
-
routerUpdates,
|
|
10
|
-
eslintUpdates,
|
|
11
|
-
tsUpdates,
|
|
12
|
-
stylesUpdates,
|
|
13
|
-
} = require('./tasks');
|
|
14
|
-
const params = require('./params');
|
|
15
|
-
|
|
16
|
-
(function main() {
|
|
17
|
-
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
18
|
-
printUsage();
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
setParams(params);
|
|
24
|
-
|
|
25
|
-
packageUpdates(params);
|
|
26
|
-
nvmUpdates(params);
|
|
27
|
-
vueConfigUpdates(params);
|
|
28
|
-
vueSyntaxUpdates(params);
|
|
29
|
-
routerUpdates(params);
|
|
30
|
-
eslintUpdates(params);
|
|
31
|
-
tsUpdates(params);
|
|
32
|
-
stylesUpdates(params);
|
|
33
|
-
|
|
34
|
-
printLog();
|
|
35
|
-
})();
|
package/migrate/package.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rancher/create-migration",
|
|
3
|
-
"description": "Rancher UI Vue3 migration helper",
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"license": "Apache-2.0",
|
|
6
|
-
"author": "SUSE",
|
|
7
|
-
"private": false,
|
|
8
|
-
"bin": "./init",
|
|
9
|
-
"files": [
|
|
10
|
-
"**/*.*",
|
|
11
|
-
"init"
|
|
12
|
-
],
|
|
13
|
-
"engines": {
|
|
14
|
-
"node": ">=20.0.0"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"diff": "^7.0.0",
|
|
18
|
-
"fs-extra": "^10.0.0",
|
|
19
|
-
"glob": "^11.0.0",
|
|
20
|
-
"path": "^0.12.7",
|
|
21
|
-
"semver": "^7.6.3"
|
|
22
|
-
}
|
|
23
|
-
}
|
package/migrate/params.js
DELETED
package/migrate/stats.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const glob = require('glob');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const stats = require('../stats');
|
|
5
|
-
const { writeContent, printContent } = require('../utils/content');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* ESLint Updates
|
|
9
|
-
* Files: .eslintrc.js, .eslintrc.json, .eslintrc.yml
|
|
10
|
-
*/
|
|
11
|
-
const eslintUpdates = (params) => {
|
|
12
|
-
const files = glob.sync(params.paths || '**/.eslintrc.*{js,json,yml}', { ignore: params.ignore });
|
|
13
|
-
const replacePlugins = [
|
|
14
|
-
['plugin:vue/essential', 'plugin:vue/vue3-essential'],
|
|
15
|
-
['plugin:vue/strongly-recommended', 'plugin:vue/vue3-strongly-recommended'],
|
|
16
|
-
['plugin:vue/recommended', 'plugin:vue/vue3-recommended']
|
|
17
|
-
];
|
|
18
|
-
const newRules = {
|
|
19
|
-
'vue/one-component-per-file': 'off',
|
|
20
|
-
'vue/no-deprecated-slot-attribute': 'off',
|
|
21
|
-
'vue/require-explicit-emits': 'off',
|
|
22
|
-
'vue/v-on-event-hyphenation': 'off',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
files.forEach((file) => {
|
|
26
|
-
const originalContent = fs.readFileSync(file, 'utf8');
|
|
27
|
-
let content = originalContent;
|
|
28
|
-
const matchedCases = [];
|
|
29
|
-
|
|
30
|
-
replacePlugins.forEach(([text, replacement]) => {
|
|
31
|
-
if (content.includes(text)) {
|
|
32
|
-
content = content.replaceAll(text, replacement);
|
|
33
|
-
matchedCases.push([text, replacement]);
|
|
34
|
-
|
|
35
|
-
writeContent(file, content, originalContent);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const eslintConfigPath = path.join(process.cwd(), `${ file }`);
|
|
40
|
-
let eslintConfig;
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
eslintConfig = require(eslintConfigPath);
|
|
44
|
-
} catch (error) {
|
|
45
|
-
eslintConfig = {};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!eslintConfig.rules) {
|
|
49
|
-
eslintConfig.rules = {};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
Object.keys(newRules).forEach((rule) => {
|
|
53
|
-
if (!eslintConfig.rules[rule]) {
|
|
54
|
-
eslintConfig.rules[rule] = newRules[rule];
|
|
55
|
-
matchedCases.push(rule);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (matchedCases.length) {
|
|
60
|
-
const updatedConfig = `module.exports = ${ JSON.stringify(eslintConfig, null, 2) }`;
|
|
61
|
-
|
|
62
|
-
writeContent(file, updatedConfig, originalContent);
|
|
63
|
-
printContent(file, `Updating ESLint`, matchedCases);
|
|
64
|
-
stats.eslint.push(file);
|
|
65
|
-
stats.total.push(file);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
module.exports = eslintUpdates;
|
package/migrate/tasks/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const packageUpdates = require('./packageUpdates');
|
|
2
|
-
const nvmUpdates = require('./nvmUpdates');
|
|
3
|
-
const vueConfigUpdates = require('./vueConfigUpdates');
|
|
4
|
-
const vueSyntaxUpdates = require('./vueSyntaxUpdates');
|
|
5
|
-
const routerUpdates = require('./routerUpdates');
|
|
6
|
-
const eslintUpdates = require('./eslintUpdates');
|
|
7
|
-
const tsUpdates = require('./tsUpdates');
|
|
8
|
-
const stylesUpdates = require('./stylesUpdates');
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
packageUpdates,
|
|
12
|
-
nvmUpdates,
|
|
13
|
-
vueConfigUpdates,
|
|
14
|
-
vueSyntaxUpdates,
|
|
15
|
-
routerUpdates,
|
|
16
|
-
eslintUpdates,
|
|
17
|
-
tsUpdates,
|
|
18
|
-
stylesUpdates,
|
|
19
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const glob = require('glob');
|
|
3
|
-
const semver = require('semver');
|
|
4
|
-
const stats = require('../stats');
|
|
5
|
-
const { printContent, writeContent } = require('../utils/content');
|
|
6
|
-
const { nodeRequirement, isDry, isSuggest } = require('../config');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* NVM updates
|
|
10
|
-
* Files: .nvmrc
|
|
11
|
-
*
|
|
12
|
-
* Verify presence of .nvmrc, create one if none, update if any
|
|
13
|
-
*/
|
|
14
|
-
const nvmUpdates = (params) => {
|
|
15
|
-
const files = glob.sync(params.paths || '**/.nvmrc', { ignore: params.ignore });
|
|
16
|
-
const nvmRequirement = 20;
|
|
17
|
-
|
|
18
|
-
if (files.length === 0) {
|
|
19
|
-
// If no .nvmrc files found, create one
|
|
20
|
-
const newFilePath = '.nvmrc';
|
|
21
|
-
|
|
22
|
-
if (!isDry && !isSuggest) {
|
|
23
|
-
fs.writeFileSync(newFilePath, nvmRequirement.toString());
|
|
24
|
-
printContent(newFilePath, `Created ${ newFilePath } with Node version ${ nvmRequirement }`, '');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
writeContent(newFilePath, nvmRequirement.toString(), '');
|
|
28
|
-
stats.nvmrc.push(newFilePath);
|
|
29
|
-
stats.total.push(newFilePath);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
files.forEach((file) => {
|
|
33
|
-
if (file) {
|
|
34
|
-
const originalContent = fs.readFileSync(file, 'utf8');
|
|
35
|
-
let content = originalContent;
|
|
36
|
-
const nodeVersionMatch = content.match(/([0-9.x]+)/g);
|
|
37
|
-
const nodeVersion = semver.coerce(nodeVersionMatch[0]);
|
|
38
|
-
|
|
39
|
-
// Ensure node version is up to date
|
|
40
|
-
if (nodeVersion && semver.lt(nodeVersion, semver.coerce(nodeRequirement))) {
|
|
41
|
-
printContent(file, `Updating node ${ [nodeVersionMatch[0], nvmRequirement] }`);
|
|
42
|
-
content = content.replaceAll(nodeVersionMatch[0], nvmRequirement);
|
|
43
|
-
writeContent(file, content, originalContent);
|
|
44
|
-
stats.nvmrc.push(file);
|
|
45
|
-
stats.total.push(file);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
module.exports = nvmUpdates;
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const glob = require('glob');
|
|
4
|
-
const semver = require('semver');
|
|
5
|
-
const stats = require('../stats');
|
|
6
|
-
const { nodeRequirement, removePlaceholder } = require('../config');
|
|
7
|
-
const { writeContent, printContent } = require('../utils/content');
|
|
8
|
-
|
|
9
|
-
function packageUpdates(params) {
|
|
10
|
-
const files = glob.sync(params.paths || '**/package.json', { ignore: params.ignore });
|
|
11
|
-
|
|
12
|
-
files.forEach((file) => {
|
|
13
|
-
const originalContent = fs.readFileSync(file, 'utf8');
|
|
14
|
-
let content = originalContent;
|
|
15
|
-
|
|
16
|
-
const [librariesContent, replaceLibraries] = packageUpdatesLibraries(file, content);
|
|
17
|
-
|
|
18
|
-
if (replaceLibraries.length) {
|
|
19
|
-
content = librariesContent;
|
|
20
|
-
printContent(file, `Updating libraries`, replaceLibraries);
|
|
21
|
-
stats.libraries.push(file);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const [nodeContent, replaceNode] = packageUpdatesEngine(file, content);
|
|
25
|
-
|
|
26
|
-
if (replaceNode.length) {
|
|
27
|
-
content = nodeContent;
|
|
28
|
-
printContent(file, `Updating node engine`, replaceNode);
|
|
29
|
-
stats.node.push(file);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const [resolutionContent, replaceResolution] = packageUpdatesResolution(file, content);
|
|
33
|
-
|
|
34
|
-
if (replaceResolution.length) {
|
|
35
|
-
content = resolutionContent;
|
|
36
|
-
printContent(file, `Updating resolutions`, replaceResolution);
|
|
37
|
-
stats.libraries.push(file);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const [annotationsContent, annotationsChanges] = packageUpdatesAnnotations(file, content);
|
|
41
|
-
|
|
42
|
-
if (annotationsChanges.length) {
|
|
43
|
-
content = annotationsContent;
|
|
44
|
-
printContent(file, `Updating annotations`, annotationsChanges);
|
|
45
|
-
stats.annotations = stats.annotations || [];
|
|
46
|
-
stats.annotations.push(file);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
replaceLibraries.length ||
|
|
51
|
-
replaceNode.length ||
|
|
52
|
-
replaceResolution.length ||
|
|
53
|
-
annotationsChanges.length
|
|
54
|
-
) {
|
|
55
|
-
writeContent(file, content, originalContent);
|
|
56
|
-
stats.total.push(file);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function packageUpdatesLibraries(file, oldContent) {
|
|
62
|
-
let content = oldContent;
|
|
63
|
-
let parsedJson = JSON.parse(content);
|
|
64
|
-
const replaceLibraries = [];
|
|
65
|
-
const types = ['dependencies', 'devDependencies', 'peerDependencies'];
|
|
66
|
-
|
|
67
|
-
// [Library name, new version or new library, new library version]
|
|
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'],
|
|
100
|
-
];
|
|
101
|
-
|
|
102
|
-
types.forEach((type) => {
|
|
103
|
-
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];
|
|
112
|
-
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
|
-
}
|
|
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
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
return [content, replaceLibraries];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function packageUpdatesEngine(file, oldContent) {
|
|
144
|
-
let content = oldContent;
|
|
145
|
-
let parsedJson = JSON.parse(content);
|
|
146
|
-
const replaceNode = [];
|
|
147
|
-
|
|
148
|
-
if (parsedJson.engines) {
|
|
149
|
-
const outdated = semver.lt(semver.coerce(parsedJson.engines.node), semver.coerce(nodeRequirement));
|
|
150
|
-
|
|
151
|
-
if (outdated) {
|
|
152
|
-
replaceNode.push([parsedJson.engines.node, nodeRequirement]);
|
|
153
|
-
content = content.replace(
|
|
154
|
-
`"node": "${ parsedJson.engines.node }"`,
|
|
155
|
-
`"node": ">=${ nodeRequirement }"`
|
|
156
|
-
);
|
|
157
|
-
parsedJson = JSON.parse(content);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return [content, replaceNode];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function packageUpdatesResolution(file, oldContent) {
|
|
165
|
-
let content = oldContent;
|
|
166
|
-
let parsedJson = JSON.parse(content);
|
|
167
|
-
const replaceResolution = [];
|
|
168
|
-
const resolutions = [
|
|
169
|
-
['@vue/cli-service/html-webpack-plugin', '^5.0.0'],
|
|
170
|
-
['**/webpack', removePlaceholder],
|
|
171
|
-
];
|
|
172
|
-
|
|
173
|
-
if (parsedJson.resolutions) {
|
|
174
|
-
resolutions.forEach(([library, newVersion]) => {
|
|
175
|
-
if (newVersion === removePlaceholder) {
|
|
176
|
-
delete parsedJson.resolutions[library];
|
|
177
|
-
content = JSON.stringify(parsedJson, null, 2);
|
|
178
|
-
parsedJson = JSON.parse(content);
|
|
179
|
-
} else if (!parsedJson.resolutions[library]) {
|
|
180
|
-
parsedJson.resolutions[library] = newVersion;
|
|
181
|
-
content = JSON.stringify(parsedJson, null, 2);
|
|
182
|
-
parsedJson = JSON.parse(content);
|
|
183
|
-
} else {
|
|
184
|
-
const outdated = semver.lt(
|
|
185
|
-
semver.coerce(parsedJson.resolutions[library]),
|
|
186
|
-
semver.coerce(newVersion)
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
if (outdated) {
|
|
190
|
-
replaceResolution.push([parsedJson.engines.node, nodeRequirement]);
|
|
191
|
-
content = content.replace(
|
|
192
|
-
`"${ library }": "${ parsedJson.resolutions[library] }"`,
|
|
193
|
-
`"${ library }": "${ newVersion }"`
|
|
194
|
-
);
|
|
195
|
-
parsedJson = JSON.parse(content);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return [content, replaceResolution];
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function packageUpdatesAnnotations(file, oldContent) {
|
|
205
|
-
let content = oldContent;
|
|
206
|
-
const parsedJson = JSON.parse(content);
|
|
207
|
-
const changesMade = [];
|
|
208
|
-
|
|
209
|
-
// Check if the file is in pkg/*/package.json
|
|
210
|
-
const dirName = path.dirname(file); // e.g., 'pkg/extension-name'
|
|
211
|
-
const parentDirName = path.basename(path.dirname(dirName)); // Should be 'pkg'
|
|
212
|
-
|
|
213
|
-
if (parentDirName === 'pkg') {
|
|
214
|
-
// The file is in pkg/<extension-name>/package.json
|
|
215
|
-
const annotations = {
|
|
216
|
-
'catalog.cattle.io/rancher-version': '>= 2.10.0-0',
|
|
217
|
-
'catalog.cattle.io/ui-extension-version': '>= 3.0.0',
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
if (!parsedJson.rancher) {
|
|
221
|
-
parsedJson.rancher = { annotations };
|
|
222
|
-
changesMade.push('Added rancher annotations');
|
|
223
|
-
} else if (!parsedJson.rancher.annotations) {
|
|
224
|
-
parsedJson.rancher.annotations = annotations;
|
|
225
|
-
changesMade.push('Added rancher annotations');
|
|
226
|
-
} else {
|
|
227
|
-
// Merge existing annotations with the new ones
|
|
228
|
-
parsedJson.rancher.annotations = {
|
|
229
|
-
...parsedJson.rancher.annotations,
|
|
230
|
-
...annotations,
|
|
231
|
-
};
|
|
232
|
-
changesMade.push('Updated rancher annotations');
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Update content
|
|
236
|
-
content = JSON.stringify(parsedJson, null, 2);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return [content, changesMade];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
module.exports = packageUpdates;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const glob = require('glob');
|
|
2
|
-
const { replaceCases } = require('../utils/content');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Vue Router
|
|
6
|
-
* Files: .vue, .js, .ts
|
|
7
|
-
*/
|
|
8
|
-
const routerUpdates = (params) => {
|
|
9
|
-
const files = glob.sync(params.paths || '**/*.{vue,js,ts}', { ignore: params.ignore });
|
|
10
|
-
const replacementCases = [
|
|
11
|
-
[`import Router from 'vue-router'`, `import { createRouter } from 'vue-router'`, 'Ensure correct import of createRouter'],
|
|
12
|
-
[`vueApp.use(Router)`, `const router = createRouter({})`, 'Update router initialization'],
|
|
13
|
-
[`Vue.use(Router)`, `const router = createRouter({})`, 'Update router initialization'],
|
|
14
|
-
|
|
15
|
-
[/import\s*\{([^}]*)\s* RouteConfig\s*([^}]*)\}\s*from\s*'vue-router'/g, (match, before, after) => `import {${ before.trim() } RouteRecordRaw ${ after.trim() }} from 'vue-router'`, 'Update RouteConfig to RouteRecordRaw'],
|
|
16
|
-
[/import\s*\{([^}]*)\s* Location\s*([^}]*)\}\s*from\s*'vue-router'/g, (match, before, after) => `import {${ before.trim() } RouteLocation ${ after.trim() }} from 'vue-router'`, 'Update Location to RouteLocation'],
|
|
17
|
-
['mode: \'history\'', 'history: createWebHistory()', 'Update router mode to history'],
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
replaceCases('router', files, replacementCases, `Updating Vue Router`);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports = routerUpdates;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const glob = require('glob');
|
|
2
|
-
const { replaceCases } = require('../utils/content');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Update styles (e.g., replace ::v-deep with :deep)
|
|
6
|
-
*/
|
|
7
|
-
const stylesUpdates = (params) => {
|
|
8
|
-
const files = glob.sync(params.paths || '**/*.{vue,scss,css}', { ignore: params.ignore });
|
|
9
|
-
const cases = [
|
|
10
|
-
// Replace '::v-deep' without parentheses with ':deep()'
|
|
11
|
-
[/::v-deep(?!\()/g, ':deep()', 'Replace ::v-deep with :deep()'],
|
|
12
|
-
// Replace '::v-deep(' with ':deep('
|
|
13
|
-
[/::v-deep\(/g, ':deep(', 'Replace ::v-deep( with :deep('],
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
replaceCases('style', files, cases, `Updating styles`);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
module.exports = stylesUpdates;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const { isSuggest } = require('../config');
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-console */
|
|
4
|
-
/**
|
|
5
|
-
* TS Updates
|
|
6
|
-
* Files: tsconfig*.json
|
|
7
|
-
*
|
|
8
|
-
* Add information about TS issues, recommend @ts-nocheck as temporary solution
|
|
9
|
-
*/
|
|
10
|
-
const tsUpdates = (params) => {
|
|
11
|
-
if (!isSuggest) {
|
|
12
|
-
console.warn('TS checks are stricter and may require to be fixed manually.',
|
|
13
|
-
'Use @ts-nocheck to give you time to fix them.',
|
|
14
|
-
'Add exception to your ESLint config to avoid linting errors.');
|
|
15
|
-
}
|
|
16
|
-
// TODO: Add case
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
module.exports = tsUpdates;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const glob = require('glob');
|
|
3
|
-
const stats = require('../stats');
|
|
4
|
-
const { writeContent } = require('../utils/content');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Vue config update
|
|
8
|
-
* Files: vue.config.js
|
|
9
|
-
*
|
|
10
|
-
* Verify vue.config presence of deprecated Webpack5 options
|
|
11
|
-
* - devServer.public: 'path' -> client: { webSocketURL: 'path' }
|
|
12
|
-
*/
|
|
13
|
-
const vueConfigUpdates = (params) => {
|
|
14
|
-
const files = glob.sync(params.paths || 'vue.config**.js', { ignore: params.ignore });
|
|
15
|
-
|
|
16
|
-
files.forEach((file) => {
|
|
17
|
-
const originalContent = fs.readFileSync(file, 'utf8');
|
|
18
|
-
const content = originalContent;
|
|
19
|
-
|
|
20
|
-
// Verify vue.config presence of deprecated Webpack5 options
|
|
21
|
-
if (content.includes('devServer.public: \'path\'')) {
|
|
22
|
-
writeContent(file, content, originalContent);
|
|
23
|
-
stats.webpack.push(file);
|
|
24
|
-
stats.total.push(file);
|
|
25
|
-
// TODO: Add replacement
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
module.exports = vueConfigUpdates;
|