@zwa73/dev-utils 1.0.29 → 1.0.31
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/Command/ExpandMacro.d.ts +3 -0
- package/dist/Command/{BuildMacro.js → ExpandMacro.js} +6 -6
- package/dist/Command/GenSchema.d.ts +3 -0
- package/dist/Command/{BuildSchema.js → GenSchema.js} +5 -5
- package/dist/Command/Route.js +4 -4
- package/dist/UtilDevTool.js +1 -1
- package/package.json +3 -2
- package/scripts/postinstall.js +62 -0
- package/src/Command/{BuildMacro.ts → ExpandMacro.ts} +4 -4
- package/src/Command/{BuildSchema.ts → GenSchema.ts} +3 -3
- package/src/Command/Route.ts +4 -4
- package/src/UtilDevTool.ts +1 -1
- package/dist/Command/BuildMacro.d.ts +0 -3
- package/dist/Command/BuildSchema.d.ts +0 -3
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.CmdExpandMacro = void 0;
|
4
4
|
const UtilDevTool_1 = require("../UtilDevTool");
|
5
5
|
/**构造macro */
|
6
|
-
const
|
7
|
-
.command("
|
8
|
-
.alias("
|
9
|
-
.description("
|
6
|
+
const CmdExpandMacro = (program) => program
|
7
|
+
.command("Expand-Macro")
|
8
|
+
.alias("expandmacro")
|
9
|
+
.description("根据macro生成代码")
|
10
10
|
.option("-i, --include <glob>", "包含的glob 默认 src/**/*.macro.ts", "src/**/*.macro.ts")
|
11
11
|
.option("-g, --exclude <glob>", "忽略的glob")
|
12
12
|
.option("-p, --project <path>", "tsconfig路径 默认tsconfig.json", "tsconfig.json")
|
@@ -17,4 +17,4 @@ const CmdBuildMacro = (program) => program
|
|
17
17
|
project: opt.project,
|
18
18
|
});
|
19
19
|
});
|
20
|
-
exports.
|
20
|
+
exports.CmdExpandMacro = CmdExpandMacro;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.CmdGenSchema = void 0;
|
4
4
|
const UtilDevTool_1 = require("../UtilDevTool");
|
5
5
|
/**生成schema */
|
6
|
-
const
|
7
|
-
.command("
|
8
|
-
.alias("
|
6
|
+
const CmdGenSchema = (program) => program
|
7
|
+
.command("Gen-Schema")
|
8
|
+
.alias("genschema")
|
9
9
|
.description("生成匹配的文件的所有type的schema")
|
10
10
|
.option("-i, --include <glob>", "包含的glob 默认 src/**/*.schema.ts", "src/**/*.schema.ts")
|
11
11
|
.option("-g, --exclude <glob>", "忽略的glob")
|
@@ -19,4 +19,4 @@ const CmdBuildSchema = (program) => program
|
|
19
19
|
outDir: opt.outDir,
|
20
20
|
});
|
21
21
|
});
|
22
|
-
exports.
|
22
|
+
exports.CmdGenSchema = CmdGenSchema;
|
package/dist/Command/Route.js
CHANGED
@@ -7,16 +7,16 @@ const Node_1 = require("./Node");
|
|
7
7
|
const Release_1 = require("./Release");
|
8
8
|
const MapPath_1 = require("./MapPath");
|
9
9
|
const ScanDups_1 = require("./ScanDups");
|
10
|
-
const
|
11
|
-
const
|
10
|
+
const GenSchema_1 = require("./GenSchema");
|
11
|
+
const ExpandMacro_1 = require("./ExpandMacro");
|
12
12
|
async function cliRoute() {
|
13
13
|
(0, Init_1.CmdInit)(commander_1.program);
|
14
14
|
(0, Node_1.CmdNode)(commander_1.program);
|
15
15
|
(0, Release_1.CmdRelease)(commander_1.program);
|
16
16
|
(0, MapPath_1.CmdMapPath)(commander_1.program);
|
17
17
|
(0, ScanDups_1.CmdScanDups)(commander_1.program);
|
18
|
-
(0,
|
19
|
-
(0,
|
18
|
+
(0, GenSchema_1.CmdGenSchema)(commander_1.program);
|
19
|
+
(0, ExpandMacro_1.CmdExpandMacro)(commander_1.program);
|
20
20
|
commander_1.program.parse(process.argv);
|
21
21
|
}
|
22
22
|
exports.cliRoute = cliRoute;
|
package/dist/UtilDevTool.js
CHANGED
@@ -138,7 +138,7 @@ var UtilDT;
|
|
138
138
|
* @param targetPath - 目标文件 默认为去除".macro"的同名文件
|
139
139
|
*/
|
140
140
|
async function $macro(regionId, codeText, targetPath) {
|
141
|
-
const loc =
|
141
|
+
const loc = utils_1.UtilFunc.getFuncLoc(2);
|
142
142
|
if (!loc) {
|
143
143
|
utils_1.SLogger.error(`UtilDT.$macro 未能找到函数位置`);
|
144
144
|
return;
|
package/package.json
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zwa73/dev-utils",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.31",
|
4
4
|
"description": "编译与调试工具",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
7
|
"test": "jest",
|
8
8
|
"release": "powershell scripts/release",
|
9
9
|
"compile": "powershell scripts/compile",
|
10
|
-
"watch": "powershell scripts/watch"
|
10
|
+
"watch": "powershell scripts/watch",
|
11
|
+
"postinstall": "start node scripts/postinstall.js"
|
11
12
|
},
|
12
13
|
"keywords": [
|
13
14
|
"schema"
|
@@ -0,0 +1,62 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
const { UtilFT, SLogger } = require("../index");
|
3
|
+
const readline = require('readline');
|
4
|
+
|
5
|
+
const PACKAGE_PATH = path.join(__dirname,'..','package.json');
|
6
|
+
const VERSION_PATH = path.join(__dirname,"..","..","version.json");
|
7
|
+
//提示表
|
8
|
+
const INFO_TABLE = {
|
9
|
+
"1.0.31":"zcli Build-Macro Build-Schema 更名为 Expand-Macro Gen-Schema"
|
10
|
+
}
|
11
|
+
|
12
|
+
// 将版本号转换为可以比较的数字
|
13
|
+
function versionToNumber(version) {
|
14
|
+
if(version==undefined) return 0;
|
15
|
+
return version.split('.').map(Number).reduce((acc, val) => acc * 1000 + val);
|
16
|
+
}
|
17
|
+
|
18
|
+
//显示提示
|
19
|
+
function showUpgradeMessages(prevVersion, currentVersion) {
|
20
|
+
const prevVersionNumber = versionToNumber(prevVersion);
|
21
|
+
const currentVersionNumber = versionToNumber(currentVersion);
|
22
|
+
let hasOut = false;
|
23
|
+
// 遍历infoTable中的所有版本
|
24
|
+
for (const version in INFO_TABLE) {
|
25
|
+
const versionNumber = versionToNumber(version);
|
26
|
+
// 如果用户的上一个版本低于这个版本,而当前版本高于或等于这个版本
|
27
|
+
if (versionNumber > prevVersionNumber && versionNumber <= currentVersionNumber) {
|
28
|
+
// 显示这个版本的提示信息
|
29
|
+
console.log(INFO_TABLE[version]);
|
30
|
+
hasOut=true;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return hasOut;
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
async function main(){
|
39
|
+
const packageTable = await UtilFT.loadJSONFile(PACKAGE_PATH);
|
40
|
+
const currentVersion = packageTable.version;
|
41
|
+
await UtilFT.ensurePathExists(VERSION_PATH);
|
42
|
+
const versionTable = Object.assign({},
|
43
|
+
await UtilFT.loadJSONFile(VERSION_PATH,{}),
|
44
|
+
{"dev-utils":{version:currentVersion}});
|
45
|
+
const prevVersion = versionTable.utils.version;
|
46
|
+
|
47
|
+
console.log(`${currentVersion} 版本已安装`);
|
48
|
+
// 使用这个函数来显示升级信息
|
49
|
+
const hasOut = showUpgradeMessages(prevVersion, currentVersion);
|
50
|
+
|
51
|
+
versionTable.utils.version = currentVersion;
|
52
|
+
await UtilFT.writeJSONFile(VERSION_PATH, versionTable);
|
53
|
+
|
54
|
+
if(!hasOut) return;
|
55
|
+
const rl = readline.createInterface({
|
56
|
+
input: process.stdin,
|
57
|
+
output: process.stdout
|
58
|
+
});
|
59
|
+
setTimeout(()=>rl.close(),20000);
|
60
|
+
rl.question('按任意键继续...', () => rl.close());
|
61
|
+
}
|
62
|
+
main()
|
@@ -2,10 +2,10 @@ import { Command } from "commander";
|
|
2
2
|
import { UtilDT } from "@src/UtilDevTool";
|
3
3
|
|
4
4
|
/**构造macro */
|
5
|
-
export const
|
6
|
-
.command("
|
7
|
-
.alias("
|
8
|
-
.description("
|
5
|
+
export const CmdExpandMacro = (program:Command) => program
|
6
|
+
.command("Expand-Macro")
|
7
|
+
.alias("expandmacro")
|
8
|
+
.description("根据macro生成代码")
|
9
9
|
.option("-i, --include <glob>", "包含的glob 默认 src/**/*.macro.ts","src/**/*.macro.ts")
|
10
10
|
.option("-g, --exclude <glob>", "忽略的glob")
|
11
11
|
.option("-p, --project <path>", "tsconfig路径 默认tsconfig.json","tsconfig.json")
|
@@ -2,9 +2,9 @@ import { Command } from "commander";
|
|
2
2
|
import { UtilDT } from "@src/UtilDevTool";
|
3
3
|
|
4
4
|
/**生成schema */
|
5
|
-
export const
|
6
|
-
.command("
|
7
|
-
.alias("
|
5
|
+
export const CmdGenSchema = (program:Command) => program
|
6
|
+
.command("Gen-Schema")
|
7
|
+
.alias("genschema")
|
8
8
|
.description("生成匹配的文件的所有type的schema")
|
9
9
|
.option("-i, --include <glob>", "包含的glob 默认 src/**/*.schema.ts","src/**/*.schema.ts")
|
10
10
|
.option("-g, --exclude <glob>", "忽略的glob")
|
package/src/Command/Route.ts
CHANGED
@@ -5,8 +5,8 @@ import { CmdNode } from './Node';
|
|
5
5
|
import { CmdRelease } from './Release';
|
6
6
|
import { CmdMapPath } from './MapPath';
|
7
7
|
import { CmdScanDups } from './ScanDups';
|
8
|
-
import {
|
9
|
-
import {
|
8
|
+
import { CmdGenSchema } from './GenSchema';
|
9
|
+
import { CmdExpandMacro } from './ExpandMacro';
|
10
10
|
|
11
11
|
export async function cliRoute(){
|
12
12
|
CmdInit(program);
|
@@ -14,7 +14,7 @@ export async function cliRoute(){
|
|
14
14
|
CmdRelease(program);
|
15
15
|
CmdMapPath(program);
|
16
16
|
CmdScanDups(program);
|
17
|
-
|
18
|
-
|
17
|
+
CmdGenSchema(program);
|
18
|
+
CmdExpandMacro(program);
|
19
19
|
program.parse(process.argv);
|
20
20
|
}
|
package/src/UtilDevTool.ts
CHANGED
@@ -138,7 +138,7 @@ export async function batchNode(filepath:string|string[],opt?:BatchNodeOpt) {
|
|
138
138
|
* @param targetPath - 目标文件 默认为去除".macro"的同名文件
|
139
139
|
*/
|
140
140
|
export async function $macro(regionId:string,codeText:string,targetPath?:string){
|
141
|
-
const loc = getFuncLoc(2);
|
141
|
+
const loc = UtilFunc.getFuncLoc(2);
|
142
142
|
if(!loc){
|
143
143
|
SLogger.error(`UtilDT.$macro 未能找到函数位置`);
|
144
144
|
return
|