@rzl-zone/build-tools 0.0.9 → 0.0.11

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.
Files changed (65) hide show
  1. package/dist/.references/index.d.cts +1 -1
  2. package/dist/.references/index.d.ts +1 -1
  3. package/dist/bundler/rolldown.cjs +2 -2
  4. package/dist/bundler/rolldown.d.cts +2 -2
  5. package/dist/bundler/rolldown.d.ts +2 -2
  6. package/dist/bundler/rolldown.js +1 -1
  7. package/dist/bundler/tsdown.cjs +3 -3
  8. package/dist/bundler/tsdown.d.cts +2 -2
  9. package/dist/bundler/tsdown.d.ts +2 -2
  10. package/dist/bundler/tsdown.js +3 -3
  11. package/dist/bundler/utils.cjs +2 -2
  12. package/dist/bundler/utils.d.cts +2 -2
  13. package/dist/bundler/utils.d.ts +2 -2
  14. package/dist/bundler/utils.js +2 -2
  15. package/dist/{client-C3jHSAqV.cjs → client-CuivP4z0.cjs} +3 -3
  16. package/dist/client-CuivP4z0.cjs.map +1 -0
  17. package/dist/{client-DUlrjus0.js → client-DzeqTq6Y.js} +3 -3
  18. package/dist/client-DzeqTq6Y.js.map +1 -0
  19. package/dist/commander-kit/index.cjs +5 -5
  20. package/dist/commander-kit/index.cjs.map +1 -1
  21. package/dist/commander-kit/index.d.cts +3 -3
  22. package/dist/commander-kit/index.d.ts +3 -3
  23. package/dist/commander-kit/index.js +5 -5
  24. package/dist/commander-kit/index.js.map +1 -1
  25. package/dist/{extra-CsRmdXC4.d.cts → extra-BleSbKJp.d.ts} +2 -2
  26. package/dist/{extra-DxvrBev9.d.ts → extra-C8r3KWjP.d.cts} +2 -2
  27. package/dist/{fast-globe-options-PH-bHWVK.d.cts → fast-globe-options-D7S2fQZZ.d.cts} +3 -3
  28. package/dist/{fast-globe-options-Cz8KJqKc.d.ts → fast-globe-options-DnV58KJc.d.ts} +3 -3
  29. package/dist/{helper-D11A-ZKL.js → helper-C0AShk-j.js} +2 -2
  30. package/dist/{helper-D11A-ZKL.js.map → helper-C0AShk-j.js.map} +1 -1
  31. package/dist/{helper-DpeqwciR.cjs → helper-DNj9Sj4w.cjs} +2 -2
  32. package/dist/{helper-DpeqwciR.cjs.map → helper-DNj9Sj4w.cjs.map} +1 -1
  33. package/dist/{identity-C5MeSAA7.js → identity-CcYkvy9q.js} +6 -6
  34. package/dist/{identity-C5MeSAA7.js.map → identity-CcYkvy9q.js.map} +1 -1
  35. package/dist/{identity-ByjqnR8L.cjs → identity-Crq3bzhv.cjs} +6 -6
  36. package/dist/{identity-ByjqnR8L.cjs.map → identity-Crq3bzhv.cjs.map} +1 -1
  37. package/dist/{index-xAz8brx-.d.cts → index-BdtMQyzF.d.cts} +2 -2
  38. package/dist/{index-Dvmmz0f_.d.ts → index-CwHGSras.d.ts} +2 -2
  39. package/dist/{index-TgjbNRWB.d.cts → index-DlH2PDPD.d.cts} +2 -2
  40. package/dist/{index-B1t7Xs3T.d.ts → index-NLQcJJFO.d.ts} +2 -2
  41. package/dist/index.cjs +176 -104
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +81 -48
  44. package/dist/index.d.ts +81 -48
  45. package/dist/index.js +176 -104
  46. package/dist/index.js.map +1 -1
  47. package/dist/{package-banner-ByfR7yCv.cjs → package-banner-BoS7Lbi9.cjs} +5 -5
  48. package/dist/{package-banner-ByfR7yCv.cjs.map → package-banner-BoS7Lbi9.cjs.map} +1 -1
  49. package/dist/{package-banner-vwqcAX8E.js → package-banner-DkNDAjMK.js} +5 -5
  50. package/dist/{package-banner-vwqcAX8E.js.map → package-banner-DkNDAjMK.js.map} +1 -1
  51. package/dist/{server-BK6eykjo.cjs → server-CvLC0e2m.cjs} +3 -3
  52. package/dist/{server-BK6eykjo.cjs.map → server-CvLC0e2m.cjs.map} +1 -1
  53. package/dist/{server-1H2HFAbi.js → server-Dc93jndm.js} +3 -3
  54. package/dist/{server-1H2HFAbi.js.map → server-Dc93jndm.js.map} +1 -1
  55. package/dist/utils/client.cjs +2 -2
  56. package/dist/utils/client.d.cts +25 -7
  57. package/dist/utils/client.d.ts +25 -7
  58. package/dist/utils/client.js +2 -2
  59. package/dist/utils/server.cjs +2 -2
  60. package/dist/utils/server.d.cts +2 -2
  61. package/dist/utils/server.d.ts +2 -2
  62. package/dist/utils/server.js +2 -2
  63. package/package.json +4 -2
  64. package/dist/client-C3jHSAqV.cjs.map +0 -1
  65. package/dist/client-DUlrjus0.js.map +0 -1
