@rancher/create-extension 3.0.1 → 3.0.3
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/files/.nvmrc +1 -0
- package/app/init +2 -1
- package/init +34 -6
- package/package.json +2 -2
- package/pkg/init +0 -5
- package/pkg/package.json +0 -22
- package/pkg/pkg.package.json +7 -21
- package/update/init +3 -7
- package/update/upgrade +10 -9
package/app/files/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20
|
package/app/init
CHANGED
|
@@ -16,6 +16,7 @@ const files = [
|
|
|
16
16
|
'gitignore',
|
|
17
17
|
'.eslintignore',
|
|
18
18
|
'.eslintrc.js',
|
|
19
|
+
'.nvmrc',
|
|
19
20
|
'.yarnrc.yml',
|
|
20
21
|
'babel.config.js',
|
|
21
22
|
'.vscode/settings.json'
|
|
@@ -28,7 +29,7 @@ const args = process.argv;
|
|
|
28
29
|
let appFolder = path.resolve('.');
|
|
29
30
|
let shellVersion = '';
|
|
30
31
|
|
|
31
|
-
if (
|
|
32
|
+
if (args.length >= 3 && !args[2].includes('@rancher/create-extension/app/init')) {
|
|
32
33
|
const name = args[2];
|
|
33
34
|
const folder = path.resolve('.');
|
|
34
35
|
|
package/init
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
|
|
4
|
-
const { execSync } = require('child_process');
|
|
4
|
+
const { execSync, spawnSync } = require('child_process');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const creatorPkg = require('./package.json');
|
|
@@ -152,7 +152,14 @@ try {
|
|
|
152
152
|
if (updateOnly) {
|
|
153
153
|
// Run the update script directly
|
|
154
154
|
console.log('Updating applications...');
|
|
155
|
-
|
|
155
|
+
const updateInitPath = path.join(updatePath, 'init');
|
|
156
|
+
const updateArgs = [updateInitPath, shellVersion, tagUsed, ...args];
|
|
157
|
+
|
|
158
|
+
const result = spawnSync('node', updateArgs, { stdio: 'inherit' });
|
|
159
|
+
|
|
160
|
+
if (result.status !== 0) {
|
|
161
|
+
throw new Error('Failed to create skeleton application.');
|
|
162
|
+
}
|
|
156
163
|
|
|
157
164
|
console.log('Update completed successfully.');
|
|
158
165
|
process.exit(0);
|
|
@@ -167,7 +174,14 @@ try {
|
|
|
167
174
|
if (!isInsideSkeleton && !skeletonExists) {
|
|
168
175
|
console.log(`Creating skeleton application: ${ appName }...`);
|
|
169
176
|
// Pass all arguments to the app/init script
|
|
170
|
-
|
|
177
|
+
const appInitPath = path.join(__dirname, 'app', 'init');
|
|
178
|
+
const appArgs = [appInitPath, appName, shellVersion, ...args];
|
|
179
|
+
|
|
180
|
+
const result = spawnSync('node', appArgs, { stdio: 'inherit' });
|
|
181
|
+
|
|
182
|
+
if (result.status !== 0) {
|
|
183
|
+
throw new Error('Failed to create skeleton application.');
|
|
184
|
+
}
|
|
171
185
|
|
|
172
186
|
// Ensure the skeleton path directory is created before attempting to change directory
|
|
173
187
|
if (!fs.existsSync(skeletonPath)) {
|
|
@@ -193,16 +207,30 @@ try {
|
|
|
193
207
|
// Check for package existence and create it if necessary
|
|
194
208
|
if (!pkgExists) {
|
|
195
209
|
console.log(`Creating package: ${ extensionName }...`);
|
|
196
|
-
|
|
210
|
+
const pkgInitPath = path.join(__dirname, 'pkg', 'init');
|
|
211
|
+
const pkgArgs = [pkgInitPath, extensionName, shellVersion, ...args];
|
|
212
|
+
|
|
213
|
+
const result = spawnSync('node', pkgArgs, { stdio: 'inherit' });
|
|
214
|
+
|
|
215
|
+
if (result.status !== 0) {
|
|
216
|
+
throw new Error('Failed to create package.');
|
|
217
|
+
}
|
|
197
218
|
}
|
|
198
219
|
|
|
199
220
|
if (args.includes('--update') || args.includes('-u')) {
|
|
200
221
|
// Run the update script
|
|
201
222
|
console.log('Updating applications...');
|
|
202
|
-
|
|
223
|
+
const updatePath = path.join(__dirname, 'update');
|
|
224
|
+
const updateArgs = [updatePath, ...args];
|
|
225
|
+
|
|
226
|
+
const result = spawnSync('node', updateArgs, { stdio: 'inherit' });
|
|
227
|
+
|
|
228
|
+
if (result.status !== 0) {
|
|
229
|
+
throw new Error('Failed to update applications.');
|
|
230
|
+
}
|
|
203
231
|
}
|
|
204
232
|
|
|
205
|
-
console.log('Extension created successfully.');
|
|
233
|
+
// console.log('Extension created successfully.');
|
|
206
234
|
|
|
207
235
|
if (skeletonOnly || !isInsideSkeleton) {
|
|
208
236
|
console.log(`To begin, run: \n\n\tcd ${ appName } && yarn install\n`);
|
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.3",
|
|
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/init
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
|
|
4
|
-
const { execSync } = require('child_process');
|
|
5
4
|
const fs = require('fs-extra');
|
|
6
5
|
const path = require('path');
|
|
7
|
-
const https = require('https');
|
|
8
6
|
|
|
9
7
|
const files = [
|
|
10
8
|
'tsconfig.json',
|
|
@@ -36,13 +34,10 @@ const args = process.argv;
|
|
|
36
34
|
const name = args[2];
|
|
37
35
|
const folder = path.resolve('.');
|
|
38
36
|
const pkgFolder = path.join(folder, 'pkg', name);
|
|
39
|
-
let shellVersion = '';
|
|
40
37
|
|
|
41
38
|
let addTypeFolders = true;
|
|
42
39
|
|
|
43
40
|
if ( args.length >= 3 ) {
|
|
44
|
-
shellVersion = args[3];
|
|
45
|
-
|
|
46
41
|
for ( let i = 3; i < args.length; i++ ) {
|
|
47
42
|
switch (args[i]) {
|
|
48
43
|
case '--skip-templates':
|
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%",
|
package/update/init
CHANGED
|
@@ -4,7 +4,7 @@ const path = require('path');
|
|
|
4
4
|
const fs = require('fs-extra');
|
|
5
5
|
const { spawnSync } = require('child_process');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const baseFolder = path.resolve(path.join(__dirname, '..'));
|
|
8
8
|
const dest = path.resolve('.');
|
|
9
9
|
|
|
10
10
|
// Remove first two args
|
|
@@ -27,13 +27,9 @@ let rawdata = fs.readFileSync(path.join(dest, 'package.json'));
|
|
|
27
27
|
const appPackage = JSON.parse(rawdata);
|
|
28
28
|
|
|
29
29
|
// Read the package.json from the app creator
|
|
30
|
-
rawdata = fs.readFileSync(path.join(
|
|
30
|
+
rawdata = fs.readFileSync(path.join(baseFolder, 'app', 'package.json'));
|
|
31
31
|
const latestPackage = JSON.parse(rawdata);
|
|
32
32
|
|
|
33
|
-
// Read the package.json from the upgrade creator
|
|
34
|
-
rawdata = fs.readFileSync(path.join(scriptFolder, 'package.json'));
|
|
35
|
-
const upgradePackage = JSON.parse(rawdata);
|
|
36
|
-
|
|
37
33
|
// Update dependency versions to match the latest from the creator
|
|
38
34
|
if ( latestPackage.dependencies ) {
|
|
39
35
|
Object.keys(latestPackage.dependencies).forEach((key) => {
|
|
@@ -48,7 +44,7 @@ appPackage.resolutions = appPackage.resolutions || {};
|
|
|
48
44
|
appPackage.resolutions['**/webpack'] = '4';
|
|
49
45
|
|
|
50
46
|
// Update the version of @rancher/shell
|
|
51
|
-
const shellVersion =
|
|
47
|
+
const shellVersion = args[0];
|
|
52
48
|
|
|
53
49
|
appPackage.dependencies['@rancher/shell'] = shellVersion;
|
|
54
50
|
|
package/update/upgrade
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
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
|
+
BASE_DIR="$(cd $SCRIPT_DIR && cd .. && pwd)"
|
|
4
5
|
|
|
5
6
|
echo "Upgrading Rancher Shell"
|
|
6
7
|
|
|
7
8
|
# Get the version number from the package.json file
|
|
8
|
-
VERSION=$
|
|
9
|
-
|
|
9
|
+
VERSION=$1
|
|
10
10
|
echo "Updating to version: ${VERSION}"
|
|
11
|
-
echo ""
|
|
12
11
|
|
|
13
12
|
FORCE="false"
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
for i in "$@"; do
|
|
15
|
+
if [ "$i" == "-f" ]; then
|
|
16
|
+
FORCE="true"
|
|
17
|
+
fi
|
|
18
|
+
done
|
|
18
19
|
|
|
19
20
|
# Check for a clean git repository
|
|
20
21
|
if [ ! -d ".git" ] && [ "${FORCE}" == "false" ]; then
|
|
@@ -42,7 +43,7 @@ if [ "${HAS_SHELL}" != "1" ]; then
|
|
|
42
43
|
fi
|
|
43
44
|
|
|
44
45
|
# Copy files for the top-level folder (from the app creator)
|
|
45
|
-
rsync ${
|
|
46
|
+
rsync --exclude nuxt.config.js --exclude .gitlab-ci.yml ${BASE_DIR}/app/files/* .
|
|
46
47
|
|
|
47
48
|
# Go through each folder in the pkg folder and update their files
|
|
48
49
|
for pkg in ./pkg/*
|
|
@@ -51,6 +52,6 @@ do
|
|
|
51
52
|
pkgName=$(basename $pkg)
|
|
52
53
|
echo "Updating package ${pkgName}"
|
|
53
54
|
|
|
54
|
-
cp ${
|
|
55
|
+
cp ${BASE_DIR}/pkg/files/* ${pkg}
|
|
55
56
|
fi
|
|
56
57
|
done
|