@lazycatcloud/lzc-cli 1.2.27 → 1.2.29

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 (37) hide show
  1. package/lib/app/apkshell.js +35 -0
  2. package/lib/app/index.js +89 -78
  3. package/lib/app/lpk_build.js +113 -117
  4. package/lib/app/lpk_create.js +78 -148
  5. package/lib/app/lpk_create_generator.js +103 -74
  6. package/lib/app/lpk_debug_bridge.js +61 -73
  7. package/lib/app/lpk_devshell.js +230 -229
  8. package/lib/app/lpk_devshell_docker.js +28 -28
  9. package/lib/app/lpk_installer.js +64 -49
  10. package/lib/appstore/index.js +29 -29
  11. package/lib/appstore/login.js +63 -68
  12. package/lib/appstore/prePublish.js +68 -68
  13. package/lib/appstore/publish.js +55 -55
  14. package/lib/box/index.js +25 -25
  15. package/lib/env.js +18 -18
  16. package/lib/shellapi.js +55 -58
  17. package/lib/utils.js +217 -164
  18. package/package.json +7 -1
  19. package/scripts/cli.js +56 -56
  20. package/template/_lpk/manifest.yml.in +8 -8
  21. package/template/vue/README.md +29 -0
  22. package/template/vue/index.html +13 -0
  23. package/template/vue/lzc-build.yml +59 -0
  24. package/template/vue/lzc-icon.png +0 -0
  25. package/template/vue/package.json +20 -0
  26. package/template/vue/public/vite.svg +1 -0
  27. package/template/vue/src/App.vue +30 -0
  28. package/template/vue/src/assets/vue.svg +1 -0
  29. package/template/vue/src/components/HelloWorld.vue +41 -0
  30. package/template/vue/src/main.ts +5 -0
  31. package/template/vue/src/style.css +79 -0
  32. package/template/vue/src/vite-env.d.ts +1 -0
  33. package/template/vue/tsconfig.app.json +24 -0
  34. package/template/vue/tsconfig.json +7 -0
  35. package/template/vue/tsconfig.node.json +22 -0
  36. package/template/vue/vite.config.ts +7 -0
  37. package/template/ionic_vue3/package-lock.json +0 -8100
package/scripts/cli.js CHANGED
@@ -1,62 +1,62 @@
1
1
  #!/usr/bin/env node
2
- import process from "process";
3
- import path from "path";
4
- import fs from "fs";
5
- import logger from "loglevel";
6
- import yargs from "yargs";
7
- import { hideBin } from "yargs/helpers";
8
- import chalk from "chalk";
2
+ import process from "process"
3
+ import path from "path"
4
+ import fs from "fs"
5
+ import logger from "loglevel"
6
+ import yargs from "yargs"
7
+ import { hideBin } from "yargs/helpers"
8
+ import chalk from "chalk"
9
9
 
10
- import { contextDirname } from "../lib/utils.js";
11
- import { boxCommand } from "../lib/box/index.js";
12
- import { appstoreCommand } from "../lib/appstore/index.js";
13
- import { lpkAppCommand, lpkProjectCommand } from "../lib/app/index.js";
10
+ import { contextDirname } from "../lib/utils.js"
11
+ import { boxCommand } from "../lib/box/index.js"
12
+ import { appstoreCommand } from "../lib/appstore/index.js"
13
+ import { lpkAppCommand, lpkProjectCommand } from "../lib/app/index.js"
14
14
  const pkgInfo = JSON.parse(
15
15
  fs.readFileSync(path.join(contextDirname(import.meta.url), "../package.json"))
16
- );
17
- import env from "../lib/env.js";
16
+ )
17
+ import env from "../lib/env.js"
18
18
 
19
19
  // logger level middleware
