@rzl-zone/build-tools 0.0.7 → 0.0.8

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 (63) 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-VbpeaXsy.cjs → client-BczBMDS6.cjs} +3 -3
  16. package/dist/{client-VbpeaXsy.cjs.map → client-BczBMDS6.cjs.map} +1 -1
  17. package/dist/{client-CuldIPPY.js → client-C0ZDdv36.js} +3 -3
  18. package/dist/{client-CuldIPPY.js.map → client-C0ZDdv36.js.map} +1 -1
  19. package/dist/commander-kit/index.cjs +5 -5
  20. package/dist/commander-kit/index.d.cts +3 -3
  21. package/dist/commander-kit/index.d.ts +3 -3
  22. package/dist/commander-kit/index.js +5 -5
  23. package/dist/{extra-DY59MRMZ.d.ts → extra-CDUxrgcT.d.ts} +2 -2
  24. package/dist/{extra-2iX9E4Hj.d.cts → extra-CnJhk-pp.d.cts} +2 -2
  25. package/dist/{fast-globe-options-BLHLcUA_.d.cts → fast-globe-options-B4edSsWz.d.cts} +3 -3
  26. package/dist/{fast-globe-options-ClsKhWod.d.ts → fast-globe-options-CMxk8gD9.d.ts} +3 -3
  27. package/dist/{helper-BlSd9P9f.js → helper-2m5t07Qe.js} +2 -2
  28. package/dist/{helper-BlSd9P9f.js.map → helper-2m5t07Qe.js.map} +1 -1
  29. package/dist/{helper-PkWCboHw.cjs → helper-BRO-s2fI.cjs} +2 -2
  30. package/dist/{helper-PkWCboHw.cjs.map → helper-BRO-s2fI.cjs.map} +1 -1
  31. package/dist/{identity-NSVVUm0l.cjs → identity-1Zk_fLSI.cjs} +6 -6
  32. package/dist/{identity-NSVVUm0l.cjs.map → identity-1Zk_fLSI.cjs.map} +1 -1
  33. package/dist/{identity-BFjidy_R.js → identity-CCGqrTRL.js} +6 -6
  34. package/dist/{identity-BFjidy_R.js.map → identity-CCGqrTRL.js.map} +1 -1
  35. package/dist/{index-BNJNsFwK.d.cts → index-B3ChWfIR.d.cts} +2 -2
  36. package/dist/{index-CNjsgh1e.d.ts → index-C-jXEIZS.d.ts} +15 -3
  37. package/dist/{index-CQatHoCR.d.ts → index-DPGJBhEK.d.ts} +2 -2
  38. package/dist/{index-B3VpO-fM.d.cts → index-De-ymoL3.d.cts} +15 -3
  39. package/dist/index.cjs +196 -196
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +157 -157
  42. package/dist/index.d.ts +157 -157
  43. package/dist/index.js +196 -196
  44. package/dist/index.js.map +1 -1
  45. package/dist/{package-banner-yTTlKTH6.cjs → package-banner-BAbZghTB.cjs} +17 -11
  46. package/dist/package-banner-BAbZghTB.cjs.map +1 -0
  47. package/dist/{package-banner-Cgukf7xE.js → package-banner-BM84W-TO.js} +17 -11
  48. package/dist/package-banner-BM84W-TO.js.map +1 -0
  49. package/dist/{server-niOC1_n4.js → server-DH801yY1.js} +3 -3
  50. package/dist/{server-niOC1_n4.js.map → server-DH801yY1.js.map} +1 -1
  51. package/dist/{server-Ct02ysTN.cjs → server-DL-uLx4N.cjs} +3 -3
  52. package/dist/{server-Ct02ysTN.cjs.map → server-DL-uLx4N.cjs.map} +1 -1
  53. package/dist/utils/client.cjs +2 -2
  54. package/dist/utils/client.d.cts +1 -1
  55. package/dist/utils/client.d.ts +1 -1
  56. package/dist/utils/client.js +2 -2
  57. package/dist/utils/server.cjs +2 -2
  58. package/dist/utils/server.d.cts +2 -2
  59. package/dist/utils/server.d.ts +2 -2
  60. package/dist/utils/server.js +2 -2
  61. package/package.json +1 -1
  62. package/dist/package-banner-Cgukf7xE.js.map +0 -1
  63. package/dist/package-banner-yTTlKTH6.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"identity-BFjidy_R.js","names":["packageJson.name","packageJson.version"],"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,CAAC,iBAAiB,QAAQ,mBAAmB,CAC/C,OAAM,IAAI,MACR,oJACD;AAGH,OAAK,eAAe,QAAQ;AAC5B,OAAK,eAAe,QAAQ;AAC5B,OAAK,WAAW,iBAAiB,QAAQ,QAAQ,GAC7C,QAAQ,UACR,aAAa;AAEjB,OAAK,WAAW,QAAQ;AACxB,OAAK,eAAe,QAAQ;AAC5B,OAAK,mBAAmB,QAAQ,oBAAoB,MAAM;;;;;;;;;;CAW5D,AAAQ,OAAO,OAKJ;EACT,MAAM,EAAE,OAAO,MAAM,WAAW,gBAAgB;EAChD,MAAM,YAAY,iBAAiB,KAAK,GAAG,OAAO,KAAK;EACvD,MAAM,aAAa,iBAAiB,MAAM,GAAG,IAAI,MAAM,KAAK;AAE5D,MAAI,CAAC,UACH,OAAM,IAAI,MACR,qHAED;EAGH,MAAM,gBAAgB,iBAAiB,KAAK,SAAS,GACjD,IAAI,KAAK,aACT;AAEJ,SACE,GAAG,WAAW,KAAK,WAAW,KAAK,cAAc,cAAc,CAAC,GAC7D,WAAW,YAAY,WAAW,GAClC,WAAW,KAAK,WAAW,cAAc,iBAAiB,UAAU,GAAG,YAAY,KAAK,iBAAiB,CAAC,CAAC,GAC3G,WAAW,UAAU,WAAW,OAAO,WAAW,aAAa,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;CAmBlF,AAAO,IAAI,UAAkC,EAAE,EAAU;EACvD,MAAM,cAAc,iBAAiB,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,cAAc,iBAAiB,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,MAAI,iBAAiB,MAAM,CAAE,MAAK,WAAW;AAE7C,SAAO"}
