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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2023 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/// <reference path="../regex.d.ts"/>
|
|
9
|
+
|
|
10
|
+
declare const ImportExportDetectRegex = `(?<!\\/\\/+\\s*)(?:import|export)\\s*(?:"(?!https?:)(?=[.\\/]+)\
|
|
11
|
+
(?:(?<globalName>(?:[.\\/]+)?[^"]+?)(?:\\.(?<globalExt>(?:c|m)?jsx?))?)"|\
|
|
12
|
+
\\(\\s*"(?!https?:)(?=[.\\/]+)(?<dynamicName>(?:[.\\/]+)?[^"]+?)(?:\\.(?<dynamicExt>(?:c|m)?jsx?))?"\\s*\\)|\
|
|
13
|
+
(?:(?<clause>.+?|(?:\\w+\\s*,)?\\s*\\{[^}]+\\})\\s*from)\\s*"(?!https?:)(?=[.\\/]+)(?:(?<moduleName>(?:[.\\/]+)?[^"]+?)\
|
|
14
|
+
(?:\\.(?<moduleExt>(?:c|m)?jsx?))?)")(?=\\s*;)?`;
|
|
15
|
+
declare const reOk: ReturnType<typeof XRegex.createRegExp<typeof ImportExportDetectRegex>>;
|
|
16
|
+
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
|
+
/**
|
|
24
|
+
* @date 2023-10-25
|
|
25
|
+
*/
|
|
26
|
+
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
|
+
type TRegexImportExportDetectorReplacer = function(
|
|
41
|
+
string, string, string, string, string, string, string, string, number, string,
|
|
42
|
+
TRegexDetectRet
|
|
43
|
+
): string;
|
|
44
|
+
|
|
45
|
+
declare function processSources(
|
|
46
|
+
taskName: string,
|
|
47
|
+
process: (source: string) => Promise<string> | string,
|
|
48
|
+
options?: TProcessSourcesOpt
|
|
49
|
+
): void;
|
|
50
|
+
|
|
51
|
+
/** regex replace sig */
|
|
52
|
+
declare type TStringReplacer = (matchs: string, ...args: any[]) => string;
|
|
53
|
+
|
|
54
|
+
/** use `(R)ecord(W)ebpack(S)ize` */
|
|
55
|
+
declare type TRwsTags = "webpack" | "umd" | "bin";
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
declare var params: ReturnType<typeof import("tin-args")<TToolArgs>>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @date 2025/2/18 0:46:03
|
|
62
|
+
*/
|
|
63
|
+
declare function getBasePaths(): string[] | undefined;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* + tool option `verb`
|
|
67
|
+
*/
|
|
68
|
+
declare var verbose: TBD<true>;
|
|
69
|
+
/**
|
|
70
|
+
* tools command arg types
|
|
71
|
+
*/
|
|
72
|
+
declare type TToolArgs = {
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* parameter is used to specify the root directory of the source code scan.
|
|
76
|
+
*
|
|
77
|
+
* This is used in the `processSources` function to determine the base path for scanning.
|
|
78
|
+
*
|
|
79
|
+
* @since 1.4.35
|
|
80
|
+
*/
|
|
81
|
+
root?: string;
|
|
82
|
+
/**
|
|
83
|
+
* @since 1.4.28
|
|
84
|
+
*/
|
|
85
|
+
shell?: string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* print jstool version
|
|
89
|
+
* @date 2025/1/23 11:37:58
|
|
90
|
+
*/
|
|
91
|
+
v?: true;
|
|
92
|
+
|
|
93
|
+
/** task command shortten name */
|
|
94
|
+
cmd: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* processSources
|
|
98
|
+
* cjbm, minify, rmc
|
|
99
|
+
*/
|
|
100
|
+
basePath: string | string[];
|
|
101
|
+
/** processSources, cmtTrick, stripSome, rmc */
|
|
102
|
+
targets: string[];
|
|
103
|
+
/** minify, rmc */
|
|
104
|
+
suffix: string;
|
|
105
|
+
|
|
106
|
+
// version
|
|
107
|
+
major?: true;
|
|
108
|
+
minor?: true;
|
|
109
|
+
patch?: true;
|
|
110
|
+
extras: string[];
|
|
111
|
+
|
|
112
|
+
/** rws, backup */
|
|
113
|
+
dest: string;
|
|
114
|
+
/** backup */
|
|
115
|
+
projectName: string;
|
|
116
|
+
|
|
117
|
+
/** for `cjbm` replace extension. default is `js` */
|
|
118
|
+
ext: string;
|
|
119
|
+
|
|
120
|
+
/** shared, minify, rmc */
|
|
121
|
+
test: RegExp;
|
|
122
|
+
|
|
123
|
+
/** stripWebpack, stripSome */
|
|
124
|
+
regex: RegExp;
|
|
125
|
+
|
|
126
|
+
/** rmc */
|
|
127
|
+
rmc4ts: boolean;
|
|
128
|
+
|
|
129
|
+
// rws
|
|
130
|
+
/**
|
|
131
|
+
* webpacked source path.
|
|
132
|
+
* @default `./dist/webpack/index.js`
|
|
133
|
+
*/
|
|
134
|
+
webpack: string;
|
|
135
|
+
/**
|
|
136
|
+
* webpacked source path.
|
|
137
|
+
* @default `./dist/umd/index.js`
|
|
138
|
+
*/
|
|
139
|
+
umd: string;
|
|
140
|
+
/**
|
|
141
|
+
* webpacked source path.
|
|
142
|
+
* @default `./dist/bin/index.js`
|
|
143
|
+
*/
|
|
144
|
+
bin: string;
|
|
145
|
+
/**
|
|
146
|
+
* if need other name then use this option.
|
|
147
|
+
* ```js
|
|
148
|
+
* `./dist/${tag}/index.js`
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
"rws-tags": `${string}:${string}` | `${string}:${string}`[];
|
|
152
|
+
|
|
153
|
+
/** zip comment */
|
|
154
|
+
comment: string;
|
|
155
|
+
/** specify target package.json(s) [version] */
|
|
156
|
+
pkgJsons: string[];
|
|
157
|
+
|
|
158
|
+
/** want help? form - "-help <cmd name>" */
|
|
159
|
+
help: string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* for stripSome
|
|
163
|
+
* @date 2024-01-05
|
|
164
|
+
*/
|
|
165
|
+
after: string;
|
|
166
|
+
/** want print written file name? */
|
|
167
|
+
verb: true;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @date 2025/4/6 17:09:40
|
|
171
|
+
*/
|
|
172
|
+
debug?: true;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// /**
|
|
176
|
+
// * @typedef {
|
|
177
|
+
// (path: string, handler: (dirent: import("fs").Dirent) => void) => void
|
|
178
|
+
// } TWalkDirSyncFunction
|
|
179
|
+
// */
|
|
180
|
+
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
|
+
declare type TProcessSourcesOpt = {
|
|
191
|
+
root?: string;
|
|
192
|
+
base?: string;
|
|
193
|
+
/** Array of search directory paths, overriding "base" */
|
|
194
|
+
bases?: string[];
|
|
195
|
+
/** @default `/\.js$/` */
|
|
196
|
+
test?: RegExp;
|
|
197
|
+
targets?: string[];
|
|
198
|
+
suffix?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// /**
|
|
202
|
+
// * @typedef {{
|
|
203
|
+
// * fn: () => void;
|
|
204
|
+
// * help: string;
|
|
205
|
+
// * taskName: string;
|
|
206
|
+
// * }} TJSToolEntry
|
|
207
|
+
// */
|
|
208
|
+
declare type TJSToolEntry = {
|
|
209
|
+
fn: (mode?: string) => void;
|
|
210
|
+
help: string;
|
|
211
|
+
taskName: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* version command type
|
|
216
|
+
*/
|
|
217
|
+
declare type TVersionString = `${number}.${number}.${number}`;
|
|
218
|
+
// unused
|
|
219
|
+
// type TNVersion = [number, number, number];
|
|
220
|
+
declare type TVersionRecords = Record<TVersionString, Partial<Record<TRwsTags, number>>>;
|
|
221
|
+
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
|
+
}
|
|
244
|
+
|
|
245
|
+
export = {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
3
|
+
Copyright (C) 2023 jeffy-g <hirotom1107@gmail.com>
|
|
4
|
+
Released under the MIT license
|
|
5
|
+
https://opensource.org/licenses/mit-license.php
|
|
6
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
+
*/
|
|
8
|
+
/// <reference path="./tools.d.ts"/>
|
|
9
|
+
// @ts-check
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @file zip compression task
|
|
13
|
+
*/
|
|
14
|
+
module.exports =
|
|
15
|
+
/**
|
|
16
|
+
* @param {import("../utils")} utils
|
|
17
|
+
* @returns {TJSToolEntry}
|
|
18
|
+
*/
|
|
19
|
+
(utils) => {
|
|
20
|
+
return {
|
|
21
|
+
taskName: "zip",
|
|
22
|
+
fn() {
|
|
23
|
+
const comment = params.comment;
|
|
24
|
+
const paths = params.args;
|
|
25
|
+
if (Array.isArray(paths)) {
|
|
26
|
+
for (let i = 0, end = paths.length; i < end; ) {
|
|
27
|
+
const path = paths[i++];
|
|
28
|
+
utils.compressScript(path, comment);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
help: `jstool -cmd zip [-comment "the comment"] lib/webpack.js lib/type-ids.js`,
|
|
33
|
+
};
|
|
34
|
+
};
|