@lazycatcloud/lzc-cli 1.3.4 → 1.3.6
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/changelog.md +10 -0
- package/lib/app/lpk_create.js +7 -2
- package/lib/debug_bridge.js +9 -9
- package/lib/utils.js +33 -21
- package/package.json +1 -1
- package/template/_lpk/manifest.yml.in +0 -2
- package/template/_lpk/vue.lzc-build.yml.in +2 -2
- package/template/blank/lzc-build.yml +2 -2
- package/template/blank/lzc-manifest.yml +0 -1
- package/template/vue/lzc-build.yml +2 -2
package/changelog.md
CHANGED
package/lib/app/lpk_create.js
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
ensureDirectoryExists,
|
|
9
9
|
dumpToYaml,
|
|
10
10
|
isFileExist,
|
|
11
|
-
isValidAppId
|
|
11
|
+
isValidAppId,
|
|
12
|
+
fakeLoadManifestYml
|
|
12
13
|
} from "../utils.js"
|
|
13
14
|
import path from "node:path"
|
|
14
15
|
import { TemplateConfig } from "./lpk_create_generator.js"
|
|
@@ -40,7 +41,11 @@ export class LpkManifest {
|
|
|
40
41
|
let answer = await this.askLpkInfo()
|
|
41
42
|
this.manifest = yaml.load(await envTemplateFile(manifestFilePath, answer))
|
|
42
43
|
} else {
|
|
43
|
-
|
|
44
|
+
try {
|
|
45
|
+
this.manifest = loadFromYaml(manifestFilePath)
|
|
46
|
+
} catch (err) {
|
|
47
|
+
this.manifest = fakeLoadManifestYml(manifestFilePath)
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
|
package/lib/debug_bridge.js
CHANGED
|
@@ -93,8 +93,8 @@ export class DebugBridge {
|
|
|
93
93
|
ssh.status == 0
|
|
94
94
|
? resolve(ssh.stdout)
|
|
95
95
|
: reject(
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
`执行命令 ${cmd} ${args.join(" ")} 出错\n${ssh.stdout ?? ""}\n${ssh.stderr ?? ""}`
|
|
97
|
+
)
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -146,11 +146,11 @@ export class DebugBridge {
|
|
|
146
146
|
const pk = Buffer.from(sshInfo.content.trimLeft()).toString("base64")
|
|
147
147
|
|
|
148
148
|
logger.warn(
|
|
149
|
-
|
|
150
|
-
-> https://${this.domain}/auth?key=${pk}
|
|
149
|
+
`您当前机器的公钥未添加到微服(${this.boxname})的信任列表中,请使用微服管理员账号在浏览器中访问以下地址,将您选择的公钥自动添加到信任列表中。(所有操作均只在您微服中进行,包括本开发机在内的任何数据不会泄漏到您的微服之外)
|
|
151
150
|
|
|
152
|
-
|
|
151
|
+
-> https://${this.domain}/auth?key=${pk}
|
|
153
152
|
`
|
|
153
|
+
|
|
154
154
|
)
|
|
155
155
|
throw "请在授权完成后重试!"
|
|
156
156
|
}
|
|
@@ -267,10 +267,10 @@ export class DebugBridge {
|
|
|
267
267
|
buildStream.on("close", (code) => {
|
|
268
268
|
code == 0
|
|
269
269
|
? resolve(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
compareVersions("0.1.12", backendVersion) >= 0
|
|
271
|
+
? `127.0.0.1:5000/${tag}`
|
|
272
|
+
: `dev.${this.boxname}.heiyu.space/${tag}`
|
|
273
|
+
)
|
|
274
274
|
: reject(`在盒子中构建 image 失败`)
|
|
275
275
|
})
|
|
276
276
|
}).finally(() => {
|
package/lib/utils.js
CHANGED
|
@@ -170,6 +170,29 @@ export function loadFromYaml(file) {
|
|
|
170
170
|
return yaml.load(fs.readFileSync(file, "utf8"))
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
// lzc-manifest.yml 要支持模板,目前无法直接用yaml库解释,手动读出必要字段
|
|
174
|
+
export function fakeLoadManifestYml(file) {
|
|
175
|
+
const res = fs.readFileSync(file, "utf8")
|
|
176
|
+
let obj = {
|
|
177
|
+
application: {
|
|
178
|
+
subdomain: undefined,
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
res.split("\n").forEach(v => {
|
|
182
|
+
let line = v.trim().replace(" ", "")
|
|
183
|
+
if (line.includes("package") && line.split(":").length == 2) {
|
|
184
|
+
obj.package = line.split(":")[1]
|
|
185
|
+
}
|
|
186
|
+
if (line.includes("subdomain") && line.split(":").length == 2) {
|
|
187
|
+
obj.application.subdomain = line.split(":")[1]
|
|
188
|
+
}
|
|
189
|
+
if (line.includes("version") && line.split(":").length == 2) {
|
|
190
|
+
obj.version = line.split(":")[1]
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
return obj
|
|
194
|
+
}
|
|
195
|
+
|
|
173
196
|
export function dumpToYaml(template, target) {
|
|
174
197
|
fs.writeFileSync(
|
|
175
198
|
target,
|
|
@@ -323,18 +346,18 @@ export async function md5File(filepath) {
|
|
|
323
346
|
}
|
|
324
347
|
|
|
325
348
|
export class Downloader {
|
|
326
|
-
constructor() {}
|
|
349
|
+
constructor() { }
|
|
327
350
|
|
|
328
351
|
showDownloadingProgress(received, total) {
|
|
329
352
|
let percentage = ((received * 100) / total).toFixed(2)
|
|
330
353
|
process.stdout.write("\r")
|
|
331
354
|
process.stdout.write(
|
|
332
355
|
percentage +
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
356
|
+
"% | " +
|
|
357
|
+
received +
|
|
358
|
+
" bytes downloaded out of " +
|
|
359
|
+
total +
|
|
360
|
+
" bytes."
|
|
338
361
|
)
|
|
339
362
|
}
|
|
340
363
|
|
|
@@ -464,7 +487,7 @@ export function isTraceMode() {
|
|
|
464
487
|
// 会直接报错,连版本检测都到不了(包导入的太前面了)
|
|
465
488
|
async function __resolveDomain(domain, ipv6 = false) {
|
|
466
489
|
return new Promise((resolve, reject) => {
|
|
467
|
-
const callback = function
|
|
490
|
+
const callback = function(err, addresses) {
|
|
468
491
|
if (addresses && addresses.length > 0) {
|
|
469
492
|
resolve(addresses[0])
|
|
470
493
|
} else {
|
|
@@ -579,22 +602,12 @@ export function findSshPublicKey() {
|
|
|
579
602
|
throw error
|
|
580
603
|
}
|
|
581
604
|
|
|
582
|
-
// 定义公钥优先级列表
|
|
583
|
-
const priorityKeys = [
|
|
584
|
-
"id_ed25519.pub",
|
|
585
|
-
"id_rsa.pub",
|
|
586
|
-
"id_ecdsa.pub",
|
|
587
|
-
"id_dsa.pub"
|
|
588
|
-
]
|
|
589
|
-
|
|
590
605
|
let avaiableKeys = []
|
|
591
606
|
try {
|
|
592
607
|
// 获取 .ssh 目录下所有文件
|
|
593
608
|
const files = fs.readdirSync(sshDir)
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
for (const keyName of priorityKeys) {
|
|
597
|
-
if (files.includes(keyName)) {
|
|
609
|
+
files.forEach((keyName) => {
|
|
610
|
+
if (keyName.endsWith(".pub")) {
|
|
598
611
|
const keyPath = path.join(sshDir, keyName)
|
|
599
612
|
// 验证文件是否可读
|
|
600
613
|
try {
|
|
@@ -605,10 +618,9 @@ export function findSshPublicKey() {
|
|
|
605
618
|
})
|
|
606
619
|
} catch (error) {
|
|
607
620
|
console.warn(`Found ${keyName} but cannot read it:`, error.message)
|
|
608
|
-
continue
|
|
609
621
|
}
|
|
610
622
|
}
|
|
611
|
-
}
|
|
623
|
+
})
|
|
612
624
|
|
|
613
625
|
if (avaiableKeys.length == 0) {
|
|
614
626
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -22,11 +22,11 @@ icon: ./lazycat.png
|
|
|
22
22
|
# deploy_params: ./lzc-deploy-params.yml
|
|
23
23
|
|
|
24
24
|
# devshell 自定义应用的开发容器环境
|
|
25
|
-
# -
|
|
25
|
+
# - routes 指定应用容器的访问路由
|
|
26
26
|
|
|
27
27
|
# devshell 没有指定 image 的情况,将会默认使用 registry.lazycat.cloud/lzc-cli/devshell:v0.0.5
|
|
28
28
|
# devshell:
|
|
29
|
-
#
|
|
29
|
+
# routes:
|
|
30
30
|
# - /=http://127.0.0.1:8080
|
|
31
31
|
|
|
32
32
|
# devshell 指定 image 的情况
|
|
@@ -18,11 +18,11 @@ pkgout: ./
|
|
|
18
18
|
# icon 仅仅允许 png 后缀的文件
|
|
19
19
|
icon: ./lzc-icon.png
|
|
20
20
|
# devshell 自定义应用的开发容器环境
|
|
21
|
-
# -
|
|
21
|
+
# - routes 指定应用容器的访问路由
|
|
22
22
|
|
|
23
23
|
# devshell 没有指定 image 的情况,将会默认使用 registry.lazycat.cloud/lzc-cli/devshell:v0.0.5
|
|
24
24
|
# devshell:
|
|
25
|
-
#
|
|
25
|
+
# routes:
|
|
26
26
|
# - /=http://127.0.0.1:8080
|
|
27
27
|
|
|
28
28
|
# devshell 指定 image 的情况
|
|
@@ -19,11 +19,11 @@ pkgout: ./
|
|
|
19
19
|
icon: ./lzc-icon.png
|
|
20
20
|
|
|
21
21
|
# devshell 自定义应用的开发容器环境
|
|
22
|
-
# -
|
|
22
|
+
# - routes 指定应用容器的访问路由
|
|
23
23
|
|
|
24
24
|
# devshell 没有指定 image 的情况,将会默认使用 registry.lazycat.cloud/lzc-cli/devshell:v0.0.5
|
|
25
25
|
# devshell:
|
|
26
|
-
#
|
|
26
|
+
# routes:
|
|
27
27
|
# - /=http://127.0.0.1:8080
|
|
28
28
|
|
|
29
29
|
# devshell 指定 image 的情况
|