@lazycatcloud/lzc-cli 1.2.33 → 1.2.35

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.
@@ -358,6 +358,12 @@ export class AppDevShell {
358
358
  return manifest
359
359
  })
360
360
 
361
+ // devshell 模式下,默认打开后台常驻
362
+ this.lpkBuild.onBeforeDumpYaml(async (manifest) => {
363
+ manifest["application"]["background_task"] = true
364
+ return manifest
365
+ })
366
+
361
367
  // 添加一个 devshell 的标记在 lpk 中,标记当前 lpk 为一个 debug 版本
362
368
  this.lpkBuild.onBeforeDumpLpk(async (options, cwd, destDir) => {
363
369
  fs.writeFileSync(path.resolve(destDir, "devshell"), "")
@@ -441,7 +447,7 @@ class DevShell {
441
447
  try {
442
448
  execSync(
443
449
  `rsync ${rsyncDebug} --rsh='${rsh}' --recursive --relative --perms --update -F --filter=':- .gitignore' --ignore-errors . ${dest}`,
444
- { stdio: ["ignore", "inherit", "inherit"] }
450
+ { stdio: ["ignore", isDebugMode() ? "inherit" : "ignore", "inherit"] }
445
451
  )
446
452
  } catch (err) {
447
453
  logger.error("rsync 同步失败")
@@ -1,8 +1,7 @@
1
1
  import logger from "loglevel"
2
2
  import fs from "node:fs"
3
3
  import path from "node:path"
4
- import { loadFromYaml, Downloader } from "../utils.js"
5
- import { spawnSync } from "node:child_process"
4
+ import { loadFromYaml, Downloader, unzipSync } from "../utils.js"
6
5
  import { DebugBridge } from "./lpk_debug_bridge.js"
7
6
  import shellapi from "../shellapi.js"
8
7
  import { triggerApk } from "./apkshell.js"
@@ -94,7 +93,7 @@ export class LpkInstaller {
94
93
  const tempDir = fs.mkdtempSync(".lzc-cli-install")
95
94
  let manifest
96
95
  try {
97
- spawnSync("unzip", ["-d", tempDir, pkgPath])
96
+ unzipSync(pkgPath, tempDir)
98
97
  manifest = loadFromYaml(path.join(tempDir, "manifest.yml"))
99
98
  logger.debug("是否生成APK:", installConfig.apk)
100
99
  if (installConfig.apk) {
@@ -3,9 +3,8 @@ import logger from "loglevel"
3
3
  import FormData from "form-data"
4
4
  import fs from "node:fs"
5
5
  import inquirer from "inquirer"
6
- import { spawnSync } from "node:child_process"
7
6
  import path from "node:path"
8
- import { isFileExist, isPngWithFile } from "../utils.js"
7
+ import { isFileExist, isPngWithFile, unzipSync } from "../utils.js"
9
8
  import env from "../env.js"
10
9
 
11
10
  async function askChangeLog() {
@@ -50,7 +49,7 @@ export class PrePublish {
50
49
  preCheck(pkgPath) {
51
50
  const tempDir = fs.mkdtempSync(".lzc-cli-publish")
52
51
  try {
53
- spawnSync("unzip", ["-d", tempDir, pkgPath])
52
+ unzipSync(pkgPath, tempDir)
54
53
  if (isFileExist(path.join(tempDir, "devshell"))) {
55
54
  logger.error(
56
55
  "不能发布一个devshell的版本,请重新使用 `lzc-cli project build` 构建"
@@ -3,9 +3,8 @@ import logger from "loglevel"
3
3
  import FormData from "form-data"
4
4
  import fs from "node:fs"
5
5
  import inquirer from "inquirer"
6
- import { spawnSync } from "node:child_process"
7
6
  import path from "node:path"
8
- import { isFileExist, isPngWithFile } from "../utils.js"
7
+ import { isFileExist, isPngWithFile, unzipSync } from "../utils.js"
9
8
 
10
9
  async function askChangeLog() {
11
10
  const noEmpty = (value) => value != ""
@@ -36,7 +35,7 @@ export class Publish {
36
35
  preCheck(pkgPath) {
37
36
  const tempDir = fs.mkdtempSync(".lzc-cli-publish")
38
37
  try {
39
- spawnSync("unzip", ["-d", tempDir, pkgPath])
38
+ unzipSync(pkgPath, tempDir)
40
39
  if (isFileExist(path.join(tempDir, "devshell"))) {
41
40
  logger.error(
42
41
  "不能发布一个devshell的版本,请重新使用 `lzc-cli project build` 构建"
package/lib/utils.js CHANGED
@@ -17,6 +17,7 @@ import logger from "loglevel"
17
17
  import * as tar from "tar"
18
18
  import dns from "node:dns/promises"
19
19
  import axios from "axios"
20
+ import AdmZip from "adm-zip"
20
21
 
21
22
  // 创建 Axios 实例
22
23
  export const api = axios.create()
@@ -475,3 +476,13 @@ export function sshCmd(...args) {
475
476
  const options = [...defaultOptions, ...args].join(" ")
476
477
  return `${baseCommand} ${options}`
477
478
  }
479
+
480
+ export function unzipSync(zipPath, destPath) {
481
+ // 确保目标目录存在
482
+ fs.mkdirSync(destPath, { recursive: true })
483
+ // 创建 zip 实例
484
+ const zip = new AdmZip(zipPath)
485
+
486
+ // 同步解压所有文件
487
+ zip.extractAllTo(destPath, true)
488
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.33",
3
+ "version": "1.2.35",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "files": [
6
6
  "template",
@@ -20,6 +20,7 @@
20
20
  "@balena/dockerignore": "^1.0.2",
21
21
  "@grpc/grpc-js": "^1.11.1",
22
22
  "@grpc/proto-loader": "^0.7.13",
23
+ "adm-zip": "^0.5.16",
23
24
  "archiver": "^7.0.1",
24
25
  "axios": "^1.7.7",
25
26
  "chalk": "^5.3.0",