@@ -2,19 +2,19 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.9`
5
+ * Version: `0.0.11`
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
  * ========================================================================
9
9
  */
10
10
 
11
11
  "use strict";
12
- const require_helper = require('./helper-DpeqwciR.cjs');
13
- const require_server = require('./server-BK6eykjo.cjs');
14
- const require_client = require('./client-C3jHSAqV.cjs');
12
+ const require_helper = require('./helper-DNj9Sj4w.cjs');
13
+ const require_server = require('./server-CvLC0e2m.cjs');
14
+ const require_client = require('./client-CuivP4z0.cjs');
15
15
  require("@rzl-zone/node-only");
16
16
  var name = "@rzl-zone/build-tools";
17
- var version = "0.0.9";
17
+ var version = "0.0.11";
18
18
  const PACKAGE_META = Object.freeze({
19
19
  name,
20
20
  version
@@ -97,4 +97,4 @@ Object.defineProperty(exports, 'PACKAGE_META', {
97
97
  return PACKAGE_META;
98
98
  }
99
99
  });
100
- //# sourceMappingURL=identity-ByjqnR8L.cjs.map
100
+ //# sourceMappingURL=identity-Crq3bzhv.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity-ByjqnR8L.cjs","names":["packageJson.name","packageJson.version","isNonEmptyString","ICONS","picocolors"],"sources":["../package.json","../src/_internal/constants/package-meta.ts","../src/commander-kit/identity/index.ts"],"sourcesContent":["","import packageJson from \"../../../package.json\";\n\n/** ----------------------------------------------------------------\n * * ***Shared package metadata derived from the package manifest.***\n * ----------------------------------------------------------------\n *\n * Centralized access to metadata sourced from the root\n * `package.json` file.\n *\n * - *This utility exists to:*\n * - Avoid repeated `package.json` imports across Node.js entry points.\n * - Ensure consistent versioning and naming.\n * - Provide a single source of truth for package-level metadata.\n *\n * - ⚠️ **Important:**\n * - This file MUST only be imported in Node.js environments.\n * - Not intended for browser or edge runtimes.\n *\n * @internal\n *\n */\nexport const PACKAGE_META = Object.freeze({\n /** Package name. */\n name: packageJson.name,\n\n /** Current package version. */\n version: packageJson.version\n});\n","import \"@rzl-zone/node-only\";\n\nimport { isNonEmptyString } from \"@/_internal/utils/helper\";\nimport { PACKAGE_META } from \"@/_internal/constants/package-meta\";\n\nimport { ICONS } from \"@/utils/server\";\nimport { picocolors } from \"@/utils/client\";\n\n/** ----------------------------------------------------------------\n * * ***Options for generating a utility command title.***\n * ----------------------------------------------------------------\n *\n * Used by `CommandIdentity.utility()`.\n */\ntype CommandUtilityTitleOptions = {\n /** ----------------------------------------------------------------\n * * ***Command name displayed in the title.***\n * ----------------------------------------------------------------\n *\n * Overrides the default command name provided in the constructor.\n *\n * @example\n * ```ts\n * { commandName: \"fix-dts-react-import\" }\n * ```\n */\n commandName?: string;\n\n /** ----------------------------------------------------------------\n * * ***Optional arrow icon override.***\n * ----------------------------------------------------------------\n *\n * If provided, this icon replaces the generator's\n * `defaultIconArrow` for this call only.\n *\n * @example\n * ```ts\n * { iconArrow: \"⇒\" }\n * ```\n */\n iconArrow?: string;\n\n /** ----------------------------------------------------------------\n * * ***Package name prefix.***\n * ----------------------------------------------------------------\n *\n * Displayed at the beginning of every generated title.\n *\n * @default \"@rzl-zone/build-tools\"\n */\n packageName?: string;\n};\n\n/** ----------------------------------------------------------------\n * * ***Options for generating a CLI command title.***\n * ----------------------------------------------------------------\n *\n * Used by `CommandIdentity.cli()`\n */\ntype CommandCliTitleOptions = Omit<\n CommandUtilityTitleOptions,\n \"packageName\"\n> & {\n /** ----------------------------------------------------------------\n * * ***Package name prefix.***\n * ----------------------------------------------------------------\n *\n * Overrides the resolved CLI package name for this call only.\n *\n * @default \"@rzl-zone/build-tools-cli\"\n */\n packageName?: string;\n};\n\n/** ----------------------------------------------------------------\n * * ***Global configuration for command identity formatting.***\n * ----------------------------------------------------------------\n *\n * Defines the default identity behavior applied to\n * all generated CLI and utility titles.\n */\ntype CommandIdentityOptions = {\n /** ----------------------------------------------------------------\n * * ***Default command name.***\n * ----------------------------------------------------------------\n *\n * Used when a command name is not provided in the respective in method `CommandIdentity.cli()` and `CommandIdentity.utility()` options.\n *\n * @example\n * ```ts\n * defaultCommandName: \"fix-dts-react-import\"\n * ```\n */\n defaultCommandName: string;\n\n /** ----------------------------------------------------------------\n * * ***Package name prefix.***\n * ----------------------------------------------------------------\n *\n * Optional base package name used for title generation.\n *\n * If not provided, an internal default will be resolved\n * depending on the title type (`CLI` or `utility`).\n */\n packageName?: string;\n\n /** ----------------------------------------------------------------\n * * ***Package version.***\n * ----------------------------------------------------------------\n *\n * Optional version displayed alongside the package name\n * in generated titles.\n *\n * If not provided, a default version will be resolved internally.\n *\n * @example\n * ```ts\n * version: \"1.2.0\"\n * ```\n */\n version?: string;\n\n /** ----------------------------------------------------------------\n * * ***Label for CLI commands.***\n * ----------------------------------------------------------------\n *\n * Optional label displayed between\n * the package name and arrow icon for CLI titles.\n */\n cliLabel?: string;\n\n /** ----------------------------------------------------------------\n * * ***Label for utility commands.***\n * ----------------------------------------------------------------\n *\n * Optional label displayed between\n * the package name and arrow icon for utility titles.\n */\n utilityLabel?: string;\n\n /** ----------------------------------------------------------------\n * * ***Default arrow icon.***\n * ----------------------------------------------------------------\n *\n * Icon displayed between the label and command name.\n *\n * @default\n * \"▶️\"\n * // or\n * \"▶\"\n */\n defaultIconArrow?: string;\n};\n\n/** ----------------------------------------------------------------\n * * ***Command identity formatter with consistent CLI styling.***\n * ----------------------------------------------------------------\n *\n * Responsible for generating formatted and colorized\n * command titles for CLI and utility commands.\n *\n * - ***Each generated title may include:***\n * - Package name.\n * - Optional label (CLI / utility).\n * - Arrow icon.\n * - Command name.\n * - Package version.\n *\n * ---\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"fix-dts-react-import\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@<version> ➔ fix-dts-react-import\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@<version> ➔ clean-dist\"\n * ```\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"build\",\n * version: \"2.1.0\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@2.1.0 ➔ build\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@2.1.0 ➔ clean-dist\"\n * ```\n */\nexport class CommandIdentity {\n /** Default command name.\n *\n * @internal\n */\n private _commandName: string;\n\n /** Package name.\n *\n * @internal\n */\n private _packageName: string | undefined;\n\n /** Package version.\n *\n * @internal\n */\n private _version: string;\n\n /** Label for CLI commands.\n *\n * @internal\n */\n private cliLabel: string | undefined;\n\n /** Label for utility commands.\n *\n * @internal\n */\n private utilityLabel: string | undefined;\n\n /** Default arrow icon.\n *\n * @internal\n */\n private defaultIconArrow: string;\n\n /** @internal */\n private static readonly DEFAULT_UTILITY_PACKAGE = \"@rzl-zone/build-tools\";\n /** @internal */\n private static readonly DEFAULT_CLI_PACKAGE = \"@rzl-zone/build-tools-cli\";\n\n /** ----------------------------------------------------------------\n * * ***Create a new command identity instance.***\n * ----------------------------------------------------------------\n *\n * Initializes global identity configuration\n * used by `CommandIdentity.cli()` and `CommandIdentity.utility()`.\n *\n * ---\n *\n * @param {CommandIdentityOptions} options - Global identity configuration.\n * @throws {Error} If `options.defaultCommandName` is missing or empty.\n *\n * ---\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"fix-dts-react-import\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@<version> ➔ fix-dts-react-import\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@<version> ➔ clean-dist\"\n * ```\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"build\",\n * version: \"2.1.0\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@2.1.0 ➔ build\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@2.1.0 ➔ clean-dist\"\n * ```\n */\n constructor(options: CommandIdentityOptions) {\n if (!isNonEmptyString(options.defaultCommandName)) {\n throw new Error(\n \"CommandIdentity: Default command name is missing, please provide in constructor method options, eg: ({ defaultCommandName: 'inject-directive' }).\"\n );\n }\n\n this._commandName = options.defaultCommandName;\n this._packageName = options.packageName;\n this._version = isNonEmptyString(options.version)\n ? options.version\n : PACKAGE_META.version;\n\n this.cliLabel = options.cliLabel;\n this.utilityLabel = options.utilityLabel;\n this.defaultIconArrow = options.defaultIconArrow ?? ICONS.arrowRight;\n }\n\n /** ----------------------------------------------------------------\n * * ***Internal title formatter.***\n * ----------------------------------------------------------------\n *\n * Shared formatter used by `CommandIdentity.cli()` and `CommandIdentity.utility()`.\n *\n * @internal\n */\n private format(props: {\n packageName: string;\n label?: string;\n name?: string;\n iconArrow?: string;\n }): string {\n const { label, name, iconArrow, packageName } = props;\n const finalName = isNonEmptyString(name) ? name : this._commandName;\n const finalLabel = isNonEmptyString(label) ? ` ${label} ` : \" \";\n\n if (!finalName) {\n throw new Error(\n \"CommandIdentity: Command name is missing. \" +\n \"Provide `defaultCommandName` in constructor or `name` in method options.\"\n );\n }\n\n const versionSuffix = isNonEmptyString(this._version)\n ? `@${this._version}`\n : \"\";\n\n return (\n `${picocolors.bold(picocolors.blue(packageName + versionSuffix))}` +\n `${picocolors.whiteBright(finalLabel)}` +\n `${picocolors.bold(picocolors.magentaBright(isNonEmptyString(iconArrow) ? iconArrow : this.defaultIconArrow))} ` +\n `${picocolors.underline(picocolors.italic(picocolors.yellowBright(finalName)))}`\n );\n }\n\n /** ----------------------------------------------------------------\n * * ***Generate a CLI command title.***\n * ----------------------------------------------------------------\n *\n * Uses the CLI default package (unless overridden)\n * and applies CLI-specific labeling.\n *\n * @param {CommandCliTitleOptions} options - CLI title configuration.\n *\n * @example\n * ```ts\n * identity.cli();\n * identity.cli({ commandName: \"build\" });\n * ```\n */\n public cli(options: CommandCliTitleOptions = {}): string {\n const packageName = isNonEmptyString(options.packageName)\n ? options.packageName\n : (this._packageName ?? CommandIdentity.DEFAULT_CLI_PACKAGE);\n\n return this.format({\n packageName,\n label: this.cliLabel,\n name: options.commandName,\n iconArrow: options.iconArrow\n });\n }\n\n /** ----------------------------------------------------------------\n * * ***Generate a utility command title.***\n * ----------------------------------------------------------------\n *\n * Uses the utility default package (unless overridden)\n * and applies utility-specific labeling.\n *\n * @param {CommandUtilityTitleOptions} options - Utility title configuration.\n *\n * @example\n * ```ts\n * identity.utility();\n * identity.utility({ commandName: \"clean-dist\", iconArrow: \"⇒\" });\n * ```\n */\n public utility(options: CommandUtilityTitleOptions = {}): string {\n const packageName = isNonEmptyString(options.packageName)\n ? options.packageName\n : (this._packageName ?? CommandIdentity.DEFAULT_UTILITY_PACKAGE);\n\n return this.format({\n packageName,\n label: this.utilityLabel,\n name: options.commandName,\n iconArrow: options.iconArrow\n });\n }\n\n /** ----------------------------------------------------------------\n * * ***Package name.***\n * ----------------------------------------------------------------\n *\n * Returns the effective package name used for title generation.\n *\n * If a custom package name has been provided via the constructor\n * or `CommandIdentity.setPackageName()`, that value will be returned.\n * Otherwise, an internal default package name (as utility) is used.\n *\n * @readonly\n */\n public get packageName(): string {\n return this._packageName ?? CommandIdentity.DEFAULT_UTILITY_PACKAGE;\n }\n\n /** ----------------------------------------------------------------\n * * ***Set package name.***\n * ----------------------------------------------------------------\n *\n * Assigns a custom package name to be used for title generation.\n *\n * - *This value overrides:*\n * - Any package name provided in the constructor.\n * - The internal default package name.\n *\n * Once set, this value will be returned by the `CommandIdentity.packageName`\n * getter and used by `CommandIdentity.cli()` and\n * `CommandIdentity.utility()` unless explicitly\n * overridden per method call.\n *\n * @param value - The new package name to assign.\n * @returns The current instance for fluent chaining.\n */\n public setPackageName(value: string): this {\n this._packageName = value;\n return this;\n }\n\n /** ----------------------------------------------------------------\n * * ***Command name.***\n * ----------------------------------------------------------------\n *\n * Returns the current command name used for title generation.\n *\n * This value is initialized via the constructor and may be\n * updated later using\n * `CommandIdentity.setCommandName()`.\n *\n * @readonly\n */\n public get commandName(): string {\n return this._commandName;\n }\n\n /** ----------------------------------------------------------------\n * * ***Set command name.***\n * ----------------------------------------------------------------\n *\n * Updates the command name used for title generation.\n *\n * This overrides the command name provided in the constructor\n * and affects subsequent calls to\n * `CommandIdentity.cli()`\n * and `CommandIdentity.utility()`,\n * unless a command name is explicitly provided per method call.\n *\n * @param value - The new command name to assign.\n * @returns The current instance for fluent chaining.\n */\n public setCommandName(value: string): this {\n this._commandName = value;\n return this;\n }\n\n /** ----------------------------------------------------------------\n * * ***Package version.***\n * ----------------------------------------------------------------\n *\n * Returns the effective version used for title generation.\n *\n * - *Resolution order:*\n * 1. If a custom version has been provided via the constructor\n * or `CommandIdentity.setVersion()`,\n * that value will be returned.\n * 2. Otherwise, the version falls back to the internally\n * resolved default package version.\n *\n * A version value is always guaranteed to be present.\n *\n * @readonly\n */\n public get version(): string {\n return this._version;\n }\n\n /** ----------------------------------------------------------------\n * * ***Set package version.***\n * ----------------------------------------------------------------\n *\n * Overrides the version used for title generation.\n *\n * If an empty or invalid value is provided,\n * the version will remain unchanged.\n *\n * @param value - The new version to assign.\n * @returns The current instance for fluent chaining.\n */\n public setVersion(value: string): this {\n if (isNonEmptyString(value)) this._version = value;\n\n return this;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqBA,MAAa,eAAe,OAAO,OAAO;CAElCA;CAGGC;CACV,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC0KF,IAAa,kBAAb,MAAa,gBAAgB;;;;;CAK3B,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;CAGR,OAAwB,0BAA0B;;CAElD,OAAwB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C9C,YAAY,SAAiC;AAC3C,MAAI,CAACC,gCAAiB,QAAQ,mBAAmB,CAC/C,OAAM,IAAI,MACR,oJACD;AAGH,OAAK,eAAe,QAAQ;AAC5B,OAAK,eAAe,QAAQ;AAC5B,OAAK,WAAWA,gCAAiB,QAAQ,QAAQ,GAC7C,QAAQ,UACR,aAAa;AAEjB,OAAK,WAAW,QAAQ;AACxB,OAAK,eAAe,QAAQ;AAC5B,OAAK,mBAAmB,QAAQ,oBAAoBC,qBAAM;;;;;;;;;;CAW5D,AAAQ,OAAO,OAKJ;EACT,MAAM,EAAE,OAAO,MAAM,WAAW,gBAAgB;EAChD,MAAM,YAAYD,gCAAiB,KAAK,GAAG,OAAO,KAAK;EACvD,MAAM,aAAaA,gCAAiB,MAAM,GAAG,IAAI,MAAM,KAAK;AAE5D,MAAI,CAAC,UACH,OAAM,IAAI,MACR,qHAED;EAGH,MAAM,gBAAgBA,gCAAiB,KAAK,SAAS,GACjD,IAAI,KAAK,aACT;AAEJ,SACE,GAAGE,0BAAW,KAAKA,0BAAW,KAAK,cAAc,cAAc,CAAC,GAC7DA,0BAAW,YAAY,WAAW,GAClCA,0BAAW,KAAKA,0BAAW,cAAcF,gCAAiB,UAAU,GAAG,YAAY,KAAK,iBAAiB,CAAC,CAAC,GAC3GE,0BAAW,UAAUA,0BAAW,OAAOA,0BAAW,aAAa,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;CAmBlF,AAAO,IAAI,UAAkC,EAAE,EAAU;EACvD,MAAM,cAAcF,gCAAiB,QAAQ,YAAY,GACrD,QAAQ,cACP,KAAK,gBAAgB,gBAAgB;AAE1C,SAAO,KAAK,OAAO;GACjB;GACA,OAAO,KAAK;GACZ,MAAM,QAAQ;GACd,WAAW,QAAQ;GACpB,CAAC;;;;;;;;;;;;;;;;;CAkBJ,AAAO,QAAQ,UAAsC,EAAE,EAAU;EAC/D,MAAM,cAAcA,gCAAiB,QAAQ,YAAY,GACrD,QAAQ,cACP,KAAK,gBAAgB,gBAAgB;AAE1C,SAAO,KAAK,OAAO;GACjB;GACA,OAAO,KAAK;GACZ,MAAM,QAAQ;GACd,WAAW,QAAQ;GACpB,CAAC;;;;;;;;;;;;;;CAeJ,IAAW,cAAsB;AAC/B,SAAO,KAAK,gBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;CAqB9C,AAAO,eAAe,OAAqB;AACzC,OAAK,eAAe;AACpB,SAAO;;;;;;;;;;;;;;CAeT,IAAW,cAAsB;AAC/B,SAAO,KAAK;;;;;;;;;;;;;;;;;CAkBd,AAAO,eAAe,OAAqB;AACzC,OAAK,eAAe;AACpB,SAAO;;;;;;;;;;;;;;;;;;;CAoBT,IAAW,UAAkB;AAC3B,SAAO,KAAK;;;;;;;;;;;;;;CAed,AAAO,WAAW,OAAqB;AACrC,MAAIA,gCAAiB,MAAM,CAAE,MAAK,WAAW;AAE7C,SAAO"}
1
+ {"version":3,"file":"identity-Crq3bzhv.cjs","names":["packageJson.name","packageJson.version","isNonEmptyString","ICONS","picocolors"],"sources":["../package.json","../src/_internal/constants/package-meta.ts","../src/commander-kit/identity/index.ts"],"sourcesContent":["","import packageJson from \"../../../package.json\";\n\n/** ----------------------------------------------------------------\n * * ***Shared package metadata derived from the package manifest.***\n * ----------------------------------------------------------------\n *\n * Centralized access to metadata sourced from the root\n * `package.json` file.\n *\n * - *This utility exists to:*\n * - Avoid repeated `package.json` imports across Node.js entry points.\n * - Ensure consistent versioning and naming.\n * - Provide a single source of truth for package-level metadata.\n *\n * - ⚠️ **Important:**\n * - This file MUST only be imported in Node.js environments.\n * - Not intended for browser or edge runtimes.\n *\n * @internal\n *\n */\nexport const PACKAGE_META = Object.freeze({\n /** Package name. */\n name: packageJson.name,\n\n /** Current package version. */\n version: packageJson.version\n});\n","import \"@rzl-zone/node-only\";\n\nimport { isNonEmptyString } from \"@/_internal/utils/helper\";\nimport { PACKAGE_META } from \"@/_internal/constants/package-meta\";\n\nimport { ICONS } from \"@/utils/server\";\nimport { picocolors } from \"@/utils/client\";\n\n/** ----------------------------------------------------------------\n * * ***Options for generating a utility command title.***\n * ----------------------------------------------------------------\n *\n * Used by `CommandIdentity.utility()`.\n */\ntype CommandUtilityTitleOptions = {\n /** ----------------------------------------------------------------\n * * ***Command name displayed in the title.***\n * ----------------------------------------------------------------\n *\n * Overrides the default command name provided in the constructor.\n *\n * @example\n * ```ts\n * { commandName: \"fix-dts-react-import\" }\n * ```\n */\n commandName?: string;\n\n /** ----------------------------------------------------------------\n * * ***Optional arrow icon override.***\n * ----------------------------------------------------------------\n *\n * If provided, this icon replaces the generator's\n * `defaultIconArrow` for this call only.\n *\n * @example\n * ```ts\n * { iconArrow: \"⇒\" }\n * ```\n */\n iconArrow?: string;\n\n /** ----------------------------------------------------------------\n * * ***Package name prefix.***\n * ----------------------------------------------------------------\n *\n * Displayed at the beginning of every generated title.\n *\n * @default \"@rzl-zone/build-tools\"\n */\n packageName?: string;\n};\n\n/** ----------------------------------------------------------------\n * * ***Options for generating a CLI command title.***\n * ----------------------------------------------------------------\n *\n * Used by `CommandIdentity.cli()`\n */\ntype CommandCliTitleOptions = Omit<\n CommandUtilityTitleOptions,\n \"packageName\"\n> & {\n /** ----------------------------------------------------------------\n * * ***Package name prefix.***\n * ----------------------------------------------------------------\n *\n * Overrides the resolved CLI package name for this call only.\n *\n * @default \"@rzl-zone/build-tools-cli\"\n */\n packageName?: string;\n};\n\n/** ----------------------------------------------------------------\n * * ***Global configuration for command identity formatting.***\n * ----------------------------------------------------------------\n *\n * Defines the default identity behavior applied to\n * all generated CLI and utility titles.\n */\ntype CommandIdentityOptions = {\n /** ----------------------------------------------------------------\n * * ***Default command name.***\n * ----------------------------------------------------------------\n *\n * Used when a command name is not provided in the respective in method `CommandIdentity.cli()` and `CommandIdentity.utility()` options.\n *\n * @example\n * ```ts\n * defaultCommandName: \"fix-dts-react-import\"\n * ```\n */\n defaultCommandName: string;\n\n /** ----------------------------------------------------------------\n * * ***Package name prefix.***\n * ----------------------------------------------------------------\n *\n * Optional base package name used for title generation.\n *\n * If not provided, an internal default will be resolved\n * depending on the title type (`CLI` or `utility`).\n */\n packageName?: string;\n\n /** ----------------------------------------------------------------\n * * ***Package version.***\n * ----------------------------------------------------------------\n *\n * Optional version displayed alongside the package name\n * in generated titles.\n *\n * If not provided, a default version will be resolved internally.\n *\n * @example\n * ```ts\n * version: \"1.2.0\"\n * ```\n */\n version?: string;\n\n /** ----------------------------------------------------------------\n * * ***Label for CLI commands.***\n * ----------------------------------------------------------------\n *\n * Optional label displayed between\n * the package name and arrow icon for CLI titles.\n */\n cliLabel?: string;\n\n /** ----------------------------------------------------------------\n * * ***Label for utility commands.***\n * ----------------------------------------------------------------\n *\n * Optional label displayed between\n * the package name and arrow icon for utility titles.\n */\n utilityLabel?: string;\n\n /** ----------------------------------------------------------------\n * * ***Default arrow icon.***\n * ----------------------------------------------------------------\n *\n * Icon displayed between the label and command name.\n *\n * @default\n * \"▶️\"\n * // or\n * \"▶\"\n */\n defaultIconArrow?: string;\n};\n\n/** ----------------------------------------------------------------\n * * ***Command identity formatter with consistent CLI styling.***\n * ----------------------------------------------------------------\n *\n * Responsible for generating formatted and colorized\n * command titles for CLI and utility commands.\n *\n * - ***Each generated title may include:***\n * - Package name.\n * - Optional label (CLI / utility).\n * - Arrow icon.\n * - Command name.\n * - Package version.\n *\n * ---\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"fix-dts-react-import\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@<version> ➔ fix-dts-react-import\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@<version> ➔ clean-dist\"\n * ```\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"build\",\n * version: \"2.1.0\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@2.1.0 ➔ build\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@2.1.0 ➔ clean-dist\"\n * ```\n */\nexport class CommandIdentity {\n /** Default command name.\n *\n * @internal\n */\n private _commandName: string;\n\n /** Package name.\n *\n * @internal\n */\n private _packageName: string | undefined;\n\n /** Package version.\n *\n * @internal\n */\n private _version: string;\n\n /** Label for CLI commands.\n *\n * @internal\n */\n private cliLabel: string | undefined;\n\n /** Label for utility commands.\n *\n * @internal\n */\n private utilityLabel: string | undefined;\n\n /** Default arrow icon.\n *\n * @internal\n */\n private defaultIconArrow: string;\n\n /** @internal */\n private static readonly DEFAULT_UTILITY_PACKAGE = \"@rzl-zone/build-tools\";\n /** @internal */\n private static readonly DEFAULT_CLI_PACKAGE = \"@rzl-zone/build-tools-cli\";\n\n /** ----------------------------------------------------------------\n * * ***Create a new command identity instance.***\n * ----------------------------------------------------------------\n *\n * Initializes global identity configuration\n * used by `CommandIdentity.cli()` and `CommandIdentity.utility()`.\n *\n * ---\n *\n * @param {CommandIdentityOptions} options - Global identity configuration.\n * @throws {Error} If `options.defaultCommandName` is missing or empty.\n *\n * ---\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"fix-dts-react-import\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@<version> ➔ fix-dts-react-import\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@<version> ➔ clean-dist\"\n * ```\n *\n * @example\n * ```ts\n * const identity = new CommandIdentity({\n * defaultCommandName: \"build\",\n * version: \"2.1.0\"\n * });\n *\n * identity.cli();\n * // => \"@rzl-zone/build-tools-cli@2.1.0 ➔ build\"\n *\n * identity.utility({ commandName: \"clean-dist\" });\n * // => \"@rzl-zone/build-tools@2.1.0 ➔ clean-dist\"\n * ```\n */\n constructor(options: CommandIdentityOptions) {\n if (!isNonEmptyString(options.defaultCommandName)) {\n throw new Error(\n \"CommandIdentity: Default command name is missing, please provide in constructor method options, eg: ({ defaultCommandName: 'inject-directive' }).\"\n );\n }\n\n this._commandName = options.defaultCommandName;\n this._packageName = options.packageName;\n this._version = isNonEmptyString(options.version)\n ? options.version\n : PACKAGE_META.version;\n\n this.cliLabel = options.cliLabel;\n this.utilityLabel = options.utilityLabel;\n this.defaultIconArrow = options.defaultIconArrow ?? ICONS.arrowRight;\n }\n\n /** ----------------------------------------------------------------\n * * ***Internal title formatter.***\n * ----------------------------------------------------------------\n *\n * Shared formatter used by `CommandIdentity.cli()` and `CommandIdentity.utility()`.\n *\n * @internal\n */\n private format(props: {\n packageName: string;\n label?: string;\n name?: string;\n iconArrow?: string;\n }): string {\n const { label, name, iconArrow, packageName } = props;\n const finalName = isNonEmptyString(name) ? name : this._commandName;\n const finalLabel = isNonEmptyString(label) ? ` ${label} ` : \" \";\n\n if (!finalName) {\n throw new Error(\n \"CommandIdentity: Command name is missing. \" +\n \"Provide `defaultCommandName` in constructor or `name` in method options.\"\n );\n }\n\n const versionSuffix = isNonEmptyString(this._version)\n ? `@${this._version}`\n : \"\";\n\n return (\n `${picocolors.bold(picocolors.blue(packageName + versionSuffix))}` +\n `${picocolors.whiteBright(finalLabel)}` +\n `${picocolors.bold(picocolors.magentaBright(isNonEmptyString(iconArrow) ? iconArrow : this.defaultIconArrow))} ` +\n `${picocolors.underline(picocolors.italic(picocolors.yellowBright(finalName)))}`\n );\n }\n\n /** ----------------------------------------------------------------\n * * ***Generate a CLI command title.***\n * ----------------------------------------------------------------\n *\n * Uses the CLI default package (unless overridden)\n * and applies CLI-specific labeling.\n *\n * @param {CommandCliTitleOptions} options - CLI title configuration.\n *\n * @example\n * ```ts\n * identity.cli();\n * identity.cli({ commandName: \"build\" });\n * ```\n */\n public cli(options: CommandCliTitleOptions = {}): string {\n const packageName = isNonEmptyString(options.packageName)\n ? options.packageName\n : (this._packageName ?? CommandIdentity.DEFAULT_CLI_PACKAGE);\n\n return this.format({\n packageName,\n label: this.cliLabel,\n name: options.commandName,\n iconArrow: options.iconArrow\n });\n }\n\n /** ----------------------------------------------------------------\n * * ***Generate a utility command title.***\n * ----------------------------------------------------------------\n *\n * Uses the utility default package (unless overridden)\n * and applies utility-specific labeling.\n *\n * @param {CommandUtilityTitleOptions} options - Utility title configuration.\n *\n * @example\n * ```ts\n * identity.utility();\n * identity.utility({ commandName: \"clean-dist\", iconArrow: \"⇒\" });\n * ```\n */\n public utility(options: CommandUtilityTitleOptions = {}): string {\n const packageName = isNonEmptyString(options.packageName)\n ? options.packageName\n : (this._packageName ?? CommandIdentity.DEFAULT_UTILITY_PACKAGE);\n\n return this.format({\n packageName,\n label: this.utilityLabel,\n name: options.commandName,\n iconArrow: options.iconArrow\n });\n }\n\n /** ----------------------------------------------------------------\n * * ***Package name.***\n * ----------------------------------------------------------------\n *\n * Returns the effective package name used for title generation.\n *\n * If a custom package name has been provided via the constructor\n * or `CommandIdentity.setPackageName()`, that value will be returned.\n * Otherwise, an internal default package name (as utility) is used.\n *\n * @readonly\n */\n public get packageName(): string {\n return this._packageName ?? CommandIdentity.DEFAULT_UTILITY_PACKAGE;\n }\n\n /** ----------------------------------------------------------------\n * * ***Set package name.***\n * ----------------------------------------------------------------\n *\n * Assigns a custom package name to be used for title generation.\n *\n * - *This value overrides:*\n * - Any package name provided in the constructor.\n * - The internal default package name.\n *\n * Once set, this value will be returned by the `CommandIdentity.packageName`\n * getter and used by `CommandIdentity.cli()` and\n * `CommandIdentity.utility()` unless explicitly\n * overridden per method call.\n *\n * @param value - The new package name to assign.\n * @returns The current instance for fluent chaining.\n */\n public setPackageName(value: string): this {\n this._packageName = value;\n return this;\n }\n\n /** ----------------------------------------------------------------\n * * ***Command name.***\n * ----------------------------------------------------------------\n *\n * Returns the current command name used for title generation.\n *\n * This value is initialized via the constructor and may be\n * updated later using\n * `CommandIdentity.setCommandName()`.\n *\n * @readonly\n */\n public get commandName(): string {\n return this._commandName;\n }\n\n /** ----------------------------------------------------------------\n * * ***Set command name.***\n * ----------------------------------------------------------------\n *\n * Updates the command name used for title generation.\n *\n * This overrides the command name provided in the constructor\n * and affects subsequent calls to\n * `CommandIdentity.cli()`\n * and `CommandIdentity.utility()`,\n * unless a command name is explicitly provided per method call.\n *\n * @param value - The new command name to assign.\n * @returns The current instance for fluent chaining.\n */\n public setCommandName(value: string): this {\n this._commandName = value;\n return this;\n }\n\n /** ----------------------------------------------------------------\n * * ***Package version.***\n * ----------------------------------------------------------------\n *\n * Returns the effective version used for title generation.\n *\n * - *Resolution order:*\n * 1. If a custom version has been provided via the constructor\n * or `CommandIdentity.setVersion()`,\n * that value will be returned.\n * 2. Otherwise, the version falls back to the internally\n * resolved default package version.\n *\n * A version value is always guaranteed to be present.\n *\n * @readonly\n */\n public get version(): string {\n return this._version;\n }\n\n /** ----------------------------------------------------------------\n * * ***Set package version.***\n * ----------------------------------------------------------------\n *\n * Overrides the version used for title generation.\n *\n * If an empty or invalid value is provided,\n * the version will remain unchanged.\n *\n * @param value - The new version to assign.\n * @returns The current instance for fluent chaining.\n */\n public setVersion(value: string): this {\n if (isNonEmptyString(value)) this._version = value;\n\n return this;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqBA,MAAa,eAAe,OAAO,OAAO;CAElCA;CAGGC;CACV,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC0KF,IAAa,kBAAb,MAAa,gBAAgB;;;;;CAK3B,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;;;;CAMR,AAAQ;;CAGR,OAAwB,0BAA0B;;CAElD,OAAwB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C9C,YAAY,SAAiC;AAC3C,MAAI,CAACC,gCAAiB,QAAQ,mBAAmB,CAC/C,OAAM,IAAI,MACR,oJACD;AAGH,OAAK,eAAe,QAAQ;AAC5B,OAAK,eAAe,QAAQ;AAC5B,OAAK,WAAWA,gCAAiB,QAAQ,QAAQ,GAC7C,QAAQ,UACR,aAAa;AAEjB,OAAK,WAAW,QAAQ;AACxB,OAAK,eAAe,QAAQ;AAC5B,OAAK,mBAAmB,QAAQ,oBAAoBC,qBAAM;;;;;;;;;;CAW5D,AAAQ,OAAO,OAKJ;EACT,MAAM,EAAE,OAAO,MAAM,WAAW,gBAAgB;EAChD,MAAM,YAAYD,gCAAiB,KAAK,GAAG,OAAO,KAAK;EACvD,MAAM,aAAaA,gCAAiB,MAAM,GAAG,IAAI,MAAM,KAAK;AAE5D,MAAI,CAAC,UACH,OAAM,IAAI,MACR,qHAED;EAGH,MAAM,gBAAgBA,gCAAiB,KAAK,SAAS,GACjD,IAAI,KAAK,aACT;AAEJ,SACE,GAAGE,0BAAW,KAAKA,0BAAW,KAAK,cAAc,cAAc,CAAC,GAC7DA,0BAAW,YAAY,WAAW,GAClCA,0BAAW,KAAKA,0BAAW,cAAcF,gCAAiB,UAAU,GAAG,YAAY,KAAK,iBAAiB,CAAC,CAAC,GAC3GE,0BAAW,UAAUA,0BAAW,OAAOA,0BAAW,aAAa,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;CAmBlF,AAAO,IAAI,UAAkC,EAAE,EAAU;EACvD,MAAM,cAAcF,gCAAiB,QAAQ,YAAY,GACrD,QAAQ,cACP,KAAK,gBAAgB,gBAAgB;AAE1C,SAAO,KAAK,OAAO;GACjB;GACA,OAAO,KAAK;GACZ,MAAM,QAAQ;GACd,WAAW,QAAQ;GACpB,CAAC;;;;;;;;;;;;;;;;;CAkBJ,AAAO,QAAQ,UAAsC,EAAE,EAAU;EAC/D,MAAM,cAAcA,gCAAiB,QAAQ,YAAY,GACrD,QAAQ,cACP,KAAK,gBAAgB,gBAAgB;AAE1C,SAAO,KAAK,OAAO;GACjB;GACA,OAAO,KAAK;GACZ,MAAM,QAAQ;GACd,WAAW,QAAQ;GACpB,CAAC;;;;;;;;;;;;;;CAeJ,IAAW,cAAsB;AAC/B,SAAO,KAAK,gBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;CAqB9C,AAAO,eAAe,OAAqB;AACzC,OAAK,eAAe;AACpB,SAAO;;;;;;;;;;;;;;CAeT,IAAW,cAAsB;AAC/B,SAAO,KAAK;;;;;;;;;;;;;;;;;CAkBd,AAAO,eAAe,OAAqB;AACzC,OAAK,eAAe;AACpB,SAAO;;;;;;;;;;;;;;;;;;;CAoBT,IAAW,UAAkB;AAC3B,SAAO,KAAK;;;;;;;;;;;;;;CAed,AAAO,WAAW,OAAqB;AACrC,MAAIA,gCAAiB,MAAM,CAAE,MAAK,WAAW;AAE7C,SAAO"}
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.9`
5
+ * Version: `0.0.11`
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
  * ========================================================================
@@ -353,4 +353,4 @@ declare class CommandIdentity {
353
353
  setVersion(value: string): this;
354
354
  }
355
355
  export { CommandIdentity as t };
356
- //# sourceMappingURL=index-xAz8brx-.d.cts.map
356
+ //# sourceMappingURL=index-BdtMQyzF.d.cts.map
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.9`
5
+ * Version: `0.0.11`
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
  * ========================================================================
@@ -679,4 +679,4 @@ type GeneratePackageBannerOptions = {
679
679
  */
680
680
  declare const generatePackageBanner: (options?: GeneratePackageBannerOptions) => Promise<string>;
681
681
  export { generatePackageBanner as n, PackageJson as r, GeneratePackageBannerOptions as t };
682
- //# sourceMappingURL=index-Dvmmz0f_.d.ts.map
682
+ //# sourceMappingURL=index-CwHGSras.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.9`
5
+ * Version: `0.0.11`
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
  * ========================================================================
@@ -679,4 +679,4 @@ type GeneratePackageBannerOptions = {
679
679
  */
680
680
  declare const generatePackageBanner: (options?: GeneratePackageBannerOptions) => Promise<string>;
681
681
  export { generatePackageBanner as n, PackageJson as r, GeneratePackageBannerOptions as t };
682
- //# sourceMappingURL=index-TgjbNRWB.d.cts.map
682
+ //# sourceMappingURL=index-DlH2PDPD.d.cts.map
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.9`
5
+ * Version: `0.0.11`
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
  * ========================================================================
@@ -353,4 +353,4 @@ declare class CommandIdentity {
353
353
  setVersion(value: string): this;
354
354
  }
355
355
  export { CommandIdentity as t };
356
- //# sourceMappingURL=index-B1t7Xs3T.d.ts.map
356
+ //# sourceMappingURL=index-NLQcJJFO.d.ts.map
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.9`
5
+ * Version: `0.0.11`
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,11 +10,11 @@
10
10
 
11
11
  "use strict";
12
12
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13
- const require_helper = require('./helper-DpeqwciR.cjs');
14
- const require_server = require('./server-BK6eykjo.cjs');
15
- const require_identity = require('./identity-ByjqnR8L.cjs');
16
- const require_client = require('./client-C3jHSAqV.cjs');
17
- const require_package_banner = require('./package-banner-ByfR7yCv.cjs');
13
+ const require_helper = require('./helper-DNj9Sj4w.cjs');
14
+ const require_server = require('./server-CvLC0e2m.cjs');
15
+ const require_identity = require('./identity-Crq3bzhv.cjs');
16
+ const require_client = require('./client-CuivP4z0.cjs');
17
+ const require_package_banner = require('./package-banner-BoS7Lbi9.cjs');
18
18
  require("@rzl-zone/node-only");
19
19
  let _babel_types = require("@babel/types");
20
20
  _babel_types = require_helper.__toESM(_babel_types, 1);
@@ -23,6 +23,7 @@ let _babel_traverse = require("@babel/traverse");
23
23
  _babel_traverse = require_helper.__toESM(_babel_traverse, 1);
24
24
  let node_path = require("node:path");
25
25
  node_path = require_helper.__toESM(node_path, 1);
26
+ let shell_quote = require("shell-quote");
26
27
  let node_child_process = require("node:child_process");
27
28
  let acorn = require("acorn");
28
29
  acorn = require_helper.__toESM(acorn, 1);
@@ -1161,31 +1162,44 @@ const normalizeJsBuildNewlines = async (pattern, options = {}) => {
1161
1162
  }
1162
1163
  };
1163
1164
  function runCommand(command, argsOrOptions = [], maybeOptions = {}) {
1164
- assertValidCommand(command);
1165
- let args;
1166
- let options;
1167
- if (Array.isArray(argsOrOptions)) {
1168
- args = argsOrOptions;
1169
- options = maybeOptions;
1170
- } else {
1171
- args = [];
1172
- options = argsOrOptions;
1173
- }
1174
1165
  return new Promise((resolve, reject) => {
1175
- const { shell = true, stdio = "inherit", argv0: _argv0, useColors = true, ...restOption } = options;
1176
- const { child, setupLifecycle, cmdStringPlain } = spawnWithLifecycle(command, args, {
1177
- ...restOption,
1178
- stdio,
1179
- useColors,
1180
- shell
1181
- }, { rejectOnNonZero: true });
1182
- setupLifecycle({
1183
- onSuccess: (code) => {
1184
- if (code === 0) resolve(child);
1185
- else reject(/* @__PURE__ */ new Error(`${cmdStringPlain} exited with code ${code}`));
1186
- },
1187
- onError: reject
1188
- });
1166
+ try {
1167
+ let args;
1168
+ let options;
1169
+ const isArgsArray = require_helper.isArray(argsOrOptions);
1170
+ if (isArgsArray) {
1171
+ args = argsOrOptions;
1172
+ options = maybeOptions;
1173
+ } else {
1174
+ args = [];
1175
+ options = argsOrOptions;
1176
+ }
1177
+ assertValidCommand(command, {
1178
+ apiType: "runCommand",
1179
+ useColors: options.useColors,
1180
+ allowInline: !isArgsArray
1181
+ });
1182
+ const { shell = true, stdio = "inherit", argv0: _argv0, useColors = true, ...restOption } = options;
1183
+ const { child, setupLifecycle, cmdStringPlain } = spawnWithLifecycle(command, args, {
1184
+ ...restOption,
1185
+ stdio,
1186
+ useColors,
1187
+ shell
1188
+ }, { rejectOnNonZero: true });
1189
+ setupLifecycle({
1190
+ onSuccess: (code) => {
1191
+ if (code === 0) resolve(child);
1192
+ else reject(/* @__PURE__ */ new Error(`${cmdStringPlain} exited with code ${code}`));
1193
+ },
1194
+ onError: reject
1195
+ });
1196
+ } catch (err) {
1197
+ const e = err instanceof Error ? err : new Error(String(err));
1198
+ const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(require_client.EOL).slice(1) ?? []).filter((line) => !line.includes("runCommand")));
1199
+ e.stack = [e.message, ...cleanedBase].join(require_client.EOL);
1200
+ reject(e);
1201
+ return;
1202
+ }
1189
1203
  });
1190
1204
  }
