@powerlines/plugin-env 0.1.0
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/LICENSE +201 -0
- package/README.md +295 -0
- package/dist/babel/index.cjs +1 -0
- package/dist/babel/index.d.cts +28 -0
- package/dist/babel/index.d.ts +28 -0
- package/dist/babel/index.js +1 -0
- package/dist/babel/plugin.cjs +19 -0
- package/dist/babel/plugin.d.cts +31 -0
- package/dist/babel/plugin.d.ts +31 -0
- package/dist/babel/plugin.js +19 -0
- package/dist/chunk-FBBMZ4NC.cjs +7 -0
- package/dist/chunk-UCUR73HG.js +7 -0
- package/dist/components/env.cjs +40 -0
- package/dist/components/env.d.cts +106 -0
- package/dist/components/env.d.ts +106 -0
- package/dist/components/env.js +40 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +9 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +1 -0
- package/dist/helpers/index.cjs +1 -0
- package/dist/helpers/index.d.cts +32 -0
- package/dist/helpers/index.d.ts +32 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/load.cjs +7 -0
- package/dist/helpers/load.d.cts +57 -0
- package/dist/helpers/load.d.ts +57 -0
- package/dist/helpers/load.js +7 -0
- package/dist/helpers/persistence.cjs +7 -0
- package/dist/helpers/persistence.d.cts +98 -0
- package/dist/helpers/persistence.d.ts +98 -0
- package/dist/helpers/persistence.js +7 -0
- package/dist/helpers/reflect.cjs +7 -0
- package/dist/helpers/reflect.d.cts +70 -0
- package/dist/helpers/reflect.d.ts +70 -0
- package/dist/helpers/reflect.js +7 -0
- package/dist/helpers/source-file-env.cjs +7 -0
- package/dist/helpers/source-file-env.d.cts +7 -0
- package/dist/helpers/source-file-env.d.ts +7 -0
- package/dist/helpers/source-file-env.js +7 -0
- package/dist/helpers/template-helpers.cjs +7 -0
- package/dist/helpers/template-helpers.d.cts +38 -0
- package/dist/helpers/template-helpers.d.ts +38 -0
- package/dist/helpers/template-helpers.js +7 -0
- package/dist/index.cjs +22 -0
- package/dist/index.d.cts +75 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +22 -0
- package/dist/runtime-DqvtGYT3.d.ts +3289 -0
- package/dist/runtime-I3P49niA.d.cts +3289 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +27 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.js +1 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +169 -0
- package/dist/types/plugin.d.ts +169 -0
- package/dist/types/plugin.js +0 -0
- package/dist/types/runtime.cjs +1 -0
- package/dist/types/runtime.d.cts +24 -0
- package/dist/types/runtime.d.ts +24 -0
- package/dist/types/runtime.js +0 -0
- package/dist/vfs-COoZkq8D.d.cts +358 -0
- package/dist/vfs-COoZkq8D.d.ts +358 -0
- package/package.json +213 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {a}from'../chunk-UCUR73HG.js';import {createBabelPlugin}from'@powerlines/plugin-babel/helpers/create-plugin';import {addImport}from'@powerlines/plugin-babel/helpers/module-helpers';import {LogLevelLabel}from'@storm-software/config-tools/types';import*as y from'@stryke/capnp';import {readFileBufferSync}from'@stryke/fs/buffer';import {existsSync}from'node:fs';import {ReflectionClass,ReflectionKind,resolveClassType,deserializeType}from'powerlines/deepkit/type';import {convertFromCapnp}from'powerlines/lib/capnp';import {stringifyDefaultValue}from'powerlines/lib/deepkit/utilities';import {SerializedTypes}from'powerlines/schemas/reflection';import {getEnvReflectionsPath}from'../helpers/persistence';/*****************************************
|
|
2
|
+
*
|
|
3
|
+
* ⚡ Built by Storm Software
|
|
4
|
+
*
|
|
5
|
+
*****************************************/
|
|
6
|
+
|
|
7
|
+
const H=createBabelPlugin("env",({log:f,context:t})=>{function l(e,o,n=false){const a=t.env.types.env?.getProperties().filter(m=>m.getAlias().length>0);if(e.name){const m=t.config.env.prefix.find(i=>e.name&&e.name.startsWith(i)&&(t.env.types.env?.hasProperty(e.name.replace(`${i}_`,""))||a.some(r=>r.getAlias().includes(e.name.replace(`${i}_`,"")))));let s=e.name;if(m&&(s=e.name.replace(`${m}_`,"")),f(LogLevelLabel.TRACE,`Environment variable ${s} found in ${o.filename||"unknown file"}.`),t.env.types.env?.hasProperty(s)||a.some(i=>i.getAlias().includes(s))){const i=t.env.types.env.hasProperty(s)?t.env.types.env.getProperty(s):a.find(r=>r.getAlias().includes(s));if(!i||i.isIgnored())return;if(t.env.used.env.hasProperty(s)||t.env.used.env.addProperty(i.property),t.config.env.inject&&n){let r=t.env.parsed?.[s];if(r===void 0){const v=t.config.env.prefix.find(u=>t.env.parsed[`${u.replace(/_$/g,"")}_${s}`]);v&&(r=t.env.parsed[`${v.replace(/_$/g,"")}_${s}`]);}if(r??=i.getDefaultValue(),i.isValueRequired()&&r===void 0)throw new Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return stringifyDefaultValue(i,r)}}else throw new Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${o.filename?o.filename:"unknown"}.
|
|
8
|
+
|
|
9
|
+
The following environment configuration names are defined in the \`env\` type definition:
|
|
10
|
+
${t.env.types.env?.getPropertyNames().sort((i,r)=>String(i).localeCompare(String(r))).map(i=>` - ${String(i)} ${a.some(r=>r.getNameAsString()===String(i)&&r.getAlias().length>0)?`(Alias: ${a?.find(r=>r.getNameAsString()===String(i))?.getAlias().join(", ")})`:""}`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
|
|
13
|
+
Using the following env prefix:
|
|
14
|
+
${t.config.env.prefix.map(i=>` - ${i}`).join(`
|
|
15
|
+
`)}
|
|
16
|
+
|
|
17
|
+
Please check your \`env\` configuration option. If you are using a custom dotenv type definition, please make sure that the configuration names match the ones in the code.
|
|
18
|
+
|
|
19
|
+
`)}}return a(l,"extractEnv"),{visitor:{MemberExpression(e,o){if(e.get("object")?.get("property")?.isIdentifier({name:"env"})&&e.get("object")?.get("object")?.isIdentifier({name:"$storm"})&&e.get("property")?.isIdentifier()){const n=e.get("property")?.node;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(e,{module:"storm:env",name:"env",imported:"env"});}else if(e.get("object")?.get("property")?.isIdentifier({name:"env"})&&e.get("object")?.get("object")?.isCallExpression({callee:{name:"useStorm",type:"Identifier"}})&&e.get("property")?.isIdentifier()){const n=e.get("property")?.node;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(e,{module:"storm:env",name:"env",imported:"env"});}else if(e.get("object")?.get("property")?.isIdentifier({name:"env"})&&e.get("object")?.get("object")?.isIdentifier({name:"process"})&&e.get("property")?.isIdentifier()){const n=e.get("property")?.node;if(!n.name)return;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(e,{module:"storm:env",name:"env",imported:"env"});}else if(e.get("object")?.get("property")?.isIdentifier({name:"env"})&&e.get("object")?.get("object")?.isMetaProperty()&&e.get("property")?.isIdentifier()){const n=e.get("property")?.node;if(!n.name)return;l(n,o,false),e.replaceWithSourceString(`env.${n.name}`),addImport(e,{module:"storm:env",name:"env",imported:"env"});}}},post(){f(LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||"unknown file"} to env.json.`);let e=ReflectionClass.from({kind:ReflectionKind.objectLiteral,description:"An object containing the environment variables used by the application.",types:[]});const o=getEnvReflectionsPath(t,"env");o&&existsSync(o)&&(f(LogLevelLabel.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),e=resolveClassType(deserializeType(convertFromCapnp(new y.Message(readFileBufferSync(o),false).getRoot(SerializedTypes).types)))),f(LogLevelLabel.TRACE,`Adding new variables to env reflection at ${o}.`),e.getProperties().filter(n=>n.getNameAsString()&&!t.env.used.env.hasProperty(n.getNameAsString())).forEach(n=>{t.env.used.env.addProperty({...n,name:n.getNameAsString(),description:n.getDescription()??`The ${n.getNameAsString()} variable.`,default:n.getDefaultValue(),optional:n.isOptional()?true:void 0,readonly:n.isReadonly()?true:void 0,visibility:n.getVisibility(),type:n.getType(),tags:n.getTags()});});}}});export{H as envBabelPlugin};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),core=require('@alloy-js/core'),typescript=require('@alloy-js/typescript'),context=require('@powerlines/alloy/core/contexts/context'),refkey=require('@powerlines/alloy/helpers/refkey'),builtinFile=require('@powerlines/alloy/typescript/components/builtin-file'),tsdoc=require('@powerlines/alloy/typescript/components/tsdoc'),typescriptInterface=require('@powerlines/alloy/typescript/components/typescript-interface'),typescriptObject=require('@powerlines/alloy/typescript/components/typescript-object'),titleCase=require('@stryke/string-format/title-case'),isNull=require('@stryke/type-checks/is-null'),W=require('defu'),type=require('powerlines/deepkit/type'),load=require('../helpers/load'),persistence=require('../helpers/persistence');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var W__default=/*#__PURE__*/_interopDefault(W);/*****************************************
|
|
2
|
+
*
|
|
3
|
+
* ⚡ Built by Storm Software
|
|
4
|
+
*
|
|
5
|
+
*****************************************/
|
|
6
|
+
|
|
7
|
+
function Q(s){const[{defaultValue:i,reflection:t}]=core.splitProps(s,["defaultValue","reflection"]),r=context.useStorm();return React.createElement(React.Fragment,null,React.createElement(typescriptInterface.TypeScriptInterface,{name:" EnvBase",extends:["EnvInterface"],defaultValue:i,reflection:t,export:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(typescript.TypeDeclaration,{name:"Env",export:true},core.code` {
|
|
8
|
+
[Key in keyof EnvBase as Key ${r?.value?.config.env.prefix.map(o=>`| \`${o.replace(/_$/g,"")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
9
|
+
}
|
|
10
|
+
`))}chunkFBBMZ4NC_cjs.a(Q,"EnvTypeDefinition");function l(s){const[{context:i,name:t}]=core.splitProps(s,["context","name"]);return i?core.code`propertyName === "${t}" || propertyName.replace(/^(${i.config.env.prefix.sort((r,o)=>r.startsWith(o)?-1:o.startsWith(r)?1:r.localeCompare(o)).map(r=>`${r.replace(/_$/,"")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${t.toLowerCase().replace(/[\s\-_]+/g,"")}"`:null}chunkFBBMZ4NC_cjs.a(l,"ConfigPropertyConditional");function U(s){const[{context:i,property:t,index:r}]=core.splitProps(s,["context","property","index"]);return i?React.createElement(React.Fragment,null,r===0?React.createElement(typescript.IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:i}))))},core.code`return target["${t.getNameAsString()}"];`):React.createElement(typescript.ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:i}))))},core.code`return target["${t.getNameAsString()}"];`)):null}chunkFBBMZ4NC_cjs.a(U,"ConfigPropertyGet");function X(s){const[{context:i,property:t,index:r}]=core.splitProps(s,["context","property","index"]);return i?React.createElement(React.Fragment,null,r===0?React.createElement(typescript.IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:i}))))},core.code`
|
|
11
|
+
target["${t.getNameAsString()}"] = newValue;
|
|
12
|
+
return true;
|
|
13
|
+
`):React.createElement(typescript.ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(core.Show,{when:t.getAlias()&&t.getAlias().length>0},core.code` || `,React.createElement(core.For,{each:t.getAlias(),joiner:core.code` || `},o=>React.createElement(l,{name:o,context:i}))))},core.code`
|
|
14
|
+
target["${t.getNameAsString()}"] = newValue;
|
|
15
|
+
return true;
|
|
16
|
+
`)):null}chunkFBBMZ4NC_cjs.a(X,"ConfigPropertySet");const Y=refkey.refkey("createEnv"),Z=refkey.refkey("env"),ee=refkey.refkey("EnvSerializer");function be(s){const[{defaultConfig:i},t]=core.splitProps(s,["defaultConfig"]),r=context.useStorm(),o=core.computed(()=>r&&load.loadEnvFromContext(r.value,process.env)),f=core.createResource(async()=>{if(!r?.value)return new type.ReflectionClass({kind:type.ReflectionKind.objectLiteral,description:"The initial environment configuration state for the Powerlines project.",types:[]});const a=await persistence.readEnvTypeReflection(r?.value,"env");return a.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(h=>{a.addProperty({name:h,optional:e.isOptional()?true:void 0,readonly:e.isReadonly()?true:void 0,description:e.getDescription(),visibility:e.getVisibility(),type:e.getType(),default:e.getDefaultValue(),tags:{hidden:e.isHidden(),ignore:e.isIgnored(),internal:e.isInternal(),alias:e.getAlias().filter(j=>j!==h).concat(e.name),title:e.getTitle()||titleCase.titleCase(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}});});}),a.getProperties().forEach(e=>{e.setDefaultValue(o.value?.[e.getNameAsString()]??e.getAlias().reduce((T,h)=>T??o.value?.[h],void 0)??e.getDefaultValue());}),a}),k=core.computed(()=>new type.ReflectionClass({kind:type.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${titleCase.titleCase(r?.value?.config?.name)} project.`,types:[]},f.data??void 0)),R=core.computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]),N=core.computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()&&!a.isReadonly()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]);return React.createElement(builtinFile.BuiltinFile,{...t,id:"env",description:"The Powerlines environment configuration module provides an interface to define environment configuration parameters.",imports:W__default.default({"powerlines/deepkit/type":["Type","stringify","serializer","serializeFunction","deserializeFunction","ReflectionKind","TemplateState","Serializer","TypeProperty","TypePropertySignature"],"powerlines/runtime-types/shared/env":[{name:"EnvInterface"}]},t.imports??{})},React.createElement(core.Show,{when:!isNull.isNull(f.data)},React.createElement(Q,{defaultValue:o.value,reflection:f.data}),React.createElement("hbr",null),React.createElement("hbr",null)),React.createElement(typescriptObject.TypescriptObject,{name:"initialEnv",type:"Partial<EnvBase>",defaultValue:o,reflection:k,export:true,const:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"The environment configuration serializer for the Powerlines application."},React.createElement(tsdoc.TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(tsdoc.TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(tsdoc.TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(typescript.ClassDeclaration,{refkey:ee,name:"EnvSerializer",extends:"Serializer",export:true},React.createElement(typescript.ClassMethod,{name:"constructor",public:true},core.code`
|
|
17
|
+
super("env");
|
|
18
|
+
|
|
19
|
+
this.deserializeRegistry.register(
|
|
20
|
+
ReflectionKind.boolean,
|
|
21
|
+
(type: Type, state: TemplateState) => {
|
|
22
|
+
state.addSetter(
|
|
23
|
+
\`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()}\`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
`)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application."},React.createElement(tsdoc.TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(tsdoc.TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(tsdoc.TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(typescript.VarDeclaration,{name:"envSerializer",export:false,const:true,initializer:React.createElement(typescript.NewExpression,{args:[],target:"EnvSerializer"})}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"Serialize a environment configuration object to JSON data objects (not a JSON string)."},React.createElement(tsdoc.TSDocRemarks,null,"The resulting JSON object can be stringified using JSON.stringify()."),React.createElement(tsdoc.TSDocExample,null,"const json = serializeEnv(env);"),React.createElement(tsdoc.TSDocThrows,null,"ValidationError when serialization or validation fails.")),React.createElement(typescript.VarDeclaration,{name:"serializeEnv",export:true,const:true,initializer:"serializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators."},React.createElement(tsdoc.TSDocRemarks,null,"Types that are already correct will be used as-is."),React.createElement(tsdoc.TSDocExample,null,"const env = deserializeEnv(json);"),React.createElement(tsdoc.TSDocThrows,null,"ValidationError when deserialization fails.")),React.createElement(typescript.VarDeclaration,{name:"deserializeEnv",export:true,const:true,initializer:"deserializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(tsdoc.TSDoc,{heading:"Initializes the Powerlines environment configuration module."},React.createElement(tsdoc.TSDocRemarks,null,"This function initializes the Powerlines environment configuration object."),React.createElement(tsdoc.TSDocParam,{name:"environmentConfig"},"The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime."),React.createElement(tsdoc.TSDocReturns,null,"The initialized Powerlines configuration object.")),React.createElement(core.Show,{when:!!r?.value?.entryPath},React.createElement(typescript.FunctionDeclaration,{refkey:Y,async:false,export:true,name:"createEnv",parameters:[{name:"environmentConfig",type:"Partial<Env>",optional:false,default:"{}"}],returnType:"Env"},core.code`
|
|
28
|
+
return new Proxy<Env>(
|
|
29
|
+
deserializeEnv({
|
|
30
|
+
...initialEnv,
|
|
31
|
+
...environmentConfig
|
|
32
|
+
}) as Env,
|
|
33
|
+
{
|
|
34
|
+
get: (target: EnvBase, propertyName: string) => { `,React.createElement("hbr",null),React.createElement(core.For,{each:R},(a,e)=>React.createElement(U,{index:e,context:r?.value,property:a})),core.code`
|
|
35
|
+
return undefined;
|
|
36
|
+
}, `,React.createElement("hbr",null),React.createElement("hbr",null),core.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,React.createElement("hbr",null),React.createElement(core.For,{each:N,ender:core.code` else `},(a,e)=>React.createElement(X,{index:e,context:r?.value,property:a})),React.createElement("hbr",null),core.code`return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
`)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(typescript.VarDeclaration,{refkey:Z,name:"env",type:"Env",export:true,const:true,initializer:React.createElement(React.Fragment,null,core.code`createEnv(`,i||"{}",core.code` as Partial<Env>)`)}))}chunkFBBMZ4NC_cjs.a(be,"EnvBuiltin");exports.EnvBuiltin=be;exports.EnvTypeDefinition=Q;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Children as Children$1, SourceFileProps as SourceFileProps$1 } from '@alloy-js/core';
|
|
2
|
+
import { Children } from '@alloy-js/core/jsx-runtime';
|
|
3
|
+
import { O as OutputModeType } from '../vfs-COoZkq8D.cjs';
|
|
4
|
+
import { InterfaceDeclarationProps } from '@alloy-js/typescript';
|
|
5
|
+
import { ReflectionClass } from '@deepkit/type';
|
|
6
|
+
import 'memfs';
|
|
7
|
+
import 'node:fs';
|
|
8
|
+
import 'unionfs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A type that represents the props of a component that can have children.
|
|
12
|
+
*/
|
|
13
|
+
interface ComponentProps {
|
|
14
|
+
children?: Children;
|
|
15
|
+
}
|
|
16
|
+
interface TypescriptFileImportItem {
|
|
17
|
+
name: string;
|
|
18
|
+
default?: boolean;
|
|
19
|
+
alias?: string;
|
|
20
|
+
type?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
|
|
23
|
+
|
|
24
|
+
interface TSDocModuleProps extends ComponentProps {
|
|
25
|
+
/**
|
|
26
|
+
* the prefix for the builtin module name
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue "storm"
|
|
29
|
+
*/
|
|
30
|
+
prefix?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the module
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { MyModule } from "storm:my-module";
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
name: Children$1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
46
|
+
/**
|
|
47
|
+
* If true, indicates that the file is virtual and should not be written to disk.
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue false
|
|
50
|
+
*/
|
|
51
|
+
mode?: OutputModeType;
|
|
52
|
+
/**
|
|
53
|
+
* The metadata associated with the source file.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* The values stored in the metadata will be available in the rendering context.
|
|
57
|
+
*/
|
|
58
|
+
meta?: Record<string, any>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type TypescriptFileProps = Omit<SourceFileProps, "filetype"> & ComponentProps & {
|
|
62
|
+
header?: Children$1;
|
|
63
|
+
imports?: TypescriptFileImports;
|
|
64
|
+
export?: boolean | string;
|
|
65
|
+
tsx?: boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
|
|
69
|
+
/**
|
|
70
|
+
* The runtime module identifier.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This value will be included after the \`storm:\` prefix in the import statement.
|
|
74
|
+
*/
|
|
75
|
+
id: string;
|
|
76
|
+
/**
|
|
77
|
+
* The description for the builtin module.
|
|
78
|
+
*/
|
|
79
|
+
description?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the file is a TSX file.
|
|
82
|
+
*
|
|
83
|
+
* @defaultValue false
|
|
84
|
+
*/
|
|
85
|
+
tsx?: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
interface TypeScriptInterfaceProps<T extends Record<string, any> = Record<string, any>> extends InterfaceDeclarationProps, ComponentProps {
|
|
89
|
+
reflection: ReflectionClass<T>;
|
|
90
|
+
defaultValue?: Partial<T>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Generates the environment configuration typescript definition for the Powerlines project.
|
|
95
|
+
*/
|
|
96
|
+
declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children$1;
|
|
97
|
+
interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
|
|
98
|
+
defaultConfig?: Children$1;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Generates the environment configuration module for the Powerlines project.
|
|
102
|
+
*/
|
|
103
|
+
declare function EnvBuiltin(props: EnvBuiltinProps): Children$1;
|
|
104
|
+
declare type __ΩEnvBuiltinProps = any[];
|
|
105
|
+
|
|
106
|
+
export { EnvBuiltin, type EnvBuiltinProps, EnvTypeDefinition, type __ΩEnvBuiltinProps };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Children as Children$1, SourceFileProps as SourceFileProps$1 } from '@alloy-js/core';
|
|
2
|
+
import { Children } from '@alloy-js/core/jsx-runtime';
|
|
3
|
+
import { O as OutputModeType } from '../vfs-COoZkq8D.js';
|
|
4
|
+
import { InterfaceDeclarationProps } from '@alloy-js/typescript';
|
|
5
|
+
import { ReflectionClass } from '@deepkit/type';
|
|
6
|
+
import 'memfs';
|
|
7
|
+
import 'node:fs';
|
|
8
|
+
import 'unionfs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A type that represents the props of a component that can have children.
|
|
12
|
+
*/
|
|
13
|
+
interface ComponentProps {
|
|
14
|
+
children?: Children;
|
|
15
|
+
}
|
|
16
|
+
interface TypescriptFileImportItem {
|
|
17
|
+
name: string;
|
|
18
|
+
default?: boolean;
|
|
19
|
+
alias?: string;
|
|
20
|
+
type?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type TypescriptFileImports = Record<string, null | Array<TypescriptFileImportItem | string>>;
|
|
23
|
+
|
|
24
|
+
interface TSDocModuleProps extends ComponentProps {
|
|
25
|
+
/**
|
|
26
|
+
* the prefix for the builtin module name
|
|
27
|
+
*
|
|
28
|
+
* @defaultValue "storm"
|
|
29
|
+
*/
|
|
30
|
+
prefix?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the module
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This will be used in the `@module` tag as well as the import path for the module, e.g. `storm:<name>`.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { MyModule } from "storm:my-module";
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
name: Children$1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type SourceFileProps = SourceFileProps$1 & ComponentProps & {
|
|
46
|
+
/**
|
|
47
|
+
* If true, indicates that the file is virtual and should not be written to disk.
|
|
48
|
+
*
|
|
49
|
+
* @defaultValue false
|
|
50
|
+
*/
|
|
51
|
+
mode?: OutputModeType;
|
|
52
|
+
/**
|
|
53
|
+
* The metadata associated with the source file.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* The values stored in the metadata will be available in the rendering context.
|
|
57
|
+
*/
|
|
58
|
+
meta?: Record<string, any>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type TypescriptFileProps = Omit<SourceFileProps, "filetype"> & ComponentProps & {
|
|
62
|
+
header?: Children$1;
|
|
63
|
+
imports?: TypescriptFileImports;
|
|
64
|
+
export?: boolean | string;
|
|
65
|
+
tsx?: boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type BuiltinFileProps = Omit<TypescriptFileProps, "path"> & Omit<TSDocModuleProps, "name"> & {
|
|
69
|
+
/**
|
|
70
|
+
* The runtime module identifier.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* This value will be included after the \`storm:\` prefix in the import statement.
|
|
74
|
+
*/
|
|
75
|
+
id: string;
|
|
76
|
+
/**
|
|
77
|
+
* The description for the builtin module.
|
|
78
|
+
*/
|
|
79
|
+
description?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the file is a TSX file.
|
|
82
|
+
*
|
|
83
|
+
* @defaultValue false
|
|
84
|
+
*/
|
|
85
|
+
tsx?: boolean;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
interface TypeScriptInterfaceProps<T extends Record<string, any> = Record<string, any>> extends InterfaceDeclarationProps, ComponentProps {
|
|
89
|
+
reflection: ReflectionClass<T>;
|
|
90
|
+
defaultValue?: Partial<T>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Generates the environment configuration typescript definition for the Powerlines project.
|
|
95
|
+
*/
|
|
96
|
+
declare function EnvTypeDefinition(props: Omit<TypeScriptInterfaceProps, "name">): Children$1;
|
|
97
|
+
interface EnvBuiltinProps extends Omit<BuiltinFileProps, "id"> {
|
|
98
|
+
defaultConfig?: Children$1;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Generates the environment configuration module for the Powerlines project.
|
|
102
|
+
*/
|
|
103
|
+
declare function EnvBuiltin(props: EnvBuiltinProps): Children$1;
|
|
104
|
+
declare type __ΩEnvBuiltinProps = any[];
|
|
105
|
+
|
|
106
|
+
export { EnvBuiltin, type EnvBuiltinProps, EnvTypeDefinition, type __ΩEnvBuiltinProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {a}from'../chunk-UCUR73HG.js';import {splitProps,code,Show,For,computed,createResource}from'@alloy-js/core';import {TypeDeclaration,IfStatement,ElseIfClause,ClassDeclaration,ClassMethod,VarDeclaration,NewExpression,FunctionDeclaration}from'@alloy-js/typescript';import {useStorm}from'@powerlines/alloy/core/contexts/context';import {refkey}from'@powerlines/alloy/helpers/refkey';import {BuiltinFile}from'@powerlines/alloy/typescript/components/builtin-file';import {TSDoc,TSDocLink,TSDocRemarks,TSDocExample,TSDocThrows,TSDocParam,TSDocReturns}from'@powerlines/alloy/typescript/components/tsdoc';import {TypeScriptInterface}from'@powerlines/alloy/typescript/components/typescript-interface';import {TypescriptObject}from'@powerlines/alloy/typescript/components/typescript-object';import {titleCase}from'@stryke/string-format/title-case';import {isNull}from'@stryke/type-checks/is-null';import W from'defu';import {ReflectionClass,ReflectionKind}from'powerlines/deepkit/type';import {loadEnvFromContext}from'../helpers/load';import {readEnvTypeReflection}from'../helpers/persistence';/*****************************************
|
|
2
|
+
*
|
|
3
|
+
* ⚡ Built by Storm Software
|
|
4
|
+
*
|
|
5
|
+
*****************************************/
|
|
6
|
+
|
|
7
|
+
function Q(s){const[{defaultValue:i,reflection:t}]=splitProps(s,["defaultValue","reflection"]),r=useStorm();return React.createElement(React.Fragment,null,React.createElement(TypeScriptInterface,{name:" EnvBase",extends:["EnvInterface"],defaultValue:i,reflection:t,export:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TypeDeclaration,{name:"Env",export:true},code` {
|
|
8
|
+
[Key in keyof EnvBase as Key ${r?.value?.config.env.prefix.map(o=>`| \`${o.replace(/_$/g,"")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
9
|
+
}
|
|
10
|
+
`))}a(Q,"EnvTypeDefinition");function l(s){const[{context:i,name:t}]=splitProps(s,["context","name"]);return i?code`propertyName === "${t}" || propertyName.replace(/^(${i.config.env.prefix.sort((r,o)=>r.startsWith(o)?-1:o.startsWith(r)?1:r.localeCompare(o)).map(r=>`${r.replace(/_$/,"")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${t.toLowerCase().replace(/[\s\-_]+/g,"")}"`:null}a(l,"ConfigPropertyConditional");function U(s){const[{context:i,property:t,index:r}]=splitProps(s,["context","property","index"]);return i?React.createElement(React.Fragment,null,r===0?React.createElement(IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:i}))))},code`return target["${t.getNameAsString()}"];`):React.createElement(ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:i}))))},code`return target["${t.getNameAsString()}"];`)):null}a(U,"ConfigPropertyGet");function X(s){const[{context:i,property:t,index:r}]=splitProps(s,["context","property","index"]);return i?React.createElement(React.Fragment,null,r===0?React.createElement(IfStatement,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:i}))))},code`
|
|
11
|
+
target["${t.getNameAsString()}"] = newValue;
|
|
12
|
+
return true;
|
|
13
|
+
`):React.createElement(ElseIfClause,{condition:React.createElement(React.Fragment,null,React.createElement(l,{name:t.getNameAsString(),context:i}),React.createElement(Show,{when:t.getAlias()&&t.getAlias().length>0},code` || `,React.createElement(For,{each:t.getAlias(),joiner:code` || `},o=>React.createElement(l,{name:o,context:i}))))},code`
|
|
14
|
+
target["${t.getNameAsString()}"] = newValue;
|
|
15
|
+
return true;
|
|
16
|
+
`)):null}a(X,"ConfigPropertySet");const Y=refkey("createEnv"),Z=refkey("env"),ee=refkey("EnvSerializer");function ze(s){const[{defaultConfig:i},t]=splitProps(s,["defaultConfig"]),r=useStorm(),o=computed(()=>r&&loadEnvFromContext(r.value,process.env)),f=createResource(async()=>{if(!r?.value)return new ReflectionClass({kind:ReflectionKind.objectLiteral,description:"The initial environment configuration state for the Powerlines project.",types:[]});const a=await readEnvTypeReflection(r?.value,"env");return a.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(h=>{a.addProperty({name:h,optional:e.isOptional()?true:void 0,readonly:e.isReadonly()?true:void 0,description:e.getDescription(),visibility:e.getVisibility(),type:e.getType(),default:e.getDefaultValue(),tags:{hidden:e.isHidden(),ignore:e.isIgnored(),internal:e.isInternal(),alias:e.getAlias().filter(j=>j!==h).concat(e.name),title:e.getTitle()||titleCase(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}});});}),a.getProperties().forEach(e=>{e.setDefaultValue(o.value?.[e.getNameAsString()]??e.getAlias().reduce((T,h)=>T??o.value?.[h],void 0)??e.getDefaultValue());}),a}),k=computed(()=>new ReflectionClass({kind:ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${titleCase(r?.value?.config?.name)} project.`,types:[]},f.data??void 0)),R=computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]),N=computed(()=>f.data?.getProperties().filter(a=>!a.isIgnored()&&!a.isReadonly()).sort((a,e)=>a.getNameAsString().localeCompare(e.getNameAsString()))??[]);return React.createElement(BuiltinFile,{...t,id:"env",description:"The Powerlines environment configuration module provides an interface to define environment configuration parameters.",imports:W({"powerlines/deepkit/type":["Type","stringify","serializer","serializeFunction","deserializeFunction","ReflectionKind","TemplateState","Serializer","TypeProperty","TypePropertySignature"],"powerlines/runtime-types/shared/env":[{name:"EnvInterface"}]},t.imports??{})},React.createElement(Show,{when:!isNull(f.data)},React.createElement(Q,{defaultValue:o.value,reflection:f.data}),React.createElement("hbr",null),React.createElement("hbr",null)),React.createElement(TypescriptObject,{name:"initialEnv",type:"Partial<EnvBase>",defaultValue:o,reflection:k,export:true,const:true}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"The environment configuration serializer for the Powerlines application."},React.createElement(TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(ClassDeclaration,{refkey:ee,name:"EnvSerializer",extends:"Serializer",export:true},React.createElement(ClassMethod,{name:"constructor",public:true},code`
|
|
17
|
+
super("env");
|
|
18
|
+
|
|
19
|
+
this.deserializeRegistry.register(
|
|
20
|
+
ReflectionKind.boolean,
|
|
21
|
+
(type: Type, state: TemplateState) => {
|
|
22
|
+
state.addSetter(
|
|
23
|
+
\`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()}\`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
`)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application."},React.createElement(TSDocLink,null,"https://deepkit.io/docs/serialization/serializers"),React.createElement(TSDocLink,null,"https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918"),React.createElement(TSDocRemarks,null,"This serializer is used to serialize and deserialize the Powerlines environment configuration.")),React.createElement(VarDeclaration,{name:"envSerializer",export:false,const:true,initializer:React.createElement(NewExpression,{args:[],target:"EnvSerializer"})}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"Serialize a environment configuration object to JSON data objects (not a JSON string)."},React.createElement(TSDocRemarks,null,"The resulting JSON object can be stringified using JSON.stringify()."),React.createElement(TSDocExample,null,"const json = serializeEnv(env);"),React.createElement(TSDocThrows,null,"ValidationError when serialization or validation fails.")),React.createElement(VarDeclaration,{name:"serializeEnv",export:true,const:true,initializer:"serializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators."},React.createElement(TSDocRemarks,null,"Types that are already correct will be used as-is."),React.createElement(TSDocExample,null,"const env = deserializeEnv(json);"),React.createElement(TSDocThrows,null,"ValidationError when deserialization fails.")),React.createElement(VarDeclaration,{name:"deserializeEnv",export:true,const:true,initializer:"deserializeFunction<EnvBase>(envSerializer)"}),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(TSDoc,{heading:"Initializes the Powerlines environment configuration module."},React.createElement(TSDocRemarks,null,"This function initializes the Powerlines environment configuration object."),React.createElement(TSDocParam,{name:"environmentConfig"},"The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime."),React.createElement(TSDocReturns,null,"The initialized Powerlines configuration object.")),React.createElement(Show,{when:!!r?.value?.entryPath},React.createElement(FunctionDeclaration,{refkey:Y,async:false,export:true,name:"createEnv",parameters:[{name:"environmentConfig",type:"Partial<Env>",optional:false,default:"{}"}],returnType:"Env"},code`
|
|
28
|
+
return new Proxy<Env>(
|
|
29
|
+
deserializeEnv({
|
|
30
|
+
...initialEnv,
|
|
31
|
+
...environmentConfig
|
|
32
|
+
}) as Env,
|
|
33
|
+
{
|
|
34
|
+
get: (target: EnvBase, propertyName: string) => { `,React.createElement("hbr",null),React.createElement(For,{each:R},(a,e)=>React.createElement(U,{index:e,context:r?.value,property:a})),code`
|
|
35
|
+
return undefined;
|
|
36
|
+
}, `,React.createElement("hbr",null),React.createElement("hbr",null),code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,React.createElement("hbr",null),React.createElement(For,{each:N,ender:code` else `},(a,e)=>React.createElement(X,{index:e,context:r?.value,property:a})),React.createElement("hbr",null),code`return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
`)),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement("hbr",null),React.createElement(VarDeclaration,{refkey:Z,name:"env",type:"Env",export:true,const:true,initializer:React.createElement(React.Fragment,null,code`createEnv(`,i||"{}",code` as Partial<Env>)`)}))}a(ze,"EnvBuiltin");export{ze as EnvBuiltin,Q as EnvTypeDefinition};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var env=require('./env');Object.keys(env).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return env[k]}})});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from './env.cjs';
|
|
2
|
+
import '@alloy-js/core';
|
|
3
|
+
import '@alloy-js/core/jsx-runtime';
|
|
4
|
+
import '../vfs-COoZkq8D.cjs';
|
|
5
|
+
import 'memfs';
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'unionfs';
|
|
8
|
+
import '@alloy-js/typescript';
|
|
9
|
+
import '@deepkit/type';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { EnvBuiltin, EnvBuiltinProps, EnvTypeDefinition, __ΩEnvBuiltinProps } from './env.js';
|
|
2
|
+
import '@alloy-js/core';
|
|
3
|
+
import '@alloy-js/core/jsx-runtime';
|
|
4
|
+
import '../vfs-COoZkq8D.js';
|
|
5
|
+
import 'memfs';
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'unionfs';
|
|
8
|
+
import '@alloy-js/typescript';
|
|
9
|
+
import '@deepkit/type';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from'./env';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var load=require('./load'),persistence=require('./persistence'),reflect=require('./reflect'),sourceFileEnv=require('./source-file-env'),templateHelpers=require('./template-helpers');Object.keys(load).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return load[k]}})});Object.keys(persistence).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return persistence[k]}})});Object.keys(reflect).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return reflect[k]}})});Object.keys(sourceFileEnv).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return sourceFileEnv[k]}})});Object.keys(templateHelpers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return templateHelpers[k]}})});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { loadEnv, loadEnvFromContext } from './load.cjs';
|
|
2
|
+
export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from './persistence.cjs';
|
|
3
|
+
export { CreateEnvReflectionOptions, StormBaseEnv, StormBaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from './reflect.cjs';
|
|
4
|
+
export { formatEnvField, removeEnvPrefix } from './source-file-env.cjs';
|
|
5
|
+
export { createTemplateReflection } from './template-helpers.cjs';
|
|
6
|
+
import '../runtime-I3P49niA.cjs';
|
|
7
|
+
import '@stryke/env/get-env-paths';
|
|
8
|
+
import '@stryke/types/package-json';
|
|
9
|
+
import 'jiti';
|
|
10
|
+
import '@deepkit/type';
|
|
11
|
+
import 'unplugin';
|
|
12
|
+
import '@stryke/capnp';
|
|
13
|
+
import '@storm-software/config-tools/types';
|
|
14
|
+
import '@stryke/types/base';
|
|
15
|
+
import '@stryke/types/configuration';
|
|
16
|
+
import '@stryke/types/file';
|
|
17
|
+
import 'vite';
|
|
18
|
+
import '@babel/core';
|
|
19
|
+
import '@storm-software/build-tools/types';
|
|
20
|
+
import '@storm-software/config/types';
|
|
21
|
+
import '@babel/helper-plugin-utils';
|
|
22
|
+
import 'semver';
|
|
23
|
+
import '@stryke/types/array';
|
|
24
|
+
import '@stryke/types/tsconfig';
|
|
25
|
+
import 'typescript';
|
|
26
|
+
import '../vfs-COoZkq8D.cjs';
|
|
27
|
+
import 'memfs';
|
|
28
|
+
import 'node:fs';
|
|
29
|
+
import 'unionfs';
|
|
30
|
+
import '@stryke/env/types';
|
|
31
|
+
import '../types/plugin.cjs';
|
|
32
|
+
import '@alloy-js/core/jsx-runtime';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { loadEnv, loadEnvFromContext } from './load.js';
|
|
2
|
+
export { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, writeEnvReflection, writeEnvReflectionSync, writeEnvTypeReflection } from './persistence.js';
|
|
3
|
+
export { CreateEnvReflectionOptions, StormBaseEnv, StormBaseSecrets, __ΩCreateEnvReflectionOptions, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from './reflect.js';
|
|
4
|
+
export { formatEnvField, removeEnvPrefix } from './source-file-env.js';
|
|
5
|
+
export { createTemplateReflection } from './template-helpers.js';
|
|
6
|
+
import '../runtime-DqvtGYT3.js';
|
|
7
|
+
import '@stryke/env/get-env-paths';
|
|
8
|
+
import '@stryke/types/package-json';
|
|
9
|
+
import 'jiti';
|
|
10
|
+
import '@deepkit/type';
|
|
11
|
+
import 'unplugin';
|
|
12
|
+
import '@stryke/capnp';
|
|
13
|
+
import '@storm-software/config-tools/types';
|
|
14
|
+
import '@stryke/types/base';
|
|
15
|
+
import '@stryke/types/configuration';
|
|
16
|
+
import '@stryke/types/file';
|
|
17
|
+
import 'vite';
|
|
18
|
+
import '@babel/core';
|
|
19
|
+
import '@storm-software/build-tools/types';
|
|
20
|
+
import '@storm-software/config/types';
|
|
21
|
+
import '@babel/helper-plugin-utils';
|
|
22
|
+
import 'semver';
|
|
23
|
+
import '@stryke/types/array';
|
|
24
|
+
import '@stryke/types/tsconfig';
|
|
25
|
+
import 'typescript';
|
|
26
|
+
import '../vfs-COoZkq8D.js';
|
|
27
|
+
import 'memfs';
|
|
28
|
+
import 'node:fs';
|
|
29
|
+
import 'unionfs';
|
|
30
|
+
import '@stryke/env/types';
|
|
31
|
+
import '../types/plugin.js';
|
|
32
|
+
import '@alloy-js/core/jsx-runtime';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from'./load';export*from'./persistence';export*from'./reflect';export*from'./source-file-env';export*from'./template-helpers';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';var chunkFBBMZ4NC_cjs=require('../chunk-FBBMZ4NC.cjs'),loadEnv=require('@stryke/env/load-env'),joinPaths=require('@stryke/path/join-paths'),kebabCase=require('@stryke/string-format/kebab-case'),isSetObject=require('@stryke/type-checks/is-set-object'),isSetString=require('@stryke/type-checks/is-set-string'),c12=require('c12'),m=require('defu'),sourceFileEnv=require('./source-file-env');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var m__default=/*#__PURE__*/_interopDefault(m);/*****************************************
|
|
2
|
+
*
|
|
3
|
+
* ⚡ Built by Storm Software
|
|
4
|
+
*
|
|
5
|
+
*****************************************/
|
|
6
|
+
|
|
7
|
+
async function k(e,o,a){let n=await loadEnv.loadEnv(a,o);if(e.additionalFiles&&e.additionalFiles?.length>0){const r=await Promise.all(e.additionalFiles.map(async i=>loadEnv.loadEnvFile(i,a)));for(const i of r)n=m__default.default(i,n);}return sourceFileEnv.removeEnvPrefix(n)}chunkFBBMZ4NC_cjs.a(k,"loadEnvFiles");async function p(e,o,a,n,r,i){const[l,t]=await Promise.all([k(e,a,o),c12.loadConfig({cwd:o,name:"storm",envName:a,defaults:{NAME:r.name?.replace(`@${i.namespace}/`,""),MODE:a,ORG:i.organization},globalRc:true,packageJson:true,dotenv:true,jitiOptions:{fsCache:joinPaths.joinPaths(n,"jiti"),moduleCache:true}})]);return m__default.default(l,t.config,i)}chunkFBBMZ4NC_cjs.a(p,"loadEnvDirectory");function C(e,o){return m__default.default({APP_NAME:kebabCase.kebabCase(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,"")),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${kebabCase.kebabCase(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:isSetString.isSetString(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode==="development",STACKTRACE:e.workspaceConfig.mode==="development",ENVIRONMENT:e.environment},isSetObject.isSetObject(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((a,n)=>(a[n.name]=o[n.name]??n.getDefaultValue(),a),{}):{})}chunkFBBMZ4NC_cjs.a(C,"loadEnvFromContext");async function N(e,o){const[a,n,r]=await Promise.all([p(o,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),p(o,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),p(o,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return m__default.default(C(e,process.env),a,n,r)}chunkFBBMZ4NC_cjs.a(N,"loadEnv");exports.loadEnv=N;exports.loadEnvFromContext=C;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { a as EnvironmentResolvedConfig } from '../runtime-I3P49niA.cjs';
|
|
2
|
+
import * as _storm_software_config_tools_types from '@storm-software/config-tools/types';
|
|
3
|
+
import { DotenvParseOutput } from '@stryke/env/types';
|
|
4
|
+
import { EnvPluginContext, EnvPluginOptions } from '../types/plugin.cjs';
|
|
5
|
+
import '@stryke/env/get-env-paths';
|
|
6
|
+
import '@stryke/types/package-json';
|
|
7
|
+
import 'jiti';
|
|
8
|
+
import '@deepkit/type';
|
|
9
|
+
import 'unplugin';
|
|
10
|
+
import '@stryke/capnp';
|
|
11
|
+
import '@stryke/types/base';
|
|
12
|
+
import '@stryke/types/configuration';
|
|
13
|
+
import '@stryke/types/file';
|
|
14
|
+
import 'vite';
|
|
15
|
+
import '@babel/core';
|
|
16
|
+
import '@storm-software/build-tools/types';
|
|
17
|
+
import '@storm-software/config/types';
|
|
18
|
+
import '@babel/helper-plugin-utils';
|
|
19
|
+
import 'semver';
|
|
20
|
+
import '@stryke/types/array';
|
|
21
|
+
import '@stryke/types/tsconfig';
|
|
22
|
+
import 'typescript';
|
|
23
|
+
import '../vfs-COoZkq8D.cjs';
|
|
24
|
+
import 'memfs';
|
|
25
|
+
import 'node:fs';
|
|
26
|
+
import 'unionfs';
|
|
27
|
+
import '@alloy-js/core/jsx-runtime';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves various dotenv configuration parameters from the context.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The context to retrieve the dotenv configuration from.
|
|
33
|
+
* @param parsed - The parsed dotenv configuration.
|
|
34
|
+
* @returns An object containing the dotenv configuration.
|
|
35
|
+
*/
|
|
36
|
+
declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
|
|
37
|
+
APP_NAME: string | undefined;
|
|
38
|
+
APP_VERSION: string | undefined;
|
|
39
|
+
BUILD_ID: string;
|
|
40
|
+
BUILD_TIMESTAMP: string;
|
|
41
|
+
BUILD_CHECKSUM: string;
|
|
42
|
+
RELEASE_ID: string;
|
|
43
|
+
RELEASE_TAG: string;
|
|
44
|
+
DEFAULT_LOCALE: string | undefined;
|
|
45
|
+
DEFAULT_TIMEZONE: string | undefined;
|
|
46
|
+
LOG_LEVEL: _storm_software_config_tools_types.LogLevelLabel | null;
|
|
47
|
+
ERROR_URL: string | undefined;
|
|
48
|
+
ORGANIZATION: string | undefined;
|
|
49
|
+
PLATFORM: "node" | "browser" | "neutral" | undefined;
|
|
50
|
+
MODE: "test" | "development" | "production" | undefined;
|
|
51
|
+
DEBUG: boolean;
|
|
52
|
+
STACKTRACE: boolean;
|
|
53
|
+
ENVIRONMENT: EnvironmentResolvedConfig;
|
|
54
|
+
};
|
|
55
|
+
declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
|
|
56
|
+
|
|
57
|
+
export { loadEnv, loadEnvFromContext };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { a as EnvironmentResolvedConfig } from '../runtime-DqvtGYT3.js';
|
|
2
|
+
import * as _storm_software_config_tools_types from '@storm-software/config-tools/types';
|
|
3
|
+
import { DotenvParseOutput } from '@stryke/env/types';
|
|
4
|
+
import { EnvPluginContext, EnvPluginOptions } from '../types/plugin.js';
|
|
5
|
+
import '@stryke/env/get-env-paths';
|
|
6
|
+
import '@stryke/types/package-json';
|
|
7
|
+
import 'jiti';
|
|
8
|
+
import '@deepkit/type';
|
|
9
|
+
import 'unplugin';
|
|
10
|
+
import '@stryke/capnp';
|
|
11
|
+
import '@stryke/types/base';
|
|
12
|
+
import '@stryke/types/configuration';
|
|
13
|
+
import '@stryke/types/file';
|
|
14
|
+
import 'vite';
|
|
15
|
+
import '@babel/core';
|
|
16
|
+
import '@storm-software/build-tools/types';
|
|
17
|
+
import '@storm-software/config/types';
|
|
18
|
+
import '@babel/helper-plugin-utils';
|
|
19
|
+
import 'semver';
|
|
20
|
+
import '@stryke/types/array';
|
|
21
|
+
import '@stryke/types/tsconfig';
|
|
22
|
+
import 'typescript';
|
|
23
|
+
import '../vfs-COoZkq8D.js';
|
|
24
|
+
import 'memfs';
|
|
25
|
+
import 'node:fs';
|
|
26
|
+
import 'unionfs';
|
|
27
|
+
import '@alloy-js/core/jsx-runtime';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves various dotenv configuration parameters from the context.
|
|
31
|
+
*
|
|
32
|
+
* @param context - The context to retrieve the dotenv configuration from.
|
|
33
|
+
* @param parsed - The parsed dotenv configuration.
|
|
34
|
+
* @returns An object containing the dotenv configuration.
|
|
35
|
+
*/
|
|
36
|
+
declare function loadEnvFromContext(context: EnvPluginContext, parsed: DotenvParseOutput): {
|
|
37
|
+
APP_NAME: string | undefined;
|
|
38
|
+
APP_VERSION: string | undefined;
|
|
39
|
+
BUILD_ID: string;
|
|
40
|
+
BUILD_TIMESTAMP: string;
|
|
41
|
+
BUILD_CHECKSUM: string;
|
|
42
|
+
RELEASE_ID: string;
|
|
43
|
+
RELEASE_TAG: string;
|
|
44
|
+
DEFAULT_LOCALE: string | undefined;
|
|
45
|
+
DEFAULT_TIMEZONE: string | undefined;
|
|
46
|
+
LOG_LEVEL: _storm_software_config_tools_types.LogLevelLabel | null;
|
|
47
|
+
ERROR_URL: string | undefined;
|
|
48
|
+
ORGANIZATION: string | undefined;
|
|
49
|
+
PLATFORM: "node" | "browser" | "neutral" | undefined;
|
|
50
|
+
MODE: "test" | "development" | "production" | undefined;
|
|
51
|
+
DEBUG: boolean;
|
|
52
|
+
STACKTRACE: boolean;
|
|
53
|
+
ENVIRONMENT: EnvironmentResolvedConfig;
|
|
54
|
+
};
|
|
55
|
+
declare function loadEnv<TEnv extends DotenvParseOutput = DotenvParseOutput>(context: EnvPluginContext, options: EnvPluginOptions): Promise<TEnv>;
|
|
56
|
+
|
|
57
|
+
export { loadEnv, loadEnvFromContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {a}from'../chunk-UCUR73HG.js';import {loadEnv,loadEnvFile}from'@stryke/env/load-env';import {joinPaths}from'@stryke/path/join-paths';import {kebabCase}from'@stryke/string-format/kebab-case';import {isSetObject}from'@stryke/type-checks/is-set-object';import {isSetString}from'@stryke/type-checks/is-set-string';import {loadConfig}from'c12';import m from'defu';import {removeEnvPrefix}from'./source-file-env';/*****************************************
|
|
2
|
+
*
|
|
3
|
+
* ⚡ Built by Storm Software
|
|
4
|
+
*
|
|
5
|
+
*****************************************/
|
|
6
|
+
|
|
7
|
+
async function k(e,o,a){let n=await loadEnv(a,o);if(e.additionalFiles&&e.additionalFiles?.length>0){const r=await Promise.all(e.additionalFiles.map(async i=>loadEnvFile(i,a)));for(const i of r)n=m(i,n);}return removeEnvPrefix(n)}a(k,"loadEnvFiles");async function p(e,o,a,n,r,i){const[l,t]=await Promise.all([k(e,a,o),loadConfig({cwd:o,name:"storm",envName:a,defaults:{NAME:r.name?.replace(`@${i.namespace}/`,""),MODE:a,ORG:i.organization},globalRc:true,packageJson:true,dotenv:true,jitiOptions:{fsCache:joinPaths(n,"jiti"),moduleCache:true}})]);return m(l,t.config,i)}a(p,"loadEnvDirectory");function C(e,o){return m({APP_NAME:kebabCase(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,"")),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${kebabCase(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:isSetString(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode==="development",STACKTRACE:e.workspaceConfig.mode==="development",ENVIRONMENT:e.environment},isSetObject(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((a,n)=>(a[n.name]=o[n.name]??n.getDefaultValue(),a),{}):{})}a(C,"loadEnvFromContext");async function J(e,o){const[a,n,r]=await Promise.all([p(o,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),p(o,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),p(o,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return m(C(e,process.env),a,n,r)}a(J,"loadEnv");export{J as loadEnv,C as loadEnvFromContext};
|