@zwa73/dev-utils 1.0.50 → 1.0.52
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/MapPath.js +1 -1
- package/dist/Command/ScanDups.js +2 -2
- package/dist/UtilDevTool.js +5 -5
- package/dist/UtilMacro.js +2 -2
- package/package.json +2 -2
- package/src/Command/MapPath.ts +1 -1
- package/src/Command/ScanDups.ts +2 -2
- package/src/UtilDevTool.ts +5 -5
- package/src/UtilMacro.ts +2 -2
package/dist/Command/MapPath.js
CHANGED
@@ -29,7 +29,7 @@ const CmdMapPath = (program) => program
|
|
29
29
|
const duplicateHandling = options.duplicateHandling;
|
30
30
|
const basePath = process.cwd();
|
31
31
|
// 遍历当前目录下的所有文件
|
32
|
-
const filePaths = utils_1.UtilFT.fileSearchRegex(basePath, regex.source, { relative: options.recursive })
|
32
|
+
const filePaths = (await utils_1.UtilFT.fileSearchRegex(basePath, regex.source, { relative: options.recursive }))
|
33
33
|
.map((filePath) => pathe_1.default.relative(basePath, filePath))
|
34
34
|
.filter((filePath) => excludeRegex ? (!excludeRegex.test(filePath)) : true);
|
35
35
|
//对单个路径映射
|
package/dist/Command/ScanDups.js
CHANGED
@@ -28,9 +28,9 @@ const CmdScanDups = (program) => program
|
|
28
28
|
.action(async (options) => {
|
29
29
|
const regex = new RegExp(options.regex);
|
30
30
|
const basePath = process.cwd();
|
31
|
-
const pList = utils_1.UtilFT.fileSearchRegex(basePath, regex.source, {
|
31
|
+
const pList = (await utils_1.UtilFT.fileSearchRegex(basePath, regex.source, {
|
32
32
|
relative: options.recursive,
|
33
|
-
}).map(async (filePath) => ({ filePath, hash: await calculateHash(filePath) }));
|
33
|
+
})).map(async (filePath) => ({ filePath, hash: await calculateHash(filePath) }));
|
34
34
|
const hashMap = (await Promise.all(pList)).reduce((obj, cur) => {
|
35
35
|
obj[cur.hash] = (obj[cur.hash] ?? []).concat(cur.filePath);
|
36
36
|
return obj;
|
package/dist/UtilDevTool.js
CHANGED
@@ -55,7 +55,7 @@ var UtilDT;
|
|
55
55
|
};
|
56
56
|
if (opt?.project)
|
57
57
|
Object.assign(compilerOptions, (await utils_1.UtilFT.loadJSONFile(opt.project)).compilerOptions);
|
58
|
-
const files = utils_1.UtilFT.fileSearchGlob(dir, opt?.include ?? "**/*.schema.ts", { ingore: opt?.exclude });
|
58
|
+
const files = await utils_1.UtilFT.fileSearchGlob(dir, opt?.include ?? "**/*.schema.ts", { ingore: opt?.exclude });
|
59
59
|
const program = TJS.getProgramFromFiles(files, compilerOptions);
|
60
60
|
const schema = TJS.generateSchema(program, "*", settings);
|
61
61
|
const outDir = opt?.outDir ?? pathe_1.default.join(process.cwd(), 'schema');
|
@@ -112,7 +112,7 @@ var UtilDT;
|
|
112
112
|
* @param opt.project - tsconfig路径
|
113
113
|
*/
|
114
114
|
async function matchNode(dir, opt) {
|
115
|
-
const files = utils_1.UtilFT.fileSearchGlob(dir, opt?.include ?? "index.ts", { ingore: opt?.exclude });
|
115
|
+
const files = await utils_1.UtilFT.fileSearchGlob(dir, opt?.include ?? "index.ts", { ingore: opt?.exclude });
|
116
116
|
await batchNode(files, opt);
|
117
117
|
}
|
118
118
|
UtilDT.matchNode = matchNode;
|
@@ -165,7 +165,7 @@ var UtilDT;
|
|
165
165
|
*/
|
166
166
|
async function regionMacro(regionId, codeText, opt) {
|
167
167
|
const plist = [];
|
168
|
-
const filePaths = parseMacroPaths(opt);
|
168
|
+
const filePaths = await parseMacroPaths(opt);
|
169
169
|
for (const filePath of filePaths) {
|
170
170
|
const queuefunc = async () => {
|
171
171
|
if (!(await utils_1.UtilFT.pathExists(filePath))) {
|
@@ -222,7 +222,7 @@ var UtilDT;
|
|
222
222
|
*/
|
223
223
|
async function commentMacro(commentId, codeText, opt) {
|
224
224
|
const plist = [];
|
225
|
-
const filePaths = parseMacroPaths(opt);
|
225
|
+
const filePaths = await parseMacroPaths(opt);
|
226
226
|
for (const filePath of filePaths) {
|
227
227
|
const queuefunc = async () => {
|
228
228
|
if (!(await utils_1.UtilFT.pathExists(filePath))) {
|
@@ -279,7 +279,7 @@ var UtilDT;
|
|
279
279
|
*/
|
280
280
|
async function fileMacro(codeText, opt) {
|
281
281
|
const plist = [];
|
282
|
-
const filePaths = parseMacroPaths(opt);
|
282
|
+
const filePaths = await parseMacroPaths(opt);
|
283
283
|
for (const filePath of filePaths) {
|
284
284
|
const queuefunc = async () => {
|
285
285
|
await utils_1.UtilFT.ensurePathExists(filePath);
|
package/dist/UtilMacro.js
CHANGED
@@ -14,9 +14,9 @@ var UtilMacro;
|
|
14
14
|
* @example
|
15
15
|
*/
|
16
16
|
function exportComment(glob) {
|
17
|
-
(0, QuickFunc_1.commentMacro)(/export (\S*)/, ({ filePath, matchId, execArr }) => {
|
17
|
+
(0, QuickFunc_1.commentMacro)(/export (\S*)/, async ({ filePath, matchId, execArr }) => {
|
18
18
|
const basedir = pathe_1.default.dirname(filePath);
|
19
|
-
const result = utils_1.UtilFT.fileSearchGlob(basedir, execArr[1])
|
19
|
+
const result = (await utils_1.UtilFT.fileSearchGlob(basedir, execArr[1]))
|
20
20
|
.map((file) => pathe_1.default.relative(basedir, file))
|
21
21
|
.map((file) => pathe_1.default.parse(file).name)
|
22
22
|
.filter((file) => file != pathe_1.default.parse(filePath).name)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@zwa73/dev-utils",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.52",
|
4
4
|
"description": "编译与调试工具",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -16,7 +16,7 @@
|
|
16
16
|
"author": "zwa73",
|
17
17
|
"license": "ISC",
|
18
18
|
"dependencies": {
|
19
|
-
"@zwa73/utils": "^1.0.
|
19
|
+
"@zwa73/utils": "^1.0.128",
|
20
20
|
"commander": "^11.1.0",
|
21
21
|
"pathe": "^1.1.2",
|
22
22
|
"ts-node": "^10.9.2",
|
package/src/Command/MapPath.ts
CHANGED
@@ -27,7 +27,7 @@ export const CmdMapPath = (program: Command) => program
|
|
27
27
|
const duplicateHandling = options.duplicateHandling as DupMethod;
|
28
28
|
const basePath = process.cwd();
|
29
29
|
// 遍历当前目录下的所有文件
|
30
|
-
const filePaths = UtilFT.fileSearchRegex(basePath, regex.source,{relative:options.recursive})
|
30
|
+
const filePaths = (await UtilFT.fileSearchRegex(basePath, regex.source,{relative:options.recursive}))
|
31
31
|
.map((filePath)=>path.relative(basePath, filePath))
|
32
32
|
.filter((filePath)=>excludeRegex ? (!excludeRegex.test(filePath)) : true);
|
33
33
|
|
package/src/Command/ScanDups.ts
CHANGED
@@ -26,9 +26,9 @@ export const CmdScanDups = (program: Command) => program
|
|
26
26
|
.action(async (options) => {
|
27
27
|
const regex = new RegExp(options.regex);
|
28
28
|
const basePath = process.cwd();
|
29
|
-
const pList = UtilFT.fileSearchRegex(basePath, regex.source, {
|
29
|
+
const pList = (await UtilFT.fileSearchRegex(basePath, regex.source, {
|
30
30
|
relative: options.recursive,
|
31
|
-
}).map(async (filePath) => ({ filePath, hash: await calculateHash(filePath) }));
|
31
|
+
})).map(async (filePath) => ({ filePath, hash: await calculateHash(filePath) }));
|
32
32
|
|
33
33
|
const hashMap = (await Promise.all(pList)).reduce((obj,cur)=>{
|
34
34
|
obj[cur.hash] = (obj[cur.hash]??[]).concat(cur.filePath);
|
package/src/UtilDevTool.ts
CHANGED
@@ -50,7 +50,7 @@ export async function generateSchema(dir:string,opt?:BuildSchemaOpt){
|
|
50
50
|
strictNullChecks: true,
|
51
51
|
};
|
52
52
|
if(opt?.project) Object.assign(compilerOptions,(await UtilFT.loadJSONFile(opt.project) as any).compilerOptions);
|
53
|
-
const files = UtilFT.fileSearchGlob(dir,opt?.include ?? "**/*.schema.ts",{ingore:opt?.exclude});
|
53
|
+
const files = await UtilFT.fileSearchGlob(dir,opt?.include ?? "**/*.schema.ts",{ingore:opt?.exclude});
|
54
54
|
|
55
55
|
const program = TJS.getProgramFromFiles(
|
56
56
|
files,
|
@@ -110,7 +110,7 @@ function coverObj(base:JObject,cover:JObject){
|
|
110
110
|
* @param opt.project - tsconfig路径
|
111
111
|
*/
|
112
112
|
export async function matchNode(dir:string,opt?:BuildMatchOpt) {
|
113
|
-
const files = UtilFT.fileSearchGlob(dir,opt?.include ?? "index.ts",{ingore:opt?.exclude});
|
113
|
+
const files = await UtilFT.fileSearchGlob(dir,opt?.include ?? "index.ts",{ingore:opt?.exclude});
|
114
114
|
await batchNode(files,opt);
|
115
115
|
}
|
116
116
|
/**运行所有js/ts文件
|
@@ -182,7 +182,7 @@ const literalRegex = (str:string)=>new RegExp(
|
|
182
182
|
*/
|
183
183
|
export async function regionMacro(regionId:string|RegExp,codeText:string|((opt:CodeTextOpt)=>string|Promise<string>),opt?:MacroOpt){
|
184
184
|
const plist:Promise<void>[] = [];
|
185
|
-
const filePaths = parseMacroPaths(opt);
|
185
|
+
const filePaths = await parseMacroPaths(opt);
|
186
186
|
for(const filePath of filePaths){
|
187
187
|
const queuefunc = async ()=>{
|
188
188
|
if(!(await UtilFT.pathExists(filePath))) {
|
@@ -239,7 +239,7 @@ export async function regionMacro(regionId:string|RegExp,codeText:string|((opt:C
|
|
239
239
|
*/
|
240
240
|
export async function commentMacro(commentId:string|RegExp,codeText:string|((opt:CodeTextOpt)=>string|Promise<string>),opt?:MacroOpt){
|
241
241
|
const plist:Promise<void>[] = [];
|
242
|
-
const filePaths = parseMacroPaths(opt);
|
242
|
+
const filePaths = await parseMacroPaths(opt);
|
243
243
|
for(const filePath of filePaths){
|
244
244
|
const queuefunc = async ()=>{
|
245
245
|
if(!(await UtilFT.pathExists(filePath))) {
|
@@ -296,7 +296,7 @@ export async function commentMacro(commentId:string|RegExp,codeText:string|((opt
|
|
296
296
|
*/
|
297
297
|
export async function fileMacro(codeText:string|((opt:Omit<CodeTextOpt,'ident'|'matchId'|'execArr'>)=>string|Promise<string>),opt?:MacroOpt){
|
298
298
|
const plist:Promise<void>[] = [];
|
299
|
-
const filePaths = parseMacroPaths(opt);
|
299
|
+
const filePaths = await parseMacroPaths(opt);
|
300
300
|
for(const filePath of filePaths){
|
301
301
|
const queuefunc = async ()=>{
|
302
302
|
await UtilFT.ensurePathExists(filePath);
|
package/src/UtilMacro.ts
CHANGED
@@ -9,9 +9,9 @@ export namespace UtilMacro{
|
|
9
9
|
* @example
|
10
10
|
*/
|
11
11
|
export function exportComment(glob:string){
|
12
|
-
commentMacro(/export (\S*)/,({filePath,matchId,execArr})=>{
|
12
|
+
commentMacro(/export (\S*)/,async ({filePath,matchId,execArr})=>{
|
13
13
|
const basedir = path.dirname(filePath);
|
14
|
-
const result = UtilFT.fileSearchGlob(basedir,execArr[1])
|
14
|
+
const result = (await UtilFT.fileSearchGlob(basedir,execArr[1]))
|
15
15
|
.map((file)=>path.relative(basedir,file))
|
16
16
|
.map((file)=>path.parse(file).name)
|
17
17
|
.filter((file)=>file!=path.parse(filePath).name)
|