@lazycatcloud/lzc-cli 1.1.0
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 +21 -0
- package/lib/api.js +123 -0
- package/lib/archiver.js +128 -0
- package/lib/builder.js +183 -0
- package/lib/dev.js +300 -0
- package/lib/docker/promise.js +91 -0
- package/lib/docker-compose.js +51 -0
- package/lib/env.js +104 -0
- package/lib/generator.js +115 -0
- package/lib/key.js +112 -0
- package/lib/sdk.js +129 -0
- package/lib/utils.js +349 -0
- package/package.json +53 -0
- package/scripts/cli.js +98 -0
- package/template/_lazycat/_gitignore +1 -0
- package/template/_lazycat/debug/devforward/50x.html +30 -0
- package/template/_lazycat/debug/devforward/Dockerfile +16 -0
- package/template/_lazycat/debug/devforward/docker-compose.override.yml.in +11 -0
- package/template/_lazycat/debug/devforward/entrypoint.sh +10 -0
- package/template/_lazycat/debug/devforward/nginx.conf.template +56 -0
- package/template/_lazycat/debug/devforward/sshd_config +116 -0
- package/template/_lazycat/debug/shell/50x.html +32 -0
- package/template/_lazycat/debug/shell/Dockerfile +16 -0
- package/template/_lazycat/debug/shell/build.sh +15 -0
- package/template/_lazycat/debug/shell/docker-compose.override.yml.in +23 -0
- package/template/_lazycat/debug/shell/entrypoint.sh +10 -0
- package/template/_lazycat/debug/shell/nginx.conf.template +64 -0
- package/template/_lazycat/debug/shell/sshd_config +117 -0
- package/template/_lazycat/docker-compose.yml.in +17 -0
- package/template/_lazycat/icon.svg +1 -0
- package/template/_lazycat/screenshot.png +0 -0
- package/template/golang/.godir +1 -0
- package/template/golang/README.md +13 -0
- package/template/golang/assets/css/bootstrap-responsive.css +1088 -0
- package/template/golang/assets/css/bootstrap-responsive.min.css +9 -0
- package/template/golang/assets/css/bootstrap.css +5893 -0
- package/template/golang/assets/css/bootstrap.min.css +9 -0
- package/template/golang/assets/css/rego.css +45 -0
- package/template/golang/assets/img/glyphicons-halflings-white.png +0 -0
- package/template/golang/assets/img/glyphicons-halflings.png +0 -0
- package/template/golang/assets/js/bootstrap.js +2025 -0
- package/template/golang/assets/js/bootstrap.min.js +6 -0
- package/template/golang/assets/js/rego.js +121 -0
- package/template/golang/go.mod +3 -0
- package/template/golang/index.html +267 -0
- package/template/golang/rego.go +83 -0
- package/template/release/golang/Dockerfile +18 -0
- package/template/release/golang/build.sh +14 -0
- package/template/release/vue/Dockerfile +9 -0
- package/template/release/vue/build.sh +9 -0
- package/template/release/vue/docker-compose.yml.in +8 -0
- package/template/vue/README.md +24 -0
- package/template/vue/_dockerignore +1 -0
- package/template/vue/babel.config.js +5 -0
- package/template/vue/package.json +43 -0
- package/template/vue/public/favicon.ico +0 -0
- package/template/vue/public/index.html +33 -0
- package/template/vue/src/App.vue +39 -0
- package/template/vue/src/lzc.js +110 -0
- package/template/vue/src/main.js +19 -0
- package/template/vue/src/todo.vue +640 -0
- package/template/vue/src/top-bar.vue +100 -0
- package/template/vue/src/webdav.vue +183 -0
- package/template/vue/vue.config.js +5 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hc_test",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve",
|
|
7
|
+
"build": "vue-cli-service build",
|
|
8
|
+
"lint": "vue-cli-service lint"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"core-js": "^3.6.5",
|
|
12
|
+
"vue": "^2.6.11",
|
|
13
|
+
"webdav": "^4.7.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@vue/cli-plugin-babel": "~4.5.0",
|
|
17
|
+
"@vue/cli-plugin-eslint": "~4.5.0",
|
|
18
|
+
"@vue/cli-service": "~4.5.0",
|
|
19
|
+
"babel-eslint": "^10.1.0",
|
|
20
|
+
"eslint": "^6.7.2",
|
|
21
|
+
"eslint-plugin-vue": "^6.2.2",
|
|
22
|
+
"vue-template-compiler": "^2.6.11"
|
|
23
|
+
},
|
|
24
|
+
"eslintConfig": {
|
|
25
|
+
"root": true,
|
|
26
|
+
"env": {
|
|
27
|
+
"node": true
|
|
28
|
+
},
|
|
29
|
+
"extends": [
|
|
30
|
+
"plugin:vue/essential",
|
|
31
|
+
"eslint:recommended"
|
|
32
|
+
],
|
|
33
|
+
"parserOptions": {
|
|
34
|
+
"parser": "babel-eslint"
|
|
35
|
+
},
|
|
36
|
+
"rules": {}
|
|
37
|
+
},
|
|
38
|
+
"browserslist": [
|
|
39
|
+
"> 1%",
|
|
40
|
+
"last 2 versions",
|
|
41
|
+
"not dead"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
7
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
|
|
8
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
font: 14px "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
12
|
+
line-height: 1.4em;
|
|
13
|
+
background: #f5f5f5;
|
|
14
|
+
color: #4d4d4d;
|
|
15
|
+
margin: 0 auto;
|
|
16
|
+
-webkit-font-smoothing: antialiased;
|
|
17
|
+
-moz-osx-font-smoothing: grayscale;
|
|
18
|
+
font-weight: 300;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<noscript>
|
|
24
|
+
<strong
|
|
25
|
+
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
|
|
26
|
+
properly without JavaScript enabled. Please enable it to
|
|
27
|
+
continue.</strong
|
|
28
|
+
>
|
|
29
|
+
</noscript>
|
|
30
|
+
<div id="app"></div>
|
|
31
|
+
<!-- built files will be auto injected -->
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="app-list">
|
|
3
|
+
<top-bar @login="isLogged = true" @logout="isLogged = false"></top-bar>
|
|
4
|
+
<todo v-if="isLogged"></todo>
|
|
5
|
+
<web-dav v-if="isLogged"></web-dav>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
components: {
|
|
12
|
+
TopBar: () => import("./top-bar.vue"),
|
|
13
|
+
Todo: () => import("./todo.vue"),
|
|
14
|
+
WebDav: () => import("./webdav.vue"),
|
|
15
|
+
},
|
|
16
|
+
mounted() {
|
|
17
|
+
this.isLogged = this.$lzc.isLogged();
|
|
18
|
+
},
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
isLogged: false,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<style scoped>
|
|
28
|
+
.app-list {
|
|
29
|
+
width: 100%;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
min-width: 230px;
|
|
33
|
+
max-width: 800px;
|
|
34
|
+
margin: auto;
|
|
35
|
+
}
|
|
36
|
+
.app-list > div {
|
|
37
|
+
margin: 50px 0px;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,110 @@
|
|
|
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Vue from "vue";
|
|
2
|
+
import App from "./App.vue";
|
|
3
|
+
|
|
4
|
+
Vue.config.productionTip = false;
|
|
5
|
+
|
|
6
|
+
import LZC from "./lzc.js";
|
|
7
|
+
const lzc = new LZC();
|
|
8
|
+
Vue.use(lzc, { webdav: true });
|
|
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
|
+
});
|