js-dev-tool 1.0.1 → 1.0.3
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/basic-types.d.ts +36 -107
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -41
- package/extras/tiny-progress.d.ts +1 -1
- package/extras/tiny-progress.js +1 -11
- package/index.d.ts +1 -6
- package/index.js +1 -1
- package/lib/unzip.min.js +1 -3
- package/lib/zip.min.js +1 -2
- package/lib/zlibjs.d.ts +1 -1
- package/package.json +2 -2
- package/progress/index.d.ts +1 -3
- package/progress/index.js +2 -38
- package/progress/progress-extras.d.ts +1 -1
- package/progress/progress-extras.js +1 -12
- package/progress/rnd-spinner.js +2 -6
- package/progress/spinners.d.ts +1 -3
- package/progress/test.js +1 -18
- package/regex.d.ts +3 -66
- package/scripts/publish-version.json +1 -1
- package/scripts/unzip.js +1 -2
- package/scripts/zip.js +6 -58
- package/tool-lib/cjbm.js +1 -117
- package/tool-lib/cmt-trick.js +1 -44
- package/tool-lib/ps.js +65 -72
- package/tool-lib/rws.js +13 -19
- package/tool-lib/tools.d.ts +3 -94
- package/tool-lib/zip-task.js +1 -2
- package/tools.d.ts +6 -6
- package/tools.js +8 -120
- package/tsconfig.json +1 -1
- package/utils.d.ts +23 -55
- package/utils.js +12 -245
package/tool-lib/cmt-trick.js
CHANGED
|
@@ -10,14 +10,11 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* @file comment trick toggle
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
*
|
|
16
15
|
* @param {string} code
|
|
17
16
|
*/
|
|
18
17
|
function cleanup(code) {
|
|
19
|
-
// DEVNOTE: 2023/10/27 - PCRE2 style: https://regex101.com/r/r3aGp5/2
|
|
20
|
-
// NOTE: cleanup 用の regex
|
|
21
18
|
const pcreStyle = String.raw`
|
|
22
19
|
\s*\/
|
|
23
20
|
(?:
|
|
@@ -33,13 +30,10 @@ function cleanup(code) {
|
|
|
33
30
|
)
|
|
34
31
|
\s*\/{2,}\*\/
|
|
35
32
|
`;
|
|
36
|
-
// to js regex
|
|
37
|
-
// /\s*\/(?:\s*\/+\*\s+(?:ctt|comment-toggle-trick|https:\/\/coderwall)([\s\S]+?)\/\*\/[\s\S]+|\s*\*\s+(?:ctt|comment-toggle-trick|https:\/\/coderwall)[\s\S]+\/\*\/([\s\S]+?))\s*\/{2,}\*\//g
|
|
38
33
|
return code.replace(
|
|
39
34
|
new RegExp(pcreStyle.replace(/\s*\(\?#.*\)\s*$|#\s.*$|\s+/gm, ""), "g"), ($0, $1, $2) => $1 || $2,
|
|
40
35
|
);
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
/**
|
|
44
38
|
* @param {string} code
|
|
45
39
|
*/
|
|
@@ -57,56 +51,19 @@ function doIt(code) {
|
|
|
57
51
|
},
|
|
58
52
|
);
|
|
59
53
|
}
|
|
60
|
-
|
|
61
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
62
|
-
// url: https://github.com/marketplace/models/azure-openai/gpt-4-1/playground?preset=jeffy-g%2Fts-js-adviser
|
|
63
|
-
// DEVNOTE: 2025/9/8 7:15:24 - この code の original は OpenAI GPT-4.1 が提示したものだが、
|
|
64
|
-
// そのままでは、意図した挙動にならず、修正
|
|
65
|
-
// -> 結局、origin `doIt` でしっかり処理できていたので、不要に
|
|
66
|
-
// -> 一回しか置換できないと勘違いし、doIt を review してもらったが、
|
|
67
|
-
// 原因は `//* ctt` のようになっていなかったため (token "ctt" が抜けていた)
|
|
68
|
-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
69
|
-
// /** @type {RegExp} */
|
|
70
|
-
// const BLOCK_RE = /^(?:\s*(\/+)\*+\s*(.+))$/gm;
|
|
71
|
-
// /**
|
|
72
|
-
// * @param {string} code
|
|
73
|
-
// */
|
|
74
|
-
// function doIt(code) {
|
|
75
|
-
// return code.replace(BLOCK_RE, ($0, $1, $2, offset, str) => {
|
|
76
|
-
// // すぐ後ろに* cttなどがあれば...
|
|
77
|
-
// if (/ctt|comment-toggle-trick|https:\/\/coderwall/.test($2)) {
|
|
78
|
-
// // if (str.slice(offset).match(/^\/*\*\s?(ctt|comment-toggle-trick|https:\/\/coderwall)/)) {
|
|
79
|
-
// const slashes = $1.length === 2 ? "/" : "//";
|
|
80
|
-
// console.log(
|
|
81
|
-
// "the-comment-toggle-trick: %s",
|
|
82
|
-
// slashes === "/" ? "-->enable before<--, mute after" : "mute before, -->enable after<--"
|
|
83
|
-
// );
|
|
84
|
-
// return slashes;
|
|
85
|
-
// }
|
|
86
|
-
// return $0;
|
|
87
|
-
// });
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
// yarn test -base ./tool-lib -test re/\\.js$/ -help cmtTrick
|
|
91
|
-
// yarn test -base ./tool-lib -test re/\\.js$/ -cmd cmtTrick:clean
|
|
92
54
|
/**
|
|
93
55
|
* @returns {TJSToolEntry}
|
|
94
56
|
* @version 2.0 2023-10-27 supports `mode` feature
|
|
95
57
|
*/
|
|
96
58
|
module.exports = () => {
|
|
97
59
|
return {
|
|
98
|
-
// ^\s*\/+\*\s+(?:ctt|comment-toggle-trick|https:\/\/coderwall)[\s\S]+\s*\/+\*\/|\/\*\s+(?:ctt|comment-toggle-trick|https:\/\/coderwall)[\s\S]+\/\*\/\s*([\s\S]+)\s*\/+\*\/
|
|
99
60
|
taskName: "comment trick toggle",
|
|
100
61
|
fn(mode) {
|
|
101
62
|
processSources(
|
|
102
63
|
/** @type {string} */ (this.taskName), (code) => {
|
|
103
64
|
return mode === "clean" ? cleanup(code) : doIt(code);
|
|
104
65
|
}, {
|
|
105
|
-
/* ctt
|
|
106
|
-
...params
|
|
107
|
-
/*/
|
|
108
66
|
...params,
|
|
109
|
-
//*/
|
|
110
67
|
},
|
|
111
68
|
);
|
|
112
69
|
},
|
|
@@ -122,4 +79,4 @@ module.exports = () => {
|
|
|
122
79
|
`;
|
|
123
80
|
},
|
|
124
81
|
};
|
|
125
|
-
};
|
|
82
|
+
};
|
package/tool-lib/ps.js
CHANGED
|
@@ -7,20 +7,45 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/// <reference path="./tools.d.ts"/>
|
|
9
9
|
// @ts-check
|
|
10
|
-
|
|
11
10
|
const DEBUG = 0;
|
|
11
|
+
/** @type {(err: NodeJS.ErrnoException, cb: () => void) => void} */
|
|
12
|
+
const handleError = (err, done) => {
|
|
13
|
+
console.error(err);
|
|
14
|
+
done();
|
|
15
|
+
};
|
|
12
16
|
/**
|
|
13
17
|
* @file `processSources` will be globalized
|
|
14
18
|
*/
|
|
15
19
|
module.exports = {
|
|
16
20
|
/**
|
|
17
|
-
*
|
|
18
21
|
* @param {import("fs")} fs
|
|
19
22
|
* @param {import("../utils")} utils
|
|
20
23
|
*/
|
|
21
24
|
globalize: (fs, utils) => {
|
|
22
25
|
/**
|
|
23
|
-
*
|
|
26
|
+
* @param {string} dir
|
|
27
|
+
* @param {string[]} sourceFiles
|
|
28
|
+
* @param {RegExp} testRe
|
|
29
|
+
* @param {true=} recurse
|
|
30
|
+
*/
|
|
31
|
+
const visitDirectory = (dir, sourceFiles, testRe, recurse) => {
|
|
32
|
+
if (dir.length) {
|
|
33
|
+
if (!fs.existsSync(dir)) {
|
|
34
|
+
console.info(`directory: [${dir}] is not found`);
|
|
35
|
+
} else {
|
|
36
|
+
utils.walkDirSync(dir, (dirent) => {
|
|
37
|
+
const currentPath = `${dir}/${dirent.name}`;
|
|
38
|
+
if (dirent.isFile() && testRe.test(dirent.name)) {
|
|
39
|
+
DEBUG && console.log("processSources::", dirent.name);
|
|
40
|
+
sourceFiles.push(currentPath);
|
|
41
|
+
} else if (recurse && dirent.isDirectory()) {
|
|
42
|
+
visitDirectory(currentPath, sourceFiles, testRe, true);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
24
49
|
* @param {string} taskName
|
|
25
50
|
* @param {(source: string) => Promise<string> | string} process
|
|
26
51
|
* @param {TProcessSourcesOpt} [opt]
|
|
@@ -34,112 +59,80 @@ module.exports = {
|
|
|
34
59
|
suffix = "",
|
|
35
60
|
targets,
|
|
36
61
|
} = opt;
|
|
37
|
-
|
|
38
|
-
|
|
62
|
+
/**
|
|
63
|
+
* 主に javascript 系 file を push する.
|
|
64
|
+
*
|
|
65
|
+
* directory は除外
|
|
66
|
+
* @type {string[]}
|
|
67
|
+
*/
|
|
39
68
|
let sourceFiles;
|
|
40
69
|
if ((!targets && root) || bases || base) {
|
|
41
70
|
sourceFiles = [];
|
|
42
|
-
const
|
|
43
|
-
const actualBases =
|
|
44
|
-
DEBUG && console.log("processSources::", actualBases,
|
|
45
|
-
|
|
46
|
-
DEBUG && console.log("processSources::re", re, re.constructor);
|
|
47
|
-
/**
|
|
48
|
-
* @param {string} dir
|
|
49
|
-
* @param {true=} recurse
|
|
50
|
-
*/
|
|
51
|
-
const visitDirectry = (dir, recurse) => {
|
|
52
|
-
if (dir.length) {
|
|
53
|
-
if (!fs.existsSync(dir)) {
|
|
54
|
-
console.info(`directory: [${dir}] is not found`);
|
|
55
|
-
} else {
|
|
56
|
-
utils.walkDirSync(dir, (dirent) => {
|
|
57
|
-
const path = `${dir}/${dirent.name}`;
|
|
58
|
-
if (dirent.isFile() && re.test(dirent.name)) {
|
|
59
|
-
DEBUG && console.log("processSources::", dirent.name);
|
|
60
|
-
sourceFiles.push(path);
|
|
61
|
-
} else if (recurse && dirent.isDirectory()) {
|
|
62
|
-
visitDirectry(path, true);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
71
|
+
const reFile = params.test || test;
|
|
72
|
+
const actualBases = isArray(bases) ? bases : [base];
|
|
73
|
+
DEBUG && console.log("processSources::", actualBases, reFile);
|
|
74
|
+
DEBUG && console.log("processSources::re", reFile, reFile.constructor);
|
|
68
75
|
if (root) {
|
|
69
|
-
|
|
76
|
+
visitDirectory(root.trim(), sourceFiles, reFile, true);
|
|
70
77
|
} else {
|
|
71
|
-
|
|
72
|
-
actualBases.forEach((base) => base && visitDirectry(base.trim()));
|
|
78
|
+
actualBases.forEach((base) => base && visitDirectory(base.trim(), sourceFiles, reFile));
|
|
73
79
|
}
|
|
74
80
|
} else {
|
|
75
|
-
sourceFiles = params.targets || params.args || targets;
|
|
81
|
+
sourceFiles = params.targets || params.args || targets || [];
|
|
76
82
|
if (sourceFiles.length && params.basePath) {
|
|
77
|
-
// DEVNOTE: remove extra whitespaces
|
|
78
83
|
sourceFiles = sourceFiles.map((s) => s && s.trim());
|
|
79
84
|
const basePath = getBasePaths()?.[0] || ".";
|
|
80
|
-
// const basePath = Array.isArray(params.basePath) ? params.basePath[0] : params.basePath;
|
|
81
85
|
utils.prependStringTo(sourceFiles, basePath, "/");
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
|
-
|
|
85
88
|
sourceFiles = sourceFiles.filter(Boolean);
|
|
86
89
|
DEBUG && console.log("processSources::processSources:", sourceFiles);
|
|
87
90
|
let count = sourceFiles.length;
|
|
88
91
|
let written = 0;
|
|
89
92
|
/** @type {(fileName?: string) => void} */
|
|
90
93
|
const done = (fileName) => {
|
|
91
|
-
--count === 0 &&
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
--count === 0 && (
|
|
95
|
+
console.timeEnd(taskName), utils.log(`[${taskName}] file written: ${written}`)
|
|
96
|
+
);
|
|
94
97
|
if (verbose && fileName) {
|
|
95
98
|
utils.log(`[${taskName}] done: ${fileName}`);
|
|
96
99
|
}
|
|
97
100
|
};
|
|
98
|
-
/** @param {NodeJS.ErrnoException} err */
|
|
99
|
-
const handleError = (err) => {
|
|
100
|
-
console.error(err);
|
|
101
|
-
done();
|
|
102
|
-
};
|
|
103
101
|
count && console.time(taskName);
|
|
104
102
|
for (const sourceFile of sourceFiles) {
|
|
105
|
-
fs.stat(sourceFile, (
|
|
103
|
+
fs.stat(sourceFile, (statErr, stat) => {
|
|
104
|
+
if (statErr) {
|
|
105
|
+
return handleError(statErr, () => done(sourceFile));
|
|
106
|
+
}
|
|
106
107
|
if (stat.isFile()) {
|
|
107
|
-
fs.readFile(sourceFile, "utf8", async (
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
return;
|
|
108
|
+
fs.readFile(sourceFile, "utf8", async (readErr, code) => {
|
|
109
|
+
if (readErr) {
|
|
110
|
+
return handleError(readErr, () => done(sourceFile));
|
|
111
|
+
}
|
|
112
|
+
const result = await runProcess(code, process);
|
|
113
|
+
const outputPath = sourceFile.replace(/(?=\.js$)/, suffix);
|
|
114
|
+
if (result !== code) {
|
|
115
|
+
fs.writeFile(outputPath, result, () => {
|
|
116
|
+
written++, done(outputPath);
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
done(outputPath);
|
|
121
120
|
}
|
|
122
|
-
handleError(err);
|
|
123
121
|
});
|
|
124
|
-
} else if (err) {
|
|
125
|
-
handleError(err);
|
|
126
122
|
} else {
|
|
127
|
-
done();
|
|
123
|
+
done(sourceFile);
|
|
128
124
|
}
|
|
129
125
|
});
|
|
130
126
|
}
|
|
131
127
|
}
|
|
132
|
-
// OK
|
|
133
128
|
globalThis.processSources = processSources;
|
|
134
129
|
},
|
|
135
130
|
};
|
|
136
131
|
globalThis.getBasePaths = function () {
|
|
137
132
|
const bp = params.basePath;
|
|
138
|
-
return
|
|
139
|
-
? bp
|
|
140
|
-
|
|
141
|
-
? [bp]
|
|
142
|
-
: void 0;
|
|
133
|
+
return isArray(bp)
|
|
134
|
+
? bp : typeof bp === "string" && bp.length
|
|
135
|
+
? [bp] : void 0;
|
|
143
136
|
};
|
|
144
137
|
/**
|
|
145
138
|
* @param {string} code
|
|
@@ -155,4 +148,4 @@ function runProcess(code, process) {
|
|
|
155
148
|
resolve(result);
|
|
156
149
|
}
|
|
157
150
|
});
|
|
158
|
-
}
|
|
151
|
+
}
|
package/tool-lib/rws.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
/**
|
|
11
11
|
* @file (R)ecord(W)ebpack(S)ize
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* actually, return value will be like `TVersionString + "-dev"`
|
|
16
15
|
*
|
|
@@ -43,12 +42,14 @@ const decrementVersion = (nversionArray) => {
|
|
|
43
42
|
}
|
|
44
43
|
return normalizeVersion(nversionArray);
|
|
45
44
|
};
|
|
46
|
-
|
|
47
45
|
/**
|
|
48
|
-
*
|
|
46
|
+
* This function is used for preview.
|
|
47
|
+
*
|
|
48
|
+
* + Too many record entries can be hard to see,
|
|
49
|
+
* so if there are more than 10 entries, they will be truncated.
|
|
49
50
|
* @param {TVersionRecords} record
|
|
50
51
|
*/
|
|
51
|
-
const
|
|
52
|
+
const shortenRecord = (record) => {
|
|
52
53
|
let keys = /** @type {TVersionString[]} */ (Object.keys(record));
|
|
53
54
|
if (keys.length > 10) {
|
|
54
55
|
keys = keys.slice(keys.length - 10);
|
|
@@ -62,7 +63,6 @@ const reduceRecord = (record) => {
|
|
|
62
63
|
}
|
|
63
64
|
return record;
|
|
64
65
|
};
|
|
65
|
-
|
|
66
66
|
/**
|
|
67
67
|
* @param {import("fs")} fs
|
|
68
68
|
* @param {import("../utils")} utils
|
|
@@ -81,8 +81,6 @@ module.exports = (fs, utils) => {
|
|
|
81
81
|
/** @type {TVersionString} */
|
|
82
82
|
const versionStr = thisPackage.version;
|
|
83
83
|
const tags = /** @type {TRwsTags[]} */ (["webpack", "umd", "bin"]);
|
|
84
|
-
// const tags = /** @type {TRwsTags[]} */(["webpack", "umd", "bin"]).concat(params["rws-tags"] || []);
|
|
85
|
-
|
|
86
84
|
/**
|
|
87
85
|
* @param {TSizeRecordEntry} a
|
|
88
86
|
* @param {TSizeRecordEntry} b
|
|
@@ -91,7 +89,6 @@ module.exports = (fs, utils) => {
|
|
|
91
89
|
const isDiff = (a, b) => {
|
|
92
90
|
return tags.some((tag) => {
|
|
93
91
|
const x = a[tag], y = b[tag];
|
|
94
|
-
// DEVNOTE: 2023/10/27 - means `tag` is not exist
|
|
95
92
|
if (typeof x !== "number" && typeof y !== "number") {
|
|
96
93
|
return false;
|
|
97
94
|
}
|
|
@@ -109,17 +106,18 @@ module.exports = (fs, utils) => {
|
|
|
109
106
|
});
|
|
110
107
|
if (params["rws-tags"]) {
|
|
111
108
|
const tagArray = Array.isArray(params["rws-tags"]) ? params["rws-tags"] : [params["rws-tags"]];
|
|
112
|
-
tagArray.forEach((
|
|
113
|
-
const
|
|
109
|
+
tagArray.forEach((tagToken) => {
|
|
110
|
+
const colon = tagToken.indexOf(":");
|
|
111
|
+
if (colon < 1) return;
|
|
112
|
+
const tag = /** @type {TRwsTags} */ (tagToken.slice(0, colon));
|
|
113
|
+
const sourcePath = tagToken.slice(colon + 1);
|
|
114
114
|
if (fs.existsSync(sourcePath)) {
|
|
115
115
|
entry[/** @type {TRwsTags} */ (tag)] = fs.statSync(sourcePath).size;
|
|
116
116
|
tags.push(/** @type {TRwsTags} */ (tag));
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
|
|
121
120
|
params.debug && console.log(entry);
|
|
122
|
-
// if (entry.webpack || entry.umd || entry.bin) {
|
|
123
121
|
if (tags.some((tag) => entry[tag])) {
|
|
124
122
|
let nversionArray = /** @type {RegExpExecArray} */ ( /(\d+)\.(\d+)\.(\d+)(-\w+)?/.exec(versionStr) );
|
|
125
123
|
const $0 = nversionArray.shift();
|
|
@@ -127,27 +125,23 @@ module.exports = (fs, utils) => {
|
|
|
127
125
|
let prevEntry = sizeRecord[/** @type {TVersionString} */ ($0)];
|
|
128
126
|
if (!prevEntry)
|
|
129
127
|
do {
|
|
130
|
-
// DEVNOTE: 2023/10/24 - Modified the code to maintain a version string like `1.3.3-dev`!
|
|
131
128
|
const version = decrementVersion(nversionArray);
|
|
132
|
-
// DEVNOTE: debug log
|
|
133
|
-
// console. log(`decrementVersion: nversion=${nversionArray}, version=${version}`);
|
|
134
129
|
prevEntry = sizeRecord[version];
|
|
135
130
|
if (prevEntry || version.startsWith("0.0.0")) {
|
|
136
131
|
break;
|
|
137
132
|
}
|
|
138
133
|
} while (1);
|
|
139
|
-
|
|
140
134
|
let needWrite = true;
|
|
141
135
|
let msg = "";
|
|
142
136
|
if (prevEntry) {
|
|
143
137
|
if (isDiff(prevEntry, entry)) {
|
|
144
138
|
sizeRecord[versionStr] = entry;
|
|
145
|
-
utils.log(
|
|
139
|
+
utils.log(shortenRecord(sizeRecord));
|
|
146
140
|
msg = "[%s] is updated";
|
|
147
141
|
} else {
|
|
148
142
|
needWrite = false;
|
|
149
143
|
console.log(
|
|
150
|
-
`${this.taskName}: No change from
|
|
144
|
+
`${this.taskName}: No change from previous webpack size record.`,
|
|
151
145
|
prevEntry,
|
|
152
146
|
);
|
|
153
147
|
}
|
|
@@ -178,4 +172,4 @@ module.exports = (fs, utils) => {
|
|
|
178
172
|
`;
|
|
179
173
|
},
|
|
180
174
|
};
|
|
181
|
-
};
|
|
175
|
+
};
|
package/tool-lib/tools.d.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
7
|
*/
|
|
8
8
|
/// <reference path="../regex.d.ts"/>
|
|
9
|
-
|
|
10
9
|
declare const ImportExportDetectRegex = `(?<!\\/\\/+\\s*)(?:import|export)\\s*(?:"(?!https?:)(?=[.\\/]+)\
|
|
11
10
|
(?:(?<globalName>(?:[.\\/]+)?[^"]+?)(?:\\.(?<globalExt>(?:c|m)?jsx?))?)"|\
|
|
12
11
|
\\(\\s*"(?!https?:)(?=[.\\/]+)(?<dynamicName>(?:[.\\/]+)?[^"]+?)(?:\\.(?<dynamicExt>(?:c|m)?jsx?))?"\\s*\\)|\
|
|
@@ -14,54 +13,29 @@ declare const ImportExportDetectRegex = `(?<!\\/\\/+\\s*)(?:import|export)\\s*(?
|
|
|
14
13
|
(?:\\.(?<moduleExt>(?:c|m)?jsx?))?)")(?=\\s*;)?`;
|
|
15
14
|
declare const reOk: ReturnType<typeof XRegex.createRegExp<typeof ImportExportDetectRegex>>;
|
|
16
15
|
type TRegexDetectRet = XRegex.ReGroups<typeof reOk>;
|
|
17
|
-
/* ctt
|
|
18
|
-
// DONE: 2025/3/18 17:49:31 ok, result is 1, works
|
|
19
|
-
type OKK = TRegexDetectRet extends TImportExportRegexGroup ? 1: 0;
|
|
20
|
-
/*/
|
|
21
|
-
//*/
|
|
22
|
-
|
|
23
16
|
/**
|
|
24
17
|
* @date 2023-10-25
|
|
25
18
|
*/
|
|
26
19
|
declare global {
|
|
27
|
-
|
|
28
|
-
// DEVNOTE: 2025/3/18 17:51:42 - Retained for a while as a product of the past
|
|
29
|
-
// type TRegexImportExportDetectorGroupNames =
|
|
30
|
-
// | "clause"
|
|
31
|
-
// | "dynamicExt"
|
|
32
|
-
// | "dynamicName"
|
|
33
|
-
// | "globalExt"
|
|
34
|
-
// | "globalName"
|
|
35
|
-
// | "moduleExt"
|
|
36
|
-
// | "moduleName";
|
|
37
|
-
// type TImportExportRegexGroup = {
|
|
38
|
-
// [K in TRegexImportExportDetectorGroupNames]?: string;
|
|
39
|
-
// };
|
|
40
20
|
type TRegexImportExportDetectorReplacer = function(
|
|
41
21
|
string, string, string, string, string, string, string, string, number, string,
|
|
42
22
|
TRegexDetectRet
|
|
43
23
|
): string;
|
|
44
|
-
|
|
45
24
|
declare function processSources(
|
|
46
25
|
taskName: string,
|
|
47
26
|
process: (source: string) => Promise<string> | string,
|
|
48
27
|
options?: TProcessSourcesOpt
|
|
49
28
|
): void;
|
|
50
|
-
|
|
51
29
|
/** regex replace sig */
|
|
52
30
|
declare type TStringReplacer = (matchs: string, ...args: any[]) => string;
|
|
53
|
-
|
|
54
31
|
/** use `(R)ecord(W)ebpack(S)ize` */
|
|
55
32
|
declare type TRwsTags = "webpack" | "umd" | "bin";
|
|
56
|
-
|
|
57
|
-
|
|
58
33
|
declare var params: ReturnType<typeof import("tin-args")<TToolArgs>>;
|
|
59
|
-
|
|
34
|
+
declare const isArray: typeof Array.isArray;
|
|
60
35
|
/**
|
|
61
36
|
* @date 2025/2/18 0:46:03
|
|
62
37
|
*/
|
|
63
38
|
declare function getBasePaths(): string[] | undefined;
|
|
64
|
-
|
|
65
39
|
/**
|
|
66
40
|
* + tool option `verb`
|
|
67
41
|
*/
|
|
@@ -70,7 +44,6 @@ declare global {
|
|
|
70
44
|
* tools command arg types
|
|
71
45
|
*/
|
|
72
46
|
declare type TToolArgs = {
|
|
73
|
-
|
|
74
47
|
/**
|
|
75
48
|
* parameter is used to specify the root directory of the source code scan.
|
|
76
49
|
*
|
|
@@ -83,16 +56,13 @@ declare global {
|
|
|
83
56
|
* @since 1.4.28
|
|
84
57
|
*/
|
|
85
58
|
shell?: string;
|
|
86
|
-
|
|
87
59
|
/**
|
|
88
60
|
* print jstool version
|
|
89
61
|
* @date 2025/1/23 11:37:58
|
|
90
62
|
*/
|
|
91
63
|
v?: true;
|
|
92
|
-
|
|
93
|
-
/** task command shortten name */
|
|
64
|
+
/** task command shorten name */
|
|
94
65
|
cmd: string;
|
|
95
|
-
|
|
96
66
|
/**
|
|
97
67
|
* processSources
|
|
98
68
|
* cjbm, minify, rmc
|
|
@@ -102,31 +72,22 @@ declare global {
|
|
|
102
72
|
targets: string[];
|
|
103
73
|
/** minify, rmc */
|
|
104
74
|
suffix: string;
|
|
105
|
-
|
|
106
|
-
// version
|
|
107
75
|
major?: true;
|
|
108
76
|
minor?: true;
|
|
109
77
|
patch?: true;
|
|
110
78
|
extras: string[];
|
|
111
|
-
|
|
112
79
|
/** rws, backup */
|
|
113
80
|
dest: string;
|
|
114
81
|
/** backup */
|
|
115
82
|
projectName: string;
|
|
116
|
-
|
|
117
83
|
/** for `cjbm` replace extension. default is `js` */
|
|
118
84
|
ext: string;
|
|
119
|
-
|
|
120
85
|
/** shared, minify, rmc */
|
|
121
86
|
test: RegExp;
|
|
122
|
-
|
|
123
87
|
/** stripWebpack, stripSome */
|
|
124
88
|
regex: RegExp;
|
|
125
|
-
|
|
126
89
|
/** rmc */
|
|
127
90
|
rmc4ts: boolean;
|
|
128
|
-
|
|
129
|
-
// rws
|
|
130
91
|
/**
|
|
131
92
|
* webpacked source path.
|
|
132
93
|
* @default `./dist/webpack/index.js`
|
|
@@ -149,15 +110,12 @@ declare global {
|
|
|
149
110
|
* ```
|
|
150
111
|
*/
|
|
151
112
|
"rws-tags": `${string}:${string}` | `${string}:${string}`[];
|
|
152
|
-
|
|
153
113
|
/** zip comment */
|
|
154
114
|
comment: string;
|
|
155
115
|
/** specify target package.json(s) [version] */
|
|
156
116
|
pkgJsons: string[];
|
|
157
|
-
|
|
158
117
|
/** want help? form - "-help <cmd name>" */
|
|
159
118
|
help: string;
|
|
160
|
-
|
|
161
119
|
/**
|
|
162
120
|
* for stripSome
|
|
163
121
|
* @date 2024-01-05
|
|
@@ -165,28 +123,12 @@ declare global {
|
|
|
165
123
|
after: string;
|
|
166
124
|
/** want print written file name? */
|
|
167
125
|
verb: true;
|
|
168
|
-
|
|
169
126
|
/**
|
|
170
127
|
* @date 2025/4/6 17:09:40
|
|
171
128
|
*/
|
|
172
129
|
debug?: true;
|
|
173
130
|
}
|
|
174
|
-
|
|
175
|
-
// /**
|
|
176
|
-
// * @typedef {
|
|
177
|
-
// (path: string, handler: (dirent: import("fs").Dirent) => void) => void
|
|
178
|
-
// } TWalkDirSyncFunction
|
|
179
|
-
// */
|
|
180
131
|
declare type TWalkDirSyncFunction = (path: string, handler: (dirent: import("fs").Dirent) => void) => void;
|
|
181
|
-
|
|
182
|
-
// /**
|
|
183
|
-
// * @typedef TProcessSourcesOpt
|
|
184
|
-
// * @prop {string} [base]
|
|
185
|
-
// * @prop {string[]} [bases] Array of search directory paths, overriding "base"
|
|
186
|
-
// * @prop {RegExp} [test] default: `/\.js$/`
|
|
187
|
-
// * @prop {string[]} [targets]
|
|
188
|
-
// * @prop {string} [suffix]
|
|
189
|
-
// */
|
|
190
132
|
declare type TProcessSourcesOpt = {
|
|
191
133
|
root?: string;
|
|
192
134
|
base?: string;
|
|
@@ -197,49 +139,16 @@ declare global {
|
|
|
197
139
|
targets?: string[];
|
|
198
140
|
suffix?: string;
|
|
199
141
|
}
|
|
200
|
-
|
|
201
|
-
// /**
|
|
202
|
-
// * @typedef {{
|
|
203
|
-
// * fn: () => void;
|
|
204
|
-
// * help: string;
|
|
205
|
-
// * taskName: string;
|
|
206
|
-
// * }} TJSToolEntry
|
|
207
|
-
// */
|
|
208
142
|
declare type TJSToolEntry = {
|
|
209
143
|
fn: (mode?: string) => void;
|
|
210
144
|
help: string;
|
|
211
145
|
taskName: string;
|
|
212
146
|
}
|
|
213
|
-
|
|
214
147
|
/**
|
|
215
148
|
* version command type
|
|
216
149
|
*/
|
|
217
150
|
declare type TVersionString = `${number}.${number}.${number}`;
|
|
218
|
-
// unused
|
|
219
|
-
// type TNVersion = [number, number, number];
|
|
220
151
|
declare type TVersionRecords = Record<TVersionString, Partial<Record<TRwsTags, number>>>;
|
|
221
152
|
declare type TSizeRecordEntry = TVersionRecords["0.0.0"];
|
|
222
|
-
|
|
223
|
-
// /**
|
|
224
|
-
// * @typedef TRecordWebpackSizeArgs
|
|
225
|
-
// * @prop {string} dest - record path
|
|
226
|
-
// * @prop {string} webpack - webpacked source path. default `./dist/webpack/index.js`
|
|
227
|
-
// * @prop {string} umd - webpacked umd source path. default `./dist/umd/index.js`
|
|
228
|
-
// * @prop {string} bin - webpacked bin source path. default `./dist/bin/index.js`
|
|
229
|
-
// *
|
|
230
|
-
// * @typedef TCJBMArgs currentlly support `js` only
|
|
231
|
-
// * @prop {string | string[]} basePath - source scan path
|
|
232
|
-
// */
|
|
233
|
-
// type TRecordWebpackSizeArgs = {
|
|
234
|
-
// /** record path */
|
|
235
|
-
// dest: string;
|
|
236
|
-
// /** {@link TToolArgs.webpack webpack} */
|
|
237
|
-
// webpack: string;
|
|
238
|
-
// /** {@link TToolArgs.umd umd} */
|
|
239
|
-
// umd: string;
|
|
240
|
-
// /** {@link TToolArgs.bin bin} */
|
|
241
|
-
// bin: string;
|
|
242
|
-
// }
|
|
243
153
|
}
|
|
244
|
-
|
|
245
|
-
export = {};
|
|
154
|
+
export = {};
|
package/tool-lib/zip-task.js
CHANGED
package/tools.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./tools.js";
|
|
2
|
+
TToolArgs,
|
|
3
|
+
TJSToolEntry,
|
|
4
|
+
TZipArgs,
|
|
5
|
+
TRecordWebpackSizeArgs,
|
|
6
|
+
TCJBMArgs
|
|
7
|
+
} from "./tools.js";
|