@rancher/create-extension 2.0.2 → 2.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.
- package/app/app.package.json +3 -20
- package/app/init +37 -4
- package/package.json +2 -2
- package/pkg/init +6 -70
- package/pkg/package.json +1 -1
package/app/app.package.json
CHANGED
|
@@ -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
|
-
"
|
|
16
|
-
"
|
|
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(
|
|
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.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SUSE",
|
|
7
|
-
"packageManager": "yarn@4.
|
|
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 =
|
|
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 =
|
|
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 */
|