js-dev-tool 1.0.0
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/LICENSE +21 -0
- package/README.md +150 -0
- package/basic-types.d.ts +279 -0
- package/common/index.d.ts +43 -0
- package/common/index.js +101 -0
- package/extras/tiny-progress.d.ts +14 -0
- package/extras/tiny-progress.js +74 -0
- package/index.d.ts +27 -0
- package/index.js +15 -0
- package/lib/unzip.min.js +812 -0
- package/lib/zip.min.js +1036 -0
- package/lib/zlibjs.d.ts +34 -0
- package/package.json +51 -0
- package/progress/index.d.ts +92 -0
- package/progress/index.js +305 -0
- package/progress/progress-extras.js +90 -0
- package/progress/rnd-spinner.js +55 -0
- package/progress/spinners.d.ts +74 -0
- package/progress/spinners.json +805 -0
- package/progress/test.js +94 -0
- package/regex.d.ts +154 -0
- package/scripts/publish-version.json +3 -0
- package/scripts/unzip.js +30 -0
- package/scripts/zip.js +138 -0
- package/tool-lib/cjbm.js +239 -0
- package/tool-lib/cjmb-regex-latest.svg +366 -0
- package/tool-lib/cjmb-regex.svg +90 -0
- package/tool-lib/cmt-trick.js +125 -0
- package/tool-lib/ps.js +158 -0
- package/tool-lib/rws.js +181 -0
- package/tool-lib/tools.d.ts +245 -0
- package/tool-lib/zip-task.js +34 -0
- package/tools.d.ts +7 -0
- package/tools.js +450 -0
- package/tsconfig.json +25 -0
- package/utils.d.ts +194 -0
- package/utils.js +643 -0
package/lib/zlibjs.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
<one line to give the program's name and a brief idea of what it does.>
|
|
4
|
+
Copyright (C) 2018 jeffy-g hirotom1107@gmail.com
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Affero General Public License as
|
|
8
|
+
published by the Free Software Foundation, either version 3 of the
|
|
9
|
+
License, or (at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
19
|
+
*/
|
|
20
|
+
declare interface IUnzip {
|
|
21
|
+
new(data: Uint8Array): this;
|
|
22
|
+
getFilenames(): string[];
|
|
23
|
+
decompress(entry: string): Uint8Array;
|
|
24
|
+
getCommentAsString(): string;
|
|
25
|
+
getFileHeader(index: number): {
|
|
26
|
+
getCommentAsString(): string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare namespace Zlib {
|
|
30
|
+
const Unzip: IUnzip;
|
|
31
|
+
}
|
|
32
|
+
interface Window {
|
|
33
|
+
Zlib: typeof Zlib;
|
|
34
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "js-dev-tool",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"jstool": "./tools.js"
|
|
6
|
+
},
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"main": "./index.js",
|
|
9
|
+
"repository": "git@github.com:jeffy-g/js-dev-scripts.git",
|
|
10
|
+
"author": "jeffy-g <hirotom1107@gmail.com>",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"js",
|
|
14
|
+
"ts",
|
|
15
|
+
"javascript",
|
|
16
|
+
"typescript",
|
|
17
|
+
"command",
|
|
18
|
+
"command line",
|
|
19
|
+
"version"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"common",
|
|
23
|
+
"extras",
|
|
24
|
+
"lib",
|
|
25
|
+
"progress",
|
|
26
|
+
"scripts",
|
|
27
|
+
"tool-lib",
|
|
28
|
+
"index.js",
|
|
29
|
+
"tools.js",
|
|
30
|
+
"utils.js",
|
|
31
|
+
"tsconfig.json",
|
|
32
|
+
"!scripts/unzip.ts",
|
|
33
|
+
"!scripts/bin",
|
|
34
|
+
"!extras/npm",
|
|
35
|
+
"!/**/*.png",
|
|
36
|
+
"!tool.sh",
|
|
37
|
+
"*.d.ts"
|
|
38
|
+
],
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"archiver": "^4.0.1"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"colors.ts": "^1.0.20",
|
|
44
|
+
"fflate": "^0.8.2",
|
|
45
|
+
"mini-semaphore": "^1.4.4",
|
|
46
|
+
"replace": "^1.2.2",
|
|
47
|
+
"rm-cstyle-cmts": "^3.3.22",
|
|
48
|
+
"terser": "^5.44.1",
|
|
49
|
+
"tin-args": "^0.0.15"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2022 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
export type TProgressFormatOptions = {
|
|
9
|
+
fmt: string;
|
|
10
|
+
payload?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* create async progress
|
|
14
|
+
*
|
|
15
|
+
* @param {number} timeSpanMS controll rotator cycle speed (ms). (maybe about...
|
|
16
|
+
* @param {string[]} frames progress frame.
|
|
17
|
+
*/
|
|
18
|
+
export function createProgress(timeSpanMS: number, frames: string[]): (text: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {string[]} frames progress frame.
|
|
22
|
+
* @param {{ fmt: string, payload?: Record<string, string> }} [formatOpt]
|
|
23
|
+
* ```
|
|
24
|
+
* " {frameName} [{tick}]: {msg}" // etc
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function createProgressSync(frames: string[], formatOpt?: {
|
|
28
|
+
fmt: string;
|
|
29
|
+
payload?: Record<string, string>;
|
|
30
|
+
}): (msg: string, done?: boolean) => void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {string[]} frames progress frame.
|
|
35
|
+
* @param {TProgressFormatOptions} formatOpt
|
|
36
|
+
* ```
|
|
37
|
+
* " {frameName} [{tick}]: {msg}" // etc
|
|
38
|
+
* ```
|
|
39
|
+
* @param {() => string} callback
|
|
40
|
+
*/
|
|
41
|
+
export function createProgressObject(frames: string[], formatOpt: TProgressFormatOptions, callback: () => string): {
|
|
42
|
+
/**
|
|
43
|
+
* @param {string[]} [newFrames]
|
|
44
|
+
* @param {TProgressFormatOptions} [newOpt]
|
|
45
|
+
*/
|
|
46
|
+
updateOptions(newFrames?: string[], newOpt?: TProgressFormatOptions): void;
|
|
47
|
+
/**
|
|
48
|
+
* which means progress done
|
|
49
|
+
*/
|
|
50
|
+
deadline(): void;
|
|
51
|
+
/**
|
|
52
|
+
* adjust to next line
|
|
53
|
+
*/
|
|
54
|
+
newLine(): void;
|
|
55
|
+
/**
|
|
56
|
+
* change the fps rate
|
|
57
|
+
*
|
|
58
|
+
* @param {number} fps
|
|
59
|
+
*/
|
|
60
|
+
setFPS(fps: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* render progress as sync
|
|
63
|
+
*
|
|
64
|
+
* this method useful when `run` method did not smooth.
|
|
65
|
+
*/
|
|
66
|
+
renderSync(): void;
|
|
67
|
+
/**
|
|
68
|
+
* run timer (30fps)
|
|
69
|
+
*/
|
|
70
|
+
run(): void;
|
|
71
|
+
/**
|
|
72
|
+
* stop timer
|
|
73
|
+
*/
|
|
74
|
+
stop(): void;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
declare global {
|
|
78
|
+
type TWebpackProgressHandler = (percentage: number, message: string, ...args: string[]) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* see https://webpack.js.org/plugins/progress-plugin/
|
|
82
|
+
*
|
|
83
|
+
* @param {string} [logFilePath] can be undefined
|
|
84
|
+
* @param {boolean} [disableRenderLine]
|
|
85
|
+
*/
|
|
86
|
+
export function createWebpackProgressPluginHandler(logFilePath?: string, disableRenderLine?: boolean): (percentage: number, message: string, ...args: string[]) => void;
|
|
87
|
+
/**
|
|
88
|
+
* logger for browserify
|
|
89
|
+
*
|
|
90
|
+
* @param {string} logFilePath log output path name.
|
|
91
|
+
*/
|
|
92
|
+
export function createBrowserifyFileEventLogger(logFilePath: string): (counter: number, message: string, ...args: string[]) => void;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2022 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
const lib = require("../common");
|
|
9
|
+
const {
|
|
10
|
+
checkENV,
|
|
11
|
+
wppHandlerV5,
|
|
12
|
+
wppHandlerV4,
|
|
13
|
+
isWebpackV5later,
|
|
14
|
+
} = require("./progress-extras");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {string[]} frames progress frame.
|
|
19
|
+
* @param {{ fmt: string, payload?: Record<string, string> }} [formatOpt]
|
|
20
|
+
* ```
|
|
21
|
+
* " {frameName} [{tick}]: {msg}" // etc
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const createProgressSync = (frames, formatOpt) => {
|
|
25
|
+
const fsize = frames.length;
|
|
26
|
+
let index = 0;
|
|
27
|
+
/** @type {string} */
|
|
28
|
+
let fmt;
|
|
29
|
+
/** @type {Record<string, string>} */
|
|
30
|
+
let payload;
|
|
31
|
+
/** @type {string[]} */
|
|
32
|
+
let keys;
|
|
33
|
+
if (formatOpt) {
|
|
34
|
+
fmt = formatOpt.fmt;
|
|
35
|
+
// FIXME: 2023/10/27 - which use payload?
|
|
36
|
+
payload = formatOpt.payload || {};
|
|
37
|
+
keys = Object.keys(payload);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} tick
|
|
41
|
+
* @param {string} msg
|
|
42
|
+
*/
|
|
43
|
+
const formater = (tick, msg) => {
|
|
44
|
+
if (fmt) {
|
|
45
|
+
let content = fmt;
|
|
46
|
+
for (let i = 0, end = keys.length; i < end; ) {
|
|
47
|
+
const key = keys[i++];
|
|
48
|
+
content = content.replace("{" + key + "}", payload[key]);
|
|
49
|
+
}
|
|
50
|
+
return content.replace("{tick}", tick).replace("{msg}", msg);
|
|
51
|
+
}
|
|
52
|
+
return `[${tick}]: ${msg}`;
|
|
53
|
+
};
|
|
54
|
+
// let prev = "";
|
|
55
|
+
return /**@type {(msg: string, done?: boolean) => void}*/ (
|
|
56
|
+
msg,
|
|
57
|
+
done = false,
|
|
58
|
+
) => {
|
|
59
|
+
const tick = done ? "-done-" : frames[index++ % fsize];
|
|
60
|
+
const line = msg ? formater(tick, msg) : "";
|
|
61
|
+
lib.renderLine(line);
|
|
62
|
+
// if (line) {
|
|
63
|
+
// // if (prev !== line) {
|
|
64
|
+
// // renderLine(line);
|
|
65
|
+
// // prev = line;
|
|
66
|
+
// // }
|
|
67
|
+
// lib.renderLine(line);
|
|
68
|
+
// } else {
|
|
69
|
+
// lib.renderLine();
|
|
70
|
+
// }
|
|
71
|
+
// // !line && (renderLine(), 1) || renderLine(line);
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {{ fmt: string, payload?: Record<string, string> }} TProgressFormatOptions
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @param {string[]} frames progress frame.
|
|
81
|
+
* @param {TProgressFormatOptions} formatOpt
|
|
82
|
+
* ```
|
|
83
|
+
* " {frameName} [{tick}]: {msg}" // etc
|
|
84
|
+
* ```
|
|
85
|
+
* @param {() => string} callback
|
|
86
|
+
*/
|
|
87
|
+
const createProgressObject = (frames, formatOpt, callback) => {
|
|
88
|
+
let done = false;
|
|
89
|
+
const render = () => {
|
|
90
|
+
// DEVNOTE: 2025/01/24 - やはりこれがいいね...
|
|
91
|
+
process.nextTick(progress, callback(), done);
|
|
92
|
+
// progress(callback(), done);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
let progress = createProgressSync(frames, formatOpt);
|
|
96
|
+
/** @type {ReturnType<typeof setInterval> | undefined} */
|
|
97
|
+
let timer;
|
|
98
|
+
let ms = 33;
|
|
99
|
+
|
|
100
|
+
// progressObject
|
|
101
|
+
return {
|
|
102
|
+
/**
|
|
103
|
+
* @param {string[]} [newFrames]
|
|
104
|
+
* @param {TProgressFormatOptions} [newOpt]
|
|
105
|
+
*/
|
|
106
|
+
updateOptions(newFrames, newOpt) {
|
|
107
|
+
if (Array.isArray(newFrames) && typeof newFrames[0] === "string") {
|
|
108
|
+
frames = newFrames;
|
|
109
|
+
}
|
|
110
|
+
if (typeof newOpt === "object" && newOpt.fmt) {
|
|
111
|
+
formatOpt = newOpt;
|
|
112
|
+
}
|
|
113
|
+
done = false;
|
|
114
|
+
progress = createProgressSync(frames, formatOpt);
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* which means progress done
|
|
118
|
+
*/
|
|
119
|
+
deadline() {
|
|
120
|
+
(done = true), render();
|
|
121
|
+
},
|
|
122
|
+
/**
|
|
123
|
+
* adjust to next line
|
|
124
|
+
*/
|
|
125
|
+
newLine() {
|
|
126
|
+
console.log();
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* change the fps rate
|
|
130
|
+
*
|
|
131
|
+
* @param {number} fps
|
|
132
|
+
*/
|
|
133
|
+
setFPS(fps) {
|
|
134
|
+
ms = (1000 / fps) | 0;
|
|
135
|
+
if (timer) {
|
|
136
|
+
clearInterval(timer);
|
|
137
|
+
timer = setInterval(render, ms);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* render progress as sync
|
|
142
|
+
*
|
|
143
|
+
* this method useful when `run` method did not smooth.
|
|
144
|
+
*/
|
|
145
|
+
renderSync() {
|
|
146
|
+
render();
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* run timer (30fps)
|
|
150
|
+
*/
|
|
151
|
+
run() {
|
|
152
|
+
lib.cursor(false);
|
|
153
|
+
done = false;
|
|
154
|
+
if (timer) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
timer = setInterval(render, ms);
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* stop timer
|
|
161
|
+
*/
|
|
162
|
+
stop() {
|
|
163
|
+
done = true;
|
|
164
|
+
clearInterval(timer);
|
|
165
|
+
timer = void 0;
|
|
166
|
+
lib.cursor(true);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* create async progress
|
|
173
|
+
*
|
|
174
|
+
* @param {number} timeSpanMS controll rotator cycle speed (ms). (maybe about...
|
|
175
|
+
* @param {string[]} frames progress frame.
|
|
176
|
+
*/
|
|
177
|
+
const createProgress = (timeSpanMS, frames) => {
|
|
178
|
+
// let index = 0;
|
|
179
|
+
// return /**@type {(text: string) => void}*/ text => {
|
|
180
|
+
// const line = text === void 0? "" : `[${frames[index++ % frames.length]}]: ${text}`;
|
|
181
|
+
// !line && (progress(), 1) || process.nextTick(progress, line);
|
|
182
|
+
// }
|
|
183
|
+
const { performance } = require("perf_hooks");
|
|
184
|
+
|
|
185
|
+
let index = 0;
|
|
186
|
+
const fsize = frames.length;
|
|
187
|
+
let x = performance.now();
|
|
188
|
+
return /**@type {(text: string) => void}*/ (text) => {
|
|
189
|
+
const x2 = performance.now();
|
|
190
|
+
const line = text === void 0 ? "" : `[${frames[index % fsize]}]: ${text}`;
|
|
191
|
+
if (x2 - x > timeSpanMS) {
|
|
192
|
+
index++;
|
|
193
|
+
}
|
|
194
|
+
x = x2;
|
|
195
|
+
(!line && (lib.renderLine(), 1)) || process.nextTick(lib.renderLine, line);
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* see https://webpack.js.org/plugins/progress-plugin/
|
|
201
|
+
*
|
|
202
|
+
* @param {string} [logFilePath] can be undefined
|
|
203
|
+
* @param {boolean} [disableRenderLine]
|
|
204
|
+
* @version 2.0 detect webpack version(v4 or v5)
|
|
205
|
+
* @version 2.1 detect gitpod process
|
|
206
|
+
*/
|
|
207
|
+
function createWebpackProgressPluginHandler(
|
|
208
|
+
logFilePath,
|
|
209
|
+
disableRenderLine = false,
|
|
210
|
+
) {
|
|
211
|
+
const formatPercentage = (/** @type {number} */ pct) => {
|
|
212
|
+
return `processing ${(pct * 100).toFixed(4)}%`;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
let dotted = 0;
|
|
216
|
+
const renderDot = () => {
|
|
217
|
+
process.stderr.write(".");
|
|
218
|
+
// FIXME: first renderDot line length is not 100
|
|
219
|
+
dotted++;
|
|
220
|
+
if (dotted % 100 === 0) {
|
|
221
|
+
process.stderr.write("\n");
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
/** @type {((msg?: string) => void) | undefined} */
|
|
225
|
+
const renderer = process.env.CI ? renderDot : lib.renderLine;
|
|
226
|
+
|
|
227
|
+
// (percentage: number, msg: string, moduleProgress?: string, activeModules?: string, moduleName?: string) => void
|
|
228
|
+
/** @type {TWebpackProgressHandler} */
|
|
229
|
+
let wppHandler;
|
|
230
|
+
{
|
|
231
|
+
const shorttenProgress = (/** @type {number} */ pct) => {
|
|
232
|
+
renderer(formatPercentage(pct));
|
|
233
|
+
pct === 1 && (console.log(), (dotted = 0));
|
|
234
|
+
};
|
|
235
|
+
if (logFilePath !== void 0) {
|
|
236
|
+
const wppLogger = lib.createLogStreamAndResolvePath(logFilePath);
|
|
237
|
+
/** @type {((p: number) => void) | undefined} */
|
|
238
|
+
let writeCallback;
|
|
239
|
+
|
|
240
|
+
if (!disableRenderLine) {
|
|
241
|
+
writeCallback = shorttenProgress;
|
|
242
|
+
}
|
|
243
|
+
wppHandler = (percentage, message, ...args) => {
|
|
244
|
+
wppLogger.write(
|
|
245
|
+
`${formatPercentage(percentage)}, ${message}: ${args}\n`,
|
|
246
|
+
() => {
|
|
247
|
+
writeCallback && writeCallback(percentage);
|
|
248
|
+
},
|
|
249
|
+
);
|
|
250
|
+
percentage === 1 && wppLogger.end();
|
|
251
|
+
};
|
|
252
|
+
} else {
|
|
253
|
+
if (disableRenderLine) {
|
|
254
|
+
// DEVNOTE: 2022/02/16 ignore CI process
|
|
255
|
+
wppHandler = () => {};
|
|
256
|
+
} else {
|
|
257
|
+
const processType = checkENV();
|
|
258
|
+
if (processType === "ci") {
|
|
259
|
+
wppHandler = renderDot;
|
|
260
|
+
} else {
|
|
261
|
+
if (processType === "gitpod") {
|
|
262
|
+
wppHandler = shorttenProgress;
|
|
263
|
+
} else {
|
|
264
|
+
wppHandler = isWebpackV5later() ? wppHandlerV5 : wppHandlerV4;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return wppHandler;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* logger for browserify
|
|
276
|
+
*
|
|
277
|
+
* @param {string} logFilePath log output path name.
|
|
278
|
+
*/
|
|
279
|
+
function createBrowserifyFileEventLogger(logFilePath) {
|
|
280
|
+
const log = lib.createLogStreamAndResolvePath(logFilePath);
|
|
281
|
+
/**
|
|
282
|
+
* write browserify file event data.
|
|
283
|
+
*
|
|
284
|
+
* @type {(counter: number, message: string, ...args: string[]) => void} */
|
|
285
|
+
const logger = (counter, message, ...args) => {
|
|
286
|
+
if (counter === void 0) {
|
|
287
|
+
log.end();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const progressMessage = `resolve - ${counter}`;
|
|
291
|
+
log.write(`${progressMessage}, ${message}: ${args}\n`, () => {
|
|
292
|
+
lib.renderLine(progressMessage);
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
return logger;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
module.exports = {
|
|
299
|
+
createProgress,
|
|
300
|
+
createProgressSync,
|
|
301
|
+
createProgressObject,
|
|
302
|
+
|
|
303
|
+
createWebpackProgressPluginHandler,
|
|
304
|
+
createBrowserifyFileEventLogger,
|
|
305
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2022 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/// <reference path="./index.d.ts"/>
|
|
9
|
+
const lib = require("../common");
|
|
10
|
+
|
|
11
|
+
const checkENV = () => {
|
|
12
|
+
const env = process.env;
|
|
13
|
+
if (env.CI) return "ci";
|
|
14
|
+
for (const k of Object.keys(env)) {
|
|
15
|
+
if (k.startsWith("GITPOD_")) return "gitpod";
|
|
16
|
+
}
|
|
17
|
+
return "maybe-local";
|
|
18
|
+
};
|
|
19
|
+
/** @type {TWebpackProgressHandler} */
|
|
20
|
+
const wppHandlerV4 = ((renderer, cwd) => {
|
|
21
|
+
return (percentage, message, ...args) => {
|
|
22
|
+
// DEVNOTE: 2022/02/16 these values are webpack v4 (maybe
|
|
23
|
+
let [modules, actives, path = ""] = args;
|
|
24
|
+
// let [modules, actives, path = ""] = args;
|
|
25
|
+
if (message) {
|
|
26
|
+
const x = path.lastIndexOf(cwd) + 1;
|
|
27
|
+
x > 0 && (path = path.substring(x + cwd.length));
|
|
28
|
+
} else {
|
|
29
|
+
// which means all processing done
|
|
30
|
+
message = "- done -";
|
|
31
|
+
}
|
|
32
|
+
// TODO: 2022/2/16 webpack version 5 is different parameters
|
|
33
|
+
// so rewrite it.
|
|
34
|
+
renderer(
|
|
35
|
+
`processing ${(percentage * 100).toFixed(4)}% | ` +
|
|
36
|
+
message +
|
|
37
|
+
` [${modules}, ${actives}] ${path}`,
|
|
38
|
+
);
|
|
39
|
+
percentage === 1 && console.log();
|
|
40
|
+
};
|
|
41
|
+
})(lib.renderLine, process.cwd());
|
|
42
|
+
|
|
43
|
+
/** @type {TWebpackProgressHandler} */
|
|
44
|
+
const wppHandlerV5 = ((renderer, cwd) => {
|
|
45
|
+
return (percentage, message, ...args) => {
|
|
46
|
+
if (!message) {
|
|
47
|
+
message = "- done -";
|
|
48
|
+
}
|
|
49
|
+
// plugin name or source path
|
|
50
|
+
let str = args[1];
|
|
51
|
+
if (str) {
|
|
52
|
+
const x = str.lastIndexOf(cwd) + 1;
|
|
53
|
+
if (x > 0) {
|
|
54
|
+
args[1] = str.substring(x + cwd.length);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
str = args.shift() || "";
|
|
58
|
+
renderer(
|
|
59
|
+
`pct: ${(percentage * 100).toFixed(4)}%, process: [${message}]${str ? `, info: [${str}]` : ""}${args.length ? " - " : ""}${args.join(", ")}`,
|
|
60
|
+
);
|
|
61
|
+
// console.log(`pct: ${(percentage*100).toFixed(4)}%, process: [${message}]${ str? `, info: [${str}]`: "" }${ args.length? " -": "" }`, args.join(", "));
|
|
62
|
+
percentage === 1 && console.log();
|
|
63
|
+
};
|
|
64
|
+
})(lib.renderLine, process.cwd());
|
|
65
|
+
|
|
66
|
+
/** @type {boolean} */
|
|
67
|
+
let checkedCache;
|
|
68
|
+
/**
|
|
69
|
+
* @type {() => boolean}
|
|
70
|
+
*/
|
|
71
|
+
const isWebpackV5later = () => {
|
|
72
|
+
if (checkedCache === void 0) {
|
|
73
|
+
try {
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
const webpack = require("webpack");
|
|
76
|
+
checkedCache = +webpack.version[0] > 4;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
console.info(e);
|
|
79
|
+
checkedCache = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return checkedCache;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
module.exports = {
|
|
86
|
+
checkENV,
|
|
87
|
+
wppHandlerV4,
|
|
88
|
+
wppHandlerV5,
|
|
89
|
+
isWebpackV5later,
|
|
90
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2020 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @file random spinner
|
|
10
|
+
* @author jeffy-g <hirotom1107@gmail.com>
|
|
11
|
+
* @version 1.0
|
|
12
|
+
* @requires spinners.json
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @param {any[]} array
|
|
16
|
+
*/
|
|
17
|
+
const randomIndex = (array) => {
|
|
18
|
+
return Math.floor(Math.random() * array.length);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import("./spinners")} TSpinners
|
|
23
|
+
* @typedef {keyof TSpinners} TSpinnersName
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @type {TSpinners}
|
|
27
|
+
*/
|
|
28
|
+
const spinners = require("./spinners.json");
|
|
29
|
+
/**
|
|
30
|
+
* @type {TSpinnersName[]}
|
|
31
|
+
*/
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
const frameNames = Object.keys(spinners);
|
|
34
|
+
|
|
35
|
+
const MAX_PAD = frameNames.reduce((acc, sn) => {
|
|
36
|
+
return Math.max(acc, sn.length);
|
|
37
|
+
}, 0);
|
|
38
|
+
const MIN_PAD = frameNames.reduce((acc, sn) => {
|
|
39
|
+
return Math.max(acc, sn.length);
|
|
40
|
+
}, MAX_PAD);
|
|
41
|
+
|
|
42
|
+
const getRandomFrame = () => {
|
|
43
|
+
/** @type {TSpinnersName} */
|
|
44
|
+
const name = frameNames[randomIndex(frameNames)]; //.frames;
|
|
45
|
+
return {
|
|
46
|
+
name,
|
|
47
|
+
frames: spinners[name].frames,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
getRandomFrame,
|
|
53
|
+
MAX_PAD,
|
|
54
|
+
MIN_PAD,
|
|
55
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2022 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
type TSpinners = {
|
|
9
|
+
dots: Dots;
|
|
10
|
+
dots2: Dots;
|
|
11
|
+
dots3: Dots;
|
|
12
|
+
dots4: Dots;
|
|
13
|
+
dots5: Dots;
|
|
14
|
+
dots6: Dots;
|
|
15
|
+
dots7: Dots;
|
|
16
|
+
dots8: Dots;
|
|
17
|
+
dots9: Dots;
|
|
18
|
+
dots10: Dots;
|
|
19
|
+
dots11: Dots;
|
|
20
|
+
dots12: Dots;
|
|
21
|
+
line: Dots;
|
|
22
|
+
line2: Dots;
|
|
23
|
+
pipe: Dots;
|
|
24
|
+
simpleDots: Dots;
|
|
25
|
+
simpleDotsScrolling: Dots;
|
|
26
|
+
star: Dots;
|
|
27
|
+
star2: Dots;
|
|
28
|
+
flip: Dots;
|
|
29
|
+
hamburger: Dots;
|
|
30
|
+
growVertical: Dots;
|
|
31
|
+
growHorizontal: Dots;
|
|
32
|
+
balloon: Dots;
|
|
33
|
+
balloon2: Dots;
|
|
34
|
+
noise: Dots;
|
|
35
|
+
bounce: Dots;
|
|
36
|
+
boxBounce: Dots;
|
|
37
|
+
boxBounce2: Dots;
|
|
38
|
+
triangle: Dots;
|
|
39
|
+
arc: Dots;
|
|
40
|
+
circle: Dots;
|
|
41
|
+
squareCorners: Dots;
|
|
42
|
+
circleQuarters: Dots;
|
|
43
|
+
circleHalves: Dots;
|
|
44
|
+
squish: Dots;
|
|
45
|
+
toggle2: Dots;
|
|
46
|
+
toggle3: Dots;
|
|
47
|
+
toggle4: Dots;
|
|
48
|
+
toggle5: Dots;
|
|
49
|
+
toggle7: Dots;
|
|
50
|
+
toggle8: Dots;
|
|
51
|
+
toggle9: Dots;
|
|
52
|
+
toggle10: Dots;
|
|
53
|
+
toggle12: Dots;
|
|
54
|
+
toggle13: Dots;
|
|
55
|
+
arrow: Dots;
|
|
56
|
+
arrow2: Dots;
|
|
57
|
+
arrow3: Dots;
|
|
58
|
+
bouncingBar: Dots;
|
|
59
|
+
bouncingBall: Dots;
|
|
60
|
+
pong: Dots;
|
|
61
|
+
airplain: Dots;
|
|
62
|
+
shark: Dots;
|
|
63
|
+
dqpb: Dots;
|
|
64
|
+
grenade: Dots;
|
|
65
|
+
point: Dots;
|
|
66
|
+
layer: Dots;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface Dots {
|
|
70
|
+
interval: number;
|
|
71
|
+
frames: string[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export = TSpinners;
|