@rzl-zone/build-tools 0.0.11 → 0.0.12
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/.references/index.d.cts +1 -1
- package/dist/.references/index.d.ts +1 -1
- package/dist/bundler/rolldown.cjs +4 -4
- package/dist/bundler/rolldown.cjs.map +1 -1
- package/dist/bundler/rolldown.d.cts +2 -2
- package/dist/bundler/rolldown.d.ts +2 -2
- package/dist/bundler/rolldown.js +1 -1
- package/dist/bundler/rolldown.js.map +1 -1
- package/dist/bundler/tsdown.cjs +9 -9
- package/dist/bundler/tsdown.cjs.map +1 -1
- package/dist/bundler/tsdown.d.cts +2 -2
- package/dist/bundler/tsdown.d.ts +2 -2
- package/dist/bundler/tsdown.js +3 -3
- package/dist/bundler/tsdown.js.map +1 -1
- package/dist/bundler/utils.cjs +2 -2
- package/dist/bundler/utils.cjs.map +1 -1
- package/dist/bundler/utils.d.cts +2 -2
- package/dist/bundler/utils.d.ts +2 -2
- package/dist/bundler/utils.js +2 -2
- package/dist/bundler/utils.js.map +1 -1
- package/dist/client-B-L0njjX.js +75 -0
- package/dist/client-B-L0njjX.js.map +1 -0
- package/dist/client-BxJj_VrQ.cjs +81 -0
- package/dist/client-BxJj_VrQ.cjs.map +1 -0
- package/dist/commander-kit/index.cjs +84 -65
- package/dist/commander-kit/index.cjs.map +1 -1
- package/dist/commander-kit/index.d.cts +3 -3
- package/dist/commander-kit/index.d.ts +3 -3
- package/dist/commander-kit/index.js +24 -5
- package/dist/commander-kit/index.js.map +1 -1
- package/dist/{extra-BleSbKJp.d.ts → extra-CNDyFVA8.d.ts} +2 -2
- package/dist/{extra-C8r3KWjP.d.cts → extra-CtuOwfZ4.d.cts} +2 -2
- package/dist/{fast-globe-options-DnV58KJc.d.ts → fast-globe-options-Dj630IVV.d.ts} +3 -3
- package/dist/{fast-globe-options-D7S2fQZZ.d.cts → fast-globe-options-NcQT6Fg5.d.cts} +3 -3
- package/dist/{helper-C0AShk-j.js → formatter-Bd8fVs2h.js} +88 -3
- package/dist/formatter-Bd8fVs2h.js.map +1 -0
- package/dist/{helper-DNj9Sj4w.cjs → formatter-DEp7VUev.cjs} +142 -14
- package/dist/formatter-DEp7VUev.cjs.map +1 -0
- package/dist/{identity-CcYkvy9q.js → identity-BaFHc-2R.js} +5 -6
- package/dist/{identity-CcYkvy9q.js.map → identity-BaFHc-2R.js.map} +1 -1
- package/dist/{identity-Crq3bzhv.cjs → identity-C9ff_g77.cjs} +14 -15
- package/dist/{identity-Crq3bzhv.cjs.map → identity-C9ff_g77.cjs.map} +1 -1
- package/dist/{index-DlH2PDPD.d.cts → index-BXqEWtZV.d.cts} +2 -2
- package/dist/{index-BdtMQyzF.d.cts → index-DgaO182z.d.cts} +2 -2
- package/dist/{index-CwHGSras.d.ts → index-qpwsLgqK.d.ts} +2 -2
- package/dist/{index-NLQcJJFO.d.ts → index-uMbOxPvL.d.ts} +2 -2
- package/dist/index.cjs +221 -274
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -58
- package/dist/index.js.map +1 -1
- package/dist/{package-banner-DkNDAjMK.js → package-banner-Bk5L__8h.js} +4 -5
- package/dist/{package-banner-DkNDAjMK.js.map → package-banner-Bk5L__8h.js.map} +1 -1
- package/dist/package-banner-Pjznq5SP.cjs +59 -0
- package/dist/{package-banner-BoS7Lbi9.cjs.map → package-banner-Pjznq5SP.cjs.map} +1 -1
- package/dist/server-BsqxhpCl.js +198 -0
- package/dist/server-BsqxhpCl.js.map +1 -0
- package/dist/server-CyO1Pxp8.cjs +255 -0
- package/dist/server-CyO1Pxp8.cjs.map +1 -0
- package/dist/utils/client.cjs +12 -11
- package/dist/utils/client.d.cts +1 -1
- package/dist/utils/client.d.ts +1 -1
- package/dist/utils/client.js +3 -2
- package/dist/utils/server.cjs +5 -2
- package/dist/utils/server.d.cts +433 -3
- package/dist/utils/server.d.ts +433 -3
- package/dist/utils/server.js +3 -3
- package/package.json +6 -4
- package/dist/client-CuivP4z0.cjs +0 -221
- package/dist/client-CuivP4z0.cjs.map +0 -1
- package/dist/client-DzeqTq6Y.js +0 -160
- package/dist/client-DzeqTq6Y.js.map +0 -1
- package/dist/helper-C0AShk-j.js.map +0 -1
- package/dist/helper-DNj9Sj4w.cjs.map +0 -1
- package/dist/package-banner-BoS7Lbi9.cjs +0 -60
- package/dist/server-CvLC0e2m.cjs +0 -181
- package/dist/server-CvLC0e2m.cjs.map +0 -1
- package/dist/server-Dc93jndm.js +0 -142
- package/dist/server-Dc93jndm.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.12`
|
|
6
6
|
* Author: `Rizalvin Dwiky <rizalvindwiky1998@gmail.com>`
|
|
7
7
|
* Repository: `https://github.com/rzl-zone/rzl-zone/tree/main/packages/build-tools`
|
|
8
8
|
* ========================================================================
|
|
@@ -10,23 +10,22 @@
|
|
|
10
10
|
|
|
11
11
|
"use strict";
|
|
12
12
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
13
|
-
const
|
|
14
|
-
const require_server = require('./server-
|
|
15
|
-
const require_identity = require('./identity-
|
|
16
|
-
const
|
|
17
|
-
const require_package_banner = require('./package-banner-BoS7Lbi9.cjs');
|
|
13
|
+
const require_formatter = require('./formatter-DEp7VUev.cjs');
|
|
14
|
+
const require_server = require('./server-CyO1Pxp8.cjs');
|
|
15
|
+
const require_identity = require('./identity-C9ff_g77.cjs');
|
|
16
|
+
const require_package_banner = require('./package-banner-Pjznq5SP.cjs');
|
|
18
17
|
require("@rzl-zone/node-only");
|
|
19
18
|
let _babel_types = require("@babel/types");
|
|
20
|
-
_babel_types =
|
|
19
|
+
_babel_types = require_formatter.__toESM(_babel_types, 1);
|
|
21
20
|
let _babel_parser = require("@babel/parser");
|
|
22
21
|
let _babel_traverse = require("@babel/traverse");
|
|
23
|
-
_babel_traverse =
|
|
22
|
+
_babel_traverse = require_formatter.__toESM(_babel_traverse, 1);
|
|
24
23
|
let node_path = require("node:path");
|
|
25
|
-
node_path =
|
|
24
|
+
node_path = require_formatter.__toESM(node_path, 1);
|
|
26
25
|
let shell_quote = require("shell-quote");
|
|
27
26
|
let node_child_process = require("node:child_process");
|
|
28
27
|
let acorn = require("acorn");
|
|
29
|
-
acorn =
|
|
28
|
+
acorn = require_formatter.__toESM(acorn, 1);
|
|
30
29
|
function isLogLevel(value) {
|
|
31
30
|
return typeof value === "string" && value in LOG_LEVEL_PRIORITY;
|
|
32
31
|
}
|
|
@@ -46,7 +45,7 @@ function resolveLogVerbosity(options, fallback = DEFAULT_LOG_LEVEL) {
|
|
|
46
45
|
function canLog(current, target, fallbackIfInvalid = DEFAULT_LOG_LEVEL) {
|
|
47
46
|
const fallbackLog = isLogLevel(fallbackIfInvalid) ? fallbackIfInvalid : DEFAULT_LOG_LEVEL;
|
|
48
47
|
const resolvedCurrent = isLogLevel(current) ? current : fallbackLog;
|
|
49
|
-
return (
|
|
48
|
+
return (require_formatter.isString(target) ? [target] : require_formatter.isArray(target) ? target : [fallbackLog]).some((level) => LOG_LEVEL_PRIORITY[resolvedCurrent] >= LOG_LEVEL_PRIORITY[level]);
|
|
50
49
|
}
|
|
51
50
|
const DEFAULT_CLEAN_PATTERN_POLICY = {
|
|
52
51
|
filesOnly: true,
|
|
@@ -83,14 +82,14 @@ const NON_COMMENTABLE_FILE_RE = /(?:^|[\\/])(?:package-lock\.json|composer\.lock
|
|
|
83
82
|
function hasExecutableCode(content) {
|
|
84
83
|
const { body } = extractAndHoistBanner(content.trim());
|
|
85
84
|
const { rest } = extractDirectives(body);
|
|
86
|
-
return
|
|
85
|
+
return require_formatter.isNonEmptyString(rest);
|
|
87
86
|
}
|
|
88
87
|
const defaultCommentOptions = {
|
|
89
88
|
removeRegion: true,
|
|
90
89
|
removeSourceMap: false
|
|
91
90
|
};
|
|
92
91
|
const isTargetComment = (line, options = defaultCommentOptions) => {
|
|
93
|
-
if (!
|
|
92
|
+
if (!require_formatter.isNonEmptyString(line)) return false;
|
|
94
93
|
if (SOURCE_PATH_RE.test(line)) return true;
|
|
95
94
|
if (ESLINT_RE.test(line)) return true;
|
|
96
95
|
if (options.removeRegion && REGION_RE.test(line)) return true;
|
|
@@ -193,58 +192,6 @@ function stripUseStrict(content, { trimStart = true, trimEnd = false } = {}) {
|
|
|
193
192
|
if (trimEnd) result.trimEnd();
|
|
194
193
|
return result;
|
|
195
194
|
}
|
|
196
|
-
const sourceOf = (value, defaultValue) => {
|
|
197
|
-
return Object.is(value, defaultValue) ? "default" : "overridden";
|
|
198
|
-
};
|
|
199
|
-
const BUILD_LOGGER = {
|
|
200
|
-
SOURCE_OF: sourceOf,
|
|
201
|
-
OPTIONS(label, value, source, isRequired) {
|
|
202
|
-
const sourceLabel = !isRequired && source ? source === "default" ? require_client.picocolors.blueBright(` (${source})`) : require_client.picocolors.yellowBright(` (${source})`) : "";
|
|
203
|
-
console.log(require_client.picocolors.dim(" - ") + require_helper.normalizeSpaces(require_client.picocolors.bold(label || "`⚠️ Label Unset!!!`") + require_client.picocolors.dim(": ") + require_client.formatOptionValue(value) + require_client.picocolors.italic(sourceLabel)));
|
|
204
|
-
},
|
|
205
|
-
SECTION(title, options = {}) {
|
|
206
|
-
const { icon = require_server.ICONS.config, indent = "" } = options;
|
|
207
|
-
console.log(require_client.picocolors.bold(`${indent}${require_client.picocolors.whiteBright(icon)} ${require_client.picocolors.underline(require_client.picocolors.cyanBright(title || "`⚠️ Unset Title!!!`"))}:`));
|
|
208
|
-
},
|
|
209
|
-
NEW_LINE(value = "") {
|
|
210
|
-
return console.log(value);
|
|
211
|
-
},
|
|
212
|
-
ON_STARTING: (options) => {
|
|
213
|
-
const { actionName, textDirectAction = "to" } = options;
|
|
214
|
-
console.log(require_client.picocolors.bold(`${require_client.picocolors.whiteBright(require_server.ICONS.start)} ${require_client.picocolors.cyanBright("Starting")} ${require_helper.normalizeSpaces(`${textDirectAction} ${require_client.picocolors.underline(require_client.picocolors.blueBright(actionName))}`)}.`));
|
|
215
|
-
},
|
|
216
|
-
ON_FINISH: (options) => {
|
|
217
|
-
const { actionName, count, typeCount = "file", progress, textSuccess = "Success" } = options;
|
|
218
|
-
console.log(require_client.picocolors.bold(`${require_client.picocolors.greenBright(require_server.ICONS.success)} ${require_client.picocolors.greenBright(textSuccess)} ${require_helper.normalizeSpaces(`${require_client.picocolors.underline(require_client.picocolors.blueBright(actionName))} (${require_client.picocolors.yellowBright(`${require_helper.isNonEmptyString(progress) ? progress : count} ${typeCount}${count > 1 ? "(s)" : ""}`)}`)}).`));
|
|
219
|
-
},
|
|
220
|
-
ON_SKIPPING: (options) => {
|
|
221
|
-
const { actionName, reasonEndText, reasonSkipAction = "nothing left", reasonTitle = "because", reasonType = "files", textDirectAction = "to" } = options;
|
|
222
|
-
console.log(require_client.picocolors.bold(`${require_client.picocolors.yellowBright(require_server.ICONS.warn)} ${require_client.picocolors.yellowBright("Skipping")} ${require_helper.normalizeSpaces(`${require_client.picocolors.underline(require_client.picocolors.blueBright(actionName))} ${require_client.picocolors.white(reasonTitle)} ${require_client.picocolors.redBright(reasonSkipAction)} ${reasonType} ${textDirectAction} ${require_client.picocolors.redBright(reasonEndText)}`)}.`));
|
|
223
|
-
},
|
|
224
|
-
ON_ERROR: (options) => {
|
|
225
|
-
const { actionName, textDirectAction = "to", error } = options;
|
|
226
|
-
const errorMsg = require_helper.isError(error) ? error.message : "Something went wrong";
|
|
227
|
-
console.error(require_client.picocolors.bold(`${require_client.picocolors.redBright(require_server.ICONS.error)} ${require_client.picocolors.redBright("Error")} ${require_helper.normalizeSpaces(`${textDirectAction} ${require_client.picocolors.underline(require_client.picocolors.blueBright(actionName))},`)} ${require_client.joinLines("because: ", "", ` ${require_client.picocolors.bold(require_client.picocolors.red(require_server.ICONS.arrowRight))} ${require_client.picocolors.inverse(require_client.picocolors.red(require_helper.normalizeSpaces(errorMsg)))}`)}`));
|
|
228
|
-
},
|
|
229
|
-
ON_PROCESS: (options) => {
|
|
230
|
-
const { actionName, count, nameDirect, textDirectFolder = "in" } = options;
|
|
231
|
-
console.log(`${require_client.picocolors.bold(" " + require_client.picocolors.whiteBright(require_server.ICONS.bullet))} ${require_client.picocolors.italic(`${require_client.picocolors.white(count + ".")} ${require_helper.normalizeSpaces(`${require_client.picocolors.white(actionName)} ${require_client.picocolors.magentaBright(textDirectFolder)} ${require_client.picocolors.bold(require_client.picocolors.underline(require_client.picocolors.blue(nameDirect)))}.`)}`)}`);
|
|
232
|
-
},
|
|
233
|
-
ON_PROCESS_COPY: (options) => {
|
|
234
|
-
const { actionName, count, copyTo, copyFrom, textFrom = "from", textArrow = "➔" } = options;
|
|
235
|
-
console.log(`${require_client.picocolors.bold(" " + require_client.picocolors.whiteBright(require_server.ICONS.bullet))} ${require_client.picocolors.italic(`${require_client.picocolors.white(count + ".")} ${require_helper.normalizeSpaces(`${require_client.picocolors.white(actionName)} ${require_client.picocolors.yellow(textFrom)} '${require_client.picocolors.bold(require_client.picocolors.underline(require_client.picocolors.cyanBright(copyFrom)))}' ${require_client.picocolors.bold(require_client.picocolors.gray(textArrow))} '${require_client.picocolors.bold(require_client.picocolors.underline(require_client.picocolors.cyanBright(copyTo)))}'.`)}`)}`);
|
|
236
|
-
},
|
|
237
|
-
ON_PROCESS_COPY_ERROR: (options) => {
|
|
238
|
-
const { actionName, count, errorReason, copyFrom, index, indexKey, textFrom = "from", textReason = "because" } = options;
|
|
239
|
-
const errorReasonText = require_helper.isError(errorReason) ? errorReason.message : String(errorReason);
|
|
240
|
-
const atIndexText = require_helper.isNumber(index) ? require_client.picocolors.blueBright(` (at${require_helper.isNonEmptyString(indexKey) ? ` '${indexKey}' ` : " "}index: ${require_client.picocolors.magentaBright(index)}) `) : " ";
|
|
241
|
-
console.log(`${require_client.picocolors.bold(" " + require_client.picocolors.whiteBright(require_server.ICONS.bullet))} ${require_client.picocolors.italic(`${require_client.picocolors.white(count + ".")} ${require_helper.normalizeSpaces(`${require_client.picocolors.redBright(actionName)} ${require_client.picocolors.yellow(textFrom)} '${require_client.picocolors.bold(require_client.picocolors.underline(require_client.picocolors.cyanBright(copyFrom)))}'${atIndexText}${require_client.picocolors.bold(require_client.picocolors.gray(textReason))} ${require_client.picocolors.redBright(errorReasonText)}.`)}`)}`);
|
|
242
|
-
},
|
|
243
|
-
ON_PROCESS_REFERENCING: (options) => {
|
|
244
|
-
const { actionName, count, referenceTo, referenceFrom, textFrom = "from", textArrow = "➔" } = options;
|
|
245
|
-
console.log(`${require_client.picocolors.bold(" " + require_client.picocolors.whiteBright(require_server.ICONS.bullet))} ${require_client.picocolors.italic(`${require_client.picocolors.white(count + ".")} ${require_helper.normalizeSpaces(`${require_client.picocolors.white(actionName)} ${require_client.picocolors.magentaBright(textFrom)} ${require_client.picocolors.bold(require_client.picocolors.underline(require_client.picocolors.cyanBright(referenceFrom)))} ${require_client.picocolors.bold(require_client.picocolors.gray(textArrow))} ${require_client.picocolors.bold(require_client.picocolors.underline(require_client.picocolors.blueBright(referenceTo)))}.`)}`)}`);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
195
|
function stripLineArtifacts(line, options) {
|
|
249
196
|
let out = line.replace(/^[ \t]*\/\/\s*(?:\.\.\/|\.\/)*[^ \n]*?(?:src|node_modules)\/[^\n]*\n?/gm, "").replace(/\/\/\s*eslint[^\n]*/g, "");
|
|
250
197
|
if (options.removeSourceMap) out = out.replace(/^[ \t]*\/\/[#@]\s*sourceMappingURL\s*=\s*\S+/gm, "");
|
|
@@ -278,27 +225,27 @@ function cleanBuildArtifactsCore(lines, options) {
|
|
|
278
225
|
}).map((line) => stripLineArtifacts(line, options));
|
|
279
226
|
}
|
|
280
227
|
async function runCleanBuildArtifacts({ patterns: pattern, options, fileTest, logAction }) {
|
|
281
|
-
if (!
|
|
228
|
+
if (!require_formatter.isPlainObject(options)) options = DEFAULT_CLEAN_OPTION;
|
|
282
229
|
else options = {
|
|
283
230
|
...DEFAULT_CLEAN_OPTION,
|
|
284
231
|
...options
|
|
285
232
|
};
|
|
286
233
|
const { patternOptions, logLevel: loggerLevel, removeAdjacentEmptyLines, removeRegion, removeSourceMap } = options;
|
|
287
234
|
try {
|
|
288
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
289
|
-
const patterns = [...
|
|
235
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(logAction.title, ""));
|
|
236
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
290
237
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_CLEAN_PATTERN_POLICY);
|
|
291
238
|
const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
292
239
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
293
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
294
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
295
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_CLEAN_OPTION.patternOptions));
|
|
296
|
-
BUILD_LOGGER.OPTIONS("options.removeSourceMap", removeSourceMap, BUILD_LOGGER.SOURCE_OF(removeSourceMap, DEFAULT_CLEAN_OPTION.removeSourceMap));
|
|
297
|
-
BUILD_LOGGER.OPTIONS("options.removeRegion", removeRegion, BUILD_LOGGER.SOURCE_OF(removeRegion, DEFAULT_CLEAN_OPTION.removeRegion));
|
|
298
|
-
BUILD_LOGGER.OPTIONS("options.removeAdjacentEmptyLines", removeAdjacentEmptyLines, BUILD_LOGGER.SOURCE_OF(removeAdjacentEmptyLines, DEFAULT_CLEAN_OPTION.removeAdjacentEmptyLines));
|
|
299
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_CLEAN_OPTION.logLevel));
|
|
300
|
-
BUILD_LOGGER.NEW_LINE();
|
|
301
|
-
BUILD_LOGGER.ON_STARTING({
|
|
240
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
241
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
242
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_CLEAN_OPTION.patternOptions));
|
|
243
|
+
require_server.BUILD_LOGGER.OPTIONS("options.removeSourceMap", removeSourceMap, require_server.BUILD_LOGGER.SOURCE_OF(removeSourceMap, DEFAULT_CLEAN_OPTION.removeSourceMap));
|
|
244
|
+
require_server.BUILD_LOGGER.OPTIONS("options.removeRegion", removeRegion, require_server.BUILD_LOGGER.SOURCE_OF(removeRegion, DEFAULT_CLEAN_OPTION.removeRegion));
|
|
245
|
+
require_server.BUILD_LOGGER.OPTIONS("options.removeAdjacentEmptyLines", removeAdjacentEmptyLines, require_server.BUILD_LOGGER.SOURCE_OF(removeAdjacentEmptyLines, DEFAULT_CLEAN_OPTION.removeAdjacentEmptyLines));
|
|
246
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_CLEAN_OPTION.logLevel));
|
|
247
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
248
|
+
require_server.BUILD_LOGGER.ON_STARTING({
|
|
302
249
|
...logAction.onStart,
|
|
303
250
|
actionName: logAction.actionName
|
|
304
251
|
});
|
|
@@ -315,7 +262,7 @@ async function runCleanBuildArtifacts({ patterns: pattern, options, fileTest, lo
|
|
|
315
262
|
}
|
|
316
263
|
const lines = splitLines(content);
|
|
317
264
|
if (!fileHasTarget(lines, options)) continue;
|
|
318
|
-
const finalContent = cleanBuildArtifactsCore(lines, options).join(
|
|
265
|
+
const finalContent = cleanBuildArtifactsCore(lines, options).join(require_formatter.EOL);
|
|
319
266
|
if (finalContent === content) continue;
|
|
320
267
|
count++;
|
|
321
268
|
try {
|
|
@@ -324,24 +271,24 @@ async function runCleanBuildArtifacts({ patterns: pattern, options, fileTest, lo
|
|
|
324
271
|
if (err.code === "ENOENT") continue;
|
|
325
272
|
throw err;
|
|
326
273
|
}
|
|
327
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
274
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
328
275
|
...logAction.onProcess,
|
|
329
276
|
actionName: logAction.actionName,
|
|
330
277
|
count,
|
|
331
278
|
nameDirect: filePath
|
|
332
279
|
});
|
|
333
280
|
}
|
|
334
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
|
|
281
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
335
282
|
actionName: logAction.actionName,
|
|
336
283
|
count
|
|
337
284
|
});
|
|
338
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
285
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
339
286
|
...logAction.onSkipping,
|
|
340
287
|
actionName: logAction.actionName,
|
|
341
288
|
reasonEndText: logAction.onSkipping?.reasonEndText ?? "cleaning"
|
|
342
289
|
});
|
|
343
290
|
} catch (error) {
|
|
344
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
291
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
345
292
|
...logAction.onError,
|
|
346
293
|
actionName: logAction.actionName,
|
|
347
294
|
error
|
|
@@ -360,7 +307,7 @@ const cleanJsBuildArtifacts = async (pattern, options = {}) => {
|
|
|
360
307
|
fileTest: JS_OUTPUT_FILE_RE,
|
|
361
308
|
logAction: {
|
|
362
309
|
actionName: "Cleaning JS Build Artifacts",
|
|
363
|
-
title:
|
|
310
|
+
title: require_formatter.isNonEmptyString(options.__commandTitle) ? options.__commandTitle : commandCjbaIdentity.utility()
|
|
364
311
|
}
|
|
365
312
|
});
|
|
366
313
|
};
|
|
@@ -376,7 +323,7 @@ const cleanTypesBuildArtifacts = async (pattern, options = {}) => {
|
|
|
376
323
|
fileTest: TS_DECLARATION_FILE_RE,
|
|
377
324
|
logAction: {
|
|
378
325
|
actionName: "Cleaning Types Build Artifacts",
|
|
379
|
-
title:
|
|
326
|
+
title: require_formatter.isNonEmptyString(options.__commandTitle) ? options.__commandTitle : commandCtbaIdentity.utility()
|
|
380
327
|
}
|
|
381
328
|
});
|
|
382
329
|
};
|
|
@@ -387,17 +334,17 @@ const DEFAULT_CFTD_OPTIONS = {
|
|
|
387
334
|
ignoreMissingSourceError: false
|
|
388
335
|
};
|
|
389
336
|
const validateItem = (item, index) => {
|
|
390
|
-
const indexText =
|
|
391
|
-
if (!
|
|
392
|
-
if (!
|
|
393
|
-
if (!
|
|
394
|
-
if (!
|
|
395
|
-
if (!
|
|
396
|
-
if (!
|
|
397
|
-
if (!
|
|
337
|
+
const indexText = require_formatter.isNumber(index) ? ` at index ${index}` : "";
|
|
338
|
+
if (!require_formatter.isPlainObject(item)) throw new TypeError(`Invalid item${indexText}: must be a 'plain object'!`);
|
|
339
|
+
if (!require_formatter.isNonEmptyString(item.source) && !require_formatter.isNonEmptyString(item.target)) throw new TypeError(`Invalid item${indexText}: 'source' and 'target' must be 'non-empty string'!`);
|
|
340
|
+
if (!require_formatter.isNonEmptyString(item.source)) throw new TypeError(`Invalid item${indexText}: 'source' must be 'non-empty string'!`);
|
|
341
|
+
if (!require_formatter.isNonEmptyString(item.target)) throw new TypeError(`Invalid item${indexText}: 'target' must be 'non-empty string'!`);
|
|
342
|
+
if (!require_formatter.isUndefined(item.fileName) && !require_formatter.isNonEmptyString(item.fileName)) throw new TypeError(`Invalid item${indexText}: 'fileName' must be 'non-empty string' if provided!`);
|
|
343
|
+
if (!require_formatter.isUndefined(item.outputRoot) && !require_formatter.isNonEmptyString(item.outputRoot)) throw new TypeError(`Invalid item${indexText}: 'outputRoot' must be 'non-empty string' if provided!`);
|
|
344
|
+
if (!require_formatter.isUndefined(item.absoluteTarget) && !require_formatter.isBoolean(item.absoluteTarget)) throw new TypeError(`Invalid item${indexText}: 'absoluteTarget' must be a 'boolean' if provided!`);
|
|
398
345
|
};
|
|
399
346
|
function buildCopySummary(successCount, errorCount, duplicateCount, label) {
|
|
400
|
-
return
|
|
347
|
+
return require_formatter.picocolors.bold(require_formatter.joinLinesLoose(require_formatter.joinInline(require_formatter.picocolors.yellowBright("⚠"), require_formatter.picocolors.blueBright(label) + require_formatter.picocolors.gray(" -"), require_formatter.picocolors.whiteBright(successCount > 0 ? "Some" : "All"), require_formatter.picocolors.whiteBright("files"), require_formatter.picocolors.redBright("failed to copy") + ":"), successCount < 1 ? false : ` ${require_formatter.picocolors.greenBright("✔")} ${require_formatter.picocolors.greenBright(successCount)} ${require_formatter.plural(successCount, "file")} copied.`, errorCount < 1 ? false : ` ${require_formatter.picocolors.redBright("✖")} ${require_formatter.picocolors.redBright(errorCount)} ${require_formatter.plural(errorCount, "file")} failed.`, duplicateCount < 1 ? false : ` ${require_formatter.picocolors.yellowBright("⚠")} ${require_formatter.picocolors.yellowBright(duplicateCount)} ${require_formatter.plural(duplicateCount, "duplicate operation")} skipped.`));
|
|
401
348
|
}
|
|
402
349
|
function buildOperationKey(item) {
|
|
403
350
|
return [
|
|
@@ -409,39 +356,39 @@ function buildOperationKey(item) {
|
|
|
409
356
|
].join("|");
|
|
410
357
|
}
|
|
411
358
|
function createCopyFileToDestParameterSet(items) {
|
|
412
|
-
return new Set(
|
|
359
|
+
return new Set(require_formatter.isArray(items) ? items : [items]);
|
|
413
360
|
}
|
|
414
361
|
const commandCftdIdentity = new require_identity.CommandIdentity({ defaultCommandName: "copy-file-to-dest" });
|
|
415
362
|
async function copyFileToDest(parameter, options = {}) {
|
|
416
363
|
const loggerLevel = resolveLogVerbosity(options);
|
|
417
364
|
try {
|
|
418
365
|
const { __commandTitle } = options;
|
|
419
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
420
|
-
if (
|
|
366
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandCftdIdentity.utility(), ""));
|
|
367
|
+
if (require_formatter.isArray(parameter) || require_formatter.isSet(parameter)) {
|
|
421
368
|
let i = 0;
|
|
422
369
|
for (const item of parameter) validateItem(item, i++);
|
|
423
|
-
} else if (
|
|
370
|
+
} else if (require_formatter.isPlainObject(parameter)) validateItem(parameter);
|
|
424
371
|
else throw new TypeError("Parameter argument must be a 'plain object', 'array of plain objects' or an 'set of plain objects'!");
|
|
425
|
-
const list = [...
|
|
372
|
+
const list = [...require_formatter.toObjectSet(parameter)];
|
|
426
373
|
const uniqueLists = [];
|
|
427
374
|
const seenOperations = /* @__PURE__ */ new Set();
|
|
428
375
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
429
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
376
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
430
377
|
list.forEach((item, i) => {
|
|
431
378
|
const { source, target, fileName = DEFAULT_CFTD_OPTIONS.fileName, outputRoot = DEFAULT_CFTD_OPTIONS.outputRoot, absoluteTarget = DEFAULT_CFTD_OPTIONS.absoluteTarget, ignoreMissingSourceError = DEFAULT_CFTD_OPTIONS.ignoreMissingSourceError } = item;
|
|
432
379
|
const defaultFileName = fileName ?? node_path.default.basename(source);
|
|
433
380
|
const indexText = list.length > 1 ? `[${i}]` : "";
|
|
434
|
-
BUILD_LOGGER.OPTIONS(`options.copy${indexText}.source`, source, "overridden", true);
|
|
435
|
-
BUILD_LOGGER.OPTIONS(`options.copy${indexText}.target`, target, "overridden", true);
|
|
436
|
-
BUILD_LOGGER.OPTIONS(`options.copy${indexText}.fileName`, fileName || defaultFileName, BUILD_LOGGER.SOURCE_OF(fileName, DEFAULT_CFTD_OPTIONS.fileName));
|
|
437
|
-
BUILD_LOGGER.OPTIONS(`options.copy${indexText}.outputRoot`, outputRoot, BUILD_LOGGER.SOURCE_OF(outputRoot, DEFAULT_CFTD_OPTIONS.outputRoot));
|
|
438
|
-
BUILD_LOGGER.OPTIONS(`options.copy${indexText}.absoluteTarget`, absoluteTarget, BUILD_LOGGER.SOURCE_OF(absoluteTarget, DEFAULT_CFTD_OPTIONS.absoluteTarget));
|
|
439
|
-
BUILD_LOGGER.OPTIONS(`options.copy${indexText}.ignoreMissingSourceError`, ignoreMissingSourceError, BUILD_LOGGER.SOURCE_OF(ignoreMissingSourceError, DEFAULT_CFTD_OPTIONS.ignoreMissingSourceError));
|
|
440
|
-
if (i < list.length - 1) console.log(
|
|
381
|
+
require_server.BUILD_LOGGER.OPTIONS(`options.copy${indexText}.source`, source, "overridden", true);
|
|
382
|
+
require_server.BUILD_LOGGER.OPTIONS(`options.copy${indexText}.target`, target, "overridden", true);
|
|
383
|
+
require_server.BUILD_LOGGER.OPTIONS(`options.copy${indexText}.fileName`, fileName || defaultFileName, require_server.BUILD_LOGGER.SOURCE_OF(fileName, DEFAULT_CFTD_OPTIONS.fileName));
|
|
384
|
+
require_server.BUILD_LOGGER.OPTIONS(`options.copy${indexText}.outputRoot`, outputRoot, require_server.BUILD_LOGGER.SOURCE_OF(outputRoot, DEFAULT_CFTD_OPTIONS.outputRoot));
|
|
385
|
+
require_server.BUILD_LOGGER.OPTIONS(`options.copy${indexText}.absoluteTarget`, absoluteTarget, require_server.BUILD_LOGGER.SOURCE_OF(absoluteTarget, DEFAULT_CFTD_OPTIONS.absoluteTarget));
|
|
386
|
+
require_server.BUILD_LOGGER.OPTIONS(`options.copy${indexText}.ignoreMissingSourceError`, ignoreMissingSourceError, require_server.BUILD_LOGGER.SOURCE_OF(ignoreMissingSourceError, DEFAULT_CFTD_OPTIONS.ignoreMissingSourceError));
|
|
387
|
+
if (i < list.length - 1) console.log(require_formatter.picocolors.gray(" =========================================================================="));
|
|
441
388
|
});
|
|
442
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_LOG_LEVEL));
|
|
443
|
-
BUILD_LOGGER.NEW_LINE();
|
|
444
|
-
BUILD_LOGGER.ON_STARTING({
|
|
389
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_LOG_LEVEL));
|
|
390
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
391
|
+
require_server.BUILD_LOGGER.ON_STARTING({
|
|
445
392
|
actionName: "Copy File",
|
|
446
393
|
textDirectAction: "action:"
|
|
447
394
|
});
|
|
@@ -454,12 +401,12 @@ async function copyFileToDest(parameter, options = {}) {
|
|
|
454
401
|
const key = buildOperationKey(item);
|
|
455
402
|
if (seenOperations.has(key)) {
|
|
456
403
|
duplicateCount++;
|
|
457
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_SKIPPING({
|
|
404
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
458
405
|
actionName: "Copy File",
|
|
459
406
|
reasonType: "",
|
|
460
407
|
textDirectAction: "at",
|
|
461
408
|
reasonSkipAction: "duplicate operation",
|
|
462
|
-
reasonEndText: item.source + " " +
|
|
409
|
+
reasonEndText: item.source + " " + require_formatter.picocolors.blueBright(`('parameter' index: ${require_formatter.picocolors.magentaBright(index)})`)
|
|
463
410
|
});
|
|
464
411
|
continue;
|
|
465
412
|
}
|
|
@@ -478,7 +425,7 @@ async function copyFileToDest(parameter, options = {}) {
|
|
|
478
425
|
if (!await require_server.fsExtra.pathExists(absSource)) {
|
|
479
426
|
if (ignoreMissingSourceError) continue;
|
|
480
427
|
errorCount++;
|
|
481
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_PROCESS_COPY_ERROR({
|
|
428
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_PROCESS_COPY_ERROR({
|
|
482
429
|
copyFrom: source,
|
|
483
430
|
index: uniqList.index,
|
|
484
431
|
indexKey: "parameter",
|
|
@@ -493,7 +440,7 @@ async function copyFileToDest(parameter, options = {}) {
|
|
|
493
440
|
await require_server.fsExtra.copy(absSource, absTargetFile);
|
|
494
441
|
const relSrc = node_path.default.relative(procCwd, absSource).replace(/\\/g, "/");
|
|
495
442
|
const relDest = node_path.default.relative(procCwd, absTargetFile).replace(/\\/g, "/");
|
|
496
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS_COPY({
|
|
443
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS_COPY({
|
|
497
444
|
actionName: "File copied",
|
|
498
445
|
count,
|
|
499
446
|
copyFrom: relSrc,
|
|
@@ -503,26 +450,26 @@ async function copyFileToDest(parameter, options = {}) {
|
|
|
503
450
|
}
|
|
504
451
|
const successCount = count - errorCount;
|
|
505
452
|
if ((errorCount > 0 || duplicateCount > 0) && loggerLevel !== "silent" && !canLog(loggerLevel, VERBOSE_LOG)) console.log(buildCopySummary(successCount, errorCount, duplicateCount, "[Copy File to Dest]"));
|
|
506
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0 && errorCount === 0 && duplicateCount === 0) BUILD_LOGGER.ON_FINISH({
|
|
453
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0 && errorCount === 0 && duplicateCount === 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
507
454
|
textSuccess: "Successfully",
|
|
508
455
|
actionName: "copied",
|
|
509
456
|
count
|
|
510
457
|
});
|
|
511
458
|
else if (successCount > 0) console.log(buildCopySummary(successCount, errorCount, duplicateCount, "[Copy File to Dest]"));
|
|
512
|
-
else if (successCount === 0 && errorCount !== 0) BUILD_LOGGER.ON_SKIPPING({
|
|
459
|
+
else if (successCount === 0 && errorCount !== 0) require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
513
460
|
actionName: "\"Copy File\"",
|
|
514
461
|
reasonSkipAction: "failed",
|
|
515
462
|
reasonEndText: `${count > 1 ? "all " : ""}files`,
|
|
516
463
|
reasonType: "to",
|
|
517
464
|
textDirectAction: "copy"
|
|
518
465
|
});
|
|
519
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
466
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
520
467
|
actionName: "\"Copy File\"",
|
|
521
468
|
reasonSkipAction: errorCount > 0 ? "nothing found" : "nothing",
|
|
522
469
|
reasonEndText: "copy"
|
|
523
470
|
});
|
|
524
471
|
} catch (error) {
|
|
525
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
472
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
526
473
|
actionName: "Copying File",
|
|
527
474
|
error
|
|
528
475
|
});
|
|
@@ -556,44 +503,44 @@ function getMissingCssStatements(body, cssImports, kind, dedupe) {
|
|
|
556
503
|
};
|
|
557
504
|
}
|
|
558
505
|
function injectCssSmart({ shebang, banner, directives, rest, cssStatements, kind, minify }) {
|
|
559
|
-
let out = minify ? shebang.trim() +
|
|
560
|
-
out += minify ? banner.trim() +
|
|
506
|
+
let out = minify ? shebang.trim() + require_formatter.EOL : shebang;
|
|
507
|
+
out += minify ? banner.trim() + require_formatter.EOL : banner;
|
|
561
508
|
let finalDirectives = stripUseStrict(directives, {
|
|
562
509
|
trimEnd: minify,
|
|
563
510
|
trimStart: minify
|
|
564
511
|
});
|
|
565
|
-
if (kind === "cjs") finalDirectives = `"use strict";${
|
|
512
|
+
if (kind === "cjs") finalDirectives = `"use strict";${require_formatter.EOL}` + finalDirectives.trimStart();
|
|
566
513
|
out += finalDirectives;
|
|
567
|
-
out += cssStatements.join(
|
|
568
|
-
out += rest.replace(/^\n+/, minify ? "" :
|
|
514
|
+
out += cssStatements.join(require_formatter.EOL) + (minify ? "" : require_formatter.EOL);
|
|
515
|
+
out += rest.replace(/^\n+/, minify ? "" : require_formatter.EOL);
|
|
569
516
|
return out.trimStart();
|
|
570
517
|
}
|
|
571
518
|
function normalizeCssImports(input) {
|
|
572
|
-
return
|
|
519
|
+
return require_formatter.flattenStrings(require_formatter.isArray(input) ? input : [input]).map((s) => s.trim()).filter(Boolean);
|
|
573
520
|
}
|
|
574
521
|
const commandEciIdentity = new require_identity.CommandIdentity({ defaultCommandName: "ensure-css-import" });
|
|
575
522
|
const ensureCssImport = async (pattern, options) => {
|
|
576
523
|
const loggerLevel = resolveLogVerbosity(options, DEFAULT_ECI_OPTIONS.logLevel);
|
|
577
524
|
try {
|
|
578
525
|
const { patternOptions = DEFAULT_ECI_OPTIONS.patternOptions, cssImportPath, dedupe = DEFAULT_ECI_OPTIONS.dedupe, sort = DEFAULT_ECI_OPTIONS.sort, minify = DEFAULT_ECI_OPTIONS.minify, __commandTitle } = options;
|
|
579
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
580
|
-
const patterns = [...
|
|
526
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandEciIdentity.utility(), ""));
|
|
527
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
581
528
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_ECI_PATTERN_POLICY);
|
|
582
529
|
let cssImports = normalizeCssImports(cssImportPath);
|
|
583
530
|
if (cssImports.length === 0) throw new Error("`cssImportPath` option must not be empty.");
|
|
584
531
|
if (dedupe) cssImports = Array.from(new Set(cssImports));
|
|
585
532
|
if (sort) cssImports.sort();
|
|
586
533
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
587
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
588
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
589
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_ECI_OPTIONS.patternOptions));
|
|
590
|
-
BUILD_LOGGER.OPTIONS("options.cssImportPath", cssImports, BUILD_LOGGER.SOURCE_OF(cssImports, DEFAULT_ECI_OPTIONS.cssImportPath), true);
|
|
591
|
-
BUILD_LOGGER.OPTIONS("options.dedupe", dedupe, BUILD_LOGGER.SOURCE_OF(dedupe, DEFAULT_ECI_OPTIONS.dedupe));
|
|
592
|
-
BUILD_LOGGER.OPTIONS("options.sort", sort, BUILD_LOGGER.SOURCE_OF(sort, DEFAULT_ECI_OPTIONS.sort));
|
|
593
|
-
BUILD_LOGGER.OPTIONS("options.minify", minify, BUILD_LOGGER.SOURCE_OF(minify, DEFAULT_ECI_OPTIONS.minify));
|
|
594
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_ECI_OPTIONS.logLevel));
|
|
595
|
-
BUILD_LOGGER.NEW_LINE();
|
|
596
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Ensuring CSS Import" });
|
|
534
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
535
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
536
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_ECI_OPTIONS.patternOptions));
|
|
537
|
+
require_server.BUILD_LOGGER.OPTIONS("options.cssImportPath", cssImports, require_server.BUILD_LOGGER.SOURCE_OF(cssImports, DEFAULT_ECI_OPTIONS.cssImportPath), true);
|
|
538
|
+
require_server.BUILD_LOGGER.OPTIONS("options.dedupe", dedupe, require_server.BUILD_LOGGER.SOURCE_OF(dedupe, DEFAULT_ECI_OPTIONS.dedupe));
|
|
539
|
+
require_server.BUILD_LOGGER.OPTIONS("options.sort", sort, require_server.BUILD_LOGGER.SOURCE_OF(sort, DEFAULT_ECI_OPTIONS.sort));
|
|
540
|
+
require_server.BUILD_LOGGER.OPTIONS("options.minify", minify, require_server.BUILD_LOGGER.SOURCE_OF(minify, DEFAULT_ECI_OPTIONS.minify));
|
|
541
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_ECI_OPTIONS.logLevel));
|
|
542
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
543
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Ensuring CSS Import" });
|
|
597
544
|
}
|
|
598
545
|
const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
599
546
|
let count = 0;
|
|
@@ -629,24 +576,24 @@ const ensureCssImport = async (pattern, options) => {
|
|
|
629
576
|
throw err;
|
|
630
577
|
}
|
|
631
578
|
count++;
|
|
632
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
579
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
633
580
|
actionName: "CSS Import",
|
|
634
581
|
count,
|
|
635
582
|
nameDirect: filePath
|
|
636
583
|
});
|
|
637
584
|
}
|
|
638
585
|
}
|
|
639
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
|
|
586
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
640
587
|
actionName: "Ensuring CSS Import",
|
|
641
588
|
count
|
|
642
589
|
});
|
|
643
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
590
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
644
591
|
actionName: "Ensuring CSS Import",
|
|
645
592
|
reasonType: "file",
|
|
646
593
|
reasonEndText: "check"
|
|
647
594
|
});
|
|
648
595
|
} catch (error) {
|
|
649
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
596
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
650
597
|
actionName: "Ensuring CSS Import",
|
|
651
598
|
error
|
|
652
599
|
});
|
|
@@ -666,16 +613,16 @@ const ensureFinalNewline = async (pattern, options = {}) => {
|
|
|
666
613
|
const loggerLevel = resolveLogVerbosity(options, DEFAULT_EFN_OPTIONS.logLevel);
|
|
667
614
|
try {
|
|
668
615
|
const { __commandTitle, patternOptions = DEFAULT_EFN_OPTIONS.patternOptions } = options;
|
|
669
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
670
|
-
const patterns = [...
|
|
616
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandEfnIdentity.utility(), ""));
|
|
617
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
671
618
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_EFN_PATTERN_POLICY);
|
|
672
619
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
673
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
674
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
675
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_EFN_OPTIONS.patternOptions));
|
|
676
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_EFN_OPTIONS.logLevel));
|
|
677
|
-
BUILD_LOGGER.NEW_LINE();
|
|
678
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Ensuring Final Newline" });
|
|
620
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
621
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
622
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_EFN_OPTIONS.patternOptions));
|
|
623
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_EFN_OPTIONS.logLevel));
|
|
624
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
625
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Ensuring Final Newline" });
|
|
679
626
|
}
|
|
680
627
|
const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
681
628
|
let count = 0;
|
|
@@ -687,7 +634,7 @@ const ensureFinalNewline = async (pattern, options = {}) => {
|
|
|
687
634
|
if (err.code === "ENOENT") continue;
|
|
688
635
|
throw err;
|
|
689
636
|
}
|
|
690
|
-
const normalized = content.replace(/(\r?\n)*$/,
|
|
637
|
+
const normalized = content.replace(/(\r?\n)*$/, require_formatter.EOL);
|
|
691
638
|
if (normalized === content) continue;
|
|
692
639
|
try {
|
|
693
640
|
await require_server.fsExtra.promises.writeFile(filePath, normalized, "utf8");
|
|
@@ -696,32 +643,32 @@ const ensureFinalNewline = async (pattern, options = {}) => {
|
|
|
696
643
|
throw err;
|
|
697
644
|
}
|
|
698
645
|
count++;
|
|
699
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
646
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
700
647
|
actionName: "Final Newline",
|
|
701
648
|
count,
|
|
702
649
|
nameDirect: filePath
|
|
703
650
|
});
|
|
704
651
|
}
|
|
705
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
|
|
652
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
706
653
|
actionName: "Ensuring Final Newline",
|
|
707
654
|
count
|
|
708
655
|
});
|
|
709
|
-
else if (files.length < 1) BUILD_LOGGER.ON_SKIPPING({
|
|
656
|
+
else if (files.length < 1) require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
710
657
|
actionName: "Ensuring Final Newline",
|
|
711
|
-
reasonSkipAction: `no files found matching the pattern${
|
|
658
|
+
reasonSkipAction: `no files found matching the pattern${require_formatter.picocolors.reset(",")}`,
|
|
712
659
|
reasonType: "",
|
|
713
660
|
textDirectAction: "no need to fix",
|
|
714
661
|
reasonEndText: "end of file (EOF)"
|
|
715
662
|
});
|
|
716
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
663
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
717
664
|
actionName: "Ensuring Final Newline",
|
|
718
|
-
reasonSkipAction: `all files are valid${
|
|
665
|
+
reasonSkipAction: `all files are valid${require_formatter.picocolors.reset(",")}`,
|
|
719
666
|
reasonType: "",
|
|
720
667
|
textDirectAction: "no need to fix",
|
|
721
668
|
reasonEndText: "end of file (EOF)"
|
|
722
669
|
});
|
|
723
670
|
} catch (error) {
|
|
724
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
671
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
725
672
|
actionName: "Ensuring Final Newline",
|
|
726
673
|
error
|
|
727
674
|
});
|
|
@@ -769,9 +716,9 @@ const validateOut = ({ outDir, outFileName, inputDirReference }) => {
|
|
|
769
716
|
};
|
|
770
717
|
const resolveBanner = async (banner) => {
|
|
771
718
|
if (banner === false) return "";
|
|
772
|
-
if (banner === true) return await require_package_banner.generatePackageBanner() +
|
|
719
|
+
if (banner === true) return await require_package_banner.generatePackageBanner() + require_formatter.EOL;
|
|
773
720
|
const resolved = await banner;
|
|
774
|
-
return
|
|
721
|
+
return require_formatter.isNonEmptyString(resolved) ? resolved : "";
|
|
775
722
|
};
|
|
776
723
|
const commandGriIdentity = new require_identity.CommandIdentity({ defaultCommandName: "generate-reference-index" });
|
|
777
724
|
const generateReferenceIndex = async (pattern, options = {}) => {
|
|
@@ -780,21 +727,21 @@ const generateReferenceIndex = async (pattern, options = {}) => {
|
|
|
780
727
|
try {
|
|
781
728
|
const { __commandTitle, patternOptions = DEFAULT_GRI_OPTIONS.patternOptions, outDir: _outDir = DEFAULT_GRI_OPTIONS.outDir, outFileName: _outFileName = DEFAULT_GRI_OPTIONS.outFileName, inputDirReference: _inputDirReference = DEFAULT_GRI_OPTIONS.inputDirReference, withExportTypes = DEFAULT_GRI_OPTIONS.withExportTypes, banner = DEFAULT_GRI_OPTIONS.banner, onlyDeclarations = DEFAULT_GRI_OPTIONS.onlyDeclarations } = options;
|
|
782
729
|
_withExportTypes = withExportTypes;
|
|
783
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
784
|
-
const patterns = [...
|
|
730
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandGriIdentity.utility(), ""));
|
|
731
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
785
732
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_GRI_PATTERN_POLICY);
|
|
786
733
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
787
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
788
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
789
|
-
BUILD_LOGGER.OPTIONS("outDir", _outDir, sourceOf(_outDir, DEFAULT_GRI_OPTIONS.outDir));
|
|
790
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_GRI_OPTIONS.patternOptions));
|
|
791
|
-
BUILD_LOGGER.OPTIONS("options.outFileName", _outFileName, sourceOf(_outFileName, DEFAULT_GRI_OPTIONS.outFileName));
|
|
792
|
-
BUILD_LOGGER.OPTIONS("options.inputDirReference", _inputDirReference, sourceOf(_inputDirReference, DEFAULT_GRI_OPTIONS.inputDirReference));
|
|
793
|
-
BUILD_LOGGER.OPTIONS("options.withExportTypes", withExportTypes, sourceOf(withExportTypes, DEFAULT_GRI_OPTIONS.withExportTypes));
|
|
794
|
-
BUILD_LOGGER.OPTIONS("options.banner", banner, sourceOf(banner, DEFAULT_GRI_OPTIONS.banner));
|
|
795
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_GRI_OPTIONS.logLevel));
|
|
796
|
-
BUILD_LOGGER.NEW_LINE();
|
|
797
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Generating References" });
|
|
734
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
735
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
736
|
+
require_server.BUILD_LOGGER.OPTIONS("outDir", _outDir, require_server.sourceOf(_outDir, DEFAULT_GRI_OPTIONS.outDir));
|
|
737
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_GRI_OPTIONS.patternOptions));
|
|
738
|
+
require_server.BUILD_LOGGER.OPTIONS("options.outFileName", _outFileName, require_server.sourceOf(_outFileName, DEFAULT_GRI_OPTIONS.outFileName));
|
|
739
|
+
require_server.BUILD_LOGGER.OPTIONS("options.inputDirReference", _inputDirReference, require_server.sourceOf(_inputDirReference, DEFAULT_GRI_OPTIONS.inputDirReference));
|
|
740
|
+
require_server.BUILD_LOGGER.OPTIONS("options.withExportTypes", withExportTypes, require_server.sourceOf(withExportTypes, DEFAULT_GRI_OPTIONS.withExportTypes));
|
|
741
|
+
require_server.BUILD_LOGGER.OPTIONS("options.banner", banner, require_server.sourceOf(banner, DEFAULT_GRI_OPTIONS.banner));
|
|
742
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_GRI_OPTIONS.logLevel));
|
|
743
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
744
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Generating References" });
|
|
798
745
|
}
|
|
799
746
|
let files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
800
747
|
if (onlyDeclarations) files = files.filter((file) => TS_DECLARATION_FILE_RE.test(file));
|
|
@@ -814,7 +761,7 @@ const generateReferenceIndex = async (pattern, options = {}) => {
|
|
|
814
761
|
if (!referencedAbs.startsWith(inputDirRefAbs + node_path.default.sep) || referencedAbs === outFileAbs) return;
|
|
815
762
|
const referencePath = normalizeRelative(node_path.default.dirname(outFileAbs), referencedAbs);
|
|
816
763
|
const displayPath = `${inputDirReference}/${node_path.default.relative(inputDirRefAbs, referencedAbs).replace(/\\/g, "/")}`;
|
|
817
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS_REFERENCING({
|
|
764
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS_REFERENCING({
|
|
818
765
|
actionName: "Generated Reference",
|
|
819
766
|
count: i + 1,
|
|
820
767
|
referenceFrom: displayPath,
|
|
@@ -825,22 +772,22 @@ const generateReferenceIndex = async (pattern, options = {}) => {
|
|
|
825
772
|
}).filter(Boolean);
|
|
826
773
|
if (Array.isArray(reference) && reference.length > 0) {
|
|
827
774
|
lines.add("//! References Paths:");
|
|
828
|
-
lines.add(reference.join(
|
|
775
|
+
lines.add(reference.join(require_formatter.EOL));
|
|
829
776
|
}
|
|
830
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (referenceCount > 0) BUILD_LOGGER.ON_FINISH({
|
|
777
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (referenceCount > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
831
778
|
actionName: "Generating Reference",
|
|
832
779
|
count: files.length,
|
|
833
780
|
typeCount: "reference"
|
|
834
781
|
});
|
|
835
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
782
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
836
783
|
actionName: "Generating References",
|
|
837
784
|
reasonEndText: "referencing",
|
|
838
785
|
reasonType: "references"
|
|
839
786
|
});
|
|
840
787
|
if (withExportTypes) {
|
|
841
788
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
842
|
-
console.log(
|
|
843
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Adding Exported Types" });
|
|
789
|
+
console.log(require_formatter.picocolors.bold(require_formatter.picocolors.magentaBright(`${require_formatter.EOL}=======================================================================================${require_formatter.EOL}`)));
|
|
790
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Adding Exported Types" });
|
|
844
791
|
}
|
|
845
792
|
const exportLines = /* @__PURE__ */ new Set();
|
|
846
793
|
let exportCount = 0;
|
|
@@ -852,7 +799,7 @@ const generateReferenceIndex = async (pattern, options = {}) => {
|
|
|
852
799
|
if (!exportLines.has(line)) {
|
|
853
800
|
exportCount++;
|
|
854
801
|
const displayPath = `${inputDirReference}/${node_path.default.relative(inputDirRefAbs, referencedAbs).replace(/\\/g, "/")}`;
|
|
855
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS_REFERENCING({
|
|
802
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS_REFERENCING({
|
|
856
803
|
actionName: "Exported Type",
|
|
857
804
|
count: exportCount,
|
|
858
805
|
referenceFrom: displayPath,
|
|
@@ -864,13 +811,13 @@ const generateReferenceIndex = async (pattern, options = {}) => {
|
|
|
864
811
|
if (exportLines.size > 0) {
|
|
865
812
|
if (referenceCount > 0) lines.add("");
|
|
866
813
|
lines.add("//! Exported Types:");
|
|
867
|
-
lines.add([...exportLines].join(
|
|
868
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_FINISH({
|
|
814
|
+
lines.add([...exportLines].join(require_formatter.EOL));
|
|
815
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_FINISH({
|
|
869
816
|
actionName: "Adding Exported Types",
|
|
870
817
|
count: exportLines.size,
|
|
871
818
|
typeCount: "type"
|
|
872
819
|
});
|
|
873
|
-
} else if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_SKIPPING({
|
|
820
|
+
} else if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
874
821
|
actionName: "Adding Exported Types",
|
|
875
822
|
reasonEndText: "exporting",
|
|
876
823
|
reasonType: "types"
|
|
@@ -881,9 +828,9 @@ const generateReferenceIndex = async (pattern, options = {}) => {
|
|
|
881
828
|
const action = withExportTypes ? "reference and type export" : "reference";
|
|
882
829
|
lines.add(`// No files matched the given patterns and input dir references, skipping ${action} generation.`);
|
|
883
830
|
}
|
|
884
|
-
await require_server.fsExtra.promises.writeFile(outFileAbs, await resolveBanner(banner) + [...lines].join(
|
|
831
|
+
await require_server.fsExtra.promises.writeFile(outFileAbs, await resolveBanner(banner) + [...lines].join(require_formatter.EOL) + require_formatter.EOL);
|
|
885
832
|
} catch (error) {
|
|
886
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
833
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
887
834
|
actionName: "Generating References" + (_withExportTypes ? " and Adding Exported Types" : ""),
|
|
888
835
|
error
|
|
889
836
|
});
|
|
@@ -906,23 +853,23 @@ const injectBanner = async (pattern, bannerText, options = {}) => {
|
|
|
906
853
|
const loggerLevel = resolveLogVerbosity(options, DEFAULT_LOG_LEVEL);
|
|
907
854
|
try {
|
|
908
855
|
const { __commandTitle, removeDuplicate = DEFAULT_IB_OPTIONS.removeDuplicate, bannerPosition = DEFAULT_IB_OPTIONS.bannerPosition, replaceBanner = DEFAULT_IB_OPTIONS.replaceBanner, patternOptions = DEFAULT_IB_OPTIONS.patternOptions } = options;
|
|
909
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
910
|
-
const patterns = [...
|
|
911
|
-
const banners =
|
|
856
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandIbIdentity.utility(), ""));
|
|
857
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
858
|
+
const banners = require_formatter.toStringSet(bannerText, { parameterKey: "bannerText" });
|
|
912
859
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_IB_PATTERN_POLICY);
|
|
913
860
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
914
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
915
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
916
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_IB_OPTIONS.patternOptions));
|
|
917
|
-
BUILD_LOGGER.OPTIONS("options.removeDuplicate", removeDuplicate, BUILD_LOGGER.SOURCE_OF(removeDuplicate, DEFAULT_IB_OPTIONS.removeDuplicate));
|
|
918
|
-
BUILD_LOGGER.OPTIONS("options.replaceBanner", replaceBanner, BUILD_LOGGER.SOURCE_OF(replaceBanner, DEFAULT_IB_OPTIONS.replaceBanner));
|
|
919
|
-
BUILD_LOGGER.OPTIONS("options.bannerPosition", bannerPosition, BUILD_LOGGER.SOURCE_OF(bannerPosition, DEFAULT_IB_OPTIONS.bannerPosition));
|
|
920
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_IB_OPTIONS.logLevel));
|
|
921
|
-
BUILD_LOGGER.NEW_LINE();
|
|
922
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Injecting Banner" });
|
|
861
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
862
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
863
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_IB_OPTIONS.patternOptions));
|
|
864
|
+
require_server.BUILD_LOGGER.OPTIONS("options.removeDuplicate", removeDuplicate, require_server.BUILD_LOGGER.SOURCE_OF(removeDuplicate, DEFAULT_IB_OPTIONS.removeDuplicate));
|
|
865
|
+
require_server.BUILD_LOGGER.OPTIONS("options.replaceBanner", replaceBanner, require_server.BUILD_LOGGER.SOURCE_OF(replaceBanner, DEFAULT_IB_OPTIONS.replaceBanner));
|
|
866
|
+
require_server.BUILD_LOGGER.OPTIONS("options.bannerPosition", bannerPosition, require_server.BUILD_LOGGER.SOURCE_OF(bannerPosition, DEFAULT_IB_OPTIONS.bannerPosition));
|
|
867
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_IB_OPTIONS.logLevel));
|
|
868
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
869
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Injecting Banner" });
|
|
923
870
|
}
|
|
924
871
|
if (banners.size === 0) {
|
|
925
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_SKIPPING({
|
|
872
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
926
873
|
actionName: "Inject Banner",
|
|
927
874
|
reasonSkipAction: "empty bannerText",
|
|
928
875
|
reasonType: "parameter",
|
|
@@ -941,7 +888,7 @@ const injectBanner = async (pattern, bannerText, options = {}) => {
|
|
|
941
888
|
if (err.code === "ENOENT") continue;
|
|
942
889
|
throw err;
|
|
943
890
|
}
|
|
944
|
-
if (!
|
|
891
|
+
if (!require_formatter.isNonEmptyString(original)) continue;
|
|
945
892
|
if (!hasExecutableCode(original)) continue;
|
|
946
893
|
const { body, shebang, banner: existingBanner } = extractAndHoistBanner(original);
|
|
947
894
|
const bannerRegex = new RegExp(BANNER_RE.source, "g");
|
|
@@ -950,7 +897,7 @@ const injectBanner = async (pattern, bannerText, options = {}) => {
|
|
|
950
897
|
const existingBlocks = existingBanner ? [...existingBanner.matchAll(bannerRegex)].map((m) => m[0]) : [];
|
|
951
898
|
let finalBlocks = [];
|
|
952
899
|
if (replaceBanner) {
|
|
953
|
-
const replaceRegex =
|
|
900
|
+
const replaceRegex = require_formatter.isRegExp(replaceBanner) ? replaceBanner : BANNER_RE;
|
|
954
901
|
if (existingBanner && new RegExp(replaceRegex.source, replaceRegex.flags.replace("g", "")).test(existingBanner)) finalBlocks = [...newBlocks];
|
|
955
902
|
else finalBlocks = bannerPosition === "top" ? [...newBlocks, ...existingBlocks] : [...existingBlocks, ...newBlocks];
|
|
956
903
|
} else finalBlocks = bannerPosition === "top" ? [...newBlocks, ...existingBlocks] : [...existingBlocks, ...newBlocks];
|
|
@@ -964,8 +911,8 @@ const injectBanner = async (pattern, bannerText, options = {}) => {
|
|
|
964
911
|
});
|
|
965
912
|
}
|
|
966
913
|
let content = shebang + finalBlocks.map((text) => {
|
|
967
|
-
if (!text || !
|
|
968
|
-
return text.replace(/\r\n/g,
|
|
914
|
+
if (!text || !require_formatter.isNonEmptyString(text)) return "";
|
|
915
|
+
return text.replace(/\r\n/g, require_formatter.EOL).replace(/\n+$/, "") + require_formatter.EOL + require_formatter.EOL;
|
|
969
916
|
}).join("") + body;
|
|
970
917
|
try {
|
|
971
918
|
await require_server.fsExtra.promises.writeFile(filePath, content, "utf8");
|
|
@@ -974,22 +921,22 @@ const injectBanner = async (pattern, bannerText, options = {}) => {
|
|
|
974
921
|
throw err;
|
|
975
922
|
}
|
|
976
923
|
count++;
|
|
977
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
978
|
-
actionName: "Banner Injected " +
|
|
924
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
925
|
+
actionName: "Banner Injected " + require_formatter.picocolors.cyanBright(replaceBanner ? "(replace mode)" : "(preserve mode)"),
|
|
979
926
|
count,
|
|
980
927
|
nameDirect: filePath
|
|
981
928
|
});
|
|
982
929
|
}
|
|
983
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
|
|
930
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
984
931
|
actionName: "Inject Banner",
|
|
985
932
|
count
|
|
986
933
|
});
|
|
987
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
934
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
988
935
|
actionName: "Inject Banner",
|
|
989
936
|
reasonEndText: "injecting"
|
|
990
937
|
});
|
|
991
938
|
} catch (error) {
|
|
992
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
939
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
993
940
|
actionName: "Inject Banner",
|
|
994
941
|
error
|
|
995
942
|
});
|
|
@@ -1009,19 +956,19 @@ const injectDirective = async (pattern, directive, options = {}) => {
|
|
|
1009
956
|
const loggerLevel = resolveLogVerbosity(options, DEFAULT_ID_OPTIONS.logLevel);
|
|
1010
957
|
try {
|
|
1011
958
|
const { __commandTitle, patternOptions = DEFAULT_ID_OPTIONS.patternOptions } = options;
|
|
1012
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
1013
|
-
const patterns = [...
|
|
959
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandIdIdentity.utility(), ""));
|
|
960
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
1014
961
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_ID_PATTERN_POLICY);
|
|
1015
962
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
1016
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
1017
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
1018
|
-
BUILD_LOGGER.OPTIONS("directive", directive, BUILD_LOGGER.SOURCE_OF(directive, void 0), true);
|
|
1019
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_ID_OPTIONS.patternOptions));
|
|
1020
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_ID_OPTIONS.logLevel));
|
|
1021
|
-
BUILD_LOGGER.NEW_LINE();
|
|
1022
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Inject Directive" });
|
|
963
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
964
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
965
|
+
require_server.BUILD_LOGGER.OPTIONS("directive", directive, require_server.BUILD_LOGGER.SOURCE_OF(directive, void 0), true);
|
|
966
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_ID_OPTIONS.patternOptions));
|
|
967
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_ID_OPTIONS.logLevel));
|
|
968
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
969
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Inject Directive" });
|
|
1023
970
|
}
|
|
1024
|
-
const directives = [...
|
|
971
|
+
const directives = [...require_formatter.toStringSet(directive)];
|
|
1025
972
|
const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
1026
973
|
let count = 0;
|
|
1027
974
|
for (const filePath of files) {
|
|
@@ -1033,7 +980,7 @@ const injectDirective = async (pattern, directive, options = {}) => {
|
|
|
1033
980
|
if (err.code === "ENOENT") continue;
|
|
1034
981
|
throw err;
|
|
1035
982
|
}
|
|
1036
|
-
if (!
|
|
983
|
+
if (!require_formatter.isNonEmptyString(original) || !hasExecutableCode(original)) continue;
|
|
1037
984
|
const { body, banner, shebang } = extractAndHoistBanner(original);
|
|
1038
985
|
const { directives: extractedDirectives, rest } = extractDirectives(body);
|
|
1039
986
|
const existing = new Set(extractedDirectives);
|
|
@@ -1052,7 +999,7 @@ const injectDirective = async (pattern, directive, options = {}) => {
|
|
|
1052
999
|
}
|
|
1053
1000
|
}
|
|
1054
1001
|
if (!injectLines?.length) continue;
|
|
1055
|
-
const finalDirective = injectLines.join(
|
|
1002
|
+
const finalDirective = injectLines.join(require_formatter.EOL) + require_formatter.EOL + stripUseStrict(extractedDirectives);
|
|
1056
1003
|
const content = shebang + banner + finalDirective + rest;
|
|
1057
1004
|
try {
|
|
1058
1005
|
await require_server.fsExtra.promises.writeFile(filePath, content, "utf8");
|
|
@@ -1061,22 +1008,22 @@ const injectDirective = async (pattern, directive, options = {}) => {
|
|
|
1061
1008
|
throw err;
|
|
1062
1009
|
}
|
|
1063
1010
|
count++;
|
|
1064
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
1065
|
-
actionName: "Directive Injected " +
|
|
1011
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
1012
|
+
actionName: "Directive Injected " + require_formatter.picocolors.cyanBright("(`" + injectLines.join("`, `") + "`)"),
|
|
1066
1013
|
count,
|
|
1067
1014
|
nameDirect: filePath
|
|
1068
1015
|
});
|
|
1069
1016
|
}
|
|
1070
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
|
|
1017
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
1071
1018
|
actionName: "Inject Directive",
|
|
1072
1019
|
count
|
|
1073
1020
|
});
|
|
1074
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
1021
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
1075
1022
|
actionName: "Inject Directive",
|
|
1076
1023
|
reasonEndText: "injecting"
|
|
1077
1024
|
});
|
|
1078
1025
|
} catch (error) {
|
|
1079
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
1026
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
1080
1027
|
actionName: "Inject Directive",
|
|
1081
1028
|
error
|
|
1082
1029
|
});
|
|
@@ -1096,16 +1043,16 @@ const normalizeJsBuildNewlines = async (pattern, options = {}) => {
|
|
|
1096
1043
|
const loggerLevel = resolveLogVerbosity(options, DEFAULT_NJBN_OPTIONS.logLevel);
|
|
1097
1044
|
try {
|
|
1098
1045
|
const { __commandTitle, patternOptions = DEFAULT_NJBN_OPTIONS.patternOptions } = options;
|
|
1099
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
1100
|
-
const patterns = [...
|
|
1046
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandNjbnIdentity.utility(), ""));
|
|
1047
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
1101
1048
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_NJBN_PATTERN_POLICY);
|
|
1102
1049
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
1103
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
1104
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
1105
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_NJBN_OPTIONS.patternOptions));
|
|
1106
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_NJBN_OPTIONS.logLevel));
|
|
1107
|
-
BUILD_LOGGER.NEW_LINE();
|
|
1108
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Normalize New Lines" });
|
|
1050
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
1051
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
1052
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_NJBN_OPTIONS.patternOptions));
|
|
1053
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_NJBN_OPTIONS.logLevel));
|
|
1054
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
1055
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Normalize New Lines" });
|
|
1109
1056
|
}
|
|
1110
1057
|
const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
1111
1058
|
const filesToClean = /* @__PURE__ */ new Set();
|
|
@@ -1131,7 +1078,7 @@ const normalizeJsBuildNewlines = async (pattern, options = {}) => {
|
|
|
1131
1078
|
if (err.code === "ENOENT") continue;
|
|
1132
1079
|
throw err;
|
|
1133
1080
|
}
|
|
1134
|
-
const finalContent = content.replace(/(\r?\n){3,}/g,
|
|
1081
|
+
const finalContent = content.replace(/(\r?\n){3,}/g, require_formatter.EOL);
|
|
1135
1082
|
if (finalContent !== content) {
|
|
1136
1083
|
try {
|
|
1137
1084
|
await require_server.fsExtra.promises.writeFile(filePath, finalContent, "utf8");
|
|
@@ -1139,23 +1086,23 @@ const normalizeJsBuildNewlines = async (pattern, options = {}) => {
|
|
|
1139
1086
|
if (err.code === "ENOENT") continue;
|
|
1140
1087
|
throw err;
|
|
1141
1088
|
}
|
|
1142
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
1089
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
1143
1090
|
actionName: "New Line Normalized",
|
|
1144
1091
|
count,
|
|
1145
1092
|
nameDirect: filePath
|
|
1146
1093
|
});
|
|
1147
1094
|
}
|
|
1148
1095
|
}
|
|
1149
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (filesToClean.size > 0) BUILD_LOGGER.ON_FINISH({
|
|
1096
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (filesToClean.size > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
1150
1097
|
actionName: "Normalize New Lines",
|
|
1151
1098
|
count
|
|
1152
1099
|
});
|
|
1153
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
1100
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
1154
1101
|
actionName: "Normalize New Lines",
|
|
1155
1102
|
reasonEndText: "normalize"
|
|
1156
1103
|
});
|
|
1157
1104
|
} catch (error) {
|
|
1158
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
1105
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
1159
1106
|
actionName: "Normalize New Lines",
|
|
1160
1107
|
error
|
|
1161
1108
|
});
|
|
@@ -1166,7 +1113,7 @@ function runCommand(command, argsOrOptions = [], maybeOptions = {}) {
|
|
|
1166
1113
|
try {
|
|
1167
1114
|
let args;
|
|
1168
1115
|
let options;
|
|
1169
|
-
const isArgsArray =
|
|
1116
|
+
const isArgsArray = require_formatter.isArray(argsOrOptions);
|
|
1170
1117
|
if (isArgsArray) {
|
|
1171
1118
|
args = argsOrOptions;
|
|
1172
1119
|
options = maybeOptions;
|
|
@@ -1195,8 +1142,8 @@ function runCommand(command, argsOrOptions = [], maybeOptions = {}) {
|
|
|
1195
1142
|
});
|
|
1196
1143
|
} catch (err) {
|
|
1197
1144
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
1198
|
-
const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(
|
|
1199
|
-
e.stack = [e.message, ...cleanedBase].join(
|
|
1145
|
+
const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(require_formatter.EOL).slice(1) ?? []).filter((line) => !line.includes("runCommand")));
|
|
1146
|
+
e.stack = [e.message, ...cleanedBase].join(require_formatter.EOL);
|
|
1200
1147
|
reject(e);
|
|
1201
1148
|
return;
|
|
1202
1149
|
}
|
|
@@ -1212,7 +1159,7 @@ function runCommandCapture(command, argsOrOptions = [], maybeOptions = {}) {
|
|
|
1212
1159
|
try {
|
|
1213
1160
|
let args;
|
|
1214
1161
|
let options;
|
|
1215
|
-
const isArgsArray =
|
|
1162
|
+
const isArgsArray = require_formatter.isArray(argsOrOptions);
|
|
1216
1163
|
if (isArgsArray) {
|
|
1217
1164
|
args = argsOrOptions;
|
|
1218
1165
|
options = maybeOptions;
|
|
@@ -1256,40 +1203,40 @@ function runCommandCapture(command, argsOrOptions = [], maybeOptions = {}) {
|
|
|
1256
1203
|
});
|
|
1257
1204
|
} catch (err) {
|
|
1258
1205
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
1259
|
-
const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(
|
|
1260
|
-
e.stack = [e.message, ...cleanedBase].join(
|
|
1206
|
+
const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(require_formatter.EOL).slice(1) ?? []).filter((line) => !line.includes("runCommandCapture")));
|
|
1207
|
+
e.stack = [e.message, ...cleanedBase].join(require_formatter.EOL);
|
|
1261
1208
|
reject(e);
|
|
1262
1209
|
return;
|
|
1263
1210
|
}
|
|
1264
1211
|
});
|
|
1265
1212
|
}
|
|
1266
1213
|
const formatMessageColor = (message, useColors = true) => {
|
|
1267
|
-
return useColors ?
|
|
1214
|
+
return useColors ? require_formatter.picocolors.redBright(message) : message;
|
|
1268
1215
|
};
|
|
1269
1216
|
function formatCommand(command, args, { useColors = true } = {}) {
|
|
1270
1217
|
const hasArgs = args.length > 0;
|
|
1271
|
-
const argsString = hasArgs ? args.map((a) =>
|
|
1218
|
+
const argsString = hasArgs ? args.map((a) => require_formatter.safeStableStringify(a)).join(" ") : "";
|
|
1272
1219
|
if (!hasArgs) return formatMessageColor(command, useColors);
|
|
1273
|
-
if (useColors) return `${
|
|
1220
|
+
if (useColors) return `${require_formatter.picocolors.cyanBright(command)} ${require_formatter.picocolors.gray(argsString)}`;
|
|
1274
1221
|
return `${command} ${argsString}`;
|
|
1275
1222
|
}
|
|
1276
1223
|
function assertValidCommand(command, options) {
|
|
1277
1224
|
const { useColors = true, allowInline = false, apiType } = options || {};
|
|
1278
|
-
if (!
|
|
1279
|
-
const errorMsg = `Invalid command: expected a string, received ${
|
|
1225
|
+
if (!require_formatter.isString(command)) {
|
|
1226
|
+
const errorMsg = `Invalid command: expected a string, received ${require_formatter.safeStableStringify(command)}`;
|
|
1280
1227
|
throw new TypeError(formatMessageColor(errorMsg, useColors));
|
|
1281
1228
|
}
|
|
1282
1229
|
const trimmed = command.trim();
|
|
1283
1230
|
if (trimmed.length === 0) throw new Error(formatMessageColor("Invalid command: command cannot be empty", useColors));
|
|
1284
1231
|
const hasSpace = /\s/.test(trimmed);
|
|
1285
1232
|
if (hasShellSyntax(trimmed)) {
|
|
1286
|
-
const errorMsg =
|
|
1233
|
+
const errorMsg = require_formatter.joinLinesLoose(`Invalid command: "${trimmed}"`, "Shell operators are not supported in this context (e.g. &&, ||, |, >).", "This utility only supports a single command with arguments.");
|
|
1287
1234
|
throw new Error(formatMessageColor(errorMsg, useColors));
|
|
1288
1235
|
}
|
|
1289
1236
|
if (!allowInline && hasSpace) {
|
|
1290
1237
|
const [cmd, ...rest] = trimmed.split(/\s+/);
|
|
1291
1238
|
if (!cmd) throw new Error("Invalid command: unable to resolve executable.");
|
|
1292
|
-
const errorMsg =
|
|
1239
|
+
const errorMsg = require_formatter.joinLinesLoose(`Invalid command: "${trimmed}"`, "Do not include arguments in the command when passing them separately.", `Use: ${apiType}("${cmd}", ${require_formatter.safeStableStringify(rest)})`);
|
|
1293
1240
|
throw new Error(formatMessageColor(errorMsg, useColors));
|
|
1294
1241
|
}
|
|
1295
1242
|
}
|
|
@@ -1322,8 +1269,8 @@ function createProcessError(message, { reason, exitCode, signal, command }, base
|
|
|
1322
1269
|
signal,
|
|
1323
1270
|
command
|
|
1324
1271
|
});
|
|
1325
|
-
const currentStack = error.stack?.split(
|
|
1326
|
-
const base = baseStack?.split(
|
|
1272
|
+
const currentStack = error.stack?.split(require_formatter.EOL) ?? [];
|
|
1273
|
+
const base = baseStack?.split(require_formatter.EOL) ?? [];
|
|
1327
1274
|
const [currentHead, ...currentRest] = currentStack;
|
|
1328
1275
|
const [, ...baseRest] = base;
|
|
1329
1276
|
const cleanedCurrent = stripInternalStack(currentRest);
|
|
@@ -1333,7 +1280,7 @@ function createProcessError(message, { reason, exitCode, signal, command }, base
|
|
|
1333
1280
|
currentHead,
|
|
1334
1281
|
...cleanedCurrent,
|
|
1335
1282
|
...cleanedBase.length ? [...cleanedBase] : []
|
|
1336
|
-
].join(
|
|
1283
|
+
].join(require_formatter.EOL);
|
|
1337
1284
|
Object.defineProperties(error, {
|
|
1338
1285
|
reason: {
|
|
1339
1286
|
value: reason,
|
|
@@ -1352,7 +1299,7 @@ function createProcessError(message, { reason, exitCode, signal, command }, base
|
|
|
1352
1299
|
enumerable: false
|
|
1353
1300
|
}
|
|
1354
1301
|
});
|
|
1355
|
-
error.stack +=
|
|
1302
|
+
error.stack += require_formatter.joinLinesLoose("", "meta:", ` reason: ${require_formatter.formatOptionValue(reason)}`, ` exitCode: ${require_formatter.formatOptionValue(exitCode ?? null)}`, ` signal: ${require_formatter.formatOptionValue(signal ?? null)}`, ` command: ${require_formatter.formatOptionValue(command)}`);
|
|
1356
1303
|
return error;
|
|
1357
1304
|
}
|
|
1358
1305
|
var CommandProcessError = class extends Error {
|
|
@@ -1408,12 +1355,12 @@ function spawnWithLifecycle(command, args, options, config) {
|
|
|
1408
1355
|
const formatError = config?.formatError ?? ((msg, meta) => {
|
|
1409
1356
|
const metaCommand = meta.command.trim();
|
|
1410
1357
|
const hasArgs = meta.args.length > 0;
|
|
1411
|
-
const argsString = hasArgs ? meta.args.map((a) =>
|
|
1358
|
+
const argsString = hasArgs ? meta.args.map((a) => require_formatter.safeStableStringify(a).trim()).join(" ") : "";
|
|
1412
1359
|
const commandString = hasArgs ? `${metaCommand} ${argsString}` : metaCommand;
|
|
1413
1360
|
if (meta.useColors) {
|
|
1414
|
-
const cmd =
|
|
1415
|
-
const args = hasArgs ?
|
|
1416
|
-
return createProcessError(`${cmd}${args ? " " + args : ""} ${
|
|
1361
|
+
const cmd = require_formatter.picocolors.magentaBright(metaCommand);
|
|
1362
|
+
const args = hasArgs ? require_formatter.picocolors.yellowBright(argsString) : "";
|
|
1363
|
+
return createProcessError(`${cmd}${args ? " " + args : ""} ${require_formatter.picocolors.redBright(msg)}`, {
|
|
1417
1364
|
...meta,
|
|
1418
1365
|
command: commandString
|
|
1419
1366
|
}, baseStack);
|
|
@@ -1576,7 +1523,7 @@ const VALID_ECMA_VERSION = new Set([
|
|
|
1576
1523
|
const REGION_COMMENT_RE = /^#(?:end)?region\b/i;
|
|
1577
1524
|
const SOURCE_MAP_COMMENT_RE = /^[#@]\s*sourceMappingURL=/;
|
|
1578
1525
|
function normalizeNewlines(code) {
|
|
1579
|
-
return code.replace(/[ \t]+\n/g,
|
|
1526
|
+
return code.replace(/[ \t]+\n/g, require_formatter.EOL).replace(/\n\s*\n+/g, require_formatter.EOL);
|
|
1580
1527
|
}
|
|
1581
1528
|
function stripComments(code, { removeRegion, removeSourceMap, sourceType, ecmaVersion }) {
|
|
1582
1529
|
const comments = [];
|
|
@@ -1642,27 +1589,27 @@ function stripComments(code, { removeRegion, removeSourceMap, sourceType, ecmaVe
|
|
|
1642
1589
|
let out = line.replace(/^[ \t]*\/\/\s*(?:\.\.\/|\.\/)*[^ \n]*?(?:src|node_modules)\/[^\n]*\n?/gm, "").replace(/\/\/\s*eslint[^\n]*/g, "");
|
|
1643
1590
|
out = out.replace(/(\/\/[#@]\s*sourceMappingURL=[^\r\n]*)(?:\r?\n\1)+/g, "$1");
|
|
1644
1591
|
return out;
|
|
1645
|
-
}).join(
|
|
1592
|
+
}).join(require_formatter.EOL);
|
|
1646
1593
|
}
|
|
1647
1594
|
const commandSjcIdentity = new require_identity.CommandIdentity({ defaultCommandName: "strip-js-comments" });
|
|
1648
1595
|
const stripJsComments = async (pattern, options = {}) => {
|
|
1649
1596
|
const loggerLevel = resolveLogVerbosity(options, DEFAULT_SJC_OPTIONS.logLevel);
|
|
1650
1597
|
try {
|
|
1651
1598
|
const { patternOptions = DEFAULT_SJC_OPTIONS.patternOptions, removeSourceMap = DEFAULT_SJC_OPTIONS.removeSourceMap, removeRegion = DEFAULT_SJC_OPTIONS.removeRegion, sourceType = DEFAULT_SJC_OPTIONS.sourceType, ecmaVersion = DEFAULT_SJC_OPTIONS.ecmaVersion, __commandTitle } = options;
|
|
1652
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(
|
|
1653
|
-
const patterns = [...
|
|
1599
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_formatter.joinLinesLoose(require_formatter.isNonEmptyString(__commandTitle) ? __commandTitle : commandSjcIdentity.utility(), ""));
|
|
1600
|
+
const patterns = [...require_formatter.toStringSet(pattern)];
|
|
1654
1601
|
const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_SJC_PATTERN_POLICY);
|
|
1655
1602
|
if (canLog(loggerLevel, VERBOSE_LOG)) {
|
|
1656
|
-
BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
1657
|
-
BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
1658
|
-
BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_SJC_OPTIONS.patternOptions));
|
|
1659
|
-
BUILD_LOGGER.OPTIONS("options.removeSourceMap", removeSourceMap, BUILD_LOGGER.SOURCE_OF(removeSourceMap, DEFAULT_SJC_OPTIONS.removeSourceMap));
|
|
1660
|
-
BUILD_LOGGER.OPTIONS("options.removeRegion", removeRegion, BUILD_LOGGER.SOURCE_OF(removeRegion, DEFAULT_SJC_OPTIONS.removeRegion));
|
|
1661
|
-
BUILD_LOGGER.OPTIONS("options.sourceType", sourceType, BUILD_LOGGER.SOURCE_OF(sourceType, DEFAULT_SJC_OPTIONS.sourceType));
|
|
1662
|
-
BUILD_LOGGER.OPTIONS("options.ecmaVersion", ecmaVersion, BUILD_LOGGER.SOURCE_OF(ecmaVersion, DEFAULT_SJC_OPTIONS.ecmaVersion));
|
|
1663
|
-
BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_SJC_OPTIONS.logLevel));
|
|
1664
|
-
BUILD_LOGGER.NEW_LINE();
|
|
1665
|
-
BUILD_LOGGER.ON_STARTING({ actionName: "Stripping JS Comments" });
|
|
1603
|
+
require_server.BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
|
|
1604
|
+
require_server.BUILD_LOGGER.OPTIONS("pattern", patterns, require_server.BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
|
|
1605
|
+
require_server.BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_SJC_OPTIONS.patternOptions));
|
|
1606
|
+
require_server.BUILD_LOGGER.OPTIONS("options.removeSourceMap", removeSourceMap, require_server.BUILD_LOGGER.SOURCE_OF(removeSourceMap, DEFAULT_SJC_OPTIONS.removeSourceMap));
|
|
1607
|
+
require_server.BUILD_LOGGER.OPTIONS("options.removeRegion", removeRegion, require_server.BUILD_LOGGER.SOURCE_OF(removeRegion, DEFAULT_SJC_OPTIONS.removeRegion));
|
|
1608
|
+
require_server.BUILD_LOGGER.OPTIONS("options.sourceType", sourceType, require_server.BUILD_LOGGER.SOURCE_OF(sourceType, DEFAULT_SJC_OPTIONS.sourceType));
|
|
1609
|
+
require_server.BUILD_LOGGER.OPTIONS("options.ecmaVersion", ecmaVersion, require_server.BUILD_LOGGER.SOURCE_OF(ecmaVersion, DEFAULT_SJC_OPTIONS.ecmaVersion));
|
|
1610
|
+
require_server.BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, require_server.BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_SJC_OPTIONS.logLevel));
|
|
1611
|
+
require_server.BUILD_LOGGER.NEW_LINE();
|
|
1612
|
+
require_server.BUILD_LOGGER.ON_STARTING({ actionName: "Stripping JS Comments" });
|
|
1666
1613
|
}
|
|
1667
1614
|
const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
|
|
1668
1615
|
let count = 0;
|
|
@@ -1683,7 +1630,7 @@ const stripJsComments = async (pattern, options = {}) => {
|
|
|
1683
1630
|
sourceType,
|
|
1684
1631
|
ecmaVersion
|
|
1685
1632
|
});
|
|
1686
|
-
output = normalizeNewlines(output).trim() +
|
|
1633
|
+
output = normalizeNewlines(output).trim() + require_formatter.EOL;
|
|
1687
1634
|
if (output !== content) {
|
|
1688
1635
|
try {
|
|
1689
1636
|
await require_server.fsExtra.promises.writeFile(filePath, output, "utf8");
|
|
@@ -1692,24 +1639,24 @@ const stripJsComments = async (pattern, options = {}) => {
|
|
|
1692
1639
|
throw err;
|
|
1693
1640
|
}
|
|
1694
1641
|
count++;
|
|
1695
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
|
|
1642
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) require_server.BUILD_LOGGER.ON_PROCESS({
|
|
1696
1643
|
actionName: "JS Comment Stripping",
|
|
1697
1644
|
count,
|
|
1698
1645
|
nameDirect: filePath
|
|
1699
1646
|
});
|
|
1700
1647
|
}
|
|
1701
1648
|
}
|
|
1702
|
-
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
|
|
1649
|
+
if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) require_server.BUILD_LOGGER.ON_FINISH({
|
|
1703
1650
|
actionName: "Stripping JS Comments",
|
|
1704
1651
|
count
|
|
1705
1652
|
});
|
|
1706
|
-
else BUILD_LOGGER.ON_SKIPPING({
|
|
1653
|
+
else require_server.BUILD_LOGGER.ON_SKIPPING({
|
|
1707
1654
|
actionName: "Stripping JS Comments",
|
|
1708
1655
|
reasonType: "file",
|
|
1709
1656
|
reasonEndText: "processing"
|
|
1710
1657
|
});
|
|
1711
1658
|
} catch (error) {
|
|
1712
|
-
if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
|
|
1659
|
+
if (loggerLevel !== "silent") require_server.BUILD_LOGGER.ON_ERROR({
|
|
1713
1660
|
actionName: "Stripping JS Comments",
|
|
1714
1661
|
error
|
|
1715
1662
|
});
|