@powerlines/core 0.44.0 → 0.44.2

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 (73) hide show
  1. package/dist/constants/index.cjs +2 -2
  2. package/dist/constants/index.mjs +2 -2
  3. package/dist/constants/log-level.cjs +2 -2
  4. package/dist/constants/log-level.d.cts +2 -2
  5. package/dist/constants/log-level.d.mts +2 -2
  6. package/dist/constants/log-level.mjs +2 -2
  7. package/dist/constants/log-level.mjs.map +1 -1
  8. package/dist/index.cjs +7 -10
  9. package/dist/index.d.cts +3 -4
  10. package/dist/index.d.mts +3 -4
  11. package/dist/index.mjs +4 -4
  12. package/dist/lib/index.cjs +1 -7
  13. package/dist/lib/index.d.cts +1 -2
  14. package/dist/lib/index.d.mts +1 -2
  15. package/dist/lib/index.mjs +2 -3
  16. package/dist/lib/unplugin/plugin.cjs +9 -11
  17. package/dist/lib/unplugin/plugin.d.cts.map +1 -1
  18. package/dist/lib/unplugin/plugin.d.mts.map +1 -1
  19. package/dist/lib/unplugin/plugin.mjs +9 -11
  20. package/dist/lib/unplugin/plugin.mjs.map +1 -1
  21. package/dist/lib/utilities/index.cjs +1 -1
  22. package/dist/lib/utilities/index.mjs +1 -1
  23. package/dist/lib/utilities/write-file.d.cts +1 -1
  24. package/dist/lib/utilities/write-file.d.mts +1 -1
  25. package/dist/lib/utilities/write-file.mjs.map +1 -1
  26. package/dist/plugin-utils/index.cjs +15 -2
  27. package/dist/plugin-utils/index.d.cts +2 -2
  28. package/dist/plugin-utils/index.d.mts +2 -2
  29. package/dist/plugin-utils/index.mjs +3 -3
  30. package/dist/plugin-utils/logging.cjs +421 -4
  31. package/dist/plugin-utils/logging.d.cts +77 -3
  32. package/dist/plugin-utils/logging.d.cts.map +1 -1
  33. package/dist/plugin-utils/logging.d.mts +77 -3
  34. package/dist/plugin-utils/logging.d.mts.map +1 -1
  35. package/dist/plugin-utils/logging.mjs +407 -4
  36. package/dist/plugin-utils/logging.mjs.map +1 -1
  37. package/dist/plugin-utils/paths.cjs +1 -1
  38. package/dist/plugin-utils/paths.mjs +1 -1
  39. package/dist/plugin-utils/paths.mjs.map +1 -1
  40. package/dist/types/config.d.cts +11 -4
  41. package/dist/types/config.d.cts.map +1 -1
  42. package/dist/types/config.d.mts +11 -4
  43. package/dist/types/config.d.mts.map +1 -1
  44. package/dist/types/context.d.cts +17 -28
  45. package/dist/types/context.d.cts.map +1 -1
  46. package/dist/types/context.d.mts +17 -28
  47. package/dist/types/context.d.mts.map +1 -1
  48. package/dist/types/index.cjs +1 -0
  49. package/dist/types/index.d.cts +2 -2
  50. package/dist/types/index.d.mts +2 -2
  51. package/dist/types/index.mjs +3 -0
  52. package/dist/types/logging.cjs +48 -0
  53. package/dist/types/logging.d.cts +175 -0
  54. package/dist/types/logging.d.cts.map +1 -0
  55. package/dist/types/logging.d.mts +175 -0
  56. package/dist/types/logging.d.mts.map +1 -0
  57. package/dist/types/logging.mjs +45 -0
  58. package/dist/types/logging.mjs.map +1 -0
  59. package/package.json +74 -442
  60. package/dist/lib/logger.cjs +0 -106
  61. package/dist/lib/logger.d.cts +0 -42
  62. package/dist/lib/logger.d.cts.map +0 -1
  63. package/dist/lib/logger.d.mts +0 -42
  64. package/dist/lib/logger.d.mts.map +0 -1
  65. package/dist/lib/logger.mjs +0 -100
  66. package/dist/lib/logger.mjs.map +0 -1
  67. package/dist/types/log.cjs +0 -26
  68. package/dist/types/log.d.cts +0 -90
  69. package/dist/types/log.d.cts.map +0 -1
  70. package/dist/types/log.d.mts +0 -90
  71. package/dist/types/log.d.mts.map +0 -1
  72. package/dist/types/log.mjs +0 -25
  73. package/dist/types/log.mjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_lib_utilities_format = require('./format.cjs');
