@rzl-zone/build-tools 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/.references/index.d.cts +1 -1
- package/dist/.references/index.d.ts +1 -1
- package/dist/bundler/rolldown.cjs +2 -2
- package/dist/bundler/rolldown.d.cts +2 -2
- package/dist/bundler/rolldown.d.ts +2 -2
- package/dist/bundler/rolldown.js +1 -1
- package/dist/bundler/tsdown.cjs +3 -3
- package/dist/bundler/tsdown.d.cts +2 -2
- package/dist/bundler/tsdown.d.ts +2 -2
- package/dist/bundler/tsdown.js +3 -3
- package/dist/bundler/utils.cjs +2 -2
- package/dist/bundler/utils.d.cts +2 -2
- package/dist/bundler/utils.d.ts +2 -2
- package/dist/bundler/utils.js +2 -2
- package/dist/{client-XhkdKJ4d.js → client-CuldIPPY.js} +3 -3
- package/dist/{client-XhkdKJ4d.js.map → client-CuldIPPY.js.map} +1 -1
- package/dist/{client-u8yLSxEI.cjs → client-VbpeaXsy.cjs} +3 -3
- package/dist/{client-u8yLSxEI.cjs.map → client-VbpeaXsy.cjs.map} +1 -1
- package/dist/commander-kit/index.cjs +5 -5
- package/dist/commander-kit/index.d.cts +3 -3
- package/dist/commander-kit/index.d.ts +3 -3
- package/dist/commander-kit/index.js +5 -5
- package/dist/{extra-CxDwtQEy.d.cts → extra-2iX9E4Hj.d.cts} +2 -2
- package/dist/{extra-CVuXMpEw.d.ts → extra-DY59MRMZ.d.ts} +2 -2
- package/dist/{fast-globe-options-BFt__e__.d.cts → fast-globe-options-BLHLcUA_.d.cts} +3 -3
- package/dist/{fast-globe-options-6r2aj6UC.d.ts → fast-globe-options-ClsKhWod.d.ts} +3 -3
- package/dist/{helper-BdjaR8Yv.js → helper-BlSd9P9f.js} +2 -2
- package/dist/{helper-BdjaR8Yv.js.map → helper-BlSd9P9f.js.map} +1 -1
- package/dist/{helper-DorgNsB9.cjs → helper-PkWCboHw.cjs} +2 -2
- package/dist/{helper-DorgNsB9.cjs.map → helper-PkWCboHw.cjs.map} +1 -1
- package/dist/{identity-BJ0QX7AJ.js → identity-BFjidy_R.js} +6 -6
- package/dist/{identity-BJ0QX7AJ.js.map → identity-BFjidy_R.js.map} +1 -1
- package/dist/{identity-CxR9DRMh.cjs → identity-NSVVUm0l.cjs} +6 -6
- package/dist/{identity-CxR9DRMh.cjs.map → identity-NSVVUm0l.cjs.map} +1 -1
- package/dist/{index-B-NeF7PU.d.cts → index-B3VpO-fM.d.cts} +2 -2
- package/dist/{index-Idak1iwg.d.cts → index-BNJNsFwK.d.cts} +2 -2
- package/dist/{index-PXsb85LI.d.ts → index-CNjsgh1e.d.ts} +2 -2
- package/dist/{index-CzxZta4Z.d.ts → index-CQatHoCR.d.ts} +2 -2
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -6
- package/dist/{package-banner-BzheZbxy.js → package-banner-Cgukf7xE.js} +5 -5
- package/dist/{package-banner-BzheZbxy.js.map → package-banner-Cgukf7xE.js.map} +1 -1
- package/dist/{package-banner-6RzEf-mV.cjs → package-banner-yTTlKTH6.cjs} +5 -5
- package/dist/{package-banner-6RzEf-mV.cjs.map → package-banner-yTTlKTH6.cjs.map} +1 -1
- package/dist/{server-B2hBoGDR.cjs → server-Ct02ysTN.cjs} +3 -3
- package/dist/{server-B2hBoGDR.cjs.map → server-Ct02ysTN.cjs.map} +1 -1
- package/dist/{server-CWrDd29Y.js → server-niOC1_n4.js} +3 -3
- package/dist/{server-CWrDd29Y.js.map → server-niOC1_n4.js.map} +1 -1
- package/dist/utils/client.cjs +2 -2
- package/dist/utils/client.d.cts +1 -1
- package/dist/utils/client.d.ts +1 -1
- package/dist/utils/client.js +2 -2
- package/dist/utils/server.cjs +2 -2
- package/dist/utils/server.d.cts +2 -2
- package/dist/utils/server.d.ts +2 -2
- package/dist/utils/server.js +2 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity-CxR9DRMh.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-NSVVUm0l.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.
|
|
5
|
+
* Version: `0.0.7`
|
|
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
|
* ========================================================================
|
|
@@ -667,4 +667,4 @@ type GeneratePackageBannerOptions = {
|
|
|
667
667
|
*/
|
|
668
668
|
declare const generatePackageBanner: (options?: GeneratePackageBannerOptions) => Promise<string>;
|
|
669
669
|
export { generatePackageBanner as n, PackageJson as r, GeneratePackageBannerOptions as t };
|
|
670
|
-
//# sourceMappingURL=index-
|
|
670
|
+
//# sourceMappingURL=index-B3VpO-fM.d.cts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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-
|
|
356
|
+
//# sourceMappingURL=index-BNJNsFwK.d.cts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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
|
* ========================================================================
|
|
@@ -667,4 +667,4 @@ type GeneratePackageBannerOptions = {
|
|
|
667
667
|
*/
|
|
668
668
|
declare const generatePackageBanner: (options?: GeneratePackageBannerOptions) => Promise<string>;
|
|
669
669
|
export { generatePackageBanner as n, PackageJson as r, GeneratePackageBannerOptions as t };
|
|
670
|
-
//# sourceMappingURL=index-
|
|
670
|
+
//# sourceMappingURL=index-CNjsgh1e.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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-
|
|
356
|
+
//# sourceMappingURL=index-CQatHoCR.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.
|
|
5
|
+
* Version: `0.0.7`
|
|
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-
|
|
14
|
-
const require_server = require('./server-
|
|
15
|
-
const require_identity = require('./identity-
|
|
16
|
-
const require_client = require('./client-
|
|
17
|
-
const require_package_banner = require('./package-banner-
|
|
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');
|
|
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);
|
package/dist/index.d.cts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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
|
-
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-
|
|
12
|
-
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-
|
|
13
|
-
import { t as CommandIdentity } from "./index-
|
|
14
|
-
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-
|
|
11
|
+
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-2iX9E4Hj.cjs";
|
|
12
|
+
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-B3VpO-fM.cjs";
|
|
13
|
+
import { t as CommandIdentity } from "./index-BNJNsFwK.cjs";
|
|
14
|
+
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-BLHLcUA_.cjs";
|
|
15
15
|
import * as acorn from "acorn";
|
|
16
16
|
import { ChildProcess, SpawnOptions, StdioOptions } from "node:child_process";
|
|
17
17
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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
|
-
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-
|
|
12
|
-
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-
|
|
13
|
-
import { t as CommandIdentity } from "./index-
|
|
14
|
-
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-
|
|
11
|
+
import { a as OmitStrict, c as PrettifyOptions, r as DefaultPrettifyOptions, s as Prettify } from "./extra-DY59MRMZ.js";
|
|
12
|
+
import { n as generatePackageBanner, r as PackageJson, t as GeneratePackageBannerOptions } from "./index-CNjsgh1e.js";
|
|
13
|
+
import { t as CommandIdentity } from "./index-CQatHoCR.js";
|
|
14
|
+
import { n as PatternOptions, t as PatternConfig } from "./fast-globe-options-ClsKhWod.js";
|
|
15
15
|
import * as acorn from "acorn";
|
|
16
16
|
import { ChildProcess, SpawnOptions, StdioOptions, spawn } from "node:child_process";
|
|
17
17
|
|
package/dist/index.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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
|
-
import { S as toStringSet, _ as isUndefined, a as isError, d as isNumber, g as isString, h as isSet, i as isBoolean, l as isNonEmptyString, m as isRegExp, n as flattenStrings, p as isPlainObject, r as isArray, v as normalizeSpaces, x as toObjectSet, y as safeStableStringify } from "./helper-
|
|
12
|
-
import { a as resolvePatternOptions, i as defaultPatternOptions, n as fsExtra, o as sourceOfPatternOptions, r as ICONS, t as fastGlob } from "./server-
|
|
13
|
-
import { t as CommandIdentity } from "./identity-
|
|
14
|
-
import { a as joinInline, i as formatOptionValue, l as picocolors, n as EOL, o as joinLines, s as joinLinesLoose, u as plural } from "./client-
|
|
15
|
-
import { n as getPackageJson, t as generatePackageBanner } from "./package-banner-
|
|
11
|
+
import { S as toStringSet, _ as isUndefined, a as isError, d as isNumber, g as isString, h as isSet, i as isBoolean, l as isNonEmptyString, m as isRegExp, n as flattenStrings, p as isPlainObject, r as isArray, v as normalizeSpaces, x as toObjectSet, y as safeStableStringify } from "./helper-BlSd9P9f.js";
|
|
12
|
+
import { a as resolvePatternOptions, i as defaultPatternOptions, n as fsExtra, o as sourceOfPatternOptions, r as ICONS, t as fastGlob } from "./server-niOC1_n4.js";
|
|
13
|
+
import { t as CommandIdentity } from "./identity-BFjidy_R.js";
|
|
14
|
+
import { a as joinInline, i as formatOptionValue, l as picocolors, n as EOL, o as joinLines, s as joinLinesLoose, u as plural } from "./client-CuldIPPY.js";
|
|
15
|
+
import { n as getPackageJson, t as generatePackageBanner } from "./package-banner-Cgukf7xE.js";
|
|
16
16
|
import "@rzl-zone/node-only";
|
|
17
17
|
import * as t from "@babel/types";
|
|
18
18
|
import { parse } from "@babel/parser";
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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
|
-
import { l as isNonEmptyString, p as isPlainObject } from "./helper-
|
|
12
|
-
import { n as fsExtra } from "./server-
|
|
13
|
-
import { n as EOL, s as joinLinesLoose } from "./client-
|
|
11
|
+
import { l as isNonEmptyString, p as isPlainObject } from "./helper-BlSd9P9f.js";
|
|
12
|
+
import { n as fsExtra } from "./server-niOC1_n4.js";
|
|
13
|
+
import { n as EOL, s as joinLinesLoose } from "./client-CuldIPPY.js";
|
|
14
14
|
import "@rzl-zone/node-only";
|
|
15
15
|
import path from "node:path";
|
|
16
16
|
const getPackageJson = async (options = {}) => {
|
|
@@ -38,4 +38,4 @@ const generatePackageBanner = async (options = {}) => {
|
|
|
38
38
|
return joinLinesLoose("/*!", "* ========================================================================", `* ${title}`, "* ------------------------------------------------------------------------", `* Version: \`${version}\``, `* Author: \`${author}\``, `* Repository: \`${repository}\``, "* ========================================================================", "*/", withEof ? "" : false);
|
|
39
39
|
};
|
|
40
40
|
export { getPackageJson as n, generatePackageBanner as t };
|
|
41
|
-
//# sourceMappingURL=package-banner-
|
|
41
|
+
//# sourceMappingURL=package-banner-Cgukf7xE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-banner-BzheZbxy.js","names":[],"sources":["../src/core/get/package-json/index.ts","../src/core/generate/package-banner/index.ts"],"sourcesContent":["import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport path from \"node:path\";\n\nimport { isNonEmptyString } from \"@/_internal/utils/helper\";\n\nimport { fsExtra } from \"@/utils/server\";\nimport { EOL } from \"@/utils/client\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link getPackageJson | **`get-package-json`**}.***\n * ----------------------------------------------------------------\n */\nexport type GetPackageJsonOptions = {\n /** ----------------------------------------------------------------\n * * ***Working directory of the target project.***\n * ----------------------------------------------------------------\n *\n * This determines where the lookup for `package.json`\n * will start.\n *\n * - If provided, resolution begins from this directory.\n * - If omitted, defaults to `process.cwd()`.\n *\n * - ***Typical use cases:***\n * - CLI tools executed in a project directory.\n * - Monorepo root resolution.\n * - Custom build pipelines.\n *\n * @default process.cwd()\n *\n * @remarks\n * This should be the directory containing your project's\n * `package.json`, not the directory of this package.\n */\n cwd?: string;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Resolve and read the nearest `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility locates and loads the closest `package.json`\n * by walking up the directory tree starting from a given\n * working directory.\n *\n * - *Key characteristics:*\n * - Works in **Node ESM and CJS**.\n * - Compatible with **tsdown, rolldown, tsup, esbuild, vite, tsx, ts-node, and others**.\n * - Does **not** rely on JSON module imports.\n * - Fully typed via {@link PackageJson | **PackageJson**}.\n *\n * - *This function is intended for:*\n * - Build tools.\n * - Bundler configuration.\n * - CLI utilities.\n * - Monorepo-aware infrastructure code.\n *\n * @param options Optional resolution configuration.\n *\n * @returns The parsed contents of the resolved `package.json`.\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson();\n * console.log(pkg.name, pkg.version);\n * ```\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson({\n * cwd: process.cwd()\n * });\n * ```\n *\n * @throws If no `package.json` can be found.\n * @throws If the located `package.json` is invalid JSON.\n *\n * @remarks\n * - Resolution always starts from `cwd` or `process.cwd()`.\n * - Results are not cached by default.\n * - Designed for infrastructure-level usage, not hot paths.\n */\nexport const getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n const startDir = isNonEmptyString(options.cwd)\n ? path.resolve(options.cwd)\n : process.cwd();\n\n let current = startDir;\n\n while (true) {\n const pkgPath = path.join(current, \"package.json\");\n\n if (fsExtra.existsSync(pkgPath)) {\n try {\n return JSON.parse(fsExtra.readFileSync(pkgPath, \"utf-8\"));\n } catch (err) {\n throw new Error(\n `[@rzl-zone/build-tools] - (get-package-json): Invalid package.json at '${pkgPath}'` +\n EOL +\n `Reason: ${(err as Error).message}`,\n { cause: err }\n );\n }\n }\n\n const parent = path.dirname(current);\n if (parent === current) break;\n\n current = parent;\n }\n\n throw new Error(\n \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json\"\n );\n};\n\n/** @deprecated Use {@link getPackageJson | `getPackageJson`} instead. */\nconst _getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n return await getPackageJson(options);\n // if (options.cwd && options.from) {\n // throw new Error(\"Provide either `cwd` or `from`, not both.\");\n // }\n\n // const cwd = isNonEmptyString(options.cwd) ? options.cwd : process.cwd();\n\n // const baseUrl =\n // options.from && isNil(options.cwd)\n // ? options.from\n // : pathToFileURL(path.resolve(cwd, \"__entry__.js\"));\n\n // const createRequire = await getCreateRequire();\n // const reqPkg = createRequire(baseUrl);\n\n // let current = cwd;\n\n // while (true) {\n // const pkgPath = path.join(current, \"package.json\");\n\n // if (fsExtra.existsSync(pkgPath)) return reqPkg(pkgPath);\n\n // const parent = path.dirname(current);\n // if (parent === current) break;\n // current = parent;\n // }\n\n // throw new Error(\n // \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json !!!\"\n // );\n};\n","import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport { isNonEmptyString, isPlainObject } from \"@/_internal/utils/helper\";\n\nimport { joinLinesLoose } from \"@/utils/helper/formatter\";\nimport { getPackageJson } from \"../../get/package-json\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link generatePackageBanner | **`generate-package-banner`**}.***\n * ----------------------------------------------------------------\n */\nexport type GeneratePackageBannerOptions = {\n /** ----------------------------------------------------------------\n * * ***Display title shown in the banner.***\n * ----------------------------------------------------------------\n *\n * Defaults to the `name` field from `package.json`\n * when available.\n */\n title?: string;\n\n /** ----------------------------------------------------------------\n * * ***Author name displayed in the banner.***\n * ----------------------------------------------------------------\n *\n * When omitted, attempts to resolve from:\n * - `author.name`.\n * - `author` (*string*).\n */\n author?: string;\n\n /** ----------------------------------------------------------------\n * * ***Custom package metadata override.***\n * ----------------------------------------------------------------\n *\n * When provided, this object will be used instead of\n * reading from the filesystem.\n *\n * - Useful for testing or advanced build pipelines.\n */\n packageJson?: PackageJson;\n\n /** ----------------------------------------------------------------\n * * ***Append an end-of-file newline to the banner output.***\n * ----------------------------------------------------------------\n *\n * Controls whether the generated banner is terminated with\n * an end-of-file (EOF) newline character.\n *\n * When enabled, a trailing newline is appended to ensure:\n * - POSIX-compliant text files.\n * - Clean concatenation with subsequent source content.\n * - Consistent formatting during code injection.\n *\n * @default true\n */\n withEof?: boolean;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Generate a standardized top banner from `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility generates a formatted banner comment suitable\n * for insertion at the top of bundled output files.\n *\n * - *Banner features:*\n * - Reads metadata from the nearest `package.json`.\n * - Provides safe fallbacks for missing fields.\n * - Produces a consistent, readable comment block.\n *\n * - *This function is intended for:*\n * - Bundler banners (tsdown, tsup, rollup, esbuild, etc).\n * - Generated build artifacts.\n * - Distributed library outputs.\n *\n * @param {GeneratePackageBannerOptions} [options]\n * Optional banner configuration.\n *\n * @returns {string}\n * A formatted banner comment string.\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner({\n * title: \"Rzl Build Tools\",\n * author: \"Rzl\"\n * });\n * ```\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner();\n * ```\n */\nexport const generatePackageBanner = async (\n options: GeneratePackageBannerOptions = {}\n): Promise<string> => {\n const pkg = options.packageJson ?? (await getPackageJson());\n const withEof = options.withEof ?? true;\n\n const title =\n options.title ??\n (isNonEmptyString(pkg.name) ? pkg.name : \"Unknown Package\");\n\n const version = isNonEmptyString(pkg.version) ? pkg.version : \"Unknown\";\n\n const author =\n options.author ??\n (isNonEmptyString(pkg.author)\n ? pkg.author\n : isPlainObject(pkg.author) && isNonEmptyString(pkg.author.name)\n ? pkg.author.name\n : \"Unknown\");\n\n const repository = isNonEmptyString(pkg.homepage)\n ? pkg.homepage.split(\"#\")[0]\n : isNonEmptyString(pkg.repository)\n ? pkg.repository.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : isPlainObject(pkg.repository) && isNonEmptyString(pkg.repository.url)\n ? pkg.repository.url.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : \"Unknown\";\n\n return joinLinesLoose(\n \"/*!\",\n \"* ========================================================================\",\n `* ${title}`,\n \"* ------------------------------------------------------------------------\",\n `* Version: \\`${version}\\``,\n `* Author: \\`${author}\\``,\n `* Repository: \\`${repository}\\``,\n \"* ========================================================================\",\n \"*/\",\n withEof ? \"\" : false\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAa,iBAAiB,OAC5B,UAAiC,EAAE,KACV;CAKzB,IAAI,UAJa,iBAAiB,QAAQ,IAAI,GAC1C,KAAK,QAAQ,QAAQ,IAAI,GACzB,QAAQ,KAAK;AAIjB,QAAO,MAAM;EACX,MAAM,UAAU,KAAK,KAAK,SAAS,eAAe;AAElD,MAAI,QAAQ,WAAW,QAAQ,CAC7B,KAAI;AACF,UAAO,KAAK,MAAM,QAAQ,aAAa,SAAS,QAAQ,CAAC;WAClD,KAAK;AACZ,SAAM,IAAI,MACR,0EAA0E,QAAQ,KAChF,MACA,WAAY,IAAc,WAC5B,EAAE,OAAO,KAAK,CACf;;EAIL,MAAM,SAAS,KAAK,QAAQ,QAAQ;AACpC,MAAI,WAAW,QAAS;AAExB,YAAU;;AAGZ,OAAM,IAAI,MACR,8EACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrBH,MAAa,wBAAwB,OACnC,UAAwC,EAAE,KACtB;CACpB,MAAM,MAAM,QAAQ,eAAgB,MAAM,gBAAgB;CAC1D,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,QACJ,QAAQ,UACP,iBAAiB,IAAI,KAAK,GAAG,IAAI,OAAO;CAE3C,MAAM,UAAU,iBAAiB,IAAI,QAAQ,GAAG,IAAI,UAAU;CAE9D,MAAM,SACJ,QAAQ,WACP,iBAAiB,IAAI,OAAO,GACzB,IAAI,SACJ,cAAc,IAAI,OAAO,IAAI,iBAAiB,IAAI,OAAO,KAAK,GAC5D,IAAI,OAAO,OACX;CAER,MAAM,aAAa,iBAAiB,IAAI,SAAS,GAC7C,IAAI,SAAS,MAAM,IAAI,CAAC,KACxB,iBAAiB,IAAI,WAAW,GAC9B,IAAI,WAAW,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC1D,cAAc,IAAI,WAAW,IAAI,iBAAiB,IAAI,WAAW,IAAI,GACnE,IAAI,WAAW,IAAI,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC9D;AAER,QAAO,eACL,OACA,8EACA,MAAM,SACN,8EACA,iBAAiB,QAAQ,KACzB,gBAAgB,OAAO,KACvB,oBAAoB,WAAW,KAC/B,8EACA,MACA,UAAU,KAAK,MAChB"}
|
|
1
|
+
{"version":3,"file":"package-banner-Cgukf7xE.js","names":[],"sources":["../src/core/get/package-json/index.ts","../src/core/generate/package-banner/index.ts"],"sourcesContent":["import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport path from \"node:path\";\n\nimport { isNonEmptyString } from \"@/_internal/utils/helper\";\n\nimport { fsExtra } from \"@/utils/server\";\nimport { EOL } from \"@/utils/client\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link getPackageJson | **`get-package-json`**}.***\n * ----------------------------------------------------------------\n */\nexport type GetPackageJsonOptions = {\n /** ----------------------------------------------------------------\n * * ***Working directory of the target project.***\n * ----------------------------------------------------------------\n *\n * This determines where the lookup for `package.json`\n * will start.\n *\n * - If provided, resolution begins from this directory.\n * - If omitted, defaults to `process.cwd()`.\n *\n * - ***Typical use cases:***\n * - CLI tools executed in a project directory.\n * - Monorepo root resolution.\n * - Custom build pipelines.\n *\n * @default process.cwd()\n *\n * @remarks\n * This should be the directory containing your project's\n * `package.json`, not the directory of this package.\n */\n cwd?: string;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Resolve and read the nearest `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility locates and loads the closest `package.json`\n * by walking up the directory tree starting from a given\n * working directory.\n *\n * - *Key characteristics:*\n * - Works in **Node ESM and CJS**.\n * - Compatible with **tsdown, rolldown, tsup, esbuild, vite, tsx, ts-node, and others**.\n * - Does **not** rely on JSON module imports.\n * - Fully typed via {@link PackageJson | **PackageJson**}.\n *\n * - *This function is intended for:*\n * - Build tools.\n * - Bundler configuration.\n * - CLI utilities.\n * - Monorepo-aware infrastructure code.\n *\n * @param options Optional resolution configuration.\n *\n * @returns The parsed contents of the resolved `package.json`.\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson();\n * console.log(pkg.name, pkg.version);\n * ```\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson({\n * cwd: process.cwd()\n * });\n * ```\n *\n * @throws If no `package.json` can be found.\n * @throws If the located `package.json` is invalid JSON.\n *\n * @remarks\n * - Resolution always starts from `cwd` or `process.cwd()`.\n * - Results are not cached by default.\n * - Designed for infrastructure-level usage, not hot paths.\n */\nexport const getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n const startDir = isNonEmptyString(options.cwd)\n ? path.resolve(options.cwd)\n : process.cwd();\n\n let current = startDir;\n\n while (true) {\n const pkgPath = path.join(current, \"package.json\");\n\n if (fsExtra.existsSync(pkgPath)) {\n try {\n return JSON.parse(fsExtra.readFileSync(pkgPath, \"utf-8\"));\n } catch (err) {\n throw new Error(\n `[@rzl-zone/build-tools] - (get-package-json): Invalid package.json at '${pkgPath}'` +\n EOL +\n `Reason: ${(err as Error).message}`,\n { cause: err }\n );\n }\n }\n\n const parent = path.dirname(current);\n if (parent === current) break;\n\n current = parent;\n }\n\n throw new Error(\n \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json\"\n );\n};\n\n/** @deprecated Use {@link getPackageJson | `getPackageJson`} instead. */\nconst _getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n return await getPackageJson(options);\n // if (options.cwd && options.from) {\n // throw new Error(\"Provide either `cwd` or `from`, not both.\");\n // }\n\n // const cwd = isNonEmptyString(options.cwd) ? options.cwd : process.cwd();\n\n // const baseUrl =\n // options.from && isNil(options.cwd)\n // ? options.from\n // : pathToFileURL(path.resolve(cwd, \"__entry__.js\"));\n\n // const createRequire = await getCreateRequire();\n // const reqPkg = createRequire(baseUrl);\n\n // let current = cwd;\n\n // while (true) {\n // const pkgPath = path.join(current, \"package.json\");\n\n // if (fsExtra.existsSync(pkgPath)) return reqPkg(pkgPath);\n\n // const parent = path.dirname(current);\n // if (parent === current) break;\n // current = parent;\n // }\n\n // throw new Error(\n // \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json !!!\"\n // );\n};\n","import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport { isNonEmptyString, isPlainObject } from \"@/_internal/utils/helper\";\n\nimport { joinLinesLoose } from \"@/utils/helper/formatter\";\nimport { getPackageJson } from \"../../get/package-json\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link generatePackageBanner | **`generate-package-banner`**}.***\n * ----------------------------------------------------------------\n */\nexport type GeneratePackageBannerOptions = {\n /** ----------------------------------------------------------------\n * * ***Display title shown in the banner.***\n * ----------------------------------------------------------------\n *\n * Defaults to the `name` field from `package.json`\n * when available.\n */\n title?: string;\n\n /** ----------------------------------------------------------------\n * * ***Author name displayed in the banner.***\n * ----------------------------------------------------------------\n *\n * When omitted, attempts to resolve from:\n * - `author.name`.\n * - `author` (*string*).\n */\n author?: string;\n\n /** ----------------------------------------------------------------\n * * ***Custom package metadata override.***\n * ----------------------------------------------------------------\n *\n * When provided, this object will be used instead of\n * reading from the filesystem.\n *\n * - Useful for testing or advanced build pipelines.\n */\n packageJson?: PackageJson;\n\n /** ----------------------------------------------------------------\n * * ***Append an end-of-file newline to the banner output.***\n * ----------------------------------------------------------------\n *\n * Controls whether the generated banner is terminated with\n * an end-of-file (EOF) newline character.\n *\n * When enabled, a trailing newline is appended to ensure:\n * - POSIX-compliant text files.\n * - Clean concatenation with subsequent source content.\n * - Consistent formatting during code injection.\n *\n * @default true\n */\n withEof?: boolean;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Generate a standardized top banner from `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility generates a formatted banner comment suitable\n * for insertion at the top of bundled output files.\n *\n * - *Banner features:*\n * - Reads metadata from the nearest `package.json`.\n * - Provides safe fallbacks for missing fields.\n * - Produces a consistent, readable comment block.\n *\n * - *This function is intended for:*\n * - Bundler banners (tsdown, tsup, rollup, esbuild, etc).\n * - Generated build artifacts.\n * - Distributed library outputs.\n *\n * @param {GeneratePackageBannerOptions} [options]\n * Optional banner configuration.\n *\n * @returns {string}\n * A formatted banner comment string.\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner({\n * title: \"Rzl Build Tools\",\n * author: \"Rzl\"\n * });\n * ```\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner();\n * ```\n */\nexport const generatePackageBanner = async (\n options: GeneratePackageBannerOptions = {}\n): Promise<string> => {\n const pkg = options.packageJson ?? (await getPackageJson());\n const withEof = options.withEof ?? true;\n\n const title =\n options.title ??\n (isNonEmptyString(pkg.name) ? pkg.name : \"Unknown Package\");\n\n const version = isNonEmptyString(pkg.version) ? pkg.version : \"Unknown\";\n\n const author =\n options.author ??\n (isNonEmptyString(pkg.author)\n ? pkg.author\n : isPlainObject(pkg.author) && isNonEmptyString(pkg.author.name)\n ? pkg.author.name\n : \"Unknown\");\n\n const repository = isNonEmptyString(pkg.homepage)\n ? pkg.homepage.split(\"#\")[0]\n : isNonEmptyString(pkg.repository)\n ? pkg.repository.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : isPlainObject(pkg.repository) && isNonEmptyString(pkg.repository.url)\n ? pkg.repository.url.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : \"Unknown\";\n\n return joinLinesLoose(\n \"/*!\",\n \"* ========================================================================\",\n `* ${title}`,\n \"* ------------------------------------------------------------------------\",\n `* Version: \\`${version}\\``,\n `* Author: \\`${author}\\``,\n `* Repository: \\`${repository}\\``,\n \"* ========================================================================\",\n \"*/\",\n withEof ? \"\" : false\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAa,iBAAiB,OAC5B,UAAiC,EAAE,KACV;CAKzB,IAAI,UAJa,iBAAiB,QAAQ,IAAI,GAC1C,KAAK,QAAQ,QAAQ,IAAI,GACzB,QAAQ,KAAK;AAIjB,QAAO,MAAM;EACX,MAAM,UAAU,KAAK,KAAK,SAAS,eAAe;AAElD,MAAI,QAAQ,WAAW,QAAQ,CAC7B,KAAI;AACF,UAAO,KAAK,MAAM,QAAQ,aAAa,SAAS,QAAQ,CAAC;WAClD,KAAK;AACZ,SAAM,IAAI,MACR,0EAA0E,QAAQ,KAChF,MACA,WAAY,IAAc,WAC5B,EAAE,OAAO,KAAK,CACf;;EAIL,MAAM,SAAS,KAAK,QAAQ,QAAQ;AACpC,MAAI,WAAW,QAAS;AAExB,YAAU;;AAGZ,OAAM,IAAI,MACR,8EACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrBH,MAAa,wBAAwB,OACnC,UAAwC,EAAE,KACtB;CACpB,MAAM,MAAM,QAAQ,eAAgB,MAAM,gBAAgB;CAC1D,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,QACJ,QAAQ,UACP,iBAAiB,IAAI,KAAK,GAAG,IAAI,OAAO;CAE3C,MAAM,UAAU,iBAAiB,IAAI,QAAQ,GAAG,IAAI,UAAU;CAE9D,MAAM,SACJ,QAAQ,WACP,iBAAiB,IAAI,OAAO,GACzB,IAAI,SACJ,cAAc,IAAI,OAAO,IAAI,iBAAiB,IAAI,OAAO,KAAK,GAC5D,IAAI,OAAO,OACX;CAER,MAAM,aAAa,iBAAiB,IAAI,SAAS,GAC7C,IAAI,SAAS,MAAM,IAAI,CAAC,KACxB,iBAAiB,IAAI,WAAW,GAC9B,IAAI,WAAW,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC1D,cAAc,IAAI,WAAW,IAAI,iBAAiB,IAAI,WAAW,IAAI,GACnE,IAAI,WAAW,IAAI,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC9D;AAER,QAAO,eACL,OACA,8EACA,MAAM,SACN,8EACA,iBAAiB,QAAQ,KACzB,gBAAgB,OAAO,KACvB,oBAAoB,WAAW,KAC/B,8EACA,MACA,UAAU,KAAK,MAChB"}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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-
|
|
13
|
-
const require_server = require('./server-
|
|
14
|
-
const require_client = require('./client-
|
|
12
|
+
const require_helper = require('./helper-PkWCboHw.cjs');
|
|
13
|
+
const require_server = require('./server-Ct02ysTN.cjs');
|
|
14
|
+
const require_client = require('./client-VbpeaXsy.cjs');
|
|
15
15
|
require("@rzl-zone/node-only");
|
|
16
16
|
let node_path = require("node:path");
|
|
17
17
|
node_path = require_helper.__toESM(node_path, 1);
|
|
@@ -51,4 +51,4 @@ Object.defineProperty(exports, 'getPackageJson', {
|
|
|
51
51
|
return getPackageJson;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
//# sourceMappingURL=package-banner-
|
|
54
|
+
//# sourceMappingURL=package-banner-yTTlKTH6.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-banner-6RzEf-mV.cjs","names":["isNonEmptyString","path","fsExtra","EOL","isNonEmptyString","isPlainObject","joinLinesLoose"],"sources":["../src/core/get/package-json/index.ts","../src/core/generate/package-banner/index.ts"],"sourcesContent":["import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport path from \"node:path\";\n\nimport { isNonEmptyString } from \"@/_internal/utils/helper\";\n\nimport { fsExtra } from \"@/utils/server\";\nimport { EOL } from \"@/utils/client\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link getPackageJson | **`get-package-json`**}.***\n * ----------------------------------------------------------------\n */\nexport type GetPackageJsonOptions = {\n /** ----------------------------------------------------------------\n * * ***Working directory of the target project.***\n * ----------------------------------------------------------------\n *\n * This determines where the lookup for `package.json`\n * will start.\n *\n * - If provided, resolution begins from this directory.\n * - If omitted, defaults to `process.cwd()`.\n *\n * - ***Typical use cases:***\n * - CLI tools executed in a project directory.\n * - Monorepo root resolution.\n * - Custom build pipelines.\n *\n * @default process.cwd()\n *\n * @remarks\n * This should be the directory containing your project's\n * `package.json`, not the directory of this package.\n */\n cwd?: string;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Resolve and read the nearest `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility locates and loads the closest `package.json`\n * by walking up the directory tree starting from a given\n * working directory.\n *\n * - *Key characteristics:*\n * - Works in **Node ESM and CJS**.\n * - Compatible with **tsdown, rolldown, tsup, esbuild, vite, tsx, ts-node, and others**.\n * - Does **not** rely on JSON module imports.\n * - Fully typed via {@link PackageJson | **PackageJson**}.\n *\n * - *This function is intended for:*\n * - Build tools.\n * - Bundler configuration.\n * - CLI utilities.\n * - Monorepo-aware infrastructure code.\n *\n * @param options Optional resolution configuration.\n *\n * @returns The parsed contents of the resolved `package.json`.\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson();\n * console.log(pkg.name, pkg.version);\n * ```\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson({\n * cwd: process.cwd()\n * });\n * ```\n *\n * @throws If no `package.json` can be found.\n * @throws If the located `package.json` is invalid JSON.\n *\n * @remarks\n * - Resolution always starts from `cwd` or `process.cwd()`.\n * - Results are not cached by default.\n * - Designed for infrastructure-level usage, not hot paths.\n */\nexport const getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n const startDir = isNonEmptyString(options.cwd)\n ? path.resolve(options.cwd)\n : process.cwd();\n\n let current = startDir;\n\n while (true) {\n const pkgPath = path.join(current, \"package.json\");\n\n if (fsExtra.existsSync(pkgPath)) {\n try {\n return JSON.parse(fsExtra.readFileSync(pkgPath, \"utf-8\"));\n } catch (err) {\n throw new Error(\n `[@rzl-zone/build-tools] - (get-package-json): Invalid package.json at '${pkgPath}'` +\n EOL +\n `Reason: ${(err as Error).message}`,\n { cause: err }\n );\n }\n }\n\n const parent = path.dirname(current);\n if (parent === current) break;\n\n current = parent;\n }\n\n throw new Error(\n \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json\"\n );\n};\n\n/** @deprecated Use {@link getPackageJson | `getPackageJson`} instead. */\nconst _getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n return await getPackageJson(options);\n // if (options.cwd && options.from) {\n // throw new Error(\"Provide either `cwd` or `from`, not both.\");\n // }\n\n // const cwd = isNonEmptyString(options.cwd) ? options.cwd : process.cwd();\n\n // const baseUrl =\n // options.from && isNil(options.cwd)\n // ? options.from\n // : pathToFileURL(path.resolve(cwd, \"__entry__.js\"));\n\n // const createRequire = await getCreateRequire();\n // const reqPkg = createRequire(baseUrl);\n\n // let current = cwd;\n\n // while (true) {\n // const pkgPath = path.join(current, \"package.json\");\n\n // if (fsExtra.existsSync(pkgPath)) return reqPkg(pkgPath);\n\n // const parent = path.dirname(current);\n // if (parent === current) break;\n // current = parent;\n // }\n\n // throw new Error(\n // \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json !!!\"\n // );\n};\n","import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport { isNonEmptyString, isPlainObject } from \"@/_internal/utils/helper\";\n\nimport { joinLinesLoose } from \"@/utils/helper/formatter\";\nimport { getPackageJson } from \"../../get/package-json\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link generatePackageBanner | **`generate-package-banner`**}.***\n * ----------------------------------------------------------------\n */\nexport type GeneratePackageBannerOptions = {\n /** ----------------------------------------------------------------\n * * ***Display title shown in the banner.***\n * ----------------------------------------------------------------\n *\n * Defaults to the `name` field from `package.json`\n * when available.\n */\n title?: string;\n\n /** ----------------------------------------------------------------\n * * ***Author name displayed in the banner.***\n * ----------------------------------------------------------------\n *\n * When omitted, attempts to resolve from:\n * - `author.name`.\n * - `author` (*string*).\n */\n author?: string;\n\n /** ----------------------------------------------------------------\n * * ***Custom package metadata override.***\n * ----------------------------------------------------------------\n *\n * When provided, this object will be used instead of\n * reading from the filesystem.\n *\n * - Useful for testing or advanced build pipelines.\n */\n packageJson?: PackageJson;\n\n /** ----------------------------------------------------------------\n * * ***Append an end-of-file newline to the banner output.***\n * ----------------------------------------------------------------\n *\n * Controls whether the generated banner is terminated with\n * an end-of-file (EOF) newline character.\n *\n * When enabled, a trailing newline is appended to ensure:\n * - POSIX-compliant text files.\n * - Clean concatenation with subsequent source content.\n * - Consistent formatting during code injection.\n *\n * @default true\n */\n withEof?: boolean;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Generate a standardized top banner from `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility generates a formatted banner comment suitable\n * for insertion at the top of bundled output files.\n *\n * - *Banner features:*\n * - Reads metadata from the nearest `package.json`.\n * - Provides safe fallbacks for missing fields.\n * - Produces a consistent, readable comment block.\n *\n * - *This function is intended for:*\n * - Bundler banners (tsdown, tsup, rollup, esbuild, etc).\n * - Generated build artifacts.\n * - Distributed library outputs.\n *\n * @param {GeneratePackageBannerOptions} [options]\n * Optional banner configuration.\n *\n * @returns {string}\n * A formatted banner comment string.\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner({\n * title: \"Rzl Build Tools\",\n * author: \"Rzl\"\n * });\n * ```\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner();\n * ```\n */\nexport const generatePackageBanner = async (\n options: GeneratePackageBannerOptions = {}\n): Promise<string> => {\n const pkg = options.packageJson ?? (await getPackageJson());\n const withEof = options.withEof ?? true;\n\n const title =\n options.title ??\n (isNonEmptyString(pkg.name) ? pkg.name : \"Unknown Package\");\n\n const version = isNonEmptyString(pkg.version) ? pkg.version : \"Unknown\";\n\n const author =\n options.author ??\n (isNonEmptyString(pkg.author)\n ? pkg.author\n : isPlainObject(pkg.author) && isNonEmptyString(pkg.author.name)\n ? pkg.author.name\n : \"Unknown\");\n\n const repository = isNonEmptyString(pkg.homepage)\n ? pkg.homepage.split(\"#\")[0]\n : isNonEmptyString(pkg.repository)\n ? pkg.repository.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : isPlainObject(pkg.repository) && isNonEmptyString(pkg.repository.url)\n ? pkg.repository.url.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : \"Unknown\";\n\n return joinLinesLoose(\n \"/*!\",\n \"* ========================================================================\",\n `* ${title}`,\n \"* ------------------------------------------------------------------------\",\n `* Version: \\`${version}\\``,\n `* Author: \\`${author}\\``,\n `* Repository: \\`${repository}\\``,\n \"* ========================================================================\",\n \"*/\",\n withEof ? \"\" : false\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAa,iBAAiB,OAC5B,UAAiC,EAAE,KACV;CAKzB,IAAI,UAJaA,gCAAiB,QAAQ,IAAI,GAC1CC,kBAAK,QAAQ,QAAQ,IAAI,GACzB,QAAQ,KAAK;AAIjB,QAAO,MAAM;EACX,MAAM,UAAUA,kBAAK,KAAK,SAAS,eAAe;AAElD,MAAIC,uBAAQ,WAAW,QAAQ,CAC7B,KAAI;AACF,UAAO,KAAK,MAAMA,uBAAQ,aAAa,SAAS,QAAQ,CAAC;WAClD,KAAK;AACZ,SAAM,IAAI,MACR,0EAA0E,QAAQ,KAChFC,qBACA,WAAY,IAAc,WAC5B,EAAE,OAAO,KAAK,CACf;;EAIL,MAAM,SAASF,kBAAK,QAAQ,QAAQ;AACpC,MAAI,WAAW,QAAS;AAExB,YAAU;;AAGZ,OAAM,IAAI,MACR,8EACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrBH,MAAa,wBAAwB,OACnC,UAAwC,EAAE,KACtB;CACpB,MAAM,MAAM,QAAQ,eAAgB,MAAM,gBAAgB;CAC1D,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,QACJ,QAAQ,UACPG,gCAAiB,IAAI,KAAK,GAAG,IAAI,OAAO;CAE3C,MAAM,UAAUA,gCAAiB,IAAI,QAAQ,GAAG,IAAI,UAAU;CAE9D,MAAM,SACJ,QAAQ,WACPA,gCAAiB,IAAI,OAAO,GACzB,IAAI,SACJC,6BAAc,IAAI,OAAO,IAAID,gCAAiB,IAAI,OAAO,KAAK,GAC5D,IAAI,OAAO,OACX;CAER,MAAM,aAAaA,gCAAiB,IAAI,SAAS,GAC7C,IAAI,SAAS,MAAM,IAAI,CAAC,KACxBA,gCAAiB,IAAI,WAAW,GAC9B,IAAI,WAAW,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC1DC,6BAAc,IAAI,WAAW,IAAID,gCAAiB,IAAI,WAAW,IAAI,GACnE,IAAI,WAAW,IAAI,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC9D;AAER,QAAOE,8BACL,OACA,8EACA,MAAM,SACN,8EACA,iBAAiB,QAAQ,KACzB,gBAAgB,OAAO,KACvB,oBAAoB,WAAW,KAC/B,8EACA,MACA,UAAU,KAAK,MAChB"}
|
|
1
|
+
{"version":3,"file":"package-banner-yTTlKTH6.cjs","names":["isNonEmptyString","path","fsExtra","EOL","isNonEmptyString","isPlainObject","joinLinesLoose"],"sources":["../src/core/get/package-json/index.ts","../src/core/generate/package-banner/index.ts"],"sourcesContent":["import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport path from \"node:path\";\n\nimport { isNonEmptyString } from \"@/_internal/utils/helper\";\n\nimport { fsExtra } from \"@/utils/server\";\nimport { EOL } from \"@/utils/client\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link getPackageJson | **`get-package-json`**}.***\n * ----------------------------------------------------------------\n */\nexport type GetPackageJsonOptions = {\n /** ----------------------------------------------------------------\n * * ***Working directory of the target project.***\n * ----------------------------------------------------------------\n *\n * This determines where the lookup for `package.json`\n * will start.\n *\n * - If provided, resolution begins from this directory.\n * - If omitted, defaults to `process.cwd()`.\n *\n * - ***Typical use cases:***\n * - CLI tools executed in a project directory.\n * - Monorepo root resolution.\n * - Custom build pipelines.\n *\n * @default process.cwd()\n *\n * @remarks\n * This should be the directory containing your project's\n * `package.json`, not the directory of this package.\n */\n cwd?: string;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Resolve and read the nearest `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility locates and loads the closest `package.json`\n * by walking up the directory tree starting from a given\n * working directory.\n *\n * - *Key characteristics:*\n * - Works in **Node ESM and CJS**.\n * - Compatible with **tsdown, rolldown, tsup, esbuild, vite, tsx, ts-node, and others**.\n * - Does **not** rely on JSON module imports.\n * - Fully typed via {@link PackageJson | **PackageJson**}.\n *\n * - *This function is intended for:*\n * - Build tools.\n * - Bundler configuration.\n * - CLI utilities.\n * - Monorepo-aware infrastructure code.\n *\n * @param options Optional resolution configuration.\n *\n * @returns The parsed contents of the resolved `package.json`.\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson();\n * console.log(pkg.name, pkg.version);\n * ```\n *\n * @example\n * ```ts\n * const pkg = await getPackageJson({\n * cwd: process.cwd()\n * });\n * ```\n *\n * @throws If no `package.json` can be found.\n * @throws If the located `package.json` is invalid JSON.\n *\n * @remarks\n * - Resolution always starts from `cwd` or `process.cwd()`.\n * - Results are not cached by default.\n * - Designed for infrastructure-level usage, not hot paths.\n */\nexport const getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n const startDir = isNonEmptyString(options.cwd)\n ? path.resolve(options.cwd)\n : process.cwd();\n\n let current = startDir;\n\n while (true) {\n const pkgPath = path.join(current, \"package.json\");\n\n if (fsExtra.existsSync(pkgPath)) {\n try {\n return JSON.parse(fsExtra.readFileSync(pkgPath, \"utf-8\"));\n } catch (err) {\n throw new Error(\n `[@rzl-zone/build-tools] - (get-package-json): Invalid package.json at '${pkgPath}'` +\n EOL +\n `Reason: ${(err as Error).message}`,\n { cause: err }\n );\n }\n }\n\n const parent = path.dirname(current);\n if (parent === current) break;\n\n current = parent;\n }\n\n throw new Error(\n \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json\"\n );\n};\n\n/** @deprecated Use {@link getPackageJson | `getPackageJson`} instead. */\nconst _getPackageJson = async (\n options: GetPackageJsonOptions = {}\n): Promise<PackageJson> => {\n return await getPackageJson(options);\n // if (options.cwd && options.from) {\n // throw new Error(\"Provide either `cwd` or `from`, not both.\");\n // }\n\n // const cwd = isNonEmptyString(options.cwd) ? options.cwd : process.cwd();\n\n // const baseUrl =\n // options.from && isNil(options.cwd)\n // ? options.from\n // : pathToFileURL(path.resolve(cwd, \"__entry__.js\"));\n\n // const createRequire = await getCreateRequire();\n // const reqPkg = createRequire(baseUrl);\n\n // let current = cwd;\n\n // while (true) {\n // const pkgPath = path.join(current, \"package.json\");\n\n // if (fsExtra.existsSync(pkgPath)) return reqPkg(pkgPath);\n\n // const parent = path.dirname(current);\n // if (parent === current) break;\n // current = parent;\n // }\n\n // throw new Error(\n // \"[@rzl-zone/build-tools] - (get-package-json): Unable to locate package.json !!!\"\n // );\n};\n","import \"@rzl-zone/node-only\";\n\nimport type { PackageJson } from \"type-fest\";\n\nimport { isNonEmptyString, isPlainObject } from \"@/_internal/utils/helper\";\n\nimport { joinLinesLoose } from \"@/utils/helper/formatter\";\nimport { getPackageJson } from \"../../get/package-json\";\n\n//? Types ----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Configuration options for {@link generatePackageBanner | **`generate-package-banner`**}.***\n * ----------------------------------------------------------------\n */\nexport type GeneratePackageBannerOptions = {\n /** ----------------------------------------------------------------\n * * ***Display title shown in the banner.***\n * ----------------------------------------------------------------\n *\n * Defaults to the `name` field from `package.json`\n * when available.\n */\n title?: string;\n\n /** ----------------------------------------------------------------\n * * ***Author name displayed in the banner.***\n * ----------------------------------------------------------------\n *\n * When omitted, attempts to resolve from:\n * - `author.name`.\n * - `author` (*string*).\n */\n author?: string;\n\n /** ----------------------------------------------------------------\n * * ***Custom package metadata override.***\n * ----------------------------------------------------------------\n *\n * When provided, this object will be used instead of\n * reading from the filesystem.\n *\n * - Useful for testing or advanced build pipelines.\n */\n packageJson?: PackageJson;\n\n /** ----------------------------------------------------------------\n * * ***Append an end-of-file newline to the banner output.***\n * ----------------------------------------------------------------\n *\n * Controls whether the generated banner is terminated with\n * an end-of-file (EOF) newline character.\n *\n * When enabled, a trailing newline is appended to ensure:\n * - POSIX-compliant text files.\n * - Clean concatenation with subsequent source content.\n * - Consistent formatting during code injection.\n *\n * @default true\n */\n withEof?: boolean;\n};\n\n//? Main -----------------------------------------------------------------\n/** ----------------------------------------------------------------\n * * ***Generate a standardized top banner from `package.json`.***\n * ----------------------------------------------------------------\n *\n * This utility generates a formatted banner comment suitable\n * for insertion at the top of bundled output files.\n *\n * - *Banner features:*\n * - Reads metadata from the nearest `package.json`.\n * - Provides safe fallbacks for missing fields.\n * - Produces a consistent, readable comment block.\n *\n * - *This function is intended for:*\n * - Bundler banners (tsdown, tsup, rollup, esbuild, etc).\n * - Generated build artifacts.\n * - Distributed library outputs.\n *\n * @param {GeneratePackageBannerOptions} [options]\n * Optional banner configuration.\n *\n * @returns {string}\n * A formatted banner comment string.\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner({\n * title: \"Rzl Build Tools\",\n * author: \"Rzl\"\n * });\n * ```\n *\n * @example\n * ```ts\n * const banner = await generatePackageBanner();\n * ```\n */\nexport const generatePackageBanner = async (\n options: GeneratePackageBannerOptions = {}\n): Promise<string> => {\n const pkg = options.packageJson ?? (await getPackageJson());\n const withEof = options.withEof ?? true;\n\n const title =\n options.title ??\n (isNonEmptyString(pkg.name) ? pkg.name : \"Unknown Package\");\n\n const version = isNonEmptyString(pkg.version) ? pkg.version : \"Unknown\";\n\n const author =\n options.author ??\n (isNonEmptyString(pkg.author)\n ? pkg.author\n : isPlainObject(pkg.author) && isNonEmptyString(pkg.author.name)\n ? pkg.author.name\n : \"Unknown\");\n\n const repository = isNonEmptyString(pkg.homepage)\n ? pkg.homepage.split(\"#\")[0]\n : isNonEmptyString(pkg.repository)\n ? pkg.repository.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : isPlainObject(pkg.repository) && isNonEmptyString(pkg.repository.url)\n ? pkg.repository.url.replace(/^git\\+/, \"\").replace(/\\.git$/, \"\")\n : \"Unknown\";\n\n return joinLinesLoose(\n \"/*!\",\n \"* ========================================================================\",\n `* ${title}`,\n \"* ------------------------------------------------------------------------\",\n `* Version: \\`${version}\\``,\n `* Author: \\`${author}\\``,\n `* Repository: \\`${repository}\\``,\n \"* ========================================================================\",\n \"*/\",\n withEof ? \"\" : false\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuFA,MAAa,iBAAiB,OAC5B,UAAiC,EAAE,KACV;CAKzB,IAAI,UAJaA,gCAAiB,QAAQ,IAAI,GAC1CC,kBAAK,QAAQ,QAAQ,IAAI,GACzB,QAAQ,KAAK;AAIjB,QAAO,MAAM;EACX,MAAM,UAAUA,kBAAK,KAAK,SAAS,eAAe;AAElD,MAAIC,uBAAQ,WAAW,QAAQ,CAC7B,KAAI;AACF,UAAO,KAAK,MAAMA,uBAAQ,aAAa,SAAS,QAAQ,CAAC;WAClD,KAAK;AACZ,SAAM,IAAI,MACR,0EAA0E,QAAQ,KAChFC,qBACA,WAAY,IAAc,WAC5B,EAAE,OAAO,KAAK,CACf;;EAIL,MAAM,SAASF,kBAAK,QAAQ,QAAQ;AACpC,MAAI,WAAW,QAAS;AAExB,YAAU;;AAGZ,OAAM,IAAI,MACR,8EACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrBH,MAAa,wBAAwB,OACnC,UAAwC,EAAE,KACtB;CACpB,MAAM,MAAM,QAAQ,eAAgB,MAAM,gBAAgB;CAC1D,MAAM,UAAU,QAAQ,WAAW;CAEnC,MAAM,QACJ,QAAQ,UACPG,gCAAiB,IAAI,KAAK,GAAG,IAAI,OAAO;CAE3C,MAAM,UAAUA,gCAAiB,IAAI,QAAQ,GAAG,IAAI,UAAU;CAE9D,MAAM,SACJ,QAAQ,WACPA,gCAAiB,IAAI,OAAO,GACzB,IAAI,SACJC,6BAAc,IAAI,OAAO,IAAID,gCAAiB,IAAI,OAAO,KAAK,GAC5D,IAAI,OAAO,OACX;CAER,MAAM,aAAaA,gCAAiB,IAAI,SAAS,GAC7C,IAAI,SAAS,MAAM,IAAI,CAAC,KACxBA,gCAAiB,IAAI,WAAW,GAC9B,IAAI,WAAW,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC1DC,6BAAc,IAAI,WAAW,IAAID,gCAAiB,IAAI,WAAW,IAAI,GACnE,IAAI,WAAW,IAAI,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG,GAC9D;AAER,QAAOE,8BACL,OACA,8EACA,MAAM,SACN,8EACA,iBAAiB,QAAQ,KACzB,gBAAgB,OAAO,KACvB,oBAAoB,WAAW,KAC/B,8EACA,MACA,UAAU,KAAK,MAChB"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* ========================================================================
|
|
3
3
|
* @rzl-zone/build-tools
|
|
4
4
|
* ------------------------------------------------------------------------
|
|
5
|
-
* Version: `0.0.
|
|
5
|
+
* Version: `0.0.7`
|
|
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-
|
|
12
|
+
const require_helper = require('./helper-PkWCboHw.cjs');
|
|
13
13
|
require("@rzl-zone/node-only");
|
|
14
14
|
let node_os = require("node:os");
|
|
15
15
|
node_os = require_helper.__toESM(node_os, 1);
|
|
@@ -178,4 +178,4 @@ Object.defineProperty(exports, 'sourceOfPatternOptions', {
|
|
|
178
178
|
return sourceOfPatternOptions;
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
|
-
//# sourceMappingURL=server-
|
|
181
|
+
//# sourceMappingURL=server-Ct02ysTN.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-B2hBoGDR.cjs","names":["os","isPlainObject","safeStableStringify","_fsExtra","_fastGlob"],"sources":["../src/_internal/libs/fast-globe-options.ts","../src/utils/helper/icons.ts","../src/utils/server.ts"],"sourcesContent":["import \"@rzl-zone/node-only\";\n\nimport type { OmitStrict, Prettify } from \"../types/extra\";\n\nimport os from \"node:os\";\nimport * as fg from \"fast-glob\";\n\nimport {\n isPlainObject,\n safeStableStringify,\n type SafeStableStringifyOptions\n} from \"@/_internal/utils/helper\";\n\ntype IfTrueGeneric<T extends boolean, K> = T extends true ? K : never;\n\n/** ----------------------------------------------------------------\n * * ***Supported pattern matching options.***\n * ----------------------------------------------------------------\n * Defines the subset of {@link fg | `fast-glob`} options exposed by\n * this module for pattern-based file resolution.\n *\n * This type intentionally omits several low-level or environment-\n * controlled fields to ensure predictable and safe behavior.\n *\n * ----------------------------------------------------------------\n *\n * *Excluded options (managed internally):*\n *\n * - `fs`\n * - `cwd`\n * - `stats`\n * - `deep`\n * - `extglob`\n * - `suppressErrors`\n * - `braceExpansion`\n *\n * These fields are controlled by the runtime environment and should\n * not be overridden by consumers.\n *\n * ----------------------------------------------------------------\n * @template FilesOnly\n * When `true`, directory filtering options (`onlyFiles`, `onlyDirectories`)\n * are removed from the public API surface, preventing consumers from\n * modifying directory matching behavior.\n *\n * @template ForceUnique\n * When `true`, the `unique` option is removed from the public API to enforce internal uniqueness handling.\n *\n * This allows higher-level utilities to guarantee that matched results\n * are always deduplicated.\n *\n * ----------------------------------------------------------------\n *\n * This type serves as the public configuration contract used when\n * resolving glob patterns.\n */\nexport type PatternOptions<\n FilesOnly extends boolean = false,\n ForceUnique extends boolean = false\n> = OmitStrict<\n fg.Options,\n | \"fs\"\n | \"cwd\"\n | \"stats\"\n | \"deep\"\n | \"extglob\"\n | \"suppressErrors\"\n | \"braceExpansion\"\n | \"dot\"\n | IfTrueGeneric<FilesOnly, \"onlyFiles\" | \"onlyDirectories\">\n | IfTrueGeneric<ForceUnique, \"unique\">,\n { skipPrettify: true }\n> & {\n /** Allow patterns to match entries that begin with a period (`.`).\n *\n * @default true\n */\n dot?: boolean;\n};\n\n/** ----------------------------------------------------------------\n * * ***Pattern configuration wrapper.***\n * ----------------------------------------------------------------\n *\n * Provides an optional container for {@link PatternOptions | `PatternOptions`}.\n *\n * This wrapper allows pattern matching configuration to be composed\n * within higher-level configuration objects without flattening\n * the option namespace.\n *\n * ----------------------------------------------------------------\n *\n * @template FilesOnly\n * When `true`, directory-related options (`onlyFiles`, `onlyDirectories`)\n * are removed from the public configuration to enforce file-only matching.\n *\n * @template ForceUnique\n * When `true`, the `unique` option is removed from the underlying\n * {@link PatternOptions | `PatternOptions`} to guarantee deduplicated results.\n *\n * ----------------------------------------------------------------\n *\n * @example\n * ```ts\n * const config: PatternConfig = {\n * patternOptions: {\n * dot: true\n * }\n * };\n * ```\n */\nexport type PatternConfig<\n FilesOnly extends boolean = false,\n ForceUnique extends boolean = false\n> = Prettify<{\n /** ----------------------------------------------------------------\n * * ***Pattern matching options.***\n * ----------------------------------------------------------------\n *\n * Optional configuration for controlling file pattern resolution.\n *\n * When provided, these options are sanitized and merged with\n * the internal default configuration before being passed to\n * {@link fg | `fast-glob`}.\n *\n * @see {@link PatternOptions | `PatternOptions`} for supported fields.\n */\n patternOptions?: PatternOptions<FilesOnly, ForceUnique>;\n}>;\n\n/** ----------------------------------------------------------------\n * * ***Default pattern matching configuration.***\n * ----------------------------------------------------------------\n *\n * Represents the canonical baseline configuration used when\n * resolving pattern options.\n *\n * These values are applied whenever a user does not explicitly\n * provide overrides.\n *\n * This object also acts as the runtime source of truth for\n * allowed pattern option keys.\n */\nexport const defaultPatternOptions: PatternOptions = {\n absolute: false,\n baseNameMatch: false,\n caseSensitiveMatch: true,\n concurrency: os.cpus().length,\n dot: true,\n followSymbolicLinks: true,\n globstar: true,\n ignore: [],\n markDirectories: false,\n objectMode: false,\n onlyDirectories: false,\n onlyFiles: true,\n unique: true,\n throwErrorOnBrokenSymbolicLink: false\n};\n\n/** ----------------------------------------------------------------\n * * ***Determines whether a pattern option key is allowed.***\n * ----------------------------------------------------------------\n *\n * Evaluates whether a given {@link PatternOptions | `PatternOptions`}\n * key is permitted under the provided runtime policy.\n *\n * This function enforces restrictions such as:\n *\n * - Disallowing directory-related options when `filesOnly` is enabled.\n * - Preventing external control over the `unique` option when\n * `forceUnique` is enabled.\n *\n * ----------------------------------------------------------------\n *\n * @param key\n * A candidate {@link PatternOptions | `PatternOptions`} property key.\n *\n * @param policy\n * Optional runtime policy controlling which keys are allowed.\n *\n * @returns\n * `true` if the key is permitted under the current policy,\n * otherwise `false`.\n *\n * @internal\n */\nfunction isKeyAllowed(\n key: keyof PatternOptions,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): boolean {\n if (!policy) return true;\n\n if (policy.filesOnly && (key === \"onlyFiles\" || key === \"onlyDirectories\"))\n return false;\n\n if (policy.forceUnique && key === \"unique\") return false;\n\n return true;\n}\n\n/** ----------------------------------------------------------------\n * * ***Runtime whitelist of allowed pattern option keys.***\n * ----------------------------------------------------------------\n *\n * Derived directly from {@link defaultPatternOptions | `defaultPatternOptions`}.\n *\n * This ensures strict synchronization between:\n *\n * - The static {@link PatternOptions | `PatternOptions`} type.\n * - Runtime validation logic used during option sanitization.\n *\n * By deriving the key list from the default configuration,\n * this module avoids manual duplication of allowed option names.\n *\n * ----------------------------------------------------------------\n *\n * This whitelist is used internally to:\n *\n * - Remove unknown properties from user-provided configuration.\n * - Guarantee that only supported options are passed to\n * {@link fg | `fast-glob`}.\n *\n * ----------------------------------------------------------------\n *\n * @internal\n */\nconst PATTERN_OPTION_KEYS = new Set<keyof PatternOptions>(\n Object.keys(defaultPatternOptions) as (keyof PatternOptions)[]\n);\n\n/** ----------------------------------------------------------------\n * * ***Assigns a validated pattern option property.***\n * ----------------------------------------------------------------\n *\n * Performs a type-safe assignment from a source object into a\n * partial {@link PatternOptions | `PatternOptions`} result object.\n *\n * A generic constraint is used to preserve proper indexed access\n * typing and avoid union assignment limitations in TypeScript.\n *\n * This helper assumes that:\n *\n * - The provided `key` has already been validated against\n * {@link PATTERN_OPTION_KEYS | `PATTERN_OPTION_KEYS`}.\n * - The property exists on the `source` object.\n *\n * ----------------------------------------------------------------\n *\n * @template K\n * A valid key of {@link PatternOptions | `PatternOptions`}.\n *\n * @param key\n * The validated pattern option key to assign.\n *\n * @param source\n * The original input object containing the property value.\n *\n * @param target\n * The partial result object receiving the assigned value.\n *\n * @internal\n */\nfunction assignIfAllowed<K extends keyof PatternOptions>(\n key: K,\n source: Record<string, unknown>,\n target: Partial<PatternOptions>\n) {\n target[key] = source[key] as PatternOptions[K];\n}\n\n/** ----------------------------------------------------------------\n * * ***Runtime policy controlling pattern option exposure.***\n * ----------------------------------------------------------------\n *\n * Defines runtime constraints that restrict which fields from\n * {@link PatternOptions | `PatternOptions`} are allowed to appear\n * in the final resolved configuration.\n *\n * This policy is primarily used by higher-level utilities that\n * enforce stricter behavior than the raw {@link fg | `fast-glob`} API.\n *\n * ----------------------------------------------------------------\n *\n * *Supported policies:*\n *\n * - `filesOnly`\n * Prevents directory-related configuration from being externally\n * controlled.\n *\n * - `forceUnique`\n * Ensures that uniqueness behavior is handled internally and\n * cannot be overridden by user configuration.\n *\n * ----------------------------------------------------------------\n *\n * These policies influence both:\n *\n * - Runtime sanitization of user-provided pattern options.\n * - Final resolution of merged configuration values.\n *\n * ----------------------------------------------------------------\n *\n * @template FilesOnly\n * Indicates whether directory-related options should be excluded.\n *\n * @template ForceUnique\n * Indicates whether the `unique` option should be excluded.\n */\nexport type PatternRuntimePolicy<\n FilesOnly extends boolean = boolean,\n ForceUnique extends boolean = boolean\n> = {\n /** ----------------------------------------------------------------\n * * ***Restricts directory-related pattern options.***\n * ----------------------------------------------------------------\n *\n * When enabled, directory filtering options are excluded from the\n * final configuration produced by the pattern resolution process.\n *\n * This prevents external configuration from modifying whether\n * directories or files are matched by the underlying\n * {@link fg | `fast-glob`} operation.\n *\n * ----------------------------------------------------------------\n *\n * *Affected options:*\n *\n * - `onlyFiles`\n * - `onlyDirectories`\n *\n * ----------------------------------------------------------------\n *\n * When `true`, these options are ignored during sanitization and\n * removed from the final resolved configuration.\n *\n * ----------------------------------------------------------------\n * @default false\n */\n filesOnly?: FilesOnly;\n\n /** ----------------------------------------------------------------\n * * ***Enforces internal uniqueness behavior.***\n * ----------------------------------------------------------------\n *\n * When enabled, the `unique` option is excluded from user-provided\n * configuration and controlled internally by the runtime.\n *\n * This ensures that result deduplication behavior cannot be\n * overridden by external configuration.\n *\n * ----------------------------------------------------------------\n *\n * *Affected option:*\n *\n * - `unique`\n *\n * ----------------------------------------------------------------\n *\n * When `true`, this option is ignored during sanitization and\n * removed from the final resolved configuration.\n *\n * ----------------------------------------------------------------\n * @default false\n */\n forceUnique?: ForceUnique;\n};\n\n/** ----------------------------------------------------------------\n * * ***Sanitizes pattern options by removing unknown keys.***\n * ----------------------------------------------------------------\n *\n * Ensures that the provided object only contains keys that exist in\n * {@link defaultPatternOptions | `defaultPatternOptions`}, any unknown keys will be removed.\n *\n * This function is intended for API boundary validation to prevent\n * unsafe or unexpected configuration injection.\n *\n * - *Behavior:*\n * - Ignores non-object values (returns empty object).\n * - Removes keys not present in {@link defaultPatternOptions | `defaultPatternOptions`}.\n * - Does NOT mutate the original object.\n *\n * ----------------------------------------------------------------\n *\n * @param input\n * The value to sanitize.\n *\n * @param policy\n * Optional runtime policy restricting which pattern options\n * are allowed during sanitization.\n *\n * @returns\n * A new object containing only allowed pattern option keys.\n *\n * @example\n * ```ts\n * const userOptions = {\n * absolute: true,\n * dot: true,\n * fakeKey: 123\n * };\n *\n * const clean = sanitizePatternOptions(userOptions);\n *\n * // Result:\n * // {\n * // absolute: true,\n * // dot: true\n * // }\n * ```\n */\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): Partial<PatternOptions<false, false>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, false>\n): Partial<PatternOptions<true, false>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, true>\n): Partial<PatternOptions<false, true>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, true>\n): Partial<PatternOptions<true, true>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): Partial<PatternOptions<false, false>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): Partial<PatternOptions>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): Partial<PatternOptions> {\n if (!isPlainObject(input)) return {};\n\n const source = input as Record<string, unknown>;\n const result: Partial<PatternOptions> = {};\n\n for (const key of Object.keys(source) as (keyof PatternOptions)[]) {\n if (PATTERN_OPTION_KEYS.has(key) && isKeyAllowed(key, policy)) {\n assignIfAllowed(key, source, result);\n }\n }\n\n return result;\n}\n\n/** ----------------------------------------------------------------\n * * ***Resolves pattern options with default values.***\n * ----------------------------------------------------------------\n *\n * Applies {@link sanitizePatternOptions | `sanitizePatternOptions`} to the provided input and merges\n * the result with `defaultPatternOptions`.\n *\n * - Unknown keys are removed.\n * - Missing keys fall back to defaults.\n *\n * Guarantees a fully-formed {@link PatternOptions | `PatternOptions`} object safe for direct\n * usage with `fast-glob`.\n *\n * ----------------------------------------------------------------\n *\n * @param input\n * Optional user-provided pattern options.\n *\n * @param policy\n * Optional runtime policy restricting which configuration\n * fields are allowed in the final resolved options.\n *\n * @returns\n * A complete and validated\n * {@link PatternOptions | `PatternOptions`} object ready for\n * direct usage with {@link fg | `fast-glob`}.\n *\n * @example\n * ```ts\n * const options = resolvePatternOptions({\n * dot: true,\n * fakeKey: 123\n * });\n *\n * // Result:\n * // {\n * // absolute: false,\n * // baseNameMatch: false,\n * // ...\n * // dot: true,\n * // ...\n * // }\n *\n * const matched = await fastGlobe(patterns, options);\n * ```\n */\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): PatternOptions<false, false>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, false>\n): PatternOptions<true, false>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, true>\n): PatternOptions<false, true>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, true>\n): PatternOptions<true, true>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): PatternOptions<false, false>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): PatternOptions {\n const clean = sanitizePatternOptions(input, policy);\n\n const options: PatternOptions = {\n ...defaultPatternOptions,\n ...clean\n };\n\n if (policy?.filesOnly) {\n delete options.onlyFiles;\n delete options.onlyDirectories;\n }\n\n if (policy?.forceUnique) {\n delete options.unique;\n }\n\n return options;\n}\n\n/** ----------------------------------------------------------------\n * * ***Stable structural equality detector.***\n * ----------------------------------------------------------------\n *\n * Determines whether two values are structurally identical using\n * deterministic serialization via `safeStableStringify`.\n *\n * - *This comparison:*\n * - Preserves `undefined` values.\n * - Sorts object keys.\n * - Sorts arrays (optional structural normalization).\n *\n * - *Ensures stable equality checks for configuration objects where:*\n * - Property order may differ.\n * - Object references are not identical.\n * - Deep comparison is required.\n *\n * ----------------------------------------------------------------\n *\n * @template T - Value type being compared.\n *\n * @param value - The current runtime value.\n * @param defaultValue - The default reference value.\n *\n * @returns\n * - `\"default\"` ➔ If values are structurally identical.\n * - `\"overridden\"` ➔ If values differ.\n *\n * @example\n * ```ts\n * const source = sourceOfPatternOptions(\n * cleanPatternOptions,\n * defaultPatternOptions\n * );\n *\n * // ➔ \"default\" | \"overridden\"\n * ```\n *\n * @internal\n */\nexport function sourceOfPatternOptions<T>(\n value: T,\n defaultValue: T\n): \"default\" | \"overridden\" {\n const stableStringifyOptions = {\n keepUndefined: true,\n sortArray: true,\n sortKeys: true\n } satisfies SafeStableStringifyOptions;\n\n const a = safeStableStringify(value, stableStringifyOptions);\n\n const b = safeStableStringify(defaultValue, stableStringifyOptions);\n\n return a === b ? \"default\" : \"overridden\";\n}\n","import \"@rzl-zone/node-only\";\n\nimport \"dotenv/config\";\n\n// eslint-disable-next-line turbo/no-undeclared-env-vars\nconst USE_EMOJI = process.env.FORCE_EMOJI === \"1\";\n\ntype Icons = {\n readonly [K in keyof typeof emojiIcons]: string;\n};\n\nconst emojiIcons = {\n /* flow */\n start: \"🕐\",\n arrowRight: \"▶️\",\n arrowRightMini: \"›\",\n\n /* list */\n bulletBold: \"●\",\n bullet: \"•\",\n whiteCircle: \"○\",\n whiteBullet: \"◦\",\n smallSquare: \"▪\",\n\n /* status */\n success: \"✅\",\n warn: \"⚠️\",\n error: \"❌\",\n\n /* config */\n config: \"⚙️\",\n settings: \"🛠️\",\n\n /* files & fs */\n file: \"📄\",\n files: \"📁\",\n folder: \"📂\",\n path: \"🧭\",\n\n /* actions */\n add: \"➕\",\n remove: \"➖\",\n update: \"♻️\",\n copy: \"📋\",\n move: \"📦\",\n clean: \"🧹\",\n\n /* build / process */\n build: \"🏗️\",\n generate: \"🧩\",\n compile: \"⚡\",\n watch: \"👀\",\n\n /* info / misc */\n info: \"ℹ️\",\n debug: \"🐛\",\n question: \"❓\",\n separator: \"━\"\n} as const;\n\nconst asciiIcons = {\n /* flow */\n start: \"▶\",\n arrowRight: \"▶\",\n arrowRightMini: \"›\",\n\n /* list */\n bulletBold: \"●\",\n bullet: \"•\",\n whiteCircle: \"○\",\n whiteBullet: \"◦\",\n smallSquare: \"▪\",\n\n /* status */\n success: \"✅\",\n warn: \"⚠️ \",\n error: \"❌\",\n\n /* config */\n config: \"#\",\n settings: \"@\",\n\n /* files & fs */\n file: \"F\",\n files: \"DIR\",\n folder: \"DIR\",\n path: \"~\",\n\n /* actions */\n add: \"+\",\n remove: \"-\",\n update: \"~\",\n copy: \"=\",\n move: \">\",\n clean: \"x\",\n\n /* build / process */\n build: \"#\",\n generate: \"*\",\n compile: \">\",\n watch: \"o\",\n\n /* info / misc */\n info: \"i\",\n debug: \"d\",\n question: \"?\",\n separator: \"-\"\n} as const satisfies Icons;\n\n/** ----------------------------------------------------------------\n * * ***CLI icon mapping (emoji or ASCII fallback).***\n * ----------------------------------------------------------------\n *\n * Provides a centralized set of visual symbols used across the CLI\n * for rendering flow indicators, status messages, filesystem labels,\n * and action markers.\n *\n * - *The icon set is determined at runtime via the environment variable:*\n * - `FORCE_EMOJI=1` ➜ Emoji icons are enabled.\n * - Otherwise ➜ ASCII-safe fallback icons are used.\n *\n * - *This ensures compatibility with:*\n * - Terminals that do not support emoji rendering.\n * - CI environments.\n * - Minimal shells or log files.\n * - *Behavior:*\n * - The object shape is identical in both modes.\n * - Only the visual representation changes.\n * - The value is resolved once at module evaluation time.\n * ----------------------------------------------------------------\n * #### Environment Control\n * ```bash\n * FORCE_EMOJI=1\n * ```\n * ----------------------------------------------------------------\n * @remarks\n * This constant is intended for internal CLI rendering only, do not mutate the returned object.\n *\n * @example\n * ```ts\n * console.log(`${ICONS.success} Build completed`);\n * ```\n *\n */\nexport const ICONS: Readonly<Icons> = Object.freeze(\n USE_EMOJI ? emojiIcons : asciiIcons\n);\n","import \"@rzl-zone/node-only\";\n\nimport _fsExtra from \"fs-extra\";\nimport _fastGlob from \"fast-glob\";\n\nexport { ICONS } from \"@/utils/helper/icons\";\n\n/** ----------------------------------------------------------------\n * * ***Node.js–only filesystem utilities (fs-extra).***\n * ----------------------------------------------------------------\n *\n * This export is a **thin re-export** of the `fs-extra` package,\n * intended for **server-side / Node.js environments only**.\n *\n * ⚠️ **DO NOT import this in browser or client-side code.**\n * The underlying implementation depends on Node.js built-in\n * modules such as `fs`, `path`, and `process`.\n *\n * - *Typical use cases:*\n * - CLI tools.\n * - Build scripts.\n * - File system manipulation on the server.\n *\n * @see {@link https://github.com/jprichardson/node-fs-extra | **`https://github.com/jprichardson/node-fs-extra`**}.\n * @environment node\n */\nexport const fsExtra: typeof _fsExtra = _fsExtra;\n\n/** ----------------------------------------------------------------\n * * ***High-performance file system globbing utility (fast-glob).***\n * ----------------------------------------------------------------\n *\n * This export re-exports the default export of `fast-glob`,\n * which is implemented using **CommonJS `export =` semantics**.\n *\n * Due to its reliance on Node.js APIs, this module is\n * **server-side only** and must not be bundled for the browser.\n *\n * - *Typical use cases:*\n * - Resolving file patterns in build tools.\n * - Scanning project directories.\n * - CLI and automation scripts.\n *\n * @see {@link https://github.com/mrmlnc/fast-glob | **`https://github.com/mrmlnc/fast-glob`**}.\n * @environment node\n */\nexport const fastGlob: typeof _fastGlob = _fastGlob;\n\nexport {\n defaultPatternOptions,\n type PatternConfig,\n type PatternOptions\n} from \"@/_internal/libs/fast-globe-options\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IA,MAAa,wBAAwC;CACnD,UAAU;CACV,eAAe;CACf,oBAAoB;CACpB,aAAaA,gBAAG,MAAM,CAAC;CACvB,KAAK;CACL,qBAAqB;CACrB,UAAU;CACV,QAAQ,EAAE;CACV,iBAAiB;CACjB,YAAY;CACZ,iBAAiB;CACjB,WAAW;CACX,QAAQ;CACR,gCAAgC;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,SAAS,aACP,KACA,QACS;AACT,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI,OAAO,cAAc,QAAQ,eAAe,QAAQ,mBACtD,QAAO;AAET,KAAI,OAAO,eAAe,QAAQ,SAAU,QAAO;AAEnD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BT,MAAM,sBAAsB,IAAI,IAC9B,OAAO,KAAK,sBAAsB,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCD,SAAS,gBACP,KACA,QACA,QACA;AACA,QAAO,OAAO,OAAO;;AAwKvB,SAAgB,uBACd,OACA,QACyB;AACzB,KAAI,CAACC,6BAAc,MAAM,CAAE,QAAO,EAAE;CAEpC,MAAM,SAAS;CACf,MAAM,SAAkC,EAAE;AAE1C,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KAAI,oBAAoB,IAAI,IAAI,IAAI,aAAa,KAAK,OAAO,CAC3D,iBAAgB,KAAK,QAAQ,OAAO;AAIxC,QAAO;;AAqET,SAAgB,sBACd,OACA,QACgB;CAChB,MAAM,QAAQ,uBAAuB,OAAO,OAAO;CAEnD,MAAM,UAA0B;EAC9B,GAAG;EACH,GAAG;EACJ;AAED,KAAI,QAAQ,WAAW;AACrB,SAAO,QAAQ;AACf,SAAO,QAAQ;;AAGjB,KAAI,QAAQ,YACV,QAAO,QAAQ;AAGjB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CT,SAAgB,uBACd,OACA,cAC0B;CAC1B,MAAM,yBAAyB;EAC7B,eAAe;EACf,WAAW;EACX,UAAU;EACX;AAMD,QAJUC,mCAAoB,OAAO,uBAAuB,KAElDA,mCAAoB,cAAc,uBAAuB,GAElD,YAAY;;;;;AChlB/B,MAAM,YAAY,QAAQ,IAAI,gBAAgB;AAM9C,MAAM,aAAa;CAEjB,OAAO;CACP,YAAY;CACZ,gBAAgB;CAGhB,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CAGb,SAAS;CACT,MAAM;CACN,OAAO;CAGP,QAAQ;CACR,UAAU;CAGV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CAGN,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;CAGP,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CAGP,MAAM;CACN,OAAO;CACP,UAAU;CACV,WAAW;CACZ;AAED,MAAM,aAAa;CAEjB,OAAO;CACP,YAAY;CACZ,gBAAgB;CAGhB,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CAGb,SAAS;CACT,MAAM;CACN,OAAO;CAGP,QAAQ;CACR,UAAU;CAGV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CAGN,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;CAGP,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CAGP,MAAM;CACN,OAAO;CACP,UAAU;CACV,WAAW;CACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCD,MAAa,QAAyB,OAAO,OAC3C,YAAY,aAAa,WAC1B;;;;;;;;;;;;;;;;;;;;;;;ACxHD,MAAa,UAA2BC;;;;;;;;;;;;;;;;;;;AAoBxC,MAAa,WAA6BC"}
|
|
1
|
+
{"version":3,"file":"server-Ct02ysTN.cjs","names":["os","isPlainObject","safeStableStringify","_fsExtra","_fastGlob"],"sources":["../src/_internal/libs/fast-globe-options.ts","../src/utils/helper/icons.ts","../src/utils/server.ts"],"sourcesContent":["import \"@rzl-zone/node-only\";\n\nimport type { OmitStrict, Prettify } from \"../types/extra\";\n\nimport os from \"node:os\";\nimport * as fg from \"fast-glob\";\n\nimport {\n isPlainObject,\n safeStableStringify,\n type SafeStableStringifyOptions\n} from \"@/_internal/utils/helper\";\n\ntype IfTrueGeneric<T extends boolean, K> = T extends true ? K : never;\n\n/** ----------------------------------------------------------------\n * * ***Supported pattern matching options.***\n * ----------------------------------------------------------------\n * Defines the subset of {@link fg | `fast-glob`} options exposed by\n * this module for pattern-based file resolution.\n *\n * This type intentionally omits several low-level or environment-\n * controlled fields to ensure predictable and safe behavior.\n *\n * ----------------------------------------------------------------\n *\n * *Excluded options (managed internally):*\n *\n * - `fs`\n * - `cwd`\n * - `stats`\n * - `deep`\n * - `extglob`\n * - `suppressErrors`\n * - `braceExpansion`\n *\n * These fields are controlled by the runtime environment and should\n * not be overridden by consumers.\n *\n * ----------------------------------------------------------------\n * @template FilesOnly\n * When `true`, directory filtering options (`onlyFiles`, `onlyDirectories`)\n * are removed from the public API surface, preventing consumers from\n * modifying directory matching behavior.\n *\n * @template ForceUnique\n * When `true`, the `unique` option is removed from the public API to enforce internal uniqueness handling.\n *\n * This allows higher-level utilities to guarantee that matched results\n * are always deduplicated.\n *\n * ----------------------------------------------------------------\n *\n * This type serves as the public configuration contract used when\n * resolving glob patterns.\n */\nexport type PatternOptions<\n FilesOnly extends boolean = false,\n ForceUnique extends boolean = false\n> = OmitStrict<\n fg.Options,\n | \"fs\"\n | \"cwd\"\n | \"stats\"\n | \"deep\"\n | \"extglob\"\n | \"suppressErrors\"\n | \"braceExpansion\"\n | \"dot\"\n | IfTrueGeneric<FilesOnly, \"onlyFiles\" | \"onlyDirectories\">\n | IfTrueGeneric<ForceUnique, \"unique\">,\n { skipPrettify: true }\n> & {\n /** Allow patterns to match entries that begin with a period (`.`).\n *\n * @default true\n */\n dot?: boolean;\n};\n\n/** ----------------------------------------------------------------\n * * ***Pattern configuration wrapper.***\n * ----------------------------------------------------------------\n *\n * Provides an optional container for {@link PatternOptions | `PatternOptions`}.\n *\n * This wrapper allows pattern matching configuration to be composed\n * within higher-level configuration objects without flattening\n * the option namespace.\n *\n * ----------------------------------------------------------------\n *\n * @template FilesOnly\n * When `true`, directory-related options (`onlyFiles`, `onlyDirectories`)\n * are removed from the public configuration to enforce file-only matching.\n *\n * @template ForceUnique\n * When `true`, the `unique` option is removed from the underlying\n * {@link PatternOptions | `PatternOptions`} to guarantee deduplicated results.\n *\n * ----------------------------------------------------------------\n *\n * @example\n * ```ts\n * const config: PatternConfig = {\n * patternOptions: {\n * dot: true\n * }\n * };\n * ```\n */\nexport type PatternConfig<\n FilesOnly extends boolean = false,\n ForceUnique extends boolean = false\n> = Prettify<{\n /** ----------------------------------------------------------------\n * * ***Pattern matching options.***\n * ----------------------------------------------------------------\n *\n * Optional configuration for controlling file pattern resolution.\n *\n * When provided, these options are sanitized and merged with\n * the internal default configuration before being passed to\n * {@link fg | `fast-glob`}.\n *\n * @see {@link PatternOptions | `PatternOptions`} for supported fields.\n */\n patternOptions?: PatternOptions<FilesOnly, ForceUnique>;\n}>;\n\n/** ----------------------------------------------------------------\n * * ***Default pattern matching configuration.***\n * ----------------------------------------------------------------\n *\n * Represents the canonical baseline configuration used when\n * resolving pattern options.\n *\n * These values are applied whenever a user does not explicitly\n * provide overrides.\n *\n * This object also acts as the runtime source of truth for\n * allowed pattern option keys.\n */\nexport const defaultPatternOptions: PatternOptions = {\n absolute: false,\n baseNameMatch: false,\n caseSensitiveMatch: true,\n concurrency: os.cpus().length,\n dot: true,\n followSymbolicLinks: true,\n globstar: true,\n ignore: [],\n markDirectories: false,\n objectMode: false,\n onlyDirectories: false,\n onlyFiles: true,\n unique: true,\n throwErrorOnBrokenSymbolicLink: false\n};\n\n/** ----------------------------------------------------------------\n * * ***Determines whether a pattern option key is allowed.***\n * ----------------------------------------------------------------\n *\n * Evaluates whether a given {@link PatternOptions | `PatternOptions`}\n * key is permitted under the provided runtime policy.\n *\n * This function enforces restrictions such as:\n *\n * - Disallowing directory-related options when `filesOnly` is enabled.\n * - Preventing external control over the `unique` option when\n * `forceUnique` is enabled.\n *\n * ----------------------------------------------------------------\n *\n * @param key\n * A candidate {@link PatternOptions | `PatternOptions`} property key.\n *\n * @param policy\n * Optional runtime policy controlling which keys are allowed.\n *\n * @returns\n * `true` if the key is permitted under the current policy,\n * otherwise `false`.\n *\n * @internal\n */\nfunction isKeyAllowed(\n key: keyof PatternOptions,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): boolean {\n if (!policy) return true;\n\n if (policy.filesOnly && (key === \"onlyFiles\" || key === \"onlyDirectories\"))\n return false;\n\n if (policy.forceUnique && key === \"unique\") return false;\n\n return true;\n}\n\n/** ----------------------------------------------------------------\n * * ***Runtime whitelist of allowed pattern option keys.***\n * ----------------------------------------------------------------\n *\n * Derived directly from {@link defaultPatternOptions | `defaultPatternOptions`}.\n *\n * This ensures strict synchronization between:\n *\n * - The static {@link PatternOptions | `PatternOptions`} type.\n * - Runtime validation logic used during option sanitization.\n *\n * By deriving the key list from the default configuration,\n * this module avoids manual duplication of allowed option names.\n *\n * ----------------------------------------------------------------\n *\n * This whitelist is used internally to:\n *\n * - Remove unknown properties from user-provided configuration.\n * - Guarantee that only supported options are passed to\n * {@link fg | `fast-glob`}.\n *\n * ----------------------------------------------------------------\n *\n * @internal\n */\nconst PATTERN_OPTION_KEYS = new Set<keyof PatternOptions>(\n Object.keys(defaultPatternOptions) as (keyof PatternOptions)[]\n);\n\n/** ----------------------------------------------------------------\n * * ***Assigns a validated pattern option property.***\n * ----------------------------------------------------------------\n *\n * Performs a type-safe assignment from a source object into a\n * partial {@link PatternOptions | `PatternOptions`} result object.\n *\n * A generic constraint is used to preserve proper indexed access\n * typing and avoid union assignment limitations in TypeScript.\n *\n * This helper assumes that:\n *\n * - The provided `key` has already been validated against\n * {@link PATTERN_OPTION_KEYS | `PATTERN_OPTION_KEYS`}.\n * - The property exists on the `source` object.\n *\n * ----------------------------------------------------------------\n *\n * @template K\n * A valid key of {@link PatternOptions | `PatternOptions`}.\n *\n * @param key\n * The validated pattern option key to assign.\n *\n * @param source\n * The original input object containing the property value.\n *\n * @param target\n * The partial result object receiving the assigned value.\n *\n * @internal\n */\nfunction assignIfAllowed<K extends keyof PatternOptions>(\n key: K,\n source: Record<string, unknown>,\n target: Partial<PatternOptions>\n) {\n target[key] = source[key] as PatternOptions[K];\n}\n\n/** ----------------------------------------------------------------\n * * ***Runtime policy controlling pattern option exposure.***\n * ----------------------------------------------------------------\n *\n * Defines runtime constraints that restrict which fields from\n * {@link PatternOptions | `PatternOptions`} are allowed to appear\n * in the final resolved configuration.\n *\n * This policy is primarily used by higher-level utilities that\n * enforce stricter behavior than the raw {@link fg | `fast-glob`} API.\n *\n * ----------------------------------------------------------------\n *\n * *Supported policies:*\n *\n * - `filesOnly`\n * Prevents directory-related configuration from being externally\n * controlled.\n *\n * - `forceUnique`\n * Ensures that uniqueness behavior is handled internally and\n * cannot be overridden by user configuration.\n *\n * ----------------------------------------------------------------\n *\n * These policies influence both:\n *\n * - Runtime sanitization of user-provided pattern options.\n * - Final resolution of merged configuration values.\n *\n * ----------------------------------------------------------------\n *\n * @template FilesOnly\n * Indicates whether directory-related options should be excluded.\n *\n * @template ForceUnique\n * Indicates whether the `unique` option should be excluded.\n */\nexport type PatternRuntimePolicy<\n FilesOnly extends boolean = boolean,\n ForceUnique extends boolean = boolean\n> = {\n /** ----------------------------------------------------------------\n * * ***Restricts directory-related pattern options.***\n * ----------------------------------------------------------------\n *\n * When enabled, directory filtering options are excluded from the\n * final configuration produced by the pattern resolution process.\n *\n * This prevents external configuration from modifying whether\n * directories or files are matched by the underlying\n * {@link fg | `fast-glob`} operation.\n *\n * ----------------------------------------------------------------\n *\n * *Affected options:*\n *\n * - `onlyFiles`\n * - `onlyDirectories`\n *\n * ----------------------------------------------------------------\n *\n * When `true`, these options are ignored during sanitization and\n * removed from the final resolved configuration.\n *\n * ----------------------------------------------------------------\n * @default false\n */\n filesOnly?: FilesOnly;\n\n /** ----------------------------------------------------------------\n * * ***Enforces internal uniqueness behavior.***\n * ----------------------------------------------------------------\n *\n * When enabled, the `unique` option is excluded from user-provided\n * configuration and controlled internally by the runtime.\n *\n * This ensures that result deduplication behavior cannot be\n * overridden by external configuration.\n *\n * ----------------------------------------------------------------\n *\n * *Affected option:*\n *\n * - `unique`\n *\n * ----------------------------------------------------------------\n *\n * When `true`, this option is ignored during sanitization and\n * removed from the final resolved configuration.\n *\n * ----------------------------------------------------------------\n * @default false\n */\n forceUnique?: ForceUnique;\n};\n\n/** ----------------------------------------------------------------\n * * ***Sanitizes pattern options by removing unknown keys.***\n * ----------------------------------------------------------------\n *\n * Ensures that the provided object only contains keys that exist in\n * {@link defaultPatternOptions | `defaultPatternOptions`}, any unknown keys will be removed.\n *\n * This function is intended for API boundary validation to prevent\n * unsafe or unexpected configuration injection.\n *\n * - *Behavior:*\n * - Ignores non-object values (returns empty object).\n * - Removes keys not present in {@link defaultPatternOptions | `defaultPatternOptions`}.\n * - Does NOT mutate the original object.\n *\n * ----------------------------------------------------------------\n *\n * @param input\n * The value to sanitize.\n *\n * @param policy\n * Optional runtime policy restricting which pattern options\n * are allowed during sanitization.\n *\n * @returns\n * A new object containing only allowed pattern option keys.\n *\n * @example\n * ```ts\n * const userOptions = {\n * absolute: true,\n * dot: true,\n * fakeKey: 123\n * };\n *\n * const clean = sanitizePatternOptions(userOptions);\n *\n * // Result:\n * // {\n * // absolute: true,\n * // dot: true\n * // }\n * ```\n */\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): Partial<PatternOptions<false, false>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, false>\n): Partial<PatternOptions<true, false>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, true>\n): Partial<PatternOptions<false, true>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, true>\n): Partial<PatternOptions<true, true>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): Partial<PatternOptions<false, false>>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): Partial<PatternOptions>;\nexport function sanitizePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): Partial<PatternOptions> {\n if (!isPlainObject(input)) return {};\n\n const source = input as Record<string, unknown>;\n const result: Partial<PatternOptions> = {};\n\n for (const key of Object.keys(source) as (keyof PatternOptions)[]) {\n if (PATTERN_OPTION_KEYS.has(key) && isKeyAllowed(key, policy)) {\n assignIfAllowed(key, source, result);\n }\n }\n\n return result;\n}\n\n/** ----------------------------------------------------------------\n * * ***Resolves pattern options with default values.***\n * ----------------------------------------------------------------\n *\n * Applies {@link sanitizePatternOptions | `sanitizePatternOptions`} to the provided input and merges\n * the result with `defaultPatternOptions`.\n *\n * - Unknown keys are removed.\n * - Missing keys fall back to defaults.\n *\n * Guarantees a fully-formed {@link PatternOptions | `PatternOptions`} object safe for direct\n * usage with `fast-glob`.\n *\n * ----------------------------------------------------------------\n *\n * @param input\n * Optional user-provided pattern options.\n *\n * @param policy\n * Optional runtime policy restricting which configuration\n * fields are allowed in the final resolved options.\n *\n * @returns\n * A complete and validated\n * {@link PatternOptions | `PatternOptions`} object ready for\n * direct usage with {@link fg | `fast-glob`}.\n *\n * @example\n * ```ts\n * const options = resolvePatternOptions({\n * dot: true,\n * fakeKey: 123\n * });\n *\n * // Result:\n * // {\n * // absolute: false,\n * // baseNameMatch: false,\n * // ...\n * // dot: true,\n * // ...\n * // }\n *\n * const matched = await fastGlobe(patterns, options);\n * ```\n */\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): PatternOptions<false, false>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, false>\n): PatternOptions<true, false>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, true>\n): PatternOptions<false, true>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<true, true>\n): PatternOptions<true, true>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<false, false>\n): PatternOptions<false, false>;\nexport function resolvePatternOptions(\n input: unknown,\n policy?: PatternRuntimePolicy<boolean, boolean>\n): PatternOptions {\n const clean = sanitizePatternOptions(input, policy);\n\n const options: PatternOptions = {\n ...defaultPatternOptions,\n ...clean\n };\n\n if (policy?.filesOnly) {\n delete options.onlyFiles;\n delete options.onlyDirectories;\n }\n\n if (policy?.forceUnique) {\n delete options.unique;\n }\n\n return options;\n}\n\n/** ----------------------------------------------------------------\n * * ***Stable structural equality detector.***\n * ----------------------------------------------------------------\n *\n * Determines whether two values are structurally identical using\n * deterministic serialization via `safeStableStringify`.\n *\n * - *This comparison:*\n * - Preserves `undefined` values.\n * - Sorts object keys.\n * - Sorts arrays (optional structural normalization).\n *\n * - *Ensures stable equality checks for configuration objects where:*\n * - Property order may differ.\n * - Object references are not identical.\n * - Deep comparison is required.\n *\n * ----------------------------------------------------------------\n *\n * @template T - Value type being compared.\n *\n * @param value - The current runtime value.\n * @param defaultValue - The default reference value.\n *\n * @returns\n * - `\"default\"` ➔ If values are structurally identical.\n * - `\"overridden\"` ➔ If values differ.\n *\n * @example\n * ```ts\n * const source = sourceOfPatternOptions(\n * cleanPatternOptions,\n * defaultPatternOptions\n * );\n *\n * // ➔ \"default\" | \"overridden\"\n * ```\n *\n * @internal\n */\nexport function sourceOfPatternOptions<T>(\n value: T,\n defaultValue: T\n): \"default\" | \"overridden\" {\n const stableStringifyOptions = {\n keepUndefined: true,\n sortArray: true,\n sortKeys: true\n } satisfies SafeStableStringifyOptions;\n\n const a = safeStableStringify(value, stableStringifyOptions);\n\n const b = safeStableStringify(defaultValue, stableStringifyOptions);\n\n return a === b ? \"default\" : \"overridden\";\n}\n","import \"@rzl-zone/node-only\";\n\nimport \"dotenv/config\";\n\n// eslint-disable-next-line turbo/no-undeclared-env-vars\nconst USE_EMOJI = process.env.FORCE_EMOJI === \"1\";\n\ntype Icons = {\n readonly [K in keyof typeof emojiIcons]: string;\n};\n\nconst emojiIcons = {\n /* flow */\n start: \"🕐\",\n arrowRight: \"▶️\",\n arrowRightMini: \"›\",\n\n /* list */\n bulletBold: \"●\",\n bullet: \"•\",\n whiteCircle: \"○\",\n whiteBullet: \"◦\",\n smallSquare: \"▪\",\n\n /* status */\n success: \"✅\",\n warn: \"⚠️\",\n error: \"❌\",\n\n /* config */\n config: \"⚙️\",\n settings: \"🛠️\",\n\n /* files & fs */\n file: \"📄\",\n files: \"📁\",\n folder: \"📂\",\n path: \"🧭\",\n\n /* actions */\n add: \"➕\",\n remove: \"➖\",\n update: \"♻️\",\n copy: \"📋\",\n move: \"📦\",\n clean: \"🧹\",\n\n /* build / process */\n build: \"🏗️\",\n generate: \"🧩\",\n compile: \"⚡\",\n watch: \"👀\",\n\n /* info / misc */\n info: \"ℹ️\",\n debug: \"🐛\",\n question: \"❓\",\n separator: \"━\"\n} as const;\n\nconst asciiIcons = {\n /* flow */\n start: \"▶\",\n arrowRight: \"▶\",\n arrowRightMini: \"›\",\n\n /* list */\n bulletBold: \"●\",\n bullet: \"•\",\n whiteCircle: \"○\",\n whiteBullet: \"◦\",\n smallSquare: \"▪\",\n\n /* status */\n success: \"✅\",\n warn: \"⚠️ \",\n error: \"❌\",\n\n /* config */\n config: \"#\",\n settings: \"@\",\n\n /* files & fs */\n file: \"F\",\n files: \"DIR\",\n folder: \"DIR\",\n path: \"~\",\n\n /* actions */\n add: \"+\",\n remove: \"-\",\n update: \"~\",\n copy: \"=\",\n move: \">\",\n clean: \"x\",\n\n /* build / process */\n build: \"#\",\n generate: \"*\",\n compile: \">\",\n watch: \"o\",\n\n /* info / misc */\n info: \"i\",\n debug: \"d\",\n question: \"?\",\n separator: \"-\"\n} as const satisfies Icons;\n\n/** ----------------------------------------------------------------\n * * ***CLI icon mapping (emoji or ASCII fallback).***\n * ----------------------------------------------------------------\n *\n * Provides a centralized set of visual symbols used across the CLI\n * for rendering flow indicators, status messages, filesystem labels,\n * and action markers.\n *\n * - *The icon set is determined at runtime via the environment variable:*\n * - `FORCE_EMOJI=1` ➜ Emoji icons are enabled.\n * - Otherwise ➜ ASCII-safe fallback icons are used.\n *\n * - *This ensures compatibility with:*\n * - Terminals that do not support emoji rendering.\n * - CI environments.\n * - Minimal shells or log files.\n * - *Behavior:*\n * - The object shape is identical in both modes.\n * - Only the visual representation changes.\n * - The value is resolved once at module evaluation time.\n * ----------------------------------------------------------------\n * #### Environment Control\n * ```bash\n * FORCE_EMOJI=1\n * ```\n * ----------------------------------------------------------------\n * @remarks\n * This constant is intended for internal CLI rendering only, do not mutate the returned object.\n *\n * @example\n * ```ts\n * console.log(`${ICONS.success} Build completed`);\n * ```\n *\n */\nexport const ICONS: Readonly<Icons> = Object.freeze(\n USE_EMOJI ? emojiIcons : asciiIcons\n);\n","import \"@rzl-zone/node-only\";\n\nimport _fsExtra from \"fs-extra\";\nimport _fastGlob from \"fast-glob\";\n\nexport { ICONS } from \"@/utils/helper/icons\";\n\n/** ----------------------------------------------------------------\n * * ***Node.js–only filesystem utilities (fs-extra).***\n * ----------------------------------------------------------------\n *\n * This export is a **thin re-export** of the `fs-extra` package,\n * intended for **server-side / Node.js environments only**.\n *\n * ⚠️ **DO NOT import this in browser or client-side code.**\n * The underlying implementation depends on Node.js built-in\n * modules such as `fs`, `path`, and `process`.\n *\n * - *Typical use cases:*\n * - CLI tools.\n * - Build scripts.\n * - File system manipulation on the server.\n *\n * @see {@link https://github.com/jprichardson/node-fs-extra | **`https://github.com/jprichardson/node-fs-extra`**}.\n * @environment node\n */\nexport const fsExtra: typeof _fsExtra = _fsExtra;\n\n/** ----------------------------------------------------------------\n * * ***High-performance file system globbing utility (fast-glob).***\n * ----------------------------------------------------------------\n *\n * This export re-exports the default export of `fast-glob`,\n * which is implemented using **CommonJS `export =` semantics**.\n *\n * Due to its reliance on Node.js APIs, this module is\n * **server-side only** and must not be bundled for the browser.\n *\n * - *Typical use cases:*\n * - Resolving file patterns in build tools.\n * - Scanning project directories.\n * - CLI and automation scripts.\n *\n * @see {@link https://github.com/mrmlnc/fast-glob | **`https://github.com/mrmlnc/fast-glob`**}.\n * @environment node\n */\nexport const fastGlob: typeof _fastGlob = _fastGlob;\n\nexport {\n defaultPatternOptions,\n type PatternConfig,\n type PatternOptions\n} from \"@/_internal/libs/fast-globe-options\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+IA,MAAa,wBAAwC;CACnD,UAAU;CACV,eAAe;CACf,oBAAoB;CACpB,aAAaA,gBAAG,MAAM,CAAC;CACvB,KAAK;CACL,qBAAqB;CACrB,UAAU;CACV,QAAQ,EAAE;CACV,iBAAiB;CACjB,YAAY;CACZ,iBAAiB;CACjB,WAAW;CACX,QAAQ;CACR,gCAAgC;CACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BD,SAAS,aACP,KACA,QACS;AACT,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI,OAAO,cAAc,QAAQ,eAAe,QAAQ,mBACtD,QAAO;AAET,KAAI,OAAO,eAAe,QAAQ,SAAU,QAAO;AAEnD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BT,MAAM,sBAAsB,IAAI,IAC9B,OAAO,KAAK,sBAAsB,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCD,SAAS,gBACP,KACA,QACA,QACA;AACA,QAAO,OAAO,OAAO;;AAwKvB,SAAgB,uBACd,OACA,QACyB;AACzB,KAAI,CAACC,6BAAc,MAAM,CAAE,QAAO,EAAE;CAEpC,MAAM,SAAS;CACf,MAAM,SAAkC,EAAE;AAE1C,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,KAAI,oBAAoB,IAAI,IAAI,IAAI,aAAa,KAAK,OAAO,CAC3D,iBAAgB,KAAK,QAAQ,OAAO;AAIxC,QAAO;;AAqET,SAAgB,sBACd,OACA,QACgB;CAChB,MAAM,QAAQ,uBAAuB,OAAO,OAAO;CAEnD,MAAM,UAA0B;EAC9B,GAAG;EACH,GAAG;EACJ;AAED,KAAI,QAAQ,WAAW;AACrB,SAAO,QAAQ;AACf,SAAO,QAAQ;;AAGjB,KAAI,QAAQ,YACV,QAAO,QAAQ;AAGjB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CT,SAAgB,uBACd,OACA,cAC0B;CAC1B,MAAM,yBAAyB;EAC7B,eAAe;EACf,WAAW;EACX,UAAU;EACX;AAMD,QAJUC,mCAAoB,OAAO,uBAAuB,KAElDA,mCAAoB,cAAc,uBAAuB,GAElD,YAAY;;;;;AChlB/B,MAAM,YAAY,QAAQ,IAAI,gBAAgB;AAM9C,MAAM,aAAa;CAEjB,OAAO;CACP,YAAY;CACZ,gBAAgB;CAGhB,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CAGb,SAAS;CACT,MAAM;CACN,OAAO;CAGP,QAAQ;CACR,UAAU;CAGV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CAGN,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;CAGP,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CAGP,MAAM;CACN,OAAO;CACP,UAAU;CACV,WAAW;CACZ;AAED,MAAM,aAAa;CAEjB,OAAO;CACP,YAAY;CACZ,gBAAgB;CAGhB,YAAY;CACZ,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CAGb,SAAS;CACT,MAAM;CACN,OAAO;CAGP,QAAQ;CACR,UAAU;CAGV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,MAAM;CAGN,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,MAAM;CACN,OAAO;CAGP,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CAGP,MAAM;CACN,OAAO;CACP,UAAU;CACV,WAAW;CACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCD,MAAa,QAAyB,OAAO,OAC3C,YAAY,aAAa,WAC1B;;;;;;;;;;;;;;;;;;;;;;;ACxHD,MAAa,UAA2BC;;;;;;;;;;;;;;;;;;;AAoBxC,MAAa,WAA6BC"}
|