@lazycatcloud/lzc-cli 1.1.3 → 1.1.6
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/cmds/app.js +133 -0
- package/cmds/config.js +55 -0
- package/cmds/create.js +55 -0
- package/cmds/dev.js +130 -0
- package/cmds/init.js +125 -0
- package/cmds/log.js +103 -0
- package/cmds/publish.js +116 -0
- package/lib/api.js +21 -7
- package/lib/app/index.js +92 -0
- package/lib/app/lpk_build.js +229 -0
- package/lib/app/lpk_create.js +201 -0
- package/lib/app/lpk_devshell.js +621 -0
- package/lib/app/lpk_installer.js +67 -0
- package/lib/archiver.js +0 -42
- package/lib/autologin.js +84 -0
- package/lib/box/check_qemu.js +50 -0
- package/lib/box/hportal.js +8 -1
- package/lib/box/index.js +35 -15
- package/lib/box/qemu_vm_mgr.js +142 -56
- package/lib/builder.js +14 -3
- package/lib/dev.js +12 -6
- package/lib/env.js +10 -6
- package/lib/generator.js +2 -2
- package/lib/git/git-commit.sh +3 -3
- package/lib/sdk.js +29 -5
- package/lib/utils.js +69 -46
- package/package.json +13 -6
- package/scripts/cli.js +92 -13
- package/template/_lazycat/debug/shell/Dockerfile +5 -3
- package/template/_lazycat/debug/shell/docker-compose.override.yml.in +2 -12
- package/template/_lazycat/debug/shell/entrypoint.sh +3 -1
- package/template/_lpk/Dockerfile.in +8 -0
- package/template/_lpk/devshell/Dockerfile +18 -0
- package/template/_lpk/devshell/build.sh +5 -0
- package/template/_lpk/devshell/entrypoint.sh +8 -0
- package/template/_lpk/devshell/sshd_config +117 -0
- package/template/_lpk/manifest.yml.in +17 -0
- package/template/_lpk/sync/Dockerfile +16 -0
- package/template/_lpk/sync/build.sh +5 -0
- package/template/_lpk/sync/entrypoint.sh +8 -0
- package/template/_lpk/sync/sshd_config +117 -0
- package/template/_lpk/sync.manifest.yml.in +3 -0
- package/template/golang/build.sh +6 -0
- package/template/golang/lzc-build.yml +52 -0
- package/template/ionic_vue3/lzc-build.yml +53 -0
- package/template/ionic_vue3/vite.config.ts +1 -1
- package/template/release/golang/build.sh +1 -1
- package/template/release/ionic_vue3/Dockerfile +1 -1
- package/template/release/ionic_vue3/build.sh +1 -3
- package/template/release/ionic_vue3/docker-compose.yml.in +0 -5
- package/template/release/vue/Dockerfile +1 -1
- package/template/release/vue/build.sh +2 -3
- package/template/release/vue/docker-compose.yml.in +0 -5
- package/template/vue/lzc-build.yml +53 -0
- package/template/vue/src/main.js +3 -14
- package/template/vue/vue.config.js +16 -0
- package/scripts/auto-completion.sh +0 -46
- package/template/_lazycat/debug/shell/nginx.conf.template +0 -64
- package/template/vue/src/lzc.js +0 -110
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# 整个文件中,可以通过 ${var} 的方式,使用 manifest.yml 文件中定义的值
|
|
2
|
+
|
|
3
|
+
# buildscript
|
|
4
|
+
# - 可以为构建脚本的路径地址
|
|
5
|
+
# - 如果构建命令简单,也可以直接写 sh 的命令
|
|
6
|
+
buildscript: npm run build
|
|
7
|
+
|
|
8
|
+
# manifest: 指定 lpk 包的 manifest.yml 文件路径
|
|
9
|
+
manifest: ./manifest.yml
|
|
10
|
+
|
|
11
|
+
# contentdir: 指定打包的内容,将会打包到 lpk 中
|
|
12
|
+
contentdir: ./dist
|
|
13
|
+
|
|
14
|
+
# pkgout: lpk 包的输出路径
|
|
15
|
+
pkgout: ./
|
|
16
|
+
|
|
17
|
+
# icon 指定 lpk 包 icon 的路径路径,如果不指定将会警告
|
|
18
|
+
# icon 仅仅允许 png 后缀的文件
|
|
19
|
+
icon: ./lazycat.png
|
|
20
|
+
|
|
21
|
+
# devshell 自定义应用的开发容器环境
|
|
22
|
+
# - routers 指定应用容器的访问路由
|
|
23
|
+
|
|
24
|
+
# devshell 没有指定 image 的情况,将会默认使用 registry.lazycat.cloud/lzc-cli/devshell:latest
|
|
25
|
+
# devshell:
|
|
26
|
+
# routers:
|
|
27
|
+
# - /=http://127.0.0.1:8080
|
|
28
|
+
|
|
29
|
+
# devshell 指定 image 的情况
|
|
30
|
+
# devshell:
|
|
31
|
+
# routes:
|
|
32
|
+
# - /=http://127.0.0.1:3000
|
|
33
|
+
# image: registry.lazycat.cloud/lzc-cli/devshell:0.0.4
|
|
34
|
+
|
|
35
|
+
# devshell 指定构建Dockerfile
|
|
36
|
+
# image 字段如果没有定义,将默认使用 ${package}-devshell:${version}
|
|
37
|
+
# devshell:
|
|
38
|
+
# routes:
|
|
39
|
+
# - /=http://127.0.0.1:3000
|
|
40
|
+
# image: ${package}-devshell:${version}
|
|
41
|
+
# pull_policy: build
|
|
42
|
+
# build: .
|
|
43
|
+
|
|
44
|
+
# dvshell 指定开发依赖的情况
|
|
45
|
+
# 这种情况下,选用 apline:3.16 作为基础镜像,在 dependencies 中添加所需要的开发依赖即可
|
|
46
|
+
# 如果 dependencies 和 build 同时存在,将会优先使用 dependencies
|
|
47
|
+
devshell:
|
|
48
|
+
routes:
|
|
49
|
+
- /=http://127.0.0.1:3000
|
|
50
|
+
dependencies:
|
|
51
|
+
- nodejs
|
|
52
|
+
- vim
|
|
53
|
+
- npm
|
package/template/vue/src/main.js
CHANGED
|
@@ -3,17 +3,6 @@ import App from "./App.vue";
|
|
|
3
3
|
|
|
4
4
|
Vue.config.productionTip = false;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
lzc
|
|
11
|
-
.autoLogin()
|
|
12
|
-
.then(() => {
|
|
13
|
-
new Vue({
|
|
14
|
-
render: (h) => h(App),
|
|
15
|
-
}).$mount("#app");
|
|
16
|
-
})
|
|
17
|
-
.catch((e) => {
|
|
18
|
-
console.error(e);
|
|
19
|
-
});
|
|
6
|
+
new Vue({
|
|
7
|
+
render: (h) => h(App),
|
|
8
|
+
}).$mount("#app");
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
const nodeVersions = process.versions.node.split(".");
|
|
2
|
+
if (
|
|
3
|
+
nodeVersions[0] >= 17 &&
|
|
4
|
+
process.env["NODE_OPTIONS"] &&
|
|
5
|
+
process.env["NODE_OPTIONS"].search(/--openssl-legacy-provider/) == -1
|
|
6
|
+
) {
|
|
7
|
+
console.warn(`
|
|
8
|
+
当前 nodejs 版本为 ${process.version}
|
|
9
|
+
|
|
10
|
+
nodejs 17.0.0 后的版本由于使用的 openssl 3.0 的原因。需要使用设置
|
|
11
|
+
export NODE_OPTIONS=--openssl-legacy-provider
|
|
12
|
+
|
|
13
|
+
推荐使用 vue3 进行开发。
|
|
14
|
+
`);
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
module.exports = {
|
|
2
18
|
devServer: {
|
|
3
19
|
historyApiFallback: true,
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Forked from https://github.com/isaacs/npm/blob/v1.3.17/lib/utils/completion.sh
|
|
2
|
-
# Forked from https://github.com/twolfson/foundry/blob/4.3.3/bin/completion/foundry
|
|
3
|
-
#!/bin/bash
|
|
4
|
-
###-begin-lzc-cli-completion-###
|
|
5
|
-
#
|
|
6
|
-
# foundry command completion script
|
|
7
|
-
#
|
|
8
|
-
# Installation: lzc-cli completion >> ~/.bashrc (or ~/.zshrc)
|
|
9
|
-
# Or, maybe: lzc-cli completion > /usr/local/etc/bash_completion.d/lzc-cli
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
|
|
13
|
-
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
|
|
14
|
-
export COMP_WORDBREAKS
|
|
15
|
-
|
|
16
|
-
if type complete &>/dev/null; then
|
|
17
|
-
_lzc_cli_completion () {
|
|
18
|
-
local si="$IFS"
|
|
19
|
-
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
|
|
20
|
-
COMP_LINE="$COMP_LINE" \
|
|
21
|
-
COMP_POINT="$COMP_POINT" \
|
|
22
|
-
lzc-cli completion -- "${COMP_WORDS[@]}" \
|
|
23
|
-
2>/dev/null)) || return $?
|
|
24
|
-
IFS="$si"
|
|
25
|
-
}
|
|
26
|
-
complete -F _lzc_cli_completion lzc-cli
|
|
27
|
-
# DEV: We removed `compdef` due to issues with `zsh` (zsh 5.0.0 (x86_64-unknown-linux-gnu))
|
|
28
|
-
elif type compctl &>/dev/null; then
|
|
29
|
-
_lzc_cli_completion () {
|
|
30
|
-
local cword line point words si
|
|
31
|
-
read -Ac words
|
|
32
|
-
read -cn cword
|
|
33
|
-
let cword-=1
|
|
34
|
-
read -l line
|
|
35
|
-
read -ln point
|
|
36
|
-
si="$IFS"
|
|
37
|
-
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
|
|
38
|
-
COMP_LINE="$line" \
|
|
39
|
-
COMP_POINT="$point" \
|
|
40
|
-
lzc-cli completion -- "${words[@]}" \
|
|
41
|
-
2>/dev/null)) || return $?
|
|
42
|
-
IFS="$si"
|
|
43
|
-
}
|
|
44
|
-
compctl -K _lzc_cli_completion lzc-cli
|
|
45
|
-
fi
|
|
46
|
-
###-end-lzc-cli-completion-###
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# need to use root permission to connect unix socket
|
|
2
|
-
user root;
|
|
3
|
-
worker_processes 1;
|
|
4
|
-
|
|
5
|
-
error_log /var/log/nginx/error.log info;
|
|
6
|
-
pid /var/run/nginx.pid;
|
|
7
|
-
|
|
8
|
-
events {
|
|
9
|
-
worker_connections 1024;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
stream {
|
|
13
|
-
upstream tunnel {
|
|
14
|
-
server ${APP_DEBUG_SHELL}:22;
|
|
15
|
-
}
|
|
16
|
-
server {
|
|
17
|
-
listen [::]:22 ipv6only=on;
|
|
18
|
-
proxy_pass tunnel;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
http {
|
|
24
|
-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
25
|
-
'$status $body_bytes_sent "$http_referer" '
|
|
26
|
-
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
27
|
-
|
|
28
|
-
access_log /var/log/nginx/access.log main;
|
|
29
|
-
|
|
30
|
-
sendfile on;
|
|
31
|
-
#tcp_nopush on;
|
|
32
|
-
|
|
33
|
-
keepalive_timeout 65;
|
|
34
|
-
|
|
35
|
-
map $http_upgrade $connection_upgrade {
|
|
36
|
-
default upgrade;
|
|
37
|
-
'' close;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
#gzip on;
|
|
41
|
-
|
|
42
|
-
server {
|
|
43
|
-
listen *:${APP_DEBUG_PORT};
|
|
44
|
-
|
|
45
|
-
error_page 502 503 504 /50x.html;
|
|
46
|
-
|
|
47
|
-
large_client_header_buffers 4 32k;
|
|
48
|
-
|
|
49
|
-
location = /50x.html {
|
|
50
|
-
root /etc/nginx;
|
|
51
|
-
internal;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
location / {
|
|
55
|
-
proxy_pass http://${APP_DEBUG_SHELL}:${APP_DEBUG_PORT}/;
|
|
56
|
-
proxy_set_header Host localhost;
|
|
57
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
58
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
59
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
60
|
-
proxy_set_header Connection $connection_upgrade;
|
|
61
|
-
proxy_next_upstream error timeout invalid_header http_502 http_503 http_504;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
package/template/vue/src/lzc.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
// lzcapis 提供以下api
|
|
2
|
-
// - lzcapis/profile
|
|
3
|
-
// - lzcapis/fs
|
|
4
|
-
// - lzcapis/login
|
|
5
|
-
|
|
6
|
-
import { createClient } from "webdav";
|
|
7
|
-
|
|
8
|
-
function statusText(res) {
|
|
9
|
-
return `Status Code: ${res.status}, Error: ${res.statusText}`;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getCookie(cname) {
|
|
13
|
-
let name = cname + "=";
|
|
14
|
-
let decodedCookie = decodeURIComponent(document.cookie);
|
|
15
|
-
let ca = decodedCookie.split(";");
|
|
16
|
-
for (let i = 0; i < ca.length; i++) {
|
|
17
|
-
let c = ca[i];
|
|
18
|
-
while (c.charAt(0) == " ") {
|
|
19
|
-
c = c.substring(1);
|
|
20
|
-
}
|
|
21
|
-
if (c.indexOf(name) == 0) {
|
|
22
|
-
return c.substring(name.length, c.length);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return "";
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
class LZC {
|
|
29
|
-
constructor() {
|
|
30
|
-
this.api = window.location.origin + "/lzcapis";
|
|
31
|
-
this.user = undefined;
|
|
32
|
-
this.fs = undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// vue plugin interface
|
|
36
|
-
install(vue, { webdav } = {}) {
|
|
37
|
-
if (webdav) {
|
|
38
|
-
this.fs = createClient(this.fsAPI(), {});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
vue.prototype.$lzc = this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fsAPI() {
|
|
45
|
-
return this.api + "/fs";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
profileAPI() {
|
|
49
|
-
return this.api + "/profile";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async getProfile() {
|
|
53
|
-
let res = await fetch(this.profileAPI());
|
|
54
|
-
if (res.status === 200) {
|
|
55
|
-
let userInfo = await res.json();
|
|
56
|
-
|
|
57
|
-
this.user = userInfo;
|
|
58
|
-
return userInfo;
|
|
59
|
-
} else {
|
|
60
|
-
throw statusText(res);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
loginAPI(redirect) {
|
|
65
|
-
if (!redirect) {
|
|
66
|
-
redirect = window.location.origin;
|
|
67
|
-
}
|
|
68
|
-
return this.api + "/login" + "?redirect=" + redirect;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// if lzcapis-session already exist, will auto login
|
|
72
|
-
// else will redirect to the lzcapis auth page.
|
|
73
|
-
async autoLogin() {
|
|
74
|
-
try {
|
|
75
|
-
let cs = getCookie("lzcapis-session");
|
|
76
|
-
if (cs) {
|
|
77
|
-
let profile = await this.getProfile();
|
|
78
|
-
return profile;
|
|
79
|
-
}
|
|
80
|
-
} catch (e) {
|
|
81
|
-
console.error(e);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
login(redirect) {
|
|
86
|
-
window.location.replace(this.loginAPI(redirect));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
logoutAPI(redirect) {
|
|
90
|
-
if (!redirect) {
|
|
91
|
-
redirect = window.location.href;
|
|
92
|
-
}
|
|
93
|
-
return this.api + "/logout" + "?redirect_uri=" + redirect;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async logout() {
|
|
97
|
-
let res = await fetch(this.logoutAPI(), { mode: "no-cors" });
|
|
98
|
-
if (res.status === 200) {
|
|
99
|
-
return Promise.resolve();
|
|
100
|
-
} else {
|
|
101
|
-
throw statusText(res);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
isLogged() {
|
|
106
|
-
return !!this.user;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export default LZC;
|