@lazycatcloud/lzc-cli 1.1.8 → 1.1.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/README.md +69 -11
- package/lib/api.js +71 -39
- package/lib/app/index.js +76 -21
- package/lib/app/lpk_build.js +95 -63
- package/lib/app/lpk_create.js +63 -41
- package/lib/app/lpk_create_generator.js +202 -0
- package/lib/app/lpk_devshell.js +393 -328
- package/lib/app/lpk_devshell_docker.js +211 -0
- package/lib/app/lpk_installer.js +63 -26
- package/lib/app/lpk_log.js +68 -0
- package/lib/app/lpk_status.js +18 -0
- package/lib/app/lpk_uninstall.js +19 -0
- package/lib/appstore/index.js +37 -0
- package/lib/appstore/login.js +96 -93
- package/lib/appstore/publish.js +62 -0
- package/lib/autologin.js +0 -78
- package/lib/box/api/clientapi.js +1322 -0
- package/lib/box/api/empty.js +35 -0
- package/lib/box/check_qemu.js +1 -0
- package/lib/box/index.js +41 -94
- package/lib/box/qemu_vm_mgr.js +208 -239
- package/lib/box/schemes/vm_box_system_debian.json +1 -1
- package/lib/docker-compose.js +1 -2
- package/lib/env.js +19 -101
- package/lib/key.js +1 -0
- package/lib/sdk.js +10 -25
- package/lib/utils.js +156 -132
- package/package.json +18 -10
- package/scripts/cli.js +14 -135
- package/template/_lpk/README.md +31 -0
- package/template/_lpk/exec.sh +19 -0
- package/template/_lpk/golang.manifest.yml.in +16 -0
- package/template/_lpk/lazycat.png +0 -0
- package/template/_lpk/lite.manifest.yml.in +19 -0
- package/template/_lpk/local_devshell/Dockerfile +16 -0
- package/template/_lpk/local_devshell/build.sh +5 -0
- package/template/_lpk/local_devshell/entrypoint.sh +87 -0
- package/template/{_lazycat/debug/shell → _lpk/local_devshell}/sshd_config +8 -8
- package/template/_lpk/manifest.yml.in +0 -1
- package/template/{vue/lzc-build.yml → _lpk/vue.lzc-build.yml.in} +9 -1
- package/template/golang/README.md +0 -2
- package/template/golang/_gitignore +2 -0
- package/template/golang/build.sh +6 -0
- package/template/golang/lazycat.png +0 -0
- package/template/golang/lzc-build.yml +9 -1
- package/template/golang/rego.go +15 -16
- package/template/golang/rego_test.go +13 -0
- package/template/ionic_vue3/lazycat.png +0 -0
- package/template/ionic_vue3/lzc-build.yml +9 -1
- package/template/lite/error_pages/502.html.tpl +13 -0
- package/template/lite/lazycat.png +0 -0
- package/template/lite/lzc-build.yml +60 -0
- package/cmds/app.js +0 -133
- package/cmds/config.js +0 -55
- package/cmds/create.js +0 -55
- package/cmds/dev.js +0 -130
- package/cmds/init.js +0 -125
- package/cmds/log.js +0 -103
- package/cmds/publish.js +0 -116
- package/lib/archiver.js +0 -105
- package/lib/box/hportal.js +0 -120
- package/lib/builder.js +0 -313
- package/lib/dev.js +0 -314
- package/lib/generator.js +0 -146
- package/template/_lazycat/_gitignore +0 -1
- package/template/_lazycat/app-config +0 -1
- package/template/_lazycat/debug/devforward/50x.html +0 -30
- package/template/_lazycat/debug/devforward/Dockerfile +0 -16
- package/template/_lazycat/debug/devforward/docker-compose.override.yml.in +0 -11
- package/template/_lazycat/debug/devforward/entrypoint.sh +0 -10
- package/template/_lazycat/debug/devforward/nginx.conf.template +0 -56
- package/template/_lazycat/debug/devforward/sshd_config +0 -116
- package/template/_lazycat/debug/shell/50x.html +0 -32
- package/template/_lazycat/debug/shell/Dockerfile +0 -18
- package/template/_lazycat/debug/shell/build.sh +0 -15
- package/template/_lazycat/debug/shell/docker-compose.override.yml.in +0 -13
- package/template/_lazycat/debug/shell/entrypoint.sh +0 -12
- package/template/_lazycat/docker-compose.yml.in +0 -15
- package/template/_lazycat/icon.svg +0 -1
- package/template/_lazycat/screenshot.png +0 -0
- package/template/_lpk/sync/Dockerfile +0 -16
- package/template/_lpk/sync/build.sh +0 -5
- package/template/_lpk/sync/entrypoint.sh +0 -8
- package/template/_lpk/sync/sshd_config +0 -117
- package/template/_lpk/sync.manifest.yml.in +0 -3
- package/template/release/golang/Dockerfile +0 -18
- package/template/release/golang/build.sh +0 -13
- package/template/release/ionic_vue3/Dockerfile +0 -10
- package/template/release/ionic_vue3/build.sh +0 -7
- package/template/release/ionic_vue3/docker-compose.yml.in +0 -3
- package/template/release/vue/Dockerfile +0 -10
- package/template/release/vue/build.sh +0 -10
- package/template/release/vue/docker-compose.yml.in +0 -3
- package/template/vue/README.md +0 -29
- package/template/vue/_dockerignore +0 -1
- package/template/vue/babel.config.js +0 -3
- package/template/vue/package.json +0 -43
- package/template/vue/public/favicon.ico +0 -0
- package/template/vue/public/index.html +0 -33
- package/template/vue/src/App.vue +0 -39
- package/template/vue/src/main.js +0 -8
- package/template/vue/src/todo.vue +0 -640
- package/template/vue/src/top-bar.vue +0 -100
- package/template/vue/src/webdav.vue +0 -183
- package/template/vue/vue.config.js +0 -21
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import _m0 from "protobufjs/minimal.js";
|
|
3
|
+
function createBaseEmpty() {
|
|
4
|
+
return {};
|
|
5
|
+
}
|
|
6
|
+
export const Empty = {
|
|
7
|
+
encode(_, writer = _m0.Writer.create()) {
|
|
8
|
+
return writer;
|
|
9
|
+
},
|
|
10
|
+
decode(input, length) {
|
|
11
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
12
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
13
|
+
const message = createBaseEmpty();
|
|
14
|
+
while (reader.pos < end) {
|
|
15
|
+
const tag = reader.uint32();
|
|
16
|
+
switch (tag >>> 3) {
|
|
17
|
+
default:
|
|
18
|
+
reader.skipType(tag & 7);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return message;
|
|
23
|
+
},
|
|
24
|
+
fromJSON(_) {
|
|
25
|
+
return {};
|
|
26
|
+
},
|
|
27
|
+
toJSON(_) {
|
|
28
|
+
const obj = {};
|
|
29
|
+
return obj;
|
|
30
|
+
},
|
|
31
|
+
fromPartial(_) {
|
|
32
|
+
const message = createBaseEmpty();
|
|
33
|
+
return message;
|
|
34
|
+
},
|
|
35
|
+
};
|
package/lib/box/check_qemu.js
CHANGED
package/lib/box/index.js
CHANGED
|
@@ -3,137 +3,84 @@
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { QemuVM, QemuResource } from "./qemu_vm_mgr.js";
|
|
6
|
-
import { contextDirname } from "../utils.js";
|
|
6
|
+
import { contextDirname, envsubstrDefault, randomString } from "../utils.js";
|
|
7
7
|
import env, { sdkEnv } from "../env.js";
|
|
8
|
-
import { HportalManager, showBoxInfo } from "./hportal.js";
|
|
9
8
|
import { CheckQemu } from "./check_qemu.js";
|
|
10
9
|
import logger from "loglevel";
|
|
11
10
|
|
|
12
|
-
async function initQemuVM(ensureResources = false) {
|
|
13
|
-
let defaultSchemeFile = path.join(
|
|
14
|
-
contextDirname(),
|
|
15
|
-
"box",
|
|
16
|
-
"schemes",
|
|
17
|
-
"vm_box_system_debian.json"
|
|
18
|
-
);
|
|
19
|
-
let scheme = JSON.parse(fs.readFileSync(defaultSchemeFile));
|
|
20
|
-
if (scheme.path.search(/\$HOME/) >= 0) {
|
|
21
|
-
let home = process.env["HOME"];
|
|
22
|
-
scheme.path = scheme.path.replace("$HOME", home);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (scheme.path && !scheme.path.startsWith("/")) {
|
|
26
|
-
scheme.path = path.join(contextDirname(), "box-emulator", scheme.path);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fs.mkdirSync(scheme.path, { recursive: true });
|
|
30
|
-
|
|
31
|
-
if (ensureResources) {
|
|
32
|
-
// 使用本地网络 api 调试 new QemuResource(scheme.path, "http://127.0.0.1");
|
|
33
|
-
let resource = new QemuResource(scheme.path);
|
|
34
|
-
await resource.init();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let m = new QemuVM(scheme);
|
|
38
|
-
return m;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function initHportal() {
|
|
42
|
-
let apiHost = "http://127.0.0.1:30553/api";
|
|
43
|
-
let m = new HportalManager(apiHost);
|
|
44
|
-
return m;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
11
|
export function boxCommand(box) {
|
|
48
12
|
let subCommands = [
|
|
49
13
|
{
|
|
50
14
|
command: "create",
|
|
51
15
|
desc: "创建一个虚拟盒子,并注册运行",
|
|
52
16
|
handler: async () => {
|
|
53
|
-
|
|
54
|
-
await
|
|
17
|
+
const cq = await new CheckQemu().init();
|
|
18
|
+
const m = await new QemuVM().init();
|
|
55
19
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
let answer = await m.askBoxInfo();
|
|
20
|
+
const scheme = m.scheme;
|
|
21
|
+
const resource = await new QemuResource(scheme.path).init();
|
|
59
22
|
|
|
23
|
+
const name = randomString();
|
|
24
|
+
|
|
25
|
+
let boxId;
|
|
60
26
|
try {
|
|
61
27
|
// 创建盒子阶段,如果出错,将直接删除所有的资源。
|
|
62
|
-
boxId = await m.createVM(
|
|
28
|
+
boxId = await m.createVM(resource, name);
|
|
63
29
|
} catch (error) {
|
|
64
30
|
logger.error(error);
|
|
65
|
-
await m.cleanVM(
|
|
31
|
+
await m.cleanVM(name);
|
|
66
32
|
return;
|
|
67
33
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// 新创建的盒子在初始化的时候,盒子里面需要安装hc的组件,需要一点时间,
|
|
73
|
-
// 所以这里并不对sdk url进行校验是否有效
|
|
74
|
-
await sdkEnv.setDefaultBoxName(answer.boxName);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let h = await initHportal();
|
|
78
|
-
logger.debug("添加盒子到 Hportal ......");
|
|
79
|
-
await h.addBox(answer.boxName);
|
|
80
|
-
logger.debug("正在使用管理员帐号密码登录中......");
|
|
81
|
-
await h.loginBox(boxId, answer.adminName, answer.adminPass);
|
|
82
|
-
logger.debug("登录成功!");
|
|
34
|
+
console.log(
|
|
35
|
+
`\n盒子初始化成功
|
|
36
|
+
请在浏览器中打开 http://127.0.0.1:30554/add?boxId=${boxId} 完成盒子注册`
|
|
37
|
+
);
|
|
83
38
|
},
|
|
84
39
|
},
|
|
85
40
|
{
|
|
86
|
-
command: "start <
|
|
41
|
+
command: "start <boxNameOrBoxId>",
|
|
87
42
|
desc: "启动一个虚拟盒子",
|
|
88
|
-
handler: async ({
|
|
89
|
-
|
|
90
|
-
let boxid = await m.runVM(
|
|
43
|
+
handler: async ({ boxNameOrBoxId }) => {
|
|
44
|
+
const m = await new QemuVM().init();
|
|
45
|
+
let boxid = await m.runVM(boxNameOrBoxId);
|
|
91
46
|
if (boxid) {
|
|
92
47
|
logger.info("盒子ID: ", boxid);
|
|
93
48
|
}
|
|
94
49
|
},
|
|
95
50
|
},
|
|
96
51
|
{
|
|
97
|
-
command: "stop <
|
|
52
|
+
command: "stop <boxNameOrBoxId>",
|
|
98
53
|
desc: "停止一个虚拟盒子",
|
|
99
|
-
handler: async ({
|
|
100
|
-
|
|
101
|
-
await m.stopVM(
|
|
54
|
+
handler: async ({ boxNameOrBoxId }) => {
|
|
55
|
+
const m = await new QemuVM().init();
|
|
56
|
+
await m.stopVM(boxNameOrBoxId);
|
|
102
57
|
},
|
|
103
58
|
},
|
|
104
59
|
{
|
|
105
|
-
command: "delete <
|
|
106
|
-
desc: "
|
|
107
|
-
handler: async ({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (boxId) {
|
|
111
|
-
await h.deleteBox(boxId);
|
|
112
|
-
}
|
|
113
|
-
let m = await initQemuVM();
|
|
114
|
-
await m.deleteVM(boxName);
|
|
60
|
+
command: "delete <boxNameOrBoxId>",
|
|
61
|
+
desc: "删除一个盒子,将会删除其所具有的数据",
|
|
62
|
+
handler: async ({ boxNameOrBoxId }) => {
|
|
63
|
+
const m = await new QemuVM().init();
|
|
64
|
+
await m.deleteVM(boxNameOrBoxId);
|
|
115
65
|
},
|
|
116
66
|
},
|
|
117
67
|
{
|
|
118
|
-
command: "
|
|
68
|
+
command: "list [boxNameOrBoxId]",
|
|
119
69
|
desc: "获取一个虚拟盒子的信息",
|
|
120
|
-
handler: async ({
|
|
121
|
-
|
|
122
|
-
let defaultBoxName = env.get("DEFAULT_BOXNAME");
|
|
123
|
-
|
|
124
|
-
let rm = await initHportal();
|
|
125
|
-
|
|
126
|
-
let vmInfos = await m.infoVM(boxName, defaultBoxName);
|
|
127
|
-
let rmInfos = await rm.boxs(boxName, defaultBoxName);
|
|
70
|
+
handler: async ({ boxNameOrBoxId }) => {
|
|
71
|
+
const m = await new QemuVM().init();
|
|
128
72
|
|
|
129
|
-
|
|
130
|
-
if (vmInfos.length == 0
|
|
131
|
-
logger.info(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
73
|
+
let vmInfos = await m.listVM(boxNameOrBoxId);
|
|
74
|
+
if (vmInfos.length == 0) {
|
|
75
|
+
logger.info("没有找到任何盒子,创建一个吧!");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
console.table(vmInfos);
|
|
79
|
+
const hasNoRegistry = vmInfos.some((vm) => !vm.name);
|
|
80
|
+
if (hasNoRegistry) {
|
|
81
|
+
logger.info(
|
|
82
|
+
`还没有注册的盒子,你可以复制 id 到 http://127.0.0.1:30554/add 进行注册`
|
|
83
|
+
);
|
|
137
84
|
}
|
|
138
85
|
},
|
|
139
86
|
},
|