@lazycatcloud/lzc-cli 1.2.7 → 1.2.10
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/lib/app/index.js +0 -2
- package/lib/app/lpk_devshell.js +5 -1
- package/lib/shellapi.js +10 -4
- package/package.json +1 -1
- package/template/_lpk/exec.sh +8 -0
package/lib/app/index.js
CHANGED
|
@@ -36,8 +36,6 @@ export function lpkProjectCommand(program) {
|
|
|
36
36
|
});
|
|
37
37
|
},
|
|
38
38
|
handler: async ({ context, output, file }) => {
|
|
39
|
-
await shellApi.init();
|
|
40
|
-
|
|
41
39
|
const lpk = await new LpkBuild(context, file).init();
|
|
42
40
|
// 正常的打包逻辑不需要 devshell
|
|
43
41
|
lpk.onBeforeBuildPackage(async (options) => {
|
package/lib/app/lpk_devshell.js
CHANGED
|
@@ -244,11 +244,15 @@ export class AppDevShell {
|
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
// 在生成 manifest.yml 之前合并 lzc-build.yml devshell 字段的值
|
|
247
|
+
// 并加上 health_check 字段
|
|
247
248
|
this.lpkBuild.onBeforeDumpYaml(async (manifest, options) => {
|
|
248
249
|
logger.debug("merge lzc-build.yml devshell services\n", options);
|
|
249
250
|
const devshell = {
|
|
250
251
|
application: {
|
|
251
252
|
devshell: options["devshell"],
|
|
253
|
+
health_check: {
|
|
254
|
+
test_url: `app.${manifest["package"]}.lzcapp/__isdevshell`,
|
|
255
|
+
},
|
|
252
256
|
},
|
|
253
257
|
};
|
|
254
258
|
return mergeYamlInMemory([manifest, devshell]);
|
|
@@ -427,7 +431,7 @@ class DevShell {
|
|
|
427
431
|
const dest = `root@${host}:/lzcapp/cache/devshell`;
|
|
428
432
|
try {
|
|
429
433
|
execSync(
|
|
430
|
-
`rsync ${rsyncDebug} --rsh='${rsh}' --recursive --relative --perms --update --filter=':- .gitignore' --ignore-errors
|
|
434
|
+
`rsync ${rsyncDebug} --rsh='${rsh}' --recursive --relative --perms --update --filter=':- .gitignore' --ignore-errors . ${dest}`,
|
|
431
435
|
{ stdio: ["ignore", "inherit", "inherit"] }
|
|
432
436
|
);
|
|
433
437
|
} catch (err) {
|
package/lib/shellapi.js
CHANGED
|
@@ -4,6 +4,7 @@ import { contextDirname } from "./utils.js";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import os from "node:os";
|
|
7
|
+
import logger from "loglevel";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @link {https://www.npmjs.com/package/appdirs}
|
|
@@ -84,10 +85,15 @@ class ShellApi {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
async initBoxInfo() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
try {
|
|
89
|
+
const boxes = await this.boxList();
|
|
90
|
+
const box = boxes.find((b) => b.is_default_box);
|
|
91
|
+
if (box) {
|
|
92
|
+
return { uid: box.login_user, boxname: box.box_name };
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
logger.debug("Error: ", e);
|
|
96
|
+
throw "获取盒子信息失败,请检查客户端是否已经连接!";
|
|
91
97
|
}
|
|
92
98
|
throw "没有默认盒子信息, 请先使用 lzc-cli box switch 设置默认的盒子信息";
|
|
93
99
|
}
|
package/package.json
CHANGED
package/template/_lpk/exec.sh
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
+
# 设置 lzcapp 环境变量
|
|
4
|
+
# 从1号进程读取环境变量
|
|
5
|
+
cat > /tmp/lzcapp_env.sh << EOF
|
|
6
|
+
#!/bin/sh
|
|
7
|
+
$(/lzcapp/pkg/content/devshell/busybox tr '\0' '\n' < /proc/1/environ | /lzcapp/pkg/content/devshell/busybox xargs -I{} echo export {})
|
|
8
|
+
EOF
|
|
9
|
+
. /tmp/lzcapp_env.sh
|
|
10
|
+
|
|
3
11
|
# 执行 setupscript 脚本
|
|
4
12
|
SETUPSCRIPT=/lzcapp/pkg/content/devshell/setupscript
|
|
5
13
|
if [ -f $SETUPSCRIPT ];then
|