@lazycatcloud/lzc-cli 1.2.32 → 1.2.34
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/lpk_debug_bridge.js +18 -11
- package/lib/app/lpk_devshell.js +9 -4
- package/lib/utils.js +11 -0
- package/package.json +1 -1
- package/template/ionic_vue3/package-lock.json +8100 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { spawn, spawnSync } from "child_process"
|
|
2
2
|
import fs from "node:fs"
|
|
3
3
|
import shellApi from "../shellapi.js"
|
|
4
|
-
import
|
|
5
|
-
import { isDebugMode, resolveDomain, sleep } from "../utils.js"
|
|
4
|
+
import { isDebugMode, resolveDomain, sleep, sshCmd } from "../utils.js"
|
|
6
5
|
import logger from "loglevel"
|
|
7
6
|
|
|
8
7
|
export class DebugBridge {
|
|
@@ -10,13 +9,17 @@ export class DebugBridge {
|
|
|
10
9
|
this.uid = shellApi.uid
|
|
11
10
|
this.boxname = shellApi.boxname
|
|
12
11
|
this.domain = `dev.${this.boxname}.heiyu.space`
|
|
13
|
-
this.sshCmd =
|
|
12
|
+
this.sshCmd = sshCmd(
|
|
13
|
+
`${isDebugMode() ? "-vv" : ""}`,
|
|
14
|
+
"-p 22222",
|
|
15
|
+
`box@${this.domain}`
|
|
16
|
+
)
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
async common(cmd, args) {
|
|
17
20
|
const resolvedIp = await resolveDomain(this.domain)
|
|
18
|
-
const
|
|
19
|
-
const ssh = spawnSync(
|
|
21
|
+
const resolvedCmd = cmd.replace(this.domain, resolvedIp)
|
|
22
|
+
const ssh = spawnSync(resolvedCmd, args, {
|
|
20
23
|
shell: true,
|
|
21
24
|
encoding: "utf-8",
|
|
22
25
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -25,7 +28,7 @@ export class DebugBridge {
|
|
|
25
28
|
ssh.status == 0
|
|
26
29
|
? resolve(ssh.stdout)
|
|
27
30
|
: reject(
|
|
28
|
-
`执行命令 ${
|
|
31
|
+
`执行命令 ${resolvedCmd} ${args.join(" ")} 出错\n${ssh.stderr ?? ""}`
|
|
29
32
|
)
|
|
30
33
|
})
|
|
31
34
|
}
|
|
@@ -39,7 +42,7 @@ export class DebugBridge {
|
|
|
39
42
|
const stream = fs.createReadStream(lpkPath)
|
|
40
43
|
const resolvedIp = await resolveDomain(this.domain)
|
|
41
44
|
const ssh = spawn(
|
|
42
|
-
|
|
45
|
+
sshCmd("-p 22222", `box@${resolvedIp}`),
|
|
43
46
|
[`install --uid ${this.uid} --pkgId ${pkgId}`],
|
|
44
47
|
{
|
|
45
48
|
shell: true,
|
|
@@ -61,7 +64,9 @@ export class DebugBridge {
|
|
|
61
64
|
|
|
62
65
|
async sshCopyId() {
|
|
63
66
|
const resolvedIp = await resolveDomain(this.domain)
|
|
64
|
-
return this.common(`ssh-copy-id`, [
|
|
67
|
+
return this.common(`ssh-copy-id`, [
|
|
68
|
+
`-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -f -p 22222 box@${resolvedIp}`
|
|
69
|
+
])
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
async status(appId) {
|
|
@@ -85,7 +90,6 @@ export class DebugBridge {
|
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
async devshell(appId, isUserApp, onconnect = null) {
|
|
88
|
-
const resolvedIp = await resolveDomain(this.domain)
|
|
89
93
|
let waiting = true
|
|
90
94
|
while (waiting) {
|
|
91
95
|
if (await this.isDevshell(appId)) {
|
|
@@ -96,8 +100,10 @@ export class DebugBridge {
|
|
|
96
100
|
await sleep(100)
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
const resolvedIp = await resolveDomain(this.domain)
|
|
104
|
+
|
|
99
105
|
const stream = spawn(
|
|
100
|
-
|
|
106
|
+
sshCmd("-p 22222", `box@${resolvedIp}`),
|
|
101
107
|
[
|
|
102
108
|
"-t",
|
|
103
109
|
"devshell",
|
|
@@ -127,8 +133,9 @@ export class DebugBridge {
|
|
|
127
133
|
const tag = `debug.bridge/${label}`
|
|
128
134
|
const resolvedIp = await resolveDomain(this.domain)
|
|
129
135
|
const stream = fs.createReadStream(contextTar)
|
|
136
|
+
|
|
130
137
|
const ssh = spawn(
|
|
131
|
-
|
|
138
|
+
sshCmd("-p 22222", `box@${resolvedIp}`),
|
|
132
139
|
[`build --tag ${tag}`],
|
|
133
140
|
{
|
|
134
141
|
shell: true,
|
package/lib/app/lpk_devshell.js
CHANGED
|
@@ -18,8 +18,7 @@ import {
|
|
|
18
18
|
isUserApp,
|
|
19
19
|
createTemplateFileCommon,
|
|
20
20
|
isDebugMode,
|
|
21
|
-
resolveDomain
|
|
22
|
-
sleep
|
|
21
|
+
resolveDomain
|
|
23
22
|
} from "../utils.js"
|
|
24
23
|
import os from "node:os"
|
|
25
24
|
import commandExists from "command-exists"
|
|
@@ -359,6 +358,12 @@ export class AppDevShell {
|
|
|
359
358
|
return manifest
|
|
360
359
|
})
|
|
361
360
|
|
|
361
|
+
// devshell 模式下,默认打开后台常驻
|
|
362
|
+
this.lpkBuild.onBeforeDumpYaml(async (manifest) => {
|
|
363
|
+
manifest["application"]["background_task"] = true
|
|
364
|
+
return manifest
|
|
365
|
+
})
|
|
366
|
+
|
|
362
367
|
// 添加一个 devshell 的标记在 lpk 中,标记当前 lpk 为一个 debug 版本
|
|
363
368
|
this.lpkBuild.onBeforeDumpLpk(async (options, cwd, destDir) => {
|
|
364
369
|
fs.writeFileSync(path.resolve(destDir, "devshell"), "")
|
|
@@ -412,8 +417,8 @@ class DevShell {
|
|
|
412
417
|
const resolvedIp = await resolveDomain(`dev.${shellApi.boxname}.heiyu.space`);
|
|
413
418
|
let rsh = [
|
|
414
419
|
"ssh",
|
|
415
|
-
"-
|
|
416
|
-
`box
|
|
420
|
+
"-o",
|
|
421
|
+
`"ProxyCommand ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q -W %h:%p -p 22222 box@${resolvedIp}"`,
|
|
417
422
|
"-p",
|
|
418
423
|
`22222`,
|
|
419
424
|
"-o",
|
package/lib/utils.js
CHANGED
|
@@ -464,3 +464,14 @@ export async function resolveDomain(domain) {
|
|
|
464
464
|
throw new Error(`无法解析域名 ${domain}: ${error.message}`)
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
+
|
|
468
|
+
export function sshCmd(...args) {
|
|
469
|
+
const baseCommand = "ssh"
|
|
470
|
+
const defaultOptions = [
|
|
471
|
+
"-o StrictHostKeyChecking=no",
|
|
472
|
+
"-o UserKnownHostsFile=/dev/null",
|
|
473
|
+
"-q"
|
|
474
|
+
]
|
|
475
|
+
const options = [...defaultOptions, ...args].join(" ")
|
|
476
|
+
return `${baseCommand} ${options}`
|
|
477
|
+
}
|