@powerlines/plugin-env 0.16.133 → 0.16.135

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.
@@ -1 +1 @@
1
- {"version":3,"file":"env-builtin.mjs","names":[],"sources":["../../src/components/env-builtin.tsx"],"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 Children,\n code,\n computed,\n For,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n InterfaceDeclaration as BaseInterfaceDeclaration,\n ClassDeclaration,\n ClassMethod,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceMember,\n NewExpression,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionKind,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { InterfaceDeclarationProps } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { InterfaceDeclaration } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { ObjectDeclaration } from \"@powerlines/plugin-alloy/typescript/components/object-declaration\";\nimport {\n TSDoc,\n TSDocExample,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns,\n TSDocThrows\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TSDocReflectionProperty } from \"@powerlines/plugin-alloy/typescript/components/tsdoc-reflection\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport defu from \"defu\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition(\n props: Omit<InterfaceDeclarationProps, \"name\">\n) {\n const [{ defaultValue, reflection }] = splitProps(props, [\n \"defaultValue\",\n \"reflection\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\"UnprefixedEnv\"\n defaultValue={defaultValue}\n reflection={reflection}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`UnprefixedEnv\\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}\n </TSDocRemarks>\n </TSDoc>\n <BaseInterfaceDeclaration name=\"Env\" export extends=\"UnprefixedEnv\">\n <For\n each={getUnique(context.config.env.prefix).map(prefix =>\n prefix.replace(/_$/, \"\")\n )}\n doubleHardline>\n {prefix => (\n <For\n each={\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored()) ?? []\n }\n doubleHardline>\n {property => (\n <>\n <TSDocReflectionProperty reflection={property} />\n <InterfaceMember\n name={`${prefix}_${property.getNameAsString()}`}\n type={`UnprefixedEnv[\"${property.getNameAsString()}\"]`}\n readonly={property.isReadonly()}\n />\n </>\n )}\n </For>\n )}\n </For>\n </BaseInterfaceDeclaration>\n <Spacing />\n </>\n );\n}\n\ninterface ConfigPropertyConditionalProps extends ComponentProps {\n context: EnvPluginContext;\n name: string;\n}\n\nfunction ConfigPropertyConditional(props: ConfigPropertyConditionalProps) {\n const [{ context, name }] = splitProps(props, [\"context\", \"name\"]);\n\n return code`propertyName === \"${name}\" || propertyName.replace(/^(${getUnique(\n context.config.env.prefix\n .sort((a, b) =>\n a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)\n )\n .map(prefix => `${prefix.replace(/_$/, \"\")}_`)\n ).join(\"|\")})/g, \"\").toLowerCase().replace(/[\\\\s\\\\-_]+/g, \"\") === \"${name\n .toLowerCase()\n .replace(/[\\s\\-_]+/g, \"\")}\"`;\n}\n\ninterface ConfigPropertyProps extends ComponentProps {\n index: number;\n context: EnvPluginContext;\n property: ReflectionProperty;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n reflection: ReflectionClass<any>;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\nconst envSerializerRefkey = refkey(\"EnvSerializer\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, reflection, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"reflection\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const envInstance = computed(() => {\n const result = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n description: `The initial environment configuration state for the ${titleCase(\n context?.config?.name\n )} project.`,\n types: []\n },\n reflection\n );\n\n result\n .getProperties()\n .filter(\n property => property.isRuntime() || property.getTags().runtime === true\n )\n .forEach(property => {\n result.removeProperty(property.getNameAsString());\n });\n\n return result;\n });\n\n const reflectionGetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n const reflectionSetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored() && !property.isReadonly())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n\n return (\n <BuiltinFile\n id=\"env\"\n description=\"The environment configuration module provides an interface to define environment configuration parameters.\"\n {...rest}\n imports={defu(\n {\n \"@powerlines/deepkit/vendor/type\": [\n \"serializeFunction\",\n \"deserializeFunction\",\n \"ReflectionKind\",\n \"Serializer\",\n \"NamingStrategy\",\n \"TemplateState\",\n \"Type\",\n \"TypeProperty\",\n \"TypePropertySignature\"\n ]\n },\n rest.imports ?? {}\n )}>\n <Show when={Boolean(reflection)}>\n <EnvTypeDefinition\n defaultValue={defaultValue}\n reflection={reflection}\n />\n <hbr />\n <hbr />\n </Show>\n\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<Env>\"\n defaultValue={defaultValue}\n reflection={envInstance}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\n\n <TSDoc heading=\"The environment configuration serializer for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <ClassDeclaration\n refkey={envSerializerRefkey}\n name=\"EnvSerializer\"\n extends=\"Serializer\"\n export>\n <ClassMethod\n name=\"constructor\"\n public\n doc=\"Initializes a new instance of the `EnvSerializer` class.\">\n {code`super(\"env\");\n\n this.deserializeRegistry.register(\n ReflectionKind.boolean,\n (type: Type, state: TemplateState) => {\n state.addSetter(\n \\`typeof \\${state.accessor.toString()} !== \"boolean\" ? \\${state.accessor.toString()} === 1 || \\${state.accessor.toString()} === \"1\" || \\${state.accessor.toString()}.toLowerCase() === \"t\" || \\${state.accessor.toString()}.toLowerCase() === \"true\" || \\${state.accessor.toString()}.toLowerCase() === \"y\" || \\${state.accessor.toString()}.toLowerCase() === \"yes\" : \\${state.accessor.toString()}\\`\n );\n }\n ); `}\n </ClassMethod>\n </ClassDeclaration>\n <Spacing />\n\n <VarDeclaration\n name=\"envNamingStrategy\"\n const\n doc=\"The environment naming strategy for the runtime.\"\n initializer={code`new class extends NamingStrategy {\n constructor() {\n super(\"env\");\n }\n\n getPropertyName(type: TypeProperty | TypePropertySignature, forSerializer: string): string | undefined {\n const name = super.getPropertyName(type, forSerializer);\n if (!name) {\n return name;\n }\n\n return name.replace(/^(${getUnique(\n context.config.env.prefix\n )\n .map(prefix => prefix.replace(/_$/, \"\"))\n .join(\"|\")})_/, \"\");\n }\n }; `}\n />\n <Spacing />\n\n <TSDoc heading=\"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n name=\"envSerializer\"\n const\n initializer={<NewExpression args={[]} target=\"EnvSerializer\" />}\n />\n <Spacing />\n\n <VarDeclaration\n name=\"_serializeEnv\"\n const\n initializer={\"serializeFunction<Env>(envSerializer, envNamingStrategy)\"}\n />\n <Spacing />\n <TSDoc heading=\"Serialize a environment configuration object to JSON data objects (not a JSON string).\">\n <TSDocRemarks>\n {`The resulting JSON object can be stringified using \\`JSON.stringify()\\`.`}\n </TSDocRemarks>\n <TSDocExample>{`const json = serializeEnv(env);`}</TSDocExample>\n <Spacing />\n <TSDocParam name=\"input\">\n {`The environment configuration object to serialize.`}\n </TSDocParam>\n <TSDocReturns>\n {`The serialized environment configuration as JSON data objects.`}\n </TSDocReturns>\n <TSDocThrows>\n {`ValidationError when serialization or validation fails.`}\n </TSDocThrows>\n </TSDoc>\n <FunctionDeclaration\n name=\"serializeEnv\"\n export\n parameters={[\n {\n name: \"input\",\n type: \"Env\"\n }\n ]}>\n {code` return _serializeEnv(input, { loosely: true }); `}\n </FunctionDeclaration>\n <Spacing />\n\n <VarDeclaration\n name=\"_deserializeEnv\"\n const\n initializer=\"deserializeFunction<Env>(envSerializer, envNamingStrategy)\"\n />\n <Spacing />\n <TSDoc heading=\"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.\">\n <TSDocRemarks>\n {`Types that are already correct will be used as-is.`}\n </TSDocRemarks>\n <TSDocExample>{`const env = deserializeEnv(json);`}</TSDocExample>\n <TSDocThrows>\n {`ValidationError when deserialization fails.`}\n </TSDocThrows>\n </TSDoc>\n <FunctionDeclaration\n name=\"deserializeEnv\"\n export\n parameters={[\n {\n name: \"input\",\n type: \"Env\"\n }\n ]}>\n {code` return _deserializeEnv(input, { loosely: true }); `}\n </FunctionDeclaration>\n <Spacing />\n\n <TSDoc heading=\"Initializes the Powerlines environment configuration module.\">\n <TSDocRemarks>\n {`This function initializes the Powerlines environment configuration object.`}\n </TSDocRemarks>\n <TSDocParam name=\"environmentConfig\">\n {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}\n </TSDocParam>\n <TSDocReturns>\n {`The initialized Powerlines configuration object.`}\n </TSDocReturns>\n </TSDoc>\n <Show when={Boolean(context?.entryPath)}>\n <FunctionDeclaration\n refkey={createEnvRefkey}\n async={false}\n export\n name=\"createEnv\"\n parameters={[\n {\n name: \"environmentConfig\",\n type: `Partial<Env>`,\n optional: false,\n default: \"{}\"\n }\n ]}\n returnType=\"Env\">\n {code`\n return new Proxy<Env>(\n deserializeEnv({\n ...initialEnv,\n ...environmentConfig\n } as Env),\n {\n get: (target: UnprefixedEnv, propertyName: string) => { `}\n <hbr />\n\n <For each={reflectionGetProperties}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `}\n <hbr />\n <For each={reflectionSetProperties} ender={code` else `}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n\n <hbr />\n {code`return false;\n }\n }\n );\n`}\n </FunctionDeclaration>\n </Show>\n <Spacing />\n <hbr />\n\n <TSDoc heading=\"The environment configuration object.\">\n <TSDocRemarks>\n {`This object provides access to the environment configuration parameters in the application runtime.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n refkey={envRefkey}\n name=\"env\"\n type=\"Env\"\n export\n const\n initializer={\n <>{code`createEnv(${defaultConfig || \"{}\"} as Partial<Env>);`}</>\n }\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isCI\"\n doc=\"Detect if the application is running in a continuous integration (CI) environment.\"\n initializer={code`Boolean(\n env.CI ||\n env.RUN_ID ||\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS || false\n ); `}\n />\n <Spacing />\n\n <TSDoc heading=\"Detect the \\`mode\\` of the current runtime environment.\">\n <TSDocRemarks>\n {code`The \\`mode\\` is determined by the \\`MODE\\` environment variable, or falls back to the \\`NEXT_PUBLIC_VERCEL_ENV\\`, \\`NODE_ENV\\`, or defaults to \\`production\\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:\n - \\`production\\`\n - \\`test\\`\n - \\`development\\`\n `}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n export\n const\n name=\"mode\"\n initializer={code`String(env.MODE) || \"production\"; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isProduction\"\n doc='Detect if the application is running in `\"production\"` mode'\n initializer={code`[\"prd\", \"prod\", \"production\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isTest\"\n doc='Detect if the application is running in `\"test\"` mode'\n initializer={code`[\"tst\", \"test\", \"testing\", \"stg\", \"stage\", \"staging\"].includes(mode.toLowerCase()) || env.TEST; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDevelopment\"\n doc='Detect if the application is running in `\"development\"` mode'\n initializer={code`[\"dev\", \"development\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDebug\"\n doc=\"Detect if the application is currently being debugged\"\n initializer={code`Boolean(isDevelopment && env.DEBUG); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{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CAAA;GAAA,IAAA,SAAA,EAAA,CAAA;GAAA,IAAA,gBAAA;IAAA,QAAA;IAAA,OAAA;IAAA,MAAA;IAAA,KAAA;IAAA,aAAA,IAAA;IAAA,CAAA;GAAA,IAAA,SAAA,EAAA,CAAA;GAAA,IAAA,gBAAA;IAAA,QAAA;IAAA,OAAA;IAAA,MAAA;IAAA,KAAA;IAAA,aAAA,IAAA;IAAA,CAAA;GAAA,IAAA,SAAA,EAAA,CAAA;GAAA,IAAA,gBAAA;IAAA,QAAA;IAAA,OAAA;IAAA,MAAA;IAAA,KAAA;IAAA,aAAA,IAAA;IAAA,CAAA;GAAA,IAAA,SAAA,EAAA,CAAA;GAAA,IAAA,gBAAA;IAAA,QAAA;IAAA,OAAA;IAAA,MAAA;IAAA,KAAA;IAAA,aAAA,IAAA;IAAA,CAAA;GAAA,IAAA,SAAA,EAAA,CAAA;GAAA,IAAA,MAAA;IAAA,MAAA,QAAA,SAAA;IAAA;IAAA,CAAA;GAAA;EAAA,CAAA;;AAEf,WAAW,SAAM;OAAU;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"env-builtin.mjs","names":[],"sources":["../../src/components/env-builtin.tsx"],"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 Children,\n code,\n computed,\n For,\n Show,\n splitProps\n} from \"@alloy-js/core\";\nimport {\n InterfaceDeclaration as BaseInterfaceDeclaration,\n ClassDeclaration,\n ClassMethod,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n InterfaceMember,\n NewExpression,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport {\n ReflectionClass,\n ReflectionKind,\n ReflectionProperty\n} from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport { ComponentProps } from \"@powerlines/plugin-alloy/types/components\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { InterfaceDeclarationProps } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { InterfaceDeclaration } from \"@powerlines/plugin-alloy/typescript/components/interface-declaration\";\nimport { ObjectDeclaration } from \"@powerlines/plugin-alloy/typescript/components/object-declaration\";\nimport {\n TSDoc,\n TSDocExample,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\n TSDocReturns,\n TSDocThrows\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TSDocReflectionProperty } from \"@powerlines/plugin-alloy/typescript/components/tsdoc-reflection\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport defu from \"defu\";\nimport { loadEnvFromContext } from \"../helpers/load\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Generates the environment configuration typescript definition for the Powerlines project.\n */\nexport function EnvTypeDefinition(\n props: Omit<InterfaceDeclarationProps, \"name\">\n) {\n const [{ defaultValue, reflection }] = splitProps(props, [\n \"defaultValue\",\n \"reflection\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n\n return (\n <>\n <InterfaceDeclaration\n name=\"UnprefixedEnv\"\n defaultValue={defaultValue}\n reflection={reflection}\n export\n />\n <Spacing />\n <TSDoc heading=\"The environment configuration object with prefixed keys.\">\n <TSDocRemarks>\n {`The \\`Env\\` type extends the \\`UnprefixedEnv\\` interface by including additional keys that are prefixed according to the project's configuration. This allows for flexibility in accessing environment variables with different naming conventions.`}\n </TSDocRemarks>\n </TSDoc>\n <BaseInterfaceDeclaration name=\"Env\" export extends=\"UnprefixedEnv\">\n <For\n each={getUnique(context.config.env.prefix).map(prefix =>\n prefix.replace(/_$/, \"\")\n )}\n doubleHardline>\n {prefix => (\n <For\n each={\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored()) ?? []\n }\n doubleHardline>\n {property => (\n <>\n <TSDocReflectionProperty reflection={property} />\n <InterfaceMember\n name={`${prefix}_${property.getNameAsString()}`}\n type={`UnprefixedEnv[\"${property.getNameAsString()}\"]`}\n readonly={property.isReadonly()}\n />\n </>\n )}\n </For>\n )}\n </For>\n </BaseInterfaceDeclaration>\n <Spacing />\n </>\n );\n}\n\ninterface ConfigPropertyConditionalProps extends ComponentProps {\n context: EnvPluginContext;\n name: string;\n}\n\nfunction ConfigPropertyConditional(props: ConfigPropertyConditionalProps) {\n const [{ context, name }] = splitProps(props, [\"context\", \"name\"]);\n\n return code`propertyName === \"${name}\" || propertyName.replace(/^(${getUnique(\n context.config.env.prefix\n .sort((a, b) =>\n a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)\n )\n .map(prefix => `${prefix.replace(/_$/, \"\")}_`)\n ).join(\"|\")})/g, \"\").toLowerCase().replace(/[\\\\s\\\\-_]+/g, \"\") === \"${name\n .toLowerCase()\n .replace(/[\\s\\-_]+/g, \"\")}\"`;\n}\n\ninterface ConfigPropertyProps extends ComponentProps {\n index: number;\n context: EnvPluginContext;\n property: ReflectionProperty;\n}\n\nfunction ConfigPropertyGet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`return target[\"${property.getNameAsString()}\"];`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nfunction ConfigPropertySet(props: ConfigPropertyProps) {\n const [{ context, property, index }] = splitProps(props, [\n \"context\",\n \"property\",\n \"index\"\n ]);\n\n return (\n <>\n {index === 0 ? (\n <IfStatement\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </IfStatement>\n ) : (\n <ElseIfClause\n condition={\n <>\n <ConfigPropertyConditional\n name={property.getNameAsString()}\n context={context}\n />\n <Show\n when={property.getAlias() && property.getAlias().length > 0}>\n {code` || `}\n <For each={property.getAlias()} joiner={code` || `}>\n {alias => (\n <ConfigPropertyConditional name={alias} context={context} />\n )}\n </For>\n </Show>\n </>\n }>\n {code`\n target[\"${property.getNameAsString()}\"] = newValue;\n return true;\n`}\n </ElseIfClause>\n )}\n </>\n );\n}\n\nexport interface EnvBuiltinProps extends Omit<BuiltinFileProps, \"id\"> {\n defaultConfig?: Children;\n reflection: ReflectionClass<any>;\n}\n\nconst createEnvRefkey = refkey(\"createEnv\");\nconst envRefkey = refkey(\"env\");\nconst envSerializerRefkey = refkey(\"EnvSerializer\");\n\n/**\n * Generates the environment configuration module for the Powerlines project.\n */\nexport function EnvBuiltin(props: EnvBuiltinProps) {\n const [{ defaultConfig, reflection, children }, rest] = splitProps(props, [\n \"defaultConfig\",\n \"reflection\",\n \"children\"\n ]);\n\n const context = usePowerlines<EnvPluginContext>();\n const defaultValue = computed(\n () => context && loadEnvFromContext(context, process.env)\n );\n\n const envInstance = computed(() => {\n const result = new ReflectionClass(\n {\n kind: ReflectionKind.objectLiteral,\n description: `The initial environment configuration state for the ${titleCase(\n context?.config?.name\n )} project.`,\n types: []\n },\n reflection\n );\n\n result\n .getProperties()\n .filter(\n property => property.isRuntime() || property.getTags().runtime === true\n )\n .forEach(property => {\n result.removeProperty(property.getNameAsString());\n });\n\n return result;\n });\n\n const reflectionGetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n const reflectionSetProperties = computed(\n () =>\n reflection\n ?.getProperties()\n .filter(property => !property.isIgnored() && !property.isReadonly())\n .sort((a, b) =>\n a.getNameAsString().localeCompare(b.getNameAsString())\n ) ?? []\n );\n\n return (\n <BuiltinFile\n id=\"env\"\n description=\"The environment configuration module provides an interface to define environment configuration parameters.\"\n {...rest}\n imports={defu(\n {\n \"@powerlines/deepkit/vendor/type\": [\n \"serializeFunction\",\n \"deserializeFunction\",\n \"ReflectionKind\",\n \"Serializer\",\n \"NamingStrategy\",\n \"TemplateState\",\n \"Type\",\n \"TypeProperty\",\n \"TypePropertySignature\"\n ]\n },\n rest.imports ?? {}\n )}>\n <Show when={Boolean(reflection)}>\n <EnvTypeDefinition\n defaultValue={defaultValue}\n reflection={reflection}\n />\n <hbr />\n <hbr />\n </Show>\n\n <ObjectDeclaration\n name=\"initialEnv\"\n type=\"Partial<Env>\"\n defaultValue={defaultValue}\n reflection={envInstance}\n export\n const\n doc=\"The initial environment configuration object values for the runtime.\"\n />\n <Spacing />\n\n <TSDoc heading=\"The environment configuration serializer for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <ClassDeclaration\n refkey={envSerializerRefkey}\n name=\"EnvSerializer\"\n extends=\"Serializer\"\n export>\n <ClassMethod\n name=\"constructor\"\n public\n doc=\"Initializes a new instance of the `EnvSerializer` class.\">\n {code`super(\"env\");\n\n this.deserializeRegistry.register(\n ReflectionKind.boolean,\n (type: Type, state: TemplateState) => {\n state.addSetter(\n \\`typeof \\${state.accessor.toString()} !== \"boolean\" ? \\${state.accessor.toString()} === 1 || \\${state.accessor.toString()} === \"1\" || \\${state.accessor.toString()}.toLowerCase() === \"t\" || \\${state.accessor.toString()}.toLowerCase() === \"true\" || \\${state.accessor.toString()}.toLowerCase() === \"y\" || \\${state.accessor.toString()}.toLowerCase() === \"yes\" : \\${state.accessor.toString()}\\`\n );\n }\n ); `}\n </ClassMethod>\n </ClassDeclaration>\n <Spacing />\n\n <VarDeclaration\n name=\"envNamingStrategy\"\n const\n doc=\"The environment naming strategy for the runtime.\"\n initializer={code`new class extends NamingStrategy {\n constructor() {\n super(\"env\");\n }\n\n getPropertyName(type: TypeProperty | TypePropertySignature, forSerializer: string): string | undefined {\n const name = super.getPropertyName(type, forSerializer);\n if (!name) {\n return name;\n }\n\n return name.replace(/^(${getUnique(\n context.config.env.prefix\n )\n .map(prefix => prefix.replace(/_$/, \"\"))\n .join(\"|\")})_/, \"\");\n }\n }; `}\n />\n <Spacing />\n\n <TSDoc heading=\"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.\">\n <TSDocLink>\n {`https://deepkit.io/docs/serialization/serializers`}\n </TSDocLink>\n <TSDocLink>\n {`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}\n </TSDocLink>\n <TSDocRemarks>\n {`This serializer is used to serialize and deserialize the Powerlines environment configuration.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n name=\"envSerializer\"\n const\n initializer={<NewExpression args={[]} target=\"EnvSerializer\" />}\n />\n <Spacing />\n\n <VarDeclaration\n name=\"_serializeEnv\"\n const\n initializer={\"serializeFunction<Env>(envSerializer, envNamingStrategy)\"}\n />\n <Spacing />\n <TSDoc heading=\"Serialize a environment configuration object to JSON data objects (not a JSON string).\">\n <TSDocRemarks>\n {`The resulting JSON object can be stringified using \\`JSON.stringify()\\`.`}\n </TSDocRemarks>\n <TSDocExample>{`const json = serializeEnv(env);`}</TSDocExample>\n <Spacing />\n <TSDocParam name=\"input\">\n {`The environment configuration object to serialize.`}\n </TSDocParam>\n <TSDocReturns>\n {`The serialized environment configuration as JSON data objects.`}\n </TSDocReturns>\n <TSDocThrows>\n {`ValidationError when serialization or validation fails.`}\n </TSDocThrows>\n </TSDoc>\n <FunctionDeclaration\n name=\"serializeEnv\"\n export\n parameters={[\n {\n name: \"input\",\n type: \"Env\"\n }\n ]}>\n {code` return _serializeEnv(input, { loosely: true }); `}\n </FunctionDeclaration>\n <Spacing />\n\n <VarDeclaration\n name=\"_deserializeEnv\"\n const\n initializer=\"deserializeFunction<Env>(envSerializer, envNamingStrategy)\"\n />\n <Spacing />\n <TSDoc heading=\"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.\">\n <TSDocRemarks>\n {`Types that are already correct will be used as-is.`}\n </TSDocRemarks>\n <TSDocExample>{`const env = deserializeEnv(json);`}</TSDocExample>\n <TSDocThrows>\n {`ValidationError when deserialization fails.`}\n </TSDocThrows>\n </TSDoc>\n <FunctionDeclaration\n name=\"deserializeEnv\"\n export\n parameters={[\n {\n name: \"input\",\n type: \"Env\"\n }\n ]}>\n {code` return _deserializeEnv(input, { loosely: true }); `}\n </FunctionDeclaration>\n <Spacing />\n\n <TSDoc heading=\"Initializes the Powerlines environment configuration module.\">\n <TSDocRemarks>\n {`This function initializes the Powerlines environment configuration object.`}\n </TSDocRemarks>\n <TSDocParam name=\"environmentConfig\">\n {`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}\n </TSDocParam>\n <TSDocReturns>\n {`The initialized Powerlines configuration object.`}\n </TSDocReturns>\n </TSDoc>\n <Show when={Boolean(context?.entryPath)}>\n <FunctionDeclaration\n refkey={createEnvRefkey}\n async={false}\n export\n name=\"createEnv\"\n parameters={[\n {\n name: \"environmentConfig\",\n type: `Partial<Env>`,\n optional: false,\n default: \"{}\"\n }\n ]}\n returnType=\"Env\">\n {code`\n return new Proxy<Env>(\n deserializeEnv({\n ...initialEnv,\n ...environmentConfig\n } as Env),\n {\n get: (target: UnprefixedEnv, propertyName: string) => { `}\n <hbr />\n\n <For each={reflectionGetProperties}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertyGet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n {code`\n return undefined;\n }, `}\n\n <Spacing />\n {code` set: (target: UnprefixedEnv, propertyName: string, newValue: any) => { `}\n <hbr />\n <For each={reflectionSetProperties} ender={code` else `}>\n {(property: ReflectionProperty, index: number) => (\n <ConfigPropertySet\n index={index}\n context={context}\n property={property}\n />\n )}\n </For>\n\n <hbr />\n {code`return false;\n }\n }\n );\n`}\n </FunctionDeclaration>\n </Show>\n <Spacing />\n <hbr />\n\n <TSDoc heading=\"The environment configuration object.\">\n <TSDocRemarks>\n {`This object provides access to the environment configuration parameters in the application runtime.`}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n refkey={envRefkey}\n name=\"env\"\n type=\"Env\"\n export\n const\n initializer={\n <>{code`createEnv(${defaultConfig || \"{}\"} as Partial<Env>);`}</>\n }\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isCI\"\n doc=\"Detect if the application is running in a continuous integration (CI) environment.\"\n initializer={code`Boolean(\n env.CI ||\n env.RUN_ID ||\n env.AGOLA_GIT_REF ||\n env.AC_APPCIRCLE ||\n env.APPVEYOR ||\n env.CODEBUILD ||\n env.TF_BUILD ||\n env.bamboo_planKey ||\n env.BITBUCKET_COMMIT ||\n env.BITRISE_IO ||\n env.BUDDY_WORKSPACE_ID ||\n env.BUILDKITE ||\n env.CIRCLECI ||\n env.CIRRUS_CI ||\n env.CF_BUILD_ID ||\n env.CM_BUILD_ID ||\n env.CI_NAME ||\n env.DRONE ||\n env.DSARI ||\n env.EARTHLY_CI ||\n env.EAS_BUILD ||\n env.GERRIT_PROJECT ||\n env.GITEA_ACTIONS ||\n env.GITHUB_ACTIONS ||\n env.GITLAB_CI ||\n env.GOCD ||\n env.BUILDER_OUTPUT ||\n env.HARNESS_BUILD_ID ||\n env.JENKINS_URL ||\n env.LAYERCI ||\n env.MAGNUM ||\n env.NETLIFY ||\n env.NEVERCODE ||\n env.PROW_JOB_ID ||\n env.RELEASE_BUILD_ID ||\n env.RENDER ||\n env.SAILCI ||\n env.HUDSON ||\n env.SCREWDRIVER ||\n env.SEMAPHORE ||\n env.SOURCEHUT ||\n env.STRIDER ||\n env.TASK_ID ||\n env.RUN_ID ||\n env.TEAMCITY_VERSION ||\n env.TRAVIS ||\n env.VELA ||\n env.NOW_BUILDER ||\n env.APPCENTER_BUILD_ID ||\n env.CI_XCODE_PROJECT ||\n env.XCS || false\n ); `}\n />\n <Spacing />\n\n <TSDoc heading=\"Detect the \\`mode\\` of the current runtime environment.\">\n <TSDocRemarks>\n {code`The \\`mode\\` is determined by the \\`MODE\\` environment variable, or falls back to the \\`NEXT_PUBLIC_VERCEL_ENV\\`, \\`NODE_ENV\\`, or defaults to \\`production\\`. While the value can potentially be any string, it is generally recommended to only allow a value in the following list:\n - \\`production\\`\n - \\`test\\`\n - \\`development\\`\n `}\n </TSDocRemarks>\n </TSDoc>\n <VarDeclaration\n export\n const\n name=\"mode\"\n initializer={code`String(env.MODE) || \"production\"; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isProduction\"\n doc='Detect if the application is running in `\"production\"` mode'\n initializer={code`[\"prd\", \"prod\", \"production\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isTest\"\n doc='Detect if the application is running in `\"test\"` mode'\n initializer={code`[\"tst\", \"test\", \"testing\", \"stg\", \"stage\", \"staging\"].includes(mode.toLowerCase()) || env.TEST; `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDevelopment\"\n doc='Detect if the application is running in `\"development\"` mode'\n initializer={code`[\"dev\", \"development\"].includes(mode.toLowerCase()); `}\n />\n <Spacing />\n\n <VarDeclaration\n export\n const\n name=\"isDebug\"\n doc=\"Detect if the application is currently being debugged\"\n initializer={code`Boolean(isDevelopment && env.DEBUG); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAU;CAAC;CAAI;CAAM;CAAQ;CAAG;;;;;;;AAItC,SAAS,aAAY,IAAI,MAAO;AAC/B,IAAI,SAAS;;;;;;AAsCd,SAAS,kBAAwB,OAAA;CACjC,MAAO,CAAA,EACL,cACA,gBACK,WAAE,OAAW,CAAM,gBAAO,aAAsB,CAAA;CACvD,MAAO,WAAO,cAAA,IAAA,CAAA,OAA4B,qBAAwB,KAAC,CAAK,EAAC,eAAW;AACpF,QAAS;EAAA,gBAAA,wBAAyC;GAClD,MAAS;GACF;GACA;GACL,UAAY;GACZ,CAAA;EAAA,gBAAS,SAAA,EAAA,CAAA;EAAA,gBAAA,OAAA;GACT,SAAU;GACV,IAAA,WAAY;AACZ,WAAA,gBAAY,cAAA,EACZ,UAAA,uPACK,CAAC;;GAER,CAAA;EAAM,gBAAe,sBAA0B;GAC/C,MAAS;GACT,UAAY;GACZ,WAAS;GACT,IAAQ,WAAC;;KAEP,IAAA,OAAA;AACC,a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AA,CAAA;IAAA,gBAAA,gBAAA;KACC,UAAQ;KACR,SAAS;KACT,MAAM;KACN,KAAA;KACA,aAAA,IAAA;KACD,CAAC;IAAA,gBAAY,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACZ,UAAU;KACV,SAAA;KACD,MAAA;KACA,KAAA;;KAEA,CAAA;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACC,UAAA;KACA,SAAA;KACA,MAAM;KACN,KAAK;KACL,aAAa,IAAI;KAClB,CAAC;IAAE,gBAAQ,SAAA,EAAA,CAAA;IAAA,gBAAA,MAAA;KACV,IAAE,OAAI;AACJ,aAAI,QAAA,SAAe;;KAEf;KACP,CAAC;IAAC;;EAEN,CAAC,CAAC;;AAEL,WAAU,SAAI;OAAY;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"automd-generator.mjs","names":[],"sources":["../../src/helpers/automd-generator.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { defineGenerator } from \"automd\";\nimport { UnresolvedContext } from \"powerlines\";\n\n/**\n * AutoMD generator to generate environment variable documentation\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const env = (context: UnresolvedContext) =>\n defineGenerator({\n name: \"env\",\n async generate() {\n const envDocFile = joinPaths(\n context.config.root,\n \"docs\",\n \"generated\",\n \"env.md\"\n );\n\n if (!context.fs.existsSync(envDocFile)) {\n return {\n contents: \"\"\n };\n }\n\n const contents = await context.fs.read(envDocFile);\n\n return {\n contents: contents || \"\"\n };\n }\n });\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AA2BX,MAAE,MAAgB,cAAA,YAAA,gBAAA;CACd,MAAM;CACN,UAAM,aAAW,eAAA,WAAA;EACf,MAAM,aAAa,UAAS,QAAA,OAAA,MAAA,QAAA,aAAA,SAAA;AAC1B,MAAA,CAAA,QAAQ,GAAO,WAAI,WAAA,CAClB,QAAK,EACL,UAAU,IACN;AAGL,SAAG,EACH,+CAAO,IACN;IACF,CAAC,YAAC,QAAA,CAAA;CACR,CAAC,EAAE;CAAC;CAAC;CAAA;CAAA,CAAA"}
1
+ {"version":3,"file":"automd-generator.mjs","names":[],"sources":["../../src/helpers/automd-generator.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { defineGenerator } from \"automd\";\nimport { UnresolvedContext } from \"powerlines\";\n\n/**\n * AutoMD generator to generate environment variable documentation\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const env = (context: UnresolvedContext) =>\n defineGenerator({\n name: \"env\",\n async generate() {\n const envDocFile = joinPaths(\n context.config.root,\n \"docs\",\n \"generated\",\n \"env.md\"\n );\n\n if (!context.fs.existsSync(envDocFile)) {\n return {\n contents: \"\"\n };\n }\n\n const contents = await context.fs.read(envDocFile);\n\n return {\n contents: contents || \"\"\n };\n }\n });\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;;;;;;;AA2BT,MAAE,MAAgB,cAAA,YAAA,gBAAA;CAChB,MAAM;CACN,UAAQ,aAAW,eAAA,WAAA;EACjB,MAAE,aAAiB,UAAE,QAAS,OAAA,MAAA,QAAA,aAAA,SAAA;AAC9B,MAAI,CAAA,QAAQ,GAAA,WAAW,WAAA,CACrB,QAAO,EACL,UAAU,IACX;AAGH,SAAO,EACL,UAAS,qCAAA,IACV;IACA,CAAC,YAAG,QAAA,CAAA;CACR,CAAC,EAAE;CAAC;CAAC;CAAA;CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-reflection-resource.mjs","names":[],"sources":["../../src/helpers/create-reflection-resource.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 { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Creates a reflection resource for the environment configuration.\n *\n * @param _context - The environment plugin context.\n * @returns A resource that provides the reflection of the environment configuration.\n */\nexport function createReflection(_context: EnvPluginContext) {\n // const defaultValue = computed(\n // () => context && loadEnvFromContext(context, process.env)\n // );\n\n return {};\n\n // return computed(() => {\n // result.getProperties().forEach(prop => {\n // const aliases = prop.getAlias();\n // aliases.filter(Boolean).forEach(alias => {\n // result.addProperty({\n // name: alias,\n // optional: prop.isOptional() ? true : undefined,\n // readonly: prop.isReadonly() ? true : undefined,\n // description: prop.getDescription(),\n // visibility: prop.getVisibility(),\n // type: prop.getType(),\n // default: prop.getDefaultValue(),\n // tags: {\n // hidden: prop.isHidden(),\n // ignore: prop.isIgnored(),\n // internal: prop.isInternal(),\n // alias: prop\n // .getAlias()\n // .filter(a => a !== alias)\n // .concat(prop.name),\n // title: prop.getTitle() || titleCase(prop.name),\n // readonly: prop.isReadonly(),\n // permission: prop.getPermission(),\n // domain: prop.getDomain()\n // }\n // });\n // });\n // });\n\n // result.getProperties().forEach(prop => {\n // prop.setDefaultValue(\n // (defaultValue.value as Record<string, any>)?.[prop.getNameAsString()] ??\n // prop\n // .getAlias()\n // .reduce(\n // (ret, alias) =>\n // ret ?? (defaultValue.value as Record<string, any>)?.[alias],\n // undefined\n // ) ??\n // prop.getDefaultValue()\n // );\n // });\n // });\n}\n"],"mappings":";;;;;;;;;;AAYC,QAAU,EAAE;;AA4Cb,iBAAe,SAAQ;OAAK;CAAU;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"create-reflection-resource.mjs","names":[],"sources":["../../src/helpers/create-reflection-resource.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 { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Creates a reflection resource for the environment configuration.\n *\n * @param _context - The environment plugin context.\n * @returns A resource that provides the reflection of the environment configuration.\n */\nexport function createReflection(_context: EnvPluginContext) {\n // const defaultValue = computed(\n // () => context && loadEnvFromContext(context, process.env)\n // );\n\n return {};\n\n // return computed(() => {\n // result.getProperties().forEach(prop => {\n // const aliases = prop.getAlias();\n // aliases.filter(Boolean).forEach(alias => {\n // result.addProperty({\n // name: alias,\n // optional: prop.isOptional() ? true : undefined,\n // readonly: prop.isReadonly() ? true : undefined,\n // description: prop.getDescription(),\n // visibility: prop.getVisibility(),\n // type: prop.getType(),\n // default: prop.getDefaultValue(),\n // tags: {\n // hidden: prop.isHidden(),\n // ignore: prop.isIgnored(),\n // internal: prop.isInternal(),\n // alias: prop\n // .getAlias()\n // .filter(a => a !== alias)\n // .concat(prop.name),\n // title: prop.getTitle() || titleCase(prop.name),\n // readonly: prop.isReadonly(),\n // permission: prop.getPermission(),\n // domain: prop.getDomain()\n // }\n // });\n // });\n // });\n\n // result.getProperties().forEach(prop => {\n // prop.setDefaultValue(\n // (defaultValue.value as Record<string, any>)?.[prop.getNameAsString()] ??\n // prop\n // .getAlias()\n // .reduce(\n // (ret, alias) =>\n // ret ?? (defaultValue.value as Record<string, any>)?.[alias],\n // undefined\n // ) ??\n // prop.getDefaultValue()\n // );\n // });\n // });\n}\n"],"mappings":";;;;;;;;;;AAYC,QAAQ,EAAE;;AA4CX,iBAAe,SAAQ;OAAK;CAAU;CAAA;CAAA;CAAA;CAAA"}
@@ -11,7 +11,7 @@ let _stryke_path_join = require("@stryke/path/join");
11
11
  * @returns The output path for the generated environment documentation.
12
12
  */
13
13
  function getDocsOutputPath(context) {
14
- return (0, _stryke_path_join.joinPaths)(context.config.root, "docs", "generated");
14
+ return (0, _stryke_path_join.joinPaths)(context.config.root, "docs", "reference");
15
15
  }
16
16
  getDocsOutputPath.__type = [
17
17
  () => require_types_plugin.__ΩEnvPluginContext,
@@ -9,7 +9,7 @@ import { joinPaths } from "@stryke/path/join";
9
9
  * @returns The output path for the generated environment documentation.
10
10
  */
11
11
  function getDocsOutputPath(context) {
12
- return joinPaths(context.config.root, "docs", "generated");
12
+ return joinPaths(context.config.root, "docs", "reference");
13
13
  }
14
14
  getDocsOutputPath.__type = [
15
15
  () => __ΩEnvPluginContext,
@@ -1 +1 @@
1
- {"version":3,"file":"docs-helper.mjs","names":[],"sources":["../../src/helpers/docs-helper.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Gets the output path for the generated environment documentation.\n *\n * @param context - The environment plugin context.\n * @returns The output path for the generated environment documentation.\n */\nexport function getDocsOutputPath(context: EnvPluginContext): string {\n return joinPaths(context.config.root, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAE,kBAAA,SAAA;AACF,QAAO,UAAS,QAAA,OAAkB,MAAQ,QAAC,YAAmB;;AAE9D,kBAAA,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"docs-helper.mjs","names":[],"sources":["../../src/helpers/docs-helper.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport { EnvPluginContext } from \"../types/plugin\";\n\n/**\n * Gets the output path for the generated environment documentation.\n *\n * @param context - The environment plugin context.\n * @returns The output path for the generated environment documentation.\n */\nexport function getDocsOutputPath(context: EnvPluginContext): string {\n return joinPaths(context.config.root, \"docs\", \"reference\");\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAE,kBAAA,SAAA;AACF,QAAO,UAAS,QAAA,OAAkB,MAAA,QAAS,YAAiB;;AAE5D,kBAAA,SAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig?: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || workspaceConfig?.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput,\n workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const workspaceConfig = await tryGetWorkspaceConfig();\n\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.cwd,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env, workspaceConfig),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC5B,IAAA,SAAW;AACd,QAAS;;;CA6BV,IAAM,MAAQ,MAAC,UAAiB,KAAC,KAAQ;AACvC,KAAA,QAAS,mBAAgB,QAAA,iBAAA,SAAA,GAAA;EACnB,MAAM,qBAAA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AA,OAAA;;AAE5C,QAAQ,SAAQ;OAAO;CAAc;OAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"load.mjs","names":[],"sources":["../../src/helpers/load.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 { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport {\n loadEnv as loadEnvBase,\n loadEnvFile as loadEnvFileBase\n} from \"@stryke/env/load-env\";\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport { loadConfig } from \"c12\";\nimport defu from \"defu\";\nimport { WorkspaceConfig } from \"powerlines\";\nimport { DEFAULT_ENVIRONMENT } from \"powerlines/constants\";\nimport { EnvPluginContext, EnvPluginOptions } from \"../types/plugin\";\nimport { removeEnvPrefix } from \"./source-file-env\";\n\nasync function loadEnvFiles<TEnv extends DotenvParseOutput = DotenvParseOutput>(\n options: EnvPluginOptions,\n mode: string,\n cwd: string\n): Promise<TEnv> {\n let env = await loadEnvBase(cwd, mode);\n if (options.additionalFiles && options.additionalFiles?.length > 0) {\n const additionalEnvFiles = await Promise.all(\n options.additionalFiles.map(async additionalEnvFile =>\n loadEnvFileBase(additionalEnvFile, cwd)\n )\n );\n\n for (const additionalEnvFile of additionalEnvFiles) {\n env = defu(additionalEnvFile, env);\n }\n }\n\n return removeEnvPrefix(env) as TEnv;\n}\n\nasync function loadEnvDirectory<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(\n context: EnvPluginContext,\n options: EnvPluginOptions,\n directory: string,\n mode: string,\n cacheDir: string,\n packageJson: PackageJson,\n workspaceConfig?: WorkspaceConfig\n): Promise<TEnv> {\n const [envResult, c12Result] = await Promise.all([\n loadEnvFiles<TEnv>(options, mode, directory),\n loadConfig({\n cwd: directory,\n name: \"storm\",\n envName: mode,\n defaults: {\n NAME:\n workspaceConfig?.namespace && packageJson.name\n ? packageJson.name?.replace(`@${workspaceConfig.namespace}/`, \"\")\n : context.config.name,\n MODE: mode,\n ORG: context.config.organization || workspaceConfig?.organization\n },\n globalRc: true,\n packageJson: true,\n dotenv: true,\n jitiOptions: {\n fsCache: joinPaths(cacheDir, \"jiti\"),\n moduleCache: true\n }\n })\n ]);\n\n return defu(envResult as any, c12Result.config, workspaceConfig) as TEnv;\n}\n\n/**\n * Retrieves various dotenv configuration parameters from the context.\n *\n * @param context - The context to retrieve the dotenv configuration from.\n * @param parsed - The parsed dotenv configuration.\n * @returns An object containing the dotenv configuration.\n */\nexport function loadEnvFromContext(\n context: EnvPluginContext,\n parsed: DotenvParseOutput,\n workspaceConfig?: WorkspaceConfig\n) {\n return defu(\n {\n APP_NAME: kebabCase(context.config.name),\n APP_VERSION: context.packageJson.version,\n BUILD_ID: context.meta.buildId,\n BUILD_TIMESTAMP: new Date(context.meta.timestamp).toISOString(),\n BUILD_CHECKSUM: context.meta.checksum,\n RELEASE_ID: context.meta.releaseId,\n RELEASE_TAG: `${kebabCase(context.config.name)}@${context.packageJson.version}`,\n DEFAULT_LOCALE: workspaceConfig?.locale,\n DEFAULT_TIMEZONE: workspaceConfig?.timezone,\n LOG_LEVEL:\n context.config.logLevel === \"trace\" ? \"debug\" : context.config.logLevel,\n ERROR_URL: workspaceConfig?.error?.url,\n ORGANIZATION:\n context.config.organization ||\n (isSetObject(workspaceConfig?.organization)\n ? workspaceConfig.organization.name\n : workspaceConfig?.organization),\n PLATFORM: context.config.platform,\n MODE: context.config.mode,\n TEST: context.config.mode === \"test\",\n DEBUG: context.config.mode === \"development\",\n STACKTRACE: context.config.mode !== \"production\",\n ENVIRONMENT:\n !context.environment.name ||\n context.environment.name === DEFAULT_ENVIRONMENT\n ? context.config.mode\n : context.environment.name\n },\n isSetObject(context?.env?.types?.env)\n ? context.env.types.env?.getProperties().reduce(\n (ret, prop) => {\n ret[prop.name] = parsed[prop.name] ?? prop.getDefaultValue();\n return ret;\n },\n {} as Record<string, any>\n )\n : {}\n );\n}\n\nexport async function loadEnv<\n TEnv extends DotenvParseOutput = DotenvParseOutput\n>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv> {\n const workspaceConfig = await tryGetWorkspaceConfig();\n\n const [project, workspace, config] = await Promise.all([\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.root,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.config.cwd,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n ),\n loadEnvDirectory<TEnv>(\n context,\n options,\n context.envPaths.config,\n context.config.mode,\n context.cachePath,\n context.packageJson,\n workspaceConfig\n )\n ]);\n\n return defu(\n loadEnvFromContext(context, process.env, workspaceConfig),\n project,\n workspace,\n config\n ) as TEnv;\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC/B,IAAG,SAAU;AACb,QAAQ;;;CA6BT,IAAM,MAAA,MAAS,UAAa,KAAK,KAAO;AACtC,KAAA,QAAS,mBAAgB,QAAA,iBAAA,SAAA,GAAA;EACzB,MAAM,qBAAM,MAAA,QAAA,IAAA,QAAA,gBAAA,IAAA,aAAA,OAAA,sBAAA,YAAA,mBAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA,CAAA;AACZ,OAAK,MAAA,qBAAA,mBACJ,O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A,GAAA,gBAAA,aAAA,OAAA,iBAAA;EACjB,UAAE,QAAA,OAAA;EACF,MAAC,QAAA,OAAA;EACD,MAAA,QAAA,OAAA,SAAA;;EAEF,YAAY,QAAU,OAAO,SAAC;EAChC,aAAA,CAAA,QAAA,YAAA,QAAA,QAAA,YAAA,SAAA,sBAAA,QAAA,OAAA,OAAA,QAAA,YAAA;;AAEE,MAAA,KAAA,QAAA,OAAA,KAAA,SAAA,KAAA,iBAAA;AACC,SAAA;IACF;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA,GAAA,EAAA,CAAA;;AAED,mBAAmB,SAAI;OAAO;CAAoB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAClD,eAAsB,QAAA,SAAe,SAAO;CAC1C,MAAA,kBAAA,MAAA,uBAAA;CACF,MAAO,CAAA,SAAS,WAAA,UAAkB,MAAA,QAAA,IAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,IAAA,CAAA,EAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,MAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,gBAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,IAAA,CAAA,EAAA,iBAAA,SAAA,SAAA,QAAA,OAAA,KAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,gBAAA;GAAA,iBAAA,IAAA,CAAA,CAAA,IAAA,CAAA,EAAA,iBAAA,SAAA,SAAA,QAAA,SAAA,QAAA,QAAA,OAAA,MAAA,QAAA,WAAA,QAAA,aAAA,gBAAA;EAAA,CAAA;AAChC,QAAO,KAAE,mBAAgB,SAAA,QAAA,KAAA,gBAAA,EAAA,SAAA,WAAA,OAAA;;AAE3B,QAAE,SAAe;OAAG;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.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 { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,eAAsB,uBAAc,SAAA;CACpC,MAAS,WAAS,MAAA,QAAiB,GAAG,QAAM,uCAAW;AACvD,KAAO,CAAA,SACL,OAAA,IAAgB,MAAA,0JAAA;AAEhB,QAAA;;AAEF,uBAAS,SAAsB;CAAA;CAAQ;CAAQ;CAAA;CAAA;;;;;;;AAO/C,eAAE,4BAAA,SAAA;AACF,QAAO;EACL,MAAS,MAAA,uBAAkB,QAAA;EAC1B,MAAQ;EACT;;AAEF,4BAAG,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOD,QAAO;EACT,MAAA,MAAA,uBAAA,QAAA;;EAEE;;AAEF,gCAAC,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQD,SAAgB,0BAAuB,SAAQ,OAAA,OAAA;AAC3C,QAAO,UAAA,mBAAY,QAAA,EAAA,OAAA,GAAA,KAAA,YAAA;;AAEvB,0BAAA,SAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,eAAW,sBAAkB,SAAuB,OAAA,OAAA;CACjD,MAAO,WAAC,0BAAgB,SAAA,KAAA;AACzB,KAAM,CAAC,WAAA,SAAA,EAAA;AACD,MAAE,CAAA,QAAM,IAAA,MAAA,OAAsB,cAAS,QAAA,IAAA,MAAA,IAA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,SAAA,UAAA;;AAEpC,SAAE,QAAa,IAAI,KAAA;;CAEvB,MAAM,SAAS,MAAA,eAAqB,SAAA;CAEpC,MAAM,cADO,IAAA,MAAW,QAAA,QAAA,MAAA,CACf,QAAA,gBAAA;CACT,MAAM,aAAQ,iBAAA,gBAAA,iBAAA,YAAA,MAAA,CAAA,CAAA;AACd,SAAK,IAAA,KAAA,UAAA;AACL,SAAI,IAAA,KAAA,QAAiB,cAAkB;AACvC,SAAQ,IAAA,KAAA,QAAU,aAAA;AAClB,QAAE;;AAEN,sBAAsB,SAAS;OAAC;CAAS;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQzC,eAAsB,mBAAS,SAAA,YAAA,OAAA,OAAA;CAC7B,MAAA,aAAA,WAAA,eAAA;;AAGA,gBAAgB,YADD,QAAM,SAAA,gBAAwB,CACX,WAAQ,WAAM,OAAA,CAAA;AAChD,OAAM,gBAAc,sBAAgB,SAAgB,KAAA,EAAA,QAAA,eAAA,CAAA;;AAEtD,mBAAmB,SAAE;OAAA;CAAgB;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQrC,SAAS,uBAAU,SAAA,YAAA,OAAA,OAAA;CACnB,MAAA,aAAA,WAAA,eAAA;;AAGG,gBAAgB,YADjB,QAAA,SAAA,gBAAA,CAC8B,WAAe,WAAU,OAAK,CAAA;AAC7D,qBAAA,sBAAA,SAAA,KAAA,EAAA,QAAA,eAAA,CAAA;;AAED,uBAAgB,SAAY;OAAW;CAAI;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.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 { convertFromCapnp, convertToCapnp } from \"@powerlines/deepkit/capnp\";\nimport { getReflectionsPath } from \"@powerlines/deepkit/resolve-reflections\";\nimport { SerializedTypes } from \"@powerlines/deepkit/schemas/reflection\";\nimport { Reflection } from \"@powerlines/deepkit/types\";\nimport {\n deserializeType,\n ReflectionClass,\n ReflectionKind,\n resolveClassType\n} from \"@powerlines/deepkit/vendor/type\";\nimport * as capnp from \"@stryke/capnp\";\nimport {\n readFileBuffer,\n writeFileBuffer,\n writeFileBufferSync\n} from \"@stryke/fs/buffer\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { isEmptyObject } from \"@stryke/type-checks/is-empty-object\";\nimport type { TypeDefinition } from \"@stryke/types/configuration\";\nimport { existsSync } from \"node:fs\";\nimport { Context, UnresolvedContext } from \"powerlines\";\nimport {\n EnvPluginContext,\n EnvPluginResolvedConfig,\n EnvType\n} from \"../types/plugin\";\nimport { createEnvReflection } from \"./reflect\";\n\n/**\n * Resolves the runtime type definition file for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The runtime type definition file for the environment variables.\n */\nexport async function resolveRuntimeTypeFile(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<string> {\n const resolved = await context.fs.resolve(\n \"@powerlines/plugin-env/types/runtime\"\n );\n if (!resolved) {\n throw new Error(\n `Failed to resolve the runtime type definition file for the environment variables. Please ensure that the \"@powerlines/plugin-env\" package is installed.`\n );\n }\n\n return resolved;\n}\n\n/**\n * Gets the default type definition for the environment variables.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment variables.\n */\nexport async function getEnvDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"EnvInterface\"\n };\n}\n\n/** Gets the default type definition for the environment secrets.\n *\n * @param context - The plugin context.\n * @returns The default type definition for the environment secrets.\n */\nexport async function getSecretsDefaultTypeDefinition(\n context: UnresolvedContext<EnvPluginResolvedConfig>\n): Promise<TypeDefinition> {\n return {\n file: await resolveRuntimeTypeFile(context),\n name: \"SecretsInterface\"\n };\n}\n\n/**\n * Gets the path to the environment type reflections.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The path to the environment type reflections.\n */\nexport function getEnvTypeReflectionsPath(\n context: Context<EnvPluginResolvedConfig>,\n name: EnvType = \"env\"\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}-types.bin`);\n}\n\n/**\n * Reads the environment type reflection from the file system.\n *\n * @param context - The plugin context.\n * @param name - The name of the type reflections.\n * @returns The environment type reflection.\n */\nexport async function readEnvTypeReflection(\n context: EnvPluginContext,\n name: EnvType = \"env\"\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvTypeReflectionsPath(context, name);\n if (!existsSync(filePath)) {\n if (!context.env.types.env || isEmptyObject(context.env.types.env)) {\n const reflection = createEnvReflection(context) as Reflection;\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.types.env = reflection;\n await writeEnvTypeReflection(context, context.env.types.env, name);\n }\n\n return context.env.types.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.types[name] = reflection;\n context.env.types[name].messageRoot = messageRoot;\n context.env.types[name].dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment type reflection to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The environment type reflection to write.\n * @param name - The name of the type reflections.\n */\nexport async function writeEnvTypeReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvTypeReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\nexport function getEnvReflectionsPath(\n context: EnvPluginContext,\n name: EnvType\n): string {\n return joinPaths(getReflectionsPath(context), \"env\", `${name}.bin`);\n}\n\n/**\n * Reads the environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readEnvReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"env\");\n if (!existsSync(filePath)) {\n if (!context.env.types.env) {\n context.env.types.env = await readEnvTypeReflection(context, \"env\");\n }\n\n if (!context.env.used.env || isEmptyObject(context.env.used.env)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `An object containing the environment configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.env\n }) as Reflection;\n reflection.name = \"Env\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.env = reflection;\n await writeEnvReflection(context, context.env.used.env, \"env\");\n }\n\n return context.env.used.env;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.env = reflection;\n context.env.used.env.messageRoot = messageRoot;\n context.env.used.env.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Reads the secret environment reflection data from the file system.\n *\n * @param context - The plugin context.\n * @returns The environment reflection data.\n */\nexport async function readSecretsReflection(\n context: EnvPluginContext\n): Promise<ReflectionClass<any>> {\n const filePath = getEnvReflectionsPath(context, \"secrets\");\n if (!existsSync(filePath)) {\n if (!context.env.types.secrets) {\n context.env.types.secrets = await readEnvTypeReflection(\n context,\n \"secrets\"\n );\n }\n\n if (!context.env.used.secrets || isEmptyObject(context.env.used.secrets)) {\n const reflection = createEnvReflection(context, {\n type: {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `An object containing the secret configuration parameters that are used (at least once) by the ${\n context.config.name\n ? `${context.config.name} application`\n : \"application\"\n }.`,\n types: []\n },\n superReflection: context.env.types.secrets\n }) as Reflection;\n reflection.name = \"Secrets\";\n\n const message = new capnp.Message();\n reflection.messageRoot = message.initRoot(SerializedTypes);\n reflection.dataBuffer = message.toArrayBuffer();\n\n context.env.used.secrets = reflection;\n await writeEnvReflection(context, context.env.used.secrets, \"secrets\");\n }\n\n return context.env.used.secrets;\n }\n\n const buffer = await readFileBuffer(filePath);\n const message = new capnp.Message(buffer, false);\n const messageRoot = message.getRoot(SerializedTypes);\n\n const reflection = resolveClassType(\n deserializeType(convertFromCapnp(messageRoot.types))\n );\n\n context.env.used.secrets = reflection;\n context.env.used.secrets.messageRoot = messageRoot;\n context.env.used.secrets.dataBuffer = buffer;\n\n return reflection;\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport async function writeEnvReflection(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n await writeFileBuffer(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n\n/**\n * Writes the environment reflection data to the file system.\n *\n * @param context - The plugin context.\n * @param reflection - The reflection data to write.\n * @param name - The name of the reflection (either \"env\" or \"secrets\").\n */\nexport function writeEnvReflectionSync(\n context: EnvPluginContext,\n reflection: ReflectionClass<any>,\n name: EnvType = \"env\"\n) {\n const serialized = reflection.serializeType();\n\n const message = new capnp.Message();\n const root = message.initRoot(SerializedTypes);\n\n convertToCapnp(serialized, root._initTypes(serialized.length));\n\n writeFileBufferSync(\n getEnvReflectionsPath(context, name),\n message.toArrayBuffer()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,eAAsB,uBAAc,SAAA;CACpC,MAAQ,WAAU,MAAA,QAAA,GAAkB,QAAQ,uCAAW;AACvD,KAAM,CAAC,SACL,OAAA,IAAA,MAAgB,0JAAA;AAEhB,QAAA;;AAEF,uBAAS,SAAsB;CAAA;CAAQ;CAAQ;CAAA;CAAA;;;;;;;AAO/C,eAAE,4BAAA,SAAA;AACF,QAAO;EACL,MAAQ,MAAC,uBAAkB,QAAA;EAC1B,MAAO;EACR;;AAEF,4BAAG,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOD,QAAO;EACT,MAAA,MAAA,uBAAA,QAAA;;EAEE;;AAEF,gCAAC,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQD,SAAgB,0BAAuB,SAAQ,OAAA,OAAA;AAC7C,QAAO,UAAE,mBAAY,QAAA,EAAA,OAAA,GAAA,KAAA,YAAA;;AAEvB,0BAAA,SAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQA,eAAW,sBAAkB,SAAuB,OAAA,OAAA;CAClD,MAAC,WAAQ,0BAAgB,SAAA,KAAA;AACzB,KAAA,CAAA,WAAO,SAAA,EAAA;AACL,MAAI,CAAC,QAAO,IAAA,MAAA,OAAA,cAA+B,QAAA,IAAA,MAAA,IAAA,EAAA;GAC3C,MAAO,aAAA,oBAAgB,QAAA;GACxB,MAAA,UAAA,IAAA,MAAA,SAAA;AACH,cAAA,cAAA,QAAA,SAAA,gBAAA;;AAEE,WAAA,IAAA,MAAA,MAAA;A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AAA,CAAA;AACzB,SAAQ,IAAI,KAAK,UAAQ;AACzB,SAAQ,IAAI,KAAG,QAAA,cAAW;AAC1B,SAAQ,IAAG,KAAA,QAAA,aAAA;AACX,QAAO;;AAET,sBAAQ,SAAiB;OAAY;CAAM;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQ3C,eAAsB,mBAAiB,SAAA,YAAA,OAAA,OAAA;CACrC,MAAI,aAAM,WAAmB,eAAgB;CAC7C,MAAE,UAAA,IAAA,MAAA,SAAA;AAEF,gBAAS,6CAAoB,CAAA,WAAA,WAAA,OAAA,CAAA;AAC7B,OAAA,gBAAA,sBAAA,SAAA,KAAA,EAAA,QAAA,eAAA,CAAA;;AAEF,mBAAiB,SAAM;OAAA;CAAwB;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQ/C,SAAc,uBAAqB,SAAA,YAAA,OAAA,OAAA;CACjC,MAAA,aAAiB,WAAI,eAAc;CACnC,MAAA,UAAgB,IAAI,MAAC,SAAa;AAElC,gBAAO,6CAAU,CAAA,WAAA,WAAA,OAAA,CAAA;AACnB,qBAAA,sBAAA,SAAA,KAAA,EAAA,QAAA,eAAA,CAAA;;AAEA,uBAAE,SAAA;OAAA;CAAA;CAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport { EnvInterface, SecretsInterface } from \"../types/runtime\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC5B,IAAC,SAAU;;;AA0Bf,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CAAA;;AAGF,oBAAgB,SAAA;OAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;AACnC,SAAW,wBAAgB,SAAA,aAAA;AAIvB,QAHW,wBAAqB,SAAA,EACjC,MAAA,MAAgB,YAAK,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACtB,CAAA;;;;;;;;;AAIF,MAAE,gCAAiB;CAAA;CAAA;CAAA;CAAA;CAAA;;CAGnB;CACE;CACA;CACC;CACD;CACE;CACA;;CAEF,WAAO;CACT,OAAA;;CAEA,QAAO;CACL,OAAO;CACP,UAAA;CACF,WAAA;;CAEA,kBAAqB;CACnB,aAAW;;CAEX;;CAEA;;CAEA,OAAA,SAAkB;EAAA;EAAM;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA;EAAA;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;AAAA,UAAA;;EAAA;EAAA,WAAA;A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AAA,EAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAY3B,eAAsB,WAAO,SAAW,MAAQ,MAAI;CAChD,IAAI;AACJ,KAAI,KAOA,UAAS,iBANO,MAAA,YAAA,SAAA;EACf,MAAA,CAAA,aAAA,MAAA,QAAA,OAAA,IAAA,GACK,UAAA,QAAA,OAAA,KAAA,KAAA,GACT;EACD;EACD,CAAA,CACkB;AAEnB,QAAO,oBAAM,SAAA;EACf,MAAA,sBAAA,SAAA,MAAA;;EAEO,iBAAS,MAAA,YAAuB,SAAA,MAAA,4BAAA,QAAA,CAAA,CAAA;EACrC,CAAA,OAAS,QAAA,CAAA;;AAEX,WAAG,SAAgB;OAAK;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYxB,eAAgB,eAAe,SAAa,MAAA,MAAA;CACxC,IAAI;AACJ,KAAI,KAOA,UAAS,iBANU,MAAA,YAAA,SAAA;EACf,MAAC,CAAA,aAAS,MAAA,QAAA,OAAA,IAAA,GACJ,UAAA,QAAA,OAAA,KAAA,KAAA,GACV;EACF;EACA,CAAA,CACmB;AAEvB,QAAM,wBAAa,SAAe;EAChC,MAAQ,sBAAQ,QAAA;EACd;EACA,iBAAmB,MAAA,YAAA,SAAA,MAAA,gCAAA,QAAA,CAAA,CAAA;EACpB,CAAC,OAAA,QAAe,CAAC;;AAEtB,eAAe,SAAS;OAAC;CAAsB;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/helpers/reflect.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 { reflectType } from \"@powerlines/deepkit/reflect-type\";\nimport {\n merge,\n ReflectionClass,\n ReflectionKind,\n resolveClassType,\n TypeClass,\n TypeObjectLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext } from \"../types/plugin\";\nimport { EnvInterface, SecretsInterface } from \"../types/runtime\";\nimport {\n getEnvDefaultTypeDefinition,\n getSecretsDefaultTypeDefinition,\n readEnvTypeReflection,\n readSecretsReflection\n} from \"./persistence\";\n\nexport function mergeEnvReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createEnvReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport function mergeSecretsReflections(\n context: EnvPluginContext,\n reflections: ReflectionClass<any>[]\n): ReflectionClass<any> {\n const reflection = createSecretsReflection(context, {\n type: merge(reflections.map(reflection => reflection.type))\n });\n\n return reflection;\n}\n\nexport interface CreateEnvReflectionOptions {\n type?: TypeObjectLiteral | TypeClass;\n superReflection?: ReflectionClass<any>;\n}\n\nexport class BaseEnv implements EnvInterface {\n APP_NAME!: string;\n\n APP_VERSION!: string;\n\n BUILD_ID!: string;\n\n BUILD_TIMESTAMP!: string;\n\n BUILD_CHECKSUM!: string;\n\n RELEASE_ID!: string;\n\n RELEASE_TAG!: string;\n\n ORGANIZATION!: string;\n\n PLATFORM: \"node\" | \"browser\" | \"neutral\" = \"neutral\";\n\n MODE: \"development\" | \"test\" | \"production\" = \"production\";\n\n ENVIRONMENT!: string;\n\n DEBUG: boolean = false;\n\n TEST: boolean = false;\n\n MINIMAL: boolean = false;\n\n NO_COLOR: boolean = false;\n\n FORCE_COLOR: number | boolean = false;\n\n FORCE_HYPERLINK: number | boolean = false;\n\n STACKTRACE: boolean = false;\n\n INCLUDE_ERROR_DATA: boolean = false;\n\n ERROR_URL!: string;\n\n DEFAULT_TIMEZONE!: string;\n\n DEFAULT_LOCALE!: string;\n\n CI: boolean = false;\n}\n\nexport class BaseSecrets implements SecretsInterface {\n ENCRYPTION_KEY!: string;\n}\n\nexport function createEnvReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base environment configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseEnv,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"EnvInterface\",\n description: `The environment configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Env\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Env\",\n description: `A schema describing the list of available environment variables that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Env\";\n\n return result;\n}\n\nexport function createSecretsReflection(\n context: EnvPluginContext,\n options: CreateEnvReflectionOptions = {}\n): ReflectionClass<any> {\n const parent =\n options.superReflection ??\n new ReflectionClass({\n kind: ReflectionKind.class,\n description: `The base secrets configuration definition for the ${titleCase(\n context.config.name\n )} project.`,\n classType: BaseSecrets,\n types: [],\n implements: [\n {\n kind: ReflectionKind.objectLiteral,\n typeName: \"SecretsInterface\",\n description: `The secrets configuration interface definition for the ${titleCase(\n context.config.name\n )} project.`,\n types: []\n }\n ]\n });\n parent.name = \"Secrets\";\n\n const result = new ReflectionClass(\n options.type ?? {\n kind: ReflectionKind.objectLiteral,\n typeName: \"Secrets\",\n description: `A schema describing the list of available environment secrets that can be used by the ${\n context.config.name\n ? `${titleCase(context.config.name)} application`\n : \"application\"\n }.`,\n types: []\n },\n parent\n );\n result.name = \"Secrets\";\n\n return result;\n}\n\n/**\n * Reflects the environment configuration type definition from the provided file and name, and merges it with the default environment configuration reflection and the currently used environment configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the environment configuration type definition from\n * @param name - The name of the type definition to reflect the environment configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the environment configuration type definition, merged with the default environment configuration reflection and the currently used environment configuration reflection. The resulting reflection will contain the structure of the expected environment variables as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default environment configuration reflection.\n */\nexport async function reflectEnv(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeEnvReflections(\n context,\n [\n await readEnvTypeReflection(context, \"env\"),\n config,\n resolveClassType(\n await reflectType(context, await getEnvDefaultTypeDefinition(context))\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n\n/**\n * Reflects the secrets configuration type definition from the provided file and name, and merges it with the default secrets configuration reflection and the currently used secrets configuration reflection.\n *\n * @remarks\n * The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n *\n * @param context - The plugin context\n * @param file - The file path to reflect the secrets configuration type definition from\n * @param name - The name of the type definition to reflect the secrets configuration from, if the file contains multiple type definitions. If not provided, the first type definition found in the file will be used.\n * @returns A reflection of the secrets configuration type definition, merged with the default secrets configuration reflection and the currently used secrets configuration reflection. The resulting reflection will contain the structure of the expected environment secrets as defined by the type definitions provided in the plugin configuration, as well as any additional properties that are currently used in the source code and defined in the default secrets configuration reflection.\n */\nexport async function reflectSecrets(\n context: EnvPluginContext,\n file?: string,\n name?: string\n) {\n let config: ReflectionClass<any> | undefined;\n if (file) {\n const configType = await reflectType(context, {\n file: !isParentPath(file, context.config.cwd)\n ? joinPaths(context.config.cwd, file)\n : file,\n name\n });\n\n config = resolveClassType(configType);\n }\n\n return mergeSecretsReflections(\n context,\n [\n await readSecretsReflection(context),\n config,\n resolveClassType(\n await reflectType(\n context,\n await getSecretsDefaultTypeDefinition(context)\n )\n )\n ].filter(Boolean) as ReflectionClass<any>[]\n );\n}\n"],"mappings":";;;;;;;;;;AAMA,SAAS,aAAY,IAAI,MAAO;AAC/B,IAAI,SAAS;;;AA0Bd,SAAE,oBAA2B,SAAA,aAAA;AAI3B,QAHA,oBAA+B,SAAA,EAC/B,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACrB,CACQ;;AAEV,oBAAgB,SAAA;OAAmB;CAAA;CAAA;CAAA;CAAA;CAAA;AACnC,SAAW,wBAAgB,SAAA,aAAA;AAIzB,QAHa,wBAAqB,SAAA,EACjC,MAAA,MAAA,YAAqB,IAAA,cAAA,eAAA,WAAA,MAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,EACtB,CACc;;;;;;;;;AAGhB,MAAE,gCAAiB;CAAA;CAAA;CAAA;CAAA;CAAA;;CAGnB;CACE;CACA;CACA;CACA;CACA;CACA;;CAEA,WAAO;CACT,OAAA;;CAEA,QAAO;CACL,OAAO;CACP,UAAA;CACF,WAAA;;CAEA,kBAAoB;CAClB,aAAW;;CAEX;;CAEA;;CAEA,OAAA,SAAgB;EAAC;EAAO;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,WAAA;;;EAExB;EAAiB;EAAM;EAAA;EAAA,WAAA;;;EAEvB;EAAa;EAAM,WAAA;;;EAEn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gBAAA,cAAA;;EAEnB,EAAA,OAAM;AACN,QAAE,OAAY;AACd,QAAI;;AAEN,wBAAsB,SAAO;OAAW;CAAqB;OAAa;CAAmC;QAAA,EAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAY7G,eAAA,WAAA,SAAA,MAAA,MAAA;;AAEA,KAAM,KAKF,UAAQ,iBAAiB,MAJF,YAAA,SAAA;EACzB,MAAS,CAAA,aAAA,MAAA,QAA6B,OAAC,IAAA,GAAA,UAAA,QAAA,OAAA,KAAA,KAAA,GAAA;EACtC;EACD,CAAA,CAC2B;AAE3B,QAAI,oBAAqB,SAAK;EAAA,MAAA,sBAAA,SAAA,MAAA;EAAA;EAAA,iBAAA,MAAA,YAAA,SAAA,MAAA,4BAAA,QAAA,CAAA,CAAA;EAAA,CAAA,OAAA,QAAA,CAAA;;AAEhC,WAAQ,SAAQ;OAAO;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYvB,eAAQ,eAAA,SAAA,MAAA,MAAA;CACN,IAAI;AACJ,KAAI,KAKF,UAAQ,iBAAe,MAJF,YAAA,SAAA;;EAEvB;EACE,CAAA,CACoC;AAEtC,QAAI,wBAAuB,SAAW;EAAG,MAAM,sBAAa,QAAY;EAAO;EAAM,iBAAmB,MAAC,YAAA,SAAA,MAAA,gCAAA,QAAA,CAAA,CAAA;EAAA,CAAA,OAAA,QAAA,CAAA;;AAE3G,eAAe,SAAS;OAAC;CAAsB;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"source-file-env.mjs","names":[],"sources":["../../src/helpers/source-file-env.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\ntype TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;\n\nexport function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(\n env: TEnv\n): TReturned<TEnv> {\n if (isString(env)) {\n let name: string = ENV_PREFIXES.reduce((ret, prefix) => {\n if (ret.startsWith(prefix)) {\n ret = ret.slice(prefix.length);\n }\n\n return ret;\n }, env.toUpperCase());\n\n while (name.startsWith(\"_\")) {\n name = name.slice(1);\n }\n\n return name as TReturned<TEnv>;\n }\n\n return Object.keys(env).reduce((ret, key) => {\n const name = removeEnvPrefix(key);\n if (name) {\n (ret as DotenvParseOutput)[name] = env[key];\n }\n\n return ret;\n }, {} as TReturned<TEnv>);\n}\n\nexport function formatEnvField(key: string): string {\n return camelCase(removeEnvPrefix(key));\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAKX,MAAK,eAAe;CAAE;CAAQ;CAAC;CAAoC;;AAElE,KAAO,SAAS,IAAI,EAAE;EACtB,IAAW,OAAO,aAAa,OAAG,cAAiB,KAAA,WAAS;AAC5D,OAAe,IAAI,WAAO,OAAQ,CACnB,OAAM,IAAI,MAAM,OAAG,OAAA;AAE7B,UAAQ;;;;;;;AAEN,SAAO,KAAK,WAAW,IAAI;AAG3B,SAAC;;AAET,QAAS,OAAS,KAAE,IAAO,CAAA,OAAO,cAAe,KAAA,QAAO;;AAEnD,MAAA;AAGE,SAAA;IACJ;EAAA;EAAU;EAAM;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA;;AAEnB,gBAAc,SAAS;CAAA;OAAa;CAAa;CAAW;CAAA;AAC5D,SAAc,eAAiB,KAAG;AAC9B,QAAO,UAAO,gBAAmB,IAAC,CAAA"}
1
+ {"version":3,"file":"source-file-env.mjs","names":[],"sources":["../../src/helpers/source-file-env.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { DotenvParseOutput } from \"@stryke/env/types\";\nimport { ENV_PREFIXES } from \"@stryke/env/types\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isString } from \"@stryke/type-checks/is-string\";\n\ntype TReturned<TEnv> = TEnv extends string ? string : DotenvParseOutput;\n\nexport function removeEnvPrefix<TEnv extends DotenvParseOutput | string>(\n env: TEnv\n): TReturned<TEnv> {\n if (isString(env)) {\n let name: string = ENV_PREFIXES.reduce((ret, prefix) => {\n if (ret.startsWith(prefix)) {\n ret = ret.slice(prefix.length);\n }\n\n return ret;\n }, env.toUpperCase());\n\n while (name.startsWith(\"_\")) {\n name = name.slice(1);\n }\n\n return name as TReturned<TEnv>;\n }\n\n return Object.keys(env).reduce((ret, key) => {\n const name = removeEnvPrefix(key);\n if (name) {\n (ret as DotenvParseOutput)[name] = env[key];\n }\n\n return ret;\n }, {} as TReturned<TEnv>);\n}\n\nexport function formatEnvField(key: string): string {\n return camelCase(removeEnvPrefix(key));\n}\n"],"mappings":";;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE9B,QAAO;;AAKT,MAAK,eAAe;CAAE;CAAQ;CAAC;CAAoC;;AAElE,KAAA,SAAc,IAAI,EAAE;EACpB,IAAA,OAAc,aAAY,OAAQ,cAAW,KAAM,WAAS;AAC5D,OAAA,IAAa,WAAW,OAAO,CACxB,OAAM,IAAI,MAAM,OAAG,OAAQ;AAE7B,UAAO;;;;;;;AAET,SAAO,KAAK,WAAW,IAAI;AAG/B,SAAS;;AAET,QAAS,OAAA,KAAW,IAAK,CAAC,OAAO,cAAa,KAAG,QAAO;;AAEpD,MAAC;AAGH,SAAK;IACJ;EAAA;EAAU;EAAM;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA;;AAEnB,gBAAc,SAAS;CAAA;OAAa;CAAa;CAAW;CAAA;AAC5D,SAAc,eAAiB,KAAG;AAChC,QAAM,UAAU,gBAAa,IAAO,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"template-helpers.mjs","names":[],"sources":["../../src/helpers/template-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext, EnvType } from \"../types/plugin\";\nimport { readEnvTypeReflection } from \"./persistence\";\n\n/**\n * Creates the reflection data used when generating runtime template files.\n *\n * @param context - The context for the configuration plugin.\n * @param name - The name of the configuration template.\n * @returns The reflection for the specified configuration template.\n */\nexport async function createTemplateReflection(\n context: EnvPluginContext,\n name?: EnvType\n): Promise<ReflectionClass<any>> {\n const reflection = await readEnvTypeReflection(context, name);\n\n reflection.getProperties().forEach(prop => {\n const aliases = prop.getAlias();\n aliases.filter(Boolean).forEach(alias => {\n reflection.addProperty({\n name: alias,\n optional: prop.isOptional() ? true : undefined,\n readonly: prop.isReadonly() ? true : undefined,\n description: prop.getDescription(),\n visibility: prop.getVisibility(),\n type: prop.getType(),\n default: prop.getDefaultValue(),\n tags: {\n hidden: prop.isHidden(),\n ignore: prop.isIgnored(),\n internal: prop.isInternal(),\n runtime: prop.isRuntime(),\n alias: prop\n .getAlias()\n .filter(a => a !== alias)\n .concat(prop.name),\n title: prop.getTitle() || titleCase(prop.name),\n readonly: prop.isReadonly(),\n permission: prop.getPermission(),\n domain: prop.getDomain()\n }\n });\n });\n });\n\n return reflection;\n}\n"],"mappings":";;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC5B,IAAA,SAAW;AACd,QAAS;;;;;;;;;;CAYV,MAAS,aAAA,MAAkB,sBAAkB,SAAe,KAAK;AACjE,YAAS,eAAmB,CAAA,QAAO,cAAc,SAAW;AAEpD,EADC,KAAkB,UAAU,CAC5B,OAAA,QAAsB,CAAC,QAAQ,cAAa,UAAA;;IAEnD,MAAA;IACa,UAAW,KAAK,YAAU,GAAA,OAAW;IACnD,UAAA,KAAA,YAAA,GAAA,OAAA;IACS,aAAc,KAAQ,gBAAQ;IACxB,YAAY,KAAK,eAAc;IAC/B,MAAA,KAAW,SAAQ;IACjC,SAAA,KAAA,iBAAA;IACW,MAAS;KACX,QAAgB,KAAA,UAAA;KAClB,QAAA,KAAA,WAAA;KACE,UAAmB,KAAG,YAAA;KACb,SAAO,KAAA,WAAA;iBAEd,UAAgB,CACJ,OAAA,cAAU,MAAA,MAAA,OAAA;MAAA;MAAA;MAAA;MAAA,CAAA,CAAA,CAChB,OAAS,KAAQ,KAAM;KACzB,OAAA,KAAY,UAAA,IAAA,UAAA,KAAA,KAAA;KACV,UAAA,KAAA,YAAA;KACD,YAAK,KAAc,eAAQ;KAC3B,QAAK,KAAU,WAAW;KACpC;IACA,CAAA;KACA;GAAI;GAAO;GAAA;GAAS,CAAA,CAAA;IACrB;EAAC;EAAQ;EAAC;EAAK,CAAA,CAAA;AAClB,QAAI;;AAER,yBAAuB,SAAW;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"template-helpers.mjs","names":[],"sources":["../../src/helpers/template-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { EnvPluginContext, EnvType } from \"../types/plugin\";\nimport { readEnvTypeReflection } from \"./persistence\";\n\n/**\n * Creates the reflection data used when generating runtime template files.\n *\n * @param context - The context for the configuration plugin.\n * @param name - The name of the configuration template.\n * @returns The reflection for the specified configuration template.\n */\nexport async function createTemplateReflection(\n context: EnvPluginContext,\n name?: EnvType\n): Promise<ReflectionClass<any>> {\n const reflection = await readEnvTypeReflection(context, name);\n\n reflection.getProperties().forEach(prop => {\n const aliases = prop.getAlias();\n aliases.filter(Boolean).forEach(alias => {\n reflection.addProperty({\n name: alias,\n optional: prop.isOptional() ? true : undefined,\n readonly: prop.isReadonly() ? true : undefined,\n description: prop.getDescription(),\n visibility: prop.getVisibility(),\n type: prop.getType(),\n default: prop.getDefaultValue(),\n tags: {\n hidden: prop.isHidden(),\n ignore: prop.isIgnored(),\n internal: prop.isInternal(),\n runtime: prop.isRuntime(),\n alias: prop\n .getAlias()\n .filter(a => a !== alias)\n .concat(prop.name),\n title: prop.getTitle() || titleCase(prop.name),\n readonly: prop.isReadonly(),\n permission: prop.getPermission(),\n domain: prop.getDomain()\n }\n });\n });\n });\n\n return reflection;\n}\n"],"mappings":";;;;;AAIA,SAAM,aAAS,IAAW,MAAM;AAC/B,IAAG,SAAU;AACb,QAAQ;;;;;;;;;;CAYT,MAAQ,aAAC,MAAkB,sBAAkB,SAAQ,KAAO;AAC5D,YAAS,eAAmB,CAAA,QAAO,cAAc,SAAM;AAEvD,EADS,KAAgB,UAChB,CAAA,OAAA,QAAA,CAAA,QAAwB,cAAQ,UAAY;;IAEnD,MAAA;IACC,UAAY,KAAA,YAAoB,GAAC,OAAK;IACxC,UAAA,KAAA,YAAA,GAAA,OAAA;IACG,aAAgB,KAAI,gBAAgB;IACpC,YAAgB,KAAK,eAAQ;IAC7B,MAAQ,KAAI,SAAW;IACzB,SAAA,KAAA,iBAAA;IACK,MAAM;KACH,QAAC,KAAA,UAAgB;KAClB,QAAA,KAAA,WAAA;KACC,UAAC,KAAA,YAAsB;KACzB,SAAW,KAAE,WAAM;;;;;;KAEzB,OAAW,KAAA,UAAgB,IAAO,UAAS,KAAA,KAAA;KACnC,UAAU,KAAK,YAAU;KAC/B,YAAe,KAAQ,eAAe;KACpC,QAAW,KAAA,WAAY;KACrB;IACD,CAAC;KACD;GAAC;GAAS;GAAC;GAAK,CAAA,CAAU;IAC5B;EAAC;EAAE;EAAA;EAAkB,CAAA,CAAA;AACxB,QAAM;;AAER,yBAAsB,SAAA;OAAiB;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
package/dist/index.cjs CHANGED
@@ -172,10 +172,13 @@ const plugin = __assignType((options = {}) => {
172
172
  }
173
173
  },
174
174
  prepare: __assignType(async function prepare() {
175
+ const _self$ = this;
175
176
  this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
176
177
  const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
177
- return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.jsx)(require_components_env_builtin.EnvBuiltin, {
178
- defaultConfig: this.config.env.defaultConfig,
178
+ return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_env_builtin.EnvBuiltin, {
179
+ get defaultConfig() {
180
+ return _self$.config.env.defaultConfig;
181
+ },
179
182
  reflection: result
180
183
  }));
181
184
  }, ["prepare", "P\"/!"]),
@@ -195,7 +198,7 @@ const plugin = __assignType((options = {}) => {
195
198
  docs: __assignType(async function docs() {
196
199
  this.debug(`Documenting environment variables configuration values in "${(0, _stryke_path_join.joinPaths)(require_helpers_docs_helper.getDocsOutputPath(this), "env.md")}"`);
197
200
  const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
198
- return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.jsx)(require_components_docs.EnvDocsFile, {
201
+ return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_docs.EnvDocsFile, {
199
202
  levelOffset: 0,
200
203
  reflection: result
201
204
  }));
package/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type
11
11
  import defu from "defu";
12
12
  import { VIRTUAL_MODULE_PREFIX } from "powerlines/constants";
13
13
  import { joinPaths } from "@stryke/path/join";
14
- import { jsx } from "@alloy-js/core/jsx-runtime";
14
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
15
15
  import { getUnique } from "@stryke/helpers/get-unique";
16
16
  import { render } from "@powerlines/plugin-alloy/render";
17
17
  import automd from "@powerlines/plugin-automd";
@@ -166,10 +166,13 @@ const plugin = __assignType((options = {}) => {
166
166
  }
167
167
  },
168
168
  prepare: __assignType(async function prepare() {
169
+ const _self$ = this;
169
170
  this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
170
171
  const result = await readEnvTypeReflection(this, "env");
171
- return render(this, jsx(EnvBuiltin, {
172
- defaultConfig: this.config.env.defaultConfig,
172
+ return render(this, createComponent(EnvBuiltin, {
173
+ get defaultConfig() {
174
+ return _self$.config.env.defaultConfig;
175
+ },
173
176
  reflection: result
174
177
  }));
175
178
  }, ["prepare", "P\"/!"]),
@@ -189,7 +192,7 @@ const plugin = __assignType((options = {}) => {
189
192
  docs: __assignType(async function docs() {
190
193
  this.debug(`Documenting environment variables configuration values in "${joinPaths(getDocsOutputPath(this), "env.md")}"`);
191
194
  const result = await readEnvTypeReflection(this, "env");
192
- return render(this, jsx(EnvDocsFile, {
195
+ return render(this, createComponent(EnvDocsFile, {
193
196
  levelOffset: 0,
194
197
  reflection: result
195
198
  }));