@rancher/create-extension 0.1.0 → 0.1.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,12 +3,28 @@
3
3
  "version": "0.1.0",
4
4
  "private": false,
5
5
  "engines": {
6
- "node": ">=12"
6
+ "node": ">=16"
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"
7
13
  },
8
- "dependencies": {},
9
14
  "resolutions": {
10
- "**/webpack": "4",
11
- "@types/node": "^16",
12
- "glob": "7.2.3"
13
- }
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"
29
+ }
14
30
  }
@@ -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
@@ -4,17 +4,19 @@ module.exports = {
4
4
  browser: true,
5
5
  node: true
6
6
  },
7
- globals: { NodeJS: true, Timer: true },
7
+ globals: {
8
+ NodeJS: true,
9
+ Timer: true
10
+ },
8
11
  extends: [
9
12
  'standard',
10
13
  'eslint:recommended',
11
14
  'plugin:@typescript-eslint/recommended',
12
15
  '@vue/standard',
13
16
  '@vue/typescript/recommended',
14
- 'plugin:vue/recommended',
15
- 'plugin:cypress/recommended',
17
+ 'plugin:vue/vue3-recommended',
18
+ 'plugin:cypress/recommended'
16
19
  ],
17
- // add your custom rules here
18
20
  rules: {
19
21
  'dot-notation': 'off',
20
22
  'generator-star-spacing': 'off',
@@ -34,141 +36,207 @@ module.exports = {
34
36
  'vue/no-unused-components': 'warn',
35
37
  'vue/no-v-html': 'error',
36
38
  'wrap-iife': 'off',
37
-
38
- 'array-bracket-spacing': 'warn',
39
- 'arrow-parens': 'warn',
40
- 'arrow-spacing': ['warn', { before: true, after: true }],
41
- 'block-spacing': ['warn', 'always'],
42
- 'brace-style': ['warn', '1tbs'],
43
- 'comma-dangle': ['warn', 'only-multiline'],
44
- 'comma-spacing': 'warn',
45
- curly: 'warn',
46
- eqeqeq: 'warn',
47
- 'func-call-spacing': ['warn', 'never'],
48
- 'implicit-arrow-linebreak': 'warn',
49
- indent: ['warn', 2],
50
- 'keyword-spacing': 'warn',
51
- 'lines-between-class-members': ['warn', 'always', { exceptAfterSingleLine: true }],
52
- 'multiline-ternary': ['warn', 'never'],
53
- 'newline-per-chained-call': ['warn', { ignoreChainWithDepth: 4 }],
54
- 'no-caller': 'warn',
55
- 'no-cond-assign': ['warn', 'except-parens'],
56
- 'no-console': 'warn',
57
- 'no-debugger': 'warn',
58
- 'no-eq-null': 'warn',
59
- 'no-eval': 'warn',
60
- 'no-trailing-spaces': 'warn',
61
- 'no-undef': 'warn',
62
- 'no-unused-vars': 'warn',
63
- 'no-whitespace-before-property': 'warn',
64
- 'object-curly-spacing': ['warn', 'always'],
65
- 'object-property-newline': 'warn',
66
- 'object-shorthand': 'warn',
67
- 'padded-blocks': ['warn', 'never'],
68
- 'prefer-arrow-callback': 'warn',
69
- 'prefer-template': 'warn',
70
- 'quote-props': 'warn',
71
- 'rest-spread-spacing': 'warn',
72
- semi: ['warn', 'always'],
73
- 'space-before-function-paren': ['warn', 'never'],
74
- 'space-infix-ops': 'warn',
75
- 'spaced-comment': 'warn',
76
- 'switch-colon-spacing': 'warn',
77
- 'template-curly-spacing': ['warn', 'always'],
78
- 'yield-star-spacing': ['warn', 'both'],
79
-
80
- 'key-spacing': ['warn', {
81
- align: {
82
- beforeColon: false,
83
- afterColon: true,
84
- on: 'value',
85
- mode: 'minimum'
86
- },
87
- multiLine: {
88
- beforeColon: false,
89
- afterColon: true
90
- },
91
- }],
92
-
93
- 'object-curly-newline': ['warn', {
94
- ObjectExpression: {
95
- multiline: true,
96
- minProperties: 3
97
- },
98
- ObjectPattern: {
99
- multiline: true,
100
- minProperties: 4
101
- },
102
- ImportDeclaration: {
103
- multiline: true,
104
- minProperties: 5
105
- },
106
- ExportDeclaration: {
107
- multiline: true,
108
- minProperties: 3
39
+ 'array-bracket-spacing': 'warn',
40
+ 'arrow-parens': 'warn',
41
+ 'arrow-spacing': [
42
+ 'warn',
43
+ {
44
+ before: true,
45
+ after: true
109
46
  }
110
- }],
111
-
47
+ ],
48
+ 'block-spacing': [
49
+ 'warn',
50
+ 'always'
51
+ ],
52
+ 'brace-style': [
53
+ 'warn',
54
+ '1tbs'
55
+ ],
56
+ 'comma-dangle': [
57
+ 'warn',
58
+ 'only-multiline'
59
+ ],
60
+ 'comma-spacing': 'warn',
61
+ curly: 'warn',
62
+ eqeqeq: 'warn',
63
+ 'func-call-spacing': [
64
+ 'warn',
65
+ 'never'
66
+ ],
67
+ 'implicit-arrow-linebreak': 'warn',
68
+ indent: [
69
+ 'warn',
70
+ 2
71
+ ],
72
+ 'keyword-spacing': 'warn',
73
+ 'lines-between-class-members': [
74
+ 'warn',
75
+ 'always',
76
+ { exceptAfterSingleLine: true }
77
+ ],
78
+ 'multiline-ternary': [
79
+ 'warn',
80
+ 'never'
81
+ ],
82
+ 'newline-per-chained-call': [
83
+ 'warn',
84
+ { ignoreChainWithDepth: 4 }
85
+ ],
86
+ 'no-caller': 'warn',
87
+ 'no-cond-assign': [
88
+ 'warn',
89
+ 'except-parens'
90
+ ],
91
+ 'no-console': 'warn',
92
+ 'no-debugger': 'warn',
93
+ 'no-eq-null': 'warn',
94
+ 'no-eval': 'warn',
95
+ 'no-trailing-spaces': 'warn',
96
+ 'no-undef': 'warn',
97
+ 'no-unused-vars': 'warn',
98
+ 'no-whitespace-before-property': 'warn',
99
+ 'object-curly-spacing': [
100
+ 'warn',
101
+ 'always'
102
+ ],
103
+ 'object-property-newline': 'warn',
104
+ 'object-shorthand': 'warn',
105
+ 'padded-blocks': [
106
+ 'warn',
107
+ 'never'
108
+ ],
109
+ 'prefer-arrow-callback': 'warn',
110
+ 'prefer-template': 'warn',
111
+ 'quote-props': 'warn',
112
+ 'rest-spread-spacing': 'warn',
113
+ semi: [
114
+ 'warn',
115
+ 'always'
116
+ ],
117
+ 'space-before-function-paren': [
118
+ 'warn',
119
+ 'never'
120
+ ],
121
+ 'space-infix-ops': 'warn',
122
+ 'spaced-comment': 'warn',
123
+ 'switch-colon-spacing': 'warn',
124
+ 'template-curly-spacing': [
125
+ 'warn',
126
+ 'always'
127
+ ],
128
+ 'yield-star-spacing': [
129
+ 'warn',
130
+ 'both'
131
+ ],
132
+ 'key-spacing': [
133
+ 'warn',
134
+ {
135
+ align: {
136
+ beforeColon: false,
137
+ afterColon: true,
138
+ on: 'value',
139
+ mode: 'minimum'
140
+ },
141
+ multiLine: {
142
+ beforeColon: false,
143
+ afterColon: true
144
+ }
145
+ }
146
+ ],
147
+ 'object-curly-newline': [
148
+ 'warn',
149
+ {
150
+ ObjectExpression: {
151
+ multiline: true,
152
+ minProperties: 3
153
+ },
154
+ ObjectPattern: {
155
+ multiline: true,
156
+ minProperties: 4
157
+ },
158
+ ImportDeclaration: {
159
+ multiline: true,
160
+ minProperties: 5
161
+ },
162
+ ExportDeclaration: {
163
+ multiline: true,
164
+ minProperties: 3
165
+ }
166
+ }
167
+ ],
112
168
  'padding-line-between-statements': [
113
169
  'warn',
114
170
  {
115
171
  blankLine: 'always',
116
172
  prev: '*',
117
- next: 'return',
173
+ next: 'return'
118
174
  },
119
175
  {
120
176
  blankLine: 'always',
121
177
  prev: 'function',
122
- next: 'function',
178
+ next: 'function'
123
179
  },
124
- // This configuration would require blank lines after every sequence of variable declarations
125
180
  {
126
181
  blankLine: 'always',
127
- prev: ['const', 'let', 'var'],
128
- next: '*'
182
+ prev: [
183
+ 'const',
184
+ 'let',
185
+ 'var'
186
+ ],
187
+ next: '*'
129
188
  },
130
189
  {
131
190
  blankLine: 'any',
132
- prev: ['const', 'let', 'var'],
133
- next: ['const', 'let', 'var']
191
+ prev: [
192
+ 'const',
193
+ 'let',
194
+ 'var'
195
+ ],
196
+ next: [
197
+ 'const',
198
+ 'let',
199
+ 'var'
200
+ ]
134
201
  }
135
202
  ],
136
-
137
203
  quotes: [
138
204
  'warn',
139
205
  'single',
140
206
  {
141
207
  avoidEscape: true,
142
208
  allowTemplateLiterals: true
143
- },
209
+ }
144
210
  ],
145
-
146
211
  'space-unary-ops': [
147
212
  'warn',
148
213
  {
149
214
  words: true,
150
- nonwords: false,
215
+ nonwords: false
151
216
  }
152
217
  ],
153
-
154
- // FIXME: The following is disabled due to new linter and old JS code. These should all be enabled and underlying issues fixed
155
- 'vue/order-in-components': 'off',
156
- 'vue/no-lone-template': 'off',
157
- 'vue/v-slot-style': 'off',
158
- 'vue/component-tags-order': 'off',
159
- 'vue/no-mutating-props': 'off',
160
- '@typescript-eslint/no-unused-vars': 'off',
161
- 'array-callback-return': 'off',
218
+ 'vue/order-in-components': 'off',
219
+ 'vue/no-lone-template': 'off',
220
+ 'vue/v-slot-style': 'off',
221
+ 'vue/component-tags-order': 'off',
222
+ 'vue/no-mutating-props': 'off',
223
+ '@typescript-eslint/no-unused-vars': 'off',
224
+ 'array-callback-return': 'off',
225
+ 'vue/one-component-per-file': 'off',
226
+ 'vue/no-deprecated-slot-attribute': 'off',
227
+ 'vue/require-explicit-emits': 'off',
228
+ 'vue/v-on-event-hyphenation': 'off'
162
229
  },
163
230
  overrides: [
164
231
  {
165
- files: ['*.js'],
232
+ files: [
233
+ '*.js'
234
+ ],
166
235
  rules: {
167
- // FIXME: The following is disabled due to new linter and old JS code. These should all be enabled and underlying issues fixed
168
236
  'prefer-regex-literals': 'off',
169
237
  'vue/component-definition-name-casing': 'off',
170
238
  'no-unreachable-loop': 'off',
171
- 'computed-property-spacing': 'off',
239
+ 'computed-property-spacing': 'off'
172
240
  }
173
241
  }
174
242
  ]
@@ -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,8 +2,12 @@ name: Build and Release Extension Charts
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:
@@ -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,
@@ -0,0 +1,2 @@
1
+ nodeLinker: node-modules
2
+ pnpMode: false
package/app/init CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
2
 
4
- const { execSync } = require('child_process');
5
3
  const path = require('path');
6
4
  const fs = require('fs-extra');
7
5
 
@@ -14,9 +12,10 @@ const targets = {
14
12
  const files = [
15
13
  'tsconfig.json',
16
14
  'vue.config.js',
17
- '.gitignore',
15
+ 'gitignore',
18
16
  '.eslintignore',
19
17
  '.eslintrc.js',
18
+ '.yarnrc.yml',
20
19
  'babel.config.js',
21
20
  '.vscode/settings.json'
22
21
  ];
@@ -26,8 +25,9 @@ console.log('Creating Skeleton Application');
26
25
 
27
26
  const args = process.argv;
28
27
  let appFolder = path.resolve('.');
28
+ let shellVersion = '';
29
29
 
30
- if ( args.length > 2 ) {
30
+ if (args.length === 3) {
31
31
  const name = args[2];
32
32
  const folder = path.resolve('.');
33
33
 
@@ -40,7 +40,9 @@ let addGitlabWorkflow = false;
40
40
  let addWorkflowFolder = true;
41
41
 
42
42
  // Check for Gitlab integration option
43
- if ( args.length > 3 ) {
43
+ if ( args.length >= 3 ) {
44
+ shellVersion = args[3];
45
+
44
46
  for (let i = 3; i < args.length; i++) {
45
47
  switch (args[i]) {
46
48
  case '-l':
@@ -62,7 +64,6 @@ if ( addGitlabWorkflow ) {
62
64
 
63
65
  let setName = false;
64
66
 
65
- // Check that there is a package file
66
67
  if (!fs.existsSync(path.join(appFolder, './package.json'))) {
67
68
  console.log(' Adding package.json');
68
69
  fs.copySync(path.join(__dirname, 'app.package.json'), path.join(appFolder, 'package.json'));
@@ -95,10 +96,7 @@ Object.keys(targets).forEach((target) => {
95
96
  const creatorPkgData = fs.readFileSync(path.join(__dirname, 'package.json'));
96
97
  const creatorPkg = JSON.parse(creatorPkgData);
97
98
 
98
- // Fetch the latest version of @rancher/shell
99
- const shellVersion = execSync('npm view @rancher/shell version').toString().trim();
100
-
101
- // Set the latest version of @rancher/shell in the dependencies
99
+ // Set the package version of @rancher/shell in the dependencies
102
100
  pkg.dependencies['@rancher/shell'] = `^${ shellVersion }`;
103
101
 
104
102
  // Rest of dependencies are in the _pkgs property of package.json - copy then across
@@ -110,41 +108,16 @@ 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) => {
113
+ const destinationFile = file === 'gitignore' ? '.gitignore' : file;
141
114
  const src = path.join(__dirname, 'files', file);
142
- const dest = path.join(appFolder, file);
115
+ const dest = path.join(appFolder, destinationFile);
143
116
 
144
117
  if (!fs.existsSync(dest)) {
145
118
  console.log(` Adding file: ${ file }`);
146
119
 
147
- const folder = path.dirname(dest);
120
+ const folder = path.dirname(file);
148
121
 
149
122
  fs.ensureDirSync(folder);
150
123
 
@@ -153,6 +126,4 @@ files.forEach((file) => {
153
126
  }
154
127
  });
155
128
 
156
- console.log('Skeleton Application creation complete.\n');
157
-
158
- /* 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": ">=12"
14
+ "node": ">=16.0.0"
15
15
  },
16
16
  "_requires": [
17
17
  "core-js",
package/init CHANGED
@@ -4,6 +4,7 @@
4
4
  const { execSync } = require('child_process');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
+ const creatorPkg = require('./package.json');
7
8
 
8
9
  const args = process.argv.slice(2);
9
10
  let extensionName = '';
@@ -11,6 +12,7 @@ let appName = '';
11
12
  let updateOnly = false;
12
13
  let skeletonOnly = false;
13
14
  let ignoreShellDepCheck = false;
15
+ let tagUsed = ''; // To store the inferred tag
14
16
 
15
17
  args.forEach((arg, index) => {
16
18
  switch (arg) {
@@ -47,6 +49,45 @@ if ( !extensionName && !updateOnly && !skeletonOnly ) {
47
49
  process.exit(1);
48
50
  }
49
51
 
52
+ // Infer the tag used based on the installed version and dist-tags
53
+ try {
54
+ const packageName = creatorPkg.name;
55
+ const currentVersion = creatorPkg.version;
56
+
57
+ // Fetch the dist-tags from npm
58
+ const distTags = JSON.parse(execSync(`npm view ${ packageName } dist-tags --json`).toString());
59
+
60
+ // Find the tag matching the current version
61
+ tagUsed = Object.keys(distTags).find((tag) => distTags[tag] === currentVersion) || 'latest';
62
+
63
+ console.log(`Inferred tag used: ${ tagUsed }`);
64
+ } catch (error) {
65
+ console.error('Error inferring tag:', error.message);
66
+ process.exit(1);
67
+ }
68
+
69
+ // Now, check the version of `@rancher/shell` package based on the inferred tag
70
+ let shellVersion = 'latest';
71
+ const shellPackageName = '@rancher/shell';
72
+
73
+ try {
74
+ // Fetch the version of the `@rancher/shell` package that corresponds to the inferred tag
75
+ const tagVersion = execSync(`npm view ${ shellPackageName } dist-tags.${ tagUsed }`).toString().trim();
76
+
77
+ if (tagVersion) {
78
+ shellVersion = tagVersion;
79
+ } else {
80
+ const latestVersion = execSync(`npm view ${ shellPackageName } version`).toString().trim();
81
+
82
+ shellVersion = latestVersion;
83
+ }
84
+ } catch (error) {
85
+ console.error(` Failed to determine version for ${ shellPackageName }:`, error.message);
86
+ process.exit(1);
87
+ }
88
+
89
+ console.log(` Using version ${ shellVersion } for ${ shellPackageName }`);
90
+
50
91
  const basePath = process.cwd();
51
92
  let skeletonPath;
52
93
  let isInsideSkeleton = false;
@@ -98,7 +139,7 @@ try {
98
139
  if ( !isInsideSkeleton && !skeletonExists ) {
99
140
  console.log(`Creating skeleton application: ${ appName }...`);
100
141
  // Pass all arguments to the app/init script
101
- execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ args.join(' ') }`, { stdio: 'inherit' });
142
+ execSync(`node ${ path.join(__dirname, 'app', 'init') } ${ appName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
102
143
 
103
144
  // Ensure the skeleton path directory is created before attempting to change directory
104
145
  if ( !fs.existsSync(skeletonPath) ) {
@@ -124,7 +165,7 @@ try {
124
165
  // Check for package existence and create it if necessary
125
166
  if ( !pkgExists ) {
126
167
  console.log(`Creating package: ${ extensionName }...`);
127
- execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ args.join(' ') }`, { stdio: 'inherit' });
168
+ execSync(`node ${ path.join(__dirname, 'pkg', 'init') } ${ extensionName } ${ shellVersion } ${ args.join(' ') }`, { stdio: 'inherit' });
128
169
  }
129
170
 
130
171
  if ( args.includes('--update') || args.includes('-u') ) {
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@rancher/create-extension",
3
3
  "description": "Rancher UI Extension generator",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SUSE",
7
- "private": false,
8
- "bin": "./init",
7
+ "packageManager": "yarn@4.4.1",
8
+ "bin": {
9
+ "create-extension": "./init"
10
+ },
9
11
  "files": [
10
12
  "**/*",
11
13
  "init"
12
14
  ],
13
15
  "engines": {
14
- "node": ">=12"
16
+ "node": ">=16"
15
17
  },
16
18
  "dependencies": {
17
19
  "fs-extra": "^10.0.0"
@@ -20,6 +22,6 @@
20
22
  "core-js": "3.21.1",
21
23
  "css-loader": "6.7.3",
22
24
  "@types/lodash": "4.14.184",
23
- "@rancher/components": "0.2.1-alpha.0"
25
+ "@rancher/components": "0.1.3"
24
26
  }
25
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,18 +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);
46
+ let shellVersion = '';
39
47
 
40
- let addTypeFolders = true;
48
+ let addTypeFolders = false;
49
+ let addWorkflowFolder = false;
50
+
51
+ if ( args.length >= 3 ) {
52
+ shellVersion = args[3];
41
53
 
42
- if ( args.length > 3 ) {
43
54
  for ( let i = 3; i < args.length; i++ ) {
44
55
  switch (args[i]) {
45
- case '--skip-templates':
46
56
  case '-t':
47
- addTypeFolders = false;
57
+ addTypeFolders = true;
58
+ break;
59
+ case '-w':
60
+ addWorkflowFolder = true;
48
61
  break;
49
62
  default:
50
63
  break;
@@ -73,6 +86,13 @@ const pkg = JSON.parse(rawdata);
73
86
  pkg.name = name;
74
87
  pkg.description = `${ name } plugin`;
75
88
 
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
+ });
95
+
76
96
  // Add annotation for the latest Rancher version by default
77
97
  function fetchLatestVersion() {
78
98
  console.log(' Fetching latest Rancher Version');
@@ -115,20 +135,12 @@ function fetchLatestVersion() {
115
135
 
116
136
  pkg.rancher = { annotations: { 'catalog.cattle.io/rancher-version': `>= ${ release.tag_name }` } };
117
137
 
118
- // Fetch the latest version of @rancher/shell
119
- const latestShellVersion = execSync('npm view @rancher/shell version').toString().trim() || null;
120
-
121
- if (!latestShellVersion) {
138
+ if ( !shellVersion ) {
122
139
  console.log('Could not get a shell version from npm, skipping adding catalog.cattle.io/ui-extensions-version annotation to package.json');
123
140
  } else {
124
- const splitShellVersion = latestShellVersion.split('.');
125
- const majorVersion = splitShellVersion[0];
126
- const minorVersion = splitShellVersion[1];
127
- const parsedShellVersion = `${ majorVersion }.${ minorVersion }.0`;
141
+ console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ shellVersion }' to package.json`);
128
142
 
129
- console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ parsedShellVersion }' to package.json`);
130
-
131
- pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ parsedShellVersion }`;
143
+ pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ shellVersion }`;
132
144
  }
133
145
 
134
146
  writePackageJson();
@@ -145,6 +157,10 @@ function fetchLatestVersion() {
145
157
  fetchLatestVersion();
146
158
  writePackageJson();
147
159
 
160
+ // Add dependencies
161
+ // pkg.dependencies['@rancher/shell'] = '^0.6.2';
162
+ // pkg.dependencies['core-js'] = '3.18.3';
163
+
148
164
  function writePackageJson() {
149
165
  fs.writeFileSync(path.join(pkgFolder, 'package.json'), JSON.stringify(pkg, null, 2));
150
166
  }
@@ -161,6 +177,31 @@ if (addTypeFolders) {
161
177
  });
162
178
  }
163
179
 
180
+ // Add workflow folder if needed
181
+ if (addWorkflowFolder) {
182
+ const workflowDir = path.join(folder, '.github/workflows');
183
+
184
+ if (!fs.existsSync(workflowDir)) {
185
+ fs.mkdirSync(workflowDir, { recursive: true });
186
+ }
187
+
188
+ const files = [
189
+ 'build-extension-catalog.yml',
190
+ 'build-extension-charts.yml'
191
+ ];
192
+
193
+ files.forEach((fileName) => {
194
+ const file = path.join(workflowDir, fileName);
195
+
196
+ if (!fs.existsSync(file)) {
197
+ const src = path.join(__dirname, 'files/.github/workflows', fileName);
198
+
199
+ console.log(` Adding file ${ fileName } to root workflows`);
200
+ fs.copySync(src, file);
201
+ }
202
+ });
203
+ }
204
+
164
205
  // Copy base files
165
206
  files.forEach((file) => {
166
207
  const src = path.join(__dirname, 'files', file);
@@ -172,6 +213,13 @@ files.forEach((file) => {
172
213
  }
173
214
  });
174
215
 
216
+ // require("child_process").spawn('yarn', ['install'], {
217
+ // cwd: process.cwd(),
218
+ // stdio: "inherit"
219
+ // });
220
+
221
+ // Update tsconfig
222
+
175
223
  const topLevelRawdata = fs.readFileSync(path.join(folder, 'package.json'));
176
224
  const topLevelPkg = JSON.parse(topLevelRawdata);
177
225
  let updated = false;
@@ -216,5 +264,3 @@ function updateArray(data) {
216
264
 
217
265
  return updated;
218
266
  }
219
-
220
- /* eslint-enable no-console */
package/pkg/package.json CHANGED
@@ -11,7 +11,23 @@
11
11
  "init"
12
12
  ],
13
13
  "engines": {
14
- "node": ">=12"
14
+ "node": ">=16.0.0"
15
+ },
16
+ "resolutions": {
17
+ "d3-color": "3.1.0",
18
+ "ejs": "3.1.9",
19
+ "follow-redirects": "1.15.2",
20
+ "glob": "7.2.3",
21
+ "glob-parent": "6.0.2",
22
+ "json5": "2.2.3",
23
+ "@types/lodash": "4.17.5",
24
+ "merge": "2.1.1",
25
+ "node-forge": "1.3.1",
26
+ "nth-check": "2.1.1",
27
+ "qs": "6.11.1",
28
+ "roarr": "7.0.4",
29
+ "semver": "7.5.4",
30
+ "@vue/cli-service/html-webpack-plugin": "^5.0.0"
15
31
  },
16
32
  "dependencies": {
17
33
  "fs-extra": "^10.0.0"
@@ -6,12 +6,31 @@
6
6
  "rancher": true,
7
7
  "scripts": {},
8
8
  "engines": {
9
- "node": ">=12"
9
+ "node": ">=16"
10
10
  },
11
11
  "devDependencies": {
12
- "@vue/cli-plugin-babel": "4.5.18",
13
- "@vue/cli-service": "4.5.18",
14
- "@vue/cli-plugin-typescript": "4.5.18"
12
+ "@vue/cli-plugin-babel": "~5.0.0",
13
+ "@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"
15
34
  },
16
35
  "browserslist": [
17
36
  "> 1%",
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": ">=12"
15
+ "node": ">=16.0.0"
16
16
  },
17
17
  "dependencies": {
18
18
  "fs-extra": "^10.0.0"
package/update/upgrade CHANGED
@@ -1,6 +1,6 @@
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
4
 
5
5
  echo "Upgrading Rancher Shell"
6
6
 
@@ -19,13 +19,13 @@ fi
19
19
  # Check for a clean git repository
20
20
  if [ ! -d ".git" ] && [ "${FORCE}" == "false" ]; then
21
21
  echo "Not runnning in a git repository. Re-run with -f to ignore this check"
22
- echo "Note: This action will update your files - running in a git repository will ensure you have visibility over changes made"
22
+ echo "Note: This action will update yuor files - running in a git repsository will ensure you have visibility over changes made"
23
23
  exit 1
24
24
  fi
25
25
 
26
26
  if [[ $(git diff --stat) != '' ]] && [ "${FORCE}" == "false" ]; then
27
27
  echo "Git repository is not clean. Re-run with -f to ignore this check"
28
- echo "Note: This action will update your files - running in a clean git repository will ensure you have visibility over changes made"
28
+ echo "Note: This action will update yuor files - running in a clean git repsository will ensure you have visibility over changes made"
29
29
  exit 1
30
30
  fi
31
31
 
@@ -42,7 +42,7 @@ if [ "${HAS_SHELL}" != "1" ]; then
42
42
  fi
43
43
 
44
44
  # Copy files for the top-level folder (from the app creator)
45
- rsync ${SCRIPT_DIR}/app/files/* .
45
+ rsync --exclude nuxt.config.js ${SCRIPT_DIR}/app/files/* .
46
46
 
47
47
  # Go through each folder in the pkg folder and update their files
48
48
  for pkg in ./pkg/*
File without changes