@lazycatcloud/lzc-cli 1.1.5 → 1.1.8

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 (52) hide show
  1. package/cmds/app.js +1 -5
  2. package/cmds/dev.js +11 -5
  3. package/lib/api.js +24 -7
  4. package/lib/app/index.js +93 -0
  5. package/lib/app/lpk_build.js +241 -0
  6. package/lib/app/lpk_create.js +201 -0
  7. package/lib/app/lpk_devshell.js +621 -0
  8. package/lib/app/lpk_installer.js +67 -0
  9. package/lib/appstore/login.js +134 -0
  10. package/lib/archiver.js +0 -42
  11. package/lib/autologin.js +82 -0
  12. package/lib/box/check_qemu.js +39 -16
  13. package/lib/box/hportal.js +7 -1
  14. package/lib/box/index.js +8 -7
  15. package/lib/box/qemu_vm_mgr.js +12 -11
  16. package/lib/dev.js +0 -4
  17. package/lib/env.js +16 -49
  18. package/lib/generator.js +2 -2
  19. package/lib/sdk.js +5 -6
  20. package/lib/utils.js +66 -144
  21. package/package.json +8 -3
  22. package/scripts/cli.js +91 -12
  23. package/template/_lazycat/debug/shell/Dockerfile +5 -3
  24. package/template/_lazycat/debug/shell/docker-compose.override.yml.in +2 -12
  25. package/template/_lazycat/debug/shell/entrypoint.sh +3 -1
  26. package/template/_lpk/Dockerfile.in +8 -0
  27. package/template/_lpk/devshell/Dockerfile +18 -0
  28. package/template/_lpk/devshell/build.sh +5 -0
  29. package/template/_lpk/devshell/entrypoint.sh +8 -0
  30. package/template/_lpk/devshell/sshd_config +117 -0
  31. package/template/_lpk/manifest.yml.in +17 -0
  32. package/template/_lpk/sync/Dockerfile +16 -0
  33. package/template/_lpk/sync/build.sh +5 -0
  34. package/template/_lpk/sync/entrypoint.sh +8 -0
  35. package/template/_lpk/sync/sshd_config +117 -0
  36. package/template/_lpk/sync.manifest.yml.in +3 -0
  37. package/template/golang/build.sh +6 -0
  38. package/template/golang/lzc-build.yml +52 -0
  39. package/template/ionic_vue3/lzc-build.yml +53 -0
  40. package/template/ionic_vue3/vite.config.ts +1 -1
  41. package/template/release/golang/build.sh +1 -1
  42. package/template/release/ionic_vue3/Dockerfile +1 -1
  43. package/template/release/ionic_vue3/build.sh +1 -3
  44. package/template/release/ionic_vue3/docker-compose.yml.in +0 -5
  45. package/template/release/vue/Dockerfile +1 -1
  46. package/template/release/vue/build.sh +2 -3
  47. package/template/release/vue/docker-compose.yml.in +0 -5
  48. package/template/vue/lzc-build.yml +53 -0
  49. package/template/vue/src/main.js +3 -14
  50. package/template/vue/vue.config.js +2 -1
  51. package/template/_lazycat/debug/shell/nginx.conf.template +0 -64
  52. package/template/vue/src/lzc.js +0 -110
@@ -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;