@lazycatcloud/lzc-cli 1.3.5 → 1.3.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/changelog.md +10 -0
- package/lib/app/lpk_build.js +9 -1
- package/lib/app/lpk_create.js +8 -2
- package/lib/debug_bridge.js +9 -9
- package/lib/utils.js +30 -7
- package/package.json +1 -1
- package/template/_lpk/vue.lzc-build.yml.in +2 -2
- package/template/blank/lzc-build.yml +2 -2
- package/template/vue/lzc-build.yml +2 -2
package/changelog.md
CHANGED
package/lib/app/lpk_build.js
CHANGED
|
@@ -211,6 +211,9 @@ export class LpkBuild {
|
|
|
211
211
|
let lpkM = new LpkManifest()
|
|
212
212
|
await lpkM.init(this.manifestFilePath)
|
|
213
213
|
this.manifest = lpkM.manifest
|
|
214
|
+
// manifest使用 text/template模板时,标记为异常manifest
|
|
215
|
+
// 创建lpk时,直接将源文件拷入 lpk
|
|
216
|
+
this.excpManifest = lpkM.excpManifest
|
|
214
217
|
|
|
215
218
|
if (!isValidPackageName(this.manifest["package"])) {
|
|
216
219
|
throw `${this.manifest["package"]} 含有非法字符,请使用正确的包名格式(java的包名格式),如:cloud.lazycat.apps.video`
|
|
@@ -331,7 +334,12 @@ export class LpkBuild {
|
|
|
331
334
|
)
|
|
332
335
|
} else {
|
|
333
336
|
logger.debug("manifest\n", manifest)
|
|
334
|
-
|
|
337
|
+
// 异常的manifest,就将源文件给转到lpk内
|
|
338
|
+
if (this.excpManifest) {
|
|
339
|
+
fs.writeFileSync(path.join(tempDir, "manifest.yml"), fs.readFileSync(this.manifestFilePath, "utf8"))
|
|
340
|
+
} else {
|
|
341
|
+
dumpToYaml(manifest, path.join(tempDir, "manifest.yml"))
|
|
342
|
+
}
|
|
335
343
|
}
|
|
336
344
|
|
|
337
345
|
// compose.override.yml
|
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,12 @@ 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
|
+
this.excpManifest = true
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
|
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 (!obj.package && line.includes("package:") && line.split(":").length == 2) {
|
|
184
|
+
obj.package = line.split(":")[1]
|
|
185
|
+
}
|
|
186
|
+
if (!obj.application.subdomain && line.includes("subdomain:") && line.split(":").length == 2) {
|
|
187
|
+
obj.application.subdomain = line.split(":")[1]
|
|
188
|
+
}
|
|
189
|
+
if (!obj.version && 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 {
|
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 的情况
|