@rancher/create-extension 0.1.0 → 0.2.1-rc.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
  }
@@ -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
  ]
@@ -0,0 +1,2 @@
1
+ nodeLinker: node-modules
2
+ pnpMode: false
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "esModuleInterop": true,
12
12
  "allowJs": true,
13
- "sourceMap": true,
13
+ "sourceMap": false,
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,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
 
@@ -37,19 +37,16 @@ if ( args.length > 2 ) {
37
37
  }
38
38
 
39
39
  let addGitlabWorkflow = false;
40
- let addWorkflowFolder = true;
41
40
 
42
41
  // Check for Gitlab integration option
43
- if ( args.length > 3 ) {
42
+ if ( args.length >= 3 ) {
43
+ shellVersion = args[3];
44
+
44
45
  for (let i = 3; i < args.length; i++) {
45
46
  switch (args[i]) {
46
47
  case '-l':
47
48
  addGitlabWorkflow = true;
48
49
  break;
49
- case '--skip-workflow':
50
- case '-w':
51
- addWorkflowFolder = false;
52
- break;
53
50
  default:
54
51
  break;
55
52
  }
@@ -60,9 +57,10 @@ if ( addGitlabWorkflow ) {
60
57
  files.push('.gitlab-ci.yml');
61
58
  }
62
59
 
60
+ // Check that there is a package file
61
+
63
62
  let setName = false;
64
63
 
65
- // Check that there is a package file
66
64
  if (!fs.existsSync(path.join(appFolder, './package.json'))) {
67
65
  console.log(' Adding package.json');
68
66
  fs.copySync(path.join(__dirname, 'app.package.json'), path.join(appFolder, 'package.json'));
@@ -95,10 +93,7 @@ Object.keys(targets).forEach((target) => {
95
93
  const creatorPkgData = fs.readFileSync(path.join(__dirname, 'package.json'));
96
94
  const creatorPkg = JSON.parse(creatorPkgData);
97
95
 
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
96
+ // Set the package version of @rancher/shell in the dependencies
102
97
  pkg.dependencies['@rancher/shell'] = `^${ shellVersion }`;
103
98
 
104
99
  // Rest of dependencies are in the _pkgs property of package.json - copy then across
@@ -110,41 +105,16 @@ if (creatorPkg._pkgs) {
110
105
 
111
106
  fs.writeFileSync(path.join(appFolder, 'package.json'), JSON.stringify(pkg, null, 2));
112
107
 
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
108
  // Copy base files
140
109
  files.forEach((file) => {
110
+ const destinationFile = file === 'gitignore' ? '.gitignore' : file;
141
111
  const src = path.join(__dirname, 'files', file);
142
- const dest = path.join(appFolder, file);
112
+ const dest = path.join(appFolder, destinationFile);
143
113
 
144
114
  if (!fs.existsSync(dest)) {
145
115
  console.log(` Adding file: ${ file }`);
146
116
 
147
- const folder = path.dirname(dest);
117
+ const folder = path.dirname(file);
148
118
 
149
119
  fs.ensureDirSync(folder);
150
120
 
@@ -153,6 +123,4 @@ files.forEach((file) => {
153
123
  }
154
124
  });
155
125
 
156
- console.log('Skeleton Application creation complete.\n');
157
-
158
- /* eslint-enable no-console */
126
+ 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.2.1-rc.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"
@@ -10,13 +10,13 @@
10
10
  "skipLibCheck": true,
11
11
  "esModuleInterop": true,
12
12
  "allowSyntheticDefaultImports": true,
13
- "sourceMap": true,
13
+ "sourceMap": false,
14
14
  "baseUrl": ".",
15
15
  "preserveSymlinks": true,
16
16
  "typeRoots": [
17
17
  "../../node_modules",
18
18
  "../../node_modules/@rancher/shell/types"
19
- ],
19
+ ],
20
20
  "types": [
21
21
  "node",
22
22
  "webpack-env",
@@ -50,4 +50,4 @@
50
50
  "exclude": [
51
51
  "../../node_modules"
52
52
  ]
53
- }
53
+ }
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',
@@ -28,23 +31,39 @@ const typeFolders = [
28
31
  'detail'
29
32
  ];
30
33
 
34
+ const shellPkgPath = 'node_modules/@rancher/shell';
35
+
31
36
  console.log('');
32
37
  console.log('Creating Skeleton UI Package');
33
38
 
34
39
  const args = process.argv;
35
40
 
41
+ if (args.length !== 3) {
42
+ console.log('Expected single argument of package name');
43
+ }
44
+
36
45
  const name = args[2];
37
46
  const folder = path.resolve('.');
38
47
  const pkgFolder = path.join(folder, 'pkg', name);
48
+ let shellVersion = '';
49
+
50
+ let addTypeFolders = false;
51
+ let addWorkflowFolder = false;
52
+ let ignoreShellPkgPathCheck = false;
39
53
 
40
- let addTypeFolders = true;
54
+ if ( args.length >= 3 ) {
55
+ shellVersion = args[3];
41
56
 
42
- if ( args.length > 3 ) {
43
57
  for ( let i = 3; i < args.length; i++ ) {
44
58
  switch (args[i]) {
45
- case '--skip-templates':
46
59
  case '-t':
47
- addTypeFolders = false;
60
+ addTypeFolders = true;
61
+ break;
62
+ case '-w':
63
+ addWorkflowFolder = true;
64
+ break;
65
+ case '-i':
66
+ ignoreShellPkgPathCheck = true;
48
67
  break;
49
68
  default:
50
69
  break;
@@ -52,6 +71,12 @@ if ( args.length > 3 ) {
52
71
  }
53
72
  }
54
73
 
74
+ if (!ignoreShellPkgPathCheck && !fs.existsSync(path.join(pkgFolder, `../../${ shellPkgPath }/package.json`))) {
75
+ console.log('');
76
+ 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');
77
+ process.exit(1);
78
+ }
79
+
55
80
  const isNodeModulesShell = !fs.existsSync(path.join(folder, 'shell'));
56
81
 
57
82
  if (!isNodeModulesShell) {
@@ -73,6 +98,13 @@ const pkg = JSON.parse(rawdata);
73
98
  pkg.name = name;
74
99
  pkg.description = `${ name } plugin`;
75
100
 
101
+ Object.keys(targets).forEach((target) => {
102
+ if (!pkg.scripts[target]) {
103
+ pkg.scripts[target] = targets[target];
104
+ console.log(` Adding script '${ target }' to package.json`);
105
+ }
106
+ });
107
+
76
108
  // Add annotation for the latest Rancher version by default
77
109
  function fetchLatestVersion() {
78
110
  console.log(' Fetching latest Rancher Version');
@@ -115,20 +147,12 @@ function fetchLatestVersion() {
115
147
 
116
148
  pkg.rancher = { annotations: { 'catalog.cattle.io/rancher-version': `>= ${ release.tag_name }` } };
117
149
 
118
- // Fetch the latest version of @rancher/shell
119
- const latestShellVersion = execSync('npm view @rancher/shell version').toString().trim() || null;
120
-
121
- if (!latestShellVersion) {
150
+ if ( !shellVersion ) {
122
151
  console.log('Could not get a shell version from npm, skipping adding catalog.cattle.io/ui-extensions-version annotation to package.json');
123
152
  } else {
124
- const splitShellVersion = latestShellVersion.split('.');
125
- const majorVersion = splitShellVersion[0];
126
- const minorVersion = splitShellVersion[1];
127
- const parsedShellVersion = `${ majorVersion }.${ minorVersion }.0`;
128
-
129
- console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ parsedShellVersion }' to package.json`);
153
+ console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ shellVersion }' to package.json`);
130
154
 
131
- pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ parsedShellVersion }`;
155
+ pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ shellVersion }`;
132
156
  }
133
157
 
134
158
  writePackageJson();
@@ -145,6 +169,10 @@ function fetchLatestVersion() {
145
169
  fetchLatestVersion();
146
170
  writePackageJson();
147
171
 
172
+ // Add dependencies
173
+ // pkg.dependencies['@rancher/shell'] = '^0.6.2';
174
+ // pkg.dependencies['core-js'] = '3.18.3';
175
+
148
176
  function writePackageJson() {
149
177
  fs.writeFileSync(path.join(pkgFolder, 'package.json'), JSON.stringify(pkg, null, 2));
150
178
  }
@@ -161,6 +189,31 @@ if (addTypeFolders) {
161
189
  });
162
190
  }
163
191
 
192
+ // Add workflow folder if needed
193
+ if (addWorkflowFolder) {
194
+ const workflowDir = path.join(folder, '.github/workflows');
195
+
196
+ if (!fs.existsSync(workflowDir)) {
197
+ fs.mkdirSync(workflowDir, { recursive: true });
198
+ }
199
+
200
+ const files = [
201
+ 'build-extension-catalog.yml',
202
+ 'build-extension-charts.yml'
203
+ ];
204
+
205
+ files.forEach((fileName) => {
206
+ const file = path.join(workflowDir, fileName);
207
+
208
+ if (!fs.existsSync(file)) {
209
+ const src = path.join(__dirname, 'files/.github/workflows', fileName);
210
+
211
+ console.log(` Adding file ${ fileName } to root workflows`);
212
+ fs.copySync(src, file);
213
+ }
214
+ });
215
+ }
216
+
164
217
  // Copy base files
165
218
  files.forEach((file) => {
166
219
  const src = path.join(__dirname, 'files', file);
@@ -172,6 +225,13 @@ files.forEach((file) => {
172
225
  }
173
226
  });
174
227
 
228
+ // require("child_process").spawn('yarn', ['install'], {
229
+ // cwd: process.cwd(),
230
+ // stdio: "inherit"
231
+ // });
232
+
233
+ // Update tsconfig
234
+
175
235
  const topLevelRawdata = fs.readFileSync(path.join(folder, 'package.json'));
176
236
  const topLevelPkg = JSON.parse(topLevelRawdata);
177
237
  let updated = false;
@@ -216,5 +276,3 @@ function updateArray(data) {
216
276
 
217
277
  return updated;
218
278
  }
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