@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.
@@ -3,7 +3,7 @@
3
3
  "version": "0.1.0",
4
4
  "private": false,
5
5
  "engines": {
6
- "node": ">=20"
6
+ "node": ">=16"
7
7
  },
8
8
  "dependencies": {
9
9
  "cache-loader": "^4.1.0",
@@ -12,7 +12,6 @@
12
12
  "node-polyfill-webpack-plugin": "^3.0.0"
13
13
  },
14
14
  "resolutions": {
15
- "@types/node": "~20.10.0",
16
15
  "d3-color": "3.1.0",
17
16
  "ejs": "3.1.9",
18
17
  "follow-redirects": "1.15.2",
@@ -7,10 +7,12 @@ node_modules/
7
7
  .env
8
8
  .cache
9
9
  .next
10
+ .nuxt
10
11
  dist
11
12
  dist-pkg
12
13
  .DS_Store
13
14
  dynamic-importer.js
14
15
  ksconfig.json
16
+ nuxt.config.js
15
17
  shell/utils/dynamic-importer.js
16
18
  shell/assets/fonts
@@ -2,8 +2,12 @@ name: Build and Release Extension Catalog
2
2
 
3
3
  on:
4
4
  workflow_dispatch:
5
- release:
6
- types: [released]
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ branches:
10
+ - main
7
11
 
8
12
  defaults:
9
13
  run:
@@ -2,7 +2,7 @@ name: Build and Release Extension Charts
2
2
 
3
3
  on:
4
4
  workflow_dispatch:
5
- release:
5
+ release:
6
6
  types: [released]
7
7
 
8
8
  defaults:
@@ -12,7 +12,7 @@ defaults:
12
12
 
13
13
  jobs:
14
14
  build-extension-charts:
15
- uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@master
15
+ uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@release-2.8
16
16
  permissions:
17
17
  actions: write
18
18
  contents: write
@@ -20,3 +20,4 @@ jobs:
20
20
  pages: write
21
21
  with:
22
22
  target_branch: gh-pages
23
+ tagged_release: ${{ github.ref_name }}
@@ -8,6 +8,7 @@
8
8
  ".eslintignore": true,
9
9
  ".eslintrc.js": true,
10
10
  ".gitignore": true,
11
+ ".nuxt*": true,
11
12
  ".nyc_output": true,
12
13
  ".vscode": true,
13
14
  "LICENSE": true,
@@ -67,4 +67,7 @@ jspm_packages/
67
67
 
68
68
  # System Files
69
69
  .DS_Store
70
- Thumbs.db
70
+ Thumbs.db
71
+
72
+ # Locally built assets (extensions)
73
+ dist-pkg
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "esModuleInterop": true,
12
12
  "allowJs": true,
13
- "sourceMap": false,
13
+ "sourceMap": true,
14
14
  "strict": true,
15
15
  "noEmit": true,
16
16
  "baseUrl": ".",
@@ -28,7 +28,7 @@
28
28
  "typeRoots": [
29
29
  "./node_modules",
30
30
  "./node_modules/@rancher/shell/types"
31
- ],
31
+ ],
32
32
  "types": [
33
33
  "@types/node",
34
34
  "cypress",
package/app/init CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
2
 
4
3
  const path = require('path');
5
4
  const fs = require('fs-extra');
@@ -28,7 +27,7 @@ const args = process.argv;
28
27
  let appFolder = path.resolve('.');
29
28
  let shellVersion = '';
30
29
 
31
- if ( args.length > 2 ) {
30
+ if (args.length === 3) {
32
31
  const name = args[2];
33
32
  const folder = path.resolve('.');
34
33
 
@@ -65,7 +64,6 @@ if ( addGitlabWorkflow ) {
65
64
 
66
65
  let setName = false;
67
66
 
68
- // Check that there is a package file
69
67
  if (!fs.existsSync(path.join(appFolder, './package.json'))) {
70
68
  console.log(' Adding package.json');
71
69
  fs.copySync(path.join(__dirname, 'app.package.json'), path.join(appFolder, 'package.json'));
@@ -110,32 +108,6 @@ if (creatorPkg._pkgs) {
110
108
 
111
109
  fs.writeFileSync(path.join(appFolder, 'package.json'), JSON.stringify(pkg, null, 2));
112
110
 
113
- // Add workflow folder if needed
114
- if ( addWorkflowFolder ) {
115
- // Point to the workflow directory inside the skeleton application
116
- const workflowDir = path.join(appFolder, '.github/workflows');
117
-
118
- if ( !fs.existsSync(workflowDir) ) {
119
- console.log(' Creating folder: .github/workflows');
120
- fs.mkdirSync(workflowDir, { recursive: true });
121
- }
122
-
123
- const workflowFiles = [
124
- 'build-extension-catalog.yml',
125
- 'build-extension-charts.yml'
126
- ];
127
-
128
- workflowFiles.forEach((fileName) => {
129
- const dest = path.join(workflowDir, fileName); // Destination in the skeleton application
130
- const src = path.join(__dirname, 'files/.github/workflows', fileName); // Source in the package
131
-
132
- if ( !fs.existsSync(dest) ) {
133
- console.log(` Adding file ${ fileName } to root workflows`);
134
- fs.copySync(src, dest);
135
- }
136
- });
137
- }
138
-
139
111
  // Copy base files
140
112
  files.forEach((file) => {
141
113
  const destinationFile = file === 'gitignore' ? '.gitignore' : file;
@@ -145,7 +117,7 @@ files.forEach((file) => {
145
117
  if (!fs.existsSync(dest)) {
146
118
  console.log(` Adding file: ${ file }`);
147
119
 
148
- const folder = path.dirname(dest);
120
+ const folder = path.dirname(file);
149
121
 
150
122
  fs.ensureDirSync(folder);
151
123
 
@@ -154,6 +126,4 @@ files.forEach((file) => {
154
126
  }
155
127
  });
156
128
 
157
- console.log('Skeleton Application creation complete.\n');
158
-
159
- /* eslint-enable no-console */
129
+ console.log('');
package/app/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "init"
12
12
  ],
13
13
  "engines": {
14
- "node": ">=20.0.0"
14
+ "node": ">=16.0.0"
15
15
  },
16
16
  "_requires": [
17
17
  "core-js",
package/init CHANGED
@@ -9,34 +9,20 @@ const creatorPkg = require('./package.json');
9
9
  const args = process.argv.slice(2);
10
10
  let extensionName = '';
11
11
  let appName = '';
12
- let migrate = false;
13
12
  let updateOnly = false;
14
13
  let skeletonOnly = false;
15
- let ignoreShellDepCheck = false; // Ignore the check for @rancher/shell dependency (Only used for testing)
14
+ let ignoreShellDepCheck = false;
16
15
  let tagUsed = ''; // To store the inferred tag
17
16
 
18
17
  args.forEach((arg, index) => {
19
18
  switch (arg) {
20
- case '--help':
21
- case '-h':
22
- console.log(`Usage: ${ creatorPkg.name } [options] [extension-name]`);
23
- console.log('\nOptions:');
24
- console.log(' --help, -h Show help');
25
- console.log(' --migrate Migrate an existing extension to Vue 3');
26
- console.log(' --update, -u Update applications');
27
- console.log(' --app-name, -a Specify the name of the application');
28
- console.log(' --skeleton-only, -s Create only the skeleton application');
29
- process.exit(0);
30
- case '--migrate':
31
- migrate = true;
32
- break;
33
19
  case '--update':
34
20
  case '-u':
35
21
  updateOnly = true;
36
22
  break;
37
23
  case '--app-name':
38
24
  case '-a':
39
- if (args[index + 1] && !args[index + 1].startsWith('-')) {
25
+ if ( args[index + 1] && !args[index + 1].startsWith('-') ) {
40
26
  appName = args[index + 1];
41
27
  } else {
42
28
  console.error('Error: Missing value for --app-name or -a option.');
@@ -51,14 +37,14 @@ args.forEach((arg, index) => {
51
37
  ignoreShellDepCheck = true;
52
38
  break;
53
39
  default:
54
- if (!arg.startsWith('-') && extensionName === '') {
40
+ if ( !arg.startsWith('-') && extensionName === '' ) {
55
41
  extensionName = arg;
56
42
  appName = appName || extensionName;
57
43
  }
58
44
  }
59
45
  });
60
46
 
61
- if (!extensionName && !updateOnly && !skeletonOnly && !migrate) {
47
+ if ( !extensionName && !updateOnly && !skeletonOnly ) {
62
48
  console.error('Please provide an extension name.');
63
49
  process.exit(1);
64
50
  }
@@ -69,7 +55,7 @@ try {
69
55
  const currentVersion = creatorPkg.version;
70
56
 
71
57
  // Fetch the dist-tags from npm
72
- const distTags = JSON.parse(execSync(`npm view ${ packageName } dist-tags --json`, { stdio: 'pipe' }).toString());
58
+ const distTags = JSON.parse(execSync(`npm view ${ packageName } dist-tags --json`).toString());
73
59
 
74
60
  // Find the tag matching the current version
75
61
  tagUsed = Object.keys(distTags).find((tag) => distTags[tag] === currentVersion) || 'latest';
@@ -86,12 +72,12 @@ const shellPackageName = '@rancher/shell';
86
72
 
87
73
  try {
88
74
  // Fetch the version of the `@rancher/shell` package that corresponds to the inferred tag
89
- const tagVersion = execSync(`npm view ${ shellPackageName } dist-tags.${ tagUsed }`, { stdio: 'pipe' }).toString().trim();
75
+ const tagVersion = execSync(`npm view ${ shellPackageName } dist-tags.${ tagUsed }`).toString().trim();
90
76
 
91
77
  if (tagVersion) {
92
78
  shellVersion = tagVersion;
93
79
  } else {
94
- const latestVersion = execSync(`npm view ${ shellPackageName } version`, { stdio: 'pipe' }).toString().trim();
80
+ const latestVersion = execSync(`npm view ${ shellPackageName } version`).toString().trim();
95
81
 
96
82
  shellVersion = latestVersion;
97
83
  }
@@ -100,9 +86,7 @@ try {
100
86
  process.exit(1);
101
87
  }
102
88
 
103
- if (!migrate) {
104
- console.log(` Using version ${ shellVersion } for ${ shellPackageName }`);
105
- }
89
+ console.log(` Using version ${ shellVersion } for ${ shellPackageName }`);
106
90
 
107
91
  const basePath = process.cwd();
108
92
  let skeletonPath;
@@ -110,12 +94,12 @@ let isInsideSkeleton = false;
110
94
  let directoryExists = false;
111
95
 
112
96
  // Check if we are inside a skeleton application by looking for package.json
113
- if (fs.existsSync(path.join(basePath, 'package.json'))) {
97
+ if ( fs.existsSync(path.join(basePath, 'package.json')) ) {
114
98
  // Check for @rancher/shell dependency
115
99
  const packageJsonPath = path.join(basePath, 'package.json');
116
100
  const packageJson = require(packageJsonPath);
117
101
 
118
- if (!ignoreShellDepCheck && (!packageJson.dependencies || !packageJson.dependencies['@rancher/shell'])) {
102
+ if ( !ignoreShellDepCheck && (!packageJson.dependencies || !packageJson.dependencies['@rancher/shell']) ) {
119
103
  throw new Error('@rancher/shell dependency is missing in package.json.');
120
104
  } else {
121
105
  isInsideSkeleton = true;
@@ -125,7 +109,7 @@ if (fs.existsSync(path.join(basePath, 'package.json'))) {
125
109
  // If not inside a skeleton, check if a directory with the appName already exists
126
110
  skeletonPath = path.join(basePath, appName);
127
111
 
128
- if (fs.existsSync(skeletonPath)) {
112
+ if ( fs.existsSync(skeletonPath) ) {
129
113
  directoryExists = true;
130
114
  }
131
115
  }
@@ -137,19 +121,7 @@ const skeletonExists = fs.existsSync(skeletonPath);
137
121
  const pkgExists = fs.existsSync(pkgPath);
138
122
 
139
123
  try {
140
- if (migrate) {
141
- if (!isInsideSkeleton) {
142
- throw new Error('Migrate option can only be used inside a skeleton application.');
143
- }
144
-
145
- console.log(`Migrating extension to Vue 3...`);
146
- execSync(`node ${ path.join(__dirname, 'migrate', 'init') } ${ args.join(' ') }`, { stdio: 'inherit' });
147
-
148
- console.log('Migration completed successfully.');
149
- process.exit(0);
150
- }
151
-
152
- if (updateOnly) {
124
+ if ( updateOnly ) {
153
125
  // Run the update script directly
154
126
  console.log('Updating applications...');
155
127
  execSync(`node ${ path.join(updatePath, 'init') }`, { stdio: 'inherit' });
@@ -159,44 +131,44 @@ try {
159
131
  }
160
132
 
161
133
  // If the directory exists but we're not inside a skeleton, we should exit to prevent overwriting
162
- if (directoryExists && !isInsideSkeleton) {
134
+ if ( directoryExists && !isInsideSkeleton ) {
163
135
  throw new Error(`A directory named "${ appName }" already exists. Aborting.`);
164
136
  }
165
137
 
166
138
  // Create skeleton application if it doesn't exist
167
- if (!isInsideSkeleton && !skeletonExists) {
139
+ if ( !isInsideSkeleton && !skeletonExists ) {
168
140
  console.log(`Creating skeleton application: ${ appName }...`);
169
141
  // Pass all arguments to the app/init script
170
142
  execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
171
143
 
172
144
  // Ensure the skeleton path directory is created before attempting to change directory
173
- if (!fs.existsSync(skeletonPath)) {
145
+ if ( !fs.existsSync(skeletonPath) ) {
174
146
  throw new Error(`Failed to create skeleton application directory: ${ skeletonPath }`);
175
147
  }
176
148
 
177
149
  // Change working directory to the newly created skeleton app
178
150
  process.chdir(skeletonPath);
179
- } else if (isInsideSkeleton) {
151
+ } else if ( isInsideSkeleton ) {
180
152
  // If skeleton exists, ensure the working directory is set correctly
181
153
  process.chdir(skeletonPath);
182
154
  }
183
155
 
184
- if (skeletonOnly) {
156
+ if ( skeletonOnly ) {
185
157
  console.log('Skeleton application created successfully. No additional packages will be installed.');
186
158
  process.exit(0);
187
159
  }
188
160
 
189
- if (pkgExists) {
161
+ if ( pkgExists ) {
190
162
  throw new Error(`A package directory for "${ extensionName }" already exists.`);
191
163
  }
192
164
 
193
165
  // Check for package existence and create it if necessary
194
- if (!pkgExists) {
166
+ if ( !pkgExists ) {
195
167
  console.log(`Creating package: ${ extensionName }...`);
196
168
  execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
197
169
  }
198
170
 
199
- if (args.includes('--update') || args.includes('-u')) {
171
+ if ( args.includes('--update') || args.includes('-u') ) {
200
172
  // Run the update script
201
173
  console.log('Updating applications...');
202
174
  execSync(`node ${ path.join(updatePath, 'init') } ${ extensionName }`, { stdio: 'inherit' });
@@ -204,7 +176,7 @@ try {
204
176
 
205
177
  console.log('Extension created successfully.');
206
178
 
207
- if (skeletonOnly || !isInsideSkeleton) {
179
+ if ( skeletonOnly || !isInsideSkeleton ) {
208
180
  console.log(`To begin, run: \n\n\tcd ${ appName } && yarn install\n`);
209
181
  }
210
182
  } catch (error) {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@rancher/create-extension",
3
3
  "description": "Rancher UI Extension generator",
4
- "version": "1.0.0-rc.2",
4
+ "version": "1.0.1",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SUSE",
7
- "packageManager": "yarn@4.5.0",
7
+ "packageManager": "yarn@4.4.1",
8
8
  "bin": {
9
9
  "create-extension": "./init"
10
10
  },
@@ -13,19 +13,15 @@
13
13
  "init"
14
14
  ],
15
15
  "engines": {
16
- "node": ">=20"
16
+ "node": ">=16"
17
17
  },
18
18
  "dependencies": {
19
- "diff": "^7.0.0",
20
- "fs-extra": "^10.0.0",
21
- "glob": "^11.0.0",
22
- "path": "^0.12.7",
23
- "semver": "^7.6.3"
19
+ "fs-extra": "^10.0.0"
24
20
  },
25
21
  "_pkgs": {
26
- "core-js": "3.25.3",
22
+ "core-js": "3.21.1",
27
23
  "css-loader": "6.7.3",
28
24
  "@types/lodash": "4.14.184",
29
- "@rancher/components": "0.3.0-alpha.1"
25
+ "@rancher/components": "0.1.3"
30
26
  }
31
27
  }
package/pkg/init CHANGED
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
2
 
4
- const { execSync } = require('child_process');
5
3
  const fs = require('fs-extra');
6
4
  const path = require('path');
7
5
  const https = require('https');
8
6
 
7
+ const targets = {
8
+ dev: './node_modules/.bin/nuxt dev',
9
+ nuxt: './node_modules/.bin/nuxt',
10
+ };
11
+
9
12
  const files = [
10
13
  'tsconfig.json',
11
14
  'vue.config.js',
@@ -33,21 +36,28 @@ console.log('Creating Skeleton UI Package');
33
36
 
34
37
  const args = process.argv;
35
38
 
39
+ if (args.length !== 3) {
40
+ console.log('Expected single argument of package name');
41
+ }
42
+
36
43
  const name = args[2];
37
44
  const folder = path.resolve('.');
38
45
  const pkgFolder = path.join(folder, 'pkg', name);
39
46
  let shellVersion = '';
40
47
 
41
- let addTypeFolders = true;
48
+ let addTypeFolders = false;
49
+ let addWorkflowFolder = false;
42
50
 
43
51
  if ( args.length >= 3 ) {
44
52
  shellVersion = args[3];
45
53
 
46
54
  for ( let i = 3; i < args.length; i++ ) {
47
55
  switch (args[i]) {
48
- case '--skip-templates':
49
56
  case '-t':
50
- addTypeFolders = false;
57
+ addTypeFolders = true;
58
+ break;
59
+ case '-w':
60
+ addWorkflowFolder = true;
51
61
  break;
52
62
  default:
53
63
  break;
@@ -76,70 +86,19 @@ const pkg = JSON.parse(rawdata);
76
86
  pkg.name = name;
77
87
  pkg.description = `${ name } plugin`;
78
88
 
79
- // Add annotation for the latest Rancher version by default
80
- function fetchLatestVersion() {
81
- console.log(' Fetching latest Rancher Version');
82
- const options = { headers: { 'User-Agent': 'nodejs' } };
83
-
84
- https.get('https://api.github.com/repos/rancher/rancher/releases/latest', options, (res) => {
85
- const { statusCode } = res;
86
- const contentType = res.headers['content-type'];
87
-
88
- let error;
89
-
90
- if ( statusCode !== 200 ) {
91
- error = new Error(' Request Failed.\n' +
92
- ` Status Code: ${ statusCode }`);
93
- } else if ( !/^application\/json/.test(contentType) ) {
94
- error = new Error(' Invalid content-type.\n' +
95
- ` Expected application/json but received ${ contentType }`);
96
- }
97
-
98
- if ( error ) {
99
- console.log(error.message);
100
-
101
- res.resume();
102
-
103
- return;
104
- }
105
-
106
- res.setEncoding('utf8');
107
- let rawData = '';
108
-
109
- res.on('data', (chunk) => {
110
- rawData += chunk;
111
- });
112
- res.on('end', () => {
113
- try {
114
- const release = JSON.parse(rawData);
115
-
116
- if ( release.tag_name ) {
117
- console.log(` Adding rancher-version annotation '>= ${ release.tag_name }' to package.json`);
118
-
119
- pkg.rancher = { annotations: { 'catalog.cattle.io/rancher-version': `>= ${ release.tag_name }` } };
120
-
121
- if ( !shellVersion ) {
122
- console.log('Could not get a shell version from npm, skipping adding catalog.cattle.io/ui-extensions-version annotation to package.json');
123
- } else {
124
- console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ shellVersion }' to package.json`);
125
-
126
- pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ shellVersion }`;
127
- }
128
-
129
- writePackageJson();
130
- }
131
- } catch (e) {
132
- console.log(' Error parsing release data', e);
133
- }
134
- });
135
- }).on('error', (e) => {
136
- console.log(' Error fetching latest Rancher Version', e);
137
- });
138
- }
89
+ Object.keys(targets).forEach((target) => {
90
+ if (!pkg.scripts[target]) {
91
+ pkg.scripts[target] = targets[target];
92
+ console.log(` Adding script '${ target }' to package.json`);
93
+ }
94
+ });
139
95
 
140
- fetchLatestVersion();
141
96
  writePackageJson();
142
97
 
98
+ // Add dependencies
99
+ // pkg.dependencies['@rancher/shell'] = '^0.6.2';
100
+ // pkg.dependencies['core-js'] = '3.18.3';
101
+
143
102
  function writePackageJson() {
144
103
  fs.writeFileSync(path.join(pkgFolder, 'package.json'), JSON.stringify(pkg, null, 2));
145
104
  }
@@ -156,6 +115,31 @@ if (addTypeFolders) {
156
115
  });
157
116
  }
158
117
 
118
+ // Add workflow folder if needed
119
+ if (addWorkflowFolder) {
120
+ const workflowDir = path.join(folder, '.github/workflows');
121
+
122
+ if (!fs.existsSync(workflowDir)) {
123
+ fs.mkdirSync(workflowDir, { recursive: true });
124
+ }
125
+
126
+ const files = [
127
+ 'build-extension-catalog.yml',
128
+ 'build-extension-charts.yml'
129
+ ];
130
+
131
+ files.forEach((fileName) => {
132
+ const file = path.join(workflowDir, fileName);
133
+
134
+ if (!fs.existsSync(file)) {
135
+ const src = path.join(__dirname, 'files/.github/workflows', fileName);
136
+
137
+ console.log(` Adding file ${ fileName } to root workflows`);
138
+ fs.copySync(src, file);
139
+ }
140
+ });
141
+ }
142
+
159
143
  // Copy base files
160
144
  files.forEach((file) => {
161
145
  const src = path.join(__dirname, 'files', file);
@@ -167,6 +151,13 @@ files.forEach((file) => {
167
151
  }
168
152
  });
169
153
 
154
+ // require("child_process").spawn('yarn', ['install'], {
155
+ // cwd: process.cwd(),
156
+ // stdio: "inherit"
157
+ // });
158
+
159
+ // Update tsconfig
160
+
170
161
  const topLevelRawdata = fs.readFileSync(path.join(folder, 'package.json'));
171
162
  const topLevelPkg = JSON.parse(topLevelRawdata);
172
163
  let updated = false;
@@ -211,5 +202,3 @@ function updateArray(data) {
211
202
 
212
203
  return updated;
213
204
  }
214
-
215
- /* eslint-enable no-console */
package/pkg/package.json CHANGED
@@ -10,8 +10,14 @@
10
10
  "**/*.*",
11
11
  "init"
12
12
  ],
13
+ "rancher": {
14
+ "annotations": {
15
+ "catalog.cattle.io/rancher-version": "< 2.9.0",
16
+ "catalog.cattle.io/ui-extensions-version": "< 3.0.0"
17
+ }
18
+ },
13
19
  "engines": {
14
- "node": ">=20.0.0"
20
+ "node": ">=16.0.0"
15
21
  },
16
22
  "resolutions": {
17
23
  "d3-color": "3.1.0",
package/update/init CHANGED
@@ -4,18 +4,17 @@ const path = require('path');
4
4
  const fs = require('fs-extra');
5
5
  const { spawnSync } = require('child_process');
6
6
 
7
- const scriptFolder = path.resolve(__dirname, '..');
7
+ const scriptFolder = __dirname;
8
8
  const dest = path.resolve('.');
9
9
 
10
10
  // Remove first two args
11
- const args = process.argv;
12
-
11
+ let args = process.argv;
13
12
  args.splice(0, 2);
14
13
 
15
- const res = spawnSync(path.join(__dirname, 'upgrade'), args, {
16
- cwd: dest,
14
+ const res = spawnSync(`${__dirname}/upgrade`, args, {
15
+ cwd: dest,
17
16
  shell: false,
18
- stdio: ['ignore', process.stdout, process.stderr],
17
+ stdio: [ 'ignore', process.stdout, process.stderr ],
19
18
  });
20
19
 
21
20
  if (res.status !== 0) {
@@ -35,13 +34,9 @@ rawdata = fs.readFileSync(path.join(scriptFolder, 'package.json'));
35
34
  const upgradePackage = JSON.parse(rawdata);
36
35
 
37
36
  // Update dependency versions to match the latest from the creator
38
- if ( latestPackage.dependencies ) {
39
- Object.keys(latestPackage.dependencies).forEach((key) => {
40
- appPackage.dependencies[key] = latestPackage.dependencies[key];
41
- });
42
- } else {
43
- console.warn('No dependencies found in latestPackage.'); // eslint-disable-line no-console
44
- }
37
+ Object.keys(latestPackage._pkgs).forEach((key) => {
38
+ appPackage.dependencies[key] = latestPackage._pkgs[key];
39
+ });
45
40
 
46
41
  // Add in the webpack resolution
47
42
  appPackage.resolutions = appPackage.resolutions || {};
@@ -52,10 +47,10 @@ const shellVersion = upgradePackage.version;
52
47
 
53
48
  appPackage.dependencies['@rancher/shell'] = shellVersion;
54
49
 
55
- fs.writeFileSync(path.join(dest, 'package.json'), `${ JSON.stringify(appPackage, null, 2) }\n`);
50
+ fs.writeFileSync(path.join(dest, 'package.json'), JSON.stringify(appPackage, null, 2) + '\n');
56
51
 
57
52
  spawnSync(`yarn`, ['install'], {
58
- cwd: dest,
53
+ cwd: dest,
59
54
  shell: false,
60
- stdio: ['ignore', process.stdout, process.stderr],
55
+ stdio: [ 'ignore', process.stdout, process.stderr ],
61
56
  });
@@ -12,7 +12,7 @@
12
12
  "upgrade"
13
13
  ],
14
14
  "engines": {
15
- "node": ">=20.0.0"
15
+ "node": ">=16.0.0"
16
16
  },
17
17
  "dependencies": {
18
18
  "fs-extra": "^10.0.0"