js-dev-tool 1.0.0 → 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 +9 -0
- 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 +7 -2
- package/utils.d.ts +23 -55
- package/utils.js +12 -245
package/tools.js
CHANGED
|
@@ -8,24 +8,18 @@
|
|
|
8
8
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
9
9
|
*/
|
|
10
10
|
// @ts-check
|
|
11
|
-
|
|
12
11
|
const fs = require("fs");
|
|
13
12
|
const path = require("path");
|
|
14
13
|
/* utilities module by own. */
|
|
15
14
|
const utils = require("./utils");
|
|
16
|
-
|
|
17
|
-
require("./tool-lib/ps").globalize(fs, utils);
|
|
18
|
-
|
|
19
|
-
// /**
|
|
20
|
-
// * @type {ReturnType<typeof utils.getExtraArgs<TToolArgs>>}
|
|
21
|
-
// */
|
|
22
15
|
// @ts-expect-error
|
|
23
16
|
global.params = require("tin-args")();
|
|
24
17
|
// @ts-expect-error
|
|
25
18
|
global.verbose = params.verb;
|
|
26
|
-
|
|
19
|
+
// @ts-expect-error
|
|
20
|
+
global.isArray = Array.isArray;
|
|
21
|
+
require("./tool-lib/ps").globalize(fs, utils);
|
|
27
22
|
utils.log(params);
|
|
28
|
-
|
|
29
23
|
/**
|
|
30
24
|
* how to config terser, see {@link https://github.com/terser/terser#minify-options-structure Minify options structure}
|
|
31
25
|
*
|
|
@@ -33,15 +27,12 @@ utils.log(params);
|
|
|
33
27
|
*
|
|
34
28
|
* @type {import("terser").MinifyOptions}
|
|
35
29
|
*/
|
|
36
|
-
// DEVNOTE: 2020/3/4 - https://terser.org/docs/api-reference
|
|
37
30
|
const terserOptions = {
|
|
38
31
|
ecma: 2019,
|
|
39
|
-
// sourceMap: true,
|
|
40
32
|
parse: {
|
|
41
33
|
shebang: true,
|
|
42
34
|
},
|
|
43
35
|
mangle: true,
|
|
44
|
-
// DEVNOTE: 2020/9/12 - terser latest version is "format"
|
|
45
36
|
output: {
|
|
46
37
|
comments: /@license|@preserve|^(?:!|\*)/,
|
|
47
38
|
indent_level: 1,
|
|
@@ -58,46 +49,18 @@ const terserOptions = {
|
|
|
58
49
|
quote_style: 3,
|
|
59
50
|
},
|
|
60
51
|
};
|
|
61
|
-
|
|
62
|
-
const isArray = Array.isArray;
|
|
63
|
-
|
|
64
52
|
/**
|
|
65
53
|
* @type {Record<string, TJSToolEntry>}
|
|
66
54
|
*/
|
|
67
55
|
const ToolFunctions = {
|
|
68
|
-
// jstool -cmd zip [-comment "the comment"] lib/webpack.js lib/type-ids.js
|
|
69
56
|
zip: require("./tool-lib/zip-task")(utils),
|
|
70
57
|
/** (r)ecord(W)ebpack(S)ize */
|
|
71
|
-
// jstool -cmd rws [-webpack lib/webpack.js -dest "./dev-extras/webpack-size.json"]
|
|
72
58
|
rws: require("./tool-lib/rws")(fs, utils),
|
|
73
|
-
|
|
74
|
-
//
|
|
75
|
-
// (C)onvert (J)S to (B)rowser (M)odule
|
|
76
|
-
// basePath <js source base directory>
|
|
77
|
-
// jstool -cmd cjbm -basePath extra-tests/mini-semaphore [-targets "['core.js', 'object.js']"]
|
|
78
|
-
//
|
|
79
59
|
cjbm: require("./tool-lib/cjbm")(),
|
|
80
|
-
|
|
81
|
-
// jstool -cmd cmtTrick -targets "['core.js', 'object.js']" [-basePath extra-tests/mini-semaphore]
|
|
82
60
|
cmtTrick: require("./tool-lib/cmt-trick")(),
|
|
83
|
-
|
|
84
|
-
// // jstool -cmd stripWebpack -targets "['dist/umd/index.js', 'dist/webpack/index.js']"
|
|
85
|
-
// stripWebpack: () => {
|
|
86
|
-
// /** @type {string[]} */
|
|
87
|
-
// const targets = params.targets || [];
|
|
88
|
-
// if (params.basePath) {
|
|
89
|
-
// utils.prependStringTo(targets, params.basePath, "/");
|
|
90
|
-
// }
|
|
91
|
-
// // regex - https://regex101.com/r/9E6ssx/2/ [eve-oauth - strip webpack regex]
|
|
92
|
-
// const RE_XXX = params.test || /,\s?\w\.t\s?=\s?function\(\w,\s?\w\s?\)\s?\{[\s\S]+?(?=,\s?r\.o)/;
|
|
93
|
-
// utils.fireReplace(RE_XXX, "", targets); // old: targets.map(name => `./${OUTPUT}/${name}.js`)
|
|
94
|
-
// },
|
|
95
|
-
|
|
96
|
-
// jstool -cmd stripWebpack -regex \"%npm_package_defs_regex%\""
|
|
97
61
|
stripWebpack: {
|
|
98
62
|
taskName: "stripWebpack",
|
|
99
63
|
fn() {
|
|
100
|
-
// https://regex101.com/r/CmraG0/1 // umd only
|
|
101
64
|
const re =
|
|
102
65
|
params.regex ||
|
|
103
66
|
/!function\s*\((.+?)\)(?:(.+?=.\(\)\})|([^]+)(?=\(.\.restrictor\s*\|\|))/g;
|
|
@@ -110,25 +73,10 @@ const ToolFunctions = {
|
|
|
110
73
|
"./dist/webpack-esm/index.mjs",
|
|
111
74
|
],
|
|
112
75
|
});
|
|
113
|
-
// processSources(
|
|
114
|
-
// this.taskName, data => {
|
|
115
|
-
// const result = data.replace(re, ($0, $1, $2, $3) => {
|
|
116
|
-
// console.log("[stripWebpack] hit!");
|
|
117
|
-
// return `((${$1})=>${$2 || $3})`;
|
|
118
|
-
// });
|
|
119
|
-
// return result;
|
|
120
|
-
// }, {
|
|
121
|
-
// base: "",
|
|
122
|
-
// // specify default targets when user omitted
|
|
123
|
-
// // DEVNOTE: 2023/10/23 - match `umd` only...
|
|
124
|
-
// targets: ["./dist/umd/index.js", "./dist/webpack/index.js", "./dist/webpack-esm/index.mjs"]
|
|
125
|
-
// }
|
|
126
|
-
// );
|
|
127
76
|
}
|
|
128
77
|
},
|
|
129
78
|
help: 'jstool -cmd stripWebpack -regex "%npm_package_defs_regex%"',
|
|
130
79
|
},
|
|
131
|
-
|
|
132
80
|
/**
|
|
133
81
|
* Performs string substitutions on various file contents
|
|
134
82
|
*
|
|
@@ -136,7 +84,6 @@ const ToolFunctions = {
|
|
|
136
84
|
*
|
|
137
85
|
* @date 2020/6/11
|
|
138
86
|
*/
|
|
139
|
-
// jstool -cmd stripSome -regex \"/^\\s+<!--[\\s\\S]+?-->(?:\\r?\\n)?/gm\""
|
|
140
87
|
stripSome: {
|
|
141
88
|
taskName: "stripSome",
|
|
142
89
|
fn() {
|
|
@@ -158,8 +105,6 @@ const ToolFunctions = {
|
|
|
158
105
|
^^^^^^^^^^^^^
|
|
159
106
|
`,
|
|
160
107
|
},
|
|
161
|
-
|
|
162
|
-
// jstool -cmd version -extras "test/web/index.html,"
|
|
163
108
|
version: {
|
|
164
109
|
taskName: "version",
|
|
165
110
|
fn() {
|
|
@@ -168,7 +113,7 @@ const ToolFunctions = {
|
|
|
168
113
|
let currentVersion;
|
|
169
114
|
/** @type {string} */
|
|
170
115
|
let nextVersion;
|
|
171
|
-
|
|
116
|
+
!isArray(pkgJsons) && (pkgJsons = [pkgJsons]);
|
|
172
117
|
utils.fireReplace(
|
|
173
118
|
/"?version("\s*:\s*)?\s"?(\d+)\.(\d+)\.(\d+)(-\w+)?"?/,
|
|
174
119
|
/** @type {TStringReplacer} */($0, isJson, $major, $minor, $patch, tag) => {
|
|
@@ -189,14 +134,12 @@ const ToolFunctions = {
|
|
|
189
134
|
} else {
|
|
190
135
|
_patch = +_patch + 1;
|
|
191
136
|
}
|
|
192
|
-
// keep current version string, usage for replace extras
|
|
193
137
|
currentVersion = `${$major}.${$minor}.${$patch}${tag ? tag : ""}`;
|
|
194
138
|
nextVersion = `${_major}.${_minor}.${_patch}${tag ? tag : ""}`;
|
|
195
139
|
return isJson ? `"version": "${nextVersion}"` : `version ${nextVersion}`;
|
|
196
140
|
},
|
|
197
141
|
pkgJsons,
|
|
198
142
|
);
|
|
199
|
-
|
|
200
143
|
const paths = isArray(params.extras)
|
|
201
144
|
? params.extras
|
|
202
145
|
: typeof params.extras === "string"
|
|
@@ -205,7 +148,7 @@ const ToolFunctions = {
|
|
|
205
148
|
if (paths.length) {
|
|
206
149
|
utils.fireReplace(/(v)?(\d+\.\d+\.\d+)(-\w+)?/g, /** @type {TStringReplacer} */($0, $prefix, $1, $2) => {
|
|
207
150
|
if ($1 === currentVersion && $prefix) {
|
|
208
|
-
return "v" + nextVersion;
|
|
151
|
+
return "v" + nextVersion;
|
|
209
152
|
}
|
|
210
153
|
return $0;
|
|
211
154
|
},
|
|
@@ -221,13 +164,9 @@ const ToolFunctions = {
|
|
|
221
164
|
extras - can be "<path>,<path>,..." (array type arg)
|
|
222
165
|
`,
|
|
223
166
|
},
|
|
224
|
-
|
|
225
|
-
// jstool -cmd minify -basePath extra-tests/web/mini-semaphore
|
|
226
167
|
minify: {
|
|
227
168
|
taskName: "minify",
|
|
228
169
|
fn() {
|
|
229
|
-
// DEVNOTE: 12:05 2020/03/04 - minify with `terser`
|
|
230
|
-
// DEVNOTE: 2020/9/12 - terser(since v5.3.1? "minify" is now returns promise
|
|
231
170
|
const Terser = require("terser");
|
|
232
171
|
const sx = params.suffix;
|
|
233
172
|
let suffix = ".mini";
|
|
@@ -239,21 +178,17 @@ const ToolFunctions = {
|
|
|
239
178
|
test: params.test || /\.js$/,
|
|
240
179
|
suffix,
|
|
241
180
|
};
|
|
242
|
-
|
|
243
181
|
if (isArray(params.basePath)) {
|
|
244
182
|
opt.bases = params.basePath;
|
|
245
183
|
} else {
|
|
246
184
|
opt.base = params.basePath;
|
|
247
185
|
}
|
|
248
186
|
processSources(
|
|
249
|
-
// @ts- ignore
|
|
250
187
|
this.taskName,
|
|
251
188
|
async (data) => {
|
|
252
|
-
// console.log(data);
|
|
253
189
|
const p = /** @type {Promise<import("terser").MinifyOutput>} */ (
|
|
254
190
|
Terser.minify(data, terserOptions)
|
|
255
191
|
);
|
|
256
|
-
// console.log({}.toString.call(p)); // [object Promise]
|
|
257
192
|
return /** @type {string} */ ((await p).code);
|
|
258
193
|
},
|
|
259
194
|
opt,
|
|
@@ -266,8 +201,6 @@ const ToolFunctions = {
|
|
|
266
201
|
suffix - can be omit, default is ".mini"
|
|
267
202
|
`,
|
|
268
203
|
},
|
|
269
|
-
|
|
270
|
-
// rmc version 3.x
|
|
271
204
|
/**
|
|
272
205
|
* NOTE: keep comment that start with "/*" when "*/" end mark appears in same line.
|
|
273
206
|
*
|
|
@@ -280,34 +213,17 @@ const ToolFunctions = {
|
|
|
280
213
|
if (params.rmc4ts) {
|
|
281
214
|
rmc.setListener(({ event, fragment }) => {
|
|
282
215
|
if (event === /*EScannerEvent.MultiLineComment*/ 1) {
|
|
283
|
-
// DEVNOTE: \b is not contained LF
|
|
284
216
|
return /^\/\*(\*|!)\s|^\/\*(?!-).+\*\/$/.test(fragment);
|
|
285
217
|
}
|
|
286
|
-
// DEVNOTE: this detection is rmc default
|
|
287
|
-
// else if (event === /*ScannerEvent.SingleLineComment*/0) {
|
|
288
|
-
// return /(?:\/\/\/?\s+@ts-\w+|\/\/\/\s*<reference)/.test(fragment);
|
|
289
|
-
// }
|
|
290
|
-
// else if (event === /*ScannerEvent.ES6Template*/2) {
|
|
291
|
-
// ;
|
|
292
|
-
// }
|
|
293
218
|
return false;
|
|
294
219
|
});
|
|
295
220
|
}
|
|
296
221
|
const targets = params.targets;
|
|
297
|
-
const basePaths = isArray(params.basePath)
|
|
298
|
-
? params.basePath
|
|
299
|
-
: [params.basePath];
|
|
222
|
+
const basePaths = isArray(params.basePath) ? params.basePath : [params.basePath];
|
|
300
223
|
processSources(
|
|
301
224
|
/** @type {string} */ (this.taskName),
|
|
302
225
|
(data) => {
|
|
303
|
-
/*
|
|
304
|
-
const after = rmc(data);
|
|
305
|
-
return after.replace(/"use strict";\s/m, "");
|
|
306
|
-
// // purge typescript v3.9.x extra statement
|
|
307
|
-
// return after.replace(/\s(exports\.\w+\s=\s)+void 0;/m, "");
|
|
308
|
-
/*/
|
|
309
226
|
return rmc(data);
|
|
310
|
-
//*/
|
|
311
227
|
},
|
|
312
228
|
{
|
|
313
229
|
bases: basePaths,
|
|
@@ -325,30 +241,17 @@ const ToolFunctions = {
|
|
|
325
241
|
if start with "/*-" remove it
|
|
326
242
|
`,
|
|
327
243
|
},
|
|
328
|
-
|
|
329
|
-
// 2020/2/21
|
|
330
244
|
backup: {
|
|
331
245
|
taskName: "backup",
|
|
332
246
|
fn() {
|
|
333
247
|
// @ts-ignore
|
|
334
248
|
const archiver = require("archiver");
|
|
335
249
|
const archive = archiver("zip", {
|
|
336
|
-
|
|
337
|
-
zlib: { level: 9 }, // Sets the compression level.
|
|
250
|
+
zlib: { level: 9 },
|
|
338
251
|
});
|
|
339
|
-
|
|
340
|
-
// TODO: Parameterize these settings
|
|
341
|
-
// node backup-session -dest "../tmp" -projectName cerebral-web-dev
|
|
342
252
|
const destDir = params.dest || "../tmp";
|
|
343
253
|
const projectName = params.projectName || "anonymouse";
|
|
344
254
|
const prefix = utils.dateStringForFile(true);
|
|
345
|
-
|
|
346
|
-
/* [https://nodejs.org/api/repl.html]
|
|
347
|
-
* Accessing Core Node.js Modules#
|
|
348
|
-
* The default evaluator will automatically load Node.js core modules into the REPL environment when used.
|
|
349
|
-
* For instance, unless otherwise declared as a global or scoped variable, the input fs will be evaluated on-demand as global.fs = require('fs').
|
|
350
|
-
*/
|
|
351
|
-
// @ts- ignore fs is already imported at node REPL
|
|
352
255
|
const output = fs.createWriteStream(`${destDir}/${prefix}-${projectName}-backup.zip`)
|
|
353
256
|
.on("close", function () {
|
|
354
257
|
console.log(archive.pointer() + " total bytes");
|
|
@@ -359,16 +262,12 @@ const ToolFunctions = {
|
|
|
359
262
|
.on("end", function () {
|
|
360
263
|
console.log("Data has been drained");
|
|
361
264
|
});
|
|
362
|
-
|
|
363
265
|
archive.on("progress", (progress) => {
|
|
364
|
-
// console.log(progress); too many infos...
|
|
365
266
|
console.log(progress.entries.processed);
|
|
366
267
|
});
|
|
367
268
|
archive.pipe(output);
|
|
368
269
|
archive.glob("{*,*/**/.*,*/**/*,.*,.*/**/*,.*/**/.*}", {
|
|
369
270
|
cwd: `${destDir}/${projectName}/`,
|
|
370
|
-
// root: "../tmp/cerebral-web-dev/",
|
|
371
|
-
// dot: true,
|
|
372
271
|
});
|
|
373
272
|
archive.finalize();
|
|
374
273
|
},
|
|
@@ -376,7 +275,6 @@ const ToolFunctions = {
|
|
|
376
275
|
\ \ result zip name form: <date string>-<projectName>-backup.zip',
|
|
377
276
|
},
|
|
378
277
|
};
|
|
379
|
-
|
|
380
278
|
/**
|
|
381
279
|
* @param {TJSToolEntry} entry
|
|
382
280
|
* @returns {entry is TJSToolEntry}
|
|
@@ -385,7 +283,6 @@ function isJSToolEntry(entry) {
|
|
|
385
283
|
if (typeof entry !== "object") return false;
|
|
386
284
|
return typeof entry.fn === "function" && typeof entry.help === "string";
|
|
387
285
|
}
|
|
388
|
-
|
|
389
286
|
let colorEnable = false;
|
|
390
287
|
function enableColors() {
|
|
391
288
|
if (!colorEnable) {
|
|
@@ -402,22 +299,14 @@ function printHelp(cmd) {
|
|
|
402
299
|
const entry = ToolFunctions[cmd];
|
|
403
300
|
console.log(`${cmd.yellow + " help:".green} ${entry.help.gray(8)}`);
|
|
404
301
|
}
|
|
405
|
-
|
|
406
302
|
if (params.cmd) {
|
|
407
|
-
// DEVNOTE: 2023/10/27 - new feature `mode`
|
|
408
303
|
const [task, mode] = params.cmd.split(":");
|
|
409
304
|
const entry = ToolFunctions[task];
|
|
410
305
|
isJSToolEntry(entry) && entry.fn(mode);
|
|
411
306
|
} else if (params.shell) {
|
|
412
|
-
// DEVNOTE: 2025/2/1 23:40:24 new feature shell
|
|
413
|
-
// const [task, mode] = params.shell.split(":");
|
|
414
307
|
const SCRIPT_DIR = path.dirname(process.argv[1]);
|
|
415
|
-
// console.log(process.cwd());
|
|
416
|
-
// console.log(process.argv);
|
|
417
|
-
// console.log(`SCRIPT_DIR: ${SCRIPT_DIR}`);
|
|
418
308
|
const arg = `${params.major ? "-major" : params.minor ? "-minor" : ""}`;
|
|
419
309
|
utils.execWithOutputResult(
|
|
420
|
-
// DEVNOTE: 2025/5/16 11:42:05 - 現在, version command の arg のみ support
|
|
421
310
|
`bash ${SCRIPT_DIR}/scripts/tool.sh ${params.shell} ${arg}`,
|
|
422
311
|
(result) => {
|
|
423
312
|
console.log(result);
|
|
@@ -425,7 +314,6 @@ if (params.cmd) {
|
|
|
425
314
|
process.cwd(),
|
|
426
315
|
);
|
|
427
316
|
} else if (params.v) {
|
|
428
|
-
// show version
|
|
429
317
|
enableColors();
|
|
430
318
|
const thisVersion = require("./package.json").version;
|
|
431
319
|
console.log(
|
|
@@ -447,4 +335,4 @@ Usage: node jstool -cmd <command name>
|
|
|
447
335
|
}
|
|
448
336
|
}
|
|
449
337
|
}
|
|
450
|
-
}
|
|
338
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
"moduleResolution": "nodenext",
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"baseUrl": "./",
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"emitDeclarationOnly": true,
|
|
11
13
|
"allowJs": true,
|
|
12
14
|
"checkJs": true,
|
|
13
15
|
"target": "es2019",
|
|
@@ -15,11 +17,14 @@
|
|
|
15
17
|
"outDir": "./build"
|
|
16
18
|
},
|
|
17
19
|
"include": [
|
|
18
|
-
"
|
|
20
|
+
"index.js",
|
|
21
|
+
"utils.js",
|
|
22
|
+
"tools.js",
|
|
23
|
+
"*.d.ts",
|
|
19
24
|
"./**/*.js",
|
|
20
25
|
"./**/*.d.ts"
|
|
21
26
|
],
|
|
22
27
|
"exclude": [
|
|
23
|
-
// "
|
|
28
|
+
// "./**/npm-outdated*.js",
|
|
24
29
|
]
|
|
25
30
|
}
|
package/utils.d.ts
CHANGED
|
@@ -7,19 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="node"/>
|
|
9
9
|
/// <reference path="./basic-types.d.ts"/>
|
|
10
|
-
|
|
11
10
|
import type {
|
|
12
|
-
|
|
11
|
+
Dirent
|
|
13
12
|
} from "fs";
|
|
14
|
-
|
|
15
13
|
export const getExtraArgs: typeof import("tin-args");
|
|
16
|
-
|
|
17
14
|
export type TFsCallback = (err: any, data: string) => void;
|
|
18
|
-
/**
|
|
19
|
-
* <T>
|
|
20
|
-
*/
|
|
21
15
|
export type TypedRecord<T> = {
|
|
22
|
-
|
|
16
|
+
[x: string]: T;
|
|
23
17
|
};
|
|
24
18
|
export type TReadJsonCallback<T> = (err: any, data: Record<string, T>) => void;
|
|
25
19
|
export type TExtraArgsValue = string | boolean | RegExp | string[];
|
|
@@ -53,9 +47,9 @@ export function prependStringTo(str_array: string[], content: string, suffix?: s
|
|
|
53
47
|
* @param {string} versionString default is process.version
|
|
54
48
|
*/
|
|
55
49
|
export function extractVersion(versionString?: string): {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
major: number;
|
|
51
|
+
minor: number;
|
|
52
|
+
patch: number;
|
|
59
53
|
};
|
|
60
54
|
/**
|
|
61
55
|
* use toLocaleString
|
|
@@ -63,7 +57,6 @@ export function extractVersion(versionString?: string): {
|
|
|
63
57
|
* + should be truthy/falsy value
|
|
64
58
|
*/
|
|
65
59
|
export function dateStringForFile(ymd?: any): string;
|
|
66
|
-
|
|
67
60
|
/**
|
|
68
61
|
* use "rm-cstyle-cmts"
|
|
69
62
|
*
|
|
@@ -79,22 +72,11 @@ export function removeJsonComments(source: string): string;
|
|
|
79
72
|
* @param {() => void} [callback] the callback function
|
|
80
73
|
*/
|
|
81
74
|
export function writeTextUTF8(content: string | NodeJS.ReadableStream | Buffer, dest: string, callback?: () => void): void;
|
|
82
|
-
/**
|
|
83
|
-
* @typedef {(err: any, data: string) => void} TFsCallback
|
|
84
|
-
*/
|
|
85
75
|
/**
|
|
86
76
|
* @param {string} from file path.
|
|
87
77
|
* @param [callback]
|
|
88
78
|
*/
|
|
89
79
|
export function readTextUTF8<C extends TBD<TFsCallback>, R extends undefined extends C ? string : void>(from: string, callback?: C): R;
|
|
90
|
-
/**
|
|
91
|
-
* @template T
|
|
92
|
-
* @typedef {Record<string, T>} TypedRecord<T>
|
|
93
|
-
*/
|
|
94
|
-
/**
|
|
95
|
-
* @template T
|
|
96
|
-
* @typedef {(err: any, data: TypedRecord<T>) => void} TReadJsonCallback
|
|
97
|
-
*/
|
|
98
80
|
/**
|
|
99
81
|
* NOTE: when callback specified, returns undefined
|
|
100
82
|
*
|
|
@@ -103,7 +85,6 @@ export function readTextUTF8<C extends TBD<TFsCallback>, R extends undefined ext
|
|
|
103
85
|
*/
|
|
104
86
|
export function readJson<T, C extends TBD<TReadJsonCallback<string>>, R extends undefined extends C ? TypedRecord<T> : void>(path: string, callback?: C): R;
|
|
105
87
|
/**
|
|
106
|
-
*
|
|
107
88
|
* @param {string} path
|
|
108
89
|
* @param {(dirent: Dirent) => void} handler
|
|
109
90
|
*/
|
|
@@ -125,45 +106,30 @@ export function compressScript2(scriptPath: string, comment?: string): void;
|
|
|
125
106
|
/**
|
|
126
107
|
* it is bundled in webpack.js, other code becomes unnecessary.(at webpack
|
|
127
108
|
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
109
|
+
* + 📝 using "exec" internally
|
|
110
|
+
* * 🆗️ can use pipe command
|
|
130
111
|
*
|
|
131
112
|
* @param {string} command
|
|
132
113
|
* @param {(result: string) => void} doneCallbackWithArgs gulp callback function.
|
|
133
114
|
* @param {string=} cwd 2025/2/1 current working directory
|
|
134
115
|
*/
|
|
135
116
|
export function execWithOutputResult(command: string, doneCallbackWithArgs: (result: string) => void, cwd?: string): any;
|
|
136
|
-
/**
|
|
137
|
-
* ### generate npm global package update script (windows command)
|
|
138
|
-
*
|
|
139
|
-
* ```js
|
|
140
|
-
* const utils = require("./utils");
|
|
141
|
-
* // ...
|
|
142
|
-
* // execute normally
|
|
143
|
-
* utils.genGlobalNpmUpdateScript("electron", "workbox-cli");
|
|
144
|
-
* // debug
|
|
145
|
-
* utils.genGlobalNpmUpdateScript("--debug", "electron", "workbox-cli");
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
148
|
-
* @param {string[]} excludes
|
|
149
|
-
*/
|
|
150
|
-
export function genGlobalNpmUpdateScript(...excludes: string[]): void;
|
|
151
117
|
/**
|
|
152
118
|
* use for gulp.dest(...)
|
|
153
119
|
*
|
|
154
120
|
* **useful when glob pattern can not be used (when path must be explicitly specified).**
|
|
155
121
|
*
|
|
156
122
|
* ```js
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
123
|
+
* gulp.src([
|
|
124
|
+
* "./src/app-config.ts",
|
|
125
|
+
* "./src/auth/{eve-sso,eve-sso-v2e}.php"
|
|
126
|
+
* ]).pipe(
|
|
127
|
+
* ...
|
|
128
|
+
* ).pipe(gulp.dest((vinyl) => {
|
|
129
|
+
* return convertRelativeDir(vinyl);
|
|
130
|
+
* })).on("end", () => {
|
|
131
|
+
* console.log("done");
|
|
132
|
+
* });
|
|
167
133
|
* ```
|
|
168
134
|
* @param {import("vinyl")} vinyl
|
|
169
135
|
* @param {string} dest default is "." -> node launched directory. (cwd?)
|
|
@@ -172,8 +138,8 @@ export function convertRelativeDir(vinyl: any, dest?: string): string;
|
|
|
172
138
|
/**
|
|
173
139
|
* ### command:
|
|
174
140
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
141
|
+
* + windows - chcp 65001 && clip
|
|
142
|
+
* + others - xclip
|
|
177
143
|
*
|
|
178
144
|
* @param {string} content the copy terget content as string.
|
|
179
145
|
* @param {string} [message] default: "text copied!"
|
|
@@ -189,6 +155,8 @@ export function copyText(content: string, message?: string, chcp65001?: boolean)
|
|
|
189
155
|
* @date 2019-4-26
|
|
190
156
|
*/
|
|
191
157
|
export function fireReplace(regex: RegExp, replacement: string | Function, paths: string[], async?: boolean): void;
|
|
192
|
-
|
|
193
158
|
export const CI: boolean;
|
|
194
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Nothing is logged in a CI environment.
|
|
161
|
+
*/
|
|
162
|
+
export const log: typeof console.log;
|