1191
1205
  function normalizeChunk(chunk) {
@@ -1194,74 +1208,89 @@ function normalizeChunk(chunk) {
1194
1208
  return String(chunk);
1195
1209
  }
1196
1210
  function runCommandCapture(command, argsOrOptions = [], maybeOptions = {}) {
1197
- assertValidCommand(command);
1198
- let args;
1199
- let options;
1200
- if (Array.isArray(argsOrOptions)) {
1201
- args = argsOrOptions;
1202
- options = maybeOptions;
1203
- } else {
1204
- args = [];
1205
- options = argsOrOptions;
1206
- }
1207
- const { shell = true, signal, timeout, forceKill, useColors = true, argv0: _argv0, ...restOption } = options;
1208
1211
  return new Promise((resolve, reject) => {
1209
- const { child, setupLifecycle } = spawnWithLifecycle(command, args, {
1210
- ...restOption,
1211
- stdio: "pipe",
1212
- shell,
1213
- signal,
1214
- timeout,
1215
- forceKill,
1216
- useColors
1217
- }, { rejectOnNonZero: false });
1218
- let stdout = "";
1219
- let stderr = "";
1220
- child.stdout?.on("data", (chunk) => {
1221
- stdout += normalizeChunk(chunk);
1222
- });
1223
- child.stderr?.on("data", (chunk) => {
1224
- stderr += normalizeChunk(chunk);
1225
- });
1226
- setupLifecycle({
1227
- onSuccess: (code) => {
1228
- resolve({
1229
- stdout: stdout.trimEnd(),
1230
- stderr: stderr.trimEnd(),
1231
- exitCode: code,
1232
- ok: code === 0
1233
- });
1234
- },
1235
- onError: reject
1236
- });
1212
+ try {
1213
+ let args;
1214
+ let options;
1215
+ const isArgsArray = require_helper.isArray(argsOrOptions);
1216
+ if (isArgsArray) {
1217
+ args = argsOrOptions;
1218
+ options = maybeOptions;
1219
+ } else {
1220
+ args = [];
1221
+ options = argsOrOptions;
1222
+ }
1223
+ assertValidCommand(command, {
1224
+ apiType: "runCommandCapture",
1225
+ useColors: options.useColors,
1226
+ allowInline: !isArgsArray
1227
+ });
1228
+ const { shell = true, signal, timeout, forceKill, useColors = true, argv0: _argv0, ...restOption } = options;
1229
+ const { child, setupLifecycle } = spawnWithLifecycle(command, args, {
1230
+ ...restOption,
1231
+ stdio: "pipe",
1232
+ shell,
1233
+ signal,
1234
+ timeout,
1235
+ forceKill,
1236
+ useColors
1237
+ }, { rejectOnNonZero: false });
1238
+ let stdout = "";
1239
+ let stderr = "";
1240
+ child.stdout?.on("data", (chunk) => {
1241
+ stdout += normalizeChunk(chunk);
1242
+ });
1243
+ child.stderr?.on("data", (chunk) => {
1244
+ stderr += normalizeChunk(chunk);
1245
+ });
1246
+ setupLifecycle({
1247
+ onSuccess: (code) => {
1248
+ resolve({
1249
+ stdout: stdout.trimEnd(),
1250
+ stderr: formatMessageColor(stderr.trimEnd(), useColors),
1251
+ exitCode: code,
1252
+ ok: code === 0
1253
+ });
1254
+ },
1255
+ onError: reject
1256
+ });
1257
+ } catch (err) {
1258
+ const e = err instanceof Error ? err : new Error(String(err));
1259
+ const cleanedBase = stripInternalStack(((/* @__PURE__ */ new Error()).stack?.split(require_client.EOL).slice(1) ?? []).filter((line) => !line.includes("runCommandCapture")));
1260
+ e.stack = [e.message, ...cleanedBase].join(require_client.EOL);
1261
+ reject(e);
1262
+ return;
1263
+ }
1237
1264
  });
1238
1265
  }
1266
+ const formatMessageColor = (message, useColors = true) => {
1267
+ return useColors ? require_client.picocolors.redBright(message) : message;
1268
+ };
1239
1269
  function formatCommand(command, args, { useColors = true } = {}) {
1240
1270
  const hasArgs = args.length > 0;
1241
1271
  const argsString = hasArgs ? args.map((a) => require_helper.safeStableStringify(a)).join(" ") : "";
1242
- if (useColors) {
1243
- const cmd = require_client.picocolors.cyanBright(command);
1244
- return hasArgs ? `${cmd} ${require_client.picocolors.gray(argsString)}` : cmd;
1245
- }
1246
- return hasArgs ? `${command} ${argsString}` : command;
1272
+ if (!hasArgs) return formatMessageColor(command, useColors);
1273
+ if (useColors) return `${require_client.picocolors.cyanBright(command)} ${require_client.picocolors.gray(argsString)}`;
1274
+ return `${command} ${argsString}`;
1247
1275
  }
1248
- function assertValidCommand(command, { useColors = true } = {}) {
1249
- if (typeof command !== "string") {
1276
+ function assertValidCommand(command, options) {
1277
+ const { useColors = true, allowInline = false, apiType } = options || {};
1278
+ if (!require_helper.isString(command)) {
1250
1279
  const errorMsg = `Invalid command: expected a string, received ${require_helper.safeStableStringify(command)}`;
1251
- throw new TypeError(useColors ? require_client.picocolors.redBright(errorMsg) : errorMsg);
1280
+ throw new TypeError(formatMessageColor(errorMsg, useColors));
1252
1281
  }
1253
1282
  const trimmed = command.trim();
1254
- if (trimmed.length === 0) {
1255
- const errorMsg = "Invalid command: command cannot be empty";
1256
- throw new Error(useColors ? require_client.picocolors.redBright(errorMsg) : errorMsg);
1283
+ if (trimmed.length === 0) throw new Error(formatMessageColor("Invalid command: command cannot be empty", useColors));
1284
+ const hasSpace = /\s/.test(trimmed);
1285
+ if (hasShellSyntax(trimmed)) {
1286
+ const errorMsg = require_client.joinLinesLoose(`Invalid command: "${trimmed}"`, "Shell operators are not supported in this context (e.g. &&, ||, |, >).", "This utility only supports a single command with arguments.");
1287
+ throw new Error(formatMessageColor(errorMsg, useColors));
1257
1288
  }
1258
- const hasSpace = trimmed.includes(" ");
1259
- const hasQuotes = /['"`]/.test(trimmed);
1260
- const hasShellOps = /[|&;<>(){}$]/.test(trimmed);
1261
- if (hasSpace || hasQuotes || hasShellOps) {
1289
+ if (!allowInline && hasSpace) {
1262
1290
  const [cmd, ...rest] = trimmed.split(/\s+/);
1263
- const errorMsg = require_client.joinLinesLoose(`Invalid command: "${trimmed}"`, "Do not pass a full shell command.", `Use arguments instead: runCommand("${cmd}", ${require_helper.safeStableStringify(rest)})`);
1264
- throw new Error(useColors ? require_client.picocolors.redBright(errorMsg) : errorMsg);
1291
+ if (!cmd) throw new Error("Invalid command: unable to resolve executable.");
1292
+ const errorMsg = require_client.joinLinesLoose(`Invalid command: "${trimmed}"`, "Do not include arguments in the command when passing them separately.", `Use: ${apiType}("${cmd}", ${require_helper.safeStableStringify(rest)})`);
1293
+ throw new Error(formatMessageColor(errorMsg, useColors));
1265
1294
  }
1266
1295
  }
1267
1296
  function stripInternalStack(lines) {
@@ -1273,8 +1302,10 @@ function stripInternalStack(lines) {
1273
1302
  "createProcessError",
1274
1303
  "formatError",
1275
1304
  "spawnWithLifecycle",
1305
+ "assertValidCommand",
1276
1306
  "setupLifecycle",
1277
- "node:internal"
1307
+ "node:internal",
1308
+ "node:internal/process/promises"
1278
1309
  ];
1279
1310
  return lines.filter((line) => {
1280
1311
  if (blacklist.some((key) => line.includes(key))) return false;
@@ -1341,29 +1372,70 @@ var CommandProcessError = class extends Error {
1341
1372
  function isCommandProcessError(err) {
1342
1373
  return err instanceof CommandProcessError;
1343
1374
  }
1375
+ function hasShellSyntax(str) {
1376
+ return /(\|\||&&|[|&;<>\n])/.test(str);
1377
+ }
1378
+ function resolveCommand(input, useColors = true) {
1379
+ const tokens = (0, shell_quote.parse)(input);
1380
+ const normalized = [];
1381
+ for (const t of tokens) {
1382
+ if (typeof t === "string") {
1383
+ normalized.push(t);
1384
+ continue;
1385
+ }
1386
+ if ("comment" in t) continue;
1387
+ if ("pattern" in t) {
1388
+ normalized.push(t.pattern);
1389
+ continue;
1390
+ }
1391
+ if ("op" in t) throw new Error(formatMessageColor("Unsupported shell operator detected.", useColors));
1392
+ throw new Error(formatMessageColor("Unknown token in command.", useColors));
1393
+ }
1394
+ if (normalized.length === 0) throw new Error(formatMessageColor("Invalid command: empty after parsing.", useColors));
1395
+ const [cmd, ...args] = normalized;
1396
+ if (!cmd) throw new Error(formatMessageColor("Invalid command: empty after parsing.", useColors));
1397
+ return {
1398
+ command: cmd,
1399
+ args
1400
+ };
1401
+ }
1344
1402
  function spawnWithLifecycle(command, args, options, config) {
1345
- const { useColors = true, timeout, forceKill, signal: abortSignal, ...restOption } = options;
1403
+ const { useColors = true, timeout, forceKill, signal: abortSignal, shell = false, ...restOption } = options;
1404
+ let cmd = command;
1405
+ let finalArgs = [...args];
1406
+ const isInline = finalArgs.length === 0 && /\s/.test(cmd);
1346
1407
  const baseStack = (/* @__PURE__ */ new Error()).stack;
1347
- const cmdString = formatCommand(command, args, { useColors });
1348
- const cmdStringPlain = formatCommand(command, args, { useColors: false });
1349
1408
  const formatError = config?.formatError ?? ((msg, meta) => {
1350
1409
  const metaCommand = meta.command.trim();
1351
- const argsString = meta.args.length > 0 ? meta.args.map((a) => require_helper.safeStableStringify(a).trim()).join(" ") : "";
1410
+ const hasArgs = meta.args.length > 0;
1411
+ const argsString = hasArgs ? meta.args.map((a) => require_helper.safeStableStringify(a).trim()).join(" ") : "";
1412
+ const commandString = hasArgs ? `${metaCommand} ${argsString}` : metaCommand;
1352
1413
  if (meta.useColors) {
1353
1414
  const cmd = require_client.picocolors.magentaBright(metaCommand);
1354
- const args = argsString ? require_client.picocolors.yellowBright(argsString) : "";
1415
+ const args = hasArgs ? require_client.picocolors.yellowBright(argsString) : "";
1355
1416
  return createProcessError(`${cmd}${args ? " " + args : ""} ${require_client.picocolors.redBright(msg)}`, {
1356
1417
  ...meta,
1357
- command: `${metaCommand} ${argsString}`
1418
+ command: commandString
1358
1419
  }, baseStack);
1359
1420
  }
1360
- return createProcessError(`${metaCommand}${require_helper.isNonEmptyString(argsString) ? " " + argsString : ""} ${msg}`, {
1421
+ return createProcessError(`${commandString} ${msg}`, {
1361
1422
  ...meta,
1362
- command: `${metaCommand} ${argsString}`
1423
+ command: commandString
1363
1424
  }, baseStack);
1364
1425
  });
1365
1426
  const rejectOnNonZero = config?.rejectOnNonZero ?? false;
1366
- const child = (0, node_child_process.spawn)(command, [...args], restOption);
1427
+ if (isInline) {
1428
+ const resolved = resolveCommand(cmd, useColors);
1429
+ cmd = resolved.command;
1430
+ finalArgs = resolved.args;
1431
+ }
1432
+ for (const arg of finalArgs) if (hasShellSyntax(arg)) throw new Error(formatMessageColor(`Invalid argument: "${arg}" contains unsupported shell syntax`, useColors));
1433
+ const cmdString = formatCommand(cmd, finalArgs, { useColors });
1434
+ const cmdStringPlain = formatCommand(cmd, finalArgs, { useColors: false });
1435
+ const child = (0, node_child_process.spawn)(cmd, finalArgs, {
1436
+ shell,
1437
+ ...restOption
1438
+ });
1367
1439
  let finished = false;
1368
1440
  const kill = () => {
1369
1441
  try {
@@ -1388,8 +1460,8 @@ function spawnWithLifecycle(command, args, options, config) {
1388
1460
  kill();
1389
1461
  fail(formatError(`timed out after ${timeout}ms`, {
1390
1462
  reason: "timeout",
1391
- command,
1392
- args,
1463
+ command: cmd,
1464
+ args: finalArgs,
1393
1465
  useColors
1394
1466
  }));
1395
1467
  }, timeout) : null;
@@ -1413,8 +1485,8 @@ function spawnWithLifecycle(command, args, options, config) {
1413
1485
  kill();
1414
1486
  fail(formatError("aborted by signal", {
1415
1487
  reason: "abort",
1416
- command,
1417
- args,
1488
+ command: cmd,
1489
+ args: finalArgs,
1418
1490
  useColors
1419
1491
  }));
1420
1492
  };
@@ -1432,8 +1504,8 @@ function spawnWithLifecycle(command, args, options, config) {
1432
1504
  reason: "signal",
1433
1505
  signal,
1434
1506
  exitCode: code ?? void 0,
1435
- command,
1436
- args,
1507
+ command: cmd,
1508
+ args: finalArgs,
1437
1509
  useColors
1438
1510
  }));
1439
1511
  return;
@@ -1443,8 +1515,8 @@ function spawnWithLifecycle(command, args, options, config) {
1443
1515
  fail(formatError(`exited with code ${exitCode}`, {
1444
1516
  reason: "non-zero exit code",
1445
1517
  exitCode,
1446
- command,
1447
- args,
1518
+ command: cmd,
1519
+ args: finalArgs,
1448
1520
  useColors
1449
1521
  }));
1450
1522
  return;