@lazycatcloud/lzc-cli 1.2.30 → 1.2.31

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/lib/app/index.js CHANGED
@@ -7,13 +7,23 @@ import logger from "loglevel"
7
7
  import { sleep } from "../utils.js"
8
8
  import { DebugBridge } from "./lpk_debug_bridge.js"
9
9
  import shellApi from "../shellapi.js"
10
+ import { generate } from "./lpk_create_generator.js"
10
11
 
11
12
  export function lpkProjectCommand(program) {
12
13
  let subCommands = [
14
+ {
15
+ command: "init",
16
+ desc: "初始化懒猫云应用(提供最基础的模板)",
17
+ handler: async () => {
18
+ generate("blank", "./")
19
+ logger.info("应用初始化完成")
20
+ }
21
+ },
13
22
  {
14
23
  command: "create <name>",
15
24
  desc: "创建懒猫云应用",
16
25
  handler: async ({ name }) => {
26
+ name = String(name)
17
27
  await lpkCreate(name)
18
28
  }
19
29
  },
@@ -52,14 +52,13 @@ export class LpkManifest {
52
52
  {
53
53
  type: "input",
54
54
  name: "appId",
55
- message: `请输入应用ID, 如(${this.defaultAppID})`,
55
+ message: `请输入应用ID,例如app-demo1`,
56
56
  default: this.defaultAppID,
57
57
  validate: (input) => {
58
58
  if (isValidAppId(input)) {
59
59
  return true
60
60
  } else {
61
- // return `请输入 1-63 位的字母、数字或-,且不能以-开头或结尾。`
62
- return `请输入 1-63 位的字母、数字。`
61
+ return `允许小写字母或数字或-的组合,但不以数字开头,且不能以 - 开头或结束,也不能有连续的短横线 --`
63
62
  }
64
63
  }
65
64
  }
@@ -50,7 +50,7 @@ function writeFileTree(target, files) {
50
50
  })
51
51
  }
52
52
 
53
- async function generate(type, to, opts = {}) {
53
+ export async function generate(type, to, opts = {}) {
54
54
  const files = await loadFiles(type, opts.prefix)
55
55
  writeFileTree(to, files)
56
56
  }
package/lib/utils.js CHANGED
@@ -359,16 +359,15 @@ export class FileLocker {
359
359
  }
360
360
 
361
361
  export function isValidAppId(appId) {
362
- // 暂时去掉 - 的支持
363
- // const regex = new RegExp("^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$")
364
- const regex = new RegExp("^[a-z][a-z0-9]{0,61}[a-zA-Z0-9]$")
362
+ const regex = new RegExp("^(?!-)(?!.*--)[a-z][a-z0-9]*([-][a-z0-9]+)*$")
365
363
  return regex.test(appId)
366
364
  }
367
365
 
368
366
  export function isValidPackageName(packageName) {
369
367
  // 暂时去掉 - 的支持
370
- // const regex = new RegExp("^(?:[a-z][a-z0-9-]*\\.)+[a-z][a-z0-9-]*$")
371
- const regex = new RegExp("^(?:[a-z][a-z0-9]*\\.)+[a-z][a-z0-9]*$")
368
+ const regex = new RegExp(
369
+ "^[a-z][a-z0-9]*([-][a-z0-9]+)*(?:.[a-z][a-z0-9]*([-][a-z0-9]+)*)*$"
370
+ )
372
371
  return regex.test(packageName)
373
372
  }
374
373
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.30",
3
+ "version": "1.2.31",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "files": [
6
6
  "template",
@@ -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,12 @@
1
+ lzc-sdk-version: 0.1
2
+ name: helloworld
3
+ package: cloud.lazycat.app.helloworld
4
+ version: 0.0.1
5
+ description:
6
+ license: https://choosealicense.com/licenses/mit/
7
+ homepage:
8
+ author:
9
+ application:
10
+ subdomain: helloworld
11
+ routes:
12
+ - /=file:///lzcapp/pkg/content/dist