@lazycatcloud/lzc-cli 1.3.17 → 2.0.0-pre.1

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.
Files changed (128) hide show
  1. package/README.md +47 -7
  2. package/changelog.md +14 -0
  3. package/lib/app/apkshell.js +7 -44
  4. package/lib/app/index.js +178 -64
  5. package/lib/app/lpk_build.js +446 -61
  6. package/lib/app/lpk_build_images.js +749 -0
  7. package/lib/app/lpk_create.js +192 -45
  8. package/lib/app/lpk_create_generator.js +141 -13
  9. package/lib/app/lpk_devshell.js +33 -19
  10. package/lib/app/lpk_embed_images.js +257 -0
  11. package/lib/app/lpk_installer.js +17 -9
  12. package/lib/app/manifest_build.js +259 -0
  13. package/lib/app/project_cp.js +59 -0
  14. package/lib/app/project_deploy.js +58 -0
  15. package/lib/app/project_exec.js +82 -0
  16. package/lib/app/project_info.js +106 -0
  17. package/lib/app/project_log.js +62 -0
  18. package/lib/app/project_runtime.js +356 -0
  19. package/lib/app/project_start.js +95 -0
  20. package/lib/app/project_sync.js +499 -0
  21. package/lib/appstore/apkshell.js +50 -0
  22. package/lib/box/index.js +101 -4
  23. package/lib/box/ssh_remote.js +259 -0
  24. package/lib/build_remote.js +21 -0
  25. package/lib/debug_bridge.js +891 -83
  26. package/lib/docker/index.js +30 -10
  27. package/lib/i18n/locales/en/translation.json +262 -255
  28. package/lib/i18n/locales/zh/translation.json +262 -255
  29. package/lib/lpk/core.js +488 -0
  30. package/lib/lpk/index.js +210 -0
  31. package/lib/migrate/index.js +52 -0
  32. package/lib/package_info.js +135 -0
  33. package/lib/shellapi.js +35 -1
  34. package/lib/sig/core.js +254 -0
  35. package/lib/sig/index.js +88 -0
  36. package/lib/utils.js +94 -15
  37. package/package.json +3 -3
  38. package/scripts/cli.js +6 -0
  39. package/scripts/smoke/frontend-dev-entry.mjs +104 -0
  40. package/scripts/smoke/template-project.mjs +311 -0
  41. package/template/_lpk/README.md +15 -4
  42. package/template/_lpk/gui-vnc.manifest.yml.in +18 -0
  43. package/template/_lpk/hello-vue.manifest.yml.in +38 -0
  44. package/template/_lpk/manifest.yml.in +4 -11
  45. package/template/_lpk/package.yml.in +7 -0
  46. package/template/_lpk/todolist-golang.manifest.yml.in +30 -0
  47. package/template/_lpk/todolist-java.manifest.yml.in +29 -0
  48. package/template/_lpk/todolist-python.manifest.yml.in +37 -0
  49. package/template/_lpk/todolist-serverless.manifest.yml.in +38 -0
  50. package/template/_lpk/vue.lzc-build.yml.in +0 -44
  51. package/template/blank/lzc-build.dev.yml +4 -0
  52. package/template/blank/lzc-build.yml +24 -41
  53. package/template/blank/lzc-manifest.yml +7 -9
  54. package/template/blank/package.yml +7 -0
  55. package/template/golang/Dockerfile +19 -0
  56. package/template/golang/Dockerfile.dev +20 -0
  57. package/template/golang/README.md +44 -0
  58. package/template/golang/_gitignore +3 -0
  59. package/template/golang/_lzcdevignore +21 -0
  60. package/template/golang/go.mod +3 -0
  61. package/template/golang/lzc-build.dev.yml +12 -0
  62. package/template/golang/lzc-build.yml +16 -0
  63. package/template/golang/lzc-icon.png +0 -0
  64. package/template/golang/main.go +252 -0
  65. package/template/golang/manifest.dev.page.js +24 -0
  66. package/template/golang/run.sh +10 -0
  67. package/template/golang/web/index.html +238 -0
  68. package/template/gui-vnc/README.md +23 -0
  69. package/template/gui-vnc/_gitignore +2 -0
  70. package/template/gui-vnc/images/Dockerfile +30 -0
  71. package/template/gui-vnc/images/kasmvnc.yaml +33 -0
  72. package/template/gui-vnc/images/startup-script.desktop +9 -0
  73. package/template/gui-vnc/images/startup-script.sh +6 -0
  74. package/template/gui-vnc/lzc-build.dev.yml +4 -0
  75. package/template/gui-vnc/lzc-build.yml +18 -0
  76. package/template/gui-vnc/lzc-icon.png +0 -0
  77. package/template/python/Dockerfile +15 -0
  78. package/template/python/Dockerfile.dev +18 -0
  79. package/template/python/README.md +50 -0
  80. package/template/python/_gitignore +3 -0
  81. package/template/python/_lzcdevignore +21 -0
  82. package/template/python/app.py +110 -0
  83. package/template/python/lzc-build.dev.yml +12 -0
  84. package/template/python/lzc-build.yml +16 -0
  85. package/template/python/lzc-icon.png +0 -0
  86. package/template/python/manifest.dev.page.js +25 -0
  87. package/template/python/requirements.txt +1 -0
  88. package/template/python/run.sh +14 -0
  89. package/template/python/web/index.html +238 -0
  90. package/template/springboot/Dockerfile +20 -0
  91. package/template/springboot/Dockerfile.dev +20 -0
  92. package/template/springboot/README.md +44 -0
  93. package/template/springboot/_gitignore +3 -0
  94. package/template/springboot/_lzcdevignore +21 -0
  95. package/template/springboot/lzc-build.dev.yml +12 -0
  96. package/template/springboot/lzc-build.yml +16 -0
  97. package/template/springboot/lzc-icon.png +0 -0
  98. package/template/springboot/manifest.dev.page.js +24 -0
  99. package/template/springboot/pom.xml +38 -0
  100. package/template/springboot/run.sh +10 -0
  101. package/template/springboot/src/main/java/cloud/lazycat/app/Application.java +132 -0
  102. package/template/springboot/src/main/resources/application.properties +1 -0
  103. package/template/springboot/src/main/resources/static/index.html +238 -0
  104. package/template/vue/README.md +18 -21
  105. package/template/vue/lzc-build.dev.yml +7 -0
  106. package/template/vue/lzc-build.yml +30 -43
  107. package/template/vue/manifest.dev.page.js +50 -0
  108. package/template/vue/src/App.vue +36 -25
  109. package/template/vue/src/style.css +106 -49
  110. package/template/vue-minidb/README.md +26 -0
  111. package/template/vue-minidb/_gitignore +25 -0
  112. package/template/vue-minidb/index.html +13 -0
  113. package/template/vue-minidb/lzc-build.dev.yml +7 -0
  114. package/template/vue-minidb/lzc-build.yml +46 -0
  115. package/template/vue-minidb/lzc-icon.png +0 -0
  116. package/template/vue-minidb/manifest.dev.page.js +50 -0
  117. package/template/vue-minidb/package.json +21 -0
  118. package/template/vue-minidb/public/vite.svg +1 -0
  119. package/template/vue-minidb/src/App.vue +206 -0
  120. package/template/vue-minidb/src/assets/vue.svg +1 -0
  121. package/template/vue-minidb/src/main.ts +5 -0
  122. package/template/vue-minidb/src/style.css +136 -0
  123. package/template/vue-minidb/src/vite-env.d.ts +1 -0
  124. package/template/vue-minidb/tsconfig.app.json +24 -0
  125. package/template/vue-minidb/tsconfig.json +7 -0
  126. package/template/vue-minidb/tsconfig.node.json +22 -0
  127. package/template/vue-minidb/vite.config.ts +10 -0
  128. /package/template/{vue → vue-minidb}/src/components/HelloWorld.vue +0 -0
