@rancher/create-extension 3.0.1 → 3.0.2

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
+ 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 ( args.length > 2 ) {
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
- execSync(`node ${ path.join(updatePath, 'init') }`, { stdio: 'inherit' });
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
- execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
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
- execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
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
- execSync(`node ${ path.join(updatePath, 'init') } ${ extensionName }`, { stdio: 'inherit' });
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@rancher/create-extension",
3
3
  "description": "Rancher UI Extension generator",
4
- "version": "3.0.1",
4
+ "version": "3.0.2",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SUSE",
7
7
  "packageManager": "yarn@4.5.0",
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/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 scriptFolder = path.resolve(__dirname, '..');
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(scriptFolder, 'app', 'package.json'));
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 = upgradePackage.version;
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]}" )"/.. &> /dev/null && pwd )
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 ${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