@lazycatcloud/lzc-cli 1.2.5 → 1.2.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/lib/app/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export function lpkProjectCommand(program) {
|
|
|
31
31
|
args.option("f", {
|
|
32
32
|
alias: "file",
|
|
33
33
|
describe: "指定构建的lzc-build.yml文件",
|
|
34
|
+
default: "lzc-build.yml",
|
|
34
35
|
type: "string",
|
|
35
36
|
});
|
|
36
37
|
},
|
|
@@ -86,7 +87,7 @@ export function lpkProjectCommand(program) {
|
|
|
86
87
|
}
|
|
87
88
|
return options;
|
|
88
89
|
});
|
|
89
|
-
const app = new AppDevShell(cwd, lpkBuild, force);
|
|
90
|
+
const app = new AppDevShell(cwd, lpkBuild, force, config);
|
|
90
91
|
await app.init();
|
|
91
92
|
await app.build();
|
|
92
93
|
await sleep(2000);
|
package/lib/app/lpk_build.js
CHANGED
|
@@ -109,10 +109,10 @@ function convenientEnv() {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
export class LpkBuild {
|
|
112
|
-
constructor(cwd,
|
|
112
|
+
constructor(cwd, buildConfigFile) {
|
|
113
113
|
this.pwd = cwd ?? process.cwd();
|
|
114
114
|
|
|
115
|
-
this.optionsFilePath = path.join(this.pwd,
|
|
115
|
+
this.optionsFilePath = path.join(this.pwd, buildConfigFile);
|
|
116
116
|
this.options = loadFromYaml(this.optionsFilePath);
|
|
117
117
|
|
|
118
118
|
this.manifestFilePath = this.options["manifest"]
|
|
@@ -21,16 +21,20 @@ export class DebugBridge {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async install(lpkPath) {
|
|
24
|
+
async install(lpkPath, pkgId) {
|
|
25
25
|
if (!(await this.canPublicKey())) {
|
|
26
26
|
await this.sshCopyId();
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const stream = fs.createReadStream(lpkPath);
|
|
30
|
-
const ssh = spawn(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const ssh = spawn(
|
|
31
|
+
this.sshCmd,
|
|
32
|
+
[`install --uid ${this.uid} --pkgId ${pkgId}`],
|
|
33
|
+
{
|
|
34
|
+
shell: true,
|
|
35
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
36
|
+
}
|
|
37
|
+
);
|
|
34
38
|
stream.pipe(ssh.stdin);
|
|
35
39
|
return new Promise((resolve, reject) => {
|
|
36
40
|
ssh.on("close", (code) => {
|
package/lib/app/lpk_devshell.js
CHANGED
|
@@ -33,11 +33,11 @@ import { collectContextFromDockerFile } from "./lpk_devshell_docker.js";
|
|
|
33
33
|
// - 根据 backend api 判断一个 appid 是否属于 running
|
|
34
34
|
// - 根据在 backend api 中判断同步的目录下是否存在文件 判断当前运行的 app 是否已经有一个挂载的实例,避免重复挂载
|
|
35
35
|
class AppDevShellMonitor {
|
|
36
|
-
constructor(cwd, pkgId) {
|
|
36
|
+
constructor(cwd, pkgId, buildConfigFile) {
|
|
37
37
|
this.pwd = cwd ? path.resolve(cwd) : process.cwd();
|
|
38
38
|
this.pkgId = pkgId;
|
|
39
39
|
|
|
40
|
-
this.optionsFilePath = path.join(this.pwd,
|
|
40
|
+
this.optionsFilePath = path.join(this.pwd, buildConfigFile);
|
|
41
41
|
this.options = loadFromYaml(this.optionsFilePath);
|
|
42
42
|
|
|
43
43
|
this.manifestFilePath = this.options["manifest"]
|
|
@@ -104,19 +104,21 @@ class AppDevShellMonitor {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export class AppDevShell {
|
|
107
|
-
constructor(cwd, lpkBuild, forceBuild
|
|
107
|
+
constructor(cwd, lpkBuild, forceBuild, buildConfigFile) {
|
|
108
108
|
this.cwd = cwd;
|
|
109
109
|
this.lpkBuild = lpkBuild;
|
|
110
|
-
this.monitor = undefined;
|
|
111
110
|
this.forceBuild = forceBuild;
|
|
111
|
+
this.buildConfigFile = buildConfigFile;
|
|
112
112
|
this.isUserApp = false;
|
|
113
|
+
this.monitor = undefined;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
async init() {
|
|
116
117
|
const manifest = await this.lpkBuild.getManifest();
|
|
117
118
|
this.monitor = await new AppDevShellMonitor(
|
|
118
119
|
this.cwd,
|
|
119
|
-
manifest["package"]
|
|
120
|
+
manifest["package"],
|
|
121
|
+
this.buildConfigFile
|
|
120
122
|
).init();
|
|
121
123
|
this.isUserApp = isUserApp(manifest);
|
|
122
124
|
}
|
package/lib/app/lpk_installer.js
CHANGED
|
@@ -38,7 +38,7 @@ export class LpkInstaller {
|
|
|
38
38
|
let pkgPath = await builder.exec();
|
|
39
39
|
logger.info("开始部署应用");
|
|
40
40
|
const bridge = new DebugBridge();
|
|
41
|
-
await bridge.install(pkgPath);
|
|
41
|
+
await bridge.install(pkgPath, manifest["package"]);
|
|
42
42
|
const appUrl = `https://${manifest["application"]["subdomain"]}.${shellapi.boxname}.heiyu.space`;
|
|
43
43
|
logger.info(`👉 请在浏览器中访问 ${appUrl}`);
|
|
44
44
|
}
|
|
@@ -98,7 +98,7 @@ export class LpkInstaller {
|
|
|
98
98
|
|
|
99
99
|
const bridge = new DebugBridge();
|
|
100
100
|
logger.info("开始安装应用");
|
|
101
|
-
await bridge.install(pkgPath);
|
|
101
|
+
await bridge.install(pkgPath, manifest["package"]);
|
|
102
102
|
logger.info(`安装成功!`);
|
|
103
103
|
logger.info(
|
|
104
104
|
`👉 请在浏览器中访问 https://${manifest["application"]["subdomain"]}.${shellapi.boxname}.heiyu.space`
|
package/lib/box/index.js
CHANGED
|
@@ -10,6 +10,14 @@ export function boxCommand(box) {
|
|
|
10
10
|
await shellapi.setDefaultBox(boxname);
|
|
11
11
|
},
|
|
12
12
|
},
|
|
13
|
+
{
|
|
14
|
+
command: "default",
|
|
15
|
+
desc: "输出当前默认的盒子名",
|
|
16
|
+
handler: async () => {
|
|
17
|
+
await shellapi.init();
|
|
18
|
+
console.log(shellapi.boxname);
|
|
19
|
+
},
|
|
20
|
+
},
|
|
13
21
|
{
|
|
14
22
|
command: "list",
|
|
15
23
|
desc: "查看盒子列表",
|