@lazycatcloud/lzc-cli 1.3.3 → 1.3.5
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 +8 -0
- package/lib/app/lpk_build.js +34 -2
- package/lib/utils.js +3 -14
- package/package.json +1 -1
- package/template/_lpk/manifest.yml.in +0 -2
- package/template/blank/lzc-manifest.yml +0 -1
package/changelog.md
CHANGED
package/lib/app/lpk_build.js
CHANGED
|
@@ -4,6 +4,7 @@ import logger from "loglevel"
|
|
|
4
4
|
import {
|
|
5
5
|
loadFromYaml,
|
|
6
6
|
isDirExist,
|
|
7
|
+
isDirSync,
|
|
7
8
|
isFileExist,
|
|
8
9
|
dumpToYaml,
|
|
9
10
|
envTemplateFile,
|
|
@@ -255,6 +256,8 @@ export class LpkBuild {
|
|
|
255
256
|
|
|
256
257
|
const tempDir = fs.mkdtempSync(".lzc-cli-build")
|
|
257
258
|
let contentdir = this.options["contentdir"]
|
|
259
|
+
let browserExtension = this.options["browser-extension"]
|
|
260
|
+
let aiPodService = this.options["ai-pod-service"]
|
|
258
261
|
try {
|
|
259
262
|
if (contentdir) {
|
|
260
263
|
contentdir = path.resolve(this.pwd, contentdir)
|
|
@@ -283,6 +286,32 @@ export class LpkBuild {
|
|
|
283
286
|
fs.rmSync(contentdir, { recursive: true })
|
|
284
287
|
}
|
|
285
288
|
|
|
289
|
+
if (browserExtension) {
|
|
290
|
+
browserExtension = path.resolve(this.pwd, browserExtension)
|
|
291
|
+
|
|
292
|
+
if (isDirSync(browserExtension)) {
|
|
293
|
+
// 开始打包 browserExtensionDir,这里打包成 zip 包
|
|
294
|
+
await archiveFolderTo(
|
|
295
|
+
browserExtension,
|
|
296
|
+
path.join(tempDir, "extension.zip")
|
|
297
|
+
)
|
|
298
|
+
} else if (isFileExist(browserExtension)) {
|
|
299
|
+
fs.copyFileSync(browserExtension, path.join(tempDir, "extension.zip"))
|
|
300
|
+
} else {
|
|
301
|
+
throw `${browserExtension} 不存在`
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (aiPodService) {
|
|
306
|
+
aiPodService = path.resolve(this.pwd, aiPodService)
|
|
307
|
+
if (!isDirExist(aiPodService)) {
|
|
308
|
+
throw `${aiPodService} 不存在`
|
|
309
|
+
}
|
|
310
|
+
fs.cpSync(aiPodService, path.join(tempDir, "ai-pod-service"), {
|
|
311
|
+
recursive: true
|
|
312
|
+
})
|
|
313
|
+
}
|
|
314
|
+
|
|
286
315
|
// 开始生成 manifest.yml
|
|
287
316
|
let manifest = await this.getManifest()
|
|
288
317
|
if (process.env.LZC_VERSION) {
|
|
@@ -306,8 +335,11 @@ export class LpkBuild {
|
|
|
306
335
|
}
|
|
307
336
|
|
|
308
337
|
// compose.override.yml
|
|
309
|
-
if (this.options[
|
|
310
|
-
dumpToYaml(
|
|
338
|
+
if (this.options["compose_override"]) {
|
|
339
|
+
dumpToYaml(
|
|
340
|
+
this.options["compose_override"],
|
|
341
|
+
path.join(tempDir, "compose.override.yml")
|
|
342
|
+
)
|
|
311
343
|
}
|
|
312
344
|
|
|
313
345
|
// 打包 lpk
|
package/lib/utils.js
CHANGED
|
@@ -579,22 +579,12 @@ export function findSshPublicKey() {
|
|
|
579
579
|
throw error
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
-
// 定义公钥优先级列表
|
|
583
|
-
const priorityKeys = [
|
|
584
|
-
"id_ed25519.pub",
|
|
585
|
-
"id_rsa.pub",
|
|
586
|
-
"id_ecdsa.pub",
|
|
587
|
-
"id_dsa.pub"
|
|
588
|
-
]
|
|
589
|
-
|
|
590
582
|
let avaiableKeys = []
|
|
591
583
|
try {
|
|
592
584
|
// 获取 .ssh 目录下所有文件
|
|
593
585
|
const files = fs.readdirSync(sshDir)
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
for (const keyName of priorityKeys) {
|
|
597
|
-
if (files.includes(keyName)) {
|
|
586
|
+
files.forEach((keyName) => {
|
|
587
|
+
if (keyName.endsWith(".pub")) {
|
|
598
588
|
const keyPath = path.join(sshDir, keyName)
|
|
599
589
|
// 验证文件是否可读
|
|
600
590
|
try {
|
|
@@ -605,10 +595,9 @@ export function findSshPublicKey() {
|
|
|
605
595
|
})
|
|
606
596
|
} catch (error) {
|
|
607
597
|
console.warn(`Found ${keyName} but cannot read it:`, error.message)
|
|
608
|
-
continue
|
|
609
598
|
}
|
|
610
599
|
}
|
|
611
|
-
}
|
|
600
|
+
})
|
|
612
601
|
|
|
613
602
|
if (avaiableKeys.length == 0) {
|
|
614
603
|
throw new Error(
|
package/package.json
CHANGED