20
- const logLevelOriginalFactory = logger.methodFactory;
20
+ const logLevelOriginalFactory = logger.methodFactory
21
21
  logger.methodFactory = function (methodName, logLevel, loggerName) {
22
- let rawMethod = logLevelOriginalFactory(methodName, logLevel, loggerName);
22
+ let rawMethod = logLevelOriginalFactory(methodName, logLevel, loggerName)
23
23
  return function (...args) {
24
- let color = (msg) => chalk.gray;
24
+ let color = (msg) => chalk.gray
25
25
  switch (methodName) {
26
26
  case "trace":
27
- color = chalk.dim.cyan;
28
- break;
27
+ color = chalk.dim.cyan
28
+ break
29
29
  case "debug":
30
- color = chalk.blue;
31
- break;
30
+ color = chalk.blue
31
+ break
32
32
  case "info":
33
- color = chalk.green;
34
- break;
33
+ color = chalk.green
34
+ break
35
35
  case "warn":
36
- color = chalk.magenta;
37
- break;
36
+ color = chalk.magenta
37
+ break
38
38
  case "error":
39
- color = chalk.bold.red;
40
- break;
39
+ color = chalk.bold.red
40
+ break
41
41
  }
42
- const prefix = loggerName ?? methodName;
42
+ const prefix = loggerName ?? methodName
43
43
  rawMethod(
44
44
  `[${prefix}] ` +
45
45
  args
46
46
  .map((a) => {
47
- let res = a;
47
+ let res = a
48
48
  if (typeof a == "object") {
49
- res = JSON.stringify(a, undefined, 4);
49
+ res = JSON.stringify(a, undefined, 4)
50
50
  }
51
- return color(res);
51
+ return color(res)
52
52
  })
53
53
  .join(" ")
54
- );
55
- };
56
- };
57
- logger.setDefaultLevel("info");
54
+ )
55
+ }
56
+ }
57
+ logger.setDefaultLevel("info")
58
58
  function setLoggerLevel({ log }) {
59
- logger.setLevel(log, false);
59
+ logger.setLevel(log, false)
60
60
  }
61
61
 
62
62
  const program = yargs(hideBin(process.argv))
@@ -66,55 +66,55 @@ const program = yargs(hideBin(process.argv))
66
66
  .option("log", {
67
67
  type: "string",
68
68
  default: "info",
69
- describe: "log level 'trace', 'debug', 'info', 'warn', 'error'",
69
+ describe: "log level 'trace', 'debug', 'info', 'warn', 'error'"
70
70
  })
71
71
  .option("help", {
72
72
  alias: "h",
73
73
  type: "boolean",
74
- default: false,
74
+ default: false
75
75
  })
76
- .completion("completion", false);
76
+ .completion("completion", false)
77
77
 
78
78
  program.command({
79
79
  command: "config [key] [value]",
80
80
  desc: false,
81
81
  builder: (args) => {
82
- args.implies("key", "value");
82
+ args.implies("key", "value")
83
83
  },
84
84
  handler: async ({ key, value }) => {
85
85
  if (!key && !value) {
86
- console.log(env.stringify());
87
- return;
86
+ console.log(env.stringify())
87
+ return
88
88
  }
89
- const pair = Object.fromEntries([[key, value]]);
90
- env.set(pair, true);
91
- },
92
- });
89
+ const pair = Object.fromEntries([[key, value]])
90
+ env.set(pair, true)
91
+ }
92
+ })
93
93
 
94
- boxCommand(program);
95
- lpkAppCommand(program);
96
- lpkProjectCommand(program);
97
- appstoreCommand(program);
94
+ boxCommand(program)
95
+ lpkAppCommand(program)
96
+ lpkProjectCommand(program)
97
+ appstoreCommand(program)
98
98
 
99
99
  // 当没有参数的时候,默认显示帮助。
100
- (async () => {
100
+ ;(async () => {
101
101
  const parser = program
102
102
  .strict()
103
103
  .showHelpOnFail(false, "使用 lzc-cli help 查看更多帮助")
104
104
  .middleware([setLoggerLevel])
105
- .parse();
105
+ .parse()
106
106
 
107
- const argv = await parser;
107
+ const argv = await parser
108
108
  if (argv._.length == 1) {
109
109
  switch (argv._[0]) {
110
110
  case "box":
111
111
  case "app":
112
112
  case "project":
113
113
  case "appstore":
114
- program.showHelp();
115
- return;
114
+ program.showHelp()
115
+ return
116
116
  }
117
117
  } else if (argv._.length == 0) {
118
- program.showHelp();
118
+ program.showHelp()
119
119
  }
120
- })();
120
+ })()
@@ -1,16 +1,16 @@
1
1
  lzc-sdk-version: 0.1
2
2
 
