@lazycatcloud/lzc-cli 1.1.7 → 1.1.9

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 (105) hide show
  1. package/README.md +69 -11
  2. package/lib/api.js +71 -36
  3. package/lib/app/index.js +79 -23
  4. package/lib/app/lpk_build.js +96 -52
  5. package/lib/app/lpk_create.js +63 -41
  6. package/lib/app/lpk_create_generator.js +202 -0
  7. package/lib/app/lpk_devshell.js +393 -328
  8. package/lib/app/lpk_devshell_docker.js +211 -0
  9. package/lib/app/lpk_installer.js +63 -26
  10. package/lib/app/lpk_log.js +68 -0
  11. package/lib/app/lpk_status.js +18 -0
  12. package/lib/app/lpk_uninstall.js +19 -0
  13. package/lib/appstore/index.js +37 -0
  14. package/lib/appstore/login.js +137 -0
  15. package/lib/appstore/publish.js +62 -0
  16. package/lib/autologin.js +0 -80
  17. package/lib/box/api/clientapi.js +1322 -0
  18. package/lib/box/api/empty.js +35 -0
  19. package/lib/box/check_qemu.js +1 -0
  20. package/lib/box/index.js +41 -94
  21. package/lib/box/qemu_vm_mgr.js +208 -239
  22. package/lib/box/schemes/vm_box_system_debian.json +1 -1
  23. package/lib/docker-compose.js +1 -2
  24. package/lib/env.js +23 -142
  25. package/lib/key.js +1 -0
  26. package/lib/sdk.js +10 -25
  27. package/lib/utils.js +156 -233
  28. package/package.json +19 -11
  29. package/scripts/cli.js +14 -135
  30. package/template/_lpk/README.md +31 -0
  31. package/template/_lpk/exec.sh +19 -0
  32. package/template/_lpk/golang.manifest.yml.in +16 -0
  33. package/template/_lpk/lazycat.png +0 -0
  34. package/template/_lpk/lite.manifest.yml.in +19 -0
  35. package/template/_lpk/local_devshell/Dockerfile +16 -0
  36. package/template/_lpk/local_devshell/build.sh +5 -0
  37. package/template/_lpk/local_devshell/entrypoint.sh +87 -0
  38. package/template/{_lazycat/debug/shell → _lpk/local_devshell}/sshd_config +8 -8
  39. package/template/_lpk/manifest.yml.in +0 -1
  40. package/template/{vue/lzc-build.yml → _lpk/vue.lzc-build.yml.in} +9 -1
  41. package/template/golang/README.md +0 -2
  42. package/template/golang/_gitignore +2 -0
  43. package/template/golang/build.sh +6 -0
  44. package/template/golang/lazycat.png +0 -0
  45. package/template/golang/lzc-build.yml +9 -1
  46. package/template/golang/rego.go +15 -16
  47. package/template/golang/rego_test.go +13 -0
  48. package/template/ionic_vue3/lazycat.png +0 -0
  49. package/template/ionic_vue3/lzc-build.yml +9 -1
  50. package/template/lite/error_pages/502.html.tpl +13 -0
  51. package/template/lite/lazycat.png +0 -0
  52. package/template/lite/lzc-build.yml +60 -0
  53. package/cmds/app.js +0 -133
  54. package/cmds/config.js +0 -55
  55. package/cmds/create.js +0 -55
  56. package/cmds/dev.js +0 -130
  57. package/cmds/init.js +0 -125
  58. package/cmds/log.js +0 -103
  59. package/cmds/publish.js +0 -116
  60. package/lib/archiver.js +0 -105
  61. package/lib/box/hportal.js +0 -120
  62. package/lib/builder.js +0 -313
  63. package/lib/dev.js +0 -314
  64. package/lib/generator.js +0 -146
  65. package/template/_lazycat/_gitignore +0 -1
  66. package/template/_lazycat/app-config +0 -1
  67. package/template/_lazycat/debug/devforward/50x.html +0 -30
  68. package/template/_lazycat/debug/devforward/Dockerfile +0 -16
  69. package/template/_lazycat/debug/devforward/docker-compose.override.yml.in +0 -11
  70. package/template/_lazycat/debug/devforward/entrypoint.sh +0 -10
  71. package/template/_lazycat/debug/devforward/nginx.conf.template +0 -56
  72. package/template/_lazycat/debug/devforward/sshd_config +0 -116
  73. package/template/_lazycat/debug/shell/50x.html +0 -32
  74. package/template/_lazycat/debug/shell/Dockerfile +0 -18
  75. package/template/_lazycat/debug/shell/build.sh +0 -15
  76. package/template/_lazycat/debug/shell/docker-compose.override.yml.in +0 -13
  77. package/template/_lazycat/debug/shell/entrypoint.sh +0 -12
  78. package/template/_lazycat/docker-compose.yml.in +0 -15
  79. package/template/_lazycat/icon.svg +0 -1
  80. package/template/_lazycat/screenshot.png +0 -0
  81. package/template/_lpk/sync/Dockerfile +0 -16
  82. package/template/_lpk/sync/build.sh +0 -5
  83. package/template/_lpk/sync/entrypoint.sh +0 -8
  84. package/template/_lpk/sync/sshd_config +0 -117
  85. package/template/_lpk/sync.manifest.yml.in +0 -3
  86. package/template/release/golang/Dockerfile +0 -18
  87. package/template/release/golang/build.sh +0 -13
  88. package/template/release/ionic_vue3/Dockerfile +0 -10
  89. package/template/release/ionic_vue3/build.sh +0 -7
  90. package/template/release/ionic_vue3/docker-compose.yml.in +0 -3
  91. package/template/release/vue/Dockerfile +0 -10
  92. package/template/release/vue/build.sh +0 -10
  93. package/template/release/vue/docker-compose.yml.in +0 -3
  94. package/template/vue/README.md +0 -29
  95. package/template/vue/_dockerignore +0 -1
  96. package/template/vue/babel.config.js +0 -3
  97. package/template/vue/package.json +0 -43
  98. package/template/vue/public/favicon.ico +0 -0
  99. package/template/vue/public/index.html +0 -33
  100. package/template/vue/src/App.vue +0 -39
  101. package/template/vue/src/main.js +0 -8
  102. package/template/vue/src/todo.vue +0 -640
  103. package/template/vue/src/top-bar.vue +0 -100
  104. package/template/vue/src/webdav.vue +0 -183
  105. package/template/vue/vue.config.js +0 -21
