@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
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { DEFAULT_ENVIRONMENT } from "../constants/environments.mjs";
|
|
2
|
+
import { PLUGIN_NON_HOOK_FIELDS } from "../constants/plugin.mjs";
|
|
3
|
+
import { dedupeHooklist, isPlugin, isPluginConfig, isPluginHookField } from "../plugin-utils/helpers.mjs";
|
|
4
|
+
import { mergeConfig } from "../plugin-utils/merge.mjs";
|
|
5
|
+
import { formatConfig } from "../plugin-utils/format.mjs";
|
|
6
|
+
import "../plugin-utils/index.mjs";
|
|
7
|
+
import { extractHooks } from "../lib/hooks.mjs";
|
|
8
|
+
import "../constants/index.mjs";
|
|
9
|
+
import { resolvePlugins } from "../lib/plugins.mjs";
|
|
10
|
+
import { PowerlinesContext } from "./context.mjs";
|
|
11
|
+
import { createPluginContext } from "./plugin-context.mjs";
|
|
12
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
13
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
14
|
+
import { uuid } from "@stryke/unique-id/uuid";
|
|
15
|
+
import { isObject } from "@stryke/type-checks/is-object";
|
|
16
|
+
import { omit } from "@stryke/helpers/omit";
|
|
17
|
+
|
|
18
|
+
//#region src/context/environment-context.ts
|
|
19
|
+
var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends PowerlinesContext {
|
|
20
|
+
/**
|
|
21
|
+
* The hooks registered by plugins in this environment
|
|
22
|
+
*/
|
|
23
|
+
#hooks = {};
|
|
24
|
+
/**
|
|
25
|
+
* The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.
|
|
26
|
+
*/
|
|
27
|
+
#execution;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new context from the config.
|
|
30
|
+
*
|
|
31
|
+
* @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.
|
|
32
|
+
* @param options - The resolved execution options.
|
|
33
|
+
* @param config - The user configuration options.
|
|
34
|
+
* @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.
|
|
35
|
+
* @returns A promise that resolves to an instance of the PowerlinesEnvironmentContext class, initialized with the provided configuration and environment data.
|
|
36
|
+
*/
|
|
37
|
+
static async from(execution, options, config, overriddenConfig) {
|
|
38
|
+
const context = new PowerlinesEnvironmentContext(execution, options, config, overriddenConfig);
|
|
39
|
+
await context.init();
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The configuration options provided by plugins added by the user (and other plugins)
|
|
44
|
+
*/
|
|
45
|
+
environmentConfig = {};
|
|
46
|
+
/**
|
|
47
|
+
* The list of plugins applied to this environment
|
|
48
|
+
*/
|
|
49
|
+
plugins = [];
|
|
50
|
+
/**
|
|
51
|
+
* The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.
|
|
52
|
+
*/
|
|
53
|
+
get id() {
|
|
54
|
+
return this.config.environment.id;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The hooks registered by plugins in this environment
|
|
58
|
+
*/
|
|
59
|
+
get hooks() {
|
|
60
|
+
return this.#hooks;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.
|
|
64
|
+
*
|
|
65
|
+
* @danger
|
|
66
|
+
* This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
|
|
67
|
+
*
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
get unstable_execution() {
|
|
71
|
+
return this.#execution;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A setter function to populate the environment config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the environment configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any environment configuration provided during execution.
|
|
75
|
+
*
|
|
76
|
+
* @param config - The environment configuration values to set.
|
|
77
|
+
* @returns A promise that resolves when the environment configuration values have been set.
|
|
78
|
+
*/
|
|
79
|
+
async setEnvironmentConfig(config) {
|
|
80
|
+
this.logger.debug({
|
|
81
|
+
meta: { category: "config" },
|
|
82
|
+
message: `Updating environment configuration object: \n${formatConfig(config)}`
|
|
83
|
+
});
|
|
84
|
+
this.environmentConfig = config;
|
|
85
|
+
await this.resolveConfig();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a new logger instance
|
|
89
|
+
*
|
|
90
|
+
* @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
|
|
91
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
92
|
+
*/
|
|
93
|
+
createLogger(options) {
|
|
94
|
+
return super.createLogger({
|
|
95
|
+
...options,
|
|
96
|
+
environment: this.environmentConfig?.name || this.config.environment?.name
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Extend the base logger with additional configuration options
|
|
101
|
+
*
|
|
102
|
+
* @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
|
|
103
|
+
* @returns A new logger client instance that extends the base logger with the provided configuration options.
|
|
104
|
+
*/
|
|
105
|
+
extendLogger(options) {
|
|
106
|
+
return super.extendLogger({
|
|
107
|
+
...options,
|
|
108
|
+
environment: this.environmentConfig?.name || this.config.environment?.name
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A function used internally to add a plugin to the context and update the configuration options
|
|
113
|
+
*
|
|
114
|
+
* @danger
|
|
115
|
+
* This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
async unstable_addPlugin(plugin) {
|
|
120
|
+
const plugins = await resolvePlugins(this, plugin);
|
|
121
|
+
for (const plugin of plugins) {
|
|
122
|
+
let resolvedPlugin = plugin;
|
|
123
|
+
if (isFunction(plugin.applyToEnvironment)) {
|
|
124
|
+
const result = await Promise.resolve(plugin.applyToEnvironment(this.config.environment));
|
|
125
|
+
if (!result || isObject(result) && Object.keys(result).length === 0) return;
|
|
126
|
+
if (isPluginConfig(result)) return this.unstable_addPlugin(result);
|
|
127
|
+
resolvedPlugin = isPlugin(result) ? result : plugin;
|
|
128
|
+
}
|
|
129
|
+
const id = uuid();
|
|
130
|
+
const context = createPluginContext(id, resolvedPlugin, this);
|
|
131
|
+
resolvedPlugin.$$internal = {
|
|
132
|
+
id,
|
|
133
|
+
context
|
|
134
|
+
};
|
|
135
|
+
this.plugins.push(resolvedPlugin);
|
|
136
|
+
this.#hooks = Object.entries(Object.keys(resolvedPlugin).filter((key) => key !== "$$internal" && !PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => extractHooks(context, ret, resolvedPlugin, key), this.hooks)).reduce((ret, [key, value]) => {
|
|
137
|
+
if (isSetObject(value)) Object.entries(value).forEach(([type, list]) => {
|
|
138
|
+
ret[key] ??= {};
|
|
139
|
+
ret[key][type] = dedupeHooklist(list);
|
|
140
|
+
});
|
|
141
|
+
return ret;
|
|
142
|
+
}, {});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Retrieves the hook handlers for a specific hook name
|
|
147
|
+
*/
|
|
148
|
+
selectHooks(key, options) {
|
|
149
|
+
const result = [];
|
|
150
|
+
if (isPluginHookField(key) && this.hooks[key]) {
|
|
151
|
+
if (this.hooks[key]) if (options?.order) {
|
|
152
|
+
const mapHooksToResult = (hooksList) => hooksList.map((hook) => {
|
|
153
|
+
const plugin = this.plugins.find((p) => p.name === hook.plugin.name);
|
|
154
|
+
if (!plugin) throw new Error(`Could not find plugin context for plugin "${hook.plugin.name}".`);
|
|
155
|
+
return {
|
|
156
|
+
handler: hook.handler,
|
|
157
|
+
plugin: hook.plugin,
|
|
158
|
+
context: plugin.$$internal.context
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
if (options?.order === "pre") {
|
|
162
|
+
result.push(...mapHooksToResult(this.hooks[key].preOrdered ?? []));
|
|
163
|
+
result.push(...mapHooksToResult(this.hooks[key].preEnforced ?? []));
|
|
164
|
+
} else if (options?.order === "post") {
|
|
165
|
+
result.push(...mapHooksToResult(this.hooks[key].postOrdered ?? []));
|
|
166
|
+
result.push(...mapHooksToResult(this.hooks[key].postEnforced ?? []));
|
|
167
|
+
} else result.push(...mapHooksToResult(this.hooks[key].normal ?? []));
|
|
168
|
+
} else {
|
|
169
|
+
result.push(...this.selectHooks(key, { order: "pre" }));
|
|
170
|
+
result.push(...this.selectHooks(key, { order: "normal" }));
|
|
171
|
+
result.push(...this.selectHooks(key, { order: "post" }));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A function to add a plugin to the context and update the configuration options. This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state. It should not be called directly by external code, as it is intended for internal use only and may be subject to change without warning.
|
|
181
|
+
*
|
|
182
|
+
* @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.
|
|
183
|
+
* @param options - The configuration options for the plugin, which may include properties such as the plugin name, hooks, and any other relevant metadata or settings that should be associated with the plugin when it is added to the context.
|
|
184
|
+
* @param config - The resolved configuration for the environment, which may include properties such as the environment name, SSR settings, and other relevant configuration options that may affect how the plugin is applied to the environment.
|
|
185
|
+
* @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.
|
|
186
|
+
* @returns A promise that resolves when the plugin has been added to the context and the configuration has been updated accordingly.
|
|
187
|
+
*/
|
|
188
|
+
constructor(execution, options, config, overriddenConfig) {
|
|
189
|
+
super(options);
|
|
190
|
+
this.#execution = execution;
|
|
191
|
+
this.userConfig = config.userConfig ?? {};
|
|
192
|
+
this.inlineConfig = config.inlineConfig ?? {};
|
|
193
|
+
this.pluginConfig = config.pluginConfig ?? {};
|
|
194
|
+
this.overriddenConfig = overriddenConfig;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.
|
|
198
|
+
*
|
|
199
|
+
* @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.
|
|
200
|
+
*/
|
|
201
|
+
mergeConfig() {
|
|
202
|
+
return mergeConfig({
|
|
203
|
+
...omit(this.environmentConfig ?? {}, [
|
|
204
|
+
"name",
|
|
205
|
+
"ssr",
|
|
206
|
+
"preview",
|
|
207
|
+
"consumer",
|
|
208
|
+
"runtime"
|
|
209
|
+
]),
|
|
210
|
+
environment: { name: this.environmentConfig?.name || "default" },
|
|
211
|
+
environmentConfig: this.environmentConfig ?? {}
|
|
212
|
+
}, super.mergeConfig());
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
export { PowerlinesEnvironmentContext };
|
|
218
|
+
//# sourceMappingURL=environment-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-context.mjs","names":["#hooks","#execution"],"sources":["../../src/context/environment-context.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 { omit } from \"@stryke/helpers/omit\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { ArrayValues } from \"@stryke/types/array\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { DEFAULT_ENVIRONMENT, PLUGIN_NON_HOOK_FIELDS } from \"../constants\";\nimport { extractHooks } from \"../lib/hooks\";\nimport { resolvePlugins } from \"../lib/plugins\";\nimport {\n dedupeHooklist,\n formatConfig,\n isPlugin,\n isPluginConfig,\n isPluginHookField,\n mergeConfig\n} from \"../plugin-utils\";\nimport type {\n EnvironmentContext,\n EnvironmentPlugin,\n EnvironmentResolvedConfig,\n ExecutionContext,\n ExecutionOptions,\n HooksList,\n HooksListItem,\n InferOverridableConfig,\n Logger,\n LoggerOptions,\n PluginConfig,\n PluginContext,\n ResolvedConfig,\n SelectHookResult,\n SelectHooksOptions\n} from \"../types\";\nimport { PowerlinesContext } from \"./context\";\nimport { createPluginContext } from \"./plugin-context\";\n\nexport class PowerlinesEnvironmentContext<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n>\n extends PowerlinesContext<\n EnvironmentResolvedConfig<TResolvedConfig>,\n TSystemContext\n >\n implements EnvironmentContext<TResolvedConfig, TSystemContext>\n{\n /**\n * The hooks registered by plugins in this environment\n */\n #hooks: Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n > = {};\n\n /**\n * The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n */\n #execution: ExecutionContext<TResolvedConfig, TSystemContext>;\n\n /**\n * Create a new context from the config.\n *\n * @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n * @param options - The resolved execution options.\n * @param config - The user configuration options.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @returns A promise that resolves to an instance of the PowerlinesEnvironmentContext class, initialized with the provided configuration and environment data.\n */\n public static async from<\n TResolvedConfig extends ResolvedConfig = ResolvedConfig,\n TSystemContext = unknown\n >(\n execution: ExecutionContext<TResolvedConfig, TSystemContext>,\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>> {\n const context = new PowerlinesEnvironmentContext<\n TResolvedConfig,\n TSystemContext\n >(execution, options, config, overriddenConfig);\n await context.init();\n\n return context;\n }\n\n /**\n * The configuration options provided by plugins added by the user (and other plugins)\n */\n protected override environmentConfig: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"] =\n {} as EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"];\n\n /**\n * The list of plugins applied to this environment\n */\n public plugins: EnvironmentPlugin<TResolvedConfig, TSystemContext>[] = [];\n\n /**\n * The unique identifier of the environment associated with this context, which can be used for logging and other purposes to distinguish between different environments in the same process.\n */\n public get id(): string {\n return this.config.environment.id;\n }\n\n /**\n * The hooks registered by plugins in this environment\n */\n public get hooks(): Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n > {\n return this.#hooks;\n }\n\n /**\n * The execution context associated with this environment, which provides access to the project configuration, environment, and utility functions for performing the build. The execution context is used to manage the state and behavior of the build process across multiple environments, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public get unstable_execution(): ExecutionContext<\n TResolvedConfig,\n TSystemContext\n > {\n return this.#execution;\n }\n\n /**\n * A setter function to populate the environment config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the environment configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any environment configuration provided during execution.\n *\n * @param config - The environment configuration values to set.\n * @returns A promise that resolves when the environment configuration values have been set.\n */\n public async setEnvironmentConfig(\n config: EnvironmentResolvedConfig<TResolvedConfig>[\"environment\"]\n ): Promise<void> {\n this.logger.debug({\n meta: { category: \"config\" },\n message: `Updating environment configuration object: \\n${formatConfig(config)}`\n });\n\n this.environmentConfig = config;\n await this.resolveConfig();\n }\n\n /**\n * Create a new logger instance\n *\n * @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.\n * @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.\n */\n public override createLogger(options: LoggerOptions): Logger {\n return super.createLogger({\n ...options,\n environment: this.environmentConfig?.name || this.config.environment?.name\n });\n }\n\n /**\n * Extend the base logger with additional configuration options\n *\n * @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.\n * @returns A new logger client instance that extends the base logger with the provided configuration options.\n */\n public override extendLogger(options: LoggerOptions): Logger {\n return super.extendLogger({\n ...options,\n environment: this.environmentConfig?.name || this.config.environment?.name\n });\n }\n\n /**\n * A function used internally to add a plugin to the context and update the configuration options\n *\n * @danger\n * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.\n *\n * @internal\n */\n public async unstable_addPlugin(\n plugin: PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>\n ): Promise<void> {\n const plugins = await resolvePlugins<TResolvedConfig, TSystemContext>(\n this,\n plugin\n );\n for (const plugin of plugins) {\n let resolvedPlugin = plugin as EnvironmentPlugin<\n TResolvedConfig,\n TSystemContext\n >;\n if (isFunction(plugin.applyToEnvironment)) {\n const result = (await Promise.resolve(\n plugin.applyToEnvironment(this.config.environment) as Promise<any>\n )) as\n | boolean\n | PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>;\n\n if (!result || (isObject(result) && Object.keys(result).length === 0)) {\n return;\n }\n\n if (\n isPluginConfig<PluginContext<TResolvedConfig, TSystemContext>>(result)\n ) {\n return this.unstable_addPlugin(result);\n }\n\n resolvedPlugin = (\n isPlugin<PluginContext<TResolvedConfig, TSystemContext>>(result)\n ? result\n : plugin\n ) as EnvironmentPlugin<TResolvedConfig, TSystemContext>;\n }\n\n const id = uuid();\n const context = createPluginContext<TResolvedConfig, TSystemContext>(\n id,\n resolvedPlugin,\n this\n );\n\n resolvedPlugin.$$internal = {\n id,\n context\n };\n\n this.plugins.push(resolvedPlugin);\n\n this.#hooks = Object.entries(\n Object.keys(resolvedPlugin)\n .filter(\n key =>\n key !== \"$$internal\" &&\n !PLUGIN_NON_HOOK_FIELDS.includes(\n key as ArrayValues<typeof PLUGIN_NON_HOOK_FIELDS>\n )\n )\n .reduce(\n (ret, key) =>\n extractHooks<TResolvedConfig, TSystemContext>(\n context,\n ret,\n resolvedPlugin,\n key\n ),\n this.hooks\n )\n ).reduce(\n (ret, [key, value]) => {\n if (isSetObject(value)) {\n Object.entries(value).forEach(([type, list]) => {\n ret[key] ??= {};\n ret[key][type as keyof (typeof ret)[typeof key]] =\n dedupeHooklist<PluginContext<TResolvedConfig, TSystemContext>>(\n list\n );\n });\n }\n\n return ret;\n },\n {} as Record<\n string,\n HooksList<PluginContext<TResolvedConfig, TSystemContext>>\n >\n );\n }\n }\n\n /**\n * Retrieves the hook handlers for a specific hook name\n */\n public selectHooks<TKey extends string>(\n key: TKey,\n options?: SelectHooksOptions\n ): SelectHookResult<PluginContext<TResolvedConfig, TSystemContext>, TKey> {\n const result = [] as SelectHookResult<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >;\n\n if (\n isPluginHookField<PluginContext<TResolvedConfig, TSystemContext>>(key) &&\n this.hooks[key]\n ) {\n if (this.hooks[key]) {\n if (options?.order) {\n const mapHooksToResult = (\n hooksList: HooksListItem<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n >[]\n ): SelectHookResult<\n PluginContext<TResolvedConfig, TSystemContext>,\n TKey\n > =>\n hooksList.map(hook => {\n const plugin = this.plugins.find(\n p => p.name === hook.plugin.name\n );\n if (!plugin) {\n throw new Error(\n `Could not find plugin context for plugin \"${\n hook.plugin.name\n }\".`\n );\n }\n\n return {\n handler: hook.handler,\n plugin: hook.plugin,\n context: plugin.$$internal.context\n };\n });\n\n if (options?.order === \"pre\") {\n result.push(...mapHooksToResult(this.hooks[key].preOrdered ?? []));\n result.push(...mapHooksToResult(this.hooks[key].preEnforced ?? []));\n } else if (options?.order === \"post\") {\n result.push(...mapHooksToResult(this.hooks[key].postOrdered ?? []));\n result.push(\n ...mapHooksToResult(this.hooks[key].postEnforced ?? [])\n );\n } else {\n result.push(...mapHooksToResult(this.hooks[key].normal ?? []));\n }\n } else {\n result.push(...this.selectHooks(key, { order: \"pre\" }));\n result.push(...this.selectHooks(key, { order: \"normal\" }));\n result.push(...this.selectHooks(key, { order: \"post\" }));\n }\n }\n }\n\n return result;\n }\n\n /**\n * A function to add a plugin to the context and update the configuration options. This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state.\n *\n * @remarks\n * This function is used internally when applying plugins to the environment, and it ensures that the plugin is added to the list of plugins in the context and that any hooks or configuration options provided by the plugin are properly integrated into the context's state. It should not be called directly by external code, as it is intended for internal use only and may be subject to change without warning.\n *\n * @param execution - The execution context for the build process, which provides access to the project configuration, environment, and utility functions for performing the build. The context is used to manage the state and behavior of the build process, allowing for hooks to be called at different stages of the build and for environment-specific configurations to be applied.\n * @param options - The configuration options for the plugin, which may include properties such as the plugin name, hooks, and any other relevant metadata or settings that should be associated with the plugin when it is added to the context.\n * @param config - The resolved configuration for the environment, which may include properties such as the environment name, SSR settings, and other relevant configuration options that may affect how the plugin is applied to the environment.\n * @param overriddenConfig - The configuration options that should override all other configuration sources, such as CLI flags or environment variables. This is used to ensure that certain configuration values take precedence over any other settings defined in the user configuration or environment configuration, allowing for dynamic overrides based on the execution context.\n * @returns A promise that resolves when the plugin has been added to the context and the configuration has been updated accordingly.\n */\n protected constructor(\n execution: ExecutionContext<TResolvedConfig, TSystemContext>,\n options: ExecutionOptions,\n config: TResolvedConfig,\n overriddenConfig: InferOverridableConfig<\n EnvironmentResolvedConfig<TResolvedConfig>\n >\n ) {\n super(options);\n\n this.#execution = execution;\n this.userConfig =\n config.userConfig ?? ({} as TResolvedConfig[\"userConfig\"]);\n this.inlineConfig =\n config.inlineConfig ?? ({} as TResolvedConfig[\"inlineConfig\"]);\n this.pluginConfig = config.pluginConfig ?? {};\n this.overriddenConfig = overriddenConfig;\n }\n\n /**\n * A function to merge the various configuration objects (initial, user, inline, and plugin) into a single resolved configuration object that can be used throughout the Powerlines process. This function takes into account the different sources of configuration and their respective priorities, ensuring that the final configuration reflects the intended settings for the project. The merged configuration is then returned as a new object that can be accessed through the `config` property of the context.\n *\n * @returns The merged configuration object that combines the initial, user, inline, and plugin configurations.\n */\n protected override mergeConfig(): EnvironmentResolvedConfig<TResolvedConfig> {\n return mergeConfig(\n {\n ...omit(this.environmentConfig ?? {}, [\n \"name\",\n \"ssr\",\n \"preview\",\n \"consumer\",\n \"runtime\"\n ]),\n environment: {\n name: this.environmentConfig?.name || DEFAULT_ENVIRONMENT\n },\n environmentConfig: this.environmentConfig ?? {}\n },\n super.mergeConfig()\n ) as EnvironmentResolvedConfig<TResolvedConfig>;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuDA,IAAa,+BAAb,MAAa,qCAIH,kBAKV;;;;CAIE,SAGI,EAAE;;;;CAKN;;;;;;;;;;CAWA,aAAoB,KAIlB,WACA,SACA,QACA,kBAGwE;EACxE,MAAM,UAAU,IAAI,6BAGlB,WAAW,SAAS,QAAQ,iBAAiB;AAC/C,QAAM,QAAQ,MAAM;AAEpB,SAAO;;;;;CAMT,AAAmB,oBACjB,EAAE;;;;CAKJ,AAAO,UAAgE,EAAE;;;;CAKzE,IAAW,KAAa;AACtB,SAAO,KAAK,OAAO,YAAY;;;;;CAMjC,IAAW,QAGT;AACA,SAAO,MAAKA;;;;;;;;;;CAWd,IAAW,qBAGT;AACA,SAAO,MAAKC;;;;;;;;CASd,MAAa,qBACX,QACe;AACf,OAAK,OAAO,MAAM;GAChB,MAAM,EAAE,UAAU,UAAU;GAC5B,SAAS,gDAAgD,aAAa,OAAO;GAC9E,CAAC;AAEF,OAAK,oBAAoB;AACzB,QAAM,KAAK,eAAe;;;;;;;;CAS5B,AAAgB,aAAa,SAAgC;AAC3D,SAAO,MAAM,aAAa;GACxB,GAAG;GACH,aAAa,KAAK,mBAAmB,QAAQ,KAAK,OAAO,aAAa;GACvE,CAAC;;;;;;;;CASJ,AAAgB,aAAa,SAAgC;AAC3D,SAAO,MAAM,aAAa;GACxB,GAAG;GACH,aAAa,KAAK,mBAAmB,QAAQ,KAAK,OAAO,aAAa;GACvE,CAAC;;;;;;;;;;CAWJ,MAAa,mBACX,QACe;EACf,MAAM,UAAU,MAAM,eACpB,MACA,OACD;AACD,OAAK,MAAM,UAAU,SAAS;GAC5B,IAAI,iBAAiB;AAIrB,OAAI,WAAW,OAAO,mBAAmB,EAAE;IACzC,MAAM,SAAU,MAAM,QAAQ,QAC5B,OAAO,mBAAmB,KAAK,OAAO,YAAY,CACnD;AAID,QAAI,CAAC,UAAW,SAAS,OAAO,IAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjE;AAGF,QACE,eAA+D,OAAO,CAEtE,QAAO,KAAK,mBAAmB,OAAO;AAGxC,qBACE,SAAyD,OAAO,GAC5D,SACA;;GAIR,MAAM,KAAK,MAAM;GACjB,MAAM,UAAU,oBACd,IACA,gBACA,KACD;AAED,kBAAe,aAAa;IAC1B;IACA;IACD;AAED,QAAK,QAAQ,KAAK,eAAe;AAEjC,SAAKD,QAAS,OAAO,QACnB,OAAO,KAAK,eAAe,CACxB,QACC,QACE,QAAQ,gBACR,CAAC,uBAAuB,SACtB,IACD,CACJ,CACA,QACE,KAAK,QACJ,aACE,SACA,KACA,gBACA,IACD,EACH,KAAK,MACN,CACJ,CAAC,QACC,KAAK,CAAC,KAAK,WAAW;AACrB,QAAI,YAAY,MAAM,CACpB,QAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,MAAM,UAAU;AAC9C,SAAI,SAAS,EAAE;AACf,SAAI,KAAK,QACP,eACE,KACD;MACH;AAGJ,WAAO;MAET,EAAE,CAIH;;;;;;CAOL,AAAO,YACL,KACA,SACwE;EACxE,MAAM,SAAS,EAAE;AAKjB,MACE,kBAAkE,IAAI,IACtE,KAAK,MAAM,MAEX;OAAI,KAAK,MAAM,KACb,KAAI,SAAS,OAAO;IAClB,MAAM,oBACJ,cAQA,UAAU,KAAI,SAAQ;KACpB,MAAM,SAAS,KAAK,QAAQ,MAC1B,MAAK,EAAE,SAAS,KAAK,OAAO,KAC7B;AACD,SAAI,CAAC,OACH,OAAM,IAAI,MACR,6CACE,KAAK,OAAO,KACb,IACF;AAGH,YAAO;MACL,SAAS,KAAK;MACd,QAAQ,KAAK;MACb,SAAS,OAAO,WAAW;MAC5B;MACD;AAEJ,QAAI,SAAS,UAAU,OAAO;AAC5B,YAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,cAAc,EAAE,CAAC,CAAC;AAClE,YAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,eAAe,EAAE,CAAC,CAAC;eAC1D,SAAS,UAAU,QAAQ;AACpC,YAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,eAAe,EAAE,CAAC,CAAC;AACnE,YAAO,KACL,GAAG,iBAAiB,KAAK,MAAM,KAAK,gBAAgB,EAAE,CAAC,CACxD;UAED,QAAO,KAAK,GAAG,iBAAiB,KAAK,MAAM,KAAK,UAAU,EAAE,CAAC,CAAC;UAE3D;AACL,WAAO,KAAK,GAAG,KAAK,YAAY,KAAK,EAAE,OAAO,OAAO,CAAC,CAAC;AACvD,WAAO,KAAK,GAAG,KAAK,YAAY,KAAK,EAAE,OAAO,UAAU,CAAC,CAAC;AAC1D,WAAO,KAAK,GAAG,KAAK,YAAY,KAAK,EAAE,OAAO,QAAQ,CAAC,CAAC;;;AAK9D,SAAO;;;;;;;;;;;;;;CAeT,AAAU,YACR,WACA,SACA,QACA,kBAGA;AACA,QAAM,QAAQ;AAEd,QAAKC,YAAa;AAClB,OAAK,aACH,OAAO,cAAe,EAAE;AAC1B,OAAK,eACH,OAAO,gBAAiB,EAAE;AAC5B,OAAK,eAAe,OAAO,gBAAgB,EAAE;AAC7C,OAAK,mBAAmB;;;;;;;CAQ1B,AAAmB,cAA0D;AAC3E,SAAO,YACL;GACE,GAAG,KAAK,KAAK,qBAAqB,EAAE,EAAE;IACpC;IACA;IACA;IACA;IACA;IACD,CAAC;GACF,aAAa,EACX,MAAM,KAAK,mBAAmB,mBAC/B;GACD,mBAAmB,KAAK,qBAAqB,EAAE;GAChD,EACD,MAAM,aAAa,CACpB"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_constants_environments = require('../constants/environments.cjs');
|
|
4
|
+
const require_lib_plugins = require('../lib/plugins.cjs');
|
|
5
|
+
const require_context_context = require('./context.cjs');
|
|
6
|
+
const require_context_environment_context = require('./environment-context.cjs');
|
|
7
|
+
const require_lib_environment = require('../lib/environment.cjs');
|
|
8
|
+
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
9
|
+
let _stryke_fs_json = require("@stryke/fs/json");
|
|
10
|
+
let chalk = require("chalk");
|
|
11
|
+
chalk = require_runtime.__toESM(chalk, 1);
|
|
12
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
13
|
+
let _stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
14
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
15
|
+
let _stryke_helpers_deep_clone = require("@stryke/helpers/deep-clone");
|
|
16
|
+
|
|
17
|
+
//#region src/context/execution-context.ts
|
|
18
|
+
var PowerlinesExecutionContext = class PowerlinesExecutionContext extends require_context_context.PowerlinesContext {
|
|
19
|
+
/**
|
|
20
|
+
* A record of all environments by name
|
|
21
|
+
*/
|
|
22
|
+
#environments = {};
|
|
23
|
+
/**
|
|
24
|
+
* The plugins added to this execution context, which may be used to track the plugins that have been added to the context and ensure that they are properly registered and executed during the build process. This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
|
|
25
|
+
*/
|
|
26
|
+
#plugins = [];
|
|
27
|
+
/**
|
|
28
|
+
* Create a new Storm context from the workspace root and user config.
|
|
29
|
+
*
|
|
30
|
+
* @param options - The execution options to create the context with.
|
|
31
|
+
* @param inlineConfig - The inline configuration for the context.
|
|
32
|
+
* @returns A promise that resolves to the new context.
|
|
33
|
+
*/
|
|
34
|
+
static async from(options, inlineConfig, system) {
|
|
35
|
+
const context = new PowerlinesExecutionContext(options);
|
|
36
|
+
if (system) context.system = system;
|
|
37
|
+
await context.init();
|
|
38
|
+
if (inlineConfig) await context.setInlineConfig(inlineConfig);
|
|
39
|
+
return context;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.
|
|
43
|
+
*/
|
|
44
|
+
get id() {
|
|
45
|
+
return this.options.executionId;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A record of all environments by name
|
|
49
|
+
*/
|
|
50
|
+
get environments() {
|
|
51
|
+
return this.#environments;
|
|
52
|
+
}
|
|
53
|
+
get plugins() {
|
|
54
|
+
return this.#plugins;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new instance.
|
|
58
|
+
*
|
|
59
|
+
* @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
|
|
60
|
+
*/
|
|
61
|
+
constructor(options) {
|
|
62
|
+
super(options);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A setter function to populate the inline config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.
|
|
66
|
+
*
|
|
67
|
+
* @param config - The inline configuration values to set.
|
|
68
|
+
* @returns A promise that resolves when the inline configuration values have been set.
|
|
69
|
+
*/
|
|
70
|
+
async setInlineConfig(config) {
|
|
71
|
+
await super.setInlineConfig(config);
|
|
72
|
+
if (this.inlineConfig.command === "new") {
|
|
73
|
+
const workspacePackageJsonPath = (0, _stryke_path_join.joinPaths)(this.cwd, "package.json");
|
|
74
|
+
if (!(0, _stryke_fs_exists.existsSync)(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
|
|
75
|
+
this.packageJson = await (0, _stryke_fs_json.readJsonFile)(workspacePackageJsonPath);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a new logger instance
|
|
80
|
+
*
|
|
81
|
+
* @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
|
|
82
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
83
|
+
*/
|
|
84
|
+
createLogger(options) {
|
|
85
|
+
return super.createLogger({
|
|
86
|
+
...options,
|
|
87
|
+
executionId: this.id,
|
|
88
|
+
configIndex: this.options.configIndex
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Extend the base logger with additional configuration options
|
|
93
|
+
*
|
|
94
|
+
* @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
|
|
95
|
+
* @returns A new logger client instance that extends the base logger with the provided configuration options.
|
|
96
|
+
*/
|
|
97
|
+
extendLogger(options) {
|
|
98
|
+
return super.extendLogger({
|
|
99
|
+
...options,
|
|
100
|
+
executionId: this.id,
|
|
101
|
+
configIndex: this.options.configIndex
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A function to copy the context and update the fields for a specific environment
|
|
106
|
+
*
|
|
107
|
+
* @param environment - The environment configuration to use.
|
|
108
|
+
* @returns A new context instance with the updated environment.
|
|
109
|
+
*/
|
|
110
|
+
async createEnvironment(environment) {
|
|
111
|
+
const context = await require_context_environment_context.PowerlinesEnvironmentContext.from(this, (0, _stryke_helpers_deep_clone.deepClone)(this.options), (0, _stryke_helpers_deep_clone.deepClone)(this.config), (0, _stryke_helpers_deep_clone.deepClone)(this.overriddenConfig));
|
|
112
|
+
context.tsconfig = this.tsconfig;
|
|
113
|
+
context.system = this.system;
|
|
114
|
+
context.dependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.dependencies);
|
|
115
|
+
context.devDependencies = (0, _stryke_helpers_deep_clone.deepClone)(this.devDependencies);
|
|
116
|
+
context.persistedMeta = (0, _stryke_helpers_deep_clone.deepClone)(this.persistedMeta);
|
|
117
|
+
context.resolvePatterns = (0, _stryke_helpers_deep_clone.deepClone)(this.resolvePatterns);
|
|
118
|
+
context.powerlinesPath ??= this.powerlinesPath;
|
|
119
|
+
context.resolver ??= this.resolver;
|
|
120
|
+
await context.setEnvironmentConfig((0, _stryke_helpers_deep_clone.deepClone)(environment));
|
|
121
|
+
context.plugins = [];
|
|
122
|
+
for (const plugin of this.plugins) await context.unstable_addPlugin(plugin);
|
|
123
|
+
for (const [key, value] of Object.entries(this)) if (![
|
|
124
|
+
"fs",
|
|
125
|
+
"system",
|
|
126
|
+
"options",
|
|
127
|
+
"config",
|
|
128
|
+
"inlineConfig",
|
|
129
|
+
"userConfig",
|
|
130
|
+
"pluginConfig",
|
|
131
|
+
"overriddenConfig",
|
|
132
|
+
"environmentConfig",
|
|
133
|
+
"dependencies",
|
|
134
|
+
"devDependencies",
|
|
135
|
+
"persistedMeta",
|
|
136
|
+
"packageJson",
|
|
137
|
+
"projectJson",
|
|
138
|
+
"tsconfig",
|
|
139
|
+
"resolver",
|
|
140
|
+
"plugins",
|
|
141
|
+
"environments"
|
|
142
|
+
].includes(key)) if ((0, _stryke_type_checks_is_object.isObject)(value) || Array.isArray(value)) context[key] = (0, _stryke_helpers_deep_clone.deepClone)(value);
|
|
143
|
+
else context[key] = value;
|
|
144
|
+
return context;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Update the context using a new inline configuration options
|
|
148
|
+
*/
|
|
149
|
+
async resolveConfig() {
|
|
150
|
+
await super.resolveConfig();
|
|
151
|
+
await Promise.all((0, _stryke_convert_to_array.toArray)(this.config.environments && Object.keys(this.config.environments).length > 0 ? Object.keys(this.config.environments).map((name) => require_lib_environment.createEnvironment(name, this.config)) : require_lib_environment.createDefaultEnvironment(this.config)).map(async (env) => {
|
|
152
|
+
this.#environments[env.name] = await this.createEnvironment(env);
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get an environment by name, or the default environment if no name is provided
|
|
157
|
+
*
|
|
158
|
+
* @param name - The name of the environment to retrieve.
|
|
159
|
+
* @returns The requested environment context.
|
|
160
|
+
*/
|
|
161
|
+
async getEnvironment(name) {
|
|
162
|
+
let environment;
|
|
163
|
+
if (name) environment = this.environments[name];
|
|
164
|
+
if (Object.keys(this.environments).length === 1) {
|
|
165
|
+
environment = this.environments[Object.keys(this.environments)[0]];
|
|
166
|
+
this.trace({
|
|
167
|
+
meta: { category: "plugins" },
|
|
168
|
+
message: `Applying the only configured environment: ${chalk.default.bold.cyanBright(environment?.config.environment?.name)}`
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (!environment) {
|
|
172
|
+
if (name) throw new Error(`Environment "${name}" not found.`);
|
|
173
|
+
environment = await this.createEnvironment(require_lib_environment.createDefaultEnvironment(this.config));
|
|
174
|
+
this.warn({
|
|
175
|
+
meta: { category: "plugins" },
|
|
176
|
+
message: `No environment specified, and no default environment found. Using a temporary default environment: ${chalk.default.bold.cyanBright(environment.config.environment?.name)}`
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return environment;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A safe version of `getEnvironment` that returns `undefined` if the environment is not found
|
|
183
|
+
*
|
|
184
|
+
* @param name - The name of the environment to retrieve.
|
|
185
|
+
* @returns The requested environment context or `undefined` if not found.
|
|
186
|
+
*/
|
|
187
|
+
async getEnvironmentSafe(name) {
|
|
188
|
+
try {
|
|
189
|
+
return await this.getEnvironment(name);
|
|
190
|
+
} catch {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* A function to merge all configured environments into a single context.
|
|
196
|
+
*
|
|
197
|
+
* @remarks
|
|
198
|
+
* If only one environment is configured, that environment will be returned directly.
|
|
199
|
+
*
|
|
200
|
+
* @returns A promise that resolves to a merged/global environment context.
|
|
201
|
+
*/
|
|
202
|
+
async toEnvironment() {
|
|
203
|
+
let environment;
|
|
204
|
+
if (Object.keys(this.environments).length > 1) {
|
|
205
|
+
environment = await this.createEnvironment(require_lib_environment.createEnvironment(require_constants_environments.GLOBAL_ENVIRONMENT, this.config));
|
|
206
|
+
this.debug({
|
|
207
|
+
meta: { category: "plugins" },
|
|
208
|
+
message: `Combined all ${Object.keys(this.environments).length} environments into a single global context.`
|
|
209
|
+
});
|
|
210
|
+
} else environment = await this.getEnvironment();
|
|
211
|
+
return environment;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A function used internally to add a plugin to the context and update the configuration options
|
|
215
|
+
*
|
|
216
|
+
* @danger
|
|
217
|
+
* This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
|
|
218
|
+
*
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
async unstable_addPlugin(plugin) {
|
|
222
|
+
this.plugins.push(...await require_lib_plugins.resolvePlugins(this, plugin, { skipLogging: Object.keys(this.environments).filter((key) => key !== "default" && key !== "__global__").length > 0 }));
|
|
223
|
+
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
224
|
+
await this.environments[name].unstable_addPlugin(plugin);
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
exports.PowerlinesExecutionContext = PowerlinesExecutionContext;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Plugin } from "../types/plugin.cjs";
|
|
2
|
+
import { Logger, LoggerOptions } from "../types/logging.cjs";
|
|
3
|
+
import { ExecutionContext, PluginContext } from "../types/context.cjs";
|
|
4
|
+
import { EnvironmentResolvedConfig, ExecutionOptions, PluginConfig, ResolvedConfig } from "../types/config.cjs";
|
|
5
|
+
import { PowerlinesContext } from "./context.cjs";
|
|
6
|
+
import { PowerlinesEnvironmentContext } from "./environment-context.cjs";
|
|
7
|
+
|
|
8
|
+
//#region src/context/execution-context.d.ts
|
|
9
|
+
declare class PowerlinesExecutionContext<TResolvedConfig extends ResolvedConfig = ResolvedConfig, TSystemContext = unknown> extends PowerlinesContext<TResolvedConfig, TSystemContext> implements ExecutionContext<TResolvedConfig, TSystemContext> {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Storm context from the workspace root and user config.
|
|
13
|
+
*
|
|
14
|
+
* @param options - The execution options to create the context with.
|
|
15
|
+
* @param inlineConfig - The inline configuration for the context.
|
|
16
|
+
* @returns A promise that resolves to the new context.
|
|
17
|
+
*/
|
|
18
|
+
static from<TResolvedConfig extends ResolvedConfig = ResolvedConfig, TSystemContext = unknown>(options: ExecutionOptions, inlineConfig?: TResolvedConfig["inlineConfig"], system?: TSystemContext): Promise<PowerlinesExecutionContext<TResolvedConfig, TSystemContext>>;
|
|
19
|
+
/**
|
|
20
|
+
* The unique identifier of the execution context, which can be used for logging and other purposes to distinguish between different executions in the same process.
|
|
21
|
+
*/
|
|
22
|
+
get id(): string;
|
|
23
|
+
/**
|
|
24
|
+
* A record of all environments by name
|
|
25
|
+
*/
|
|
26
|
+
get environments(): Record<string, PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>>;
|
|
27
|
+
get plugins(): Array<Plugin<PluginContext<TResolvedConfig, TSystemContext>>>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance.
|
|
30
|
+
*
|
|
31
|
+
* @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
|
|
32
|
+
*/
|
|
33
|
+
protected constructor(options: ExecutionOptions);
|
|
34
|
+
/**
|
|
35
|
+
* A setter function to populate the inline config values provided during execution of the command, such as CLI flags or other parameters that may be relevant to the command being executed. This function can be used to update the context with the inline configuration values, which may be used during the configuration resolution process to ensure that the final configuration reflects both the user configuration and any inline configuration provided during execution.
|
|
36
|
+
*
|
|
37
|
+
* @param config - The inline configuration values to set.
|
|
38
|
+
* @returns A promise that resolves when the inline configuration values have been set.
|
|
39
|
+
*/
|
|
40
|
+
setInlineConfig(config: TResolvedConfig["inlineConfig"]): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Create a new logger instance
|
|
43
|
+
*
|
|
44
|
+
* @param options - The configuration options to use for the logger instance, which can be used to customize the appearance and behavior of the log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance.
|
|
45
|
+
* @returns A logger client instance that can be used to generate log messages with consistent formatting and metadata.
|
|
46
|
+
*/
|
|
47
|
+
createLogger(options: LoggerOptions): Logger;
|
|
48
|
+
/**
|
|
49
|
+
* Extend the base logger with additional configuration options
|
|
50
|
+
*
|
|
51
|
+
* @param options - The configuration options to extend the base logger with, which can be used to add additional metadata or customize the appearance of log messages generated by the logger. This is typically the name of the plugin or module that is creating the logger instance, as well as any additional metadata such as the plugin category or environment.
|
|
52
|
+
* @returns A new logger client instance that extends the base logger with the provided configuration options.
|
|
53
|
+
*/
|
|
54
|
+
extendLogger(options: LoggerOptions): Logger;
|
|
55
|
+
/**
|
|
56
|
+
* A function to copy the context and update the fields for a specific environment
|
|
57
|
+
*
|
|
58
|
+
* @param environment - The environment configuration to use.
|
|
59
|
+
* @returns A new context instance with the updated environment.
|
|
60
|
+
*/
|
|
61
|
+
createEnvironment(environment: EnvironmentResolvedConfig<TResolvedConfig>["environment"]): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>>;
|
|
62
|
+
/**
|
|
63
|
+
* Update the context using a new inline configuration options
|
|
64
|
+
*/
|
|
65
|
+
resolveConfig(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Get an environment by name, or the default environment if no name is provided
|
|
68
|
+
*
|
|
69
|
+
* @param name - The name of the environment to retrieve.
|
|
70
|
+
* @returns The requested environment context.
|
|
71
|
+
*/
|
|
72
|
+
getEnvironment(name?: string): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>>;
|
|
73
|
+
/**
|
|
74
|
+
* A safe version of `getEnvironment` that returns `undefined` if the environment is not found
|
|
75
|
+
*
|
|
76
|
+
* @param name - The name of the environment to retrieve.
|
|
77
|
+
* @returns The requested environment context or `undefined` if not found.
|
|
78
|
+
*/
|
|
79
|
+
getEnvironmentSafe(name?: string): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext> | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* A function to merge all configured environments into a single context.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* If only one environment is configured, that environment will be returned directly.
|
|
85
|
+
*
|
|
86
|
+
* @returns A promise that resolves to a merged/global environment context.
|
|
87
|
+
*/
|
|
88
|
+
toEnvironment(): Promise<PowerlinesEnvironmentContext<TResolvedConfig, TSystemContext>>;
|
|
89
|
+
/**
|
|
90
|
+
* A function used internally to add a plugin to the context and update the configuration options
|
|
91
|
+
*
|
|
92
|
+
* @danger
|
|
93
|
+
* This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
|
|
94
|
+
*
|
|
95
|
+
* @internal
|
|
96
|
+
*/
|
|
97
|
+
unstable_addPlugin(plugin: PluginConfig<PluginContext<TResolvedConfig, TSystemContext>>): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { PowerlinesExecutionContext };
|
|
101
|
+
//# sourceMappingURL=execution-context.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-context.d.cts","names":[],"sources":["../../src/context/execution-context.ts"],"mappings":";;;;;;;;cAkDa,0BAAA,yBACa,cAAA,GAAiB,cAAA,oCAGjC,iBAAA,CAAkB,eAAA,EAAiB,cAAA,aAChC,gBAAA,CAAiB,eAAA,EAAiB,cAAA;EAAA;;;;;AAL/C;;;SA2BsB,IAAA,yBACM,cAAA,GAAiB,cAAA,2BAAA,CAGzC,OAAA,EAAS,gBAAA,EACT,YAAA,GAAe,eAAA,kBACf,MAAA,GAAS,cAAA,GACR,OAAA,CAAQ,0BAAA,CAA2B,eAAA,EAAiB,cAAA;EAjCd;;;EAAA,IAsD9B,EAAA,CAAA;EAlDkC;;;EAAA,IAyDlC,YAAA,CAAA,GAAgB,MAAA,SAEzB,4BAAA,CAA6B,eAAA,EAAiB,cAAA;EAAA,IAKrC,OAAA,CAAA,GAAW,KAAA,CACpB,MAAA,CAAO,aAAA,CAAc,eAAA,EAAiB,cAAA;EArC7B;;;;;EAAA,UA+CF,WAAA,CAAa,OAAA,EAAS,gBAAA;EAhBiB;;;;;;EA0B1B,eAAA,CACpB,MAAA,EAAQ,eAAA,mBACP,OAAA;EAvBmB;;;;;;EA6CN,YAAA,CAAa,OAAA,EAAS,aAAA,GAAgB,MAAA;EAcA;;;;;;EAAtC,YAAA,CAAa,OAAA,EAAS,aAAA,GAAgB,MAAA;EAgGnB;;;;;;EAlFtB,iBAAA,CACX,WAAA,EAAa,yBAAA,CAA0B,eAAA,mBACtC,OAAA,CAAQ,4BAAA,CAA6B,eAAA,EAAiB,cAAA;EAuKvD;;;EAvFoB,aAAA,CAAA,GAAa,OAAA;EAyGjC;;;;;;EAlFW,cAAA,CAAe,IAAA,YAAa,OAAA,CAAA,4BAAA,CAAA,eAAA,EAAA,cAAA;EAnPjC;;;;;;EAgTK,kBAAA,CACX,IAAA,YACC,OAAA,CACD,4BAAA,CAA6B,eAAA,EAAiB,cAAA;EArThD;;;;;;;;EAsUa,aAAA,CAAA,GAAiB,OAAA,CAC5B,4BAAA,CAA6B,eAAA,EAAiB,cAAA;EA7S9C;;;;;;;;EA2UW,kBAAA,CACX,MAAA,EAAQ,YAAA,CAAa,aAAA,CAAc,eAAA,EAAiB,cAAA,KAAgB,OAAA;AAAA"}
|