@xcanwin/manyoyo 5.10.6 → 5.10.7
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 +35 -1
- package/package.json +1 -1
package/bin/manyoyo.js
CHANGED
|
@@ -713,6 +713,32 @@ function showImagePullHint(err) {
|
|
|
713
713
|
console.log(`${YELLOW} 你可以: (1) 更新 ~/.manyoyo/manyoyo.json 的 imageVersion。 (2) 或先执行 ${MANYOYO_NAME} build --iv <x.y.z-后缀> 构建镜像。${NC}`);
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
+
function getCommandFailureText(err) {
|
|
717
|
+
const stderr = err && err.stderr ? err.stderr.toString() : '';
|
|
718
|
+
const stdout = err && err.stdout ? err.stdout.toString() : '';
|
|
719
|
+
const message = err && err.message ? err.message : '';
|
|
720
|
+
return `${message}\n${stderr}\n${stdout}`;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
function getContainerRuntimeUnavailableHint(command, err) {
|
|
724
|
+
const text = getCommandFailureText(err);
|
|
725
|
+
if (/Cannot connect to Podman|unable to connect to Podman socket|podman machine start|podman system connection/i.test(text)) {
|
|
726
|
+
return [
|
|
727
|
+
'',
|
|
728
|
+
`提示: 当前 ${command} 命令正在连接 Podman machine,但连接不可用。`,
|
|
729
|
+
'请先在宿主机执行: podman machine start'
|
|
730
|
+
].join('\n');
|
|
731
|
+
}
|
|
732
|
+
if (/Cannot connect to the Docker daemon|docker daemon is not running|Is the docker daemon running/i.test(text)) {
|
|
733
|
+
return [
|
|
734
|
+
'',
|
|
735
|
+
`提示: 当前 ${command} 命令无法连接容器运行时。`,
|
|
736
|
+
'请先启动 Docker Desktop / Docker daemon,或确认 Podman machine 已启动。'
|
|
737
|
+
].join('\n');
|
|
738
|
+
}
|
|
739
|
+
return '';
|
|
740
|
+
}
|
|
741
|
+
|
|
716
742
|
function runCmd(cmd, args, options = {}) {
|
|
717
743
|
const result = spawnSync(cmd, args, { encoding: 'utf-8', ...options });
|
|
718
744
|
if (result.error) {
|
|
@@ -732,7 +758,15 @@ function runCmd(cmd, args, options = {}) {
|
|
|
732
758
|
}
|
|
733
759
|
|
|
734
760
|
function dockerExecArgs(args, options = {}) {
|
|
735
|
-
|
|
761
|
+
try {
|
|
762
|
+
return runCmd(DOCKER_CMD, args, options);
|
|
763
|
+
} catch (e) {
|
|
764
|
+
const hint = getContainerRuntimeUnavailableHint(DOCKER_CMD, e);
|
|
765
|
+
if (hint && e && e.message && !e.message.includes(hint)) {
|
|
766
|
+
e.message = `${e.message}${hint}`;
|
|
767
|
+
}
|
|
768
|
+
throw e;
|
|
769
|
+
}
|
|
736
770
|
}
|
|
737
771
|
|
|
738
772
|
function containerExists(name) {
|