@powerlines/core 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/api.cjs +6 -5
- package/dist/constants/api.d.cts +3 -3
- package/dist/constants/api.d.cts.map +1 -1
- package/dist/constants/api.d.mts +3 -3
- package/dist/constants/api.d.mts.map +1 -1
- package/dist/constants/api.mjs +4 -4
- package/dist/constants/api.mjs.map +1 -1
- package/dist/constants/commands.cjs +3 -2
- package/dist/constants/commands.d.cts +1 -1
- package/dist/constants/commands.d.mts +1 -1
- package/dist/constants/commands.mjs +2 -2
- package/dist/constants/commands.mjs.map +1 -1
- package/dist/constants/devtools.cjs +23 -0
- package/dist/constants/devtools.d.cts +13 -0
- package/dist/constants/devtools.d.cts.map +1 -0
- package/dist/constants/devtools.d.mts +13 -0
- package/dist/constants/devtools.d.mts.map +1 -0
- package/dist/constants/devtools.mjs +14 -0
- package/dist/constants/devtools.mjs.map +1 -0
- package/dist/constants/environments.cjs +1 -0
- package/dist/constants/extensions.cjs +21 -0
- package/dist/constants/extensions.d.cts +5 -0
- package/dist/constants/extensions.d.cts.map +1 -0
- package/dist/constants/extensions.d.mts +5 -0
- package/dist/constants/extensions.d.mts.map +1 -0
- package/dist/constants/extensions.mjs +20 -0
- package/dist/constants/extensions.mjs.map +1 -0
- package/dist/constants/fs.cjs +1 -0
- package/dist/constants/hooks.cjs +1 -0
- package/dist/constants/index.cjs +48 -30
- package/dist/constants/index.d.cts +5 -3
- package/dist/constants/index.d.mts +5 -3
- package/dist/constants/index.mjs +5 -3
- package/dist/constants/log-level.cjs +90 -0
- package/dist/constants/log-level.d.cts +63 -0
- package/dist/constants/log-level.d.cts.map +1 -0
- package/dist/constants/log-level.d.mts +63 -0
- package/dist/constants/log-level.d.mts.map +1 -0
- package/dist/constants/log-level.mjs +82 -0
- package/dist/constants/log-level.mjs.map +1 -0
- package/dist/constants/meta.cjs +1 -0
- package/dist/constants/plugin.cjs +3 -2
- package/dist/constants/plugin.d.cts +2 -2
- package/dist/constants/plugin.d.mts +2 -2
- package/dist/context/base-context.cjs +127 -0
- package/dist/context/base-context.d.cts +81 -0
- package/dist/context/base-context.d.cts.map +1 -0
- package/dist/context/base-context.d.mts +81 -0
- package/dist/context/base-context.d.mts.map +1 -0
- package/dist/context/base-context.mjs +125 -0
- package/dist/context/base-context.mjs.map +1 -0
- package/dist/context/context.cjs +934 -0
- package/dist/context/context.d.cts +369 -0
- package/dist/context/context.d.cts.map +1 -0
- package/dist/context/context.d.mts +369 -0
- package/dist/context/context.d.mts.map +1 -0
- package/dist/context/context.mjs +932 -0
- package/dist/context/context.mjs.map +1 -0
- package/dist/context/environment-context.cjs +219 -0
- package/dist/context/environment-context.d.cts +100 -0
- package/dist/context/environment-context.d.cts.map +1 -0
- package/dist/context/environment-context.d.mts +100 -0
- package/dist/context/environment-context.d.mts.map +1 -0
- package/dist/context/environment-context.mjs +218 -0
- package/dist/context/environment-context.mjs.map +1 -0
- package/dist/context/execution-context.cjs +230 -0
- package/dist/context/execution-context.d.cts +101 -0
- package/dist/context/execution-context.d.cts.map +1 -0
- package/dist/context/execution-context.d.mts +101 -0
- package/dist/context/execution-context.d.mts.map +1 -0
- package/dist/context/execution-context.mjs +228 -0
- package/dist/context/execution-context.mjs.map +1 -0
- package/dist/context/index.cjs +12 -0
- package/dist/context/index.d.cts +6 -0
- package/dist/context/index.d.mts +6 -0
- package/dist/context/index.mjs +7 -0
- package/dist/context/plugin-context.cjs +83 -0
- package/dist/context/plugin-context.d.cts +18 -0
- package/dist/context/plugin-context.d.cts.map +1 -0
- package/dist/context/plugin-context.d.mts +18 -0
- package/dist/context/plugin-context.d.mts.map +1 -0
- package/dist/context/plugin-context.mjs +82 -0
- package/dist/context/plugin-context.mjs.map +1 -0
- package/dist/index.cjs +62 -9
- package/dist/index.d.cts +20 -9
- package/dist/index.d.mts +20 -9
- package/dist/index.mjs +17 -5
- package/dist/lib/config.cjs +160 -15
- package/dist/lib/config.d.cts +92 -6
- package/dist/lib/config.d.cts.map +1 -1
- package/dist/lib/config.d.mts +92 -6
- package/dist/lib/config.d.mts.map +1 -1
- package/dist/lib/config.mjs +154 -16
- package/dist/lib/config.mjs.map +1 -1
- package/dist/lib/context-helpers.cjs +43 -0
- package/dist/lib/context-helpers.d.cts +19 -0
- package/dist/lib/context-helpers.d.cts.map +1 -0
- package/dist/lib/context-helpers.d.mts +19 -0
- package/dist/lib/context-helpers.d.mts.map +1 -0
- package/dist/lib/context-helpers.mjs +41 -0
- package/dist/lib/context-helpers.mjs.map +1 -0
- package/dist/lib/entry.cjs +5 -5
- package/dist/lib/entry.d.cts.map +1 -1
- package/dist/lib/entry.d.mts.map +1 -1
- package/dist/lib/entry.mjs +5 -5
- package/dist/lib/entry.mjs.map +1 -1
- package/dist/lib/environment.cjs +72 -0
- package/dist/lib/environment.d.cts +12 -0
- package/dist/lib/environment.d.cts.map +1 -0
- package/dist/lib/environment.d.mts +12 -0
- package/dist/lib/environment.d.mts.map +1 -0
- package/dist/lib/environment.mjs +67 -0
- package/dist/lib/environment.mjs.map +1 -0
- package/dist/lib/events.cjs +43 -0
- package/dist/lib/events.d.cts +10 -0
- package/dist/lib/events.d.cts.map +1 -0
- package/dist/lib/events.d.mts +10 -0
- package/dist/lib/events.d.mts.map +1 -0
- package/dist/lib/events.mjs +42 -0
- package/dist/lib/events.mjs.map +1 -0
- package/dist/lib/generate-types.cjs +371 -0
- package/dist/lib/generate-types.d.cts +67 -0
- package/dist/lib/generate-types.d.cts.map +1 -0
- package/dist/lib/generate-types.d.mts +67 -0
- package/dist/lib/generate-types.d.mts.map +1 -0
- package/dist/lib/generate-types.mjs +368 -0
- package/dist/lib/generate-types.mjs.map +1 -0
- package/dist/lib/hooks.cjs +152 -0
- package/dist/lib/hooks.d.cts +28 -0
- package/dist/lib/hooks.d.cts.map +1 -0
- package/dist/lib/hooks.d.mts +28 -0
- package/dist/lib/hooks.d.mts.map +1 -0
- package/dist/lib/hooks.mjs +147 -0
- package/dist/lib/hooks.mjs.map +1 -0
- package/dist/lib/index.cjs +64 -9
- package/dist/lib/index.d.cts +15 -3
- package/dist/lib/index.d.mts +15 -3
- package/dist/lib/index.mjs +19 -5
- package/dist/lib/install-dependencies.cjs +25 -0
- package/dist/lib/install-dependencies.d.cts +12 -0
- package/dist/lib/install-dependencies.d.cts.map +1 -0
- package/dist/lib/install-dependencies.d.mts +12 -0
- package/dist/lib/install-dependencies.d.mts.map +1 -0
- package/dist/lib/install-dependencies.mjs +24 -0
- package/dist/lib/install-dependencies.mjs.map +1 -0
- package/dist/lib/meta.cjs +57 -0
- package/dist/lib/meta.d.cts +34 -0
- package/dist/lib/meta.d.cts.map +1 -0
- package/dist/lib/meta.d.mts +34 -0
- package/dist/lib/meta.d.mts.map +1 -0
- package/dist/lib/meta.mjs +54 -0
- package/dist/lib/meta.mjs.map +1 -0
- package/dist/lib/plugins.cjs +150 -0
- package/dist/lib/plugins.d.cts +40 -0
- package/dist/lib/plugins.d.cts.map +1 -0
- package/dist/lib/plugins.d.mts +40 -0
- package/dist/lib/plugins.d.mts.map +1 -0
- package/dist/lib/plugins.mjs +146 -0
- package/dist/lib/plugins.mjs.map +1 -0
- package/dist/lib/resolver.cjs +35 -0
- package/dist/lib/resolver.d.cts +21 -0
- package/dist/lib/resolver.d.cts.map +1 -0
- package/dist/lib/resolver.d.mts +21 -0
- package/dist/lib/resolver.d.mts.map +1 -0
- package/dist/lib/resolver.mjs +33 -0
- package/dist/lib/resolver.mjs.map +1 -0
- package/dist/lib/schemas.cjs +9 -0
- package/dist/lib/schemas.d.cts +2 -0
- package/dist/lib/schemas.d.mts +2 -0
- package/dist/lib/schemas.mjs +3 -0
- package/dist/lib/streaming-channel.cjs +260 -0
- package/dist/lib/streaming-channel.d.cts +133 -0
- package/dist/lib/streaming-channel.d.cts.map +1 -0
- package/dist/lib/streaming-channel.d.mts +133 -0
- package/dist/lib/streaming-channel.d.mts.map +1 -0
- package/dist/lib/streaming-channel.mjs +258 -0
- package/dist/lib/streaming-channel.mjs.map +1 -0
- package/dist/lib/typescript/index.cjs +16 -0
- package/dist/lib/typescript/index.d.cts +3 -0
- package/dist/lib/typescript/index.d.mts +3 -0
- package/dist/lib/typescript/index.mjs +4 -0
- package/dist/lib/typescript/ts-morph.cjs +105 -0
- package/dist/lib/typescript/ts-morph.d.cts +38 -0
- package/dist/lib/typescript/ts-morph.d.cts.map +1 -0
- package/dist/lib/typescript/ts-morph.d.mts +38 -0
- package/dist/lib/typescript/ts-morph.d.mts.map +1 -0
- package/dist/lib/typescript/ts-morph.mjs +102 -0
- package/dist/lib/typescript/ts-morph.mjs.map +1 -0
- package/dist/lib/typescript/tsconfig.cjs +253 -0
- package/dist/lib/typescript/tsconfig.d.cts +77 -0
- package/dist/lib/typescript/tsconfig.d.cts.map +1 -0
- package/dist/lib/typescript/tsconfig.d.mts +77 -0
- package/dist/lib/typescript/tsconfig.d.mts.map +1 -0
- package/dist/lib/typescript/tsconfig.mjs +240 -0
- package/dist/lib/typescript/tsconfig.mjs.map +1 -0
- package/dist/lib/unplugin/helpers.cjs +2 -2
- package/dist/lib/unplugin/module-resolution.cjs +18 -18
- package/dist/lib/unplugin/module-resolution.mjs +18 -18
- package/dist/lib/unplugin/module-resolution.mjs.map +1 -1
- package/dist/lib/unplugin/plugin.cjs +55 -62
- package/dist/lib/unplugin/plugin.d.cts +10 -11
- package/dist/lib/unplugin/plugin.d.cts.map +1 -1
- package/dist/lib/unplugin/plugin.d.mts +10 -11
- package/dist/lib/unplugin/plugin.d.mts.map +1 -1
- package/dist/lib/unplugin/plugin.mjs +55 -62
- package/dist/lib/unplugin/plugin.mjs.map +1 -1
- package/dist/lib/utilities/file-header.cjs +2 -2
- package/dist/lib/utilities/file-header.mjs +2 -2
- package/dist/lib/utilities/file-header.mjs.map +1 -1
- package/dist/lib/utilities/format.cjs +1 -1
- package/dist/lib/utilities/format.mjs +1 -1
- package/dist/lib/utilities/index.cjs +2 -2
- package/dist/lib/utilities/index.mjs +2 -2
- package/dist/lib/utilities/write-file.cjs +1 -2
- package/dist/lib/utilities/write-file.d.cts +1 -1
- package/dist/lib/utilities/write-file.d.cts.map +1 -1
- package/dist/lib/utilities/write-file.d.mts +1 -1
- package/dist/lib/utilities/write-file.d.mts.map +1 -1
- package/dist/lib/utilities/write-file.mjs +1 -2
- package/dist/lib/utilities/write-file.mjs.map +1 -1
- package/dist/lib/vfs.cjs +1104 -0
- package/dist/lib/vfs.d.cts +321 -0
- package/dist/lib/vfs.d.cts.map +1 -0
- package/dist/lib/vfs.d.mts +321 -0
- package/dist/lib/vfs.d.mts.map +1 -0
- package/dist/lib/vfs.mjs +1102 -0
- package/dist/lib/vfs.mjs.map +1 -0
- package/dist/plugin-base.cjs +1 -1
- package/dist/plugin-base.mjs +1 -1
- package/dist/plugin-base.mjs.map +1 -1
- package/dist/plugin-utils/build-helpers.cjs +2 -2
- package/dist/plugin-utils/build-helpers.mjs +2 -2
- package/dist/plugin-utils/build-helpers.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +22 -12
- package/dist/plugin-utils/context-helpers.d.cts +9 -1
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/context-helpers.d.mts +9 -1
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +22 -13
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/filter.cjs +13 -5
- package/dist/plugin-utils/filter.d.cts +2 -1
- package/dist/plugin-utils/filter.d.cts.map +1 -1
- package/dist/plugin-utils/filter.d.mts +2 -1
- package/dist/plugin-utils/filter.d.mts.map +1 -1
- package/dist/plugin-utils/filter.mjs +13 -6
- package/dist/plugin-utils/filter.mjs.map +1 -1
- package/dist/plugin-utils/format.cjs +44 -0
- package/dist/plugin-utils/format.d.cts +11 -0
- package/dist/plugin-utils/format.d.cts.map +1 -0
- package/dist/plugin-utils/format.d.mts +11 -0
- package/dist/plugin-utils/format.d.mts.map +1 -0
- package/dist/plugin-utils/format.mjs +43 -0
- package/dist/plugin-utils/format.mjs.map +1 -0
- package/dist/plugin-utils/helpers.cjs +6 -6
- package/dist/plugin-utils/helpers.d.cts +15 -15
- package/dist/plugin-utils/helpers.d.cts.map +1 -1
- package/dist/plugin-utils/helpers.d.mts +15 -15
- package/dist/plugin-utils/helpers.d.mts.map +1 -1
- package/dist/plugin-utils/helpers.mjs +1 -1
- package/dist/plugin-utils/helpers.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +34 -4
- package/dist/plugin-utils/index.d.cts +7 -4
- package/dist/plugin-utils/index.d.mts +7 -4
- package/dist/plugin-utils/index.mjs +9 -6
- package/dist/plugin-utils/install.cjs +47 -0
- package/dist/plugin-utils/install.d.cts +23 -0
- package/dist/plugin-utils/install.d.cts.map +1 -0
- package/dist/plugin-utils/install.d.mts +23 -0
- package/dist/plugin-utils/install.d.mts.map +1 -0
- package/dist/plugin-utils/install.mjs +45 -0
- package/dist/plugin-utils/install.mjs.map +1 -0
- package/dist/plugin-utils/logging.cjs +588 -1
- package/dist/plugin-utils/logging.d.cts +93 -1
- package/dist/plugin-utils/logging.d.cts.map +1 -1
- package/dist/plugin-utils/logging.d.mts +93 -1
- package/dist/plugin-utils/logging.d.mts.map +1 -1
- package/dist/plugin-utils/logging.mjs +572 -1
- package/dist/plugin-utils/logging.mjs.map +1 -1
- package/dist/plugin-utils/merge.cjs +1 -1
- package/dist/plugin-utils/merge.mjs +1 -1
- package/dist/plugin-utils/modules.cjs +1 -1
- package/dist/plugin-utils/modules.mjs +1 -1
- package/dist/plugin-utils/modules.mjs.map +1 -1
- package/dist/plugin-utils/paths.cjs +6 -2
- package/dist/plugin-utils/paths.mjs +6 -2
- package/dist/plugin-utils/paths.mjs.map +1 -1
- package/dist/plugin-utils/virtual.cjs +80 -0
- package/dist/plugin-utils/virtual.d.cts +69 -0
- package/dist/plugin-utils/virtual.d.cts.map +1 -0
- package/dist/plugin-utils/virtual.d.mts +69 -0
- package/dist/plugin-utils/virtual.d.mts.map +1 -0
- package/dist/plugin-utils/virtual.mjs +73 -0
- package/dist/plugin-utils/virtual.mjs.map +1 -0
- package/dist/schemas/fs.cjs +232 -0
- package/dist/schemas/fs.d.cts +127 -0
- package/dist/schemas/fs.d.cts.map +1 -0
- package/dist/schemas/fs.d.mts +127 -0
- package/dist/schemas/fs.d.mts.map +1 -0
- package/dist/schemas/fs.mjs +226 -0
- package/dist/schemas/fs.mjs.map +1 -0
- package/dist/storage/base.cjs +216 -0
- package/dist/storage/base.d.cts +201 -0
- package/dist/storage/base.d.cts.map +1 -0
- package/dist/storage/base.d.mts +201 -0
- package/dist/storage/base.d.mts.map +1 -0
- package/dist/storage/base.mjs +215 -0
- package/dist/storage/base.mjs.map +1 -0
- package/dist/storage/file-system.cjs +180 -0
- package/dist/storage/file-system.d.cts +129 -0
- package/dist/storage/file-system.d.cts.map +1 -0
- package/dist/storage/file-system.d.mts +129 -0
- package/dist/storage/file-system.d.mts.map +1 -0
- package/dist/storage/file-system.mjs +179 -0
- package/dist/storage/file-system.mjs.map +1 -0
- package/dist/storage/helpers.cjs +37 -0
- package/dist/storage/helpers.d.cts +25 -0
- package/dist/storage/helpers.d.cts.map +1 -0
- package/dist/storage/helpers.d.mts +25 -0
- package/dist/storage/helpers.d.mts.map +1 -0
- package/dist/storage/helpers.mjs +34 -0
- package/dist/storage/helpers.mjs.map +1 -0
- package/dist/storage/index.cjs +12 -0
- package/dist/storage/index.d.cts +5 -0
- package/dist/storage/index.d.mts +5 -0
- package/dist/storage/index.mjs +6 -0
- package/dist/storage/virtual.cjs +98 -0
- package/dist/storage/virtual.d.cts +80 -0
- package/dist/storage/virtual.d.cts.map +1 -0
- package/dist/storage/virtual.d.mts +80 -0
- package/dist/storage/virtual.d.mts.map +1 -0
- package/dist/storage/virtual.mjs +97 -0
- package/dist/storage/virtual.mjs.map +1 -0
- package/dist/types/api.d.cts +18 -152
- package/dist/types/api.d.cts.map +1 -1
- package/dist/types/api.d.mts +18 -152
- package/dist/types/api.d.mts.map +1 -1
- package/dist/types/config.d.cts +194 -135
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +195 -136
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/context.d.cts +152 -128
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +155 -131
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/fs.d.mts +1 -1
- package/dist/types/index.d.cts +5 -6
- package/dist/types/index.d.mts +5 -6
- package/dist/types/logging.d.cts +161 -0
- package/dist/types/logging.d.cts.map +1 -0
- package/dist/types/logging.d.mts +161 -0
- package/dist/types/logging.d.mts.map +1 -0
- package/dist/types/plugin.d.cts +6 -9
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +6 -9
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/tsconfig.d.mts +1 -1
- package/dist/types/unplugin.d.cts +5 -26
- package/dist/types/unplugin.d.cts.map +1 -1
- package/dist/types/unplugin.d.mts +5 -26
- package/dist/types/unplugin.d.mts.map +1 -1
- package/package.json +259 -457
- package/schemas/fs.capnp +42 -0
- package/dist/constants/virtual-modules.cjs +0 -8
- package/dist/constants/virtual-modules.d.cts +0 -6
- package/dist/constants/virtual-modules.d.cts.map +0 -1
- package/dist/constants/virtual-modules.d.mts +0 -6
- package/dist/constants/virtual-modules.d.mts.map +0 -1
- package/dist/constants/virtual-modules.mjs +0 -7
- package/dist/constants/virtual-modules.mjs.map +0 -1
- package/dist/lib/logger.cjs +0 -99
- package/dist/lib/logger.d.cts +0 -53
- package/dist/lib/logger.d.cts.map +0 -1
- package/dist/lib/logger.d.mts +0 -53
- package/dist/lib/logger.d.mts.map +0 -1
- package/dist/lib/logger.mjs +0 -93
- package/dist/lib/logger.mjs.map +0 -1
- package/dist/types/_internal.cjs +0 -0
- package/dist/types/_internal.d.cts +0 -106
- package/dist/types/_internal.d.cts.map +0 -1
- package/dist/types/_internal.d.mts +0 -106
- package/dist/types/_internal.d.mts.map +0 -1
- package/dist/types/_internal.mjs +0 -1
- package/dist/types/commands.d.cts +0 -16
- package/dist/types/commands.d.cts.map +0 -1
- package/dist/types/commands.d.mts +0 -16
- package/dist/types/commands.d.mts.map +0 -1
- package/dist/types/utils.d.cts +0 -9
- package/dist/types/utils.d.cts.map +0 -1
- package/dist/types/utils.d.mts +0 -9
- package/dist/types/utils.d.mts.map +0 -1
package/dist/lib/config.d.cts
CHANGED
|
@@ -1,8 +1,86 @@
|
|
|
1
|
+
import { LogLevelResolvedConfig } from "../types/logging.cjs";
|
|
1
2
|
import { Context } from "../types/context.cjs";
|
|
2
|
-
import { AnyUserConfig,
|
|
3
|
-
import {
|
|
3
|
+
import { AnyUserConfig, FrameworkOptions, InlineConfig, Mode, ParsedUserConfig, UserConfig, WorkspaceConfig } from "../types/config.cjs";
|
|
4
|
+
import { PartialKeys } from "@stryke/types/base";
|
|
5
|
+
import { PackageJson } from "@stryke/types/package-json";
|
|
4
6
|
|
|
5
7
|
//#region src/lib/config.d.ts
|
|
8
|
+
declare function normalizeBasePath(base?: string): string;
|
|
9
|
+
interface ResolvePackageConfigsResult {
|
|
10
|
+
/**
|
|
11
|
+
* The parsed `package.json` file for the project, if it exists. This file typically contains metadata about the project, such as its name, version, dependencies, and other information relevant to the build process.
|
|
12
|
+
*/
|
|
13
|
+
packageJson?: PackageJson;
|
|
14
|
+
/**
|
|
15
|
+
* The parsed `project.json` file for the project, if it exists. This file is an optional configuration file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
|
|
16
|
+
*/
|
|
17
|
+
projectJson?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
|
|
24
|
+
*
|
|
25
|
+
* @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
|
|
26
|
+
* @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
|
|
27
|
+
* @returns A promise that resolves when the package configurations have been loaded and stored in the context.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolvePackageConfigs(cwd: string, root: string): Promise<ResolvePackageConfigsResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the root directory for the project based on the provided options. This function will determine the root directory by checking the provided `root` option, and if it is not provided, it will look for a configuration file (such as `powerlines.config.ts`) in the current working directory. If a configuration file is found, the root directory will be set to the directory containing that file. If no configuration file is found, the root directory will default to the current working directory.
|
|
32
|
+
*
|
|
33
|
+
* @param cwd - The current working directory to use as the base for resolving the root directory. This is typically the directory from which the Powerlines process was executed.
|
|
34
|
+
* @param root - An optional root directory to use for the project. If provided, this will be used as the root directory instead of looking for a configuration file. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
35
|
+
* @param configFile - An optional path to a configuration file to look for when resolving the root directory. If provided, this file will be used to determine the root directory if the `root` option is not provided. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
36
|
+
* @returns The resolved root directory for the project, which will be used as the base for resolving other paths and configurations throughout the Powerlines process. This will typically be an absolute path to the root directory of the project.
|
|
37
|
+
*/
|
|
38
|
+
declare function resolveRoot(cwd: string, root?: string, configFile?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
|
|
41
|
+
*
|
|
42
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
43
|
+
* @param root - An optional root directory to use as the base for searching for the configuration file. If provided, this will be used as the starting point for searching for the configuration file instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
44
|
+
* @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
|
|
45
|
+
*/
|
|
46
|
+
declare function tryResolveWorkspaceConfig(cwd: string, root?: string): Promise<WorkspaceConfig | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* The mode is used to determine which configuration file to load (e.g., `powerlines.development.config.js` for development mode, `powerlines.production.config.js` for production mode, etc.) and can also be used by plugins and other parts of the build process to conditionally apply certain behaviors based on the current mode.
|
|
52
|
+
*
|
|
53
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
54
|
+
* @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
55
|
+
* @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
|
|
56
|
+
*/
|
|
57
|
+
declare function getDefaultMode(cwd: string, root?: string): Promise<Mode>;
|
|
58
|
+
/**
|
|
59
|
+
* Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* The log level is used to determine which log messages should be output during the execution of the Powerlines process. For example, if the log level is set to "warn", only messages with a level of "warn", "error", or "fatal" will be output, while messages with a level of "info", "debug", or "trace" will be suppressed. This allows users to control the verbosity of the logs and focus on the most relevant information based on their current needs.
|
|
63
|
+
*
|
|
64
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
65
|
+
* @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
66
|
+
* @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
|
|
67
|
+
*/
|
|
68
|
+
declare function getDefaultLogLevel(cwd: string, root?: string): Promise<LogLevelResolvedConfig>;
|
|
69
|
+
/**
|
|
70
|
+
* Load the user configuration file for the project and set up the context with the loaded configuration. This function will be called during the initialization of the context to load the user configuration file based on the provided options and set up the context accordingly. It will also set up the resolver for loading modules from the user configuration file and ensure that the context is properly initialized with the loaded configuration.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
|
|
74
|
+
*
|
|
75
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
76
|
+
* @param root - The root directory of the project to look for the configuration file. This is typically the root directory of the project, which may be different from the current working directory if the process was executed from a subdirectory.
|
|
77
|
+
* @param framework - The name of the framework to use when looking for configuration files (default is "powerlines"). This is used to determine the naming convention for the configuration files to look for (e.g., `powerlines.development.config.js` for the "powerlines" framework in development mode).
|
|
78
|
+
* @param orgId - The name of the organization to use when looking for configuration files (optional). This can be used to further customize the naming convention for the configuration files to look for (e.g., `powerlines.myorg.development.config.js` for the "powerlines" framework in development mode with an organization of "myorg").
|
|
79
|
+
* @param inlineConfig - The inline configuration options provided during the execution of a Powerlines command, which can include properties such as the project root, mode, and an explicit path to a configuration file. This is used to determine how the context should be initialized and which configuration file should be loaded for the execution.
|
|
80
|
+
* @returns A promise that resolves when the context has been successfully initialized with the loaded configuration and resolver setup.
|
|
81
|
+
* @throws Will throw an error if no configuration file is found in the project root or current working directory. This ensures that the context cannot be initialized without a valid configuration, which is essential for the proper functioning of the Powerlines process.
|
|
82
|
+
*/
|
|
83
|
+
declare function loadParsedConfig(cwd: string, root: string, framework: string, orgId: string, inlineConfig: InlineConfig): Promise<ParsedUserConfig>;
|
|
6
84
|
type PartiallyResolvedContext<TContext extends Context = Context> = Omit<TContext, "config" | "tsconfig" | "entry" | "fs" | "compiler" | "unimport"> & Partial<TContext> & {
|
|
7
85
|
config: TContext["config"];
|
|
8
86
|
};
|
|
@@ -17,11 +95,18 @@ declare function loadWorkspaceConfig(cwd: string, root: string): Promise<Workspa
|
|
|
17
95
|
/**
|
|
18
96
|
* Loads the user configuration file for the project.
|
|
19
97
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* This function will attempt to locate and load the user configuration file for the project based on the provided parameters. It will look for configuration files in various formats (e.g., `.ts`, `.js`, `.mts`, `.mjs`) and with different naming conventions (e.g., `powerlines.config.ts`, `powerlines.development.config.js`, etc.) in the project root and current working directory. If a configuration file is found, it will be loaded using a Jiti resolver, and the resulting configuration object will be returned. If no configuration file is found, an empty configuration object will be returned.
|
|
100
|
+
*
|
|
101
|
+
* @param cwd - The current working directory to start searching from.
|
|
102
|
+
* @param root - The root directory of the project.
|
|
103
|
+
* @param mode - The mode to determine which configuration file to load (e.g., "development", "test", "production").
|
|
104
|
+
* @param command - The command being executed (e.g., "build", "dev", "test"), which can be used to further customize the configuration loading logic if needed.
|
|
105
|
+
* @param framework - The name of the framework to use when looking for configuration files (default is "powerlines").
|
|
106
|
+
* @param configFile - An explicit path to a configuration file to load (optional). If provided, this file will be loaded instead of searching for configuration files based on the mode and framework.
|
|
22
107
|
* @returns A promise that resolves to the resolved user configuration.
|
|
23
108
|
*/
|
|
24
|
-
declare function loadUserConfigFile(
|
|
109
|
+
declare function loadUserConfigFile(cwd: string, root: string, mode: Mode, command: string, framework?: PartialKeys<FrameworkOptions, "orgId">, configFile?: string): Promise<ParsedUserConfig>;
|
|
25
110
|
/**
|
|
26
111
|
* A type helper to make it easier to use `powerlines.config.ts` files.
|
|
27
112
|
*
|
|
@@ -29,7 +114,8 @@ declare function loadUserConfigFile(options: ResolvedEngineOptions, jiti: Jiti):
|
|
|
29
114
|
* The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.
|
|
30
115
|
*/
|
|
31
116
|
declare function defineConfig(config: AnyUserConfig): UserConfig;
|
|
117
|
+
declare type __ΩResolvePackageConfigsResult = any[];
|
|
32
118
|
declare type __ΩPartiallyResolvedContext = any[];
|
|
33
119
|
//#endregion
|
|
34
|
-
export { PartiallyResolvedContext, __ΩPartiallyResolvedContext, defineConfig, loadUserConfigFile, loadWorkspaceConfig };
|
|
120
|
+
export { PartiallyResolvedContext, ResolvePackageConfigsResult, __ΩPartiallyResolvedContext, __ΩResolvePackageConfigsResult, defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig };
|
|
35
121
|
//# sourceMappingURL=config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/lib/config.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/lib/config.ts"],"mappings":";;;;;;;iBAyDgB,iBAAA,CAAkB,IAAA;AAAA,UAMjB,2BAAA;EANgB;;;EAU/B,WAAA,GAAc,WAAA;EAJC;;;EASf,WAAA,GAAc,MAAA;AAAA;;;;;;AAahB;;;;;iBAAsB,qBAAA,CACpB,GAAA,UACA,IAAA,WACC,OAAA,CAAQ,2BAAA;;;;;AA+BX;;;;iBAAgB,WAAA,CACd,GAAA,UACA,IAAA,WACA,UAAA;;;;;AAmCF;;;iBAAsB,yBAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAA,CAAQ,eAAA;;;;;;;AAiBX;;;;iBAAsB,cAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAA,CAAQ,IAAA;;;;;;AAsBX;;;;;iBAAsB,kBAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAA,CAAQ,sBAAA;;;;;AAgCX;;;;;;;;;;iBAAsB,gBAAA,CACpB,GAAA,UACA,IAAA,UACA,SAAA,UACA,KAAA,UACA,YAAA,EAAc,YAAA,GAAY,OAAA,CAAA,gBAAA;AAAA,KAwBhB,wBAAA,kBAA0C,OAAA,GAAU,OAAA,IAAW,IAAA,CACzE,QAAA,sEAGA,OAAA,CAAQ,QAAA;EACN,MAAA,EAAQ,QAAA;AAAA;;;;;AALZ;;;iBAesB,mBAAA,CACpB,GAAA,UACA,IAAA,WACC,OAAA,CAAQ,eAAA;;;;;;;;;;;;;;;iBA2BW,kBAAA,CACpB,GAAA,UACA,IAAA,UACA,IAAA,EAAM,IAAA,EACN,OAAA,UACA,SAAA,GAAY,WAAA,CAAY,gBAAA,YACxB,UAAA,YACC,OAAA,CAAQ,gBAAA;;;;;AArCX;;iBA+LgB,YAAA,CAAa,MAAA,EAAQ,aAAA,GAAgB,UAAA;AAAA"}
|
package/dist/lib/config.d.mts
CHANGED
|
@@ -1,8 +1,86 @@
|
|
|
1
|
+
import { LogLevelResolvedConfig } from "../types/logging.mjs";
|
|
1
2
|
import { Context } from "../types/context.mjs";
|
|
2
|
-
import { AnyUserConfig,
|
|
3
|
-
import {
|
|
3
|
+
import { AnyUserConfig, FrameworkOptions, InlineConfig, Mode, ParsedUserConfig, UserConfig, WorkspaceConfig } from "../types/config.mjs";
|
|
4
|
+
import { PartialKeys } from "@stryke/types/base";
|
|
5
|
+
import { PackageJson } from "@stryke/types/package-json";
|
|
4
6
|
|
|
5
7
|
//#region src/lib/config.d.ts
|
|
8
|
+
declare function normalizeBasePath(base?: string): string;
|
|
9
|
+
interface ResolvePackageConfigsResult {
|
|
10
|
+
/**
|
|
11
|
+
* The parsed `package.json` file for the project, if it exists. This file typically contains metadata about the project, such as its name, version, dependencies, and other information relevant to the build process.
|
|
12
|
+
*/
|
|
13
|
+
packageJson?: PackageJson;
|
|
14
|
+
/**
|
|
15
|
+
* The parsed `project.json` file for the project, if it exists. This file is an optional configuration file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
|
|
16
|
+
*/
|
|
17
|
+
projectJson?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
|
|
24
|
+
*
|
|
25
|
+
* @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
|
|
26
|
+
* @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
|
|
27
|
+
* @returns A promise that resolves when the package configurations have been loaded and stored in the context.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolvePackageConfigs(cwd: string, root: string): Promise<ResolvePackageConfigsResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve the root directory for the project based on the provided options. This function will determine the root directory by checking the provided `root` option, and if it is not provided, it will look for a configuration file (such as `powerlines.config.ts`) in the current working directory. If a configuration file is found, the root directory will be set to the directory containing that file. If no configuration file is found, the root directory will default to the current working directory.
|
|
32
|
+
*
|
|
33
|
+
* @param cwd - The current working directory to use as the base for resolving the root directory. This is typically the directory from which the Powerlines process was executed.
|
|
34
|
+
* @param root - An optional root directory to use for the project. If provided, this will be used as the root directory instead of looking for a configuration file. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
35
|
+
* @param configFile - An optional path to a configuration file to look for when resolving the root directory. If provided, this file will be used to determine the root directory if the `root` option is not provided. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
36
|
+
* @returns The resolved root directory for the project, which will be used as the base for resolving other paths and configurations throughout the Powerlines process. This will typically be an absolute path to the root directory of the project.
|
|
37
|
+
*/
|
|
38
|
+
declare function resolveRoot(cwd: string, root?: string, configFile?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
|
|
41
|
+
*
|
|
42
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
43
|
+
* @param root - An optional root directory to use as the base for searching for the configuration file. If provided, this will be used as the starting point for searching for the configuration file instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
44
|
+
* @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
|
|
45
|
+
*/
|
|
46
|
+
declare function tryResolveWorkspaceConfig(cwd: string, root?: string): Promise<WorkspaceConfig | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* The mode is used to determine which configuration file to load (e.g., `powerlines.development.config.js` for development mode, `powerlines.production.config.js` for production mode, etc.) and can also be used by plugins and other parts of the build process to conditionally apply certain behaviors based on the current mode.
|
|
52
|
+
*
|
|
53
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
54
|
+
* @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
55
|
+
* @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
|
|
56
|
+
*/
|
|
57
|
+
declare function getDefaultMode(cwd: string, root?: string): Promise<Mode>;
|
|
58
|
+
/**
|
|
59
|
+
* Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* The log level is used to determine which log messages should be output during the execution of the Powerlines process. For example, if the log level is set to "warn", only messages with a level of "warn", "error", or "fatal" will be output, while messages with a level of "info", "debug", or "trace" will be suppressed. This allows users to control the verbosity of the logs and focus on the most relevant information based on their current needs.
|
|
63
|
+
*
|
|
64
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
65
|
+
* @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
66
|
+
* @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
|
|
67
|
+
*/
|
|
68
|
+
declare function getDefaultLogLevel(cwd: string, root?: string): Promise<LogLevelResolvedConfig>;
|
|
69
|
+
/**
|
|
70
|
+
* Load the user configuration file for the project and set up the context with the loaded configuration. This function will be called during the initialization of the context to load the user configuration file based on the provided options and set up the context accordingly. It will also set up the resolver for loading modules from the user configuration file and ensure that the context is properly initialized with the loaded configuration.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
|
|
74
|
+
*
|
|
75
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
76
|
+
* @param root - The root directory of the project to look for the configuration file. This is typically the root directory of the project, which may be different from the current working directory if the process was executed from a subdirectory.
|
|
77
|
+
* @param framework - The name of the framework to use when looking for configuration files (default is "powerlines"). This is used to determine the naming convention for the configuration files to look for (e.g., `powerlines.development.config.js` for the "powerlines" framework in development mode).
|
|
78
|
+
* @param orgId - The name of the organization to use when looking for configuration files (optional). This can be used to further customize the naming convention for the configuration files to look for (e.g., `powerlines.myorg.development.config.js` for the "powerlines" framework in development mode with an organization of "myorg").
|
|
79
|
+
* @param inlineConfig - The inline configuration options provided during the execution of a Powerlines command, which can include properties such as the project root, mode, and an explicit path to a configuration file. This is used to determine how the context should be initialized and which configuration file should be loaded for the execution.
|
|
80
|
+
* @returns A promise that resolves when the context has been successfully initialized with the loaded configuration and resolver setup.
|
|
81
|
+
* @throws Will throw an error if no configuration file is found in the project root or current working directory. This ensures that the context cannot be initialized without a valid configuration, which is essential for the proper functioning of the Powerlines process.
|
|
82
|
+
*/
|
|
83
|
+
declare function loadParsedConfig(cwd: string, root: string, framework: string, orgId: string, inlineConfig: InlineConfig): Promise<ParsedUserConfig>;
|
|
6
84
|
type PartiallyResolvedContext<TContext extends Context = Context> = Omit<TContext, "config" | "tsconfig" | "entry" | "fs" | "compiler" | "unimport"> & Partial<TContext> & {
|
|
7
85
|
config: TContext["config"];
|
|
8
86
|
};
|
|
@@ -17,11 +95,18 @@ declare function loadWorkspaceConfig(cwd: string, root: string): Promise<Workspa
|
|
|
17
95
|
/**
|
|
18
96
|
* Loads the user configuration file for the project.
|
|
19
97
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* This function will attempt to locate and load the user configuration file for the project based on the provided parameters. It will look for configuration files in various formats (e.g., `.ts`, `.js`, `.mts`, `.mjs`) and with different naming conventions (e.g., `powerlines.config.ts`, `powerlines.development.config.js`, etc.) in the project root and current working directory. If a configuration file is found, it will be loaded using a Jiti resolver, and the resulting configuration object will be returned. If no configuration file is found, an empty configuration object will be returned.
|
|
100
|
+
*
|
|
101
|
+
* @param cwd - The current working directory to start searching from.
|
|
102
|
+
* @param root - The root directory of the project.
|
|
103
|
+
* @param mode - The mode to determine which configuration file to load (e.g., "development", "test", "production").
|
|
104
|
+
* @param command - The command being executed (e.g., "build", "dev", "test"), which can be used to further customize the configuration loading logic if needed.
|
|
105
|
+
* @param framework - The name of the framework to use when looking for configuration files (default is "powerlines").
|
|
106
|
+
* @param configFile - An explicit path to a configuration file to load (optional). If provided, this file will be loaded instead of searching for configuration files based on the mode and framework.
|
|
22
107
|
* @returns A promise that resolves to the resolved user configuration.
|
|
23
108
|
*/
|
|
24
|
-
declare function loadUserConfigFile(
|
|
109
|
+
declare function loadUserConfigFile(cwd: string, root: string, mode: Mode, command: string, framework?: PartialKeys<FrameworkOptions, "orgId">, configFile?: string): Promise<ParsedUserConfig>;
|
|
25
110
|
/**
|
|
26
111
|
* A type helper to make it easier to use `powerlines.config.ts` files.
|
|
27
112
|
*
|
|
@@ -29,7 +114,8 @@ declare function loadUserConfigFile(options: ResolvedEngineOptions, jiti: Jiti):
|
|
|
29
114
|
* The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.
|
|
30
115
|
*/
|
|
31
116
|
declare function defineConfig(config: AnyUserConfig): UserConfig;
|
|
117
|
+
declare type __ΩResolvePackageConfigsResult = any[];
|
|
32
118
|
declare type __ΩPartiallyResolvedContext = any[];
|
|
33
119
|
//#endregion
|
|
34
|
-
export { PartiallyResolvedContext, __ΩPartiallyResolvedContext, defineConfig, loadUserConfigFile, loadWorkspaceConfig };
|
|
120
|
+
export { PartiallyResolvedContext, ResolvePackageConfigsResult, __ΩPartiallyResolvedContext, __ΩResolvePackageConfigsResult, defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig };
|
|
35
121
|
//# sourceMappingURL=config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/lib/config.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/lib/config.ts"],"mappings":";;;;;;;iBAyDgB,iBAAA,CAAkB,IAAA;AAAA,UAMjB,2BAAA;EANgB;;;EAU/B,WAAA,GAAc,WAAA;EAJC;;;EASf,WAAA,GAAc,MAAA;AAAA;;;;;;AAahB;;;;;iBAAsB,qBAAA,CACpB,GAAA,UACA,IAAA,WACC,OAAA,CAAQ,2BAAA;;;;;AA+BX;;;;iBAAgB,WAAA,CACd,GAAA,UACA,IAAA,WACA,UAAA;;;;;AAmCF;;;iBAAsB,yBAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAA,CAAQ,eAAA;;;;;;;AAiBX;;;;iBAAsB,cAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAA,CAAQ,IAAA;;;;;;AAsBX;;;;;iBAAsB,kBAAA,CACpB,GAAA,UACA,IAAA,YACC,OAAA,CAAQ,sBAAA;;;;;AAgCX;;;;;;;;;;iBAAsB,gBAAA,CACpB,GAAA,UACA,IAAA,UACA,SAAA,UACA,KAAA,UACA,YAAA,EAAc,YAAA,GAAY,OAAA,CAAA,gBAAA;AAAA,KAwBhB,wBAAA,kBAA0C,OAAA,GAAU,OAAA,IAAW,IAAA,CACzE,QAAA,sEAGA,OAAA,CAAQ,QAAA;EACN,MAAA,EAAQ,QAAA;AAAA;;;;;AALZ;;;iBAesB,mBAAA,CACpB,GAAA,UACA,IAAA,WACC,OAAA,CAAQ,eAAA;;;;;;;;;;;;;;;iBA2BW,kBAAA,CACpB,GAAA,UACA,IAAA,UACA,IAAA,EAAM,IAAA,EACN,OAAA,UACA,SAAA,GAAY,WAAA,CAAY,gBAAA,YACxB,UAAA,YACC,OAAA,CAAQ,gBAAA;;;;;AArCX;;iBA+LgB,YAAA,CAAa,MAAA,EAAQ,aAAA,GAAgB,UAAA;AAAA"}
|
package/dist/lib/config.mjs
CHANGED
|
@@ -1,15 +1,130 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveLogLevel } from "../plugin-utils/logging.mjs";
|
|
2
|
+
import { createResolver } from "./resolver.mjs";
|
|
3
|
+
import { getWorkspaceConfig, tryGetWorkspaceConfig } from "@storm-software/config-tools/get-config";
|
|
4
|
+
import { isDevelopment, isProduction, isTest } from "@stryke/env/environment-checks";
|
|
5
|
+
import { getEnvPaths } from "@stryke/env/get-env-paths";
|
|
2
6
|
import { existsSync } from "@stryke/fs/exists";
|
|
7
|
+
import { isFile } from "@stryke/fs/is-file";
|
|
8
|
+
import { readJsonFile } from "@stryke/fs/json";
|
|
3
9
|
import { appendPath } from "@stryke/path/append";
|
|
10
|
+
import { findFilePath, relativePath } from "@stryke/path/file-path-fns";
|
|
4
11
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
12
|
import { replacePath } from "@stryke/path/replace";
|
|
6
13
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
14
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
7
15
|
import { isFunction } from "@stryke/type-checks/is-function";
|
|
8
16
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
9
17
|
import { loadConfig } from "c12";
|
|
10
18
|
import defu from "defu";
|
|
11
19
|
|
|
12
20
|
//#region src/lib/config.ts
|
|
21
|
+
function normalizeBasePath(base = "/") {
|
|
22
|
+
let out = base.startsWith("/") ? base : `/${base}`;
|
|
23
|
+
if (!out.endsWith("/")) out = `${out}/`;
|
|
24
|
+
return out.replace(/\/+/g, "/");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.
|
|
31
|
+
*
|
|
32
|
+
* @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.
|
|
33
|
+
* @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.
|
|
34
|
+
* @returns A promise that resolves when the package configurations have been loaded and stored in the context.
|
|
35
|
+
*/
|
|
36
|
+
async function resolvePackageConfigs(cwd, root) {
|
|
37
|
+
const result = {};
|
|
38
|
+
if (cwd || root) {
|
|
39
|
+
const projectJsonPath = joinPaths(appendPath(root || ".", cwd || "."), "project.json");
|
|
40
|
+
if (existsSync(projectJsonPath)) result.projectJson = await readJsonFile(projectJsonPath);
|
|
41
|
+
const packageJsonPath = joinPaths(appendPath(root || ".", cwd || "."), "package.json");
|
|
42
|
+
if (existsSync(packageJsonPath)) result.packageJson = await readJsonFile(packageJsonPath);
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the root directory for the project based on the provided options. This function will determine the root directory by checking the provided `root` option, and if it is not provided, it will look for a configuration file (such as `powerlines.config.ts`) in the current working directory. If a configuration file is found, the root directory will be set to the directory containing that file. If no configuration file is found, the root directory will default to the current working directory.
|
|
48
|
+
*
|
|
49
|
+
* @param cwd - The current working directory to use as the base for resolving the root directory. This is typically the directory from which the Powerlines process was executed.
|
|
50
|
+
* @param root - An optional root directory to use for the project. If provided, this will be used as the root directory instead of looking for a configuration file. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
51
|
+
* @param configFile - An optional path to a configuration file to look for when resolving the root directory. If provided, this file will be used to determine the root directory if the `root` option is not provided. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
52
|
+
* @returns The resolved root directory for the project, which will be used as the base for resolving other paths and configurations throughout the Powerlines process. This will typically be an absolute path to the root directory of the project.
|
|
53
|
+
*/
|
|
54
|
+
function resolveRoot(cwd, root, configFile) {
|
|
55
|
+
let result = root || ".";
|
|
56
|
+
if (!root) {
|
|
57
|
+
if (configFile) {
|
|
58
|
+
if (!existsSync(appendPath(configFile, cwd))) throw new Error(`The user-provided configuration file at "${configFile}" does not exist. Please ensure this path is correct and try again.`);
|
|
59
|
+
if (!isFile(configFile)) throw new Error(`The user-provided configuration file at "${configFile}" is not a file. Please ensure this path is correct and try again.`);
|
|
60
|
+
result = relativePath(cwd, findFilePath(configFile));
|
|
61
|
+
}
|
|
62
|
+
} else result = replacePath(root, cwd);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.
|
|
67
|
+
*
|
|
68
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
69
|
+
* @param root - An optional root directory to use as the base for searching for the configuration file. If provided, this will be used as the starting point for searching for the configuration file instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
70
|
+
* @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.
|
|
71
|
+
*/
|
|
72
|
+
async function tryResolveWorkspaceConfig(cwd, root) {
|
|
73
|
+
return tryGetWorkspaceConfig(false, {
|
|
74
|
+
cwd: root ? appendPath(root, cwd) : void 0,
|
|
75
|
+
workspaceRoot: cwd
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to "production".
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* The mode is used to determine which configuration file to load (e.g., `powerlines.development.config.js` for development mode, `powerlines.production.config.js` for production mode, etc.) and can also be used by plugins and other parts of the build process to conditionally apply certain behaviors based on the current mode.
|
|
83
|
+
*
|
|
84
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
85
|
+
* @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
86
|
+
* @returns A promise that resolves to the default mode for the current execution, which can be "development", "production", or "test".
|
|
87
|
+
*/
|
|
88
|
+
async function getDefaultMode(cwd, root) {
|
|
89
|
+
const workspaceConfig = await tryResolveWorkspaceConfig(cwd, root);
|
|
90
|
+
return isProduction ? "production" : isDevelopment ? "development" : isTest ? "test" : workspaceConfig?.mode || "production";
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to "info" for development mode and "warn" for production mode.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* The log level is used to determine which log messages should be output during the execution of the Powerlines process. For example, if the log level is set to "warn", only messages with a level of "warn", "error", or "fatal" will be output, while messages with a level of "info", "debug", or "trace" will be suppressed. This allows users to control the verbosity of the logs and focus on the most relevant information based on their current needs.
|
|
97
|
+
*
|
|
98
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
99
|
+
* @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.
|
|
100
|
+
* @returns A promise that resolves to the default log level for the current execution, which can be "fatal", "error", "warn", "info", "debug", or "trace".
|
|
101
|
+
*/
|
|
102
|
+
async function getDefaultLogLevel(cwd, root) {
|
|
103
|
+
const workspaceConfig = await tryResolveWorkspaceConfig(cwd, root);
|
|
104
|
+
return resolveLogLevel(workspaceConfig?.logLevel ? workspaceConfig.logLevel === "success" || workspaceConfig.logLevel === "performance" ? "info" : workspaceConfig.logLevel === "all" ? "debug" : workspaceConfig.logLevel === "fatal" ? "error" : workspaceConfig.logLevel : void 0, workspaceConfig?.mode || await getDefaultMode(cwd, root));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Load the user configuration file for the project and set up the context with the loaded configuration. This function will be called during the initialization of the context to load the user configuration file based on the provided options and set up the context accordingly. It will also set up the resolver for loading modules from the user configuration file and ensure that the context is properly initialized with the loaded configuration.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
|
|
111
|
+
*
|
|
112
|
+
* @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.
|
|
113
|
+
* @param root - The root directory of the project to look for the configuration file. This is typically the root directory of the project, which may be different from the current working directory if the process was executed from a subdirectory.
|
|
114
|
+
* @param framework - The name of the framework to use when looking for configuration files (default is "powerlines"). This is used to determine the naming convention for the configuration files to look for (e.g., `powerlines.development.config.js` for the "powerlines" framework in development mode).
|
|
115
|
+
* @param orgId - The name of the organization to use when looking for configuration files (optional). This can be used to further customize the naming convention for the configuration files to look for (e.g., `powerlines.myorg.development.config.js` for the "powerlines" framework in development mode with an organization of "myorg").
|
|
116
|
+
* @param inlineConfig - The inline configuration options provided during the execution of a Powerlines command, which can include properties such as the project root, mode, and an explicit path to a configuration file. This is used to determine how the context should be initialized and which configuration file should be loaded for the execution.
|
|
117
|
+
* @returns A promise that resolves when the context has been successfully initialized with the loaded configuration and resolver setup.
|
|
118
|
+
* @throws Will throw an error if no configuration file is found in the project root or current working directory. This ensures that the context cannot be initialized without a valid configuration, which is essential for the proper functioning of the Powerlines process.
|
|
119
|
+
*/
|
|
120
|
+
async function loadParsedConfig(cwd, root, framework, orgId, inlineConfig) {
|
|
121
|
+
const configFile = await loadUserConfigFile(cwd, root, inlineConfig.mode || await getDefaultMode(cwd, root), inlineConfig.command, {
|
|
122
|
+
name: framework,
|
|
123
|
+
orgId
|
|
124
|
+
}, inlineConfig.configFile);
|
|
125
|
+
if (!configFile) throw new Error(`No configuration file found in ${appendPath(root, cwd)}. Please ensure you have a valid configuration file in your project.`);
|
|
126
|
+
return configFile;
|
|
127
|
+
}
|
|
13
128
|
/**
|
|
14
129
|
* Loads the workspace configuration.
|
|
15
130
|
*
|
|
@@ -27,20 +142,44 @@ async function loadWorkspaceConfig(cwd, root) {
|
|
|
27
142
|
/**
|
|
28
143
|
* Loads the user configuration file for the project.
|
|
29
144
|
*
|
|
30
|
-
* @
|
|
31
|
-
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* This function will attempt to locate and load the user configuration file for the project based on the provided parameters. It will look for configuration files in various formats (e.g., `.ts`, `.js`, `.mts`, `.mjs`) and with different naming conventions (e.g., `powerlines.config.ts`, `powerlines.development.config.js`, etc.) in the project root and current working directory. If a configuration file is found, it will be loaded using a Jiti resolver, and the resulting configuration object will be returned. If no configuration file is found, an empty configuration object will be returned.
|
|
147
|
+
*
|
|
148
|
+
* @param cwd - The current working directory to start searching from.
|
|
149
|
+
* @param root - The root directory of the project.
|
|
150
|
+
* @param mode - The mode to determine which configuration file to load (e.g., "development", "test", "production").
|
|
151
|
+
* @param command - The command being executed (e.g., "build", "dev", "test"), which can be used to further customize the configuration loading logic if needed.
|
|
152
|
+
* @param framework - The name of the framework to use when looking for configuration files (default is "powerlines").
|
|
153
|
+
* @param configFile - An explicit path to a configuration file to load (optional). If provided, this file will be loaded instead of searching for configuration files based on the mode and framework.
|
|
32
154
|
* @returns A promise that resolves to the resolved user configuration.
|
|
33
155
|
*/
|
|
34
|
-
async function loadUserConfigFile(
|
|
156
|
+
async function loadUserConfigFile(cwd, root, mode, command, framework, configFile) {
|
|
157
|
+
const frameworkName = kebabCase(framework?.name || "powerlines");
|
|
158
|
+
const frameworkOrgId = kebabCase(framework?.orgId || "storm-software");
|
|
35
159
|
let resolvedUserConfig = {};
|
|
36
160
|
let resolvedUserConfigFile;
|
|
37
|
-
if (
|
|
38
|
-
if (!resolvedUserConfigFile) resolvedUserConfigFile = existsSync(joinPaths(appendPath(
|
|
161
|
+
if (configFile) resolvedUserConfigFile = existsSync(replacePath(configFile, root)) ? replacePath(configFile, root) : existsSync(joinPaths(appendPath(root, cwd), replacePath(configFile, root))) ? joinPaths(appendPath(root, cwd), replacePath(configFile, root)) : existsSync(joinPaths(appendPath(root, cwd), configFile)) ? joinPaths(appendPath(root, cwd), configFile) : void 0;
|
|
162
|
+
if (!resolvedUserConfigFile) resolvedUserConfigFile = existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.ts`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.ts`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.js`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.js`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.mts`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.mts`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.mjs`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.mjs`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.config.ts`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.config.ts`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.config.js`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.config.js`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.config.mts`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.config.mts`) : existsSync(joinPaths(appendPath(root, cwd), `${frameworkName}.config.mjs`)) ? joinPaths(appendPath(root, cwd), `${frameworkName}.config.mjs`) : void 0;
|
|
163
|
+
const jiti = createResolver({
|
|
164
|
+
cwd,
|
|
165
|
+
root,
|
|
166
|
+
cacheDir: getEnvPaths({
|
|
167
|
+
orgId: frameworkOrgId,
|
|
168
|
+
appId: frameworkName,
|
|
169
|
+
workspaceRoot: cwd
|
|
170
|
+
}).cache,
|
|
171
|
+
mode
|
|
172
|
+
});
|
|
39
173
|
if (resolvedUserConfigFile) {
|
|
40
174
|
const resolved = await jiti.import(jiti.esmResolve(resolvedUserConfigFile));
|
|
41
175
|
if (resolved?.default) {
|
|
42
176
|
let config = {};
|
|
43
|
-
if (isFunction(resolved.default)) config = await Promise.resolve(resolved.default(
|
|
177
|
+
if (isFunction(resolved.default)) config = await Promise.resolve(resolved.default({
|
|
178
|
+
root,
|
|
179
|
+
cwd,
|
|
180
|
+
mode,
|
|
181
|
+
command
|
|
182
|
+
}));
|
|
44
183
|
else if (isSetObject(resolved.default) || Array.isArray(resolved.default)) config = resolved.default;
|
|
45
184
|
if (isSetObject(config) || Array.isArray(config)) resolvedUserConfig = {
|
|
46
185
|
...config,
|
|
@@ -50,19 +189,18 @@ async function loadUserConfigFile(options, jiti) {
|
|
|
50
189
|
}
|
|
51
190
|
}
|
|
52
191
|
const result = await loadConfig({
|
|
53
|
-
cwd:
|
|
54
|
-
name:
|
|
55
|
-
envName:
|
|
192
|
+
cwd: root,
|
|
193
|
+
name: frameworkName,
|
|
194
|
+
envName: mode,
|
|
56
195
|
globalRc: true,
|
|
57
|
-
packageJson: camelCase(
|
|
196
|
+
packageJson: camelCase(frameworkName),
|
|
58
197
|
dotenv: true,
|
|
59
198
|
jiti
|
|
60
199
|
});
|
|
61
200
|
return defu({ config: {
|
|
62
|
-
root
|
|
63
|
-
cwd
|
|
64
|
-
framework
|
|
65
|
-
organization: options.organization
|
|
201
|
+
root,
|
|
202
|
+
cwd,
|
|
203
|
+
framework
|
|
66
204
|
} }, resolvedUserConfig, isSetObject(result?.config) ? {
|
|
67
205
|
...result.config,
|
|
68
206
|
...result
|
|
@@ -79,5 +217,5 @@ function defineConfig(config) {
|
|
|
79
217
|
}
|
|
80
218
|
|
|
81
219
|
//#endregion
|
|
82
|
-
export { defineConfig, loadUserConfigFile, loadWorkspaceConfig };
|
|
220
|
+
export { defineConfig, getDefaultLogLevel, getDefaultMode, loadParsedConfig, loadUserConfigFile, loadWorkspaceConfig, normalizeBasePath, resolvePackageConfigs, resolveRoot, tryResolveWorkspaceConfig };
|
|
83
221
|
//# sourceMappingURL=config.mjs.map
|
package/dist/lib/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":["loadConfigC12"],"sources":["../../src/lib/config.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 { getWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { loadConfig as loadConfigC12 } from \"c12\";\nimport defu from \"defu\";\nimport type { Jiti } from \"jiti\";\nimport type {\n ParsedUserConfig,\n ResolvedEngineOptions,\n UserConfig,\n WorkspaceConfig\n} from \"../types/config\";\nimport { AnyUserConfig } from \"../types/config\";\nimport { Context } from \"../types/context\";\n\nexport type PartiallyResolvedContext<TContext extends Context = Context> = Omit<\n TContext,\n \"config\" | \"tsconfig\" | \"entry\" | \"fs\" | \"compiler\" | \"unimport\"\n> &\n Partial<TContext> & {\n config: TContext[\"config\"];\n };\n\n/**\n * Loads the workspace configuration.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The current working directory to start searching from.\n * @returns A promise that resolves to the loaded workspace configuration.\n */\nexport async function loadWorkspaceConfig(\n cwd: string,\n root: string\n): Promise<WorkspaceConfig> {\n return defu(\n {\n workspaceRoot: cwd\n },\n await getWorkspaceConfig(true, {\n cwd: root,\n workspaceRoot: cwd,\n useDefault: true\n })\n );\n}\n\n/**\n * Loads the user configuration file for the project.\n *\n * @param options - The engine options containing the root, cwd, mode, framework, and organization.\n * @param jiti - An instance of Jiti to resolve modules from\n * @returns A promise that resolves to the resolved user configuration.\n */\nexport async function loadUserConfigFile(\n options: ResolvedEngineOptions,\n jiti: Jiti\n): Promise<ParsedUserConfig> {\n let resolvedUserConfig: Partial<ParsedUserConfig> = {};\n\n let resolvedUserConfigFile: string | undefined;\n if (options.configFile) {\n resolvedUserConfigFile = existsSync(\n replacePath(options.configFile, options.root)\n )\n ? replacePath(options.configFile, options.root)\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n replacePath(options.configFile, options.root)\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n replacePath(options.configFile, options.root)\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n options.configFile\n )\n )\n ? joinPaths(appendPath(options.root, options.cwd), options.configFile)\n : undefined;\n }\n\n if (!resolvedUserConfigFile) {\n resolvedUserConfigFile = existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.ts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.ts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.js`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.js`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mjs`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.ts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.ts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.js`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.js`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mjs`\n )\n : undefined;\n }\n\n if (resolvedUserConfigFile) {\n const resolved = await jiti.import<{ default: AnyUserConfig }>(\n jiti.esmResolve(resolvedUserConfigFile)\n );\n if (resolved?.default) {\n let config = {};\n if (isFunction(resolved.default)) {\n config = await Promise.resolve(resolved.default(options));\n } else if (\n isSetObject(resolved.default) ||\n Array.isArray(resolved.default)\n ) {\n config = resolved.default;\n }\n\n if (isSetObject(config) || Array.isArray(config)) {\n resolvedUserConfig = {\n ...config,\n config,\n configFile: resolvedUserConfigFile\n };\n }\n }\n }\n\n const result = await loadConfigC12({\n cwd: options.root,\n name: options.framework,\n envName: options.mode,\n globalRc: true,\n packageJson: camelCase(options.framework),\n dotenv: true,\n jiti\n });\n\n return defu(\n {\n config: {\n root: options.root,\n cwd: options.cwd,\n framework: options.framework,\n organization: options.organization\n }\n },\n resolvedUserConfig,\n isSetObject(result?.config) ? { ...result.config, ...result } : {}\n );\n}\n\n/**\n * A type helper to make it easier to use `powerlines.config.ts` files.\n *\n * @remarks\n * The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.\n */\nexport function defineConfig(config: AnyUserConfig): UserConfig {\n return config as any;\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"config.mjs","names":["loadConfigC12"],"sources":["../../src/lib/config.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 {\n getWorkspaceConfig,\n tryGetWorkspaceConfig\n} from \"@storm-software/config-tools/get-config\";\nimport {\n isDevelopment,\n isProduction,\n isTest\n} from \"@stryke/env/environment-checks\";\nimport { getEnvPaths } from \"@stryke/env/get-env-paths\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { isFile } from \"@stryke/fs/is-file\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\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 { PartialKeys } from \"@stryke/types/base\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig as loadConfigC12 } from \"c12\";\nimport defu from \"defu\";\nimport { resolveLogLevel } from \"../plugin-utils/logging\";\nimport type {\n FrameworkOptions,\n InlineConfig,\n Mode,\n ParsedUserConfig,\n UserConfig,\n WorkspaceConfig\n} from \"../types/config\";\nimport { AnyUserConfig } from \"../types/config\";\nimport { Context } from \"../types/context\";\nimport { LogLevelResolvedConfig } from \"../types/logging\";\nimport { createResolver } from \"./resolver\";\n\nexport function normalizeBasePath(base: string = \"/\"): string {\n let out = base.startsWith(\"/\") ? base : `/${base}`;\n if (!out.endsWith(\"/\")) out = `${out}/`;\n return out.replace(/\\/+/g, \"/\");\n}\n\nexport interface ResolvePackageConfigsResult {\n /**\n * The parsed `package.json` file for the project, if it exists. This file typically contains metadata about the project, such as its name, version, dependencies, and other information relevant to the build process.\n */\n packageJson?: PackageJson;\n\n /**\n * The parsed `project.json` file for the project, if it exists. This file is an optional configuration file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.\n */\n projectJson?: Record<string, unknown>;\n}\n\n/**\n * Resolve the package configurations for the project by loading the `package.json` and `project.json` files, if they exist. This function will look for these files in the project root and parse their contents as JavaScript objects. The parsed contents will be stored in the context for later use by plugins and other parts of the build process.\n *\n * @remarks\n * The `package.json` file is typically used to store metadata about the project, such as its name, version, dependencies, and other information. The `project.json` file is an optional file that can be used to store additional configuration or metadata specific to the project, and is not required for all projects.\n *\n * @param cwd - The current working directory to look for the package configurations. Defaults to the `cwd` specified in the context configuration.\n * @param root - The root directory of the project to look for the package configurations. Defaults to the `root` specified in the context configuration.\n * @returns A promise that resolves when the package configurations have been loaded and stored in the context.\n */\nexport async function resolvePackageConfigs(\n cwd: string,\n root: string\n): Promise<ResolvePackageConfigsResult> {\n const result: ResolvePackageConfigsResult = {};\n if (cwd || root) {\n const projectJsonPath = joinPaths(\n appendPath(root || \".\", cwd || \".\"),\n \"project.json\"\n );\n if (existsSync(projectJsonPath)) {\n result.projectJson = await readJsonFile(projectJsonPath);\n }\n\n const packageJsonPath = joinPaths(\n appendPath(root || \".\", cwd || \".\"),\n \"package.json\"\n );\n if (existsSync(packageJsonPath)) {\n result.packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n }\n }\n\n return result;\n}\n\n/**\n * Resolve the root directory for the project based on the provided options. This function will determine the root directory by checking the provided `root` option, and if it is not provided, it will look for a configuration file (such as `powerlines.config.ts`) in the current working directory. If a configuration file is found, the root directory will be set to the directory containing that file. If no configuration file is found, the root directory will default to the current working directory.\n *\n * @param cwd - The current working directory to use as the base for resolving the root directory. This is typically the directory from which the Powerlines process was executed.\n * @param root - An optional root directory to use for the project. If provided, this will be used as the root directory instead of looking for a configuration file. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.\n * @param configFile - An optional path to a configuration file to look for when resolving the root directory. If provided, this file will be used to determine the root directory if the `root` option is not provided. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.\n * @returns The resolved root directory for the project, which will be used as the base for resolving other paths and configurations throughout the Powerlines process. This will typically be an absolute path to the root directory of the project.\n */\nexport function resolveRoot(\n cwd: string,\n root?: string,\n configFile?: string\n): string {\n let result = root || \".\";\n if (!root) {\n if (configFile) {\n const configFilePath = appendPath(configFile, cwd);\n if (!existsSync(configFilePath)) {\n throw new Error(\n `The user-provided configuration file at \"${configFile}\" does not exist. Please ensure this path is correct and try again.`\n );\n }\n if (!isFile(configFile)) {\n throw new Error(\n `The user-provided configuration file at \"${\n configFile\n }\" is not a file. Please ensure this path is correct and try again.`\n );\n }\n\n result = relativePath(cwd, findFilePath(configFile));\n }\n } else {\n result = replacePath(root, cwd);\n }\n\n return result;\n}\n\n/**\n * Retrieve the workspace configuration for the current project, if it exists. This function will look for a configuration file in the project root and return its contents as a JavaScript object. If no configuration file is found, it will return undefined.\n *\n * @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.\n * @param root - An optional root directory to use as the base for searching for the configuration file. If provided, this will be used as the starting point for searching for the configuration file instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.\n * @returns A promise that resolves to the workspace configuration object, or undefined if no configuration file is found.\n */\nexport async function tryResolveWorkspaceConfig(\n cwd: string,\n root?: string\n): Promise<WorkspaceConfig | undefined> {\n return tryGetWorkspaceConfig(false, {\n cwd: root ? appendPath(root, cwd) : undefined,\n workspaceRoot: cwd\n });\n}\n\n/**\n * Determine the default mode for the current execution based on the environment and workspace configuration. This function will check the `NODE_ENV` environment variable to determine if the current environment is development, production, or test. If `NODE_ENV` is not set, it will look for a `mode` property in the workspace configuration file. If no mode is specified in the workspace configuration, it will default to \"production\".\n *\n * @remarks\n * The mode is used to determine which configuration file to load (e.g., `powerlines.development.config.js` for development mode, `powerlines.production.config.js` for production mode, etc.) and can also be used by plugins and other parts of the build process to conditionally apply certain behaviors based on the current mode.\n *\n * @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.\n * @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.\n * @returns A promise that resolves to the default mode for the current execution, which can be \"development\", \"production\", or \"test\".\n */\nexport async function getDefaultMode(\n cwd: string,\n root?: string\n): Promise<Mode> {\n const workspaceConfig = await tryResolveWorkspaceConfig(cwd, root);\n\n return isProduction\n ? \"production\"\n : isDevelopment\n ? \"development\"\n : isTest\n ? \"test\"\n : workspaceConfig?.mode || \"production\";\n}\n\n/**\n * Determine the default log level for the current execution based on the environment and workspace configuration. This function will check the `logLevel` property in the workspace configuration file and resolve it to a `LogLevelResolvedConfig` value. If no log level is specified in the workspace configuration, it will default to \"info\" for development mode and \"warn\" for production mode.\n *\n * @remarks\n * The log level is used to determine which log messages should be output during the execution of the Powerlines process. For example, if the log level is set to \"warn\", only messages with a level of \"warn\", \"error\", or \"fatal\" will be output, while messages with a level of \"info\", \"debug\", or \"trace\" will be suppressed. This allows users to control the verbosity of the logs and focus on the most relevant information based on their current needs.\n *\n * @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.\n * @param root - An optional root directory to use as the base for searching for the workspace configuration. If provided, this will be used as the starting point for searching for the workspace configuration instead of the current working directory. This can be an absolute or relative path, and if it is relative, it will be resolved based on the current working directory.\n * @returns A promise that resolves to the default log level for the current execution, which can be \"fatal\", \"error\", \"warn\", \"info\", \"debug\", or \"trace\".\n */\nexport async function getDefaultLogLevel(\n cwd: string,\n root?: string\n): Promise<LogLevelResolvedConfig> {\n const workspaceConfig = await tryResolveWorkspaceConfig(cwd, root);\n\n return resolveLogLevel(\n workspaceConfig?.logLevel\n ? workspaceConfig.logLevel === \"success\" ||\n workspaceConfig.logLevel === \"performance\"\n ? \"info\"\n : workspaceConfig.logLevel === \"all\"\n ? \"debug\"\n : workspaceConfig.logLevel === \"fatal\"\n ? \"error\"\n : workspaceConfig.logLevel\n : undefined,\n workspaceConfig?.mode || (await getDefaultMode(cwd, root))\n );\n}\n\n/**\n * Load the user configuration file for the project and set up the context with the loaded configuration. This function will be called during the initialization of the context to load the user configuration file based on the provided options and set up the context accordingly. It will also set up the resolver for loading modules from the user configuration file and ensure that the context is properly initialized with the loaded configuration.\n *\n * @remarks\n * This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.\n *\n * @param cwd - The current working directory to start searching from. This is typically the directory from which the Powerlines process was executed.\n * @param root - The root directory of the project to look for the configuration file. This is typically the root directory of the project, which may be different from the current working directory if the process was executed from a subdirectory.\n * @param framework - The name of the framework to use when looking for configuration files (default is \"powerlines\"). This is used to determine the naming convention for the configuration files to look for (e.g., `powerlines.development.config.js` for the \"powerlines\" framework in development mode).\n * @param orgId - The name of the organization to use when looking for configuration files (optional). This can be used to further customize the naming convention for the configuration files to look for (e.g., `powerlines.myorg.development.config.js` for the \"powerlines\" framework in development mode with an organization of \"myorg\").\n * @param inlineConfig - The inline configuration options provided during the execution of a Powerlines command, which can include properties such as the project root, mode, and an explicit path to a configuration file. This is used to determine how the context should be initialized and which configuration file should be loaded for the execution.\n * @returns A promise that resolves when the context has been successfully initialized with the loaded configuration and resolver setup.\n * @throws Will throw an error if no configuration file is found in the project root or current working directory. This ensures that the context cannot be initialized without a valid configuration, which is essential for the proper functioning of the Powerlines process.\n */\nexport async function loadParsedConfig(\n cwd: string,\n root: string,\n framework: string,\n orgId: string,\n inlineConfig: InlineConfig\n) {\n const mode = inlineConfig.mode || (await getDefaultMode(cwd, root));\n\n const configFile = await loadUserConfigFile(\n cwd,\n root,\n mode,\n inlineConfig.command,\n { name: framework, orgId },\n inlineConfig.configFile\n );\n if (!configFile) {\n throw new Error(\n `No configuration file found in ${appendPath(\n root,\n cwd\n )}. Please ensure you have a valid configuration file in your project.`\n );\n }\n\n return configFile;\n}\n\nexport type PartiallyResolvedContext<TContext extends Context = Context> = Omit<\n TContext,\n \"config\" | \"tsconfig\" | \"entry\" | \"fs\" | \"compiler\" | \"unimport\"\n> &\n Partial<TContext> & {\n config: TContext[\"config\"];\n };\n\n/**\n * Loads the workspace configuration.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The current working directory to start searching from.\n * @returns A promise that resolves to the loaded workspace configuration.\n */\nexport async function loadWorkspaceConfig(\n cwd: string,\n root: string\n): Promise<WorkspaceConfig> {\n return defu(\n {\n workspaceRoot: cwd\n },\n await getWorkspaceConfig(true, {\n cwd: root,\n workspaceRoot: cwd,\n useDefault: true\n })\n );\n}\n\n/**\n * Loads the user configuration file for the project.\n *\n * @remarks\n * This function will attempt to locate and load the user configuration file for the project based on the provided parameters. It will look for configuration files in various formats (e.g., `.ts`, `.js`, `.mts`, `.mjs`) and with different naming conventions (e.g., `powerlines.config.ts`, `powerlines.development.config.js`, etc.) in the project root and current working directory. If a configuration file is found, it will be loaded using a Jiti resolver, and the resulting configuration object will be returned. If no configuration file is found, an empty configuration object will be returned.\n *\n * @param cwd - The current working directory to start searching from.\n * @param root - The root directory of the project.\n * @param mode - The mode to determine which configuration file to load (e.g., \"development\", \"test\", \"production\").\n * @param command - The command being executed (e.g., \"build\", \"dev\", \"test\"), which can be used to further customize the configuration loading logic if needed.\n * @param framework - The name of the framework to use when looking for configuration files (default is \"powerlines\").\n * @param configFile - An explicit path to a configuration file to load (optional). If provided, this file will be loaded instead of searching for configuration files based on the mode and framework.\n * @returns A promise that resolves to the resolved user configuration.\n */\nexport async function loadUserConfigFile(\n cwd: string,\n root: string,\n mode: Mode,\n command: string,\n framework?: PartialKeys<FrameworkOptions, \"orgId\">,\n configFile?: string\n): Promise<ParsedUserConfig> {\n const frameworkName = kebabCase(framework?.name || \"powerlines\");\n const frameworkOrgId = kebabCase(framework?.orgId || \"storm-software\");\n\n let resolvedUserConfig: Partial<ParsedUserConfig> = {};\n\n let resolvedUserConfigFile: string | undefined;\n if (configFile) {\n resolvedUserConfigFile = existsSync(replacePath(configFile, root))\n ? replacePath(configFile, root)\n : existsSync(\n joinPaths(appendPath(root, cwd), replacePath(configFile, root))\n )\n ? joinPaths(appendPath(root, cwd), replacePath(configFile, root))\n : existsSync(joinPaths(appendPath(root, cwd), configFile))\n ? joinPaths(appendPath(root, cwd), configFile)\n : undefined;\n }\n\n if (!resolvedUserConfigFile) {\n resolvedUserConfigFile = existsSync(\n joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.ts`)\n )\n ? joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.ts`)\n : existsSync(\n joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.${mode}.config.js`\n )\n )\n ? joinPaths(appendPath(root, cwd), `${frameworkName}.${mode}.config.js`)\n : existsSync(\n joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.${mode}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.${mode}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.${mode}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.${mode}.config.mjs`\n )\n : existsSync(\n joinPaths(appendPath(root, cwd), `${frameworkName}.config.ts`)\n )\n ? joinPaths(appendPath(root, cwd), `${frameworkName}.config.ts`)\n : existsSync(\n joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.config.js`\n )\n )\n ? joinPaths(appendPath(root, cwd), `${frameworkName}.config.js`)\n : existsSync(\n joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(root, cwd),\n `${frameworkName}.config.mjs`\n )\n : undefined;\n }\n\n const envPaths = getEnvPaths({\n orgId: frameworkOrgId,\n appId: frameworkName,\n workspaceRoot: cwd\n });\n\n const jiti = createResolver({\n cwd,\n root,\n cacheDir: envPaths.cache,\n mode\n });\n\n if (resolvedUserConfigFile) {\n const resolved = await jiti.import<{ default: AnyUserConfig }>(\n jiti.esmResolve(resolvedUserConfigFile)\n );\n if (resolved?.default) {\n let config = {};\n if (isFunction(resolved.default)) {\n config = await Promise.resolve(\n resolved.default({ root, cwd, mode, command })\n );\n } else if (\n isSetObject(resolved.default) ||\n Array.isArray(resolved.default)\n ) {\n config = resolved.default;\n }\n\n if (isSetObject(config) || Array.isArray(config)) {\n resolvedUserConfig = {\n ...config,\n config,\n configFile: resolvedUserConfigFile\n };\n }\n }\n }\n\n const result = await loadConfigC12({\n cwd: root,\n name: frameworkName,\n envName: mode,\n globalRc: true,\n packageJson: camelCase(frameworkName),\n dotenv: true,\n jiti\n });\n\n return defu(\n {\n config: {\n root,\n cwd,\n framework\n }\n },\n resolvedUserConfig,\n isSetObject(result?.config) ? { ...result.config, ...result } : {}\n );\n}\n\n/**\n * A type helper to make it easier to use `powerlines.config.ts` files.\n *\n * @remarks\n * The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.\n */\nexport function defineConfig(config: AnyUserConfig): UserConfig {\n return config as any;\n}\n"],"mappings":"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"}
|