@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.
- package/README.md +47 -7
- package/changelog.md +14 -0
- package/lib/app/apkshell.js +7 -44
- package/lib/app/index.js +178 -64
- package/lib/app/lpk_build.js +446 -61
- package/lib/app/lpk_build_images.js +749 -0
- package/lib/app/lpk_create.js +192 -45
- package/lib/app/lpk_create_generator.js +141 -13
- package/lib/app/lpk_devshell.js +33 -19
- package/lib/app/lpk_embed_images.js +257 -0
- package/lib/app/lpk_installer.js +17 -9
- package/lib/app/manifest_build.js +259 -0
- package/lib/app/project_cp.js +59 -0
- package/lib/app/project_deploy.js +58 -0
- package/lib/app/project_exec.js +82 -0
- package/lib/app/project_info.js +106 -0
- package/lib/app/project_log.js +62 -0
- package/lib/app/project_runtime.js +356 -0
- package/lib/app/project_start.js +95 -0
- package/lib/app/project_sync.js +499 -0
- package/lib/appstore/apkshell.js +50 -0
- package/lib/box/index.js +101 -4
- package/lib/box/ssh_remote.js +259 -0
- package/lib/build_remote.js +21 -0
- package/lib/debug_bridge.js +891 -83
- package/lib/docker/index.js +30 -10
- package/lib/i18n/locales/en/translation.json +262 -255
- package/lib/i18n/locales/zh/translation.json +262 -255
- package/lib/lpk/core.js +488 -0
- package/lib/lpk/index.js +210 -0
- package/lib/migrate/index.js +52 -0
- package/lib/package_info.js +135 -0
- package/lib/shellapi.js +35 -1
- package/lib/sig/core.js +254 -0
- package/lib/sig/index.js +88 -0
- package/lib/utils.js +94 -15
- package/package.json +3 -3
- package/scripts/cli.js +6 -0
- package/scripts/smoke/frontend-dev-entry.mjs +104 -0
- package/scripts/smoke/template-project.mjs +311 -0
- package/template/_lpk/README.md +15 -4
- package/template/_lpk/gui-vnc.manifest.yml.in +18 -0
- package/template/_lpk/hello-vue.manifest.yml.in +38 -0
- package/template/_lpk/manifest.yml.in +4 -11
- package/template/_lpk/package.yml.in +7 -0
- package/template/_lpk/todolist-golang.manifest.yml.in +30 -0
- package/template/_lpk/todolist-java.manifest.yml.in +29 -0
- package/template/_lpk/todolist-python.manifest.yml.in +37 -0
- package/template/_lpk/todolist-serverless.manifest.yml.in +38 -0
- package/template/_lpk/vue.lzc-build.yml.in +0 -44
- package/template/blank/lzc-build.dev.yml +4 -0
- package/template/blank/lzc-build.yml +24 -41
- package/template/blank/lzc-manifest.yml +7 -9
- package/template/blank/package.yml +7 -0
- package/template/golang/Dockerfile +19 -0
- package/template/golang/Dockerfile.dev +20 -0
- package/template/golang/README.md +44 -0
- package/template/golang/_gitignore +3 -0
- package/template/golang/_lzcdevignore +21 -0
- package/template/golang/go.mod +3 -0
- package/template/golang/lzc-build.dev.yml +12 -0
- package/template/golang/lzc-build.yml +16 -0
- package/template/golang/lzc-icon.png +0 -0
- package/template/golang/main.go +252 -0
- package/template/golang/manifest.dev.page.js +24 -0
- package/template/golang/run.sh +10 -0
- package/template/golang/web/index.html +238 -0
- package/template/gui-vnc/README.md +23 -0
- package/template/gui-vnc/_gitignore +2 -0
- package/template/gui-vnc/images/Dockerfile +30 -0
- package/template/gui-vnc/images/kasmvnc.yaml +33 -0
- package/template/gui-vnc/images/startup-script.desktop +9 -0
- package/template/gui-vnc/images/startup-script.sh +6 -0
- package/template/gui-vnc/lzc-build.dev.yml +4 -0
- package/template/gui-vnc/lzc-build.yml +18 -0
- package/template/gui-vnc/lzc-icon.png +0 -0
- package/template/python/Dockerfile +15 -0
- package/template/python/Dockerfile.dev +18 -0
- package/template/python/README.md +50 -0
- package/template/python/_gitignore +3 -0
- package/template/python/_lzcdevignore +21 -0
- package/template/python/app.py +110 -0
- package/template/python/lzc-build.dev.yml +12 -0
- package/template/python/lzc-build.yml +16 -0
- package/template/python/lzc-icon.png +0 -0
- package/template/python/manifest.dev.page.js +25 -0
- package/template/python/requirements.txt +1 -0
- package/template/python/run.sh +14 -0
- package/template/python/web/index.html +238 -0
- package/template/springboot/Dockerfile +20 -0
- package/template/springboot/Dockerfile.dev +20 -0
- package/template/springboot/README.md +44 -0
- package/template/springboot/_gitignore +3 -0
- package/template/springboot/_lzcdevignore +21 -0
- package/template/springboot/lzc-build.dev.yml +12 -0
- package/template/springboot/lzc-build.yml +16 -0
- package/template/springboot/lzc-icon.png +0 -0
- package/template/springboot/manifest.dev.page.js +24 -0
- package/template/springboot/pom.xml +38 -0
- package/template/springboot/run.sh +10 -0
- package/template/springboot/src/main/java/cloud/lazycat/app/Application.java +132 -0
- package/template/springboot/src/main/resources/application.properties +1 -0
- package/template/springboot/src/main/resources/static/index.html +238 -0
- package/template/vue/README.md +18 -21
- package/template/vue/lzc-build.dev.yml +7 -0
- package/template/vue/lzc-build.yml +30 -43
- package/template/vue/manifest.dev.page.js +50 -0
- package/template/vue/src/App.vue +36 -25
- package/template/vue/src/style.css +106 -49
- package/template/vue-minidb/README.md +26 -0
- package/template/vue-minidb/_gitignore +25 -0
- package/template/vue-minidb/index.html +13 -0
- package/template/vue-minidb/lzc-build.dev.yml +7 -0
- package/template/vue-minidb/lzc-build.yml +46 -0
- package/template/vue-minidb/lzc-icon.png +0 -0
- package/template/vue-minidb/manifest.dev.page.js +50 -0
- package/template/vue-minidb/package.json +21 -0
- package/template/vue-minidb/public/vite.svg +1 -0
- package/template/vue-minidb/src/App.vue +206 -0
- package/template/vue-minidb/src/assets/vue.svg +1 -0
- package/template/vue-minidb/src/main.ts +5 -0
- package/template/vue-minidb/src/style.css +136 -0
- package/template/vue-minidb/src/vite-env.d.ts +1 -0
- package/template/vue-minidb/tsconfig.app.json +24 -0
- package/template/vue-minidb/tsconfig.json +7 -0
- package/template/vue-minidb/tsconfig.node.json +22 -0
- package/template/vue-minidb/vite.config.ts +10 -0
- /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
|
-
#
|
|
23
|
-
lzc-cli project
|
|
23
|
+
# 在当前目录初始化空白项目
|
|
24
|
+
lzc-cli project create --in-place
|
|
24
25
|
|
|
25
|
-
#
|
|
26
|
-
lzc-cli
|
|
26
|
+
# 部署开发态项目(优先使用 lzc-build.dev.yml)
|
|
27
|
+
lzc-cli project deploy
|
|
27
28
|
|
|
28
|
-
#
|
|
29
|
-
lzc-cli project
|
|
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
|
|
package/lib/app/apkshell.js
CHANGED
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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: '
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
128
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
315
|
+
desc: false,
|
|
202
316
|
builder: async (args) => {
|
|
203
317
|
args.command(subCommands);
|
|
204
318
|
},
|