@lazycatcloud/lzc-cli 1.2.28 → 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.
@@ -23,8 +23,6 @@ export async function triggerApk(id, name, iconPath) {
23
23
  }
24
24
  )
25
25
  if (resp.status == 304) {
26
- // 没有修改
27
- logger.info(`APK构建任务已创建成功,如需使用安卓端,请耐心等待1分钟左右`)
28
26
  } else if (resp.status == 201) {
29
27
  logger.info(`APK构建任务已创建成功,如需使用安卓端,请耐心等待1分钟左右`)
30
28
  } else if (resp.status >= 400) {
package/lib/app/index.js CHANGED
@@ -2,7 +2,7 @@ import path from "node:path"
2
2
  import lpkCreate from "./lpk_create.js"
3
3
  import { LpkBuild } from "./lpk_build.js"
4
4
  import { AppDevShell } from "./lpk_devshell.js"
5
- import { LpkInstaller } from "./lpk_installer.js"
5
+ import { LpkInstaller, installConfig } from "./lpk_installer.js"
6
6
  import logger from "loglevel"
7
7
  import { sleep } from "../utils.js"
8
8
  import { DebugBridge } from "./lpk_debug_bridge.js"
@@ -14,8 +14,6 @@ export function lpkProjectCommand(program) {
14
14
  command: "create <name>",
15
15
  desc: "创建懒猫云应用",
16
16
  handler: async ({ name }) => {
17
- await shellApi.init()
18
-
19
17
  await lpkCreate(name)
20
18
  }
21
19
  },
@@ -68,10 +66,15 @@ export function lpkProjectCommand(program) {
68
66
  describe: "同时打包 lzc-build.yml 中指定的 contentdir 目录",
69
67
  type: "boolean"
70
68
  })
69
+ args.option("apk", {
70
+ describe: "是否生成APK(y/n)",
71
+ type: "string",
72
+ default: "y"
73
+ })
71
74
  },
