@lazycatcloud/lzc-cli 1.2.58 → 1.2.59
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/changelog.md +6 -0
- package/lib/app/lpk_installer.js +9 -5
- package/lib/appstore/index.js +15 -6
- package/lib/debug_bridge.js +33 -1
- package/lib/shellapi.js +0 -31
- package/package.json +1 -1
package/changelog.md
CHANGED
package/lib/app/lpk_installer.js
CHANGED
|
@@ -113,6 +113,8 @@ export class LpkInstaller {
|
|
|
113
113
|
})
|
|
114
114
|
}
|
|
115
115
|
logger.debug("lpk manifest", manifest)
|
|
116
|
+
} catch (err) {
|
|
117
|
+
logger.debug("parse manifest ", err)
|
|
116
118
|
} finally {
|
|
117
119
|
fs.rmSync(tempDir, { recursive: true })
|
|
118
120
|
}
|
|
@@ -120,12 +122,14 @@ export class LpkInstaller {
|
|
|
120
122
|
const bridge = new DebugBridge()
|
|
121
123
|
await bridge.init()
|
|
122
124
|
logger.info("开始安装应用")
|
|
123
|
-
await bridge.install(pkgPath, manifest["package"])
|
|
125
|
+
await bridge.install(pkgPath, manifest ? manifest["package"] : "")
|
|
124
126
|
logger.info("\n")
|
|
125
127
|
logger.info(`安装成功!`)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
if (manifest) {
|
|
129
|
+
logger.info(
|
|
130
|
+
`👉 请在浏览器中访问 https://${manifest["application"]["subdomain"]}.${shellapi.boxname}.heiyu.space`
|
|
131
|
+
)
|
|
132
|
+
logger.info(`👉 并使用微服的用户名和密码登录`)
|
|
133
|
+
}
|
|
130
134
|
}
|
|
131
135
|
}
|
package/lib/appstore/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import logger from "loglevel"
|
|
|
3
3
|
import { PrePublish } from "./prePublish.js"
|
|
4
4
|
import { reLogin, request } from "./login.js"
|
|
5
5
|
import fs from "node:fs"
|
|
6
|
+
import { sleep } from "../utils.js"
|
|
6
7
|
|
|
7
8
|
export function appstoreCommand(program) {
|
|
8
9
|
let subCommands = [
|
|
@@ -72,13 +73,21 @@ export function appstoreCommand(program) {
|
|
|
72
73
|
logger.info(
|
|
73
74
|
`Waiting ... ( copy ${imageName} to lazycat offical registry)`
|
|
74
75
|
)
|
|
75
|
-
|
|
76
76
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
for (; ;) {
|
|
78
|
+
const resp = await request(`${baseUrl}/push-image?image=${imageName}&v=2`)
|
|
79
|
+
if (resp.ok) {
|
|
80
|
+
const tag = await resp.text()
|
|
81
|
+
if (tag.length == 0) {
|
|
82
|
+
await sleep(2500)
|
|
83
|
+
continue
|
|
84
|
+
}
|
|
85
|
+
logger.info("lazycat-registry:", tag)
|
|
86
|
+
} else {
|
|
87
|
+
logger.error("error: ", await resp.text())
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
break;
|
|
82
91
|
}
|
|
83
92
|
} catch (err) {
|
|
84
93
|
console.error(err)
|
package/lib/debug_bridge.js
CHANGED
|
@@ -15,6 +15,9 @@ import {
|
|
|
15
15
|
import logger from "loglevel"
|
|
16
16
|
import commandExists from "command-exists"
|
|
17
17
|
import path from "node:path"
|
|
18
|
+
import fetch from "node-fetch"
|
|
19
|
+
|
|
20
|
+
const bannerfileContent = `˄=ᆽ=ᐟ \\`
|
|
18
21
|
|
|
19
22
|
export function sshBinary() {
|
|
20
23
|
if (isWindows) {
|
|
@@ -42,12 +45,40 @@ export class DebugBridge {
|
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
async init() {
|
|
48
|
+
await this.checkDevTools()
|
|
45
49
|
if (!(await this.canPublicKey())) {
|
|
46
50
|
// 如果不能 ssh public key 登录则提示授权申请,否则后面可能会出现 rsync 询问密码的问题
|
|
47
51
|
await this.sshApplyGrant()
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
|
|
55
|
+
async checkDevTools() {
|
|
56
|
+
const url = `https://dev.${this.boxname}.heiyu.space/bannerfile`
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
fetch(url, { redirect: "error" })
|
|
59
|
+
.then(async (res) => {
|
|
60
|
+
const content = await res.text()
|
|
61
|
+
if (res.status == 200 && content == bannerfileContent) {
|
|
62
|
+
resolve()
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
logger.warn(
|
|
66
|
+
`检测到你还没有安装 '懒猫开发者工具',请先到商店中搜索安装
|
|
67
|
+
点击直接跳转 https://appstore.${this.boxname}.heiyu.space/#/shop/detail/cloud.lazycat.developer.tools
|
|
68
|
+
点击打开应用 https://dev.${this.boxname}.heiyu.space 查看应用状态
|
|
69
|
+
`
|
|
70
|
+
)
|
|
71
|
+
reject()
|
|
72
|
+
})
|
|
73
|
+
.catch(() => {
|
|
74
|
+
logger.error(
|
|
75
|
+
`检测懒猫开发者工具失败,请检测您当前的网络或者懒猫微服客户端是否正常启动。`
|
|
76
|
+
)
|
|
77
|
+
reject()
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
51
82
|
async common(cmd, args) {
|
|
52
83
|
const resolvedIp = await resolveDomain(this.domain)
|
|
53
84
|
args = args.map((arg) => arg.replace(this.domain, resolvedIp))
|
|
@@ -73,7 +104,8 @@ export class DebugBridge {
|
|
|
73
104
|
sshBinary(),
|
|
74
105
|
[
|
|
75
106
|
...sshCmdArgs(`box@${resolvedIp}`),
|
|
76
|
-
`install --uid ${this.uid}
|
|
107
|
+
`install --uid ${this.uid}`,
|
|
108
|
+
pkgId ? `--pkgId ${pkgId}` : ""
|
|
77
109
|
],
|
|
78
110
|
{
|
|
79
111
|
shell: true,
|
package/lib/shellapi.js
CHANGED
|
@@ -11,9 +11,6 @@ import path from "node:path"
|
|
|
11
11
|
import fs from "node:fs"
|
|
12
12
|
import os from "node:os"
|
|
13
13
|
import logger from "loglevel"
|
|
14
|
-
import fetch from "node-fetch"
|
|
15
|
-
|
|
16
|
-
const bannerfileContent = `˄=ᆽ=ᐟ \\`
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* @link {https://www.npmjs.com/package/appdirs}
|
|
@@ -77,7 +74,6 @@ NOTE:在指定环境变量的模式下,有些接口依旧不能访问,为
|
|
|
77
74
|
this.metadata = md
|
|
78
75
|
this.info = await this.initBoxInfo()
|
|
79
76
|
}
|
|
80
|
-
await this.checkDevTools()
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
get boxname() {
|
|
@@ -140,33 +136,6 @@ NOTE:在指定环境变量的模式下,有些接口依旧不能访问,为
|
|
|
140
136
|
throw "没有默认盒子信息, 请先使用 lzc-cli box switch 设置默认的盒子信息"
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
async checkDevTools() {
|
|
144
|
-
const url = `https://dev.${this.info.boxname}.heiyu.space/bannerfile`
|
|
145
|
-
return new Promise((resolve, reject) => {
|
|
146
|
-
fetch(url, { redirect: "error" })
|
|
147
|
-
.then(async (res) => {
|
|
148
|
-
const content = await res.text()
|
|
149
|
-
if (res.status == 200 && content == bannerfileContent) {
|
|
150
|
-
resolve()
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
logger.warn(
|
|
154
|
-
`检测到你还没有安装 '懒猫开发者工具',请先到商店中搜索安装
|
|
155
|
-
点击直接跳转 https://appstore.${this.info.boxname}.heiyu.space/#/shop/detail/cloud.lazycat.developer.tools
|
|
156
|
-
点击打开应用 https://dev.${this.info.boxname}.heiyu.space 查看应用状态
|
|
157
|
-
`
|
|
158
|
-
)
|
|
159
|
-
reject()
|
|
160
|
-
})
|
|
161
|
-
.catch(() => {
|
|
162
|
-
logger.error(
|
|
163
|
-
`检测懒猫开发者工具失败,请检测您当前的网络或者懒猫微服客户端是否正常启动。`
|
|
164
|
-
)
|
|
165
|
-
reject()
|
|
166
|
-
})
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
|
|
170
139
|
checkEnvProxy() {
|
|
171
140
|
if (
|
|
172
141
|
process.env.HTTPS_PROXY ||
|