3
2
  const require_lib_utilities_source_file = require('./source-file.cjs');
4
3
  const require_lib_utilities_file_header = require('./file-header.cjs');
4
+ const require_lib_utilities_format = require('./format.cjs');
5
5
  const require_lib_utilities_source_map = require('./source-map.cjs');
6
6
  const require_lib_utilities_write_file = require('./write-file.cjs');
7
7
 
@@ -1,6 +1,6 @@
1
- import { format, formatFolder } from "./format.mjs";
2
1
  import { getMagicString, getSourceFile, getString } from "./source-file.mjs";
3
2
  import { getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getTypescriptFileHeader } from "./file-header.mjs";
3
+ import { format, formatFolder } from "./format.mjs";
4
4
  import { generateSourceMap } from "./source-map.mjs";
5
5
  import { writeFile } from "./write-file.mjs";
6
6
 
@@ -1,4 +1,4 @@
1
- import { LogFn } from "../../types/log.cjs";
1
+ import { LogFn } from "../../types/logging.cjs";
2
2
 
3
3
  //#region src/lib/utilities/write-file.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { LogFn } from "../../types/log.mjs";
1
+ import { LogFn } from "../../types/logging.mjs";
2
2
 
3
3
  //#region src/lib/utilities/write-file.d.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"write-file.mjs","names":["writeFileBase"],"sources":["../../../src/lib/utilities/write-file.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 { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/log\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n \"error\",\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,eAAsB,UACpB,KACA,UACA,SACA,aAAa,OACb;AACA,KAAI;AACF,MAAI,WACF,OAAMA,YAAc,UAAU,QAAQ;MAQtC,OAAMA,YAAc,UAAU,MALN,OAAO,SAAS;GACtC,GAAI,MAFe,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,SACA,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
