qdmp-cli 0.1.0 → 0.1.1

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 CHANGED
@@ -27,6 +27,11 @@ npm install -g qdmp-cli
27
27
  ```bash
28
28
  qdmp-cli create [options] <app-name>
29
29
  ```
30
+ ### 拉取配置
31
+ ```bash
32
+ qdmp-cli init
33
+ qdmp-cli init -a appId
34
+ ```
30
35
  ### 查看可选模版
31
36
  ```bash
32
37
  qdmp-cli list
package/actions.js CHANGED
@@ -140,3 +140,24 @@ export async function uploadAction(option) {
140
140
  error(`${e.message}`);
141
141
  }
142
142
  }
143
+ export const initConfigAction = async (option) => {
144
+ try {
145
+ const qdmpJsonPath = `${process.cwd()}/qdmp.json`;
146
+ if (fs.existsSync(qdmpJsonPath)) {
147
+ return error("配置文件已存在,请勿重复初始化");
148
+ }
149
+ const appId = option.appId;
150
+ if (!appId) return error("未配置应用ID,请使用-a参数指定应用ID");
151
+ const appInfo = await getAppInfo(appId);
152
+ const config = {
153
+ name: appInfo.name,
154
+ appId: appInfo.appId,
155
+ loader: appInfo.loader,
156
+ latest: appInfo.latest,
157
+ };
158
+ fs.writeFileSync(qdmpJsonPath, JSON.stringify(config, null, 2), "utf8");
159
+ success("qdmp.json 配置文件创建成功");
160
+ } catch (e) {
161
+ error(e.message);
162
+ }
163
+ };
package/index.js CHANGED
@@ -8,6 +8,7 @@ import { fileURLToPath } from "url";
8
8
  import { dirname } from "path";
9
9
  import {
10
10
  initAction,
11
+ initConfigAction,
11
12
  listAction,
12
13
  loginAction,
13
14
  getMyInfoAction,
@@ -40,6 +41,12 @@ program
40
41
  .action(initAction);
41
42
 
42
43
  program.command("list").description("列出可选模版").action(listAction);
44
+ program
45
+ .command("init")
46
+ .description("初始化qdmp.json配置文件")
47
+ .option("-e, --env <env>", "当前环境")
48
+ .option("-a, --appId <appId>", "应用ID")
49
+ .action(initConfigAction);
43
50
  program
44
51
  .command("login")
45
52
  .description("登录")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdmp-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "qdmp-cli",
5
5
  "main": "index.js",
6
6
  "type": "module",