@oinone/cli 7.2.2 → 7.2.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.
- package/bin/cli.js +61 -0
- package/package.json +1 -1
- package/template-7.2.0-community/packages/ss-admin-widget/rollup.config.js +2 -0
- package/template-7.2.0-community/packages/ss-oinone/rollup.config.js +2 -0
- package/template-7.2.0-community/packages/ss-project/rollup.config.js +2 -0
- package/template-7.2.0-enterprise/packages/ss-admin-widget/rollup.config.js +2 -0
- package/template-7.2.0-enterprise/packages/ss-oinone/rollup.config.js +2 -0
- package/template-7.2.0-enterprise/packages/ss-project/rollup.config.js +2 -0
package/bin/cli.js
CHANGED
|
@@ -15,6 +15,9 @@ const packageJson = require('../package.json');
|
|
|
15
15
|
const downloadAndExtractZip = (url, targetDir) => {
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
17
|
const req = https.request(url, { method: 'HEAD' }, (headRes) => {
|
|
18
|
+
// 必须调用 resume() 消费响应数据,否则 Node 19+ 默认开启 keepAlive 会导致 socket 保持连接,进程卡住 60 秒
|
|
19
|
+
headRes.resume();
|
|
20
|
+
|
|
18
21
|
if (headRes.statusCode !== 200) {
|
|
19
22
|
reject(new Error(`Failed to fetch file info: ${headRes.statusCode}`));
|
|
20
23
|
return;
|
|
@@ -49,6 +52,7 @@ const downloadAndExtractZip = (url, targetDir) => {
|
|
|
49
52
|
|
|
50
53
|
https.get(url, (response) => {
|
|
51
54
|
if (response.statusCode !== 200) {
|
|
55
|
+
response.resume(); // 消费响应数据释放 socket
|
|
52
56
|
reject(new Error(`Failed to download: ${response.statusCode}`));
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
@@ -212,6 +216,30 @@ program
|
|
|
212
216
|
if (projectNameArg === 'cache') {
|
|
213
217
|
return;
|
|
214
218
|
}
|
|
219
|
+
|
|
220
|
+
// Trigger version check without blocking
|
|
221
|
+
let checkReq = null;
|
|
222
|
+
const versionCheckPromise = new Promise((resolve) => {
|
|
223
|
+
checkReq = https.get('https://registry.npmjs.org/-/package/@oinone/cli/dist-tags', { timeout: 3000 }, (res) => {
|
|
224
|
+
let data = '';
|
|
225
|
+
res.on('data', chunk => data += chunk);
|
|
226
|
+
res.on('end', () => {
|
|
227
|
+
try {
|
|
228
|
+
const parsed = JSON.parse(data);
|
|
229
|
+
resolve(parsed.latest);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
resolve(null);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
checkReq.on('timeout', () => {
|
|
236
|
+
checkReq.destroy();
|
|
237
|
+
resolve(null);
|
|
238
|
+
});
|
|
239
|
+
checkReq.on('error', () => {
|
|
240
|
+
resolve(null);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
215
243
|
|
|
216
244
|
try {
|
|
217
245
|
let prefix;
|
|
@@ -421,6 +449,39 @@ program
|
|
|
421
449
|
console.log(chalk.cyan(` pnpm run dev\n`));
|
|
422
450
|
console.log(chalk.magenta(`Happy coding! 💻☕\n`));
|
|
423
451
|
|
|
452
|
+
try {
|
|
453
|
+
const latestVersion = await Promise.race([
|
|
454
|
+
versionCheckPromise,
|
|
455
|
+
new Promise(resolve => setTimeout(() => {
|
|
456
|
+
if (checkReq) checkReq.destroy();
|
|
457
|
+
resolve(null);
|
|
458
|
+
}, 1000))
|
|
459
|
+
]);
|
|
460
|
+
|
|
461
|
+
if (latestVersion) {
|
|
462
|
+
const isNewerVersion = (current, latest) => {
|
|
463
|
+
const c = current.replace(/[^0-9.]/g, '').split('.').map(Number);
|
|
464
|
+
const l = latest.replace(/[^0-9.]/g, '').split('.').map(Number);
|
|
465
|
+
for (let i = 0; i < Math.max(c.length, l.length); i++) {
|
|
466
|
+
const numC = c[i] || 0;
|
|
467
|
+
const numL = l[i] || 0;
|
|
468
|
+
if (numL > numC) return true;
|
|
469
|
+
if (numL < numC) return false;
|
|
470
|
+
}
|
|
471
|
+
return false;
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
if (isNewerVersion(packageJson.version, latestVersion)) {
|
|
475
|
+
console.log(chalk.yellow(`====================================================`));
|
|
476
|
+
console.log(chalk.yellow(`📦 Update available! ${chalk.red(packageJson.version)} → ${chalk.green(latestVersion)}`));
|
|
477
|
+
console.log(chalk.yellow(`Run ${chalk.cyan('npm install -g @oinone/cli')} to update.`));
|
|
478
|
+
console.log(chalk.yellow(`====================================================\n`));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
} catch (e) {
|
|
482
|
+
// ignore errors
|
|
483
|
+
}
|
|
484
|
+
|
|
424
485
|
} catch (error) {
|
|
425
486
|
console.error(chalk.red(`\n💥 Oops! Something broke: ${error.message}\n`));
|
|
426
487
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
1
2
|
import CompileConfigBuilder from '@oinone/kunlun-compile';
|
|
2
3
|
|
|
3
4
|
export default CompileConfigBuilder.config()
|
|
4
5
|
.setLibraryName('ss-admin-widget')
|
|
6
|
+
.externalPkg(pkg)
|
|
5
7
|
.singleModule()
|
|
6
8
|
.replace()
|
|
7
9
|
.nodeResolve()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
1
2
|
import CompileConfigBuilder from '@oinone/kunlun-compile';
|
|
2
3
|
|
|
3
4
|
export default CompileConfigBuilder.config()
|
|
4
5
|
.setLibraryName('ss-oinone')
|
|
6
|
+
.externalPkg(pkg)
|
|
5
7
|
.singleModule()
|
|
6
8
|
.replace()
|
|
7
9
|
.nodeResolve()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
1
2
|
import CompileConfigBuilder from '@oinone/kunlun-compile';
|
|
2
3
|
|
|
3
4
|
export default CompileConfigBuilder.config()
|
|
4
5
|
.setLibraryName('ss-project')
|
|
6
|
+
.externalPkg(pkg)
|
|
5
7
|
.singleModule()
|
|
6
8
|
.replace()
|
|
7
9
|
.nodeResolve()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
1
2
|
import CompileConfigBuilder from '@oinone/kunlun-compile';
|
|
2
3
|
|
|
3
4
|
export default CompileConfigBuilder.config()
|
|
4
5
|
.setLibraryName('ss-admin-widget')
|
|
6
|
+
.externalPkg(pkg)
|
|
5
7
|
.singleModule()
|
|
6
8
|
.replace()
|
|
7
9
|
.nodeResolve()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
1
2
|
import CompileConfigBuilder from '@oinone/kunlun-compile';
|
|
2
3
|
|
|
3
4
|
export default CompileConfigBuilder.config()
|
|
4
5
|
.setLibraryName('ss-oinone')
|
|
6
|
+
.externalPkg(pkg)
|
|
5
7
|
.singleModule()
|
|
6
8
|
.replace()
|
|
7
9
|
.nodeResolve()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
1
2
|
import CompileConfigBuilder from '@oinone/kunlun-compile';
|
|
2
3
|
|
|
3
4
|
export default CompileConfigBuilder.config()
|
|
4
5
|
.setLibraryName('ss-project')
|
|
6
|
+
.externalPkg(pkg)
|
|
5
7
|
.singleModule()
|
|
6
8
|
.replace()
|
|
7
9
|
.nodeResolve()
|