package/lib/autologin.js CHANGED
@@ -1,84 +1,4 @@
1
1
  import fetch from "node-fetch";
2
-
3
- // autologin.js 提供一个封装好的 fetch request 请求方法,通过这个中间件,可以不用考虑
4
- // auth:auto 所做的授权验证。
5
- let AutoLoginToken = "";
6
- let AutoLoginFailed = false;
7
-
8
- function fetchTokenAction(url) {
9
- return fetch(url).then(async (res) => {
10
- const body = await res.text();
11
- const token = body.match(/name=\"token\" value=\"(.*?)\"/i)[1];
12
- const action = body.match(/action=\"(.*?)\"/i)[1];
13
-
14
- return { token, action };
15
- });
16
- }
17
-
18
- function fetchTokenActionAndRedirect(dataToken, dataAction) {
19
- return fetch(dataAction, {
20
- method: "POST",
21
- body: `token=${dataToken}`,
22
- redirect: "follow",
23
- headers: {
24
- accept:
25
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
26
- "accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
27
- "content-type": "application/x-www-form-urlencoded",
28
- },
29
- }).then(async (res) => {
30
- let body = await res.text();
31
- const token = body.match(/name=\"token\" value=\"(.*?)\"/i)[1];
32
- const action = body.match(/action=\"(.*?)\"/i)[1];
33
- const redirect = body.match(/name=\"redirect\" value=\"(.*?)\"/i)[1];
34
-
35
- return { token, action, redirect };
36
- });
37
- }
38
-
39
2
  export async function request(url, options = {}) {
40
- if (AutoLoginFailed) {
41
- return fetch(url, options);
42
- }
43
-
44
- await tryAuthLogin(url);
45
-
46
- if (!AutoLoginToken) {
47
- return fetch(url, options);
48
- }
49
-
50
- let headers = { cookie: `HC-Auth-Token=${AutoLoginToken}` };
51
- if (options.headers) {
52
- headers = Object.assign({}, options.headers, headers);
53
- }
54
-
55
- options = Object.assign({}, options, { headers });
56
3
  return fetch(url, options);
57
4
  }
58
-
59
- export async function tryAuthLogin(url) {
60
- if (!url.startsWith("http")) {
61
- url = "https://" + url;
62
- }
63
-
64
- try {
65
- if (!AutoLoginToken) {
66
- let _url = new URL(url);
67
- let u = _url.host.split(".").reverse().slice(0, 3).reverse().join(".");
68
-
69
- console.log(`${u} 尝试自动登录...`);
70
-
71
- let data = await fetchTokenAction(`${_url.protocol}//${u}`);
72
- let data2 = await fetchTokenActionAndRedirect(data.token, data.action);
73
-
74
- AutoLoginToken = data2.token;
75
- console.log(`自动登录成功!`);
76
- return AutoLoginToken;
77
- }
78
- } catch (e) {
79
- console.error(e);
80
- console.log(`尝试自动登录失败,正在使用默认的登录方式...`);
81
- AutoLoginFailed = true;
82
- return "";
83
- }
84
- }