@powerlines/plugin-env 0.16.121 → 0.16.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel/plugin.cjs +1 -11
- package/dist/babel/plugin.d.cts.map +1 -1
- package/dist/babel/plugin.d.mts.map +1 -1
- package/dist/babel/plugin.mjs +1 -11
- package/dist/babel/plugin.mjs.map +1 -1
- package/dist/components/docs.cjs +44 -4
- package/dist/components/docs.mjs +43 -4
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/env-builtin.cjs +299 -53
- package/dist/components/env-builtin.d.cts.map +1 -1
- package/dist/components/env-builtin.d.mts.map +1 -1
- package/dist/components/env-builtin.mjs +301 -56
- package/dist/components/env-builtin.mjs.map +1 -1
- package/dist/components/index.cjs +3 -1
- package/dist/components/index.mjs +3 -3
- package/dist/helpers/load.cjs +1 -1
- package/dist/helpers/persistence.cjs +1 -1
- package/dist/index.cjs +77 -32
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +76 -31
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.cjs +1 -1
- package/dist/types/plugin.d.cts +6 -6
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +6 -6
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/dist/types/plugin.mjs.map +1 -1
- package/dist/types/runtime.cjs +303 -7
- package/dist/types/runtime.mjs +303 -7
- package/dist/types/runtime.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -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 ClassDeclaration,\n ClassMethod,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n NewExpression,\n TypeDeclaration,\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 { 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=\" EnvBase\"\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 \\`EnvBase\\` 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 <TypeDeclaration name=\"Env\" export>\n {code` {\n [Key in keyof EnvBase as Key ${getUnique(\n context.config.env.prefix.map(\n prefix => `| \\`${prefix.replace(/_$/g, \"\")}_\\${Key}\\``\n )\n ).join(\" \")}]: EnvBase[Key];\n}\n`}\n </TypeDeclaration>\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 \"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<EnvBase>\"\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 <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 export={false}\n const\n initializer={<NewExpression args={[]} target=\"EnvSerializer\" />}\n />\n <Spacing />\n\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 <TSDocThrows>\n {`ValidationError when serialization or validation fails.`}\n </TSDocThrows>\n </TSDoc>\n <VarDeclaration\n name=\"serializeEnv\"\n export\n const\n initializer={\"serializeFunction<EnvBase>(envSerializer)\"}\n />\n <Spacing />\n\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 <VarDeclaration\n name=\"deserializeEnv\"\n export\n const\n initializer=\"deserializeFunction<EnvBase>(envSerializer)\"\n />\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: EnvBase, 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: EnvBase, propertyName: string, newValue: any) => { `}\n <hbr />\n\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 />\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":";;;;;;;;;;;;;;;;;;;;AAwCA,SAAS,kBAAyB,OAAM;CACxC,MAAQ,CAAC,EACT,cACA,gBACO,WAAE,OAAgB,CAAC,gBAAO,aAAkB,CAAK;CACxD,MAAO,UA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lB,CAAC;IAAE,gBAAkB,SAAA,EAAA,CAAA;IAAA,gBAAA,OAAA;KACpB,SAAQ;KACR,IAAI,WAAI;AACN,aAAK,gBAAA,cAAA,EACH,UAAC,IAAA;;;;aAKP,CAAA;;KAEH,CAAA;IAAA,gBAAA,gBAAA;KACF,UAAA;KACO,SAAE;KACF,MAAI;KACL,aAAS,IAAA;KACT,CAAA;IAAG,gBAAE,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;;KAEL,SAAM;KACL,MAAC;KACD,KAAI;KACJ,aAAE,IAAY;KACf,CAAC;IAAA,gBAAK,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACN,UAAA;KACC,SAAQ;KACR,MAAM;KACN,KAAK;KACL,aAAA,IAAA;KACD,CAAC;IAAA,gBAAA,SAAA,EAAA,CAAA;IAAA,gBAAA,gBAAA;KACA,UAAA;KACA,SAAS;KACT,MAAA;KACD,KAAA;KACA,aAAS,IAAA;;;;KAET,UAAA;KACC,SAAA;KACA,MAAA;KACA,KAAK;KACL,aAAY,IAAG;KAChB,CAAC;IAAA,gBAAkB,SAAO,EAAA,CAAA;IAAA,gBAAA,MAAA;KACzB,IAAE,OAAQ;AACR,aAAI,QAAQ,SAAA;;KAER;KACP,CAAC;IAAC;;EAEN,CAAC,CAAC"}
|
|
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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,SAAI;KACL,MAAO;KACP,aAAK,IAAA;;;;KAEL,UAAM;KACL,SAAC;KACD,MAAI;KACJ,KAAE;KACF,aAAK,IAAA;KACN,CAAA;IAAA,gBAAA,SAAA,EAAA,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"}
|
|
@@ -4,4 +4,6 @@ const require_components_env_builtin = require('./env-builtin.cjs');
|
|
|
4
4
|
|
|
5
5
|
exports.EnvBuiltin = require_components_env_builtin.EnvBuiltin;
|
|
6
6
|
exports.EnvDocsFile = require_components_docs.EnvDocsFile;
|
|
7
|
-
exports.EnvTypeDefinition = require_components_env_builtin.EnvTypeDefinition;
|
|
7
|
+
exports.EnvTypeDefinition = require_components_env_builtin.EnvTypeDefinition;
|
|
8
|
+
exports.__ΩEnvBuiltinProps = require_components_env_builtin.__ΩEnvBuiltinProps;
|
|
9
|
+
exports.__ΩEnvDocsFileProps = require_components_docs.__ΩEnvDocsFileProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvDocsFile } from "./docs.mjs";
|
|
2
|
-
import { EnvBuiltin, EnvTypeDefinition } from "./env-builtin.mjs";
|
|
1
|
+
import { EnvDocsFile, __ΩEnvDocsFileProps } from "./docs.mjs";
|
|
2
|
+
import { EnvBuiltin, EnvTypeDefinition, __ΩEnvBuiltinProps } from "./env-builtin.mjs";
|
|
3
3
|
|
|
4
|
-
export { EnvBuiltin, EnvDocsFile, EnvTypeDefinition };
|
|
4
|
+
export { EnvBuiltin, EnvDocsFile, EnvTypeDefinition, __ΩEnvBuiltinProps, __ΩEnvDocsFileProps };
|
package/dist/helpers/load.cjs
CHANGED
|
@@ -8,7 +8,7 @@ let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case
|
|
|
8
8
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
9
9
|
let c12 = require("c12");
|
|
10
10
|
let defu = require("defu");
|
|
11
|
-
defu = require_runtime.__toESM(defu);
|
|
11
|
+
defu = require_runtime.__toESM(defu, 1);
|
|
12
12
|
let powerlines_constants = require("powerlines/constants");
|
|
13
13
|
|
|
14
14
|
//#region src/helpers/load.ts
|
|
@@ -7,7 +7,7 @@ let _powerlines_deepkit_resolve_reflections = require("@powerlines/deepkit/resol
|
|
|
7
7
|
let _powerlines_deepkit_schemas_reflection = require("@powerlines/deepkit/schemas/reflection");
|
|
8
8
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
9
9
|
let _stryke_capnp = require("@stryke/capnp");
|
|
10
|
-
_stryke_capnp = require_runtime.__toESM(_stryke_capnp);
|
|
10
|
+
_stryke_capnp = require_runtime.__toESM(_stryke_capnp, 1);
|
|
11
11
|
let _stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
12
12
|
let _stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
13
13
|
let _stryke_type_checks_is_empty_object = require("@stryke/type-checks/is-empty-object");
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_types_plugin = require('./types/plugin.cjs');
|
|
3
4
|
const require_helpers_reflect = require('./helpers/reflect.cjs');
|
|
4
5
|
const require_helpers_persistence = require('./helpers/persistence.cjs');
|
|
5
6
|
const require_helpers_load = require('./helpers/load.cjs');
|
|
@@ -9,19 +10,19 @@ const require_components_docs = require('./components/docs.cjs');
|
|
|
9
10
|
const require_components_env_builtin = require('./components/env-builtin.cjs');
|
|
10
11
|
const require_babel_plugin = require('./babel/plugin.cjs');
|
|
11
12
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
12
|
-
let _stryke_env_types = require("@stryke/env/types");
|
|
13
13
|
let defu = require("defu");
|
|
14
14
|
defu = require_runtime.__toESM(defu);
|
|
15
|
+
let powerlines_constants = require("powerlines/constants");
|
|
15
16
|
let _stryke_path_join = require("@stryke/path/join");
|
|
16
17
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
17
18
|
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
18
|
-
let _powerlines_plugin_alloy = require("@powerlines/plugin-alloy");
|
|
19
|
-
_powerlines_plugin_alloy = require_runtime.__toESM(_powerlines_plugin_alloy);
|
|
20
19
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
21
20
|
let _powerlines_plugin_automd = require("@powerlines/plugin-automd");
|
|
22
21
|
_powerlines_plugin_automd = require_runtime.__toESM(_powerlines_plugin_automd);
|
|
23
22
|
let _powerlines_plugin_babel = require("@powerlines/plugin-babel");
|
|
24
23
|
_powerlines_plugin_babel = require_runtime.__toESM(_powerlines_plugin_babel);
|
|
24
|
+
let _powerlines_plugin_deepkit = require("@powerlines/plugin-deepkit");
|
|
25
|
+
_powerlines_plugin_deepkit = require_runtime.__toESM(_powerlines_plugin_deepkit);
|
|
25
26
|
let _stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
|
|
26
27
|
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
27
28
|
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
@@ -29,12 +30,16 @@ let _stryke_string_format_constant_case = require("@stryke/string-format/constan
|
|
|
29
30
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
30
31
|
|
|
31
32
|
//#region src/index.tsx
|
|
33
|
+
function __assignType(fn, args) {
|
|
34
|
+
fn.__type = args;
|
|
35
|
+
return fn;
|
|
36
|
+
}
|
|
32
37
|
/**
|
|
33
38
|
* A Powerlines plugin to inject environment variables into the source code.
|
|
34
39
|
*/
|
|
35
|
-
const plugin = (options = {}) => {
|
|
40
|
+
const plugin = __assignType((options = {}) => {
|
|
36
41
|
return [
|
|
37
|
-
(0,
|
|
42
|
+
(0, _powerlines_plugin_deepkit.default)(options.deepkit),
|
|
38
43
|
(0, _powerlines_plugin_babel.default)(options.babel),
|
|
39
44
|
{
|
|
40
45
|
name: "env:core",
|
|
@@ -47,7 +52,12 @@ const plugin = (options = {}) => {
|
|
|
47
52
|
inject: false,
|
|
48
53
|
prefix: []
|
|
49
54
|
}),
|
|
50
|
-
babel: { plugins: [require_babel_plugin.envBabelPlugin] }
|
|
55
|
+
babel: { plugins: [require_babel_plugin.envBabelPlugin] },
|
|
56
|
+
deepkit: {
|
|
57
|
+
reflection: "default",
|
|
58
|
+
level: "all"
|
|
59
|
+
},
|
|
60
|
+
tsc: {}
|
|
51
61
|
};
|
|
52
62
|
if ((0, _stryke_type_checks_is_set_string.isSetString)(config.env.types) || config.env.types && (0, _stryke_type_checks_is_set_string.isSetString)(config.env.types.file)) {
|
|
53
63
|
config.env.types = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(config.env.types);
|
|
@@ -68,19 +78,26 @@ const plugin = (options = {}) => {
|
|
|
68
78
|
const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
|
|
69
79
|
if (file) config.env.secrets = (0, _stryke_convert_parse_type_definition.parseTypeDefinition)(`${file}#${secretsDefaultTypeDefinition.name}`);
|
|
70
80
|
}
|
|
71
|
-
config.env.
|
|
81
|
+
if (config.env.types || config.env.secrets) config.tsc.filter = { id: [new RegExp(`^(${powerlines_constants.VIRTUAL_MODULE_PREFIX})?${(0, _stryke_path_join.joinPaths)(this.builtinsPath, "env.ts").replace(/\\/g, "\\\\").replace(/\//g, "\\/").replace(/\./g, "\\.").replace(/\$/g, "\\$")}$`)] };
|
|
82
|
+
config.env.prefix = (0, _stryke_convert_to_array.toArray)(config.env.prefix ?? []).reduce(__assignType((ret, prefix) => {
|
|
72
83
|
const formattedPrefix = (0, _stryke_string_format_constant_case.constantCase)(prefix);
|
|
73
84
|
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
74
85
|
return ret;
|
|
75
86
|
}, [
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
config.
|
|
87
|
+
"ret",
|
|
88
|
+
"prefix",
|
|
89
|
+
"",
|
|
90
|
+
"P&F2!&2\"\"/#"
|
|
91
|
+
]), ["POWERLINES_", this.config.framework && this.config.framework !== "powerlines" && `${(0, _stryke_string_format_constant_case.constantCase)(this.config.framework)}_`].filter(Boolean));
|
|
92
|
+
config.env.prefix = (0, _stryke_helpers_get_unique.getUnique)((0, _stryke_convert_to_array.toArray)(config.env.prefix).reduce(__assignType((ret, prefix) => {
|
|
81
93
|
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
82
94
|
return ret;
|
|
83
|
-
}, [
|
|
95
|
+
}, [
|
|
96
|
+
"ret",
|
|
97
|
+
"prefix",
|
|
98
|
+
"",
|
|
99
|
+
"P\"2!\"2\"\"/#"
|
|
100
|
+
]), []));
|
|
84
101
|
return config;
|
|
85
102
|
},
|
|
86
103
|
async configResolved() {
|
|
@@ -109,15 +126,32 @@ const plugin = (options = {}) => {
|
|
|
109
126
|
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
110
127
|
await require_helpers_persistence.writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
111
128
|
this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
112
|
-
const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
const envWithAlias = this.env.types.env.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
130
|
+
"prop",
|
|
131
|
+
"",
|
|
132
|
+
"P\"2!\"/\""
|
|
133
|
+
]));
|
|
134
|
+
Object.entries(await require_helpers_load.loadEnv(this, this.config.env)).forEach(__assignType(([key, value]) => {
|
|
135
|
+
const unprefixedKey = this.config.env.prefix.reduce(__assignType((ret, prefix) => {
|
|
115
136
|
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
116
137
|
return ret;
|
|
117
|
-
},
|
|
118
|
-
|
|
138
|
+
}, [
|
|
139
|
+
"ret",
|
|
140
|
+
"prefix",
|
|
141
|
+
"",
|
|
142
|
+
"P\"2!\"2\"\"/#"
|
|
143
|
+
]), key);
|
|
144
|
+
const aliasKey = envWithAlias.find(__assignType((prop) => prop?.getAlias().reverse().includes(unprefixedKey), [
|
|
145
|
+
"prop",
|
|
146
|
+
"",
|
|
147
|
+
"P\"2!\"/\""
|
|
148
|
+
]));
|
|
119
149
|
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
120
|
-
}
|
|
150
|
+
}, [
|
|
151
|
+
"param0",
|
|
152
|
+
"",
|
|
153
|
+
"P\"2!\"/\""
|
|
154
|
+
]));
|
|
121
155
|
this.env.used.env = new _powerlines_deepkit_vendor_type.ReflectionClass({
|
|
122
156
|
kind: _powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
123
157
|
typeName: "Env",
|
|
@@ -137,7 +171,7 @@ const plugin = (options = {}) => {
|
|
|
137
171
|
}
|
|
138
172
|
}
|
|
139
173
|
},
|
|
140
|
-
async prepare() {
|
|
174
|
+
prepare: __assignType(async function prepare() {
|
|
141
175
|
const _self$ = this;
|
|
142
176
|
this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
143
177
|
const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
@@ -147,10 +181,10 @@ const plugin = (options = {}) => {
|
|
|
147
181
|
},
|
|
148
182
|
reflection: result
|
|
149
183
|
}));
|
|
150
|
-
},
|
|
184
|
+
}, ["prepare", "P\"/!"]),
|
|
151
185
|
transform: {
|
|
152
186
|
order: "post",
|
|
153
|
-
async handler() {
|
|
187
|
+
handler: __assignType(async function handler() {
|
|
154
188
|
if (this.env.used.env.getProperties().length > 0) {
|
|
155
189
|
this.trace(`Persisting used environment configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "env")}.`);
|
|
156
190
|
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
@@ -159,37 +193,48 @@ const plugin = (options = {}) => {
|
|
|
159
193
|
this.trace(`Persisting used secret configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "secrets")}.`);
|
|
160
194
|
await require_helpers_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
161
195
|
}
|
|
162
|
-
}
|
|
196
|
+
}, ["handler", "P\"/!"])
|
|
163
197
|
},
|
|
164
|
-
async docs() {
|
|
198
|
+
docs: __assignType(async function docs() {
|
|
165
199
|
this.debug(`Documenting environment variables configuration values in "${(0, _stryke_path_join.joinPaths)(require_helpers_docs_helper.getDocsOutputPath(this), "env.md")}"`);
|
|
166
200
|
const result = await require_helpers_persistence.readEnvTypeReflection(this, "env");
|
|
167
201
|
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_docs.EnvDocsFile, {
|
|
168
202
|
levelOffset: 0,
|
|
169
203
|
reflection: result
|
|
170
204
|
}));
|
|
171
|
-
},
|
|
172
|
-
async buildEnd() {
|
|
205
|
+
}, ["docs", "P\"/!"]),
|
|
206
|
+
buildEnd: __assignType(async function buildEnd() {
|
|
173
207
|
const reflectionPath = require_helpers_persistence.getEnvReflectionsPath(this, "env");
|
|
174
208
|
this.debug(`Writing env reflection types to ${reflectionPath}.`);
|
|
175
209
|
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
176
|
-
}
|
|
210
|
+
}, ["buildEnd", "P\"/!"])
|
|
177
211
|
},
|
|
178
212
|
{
|
|
179
213
|
name: "env:automd-generator",
|
|
180
|
-
config() {
|
|
214
|
+
config: __assignType(function config() {
|
|
181
215
|
return { automd: (0, defu.default)(options.automd ?? {}, { generators: { env: require_helpers_automd_generator.env(this) } }) };
|
|
182
|
-
}
|
|
216
|
+
}, ["config", "P\"/!"])
|
|
183
217
|
},
|
|
184
218
|
{
|
|
185
219
|
name: "env:vite",
|
|
186
|
-
vite: { configResolved() {
|
|
220
|
+
vite: { configResolved: __assignType(function configResolved() {
|
|
187
221
|
return { envPrefix: this.config?.env?.prefix };
|
|
188
|
-
}
|
|
222
|
+
}, [
|
|
223
|
+
() => require_types_plugin.__ΩEnvPluginContext,
|
|
224
|
+
"this",
|
|
225
|
+
"configResolved",
|
|
226
|
+
"Pn!2\"\"/#"
|
|
227
|
+
]) }
|
|
189
228
|
},
|
|
190
229
|
(0, _powerlines_plugin_automd.default)(options.automd)
|
|
191
230
|
];
|
|
192
|
-
}
|
|
231
|
+
}, [
|
|
232
|
+
() => require_types_plugin.__ΩEnvPluginOptions,
|
|
233
|
+
"options",
|
|
234
|
+
() => ({}),
|
|
235
|
+
"",
|
|
236
|
+
"Pn!2\">#\"/$"
|
|
237
|
+
]);
|
|
193
238
|
|
|
194
239
|
//#endregion
|
|
195
240
|
exports.default = plugin;
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;YAiEY,MAAA;IACR,GAAA,GAAM,gBAAA;EAAA;AAAA;;;;cAOG,MAAA,oBAA2B,gBAAA,GAAmB,gBAAA,EACzD,OAAA,GAAS,gBAAA,KAgXJ,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;YAiEY,MAAA;IACR,GAAA,GAAM,gBAAA;EAAA;AAAA;;;;cAOG,MAAA,oBAA2B,gBAAA,GAAmB,gBAAA,EACzD,OAAA,GAAS,gBAAA,KAgXJ,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __ΩEnvPluginContext, __ΩEnvPluginOptions } from "./types/plugin.mjs";
|
|
1
2
|
import { reflectEnv, reflectSecrets } from "./helpers/reflect.mjs";
|
|
2
3
|
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, writeEnvReflection, writeEnvTypeReflection } from "./helpers/persistence.mjs";
|
|
3
4
|
import { loadEnv } from "./helpers/load.mjs";
|
|
@@ -7,15 +8,15 @@ import { EnvDocsFile } from "./components/docs.mjs";
|
|
|
7
8
|
import { EnvBuiltin } from "./components/env-builtin.mjs";
|
|
8
9
|
import { envBabelPlugin } from "./babel/plugin.mjs";
|
|
9
10
|
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
10
|
-
import { ENV_PREFIXES } from "@stryke/env/types";
|
|
11
11
|
import defu from "defu";
|
|
12
|
+
import { VIRTUAL_MODULE_PREFIX } from "powerlines/constants";
|
|
12
13
|
import { joinPaths } from "@stryke/path/join";
|
|
13
14
|
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
14
15
|
import { getUnique } from "@stryke/helpers/get-unique";
|
|
15
|
-
import alloy from "@powerlines/plugin-alloy";
|
|
16
16
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
17
17
|
import automd from "@powerlines/plugin-automd";
|
|
18
18
|
import babel from "@powerlines/plugin-babel";
|
|
19
|
+
import deepkit from "@powerlines/plugin-deepkit";
|
|
19
20
|
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
|
|
20
21
|
import { toArray } from "@stryke/convert/to-array";
|
|
21
22
|
import { existsSync } from "@stryke/fs/exists";
|
|
@@ -23,12 +24,16 @@ import { constantCase } from "@stryke/string-format/constant-case";
|
|
|
23
24
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
24
25
|
|
|
25
26
|
//#region src/index.tsx
|
|
27
|
+
function __assignType(fn, args) {
|
|
28
|
+
fn.__type = args;
|
|
29
|
+
return fn;
|
|
30
|
+
}
|
|
26
31
|
/**
|
|
27
32
|
* A Powerlines plugin to inject environment variables into the source code.
|
|
28
33
|
*/
|
|
29
|
-
const plugin = (options = {}) => {
|
|
34
|
+
const plugin = __assignType((options = {}) => {
|
|
30
35
|
return [
|
|
31
|
-
|
|
36
|
+
deepkit(options.deepkit),
|
|
32
37
|
babel(options.babel),
|
|
33
38
|
{
|
|
34
39
|
name: "env:core",
|
|
@@ -41,7 +46,12 @@ const plugin = (options = {}) => {
|
|
|
41
46
|
inject: false,
|
|
42
47
|
prefix: []
|
|
43
48
|
}),
|
|
44
|
-
babel: { plugins: [envBabelPlugin] }
|
|
49
|
+
babel: { plugins: [envBabelPlugin] },
|
|
50
|
+
deepkit: {
|
|
51
|
+
reflection: "default",
|
|
52
|
+
level: "all"
|
|
53
|
+
},
|
|
54
|
+
tsc: {}
|
|
45
55
|
};
|
|
46
56
|
if (isSetString(config.env.types) || config.env.types && isSetString(config.env.types.file)) {
|
|
47
57
|
config.env.types = parseTypeDefinition(config.env.types);
|
|
@@ -62,19 +72,26 @@ const plugin = (options = {}) => {
|
|
|
62
72
|
const file = await this.fs.resolve(secretsDefaultTypeDefinition.file);
|
|
63
73
|
if (file) config.env.secrets = parseTypeDefinition(`${file}#${secretsDefaultTypeDefinition.name}`);
|
|
64
74
|
}
|
|
65
|
-
config.env.
|
|
75
|
+
if (config.env.types || config.env.secrets) config.tsc.filter = { id: [new RegExp(`^(${VIRTUAL_MODULE_PREFIX})?${joinPaths(this.builtinsPath, "env.ts").replace(/\\/g, "\\\\").replace(/\//g, "\\/").replace(/\./g, "\\.").replace(/\$/g, "\\$")}$`)] };
|
|
76
|
+
config.env.prefix = toArray(config.env.prefix ?? []).reduce(__assignType((ret, prefix) => {
|
|
66
77
|
const formattedPrefix = constantCase(prefix);
|
|
67
78
|
if (!ret.includes(formattedPrefix)) ret.push(formattedPrefix);
|
|
68
79
|
return ret;
|
|
69
80
|
}, [
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
config.
|
|
81
|
+
"ret",
|
|
82
|
+
"prefix",
|
|
83
|
+
"",
|
|
84
|
+
"P&F2!&2\"\"/#"
|
|
85
|
+
]), ["POWERLINES_", this.config.framework && this.config.framework !== "powerlines" && `${constantCase(this.config.framework)}_`].filter(Boolean));
|
|
86
|
+
config.env.prefix = getUnique(toArray(config.env.prefix).reduce(__assignType((ret, prefix) => {
|
|
75
87
|
if (!ret.includes(prefix.replace(/_$/g, ""))) ret.push(prefix.replace(/_$/g, ""));
|
|
76
88
|
return ret;
|
|
77
|
-
}, [
|
|
89
|
+
}, [
|
|
90
|
+
"ret",
|
|
91
|
+
"prefix",
|
|
92
|
+
"",
|
|
93
|
+
"P\"2!\"2\"\"/#"
|
|
94
|
+
]), []));
|
|
78
95
|
return config;
|
|
79
96
|
},
|
|
80
97
|
async configResolved() {
|
|
@@ -103,15 +120,32 @@ const plugin = (options = {}) => {
|
|
|
103
120
|
if (!this.env.types.secrets) throw new Error("Failed to find the secrets configuration type reflection in the context.");
|
|
104
121
|
await writeEnvTypeReflection(this, this.env.types.secrets, "secrets");
|
|
105
122
|
this.debug(`Resolved ${this.env.types.env.getProperties().length ?? 0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length ?? 0} secret configuration parameters`);
|
|
106
|
-
const envWithAlias = this.env.types.env.getProperties().filter((prop) => prop.getAlias().length > 0
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
const envWithAlias = this.env.types.env.getProperties().filter(__assignType((prop) => prop.getAlias().length > 0, [
|
|
124
|
+
"prop",
|
|
125
|
+
"",
|
|
126
|
+
"P\"2!\"/\""
|
|
127
|
+
]));
|
|
128
|
+
Object.entries(await loadEnv(this, this.config.env)).forEach(__assignType(([key, value]) => {
|
|
129
|
+
const unprefixedKey = this.config.env.prefix.reduce(__assignType((ret, prefix) => {
|
|
109
130
|
if (key.replace(/_$/g, "").startsWith(prefix)) return key.replace(/_$/g, "").slice(prefix.length);
|
|
110
131
|
return ret;
|
|
111
|
-
},
|
|
112
|
-
|
|
132
|
+
}, [
|
|
133
|
+
"ret",
|
|
134
|
+
"prefix",
|
|
135
|
+
"",
|
|
136
|
+
"P\"2!\"2\"\"/#"
|
|
137
|
+
]), key);
|
|
138
|
+
const aliasKey = envWithAlias.find(__assignType((prop) => prop?.getAlias().reverse().includes(unprefixedKey), [
|
|
139
|
+
"prop",
|
|
140
|
+
"",
|
|
141
|
+
"P\"2!\"/\""
|
|
142
|
+
]));
|
|
113
143
|
if (this.env.types.env?.hasProperty(unprefixedKey) || aliasKey) this.env.types.env.getProperty(unprefixedKey).setDefaultValue(value);
|
|
114
|
-
}
|
|
144
|
+
}, [
|
|
145
|
+
"param0",
|
|
146
|
+
"",
|
|
147
|
+
"P\"2!\"/\""
|
|
148
|
+
]));
|
|
115
149
|
this.env.used.env = new ReflectionClass({
|
|
116
150
|
kind: ReflectionKind.objectLiteral,
|
|
117
151
|
typeName: "Env",
|
|
@@ -131,7 +165,7 @@ const plugin = (options = {}) => {
|
|
|
131
165
|
}
|
|
132
166
|
}
|
|
133
167
|
},
|
|
134
|
-
async prepare() {
|
|
168
|
+
prepare: __assignType(async function prepare() {
|
|
135
169
|
const _self$ = this;
|
|
136
170
|
this.debug(`Preparing the Environment runtime artifacts for the Powerlines project.`);
|
|
137
171
|
const result = await readEnvTypeReflection(this, "env");
|
|
@@ -141,10 +175,10 @@ const plugin = (options = {}) => {
|
|
|
141
175
|
},
|
|
142
176
|
reflection: result
|
|
143
177
|
}));
|
|
144
|
-
},
|
|
178
|
+
}, ["prepare", "P\"/!"]),
|
|
145
179
|
transform: {
|
|
146
180
|
order: "post",
|
|
147
|
-
async handler() {
|
|
181
|
+
handler: __assignType(async function handler() {
|
|
148
182
|
if (this.env.used.env.getProperties().length > 0) {
|
|
149
183
|
this.trace(`Persisting used environment configuration reflections to ${getEnvReflectionsPath(this, "env")}.`);
|
|
150
184
|
await writeEnvReflection(this, this.env.used.env, "env");
|
|
@@ -153,37 +187,48 @@ const plugin = (options = {}) => {
|
|
|
153
187
|
this.trace(`Persisting used secret configuration reflections to ${getEnvReflectionsPath(this, "secrets")}.`);
|
|
154
188
|
await writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
155
189
|
}
|
|
156
|
-
}
|
|
190
|
+
}, ["handler", "P\"/!"])
|
|
157
191
|
},
|
|
158
|
-
async docs() {
|
|
192
|
+
docs: __assignType(async function docs() {
|
|
159
193
|
this.debug(`Documenting environment variables configuration values in "${joinPaths(getDocsOutputPath(this), "env.md")}"`);
|
|
160
194
|
const result = await readEnvTypeReflection(this, "env");
|
|
161
195
|
return render(this, createComponent(EnvDocsFile, {
|
|
162
196
|
levelOffset: 0,
|
|
163
197
|
reflection: result
|
|
164
198
|
}));
|
|
165
|
-
},
|
|
166
|
-
async buildEnd() {
|
|
199
|
+
}, ["docs", "P\"/!"]),
|
|
200
|
+
buildEnd: __assignType(async function buildEnd() {
|
|
167
201
|
const reflectionPath = getEnvReflectionsPath(this, "env");
|
|
168
202
|
this.debug(`Writing env reflection types to ${reflectionPath}.`);
|
|
169
203
|
await writeEnvReflection(this, this.env.used.env, "env");
|
|
170
|
-
}
|
|
204
|
+
}, ["buildEnd", "P\"/!"])
|
|
171
205
|
},
|
|
172
206
|
{
|
|
173
207
|
name: "env:automd-generator",
|
|
174
|
-
config() {
|
|
208
|
+
config: __assignType(function config() {
|
|
175
209
|
return { automd: defu(options.automd ?? {}, { generators: { env: env(this) } }) };
|
|
176
|
-
}
|
|
210
|
+
}, ["config", "P\"/!"])
|
|
177
211
|
},
|
|
178
212
|
{
|
|
179
213
|
name: "env:vite",
|
|
180
|
-
vite: { configResolved() {
|
|
214
|
+
vite: { configResolved: __assignType(function configResolved() {
|
|
181
215
|
return { envPrefix: this.config?.env?.prefix };
|
|
182
|
-
}
|
|
216
|
+
}, [
|
|
217
|
+
() => __ΩEnvPluginContext,
|
|
218
|
+
"this",
|
|
219
|
+
"configResolved",
|
|
220
|
+
"Pn!2\"\"/#"
|
|
221
|
+
]) }
|
|
183
222
|
},
|
|
184
223
|
automd(options.automd)
|
|
185
224
|
];
|
|
186
|
-
}
|
|
225
|
+
}, [
|
|
226
|
+
() => __ΩEnvPluginOptions,
|
|
227
|
+
"options",
|
|
228
|
+
() => ({}),
|
|
229
|
+
"",
|
|
230
|
+
"Pn!2\">#\"/$"
|
|
231
|
+
]);
|
|
187
232
|
|
|
188
233
|
//#endregion
|
|
189
234
|
export { plugin as default, plugin };
|