@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.
- package/lib/app/apkshell.js +35 -0
- package/lib/app/index.js +89 -78
- package/lib/app/lpk_build.js +113 -117
- package/lib/app/lpk_create.js +78 -148
- package/lib/app/lpk_create_generator.js +103 -74
- package/lib/app/lpk_debug_bridge.js +61 -73
- package/lib/app/lpk_devshell.js +230 -229
- package/lib/app/lpk_devshell_docker.js +28 -28
- package/lib/app/lpk_installer.js +64 -49
- package/lib/appstore/index.js +29 -29
- package/lib/appstore/login.js +63 -68
- package/lib/appstore/prePublish.js +68 -68
- package/lib/appstore/publish.js +55 -55
- package/lib/box/index.js +25 -25
- package/lib/env.js +18 -18
- package/lib/shellapi.js +55 -58
- package/lib/utils.js +217 -164
- package/package.json +7 -1
- package/scripts/cli.js +56 -56
- package/template/_lpk/manifest.yml.in +8 -8
- package/template/vue/README.md +29 -0
- package/template/vue/index.html +13 -0
- package/template/vue/lzc-build.yml +59 -0
- package/template/vue/lzc-icon.png +0 -0
- package/template/vue/package.json +20 -0
- package/template/vue/public/vite.svg +1 -0
- package/template/vue/src/App.vue +30 -0
- package/template/vue/src/assets/vue.svg +1 -0
- package/template/vue/src/components/HelloWorld.vue +41 -0
- package/template/vue/src/main.ts +5 -0
- package/template/vue/src/style.css +79 -0
- package/template/vue/src/vite-env.d.ts +1 -0
- package/template/vue/tsconfig.app.json +24 -0
- package/template/vue/tsconfig.json +7 -0
- package/template/vue/tsconfig.node.json +22 -0
- package/template/vue/vite.config.ts +7 -0
- package/template/ionic_vue3/package-lock.json +0 -8100
package/lib/shellapi.js
CHANGED
|
@@ -1,65 +1,62 @@
|
|
|
1
|
-
import grpc from "@grpc/grpc-js"
|
|
2
|
-
import protoLoader from "@grpc/proto-loader"
|
|
3
|
-
import { contextDirname } from "./utils.js"
|
|
4
|
-
import path from "node:path"
|
|
5
|
-
import fs from "node:fs"
|
|
6
|
-
import os from "node:os"
|
|
7
|
-
import logger from "loglevel"
|
|
8
|
-
import fetch from "node-fetch"
|
|
1
|
+
import grpc from "@grpc/grpc-js"
|
|
2
|
+
import protoLoader from "@grpc/proto-loader"
|
|
3
|
+
import { contextDirname } from "./utils.js"
|
|
4
|
+
import path from "node:path"
|
|
5
|
+
import fs from "node:fs"
|
|
6
|
+
import os from "node:os"
|
|
7
|
+
import logger from "loglevel"
|
|
8
|
+
import fetch from "node-fetch"
|
|
9
9
|
|
|
10
|
-
const bannerfileContent = `˄=ᆽ=ᐟ
|
|
10
|
+
const bannerfileContent = `˄=ᆽ=ᐟ \\`
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @link {https://www.npmjs.com/package/appdirs}
|
|
14
14
|
*/
|
|
15
15
|
function getShellAPIConfigDir() {
|
|
16
|
-
const home = os.homedir()
|
|
17
|
-
let suffix = "/.config/hportal-client"
|
|
16
|
+
const home = os.homedir()
|
|
17
|
+
let suffix = "/.config/hportal-client"
|
|
18
18
|
if (process.platform === "darwin") {
|
|
19
|
-
suffix = "/Library/Application Support/hportal-client"
|
|
19
|
+
suffix = "/Library/Application Support/hportal-client"
|
|
20
20
|
} else if (process.platform === "win32") {
|
|
21
|
-
suffix = "\\AppData\\Roaming\\hportal-client"
|
|
21
|
+
suffix = "\\AppData\\Roaming\\hportal-client"
|
|
22
22
|
}
|
|
23
|
-
const SHELLAPI_CONFIG_DIR = path.join(home, suffix)
|
|
24
|
-
return SHELLAPI_CONFIG_DIR
|
|
23
|
+
const SHELLAPI_CONFIG_DIR = path.join(home, suffix)
|
|
24
|
+
return SHELLAPI_CONFIG_DIR
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
class ShellApi {
|
|
28
28
|
constructor() {}
|
|
29
29
|
|
|
30
30
|
async init() {
|
|
31
|
-
const pbShell = this.initShell()
|
|
32
|
-
const { addr, cred } = this.readShellApiInfo()
|
|
33
|
-
this.client = new pbShell.ShellCore(
|
|
34
|
-
addr,
|
|
35
|
-
grpc.credentials.createInsecure()
|
|
36
|
-
);
|
|
31
|
+
const pbShell = this.initShell()
|
|
32
|
+
const { addr, cred } = this.readShellApiInfo()
|
|
33
|
+
this.client = new pbShell.ShellCore(addr, grpc.credentials.createInsecure())
|
|
37
34
|
|
|
38
|
-
const md = new grpc.Metadata()
|
|
39
|
-
md.add("lzc-shellapi-cred", cred)
|
|
40
|
-
this.metadata = md
|
|
41
|
-
this.info = await this.initBoxInfo()
|
|
42
|
-
this.checkDevTools()
|
|
35
|
+
const md = new grpc.Metadata()
|
|
36
|
+
md.add("lzc-shellapi-cred", cred)
|
|
37
|
+
this.metadata = md
|
|
38
|
+
this.info = await this.initBoxInfo()
|
|
39
|
+
this.checkDevTools()
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
get boxname() {
|
|
46
|
-
return this.info.boxname
|
|
43
|
+
return this.info.boxname
|
|
47
44
|
}
|
|
48
45
|
get uid() {
|
|
49
|
-
return this.info.uid
|
|
46
|
+
return this.info.uid
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
readShellApiInfo() {
|
|
53
|
-
const SHELLAPI_CONFIG_DIR = getShellAPIConfigDir()
|
|
50
|
+
const SHELLAPI_CONFIG_DIR = getShellAPIConfigDir()
|
|
54
51
|
const addr = fs.readFileSync(
|
|
55
52
|
path.resolve(SHELLAPI_CONFIG_DIR, "shellapi_addr"),
|
|
56
53
|
{ encoding: "utf-8" }
|
|
57
|
-
)
|
|
54
|
+
)
|
|
58
55
|
const cred = fs.readFileSync(
|
|
59
56
|
path.resolve(SHELLAPI_CONFIG_DIR, "shellapi_cred"),
|
|
60
57
|
{ encoding: "utf-8" }
|
|
61
|
-
)
|
|
62
|
-
return { addr, cred }
|
|
58
|
+
)
|
|
59
|
+
return { addr, cred }
|
|
63
60
|
}
|
|
64
61
|
|
|
65
62
|
initShell() {
|
|
@@ -70,70 +67,70 @@ class ShellApi {
|
|
|
70
67
|
longs: String,
|
|
71
68
|
enums: String,
|
|
72
69
|
defaults: true,
|
|
73
|
-
oneofs: true
|
|
70
|
+
oneofs: true
|
|
74
71
|
}
|
|
75
|
-
)
|
|
76
|
-
return grpc.loadPackageDefinition(coreDefinition).space.heiyu.hportal.shell
|
|
72
|
+
)
|
|
73
|
+
return grpc.loadPackageDefinition(coreDefinition).space.heiyu.hportal.shell
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
async boxList() {
|
|
80
77
|
return new Promise((resolve, reject) => {
|
|
81
78
|
this.client.queryBoxList({}, this.metadata, function (err, response) {
|
|
82
79
|
if (err) {
|
|
83
|
-
reject(err)
|
|
84
|
-
return
|
|
80
|
+
reject(err)
|
|
81
|
+
return
|
|
85
82
|
}
|
|
86
|
-
resolve(response.boxes)
|
|
87
|
-
})
|
|
88
|
-
})
|
|
83
|
+
resolve(response.boxes)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
89
86
|
}
|
|
90
87
|
|
|
91
88
|
async initBoxInfo() {
|
|
92
89
|
try {
|
|
93
|
-
const boxes = await this.boxList()
|
|
94
|
-
const box = boxes.find((b) => b.is_default_box)
|
|
90
|
+
const boxes = await this.boxList()
|
|
91
|
+
const box = boxes.find((b) => b.is_default_box)
|
|
95
92
|
if (box) {
|
|
96
|
-
return { uid: box.login_user, boxname: box.box_name }
|
|
93
|
+
return { uid: box.login_user, boxname: box.box_name }
|
|
97
94
|
}
|
|
98
95
|
} catch (e) {
|
|
99
|
-
logger.debug("Error: ", e)
|
|
100
|
-
throw "获取盒子信息失败,请检查客户端是否已经连接!"
|
|
96
|
+
logger.debug("Error: ", e)
|
|
97
|
+
throw "获取盒子信息失败,请检查客户端是否已经连接!"
|
|
101
98
|
}
|
|
102
|
-
throw "没有默认盒子信息, 请先使用 lzc-cli box switch 设置默认的盒子信息"
|
|
99
|
+
throw "没有默认盒子信息, 请先使用 lzc-cli box switch 设置默认的盒子信息"
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
async checkDevTools() {
|
|
106
|
-
const url = `https://dev.${this.info.boxname}.heiyu.space/bannerfile
|
|
103
|
+
const url = `https://dev.${this.info.boxname}.heiyu.space/bannerfile`
|
|
107
104
|
fetch(url, { redirect: "error" })
|
|
108
105
|
.then(async (res) => {
|
|
109
|
-
const content = await res.text()
|
|
106
|
+
const content = await res.text()
|
|
110
107
|
if (res.status != 200 || content != bannerfileContent) {
|
|
111
108
|
logger.warn(
|
|
112
109
|
`检测到你还没有安装懒猫微服开发者工具,请先到商店中搜索安装`
|
|
113
|
-
)
|
|
110
|
+
)
|
|
114
111
|
}
|
|
115
112
|
})
|
|
116
113
|
.catch(() => {
|
|
117
|
-
logger.debug(`你的懒猫微服开发者工具版本较低,请从商店中更新`)
|
|
118
|
-
})
|
|
114
|
+
logger.debug(`你的懒猫微服开发者工具版本较低,请从商店中更新`)
|
|
115
|
+
})
|
|
119
116
|
}
|
|
120
117
|
|
|
121
118
|
async setDefaultBox(boxname) {
|
|
122
|
-
const boxes = await this.boxList()
|
|
123
|
-
const box = boxes.find((b) => b.box_name === boxname)
|
|
119
|
+
const boxes = await this.boxList()
|
|
120
|
+
const box = boxes.find((b) => b.box_name === boxname)
|
|
124
121
|
if (!box) {
|
|
125
|
-
throw `${boxname}
|
|
122
|
+
throw `${boxname} 盒子不存在`
|
|
126
123
|
}
|
|
127
124
|
return new Promise((resolve, reject) => {
|
|
128
125
|
this.client.modifyBoxConfig(
|
|
129
126
|
{ id: box.id, name: box.box_name, set_as_default_box: true },
|
|
130
127
|
this.metadata,
|
|
131
128
|
function (err) {
|
|
132
|
-
err ? reject(err) : resolve()
|
|
129
|
+
err ? reject(err) : resolve()
|
|
133
130
|
}
|
|
134
|
-
)
|
|
135
|
-
})
|
|
131
|
+
)
|
|
132
|
+
})
|
|
136
133
|
}
|
|
137
134
|
}
|
|
138
135
|
|
|
139
|
-
export default new ShellApi()
|
|
136
|
+
export default new ShellApi()
|