@rancher/create-extension 1.0.3 → 1.0.5
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 +32 -2
- package/package.json +2 -2
- package/pkg/init +6 -58
- package/pkg/package.json +1 -1
- package/update/init +8 -4
- package/update/upgrade +3 -3
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');
|
|
@@ -65,6 +66,7 @@ if ( addGitlabWorkflow ) {
|
|
|
65
66
|
|
|
66
67
|
let setName = false;
|
|
67
68
|
|
|
69
|
+
// Check that there is a package file
|
|
68
70
|
if (!fs.existsSync(path.join(appFolder, './package.json'))) {
|
|
69
71
|
console.log(' Adding package.json');
|
|
70
72
|
fs.copySync(path.join(__dirname, 'app.package.json'), path.join(appFolder, 'package.json'));
|
|
@@ -109,6 +111,32 @@ if (creatorPkg._pkgs) {
|
|
|
109
111
|
|
|
110
112
|
fs.writeFileSync(path.join(appFolder, 'package.json'), JSON.stringify(pkg, null, 2));
|
|
111
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
|
+
|
|
112
140
|
// Copy base files
|
|
113
141
|
files.forEach((file) => {
|
|
114
142
|
const destinationFile = file === 'gitignore' ? '.gitignore' : file;
|
|
@@ -118,7 +146,7 @@ files.forEach((file) => {
|
|
|
118
146
|
if (!fs.existsSync(dest)) {
|
|
119
147
|
console.log(` Adding file: ${ file }`);
|
|
120
148
|
|
|
121
|
-
const folder = path.dirname(
|
|
149
|
+
const folder = path.dirname(dest);
|
|
122
150
|
|
|
123
151
|
fs.ensureDirSync(folder);
|
|
124
152
|
|
|
@@ -127,4 +155,6 @@ files.forEach((file) => {
|
|
|
127
155
|
}
|
|
128
156
|
});
|
|
129
157
|
|
|
130
|
-
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": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
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',
|
|
@@ -35,25 +31,18 @@ console.log('Creating Skeleton UI Package');
|
|
|
35
31
|
|
|
36
32
|
const args = process.argv;
|
|
37
33
|
|
|
38
|
-
if (args.length !== 3) {
|
|
39
|
-
console.log('Expected single argument of package name');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
34
|
const name = args[2];
|
|
43
35
|
const folder = path.resolve('.');
|
|
44
36
|
const pkgFolder = path.join(folder, 'pkg', name);
|
|
45
37
|
|
|
46
|
-
let addTypeFolders =
|
|
47
|
-
let addWorkflowFolder = false;
|
|
38
|
+
let addTypeFolders = true;
|
|
48
39
|
|
|
49
40
|
if ( args.length >= 3 ) {
|
|
50
41
|
for ( let i = 3; i < args.length; i++ ) {
|
|
51
42
|
switch (args[i]) {
|
|
43
|
+
case '--skip-templates':
|
|
52
44
|
case '-t':
|
|
53
|
-
addTypeFolders =
|
|
54
|
-
break;
|
|
55
|
-
case '-w':
|
|
56
|
-
addWorkflowFolder = true;
|
|
45
|
+
addTypeFolders = false;
|
|
57
46
|
break;
|
|
58
47
|
default:
|
|
59
48
|
break;
|
|
@@ -82,19 +71,8 @@ const pkg = JSON.parse(rawdata);
|
|
|
82
71
|
pkg.name = name;
|
|
83
72
|
pkg.description = `${ name } plugin`;
|
|
84
73
|
|
|
85
|
-
Object.keys(targets).forEach((target) => {
|
|
86
|
-
if (!pkg.scripts[target]) {
|
|
87
|
-
pkg.scripts[target] = targets[target];
|
|
88
|
-
console.log(` Adding script '${ target }' to package.json`);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
74
|
writePackageJson();
|
|
93
75
|
|
|
94
|
-
// Add dependencies
|
|
95
|
-
// pkg.dependencies['@rancher/shell'] = '^0.6.2';
|
|
96
|
-
// pkg.dependencies['core-js'] = '3.18.3';
|
|
97
|
-
|
|
98
76
|
function writePackageJson() {
|
|
99
77
|
fs.writeFileSync(path.join(pkgFolder, 'package.json'), JSON.stringify(pkg, null, 2));
|
|
100
78
|
}
|
|
@@ -111,31 +89,6 @@ if (addTypeFolders) {
|
|
|
111
89
|
});
|
|
112
90
|
}
|
|
113
91
|
|
|
114
|
-
// Add workflow folder if needed
|
|
115
|
-
if (addWorkflowFolder) {
|
|
116
|
-
const workflowDir = path.join(folder, '.github/workflows');
|
|
117
|
-
|
|
118
|
-
if (!fs.existsSync(workflowDir)) {
|
|
119
|
-
fs.mkdirSync(workflowDir, { recursive: true });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const files = [
|
|
123
|
-
'build-extension-catalog.yml',
|
|
124
|
-
'build-extension-charts.yml'
|
|
125
|
-
];
|
|
126
|
-
|
|
127
|
-
files.forEach((fileName) => {
|
|
128
|
-
const file = path.join(workflowDir, fileName);
|
|
129
|
-
|
|
130
|
-
if (!fs.existsSync(file)) {
|
|
131
|
-
const src = path.join(__dirname, 'files/.github/workflows', fileName);
|
|
132
|
-
|
|
133
|
-
console.log(` Adding file ${ fileName } to root workflows`);
|
|
134
|
-
fs.copySync(src, file);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
92
|
// Copy base files
|
|
140
93
|
files.forEach((file) => {
|
|
141
94
|
const src = path.join(__dirname, 'files', file);
|
|
@@ -147,13 +100,6 @@ files.forEach((file) => {
|
|
|
147
100
|
}
|
|
148
101
|
});
|
|
149
102
|
|
|
150
|
-
// require("child_process").spawn('yarn', ['install'], {
|
|
151
|
-
// cwd: process.cwd(),
|
|
152
|
-
// stdio: "inherit"
|
|
153
|
-
// });
|
|
154
|
-
|
|
155
|
-
// Update tsconfig
|
|
156
|
-
|
|
157
103
|
const topLevelRawdata = fs.readFileSync(path.join(folder, 'package.json'));
|
|
158
104
|
const topLevelPkg = JSON.parse(topLevelRawdata);
|
|
159
105
|
let updated = false;
|
|
@@ -198,3 +144,5 @@ function updateArray(data) {
|
|
|
198
144
|
|
|
199
145
|
return updated;
|
|
200
146
|
}
|
|
147
|
+
|
|
148
|
+
/* eslint-enable no-console */
|
package/pkg/package.json
CHANGED
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(
|
|
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
|
-
|
|
35
|
-
|
|
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
|
|
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
|
|
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
|