package/README.md CHANGED
@@ -14,22 +14,62 @@ npm install -g @lazycatcloud/lzc-cli
14
14
  lzc-cli completion >> ~/.zshrc
15
15
  ```
16
16
 
17
- 下面开始使用 `lzc-cli` 去创建一个项目吧!
17
+ 下面开始使用 `lzc-cli` 去创建一个项目吧。
18
18
 
19
19
  ```bash
20
+ # 在新目录创建项目(交互选择模板)
20
21
  lzc-cli project create you_project
21
22
 
22
- # 构建懒猫云平台lpk包
23
- lzc-cli project build
23
+ # 在当前目录初始化空白项目
24
+ lzc-cli project create --in-place
24
25
 
25
- # 将lpk包安装到盒子中去
26
- lzc-cli app install
26
+ # 部署开发态项目(优先使用 lzc-build.dev.yml)
27
+ lzc-cli project deploy
27
28
 
28
- # 使用 devshell 可以让你在盒子中开发调试
29
- lzc-cli project devshell
29
+ # 查看当前部署信息与 Target URL
30
+ lzc-cli project info
31
+
32
+ # 持续同步本地代码到真实运行环境
33
+ lzc-cli project sync --watch
34
+
35
+ # 进入运行容器调试
36
+ lzc-cli project exec /bin/sh
37
+
38
+ # 构建 release lpk 包(使用 lzc-build.yml)
39
+ lzc-cli project release
40
+
41
+ # 将 lpk 包安装到盒子中去
42
+ lzc-cli lpk install
30
43
 
