@powerlines/core 0.48.52 → 0.48.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/constants/api.mjs.map +1 -1
  2. package/dist/constants/commands.mjs.map +1 -1
  3. package/dist/constants/devtools.mjs.map +1 -1
  4. package/dist/constants/environments.mjs.map +1 -1
  5. package/dist/constants/extensions.mjs.map +1 -1
  6. package/dist/constants/fs.mjs.map +1 -1
  7. package/dist/constants/hooks.mjs.map +1 -1
  8. package/dist/constants/log-level.mjs.map +1 -1
  9. package/dist/constants/meta.mjs.map +1 -1
  10. package/dist/constants/plugin.mjs.map +1 -1
  11. package/dist/context/base-context.mjs.map +1 -1
  12. package/dist/context/context.mjs.map +1 -1
  13. package/dist/context/environment-context.mjs.map +1 -1
  14. package/dist/context/execution-context.mjs.map +1 -1
  15. package/dist/context/plugin-context.mjs.map +1 -1
  16. package/dist/lib/config.mjs.map +1 -1
  17. package/dist/lib/context-helpers.mjs.map +1 -1
  18. package/dist/lib/entry.mjs.map +1 -1
  19. package/dist/lib/environment.mjs.map +1 -1
  20. package/dist/lib/events.mjs.map +1 -1
  21. package/dist/lib/generate-types.mjs.map +1 -1
  22. package/dist/lib/hooks.mjs.map +1 -1
  23. package/dist/lib/install-dependencies.mjs.map +1 -1
  24. package/dist/lib/meta.mjs.map +1 -1
  25. package/dist/lib/plugins.mjs.map +1 -1
  26. package/dist/lib/resolver.mjs.map +1 -1
  27. package/dist/lib/streaming-channel.mjs.map +1 -1
  28. package/dist/lib/typescript/ts-morph.mjs.map +1 -1
  29. package/dist/lib/typescript/tsconfig.mjs.map +1 -1
  30. package/dist/lib/unplugin/helpers.mjs.map +1 -1
  31. package/dist/lib/unplugin/module-resolution.mjs.map +1 -1
  32. package/dist/lib/unplugin/plugin.mjs.map +1 -1
  33. package/dist/lib/utilities/file-header.mjs.map +1 -1
  34. package/dist/lib/utilities/format.cjs +7 -1
  35. package/dist/lib/utilities/format.d.cts.map +1 -1
  36. package/dist/lib/utilities/format.d.mts.map +1 -1
  37. package/dist/lib/utilities/format.mjs +6 -1
  38. package/dist/lib/utilities/format.mjs.map +1 -1
  39. package/dist/lib/utilities/source-file.mjs.map +1 -1
  40. package/dist/lib/utilities/source-map.mjs.map +1 -1
  41. package/dist/lib/utilities/write-file.mjs.map +1 -1
  42. package/dist/lib/vfs.cjs +1 -1
  43. package/dist/lib/vfs.mjs +1 -1
  44. package/dist/lib/vfs.mjs.map +1 -1
  45. package/dist/plugin-base.mjs.map +1 -1
  46. package/dist/plugin-utils/build-helpers.mjs.map +1 -1
  47. package/dist/plugin-utils/combine-plugins.mjs.map +1 -1
  48. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  49. package/dist/plugin-utils/docs-helper.mjs.map +1 -1
  50. package/dist/plugin-utils/enable-plugin.mjs.map +1 -1
  51. package/dist/plugin-utils/extend.mjs.map +1 -1
  52. package/dist/plugin-utils/filter.mjs.map +1 -1
  53. package/dist/plugin-utils/format-package-json.mjs.map +1 -1
  54. package/dist/plugin-utils/format.mjs.map +1 -1
  55. package/dist/plugin-utils/get-config-path.mjs.map +1 -1
  56. package/dist/plugin-utils/helpers.mjs.map +1 -1
  57. package/dist/plugin-utils/install.mjs.map +1 -1
  58. package/dist/plugin-utils/logging.mjs.map +1 -1
  59. package/dist/plugin-utils/merge.mjs.map +1 -1
  60. package/dist/plugin-utils/modules.mjs.map +1 -1
  61. package/dist/plugin-utils/paths.mjs.map +1 -1
  62. package/dist/plugin-utils/virtual.mjs.map +1 -1
  63. package/dist/storage/base.mjs.map +1 -1
  64. package/dist/storage/file-system.mjs.map +1 -1
  65. package/dist/storage/helpers.mjs.map +1 -1
  66. package/dist/storage/virtual.mjs.map +1 -1
  67. package/package.json +10 -7
