@rancher/create-extension 2.0.2 → 2.0.4

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.
@@ -5,26 +5,9 @@
5
5
  "engines": {
6
6
  "node": ">=16"
7
7
  },
8
- "dependencies": {
9
- "cache-loader": "^4.1.0",
10
- "color": "4.2.3",
11
- "ip": "2.0.1",
12
- "node-polyfill-webpack-plugin": "^3.0.0"
13
- },
8
+ "dependencies": {},
14
9
  "resolutions": {
15
- "d3-color": "3.1.0",
16
- "ejs": "3.1.9",
17
- "follow-redirects": "1.15.2",
18
- "glob": "7.2.3",
19
- "glob-parent": "6.0.2",
20
- "json5": "2.2.3",
21
- "@types/lodash": "4.17.5",
22
- "merge": "2.1.1",
23
- "node-forge": "1.3.1",
24
- "nth-check": "2.1.1",
25
- "qs": "6.11.1",
26
- "roarr": "7.0.4",
27
- "semver": "7.5.4",
28
- "@vue/cli-service/html-webpack-plugin": "^5.0.0"
10
+ "@types/node": "18.11.9",
11
+ "@types/lodash": "4.17.5"
29
12
  }
30
13
  }
package/app/init CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable no-console */
2
3
 
3
4
  const path = require('path');
4
5
  const fs = require('fs-extra');
@@ -38,6 +39,7 @@ if (args.length >= 3 && !args[2].includes('@rancher/create-extension/app/init'))
38
39
  }
39
40
 
40
41
  let addGitlabWorkflow = false;
42
+ let addWorkflowFolder = true;
41
43
 
42
44
  // Check for Gitlab integration option
