cli-z-develop 0.0.6 → 0.0.9
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/dist/index.js +98 -38
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import child_process from 'child_process';
|
|
|
20
20
|
import lintStaged from 'lint-staged';
|
|
21
21
|
|
|
22
22
|
var name = "cli-z-develop";
|
|
23
|
-
var version = "0.0.
|
|
23
|
+
var version = "0.0.9";
|
|
24
24
|
var description = "前端本地开发命令行工具";
|
|
25
25
|
var main = "dist/index.js";
|
|
26
26
|
var bin = {
|
|
@@ -30,7 +30,7 @@ var bin = {
|
|
|
30
30
|
var scripts = {
|
|
31
31
|
prepare: "husky",
|
|
32
32
|
dev: "rollup -c -w --environment DEBUG:true",
|
|
33
|
-
build: "rollup -c",
|
|
33
|
+
build: "rollup -c --environment DEBUG:true",
|
|
34
34
|
eslint: "eslint '**/*.{ts,js}' --fix",
|
|
35
35
|
prettier: "prettier -wu .",
|
|
36
36
|
upload: "npm version patch && npm run build && npm publish --access public --registry https://registry.npmjs.org/"
|
|
@@ -334,6 +334,9 @@ ${projectDesc}
|
|
|
334
334
|
|
|
335
335
|
const { red, green, blue, magenta } = chalk;
|
|
336
336
|
function log(...args) {
|
|
337
|
+
{
|
|
338
|
+
console.log(blue(...args));
|
|
339
|
+
}
|
|
337
340
|
}
|
|
338
341
|
function success(...args) {
|
|
339
342
|
console.log(green(...args));
|
|
@@ -880,6 +883,16 @@ function getWeWorkUserListApi() {
|
|
|
880
883
|
url: "/user/list",
|
|
881
884
|
});
|
|
882
885
|
}
|
|
886
|
+
/**
|
|
887
|
+
* 发送通知给企微用户
|
|
888
|
+
* @param data
|
|
889
|
+
*/
|
|
890
|
+
function notifyWeWorkUserApi(data) {
|
|
891
|
+
return getPaiRequest({
|
|
892
|
+
url: "/dingding/sendMessage",
|
|
893
|
+
data,
|
|
894
|
+
});
|
|
895
|
+
}
|
|
883
896
|
/**
|
|
884
897
|
* 获取企微审批流程状态
|
|
885
898
|
* @param data
|
|
@@ -1220,8 +1233,10 @@ class SearchCheckbox extends Base {
|
|
|
1220
1233
|
|
|
1221
1234
|
function initConfig$1() {
|
|
1222
1235
|
process.on("unhandledRejection", (e) => {
|
|
1236
|
+
log("unhandledRejection", e);
|
|
1223
1237
|
});
|
|
1224
1238
|
process.on("uncaughtException", (e) => {
|
|
1239
|
+
log("uncaughtException", e);
|
|
1225
1240
|
});
|
|
1226
1241
|
// 配置 shelljs
|
|
1227
1242
|
// exec执行命令出错,将抛出js error
|
|
@@ -1229,7 +1244,7 @@ function initConfig$1() {
|
|
|
1229
1244
|
// 隐藏所有exec命令的输出内容
|
|
1230
1245
|
shelljs.config.silent = true;
|
|
1231
1246
|
// 调试模式下,打印命令
|
|
1232
|
-
shelljs.config.verbose =
|
|
1247
|
+
shelljs.config.verbose = !!true ;
|
|
1233
1248
|
}
|
|
1234
1249
|
function initStore() {
|
|
1235
1250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1241,10 +1256,6 @@ function initStore() {
|
|
|
1241
1256
|
setProfileConfig(config.profile);
|
|
1242
1257
|
setMainConfig(config.main);
|
|
1243
1258
|
setConstantsConfig(config.constants);
|
|
1244
|
-
// 调试模式下,不需要自动更新
|
|
1245
|
-
{
|
|
1246
|
-
yield autoUpdate();
|
|
1247
|
-
}
|
|
1248
1259
|
}
|
|
1249
1260
|
else {
|
|
1250
1261
|
if (!(argv.h || argv.help || argv.v || argv.version)) {
|
|
@@ -1254,34 +1265,6 @@ function initStore() {
|
|
|
1254
1265
|
}
|
|
1255
1266
|
});
|
|
1256
1267
|
}
|
|
1257
|
-
function autoUpdate() {
|
|
1258
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1259
|
-
const latestCheckVersionTimestamp = getMainConfig("latestCheckVersionTimestamp");
|
|
1260
|
-
const versionCheckDuring = getMainConfig("versionCheckDuring");
|
|
1261
|
-
// 指定时间间隔后才检查是否需要更新
|
|
1262
|
-
if (Date.now() - Number(latestCheckVersionTimestamp) > Number(versionCheckDuring) * 24 * 3600 * 1000) {
|
|
1263
|
-
// 数据自动更新
|
|
1264
|
-
const constantsConfig = yield getConstantsConfigApi();
|
|
1265
|
-
setConstantsConfig(constantsConfig);
|
|
1266
|
-
// 版本自动升级
|
|
1267
|
-
const version = yield asyncExec(`npm view ${pkg.name} version`);
|
|
1268
|
-
if (version !== pkg.version) {
|
|
1269
|
-
console.log(`${chalk.blue(pkg.name)}本地版本为${pkg.version},低于线上版本${version},开始升级`);
|
|
1270
|
-
try {
|
|
1271
|
-
yield asyncExec(`npm i -g ${pkg.name}`);
|
|
1272
|
-
setMainConfig("latestCheckVersionTimestamp", Date.now());
|
|
1273
|
-
writeConfigFile();
|
|
1274
|
-
console.log(chalk.green("升级完成!"));
|
|
1275
|
-
process.exit(0);
|
|
1276
|
-
}
|
|
1277
|
-
catch (e) {
|
|
1278
|
-
console.log("升级出错!请重试,或者手动升级");
|
|
1279
|
-
error(e);
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
1268
|
function initRegister() {
|
|
1286
1269
|
// 注册inquirer组件
|
|
1287
1270
|
inquirer.registerPrompt("search-checkbox", SearchCheckbox);
|
|
@@ -1312,6 +1295,8 @@ function initGlobal() {
|
|
|
1312
1295
|
process.exit(0);
|
|
1313
1296
|
}
|
|
1314
1297
|
}
|
|
1298
|
+
// 创建配置文件夹
|
|
1299
|
+
shelljs.mkdir("-p", getConfigDir());
|
|
1315
1300
|
const { jobType, account, password } = yield inquirer.prompt([
|
|
1316
1301
|
{
|
|
1317
1302
|
type: "list",
|
|
@@ -1388,8 +1373,6 @@ function initGlobal() {
|
|
|
1388
1373
|
});
|
|
1389
1374
|
// 设置版本相关信息
|
|
1390
1375
|
setMainConfig("latestCheckVersionTimestamp", Date.now());
|
|
1391
|
-
// 创建配置文件夹
|
|
1392
|
-
shelljs.mkdir("-p", getConfigDir());
|
|
1393
1376
|
// 创建配置文件并写入配置
|
|
1394
1377
|
writeConfigFile();
|
|
1395
1378
|
s1.succeed("配置信息初始化完成");
|
|
@@ -2204,6 +2187,83 @@ function startAction() {
|
|
|
2204
2187
|
|
|
2205
2188
|
program.command("start").alias("s").description("启动本地开发环境").action(startAction);
|
|
2206
2189
|
|
|
2190
|
+
{
|
|
2191
|
+
program
|
|
2192
|
+
.command("test")
|
|
2193
|
+
.alias("t")
|
|
2194
|
+
.description("开发功能调试。")
|
|
2195
|
+
.action(() => {
|
|
2196
|
+
console.log(validateBranchName("feata_abc_20220203_zpc"));
|
|
2197
|
+
console.log(validateBranchName("feat_abc12.D_20220203_zpc"));
|
|
2198
|
+
console.log(validateBranchName("feat_abcDe3_2022203_zpc"));
|
|
2199
|
+
console.log(validateBranchName("feat_abcDe3_20220203_zpc23"));
|
|
2200
|
+
console.log(validateBranchName("feat_abcDe3_20220203_zpc"));
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
function notifyAction(options) {
|
|
2205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2206
|
+
try {
|
|
2207
|
+
// 获取企微用户列表
|
|
2208
|
+
const choices = yield getSortedWeWorkUserList();
|
|
2209
|
+
const questions = [
|
|
2210
|
+
{
|
|
2211
|
+
type: "search-checkbox",
|
|
2212
|
+
name: "weWork",
|
|
2213
|
+
message: "请选择要通知的人员:",
|
|
2214
|
+
choices,
|
|
2215
|
+
validate(input) {
|
|
2216
|
+
if (input.length < 1) {
|
|
2217
|
+
return "至少选一个";
|
|
2218
|
+
}
|
|
2219
|
+
return true;
|
|
2220
|
+
},
|
|
2221
|
+
},
|
|
2222
|
+
];
|
|
2223
|
+
if (!options.dryRun) {
|
|
2224
|
+
questions.push({
|
|
2225
|
+
type: "input",
|
|
2226
|
+
name: "title",
|
|
2227
|
+
message: "请输入通知标题:",
|
|
2228
|
+
}, {
|
|
2229
|
+
type: "input",
|
|
2230
|
+
name: "text",
|
|
2231
|
+
message: "请输入通知内容(支持markdown):",
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
const { weWork, title, text } = yield inquirer.prompt(questions);
|
|
2235
|
+
const notifyStr = [...new Set(weWork)].join(",");
|
|
2236
|
+
recordWeWorkUserUsage(weWork, choices);
|
|
2237
|
+
if (options.dryRun) {
|
|
2238
|
+
console.table(getMainConfig("weWorkListCache"));
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
yield notifyWeWorkUserApi({
|
|
2242
|
+
userid_list: notifyStr,
|
|
2243
|
+
msg: {
|
|
2244
|
+
msgtype: "markdown",
|
|
2245
|
+
markdown: {
|
|
2246
|
+
title,
|
|
2247
|
+
text,
|
|
2248
|
+
},
|
|
2249
|
+
},
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
catch (e) {
|
|
2253
|
+
error(e);
|
|
2254
|
+
}
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
{
|
|
2259
|
+
program
|
|
2260
|
+
.command("notify")
|
|
2261
|
+
.alias("n")
|
|
2262
|
+
.description("发送企微通知")
|
|
2263
|
+
.option("-d, --dry-run", "只记录使用次数,不发送通知")
|
|
2264
|
+
.action(notifyAction);
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2207
2267
|
function lintCommitMsg() {
|
|
2208
2268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2209
2269
|
const msg = fs.readFileSync("./.git/COMMIT_EDITMSG", "utf-8");
|
|
@@ -2249,7 +2309,7 @@ function lintCommitFiles() {
|
|
|
2249
2309
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2250
2310
|
const result = yield lintStaged({
|
|
2251
2311
|
concurrent: false,
|
|
2252
|
-
debug:
|
|
2312
|
+
debug: true,
|
|
2253
2313
|
config: getConfig(),
|
|
2254
2314
|
});
|
|
2255
2315
|
if (result) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cli-z-develop",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "前端本地开发命令行工具",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepare": "husky",
|
|
12
12
|
"dev": "rollup -c -w --environment DEBUG:true",
|
|
13
|
-
"build": "rollup -c",
|
|
13
|
+
"build": "rollup -c --environment DEBUG:true",
|
|
14
14
|
"eslint": "eslint '**/*.{ts,js}' --fix",
|
|
15
15
|
"prettier": "prettier -wu .",
|
|
16
16
|
"upload": "npm version patch && npm run build && npm publish --access public --registry https://registry.npmjs.org/"
|