72
- handler: async ({ context, force, config, contentdir }) => {
75
+ handler: async ({ context, force, config, contentdir, apk }) => {
73
76
  await shellApi.init()
74
-
77
+ installConfig.apk = apk == "y"
75
78
  const cwd = context ? path.resolve(context) : process.cwd()
76
79
  const lpkBuild = await new LpkBuild(cwd, config).init()
77
80
  lpkBuild.onBeforeBuildPackage(async (options) => {
@@ -107,8 +110,16 @@ export function lpkAppCommand(program) {
107
110
  {
108
111
  command: "install [pkgPath]",
109
112
  desc: "部署应用至设备, pkgPath 可以为路径,或者https://,http://请求地址, 如果不填写,将默认为当前目录下的lpk",
110
- handler: async ({ pkgPath }) => {
113
+ builder: (args) => {
114
+ args.option("apk", {
115
+ describe: "是否生成APK(y/n)",
116
+ type: "string",
117
+ default: "y"
118
+ })
119
+ },
120
+ handler: async ({ pkgPath, apk }) => {
111
121
  await shellApi.init()
122
+ installConfig.apk = apk == "y"
112
123
 
113
124
  pkgPath = pkgPath ?? process.cwd()
114
125
  const installer = new LpkInstaller()
@@ -144,6 +144,8 @@ export const TemplateConfig = {
144
144
  ⚙️ 进入应用容器后执行下面命令:
145
145
  npm install
146
146
  npm run dev
147
+ 🚀 启动应用:
148
+ 进入微服客户端启动器页面点击应用图标来测试应用
147
149
  `.trim()
148
150
  )
149
151
  )
@@ -18,7 +18,7 @@ export class DebugBridge {
18
18
  const ssh = spawnSync(sshCmd, args, {
19
19
  shell: true,
20
20
  encoding: "utf-8",
21
- stdio: ["pipe", "pipe", "inherit"]
21
+ stdio: ["pipe", "pipe", "pipe"]
22
22
  })
23
23
  return new Promise((resolve, reject) => {
24
24
  ssh.status == 0
@@ -31,6 +31,7 @@ export class DebugBridge {
31
31
 
32
32
  async install(lpkPath, pkgId) {
33
33
  if (!(await this.canPublicKey())) {
34
+ // 如果不能 ssh public key 登录则直接调用 ssh-copy-id 复制,否则后面可能会出现 rsync 询问密码的问题
34
35
  await this.sshCopyId()
35
36
  }
36
37
 
@@ -53,29 +54,13 @@ export class DebugBridge {
53
54
  }
54
55
 
55
56
  async canPublicKey() {
56
- try {
57
- await this.common(this.sshCmd, [`-o PasswordAuthentication=no`])
58
- return true
59
- } catch {
60
- return false
61
- }
57
+ // FIXME: 目前没有找到在允许空密码的情况下,检测是否只能通过 publickey 登录的方法。
58
+ return false
62
59
  }
63
60
 
64
61
  async sshCopyId() {
65
- const questions = [
66
- {
67
- name: "upload",
68
- type: "input",
69
- default: "y",
70
- message:
71
- "检测到你目前使用的密码帐号登录,是否使用 ssh-copy-id 上传密钥 (y/n): "
72
- }
73
- ]
74
- const answers = await inquirer.prompt(questions)
75
- if (answers.upload.toLowerCase() == "y") {
76
- const resolvedIp = await resolveDomain(this.domain)
77
- return this.common(`ssh-copy-id`, [`-f -p 22222 box@${resolvedIp}`])
78
- }
62
+ const resolvedIp = await resolveDomain(this.domain)
63
+ return this.common(`ssh-copy-id`, [`-f -p 22222 box@${resolvedIp}`])
79
64
  }
80
65
 
81
66
  async status(appId) {
@@ -18,7 +18,8 @@ import {
18
18
  isUserApp,
19
19
  createTemplateFileCommon,
20
20
  isDebugMode,
21
- resolveDomain
21
+ resolveDomain,
22
+ sleep
22
23
  } from "../utils.js"
23
24
  import os from "node:os"
24
25
  import commandExists from "command-exists"
@@ -512,6 +513,7 @@ class DevShell {
512
513
  await this.watchFile(this.appId)
513
514
  await this.connectShell(async () => {
514
515
  // 在连接成功的时候,同步一次文件
516
+ await sleep(300)
515
517
  await this.syncProject(this.appId)
516
518
  })
517
519
  } catch (e) {
@@ -7,6 +7,7 @@ import { DebugBridge } from "./lpk_debug_bridge.js"
7
7
  import shellapi from "../shellapi.js"
8
8
  import { triggerApk } from "./apkshell.js"
9
9
 
10
+ export const installConfig = { apk: true }
10
11
  // 从一个目录中找出修改时间最新的包
11
12
  function findOnceLpkByDir(dir = process.cwd()) {
12
13
  const pkg = fs
@@ -95,11 +96,14 @@ export class LpkInstaller {
95
96
  try {
96
97
  spawnSync("unzip", ["-d", tempDir, pkgPath])
97
98
  manifest = loadFromYaml(path.join(tempDir, "manifest.yml"))
98
- await triggerApk(
99
- manifest["package"],
100
- manifest["name"],
101
- path.resolve(path.join(tempDir, "icon.png"))
102
- )
99
+ logger.debug("是否生成APK:", installConfig.apk)
100
+ if (installConfig.apk) {
101
+ await triggerApk(
102
+ manifest["package"],
103
+ manifest["name"],
104
+ path.resolve(path.join(tempDir, "icon.png"))
105
+ )
106
+ }
103
107
  logger.debug("lpk manifest", manifest)
104
108
  } finally {
105
109
  fs.rmSync(tempDir, { recursive: true })
@@ -113,5 +117,6 @@ export class LpkInstaller {
113
117
  logger.info(
114
118
  `👉 请在浏览器中访问 https://${manifest["application"]["subdomain"]}.${shellapi.boxname}.heiyu.space`
115
119
  )
120
+ logger.info(`👉 并使用微服的用户名和密码登录`)
116
121
  }
117
122
  }
@@ -3,7 +3,6 @@ import path from "path"
3
3
  import logger from "loglevel"
4
4
  import env from "../env.js"
5
5
  import inquirer from "inquirer"
6
- import FormData from "form-data"
7
6
 
8
7
  const accountServerUrl = "https://account.lazycat.cloud"
9
8
 
@@ -12,17 +11,13 @@ function join(...params) {
12
11
  return x
13
12
  }
14
13
 
15
- function login(username, password) {
16
- const form = new FormData()
17
- form.append("username", username)
18
- form.append("password", password)
19
-
14
+ async function login(username, password) {
20
15
  return fetch(join(accountServerUrl, "/api/login/signin"), {
21
16
  method: "POST",
22
- headers: {
23
- "content-type": `multipart/form-data; boundary=${form.getBoundary()}`
24
- },
25
- body: form
17
+ body: new URLSearchParams({
18
+ username: username,
19
+ password: password
20
+ })
26
21
  })
27
22
  .then(async (res) => {
28
23
  let bodyText = await res.text()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/lzc-cli",
3
- "version": "1.2.28",
3
+ "version": "1.2.29",
4
4
  "description": "lazycat cloud developer kit",
5
5
  "files": [
6
6
  "template",