@lazycatcloud/lzc-cli 1.2.27 → 1.2.28
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/apkshell.js +37 -0
- package/lib/app/index.js +74 -74
- package/lib/app/lpk_build.js +113 -117
- package/lib/app/lpk_create.js +78 -148
- package/lib/app/lpk_create_generator.js +101 -74
- package/lib/app/lpk_debug_bridge.js +65 -62
- package/lib/app/lpk_devshell.js +227 -228
- package/lib/app/lpk_devshell_docker.js +28 -28
- package/lib/app/lpk_installer.js +59 -49
- package/lib/appstore/index.js +29 -29
- package/lib/appstore/login.js +64 -64
- package/lib/appstore/prePublish.js +68 -68
- package/lib/appstore/publish.js +55 -55
- package/lib/box/index.js +25 -25
- package/lib/env.js +18 -18
- package/lib/shellapi.js +55 -58
- package/lib/utils.js +217 -164
- package/package.json +7 -1
- package/scripts/cli.js +56 -56
- package/template/_lpk/manifest.yml.in +8 -8
- package/template/vue/README.md +29 -0
- package/template/vue/index.html +13 -0
- package/template/vue/lzc-build.yml +59 -0
- package/template/vue/lzc-icon.png +0 -0
- package/template/vue/package.json +20 -0
- package/template/vue/public/vite.svg +1 -0
- package/template/vue/src/App.vue +30 -0
- package/template/vue/src/assets/vue.svg +1 -0
- package/template/vue/src/components/HelloWorld.vue +41 -0
- package/template/vue/src/main.ts +5 -0
- package/template/vue/src/style.css +79 -0
- package/template/vue/src/vite-env.d.ts +1 -0
- package/template/vue/tsconfig.app.json +24 -0
- package/template/vue/tsconfig.json +7 -0
- package/template/vue/tsconfig.node.json +22 -0
- package/template/vue/vite.config.ts +7 -0
- package/template/ionic_vue3/package-lock.json +0 -8100
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
import { spawn, spawnSync } from "child_process"
|
|
2
|
-
import fs from "node:fs"
|
|
3
|
-
import shellApi from "../shellapi.js"
|
|
4
|
-
import inquirer from "inquirer"
|
|
5
|
-
import { isDebugMode, resolveDomain } from "../utils.js"
|
|
6
|
-
|
|
1
|
+
import { spawn, spawnSync } from "child_process"
|
|
2
|
+
import fs from "node:fs"
|
|
3
|
+
import shellApi from "../shellapi.js"
|
|
4
|
+
import inquirer from "inquirer"
|
|
5
|
+
import { isDebugMode, resolveDomain } from "../utils.js"
|
|
7
6
|
|
|
8
7
|
export class DebugBridge {
|
|
9
8
|
constructor() {
|
|
10
|
-
this.uid = shellApi.uid
|
|
11
|
-
this.boxname = shellApi.boxname
|
|
12
|
-
this.domain = `dev.${this.boxname}.heiyu.space
|
|
13
|
-
this.sshCmd = `ssh ${isDebugMode() ? "-vv" : ""} -p 22222 box@${this.domain}
|
|
9
|
+
this.uid = shellApi.uid
|
|
10
|
+
this.boxname = shellApi.boxname
|
|
11
|
+
this.domain = `dev.${this.boxname}.heiyu.space`
|
|
12
|
+
this.sshCmd = `ssh ${isDebugMode() ? "-vv" : ""} -p 22222 box@${this.domain}`
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
async common(cmd, args) {
|
|
17
|
-
const resolvedIp = await resolveDomain(this.domain)
|
|
18
|
-
const sshCmd = cmd.replace(this.domain, resolvedIp)
|
|
16
|
+
const resolvedIp = await resolveDomain(this.domain)
|
|
17
|
+
const sshCmd = cmd.replace(this.domain, resolvedIp)
|
|
19
18
|
const ssh = spawnSync(sshCmd, args, {
|
|
20
19
|
shell: true,
|
|
21
20
|
encoding: "utf-8",
|
|
22
|
-
stdio: ["pipe", "pipe", "inherit"]
|
|
23
|
-
})
|
|
21
|
+
stdio: ["pipe", "pipe", "inherit"]
|
|
22
|
+
})
|
|
24
23
|
return new Promise((resolve, reject) => {
|
|
25
24
|
ssh.status == 0
|
|
26
25
|
? resolve(ssh.stdout)
|
|
27
|
-
: reject(
|
|
28
|
-
|
|
26
|
+
: reject(
|
|
27
|
+
`执行命令 ${sshCmd} ${args.join(" ")} 出错\n${ssh.stderr ?? ""}`
|
|
28
|
+
)
|
|
29
|
+
})
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
async install(lpkPath, pkgId) {
|
|
32
33
|
if (!(await this.canPublicKey())) {
|
|
33
|
-
await this.sshCopyId()
|
|
34
|
+
await this.sshCopyId()
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
const stream = fs.createReadStream(lpkPath)
|
|
37
|
-
const resolvedIp = await resolveDomain(this.domain)
|
|
37
|
+
const stream = fs.createReadStream(lpkPath)
|
|
38
|
+
const resolvedIp = await resolveDomain(this.domain)
|
|
38
39
|
const ssh = spawn(
|
|
39
40
|
`ssh -p 22222 box@${resolvedIp}`,
|
|
40
41
|
[`install --uid ${this.uid} --pkgId ${pkgId}`],
|
|
41
42
|
{
|
|
42
43
|
shell: true,
|
|
43
|
-
stdio: ["pipe", "inherit", "inherit"]
|
|
44
|
+
stdio: ["pipe", "inherit", "inherit"]
|
|
44
45
|
}
|
|
45
|
-
)
|
|
46
|
-
stream.pipe(ssh.stdin)
|
|
46
|
+
)
|
|
47
|
+
stream.pipe(ssh.stdin)
|
|
47
48
|
return new Promise((resolve, reject) => {
|
|
48
49
|
ssh.on("close", (code) => {
|
|
49
|
-
code == 0 ? resolve() : reject("install 失败")
|
|
50
|
-
})
|
|
51
|
-
})
|
|
50
|
+
code == 0 ? resolve() : reject("install 失败")
|
|
51
|
+
})
|
|
52
|
+
})
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
async canPublicKey() {
|
|
55
56
|
try {
|
|
56
|
-
await this.common(this.sshCmd, [`-o PasswordAuthentication=no`])
|
|
57
|
-
return true
|
|
57
|
+
await this.common(this.sshCmd, [`-o PasswordAuthentication=no`])
|
|
58
|
+
return true
|
|
58
59
|
} catch {
|
|
59
|
-
return false
|
|
60
|
+
return false
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -67,40 +68,38 @@ export class DebugBridge {
|
|
|
67
68
|
type: "input",
|
|
68
69
|
default: "y",
|
|
69
70
|
message:
|
|
70
|
-
"检测到你目前使用的密码帐号登录,是否使用 ssh-copy-id 上传密钥 (y/n): "
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
const answers = await inquirer.prompt(questions)
|
|
71
|
+
"检测到你目前使用的密码帐号登录,是否使用 ssh-copy-id 上传密钥 (y/n): "
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
const answers = await inquirer.prompt(questions)
|
|
74
75
|
if (answers.upload.toLowerCase() == "y") {
|
|
75
|
-
const resolvedIp = await resolveDomain(this.domain)
|
|
76
|
-
return this.common(`ssh-copy-id`, [
|
|
77
|
-
`-f -p 22222 box@${resolvedIp}`,
|
|
78
|
-
]);
|
|
76
|
+
const resolvedIp = await resolveDomain(this.domain)
|
|
77
|
+
return this.common(`ssh-copy-id`, [`-f -p 22222 box@${resolvedIp}`])
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
async status(appId) {
|
|
83
|
-
return this.common(this.sshCmd, [`status --uid ${this.uid}`, appId])
|
|
82
|
+
return this.common(this.sshCmd, [`status --uid ${this.uid}`, appId])
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
async isDevshell(appId) {
|
|
87
86
|
const stdout = await this.common(this.sshCmd, [
|
|
88
87
|
`isDevshell --uid ${this.uid}`,
|
|
89
|
-
appId
|
|
90
|
-
])
|
|
91
|
-
return stdout == "true"
|
|
88
|
+
appId
|
|
89
|
+
])
|
|
90
|
+
return stdout == "true"
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
async resume(appId) {
|
|
95
|
-
return this.common(this.sshCmd, [`resume --uid ${this.uid}`, appId])
|
|
94
|
+
return this.common(this.sshCmd, [`resume --uid ${this.uid}`, appId])
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
async uninstall(appId) {
|
|
99
|
-
return this.common(this.sshCmd, [`uninstall --uid ${this.uid}`, appId])
|
|
98
|
+
return this.common(this.sshCmd, [`uninstall --uid ${this.uid}`, appId])
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
async devshell(appId, isUserApp, onconnect = null) {
|
|
103
|
-
const resolvedIp = await resolveDomain(this.domain)
|
|
102
|
+
const resolvedIp = await resolveDomain(this.domain)
|
|
104
103
|
const stream = spawn(
|
|
105
104
|
`ssh -p 22222 box@${resolvedIp}`,
|
|
106
105
|
[
|
|
@@ -109,40 +108,44 @@ export class DebugBridge {
|
|
|
109
108
|
`--uid ${this.uid}`,
|
|
110
109
|
isUserApp ? "--userapp" : "",
|
|
111
110
|
appId,
|
|
112
|
-
"/lzcapp/pkg/content/devshell/exec.sh"
|
|
111
|
+
"/lzcapp/pkg/content/devshell/exec.sh"
|
|
113
112
|
],
|
|
114
113
|
{
|
|
115
114
|
shell: true,
|
|
116
|
-
stdio: "inherit"
|
|
115
|
+
stdio: "inherit"
|
|
117
116
|
}
|
|
118
|
-
)
|
|
117
|
+
)
|
|
119
118
|
return new Promise((resolve, reject) => {
|
|
120
119
|
stream.on("close", (code) => {
|
|
121
|
-
code == 0 ? resolve() : reject()
|
|
122
|
-
})
|
|
120
|
+
code == 0 ? resolve() : reject()
|
|
121
|
+
})
|
|
123
122
|
if (onconnect) {
|
|
124
|
-
stream.on("spawn", onconnect)
|
|
123
|
+
stream.on("spawn", onconnect)
|
|
125
124
|
}
|
|
126
|
-
})
|
|
125
|
+
})
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
async buildImage(label, contextTar) {
|
|
130
|
-
const tag = `debug.bridge/${label}
|
|
131
|
-
const resolvedIp = await resolveDomain(this.domain)
|
|
132
|
-
const stream = fs.createReadStream(contextTar)
|
|
133
|
-
const ssh = spawn(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
const tag = `debug.bridge/${label}`
|
|
130
|
+
const resolvedIp = await resolveDomain(this.domain)
|
|
131
|
+
const stream = fs.createReadStream(contextTar)
|
|
132
|
+
const ssh = spawn(
|
|
133
|
+
`ssh -p 22222 box@${resolvedIp}`,
|
|
134
|
+
[`build --tag ${tag}`],
|
|
135
|
+
{
|
|
136
|
+
shell: true,
|
|
137
|
+
stdio: ["pipe", "inherit", "inherit"]
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
stream.pipe(ssh.stdin)
|
|
138
141
|
return new Promise((resolve, reject) => {
|
|
139
142
|
ssh.on("close", (code) => {
|
|
140
143
|
code == 0
|
|
141
144
|
? resolve(`dev.${this.boxname}.heiyu.space/${tag}`)
|
|
142
|
-
: reject("在盒子中构建 image 失败")
|
|
143
|
-
})
|
|
145
|
+
: reject("在盒子中构建 image 失败")
|
|
146
|
+
})
|
|
144
147
|
}).finally(() => {
|
|
145
|
-
fs.rmSync(contextTar)
|
|
146
|
-
})
|
|
148
|
+
fs.rmSync(contextTar)
|
|
149
|
+
})
|
|
147
150
|
}
|
|
148
151
|
}
|