31
44
  # 经过测试后,将包发布到懒猫云商店中去
32
45
  lzc-cli appstore publish
33
46
  ```
34
47
 
48
+ 补充说明:
49
+
50
+ 1. 只要项目里存在 `lzc-build.dev.yml`,`project deploy/info/start/exec/cp/log/sync` 默认都会优先使用它。
51
+ 2. 所有 `project` 命令都会打印当前实际使用的 `Build config`。
52
+ 3. 如需显式操作 release,请加 `--release`。
53
+ 4. 前端模板建议先 `project deploy` 并打开应用,再根据页面提示执行 `npm run dev`。
54
+ 5. 后端模板建议先打开应用,再根据页面提示执行 `project sync --watch` 与容器内进程启动。
55
+ 6. `project create` 生成的新项目会默认包含 `lzc-manifest.yml` 与 `package.yml`;静态包元数据不再写在 manifest 顶层。
56
+
35
57
  [changelog](./changelog.md)
58
+
59
+ #### box add-by-ssh 远端直连模式
60
+
61
+ 当运行环境无法使用 `hclient` 时,可通过 `box add-by-ssh` 配置远端 ssh 目标,由 `lzc-cli` 直连 `lzcos ssh` 并在远端执行 debug bridge 命令。
62
+
63
+ 示例:
64
+
65
+ ```bash
66
+ lzc-cli box add-by-ssh root 192.168.31.13
67
+ ```
68
+
69
+ 说明:
70
+
71
+ 1. 参数格式为 `loginUser address`,地址支持 `host` 或 `host:port`
72
+ 2. 配置后会自动设为默认盒子,可通过 `box list/switch/default` 管理
73
+ 3. `project release/deploy/start/exec/cp/log/info`、`lpk install/uninstall`、`docker/docker-compose` 都会优先使用该远端
74
+ 4. `lzc-build.yml` 不再支持 `remote` 字段
75
+ 5. 可选基础配置文件为 `lzc-build.base.yml`(与构建配置同目录)
package/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.0-pre.1](https://gitee.com/linakesi/lzc-cli/compare/v1.3.17...v2.0.0-pre.1) (2026-03-11)
4
+
5
+ ### Features
6
+
7
+ - add the LPK v2 project workflow with `project deploy`, `project start`, `project exec`, `project log`, `project cp`, and `project sync`
8
+ - refresh `project create` templates for request inject based frontend and backend development
9
+ - add dev id sync support during `project deploy` for remote development routing
10
+
11
+ ### Bug Fixes
12
+
13
+ - restore old cli devshell compatibility with current developer tools backend
14
+ - refine `project exec` and deploy behavior in dev mode
15
+ - load Vue devtools only in serve mode
16
+
3
17
  ## [1.3.17](https://gitee.com/linakesi/lzc-cli/compare/v1.3.15...v1.3.17) (2026-03-03)
4
18
 
5
19
 
@@ -1,45 +1,8 @@
1
- import fs from 'node:fs';
2
- import logger from 'loglevel';
3
- import axios from 'axios';
4
- import { t } from '../i18n/index.js';
1
+ import { triggerApk as triggerApkFunc } from '../appstore/apkshell.js';
5
2
 
6
- // 创建 Axios 实例
7
- const api = axios.create();
8
-
9
- // 添加响应拦截器
10
- api.interceptors.response.use(
11
- (response) => response, // 直接返回响应
12
- (error) => {
13
- if (error.response && error.response.status === 304) {
14
- return Promise.resolve(error.response); // 返回响应以便后续处理
15
- }
16
- return Promise.reject(error); // 其他错误继续抛出
17
- },
18
- );
19
-
20
- export async function triggerApk(id, name, iconPath) {
21
- if (!id) {
22
- logger.error(t('lzc_cli.lib.app.apkshell.trigger_apk_empty_appid', 'Appid 为必填项!'));
23
- return;
24
- }
25
- name = name || t('lzc_cli.lib.app.apkshell.trigger_apk_default_app_name', '懒猫应用');
26
- try {
27
- const form = new FormData();
28
- form.append('app_id', id);
29
- form.append('app_name', name);
30
- if (iconPath) {
31
- form.append('app_icon', new Blob([fs.readFileSync(iconPath)]));
32
- }
33
- const resp = await api.post('https://appstore.api.lazycat.cloud/api/trigger_latest_for_app', form, { timeout: 5000 });
34
- if (resp.status == 304) {
35
- logger.debug(t('lzc_cli.lib.app.apkshell.trigger_apk_build_tips', `APK构建任务已创建成功,如需使用安卓端,请耐心等待1分钟左右`));
36
- } else if (resp.status <= 201) {
37
- logger.info(t('lzc_cli.lib.app.apkshell.trigger_apk_build_ok_tips', `APK构建任务已创建成功,如需使用安卓端,请耐心等待1分钟左右`));
38
- } else if (resp.status >= 400) {
39
- logger.debug(t('lzc_cli.lib.app.apkshell.trigger_apk_build_failed', '请求按钮应用出错:'), resp);
40
- throw t('lzc_cli.lib.app.apkshell.trigger_apk_build_failed_tips', `请求生成应用出错! 使用 --apk=n 停止生成APK`);
41
- }
42
- } catch (error) {
43
- logger.debug(error);
44
- }
45
- }
3
+ /**
4
+ * @deprecated use appstore/apk.js triggerApk
5
+ * @return {*}
6
+ */
7
+ const triggerApk = triggerApkFunc;
8
+ export { triggerApk };
package/lib/app/index.js CHANGED
@@ -1,7 +1,14 @@
1
1
  import path from 'node:path';
2
- import lpkCreate from './lpk_create.js';
2
+ import lpkCreate, { listProjectTemplateValues, normalizeTemplateType } from './lpk_create.js';
3
3
  import { LpkBuild } from './lpk_build.js';
4
4
  import { AppDevShell } from './lpk_devshell.js';
5
+ import { projectExecCommand } from './project_exec.js';
6
+ import { projectCpCommand } from './project_cp.js';
7
+ import { projectLogCommand } from './project_log.js';
8
+ import { projectInfoCommand } from './project_info.js';
9
+ import { projectStartCommand } from './project_start.js';
10
+ import { projectDeployCommand } from './project_deploy.js';
11
+ import { projectSyncCommand } from './project_sync.js';
5
12
  import { LpkInstaller, installConfig } from './lpk_installer.js';
6
13
  import logger from 'loglevel';
7
14
  import { sleep, checkRsync } from '../utils.js';
@@ -9,28 +16,110 @@ import { DebugBridge } from '../debug_bridge.js';
9
16
  import shellApi from '../shellapi.js';
10
17
  import { generate } from './lpk_create_generator.js';
11
18
  import { t } from '../i18n/index.js';
19
+ import { resolveBuildRemoteFromFile } from '../build_remote.js';
20
+ import { resolveProjectReleaseConfigPath } from './project_runtime.js';
21
+
22
+ async function installLpk(pkgPath, apk) {
23
+ if (!resolveBuildRemoteFromFile(process.cwd())) {
24
+ await shellApi.init();
25
+ }
26
+ installConfig.apk = apk == 'y';
27
+
28
+ const installPath = pkgPath ?? process.cwd();
29
+ const installer = new LpkInstaller();
30
+ await installer.init();
31
+ await installer.install(installPath);
32
+ }
33
+
34
+ async function uninstallLpk(pkgId, deleteData) {
35
+ const buildRemote = resolveBuildRemoteFromFile(process.cwd());
36
+ if (!buildRemote) {
37
+ await shellApi.init();
38
+ }
39
+
40
+ const bridge = new DebugBridge(process.cwd(), buildRemote);
41
+ await bridge.init();
42
+ await bridge.uninstall(pkgId, deleteData);
43
+ logger.debug(`default lcmd device: ${bridge.boxname} , uninstall the app ${pkgId} finish`);
44
+ }
45
+
46
+ function lpkInstallSubCommand({ desc }) {
47
+ return {
48
+ command: 'install [pkgPath]',
49
+ desc,
50
+ builder: (args) => {
51
+ args.option('apk', {
52
+ describe: t('lzc_cli.lib.app.index.lpk_cmd_index_rags_apk_desc', '是否生成APK(y/n)'),
53
+ type: 'string',
54
+ default: 'y',
55
+ });
56
+ },
57
+ handler: async ({ pkgPath, apk }) => {
58
+ await installLpk(pkgPath, apk);
59
+ },
60
+ };
61
+ }
62
+
63
+ function lpkUninstallSubCommand({ desc }) {
64
+ return {
65
+ command: 'uninstall <pkgId>',
66
+ desc,
67
+ builder: (args) => {
68
+ args.option('delete-data', {
69
+ describe: t('lzc_cli.lib.app.index.lpk_cmd_uninstall_rags_delete_data_desc', '删除应用数据 ⚠️ 警告: 应用数据删除后无法恢复'),
70
+ type: 'boolean',
71
+ default: false,
72
+ });
73
+ },
74
+ handler: async ({ pkgId, deleteData }) => {
75
+ await uninstallLpk(pkgId, deleteData);
76
+ },
77
+ };
78
+ }
12
79
 
13
80
  export function lpkProjectCommand(program) {
14
81
  let subCommands = [
15
82
  {
16
- command: 'init',
17
- desc: t('lzc_cli.lib.app.index.lpk_cmd_init_desc', '初始化懒猫云应用(提供最基础的模板)'),
18
- handler: async () => {
19
- generate('blank', './');
20
- logger.info(t('lzc_cli.lib.app.index.lpk_cmd_init_success', '应用初始化完成'));
21
- },
22
- },
23
- {
24
- command: 'create <name>',
83
+ command: 'create [name]',
25
84
  desc: t('lzc_cli.lib.app.index.lpk_cmd_create_desc', '创建懒猫云应用'),
26
- handler: async ({ name }) => {
27
- name = String(name);
28
- await lpkCreate(name);
85
+ builder: (args) => {
86
+ args.option('in-place', {
87
+ describe: 'Initialize current directory with blank template',
88
+ type: 'boolean',
89
+ default: false,
90
+ });
91
+ args.option('t', {
92
+ alias: 'template',
93
+ describe: `Template name (${listProjectTemplateValues().join(', ')})`,
94
+ type: 'string',
95
+ });
96
+ },
97
+ handler: async ({ name, inPlace, template }) => {
98
+ if (name && inPlace) {
99
+ throw new Error('--in-place cannot be used with <name>.');
100
+ }
101
+ const normalizedTemplate = normalizeTemplateType(template);
102
+ if (name) {
103
+ name = String(name);
104
+ await lpkCreate(name, process.cwd(), normalizedTemplate);
105
+ return;
106
+ }
107
+
108
+ if (inPlace) {
109
+ if (normalizedTemplate) {
110
+ throw new Error('--template cannot be used with --in-place.');
111
+ }
112
+ generate('blank', './');
113
+ logger.info(t('lzc_cli.lib.app.index.lpk_cmd_init_success', '应用初始化完成'));
114
+ return;
115
+ }
116
+
117
+ throw new Error('Project name is required unless --in-place is used.');
29
118
  },
30
119
  },
31
120
  {
32
121
  command: 'build [context]',
33
- desc: t('lzc_cli.lib.app.index.lpk_cmd_build_desc', '构建'),
122
+ desc: false,
34
123
  builder: (args) => {
35
124
  args.option('o', {
36
125
  alias: 'output',
@@ -46,6 +135,7 @@ export function lpkProjectCommand(program) {
46
135
  },
47
136
  handler: async ({ context, output, file }) => {
48
137
  const lpk = await new LpkBuild(context, file).init();
138
+ logger.info(`Build config: ${lpk.optionsFilePath}`);
49
139
  // 正常的打包逻辑不需要 devshell
50
140
  lpk.onBeforeBuildPackage(async (options) => {
51
141
  delete options['devshell'];
@@ -58,9 +148,42 @@ export function lpkProjectCommand(program) {
58
148
  await lpk.exec();
59
149
  },
60
150
  },
151
+ {
152
+ command: 'release [context]',
153
+ desc: 'Build release package',
154
+ builder: (args) => {
155
+ args.option('o', {
156
+ alias: 'output',
157
+ describe: t('lzc_cli.lib.app.index.lpk_cmd_build_args_output_desc', '输出文件'),
158
+ type: 'string',
159
+ });
160
+ args.option('f', {
161
+ alias: 'file',
162
+ describe: t('lzc_cli.lib.app.index.lpk_cmd_build_args_file_desc', '指定构建的lzc-build.yml文件'),
163
+ type: 'string',
164
+ });
165
+ },
166
+ handler: async ({ context, output, file }) => {
167
+ const cwd = context ? path.resolve(context) : process.cwd();
168
+ const configPath = resolveProjectReleaseConfigPath(cwd, file);
169
+ logger.info(`Build config: ${configPath}`);
170
+ const projectCwd = path.dirname(configPath);
171
+ const configName = path.basename(configPath);
172
+ const lpk = await new LpkBuild(projectCwd, configName).init();
173
+ lpk.onBeforeBuildPackage(async (options) => {
174
+ delete options['devshell'];
175
+
176
+ if (output) {
177
+ options['lpkPath'] = output;
178
+ }
179
+ return options;
180
+ });
181
+ await lpk.exec();
182
+ },
183
+ },
61
184
  {
62
185
  command: 'devshell [context]',
63
- desc: t('lzc_cli.lib.app.index.lpk_cmd_devshell_desc', '进入盒子的开发环境'),
186
+ desc: false,
64
187
  builder: (args) => {
65
188
  args.option('f', {
66
189
  alias: 'force',
@@ -84,12 +207,16 @@ export function lpkProjectCommand(program) {
84
207
  });
85
208
  },
86
209
  handler: async ({ context, force, config, contentdir, apk }) => {
87
- await shellApi.init();
210
+ logger.warn('project devshell is deprecated. Use "project deploy", "project start", "project exec", "project cp", and "project log" instead.');
211
+ const cwd = context ? path.resolve(context) : process.cwd();
212
+ const buildRemote = resolveBuildRemoteFromFile(cwd, config);
213
+ if (!buildRemote) {
214
+ await shellApi.init();
215
+ }
88
216
  // 检测 rsync 满足
89
217
  await checkRsync();
90
218
 
91
219
  installConfig.apk = apk == 'y';
92
- const cwd = context ? path.resolve(context) : process.cwd();
93
220
  const lpkBuild = await new LpkBuild(cwd, config).init();
94
221
  lpkBuild.onBeforeBuildPackage(async (options) => {
95
222
  // devshell 正常情况下,不需要执行 buildscript 和 contentdir 字段
@@ -109,6 +236,27 @@ export function lpkProjectCommand(program) {
109
236
  await app.rsyncShell();
110
237
  },
111
238
  },
239
+ {
240
+ command: 'app',
241
+ desc: false,
242
+ builder: (args) => {
243
+ args.command([
244
+ lpkInstallSubCommand({
245
+ desc: false,
246
+ }),
247
+ lpkUninstallSubCommand({
248
+ desc: false,
249
+ }),
250
+ ]);
251
+ },
252
+ },
253
+ projectExecCommand(),
254
+ projectCpCommand(),
255
+ projectLogCommand(),
256
+ projectInfoCommand(),
257
+ projectStartCommand(),
258
+ projectDeployCommand(),
259
+ projectSyncCommand(),
112
260
  ];
113
261
  program.command({
114
262
  command: 'project',
@@ -121,58 +269,22 @@ export function lpkProjectCommand(program) {
121
269
 
122
270
  export function lpkAppCommand(program) {
123
271
  let subCommands = [
124
- {
125
- command: 'install [pkgPath]',
272
+ lpkInstallSubCommand({
126
273
  desc: t('lzc_cli.lib.app.index.lpk_cmd_install_desc', '部署应用至设备, pkgPath 可以为路径,或者https://,http://请求地址, 如果不填写,将默认为当前目录下的lpk'),
127
- builder: (args) => {
128
- args.option('apk', {
129
- describe: t('lzc_cli.lib.app.index.lpk_cmd_index_rags_apk_desc', '是否生成APK(y/n)'),
130
- type: 'string',
131
- default: 'y',
132
- });
133
- args.option('ssh-private-key', {
134
- alias: 'ssh-key',
135
- describe: t('lzc_cli.lib.app.index.lpk_cmd_install_args_ssh_private_key_desc', '指定安装时用于连接设备的 SSH 私钥路径(兼容别名: --ssh-key)'),
136
- type: 'string',
137
- });
138
- },
139
- handler: async ({ pkgPath, apk, sshPrivateKey }) => {
140
- await shellApi.init();
141
- installConfig.apk = apk == 'y';
142
- installConfig.sshPrivateKey = sshPrivateKey ? path.resolve(sshPrivateKey) : '';
143
-
144
- pkgPath = pkgPath ?? process.cwd();
145
- const installer = new LpkInstaller();
146
- await installer.init();
147
- await installer.install(pkgPath);
148
- },
149
- },
150
- {
151
- command: 'uninstall <pkgId>',
274
+ }),
275
+ lpkUninstallSubCommand({
152
276
  desc: t('lzc_cli.lib.app.index.lpk_cmd_uninstall_desc', '从设备中卸载某一个应用'),
153
- builder: (args) => {
154
- args.option('delete-data', {
155
- describe: t('lzc_cli.lib.app.index.lpk_cmd_uninstall_rags_delete_data_desc', '删除应用数据 ⚠️ 警告: 应用数据删除后无法恢复'),
156
- type: 'boolean',
157
- default: false,
158
- });
159
- },
160
- handler: async ({ pkgId, deleteData }) => {
161
- await shellApi.init();
162
-
163
- const bridge = new DebugBridge();
164
- await bridge.init();
165
- await bridge.uninstall(pkgId, deleteData);
166
- logger.debug(`default lcmd device: ${bridge.boxname} , uninstall the app ${pkgId} finish`);
167
- },
168
- },
277
+ }),
169
278
  {
170
279
  command: 'status <pkgId>',
171
280
  desc: t('lzc_cli.lib.app.index.lpk_cmd_status_desc', '获取某一个应用的状态'),
172
281
  handler: async ({ pkgId }) => {
173
- await shellApi.init();
282
+ const buildRemote = resolveBuildRemoteFromFile(process.cwd());
283
+ if (!buildRemote) {
284
+ await shellApi.init();
285
+ }
174
286
 
175
- const bridge = new DebugBridge();
287
+ const bridge = new DebugBridge(process.cwd(), buildRemote);
176
288
  await bridge.init();
177
289
  const status = await bridge.status(pkgId);
178
290
  console.log(status);
@@ -190,7 +302,9 @@ export function lpkAppCommand(program) {
190
302
  });
191
303
  },
192
304
  handler: async () => {
193
- await shellApi.init();
305
+ if (!resolveBuildRemoteFromFile(process.cwd())) {
306
+ await shellApi.init();
307
+ }
194
308
 
195
309
  throw 'not yet realized';
196
310
  },
@@ -198,7 +312,7 @@ export function lpkAppCommand(program) {
198
312
  ];
199
313
  program.command({
200
314
  command: 'app',
201
- desc: t('lzc_cli.lib.app.index.lpk_cmd_app_desc', '应用管理'),
315
+ desc: false,
202
316
  builder: async (args) => {
203
317
  args.command(subCommands);
204
318
  },