1
+ {"version":3,"file":"write-file.mjs","names":["writeFileBase"],"sources":["../../../src/lib/utilities/write-file.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 { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/logging\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n \"error\",\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,eAAsB,UACpB,KACA,UACA,SACA,aAAa,OACb;AACA,KAAI;AACF,MAAI,WACF,OAAMA,YAAc,UAAU,QAAQ;MAQtC,OAAMA,YAAc,UAAU,MALN,OAAO,SAAS;GACtC,GAAI,MAFe,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,SACA,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_plugin_utils_paths = require('./paths.cjs');
3
+ const require_plugin_utils_format_package_json = require('./format-package-json.cjs');
3
4
  const require_plugin_utils_build_helpers = require('./build-helpers.cjs');
4
5
  const require_plugin_utils_helpers = require('./helpers.cjs');
5
6
  const require_plugin_utils_merge = require('./merge.cjs');
@@ -8,21 +9,28 @@ const require_plugin_utils_context_helpers = require('./context-helpers.cjs');
8
9
  const require_plugin_utils_docs_helper = require('./docs-helper.cjs');
9
10
  const require_plugin_utils_extend = require('./extend.cjs');
10
11
  const require_plugin_utils_filter = require('./filter.cjs');
11
- const require_plugin_utils_format_package_json = require('./format-package-json.cjs');
12
12
  const require_plugin_utils_get_config_path = require('./get-config-path.cjs');
13
13
  const require_plugin_utils_logging = require('./logging.cjs');
14
14
  const require_plugin_utils_modules = require('./modules.cjs');
15
15
 
16
16
  exports.addPluginHook = require_plugin_utils_helpers.addPluginHook;
17
+ exports.colorBackground = require_plugin_utils_logging.colorBackground;
18
+ exports.colorText = require_plugin_utils_logging.colorText;
17
19
  exports.combinePluginOptions = require_plugin_utils_combine_plugins.combinePluginOptions;
18
20
  exports.combinePlugins = require_plugin_utils_combine_plugins.combinePlugins;
21
+ exports.consoleLog = require_plugin_utils_logging.consoleLog;
22
+ exports.consoleLogger = require_plugin_utils_logging.consoleLogger;
19
23
  exports.createCodeFilter = require_plugin_utils_filter.createCodeFilter;
20
24
  exports.createFilter = require_plugin_utils_filter.createFilter;
21
25
  exports.createFilterForId = require_plugin_utils_filter.createFilterForId;
22
26
  exports.createFilterForTransform = require_plugin_utils_filter.createFilterForTransform;
23
27
  exports.createIdFilter = require_plugin_utils_filter.createIdFilter;
28
+ exports.createLogFn = require_plugin_utils_logging.createLogFn;
29
+ exports.createLogger = require_plugin_utils_logging.createLogger;
24
30
  exports.dedupeHooklist = require_plugin_utils_helpers.dedupeHooklist;
25
31
  exports.extend = require_plugin_utils_extend.extend;
32
+ exports.extendLogFn = require_plugin_utils_logging.extendLogFn;
33
+ exports.extendLogger = require_plugin_utils_logging.extendLogger;
26
34
  exports.extractPluginHook = require_plugin_utils_helpers.extractPluginHook;
27
35
  exports.findInvalidPluginConfig = require_plugin_utils_helpers.findInvalidPluginConfig;
28
36
  exports.formatPackageJson = require_plugin_utils_format_package_json.formatPackageJson;
@@ -31,6 +39,7 @@ exports.getDependencyConfig = require_plugin_utils_build_helpers.getDependencyCo
31
39
  exports.getDocsOutputPath = require_plugin_utils_docs_helper.getDocsOutputPath;
32
40
  exports.getHookHandler = require_plugin_utils_helpers.getHookHandler;
33
41
  exports.getOrganizationName = require_plugin_utils_context_helpers.getOrganizationName;
42
+ exports.getTextColor = require_plugin_utils_logging.getTextColor;
34
43
  exports.getWorkspaceName = require_plugin_utils_context_helpers.getWorkspaceName;
35
44
  exports.isBuiltinModule = require_plugin_utils_modules.isBuiltinModule;
36
45
  exports.isDuplicate = require_plugin_utils_helpers.isDuplicate;
@@ -44,6 +53,8 @@ exports.isPluginHookFunction = require_plugin_utils_helpers.isPluginHookFunction
44
53
  exports.isPluginHookObject = require_plugin_utils_helpers.isPluginHookObject;
45
54
  exports.isUnpluginHookField = require_plugin_utils_helpers.isUnpluginHookField;
46
55
  exports.isUnpluginHookKey = require_plugin_utils_helpers.isUnpluginHookKey;
56
+ exports.isValidLogLevel = require_plugin_utils_logging.isValidLogLevel;
57
+ exports.isValidLogLevelConfig = require_plugin_utils_logging.isValidLogLevelConfig;
47
58
  exports.isVerbose = require_plugin_utils_logging.isVerbose;
48
59
  exports.merge = require_plugin_utils_merge.merge;
49
60
  exports.mergeConfig = require_plugin_utils_merge.mergeConfig;
@@ -51,4 +62,6 @@ exports.normalizeFilter = require_plugin_utils_filter.normalizeFilter;
51
62
  exports.patternToCodeFilter = require_plugin_utils_filter.patternToCodeFilter;
52
63
  exports.patternToIdFilter = require_plugin_utils_filter.patternToIdFilter;
53
64
  exports.replacePathTokens = require_plugin_utils_paths.replacePathTokens;
54
- exports.resolveLogLevel = require_plugin_utils_logging.resolveLogLevel;
65
+ exports.resolveLogLevel = require_plugin_utils_logging.resolveLogLevel;
66
+ exports.withCustomLogger = require_plugin_utils_logging.withCustomLogger;
67
+ exports.withLogger = require_plugin_utils_logging.withLogger;
@@ -7,8 +7,8 @@ import { createCodeFilter, createFilter, createFilterForId, createFilterForTrans
7
7
  import { formatPackageJson } from "./format-package-json.cjs";
8
8
  import { getConfigPath } from "./get-config-path.cjs";
9
9
  import { GetHookHandlerReturnType, __ΩGetHookHandlerReturnType, addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.cjs";
10
- import { isVerbose, resolveLogLevel } from "./logging.cjs";
10
+ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger } from "./logging.cjs";
11
11
  import { MergeResult, __ΩMergeResult, merge, mergeConfig } from "./merge.cjs";
12
12
  import { isBuiltinModule } from "./modules.cjs";
13
13
  import { replacePathTokens } from "./paths.cjs";
14
- export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, combinePluginOptions, combinePlugins, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, dedupeHooklist, extend, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel };
14
+ export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel, withCustomLogger, withLogger };
@@ -7,8 +7,8 @@ import { createCodeFilter, createFilter, createFilterForId, createFilterForTrans
7
7
  import { formatPackageJson } from "./format-package-json.mjs";
8
8
  import { getConfigPath } from "./get-config-path.mjs";
9
9
  import { GetHookHandlerReturnType, __ΩGetHookHandlerReturnType, addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.mjs";
10
- import { isVerbose, resolveLogLevel } from "./logging.mjs";
10
+ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger } from "./logging.mjs";
11
11
  import { MergeResult, __ΩMergeResult, merge, mergeConfig } from "./merge.mjs";
12
12
  import { isBuiltinModule } from "./modules.mjs";
13
13
  import { replacePathTokens } from "./paths.mjs";
14
- export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, combinePluginOptions, combinePlugins, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, dedupeHooklist, extend, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel };
14
+ export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, __ΩCombinePluginsOptions, __ΩGetDependencyConfigResult, __ΩGetHookHandlerReturnType, __ΩMergeResult, addPluginHook, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel, withCustomLogger, withLogger };
@@ -1,4 +1,5 @@
1
1
  import { replacePathTokens } from "./paths.mjs";
