@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
|
@@ -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,10 +10,10 @@
|
|
|
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 require_client = require('../client-
|
|
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_client = require('../client-BxJj_VrQ.cjs');
|
|
17
17
|
require("@rzl-zone/node-only");
|
|
18
18
|
let node_path = require("node:path");
|
|
19
19
|
let commander = require("commander");
|
|
@@ -30,7 +30,7 @@ function getCommanderErrorCode(err) {
|
|
|
30
30
|
}
|
|
31
31
|
var CliCommand = class extends commander.Command {
|
|
32
32
|
constructor(name) {
|
|
33
|
-
name =
|
|
33
|
+
name = require_formatter.isNonEmptyString(name) ? name : void 0;
|
|
34
34
|
super(name);
|
|
35
35
|
}
|
|
36
36
|
usage(str) {
|
|
@@ -38,7 +38,7 @@ var CliCommand = class extends commander.Command {
|
|
|
38
38
|
super.usage("");
|
|
39
39
|
return this;
|
|
40
40
|
}
|
|
41
|
-
if (!
|
|
41
|
+
if (!require_formatter.isNonEmptyString(str)) return super.usage();
|
|
42
42
|
return super.usage(str);
|
|
43
43
|
}
|
|
44
44
|
version(str, flags, description) {
|
|
@@ -46,7 +46,7 @@ var CliCommand = class extends commander.Command {
|
|
|
46
46
|
super.version("");
|
|
47
47
|
return this;
|
|
48
48
|
}
|
|
49
|
-
if (!
|
|
49
|
+
if (!require_formatter.isNonEmptyString(str)) return super.version();
|
|
50
50
|
return super.version(str, flags, description);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
@@ -59,11 +59,28 @@ function handleCommanderExit(err) {
|
|
|
59
59
|
console.error(err);
|
|
60
60
|
process.exit(1);
|
|
61
61
|
}
|
|
62
|
+
//! Reject primitive values: prototype chains only exist on object-like entities
|
|
63
|
+
//! Safety guard: If target has no prototype (e.g., Object.create(null)), match is impossible
|
|
64
|
+
//! Constraint: Primitives do not have prototype chains and cannot be instances
|
|
62
65
|
function isExactInstanceOf(value, ctor) {
|
|
63
66
|
//! Constraint: Immediately reject primitives
|
|
64
67
|
if (value === null || typeof value !== "object" && typeof value !== "function") return false;
|
|
65
68
|
return Object.getPrototypeOf(value) === ctor.prototype;
|
|
66
69
|
}
|
|
70
|
+
//! Requirement: Must be a function to even be a candidate for a constructor
|
|
71
|
+
//! Safety Guard: If toString fails (e.g. on certain Proxy types), reject immediately
|
|
72
|
+
//! Logic Boundary: If it lacks both ES6 class syntax and native constructor markers, reject as regular function
|
|
73
|
+
//! also Reject ordinary functions that are not constructable class-like entities
|
|
74
|
+
//! Validity constructor must have valid prototype object
|
|
75
|
+
//! Identity Verification: The back-reference must strictly equal the original function
|
|
76
|
+
//! Panic Guard: Catch errors from potential 'poisoned' prototypes or proxy traps
|
|
77
|
+
//! Reference Matching: Ensure the descriptor's value is the exact same object as the prototype link
|
|
78
|
+
//! NOTE:
|
|
79
|
+
//! Native class constructors (e.g. Map, Set, Promise, Error)
|
|
80
|
+
//! may have non-writable prototype properties.
|
|
81
|
+
//!
|
|
82
|
+
//! Therefore, checking descriptor.value identity is sufficient
|
|
83
|
+
//! to confirm structural integrity without enforcing write-ability.
|
|
67
84
|
var CliHelp = class extends commander.Help {
|
|
68
85
|
constructor() {
|
|
69
86
|
super();
|
|
@@ -165,25 +182,25 @@ function setInternalUiState(cmd, input) {
|
|
|
165
182
|
}
|
|
166
183
|
function createUIState(input) {
|
|
167
184
|
const result = {};
|
|
168
|
-
if (
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
185
|
+
if (require_formatter.isNonEmptyString(input.title)) result.title = input.title;
|
|
186
|
+
if (require_formatter.isNonEmptyString(input.usage)) result.usage = input.usage;
|
|
187
|
+
if (require_formatter.isNonEmptyString(input.packageName)) result.packageName = input.packageName;
|
|
188
|
+
if (require_formatter.isNonEmptyString(input.version)) result.version = input.version;
|
|
172
189
|
return result;
|
|
173
190
|
}
|
|
174
191
|
function styleUsage(raw, { fromHelpCommandUsage, errorConfig: { field = "raw", expected = "a non-empty string", context = "styleUsage" } = {} } = {}) {
|
|
175
|
-
if (!
|
|
192
|
+
if (!require_formatter.isNonEmptyString(raw)) throw require_client.ConfigurationError.type(field, expected, raw, context);
|
|
176
193
|
return raw.split(/\s+/).map((token, index) => {
|
|
177
|
-
if (!!fromHelpCommandUsage && index === 0) return
|
|
178
|
-
if (token === "[options]") return
|
|
179
|
-
if (token === "[command]") return
|
|
180
|
-
if (token.startsWith("<") && token.endsWith(">")) return
|
|
181
|
-
if (token.startsWith("[") && token.endsWith("]")) return
|
|
194
|
+
if (!!fromHelpCommandUsage && index === 0) return require_formatter.picocolors.cyanBright(token);
|
|
195
|
+
if (token === "[options]") return require_formatter.picocolors.blueBright(token);
|
|
196
|
+
if (token === "[command]") return require_formatter.picocolors.magentaBright(token);
|
|
197
|
+
if (token.startsWith("<") && token.endsWith(">")) return require_formatter.picocolors.gray(token);
|
|
198
|
+
if (token.startsWith("[") && token.endsWith("]")) return require_formatter.picocolors.gray(token);
|
|
182
199
|
return token;
|
|
183
200
|
}).join(" ");
|
|
184
201
|
}
|
|
185
202
|
function reorderUsage(raw, { errorConfig: { field = "raw", expected = "a non-empty string", context = "reorderUsage" } = {} } = {}) {
|
|
186
|
-
if (!
|
|
203
|
+
if (!require_formatter.isNonEmptyString(raw)) throw require_client.ConfigurationError.type(field, expected, raw, context);
|
|
187
204
|
const tokens = raw.match(/\S+/g) ?? [];
|
|
188
205
|
const optionTokens = tokens.filter((t) => t === "[options]");
|
|
189
206
|
return [...tokens.filter((t) => t !== "[options]"), ...optionTokens].join(" ");
|
|
@@ -195,8 +212,8 @@ var StyledHelp = class extends CliHelp {
|
|
|
195
212
|
commandUsage(cmd) {
|
|
196
213
|
const { manualUsage, ui, disableUsage } = getInternalState(cmd);
|
|
197
214
|
if (disableUsage) return "";
|
|
198
|
-
if (
|
|
199
|
-
if (
|
|
215
|
+
if (require_formatter.isNonEmptyString(manualUsage)) return manualUsage;
|
|
216
|
+
if (require_formatter.isNonEmptyString(ui?.usage)) return ui.usage;
|
|
200
217
|
return styleUsage(reorderUsage(super.commandUsage(cmd), { errorConfig: {
|
|
201
218
|
field: "`super.commandUsage(cmd)`",
|
|
202
219
|
context: "StyledHelp.commandUsage"
|
|
@@ -210,20 +227,20 @@ var StyledHelp = class extends CliHelp {
|
|
|
210
227
|
}
|
|
211
228
|
formatHelp(cmd, helper) {
|
|
212
229
|
const usage = this.commandUsage(cmd);
|
|
213
|
-
const usageBlock =
|
|
230
|
+
const usageBlock = require_formatter.joinLinesLoose(require_formatter.picocolors.reset("Usage:"), ` ${usage}`);
|
|
214
231
|
const rest = super.formatHelp(cmd, helper);
|
|
215
232
|
if (!usage) return rest.replace(/^Usage:[\s\S]*?\n(?=\S)/, "");
|
|
216
|
-
return rest.replace(/^Usage:[\s\S]*?\n(?=\S)/, usageBlock +
|
|
233
|
+
return rest.replace(/^Usage:[\s\S]*?\n(?=\S)/, usageBlock + require_formatter.EOL + require_formatter.EOL);
|
|
217
234
|
}
|
|
218
235
|
optionDescription(option) {
|
|
219
236
|
let desc = option.description || "";
|
|
220
237
|
const hasDefault = option.defaultValue !== void 0;
|
|
221
|
-
if (
|
|
238
|
+
if (require_formatter.isNonEmptyString(desc)) {
|
|
222
239
|
desc = desc.trim();
|
|
223
240
|
if (hasDefault) {
|
|
224
241
|
if (desc.endsWith(".")) desc = desc.slice(0, -1) + "";
|
|
225
242
|
else if (!desc.endsWith(",")) desc += "";
|
|
226
|
-
desc += ` ${
|
|
243
|
+
desc += ` ${require_formatter.picocolors.italic(`(default: ${require_formatter.formatOptionValue(option.defaultValue)})`)}.`;
|
|
227
244
|
} else if (!desc.trim().endsWith(".")) desc += ".";
|
|
228
245
|
}
|
|
229
246
|
return desc;
|
|
@@ -238,13 +255,13 @@ function resolveInstanceOriginErrorSuffix(programCommand) {
|
|
|
238
255
|
function interceptUsage(cmd) {
|
|
239
256
|
const originalUsage = cmd.usage.bind(cmd);
|
|
240
257
|
function usage(str) {
|
|
241
|
-
if (!
|
|
258
|
+
if (!require_formatter.isNil(str)) {
|
|
242
259
|
if (str === false) {
|
|
243
260
|
getInternalState(cmd).manualUsage = void 0;
|
|
244
261
|
getInternalState(cmd).disableUsage = true;
|
|
245
262
|
return cmd;
|
|
246
263
|
}
|
|
247
|
-
if (!
|
|
264
|
+
if (!require_formatter.isNonEmptyString(str)) {
|
|
248
265
|
const errorMessageByFactory = resolveFactoryOriginErrorSuffix(cmd);
|
|
249
266
|
const errorMessageInstance = resolveInstanceOriginErrorSuffix(cmd);
|
|
250
267
|
throw require_client.ConfigurationError.type("usage", "a non-empty string or `false` only", str, `'${errorMessageInstance}.usage'${errorMessageByFactory}`);
|
|
@@ -256,7 +273,7 @@ function interceptUsage(cmd) {
|
|
|
256
273
|
}
|
|
257
274
|
cmd.usage = usage;
|
|
258
275
|
}
|
|
259
|
-
const COMMANDER_UI_DEFAULTS =
|
|
276
|
+
const COMMANDER_UI_DEFAULTS = require_formatter.deepFreeze({
|
|
260
277
|
FLAGS: {
|
|
261
278
|
VERSION: "-v, --version",
|
|
262
279
|
HELP: "-h, --help"
|
|
@@ -275,15 +292,15 @@ function interceptHelp(cmd) {
|
|
|
275
292
|
cmd.helpOption = function(flags, description) {
|
|
276
293
|
const errorMessageByFactory = resolveFactoryOriginErrorSuffix(cmd);
|
|
277
294
|
const errorMessageInstance = resolveInstanceOriginErrorSuffix(cmd);
|
|
278
|
-
if (!
|
|
295
|
+
if (!require_formatter.isNil(flags) && !require_formatter.isNonEmptyString(flags) && !require_formatter.isBoolean(flags)) {
|
|
279
296
|
resetInternalHelpState(cmd);
|
|
280
297
|
throw require_client.ConfigurationError.type("flags", "a non-empty string or a boolean", flags, `'${errorMessageInstance}.helpOption'${errorMessageByFactory}`);
|
|
281
298
|
}
|
|
282
|
-
if (!
|
|
299
|
+
if (!require_formatter.isNil(description) && !require_formatter.isNonEmptyString(description)) {
|
|
283
300
|
resetInternalHelpState(cmd);
|
|
284
301
|
throw require_client.ConfigurationError.type("description", "a non-empty string if provided", description, `'${errorMessageInstance}.helpOption'${errorMessageByFactory}`);
|
|
285
302
|
}
|
|
286
|
-
const _decs =
|
|
303
|
+
const _decs = require_formatter.isNonEmptyString(description) ? description : DESCRIPTIONS$2.HELP;
|
|
287
304
|
if (flags === false) {
|
|
288
305
|
getInternalState(cmd).help = { disabled: true };
|
|
289
306
|
return original(flags);
|
|
@@ -296,7 +313,7 @@ function interceptHelp(cmd) {
|
|
|
296
313
|
};
|
|
297
314
|
return original(flags, _decs);
|
|
298
315
|
}
|
|
299
|
-
if (
|
|
316
|
+
if (require_formatter.isNonEmptyString(flags)) {
|
|
300
317
|
getInternalState(cmd).help = {
|
|
301
318
|
flags,
|
|
302
319
|
description: _decs,
|
|
@@ -320,11 +337,11 @@ function interceptVersion(cmd, versionDescription) {
|
|
|
320
337
|
}
|
|
321
338
|
const errorMessageByFactory = resolveFactoryOriginErrorSuffix(cmd);
|
|
322
339
|
const errorMessageInstance = resolveInstanceOriginErrorSuffix(cmd);
|
|
323
|
-
if (!
|
|
324
|
-
if (!
|
|
325
|
-
if (!
|
|
326
|
-
const _flag =
|
|
327
|
-
const _decs =
|
|
340
|
+
if (!require_formatter.isNonEmptyString(value)) throw require_client.ConfigurationError.type("str", "a non-empty string", value, `'${errorMessageInstance}.version'${errorMessageByFactory}`);
|
|
341
|
+
if (!require_formatter.isNil(flags) && !require_formatter.isNonEmptyString(flags)) throw require_client.ConfigurationError.type("flags", "a non-empty string if provided", flags, `'${errorMessageInstance}.version'${errorMessageByFactory}`);
|
|
342
|
+
if (!require_formatter.isNil(description) && !require_formatter.isNonEmptyString(description)) throw require_client.ConfigurationError.type("description", "a non-empty string if provided", description, `'${errorMessageInstance}.version'${errorMessageByFactory}`);
|
|
343
|
+
const _flag = require_formatter.isNonEmptyString(flags) ? flags : FLAGS$2.VERSION;
|
|
344
|
+
const _decs = require_formatter.isNonEmptyString(description) ? description : versionDescription;
|
|
328
345
|
getInternalState(cmd).versionMeta = {
|
|
329
346
|
value,
|
|
330
347
|
flags: _flag,
|
|
@@ -342,37 +359,37 @@ var CliArgument = class extends commander.Argument {
|
|
|
342
359
|
};
|
|
343
360
|
const { DESCRIPTIONS: DESCRIPTIONS$1, FLAGS: FLAGS$1 } = COMMANDER_UI_DEFAULTS;
|
|
344
361
|
const composeVersionDescription = (packageName) => {
|
|
345
|
-
const isPkgNameEmptyString = !
|
|
346
|
-
if (!
|
|
362
|
+
const isPkgNameEmptyString = !require_formatter.isNonEmptyString(packageName);
|
|
363
|
+
if (!require_formatter.isUndefined(packageName) && isPkgNameEmptyString) throw require_client.ConfigurationError.type("packageName", "a non-empty string", packageName, "composeVersionDescription");
|
|
347
364
|
return (!isPkgNameEmptyString ? `The version package of ${packageName}.` : DESCRIPTIONS$1.VERSION).trim().replace(/\.*$/, "") + ".";
|
|
348
365
|
};
|
|
349
366
|
function normalizeVersionPrefix(version) {
|
|
350
|
-
if (!
|
|
351
|
-
if (
|
|
367
|
+
if (!require_formatter.isNil(version) && !require_formatter.isNonEmptyString(version)) throw require_client.ConfigurationError.type("version", "a non-empty string, null or undefined", version, "composeVersionDescription");
|
|
368
|
+
if (require_formatter.isNull(version)) return null;
|
|
352
369
|
return version?.replace(/^v(?=\d)/, "");
|
|
353
370
|
}
|
|
354
371
|
function ensureVersionInjected(cmd, options) {
|
|
355
372
|
const { pkgNameFormatted, normalizedVersion } = options;
|
|
356
373
|
const _internal = getInternalState(cmd);
|
|
357
374
|
if (!_internal.versionSetByUser && !_internal.versionInjected) {
|
|
358
|
-
const _isNonEmptyString =
|
|
375
|
+
const _isNonEmptyString = require_formatter.isNonEmptyString(pkgNameFormatted);
|
|
359
376
|
const _pkgName = _isNonEmptyString ? pkgNameFormatted : void 0;
|
|
360
|
-
const _subTitle = _isNonEmptyString ? `${pkgNameFormatted} ${
|
|
361
|
-
_internal.versionOriginal?.(
|
|
377
|
+
const _subTitle = _isNonEmptyString ? `${pkgNameFormatted} ${require_formatter.picocolors.reset("version")}:` : `${require_formatter.picocolors.blueBright("Version")}:`;
|
|
378
|
+
_internal.versionOriginal?.(require_formatter.joinLinesLoose(_subTitle, require_formatter.joinInline(`${require_formatter.picocolors.magentaBright(require_server.ICONS.arrowRight)}`, `${require_formatter.picocolors.gray(`v${normalizedVersion}`)}`)), FLAGS$1.VERSION, composeVersionDescription(_pkgName));
|
|
362
379
|
_internal.versionInjected = true;
|
|
363
380
|
}
|
|
364
381
|
}
|
|
365
382
|
function resolveBaseProgramPresentationMeta(params) {
|
|
366
383
|
const { cliName, packageName, packageVersion, commandIdentity, ui } = params;
|
|
367
|
-
const resolvedCliName =
|
|
384
|
+
const resolvedCliName = require_formatter.isNonEmptyString(cliName) ? cliName : require_formatter.isNonEmptyString(commandIdentity?.commandName) ? commandIdentity.commandName : require_formatter.isNonEmptyString(process.argv[1]) ? (0, node_path.parse)(process.argv[1]).name : void 0;
|
|
368
385
|
const identityTitle = commandIdentity?.cli?.();
|
|
369
|
-
const commandTitle =
|
|
370
|
-
const resolvedPackageName =
|
|
371
|
-
const resolvedPackageVersion =
|
|
386
|
+
const commandTitle = require_formatter.isNonEmptyString(identityTitle) ? identityTitle : require_formatter.isNonEmptyString(ui?.title) ? ui.title : void 0;
|
|
387
|
+
const resolvedPackageName = require_formatter.isNonEmptyString(packageName) ? packageName : require_formatter.isNonEmptyString(commandIdentity?.packageName) ? commandIdentity.packageName : require_identity.PACKAGE_META.name;
|
|
388
|
+
const resolvedPackageVersion = require_formatter.isNonEmptyString(packageVersion) ? packageVersion : require_formatter.isNonEmptyString(commandIdentity?.version) ? commandIdentity.version : require_identity.PACKAGE_META.version;
|
|
372
389
|
const normalizedVersion = normalizeVersionPrefix(resolvedPackageVersion);
|
|
373
390
|
const isDiffCommandName = !!resolvedCliName && resolvedCliName !== require_identity.PACKAGE_META.name;
|
|
374
|
-
const pkgNameFormatted = `${
|
|
375
|
-
const defaultTitleFormatted =
|
|
391
|
+
const pkgNameFormatted = `${require_formatter.picocolors.blueBright(resolvedPackageName)}${isDiffCommandName ? ` ${require_formatter.picocolors.cyanBright(`(${resolvedCliName})`)}` : ""}`;
|
|
392
|
+
const defaultTitleFormatted = require_formatter.joinInline(require_formatter.picocolors.blueBright(require_identity.PACKAGE_META.name + "@" + normalizedVersion), isDiffCommandName ? `${require_formatter.picocolors.magentaBright(require_server.ICONS.arrowRight)} ${require_formatter.picocolors.yellowBright(resolvedCliName)}` : false);
|
|
376
393
|
return Object.freeze({
|
|
377
394
|
resolvedCliName,
|
|
378
395
|
commandTitle,
|
|
@@ -428,7 +445,7 @@ function createBaseProgram(options = {}) {
|
|
|
428
445
|
interceptHelp(cmd);
|
|
429
446
|
interceptVersion(cmd, composeVersionDescription(pkgNameFormatted));
|
|
430
447
|
cmd.createHelp = () => new StyledHelp();
|
|
431
|
-
cmd.addHelpText("before",
|
|
448
|
+
cmd.addHelpText("before", require_formatter.joinLinesLoose("", commandTitle ?? defaultTitleFormatted, ""));
|
|
432
449
|
cmd.exitOverride(handleCommanderExit);
|
|
433
450
|
const cmdApplyUi = applyCommanderUi(cmd, {
|
|
434
451
|
title: commandTitle,
|
|
@@ -446,21 +463,21 @@ function resolveCliPresentationMeta(params) {
|
|
|
446
463
|
const { program, commandName, title, version, packageName } = params;
|
|
447
464
|
const _internal = getInternalState(program);
|
|
448
465
|
const isCommandBaseProgram = isExactInstanceOf(program, CommandBaseProgram);
|
|
449
|
-
const resolvedCliName =
|
|
466
|
+
const resolvedCliName = require_formatter.isNonEmptyString(commandName) ? commandName : require_formatter.isNonEmptyString(process.argv[1]) ? (0, node_path.parse)(process.argv[1]).name : void 0;
|
|
450
467
|
const isDiffCommandName = !!resolvedCliName && resolvedCliName !== require_identity.PACKAGE_META.name;
|
|
451
|
-
const commandTitle =
|
|
452
|
-
let normalizedVersion = normalizeVersionPrefix(!isCommandBaseProgram &&
|
|
453
|
-
normalizedVersion =
|
|
454
|
-
const defaultTitleFormatted =
|
|
455
|
-
const dynamicUsage =
|
|
468
|
+
const commandTitle = require_formatter.isNonEmptyString(commandName) ? commandName : require_formatter.isNonEmptyString(title) ? title : void 0;
|
|
469
|
+
let normalizedVersion = normalizeVersionPrefix(!isCommandBaseProgram && require_formatter.isNonEmptyString(version) ? version : require_formatter.isNonEmptyString(_internal.versionMeta?.value) ? _internal.versionMeta.value : void 0);
|
|
470
|
+
normalizedVersion = require_formatter.isNonEmptyString(normalizedVersion) ? normalizedVersion : normalizeVersionPrefix(require_identity.PACKAGE_META.version);
|
|
471
|
+
const defaultTitleFormatted = require_formatter.joinInline(require_formatter.picocolors.blueBright((require_formatter.isNonEmptyString(_internal.packageName) ? _internal.packageName : require_identity.PACKAGE_META.name) + "@" + normalizedVersion), isDiffCommandName ? `${require_formatter.picocolors.magentaBright(require_server.ICONS.arrowRight)} ${require_formatter.picocolors.yellowBright(resolvedCliName)}` : false);
|
|
472
|
+
const dynamicUsage = require_formatter.isNonEmptyString(_internal.manualUsage) ? _internal.manualUsage : require_formatter.isNonEmptyString(_internal.ui?.usage) ? _internal.ui.usage : (isDiffCommandName ? `${require_formatter.picocolors.cyanBright(resolvedCliName)} ` : "") + (require_formatter.isNonEmptyString(program.usage()) ? styleUsage(reorderUsage(program.usage(), { errorConfig: {
|
|
456
473
|
field: "`program.usage()`",
|
|
457
474
|
context: "resolveCliPresentationMeta (by `program.usage()` at const variable 'dynamicUsage')"
|
|
458
475
|
} }), { errorConfig: {
|
|
459
476
|
field: "`reorderUsage(program.usage())`",
|
|
460
477
|
context: "resolveCliPresentationMeta (by `reorderUsage(program.usage())` at const variable 'dynamicUsage')"
|
|
461
478
|
} }) : "");
|
|
462
|
-
const resolvedPackageName =
|
|
463
|
-
const resolvedPackageNameFormatted = `${
|
|
479
|
+
const resolvedPackageName = require_formatter.isNonEmptyString(packageName) ? packageName : require_identity.PACKAGE_META.name;
|
|
480
|
+
const resolvedPackageNameFormatted = `${require_formatter.picocolors.blueBright(resolvedPackageName)}${isDiffCommandName ? ` ${require_formatter.picocolors.cyanBright(`(${resolvedCliName})`)}` : ""}`;
|
|
464
481
|
const helpMeta = _internal.help;
|
|
465
482
|
const isHelpDisabled = helpMeta?.disabled === true;
|
|
466
483
|
const helpFlags = helpMeta?.flags ?? FLAGS.HELP;
|
|
@@ -501,7 +518,7 @@ function applyCommanderUi(program, options) {
|
|
|
501
518
|
interceptHelp(program);
|
|
502
519
|
interceptVersion(program, composeVersionDescription(resolvedPackageNameFormatted));
|
|
503
520
|
program.createHelp = () => new StyledHelp();
|
|
504
|
-
program.addHelpText("before",
|
|
521
|
+
program.addHelpText("before", require_formatter.joinLinesLoose("", commandTitle ?? defaultTitleFormatted, ""));
|
|
505
522
|
program.exitOverride(handleCommanderExit);
|
|
506
523
|
installParseVersionInterceptor(program, { versionInjection: {
|
|
507
524
|
normalizedVersion,
|
|
@@ -518,13 +535,13 @@ function applyCommanderUi(program, options) {
|
|
|
518
535
|
commandName: __commandName
|
|
519
536
|
});
|
|
520
537
|
const printOut = [
|
|
521
|
-
|
|
538
|
+
require_formatter.isNonEmptyString(title) ? title : defaultTitleFormatted,
|
|
522
539
|
"",
|
|
523
|
-
`${
|
|
540
|
+
`${require_formatter.picocolors.bold(`${require_formatter.picocolors.red(`${require_server.ICONS.error} Error`)}`)} ${require_formatter.picocolors.redBright(errMsg)}`
|
|
524
541
|
];
|
|
525
|
-
if (!disableUsage &&
|
|
526
|
-
if (!help.disabled) printOut.push("", `${
|
|
527
|
-
console.error(
|
|
542
|
+
if (!disableUsage && require_formatter.isNonEmptyString(dynamicUsage)) printOut.push("", require_formatter.picocolors.bold("Usage:"), ` ${require_formatter.picocolors.reset(require_formatter.picocolors.gray(dynamicUsage))}`);
|
|
543
|
+
if (!help.disabled) printOut.push("", `${require_formatter.picocolors.dim("Run")} ${require_formatter.picocolors.cyanBright(help.flags)} ${require_formatter.picocolors.dim(help.description)}`);
|
|
544
|
+
console.error(require_formatter.joinLinesLoose(...printOut));
|
|
528
545
|
process.exit(1);
|
|
529
546
|
};
|
|
530
547
|
return program;
|
|
@@ -548,6 +565,8 @@ var CliInvalidOptionArgumentError = class extends commander.InvalidOptionArgumen
|
|
|
548
565
|
const cliCreateArgument = (name, description) => new CliArgument(name, description);
|
|
549
566
|
const cliCreateCommand = (name) => new CliCommand(name);
|
|
550
567
|
const cliCreateOption = (arg, description) => new CliOption(arg, description);
|
|
568
|
+
//! --- CLI ---
|
|
569
|
+
//! --- CLI TYPE ---
|
|
551
570
|
exports.CliArgument = CliArgument;
|
|
552
571
|
exports.CliCommand = CliCommand;
|
|
553
572
|
exports.CliCommanderError = CliCommanderError;
|