1
+ {"version":3,"file":"identity-CCGqrTRL.js","names":["packageJson.name","packageJson.version"],"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,CAAC,iBAAiB,QAAQ,mBAAmB,CAC/C,OAAM,IAAI,MACR,oJACD;AAGH,OAAK,eAAe,QAAQ;AAC5B,OAAK,eAAe,QAAQ;AAC5B,OAAK,WAAW,iBAAiB,QAAQ,QAAQ,GAC7C,QAAQ,UACR,aAAa;AAEjB,OAAK,WAAW,QAAQ;AACxB,OAAK,eAAe,QAAQ;AAC5B,OAAK,mBAAmB,QAAQ,oBAAoB,MAAM;;;;;;;;;;CAW5D,AAAQ,OAAO,OAKJ;EACT,MAAM,EAAE,OAAO,MAAM,WAAW,gBAAgB;EAChD,MAAM,YAAY,iBAAiB,KAAK,GAAG,OAAO,KAAK;EACvD,MAAM,aAAa,iBAAiB,MAAM,GAAG,IAAI,MAAM,KAAK;AAE5D,MAAI,CAAC,UACH,OAAM,IAAI,MACR,qHAED;EAGH,MAAM,gBAAgB,iBAAiB,KAAK,SAAS,GACjD,IAAI,KAAK,aACT;AAEJ,SACE,GAAG,WAAW,KAAK,WAAW,KAAK,cAAc,cAAc,CAAC,GAC7D,WAAW,YAAY,WAAW,GAClC,WAAW,KAAK,WAAW,cAAc,iBAAiB,UAAU,GAAG,YAAY,KAAK,iBAAiB,CAAC,CAAC,GAC3G,WAAW,UAAU,WAAW,OAAO,WAAW,aAAa,UAAU,CAAC,CAAC;;;;;;;;;;;;;;;;;CAmBlF,AAAO,IAAI,UAAkC,EAAE,EAAU;EACvD,MAAM,cAAc,iBAAiB,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,cAAc,iBAAiB,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,MAAI,iBAAiB,MAAM,CAAE,MAAK,WAAW;AAE7C,SAAO"}
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.7`
5
+ * Version: `0.0.8`
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-BNJNsFwK.d.cts.map
356
+ //# sourceMappingURL=index-B3ChWfIR.d.cts.map
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.7`
5
+ * Version: `0.0.8`
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
  * ========================================================================
