qdmp-cli 0.1.1 → 0.1.2
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/README.md +4 -1
- package/actions.js +26 -0
- package/index.js +6 -0
- package/package.json +1 -1
- package/utils/common.js +12 -0
- package/utils/gitClone.js +1 -13
package/README.md
CHANGED
|
@@ -29,7 +29,6 @@ qdmp-cli create [options] <app-name>
|
|
|
29
29
|
```
|
|
30
30
|
### 拉取配置
|
|
31
31
|
```bash
|
|
32
|
-
qdmp-cli init
|
|
33
32
|
qdmp-cli init -a appId
|
|
34
33
|
```
|
|
35
34
|
### 查看可选模版
|
|
@@ -46,6 +45,10 @@ qdmp-cli login -e dev //登录开发环境
|
|
|
46
45
|
qdmp-cli getMe
|
|
47
46
|
qdmp-cli getMe -e dev //查看开发环境用户
|
|
48
47
|
```
|
|
48
|
+
### 打包
|
|
49
|
+
```bash
|
|
50
|
+
qdmp-cli upload -t emp //目前仅支持taro类型的emp
|
|
51
|
+
```
|
|
49
52
|
### 上传版本
|
|
50
53
|
```bash
|
|
51
54
|
qdmp-cli upload
|
package/actions.js
CHANGED
|
@@ -161,3 +161,29 @@ export const initConfigAction = async (option) => {
|
|
|
161
161
|
error(e.message);
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
|
+
export const buildAction = async (option) => {
|
|
165
|
+
try {
|
|
166
|
+
switch (option.type) {
|
|
167
|
+
case "emp":
|
|
168
|
+
info("开始构建...");
|
|
169
|
+
const buildResult = shell.exec("taro build --type weapp");
|
|
170
|
+
if (buildResult.code !== 0) {
|
|
171
|
+
throw new Error("构建失败");
|
|
172
|
+
}
|
|
173
|
+
shell.cd("dist");
|
|
174
|
+
const dmccResult = shell.exec("dmcc build --no-app-id-dir");
|
|
175
|
+
if (dmccResult.code !== 0) {
|
|
176
|
+
throw new Error("dmcc 构建失败");
|
|
177
|
+
}
|
|
178
|
+
shell.cd("..");
|
|
179
|
+
success("构建完成");
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
default:
|
|
183
|
+
error("不支持的构建类型");
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
} catch (e) {
|
|
187
|
+
error(e?.message || "构建过程出错");
|
|
188
|
+
}
|
|
189
|
+
};
|
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
loginAction,
|
|
14
14
|
getMyInfoAction,
|
|
15
15
|
uploadAction,
|
|
16
|
+
buildAction,
|
|
16
17
|
} from "./actions.js";
|
|
17
18
|
import { printLogo } from "./utils/logHandler.js";
|
|
18
19
|
// import.meta.url: esm模块化中的属性,获取模块文件的绝对地址
|
|
@@ -57,6 +58,11 @@ program
|
|
|
57
58
|
.description("查看登录用户")
|
|
58
59
|
.option("-e, --env <env>", "当前环境")
|
|
59
60
|
.action(getMyInfoAction);
|
|
61
|
+
program
|
|
62
|
+
.command("build")
|
|
63
|
+
.description("部署项目")
|
|
64
|
+
.option("-t, --type <type>", "部署类型")
|
|
65
|
+
.action(buildAction);
|
|
60
66
|
program
|
|
61
67
|
.command("upload")
|
|
62
68
|
.description("上传项目")
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -3,6 +3,7 @@ import AdmZip from "adm-zip";
|
|
|
3
3
|
import { WORKSPACE_DIR } from "../constants.js";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
|
+
import child_process from "child_process";
|
|
6
7
|
|
|
7
8
|
/** 获取上传链接
|
|
8
9
|
* @param {*} appId 文件
|
|
@@ -229,3 +230,14 @@ export async function cleanWorkSpaceFolder(dirname) {
|
|
|
229
230
|
return false;
|
|
230
231
|
}
|
|
231
232
|
}
|
|
233
|
+
export async function execSync(cmd) {
|
|
234
|
+
return new Promise((resolve, reject) => {
|
|
235
|
+
child_process.exec(cmd, function (err, stdout, stderr) {
|
|
236
|
+
if (err) {
|
|
237
|
+
reject(new Error(stderr || err.message));
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
resolve(stdout);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
package/utils/gitClone.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import child_process from "child_process";
|
|
2
1
|
import ora from "ora";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import chalk from "chalk";
|
|
@@ -6,6 +5,7 @@ import { rm } from "fs/promises";
|
|
|
6
5
|
import { existsSync } from "fs";
|
|
7
6
|
import { inquirerConfirm } from "./interactive.js";
|
|
8
7
|
import { error } from "./logHandler.js";
|
|
8
|
+
import { execSync } from "./common.js";
|
|
9
9
|
/**
|
|
10
10
|
* 下载项目
|
|
11
11
|
* @param {string} projectName - 项目名称
|
|
@@ -35,18 +35,6 @@ export const download = async (projectName, repo) => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const execSync = async (cmd) => {
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
child_process.exec(cmd, function (err, stdout, stderr) {
|
|
41
|
-
if (err) {
|
|
42
|
-
reject(new Error(stderr || err.message));
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
resolve(stdout);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
38
|
const clone = async (repo, name) => {
|
|
51
39
|
const spinner = ora("正在拉取项目......").start();
|
|
52
40
|
try {
|