43
45
  if ( args.length >= 3 ) {
@@ -48,6 +50,10 @@ if ( args.length >= 3 ) {
48
50
  case '-l':
49
51
  addGitlabWorkflow = true;
50
52
  break;
53
+ case '--skip-workflow':
54
+ case '-w':
55
+ addWorkflowFolder = false;
56
+ break;
51
57
  default:
52
58
  break;
53
59
  }
@@ -58,10 +64,9 @@ if ( addGitlabWorkflow ) {
58
64
  files.push('.gitlab-ci.yml');
59
65
  }
60
66
 
61
- // Check that there is a package file
62
-
63
67
  let setName = false;
64
68
 
69
+ // Check that there is a package file
65
70
  if (!fs.existsSync(path.join(appFolder, './package.json'))) {
66
71
  console.log(' Adding package.json');
67
72
  fs.copySync(path.join(__dirname, 'app.package.json'), path.join(appFolder, 'package.json'));
@@ -106,6 +111,32 @@ if (creatorPkg._pkgs) {
106
111
 
107
112
  fs.writeFileSync(path.join(appFolder, 'package.json'), JSON.stringify(pkg, null, 2));
108
113
 
114
+ // Add workflow folder if needed
115
+ if ( addWorkflowFolder ) {
116
+ // Point to the workflow directory inside the skeleton application
117
+ const workflowDir = path.join(appFolder, '.github/workflows');
118
+
119
+ if ( !fs.existsSync(workflowDir) ) {
120
+ console.log(' Creating folder: .github/workflows');
121
+ fs.mkdirSync(workflowDir, { recursive: true });
122
+ }
123
+
124
+ const workflowFiles = [
125
+ 'build-extension-catalog.yml',
126
+ 'build-extension-charts.yml'
127
+ ];
128
+
129
+ workflowFiles.forEach((fileName) => {
130
+ const dest = path.join(workflowDir, fileName); // Destination in the skeleton application
131
+ const src = path.join(__dirname, 'files/.github/workflows', fileName); // Source in the package
132
+
133
+ if ( !fs.existsSync(dest) ) {
134
+ console.log(` Adding file ${ fileName } to root workflows`);
135
+ fs.copySync(src, dest);
136
+ }
137
+ });
138
+ }
139
+
109
140
  // Copy base files
110
141
  files.forEach((file) => {
111
142
  const destinationFile = file === 'gitignore' ? '.gitignore' : file;
@@ -115,7 +146,7 @@ files.forEach((file) => {
115
146
  if (!fs.existsSync(dest)) {
116
147
  console.log(` Adding file: ${ file }`);
117
148
 
118
- const folder = path.dirname(file);
149
+ const folder = path.dirname(dest);
119
150
 
120
151
  fs.ensureDirSync(folder);
121
152
 
@@ -124,4 +155,6 @@ files.forEach((file) => {
124
155
  }
125
156
  });
126
157
 
127
- console.log('');
158
+ console.log('Skeleton Application creation complete.\n');
159
+
160
+ /* eslint-enable no-console */
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": "2.0.2",
4
+ "version": "2.0.4",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SUSE",
7
- "packageManager": "yarn@4.4.1",
7
+ "packageManager": "yarn@4.5.0",
8
8
  "bin": {
9
9
  "create-extension": "init"
10
10
  },
package/pkg/init CHANGED
@@ -1,13 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable no-console */
2
3
 
3
4
  const fs = require('fs-extra');
4
5
  const path = require('path');
5
6
 
6
- const targets = {
7
- dev: './node_modules/.bin/nuxt dev',
8
- nuxt: './node_modules/.bin/nuxt',
9
- };
10
-
11
7
  const files = [
12
8
  'tsconfig.json',
13
9
  'vue.config.js',
@@ -30,36 +26,23 @@ const typeFolders = [
30
26
  'detail'
31
27
  ];
32
28
 
33
- const shellPkgPath = 'node_modules/@rancher/shell';
34
-
35
29
  console.log('');
36
30
  console.log('Creating Skeleton UI Package');
37
31
 
38
32
  const args = process.argv;
39
33
 
40
- if (args.length !== 3) {
41
- console.log('Expected single argument of package name');
42
- }
43
-
44
34
  const name = args[2];
45
35
  const folder = path.resolve('.');
46
36
  const pkgFolder = path.join(folder, 'pkg', name);
47
37
 
48
- let addTypeFolders = false;
49
- let addWorkflowFolder = false;
50
- let ignoreShellPkgPathCheck = false;
38
+ let addTypeFolders = true;
51
39
 
52
40
  if ( args.length >= 3 ) {
53
41
  for ( let i = 3; i < args.length; i++ ) {
54
42
  switch (args[i]) {
43
+ case '--skip-templates':
55
44
  case '-t':
56
- addTypeFolders = true;
57
- break;
58
- case '-w':
59
- addWorkflowFolder = true;
60
- break;
61
- case '-i':
62
- ignoreShellPkgPathCheck = true;
45
+ addTypeFolders = false;
63
46
  break;
64
47
  default:
65
48
  break;
@@ -67,12 +50,6 @@ if ( args.length >= 3 ) {
67
50
  }
68
51
  }
69
52
 
70
- if (!ignoreShellPkgPathCheck && !fs.existsSync(path.join(pkgFolder, `../../${ shellPkgPath }/package.json`))) {
71
- console.log('');
72
- console.log('@rancher/shell not found in node_modules! Please do "yarn install" and make sure you run this command from the base folder of your app');
73
- process.exit(1);
74
- }
75
-
76
53
  const isNodeModulesShell = !fs.existsSync(path.join(folder, 'shell'));
77
54
 
78
55
  if (!isNodeModulesShell) {
@@ -94,19 +71,8 @@ const pkg = JSON.parse(rawdata);
94
71
  pkg.name = name;
95
72
  pkg.description = `${ name } plugin`;
96
73
 
97
- Object.keys(targets).forEach((target) => {
98
- if (!pkg.scripts[target]) {
99
- pkg.scripts[target] = targets[target];
100
- console.log(` Adding script '${ target }' to package.json`);
101
- }
102
- });
103
-
104
74
  writePackageJson();
105
75
 
106
- // Add dependencies
107
- // pkg.dependencies['@rancher/shell'] = '^0.6.2';
108
- // pkg.dependencies['core-js'] = '3.18.3';
109
-
110
76
  function writePackageJson() {
111
77
  fs.writeFileSync(path.join(pkgFolder, 'package.json'), JSON.stringify(pkg, null, 2));
112
78
  }
@@ -123,31 +89,6 @@ if (addTypeFolders) {
123
89
  });
124
90
  }
125
91
 
126
- // Add workflow folder if needed
127
- if (addWorkflowFolder) {
128
- const workflowDir = path.join(folder, '.github/workflows');
129
-
130
- if (!fs.existsSync(workflowDir)) {
131
- fs.mkdirSync(workflowDir, { recursive: true });
132
- }
133
-
134
- const files = [
135
- 'build-extension-catalog.yml',
136
- 'build-extension-charts.yml'
137
- ];
138
-
139
- files.forEach((fileName) => {
140
- const file = path.join(workflowDir, fileName);
141
-
142
- if (!fs.existsSync(file)) {
143
- const src = path.join(__dirname, 'files/.github/workflows', fileName);
144
-
145
- console.log(` Adding file ${ fileName } to root workflows`);
146
- fs.copySync(src, file);
147
- }
148
- });
149
- }
150
-
151
92
  // Copy base files
152
93
  files.forEach((file) => {
153
94
  const src = path.join(__dirname, 'files', file);
@@ -159,13 +100,6 @@ files.forEach((file) => {
159
100
  }
160
101
  });
161
102
 
162
- // require("child_process").spawn('yarn', ['install'], {
163
- // cwd: process.cwd(),
164
- // stdio: "inherit"
165
- // });
166
-
167
- // Update tsconfig
168
-
169
103
  const topLevelRawdata = fs.readFileSync(path.join(folder, 'package.json'));
170
104
  const topLevelPkg = JSON.parse(topLevelRawdata);
171
105
  let updated = false;
@@ -210,3 +144,5 @@ function updateArray(data) {
210
144
 
211
145
  return updated;
212
146
  }
147
+
148
+ /* eslint-enable no-console */
package/pkg/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
  "dependencies": {
17
17
  "fs-extra": "^10.0.0"
package/update/init CHANGED
@@ -12,7 +12,7 @@ const args = process.argv;
12
12
 
13
13
  args.splice(0, 2);
14
14
 
15
- const res = spawnSync(`${ __dirname }/upgrade`, args, {
15
+ const res = spawnSync(path.join(__dirname, 'upgrade'), args, {
16
16
  cwd: dest,
17
17
  shell: false,
18
18
  stdio: ['ignore', process.stdout, process.stderr],
@@ -31,9 +31,13 @@ rawdata = fs.readFileSync(path.join(baseFolder, 'app', 'package.json'));
31
31
  const latestPackage = JSON.parse(rawdata);
32
32
 
33
33
  // Update dependency versions to match the latest from the creator
34
- Object.keys(latestPackage._pkgs).forEach((key) => {
35
- appPackage.dependencies[key] = latestPackage._pkgs[key];
36
- });
34
+ if ( latestPackage.dependencies ) {
35
+ Object.keys(latestPackage.dependencies).forEach((key) => {
36
+ appPackage.dependencies[key] = latestPackage.dependencies[key];
37
+ });
38
+ } else {
39
+ console.warn('No dependencies found in latestPackage.'); // eslint-disable-line no-console
40
+ }
37
41
 
38
42
  // Add in the webpack resolution
39
43
  appPackage.resolutions = appPackage.resolutions || {};
package/update/upgrade CHANGED
@@ -20,13 +20,13 @@ done
20
20
  # Check for a clean git repository
21
21
  if [ ! -d ".git" ] && [ "${FORCE}" == "false" ]; then
22
22
  echo "Not runnning in a git repository. Re-run with -f to ignore this check"
23
- echo "Note: This action will update yuor files - running in a git repsository will ensure you have visibility over changes made"
23
+ echo "Note: This action will update your files - running in a git repository will ensure you have visibility over changes made"
24
24
  exit 1
25
25
  fi
26
26
 
27
27
  if [[ $(git diff --stat) != '' ]] && [ "${FORCE}" == "false" ]; then
28
28
  echo "Git repository is not clean. Re-run with -f to ignore this check"
29
- echo "Note: This action will update yuor files - running in a clean git repsository will ensure you have visibility over changes made"
29
+ echo "Note: This action will update your files - running in a clean git repository will ensure you have visibility over changes made"
30
30
  exit 1
31
31
  fi
32
32
 
@@ -54,4 +54,4 @@ do
54
54
 
55
55
  cp ${BASE_DIR}/pkg/files/* ${pkg}
56
56
  fi
57
- done
57
+ done