3
- package: ${package} # app的唯一标识符
4
- version: ${version} # app的版本
5
- name: ${name} # app名称
6
- description: ${description} # app描述
3
+ name: ${name} # app名称
4
+ package: ${package} # app的唯一标识符
5
+ version: 0.0.1 # app的版本
6
+ description: # app描述
7
7
 
8
8
  license: https://choosealicense.com/licenses/mit/
9
- homepage: ${homepage} # 出现bug时候提交反馈的地方
10
- author: ${author} # app author
9
+ homepage: # 出现bug时候提交反馈的地方
10
+ author: # app author
11
11
 
12
12
  #application作为一个特殊的container运行,对应的service名称为固定的`app`,其他service可以通过此名称与app进行通讯
13
13
  application:
14
- subdomain: ${subdomain} #期望的app域名
14
+ subdomain: ${subdomain} #期望的app域名
15
15
  routes:
16
- - /=file:///lzcapp/pkg/content/
16
+ - /=file:///lzcapp/pkg/content/dist
@@ -0,0 +1,29 @@
1
+ # 懒猫云应用
2
+
3
+ ## 开发
4
+ ```
5
+ lzc-cli project devshell
6
+ ```
7
+
8
+ 进入应用容器,并且自动同步当前目录内容到容器
9
+ 然后就可以启动你的应用了,例如前端
10
+ npm install
11
+ npm run dev
12
+
13
+ ## 构建
14
+ ```
15
+ lzc-cli project build -o you-awesome.lpk
16
+ ```
17
+
18
+ 会在当前的目录下构建出一个 lpk 包。
19
+
20
+ ## 安装
21
+ ```
22
+ lzc-cli app install you-awesome.lpk
23
+ ```
24
+
25
+ 会安装在你的微服应用中,安装成功后可在懒猫微服启动器中查看!
26
+
27
+ ## 交流和帮助
28
+
29
+ 你可以在 https://bbs.lazycat.cloud/ 畅所欲言。
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + Vue + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,59 @@
1
+ # 整个文件中,可以通过 ${var} 的方式,使用 manifest 字段指定的文件定义的值
2
+
3
+ # buildscript
4
+ # - 可以为构建脚本的路径地址
5
+ # - 如果构建命令简单,也可以直接写 sh 的命令
6
+ buildscript: npm run build
7
+
8
+ # manifest: 指定 lpk 包的 manifest.yml 文件路径
9
+ manifest: ./lzc-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: ./lzc-icon.png
20
+
21
+ # devshell 自定义应用的开发容器环境
22
+ # - routers 指定应用容器的访问路由
23
+
24
+ # devshell 没有指定 image 的情况,将会默认使用 registry.lazycat.cloud/lzc-cli/devshell:v0.0.5
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:v0.0.5
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
+ # 这种情况下,选用 alpine:latest 作为基础镜像,在 dependencies 中添加所需要的开发依赖即可
46
+ # 如果 dependencies 和 build 同时存在,将会优先使用 dependencies
47
+ devshell:
48
+ routes:
49
+ - /=http://127.0.0.1:3000
50
+ dependencies:
51
+ - nodejs
52
+ - npm
53
+ # setupscript 每次进入到app container后都会执行的配置脚本
54
+ # - 可以为脚本的路径地址
55
+ # - 如果构建命令简单,也可以直接写 sh 的命令
56
+ # setupscript: export GOPROXY=https://goproxy.cn
57
+ # setupscript: ./setupscript.sh
58
+ setupscript: |
59
+ export npm_config_registry=https://registry.npmmirror.com
Binary file
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "lzc-app-template",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite --port 3000 --host",
8
+ "build": "vue-tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "vue": "^3.4.37"
13
+ },
14
+ "devDependencies": {
15
+ "@vitejs/plugin-vue": "^5.1.2",
16
+ "typescript": "^5.5.3",
17
+ "vite": "^5.4.1",
18
+ "vue-tsc": "^2.0.29"
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import HelloWorld from './components/HelloWorld.vue'
3
+ </script>
4
+
5
+ <template>
6
+ <div>
7
+ <a href="https://vitejs.dev" target="_blank">
8
+ <img src="/vite.svg" class="logo" alt="Vite logo" />
9
+ </a>
10
+ <a href="https://vuejs.org/" target="_blank">
11
+ <img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
12
+ </a>
13
+ </div>
14
+ <HelloWorld msg="Vite + Vue" />
15
+ </template>
16
+
17
+ <style scoped>
18
+ .logo {
19
+ height: 6em;
20
+ padding: 1.5em;
21
+ will-change: filter;
22
+ transition: filter 300ms;
23
+ }
24
+ .logo:hover {
25
+ filter: drop-shadow(0 0 2em #646cffaa);
26
+ }
27
+ .logo.vue:hover {
28
+ filter: drop-shadow(0 0 2em #42b883aa);
29
+ }
30
+ </style>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
@@ -0,0 +1,41 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+
4
+ defineProps<{ msg: string }>()
5
+
6
+ const count = ref(0)
7
+ </script>
8
+
9
+ <template>
10
+ <h1>{{ msg }}</h1>
11
+
12
+ <div class="card">
13
+ <button type="button" @click="count++">count is {{ count }}</button>
14
+ <p>
15
+ Edit
16
+ <code>components/HelloWorld.vue</code> to test HMR
17
+ </p>
18
+ </div>
19
+
20
+ <p>
21
+ Check out
22
+ <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
23
+ >create-vue</a
24
+ >, the official Vue + Vite starter
25
+ </p>
26
+ <p>
27
+ Learn more about IDE Support for Vue in the
28
+ <a
29
+ href="https://vuejs.org/guide/scaling-up/tooling.html#ide-support"
30
+ target="_blank"
31
+ >Vue Docs Scaling up Guide</a
32
+ >.
33
+ </p>
34
+ <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
35
+ </template>
36
+
37
+ <style scoped>
38
+ .read-the-docs {
39
+ color: #888;
40
+ }
41
+ </style>
@@ -0,0 +1,5 @@
1
+ import { createApp } from 'vue'
2
+ import './style.css'
3
+ import App from './App.vue'
4
+
5
+ createApp(App).mount('#app')
@@ -0,0 +1,79 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ a {
17
+ font-weight: 500;
18
+ color: #646cff;
19
+ text-decoration: inherit;
20
+ }
21
+ a:hover {
22
+ color: #535bf2;
23
+ }
24
+
25
+ body {
26
+ margin: 0;
27
+ display: flex;
28
+ place-items: center;
29
+ min-width: 320px;
30
+ min-height: 100vh;
31
+ }
32
+
33
+ h1 {
34
+ font-size: 3.2em;
35
+ line-height: 1.1;
36
+ }
37
+
38
+ button {
39
+ border-radius: 8px;
40
+ border: 1px solid transparent;
41
+ padding: 0.6em 1.2em;
42
+ font-size: 1em;
43
+ font-weight: 500;
44
+ font-family: inherit;
45
+ background-color: #1a1a1a;
46
+ cursor: pointer;
47
+ transition: border-color 0.25s;
48
+ }
49
+ button:hover {
50
+ border-color: #646cff;
51
+ }
52
+ button:focus,
53
+ button:focus-visible {
54
+ outline: 4px auto -webkit-focus-ring-color;
55
+ }
56
+
57
+ .card {
58
+ padding: 2em;
59
+ }
60
+
61
+ #app {
62
+ max-width: 1280px;
63
+ margin: 0 auto;
64
+ padding: 2rem;
65
+ text-align: center;
66
+ }
67
+
68
+ @media (prefers-color-scheme: light) {
69
+ :root {
70
+ color: #213547;
71
+ background-color: #ffffff;
72
+ }
73
+ a:hover {
74
+ color: #747bff;
75
+ }
76
+ button {
77
+ background-color: #f9f9f9;
78
+ }
79
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "isolatedModules": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+ "jsx": "preserve",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true
22
+ },
23
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
24
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
6
+ ]
7
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2023"],
5
+ "module": "ESNext",
6
+ "skipLibCheck": true,
7
+
8
+ /* Bundler mode */
9
+ "moduleResolution": "bundler",
10
+ "allowImportingTsExtensions": true,
11
+ "isolatedModules": true,
12
+ "moduleDetection": "force",
13
+ "noEmit": true,
14
+
15
+ /* Linting */
16
+ "strict": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noFallthroughCasesInSwitch": true
20
+ },
21
+ "include": ["vite.config.ts"]
22
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [vue()],
7
+ })