@lazycatcloud/lzc-cli 1.2.41 → 1.2.42

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.
@@ -187,6 +187,11 @@ export class LpkBuild {
187
187
  if (!isValidPackageName(this.manifest["package"])) {
188
188
  throw `${this.manifest["package"]} 含有非法字符,请使用正确的包名格式(java的包名格式),如:cloud.lazycat.apps.video`
189
189
  }
190
+
191
+ if (!this.manifest["application"]["subdomain"]) {
192
+ throw `application 模块下的 subdomain 字段不能为空`
193
+ }
194
+
190
195
  return this.manifest
191
196
  }
192
197
 
@@ -28,7 +28,11 @@ export class LpkManifest {
28
28
  if (!manifestFilePath) {
29
29
  manifestFilePath = path.join(
30
30
  this.pwd,
31
- "../../template/_lpk/manifest.yml.in"
31
+ "..",
32
+ "..",
33
+ "template",
34
+ "_lpk",
35
+ "manifest.yml.in"
32
36
  )
33
37
  }
34
38
 
@@ -88,7 +92,11 @@ export class TemplateInit {
88
92
  // 优先使用模板项目自定义的模板文件
89
93
  const typeTemplatePath = path.join(
90
94
  contextDirname(import.meta.url),
91
- `../../template/_lpk/${this.type}.manifest.yml.in`
95
+ "..",
96
+ "..",
97
+ "template",
98
+ "_lpk",
99
+ `${this.type}.manifest.yml.in`
92
100
  )
93
101
  const templatePath = isFileExist(typeTemplatePath) ? typeTemplatePath : ""
94
102
  await this.lpkManifest.init(templatePath, true)
@@ -10,10 +10,10 @@ import logger from "loglevel"
10
10
  const __dirname = contextDirname(import.meta.url)
11
11
 
12
12
  async function loadFiles(dirPath, prefix = "") {
13
- const templateRoot = path.join(__dirname, "../../template/")
13
+ const templateRoot = path.join(__dirname, "..", "..", "template")
14
14
  const templateDir = path.join(templateRoot, dirPath)
15
15
 
16
- const _files = await glob(["**/*"], { cwd: templateDir })
16
+ const _files = await glob(["**/*", "**/.*", ".*"], { cwd: templateDir })
17
17
  let content
18
18
  let files = {}
19
19
  for (let p of _files) {
@@ -59,7 +59,11 @@ function appendREADME(dir) {
59
59
  const readme = path.resolve(dir, "README.md")
60
60
  const readmeTemplate = path.resolve(
61
61
  __dirname,
62
- "../../template/_lpk/README.md"
62
+ "..",
63
+ "..",
64
+ "template",
65
+ "_lpk",
66
+ "README.md"
63
67
  )
64
68
  if (!isFileExist(readme)) {
65
69
  fs.copyFileSync(readmeTemplate, readme)
@@ -85,14 +89,22 @@ function vueTemplate(type) {
85
89
 
86
90
  const lzcBuildTemplatePath = path.resolve(
87
91
  __dirname,
88
- `../../template/_lpk/vue.lzc-build.yml.in`
92
+ "..",
93
+ "..",
94
+ "template",
95
+ "_lpk",
96
+ "vue.lzc-build.yml.in"
89
97
  )
90
98
  logger.debug("复制", lzcBuildTemplatePath)
91
99
  fs.copyFileSync(lzcBuildTemplatePath, path.resolve(name, "lzc-build.yml"))
92
100
 
93
101
  const iconPngPath = path.resolve(
94
102
  __dirname,
95
- "../../template/_lpk/lazycat.png"
103
+ "..",
104
+ "..",
105
+ "template",
106
+ "_lpk",
107
+ "lazycat.png"
96
108
  )
97
109
  fs.copyFileSync(iconPngPath, path.resolve(name, "lazycat.png"))
98
110
 
@@ -93,8 +93,12 @@ export class LpkInstaller {
93
93
  const tempDir = fs.mkdtempSync(".lzc-cli-install")
94
94
  let manifest
95
95
  try {
96
- unzipSync(pkgPath, tempDir)
96
+ unzipSync(pkgPath, tempDir, ["manifest.yml", "icon.png"])
97
97
  manifest = loadFromYaml(path.join(tempDir, "manifest.yml"))
98
+ if (!manifest["application"]["subdomain"]) {
99
+ throw "manifest.yml 中的 `application.subdomain` 字段不能为空"
100
+ }
101
+
98
102
  logger.debug("是否生成APK:", installConfig.apk)
99
103
  if (installConfig.apk) {
100
104
  await triggerApk(
@@ -6,6 +6,7 @@ import inquirer from "inquirer"
6
6
  import path from "node:path"
7
7
  import { isFileExist, isPngWithFile, unzipSync } from "../utils.js"
8
8
  import env from "../env.js"
9
+ import { Publish } from "./publish.js"
9
10
 
10
11
  async function askChangeLog() {
11
12
  const noEmpty = (value) => value != ""
@@ -37,36 +38,6 @@ export class PrePublish {
37
38
  this.baseUrl = baseUrl
38
39
  }
39
40
 
40
- /**
41
- * @param {string} raw
42
- */
43
- isJSON(raw) {
44
- const ml = raw.length
45
- if (ml <= 1) return false
46
- return raw[0] == "{" && raw[ml - 1] == "}"
47
- }
48
-
49
- preCheck(pkgPath) {
50
- const tempDir = fs.mkdtempSync(".lzc-cli-publish")
51
- try {
52
- unzipSync(pkgPath, tempDir)
53
- if (isFileExist(path.join(tempDir, "devshell"))) {
54
- logger.error(
55
- "不能发布一个devshell的版本,请重新使用 `lzc-cli project build` 构建"
56
- )
57
- return false
58
- }
59
- const tempIcon = path.join(tempDir, "icon.png")
60
- if (!isFileExist(tempIcon) || !isPngWithFile(tempIcon)) {
61
- logger.error("icon 必须是 png 格式")
62
- return false
63
- }
64
- return true
65
- } finally {
66
- fs.rmSync(tempDir, { recursive: true })
67
- }
68
- }
69
-
70
41
  async getDict() {
71
42
  const url = this.baseUrl + "/groups/dict"
72
43
  const token = env.get("token")
@@ -77,7 +48,7 @@ export class PrePublish {
77
48
  }
78
49
  })
79
50
  const text = (await res.text()).trim()
80
- if (!this.isJSON(text)) {
51
+ if (!Publish.isJSON(text)) {
81
52
  logger.error(`parse error: dict resp text not is json`)
82
53
  return
83
54
  }
@@ -101,7 +72,7 @@ export class PrePublish {
101
72
  }
102
73
  })
103
74
  const text = (await res.text()).trim()
104
- if (!this.isJSON(text)) {
75
+ if (!Publish.isJSON(text)) {
105
76
  logger.error(`parse error: upload resp text not is json`)
106
77
  return
107
78
  }
@@ -115,7 +86,7 @@ export class PrePublish {
115
86
  * @param {string} changelog
116
87
  */
117
88
  async publish(pkgPath, changelog, gid) {
118
- if (!this.preCheck(pkgPath)) return
89
+ if (!Publish.preCheck(pkgPath)) return
119
90
 
120
91
  await autoLogin()
121
92
 
@@ -26,16 +26,16 @@ export class Publish {
26
26
  /**
27
27
  * @param {string} raw
28
28
  */
29
- isJSON(raw) {
29
+ static isJSON(raw) {
30
30
  const ml = raw.length
31
31
  if (ml <= 1) return false
32
32
  return raw[0] == "{" && raw[ml - 1] == "}"
33
33
  }
34
34
 
35
- preCheck(pkgPath) {
35
+ static preCheck(pkgPath) {
36
36
  const tempDir = fs.mkdtempSync(".lzc-cli-publish")
37
37
  try {
38
- unzipSync(pkgPath, tempDir)
38
+ unzipSync(pkgPath, tempDir, ["devshell", "icon.png"])
39
39
  if (isFileExist(path.join(tempDir, "devshell"))) {
40
40
  logger.error(
41
41
  "不能发布一个devshell的版本,请重新使用 `lzc-cli project build` 构建"
@@ -44,7 +44,7 @@ export class Publish {
44
44
  }
45
45
  const tempIcon = path.join(tempDir, "icon.png")
46
46
  if (!isFileExist(tempIcon) || !isPngWithFile(tempIcon)) {
47
- logger.error("icon 必须是 png 格式")
47
+ logger.error("icon 必须存在且要求是 png 格式")
48
48
  return false
49
49
  }
50
50
  return true
@@ -58,7 +58,7 @@ export class Publish {
58
58
  * @param {string} changelog
59
59
  */
60
60
  async publish(pkgPath, changelog) {
61
- if (!this.preCheck(pkgPath)) return
61
+ if (!Publish.preCheck(pkgPath)) return
62
62
 
63
63
  await autoLogin()
64
64
 
@@ -80,7 +80,7 @@ export class Publish {
80
80
  body: form
81
81
  })
82
82
  const text = (await res.text()).trim()
83
- if (!this.isJSON(text)) {
83
+ if (!Publish.isJSON(text)) {
84
84
  logger.info("upload lpk fail", text)
85
85
  return
86
86
  }
package/lib/utils.js CHANGED
@@ -474,14 +474,24 @@ export async function resolveDomain(domain) {
474
474
  }
475
475
  }
476
476
 
477
- export function unzipSync(zipPath, destPath) {
477
+ export function unzipSync(zipPath, destPath, entries = []) {
478
478
  // 确保目标目录存在
479
479
  fs.mkdirSync(destPath, { recursive: true })
480
480
  // 创建 zip 实例
481
481
  const zip = new AdmZip(zipPath)
482
482
 
483
- // 同步解压所有文件
484
- zip.extractAllTo(destPath, true)
483
+ if (entries.length > 0) {
484
+ entries.forEach((entry) => {
485
+ try {
486
+ zip.extractEntryTo(entry, destPath, false, true)
487
+ } catch {
488
+ logger.debug(`压缩包中没有找到 ${entry} 文件`)
489
+ }
490
+ })
491
+ } else {
492
+ // 同步解压所有文件
493
+ zip.extractAllTo(destPath, true)
494
+ }
485
495
  }
486
496
 
487
497
  export function findSshPublicKey() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.41",
3
+ "version": "1.2.42",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "files": [
6
6
  "template",
@@ -0,0 +1,4 @@
1
+ **/*.lpk
2
+ **/*.tar.gz
3
+ **/*.md5
4
+ /.pushed.timestamp
@@ -0,0 +1,25 @@
1
+ .DS_Store
2
+ node_modules
3
+ dist
4
+ *.lpk
5
+
6
+ # local env files
7
+ .env.local
8
+ .env.*.local
9
+
10
+ # Log files
11
+ npm-debug.log*
12
+ yarn-debug.log*
13
+ yarn-error.log*
14
+ pnpm-debug.log*
15
+
16
+ # Editor directories and files
17
+ .idea
18
+ .vscode
19
+ *.suo
20
+ *.ntvs*
21
+ *.njsproj
22
+ *.sln
23
+ *.sw?
24
+ .temp
25
+ .cache