2
+ import { formatPackageJson } from "./format-package-json.mjs";
2
3
  import { getDependencyConfig } from "./build-helpers.mjs";
3
4
  import { addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.mjs";
4
5
  import { merge, mergeConfig } from "./merge.mjs";
@@ -7,9 +8,8 @@ import { getOrganizationName, getWorkspaceName } from "./context-helpers.mjs";
7
8
  import { getDocsOutputPath } from "./docs-helper.mjs";
8
9
  import { extend } from "./extend.mjs";
9
10
  import { createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, normalizeFilter, patternToCodeFilter, patternToIdFilter } from "./filter.mjs";
10
- import { formatPackageJson } from "./format-package-json.mjs";
11
11
  import { getConfigPath } from "./get-config-path.mjs";
12
- import { isVerbose, resolveLogLevel } from "./logging.mjs";
12
+ import { colorBackground, colorText, consoleLog, consoleLogger, createLogFn, createLogger, extendLogFn, extendLogger, getTextColor, isValidLogLevel, isValidLogLevelConfig, isVerbose, resolveLogLevel, withCustomLogger, withLogger } from "./logging.mjs";
13
13
  import { isBuiltinModule } from "./modules.mjs";
14
14
 
15
- export { addPluginHook, combinePluginOptions, combinePlugins, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, dedupeHooklist, extend, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel };
15
+ export { addPluginHook, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, dedupeHooklist, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getTextColor, getWorkspaceName, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, merge, mergeConfig, normalizeFilter, patternToCodeFilter, patternToIdFilter, replacePathTokens, resolveLogLevel, withCustomLogger, withLogger };
@@ -1,10 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_logging = require('../types/logging.cjs');
4
+ const require_environments = require('../constants/environments.cjs');
3
5
  const require_log_level = require('../constants/log-level.cjs');
4
6
  let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
5
7
  let defu = require("defu");
6
8
  let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
7
9
  let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
10
+ let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
11
+ let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
12
+ let _storm_software_config_tools_logger = require("@storm-software/config-tools/logger");
13
+ let _storm_software_config_tools_utilities_colors = require("@storm-software/config-tools/utilities/colors");
14
+ let _stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
15
+ let chalk = require("chalk");
16
+ chalk = require_runtime.__toESM(chalk, 1);
8
17
 
9
18
  //#region src/plugin-utils/logging.ts
10
19
  /**
@@ -34,7 +43,8 @@ function resolveLogLevel(logLevel, mode) {
34
43
  hooks: "trace",
35
44
  env: "trace",
36
45
  ipc: "trace",
37
- config: "trace"
46
+ config: "trace",
47
+ babel: "trace"
38
48
  };
39
49
  else if (logLevel === "silent") return {
40
50
  general: "silent",
@@ -45,7 +55,8 @@ function resolveLogLevel(logLevel, mode) {
45
55
  hooks: "silent",
46
56
  env: "silent",
47
57
  ipc: "silent",
48
- config: "silent"
58
+ config: "silent",
59
+ babel: "silent"
49
60
  };
50
61
  let defaultLogLevel;
51
62
  if (mode === "development") defaultLogLevel = require_log_level.DEFAULT_DEVELOPMENT_LOG_LEVEL;
@@ -60,12 +71,418 @@ function resolveLogLevel(logLevel, mode) {
60
71
  hooks: logLevel,
61
72
  env: defaultLogLevel.env,
62
73
  ipc: defaultLogLevel.ipc,
63
- config: defaultLogLevel.config
74
+ config: defaultLogLevel.config,
75
+ babel: logLevel
64
76
  };
65
77
  else if ((0, _stryke_type_checks_is_set_object.isSetObject)(logLevel)) return (0, defu.defu)(logLevel, defaultLogLevel);
66
78
  return defaultLogLevel;
67
79
  }
80
+ const BADGE_COLORS = [
81
+ "#00A0DD",
82
+ "#6FCE4E",
83
+ "#FBBF24",
84
+ "#F43F5E",
85
+ "#3B82F6",
86
+ "#A855F7",
87
+ "#469592",
88
+ "#288EDF",
89
+ "#D8B4FE",
90
+ "#10B981",
91
+ "#EF4444",
92
+ "#F0EC56",
93
+ "#F472B6",
94
+ "#22D3EE",
95
+ "#EAB308",
96
+ "#84CC16",
97
+ "#F87171",
98
+ "#0EA5E9",
99
+ "#D946EF",
100
+ "#FACC15",
101
+ "#34D399",
102
+ "#8B5CF6"
103
+ ];
104
+ const BRAND_COLOR = (0, _storm_software_config_tools_utilities_colors.getColor)("brand");
105
+ /**
106
+ * Generate a consistent color based on the input text.
107
+ *
108
+ * @param text - The input text to generate the color from.
109
+ * @return A hexadecimal color string.
110
+ */
111
+ const getTextColor = (text) => {
112
+ return BADGE_COLORS[text.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0];
113
+ };
114
+ /**
115
+ * Generate a consistent color based on the input text.
116
+ *
117
+ * @param text - The input text to generate the color from.
118
+ * @return A hexadecimal color string.
119
+ */
120
+ const colorText = (text) => {
121
+ const title = (0, _stryke_string_format_title_case.titleCase)(text);
122
+ return chalk.default.hex(getTextColor(title))(title);
123
+ };
124
+ /**
125
+ * Generate a consistent color based on the input text.
126
+ *
127
+ * @param text - The input text to generate the color from.
128
+ * @return A hexadecimal color string.
129
+ */
130
+ const colorBackground = (text) => {
131
+ const title = (0, _stryke_string_format_title_case.titleCase)(text);
132
+ return chalk.default.inverse.hex(getTextColor(title))(` ${title} `);
133
+ };
134
+ const consoleLog = (meta, ...args) => (0, _storm_software_config_tools_logger.getLogFn)((0, _storm_software_config_tools_logger.getLogLevel)(meta.type), { logLevel: "trace" })(`${meta.name ? chalk.default.bold.hex(BRAND_COLOR)((0, _stryke_string_format_kebab_case.kebabCase)(meta.name)) : ""}${meta.command ? chalk.default.hex(BRAND_COLOR)(` (${meta.command})`) : ""}${meta.name ? chalk.default.grey(" > ") : ""}${(meta.source || meta.plugin) && (!meta.name || (0, _stryke_string_format_kebab_case.kebabCase)(meta.source || meta.plugin) !== (0, _stryke_string_format_kebab_case.kebabCase)(meta.name)) ? `${chalk.default.bold.hex(BRAND_COLOR)((0, _stryke_string_format_kebab_case.kebabCase)(meta.source || meta.plugin))}${chalk.default.grey(" > ")}` : ""}${meta.environment && (0, _stryke_string_format_kebab_case.kebabCase)(meta.environment) !== "default" ? `${chalk.default.bold.hex(BRAND_COLOR)((0, _stryke_string_format_kebab_case.kebabCase)(meta.environment))}${chalk.default.grey(" > ")}` : ""}${meta.category && meta.category !== require_logging.LogCategories.GENERAL ? `${colorBackground((0, _stryke_string_format_kebab_case.kebabCase)(meta.category))} ` : ""}${args.join(" ")} `.trim());
135
+ function isValidLogLevel(logLevel, type) {
136
+ if (logLevel === require_logging.LogLevels.SILENT) return false;
137
+ return require_logging.LOG_LEVELS.indexOf(logLevel) >= require_logging.LOG_LEVELS.indexOf(type);
138
+ }
139
+ function isValidLogLevelConfig(type, logLevel, category = require_logging.LogCategories.GENERAL) {
140
+ return isValidLogLevel(logLevel[category], type);
141
+ }
142
+ /**
143
+ * Create a logging function with a specific name and options.
144
+ *
145
+ * @param name - The name of the logging function.
146
+ * @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.
147
+ * @returns A logging function.
148
+ */
149
+ const createLogFn = (name, options) => {
150
+ const logLevel = resolveLogLevel(options.logLevel, options.mode);
151
+ return (meta, ...args) => {
152
+ const logMeta = (0, _stryke_type_checks_is_set_object.isSetObject)(meta) ? {
153
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
154
+ timestamp: Date.now(),
155
+ category: require_logging.LogCategories.GENERAL,
156
+ ...options,
157
+ ...meta,
158
+ name
159
+ } : {
160
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
161
+ timestamp: Date.now(),
162
+ category: require_logging.LogCategories.GENERAL,
163
+ ...options,
164
+ type: meta,
165
+ name
166
+ };
167
+ if (isValidLogLevelConfig(logMeta.type, logLevel, logMeta.category ? logMeta.category : require_logging.LogCategories.GENERAL)) consoleLog(logMeta, ...args);
168
+ };
169
+ };
170
+ const validateLogger = (type, name, options, callback) => {
171
+ const logLevel = resolveLogLevel(options.logLevel, options.mode);
172
+ return (message) => {
173
+ const params = (0, _stryke_type_checks_is_set_string.isSetString)(message) ? {
174
+ name,
175
+ plugin: options.plugin,
176
+ meta: {
177
+ type,
178
+ name,
179
+ category: require_logging.LogCategories.GENERAL,
180
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
181
+ timestamp: Date.now(),
182
+ ...options
183
+ },
184
+ message
185
+ } : {
186
+ name,
187
+ plugin: options.plugin,
188
+ ...message,
189
+ meta: {
190
+ type,
191
+ name,
192
+ category: require_logging.LogCategories.GENERAL,
193
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
194
+ timestamp: Date.now(),
195
+ plugin: message.plugin,
196
+ ...options,
197
+ ...message.meta
198
+ }
199
+ };
200
+ if (isValidLogLevelConfig(type, logLevel, params.meta.category)) callback(params);
201
+ };
202
+ };
203
+ const validateCustomLogger = (type, name, options, callback, customCallback) => {
204
+ const logLevel = resolveLogLevel(options.logLevel, options.mode);
205
+ return (message) => {
206
+ const params = (0, _stryke_type_checks_is_set_string.isSetString)(message) ? {
207
+ name,
208
+ plugin: options.plugin,
209
+ meta: {
210
+ type,
211
+ name,
212
+ category: require_logging.LogCategories.GENERAL,
213
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
214
+ timestamp: Date.now(),
215
+ ...options
216
+ },
217
+ message
218
+ } : {
219
+ name,
220
+ plugin: options.plugin,
221
+ ...message,
222
+ meta: {
223
+ type,
224
+ name,
225
+ category: require_logging.LogCategories.GENERAL,
226
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
227
+ timestamp: Date.now(),
228
+ plugin: message.plugin,
229
+ ...options,
230
+ ...message.meta
231
+ }
232
+ };
233
+ if (isValidLogLevelConfig(type, logLevel, params.meta.category)) {
234
+ callback?.(params);
235
+ customCallback?.(params);
236
+ }
237
+ };
238
+ };
239
+ /**
240
+ * Create a logging function with a specific name and options.
241
+ *
242
+ * @param logger - The original logger to wrap with the custom logger.
243
+ * @param secondaryLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
244
+ * @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.
245
+ */
246
+ const withLogger = (logger, secondaryLogger) => {
247
+ const options = {
248
+ ...secondaryLogger.options,
249
+ ...logger.options
250
+ };
251
+ const result = {
252
+ options,
253
+ error: validateLogger("error", options.name, options, (message) => {
254
+ logger.error?.(message);
255
+ secondaryLogger.error?.(message);
256
+ }),
257
+ warn: validateLogger("warn", options.name, options, (message) => {
258
+ logger.warn?.(message);
259
+ secondaryLogger.warn?.(message);
260
+ }),
261
+ info: validateLogger("info", options.name, options, (message) => {
262
+ logger.info?.(message);
263
+ secondaryLogger.info?.(message);
264
+ }),
265
+ debug: validateLogger("debug", options.name, options, (message) => {
266
+ logger.debug?.(message);
267
+ secondaryLogger.debug?.(message);
268
+ }),
269
+ trace: validateLogger("trace", options.name, options, (message) => {
270
+ logger.trace?.(message);
271
+ secondaryLogger.trace?.(message);
272
+ })
273
+ };
274
+ result.log = (type, message) => {
275
+ switch (type) {
276
+ case "error":
277
+ result.error(message);
278
+ break;
279
+ case "warn":
280
+ result.warn(message);
281
+ break;
282
+ case "info":
283
+ result.info(message);
284
+ break;
285
+ case "debug":
286
+ result.debug(message);
287
+ break;
288
+ case "trace":
289
+ result.trace(message);
290
+ break;
291
+ case "silent": break;
292
+ default:
293
+ result.info(message);
294
+ break;
295
+ }
296
+ };
297
+ return result;
298
+ };
299
+ /**
300
+ * Create a logging function with a specific name and options.
301
+ *
302
+ * @param logger - The original logger to wrap with the custom logger.
303
+ * @param customLogger - The custom logger to use for logging messages, which can be used to override the default logging behavior of the original logger.
304
+ * @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.
305
+ */
306
+ const withCustomLogger = (logger, customLogger) => {
307
+ const result = {
308
+ options: logger.options,
309
+ error: validateCustomLogger("error", logger.options.name, logger.options, logger.error.bind(logger), customLogger.error?.bind(customLogger)),
310
+ warn: validateCustomLogger("warn", logger.options.name, logger.options, logger.warn.bind(logger), customLogger.warn?.bind(customLogger)),
311
+ info: validateCustomLogger("info", logger.options.name, logger.options, logger.info.bind(logger), customLogger.info?.bind(customLogger)),
312
+ debug: validateCustomLogger("debug", logger.options.name, logger.options, logger.debug.bind(logger), customLogger.debug?.bind(customLogger)),
313
+ trace: validateCustomLogger("trace", logger.options.name, logger.options, logger.trace.bind(logger), customLogger.trace?.bind(customLogger))
314
+ };
315
+ result.log = (type, message) => {
316
+ switch (type) {
317
+ case "error":
318
+ result.error(message);
319
+ break;
320
+ case "warn":
321
+ result.warn(message);
322
+ break;
323
+ case "info":
324
+ result.info(message);
325
+ break;
326
+ case "debug":
327
+ result.debug(message);
328
+ break;
329
+ case "trace":
330
+ result.trace(message);
331
+ break;
332
+ case "silent": break;
333
+ default:
334
+ result.info(message);
335
+ break;
336
+ }
337
+ };
338
+ return result;
339
+ };
340
+ const consoleLogger = (type, message) => consoleLog((0, _stryke_type_checks_is_set_string.isSetString)(message) ? {
341
+ type,
342
+ category: require_logging.LogCategories.GENERAL,
343
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
344
+ timestamp: Date.now()
345
+ } : {
346
+ type,
347
+ category: require_logging.LogCategories.GENERAL,
348
+ logId: (0, _stryke_unique_id_uuid.uuid)(),
349
+ timestamp: Date.now(),
350
+ ...message.meta
351
+ }, (0, _stryke_type_checks_is_set_string.isSetString)(message) ? message : message.message);
352
+ /**
353
+ * Create a logging function with a specific name and options.
354
+ *
355
+ * @param name - The name of the logging function.
356
+ * @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.
357
+ * @returns A logging function.
358
+ */
359
+ const createLogger = (name, options, callback = consoleLogger) => {
360
+ const result = {
361
+ options: {
362
+ ...options,
363
+ name
364
+ },
365
+ error: validateLogger("error", name, {
366
+ ...options,
367
+ name
368
+ }, (message) => callback("error", message)),
369
+ warn: validateLogger("warn", name, {
370
+ ...options,
371
+ name
372
+ }, (message) => callback("warn", message)),
373
+ info: validateLogger("info", name, {
374
+ ...options,
375
+ name
376
+ }, (message) => callback("info", message)),
377
+ debug: validateLogger("debug", name, {
378
+ ...options,
379
+ name
380
+ }, (message) => callback("debug", message)),
381
+ trace: validateLogger("trace", name, {
382
+ ...options,
383
+ name
384
+ }, (message) => callback("trace", message))
385
+ };
386
+ result.log = (type, message) => {
387
+ switch (type) {
388
+ case "error":
389
+ result.error(message);
390
+ break;
391
+ case "warn":
392
+ result.warn(message);
393
+ break;
394
+ case "info":
395
+ result.info(message);
396
+ break;
397
+ case "debug":
398
+ result.debug(message);
399
+ break;
400
+ case "trace":
401
+ result.trace(message);
402
+ break;
403
+ case "silent": break;
404
+ default:
405
+ result.info(message);
406
+ break;
407
+ }
408
+ };
409
+ return result;
410
+ };
411
+ /**
412
+ * Extend a logging function with a specific name, adding a colored badge to the log output.
413
+ *
414
+ * @param logFn - The original logging function to extend.
415
+ * @param options - The overlay metadata to use for the badge in the log output.
416
+ * @returns A new logging function that includes the badge in its output.
417
+ */
418
+ const extendLogFn = (logFn, options) => {
419
+ return (meta, ...args) => options.source || options.category ? logFn((0, _stryke_type_checks_is_set_object.isSetObject)(meta) ? {
420
+ ...options,
421
+ ...meta
422
+ } : {
423
+ ...options,
424
+ type: meta
425
+ }, `${colorBackground(String(options.source || options.category))} ${args.filter(Boolean).map((arg) => String(arg).trim()).join(" ")} `) : logFn(meta, ...args);
426
+ };
427
+ /**
428
+ * 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.
429
+ *
430
+ * @param logger - The original logger to extend.
431
+ * @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.
432
+ * @returns A new logger that includes the badge in its output for each log message.
433
+ */
434
+ const extendLogger = (logger, options) => {
435
+ const opts = {
436
+ ...logger.options,
437
+ ...options
438
+ };
439
+ const result = {
440
+ options: opts,
441
+ error: validateLogger("error", opts.name, opts, logger.error.bind(logger)),
442
+ warn: validateLogger("warn", opts.name, opts, logger.warn.bind(logger)),
443
+ info: validateLogger("info", opts.name, opts, logger.info.bind(logger)),
444
+ debug: validateLogger("debug", opts.name, opts, logger.debug.bind(logger)),
445
+ trace: validateLogger("trace", opts.name, opts, logger.trace.bind(logger))
446
+ };
447
+ result.log = (type, message) => {
448
+ switch (type) {
449
+ case "error":
450
+ result.error(message);
451
+ break;
452
+ case "warn":
453
+ result.warn(message);
454
+ break;
455
+ case "info":
456
+ result.info(message);
457
+ break;
458
+ case "debug":
459
+ result.debug(message);
460
+ break;
461
+ case "trace":
462
+ result.trace(message);
463
+ break;
464
+ case "silent": break;
465
+ default:
466
+ result.info(message);
467
+ break;
468
+ }
469
+ };
470
+ return result;
471
+ };
68
472
 
69
473
  //#endregion
474
+ exports.colorBackground = colorBackground;
475
+ exports.colorText = colorText;
476
+ exports.consoleLog = consoleLog;
477
+ exports.consoleLogger = consoleLogger;
478
+ exports.createLogFn = createLogFn;
479
+ exports.createLogger = createLogger;
480
+ exports.extendLogFn = extendLogFn;
481
+ exports.extendLogger = extendLogger;
482
+ exports.getTextColor = getTextColor;
483
+ exports.isValidLogLevel = isValidLogLevel;
484
+ exports.isValidLogLevelConfig = isValidLogLevelConfig;
70
485
  exports.isVerbose = isVerbose;
71
- exports.resolveLogLevel = resolveLogLevel;
486
+ exports.resolveLogLevel = resolveLogLevel;
487
+ exports.withCustomLogger = withCustomLogger;
488
+ exports.withLogger = withLogger;