@@ -1 +1 @@
1
- {"version":3,"file":"enable-plugin.mjs","names":[],"sources":["../../src/plugin-utils/enable-plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { Plugin } from \"../types\";\nimport { PluginContext } from \"../types/context\";\n\n/**\n * Utility function to conditionally enable plugins based on a boolean value or a function that returns a boolean. This is useful for scenarios where you want to enable certain plugins only in specific environments (e.g., development vs production) or based on certain conditions (e.g., presence of environment variables).\n *\n * @example\n * ```ts\n * const somePlugin = <TContext extends PluginContext = PluginContext>(options: { enableThirdPlugin: boolean }) => {\n * return [\n * ...enable<TContext>(anotherPlugin, () => process.env.NODE_ENV === \"development\"),\n * ...enable<TContext>(yetAnotherPlugin, process.env.ENABLE_YET_ANOTHER_PLUGIN === \"true\"),\n * ...enable<TContext>(thirdPlugin, options.enableThirdPlugin),\n * {\n * name: \"some-plugin\",\n * ...\n * }\n * ];\n * };\n * ```\n *\n * @param plugin - A single plugin or an array of plugins to conditionally enable.\n * @param condition - A boolean value or a function that returns a boolean. If it's a function, it will be executed to determine whether to enable the plugin(s). If it's a boolean, it will be used directly.\n * @returns An array of plugins that should be enabled based on the provided condition. If the condition is false, an empty array will be returned.\n */\nexport function enable<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n condition: boolean | (() => boolean) = true\n): Plugin<TContext>[] {\n return (isFunction(condition) && condition()) ||\n (!isFunction(condition) && condition)\n ? toArray(plugin).filter(Boolean)\n : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,OACd,QACA,YAAuC,MACnB;CACpB,OAAQ,WAAW,SAAS,KAAK,UAAU,KACxC,CAAC,WAAW,SAAS,KAAK,YACzB,QAAQ,MAAM,CAAC,CAAC,OAAO,OAAO,IAC9B,CAAC;AACP"}
1
+ {"version":3,"file":"enable-plugin.mjs","names":[],"sources":["../../src/plugin-utils/enable-plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { Plugin } from \"../types\";\nimport { PluginContext } from \"../types/context\";\n\n/**\n * Utility function to conditionally enable plugins based on a boolean value or a function that returns a boolean. This is useful for scenarios where you want to enable certain plugins only in specific environments (e.g., development vs production) or based on certain conditions (e.g., presence of environment variables).\n *\n * @example\n * ```ts\n * const somePlugin = <TContext extends PluginContext = PluginContext>(options: { enableThirdPlugin: boolean }) => {\n * return [\n * ...enable<TContext>(anotherPlugin, () => process.env.NODE_ENV === \"development\"),\n * ...enable<TContext>(yetAnotherPlugin, process.env.ENABLE_YET_ANOTHER_PLUGIN === \"true\"),\n * ...enable<TContext>(thirdPlugin, options.enableThirdPlugin),\n * {\n * name: \"some-plugin\",\n * ...\n * }\n * ];\n * };\n * ```\n *\n * @param plugin - A single plugin or an array of plugins to conditionally enable.\n * @param condition - A boolean value or a function that returns a boolean. If it's a function, it will be executed to determine whether to enable the plugin(s). If it's a boolean, it will be used directly.\n * @returns An array of plugins that should be enabled based on the provided condition. If the condition is false, an empty array will be returned.\n */\nexport function enable<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n condition: boolean | (() => boolean) = true\n): Plugin<TContext>[] {\n return (isFunction(condition) && condition()) ||\n (!isFunction(condition) && condition)\n ? toArray(plugin).filter(Boolean)\n : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,OACd,QACA,YAAuC,MACnB;CACpB,OAAQ,WAAW,SAAS,KAAK,UAAU,KACxC,CAAC,WAAW,SAAS,KAAK,YACzB,QAAQ,MAAM,CAAC,CAAC,OAAO,OAAO,IAC9B,CAAC;AACP"}
@@ -1 +1 @@
1
- {"version":3,"file":"extend.mjs","names":[],"sources":["../../src/plugin-utils/extend.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport {\n PartialPlugin,\n PartialPluginFactory,\n PluginFactory\n} from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { merge } from \"./merge\";\n\n/**\n * Adds additional helper functionality to a plugin via a plugin builder function.\n *\n * @param plugin - The base plugin object or factory function to extend.\n * @param extension - The plugin extension object or factory function. This function receives the plugin options and returns a plugin object.\n * @returns A function accepting the plugin options and returning the extended plugin.\n */\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown,\n TExtensionOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TPluginOptions & TExtensionOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPlugin<TContext>\n): PluginFactory<TContext, TPluginOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TExtensionOptions = unknown\n>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TExtensionOptions>;\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPlugin<TContext>\n): Plugin<TContext>[];\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[] | PluginFactory<TContext, any>,\n extension: PartialPlugin<TContext> | PartialPluginFactory<TContext, any>\n): PluginFactory<TContext, any> | Plugin<TContext>[] {\n if (isFunction(plugin)) {\n if (isFunction(extension)) {\n return async (options: any) => {\n const pluginResult = toArray(await Promise.resolve(plugin(options)));\n const extensionResult = toArray(\n await Promise.resolve(extension(options))\n );\n\n return pluginResult\n .map(p => extensionResult.map(e => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return async (options: any) => {\n const result = toArray(await Promise.resolve(plugin(options)));\n\n return result.map(p => merge(p, extension) as Plugin<TContext>);\n };\n } else if (isFunction(extension)) {\n return async (options: any) => {\n const result = toArray(await Promise.resolve(extension(options)));\n\n return result\n .map(e => toArray(plugin).map(p => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return toArray(plugin).map(p => merge(p, extension) as Plugin<TContext>);\n}\n"],"mappings":";;;;;AA8DA,SAAgB,OACd,QACA,WACmD;CACnD,IAAI,WAAW,MAAM,GAAG;EACtB,IAAI,WAAW,SAAS,GACtB,OAAO,OAAO,YAAiB;GAC7B,MAAM,eAAe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAAC;GACnE,MAAM,kBAAkB,QACtB,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAC1C;GAEA,OAAO,aACJ,KAAI,MAAK,gBAAgB,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,CAAC,CACnE,KAAK;EACV;EAGF,OAAO,OAAO,YAAiB;GAG7B,OAFe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAEhD,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,SAAS,CAAqB;EAChE;CACF,OAAO,IAAI,WAAW,SAAS,GAC7B,OAAO,OAAO,YAAiB;EAG7B,OAFe,QAAQ,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAEnD,CAAC,CACV,KAAI,MAAK,QAAQ,MAAM,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,CAAC,CACnE,KAAK;CACV;CAGF,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,SAAS,CAAqB;AACzE"}
1
+ {"version":3,"file":"extend.mjs","names":[],"sources":["../../src/plugin-utils/extend.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport {\n PartialPlugin,\n PartialPluginFactory,\n PluginFactory\n} from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { merge } from \"./merge\";\n\n/**\n * Adds additional helper functionality to a plugin via a plugin builder function.\n *\n * @param plugin - The base plugin object or factory function to extend.\n * @param extension - The plugin extension object or factory function. This function receives the plugin options and returns a plugin object.\n * @returns A function accepting the plugin options and returning the extended plugin.\n */\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown,\n TExtensionOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TPluginOptions & TExtensionOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPlugin<TContext>\n): PluginFactory<TContext, TPluginOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TExtensionOptions = unknown\n>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TExtensionOptions>;\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPlugin<TContext>\n): Plugin<TContext>[];\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[] | PluginFactory<TContext, any>,\n extension: PartialPlugin<TContext> | PartialPluginFactory<TContext, any>\n): PluginFactory<TContext, any> | Plugin<TContext>[] {\n if (isFunction(plugin)) {\n if (isFunction(extension)) {\n return async (options: any) => {\n const pluginResult = toArray(await Promise.resolve(plugin(options)));\n const extensionResult = toArray(\n await Promise.resolve(extension(options))\n );\n\n return pluginResult\n .map(p => extensionResult.map(e => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return async (options: any) => {\n const result = toArray(await Promise.resolve(plugin(options)));\n\n return result.map(p => merge(p, extension) as Plugin<TContext>);\n };\n } else if (isFunction(extension)) {\n return async (options: any) => {\n const result = toArray(await Promise.resolve(extension(options)));\n\n return result\n .map(e => toArray(plugin).map(p => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return toArray(plugin).map(p => merge(p, extension) as Plugin<TContext>);\n}\n"],"mappings":";;;;;AA8DA,SAAgB,OACd,QACA,WACmD;CACnD,IAAI,WAAW,MAAM,GAAG;EACtB,IAAI,WAAW,SAAS,GACtB,OAAO,OAAO,YAAiB;GAC7B,MAAM,eAAe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAAC;GACnE,MAAM,kBAAkB,QACtB,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAC1C;GAEA,OAAO,aACJ,KAAI,MAAK,gBAAgB,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,CAAC,CACnE,KAAK;EACV;EAGF,OAAO,OAAO,YAAiB;GAG7B,OAFe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAEhD,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,SAAS,CAAqB;EAChE;CACF,OAAO,IAAI,WAAW,SAAS,GAC7B,OAAO,OAAO,YAAiB;EAG7B,OAFe,QAAQ,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAEnD,CAAC,CACV,KAAI,MAAK,QAAQ,MAAM,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,CAAC,CACnE,KAAK;CACV;CAGF,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,SAAS,CAAqB;AACzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"filter.mjs","names":[],"sources":["../../src/plugin-utils/filter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolve } from \"node:path\";\nimport picomatch from \"picomatch\";\nimport type { StringFilter, StringOrRegExp } from \"unplugin\";\nimport {\n NormalizedStringFilter,\n PluginFilter,\n TransformHookFilter\n} from \"../types/hooks\";\nimport { removeVirtualPrefix } from \"./virtual\";\n\nconst BACKSLASH_REGEX = /\\\\/g;\nfunction normalize(path: string): string {\n return removeVirtualPrefix(path).replace(BACKSLASH_REGEX, \"/\");\n}\n\nfunction getMatcherString(glob: string, cwd: string) {\n if (glob.startsWith(\"**\") || isAbsolutePath(glob)) {\n return normalize(glob);\n }\n\n const resolved = resolve(cwd, glob);\n\n return normalize(resolved);\n}\n\nexport function patternToIdFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (id: string) => {\n const normalizedId = normalize(id);\n const result = pattern.test(normalizedId);\n pattern.lastIndex = 0;\n return result;\n };\n }\n const cwd = process.cwd();\n const glob = getMatcherString(pattern, cwd);\n const matcher = picomatch(glob, { dot: true });\n\n return (id: string) => {\n const normalizedId = normalize(id);\n\n return matcher(normalizedId);\n };\n}\n\nexport function patternToCodeFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (code: string) => {\n const result = pattern.test(code);\n pattern.lastIndex = 0;\n return result;\n };\n }\n return (code: string) => code.includes(pattern);\n}\n\nexport function createFilter(\n exclude: PluginFilter[] | undefined,\n include: PluginFilter[] | undefined\n): PluginFilter | undefined {\n if (!exclude && !include) {\n return;\n }\n\n return input => {\n if (exclude?.some(filter => filter(input))) {\n return false;\n }\n if (include?.some(filter => filter(input))) {\n return true;\n }\n return !(include && include.length > 0);\n };\n}\n\nexport function normalizeSingleFilter(\n filter: string | RegExp\n): string | RegExp {\n if (isSetString(filter)) {\n return removeVirtualPrefix(filter);\n }\n\n return filter;\n}\n\nexport function normalizeFilter(filter: StringFilter): NormalizedStringFilter {\n if (isSetString(filter) || isRegExp(filter)) {\n return {\n include: [normalizeSingleFilter(filter)]\n };\n }\n\n if (Array.isArray(filter)) {\n return {\n include: filter.map(normalizeSingleFilter)\n };\n }\n\n return {\n exclude: filter.exclude\n ? toArray(filter.exclude).map(normalizeSingleFilter)\n : undefined,\n include: filter.include\n ? toArray(filter.include).map(normalizeSingleFilter)\n : undefined\n };\n}\n\nexport function createIdFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToIdFilter);\n const includeFilter = include?.map(patternToIdFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createCodeFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToCodeFilter);\n const includeFilter = include?.map(patternToCodeFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createFilterForId(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n\n return filterFunction ? id => !!filterFunction(id) : undefined;\n}\n\nexport function createFilterForTransform(\n idFilter: StringFilter | undefined,\n codeFilter: StringFilter | undefined\n): TransformHookFilter | undefined {\n if (!idFilter && !codeFilter) return;\n const idFilterFunction = createIdFilter(idFilter);\n const codeFilterFunction = createCodeFilter(codeFilter);\n\n return (id, code) => {\n let fallback = true;\n if (idFilterFunction) {\n fallback &&= idFilterFunction(id);\n }\n if (!fallback) {\n return false;\n }\n\n if (codeFilterFunction) {\n fallback &&= codeFilterFunction(code);\n }\n return fallback;\n };\n}\n"],"mappings":";;;;;;;;;AAgCA,MAAM,kBAAkB;AACxB,SAAS,UAAU,MAAsB;CACvC,OAAO,oBAAoB,IAAI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L,SAAS,OAAO,IAAI,qBAAqB,EAC3C;CAGF,OAAO;EACL,SAAS,OAAO,UACZ,QAAQ,OAAO,OAAO,CAAC,CAAC,IAAI,qBAAqB,IACjD;EACJ,SAAS,OAAO,UACZ,QAAQ,OAAO,OAAO,CAAC,CAAC,IAAI,qBAAqB,IACjD;CACN;AACF;AAEA,SAAgB,eACd,QAC0B;CAC1B,IAAI,CAAC,QAAQ;CACb,MAAM,EAAE,SAAS,YAAY,gBAAgB,MAAM;CACnD,MAAM,gBAAgB,SAAS,IAAI,iBAAiB;CACpD,MAAM,gBAAgB,SAAS,IAAI,iBAAiB;CAEpD,OAAO,aAAa,eAAe,aAAa;AAClD;AAEA,SAAgB,iBACd,QAC0B;CAC1B,IAAI,CAAC,QAAQ;CACb,MAAM,EAAE,SAAS,YAAY,gBAAgB,MAAM;CACnD,MAAM,gBAAgB,SAAS,IAAI,mBAAmB;CACtD,MAAM,gBAAgB,SAAS,IAAI,mBAAmB;CAEtD,OAAO,aAAa,eAAe,aAAa;AAClD;AAEA,SAAgB,kBACd,QAC0B;CAC1B,MAAM,iBAAiB,eAAe,MAAM;CAE5C,OAAO,kBAAiB,OAAM,CAAC,CAAC,eAAe,EAAE,IAAI;AACvD;AAEA,SAAgB,yBACd,UACA,YACiC;CACjC,IAAI,CAAC,YAAY,CAAC,YAAY;CAC9B,MAAM,mBAAmB,eAAe,QAAQ;CAChD,MAAM,qBAAqB,iBAAiB,UAAU;CAEtD,QAAQ,IAAI,SAAS;EACnB,IAAI,WAAW;EACf,IAAI,kBACF,aAAa,iBAAiB,EAAE;EAElC,IAAI,CAAC,UACH,OAAO;EAGT,IAAI,oBACF,aAAa,mBAAmB,IAAI;EAEtC,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"filter.mjs","names":[],"sources":["../../src/plugin-utils/filter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolve } from \"node:path\";\nimport picomatch from \"picomatch\";\nimport type { StringFilter, StringOrRegExp } from \"unplugin\";\nimport {\n NormalizedStringFilter,\n PluginFilter,\n TransformHookFilter\n} from \"../types/hooks\";\nimport { removeVirtualPrefix } from \"./virtual\";\n\nconst BACKSLASH_REGEX = /\\\\/g;\nfunction normalize(path: string): string {\n return removeVirtualPrefix(path).replace(BACKSLASH_REGEX, \"/\");\n}\n\nfunction getMatcherString(glob: string, cwd: string) {\n if (glob.startsWith(\"**\") || isAbsolutePath(glob)) {\n return normalize(glob);\n }\n\n const resolved = resolve(cwd, glob);\n\n return normalize(resolved);\n}\n\nexport function patternToIdFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (id: string) => {\n const normalizedId = normalize(id);\n const result = pattern.test(normalizedId);\n pattern.lastIndex = 0;\n return result;\n };\n }\n const cwd = process.cwd();\n const glob = getMatcherString(pattern, cwd);\n const matcher = picomatch(glob, { dot: true });\n\n return (id: string) => {\n const normalizedId = normalize(id);\n\n return matcher(normalizedId);\n };\n}\n\nexport function patternToCodeFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (code: string) => {\n const result = pattern.test(code);\n pattern.lastIndex = 0;\n return result;\n };\n }\n return (code: string) => code.includes(pattern);\n}\n\nexport function createFilter(\n exclude: PluginFilter[] | undefined,\n include: PluginFilter[] | undefined\n): PluginFilter | undefined {\n if (!exclude && !include) {\n return;\n }\n\n return input => {\n if (exclude?.some(filter => filter(input))) {\n return false;\n }\n if (include?.some(filter => filter(input))) {\n return true;\n }\n return !(include && include.length > 0);\n };\n}\n\nexport function normalizeSingleFilter(\n filter: string | RegExp\n): string | RegExp {\n if (isSetString(filter)) {\n return removeVirtualPrefix(filter);\n }\n\n return filter;\n}\n\nexport function normalizeFilter(filter: StringFilter): NormalizedStringFilter {\n if (isSetString(filter) || isRegExp(filter)) {\n return {\n include: [normalizeSingleFilter(filter)]\n };\n }\n\n if (Array.isArray(filter)) {\n return {\n include: filter.map(normalizeSingleFilter)\n };\n }\n\n return {\n exclude: filter.exclude\n ? toArray(filter.exclude).map(normalizeSingleFilter)\n : undefined,\n include: filter.include\n ? toArray(filter.include).map(normalizeSingleFilter)\n : undefined\n };\n}\n\nexport function createIdFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToIdFilter);\n const includeFilter = include?.map(patternToIdFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createCodeFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToCodeFilter);\n const includeFilter = include?.map(patternToCodeFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createFilterForId(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n\n return filterFunction ? id => !!filterFunction(id) : undefined;\n}\n\nexport function createFilterForTransform(\n idFilter: StringFilter | undefined,\n codeFilter: StringFilter | undefined\n): TransformHookFilter | undefined {\n if (!idFilter && !codeFilter) return;\n const idFilterFunction = createIdFilter(idFilter);\n const codeFilterFunction = createCodeFilter(codeFilter);\n\n return (id, code) => {\n let fallback = true;\n if (idFilterFunction) {\n fallback &&= idFilterFunction(id);\n }\n if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;CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"format-package-json.mjs","names":[],"sources":["../../src/plugin-utils/format-package-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { format } from \"../lib/utilities/format\";\nimport { Context } from \"../types/context\";\n\n/**\n * Formats the `package.json` file in the project root.\n *\n * @param context - The powerlines context.\n */\nexport async function formatPackageJson(context: Context) {\n const packageJsonPath = joinPaths(\n context.config.cwd,\n context.config.root,\n \"package.json\"\n );\n\n const packageJsonFile = await context.fs.read(packageJsonPath);\n if (isSetString(packageJsonFile)) {\n await context.fs.write(\n packageJsonPath,\n await format(context, packageJsonPath, packageJsonFile)\n );\n }\n}\n"],"mappings":";;;;;;;;;;AA4BA,eAAsB,kBAAkB,SAAkB;CACxD,MAAM,kBAAkB,UACtB,QAAQ,OAAO,KACf,QAAQ,OAAO,MACf,cACF;CAEA,MAAM,kBAAkB,MAAM,QAAQ,GAAG,KAAK,eAAe;CAC7D,IAAI,YAAY,eAAe,GAC7B,MAAM,QAAQ,GAAG,MACf,iBACA,MAAM,OAAO,SAAS,iBAAiB,eAAe,CACxD;AAEJ"}
1
+ {"version":3,"file":"format-package-json.mjs","names":[],"sources":["../../src/plugin-utils/format-package-json.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { format } from \"../lib/utilities/format\";\nimport { Context } from \"../types/context\";\n\n/**\n * Formats the `package.json` file in the project root.\n *\n * @param context - The powerlines context.\n */\nexport async function formatPackageJson(context: Context) {\n const packageJsonPath = joinPaths(\n context.config.cwd,\n context.config.root,\n \"package.json\"\n );\n\n const packageJsonFile = await context.fs.read(packageJsonPath);\n if (isSetString(packageJsonFile)) {\n await context.fs.write(\n packageJsonPath,\n await format(context, packageJsonPath, packageJsonFile)\n );\n }\n}\n"],"mappings":";;;;;;;;;;AA4BA,eAAsB,kBAAkB,SAAkB;CACxD,MAAM,kBAAkB,UACtB,QAAQ,OAAO,KACf,QAAQ,OAAO,MACf,cACF;CAEA,MAAM,kBAAkB,MAAM,QAAQ,GAAG,KAAK,eAAe;CAC7D,IAAI,YAAY,eAAe,GAC7B,MAAM,QAAQ,GAAG,MACf,iBACA,MAAM,OAAO,SAAS,iBAAiB,eAAe,CACxD;AAEJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","names":[],"sources":["../../src/plugin-utils/format.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { ResolveConfig, ResolvedConfig } from \"../types/config\";\n\n/**\n * Formats a configuration object into a human-readable string, omitting certain properties and simplifying others for better readability.\n *\n * @param config - The configuration object to format.\n * @returns A formatted string representation of the configuration.\n */\nexport function formatConfig(config: Record<string, any>): string {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries({\n ...omit(config, [\n \"deps\",\n \"resolve\",\n \"plugins\",\n \"initialConfig\",\n \"userConfig\",\n \"inlineConfig\",\n \"pluginConfig\",\n \"environmentConfig\"\n ]),\n deps: isSetObject(config.deps)\n ? {\n alwaysBundle: isSetArray(\n (config.deps as { alwaysBundle?: unknown[] })?.alwaysBundle\n )\n ? (\n (config.deps as { alwaysBundle?: unknown[] })\n ?.alwaysBundle ?? []\n )\n .filter(Boolean)\n .map(alwaysBundle =>\n isSetString(alwaysBundle)\n ? alwaysBundle\n : isRegExp(alwaysBundle)\n ? alwaysBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n onlyBundle: isSetArray(\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle\n )\n ? (\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle ??\n []\n )\n .filter(Boolean)\n .map(onlyBundle =>\n isSetString(onlyBundle)\n ? onlyBundle\n : isRegExp(onlyBundle)\n ? onlyBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n neverBundle: isSetArray(\n (config.deps as { neverBundle?: unknown[] })?.neverBundle\n )\n ? (\n (config.deps as { neverBundle?: unknown[] })?.neverBundle ??\n []\n )\n .filter(Boolean)\n .map(neverBundle =>\n isSetString(neverBundle)\n ? neverBundle\n : isRegExp(neverBundle)\n ? neverBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n\n resolve: isSetObject(config.resolve)\n ? {\n ...config.resolve,\n external: isSetArray((config.resolve as ResolveConfig)?.external)\n ? ((config.resolve as ResolveConfig)?.external ?? [])\n .filter(Boolean)\n .map(external =>\n isSetString(external)\n ? external\n : isRegExp(external)\n ? external.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n noExternal: isSetArray(\n (config.resolve as ResolveConfig)?.noExternal\n )\n ? ((config.resolve as ResolveConfig)?.noExternal ?? [])\n .filter(Boolean)\n .map(noExternal =>\n isSetString(noExternal)\n ? noExternal\n : isRegExp(noExternal)\n ? noExternal.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n plugins: isSetArray(config.plugins)\n ? (toArray(config.plugins) as ResolvedConfig[\"plugins\"])\n ?.flatMap(plugin => toArray(plugin))\n ?.map(plugin =>\n String(\n isSetString(plugin)\n ? plugin\n : isSetObject(plugin) &&\n isSetString((plugin as { name: string }).name)\n ? (plugin as { name: string }).name\n : Array.isArray(plugin) && isSetString(plugin[0])\n ? plugin[0]\n : \"<function-plugin>\"\n )\n )\n : undefined\n }).sort(([key1], [key2]) => key1.localeCompare(key2))\n ),\n null,\n 4\n )\n .replace(/\"([^\"]+)\":/g, \"$1:\")\n .replace(/,\\s*$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,aAAa,QAAqC;CAChE,OAAO,KAAK,UACV,OAAO,YACL,OAAO,QAAQ;EACb,GAAG,KAAK,QAAQ;GACd;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM,YAAY,OAAO,IAAI,IACzB;GACE,cAAc,WACX,OAAO,MAAuC,YACjD,KAEO,OAAO,MACJ,gBAAgB,CAAC,EAAC,CAErB,OAAO,OAAO,CAAC,CACf,KAAI,iBACH,YAAY,YAAY,IACpB,eACA,SAAS,YAAY,IACnB,aAAa,SACb,kBACR,IACF;GACJ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"}
1
+ {"version":3,"file":"format.mjs","names":[],"sources":["../../src/plugin-utils/format.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { ResolveConfig, ResolvedConfig } from \"../types/config\";\n\n/**\n * Formats a configuration object into a human-readable string, omitting certain properties and simplifying others for better readability.\n *\n * @param config - The configuration object to format.\n * @returns A formatted string representation of the configuration.\n */\nexport function formatConfig(config: Record<string, any>): string {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries({\n ...omit(config, [\n \"deps\",\n \"resolve\",\n \"plugins\",\n \"initialConfig\",\n \"userConfig\",\n \"inlineConfig\",\n \"pluginConfig\",\n \"environmentConfig\"\n ]),\n deps: isSetObject(config.deps)\n ? {\n alwaysBundle: isSetArray(\n (config.deps as { alwaysBundle?: unknown[] })?.alwaysBundle\n )\n ? (\n (config.deps as { alwaysBundle?: unknown[] })\n ?.alwaysBundle ?? []\n )\n .filter(Boolean)\n .map(alwaysBundle =>\n isSetString(alwaysBundle)\n ? alwaysBundle\n : isRegExp(alwaysBundle)\n ? alwaysBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n onlyBundle: isSetArray(\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle\n )\n ? (\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle ??\n []\n )\n .filter(Boolean)\n .map(onlyBundle =>\n isSetString(onlyBundle)\n ? onlyBundle\n : isRegExp(onlyBundle)\n ? onlyBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n neverBundle: isSetArray(\n (config.deps as { neverBundle?: unknown[] })?.neverBundle\n )\n ? (\n (config.deps as { neverBundle?: unknown[] })?.neverBundle ??\n []\n )\n .filter(Boolean)\n .map(neverBundle =>\n isSetString(neverBundle)\n ? neverBundle\n : isRegExp(neverBundle)\n ? neverBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n\n resolve: isSetObject(config.resolve)\n ? {\n ...config.resolve,\n external: isSetArray((config.resolve as ResolveConfig)?.external)\n ? ((config.resolve as ResolveConfig)?.external ?? [])\n .filter(Boolean)\n .map(external =>\n isSetString(external)\n ? external\n : isRegExp(external)\n ? external.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n noExternal: isSetArray(\n (config.resolve as ResolveConfig)?.noExternal\n )\n ? ((config.resolve as ResolveConfig)?.noExternal ?? [])\n .filter(Boolean)\n .map(noExternal =>\n isSetString(noExternal)\n ? noExternal\n : isRegExp(noExternal)\n ? noExternal.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n plugins: isSetArray(config.plugins)\n ? (toArray(config.plugins) as ResolvedConfig[\"plugins\"])\n ?.flatMap(plugin => toArray(plugin))\n ?.map(plugin =>\n String(\n isSetString(plugin)\n ? plugin\n : isSetObject(plugin) &&\n isSetString((plugin as { name: string }).name)\n ? (plugin as { name: string }).name\n : Array.isArray(plugin) && isSetString(plugin[0])\n ? plugin[0]\n : \"<function-plugin>\"\n )\n )\n : undefined\n }).sort(([key1], [key2]) => key1.localeCompare(key2))\n ),\n null,\n 4\n )\n .replace(/\"([^\"]+)\":/g, \"$1:\")\n .replace(/,\\s*$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;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,MAAM,CAAC,CAAC,EAClC,KAAI,WACJ,OACE,YAAY,MAAM,IACd,SACA,YAAY,MAAM,KAChB,YAAa,OAA4B,IAAI,IAC5C,OAA4B,OAC7B,MAAM,QAAQ,MAAM,KAAK,YAAY,OAAO,EAAE,IAC5C,OAAO,KACP,mBACV,CACF,IACF;CACN,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,KAAK,cAAc,IAAI,CAAC,CACtD,GACA,MACA,CACF,CAAC,CACE,QAAQ,eAAe,KAAK,CAAC,CAC7B,QAAQ,UAAU,EAAE;AACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-config-path.mjs","names":[],"sources":["../../src/plugin-utils/get-config-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { existsSync } from \"node:fs\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Get the configuration file path for a given name.\n *\n * @param context - The Powerlines context.\n * @param name - The name of the configuration file (without extension).\n * @returns The absolute path to the configuration file, or undefined if not found.\n */\nexport function getConfigPath(\n context: UnresolvedContext | { cwd?: string; root: string },\n name: string\n): string | undefined {\n const cwd =\n ((context as UnresolvedContext).config\n ? (context as UnresolvedContext).config.cwd\n : (context as { cwd?: string; root: string }).cwd) || process.cwd();\n const root = (context as UnresolvedContext).config\n ? (context as UnresolvedContext).config.root\n : (context as { cwd?: string; root: string }).root;\n\n if (existsSync(joinPaths(cwd, root, `${name}.yml`))) {\n return joinPaths(cwd, root, `${name}.yml`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.yaml`))) {\n return joinPaths(cwd, root, `${name}.yaml`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.json`))) {\n return joinPaths(cwd, root, `${name}.json`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.jsonc`))) {\n return joinPaths(cwd, root, `${name}.jsonc`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.ts`))) {\n return joinPaths(cwd, root, `${name}.ts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.cts`))) {\n return joinPaths(cwd, root, `${name}.cts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.mts`))) {\n return joinPaths(cwd, root, `${name}.mts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.js`))) {\n return joinPaths(cwd, root, `${name}.js`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.cjs`))) {\n return joinPaths(cwd, root, `${name}.cjs`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.mjs`))) {\n return joinPaths(cwd, root, `${name}.mjs`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.ts`))) {\n return joinPaths(cwd, root, `${name}.config.ts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.cts`))) {\n return joinPaths(cwd, root, `${name}.config.cts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.mts`))) {\n return joinPaths(cwd, root, `${name}.config.mts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.js`))) {\n return joinPaths(cwd, root, `${name}.config.js`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.cjs`))) {\n return joinPaths(cwd, root, `${name}.config.cjs`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.mjs`))) {\n return joinPaths(cwd, root, `${name}.config.mjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.yml`))) {\n return joinPaths(cwd, `${name}.yml`);\n } else if (existsSync(joinPaths(cwd, `${name}.yaml`))) {\n return joinPaths(cwd, `${name}.yaml`);\n } else if (existsSync(joinPaths(cwd, `${name}.json`))) {\n return joinPaths(cwd, `${name}.json`);\n } else if (existsSync(joinPaths(cwd, `${name}.jsonc`))) {\n return joinPaths(cwd, `${name}.jsonc`);\n } else if (existsSync(joinPaths(cwd, `${name}.ts`))) {\n return joinPaths(cwd, `${name}.ts`);\n } else if (existsSync(joinPaths(cwd, `${name}.cts`))) {\n return joinPaths(cwd, `${name}.cts`);\n } else if (existsSync(joinPaths(cwd, `${name}.mts`))) {\n return joinPaths(cwd, `${name}.mts`);\n } else if (existsSync(joinPaths(cwd, `${name}.js`))) {\n return joinPaths(cwd, `${name}.js`);\n } else if (existsSync(joinPaths(cwd, `${name}.cjs`))) {\n return joinPaths(cwd, `${name}.cjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.mjs`))) {\n return joinPaths(cwd, `${name}.mjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.ts`))) {\n return joinPaths(cwd, `${name}.config.ts`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.cts`))) {\n return joinPaths(cwd, `${name}.config.cts`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.mts`))) {\n return joinPaths(cwd, `${name}.config.mts`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.js`))) {\n return joinPaths(cwd, `${name}.config.js`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.cjs`))) {\n return joinPaths(cwd, `${name}.config.cjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.mjs`))) {\n return joinPaths(cwd, `${name}.config.mjs`);\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;AA6BA,SAAgB,cACd,SACA,MACoB;CACpB,MAAM,OACF,QAA8B,SAC3B,QAA8B,OAAO,MACrC,QAA2C,QAAQ,QAAQ,IAAI;CACtE,MAAM,OAAQ,QAA8B,SACvC,QAA8B,OAAO,OACrC,QAA2C;CAEhD,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK,CAAC,GAChD,OAAO,UAAU,K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UAAU,KAAK,GAAG,KAAK,KAAK,CAAC,GACjD,OAAO,UAAU,KAAK,GAAG,KAAK,KAAK;MAC9B,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,KAAK,CAAC,GACjD,OAAO,UAAU,KAAK,GAAG,KAAK,KAAK;MAC9B,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,WAAW,CAAC,GACvD,OAAO,UAAU,KAAK,GAAG,KAAK,WAAW;MACpC,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,YAAY,CAAC,GACxD,OAAO,UAAU,KAAK,GAAG,KAAK,YAAY;MACrC,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,YAAY,CAAC,GACxD,OAAO,UAAU,KAAK,GAAG,KAAK,YAAY;MACrC,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,WAAW,CAAC,GACvD,OAAO,UAAU,KAAK,GAAG,KAAK,WAAW;MACpC,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,YAAY,CAAC,GACxD,OAAO,UAAU,KAAK,GAAG,KAAK,YAAY;MACrC,IAAI,WAAW,UAAU,KAAK,GAAG,KAAK,YAAY,CAAC,GACxD,OAAO,UAAU,KAAK,GAAG,KAAK,YAAY;AAI9C"}
1
+ {"version":3,"file":"get-config-path.mjs","names":[],"sources":["../../src/plugin-utils/get-config-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { existsSync } from \"node:fs\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Get the configuration file path for a given name.\n *\n * @param context - The Powerlines context.\n * @param name - The name of the configuration file (without extension).\n * @returns The absolute path to the configuration file, or undefined if not found.\n */\nexport function getConfigPath(\n context: UnresolvedContext | { cwd?: string; root: string },\n name: string\n): string | undefined {\n const cwd =\n ((context as UnresolvedContext).config\n ? (context as UnresolvedContext).config.cwd\n : (context as { cwd?: string; root: string }).cwd) || process.cwd();\n const root = (context as UnresolvedContext).config\n ? (context as UnresolvedContext).config.root\n : (context as { cwd?: string; root: string }).root;\n\n if (existsSync(joinPaths(cwd, root, `${name}.yml`))) {\n return joinPaths(cwd, root, `${name}.yml`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.yaml`))) {\n return joinPaths(cwd, root, `${name}.yaml`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.json`))) {\n return joinPaths(cwd, root, `${name}.json`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.jsonc`))) {\n return joinPaths(cwd, root, `${name}.jsonc`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.ts`))) {\n return joinPaths(cwd, root, `${name}.ts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.cts`))) {\n return joinPaths(cwd, root, `${name}.cts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.mts`))) {\n return joinPaths(cwd, root, `${name}.mts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.js`))) {\n return joinPaths(cwd, root, `${name}.js`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.cjs`))) {\n return joinPaths(cwd, root, `${name}.cjs`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.mjs`))) {\n return joinPaths(cwd, root, `${name}.mjs`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.ts`))) {\n return joinPaths(cwd, root, `${name}.config.ts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.cts`))) {\n return joinPaths(cwd, root, `${name}.config.cts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.mts`))) {\n return joinPaths(cwd, root, `${name}.config.mts`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.js`))) {\n return joinPaths(cwd, root, `${name}.config.js`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.cjs`))) {\n return joinPaths(cwd, root, `${name}.config.cjs`);\n } else if (existsSync(joinPaths(cwd, root, `${name}.config.mjs`))) {\n return joinPaths(cwd, root, `${name}.config.mjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.yml`))) {\n return joinPaths(cwd, `${name}.yml`);\n } else if (existsSync(joinPaths(cwd, `${name}.yaml`))) {\n return joinPaths(cwd, `${name}.yaml`);\n } else if (existsSync(joinPaths(cwd, `${name}.json`))) {\n return joinPaths(cwd, `${name}.json`);\n } else if (existsSync(joinPaths(cwd, `${name}.jsonc`))) {\n return joinPaths(cwd, `${name}.jsonc`);\n } else if (existsSync(joinPaths(cwd, `${name}.ts`))) {\n return joinPaths(cwd, `${name}.ts`);\n } else if (existsSync(joinPaths(cwd, `${name}.cts`))) {\n return joinPaths(cwd, `${name}.cts`);\n } else if (existsSync(joinPaths(cwd, `${name}.mts`))) {\n return joinPaths(cwd, `${name}.mts`);\n } else if (existsSync(joinPaths(cwd, `${name}.js`))) {\n return joinPaths(cwd, `${name}.js`);\n } else if (existsSync(joinPaths(cwd, `${name}.cjs`))) {\n return joinPaths(cwd, `${name}.cjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.mjs`))) {\n return joinPaths(cwd, `${name}.mjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.ts`))) {\n return joinPaths(cwd, `${name}.config.ts`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.cts`))) {\n return joinPaths(cwd, `${name}.config.cts`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.mts`))) {\n return joinPaths(cwd, `${name}.config.mts`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.js`))) {\n return joinPaths(cwd, `${name}.config.js`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.cjs`))) {\n return joinPaths(cwd, `${name}.config.cjs`);\n } else if (existsSync(joinPaths(cwd, `${name}.config.mjs`))) {\n return joinPaths(cwd, `${name}.config.mjs`);\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;AA6BA,SAAgB,cACd,SACA,MACoB;CACpB,MAAM,OACF,QAA8B,SAC3B,QAA8B,OAAO,MACrC,QAA2C,QAAQ,QAAQ,IAAI;CACtE,MAAM,OAAQ,QAA8B,SACvC,QAA8B,OAAO,OACrC,QAA2C;CAEhD,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK,CAAC,GAChD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK;MACpC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,MAAM,CAAC,GACxD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,MAAM;MACrC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,MAAM,CAAC,GACxD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,MAAM;MACrC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,OAAO,CAAC,GACzD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,OAAO;MACtC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,IAAI,CAAC,GACtD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,IAAI;MACnC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK,CAAC,GACvD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK;MACpC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK,CAAC,GACvD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK;MACpC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,IAAI,CAAC,GACtD,OAAO,UAAU,KAAK,MAAM,GAAG,KAAK,IAAI;MACnC,IAAI,WAAW,UAAU,KAAK,MAAM,GAAG,KAAK,KAAK,CAA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ent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport {\n PLUGIN_HOOKS_FIELDS,\n PLUGIN_NON_HOOK_FIELDS,\n UNPLUGIN_BUILDER_VARIANTS\n} from \"../constants/plugin\";\nimport type {\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple\n} from \"../types/config\";\nimport type { PluginContext, WithUnpluginBuildContext } from \"../types/context\";\nimport type { HooksListItem } from \"../types/hooks\";\nimport type {\n Plugin,\n PluginHook,\n PluginHookFields,\n PluginHookObject,\n PluginHooks\n} from \"../types/plugin\";\nimport type {\n UnpluginBuilderVariant,\n UnpluginOptions\n} from \"../types/unplugin\";\n\n/**\n * Type guard to check if an object is a {@link Plugin}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link Plugin}, false otherwise\n */\nexport function isPlugin<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is Plugin<TContext> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined((value as Plugin<TContext>).api) ||\n (\"api\" in value && isSetObject(value.api))) &&\n (isUndefined((value as Plugin<TContext>).applyToEnvironment) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<TContext>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n PLUGIN_HOOKS_FIELDS.every(\n hook =>\n isUndefined((value as Record<string, unknown>)[hook]) ||\n (hook in value &&\n (isPluginHookFunction((value as Record<string, unknown>)[hook]) ||\n (hook === \"config\" &&\n isSetObject((value as Plugin<TContext>)[hook]))))\n )\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigObject}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigObject}, false otherwise\n */\nexport function isPluginConfigObject<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigObject<TContext> {\n return (\n isSetObject(value) &&\n \"plugin\" in value &&\n (((isSetString(value.plugin) || isFunction(value.plugin)) &&\n \"options\" in value &&\n isSetObject(value.options)) ||\n isPlugin(value.plugin))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigTuple}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigTuple}, false otherwise\n */\nexport function isPluginConfigTuple<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigTuple<TContext> {\n return (\n Array.isArray(value) &&\n (value.length === 1 || value.length === 2) &&\n (((isSetString(value[0]) || isFunction(value[0])) &&\n value.length > 1 &&\n isSetObject(value[1])) ||\n isPlugin(value[0]))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfig}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfig}, false otherwise\n */\nexport function isPluginConfig<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is PluginConfig<TContext> {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value) ||\n (Array.isArray(value) && value.every(item => isPluginConfig(item)))\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookObject(\n value: unknown\n): value is PluginHookObject<AnyFunction> {\n return isSetObject(value) && \"handler\" in value && isFunction(value.handler);\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookFunction(value: unknown): value is AnyFunction {\n return isFunction(value) || isPluginHookObject(value);\n}\n\n/**\n * Type guard to check if an object is a {@link PluginHook}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginHook}, false otherwise\n */\nexport function isPluginHook(value: unknown): value is PluginHook<AnyFunction> {\n return isPluginHookFunction(value) || isPluginHookObject(value);\n}\n\nexport type GetHookHandlerReturnType<\n TContext extends PluginContext = PluginContext,\n TField extends string = string\n> = HooksListItem<TContext, TField>[\"handler\"];\n\n/**\n * Extract the hook handler function from a plugin hook\n *\n * @param pluginHook - The plugin hook to extract the handler function from\n * @returns The hook handler function\n */\nexport function getHookHandler<\n TContext extends PluginContext = PluginContext,\n TKey extends string = string\n>(\n pluginHook: PluginHook<AnyFunction>\n): GetHookHandlerReturnType<TContext, TKey> {\n return (\n isFunction(pluginHook) ? pluginHook : pluginHook.handler\n ) as GetHookHandlerReturnType<TContext, TKey>;\n}\n\n/**\n * Extract a plugin hook from a plugin\n *\n * @param context - The build context\n * @param plugin - The plugin to extract the hook from\n * @param hook - The name of the hook to extract\n * @returns The extracted hook, or undefined if the hook does not exist\n */\nexport function extractPluginHook<\n TContext extends PluginContext = PluginContext,\n TPlugin extends Plugin<TContext> = Plugin<TContext>\n>(context: TContext, plugin: TPlugin, hook: keyof PluginHooks<TContext>) {\n const pluginHook = plugin[hook];\n if (!isPluginHook(pluginHook)) {\n return undefined;\n }\n\n return isFunction(pluginHook)\n ? {\n normal: pluginHook.bind(context)\n }\n : {\n [pluginHook.order ? pluginHook.order : \"normal\"]:\n pluginHook.handler.bind(context)\n };\n}\n\n/**\n * Check if a hook is external.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookKey<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TContext extends PluginContext = PluginContext\n>(\n keys: string\n): keys is `${TUnpluginBuilderVariant}:${keyof UnpluginOptions<TContext>[TUnpluginBuilderVariant] & string}` {\n return UNPLUGIN_BUILDER_VARIANTS.some(variant =>\n keys.startsWith(`${variant}:`)\n );\n}\n\n/**\n * Check if a hook is internal.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isPluginHookField<TContext extends PluginContext>(\n keys: string\n) {\n return !PLUGIN_NON_HOOK_FIELDS.includes(keys as PluginHookFields<TContext>);\n}\n\n/**\n * Check if a hook is external.\n *\n * @param field - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookField<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant\n>(field: string): field is TUnpluginBuilderVariant {\n return (\n !isPluginHookField(field) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(field as UnpluginBuilderVariant)\n );\n}\n\n/**\n * Check if a plugin should be deduplicated.\n *\n * @param plugin - The plugin to check\n * @param plugins - The list of plugins to check against\n * @returns True if the plugin should be deduplicated, false otherwise\n */\nexport function isDuplicate<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext>,\n plugins: Plugin<TContext>[]\n) {\n return (\n plugin.dedupe !== false &&\n plugins.some(\n p =>\n p.dedupe !== false &&\n ((isFunction(p.dedupe) && p.dedupe(plugin)) ||\n kebabCase(p.name) === kebabCase(plugin.name))\n )\n );\n}\n\n/**\n * Remove duplicate hooks from a list of hooks, keeping the first occurrence of each plugin.\n *\n * @param hooksList - The list of hooks to deduplicate.\n * @returns A new list of hooks with duplicates removed.\n */\nexport function dedupeHooklist<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(hooksList: TList[]): TList[] {\n return hooksList.reduce((ret, hook) => {\n if (\n !isDuplicate(\n hook.plugin,\n ret.map(h => h.plugin)\n )\n ) {\n ret.push(hook);\n }\n return ret;\n }, [] as TList[]);\n}\n\n/**\n * Add a plugin hook to the hooks list.\n *\n * @param context - The plugin context\n * @param plugin - The plugin to add the hook from\n * @param pluginHook - The plugin hook to add\n * @param hooksList - The list of hooks to add to\n */\nexport function addPluginHook<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(\n context: TContext,\n plugin: Plugin<TContext>,\n pluginHook: PluginHook<AnyFunction>,\n hooksList: TList[]\n): TList[] {\n if (\n !isDuplicate(plugin, hooksList.map(hook => hook.plugin).filter(Boolean))\n ) {\n const handler = ((...args: unknown[]) =>\n (\n getHookHandler<WithUnpluginBuildContext<TContext>, TField>(\n pluginHook\n ) as unknown as (...args: unknown[]) => unknown\n ).apply(context, args)) as GetHookHandlerReturnType<TContext, TField>;\n if (!handler) {\n return hooksList;\n }\n\n hooksList.push({\n plugin,\n handler\n } as any);\n }\n\n return hooksList;\n}\n\n/**\n * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.\n *\n * @param config - The plugin configuration to check\n * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations\n */\nexport function findInvalidPluginConfig<\n TContext extends PluginContext = PluginContext\n>(config: PluginConfig<TContext>): string[] | null {\n if (isPluginConfig<TContext>(config)) {\n return null;\n }\n\n if (Array.isArray(config as PluginConfig<TContext>[])) {\n const invalidItems: string[] = [];\n (config as PluginConfig<TContext>[]).forEach(item => {\n const invalid = findInvalidPluginConfig<TContext>(item);\n if (invalid) {\n invalidItems.push(...invalid.map(i => JSON.stringify(i, null, 2)));\n }\n });\n\n return invalidItems.length > 0 ? invalidItems : null;\n }\n\n return [JSON.stringify(config, null, 2)];\n}\n"],"mapp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AC,CAAC,OAAO,OAAO,CAAC,GACvE;EACA,MAAM,YAAY,GAAG,SAEjB,eACE,UACF,CAAC,CACD,MAAM,SAAS,IAAI;EACvB,IAAI,CAAC,SACH,OAAO;EAGT,UAAU,KAAK;GACb;GACA;EACF,CAAQ;CACV;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,wBAEd,QAAiD;CACjD,IAAI,eAAyB,MAAM,GACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,MAAkC,GAAG;EACrD,MAAM,eAAyB,CAAC;EAChC,AAAC,OAAoC,SAAQ,SAAQ;GACnD,MAAM,UAAU,wBAAkC,IAAI;GACtD,IAAI,SACF,aAAa,KAAK,GAAG,QAAQ,KAAI,MAAK,KAAK,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC;EAErE,CAAC;EAED,OAAO,aAAa,SAAS,IAAI,eAAe;CAClD;CAEA,OAAO,CAAC,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AACzC"}
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/plugin-utils/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport {\n PLUGIN_HOOKS_FIELDS,\n PLUGIN_NON_HOOK_FIELDS,\n UNPLUGIN_BUILDER_VARIANTS\n} from \"../constants/plugin\";\nimport type {\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple\n} from \"../types/config\";\nimport type { PluginContext, WithUnpluginBuildContext } from \"../types/context\";\nimport type { HooksListItem } from \"../types/hooks\";\nimport type {\n Plugin,\n PluginHook,\n PluginHookFields,\n PluginHookObject,\n PluginHooks\n} from \"../types/plugin\";\nimport type {\n UnpluginBuilderVariant,\n UnpluginOptions\n} from \"../types/unplugin\";\n\n/**\n * Type guard to check if an object is a {@link Plugin}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link Plugin}, false otherwise\n */\nexport function isPlugin<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is Plugin<TContext> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined((value as Plugin<TContext>).api) ||\n (\"api\" in value && isSetObject(value.api))) &&\n (isUndefined((value as Plugin<TContext>).applyToEnvironment) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<TContext>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n PLUGIN_HOOKS_FIELDS.every(\n hook =>\n isUndefined((value as Record<string, unknown>)[hook]) ||\n (hook in value &&\n (isPluginHookFunction((value as Record<string, unknown>)[hook]) ||\n (hook === \"config\" &&\n isSetObject((value as Plugin<TContext>)[hook]))))\n )\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigObject}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigObject}, false otherwise\n */\nexport function isPluginConfigObject<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigObject<TContext> {\n return (\n isSetObject(value) &&\n \"plugin\" in value &&\n (((isSetString(value.plugin) || isFunction(value.plugin)) &&\n \"options\" in value &&\n isSetObject(value.options)) ||\n isPlugin(value.plugin))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigTuple}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigTuple}, false otherwise\n */\nexport function isPluginConfigTuple<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigTuple<TContext> {\n return (\n Array.isArray(value) &&\n (value.length === 1 || value.length === 2) &&\n (((isSetString(value[0]) || isFunction(value[0])) &&\n value.length > 1 &&\n isSetObject(value[1])) ||\n isPlugin(value[0]))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfig}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfig}, false otherwise\n */\nexport function isPluginConfig<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is PluginConfig<TContext> {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value) ||\n (Array.isArray(value) && value.every(item => isPluginConfig(item)))\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookObject(\n value: unknown\n): value is PluginHookObject<AnyFunction> {\n return isSetObject(value) && \"handler\" in value && isFunction(value.handler);\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookFunction(value: unknown): value is AnyFunction {\n return isFunction(value) || isPluginHookObject(value);\n}\n\n/**\n * Type guard to check if an object is a {@link PluginHook}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginHook}, false otherwise\n */\nexport function isPluginHook(value: unknown): value is PluginHook<AnyFunction> {\n return isPluginHookFunction(value) || isPluginHookObject(value);\n}\n\nexport type GetHookHandlerReturnType<\n TContext extends PluginContext = PluginContext,\n TField extends string = string\n> = HooksListItem<TContext, TField>[\"handler\"];\n\n/**\n * Extract the hook handler function from a plugin hook\n *\n * @param pluginHook - The plugin hook to extract the handler function from\n * @returns The hook handler function\n */\nexport function getHookHandler<\n TContext extends PluginContext = PluginContext,\n TKey extends string = string\n>(\n pluginHook: PluginHook<AnyFunction>\n): GetHookHandlerReturnType<TContext, TKey> {\n return (\n isFunction(pluginHook) ? pluginHook : pluginHook.handler\n ) as GetHookHandlerReturnType<TContext, TKey>;\n}\n\n/**\n * Extract a plugin hook from a plugin\n *\n * @param context - The build context\n * @param plugin - The plugin to extract the hook from\n * @param hook - The name of the hook to extract\n * @returns The extracted hook, or undefined if the hook does not exist\n */\nexport function extractPluginHook<\n TContext extends PluginContext = PluginContext,\n TPlugin extends Plugin<TContext> = Plugin<TContext>\n>(context: TContext, plugin: TPlugin, hook: keyof PluginHooks<TContext>) {\n const pluginHook = plugin[hook];\n if (!isPluginHook(pluginHook)) {\n return undefined;\n }\n\n return isFunction(pluginHook)\n ? {\n normal: pluginHook.bind(context)\n }\n : {\n [pluginHook.order ? pluginHook.order : \"normal\"]:\n pluginHook.handler.bind(context)\n };\n}\n\n/**\n * Check if a hook is external.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookKey<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TContext extends PluginContext = PluginContext\n>(\n keys: string\n): keys is `${TUnpluginBuilderVariant}:${keyof UnpluginOptions<TContext>[TUnpluginBuilderVariant] & string}` {\n return UNPLUGIN_BUILDER_VARIANTS.some(variant =>\n keys.startsWith(`${variant}:`)\n );\n}\n\n/**\n * Check if a hook is internal.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isPluginHookField<TContext extends PluginContext>(\n keys: string\n) {\n return !PLUGIN_NON_HOOK_FIELDS.includes(keys as PluginHookFields<TContext>);\n}\n\n/**\n * Check if a hook is external.\n *\n * @param field - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookField<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant\n>(field: string): field is TUnpluginBuilderVariant {\n return (\n !isPluginHookField(field) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(field as UnpluginBuilderVariant)\n );\n}\n\n/**\n * Check if a plugin should be deduplicated.\n *\n * @param plugin - The plugin to check\n * @param plugins - The list of plugins to check against\n * @returns True if the plugin should be deduplicated, false otherwise\n */\nexport function isDuplicate<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext>,\n plugins: Plugin<TContext>[]\n) {\n return (\n plugin.dedupe !== false &&\n plugins.some(\n p =>\n p.dedupe !== false &&\n ((isFunction(p.dedupe) && p.dedupe(plugin)) ||\n kebabCase(p.name) === kebabCase(plugin.name))\n )\n );\n}\n\n/**\n * Remove duplicate hooks from a list of hooks, keeping the first occurrence of each plugin.\n *\n * @param hooksList - The list of hooks to deduplicate.\n * @returns A new list of hooks with duplicates removed.\n */\nexport function dedupeHooklist<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(hooksList: TList[]): TList[] {\n return hooksList.reduce((ret, hook) => {\n if (\n !isDuplicate(\n hook.plugin,\n ret.map(h => h.plugin)\n )\n ) {\n ret.push(hook);\n }\n return ret;\n }, [] as TList[]);\n}\n\n/**\n * Add a plugin hook to the hooks list.\n *\n * @param context - The plugin context\n * @param plugin - The plugin to add the hook from\n * @param pluginHook - The plugin hook to add\n * @param hooksList - The list of hooks to add to\n */\nexport function addPluginHook<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(\n context: TContext,\n plugin: Plugin<TContext>,\n pluginHook: PluginHook<AnyFunction>,\n hooksList: TList[]\n): TList[] {\n if (\n !isDuplicate(plugin, hooksList.map(hook => hook.plugin).filter(Boolean))\n ) {\n const handler = ((...args: unknown[]) =>\n (\n getHookHandler<WithUnpluginBuildContext<TContext>, TField>(\n pluginHook\n ) as unknown as (...args: unknown[]) => unknown\n ).apply(context, args)) as GetHookHandlerReturnType<TContext, TField>;\n if (!handler) {\n return hooksList;\n }\n\n hooksList.push({\n plugin,\n handler\n } as any);\n }\n\n return hooksList;\n}\n\n/**\n * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.\n *\n * @param config - The plugin configuration to check\n * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations\n */\nexport function findInvalidPluginConfig<\n TContext extends PluginContext = PluginContext\n>(config: PluginConfig<TContext>): string[] | null {\n if (isPluginConfig<TContext>(config)) {\n return null;\n }\n\n if (Array.isArray(config as PluginConfig<TContext>[])) {\n const invalidItems: string[] = [];\n (config as PluginConfig<TContext>[]).forEach(item => {\n const invalid = findInvalidPluginConfig<TContext>(item);\n if (invalid) {\n invalidItems.push(...invalid.map(i => JSON.stringify(i, null, 2)));\n }\n });\n\n return invalidItems.length > 0 ? invalidItems : null;\n }\n\n return [JSON.stringify(config, null, 2)];\n}\n"],"mappings":";;;;;;;;;;;;;;AAsDA,SAAgB,SACd,OAC2B;CAC3B,OACE,YAAY,KAAK,KACjB,UAAU,SACV,YAAY,MAAM,IAAI,MACrB,YAAa,MAA2B,GAAG,KACzC,SAAS,SAAS,YAAY,MAAM,GAAG,OACzC,YAAa,MAA2B,kBAAkB,KACxD,wBAAwB,SACvB,WAAW,MAAM,kBAAkB,OACtC,YAAa,MAA2B,MAAM,KAC5C,YAAY,SAAS,WAAW,MAAM,MAAM,MAC/C,oBAAoB,OAClB,SACE,YAAa,MAAkC,KAAK,KACnD,QAAQ,UACN,qBAAsB,MAAkC,KAAK,KAC3D,SAAS,YACR,YAAa,MAA2B,KAAK,EACvD;AAEJ;;;;;;;AAQA,SAAgB,qBAEd,OAAuD;CACvD,OACE,YAAY,KAAK,KACjB,YAAY,WACT,YAAY,MAAM,MAAM,KAAK,WAAW,MAAM,MAAM,MACrD,a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AAC,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"install.mjs","names":[],"sources":["../../src/plugin-utils/install.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Context } from \"@powerlines/core\";\nimport { install } from \"@stryke/fs/install\";\nimport {\n doesPackageMatch,\n getPackageListing,\n isPackageListed\n} from \"@stryke/fs/package-fns\";\nimport {\n getPackageName,\n getPackageVersion,\n hasPackageVersion\n} from \"@stryke/string-format/package\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\n\n/**\n * Installs a package if it is not already installed.\n *\n * @param context - The resolved options\n * @param packageName - The name of the package to install\n * @param dev - Whether to install the package as a dev dependency\n */\nexport async function installPackage(\n context: Context,\n packageName: string,\n dev = false\n) {\n if (\n !(await isPackageListed(getPackageName(packageName), {\n cwd: context.config.root\n }))\n ) {\n if (context.config.autoInstall) {\n context.warn(\n `The package \"${packageName}\" is not installed. It will be installed automatically.`\n );\n\n const result = await install(packageName, {\n cwd: context.config.root,\n dev\n });\n if (isNumber(result.exitCode) && result.exitCode > 0) {\n context.error(result.stderr);\n throw new Error(\n `An error occurred while installing the package \"${packageName}\"`\n );\n }\n } else {\n context.warn(\n `The package \"${packageName}\" is not installed. Since the \"autoInstall\" option is set to false, it will not be installed automatically.`\n );\n }\n } else if (\n hasPackageVersion(packageName) &&\n !process.env.POWERLINES_SKIP_VERSION_CHECK\n ) {\n const isMatching = await doesPackageMatch(\n getPackageName(packageName),\n getPackageVersion(packageName)!,\n context.config.root\n );\n if (!isMatching) {\n const packageListing = await getPackageListing(\n getPackageName(packageName),\n {\n cwd: context.config.root\n }\n );\n if (\n !packageListing?.version.startsWith(\"catalog:\") &&\n !packageListing?.version.startsWith(\"workspace:\")\n ) {\n context.warn(\n `The package \"${getPackageName(packageName)}\" is installed but does not match the expected version ${getPackageVersion(\n packageName\n )} (installed version: ${packageListing?.version || \"<Unknown>\"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the \"STORM_STACK_SKIP_VERSION_CHECK\" environment variable.`\n );\n }\n }\n }\n}\n\n/**\n * Installs a package if it is not already installed.\n *\n * @param context - The resolved options\n * @param packages - The list of packages to install\n */\nexport async function installPackages(\n context: Context,\n packages: Array<{ name: string; dev?: boolean }>\n) {\n return Promise.all(\n packages.map(async pkg => installPackage(context, pkg.name, pkg.dev))\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,eAAsB,eACpB,SACA,aACA,MAAM,OACN;CACA,IACE,CAAE,MAAM,gBAAgB,eAAe,WAAW,GAAG,EACnD,KAAK,QAAQ,OAAO,KACtB,CAAC,GAED,IAAI,QAAQ,OAAO,aAAa;EAC9B,QAAQ,KACN,gBAAgB,YAAY,wDAC9B;EAEA,MAAM,SAAS,MAAM,QAAQ,aAAa;GACxC,KAAK,QAAQ,OAAO;GACpB;EACF,CAAC;EACD,IAAI,SAAS,OAAO,QAAQ,KAAK,OAAO,WAAW,GAAG;GACpD,QAAQ,MAAM,OAAO,MAAM;GAC3B,MAAM,IAAI,MACR,mDAAmD,YAAY,EACjE;EACF;CACF,OACE,QAAQ,KACN,gBAAgB,YAAY,4GAC9B;MAEG,IACL,kBAAkB,WAAW,KAC7B,CAAC,QAAQ,IAAI,+BAOb;MAAI,CAAC,MALoB,iBACvB,eAAe,WAAW,GAC1B,kBAAkB,WAAW,GAC7B,QAAQ,OAAO,IACjB,GACiB;GACf,MAAM,iBAAiB,MAAM,kBAC3B,eAAe,WAAW,GAC1B,EACE,KAAK,QAAQ,OAAO,KACtB,CACF;GACA,IACE,CAAC,gBAAgB,QAAQ,WAAW,UAAU,KAC9C,CAAC,gBAAgB,QAAQ,WAAW,YAAY,GAEhD,QAAQ,KACN,gBAAgB,eAAe,WAAW,EAAE,yDAAyD,kBACnG,WACF,EAAE,uBAAuB,gBAAgB,WAAW,YAAY,2JAClE;EAEJ;;AAEJ;;;;;;;AAQA,eAAsB,gBACpB,SACA,UACA;CACA,OAAO,QAAQ,IACb,SAAS,IAAI,OAAM,QAAO,eAAe,SAAS,IAAI,MAAM,IAAI,GAAG,CAAC,CACtE;AACF"}
1
+ {"version":3,"file":"install.mjs","names":[],"sources":["../../src/plugin-utils/install.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Context } from \"@powerlines/core\";\nimport { install } from \"@stryke/fs/install\";\nimport {\n doesPackageMatch,\n getPackageListing,\n isPackageListed\n} from \"@stryke/fs/package-fns\";\nimport {\n getPackageName,\n getPackageVersion,\n hasPackageVersion\n} from \"@stryke/string-format/package\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\n\n/**\n * Installs a package if it is not already installed.\n *\n * @param context - The resolved options\n * @param packageName - The name of the package to install\n * @param dev - Whether to install the package as a dev dependency\n */\nexport async function installPackage(\n context: Context,\n packageName: string,\n dev = false\n) {\n if (\n !(await isPackageListed(getPackageName(packageName), {\n cwd: context.config.root\n }))\n ) {\n if (context.config.autoInstall) {\n context.warn(\n `The package \"${packageName}\" is not installed. It will be installed automatically.`\n );\n\n const result = await install(packageName, {\n cwd: context.config.root,\n dev\n });\n if (isNumber(result.exitCode) && result.exitCode > 0) {\n context.error(result.stderr);\n throw new Error(\n `An error occurred while installing the package \"${packageName}\"`\n );\n }\n } else {\n context.warn(\n `The package \"${packageName}\" is not installed. Since the \"autoInstall\" option is set to false, it will not be installed automatically.`\n );\n }\n } else if (\n hasPackageVersion(packageName) &&\n !process.env.POWERLINES_SKIP_VERSION_CHECK\n ) {\n const isMatching = await doesPackageMatch(\n getPackageName(packageName),\n getPackageVersion(packageName)!,\n context.config.root\n );\n if (!isMatching) {\n const packageListing = await getPackageListing(\n getPackageName(packageName),\n {\n cwd: context.config.root\n }\n );\n if (\n !packageListing?.version.startsWith(\"catalog:\") &&\n !packageListing?.version.startsWith(\"workspace:\")\n ) {\n context.warn(\n `The package \"${getPackageName(packageName)}\" is installed but does not match the expected version ${getPackageVersion(\n packageName\n )} (installed version: ${packageListing?.version || \"<Unknown>\"}). Please ensure this is intentional before proceeding. Note: You can skip this validation with the \"STORM_STACK_SKIP_VERSION_CHECK\" environment variable.`\n );\n }\n }\n }\n}\n\n/**\n * Installs a package if it is not already installed.\n *\n * @param context - The resolved options\n * @param packages - The list of packages to install\n */\nexport async function installPackages(\n context: Context,\n packages: Array<{ name: string; dev?: boolean }>\n) {\n return Promise.all(\n packages.map(async pkg => installPackage(context, pkg.name, pkg.dev))\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,eAAsB,eACpB,SACA,aACA,MAAM,OACN;CACA,IACE,CAAE,MAAM,gBAAgB,eAAe,WAAW,GAAG,EACnD,KAAK,QAAQ,OAAO,KACtB,CAAC,GAED,IAAI,QAAQ,OAAO,aAAa;EAC9B,QAAQ,KACN,gBAAgB,YAAY,wDAC9B;EAEA,MAAM,SAAS,MAAM,QAAQ,aAAa;GACxC,KAAK,QAAQ,OAAO;GACpB;EACF,CAAC;EACD,IAAI,SAAS,OAAO,QAAQ,KAAK,OAAO,WAAW,GAAG;GACpD,QAAQ,MAAM,OAAO,MAAM;GAC3B,MAAM,IAAI,MACR,mDAAmD,YAAY,EACjE;EACF;CACF,OACE,QAAQ,KACN,gBAAgB,YAAY,4GAC9B;MAEG,IACL,kBAAkB,WAAW,KAC7B,CAAC,QAAQ,IAAI,+BAOb;MAAI,CAAC,MALoB,iBACvB,eAAe,WAAW,GAC1B,kBAAkB,WAAW,GAC7B,QAAQ,OAAO,IACjB,GACiB;GACf,MAAM,iBAAiB,MAAM,kBAC3B,eAAe,WAAW,GAC1B,EACE,KAAK,QAAQ,OAAO,KACtB,CACF;GACA,IACE,CAAC,gBAAgB,QAAQ,WAAW,UAAU,KAC9C,CAAC,gBAAgB,QAAQ,WAAW,YAAY,GAEhD,QAAQ,KACN,gBAAgB,eAAe,WAAW,EAAE,yDAAyD,kBACnG,WACF,EAAE,uBAAuB,gBAAgB,WAAW,YAAY,2JAClE;EAEJ;;AAEJ;;;;;;;AAQA,eAAsB,gBACpB,SACA,UACA;CACA,OAAO,QAAQ,IACb,SAAS,IAAI,OAAM,QAAO,eAAe,SAAS,IAAI,MAAM,IAAI,GAAG,CAAC,CACtE;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"logging.mjs","names":["defu"],"sources":["../../src/plugin-utils/logging.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { RequiredKeys } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport chalk, { ChalkInstance } from \"chalk\";\nimport { defu } from \"defu\";\nimport { DEFAULT_ENVIRONMENT } from \"../constants/environments\";\nimport {\n DEFAULT_DEVELOPMENT_LOG_LEVEL,\n DEFAULT_PRODUCTION_LOG_LEVEL,\n DEFAULT_TEST_LOG_LEVEL,\n LOG_CATEGORIES_ARRAY,\n LOG_LEVELS,\n LogCategories,\n LogLevels\n} from \"../constants/log-level\";\nimport { Mode } from \"../types/config\";\nimport { UnresolvedContext } from \"../types/context\";\nimport type {\n CustomLogger,\n CustomLoggerMessage,\n LogCategory,\n LogFn,\n LogFnMeta,\n LogFnOptions,\n Logger,\n LoggerMessage,\n LoggerOptions,\n LogLevel,\n LogLevelResolvedConfig,\n LogLevelUserConfig,\n LogMeta\n} from \"../types/logging\";\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevel - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(logLevel: string): boolean;\n\n/**\n * Determines if the provided context is considered verbose (debug or trace).\n *\n * @param context - The context to check, which contains the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(context: UnresolvedContext): boolean;\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevelOrContext - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(\n logLevelOrContext: string | UnresolvedContext\n): boolean {\n const level = isString(logLevelOrContext)\n ? logLevelOrContext\n : logLevelOrContext.config.logLevel;\n\n return level === \"debug\" || level === \"trace\";\n}\n\n/**\n * Resolves the log level configuration based on the provided log level and mode, returning a complete LogLevelResolvedConfig object that specifies the log level for each log category.\n *\n * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.\n * @param mode - The current mode of the application (e.g., \"development\", \"test\", \"production\"), which determines the default log levels.\n * @returns A LogLevelResolvedConfig object specifying the log level for each log category.\n */\nexport function resolveLogLevel(\n logLevel?: LogLevelUserConfig,\n mode?: Mode\n): LogLevelResolvedConfig {\n if (logLevel === \"trace\") {\n return {\n general: \"trace\",\n fs: \"trace\",\n performance: \"trace\",\n communication: \"trace\",\n plugins: \"trace\",\n hooks: \"trace\",\n env: \"trace\",\n rpc: \"trace\",\n schema: \"trace\",\n config: \"trace\",\n babel: \"trace\"\n };\n } else if (logLevel === \"silent\") {\n return {\n general: \"silent\",\n fs: \"silent\",\n performance: \"silent\",\n communication: \"silent\",\n plugins: \"silent\",\n hooks: \"silent\",\n env: \"silent\",\n rpc: \"silent\",\n schema: \"silent\",\n config: \"silent\",\n babel: \"silent\"\n };\n }\n\n let defaultLogLevel: LogLevelResolvedConfig;\n if (mode === \"development\") {\n defaultLogLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;\n } else if (mode === \"test\") {\n defaultLogLevel = DEFAULT_TEST_LOG_LEVEL;\n } else {\n defaultLogLevel = DEFAULT_PRODUCTION_LOG_LEVEL;\n }\n\n if (isSetString(logLevel)) {\n return {\n general: logLevel,\n fs: defaultLogLevel.fs,\n performance: logLevel,\n communication: defaultLogLevel.communication,\n plugins: logLevel,\n hooks: logLevel,\n env: defaultLogLevel.env,\n rpc: defaultLogLevel.rpc,\n schema: defaultLogLevel.schema,\n config: defaultLogLevel.config,\n babel: logLevel\n };\n } else if (isSetObject(logLevel)) {\n if (\n Object.values(logLevel).filter(level => isSetString(level)).length ===\n LOG_CATEGORIES_ARRAY.length\n ) {\n return logLevel as LogLevelResolvedConfig;\n }\n\n return defu(logLevel, defaultLogLevel) as LogLevelResolvedConfig;\n }\n\n return defaultLogLevel;\n}\n\nconst colors = [\n chalk.green,\n chalk.greenBright,\n chalk.red,\n chalk.redBright,\n chalk.cyan,\n chalk.cyanBright,\n chalk.yellow,\n chalk.yellowBright,\n chalk.magenta,\n chalk.magentaBright\n] as const;\n\nconst BRAND_COLOR = getColor(\"brand\");\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const getTextColor = (text: string): ChalkInstance => {\n let code = 0;\n for (let i = 0; i < text.length; ++i) {\n code += text.charCodeAt(i);\n }\n\n return colors[code % colors.length] ?? chalk.cyanBright;\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorText = (text: string): string => {\n const title = titleCase(text);\n\n return getTextColor(title)(title);\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorBackground = (text: string): string => {\n const title = titleCase(text);\n\n return chalk.inverse(getTextColor(title)(` ${title} `));\n};\n\nexport const consoleLog = (meta: LogMeta, ...args: string[]) =>\n getLogFn(\n getLogLevel(\n meta.category === LogCategories.PERFORMANCE ? \"performance\" : meta.type\n ),\n {\n logLevel: \"all\"\n }\n )(\n `${meta.name ? chalk.bold.hex(BRAND_COLOR)(kebabCase(meta.name)) : \"\"}${meta.name ? chalk.grey(\" > \") : \"\"}${\n meta.command\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.command)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.environment && kebabCase(meta.environment) !== DEFAULT_ENVIRONMENT\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.environment)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.plugin\n ? `${chalk.bold.hex(BRAND_COLOR)(meta.plugin)}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.source\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.source)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.category &&\n meta.category !== LogCategories.GENERAL &&\n meta.category !== LogCategories.PERFORMANCE\n ? `${colorBackground(kebabCase(meta.category))} `\n : \"\"\n }${args.join(\" \")} `.trim()\n );\n\nexport function isValidLogLevel(logLevel: LogLevel, type: LogLevel): boolean {\n if (logLevel === LogLevels.SILENT) {\n return false;\n }\n\n return LOG_LEVELS.indexOf(logLevel) >= LOG_LEVELS.indexOf(type);\n}\n\nexport function isValidLogLevelConfig(\n type: LogLevel,\n logLevel: LogLevelResolvedConfig,\n category: LogCategory = LogCategories.GENERAL\n): boolean {\n return isValidLogLevel(logLevel[category], type);\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.\n * @returns A logging function.\n */\nexport const createLogFn = (name: string, options: LogFnOptions): LogFn => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (meta: LogFnMeta | LogLevel, ...args: string[]) => {\n const logMeta = isSetObject(meta)\n ? {\n logId: uuid(),\n timestamp: Date.now(),\n category: LogCategories.GENERAL,\n ...options,\n ...meta,\n name\n }\n : {\n logId: uuid(),\n timestamp: Date.now(),\n category: LogCategories.GENERAL,\n ...options,\n type: meta,\n name\n };\n\n if (\n logMeta.$$ipc ||\n isValidLogLevelConfig(\n logMeta.type,\n logLevel,\n logMeta.category ? logMeta.category : LogCategories.GENERAL\n )\n ) {\n consoleLog(logMeta, ...args);\n }\n };\n};\n\nconst validateLogger = (\n type: LogLevel,\n name: string | undefined,\n options: LoggerOptions,\n callback: (message: LoggerMessage) => void\n) => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (message: string | LoggerMessage | Error) => {\n const params = isSetString(message)\n ? {\n name,\n plugin: options.plugin,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...options\n },\n message\n }\n : message instanceof Error || message.error\n ? {\n name,\n plugin: options.plugin,\n message: `${\n (message instanceof Error ? message : message.error)?.message\n ? (message instanceof Error ? message : message.error)?.name\n ? `[${\n (message instanceof Error ? message : message.error)?.name\n }]: ${message.message || (message instanceof Error ? message : message.error)?.message}`\n : message.message ||\n (message instanceof Error ? message : message.error)\n ?.message\n : message.message\n ? message.message\n : JSON.stringify(message)\n }${\n (message instanceof Error ? message : message.error)?.stack\n ? `\nStack Trace: ${(message instanceof Error ? message : message.error)?.stack}`\n : \"\"\n }`,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...options\n }\n }\n : {\n name,\n plugin: options.plugin,\n ...message,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n plugin: message.plugin,\n ...options,\n ...message.meta\n }\n };\n\n if (\n params.meta.$$ipc ||\n isValidLogLevelConfig(type, logLevel, params.meta.category)\n ) {\n callback(params);\n }\n };\n};\n\nconst validateCustomLogger = (\n type: LogLevel,\n name: string | undefined,\n options: LoggerOptions,\n callback?: (message: string | LoggerMessage) => void,\n customCallback?: (message: CustomLoggerMessage) => void\n) => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (message: string | LoggerMessage) => {\n const params = isSetString(message)\n ? {\n name,\n plugin: options.plugin,\n meta: {\n category: LogCategories.GENERAL,\n ...options,\n type,\n name,\n logId: uuid(),\n timestamp: Date.now()\n },\n message\n }\n : {\n name,\n plugin: options.plugin,\n ...message,\n meta: {\n category: LogCategories.GENERAL,\n ...options,\n type,\n name,\n logId: uuid(),\n timestamp: Date.now(),\n plugin: message.plugin,\n ...message.meta\n }\n };\n\n if (\n params.meta.$$ipc ||\n isValidLogLevelConfig(type, logLevel, params.meta.category)\n ) {\n callback?.(params);\n customCallback?.(params);\n }\n };\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.\n */\nexport const withLogger = (logger: Logger, secondaryLogger: Logger): Logger => {\n const options = { ...secondaryLogger.options, ...logger.options };\n\n const result = {\n options,\n error: validateLogger(\n \"error\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.error?.(message);\n secondaryLogger.error?.(message);\n }\n ),\n warn: validateLogger(\n \"warn\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.warn?.(message);\n secondaryLogger.warn?.(message);\n }\n ),\n info: validateLogger(\n \"info\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.info?.(message);\n secondaryLogger.info?.(message);\n }\n ),\n debug: validateLogger(\n \"debug\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.debug?.(message);\n secondaryLogger.debug?.(message);\n }\n ),\n trace: validateLogger(\n \"trace\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.trace?.(message);\n secondaryLogger.trace?.(message);\n }\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A new logger that combines the original logger's options with the custom logging function, allowing for customized logging behavior while still maintaining the original logger's configuration.\n */\nexport const withLogFn = (logger: Logger, logFn: LogFn): Logger => {\n const result = {\n options: logger.options,\n error: validateLogger(\n \"error\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.error?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"error\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n warn: validateLogger(\n \"warn\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.warn?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"warn\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n info: validateLogger(\n \"info\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.info?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"info\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n debug: validateLogger(\n \"debug\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.debug?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"debug\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n trace: validateLogger(\n \"trace\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.trace?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"trace\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.\n */\nexport const withCustomLogger = (\n logger: Logger,\n customLogger: CustomLogger\n): Logger => {\n const result = {\n options: logger.options,\n error: validateCustomLogger(\n \"error\",\n logger.options.name,\n logger.options,\n logger.error.bind(logger),\n customLogger.error?.bind(customLogger)\n ),\n warn: validateCustomLogger(\n \"warn\",\n logger.options.name,\n logger.options,\n logger.warn.bind(logger),\n customLogger.warn?.bind(customLogger)\n ),\n info: validateCustomLogger(\n \"info\",\n logger.options.name,\n logger.options,\n logger.info.bind(logger),\n customLogger.info?.bind(customLogger)\n ),\n debug: validateCustomLogger(\n \"debug\",\n logger.options.name,\n logger.options,\n logger.debug.bind(logger),\n customLogger.debug?.bind(customLogger)\n ),\n trace: validateCustomLogger(\n \"trace\",\n logger.options.name,\n logger.options,\n logger.trace.bind(logger),\n customLogger.trace?.bind(customLogger)\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\nexport const consoleLogger: LogFn = (meta: LogFnMeta, message: string) =>\n consoleLog(\n {\n type: isSetString(meta) ? meta : meta.type,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...(isSetObject(meta) ? meta : {})\n },\n message\n );\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.\n * @returns A logging function.\n */\nexport const createLogger = (\n name: string | undefined,\n options: LoggerOptions,\n callback: LogFn = consoleLogger\n): Logger => {\n const result = {\n options: { name, ...options },\n error: validateLogger(\"error\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"error\" }, data.message)\n ),\n warn: validateLogger(\"warn\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"warn\" }, data.message)\n ),\n info: validateLogger(\"info\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"info\" }, data.message)\n ),\n debug: validateLogger(\"debug\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"debug\" }, data.message)\n ),\n trace: validateLogger(\"trace\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"trace\" }, data.message)\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\n/**\n * Extend a logging function with a specific name, adding a colored badge to the log output.\n *\n * @param logFn - The original logging function to extend.\n * @param options - The overlay metadata to use for the badge in the log output.\n * @returns A new logging function that includes the badge in its output.\n */\nexport const extendLogFn = (logFn: LogFn, options: LogFnOptions): LogFn => {\n return (meta, ...args) =>\n options.source || options.category\n ? logFn(\n isSetObject(meta)\n ? { ...options, ...meta }\n : { ...options, type: meta },\n `${colorBackground(String(options.source || options.category))} ${args\n .filter(Boolean)\n .map(arg => String(arg).trim())\n .join(\" \")} `\n )\n : logFn(meta, ...args);\n};\n\n/**\n * Extend a logger with a specific name and options, adding a colored badge to the log output for each log message generated by the logger.\n *\n * @param logger - The original logger to extend.\n * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the extended logger.\n * @returns A new logger that includes the badge in its output for each log message.\n */\nexport const extendLogger = (\n logger: Logger,\n options: LoggerOptions\n): Logger => {\n const opts = { ...logger.options, ...options } as RequiredKeys<\n LoggerOptions,\n \"name\"\n >;\n\n const result = {\n options: opts,\n error: validateLogger(\"error\", opts.name, opts, logger.error.bind(logger)),\n warn: validateLogger(\"warn\", opts.name, opts, logger.warn.bind(logger)),\n info: validateLogger(\"info\", opts.name, opts, logger.info.bind(logger)),\n debug: validateLogger(\"debug\", opts.name, opts, logger.debug.bind(logger)),\n trace: validateLogger(\"trace\", opts.name, opts, logger.trace.bind(logger))\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,UACd,mBACS;CACT,MAAM,QAAQ,SAAS,iBAAiB,IACpC,oBACA,kBAAkB,OAAO;CAE7B,OAAO,UAAU,WAAW,UAAU;AACxC;;;;;;;;AASA,SAAgB,gBACd,UACA,MACwB;CACxB,IAAI,aAAa,SACf,OAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,eAAe;EACf,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;MACK,IAAI,aAAa,UACtB,OAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,eAAe;EACf,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CAGF,IAAI;CACJ,IAAI,SAAS,eACX,kBAAkB;MACb,IAAI,SAAS,QAClB,kBAAkB;MAElB,kBAAkB;CAGpB,IAAI,YAAY,QAAQ,GACtB,OAAO;EACL,SAAS;EACT,IAAI,gBAAgB;EACpB,aAAa;EACb,eAAe,gBAAgB;EAC/B,SAAS;EACT,OAAO;EACP,KAAK,gBAAgB;EACrB,KAA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AAM,KAAK,MAAM,CAAC;EACzE,OAAO,eAAe,SAAS,KAAK,MAAM,MAAM,OAAO,MAAM,KAAK,MAAM,CAAC;CAC3E;CAEA,OAAO,OAAO,MAAgB,YAAoC;EAChE,QAAQ,MAAR;GACE,KAAK;IACH,OAAO,MAAM,OAAO;IACpB;GACF,KAAK;IACH,OAAO,KAAK,OAAO;IACnB;GACF,KAAK;IACH,OAAO,KAAK,OAAO;IACnB;GACF,KAAK;IACH,OAAO,MAAM,OAAO;IACpB;GACF,KAAK;IACH,OAAO,MAAM,OAAO;IACpB;GACF,KAAK,UACH;GACF;IACE,OAAO,KAAK,OAAO;IACnB;EACJ;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"logging.mjs","names":["defu"],"sources":["../../src/plugin-utils/logging.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { RequiredKeys } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport chalk, { ChalkInstance } from \"chalk\";\nimport { defu } from \"defu\";\nimport { DEFAULT_ENVIRONMENT } from \"../constants/environments\";\nimport {\n DEFAULT_DEVELOPMENT_LOG_LEVEL,\n DEFAULT_PRODUCTION_LOG_LEVEL,\n DEFAULT_TEST_LOG_LEVEL,\n LOG_CATEGORIES_ARRAY,\n LOG_LEVELS,\n LogCategories,\n LogLevels\n} from \"../constants/log-level\";\nimport { Mode } from \"../types/config\";\nimport { UnresolvedContext } from \"../types/context\";\nimport type {\n CustomLogger,\n CustomLoggerMessage,\n LogCategory,\n LogFn,\n LogFnMeta,\n LogFnOptions,\n Logger,\n LoggerMessage,\n LoggerOptions,\n LogLevel,\n LogLevelResolvedConfig,\n LogLevelUserConfig,\n LogMeta\n} from \"../types/logging\";\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevel - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(logLevel: string): boolean;\n\n/**\n * Determines if the provided context is considered verbose (debug or trace).\n *\n * @param context - The context to check, which contains the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(context: UnresolvedContext): boolean;\n\n/**\n * Determines if the provided log level is considered verbose (debug or trace).\n *\n * @param logLevelOrContext - The log level to check, which can be a string or an UnresolvedContext containing the log level in its config.\n * @returns True if the log level is \"debug\" or \"trace\", false otherwise.\n */\nexport function isVerbose(\n logLevelOrContext: string | UnresolvedContext\n): boolean {\n const level = isString(logLevelOrContext)\n ? logLevelOrContext\n : logLevelOrContext.config.logLevel;\n\n return level === \"debug\" || level === \"trace\";\n}\n\n/**\n * Resolves the log level configuration based on the provided log level and mode, returning a complete LogLevelResolvedConfig object that specifies the log level for each log category.\n *\n * @param logLevel - The user-provided log level configuration, which can be a string or an object specifying log levels for each category.\n * @param mode - The current mode of the application (e.g., \"development\", \"test\", \"production\"), which determines the default log levels.\n * @returns A LogLevelResolvedConfig object specifying the log level for each log category.\n */\nexport function resolveLogLevel(\n logLevel?: LogLevelUserConfig,\n mode?: Mode\n): LogLevelResolvedConfig {\n if (logLevel === \"trace\") {\n return {\n general: \"trace\",\n fs: \"trace\",\n performance: \"trace\",\n communication: \"trace\",\n plugins: \"trace\",\n hooks: \"trace\",\n env: \"trace\",\n rpc: \"trace\",\n schema: \"trace\",\n config: \"trace\",\n babel: \"trace\"\n };\n } else if (logLevel === \"silent\") {\n return {\n general: \"silent\",\n fs: \"silent\",\n performance: \"silent\",\n communication: \"silent\",\n plugins: \"silent\",\n hooks: \"silent\",\n env: \"silent\",\n rpc: \"silent\",\n schema: \"silent\",\n config: \"silent\",\n babel: \"silent\"\n };\n }\n\n let defaultLogLevel: LogLevelResolvedConfig;\n if (mode === \"development\") {\n defaultLogLevel = DEFAULT_DEVELOPMENT_LOG_LEVEL;\n } else if (mode === \"test\") {\n defaultLogLevel = DEFAULT_TEST_LOG_LEVEL;\n } else {\n defaultLogLevel = DEFAULT_PRODUCTION_LOG_LEVEL;\n }\n\n if (isSetString(logLevel)) {\n return {\n general: logLevel,\n fs: defaultLogLevel.fs,\n performance: logLevel,\n communication: defaultLogLevel.communication,\n plugins: logLevel,\n hooks: logLevel,\n env: defaultLogLevel.env,\n rpc: defaultLogLevel.rpc,\n schema: defaultLogLevel.schema,\n config: defaultLogLevel.config,\n babel: logLevel\n };\n } else if (isSetObject(logLevel)) {\n if (\n Object.values(logLevel).filter(level => isSetString(level)).length ===\n LOG_CATEGORIES_ARRAY.length\n ) {\n return logLevel as LogLevelResolvedConfig;\n }\n\n return defu(logLevel, defaultLogLevel) as LogLevelResolvedConfig;\n }\n\n return defaultLogLevel;\n}\n\nconst colors = [\n chalk.green,\n chalk.greenBright,\n chalk.red,\n chalk.redBright,\n chalk.cyan,\n chalk.cyanBright,\n chalk.yellow,\n chalk.yellowBright,\n chalk.magenta,\n chalk.magentaBright\n] as const;\n\nconst BRAND_COLOR = getColor(\"brand\");\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const getTextColor = (text: string): ChalkInstance => {\n let code = 0;\n for (let i = 0; i < text.length; ++i) {\n code += text.charCodeAt(i);\n }\n\n return colors[code % colors.length] ?? chalk.cyanBright;\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorText = (text: string): string => {\n const title = titleCase(text);\n\n return getTextColor(title)(title);\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorBackground = (text: string): string => {\n const title = titleCase(text);\n\n return chalk.inverse(getTextColor(title)(` ${title} `));\n};\n\nexport const consoleLog = (meta: LogMeta, ...args: string[]) =>\n getLogFn(\n getLogLevel(\n meta.category === LogCategories.PERFORMANCE ? \"performance\" : meta.type\n ),\n {\n logLevel: \"all\"\n }\n )(\n `${meta.name ? chalk.bold.hex(BRAND_COLOR)(kebabCase(meta.name)) : \"\"}${meta.name ? chalk.grey(\" > \") : \"\"}${\n meta.command\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.command)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.environment && kebabCase(meta.environment) !== DEFAULT_ENVIRONMENT\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.environment)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.plugin\n ? `${chalk.bold.hex(BRAND_COLOR)(meta.plugin)}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.source\n ? `${chalk.bold.hex(BRAND_COLOR)(\n kebabCase(meta.source)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n meta.category &&\n meta.category !== LogCategories.GENERAL &&\n meta.category !== LogCategories.PERFORMANCE\n ? `${colorBackground(kebabCase(meta.category))} `\n : \"\"\n }${args.join(\" \")} `.trim()\n );\n\nexport function isValidLogLevel(logLevel: LogLevel, type: LogLevel): boolean {\n if (logLevel === LogLevels.SILENT) {\n return false;\n }\n\n return LOG_LEVELS.indexOf(logLevel) >= LOG_LEVELS.indexOf(type);\n}\n\nexport function isValidLogLevelConfig(\n type: LogLevel,\n logLevel: LogLevelResolvedConfig,\n category: LogCategory = LogCategories.GENERAL\n): boolean {\n return isValidLogLevel(logLevel[category], type);\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.\n * @returns A logging function.\n */\nexport const createLogFn = (name: string, options: LogFnOptions): LogFn => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (meta: LogFnMeta | LogLevel, ...args: string[]) => {\n const logMeta = isSetObject(meta)\n ? {\n logId: uuid(),\n timestamp: Date.now(),\n category: LogCategories.GENERAL,\n ...options,\n ...meta,\n name\n }\n : {\n logId: uuid(),\n timestamp: Date.now(),\n category: LogCategories.GENERAL,\n ...options,\n type: meta,\n name\n };\n\n if (\n logMeta.$$ipc ||\n isValidLogLevelConfig(\n logMeta.type,\n logLevel,\n logMeta.category ? logMeta.category : LogCategories.GENERAL\n )\n ) {\n consoleLog(logMeta, ...args);\n }\n };\n};\n\nconst validateLogger = (\n type: LogLevel,\n name: string | undefined,\n options: LoggerOptions,\n callback: (message: LoggerMessage) => void\n) => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (message: string | LoggerMessage | Error) => {\n const params = isSetString(message)\n ? {\n name,\n plugin: options.plugin,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...options\n },\n message\n }\n : message instanceof Error || message.error\n ? {\n name,\n plugin: options.plugin,\n message: `${\n (message instanceof Error ? message : message.error)?.message\n ? (message instanceof Error ? message : message.error)?.name\n ? `[${\n (message instanceof Error ? message : message.error)?.name\n }]: ${message.message || (message instanceof Error ? message : message.error)?.message}`\n : message.message ||\n (message instanceof Error ? message : message.error)\n ?.message\n : message.message\n ? message.message\n : JSON.stringify(message)\n }${\n (message instanceof Error ? message : message.error)?.stack\n ? `\nStack Trace: ${(message instanceof Error ? message : message.error)?.stack}`\n : \"\"\n }`,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...options\n }\n }\n : {\n name,\n plugin: options.plugin,\n ...message,\n meta: {\n type,\n name,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n plugin: message.plugin,\n ...options,\n ...message.meta\n }\n };\n\n if (\n params.meta.$$ipc ||\n isValidLogLevelConfig(type, logLevel, params.meta.category)\n ) {\n callback(params);\n }\n };\n};\n\nconst validateCustomLogger = (\n type: LogLevel,\n name: string | undefined,\n options: LoggerOptions,\n callback?: (message: string | LoggerMessage) => void,\n customCallback?: (message: CustomLoggerMessage) => void\n) => {\n const logLevel = resolveLogLevel(options.logLevel, options.mode);\n\n return (message: string | LoggerMessage) => {\n const params = isSetString(message)\n ? {\n name,\n plugin: options.plugin,\n meta: {\n category: LogCategories.GENERAL,\n ...options,\n type,\n name,\n logId: uuid(),\n timestamp: Date.now()\n },\n message\n }\n : {\n name,\n plugin: options.plugin,\n ...message,\n meta: {\n category: LogCategories.GENERAL,\n ...options,\n type,\n name,\n logId: uuid(),\n timestamp: Date.now(),\n plugin: message.plugin,\n ...message.meta\n }\n };\n\n if (\n params.meta.$$ipc ||\n isValidLogLevelConfig(type, logLevel, params.meta.category)\n ) {\n callback?.(params);\n customCallback?.(params);\n }\n };\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.\n */\nexport const withLogger = (logger: Logger, secondaryLogger: Logger): Logger => {\n const options = { ...secondaryLogger.options, ...logger.options };\n\n const result = {\n options,\n error: validateLogger(\n \"error\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.error?.(message);\n secondaryLogger.error?.(message);\n }\n ),\n warn: validateLogger(\n \"warn\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.warn?.(message);\n secondaryLogger.warn?.(message);\n }\n ),\n info: validateLogger(\n \"info\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.info?.(message);\n secondaryLogger.info?.(message);\n }\n ),\n debug: validateLogger(\n \"debug\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.debug?.(message);\n secondaryLogger.debug?.(message);\n }\n ),\n trace: validateLogger(\n \"trace\",\n options.name,\n options,\n (message: LoggerMessage) => {\n logger.trace?.(message);\n secondaryLogger.trace?.(message);\n }\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param logFn - The custom logging function to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A new logger that combines the original logger's options with the custom logging function, allowing for customized logging behavior while still maintaining the original logger's configuration.\n */\nexport const withLogFn = (logger: Logger, logFn: LogFn): Logger => {\n const result = {\n options: logger.options,\n error: validateLogger(\n \"error\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.error?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"error\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n warn: validateLogger(\n \"warn\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.warn?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"warn\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n info: validateLogger(\n \"info\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.info?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"info\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n debug: validateLogger(\n \"debug\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.debug?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"debug\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n ),\n trace: validateLogger(\n \"trace\",\n logger.options.name,\n logger.options,\n (msg: LoggerMessage) => {\n logger.trace?.(msg);\n logFn(\n {\n category: LogCategories.GENERAL,\n ...logger.options,\n type: \"trace\",\n logId: uuid(),\n timestamp: Date.now(),\n ...msg.meta\n },\n msg.message\n );\n }\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param logger - The original logger to wrap with the custom logger.\n * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.\n * @returns A new logger that combines the original logger's options with the custom logger's methods, allowing for customized logging behavior while still maintaining the original logger's configuration.\n */\nexport const withCustomLogger = (\n logger: Logger,\n customLogger: CustomLogger\n): Logger => {\n const result = {\n options: logger.options,\n error: validateCustomLogger(\n \"error\",\n logger.options.name,\n logger.options,\n logger.error.bind(logger),\n customLogger.error?.bind(customLogger)\n ),\n warn: validateCustomLogger(\n \"warn\",\n logger.options.name,\n logger.options,\n logger.warn.bind(logger),\n customLogger.warn?.bind(customLogger)\n ),\n info: validateCustomLogger(\n \"info\",\n logger.options.name,\n logger.options,\n logger.info.bind(logger),\n customLogger.info?.bind(customLogger)\n ),\n debug: validateCustomLogger(\n \"debug\",\n logger.options.name,\n logger.options,\n logger.debug.bind(logger),\n customLogger.debug?.bind(customLogger)\n ),\n trace: validateCustomLogger(\n \"trace\",\n logger.options.name,\n logger.options,\n logger.trace.bind(logger),\n customLogger.trace?.bind(customLogger)\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\nexport const consoleLogger: LogFn = (meta: LogFnMeta, message: string) =>\n consoleLog(\n {\n type: isSetString(meta) ? meta : meta.type,\n category: LogCategories.GENERAL,\n logId: uuid(),\n timestamp: Date.now(),\n ...(isSetObject(meta) ? meta : {})\n },\n message\n );\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the logging function.\n * @returns A logging function.\n */\nexport const createLogger = (\n name: string | undefined,\n options: LoggerOptions,\n callback: LogFn = consoleLogger\n): Logger => {\n const result = {\n options: { name, ...options },\n error: validateLogger(\"error\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"error\" }, data.message)\n ),\n warn: validateLogger(\"warn\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"warn\" }, data.message)\n ),\n info: validateLogger(\"info\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"info\" }, data.message)\n ),\n debug: validateLogger(\"debug\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"debug\" }, data.message)\n ),\n trace: validateLogger(\"trace\", name, { name, ...options }, data =>\n callback({ ...data.meta, type: \"trace\" }, data.message)\n )\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n\n/**\n * Extend a logging function with a specific name, adding a colored badge to the log output.\n *\n * @param logFn - The original logging function to extend.\n * @param options - The overlay metadata to use for the badge in the log output.\n * @returns A new logging function that includes the badge in its output.\n */\nexport const extendLogFn = (logFn: LogFn, options: LogFnOptions): LogFn => {\n return (meta, ...args) =>\n options.source || options.category\n ? logFn(\n isSetObject(meta)\n ? { ...options, ...meta }\n : { ...options, type: meta },\n `${colorBackground(String(options.source || options.category))} ${args\n .filter(Boolean)\n .map(arg => String(arg).trim())\n .join(\" \")} `\n )\n : logFn(meta, ...args);\n};\n\n/**\n * Extend a logger with a specific name and options, adding a colored badge to the log output for each log message generated by the logger.\n *\n * @param logger - The original logger to extend.\n * @param options - The options to configure the logging function, including the source, command, environment, plugin, log level, custom logger, and colors. These options can be used to customize the appearance and behavior of the log messages generated by the extended logger.\n * @returns A new logger that includes the badge in its output for each log message.\n */\nexport const extendLogger = (\n logger: Logger,\n options: LoggerOptions\n): Logger => {\n const opts = { ...logger.options, ...options } as RequiredKeys<\n LoggerOptions,\n \"name\"\n >;\n\n const result = {\n options: opts,\n error: validateLogger(\"error\", opts.name, opts, logger.error.bind(logger)),\n warn: validateLogger(\"warn\", opts.name, opts, logger.warn.bind(logger)),\n info: validateLogger(\"info\", opts.name, opts, logger.info.bind(logger)),\n debug: validateLogger(\"debug\", opts.name, opts, logger.debug.bind(logger)),\n trace: validateLogger(\"trace\", opts.name, opts, logger.trace.bind(logger))\n } as Logger;\n\n result.log = (type: LogLevel, message: string | LoggerMessage) => {\n switch (type) {\n case \"error\":\n result.error(message);\n break;\n case \"warn\":\n result.warn(message);\n break;\n case \"info\":\n result.info(message);\n break;\n case \"debug\":\n result.debug(message);\n break;\n case \"trace\":\n result.trace(message);\n break;\n case \"silent\":\n break;\n default:\n result.info(message);\n break;\n }\n };\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,UACd,mBACS;CACT,MAAM,QAAQ,SAAS,iBAAiB,IACpC,oBACA,kBAAkB,OAAO;CAE7B,OAAO,UAAU,WAAW,UAAU;AACxC;;;;;;;;AASA,SAAgB,gBACd,UACA,MACwB;CACxB,IAAI,aAAa,SACf,OAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,eAAe;EACf,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;MACK,IAAI,aAAa,UACtB,OAAO;EACL,SAAS;EACT,IAAI;EACJ,aAAa;EACb,eAAe;EACf,SAAS;EACT,OAAO;EACP,KAAK;EACL,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CAGF,IAAI;CACJ,IAAI,SAAS,eACX,kBAAkB;MACb,IAAI,SAAS,QAClB,kBAAkB;MAElB,kBAAkB;CAGpB,IAAI,YAAY,QAAQ,GACtB,OAAO;EACL,SAAS;EACT,IAAI,gBAAgB;EACpB,aAAa;EACb,eAAe,gBAAgB;EAC/B,SAAS;EACT,OAAO;EACP,KAAK,gBAAgB;EACrB,KAAK,gBAAgB;EACrB,QAAQ,gBAAgB;EACxB,QAAQ,gBAAgB;EACxB,OAAO;CACT;MACK,IAAI,YAAY,QAAQ,GAAG;EAChC,IACE,OAAO,OAAO,QAAQ,CAAC,CAAC,QAAO,UAAS,YAAY,KAAK,CAAC,CAAC,CAAC,WAC5D,qBAAqB,QAErB,OAAO;EAGT,OAAOA,OAAK,UAAU,eAAe;CACvC;CAEA,OAAO;AAC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O;IACnB;GACF,KAAK;IACH,OAAO,MAAM,OAAO;IACpB;GACF,KAAK;IACH,OAAO,MAAM,OAAO;IACpB;GACF,KAAK,UACH;GACF;IACE,OAAO,KAAK,OAAO;IACnB;EACJ;CACF;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"merge.mjs","names":[],"sources":["../../src/plugin-utils/merge.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu, { createDefu } from \"defu\";\nimport type {\n PartialPlugin,\n Plugin,\n PluginContext,\n ResolvedConfig\n} from \"../types\";\nimport { getHookHandler, isPluginHook } from \"./helpers\";\n\nexport type MergeResult<\n TContext extends PluginContext,\n TPluginA extends Plugin<TContext> | PartialPlugin<TContext>,\n TPluginB extends Plugin<TContext> | PartialPlugin<TContext>\n> =\n TPluginA extends Plugin<TContext>\n ? Plugin<TContext>\n : TPluginB extends Plugin<TContext>\n ? Plugin<TContext>\n : PartialPlugin<TContext>;\n\nconst mergePlugin = createDefu((obj, key, value) => {\n if (isPluginHook(obj[key]) && isPluginHook(value)) {\n obj[key] = {\n ...obj[key],\n ...value,\n handler: async (...params: any[]) => {\n const [resultA, resultB] = await Promise.all([\n // eslint-disable-next-line ts/no-unsafe-call\n (getHookHandler(obj[key]) as any)(...params),\n // eslint-disable-next-line ts/no-unsafe-call\n (getHookHandler(value) as any)(...params)\n ]);\n\n return resultB && resultA ? defu(resultA, resultB) : resultA || resultB;\n }\n };\n return true;\n }\n\n return false;\n});\n\n/**\n * Merges two {@link Plugin | plugins} or {@link PartialPlugin | partial plugins} together.\n *\n * @param pluginA - The first {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @param pluginB - The second {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @returns The merged {@link Plugin | plugin} or {@link PartialPlugin | partial plugin}.\n */\nexport function merge<TContext extends PluginContext = PluginContext>(\n pluginA: Plugin<TContext> | PartialPlugin<TContext>,\n pluginB: Plugin<TContext> | PartialPlugin<TContext>\n): MergeResult<TContext, typeof pluginA, typeof pluginB> {\n return mergePlugin(pluginA, pluginB) as MergeResult<\n TContext,\n typeof pluginA,\n typeof pluginB\n >;\n}\n\n/**\n * Merges two configuration objects together, with special handling for string values.\n * If the value from the second object is a non-empty string, it will overwrite the value from the first object.\n *\n * @example\n * ```ts\n * const configA = { name: \"Default\", version: \"1.0.0\" };\n * const configB = { name: \"Custom\", description: \"A custom config\" };\n * const mergedConfig = mergeConfig(configA, configB);\n * // Result: { name: \"Custom\", version: \"1.0.0\", description: \"A custom config\" }\n * ```\n *\n * @param objA - The first configuration object.\n * @param objB - The second configuration object.\n * @returns The merged configuration object.\n */\nexport const mergeConfig = createDefu((obj, key, value) => {\n type TValue = (typeof obj)[typeof key];\n\n if (key === \"input\" && isSet(value)) {\n if (isString(obj[key]) && Array.isArray(value) && value.length === 0) {\n return true;\n }\n\n obj[key] = value;\n if (isSetArray(obj[key])) {\n obj[key] = getUnique(obj[key]) as TValue;\n }\n\n return true;\n }\n\n if (key === \"compatibilityDate\" && isSetString(value)) {\n obj[key] = value;\n return true;\n }\n\n if (\n (key === \"format\" || key === \"output.format\") &&\n (isSetString(value) || isSetArray(value))\n ) {\n obj[key] = value;\n if (isSetArray(obj[key])) {\n obj[key] = getUnique(obj[key]) as TValue;\n }\n\n return true;\n }\n\n if (!isSet(obj[key]) && isString(value)) {\n obj[key] = value;\n return true;\n }\n\n return false;\n}) as (...configs: unknown[]) => ResolvedConfig;\n"],"mappings":";;;;;;;;;AA2CA,MAAM,cAAc,YAAY,KAAK,KAAK,UAAU;CAClD,IAAI,aAAa,IAAI,IAAI,KAAK,aAAa,KAAK,GAAG;EACjD,IAAI,OAAO;GACT,GAAG,IAAI;GACP,GAAG;GACH,SAAS,OAAO,GAAG,WAAkB;IACnC,MAAM,CAAC,SAAS,WAAW,MAAM,QAAQ,IAAI,CAE1C,eAAe,IAAI,IAAI,CAAC,CAAS,GAAG,MAAM,GAE1C,eAAe,KAAK,CAAC,CAAS,GAAG,MAAM,CAC1C,CAAC;IAED,OAAO,WAAW,UAAU,KAAK,SAAS,OAAO,IAAI,WAAW;GAClE;EACF;EACA,OAAO;CACT;CAEA,OAAO;AACT,CAAC;;;;;;;;AASD,SAAgB,MACd,SACA,SACuD;CACvD,OAAO,YAAY,SAAS,OAAO;AAKrC;;;;;;;;;;;;;;;;;AAkBA,MAAa,cAAc,YAAY,KAAK,KAAK,UAAU;CAGzD,IAAI,QAAQ,WAAW,MAAM,KAAK,GAAG;EACnC,IAAI,SAAS,IAAI,IAAI,KAAK,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GACjE,OAAO;EAGT,IAAI,OAAO;EACX,IAAI,WAAW,IAAI,IAAI,GACrB,IAAI,OAAO,UAAU,IAAI,IAAI;EAG/B,OAAO;CACT;CAEA,IAAI,QAAQ,uBAAuB,YAAY,KAAK,GAAG;EACrD,IAAI,OAAO;EACX,OAAO;CACT;CAEA,KACG,QAAQ,YAAY,QAAQ,qBAC5B,YAAY,KAAK,KAAK,WAAW,KAAK,IACvC;EACA,IAAI,OAAO;EACX,IAAI,WAAW,IAAI,IAAI,GACrB,IAAI,OAAO,UAAU,IAAI,IAAI;EAG/B,OAAO;CACT;CAEA,IAAI,CAAC,MAAM,IAAI,IAAI,KAAK,SAAS,KAAK,GAAG;EACvC,IAAI,OAAO;EACX,OAAO;CACT;CAEA,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"merge.mjs","names":[],"sources":["../../src/plugin-utils/merge.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport defu, { createDefu } from \"defu\";\nimport type {\n PartialPlugin,\n Plugin,\n PluginContext,\n ResolvedConfig\n} from \"../types\";\nimport { getHookHandler, isPluginHook } from \"./helpers\";\n\nexport type MergeResult<\n TContext extends PluginContext,\n TPluginA extends Plugin<TContext> | PartialPlugin<TContext>,\n TPluginB extends Plugin<TContext> | PartialPlugin<TContext>\n> =\n TPluginA extends Plugin<TContext>\n ? Plugin<TContext>\n : TPluginB extends Plugin<TContext>\n ? Plugin<TContext>\n : PartialPlugin<TContext>;\n\nconst mergePlugin = createDefu((obj, key, value) => {\n if (isPluginHook(obj[key]) && isPluginHook(value)) {\n obj[key] = {\n ...obj[key],\n ...value,\n handler: async (...params: any[]) => {\n const [resultA, resultB] = await Promise.all([\n // eslint-disable-next-line ts/no-unsafe-call\n (getHookHandler(obj[key]) as any)(...params),\n // eslint-disable-next-line ts/no-unsafe-call\n (getHookHandler(value) as any)(...params)\n ]);\n\n return resultB && resultA ? defu(resultA, resultB) : resultA || resultB;\n }\n };\n return true;\n }\n\n return false;\n});\n\n/**\n * Merges two {@link Plugin | plugins} or {@link PartialPlugin | partial plugins} together.\n *\n * @param pluginA - The first {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @param pluginB - The second {@link Plugin | plugin} or {@link PartialPlugin | partial plugin} to merge.\n * @returns The merged {@link Plugin | plugin} or {@link PartialPlugin | partial plugin}.\n */\nexport function merge<TContext extends PluginContext = PluginContext>(\n pluginA: Plugin<TContext> | PartialPlugin<TContext>,\n pluginB: Plugin<TContext> | PartialPlugin<TContext>\n): MergeResult<TContext, typeof pluginA, typeof pluginB> {\n return mergePlugin(pluginA, pluginB) as MergeResult<\n TContext,\n typeof pluginA,\n typeof pluginB\n >;\n}\n\n/**\n * Merges two configuration objects together, with special handling for string values.\n * If the value from the second object is a non-empty string, it will overwrite the value from the first object.\n *\n * @example\n * ```ts\n * const configA = { name: \"Default\", version: \"1.0.0\" };\n * const configB = { name: \"Custom\", description: \"A custom config\" };\n * const mergedConfig = mergeConfig(configA, configB);\n * // Result: { name: \"Custom\", version: \"1.0.0\", description: \"A custom config\" }\n * ```\n *\n * @param objA - The first configuration object.\n * @param objB - The second configuration object.\n * @returns The merged configuration object.\n */\nexport const mergeConfig = createDefu((obj, key, value) => {\n type TValue = (typeof obj)[typeof key];\n\n if (key === \"input\" && isSet(value)) {\n if (isString(obj[key]) && Array.isArray(value) && value.length === 0) {\n return true;\n }\n\n obj[key] = value;\n if (isSetArray(obj[key])) {\n obj[key] = getUnique(obj[key]) as TValue;\n }\n\n return true;\n }\n\n if (key === \"compatibilityDate\" && isSetString(value)) {\n obj[key] = value;\n return true;\n }\n\n if (\n (key === \"format\" || key === \"output.format\") &&\n (isSetString(value) || isSetArray(value))\n ) {\n obj[key] = value;\n if (isSetArray(obj[key])) {\n obj[key] = getUnique(obj[key]) as TValue;\n }\n\n return true;\n }\n\n if (!isSet(obj[key]) && isString(value)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CAEA,OAAO;AACT,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"modules.mjs","names":[],"sources":["../../src/plugin-utils/modules.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Context } from \"../types/context\";\n\n/**\n * Determine if a module ID is a built-in Powerlines module ID.\n *\n * @param context - The Powerlines context.\n * @param moduleName - The name of the module to check.\n * @returns `true` if the module is a built-in module, otherwise `false`.\n */\nexport function isBuiltinModule(context: Context, moduleName: string): boolean {\n const prefix: string = context.config?.framework?.name || \"powerlines\";\n\n return (\n moduleName.startsWith(`${prefix.replace(/:$/, \"\")}:`) ||\n Object.keys(context.fs.metadata)\n .filter(key => context.fs.metadata[key]?.type === \"builtin\")\n .includes(moduleName)\n );\n}\n"],"mappings":";;;;;;;;AA2BA,SAAgB,gBAAgB,SAAkB,YAA6B;CAC7E,MAAM,SAAiB,QAAQ,QAAQ,WAAW,QAAQ;CAE1D,OACE,WAAW,WAAW,GAAG,OAAO,QAAQ,MAAM,EAAE,EAAE,EAAE,KACpD,OAAO,KAAK,QAAQ,GAAG,QAAQ,CAAC,CAC7B,QAAO,QAAO,QAAQ,GAAG,SAAS,IAAI,EAAE,SAAS,SAAS,CAAC,CAC3D,SAAS,UAAU;AAE1B"}
1
+ {"version":3,"file":"modules.mjs","names":[],"sources":["../../src/plugin-utils/modules.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Context } from \"../types/context\";\n\n/**\n * Determine if a module ID is a built-in Powerlines module ID.\n *\n * @param context - The Powerlines context.\n * @param moduleName - The name of the module to check.\n * @returns `true` if the module is a built-in module, otherwise `false`.\n */\nexport function isBuiltinModule(context: Context, moduleName: string): boolean {\n const prefix: string = context.config?.framework?.name || \"powerlines\";\n\n return (\n moduleName.startsWith(`${prefix.replace(/:$/, \"\")}:`) ||\n Object.keys(context.fs.metadata)\n .filter(key => context.fs.metadata[key]?.type === \"builtin\")\n .includes(moduleName)\n );\n}\n"],"mappings":";;;;;;;;AA2BA,SAAgB,gBAAgB,SAAkB,YAA6B;CAC7E,MAAM,SAAiB,QAAQ,QAAQ,WAAW,QAAQ;CAE1D,OACE,WAAW,WAAW,GAAG,OAAO,QAAQ,MAAM,EAAE,EAAE,EAAE,KACpD,OAAO,KAAK,QAAQ,GAAG,QAAQ,CAAC,CAC7B,QAAO,QAAO,QAAQ,GAAG,SAAS,IAAI,EAAE,SAAS,SAAS,CAAC,CAC3D,SAAS,UAAU;AAE1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.mjs","names":[],"sources":["../../src/plugin-utils/paths.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{cwd}` - The current working directory.\n * - `{workspaceRoot}` - The current working directory (same as `{cwd}`).\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `{root}/src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{output}` - The configured output directory for the project.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{copy}` - The configured final/copied distribution directory for the project.\n * - `{copyPath}` - The configured final/copied distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @example\n * ```ts\n * const path = replacePathTokens(context, \"{root}/dist\");\n * // If context.config.root is \"/home/user/project\", this will return \"/home/user/project/dist\"\n *\n * const pathWithCopy = replacePathTokens(context, \"{copy}\");\n * // If context.config.output.copy.path is \"/home/user/project/dist-copy\", this will return \"/home/user/project/dist-copy\"\n * ```\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n let result = path\n .replaceAll(\"{cwd}\", context.config.cwd || process.cwd())\n .replaceAll(\"{workspaceRoot}\", context.config.cwd || process.cwd())\n .replaceAll(\"{root}\", context.config.root)\n .replaceAll(\"{projectRoot}\", context.config.root)\n .replaceAll(\"{sourceRoot}\", joinPaths(context.config.root, \"src\"))\n // .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.config.cwd)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.config.cwd)\n )\n .replaceAll(\n \"{builtinsPath}\",\n replacePath(context.builtinsPath, context.config.cwd)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.config.cwd)\n );\n\n if (context.config.output) {\n if (isSetString(context.config.output.path)) {\n result = result\n .replaceAll(\"{outputPath}\", context.config.output.path)\n .replaceAll(\"{output}\", context.config.output.path);\n }\n if (\n context.config.output.copy &&\n isSetString(context.config.output.copy?.path)\n ) {\n result = result\n .replaceAll(\"{copyPath}\", context.config.output.copy.path)\n .replaceAll(\"{copy}\", context.config.output.copy.path);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,kBACd,SACA,MAC4D;CAC5D,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,SAAS,KACV,WAAW,SAAS,QAAQ,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,CACxD,WAAW,mBAAmB,QAAQ,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,CAClE,WAAW,UAAU,QAAQ,OAAO,IAAI,CAAC,CACzC,WAAW,iBAAiB,QAAQ,OAAO,IAAI,CAAC,CAChD,WAAW,gBAAgB,UAAU,QAAQ,OAAO,MAAM,KAAK,CAAC,CAAC,CAEjE,WAAW,eAAe,QAAQ,SAAS,CAAC,CAC5C,WAAW,cAAc,QAAQ,QAAQ,CAAC,CAC1C,WAAW,aAAa,QAAQ,SAAS,GAAG,CAAC,CAC7C,WAAW,cAAc,QAAQ,SAAS,IAAI,CAAC,CAC/C,WAAW,gBAAgB,QAAQ,SAAS,MAAM,CAAC,CACnD,WACC,mBACA,YAAY,QAAQ,eAAe,QAAQ,OAAO,GAAG,CACvD,CAAC,CACA,WACC,iBACA,YAAY,QAAQ,cAAc,QAAQ,OAAO,GAAG,CACtD,CAAC,CACA,WACC,kBACA,YAAY,QAAQ,cAAc,QAAQ,OAAO,GAAG,CACtD,CAAC,CACA,WACC,eACA,YAAY,QAAQ,WAAW,QAAQ,OAAO,GAAG,CACnD;CAEF,IAAI,QAAQ,OAAO,QAAQ;EACzB,IAAI,YAAY,QAAQ,OAAO,OAAO,IAAI,GACxC,SAAS,OACN,WAAW,gBAAgB,QAAQ,OAAO,OAAO,IAAI,CAAC,CACtD,WAAW,YAAY,QAAQ,OAAO,OAAO,IAAI;EAEtD,IACE,QAAQ,OAAO,OAAO,QACtB,YAAY,QAAQ,OAAO,OAAO,MAAM,IAAI,GAE5C,SAAS,OACN,WAAW,cAAc,QAAQ,OAAO,OAAO,KAAK,IAAI,CAAC,CACzD,WAAW,UAAU,QAAQ,OAAO,OAAO,KAAK,IAAI;CAE3D;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"paths.mjs","names":[],"sources":["../../src/plugin-utils/paths.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{cwd}` - The current working directory.\n * - `{workspaceRoot}` - The current working directory (same as `{cwd}`).\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `{root}/src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{output}` - The configured output directory for the project.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{copy}` - The configured final/copied distribution directory for the project.\n * - `{copyPath}` - The configured final/copied distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @example\n * ```ts\n * const path = replacePathTokens(context, \"{root}/dist\");\n * // If context.config.root is \"/home/user/project\", this will return \"/home/user/project/dist\"\n *\n * const pathWithCopy = replacePathTokens(context, \"{copy}\");\n * // If context.config.output.copy.path is \"/home/user/project/dist-copy\", this will return \"/home/user/project/dist-copy\"\n * ```\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n let result = path\n .replaceAll(\"{cwd}\", context.config.cwd || process.cwd())\n .replaceAll(\"{workspaceRoot}\", context.config.cwd || process.cwd())\n .replaceAll(\"{root}\", context.config.root)\n .replaceAll(\"{projectRoot}\", context.config.root)\n .replaceAll(\"{sourceRoot}\", joinPaths(context.config.root, \"src\"))\n // .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.config.cwd)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.config.cwd)\n )\n .replaceAll(\n \"{builtinsPath}\",\n replacePath(context.builtinsPath, context.config.cwd)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.config.cwd)\n );\n\n if (context.config.output) {\n if (isSetString(context.config.output.path)) {\n result = result\n .replaceAll(\"{outputPath}\", context.config.output.path)\n .replaceAll(\"{output}\", context.config.output.path);\n }\n if (\n context.config.output.copy &&\n isSetString(context.config.output.copy?.path)\n ) {\n result = result\n .replaceAll(\"{copyPath}\", context.config.output.copy.path)\n .replaceAll(\"{copy}\", context.config.output.copy.path);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,kBACd,SACA,MAC4D;CAC5D,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,SAAS,KACV,WAAW,SAAS,QAAQ,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,CACxD,WAAW,mBAAmB,QAAQ,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,CAClE,WAAW,UAAU,QAAQ,OAAO,IAAI,CAAC,CACzC,WAAW,iBAAiB,QAAQ,OAAO,IAAI,CAAC,CAChD,WAAW,gBAAgB,UAAU,QAAQ,OAAO,MAAM,KAAK,CAAC,CAAC,CAEjE,WAAW,eAAe,QAAQ,SAAS,CAAC,CAC5C,WAAW,cAAc,QAAQ,QAAQ,CAAC,CAC1C,WAAW,aAAa,QAAQ,SAAS,GAAG,CAAC,CAC7C,WAAW,cAAc,QAAQ,SAAS,IAAI,CAAC,CAC/C,WAAW,gBAAgB,QAAQ,SAAS,MAAM,CAAC,CACnD,WACC,mBACA,YAAY,QAAQ,eAAe,QAAQ,OAAO,GAAG,CACvD,CAAC,CACA,WACC,iBACA,YAAY,QAAQ,cAAc,QAAQ,OAAO,GAAG,CACtD,CAAC,CACA,WACC,kBACA,YAAY,QAAQ,cAAc,QAAQ,OAAO,GAAG,CACtD,CAAC,CACA,WACC,eACA,YAAY,QAAQ,WAAW,QAAQ,OAAO,GAAG,CACnD;CAEF,IAAI,QAAQ,OAAO,QAAQ;EACzB,IAAI,YAAY,QAAQ,OAAO,OAAO,IAAI,GACxC,SAAS,OACN,WAAW,gBAAgB,QAAQ,OAAO,OAAO,IAAI,CAAC,CACtD,WAAW,YAAY,QAAQ,OAAO,OAAO,IAAI;EAEtD,IACE,QAAQ,OAAO,OAAO,QACtB,YAAY,QAAQ,OAAO,OAAO,MAAM,IAAI,GAE5C,SAAS,OACN,WAAW,cAAc,QAAQ,OAAO,OAAO,KAAK,IAAI,CAAC,CACzD,WAAW,UAAU,QAAQ,OAAO,OAAO,KAAK,IAAI;CAE3D;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtual.mjs","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst ESCAPE_REGEX = /[-/\\\\^$*+?.()|[\\]{}]/g;\nfunction escapeRegex(str: string): string {\n return str.replace(ESCAPE_REGEX, \"\\\\$&\");\n}\n\nexport const VIRTUAL_MODULE_PREFIX = \"\\0\";\nexport const VIRTUAL_MODULE_PREFIX_REGEX = prefixRegex(\"\\0\");\n\nexport interface PrefixRegexOptions {\n /**\n * Flags for the RegExp.\n */\n flags?: string;\n\n /**\n * The prefix to match. This will be escaped and used as the prefix in the generated RegExp.\n */\n prefix?: string;\n\n /**\n * Whether the prefix is optional. If true, the generated RegExp will match both strings that start with the prefix and strings that do not start with the prefix. Default is false.\n */\n isPrefixOptional?: boolean;\n}\n\n/**\n * Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.\n *\n * @example\n * ```ts\n * import { prefixRegex } from '@rolldown/pluginutils';\n * const plugin = {\n * name: 'plugin',\n * resolveId: {\n * filter: { id: prefixRegex('foo') },\n * handler(id) {} // will only be called for IDs starting with `foo`\n * }\n * }\n * ```\n *\n * @param str - the string to match.\n * @param options - options for the RegExp.\n * @return a RegExp that matches the specified string with the specified prefix.\n */\nexport function prefixRegex(\n str: string,\n options: PrefixRegexOptions = {}\n): RegExp {\n const { flags, prefix, isPrefixOptional = false } = options;\n\n return new RegExp(\n `^${\n prefix\n ? isPrefixOptional\n ? `(${escapeRegex(prefix)})?`\n : `${escapeRegex(prefix)}`\n : \"\"\n }${escapeRegex(str)}`,\n flags\n );\n}\n\n/**\n * Adds the virtual module prefix to the given ID.\n *\n * @param id - The ID to add the virtual module prefix to.\n * @returns The ID with the virtual module prefix added.\n */\nexport function addVirtualPrefix(id: string): string {\n return `${VIRTUAL_MODULE_PREFIX}${id}`;\n}\n\n/**\n * Removes the virtual module prefix from the given ID, if it exists.\n *\n * @param id - The ID to remove the virtual module prefix from.\n * @returns The ID without the virtual module prefix.\n */\nexport function removeVirtualPrefix(id: string): string {\n return id.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\");\n}\n\n/**\n * Checks if the given ID is a virtual module by checking if it starts with the virtual module prefix.\n *\n * @param id - The ID to check.\n * @returns True if the ID is a virtual module, false otherwise.\n */\nexport function isVirtualModule(id: string): boolean {\n return id.startsWith(VIRTUAL_MODULE_PREFIX);\n}\n\n/**\n * Creates a regular expression that matches the given ID with the virtual module prefix.\n *\n * @param id - The ID to create a regular expression for.\n * @returns A regular expression that matches the given ID with the virtual module prefix.\n */\nexport function createVirtualPrefixRegex(id: string): RegExp {\n return prefixRegex(removeVirtualPrefix(id), {\n prefix: VIRTUAL_MODULE_PREFIX,\n isPrefixOptional: true\n });\n}\n"],"mappings":";AAkBA,MAAM,eAAe;AACrB,SAAS,YAAY,KAAqB;CACxC,OAAO,IAAI,QAAQ,cAAc,MAAM;AACzC;AAEA,MAAa,wBAAwB;AACrC,MAAa,8BAA8B,YAAY,IAAI;;;;;;;;;;;;;;;;;;;;AAsC3D,SAAgB,YACd,KACA,UAA8B,CAAC,GACvB;CACR,MAAM,EAAE,OAAO,QAAQ,mBAAmB,UAAU;CAEpD,OAAO,IAAI,OACT,IACE,SACI,mBACE,IAAI,YAAY,MAAM,EAAE,MACxB,GAAG,YAAY,MAAM,MACvB,KACH,YAAY,GAAG,KAClB,KACF;AACF;;;;;;;AAQA,SAAgB,iBAAiB,IAAoB;CACnD,OAAO,UAA2B;AACpC;;;;;;;AAQA,SAAgB,oBAAoB,IAAoB;CACtD,OAAO,GAAG,QAAQ,6BAA6B,EAAE;AACnD;;;;;;;AAQA,SAAgB,gBAAgB,IAAqB;CACnD,OAAO,GAAG,eAAgC;AAC5C;;;;;;;AAQA,SAAgB,yBAAyB,IAAoB;CAC3D,OAAO,YAAY,oBAAoB,EAAE,GAAG;EAC1C;EACA,kBAAkB;CACpB,CAAC;AACH"}
1
+ {"version":3,"file":"virtual.mjs","names":[],"sources":["../../src/plugin-utils/virtual.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst ESCAPE_REGEX = /[-/\\\\^$*+?.()|[\\]{}]/g;\nfunction escapeRegex(str: string): string {\n return str.replace(ESCAPE_REGEX, \"\\\\$&\");\n}\n\nexport const VIRTUAL_MODULE_PREFIX = \"\\0\";\nexport const VIRTUAL_MODULE_PREFIX_REGEX = prefixRegex(\"\\0\");\n\nexport interface PrefixRegexOptions {\n /**\n * Flags for the RegExp.\n */\n flags?: string;\n\n /**\n * The prefix to match. This will be escaped and used as the prefix in the generated RegExp.\n */\n prefix?: string;\n\n /**\n * Whether the prefix is optional. If true, the generated RegExp will match both strings that start with the prefix and strings that do not start with the prefix. Default is false.\n */\n isPrefixOptional?: boolean;\n}\n\n/**\n * Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.\n *\n * @example\n * ```ts\n * import { prefixRegex } from '@rolldown/pluginutils';\n * const plugin = {\n * name: 'plugin',\n * resolveId: {\n * filter: { id: prefixRegex('foo') },\n * handler(id) {} // will only be called for IDs starting with `foo`\n * }\n * }\n * ```\n *\n * @param str - the string to match.\n * @param options - options for the RegExp.\n * @return a RegExp that matches the specified string with the specified prefix.\n */\nexport function prefixRegex(\n str: string,\n options: PrefixRegexOptions = {}\n): RegExp {\n const { flags, prefix, isPrefixOptional = false } = options;\n\n return new RegExp(\n `^${\n prefix\n ? isPrefixOptional\n ? `(${escapeRegex(prefix)})?`\n : `${escapeRegex(prefix)}`\n : \"\"\n }${escapeRegex(str)}`,\n flags\n );\n}\n\n/**\n * Adds the virtual module prefix to the given ID.\n *\n * @param id - The ID to add the virtual module prefix to.\n * @returns The ID with the virtual module prefix added.\n */\nexport function addVirtualPrefix(id: string): string {\n return `${VIRTUAL_MODULE_PREFIX}${id}`;\n}\n\n/**\n * Removes the virtual module prefix from the given ID, if it exists.\n *\n * @param id - The ID to remove the virtual module prefix from.\n * @returns The ID without the virtual module prefix.\n */\nexport function removeVirtualPrefix(id: string): string {\n return id.replace(VIRTUAL_MODULE_PREFIX_REGEX, \"\");\n}\n\n/**\n * Checks if the given ID is a virtual module by checking if it starts with the virtual module prefix.\n *\n * @param id - The ID to check.\n * @returns True if the ID is a virtual module, false otherwise.\n */\nexport function isVirtualModule(id: string): boolean {\n return id.startsWith(VIRTUAL_MODULE_PREFIX);\n}\n\n/**\n * Creates a regular expression that matches the given ID with the virtual module prefix.\n *\n * @param id - The ID to create a regular expression for.\n * @returns A regular expression that matches the given ID with the virtual module prefix.\n */\nexport function createVirtualPrefixRegex(id: string): RegExp {\n return prefixRegex(removeVirtualPrefix(id), {\n prefix: VIRTUAL_MODULE_PREFIX,\n isPrefixOptional: true\n });\n}\n"],"mappings":";AAkBA,MAAM,eAAe;AACrB,SAAS,YAAY,KAAqB;CACxC,OAAO,IAAI,QAAQ,cAAc,MAAM;AACzC;AAEA,MAAa,wBAAwB;AACrC,MAAa,8BAA8B,YAAY,IAAI;;;;;;;;;;;;;;;;;;;;AAsC3D,SAAgB,YACd,KACA,UAA8B,CAAC,GACvB;CACR,MAAM,EAAE,OAAO,QAAQ,mBAAmB,UAAU;CAEpD,OAAO,IAAI,OACT,IACE,SACI,mBACE,IAAI,YAAY,MAAM,EAAE,MACxB,GAAG,YAAY,MAAM,MACvB,KACH,YAAY,GAAG,KAClB,KACF;AACF;;;;;;;AAQA,SAAgB,iBAAiB,IAAoB;CACnD,OAAO,UAA2B;AACpC;;;;;;;AAQA,SAAgB,oBAAoB,IAAoB;CACtD,OAAO,GAAG,QAAQ,6BAA6B,EAAE;AACnD;;;;;;;AAQA,SAAgB,gBAAgB,IAAqB;CACnD,OAAO,GAAG,eAAgC;AAC5C;;;;;;;AAQA,SAAgB,yBAAyB,IAAoB;CAC3D,OAAO,YAAY,oBAAoB,EAAE,GAAG;EAC1C;EACA,kBAAkB;CACpB,CAAC;AACH"}