@xcanwin/manyoyo 4.2.5 → 4.2.8
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/manyoyo.js +28 -1
- package/lib/image-build.js +10 -4
- package/package.json +1 -1
package/bin/manyoyo.js
CHANGED
|
@@ -642,10 +642,18 @@ function installManyoyo(name) {
|
|
|
642
642
|
|
|
643
643
|
function updateManyoyo() {
|
|
644
644
|
let isLocalFileInstall = false;
|
|
645
|
+
let currentVersion = 'unknown';
|
|
646
|
+
|
|
645
647
|
try {
|
|
646
648
|
const listOutput = runCmd('npm', ['ls', '-g', '@xcanwin/manyoyo', '--json', '--long'], { stdio: 'pipe' });
|
|
647
649
|
const listJson = JSON.parse(listOutput || '{}');
|
|
648
650
|
const dep = listJson && listJson.dependencies && listJson.dependencies['@xcanwin/manyoyo'];
|
|
651
|
+
|
|
652
|
+
// 获取当前版本
|
|
653
|
+
if (dep && dep.version) {
|
|
654
|
+
currentVersion = dep.version;
|
|
655
|
+
}
|
|
656
|
+
|
|
649
657
|
const resolved = dep && typeof dep.resolved === 'string' ? dep.resolved : '';
|
|
650
658
|
const depPath = dep && typeof dep.path === 'string' ? dep.path : '';
|
|
651
659
|
|
|
@@ -664,9 +672,28 @@ function updateManyoyo() {
|
|
|
664
672
|
return;
|
|
665
673
|
}
|
|
666
674
|
|
|
675
|
+
console.log(`${CYAN}🔄 当前版本: ${currentVersion}${NC}`);
|
|
667
676
|
console.log(`${CYAN}🔄 正在更新 ${MANYOYO_NAME} 到最新版本...${NC}`);
|
|
668
677
|
runCmd('npm', ['update', '-g', '@xcanwin/manyoyo'], { stdio: 'inherit' });
|
|
669
|
-
|
|
678
|
+
|
|
679
|
+
// 升级后获取新版本
|
|
680
|
+
let newVersion = 'unknown';
|
|
681
|
+
try {
|
|
682
|
+
const listOutput = runCmd('npm', ['ls', '-g', '@xcanwin/manyoyo', '--json'], { stdio: 'pipe' });
|
|
683
|
+
const listJson = JSON.parse(listOutput || '{}');
|
|
684
|
+
const dep = listJson && listJson.dependencies && listJson.dependencies['@xcanwin/manyoyo'];
|
|
685
|
+
if (dep && dep.version) {
|
|
686
|
+
newVersion = dep.version;
|
|
687
|
+
}
|
|
688
|
+
} catch (e) {
|
|
689
|
+
// ignore
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (currentVersion === newVersion) {
|
|
693
|
+
console.log(`${GREEN}✅ 已是最新版本 ${newVersion}${NC}`);
|
|
694
|
+
} else {
|
|
695
|
+
console.log(`${GREEN}✅ 更新完成: ${currentVersion} → ${newVersion}${NC}`);
|
|
696
|
+
}
|
|
670
697
|
}
|
|
671
698
|
|
|
672
699
|
function getContList() {
|
package/lib/image-build.js
CHANGED
|
@@ -309,10 +309,11 @@ function buildBuildkitRunArgs(ctx, dockerfilePath, fullImageTag, imageBuildArgs)
|
|
|
309
309
|
'--local', 'context=/workspace',
|
|
310
310
|
'--local', 'dockerfile=/workspace',
|
|
311
311
|
'--opt', `filename=${dockerfileRelativePath}`,
|
|
312
|
-
'--opt',
|
|
313
|
-
'--opt', `build-arg:
|
|
314
|
-
'--opt', `build-arg:
|
|
315
|
-
'--opt', `build-arg:
|
|
312
|
+
'--opt', 'network=host',
|
|
313
|
+
'--opt', `build-arg:HTTP_PROXY=${process.env.HTTP_PROXY}`,
|
|
314
|
+
'--opt', `build-arg:HTTPS_PROXY=${process.env.HTTPS_PROXY}`,
|
|
315
|
+
'--opt', `build-arg:ALL_PROXY=${process.env.ALL_PROXY}`,
|
|
316
|
+
'--opt', `build-arg:NO_PROXY=${process.env.NO_PROXY}`
|
|
316
317
|
];
|
|
317
318
|
|
|
318
319
|
for (const value of buildArgs) {
|
|
@@ -428,6 +429,9 @@ async function buildImage(options = {}) {
|
|
|
428
429
|
|
|
429
430
|
await prepareBuildCache(ctx, imageTool);
|
|
430
431
|
|
|
432
|
+
// 记录构建开始时间
|
|
433
|
+
const buildStartTime = Date.now();
|
|
434
|
+
|
|
431
435
|
const dockerfilePath = path.join(ctx.rootDir, 'docker', 'manyoyo.Dockerfile');
|
|
432
436
|
if (!fs.existsSync(dockerfilePath)) {
|
|
433
437
|
ctx.error(`${RED}错误: 找不到 Dockerfile: ${dockerfilePath}${NC}`);
|
|
@@ -447,7 +451,9 @@ async function buildImage(options = {}) {
|
|
|
447
451
|
const buildkitRunArgs = buildBuildkitRunArgs(ctx, dockerfilePath, fullImageTag, imageBuildArgs);
|
|
448
452
|
|
|
449
453
|
function logBuildSuccess() {
|
|
454
|
+
const buildDuration = ((Date.now() - buildStartTime) / 1000).toFixed(1);
|
|
450
455
|
ctx.log(`\n${GREEN}✅ 镜像构建成功: ${fullImageTag}${NC}`);
|
|
456
|
+
ctx.log(`${GREEN}⏱️ 构建耗时: ${buildDuration} 秒${NC}`);
|
|
451
457
|
ctx.log(`${BLUE}使用镜像:${NC}`);
|
|
452
458
|
ctx.log(` ${ctx.manyoyoName} -n test --in ${ctx.imageName} --iv ${version}-${imageTool} -y c`);
|
|
453
459
|
ctx.pruneDanglingImages();
|