@rancher/create-extension 1.0.1 → 1.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.
@@ -0,0 +1 @@
1
+ 16
package/app/init CHANGED
@@ -15,6 +15,7 @@ const files = [
15
15
  'gitignore',
16
16
  '.eslintignore',
17
17
  '.eslintrc.js',
18
+ '.nvmrc',
18
19
  '.yarnrc.yml',
19
20
  'babel.config.js',
20
21
  '.vscode/settings.json'
@@ -27,7 +28,7 @@ const args = process.argv;
27
28
  let appFolder = path.resolve('.');
28
29
  let shellVersion = '';
29
30
 
30
- if (args.length === 3) {
31
+ if (args.length >= 3 && !args[2].includes('@rancher/create-extension/app/init')) {
31
32
  const name = args[2];
32
33
  const folder = path.resolve('.');
33
34
 
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');
@@ -124,7 +124,14 @@ try {
124
124
  if ( updateOnly ) {
125
125
  // Run the update script directly
126
126
  console.log('Updating applications...');
127
- execSync(`node ${ path.join(updatePath, 'init') }`, { stdio: 'inherit' });
127
+ const updateInitPath = path.join(updatePath, 'init');
128
+ const updateArgs = [updateInitPath, shellVersion, tagUsed, ...args];
129
+
130
+ const result = spawnSync('node', updateArgs, { stdio: 'inherit' });
131
+
132
+ if (result.status !== 0) {
133
+ throw new Error('Failed to create skeleton application.');
134
+ }
128
135
 
129
136
  console.log('Update completed successfully.');
130
137
  process.exit(0);
@@ -139,7 +146,14 @@ try {
139
146
  if ( !isInsideSkeleton && !skeletonExists ) {
140
147
  console.log(`Creating skeleton application: ${ appName }...`);
141
148
  // Pass all arguments to the app/init script
142
- execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
149
+ const appInitPath = path.join(__dirname, 'app', 'init');
150
+ const appArgs = [appInitPath, appName, shellVersion, ...args];
151
+
152
+ const result = spawnSync('node', appArgs, { stdio: 'inherit' });
153
+
154
+ if (result.status !== 0) {
155
+ throw new Error('Failed to create skeleton application.');
156
+ }
143
157
 
144
158
  // Ensure the skeleton path directory is created before attempting to change directory
145
159
  if ( !fs.existsSync(skeletonPath) ) {
@@ -165,16 +179,30 @@ try {
165
179
  // Check for package existence and create it if necessary
166
180
  if ( !pkgExists ) {
167
181
  console.log(`Creating package: ${ extensionName }...`);
168
- execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
182
+ const pkgInitPath = path.join(__dirname, 'pkg', 'init');
183
+ const pkgArgs = [pkgInitPath, extensionName, shellVersion, ...args];
184
+
185
+ const result = spawnSync('node', pkgArgs, { stdio: 'inherit' });
186
+
187
+ if (result.status !== 0) {
188
+ throw new Error('Failed to create package.');
189
+ }
169
190
  }
170
191
 
171
192
  if ( args.includes('--update') || args.includes('-u') ) {
172
193
  // Run the update script
173
194
  console.log('Updating applications...');
174
- execSync(`node ${ path.join(updatePath, 'init') } ${ extensionName }`, { stdio: 'inherit' });
195
+ const updatePath = path.join(__dirname, 'update');
196
+ const updateArgs = [updatePath, ...args];
197
+
198
+ const result = spawnSync('node', updateArgs, { stdio: 'inherit' });
199
+
200
+ if (result.status !== 0) {
201
+ throw new Error('Failed to update applications.');
202
+ }
175
203
  }
176
204
 
177
- console.log('Extension created successfully.');
205
+ // console.log('Extension created successfully.');
178
206
 
179
207
  if ( skeletonOnly || !isInsideSkeleton ) {
180
208
  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": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SUSE",
7
7
  "packageManager": "yarn@4.4.1",
8
8
  "bin": {
9
- "create-extension": "./init"
9
+ "create-extension": "init"
10
10
  },
11
11
  "files": [
12
12
  "**/*",
package/pkg/init CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
5
- const https = require('https');
6
5
 
7
6
  const targets = {
8
7
  dev: './node_modules/.bin/nuxt dev',
@@ -43,14 +42,11 @@ if (args.length !== 3) {
43
42
  const name = args[2];
44
43
  const folder = path.resolve('.');
45
44
  const pkgFolder = path.join(folder, 'pkg', name);
46
- let shellVersion = '';
47
45
 
48
46
  let addTypeFolders = false;
49
47
  let addWorkflowFolder = false;
50
48
 
51
49
  if ( args.length >= 3 ) {
52
- shellVersion = args[3];
53
-
54
50
  for ( let i = 3; i < args.length; i++ ) {
55
51
  switch (args[i]) {
56
52
  case '-t':
package/pkg/package.json CHANGED
@@ -10,30 +10,8 @@
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
- },
19
13
  "engines": {
20
- "node": ">=16.0.0"
21
- },
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"
14
+ "node": ">=20.0.0"
37
15
  },
38
16
  "dependencies": {
39
17
  "fs-extra": "^10.0.0"
@@ -3,7 +3,12 @@
3
3
  "description": "NAME plugin",
4
4
  "version": "0.1.0",
5
5
  "private": false,
6
- "rancher": true,
6
+ "rancher": {
7
+ "annotations": {
8
+ "catalog.cattle.io/rancher-version": "< 2.9.0",
9
+ "catalog.cattle.io/ui-extensions-version": "< 3.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,17 +4,18 @@ const path = require('path');
4
4
  const fs = require('fs-extra');
5
5
  const { spawnSync } = require('child_process');
6
6
 
7
- const scriptFolder = __dirname;
7
+ const baseFolder = path.resolve(path.join(__dirname, '..'));
8
8
  const dest = path.resolve('.');
9
9
 
10
10
  // Remove first two args
11
- let args = process.argv;
11
+ const args = process.argv;
12
+
12
13
  args.splice(0, 2);
13
14
 
14
- const res = spawnSync(`${__dirname}/upgrade`, args, {
15
- cwd: dest,
15
+ const res = spawnSync(`${ __dirname }/upgrade`, args, {
16
+ cwd: dest,
16
17
  shell: false,
17
- stdio: [ 'ignore', process.stdout, process.stderr ],
18
+ stdio: ['ignore', process.stdout, process.stderr],
18
19
  });
19
20
 
20
21
  if (res.status !== 0) {
@@ -26,13 +27,9 @@ let rawdata = fs.readFileSync(path.join(dest, 'package.json'));
26
27
  const appPackage = JSON.parse(rawdata);
27
28
 
28
29
  // Read the package.json from the app creator
29
- rawdata = fs.readFileSync(path.join(scriptFolder, 'app', 'package.json'));
30
+ rawdata = fs.readFileSync(path.join(baseFolder, 'app', 'package.json'));
30
31
  const latestPackage = JSON.parse(rawdata);
31
32
 
32
- // Read the package.json from the upgrade creator
33
- rawdata = fs.readFileSync(path.join(scriptFolder, 'package.json'));
34
- const upgradePackage = JSON.parse(rawdata);
35
-
36
33
  // Update dependency versions to match the latest from the creator
37
34
  Object.keys(latestPackage._pkgs).forEach((key) => {
38
35
  appPackage.dependencies[key] = latestPackage._pkgs[key];
@@ -43,14 +40,14 @@ appPackage.resolutions = appPackage.resolutions || {};
43
40
  appPackage.resolutions['**/webpack'] = '4';
44
41
 
45
42
  // Update the version of @rancher/shell
46
- const shellVersion = upgradePackage.version;
43
+ const shellVersion = args[0];
47
44
 
48
45
  appPackage.dependencies['@rancher/shell'] = shellVersion;
49
46
 
50
- fs.writeFileSync(path.join(dest, 'package.json'), JSON.stringify(appPackage, null, 2) + '\n');
47
+ fs.writeFileSync(path.join(dest, 'package.json'), `${ JSON.stringify(appPackage, null, 2) }\n`);
51
48
 
52
49
  spawnSync(`yarn`, ['install'], {
53
- cwd: dest,
50
+ cwd: dest,
54
51
  shell: false,
55
- stdio: [ 'ignore', process.stdout, process.stderr ],
52
+ stdio: ['ignore', process.stdout, process.stderr],
56
53
  });
package/update/upgrade CHANGED
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env sh
2
2
 
3
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=$(node -p -e "require('${SCRIPT_DIR}/package.json').version")
9
-
9
+ VERSION=$1
10
10
  echo "Updating to version: ${VERSION}"
11
- echo ""
12
11
 
13
12
  FORCE="false"
14
13
 
15
- if [ "$1" == "-f" ]; then
16
- FORCE="true"
17
- fi
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 --exclude nuxt.config.js ${SCRIPT_DIR}/app/files/* .
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 ${SCRIPT_DIR}/pkg/files/* ${pkg}
55
+ cp ${BASE_DIR}/pkg/files/* ${pkg}
55
56
  fi
56
57
  done