@lazycatcloud/lzc-cli 1.2.8 → 1.2.10

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/index.js CHANGED
@@ -36,8 +36,6 @@ export function lpkProjectCommand(program) {
36
36
  });
37
37
  },
38
38
  handler: async ({ context, output, file }) => {
39
- await shellApi.init();
40
-
41
39
  const lpk = await new LpkBuild(context, file).init();
42
40
  // 正常的打包逻辑不需要 devshell
43
41
  lpk.onBeforeBuildPackage(async (options) => {
package/lib/shellapi.js CHANGED
@@ -4,6 +4,7 @@ import { contextDirname } from "./utils.js";
4
4
  import path from "node:path";
5
5
  import fs from "node:fs";
6
6
  import os from "node:os";
7
+ import logger from "loglevel";
7
8
 
8
9
  /**
9
10
  * @link {https://www.npmjs.com/package/appdirs}
@@ -84,10 +85,15 @@ class ShellApi {
84
85
  }
85
86
 
86
87
  async initBoxInfo() {
87
- const boxes = await this.boxList();
88
- const box = boxes.find((b) => b.is_default_box);
89
- if (box) {
90
- return { uid: box.login_user, boxname: box.box_name };
88
+ try {
89
+ const boxes = await this.boxList();
90
+ const box = boxes.find((b) => b.is_default_box);
91
+ if (box) {
92
+ return { uid: box.login_user, boxname: box.box_name };
93
+ }
94
+ } catch (e) {
95
+ logger.debug("Error: ", e);
96
+ throw "获取盒子信息失败,请检查客户端是否已经连接!";
91
97
  }
92
98
  throw "没有默认盒子信息, 请先使用 lzc-cli box switch 设置默认的盒子信息";
93
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "files": [
6
6
  "template",
@@ -1,5 +1,13 @@
1
1
  #!/bin/sh
2
2
 
3
+ # 设置 lzcapp 环境变量
4
+ # 从1号进程读取环境变量
5
+ cat > /tmp/lzcapp_env.sh << EOF
6
+ #!/bin/sh
7
+ $(/lzcapp/pkg/content/devshell/busybox tr '\0' '\n' < /proc/1/environ | /lzcapp/pkg/content/devshell/busybox xargs -I{} echo export {})
8
+ EOF
9
+ . /tmp/lzcapp_env.sh
10
+
3
11
  # 执行 setupscript 脚本
4
12
  SETUPSCRIPT=/lzcapp/pkg/content/devshell/setupscript
5
13
  if [ -f $SETUPSCRIPT ];then