@@ -636,10 +636,16 @@ type GeneratePackageBannerOptions = {
636
636
  * This utility generates a formatted banner comment suitable
637
637
  * for insertion at the top of bundled output files.
638
638
  *
639
+ * By default, it automatically locates and reads the nearest
640
+ * `package.json` file, you may also provide a custom package object
641
+ * through the options parameter.
642
+ *
639
643
  * - *Banner features:*
640
644
  * - Reads metadata from the nearest `package.json`.
645
+ * - Supports custom package metadata via options.
641
646
  * - Provides safe fallbacks for missing fields.
642
647
  * - Produces a consistent, readable comment block.
648
+ * - Normalizes repository URLs when possible.
643
649
  *
644
650
  * - *This function is intended for:*
645
651
  * - Bundler banners (tsdown, tsup, rollup, esbuild, etc).
@@ -649,9 +655,15 @@ type GeneratePackageBannerOptions = {
649
655
  * @param {GeneratePackageBannerOptions} [options]
650
656
  * Optional banner configuration.
651
657
  *
652
- * @returns {string}
658
+ * @returns {Promise<string>}
653
659
  * A formatted banner comment string.
654
660
  *
661
+ * @throws {Error}
662
+ * If no `package.json` can be found.
663
+ *
664
+ * @throws {Error}
665
+ * If the resolved `package.json` contains invalid JSON.
666
+ *
655
667
  * @example
656
668
  * ```ts
657
669
  * const banner = await generatePackageBanner({
@@ -667,4 +679,4 @@ type GeneratePackageBannerOptions = {
667
679
  */
668
680
  declare const generatePackageBanner: (options?: GeneratePackageBannerOptions) => Promise<string>;
669
681
  export { generatePackageBanner as n, PackageJson as r, GeneratePackageBannerOptions as t };
670
- //# sourceMappingURL=index-CNjsgh1e.d.ts.map
682
+ //# sourceMappingURL=index-C-jXEIZS.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.7`
5
+ * Version: `0.0.8`
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-CQatHoCR.d.ts.map
356
+ //# sourceMappingURL=index-DPGJBhEK.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.7`
5
+ * Version: `0.0.8`
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
  * ========================================================================
@@ -636,10 +636,16 @@ type GeneratePackageBannerOptions = {
636
636
  * This utility generates a formatted banner comment suitable
637
637
  * for insertion at the top of bundled output files.
638
638
  *
639
+ * By default, it automatically locates and reads the nearest
640
+ * `package.json` file, you may also provide a custom package object
641
+ * through the options parameter.
642
+ *
639
643
  * - *Banner features:*
640
644
  * - Reads metadata from the nearest `package.json`.
645
+ * - Supports custom package metadata via options.
641
646
  * - Provides safe fallbacks for missing fields.
642
647
  * - Produces a consistent, readable comment block.
648
+ * - Normalizes repository URLs when possible.
643
649
  *
644
650
  * - *This function is intended for:*
645
651
  * - Bundler banners (tsdown, tsup, rollup, esbuild, etc).
@@ -649,9 +655,15 @@ type GeneratePackageBannerOptions = {
649
655
  * @param {GeneratePackageBannerOptions} [options]
650
656
  * Optional banner configuration.
651
657
  *
652
- * @returns {string}
658
+ * @returns {Promise<string>}
653
659
  * A formatted banner comment string.
654
660
  *
661
+ * @throws {Error}
662
+ * If no `package.json` can be found.
663
+ *
664
+ * @throws {Error}
665
+ * If the resolved `package.json` contains invalid JSON.
666
+ *
655
667
  * @example
656
668
  * ```ts
657
669
  * const banner = await generatePackageBanner({
@@ -667,4 +679,4 @@ type GeneratePackageBannerOptions = {
667
679
  */
668
680
  declare const generatePackageBanner: (options?: GeneratePackageBannerOptions) => Promise<string>;
669
681
  export { generatePackageBanner as n, PackageJson as r, GeneratePackageBannerOptions as t };
670
- //# sourceMappingURL=index-B3VpO-fM.d.cts.map
682
+ //# sourceMappingURL=index-De-ymoL3.d.cts.map
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  * ========================================================================
3
3
  * @rzl-zone/build-tools
4
4
  * ------------------------------------------------------------------------
5
- * Version: `0.0.7`
5
+ * Version: `0.0.8`
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-PkWCboHw.cjs');
14
- const require_server = require('./server-Ct02ysTN.cjs');
15
- const require_identity = require('./identity-NSVVUm0l.cjs');
16
- const require_client = require('./client-VbpeaXsy.cjs');
17
- const require_package_banner = require('./package-banner-yTTlKTH6.cjs');
13
+ const require_helper = require('./helper-BRO-s2fI.cjs');
14
+ const require_server = require('./server-DL-uLx4N.cjs');
15
+ const require_identity = require('./identity-1Zk_fLSI.cjs');
16
+ const require_client = require('./client-BczBMDS6.cjs');
17
+ const require_package_banner = require('./package-banner-BAbZghTB.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,9 +23,9 @@ 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 node_child_process = require("node:child_process");
26
27
  let acorn = require("acorn");
27
28
  acorn = require_helper.__toESM(acorn, 1);
28
- let node_child_process = require("node:child_process");
29
29
  function isLogLevel(value) {
30
30
  return typeof value === "string" && value in LOG_LEVEL_PRIORITY;
31
31
  }
@@ -1160,195 +1160,6 @@ const normalizeJsBuildNewlines = async (pattern, options = {}) => {
1160
1160
  });
1161
1161
  }
1162
1162
  };
1163
- const DEFAULT_SJC_PATTERN_POLICY = {
1164
- filesOnly: true,
1165
- forceUnique: true
1166
- };
1167
- const resolvedSjcPatternOption = require_server.resolvePatternOptions(require_server.defaultPatternOptions, DEFAULT_SJC_PATTERN_POLICY);
1168
- const DEFAULT_SJC_OPTIONS = {
1169
- removeSourceMap: false,
1170
- sourceType: "module",
1171
- removeRegion: true,
1172
- ecmaVersion: "latest",
1173
- patternOptions: resolvedSjcPatternOption,
1174
- logLevel: DEFAULT_LOG_LEVEL
1175
- };
1176
- const VALID_SOURCE_TYPE = new Set([
1177
- "module",
1178
- "script",
1179
- "commonjs"
1180
- ]);
1181
- const VALID_ECMA_VERSION = new Set([
1182
- "latest",
1183
- 3,
1184
- 5,
1185
- 6,
1186
- 7,
1187
- 8,
1188
- 9,
1189
- 10,
1190
- 11,
1191
- 12,
1192
- 13,
1193
- 14,
1194
- 15,
1195
- 16,
1196
- 17,
1197
- 2015,
1198
- 2016,
1199
- 2017,
1200
- 2018,
1201
- 2019,
1202
- 2020,
1203
- 2021,
1204
- 2022,
1205
- 2023,
1206
- 2024,
1207
- 2025,
1208
- 2026
1209
- ]);
1210
- const REGION_COMMENT_RE = /^#(?:end)?region\b/i;
1211
- const SOURCE_MAP_COMMENT_RE = /^[#@]\s*sourceMappingURL=/;
1212
- function normalizeNewlines(code) {
1213
- return code.replace(/[ \t]+\n/g, require_client.EOL).replace(/\n\s*\n+/g, require_client.EOL);
1214
- }
1215
- function stripComments(code, { removeRegion, removeSourceMap, sourceType, ecmaVersion }) {
1216
- const comments = [];
1217
- if (sourceType == null || !VALID_SOURCE_TYPE.has(sourceType)) sourceType = DEFAULT_SJC_OPTIONS.sourceType;
1218
- if (ecmaVersion == null || !VALID_ECMA_VERSION.has(ecmaVersion)) ecmaVersion = DEFAULT_SJC_OPTIONS.ecmaVersion;
1219
- try {
1220
- acorn.parse(code, {
1221
- sourceType,
1222
- ecmaVersion,
1223
- allowHashBang: true,
1224
- onComment(block, text, start, end) {
1225
- if (!block) {
1226
- const value = text.trim();
1227
- if (!REGION_COMMENT_RE.test(value) && !SOURCE_MAP_COMMENT_RE.test(value)) return;
1228
- }
1229
- const value = text.trim();
1230
- const forceRemove = shouldRemoveDocRuntime(value);
1231
- if (forceRemove === true) {
1232
- comments.push([start, end]);
1233
- return;
1234
- }
1235
- if (forceRemove === false) return;
1236
- if (IMPORTANT_COMMENT.test(value)) return;
1237
- if (SOURCE_MAP_COMMENT_RE.test(value)) {
1238
- if (removeSourceMap) comments.push([start, end]);
1239
- return;
1240
- }
1241
- if (REGION_COMMENT_RE.test(value)) {
1242
- if (removeRegion) comments.push([start, end]);
1243
- return;
1244
- }
1245
- if (block) comments.push([start, end]);
1246
- }
1247
- });
1248
- } catch {
1249
- return code;
1250
- }
1251
- if (!comments.length) return code;
1252
- const parts = [];
1253
- let last = 0;
1254
- for (const [start, end] of comments) {
1255
- parts.push(code.slice(last, start));
1256
- last = end;
1257
- }
1258
- parts.push(code.slice(last));
1259
- const lines = parts.join("").split(/\r?\n/);
1260
- const seenSourceMap = /* @__PURE__ */ new Set();
1261
- return lines.filter((line) => {
1262
- if (SOURCE_MAP_RE.test(line)) {
1263
- const key = line.trim();
1264
- if (seenSourceMap.has(key)) return false;
1265
- seenSourceMap.add(key);
1266
- if (removeSourceMap) return false;
1267
- return true;
1268
- }
1269
- if (removeRegion && REGION_RE.test(line)) return false;
1270
- if (isTargetComment(line, {
1271
- removeSourceMap,
1272
- removeRegion
1273
- })) return false;
1274
- return true;
1275
- }).map((line) => {
1276
- let out = line.replace(/^[ \t]*\/\/\s*(?:\.\.\/|\.\/)*[^ \n]*?(?:src|node_modules)\/[^\n]*\n?/gm, "").replace(/\/\/\s*eslint[^\n]*/g, "");
1277
- out = out.replace(/(\/\/[#@]\s*sourceMappingURL=[^\r\n]*)(?:\r?\n\1)+/g, "$1");
1278
- return out;
1279
- }).join(require_client.EOL);
1280
- }
1281
- const commandSjcIdentity = new require_identity.CommandIdentity({ defaultCommandName: "strip-js-comments" });
1282
- const stripJsComments = async (pattern, options = {}) => {
1283
- const loggerLevel = resolveLogVerbosity(options, DEFAULT_SJC_OPTIONS.logLevel);
1284
- try {
1285
- 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;
1286
- if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_client.joinLinesLoose(require_helper.isNonEmptyString(__commandTitle) ? __commandTitle : commandSjcIdentity.utility(), ""));
1287
- const patterns = [...require_helper.toStringSet(pattern)];
1288
- const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_SJC_PATTERN_POLICY);
1289
- if (canLog(loggerLevel, VERBOSE_LOG)) {
1290
- BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
1291
- BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
1292
- BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_SJC_OPTIONS.patternOptions));
1293
- BUILD_LOGGER.OPTIONS("options.removeSourceMap", removeSourceMap, BUILD_LOGGER.SOURCE_OF(removeSourceMap, DEFAULT_SJC_OPTIONS.removeSourceMap));
1294
- BUILD_LOGGER.OPTIONS("options.removeRegion", removeRegion, BUILD_LOGGER.SOURCE_OF(removeRegion, DEFAULT_SJC_OPTIONS.removeRegion));
1295
- BUILD_LOGGER.OPTIONS("options.sourceType", sourceType, BUILD_LOGGER.SOURCE_OF(sourceType, DEFAULT_SJC_OPTIONS.sourceType));
1296
- BUILD_LOGGER.OPTIONS("options.ecmaVersion", ecmaVersion, BUILD_LOGGER.SOURCE_OF(ecmaVersion, DEFAULT_SJC_OPTIONS.ecmaVersion));
1297
- BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_SJC_OPTIONS.logLevel));
1298
- BUILD_LOGGER.NEW_LINE();
1299
- BUILD_LOGGER.ON_STARTING({ actionName: "Stripping JS Comments" });
1300
- }
1301
- const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
1302
- let count = 0;
1303
- for (const filePath of files) {
1304
- if (!JS_OUTPUT_FILE_RE.test(filePath)) continue;
1305
- let content;
1306
- try {
1307
- content = await require_server.fsExtra.promises.readFile(filePath, "utf8");
1308
- } catch (err) {
1309
- if (err.code === "ENOENT") continue;
1310
- throw err;
1311
- }
1312
- let output = content;
1313
- if (!/\/[/*]/.test(content)) continue;
1314
- output = stripComments(content, {
1315
- removeRegion,
1316
- removeSourceMap,
1317
- sourceType,
1318
- ecmaVersion
1319
- });
1320
- output = normalizeNewlines(output).trim() + require_client.EOL;
1321
- if (output !== content) {
1322
- try {
1323
- await require_server.fsExtra.promises.writeFile(filePath, output, "utf8");
1324
- } catch (err) {
1325
- if (err.code === "ENOENT") continue;
1326
- throw err;
1327
- }
1328
- count++;
1329
- if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
1330
- actionName: "JS Comment Stripping",
1331
- count,
1332
- nameDirect: filePath
1333
- });
1334
- }
1335
- }
1336
- if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
1337
- actionName: "Stripping JS Comments",
1338
- count
1339
- });
1340
- else BUILD_LOGGER.ON_SKIPPING({
1341
- actionName: "Stripping JS Comments",
1342
- reasonType: "file",
1343
- reasonEndText: "processing"
1344
- });
1345
- } catch (error) {
1346
- if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
1347
- actionName: "Stripping JS Comments",
1348
- error
1349
- });
1350
- }
1351
- };
1352
1163
  function runCommand(command, argsOrOptions = [], maybeOptions = {}) {
1353
1164
  assertValidCommand(command);
1354
1165
  let args;
@@ -1643,6 +1454,195 @@ function spawnWithLifecycle(command, args, options, config) {
1643
1454
  }
1644
1455
  };
1645
1456
  }
1457
+ const DEFAULT_SJC_PATTERN_POLICY = {
1458
+ filesOnly: true,
1459
+ forceUnique: true
1460
+ };
1461
+ const resolvedSjcPatternOption = require_server.resolvePatternOptions(require_server.defaultPatternOptions, DEFAULT_SJC_PATTERN_POLICY);
1462
+ const DEFAULT_SJC_OPTIONS = {
1463
+ removeSourceMap: false,
1464
+ sourceType: "module",
1465
+ removeRegion: true,
1466
+ ecmaVersion: "latest",
1467
+ patternOptions: resolvedSjcPatternOption,
1468
+ logLevel: DEFAULT_LOG_LEVEL
1469
+ };
1470
+ const VALID_SOURCE_TYPE = new Set([
1471
+ "module",
1472
+ "script",
1473
+ "commonjs"
1474
+ ]);
1475
+ const VALID_ECMA_VERSION = new Set([
1476
+ "latest",
1477
+ 3,
1478
+ 5,
1479
+ 6,
1480
+ 7,
1481
+ 8,
1482
+ 9,
1483
+ 10,
1484
+ 11,
1485
+ 12,
1486
+ 13,
1487
+ 14,
1488
+ 15,
1489
+ 16,
1490
+ 17,
1491
+ 2015,
1492
+ 2016,
1493
+ 2017,
1494
+ 2018,
1495
+ 2019,
1496
+ 2020,
1497
+ 2021,
1498
+ 2022,
1499
+ 2023,
1500
+ 2024,
1501
+ 2025,
1502
+ 2026
1503
+ ]);
1504
+ const REGION_COMMENT_RE = /^#(?:end)?region\b/i;
1505
+ const SOURCE_MAP_COMMENT_RE = /^[#@]\s*sourceMappingURL=/;
1506
+ function normalizeNewlines(code) {
1507
+ return code.replace(/[ \t]+\n/g, require_client.EOL).replace(/\n\s*\n+/g, require_client.EOL);
1508
+ }
1509
+ function stripComments(code, { removeRegion, removeSourceMap, sourceType, ecmaVersion }) {
1510
+ const comments = [];
1511
+ if (sourceType == null || !VALID_SOURCE_TYPE.has(sourceType)) sourceType = DEFAULT_SJC_OPTIONS.sourceType;
1512
+ if (ecmaVersion == null || !VALID_ECMA_VERSION.has(ecmaVersion)) ecmaVersion = DEFAULT_SJC_OPTIONS.ecmaVersion;
1513
+ try {
1514
+ acorn.parse(code, {
1515
+ sourceType,
1516
+ ecmaVersion,
1517
+ allowHashBang: true,
1518
+ onComment(block, text, start, end) {
1519
+ if (!block) {
1520
+ const value = text.trim();
1521
+ if (!REGION_COMMENT_RE.test(value) && !SOURCE_MAP_COMMENT_RE.test(value)) return;
1522
+ }
1523
+ const value = text.trim();
1524
+ const forceRemove = shouldRemoveDocRuntime(value);
1525
+ if (forceRemove === true) {
1526
+ comments.push([start, end]);
1527
+ return;
1528
+ }
1529
+ if (forceRemove === false) return;
1530
+ if (IMPORTANT_COMMENT.test(value)) return;
1531
+ if (SOURCE_MAP_COMMENT_RE.test(value)) {
1532
+ if (removeSourceMap) comments.push([start, end]);
1533
+ return;
1534
+ }
1535
+ if (REGION_COMMENT_RE.test(value)) {
1536
+ if (removeRegion) comments.push([start, end]);
1537
+ return;
1538
+ }
1539
+ if (block) comments.push([start, end]);
1540
+ }
1541
+ });
1542
+ } catch {
1543
+ return code;
1544
+ }
1545
+ if (!comments.length) return code;
1546
+ const parts = [];
1547
+ let last = 0;
1548
+ for (const [start, end] of comments) {
1549
+ parts.push(code.slice(last, start));
1550
+ last = end;
1551
+ }
1552
+ parts.push(code.slice(last));
1553
+ const lines = parts.join("").split(/\r?\n/);
1554
+ const seenSourceMap = /* @__PURE__ */ new Set();
1555
+ return lines.filter((line) => {
1556
+ if (SOURCE_MAP_RE.test(line)) {
1557
+ const key = line.trim();
1558
+ if (seenSourceMap.has(key)) return false;
1559
+ seenSourceMap.add(key);
1560
+ if (removeSourceMap) return false;
1561
+ return true;
1562
+ }
1563
+ if (removeRegion && REGION_RE.test(line)) return false;
1564
+ if (isTargetComment(line, {
1565
+ removeSourceMap,
1566
+ removeRegion
1567
+ })) return false;
1568
+ return true;
1569
+ }).map((line) => {
1570
+ let out = line.replace(/^[ \t]*\/\/\s*(?:\.\.\/|\.\/)*[^ \n]*?(?:src|node_modules)\/[^\n]*\n?/gm, "").replace(/\/\/\s*eslint[^\n]*/g, "");
1571
+ out = out.replace(/(\/\/[#@]\s*sourceMappingURL=[^\r\n]*)(?:\r?\n\1)+/g, "$1");
1572
+ return out;
1573
+ }).join(require_client.EOL);
1574
+ }
1575
+ const commandSjcIdentity = new require_identity.CommandIdentity({ defaultCommandName: "strip-js-comments" });
1576
+ const stripJsComments = async (pattern, options = {}) => {
1577
+ const loggerLevel = resolveLogVerbosity(options, DEFAULT_SJC_OPTIONS.logLevel);
1578
+ try {
1579
+ 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;
1580
+ if (canLog(loggerLevel, VERBOSE_LOG)) console.log(require_client.joinLinesLoose(require_helper.isNonEmptyString(__commandTitle) ? __commandTitle : commandSjcIdentity.utility(), ""));
1581
+ const patterns = [...require_helper.toStringSet(pattern)];
1582
+ const cleanPatternOptions = require_server.resolvePatternOptions(patternOptions, DEFAULT_SJC_PATTERN_POLICY);
1583
+ if (canLog(loggerLevel, VERBOSE_LOG)) {
1584
+ BUILD_LOGGER.SECTION("Options", { icon: "⚙️ " });
1585
+ BUILD_LOGGER.OPTIONS("pattern", patterns, BUILD_LOGGER.SOURCE_OF(patterns, void 0), true);
1586
+ BUILD_LOGGER.OPTIONS("options.patternOptions", cleanPatternOptions, require_server.sourceOfPatternOptions(cleanPatternOptions, DEFAULT_SJC_OPTIONS.patternOptions));
1587
+ BUILD_LOGGER.OPTIONS("options.removeSourceMap", removeSourceMap, BUILD_LOGGER.SOURCE_OF(removeSourceMap, DEFAULT_SJC_OPTIONS.removeSourceMap));
1588
+ BUILD_LOGGER.OPTIONS("options.removeRegion", removeRegion, BUILD_LOGGER.SOURCE_OF(removeRegion, DEFAULT_SJC_OPTIONS.removeRegion));
1589
+ BUILD_LOGGER.OPTIONS("options.sourceType", sourceType, BUILD_LOGGER.SOURCE_OF(sourceType, DEFAULT_SJC_OPTIONS.sourceType));
1590
+ BUILD_LOGGER.OPTIONS("options.ecmaVersion", ecmaVersion, BUILD_LOGGER.SOURCE_OF(ecmaVersion, DEFAULT_SJC_OPTIONS.ecmaVersion));
1591
+ BUILD_LOGGER.OPTIONS("options.logLevel", loggerLevel, BUILD_LOGGER.SOURCE_OF(loggerLevel, DEFAULT_SJC_OPTIONS.logLevel));
1592
+ BUILD_LOGGER.NEW_LINE();
1593
+ BUILD_LOGGER.ON_STARTING({ actionName: "Stripping JS Comments" });
1594
+ }
1595
+ const files = (await require_server.fastGlob(patterns, cleanPatternOptions)).sort();
1596
+ let count = 0;
1597
+ for (const filePath of files) {
1598
+ if (!JS_OUTPUT_FILE_RE.test(filePath)) continue;
1599
+ let content;
1600
+ try {
1601
+ content = await require_server.fsExtra.promises.readFile(filePath, "utf8");
1602
+ } catch (err) {
1603
+ if (err.code === "ENOENT") continue;
1604
+ throw err;
1605
+ }
1606
+ let output = content;
1607
+ if (!/\/[/*]/.test(content)) continue;
1608
+ output = stripComments(content, {
1609
+ removeRegion,
1610
+ removeSourceMap,
1611
+ sourceType,
1612
+ ecmaVersion
1613
+ });
1614
+ output = normalizeNewlines(output).trim() + require_client.EOL;
1615
+ if (output !== content) {
1616
+ try {
1617
+ await require_server.fsExtra.promises.writeFile(filePath, output, "utf8");
1618
+ } catch (err) {
1619
+ if (err.code === "ENOENT") continue;
1620
+ throw err;
1621
+ }
1622
+ count++;
1623
+ if (canLog(loggerLevel, VERBOSE_LOG)) BUILD_LOGGER.ON_PROCESS({
1624
+ actionName: "JS Comment Stripping",
1625
+ count,
1626
+ nameDirect: filePath
1627
+ });
1628
+ }
1629
+ }
1630
+ if (canLog(loggerLevel, VERBOSE_LOG)) if (count > 0) BUILD_LOGGER.ON_FINISH({
1631
+ actionName: "Stripping JS Comments",
1632
+ count
1633
+ });
1634
+ else BUILD_LOGGER.ON_SKIPPING({
1635
+ actionName: "Stripping JS Comments",
1636
+ reasonType: "file",
1637
+ reasonEndText: "processing"
1638
+ });
1639
+ } catch (error) {
1640
+ if (loggerLevel !== "silent") BUILD_LOGGER.ON_ERROR({
1641
+ actionName: "Stripping JS Comments",
1642
+ error
1643
+ });
1644
+ }
1645
+ };
1646
1646
  exports.CommandProcessError = CommandProcessError;
1647
1647
  exports.DEFAULT_CLEAN_PATTERN_POLICY = DEFAULT_CLEAN_PATTERN_POLICY;
1648
1648
  exports.DEFAULT_ECI_PATTERN_POLICY = DEFAULT_ECI_PATTERN_POLICY;