@powerlines/plugin-env 0.14.5 → 0.14.7

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/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./create-reflection-resource-I684bqD1.cjs`),t=require(`./env-CgSzbXBL.cjs`),n=require(`./docs-qvDyetF0.cjs`);require(`./components-C9bYrQVK.cjs`),require(`./plugin-D5qyQPqC.cjs`),require(`./runtime-Bisl_1Ja.cjs`),require(`./types-MYBaygjr.cjs`);let r=require(`@stryke/convert/to-array`),i=require(`@stryke/fs/is-file`),a=require(`@stryke/fs/list-files`),o=require(`@stryke/path/append`),s=require(`@stryke/path/is-type`),c=require(`@stryke/path/join-paths`),ee=require(`@stryke/path/replace`),l=require(`automd`),u=require(`c12`),d=require(`defu`);d=e.O(d);let f=require(`markdown-toc`);f=e.O(f);let p=require(`@babel/core`),m=require(`@storm-software/config-tools/types`),h=require(`@stryke/path/file-path-fns`),g=require(`@stryke/path/is-parent-path`),_=require(`@stryke/type-checks/is-set-object`),v=require(`@stryke/type-checks/is-function`);require(`@stryke/type-checks/is-object`);let te=require(`@stryke/type-checks/is-set-string`),y=require(`chalk`);y=e.O(y);let b=require(`@babel/generator`);b=e.O(b),require(`@babel/parser`);let x=require(`@babel/helper-plugin-utils`);require(`@storm-software/config-tools/logger`),require(`@storm-software/config-tools/utilities/colors`),require(`@stryke/helpers/noop`);let S=require(`@stryke/string-format/title-case`),C=require(`@babel/types`);C=e.O(C);let w=require(`@stryke/type-checks/is-string`),T=require(`@stryke/convert/parse-type-definition`),E=require(`@stryke/env/types`),D=require(`@stryke/fs/exists`),O=require(`@stryke/fs/helpers`),k=require(`@stryke/path/join`),A=require(`@stryke/string-format/constant-case`),j=require(`@stryke/capnp`);j=e.O(j);let M=require(`@stryke/helpers/get-unique`),N=require(`@stryke/json/storm-json`),ne=require(`@stryke/type-checks/is-null`),re=require(`@stryke/type-checks/is-undefined`),ie=require(`@stryke/fs/buffer`),P=require(`node:fs`),F=require(`@alloy-js/core/jsx-runtime`);const I=(e={})=>({name:`automd`,async config(){let t=await(0,l.loadConfig)((0,c.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=(0,r.toArray)(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:(0,d.default)(t??{},{configFile:e.configFile,allowIssues:!0,dir:this.config.projectRoot,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!(0,r.toArray)(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=(0,r.toArray)(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await(0,u.loadConfig)({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=(0,l.resolveConfig)((0,d.default)(this.config.automd,{...e,prefix:(0,r.toArray)(e.prefix??[])}))}this.config.automd.input=(await Promise.all((0,r.toArray)(this.config.automd.input).map(async e=>e.includes(`*`)?(0,a.listFiles)((0,s.isAbsolutePath)(e)?e:(0,o.appendPath)(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):(0,s.isAbsolutePath)(e)?e:(0,o.appendPath)(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!(0,s.isAbsolutePath)(this.config.automd.output)&&(this.config.automd.output=(0,o.appendPath)(this.config.automd.output,this.config.projectRoot)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:(0,f.default)(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all((0,r.toArray)(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await(0,l.transform)(t,this.config.automd);if(n.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);n.hasChanged&&await this.fs.write((0,o.appendPath)(this.config.automd.output?(0,i.isDirectory)(this.config.automd.output)?(0,ee.replacePath)(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});var L=I;function R(e){return(0,te.isSetString)(e)?e:Array.isArray(e)&&e.length>0?R(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function z(e,t){return!!(R(t)&&e.some(e=>Array.isArray(e)&&R(e[0])===R(t)))}function B(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,v.isFunction)(t[0])?t[0](e):t[0]:(0,v.isFunction)(t)?t(e):t}catch{return t[0]}}function V(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&(0,v.isFunction)(r[2])&&!r[2](t,n)){e.log(m.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${y.default.bold.cyanBright(R(r)||`unnamed`)} for ${n}`);return}return r.length>2?[B(e,r),r[1],r[2]]:[B(e,r),r[1],null]}return[B(e,r),{},null]}let H=b.default;`default`in H&&(H=H.default);const U=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],W=(e,t)=>(n,...r)=>e(n,` ${y.default.inverse.hex(U[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%U.length]||U[0])(` ${(0,S.titleCase)(t)} `)} ${r.join(` `)} `);function G(e,t){let n=n=>(0,x.declare)((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let o=W(n.log,e);o(m.LogLevelLabel.TRACE,`Initializing the ${y.default.bold.cyanBright(e)} Babel plugin`);let s=t({log:o,name:e,api:r,options:i,context:n,dirname:a});return s.name=e,o(m.LogLevelLabel.TRACE,`Completed initialization of the ${y.default.bold.cyanBright(e)} Babel plugin`),s});return n.$$name=e,n}function K(e,t){ae(e.scope.getProgramParent().path,t)}function q(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function J(e){let t=new Map;return e.traverse({ImportDeclaration(e){q(e)&&t.set(e.node.source.value,e)}}),t}function ae(e,t){J(e).get(t.module)||e.unshiftContainer(`body`,C.importDeclaration([C.importSpecifier(C.identifier(t.name||t.imported),C.identifier(t.imported))],C.stringLiteral(t.module)))}const oe=(e={})=>({name:`babel`,config(){if((0,_.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,d.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if((0,g.isParentPath)(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(m.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(m.LogLevelLabel.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>V(this,t,n,e)).filter((e,t,n)=>e&&!z(n,e)),i=this.config.transform.babel.presets.map(e=>V(this,t,n,e)).filter((e,t,n)=>e&&!z(n,e));if(Array.isArray(r)&&r.length===0&&Array.isArray(i)&&i.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes((0,h.findFileExtensionSafe)(n))&&!z(r,`@babel/plugin-syntax-typescript`)&&!z(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,h.findFileExtension)(n)===`.tsx`}]);let a=await(0,p.transformAsync)(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:r.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,d.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,d.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!a?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:a.code,id:n}}});var se=oe;function ce(e,t){return X(e.type,t??e.getDefaultValue())}function Y(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function X(t,n){return(0,re.isUndefined)(n)?`undefined`:(0,ne.isNull)(n)?`null`:t.kind===e.D.ReflectionKind.boolean?String(n).trim().toLowerCase()===`true`?`true`:`false`:t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,w.isString)(t.literal)?Y(n):t.kind===e.D.ReflectionKind.enum?Z(t).kind===e.D.ReflectionKind.string?Y(n):`${String(n)}`:t.kind===e.D.ReflectionKind.union?ue(t)?Y(n):`${String(n)}`:t.kind===e.D.ReflectionKind.array?Y(N.StormJSON.stringify(n)):t.kind===e.D.ReflectionKind.object||t.kind===e.D.ReflectionKind.objectLiteral?N.StormJSON.stringify(n):t.kind===e.D.ReflectionKind.property||t.kind===e.D.ReflectionKind.parameter?X(t.type,n):String(n)}function Z(t){if(t.kind!==e.D.ReflectionKind.enum)throw Error(`Expected a TypeEnum, but received ${t.kind}.`);let n=(0,M.getUniqueBy)(t.values.filter(e=>e!=null),t=>(0,w.isString)(t)?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number});if(n.length===0)throw Error(`No valid enum members could be found.`);return n[0]&&(0,w.isString)(n[0])?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number}}function le(t){if(t.kind===e.D.ReflectionKind.union&&t.types.length>0)return(0,M.getUniqueBy)(t.types,e=>e.kind);throw Error(`Expected a TypeUnion, but received ${t.kind}.`)}function ue(t){return le(t).some(t=>t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,w.isString)(t.literal))}const Q=G(`env`,({log:t,context:n})=>{function r(e,r,i=!1){let a=n.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(e.name){let o=n.config.env.prefix.find(t=>e.name&&e.name.startsWith(t)&&(n.env.types.env?.hasProperty(e.name.replace(`${t}_`,``))||a.some(n=>n.getAlias().includes(e.name.replace(`${t}_`,``))))),s=e.name;if(o&&(s=e.name.replace(`${o}_`,``)),t(m.LogLevelLabel.TRACE,`Environment variable ${s} found in ${r.filename||`unknown file`}.`),n.env.types.env?.hasProperty(s)||a.some(e=>e.getAlias().includes(s))){let e=n.env.types.env.hasProperty(s)?n.env.types.env.getProperty(s):a.find(e=>e.getAlias().includes(s));if(!e||e.isIgnored())return;if(n.env.used.env.hasProperty(s)||n.env.used.env.addProperty(e.property),n.config.env.inject&&i){let t=n.env.parsed?.[s];if(t===void 0){let e=n.config.env.prefix.find(e=>n.env.parsed[`${e.replace(/_$/g,``)}_${s}`]);e&&(t=n.env.parsed[`${e.replace(/_$/g,``)}_${s}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return ce(e,t)}}else throw Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${r.filename?r.filename:`unknown`}.
1
+ Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./create-reflection-resource-CdrQyUuT.cjs`),t=require(`./env-mhFQyGk4.cjs`),n=require(`./docs-DWXbRrEK.cjs`);require(`./components-C9bYrQVK.cjs`),require(`./plugin-D5qyQPqC.cjs`),require(`./runtime-Bisl_1Ja.cjs`),require(`./types-MYBaygjr.cjs`);let r=require(`@stryke/convert/to-array`),i=require(`@stryke/fs/is-file`),a=require(`@stryke/fs/list-files`),o=require(`@stryke/path/append`),s=require(`@stryke/path/is-type`),c=require(`@stryke/path/join-paths`),l=require(`@stryke/path/replace`),u=require(`automd`),d=require(`c12`),f=require(`defu`);f=e.O(f);let p=require(`markdown-toc`);p=e.O(p);let m=require(`@babel/core`),h=require(`@storm-software/config-tools/types`),g=require(`@stryke/path/file-path-fns`),_=require(`@stryke/path/is-parent-path`),v=require(`@stryke/type-checks/is-set-object`),y=require(`@stryke/type-checks/is-function`);require(`@stryke/type-checks/is-object`);let b=require(`@stryke/type-checks/is-set-string`),x=require(`chalk`);x=e.O(x);let S=require(`@babel/generator`);S=e.O(S),require(`@babel/parser`);let C=require(`@babel/helper-plugin-utils`);require(`@storm-software/config-tools/logger`),require(`@storm-software/config-tools/utilities/colors`),require(`@stryke/helpers/noop`);let ee=require(`@stryke/string-format/kebab-case`),w=require(`@stryke/string-format/title-case`),T=require(`@babel/types`);T=e.O(T);let E=require(`@stryke/type-checks/is-string`),D=require(`@stryke/convert/parse-type-definition`),O=require(`@stryke/env/types`),k=require(`@stryke/fs/exists`),te=require(`@stryke/fs/helpers`),A=require(`@stryke/path/join`),j=require(`@stryke/string-format/constant-case`),M=require(`@stryke/capnp`);M=e.O(M);let N=require(`@stryke/helpers/get-unique`),P=require(`@stryke/json/storm-json`),ne=require(`@stryke/type-checks/is-null`),re=require(`@stryke/type-checks/is-undefined`),ie=require(`@stryke/fs/buffer`),F=require(`node:fs`),I=require(`@alloy-js/core/jsx-runtime`);const L=(e={})=>({name:`automd`,async config(){let t=await(0,u.loadConfig)((0,c.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=(0,r.toArray)(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:(0,f.default)(t??{},{configFile:e.configFile,allowIssues:!0,dir:this.config.projectRoot,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!(0,r.toArray)(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=(0,r.toArray)(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await(0,d.loadConfig)({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=(0,u.resolveConfig)((0,f.default)(this.config.automd,{...e,prefix:(0,r.toArray)(e.prefix??[])}))}this.config.automd.input=(await Promise.all((0,r.toArray)(this.config.automd.input).map(async e=>e.includes(`*`)?(0,a.listFiles)((0,s.isAbsolutePath)(e)?e:(0,o.appendPath)(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):(0,s.isAbsolutePath)(e)?e:(0,o.appendPath)(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!(0,s.isAbsolutePath)(this.config.automd.output)&&(this.config.automd.output=(0,o.appendPath)(this.config.automd.output,this.config.projectRoot)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:(0,p.default)(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all((0,r.toArray)(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await(0,u.transform)(t,this.config.automd);if(n.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);n.hasChanged&&await this.fs.write((0,o.appendPath)(this.config.automd.output?(0,i.isDirectory)(this.config.automd.output)?(0,l.replacePath)(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});var R=L;function z(e){return(0,b.isSetString)(e)?e:Array.isArray(e)&&e.length>0?z(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function B(e,t){return!!(z(t)&&e.some(e=>Array.isArray(e)&&z(e[0])===z(t)))}function V(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,y.isFunction)(t[0])?t[0](e):t[0]:(0,y.isFunction)(t)?t(e):t}catch{return t[0]}}function H(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&(0,y.isFunction)(r[2])&&!r[2](t,n)){e.log(h.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${x.default.bold.cyanBright(z(r)||`unnamed`)} for ${n}`);return}return r.length>2?[V(e,r),r[1],r[2]]:[V(e,r),r[1],null]}return[V(e,r),{},null]}let U=S.default;`default`in U&&(U=U.default);const W=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#D8B4FE`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`,`#8B5CF6`],G=(e,t)=>(n,...r)=>e(n,` ${x.default.inverse.hex(W[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%W.length]||W[0])(` ${(0,w.titleCase)(t)} `)} ${r.join(` `)} `);function K(e,t){let n=n=>(0,C.declare)((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let o=G(n.log,e);o(h.LogLevelLabel.TRACE,`Initializing the ${x.default.bold.cyanBright(e)} Babel plugin`);let s=t({log:o,name:e,api:r,options:i,context:n,dirname:a});return s.name=e,o(h.LogLevelLabel.TRACE,`Completed initialization of the ${x.default.bold.cyanBright(e)} Babel plugin`),s});return n.$$name=e,n}function q(e,t){ae(e.scope.getProgramParent().path,t)}function J(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function Y(e){let t=new Map;return e.traverse({ImportDeclaration(e){J(e)&&t.set(e.node.source.value,e)}}),t}function ae(e,t){Y(e).get(t.module)||e.unshiftContainer(`body`,T.importDeclaration([T.importSpecifier(T.identifier(t.name||t.imported),T.identifier(t.imported))],T.stringLiteral(t.module)))}const oe=(e={})=>({name:`babel`,config(){if((0,v.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,f.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if((0,_.isParentPath)(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(h.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(h.LogLevelLabel.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>H(this,t,n,e)).filter((e,t,n)=>e&&!B(n,e)),i=this.config.transform.babel.presets.map(e=>H(this,t,n,e)).filter((e,t,n)=>e&&!B(n,e));if(Array.isArray(r)&&r.length===0&&Array.isArray(i)&&i.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes((0,g.findFileExtensionSafe)(n))&&!B(r,`@babel/plugin-syntax-typescript`)&&!B(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,g.findFileExtension)(n)===`.tsx`}]);let a=await(0,m.transformAsync)(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:r.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,f.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,f.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!a?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:a.code,id:n}}});var se=oe;function ce(e,t){return Z(e.type,t??e.getDefaultValue())}function X(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function Z(t,n){return(0,re.isUndefined)(n)?`undefined`:(0,ne.isNull)(n)?`null`:t.kind===e.D.ReflectionKind.boolean?String(n).trim().toLowerCase()===`true`?`true`:`false`:t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,E.isString)(t.literal)?X(n):t.kind===e.D.ReflectionKind.enum?le(t).kind===e.D.ReflectionKind.string?X(n):`${String(n)}`:t.kind===e.D.ReflectionKind.union?de(t)?X(n):`${String(n)}`:t.kind===e.D.ReflectionKind.array?X(P.StormJSON.stringify(n)):t.kind===e.D.ReflectionKind.object||t.kind===e.D.ReflectionKind.objectLiteral?P.StormJSON.stringify(n):t.kind===e.D.ReflectionKind.property||t.kind===e.D.ReflectionKind.parameter?Z(t.type,n):String(n)}function le(t){if(t.kind!==e.D.ReflectionKind.enum)throw Error(`Expected a TypeEnum, but received ${t.kind}.`);let n=(0,N.getUniqueBy)(t.values.filter(e=>e!=null),t=>(0,E.isString)(t)?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number});if(n.length===0)throw Error(`No valid enum members could be found.`);return n[0]&&(0,E.isString)(n[0])?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number}}function ue(t){if(t.kind===e.D.ReflectionKind.union&&t.types.length>0)return(0,N.getUniqueBy)(t.types,e=>e.kind);throw Error(`Expected a TypeUnion, but received ${t.kind}.`)}function de(t){return ue(t).some(t=>t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,E.isString)(t.literal))}const Q=K(`env`,({log:t,context:n})=>{function r(e,r,i=!1){let a=n.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(e.name){let o=n.config.env.prefix.find(t=>e.name&&e.name.startsWith(t)&&(n.env.types.env?.hasProperty(e.name.replace(`${t}_`,``))||a.some(n=>n.getAlias().includes(e.name.replace(`${t}_`,``))))),s=e.name;if(o&&(s=e.name.replace(`${o}_`,``)),t(h.LogLevelLabel.TRACE,`Environment variable ${s} found in ${r.filename||`unknown file`}.`),n.env.types.env?.hasProperty(s)||a.some(e=>e.getAlias().includes(s))){let e=n.env.types.env.hasProperty(s)?n.env.types.env.getProperty(s):a.find(e=>e.getAlias().includes(s));if(!e||e.isIgnored())return;if(n.env.used.env.hasProperty(s)||n.env.used.env.addProperty(e.property),n.config.env.inject&&i){let t=n.env.parsed?.[s];if(t===void 0){let e=n.config.env.prefix.find(e=>n.env.parsed[`${e.replace(/_$/g,``)}_${s}`]);e&&(t=n.env.parsed[`${e.replace(/_$/g,``)}_${s}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return ce(e,t)}}else throw Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${r.filename?r.filename:`unknown`}.
2
2
 
3
3
  The following environment configuration names are defined in the \`env\` type definition: \n${n.env.types.env?.getPropertyNames().sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` - ${String(e)} ${a.some(t=>t.getNameAsString()===String(e)&&t.getAlias().length>0)?`(Alias: ${a?.find(t=>t.getNameAsString()===String(e))?.getAlias().join(`, `)})`:``}`).join(`
4
4
  `)} \n\nUsing the following env prefix: \n${n.config.env.prefix.map(e=>` - ${e}`).join(`
5
- `)} \n\nPlease 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. \n\n`)}}return{visitor:{MemberExpression(e,t){if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`$storm`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(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()){let n=e.get(`property`)?.node;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(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()){let n=e.get(`property`)?.node;if(!n.name)return;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(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()){let n=e.get(`property`)?.node;if(!n.name)return;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),K(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){t(m.LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let r=e.D.ReflectionClass.from({kind:e.D.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),i=e.s(n,`env`);i&&(0,P.existsSync)(i)&&(t(m.LogLevelLabel.TRACE,`Environment reflection file found at ${i}, reading existing reflection.`),r=(0,e.D.resolveClassType)((0,e.D.deserializeType)(e.E(new j.Message((0,ie.readFileBufferSync)(i),!1).getRoot(e.T).types)))),t(m.LogLevelLabel.TRACE,`Adding new variables to env reflection at ${i}.`),r.getProperties().filter(e=>e.getNameAsString()&&!n.env.used.env.hasProperty(e.getNameAsString())).forEach(e=>{n.env.used.env.addProperty({...e,name:e.getNameAsString(),description:e.getDescription()??`The ${e.getNameAsString()} variable.`,default:e.getDefaultValue(),optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,visibility:e.getVisibility(),type:e.getType(),tags:e.getTags()})})}}}),de=e=>(0,l.defineGenerator)({name:`env`,async generate(){let t=(0,c.joinPaths)(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function fe(t,n){let r=await e.d(t,n);return r.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(t=>{r.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0: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(e=>e!==t).concat(e.name),title:e.getTitle()||(0,S.titleCase)(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),r}const $=(n={})=>[se(n.babel),{name:`env`,async config(){this.log(m.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,d.default)(n,{types:{},prefix:[]}),transform:{babel:{plugins:[Q]}}};if(t.env.types)t.env.types=(0,T.parseTypeDefinition)(t.env.types);else{this.log(m.LogLevelLabel.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let n=await e.o(this);t.env.types=(0,T.parseTypeDefinition)(`${n.file}#${n.name}`)}if(t.env.secrets)t.env.secrets=(0,T.parseTypeDefinition)(t.env.secrets);else{let n=await e.l(this);t.env.secrets=(0,T.parseTypeDefinition)(`${n.file}#${n.name}`)}return t.env.prefix=(0,r.toArray)(t.env.prefix??[]).reduce((e,t)=>{let n=(0,A.constantCase)(t);return e.includes(n)||e.push(n),e},[...E.ENV_PREFIXES,`POWERLINES_`]),t.env.prefix=t.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),t},async configResolved(){if(this.log(m.LogLevelLabel.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=(0,d.default)({parsed:await e.n(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&(0,D.existsSync)(e.c(this,`env`)))this.log(m.LogLevelLabel.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await e.d(this,`env`),(0,D.existsSync)(e.s(this,`env`))&&(this.env.used.env=await e.u(this)),(0,D.existsSync)(e.c(this,`secrets`))&&(this.env.types.secrets=await e.d(this,`secrets`)),(0,D.existsSync)(e.s(this,`secrets`))&&(this.env.used.secrets=await e.f(this));else{if(this.env.types.env=await e.C(this,this.config.env.types?.file?(0,g.isParentPath)(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:(0,k.joinPaths)(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await e.g(this,this.env.types.env,`env`),this.env.types.secrets=await e.w(this,this.config.env.secrets?.file?(0,g.isParentPath)(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:(0,k.joinPaths)(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await e.g(this,this.env.types.secrets,`secrets`),this.log(m.LogLevelLabel.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let t=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await e.n(this,this.config.env)).forEach(([e,n])=>{let r=this.config.env.prefix.reduce((t,n)=>e.replace(/_$/g,``).startsWith(n)?e.replace(/_$/g,``).slice(n.length):t,e),i=t.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(n)}),this.env.used.env=new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await e.m(this,this.env.used.env,`env`),this.env.types.secrets&&(await e.g(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await e.m(this,this.env.used.secrets,`secrets`))}},async prepare(){return this.log(m.LogLevelLabel.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render((0,F.jsx)(t.t,{defaultConfig:this.config.env.defaultConfig}))},async docs(){this.log(m.LogLevelLabel.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let t=(0,k.joinPaths)(this.config.projectRoot,`docs`,`generated`);(0,D.existsSync)(t)||await(0,O.createDirectory)(t);let n=await e.d(this,`env`),r=(0,k.joinPaths)(t,`env.md`);this.log(m.LogLevelLabel.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${(0,S.titleCase)(this.config.framework)||`Powerlines`} -->
5
+ `)} \n\nPlease 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. \n\n`)}}return{visitor:{MemberExpression(e,t){if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`$storm`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),q(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()){let n=e.get(`property`)?.node;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),q(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()){let n=e.get(`property`)?.node;if(!n.name)return;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),q(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()){let n=e.get(`property`)?.node;if(!n.name)return;r(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),q(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){t(h.LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let r=e.D.ReflectionClass.from({kind:e.D.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),i=e.s(n,`env`);i&&(0,F.existsSync)(i)&&(t(h.LogLevelLabel.TRACE,`Environment reflection file found at ${i}, reading existing reflection.`),r=(0,e.D.resolveClassType)((0,e.D.deserializeType)(e.E(new M.Message((0,ie.readFileBufferSync)(i),!1).getRoot(e.T).types)))),t(h.LogLevelLabel.TRACE,`Adding new variables to env reflection at ${i}.`),r.getProperties().filter(e=>e.getNameAsString()&&!n.env.used.env.hasProperty(e.getNameAsString())).forEach(e=>{n.env.used.env.addProperty({...e,name:e.getNameAsString(),description:e.getDescription()??`The ${e.getNameAsString()} variable.`,default:e.getDefaultValue(),optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,visibility:e.getVisibility(),type:e.getType(),tags:e.getTags()})})}}}),fe=e=>(0,u.defineGenerator)({name:`env`,async generate(){let t=(0,c.joinPaths)(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function pe(t,n){let r=await e.d(t,n);return r.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(t=>{r.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0: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(e=>e!==t).concat(e.name),title:e.getTitle()||(0,w.titleCase)(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),r}const $=(n={})=>[se(n.babel),{name:`env`,async config(){this.log(h.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,f.default)(n,{types:{},prefix:[]}),transform:{babel:{plugins:[Q]}}};if(t.env.types)t.env.types=(0,D.parseTypeDefinition)(t.env.types);else{this.log(h.LogLevelLabel.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let n=await e.o(this);t.env.types=(0,D.parseTypeDefinition)(`${n.file}#${n.name}`)}if(t.env.secrets)t.env.secrets=(0,D.parseTypeDefinition)(t.env.secrets);else{let n=await e.l(this);t.env.secrets=(0,D.parseTypeDefinition)(`${n.file}#${n.name}`)}return t.env.prefix=(0,r.toArray)(t.env.prefix??[]).reduce((e,t)=>{let n=(0,j.constantCase)(t);return e.includes(n)||e.push(n),e},[...O.ENV_PREFIXES,`POWERLINES_`]),t.env.prefix=t.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),t},async configResolved(){if(this.log(h.LogLevelLabel.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=(0,f.default)({parsed:await e.n(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&(0,k.existsSync)(e.c(this,`env`)))this.log(h.LogLevelLabel.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await e.d(this,`env`),(0,k.existsSync)(e.s(this,`env`))&&(this.env.used.env=await e.u(this)),(0,k.existsSync)(e.c(this,`secrets`))&&(this.env.types.secrets=await e.d(this,`secrets`)),(0,k.existsSync)(e.s(this,`secrets`))&&(this.env.used.secrets=await e.f(this));else{if(this.env.types.env=await e.C(this,this.config.env.types?.file?(0,_.isParentPath)(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:(0,A.joinPaths)(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await e.g(this,this.env.types.env,`env`),this.env.types.secrets=await e.w(this,this.config.env.secrets?.file?(0,_.isParentPath)(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:(0,A.joinPaths)(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await e.g(this,this.env.types.secrets,`secrets`),this.log(h.LogLevelLabel.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let t=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await e.n(this,this.config.env)).forEach(([e,n])=>{let r=this.config.env.prefix.reduce((t,n)=>e.replace(/_$/g,``).startsWith(n)?e.replace(/_$/g,``).slice(n.length):t,e),i=t.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(n)}),this.env.used.env=new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await e.m(this,this.env.used.env,`env`),this.env.types.secrets&&(await e.g(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new e.D.ReflectionClass({kind:e.D.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await e.m(this,this.env.used.secrets,`secrets`))}},async prepare(){return this.log(h.LogLevelLabel.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render((0,I.jsx)(t.t,{defaultConfig:this.config.env.defaultConfig}))},async docs(){this.log(h.LogLevelLabel.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let t=(0,A.joinPaths)(this.config.projectRoot,`docs`,`generated`);(0,k.existsSync)(t)||await(0,te.createDirectory)(t);let n=await e.d(this,`env`),r=(0,A.joinPaths)(t,`env.md`);this.log(h.LogLevelLabel.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${(0,w.titleCase)(this.config.framework)||`Powerlines`} -->
6
6
 
7
7
  Below is a list of environment variables used by the [${this.packageJson.name}](https://www.npmjs.com/package/${this.packageJson.name}) package. These values can be updated in the \`.env\` file in the root of the project. The variables in the list below are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.
8
8
 
@@ -11,4 +11,4 @@ Below is a list of environment variables used by the [${this.packageJson.name}](
11
11
  ${n.getProperties().filter(e=>e.getNameAsString()!==`__POWERLINES_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(t=>`| ${t.getNameAsString().trim()} | ${(t.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
12
12
  `,``)??``).trim()} | ${(0,e.D.stringifyType)(t.getType()).trim().replaceAll(` | `,`, or `)} | ${t.hasDefault()?String(t.getDefaultValue())?.includes(`"`)?t.getDefaultValue():`\`${t.getDefaultValue()}\``:``} | ${t.isValueRequired()?``:`✔`} |`).join(`
13
13
  `)}
14
- `)},async buildEnd(){let t=e.s(this,`env`);this.log(m.LogLevelLabel.TRACE,`Writing env reflection types to ${t}.`),await e.m(this,this.env.used.env,`env`)}},{name:`env:automd-generator`,config(){return{automd:(0,d.default)(n.automd??{},{generators:{env:de(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},L(n.automd)];var pe=$;exports.BaseEnv=e._,exports.BaseSecrets=e.v,exports.EnvBuiltin=t.t,exports.EnvDocs=n.t,exports.EnvTypeDefinition=t.n,exports.createEnvReflection=e.y,exports.createReflectionResource=e.t,exports.createSecretsReflection=e.b,exports.createTemplateReflection=fe,exports.default=pe,exports.envBabelPlugin=Q,exports.formatEnvField=e.i,exports.getEnvDefaultTypeDefinition=e.o,exports.getEnvReflectionsPath=e.s,exports.getEnvTypeReflectionsPath=e.c,exports.getSecretsDefaultTypeDefinition=e.l,exports.loadEnv=e.n,exports.loadEnvFromContext=e.r,exports.mergeEnvReflections=e.x,exports.mergeSecretsReflections=e.S,exports.plugin=$,exports.readEnvReflection=e.u,exports.readEnvTypeReflection=e.d,exports.readSecretsReflection=e.f,exports.reflectEnv=e.C,exports.reflectSecrets=e.w,exports.removeEnvPrefix=e.a,exports.resolveRuntimeTypeFile=e.p,exports.writeEnvReflection=e.m,exports.writeEnvReflectionSync=e.h,exports.writeEnvTypeReflection=e.g;
14
+ `)},async buildEnd(){let t=e.s(this,`env`);this.log(h.LogLevelLabel.TRACE,`Writing env reflection types to ${t}.`),await e.m(this,this.env.used.env,`env`)}},{name:`env:automd-generator`,config(){return{automd:(0,f.default)(n.automd??{},{generators:{env:fe(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},R(n.automd)];var me=$;exports.BaseEnv=e._,exports.BaseSecrets=e.v,exports.EnvBuiltin=t.t,exports.EnvDocs=n.t,exports.EnvTypeDefinition=t.n,exports.createEnvReflection=e.y,exports.createReflectionResource=e.t,exports.createSecretsReflection=e.b,exports.createTemplateReflection=pe,exports.default=me,exports.envBabelPlugin=Q,exports.formatEnvField=e.i,exports.getEnvDefaultTypeDefinition=e.o,exports.getEnvReflectionsPath=e.s,exports.getEnvTypeReflectionsPath=e.c,exports.getSecretsDefaultTypeDefinition=e.l,exports.loadEnv=e.n,exports.loadEnvFromContext=e.r,exports.mergeEnvReflections=e.x,exports.mergeSecretsReflections=e.S,exports.plugin=$,exports.readEnvReflection=e.u,exports.readEnvTypeReflection=e.d,exports.readSecretsReflection=e.f,exports.reflectEnv=e.C,exports.reflectSecrets=e.w,exports.removeEnvPrefix=e.a,exports.resolveRuntimeTypeFile=e.p,exports.writeEnvReflection=e.m,exports.writeEnvReflectionSync=e.h,exports.writeEnvTypeReflection=e.g;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { a as EnvType, c as __ΩEnvPluginResolvedConfig, d as type_d_exports, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-CPy0CKXL.cjs";
1
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, d as type_d_exports, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-vBgCrEuY.cjs";
2
2
  import { t as EnvDocs } from "./docs-CdtUw4WA.cjs";
3
3
  import { i as __ΩEnvBuiltinProps, n as EnvBuiltinProps, r as EnvTypeDefinition, t as EnvBuiltin } from "./env-COWzTupf.cjs";
4
4
  import "./index-DWPDThxu.cjs";
5
- import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-Bo02eIQ-.cjs";
5
+ import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-rhT2IfSg.cjs";
6
6
  import "./index-B_e8BwCm.cjs";
7
7
  import * as _alloy_js_core0 from "@alloy-js/core";
8
8
  import * as powerlines0 from "powerlines";
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as EnvDocs } from "./docs-CKCRAUnO.mjs";
2
2
  import { i as __ΩEnvBuiltinProps, n as EnvBuiltinProps, r as EnvTypeDefinition, t as EnvBuiltin } from "./env-DqPOEUEu.mjs";
3
3
  import "./index-CW2WHUXP.mjs";
4
- import { a as EnvType, c as __ΩEnvPluginResolvedConfig, d as type_d_exports, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-Cz3MZ6FL.mjs";
5
- import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-B7kcxFAf.mjs";
4
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, d as type_d_exports, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "./plugin-CuDS8_K8.mjs";
5
+ import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-CRLPiOqf.mjs";
6
6
  import "./index-DCQ5Y2ED.mjs";
7
7
  import { DotenvParseOutput } from "@stryke/env/types";
8
8
  import * as _alloy_js_core0 from "@alloy-js/core";
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import{C as e,D as t,E as n,S as r,T as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as ee,l as p,m,n as h,o as g,p as te,r as ne,s as _,t as re,u as v,v as ie,w as y,x as ae,y as oe}from"./create-reflection-resource-D6mTRo2f.mjs";import{n as se,t as b}from"./env-CHnpBV7X.mjs";import{t as x}from"./docs-BEsuuE9f.mjs";import"./components-ByVHjWXF.mjs";import"./plugin-CyRU_Pln.mjs";import"./runtime-g_eXGBBi.mjs";import"./types-DMh7K7VC.mjs";import{toArray as S}from"@stryke/convert/to-array";import{isDirectory as ce}from"@stryke/fs/is-file";import{listFiles as le}from"@stryke/fs/list-files";import{appendPath as C}from"@stryke/path/append";import{isAbsolutePath as w}from"@stryke/path/is-type";import{joinPaths as T}from"@stryke/path/join-paths";import{replacePath as ue}from"@stryke/path/replace";import{defineGenerator as de,loadConfig as fe,resolveConfig as pe,transform as me}from"automd";import{loadConfig as he}from"c12";import E from"defu";import ge from"markdown-toc";import{transformAsync as _e}from"@babel/core";import{LogLevelLabel as D}from"@storm-software/config-tools/types";import{findFileExtension as ve,findFileExtensionSafe as ye}from"@stryke/path/file-path-fns";import{isParentPath as O}from"@stryke/path/is-parent-path";import{isSetObject as be}from"@stryke/type-checks/is-set-object";import{isFunction as k}from"@stryke/type-checks/is-function";import"@stryke/type-checks/is-object";import{isSetString as A}from"@stryke/type-checks/is-set-string";import j from"chalk";import M from"@babel/generator";import"@babel/parser";import{declare as N}from"@babel/helper-plugin-utils";import"@storm-software/config-tools/logger";import"@storm-software/config-tools/utilities/colors";import"@stryke/helpers/noop";import{titleCase as P}from"@stryke/string-format/title-case";import*as F from"@babel/types";import{isString as I}from"@stryke/type-checks/is-string";import{parseTypeDefinition as L}from"@stryke/convert/parse-type-definition";import{ENV_PREFIXES as xe}from"@stryke/env/types";import{existsSync as R}from"@stryke/fs/exists";import{createDirectory as Se}from"@stryke/fs/helpers";import{joinPaths as z}from"@stryke/path/join";import{constantCase as B}from"@stryke/string-format/constant-case";import*as Ce from"@stryke/capnp";import{getUniqueBy as V}from"@stryke/helpers/get-unique";import{StormJSON as H}from"@stryke/json/storm-json";import{isNull as we}from"@stryke/type-checks/is-null";import{isUndefined as Te}from"@stryke/type-checks/is-undefined";import{readFileBufferSync as Ee}from"@stryke/fs/buffer";import{existsSync as De}from"node:fs";import{jsx as Oe}from"@alloy-js/core/jsx-runtime";var ke=(e={})=>({name:`automd`,async config(){let t=await fe(T(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=S(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:E(t??{},{configFile:e.configFile,allowIssues:!0,dir:this.config.projectRoot,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!S(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=S(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await he({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=pe(E(this.config.automd,{...e,prefix:S(e.prefix??[])}))}this.config.automd.input=(await Promise.all(S(this.config.automd.input).map(async e=>e.includes(`*`)?le(w(e)?e:C(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):w(e)?e:C(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!w(this.config.automd.output)&&(this.config.automd.output=C(this.config.automd.output,this.config.projectRoot)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:ge(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all(S(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await me(t,this.config.automd);if(n.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);n.hasChanged&&await this.fs.write(C(this.config.automd.output?ce(this.config.automd.output)?ue(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});function U(e){return A(e)?e:Array.isArray(e)&&e.length>0?U(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function W(e,t){return!!(U(t)&&e.some(e=>Array.isArray(e)&&U(e[0])===U(t)))}function G(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?k(t[0])?t[0](e):t[0]:k(t)?t(e):t}catch{return t[0]}}function K(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&k(r[2])&&!r[2](t,n)){e.log(D.TRACE,`Skipping filtered Babel plugin ${j.bold.cyanBright(U(r)||`unnamed`)} for ${n}`);return}return r.length>2?[G(e,r),r[1],r[2]]:[G(e,r),r[1],null]}return[G(e,r),{},null]}let q=M;`default`in q&&(q=q.default);const J=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`],Ae=(e,t)=>(n,...r)=>e(n,` ${j.inverse.hex(J[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%J.length]||J[0])(` ${P(t)} `)} ${r.join(` `)} `);function je(e,t){let n=n=>N((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let o=Ae(n.log,e);o(D.TRACE,`Initializing the ${j.bold.cyanBright(e)} Babel plugin`);let s=t({log:o,name:e,api:r,options:i,context:n,dirname:a});return s.name=e,o(D.TRACE,`Completed initialization of the ${j.bold.cyanBright(e)} Babel plugin`),s});return n.$$name=e,n}function Y(e,t){Pe(e.scope.getProgramParent().path,t)}function Me(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function Ne(e){let t=new Map;return e.traverse({ImportDeclaration(e){Me(e)&&t.set(e.node.source.value,e)}}),t}function Pe(e,t){Ne(e).get(t.module)||e.unshiftContainer(`body`,F.importDeclaration([F.importSpecifier(F.identifier(t.name||t.imported),F.identifier(t.imported))],F.stringLiteral(t.module)))}var Fe=(e={})=>({name:`babel`,config(){if(be(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=E(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if(O(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(D.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(D.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>K(this,t,n,e)).filter((e,t,n)=>e&&!W(n,e)),i=this.config.transform.babel.presets.map(e=>K(this,t,n,e)).filter((e,t,n)=>e&&!W(n,e));if(Array.isArray(r)&&r.length===0&&Array.isArray(i)&&i.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes(ye(n))&&!W(r,`@babel/plugin-syntax-typescript`)&&!W(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:ve(n)===`.tsx`}]);let a=await _e(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:r.map(t=>Array.isArray(t)&&t.length>=2?[t[0],E(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],E(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!a?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:a.code,id:n}}});function Ie(e,t){return Z(e.type,t??e.getDefaultValue())}function X(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function Z(e,n){return Te(n)?`undefined`:we(n)?`null`:e.kind===t.ReflectionKind.boolean?String(n).trim().toLowerCase()===`true`?`true`:`false`:e.kind===t.ReflectionKind.string||e.kind===t.ReflectionKind.literal&&I(e.literal)?X(n):e.kind===t.ReflectionKind.enum?Le(e).kind===t.ReflectionKind.string?X(n):`${String(n)}`:e.kind===t.ReflectionKind.union?ze(e)?X(n):`${String(n)}`:e.kind===t.ReflectionKind.array?X(H.stringify(n)):e.kind===t.ReflectionKind.object||e.kind===t.ReflectionKind.objectLiteral?H.stringify(n):e.kind===t.ReflectionKind.property||e.kind===t.ReflectionKind.parameter?Z(e.type,n):String(n)}function Le(e){if(e.kind!==t.ReflectionKind.enum)throw Error(`Expected a TypeEnum, but received ${e.kind}.`);let n=V(e.values.filter(e=>e!=null),e=>I(e)?{kind:t.ReflectionKind.string}:{kind:t.ReflectionKind.number});if(n.length===0)throw Error(`No valid enum members could be found.`);return n[0]&&I(n[0])?{kind:t.ReflectionKind.string}:{kind:t.ReflectionKind.number}}function Re(e){if(e.kind===t.ReflectionKind.union&&e.types.length>0)return V(e.types,e=>e.kind);throw Error(`Expected a TypeUnion, but received ${e.kind}.`)}function ze(e){return Re(e).some(e=>e.kind===t.ReflectionKind.string||e.kind===t.ReflectionKind.literal&&I(e.literal))}const Q=je(`env`,({log:e,context:r})=>{function a(t,n,i=!1){let a=r.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(t.name){let o=r.config.env.prefix.find(e=>t.name&&t.name.startsWith(e)&&(r.env.types.env?.hasProperty(t.name.replace(`${e}_`,``))||a.some(n=>n.getAlias().includes(t.name.replace(`${e}_`,``))))),s=t.name;if(o&&(s=t.name.replace(`${o}_`,``)),e(D.TRACE,`Environment variable ${s} found in ${n.filename||`unknown file`}.`),r.env.types.env?.hasProperty(s)||a.some(e=>e.getAlias().includes(s))){let e=r.env.types.env.hasProperty(s)?r.env.types.env.getProperty(s):a.find(e=>e.getAlias().includes(s));if(!e||e.isIgnored())return;if(r.env.used.env.hasProperty(s)||r.env.used.env.addProperty(e.property),r.config.env.inject&&i){let t=r.env.parsed?.[s];if(t===void 0){let e=r.config.env.prefix.find(e=>r.env.parsed[`${e.replace(/_$/g,``)}_${s}`]);e&&(t=r.env.parsed[`${e.replace(/_$/g,``)}_${s}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return Ie(e,t)}}else throw Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${n.filename?n.filename:`unknown`}.
1
+ import{C as e,D as t,E as n,S as r,T as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as ee,l as p,m,n as h,o as g,p as te,r as ne,s as _,t as re,u as v,v as ie,w as y,x as ae,y as oe}from"./create-reflection-resource-BtYlphp1.mjs";import{n as se,t as b}from"./env-Bwys2dqb.mjs";import{t as x}from"./docs-CMoOO30q.mjs";import"./components-ByVHjWXF.mjs";import"./plugin-CyRU_Pln.mjs";import"./runtime-g_eXGBBi.mjs";import"./types-DMh7K7VC.mjs";import{toArray as S}from"@stryke/convert/to-array";import{isDirectory as ce}from"@stryke/fs/is-file";import{listFiles as le}from"@stryke/fs/list-files";import{appendPath as C}from"@stryke/path/append";import{isAbsolutePath as w}from"@stryke/path/is-type";import{joinPaths as T}from"@stryke/path/join-paths";import{replacePath as ue}from"@stryke/path/replace";import{defineGenerator as de,loadConfig as fe,resolveConfig as pe,transform as me}from"automd";import{loadConfig as he}from"c12";import E from"defu";import ge from"markdown-toc";import{transformAsync as _e}from"@babel/core";import{LogLevelLabel as D}from"@storm-software/config-tools/types";import{findFileExtension as ve,findFileExtensionSafe as ye}from"@stryke/path/file-path-fns";import{isParentPath as O}from"@stryke/path/is-parent-path";import{isSetObject as be}from"@stryke/type-checks/is-set-object";import{isFunction as k}from"@stryke/type-checks/is-function";import"@stryke/type-checks/is-object";import{isSetString as A}from"@stryke/type-checks/is-set-string";import j from"chalk";import M from"@babel/generator";import"@babel/parser";import{declare as N}from"@babel/helper-plugin-utils";import"@storm-software/config-tools/logger";import"@storm-software/config-tools/utilities/colors";import"@stryke/helpers/noop";import{kebabCase as xe}from"@stryke/string-format/kebab-case";import{titleCase as P}from"@stryke/string-format/title-case";import*as F from"@babel/types";import{isString as I}from"@stryke/type-checks/is-string";import{parseTypeDefinition as L}from"@stryke/convert/parse-type-definition";import{ENV_PREFIXES as Se}from"@stryke/env/types";import{existsSync as R}from"@stryke/fs/exists";import{createDirectory as Ce}from"@stryke/fs/helpers";import{joinPaths as z}from"@stryke/path/join";import{constantCase as we}from"@stryke/string-format/constant-case";import*as Te from"@stryke/capnp";import{getUniqueBy as B}from"@stryke/helpers/get-unique";import{StormJSON as V}from"@stryke/json/storm-json";import{isNull as Ee}from"@stryke/type-checks/is-null";import{isUndefined as De}from"@stryke/type-checks/is-undefined";import{readFileBufferSync as Oe}from"@stryke/fs/buffer";import{existsSync as ke}from"node:fs";import{jsx as Ae}from"@alloy-js/core/jsx-runtime";var je=(e={})=>({name:`automd`,async config(){let t=await fe(T(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=S(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:E(t??{},{configFile:e.configFile,allowIssues:!0,dir:this.config.projectRoot,watch:!1,input:`README.md`,toc:{maxDepth:6,bullets:`-`}})}},async configResolved(){if(this.config.framework&&!S(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=S(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await he({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=pe(E(this.config.automd,{...e,prefix:S(e.prefix??[])}))}this.config.automd.input=(await Promise.all(S(this.config.automd.input).map(async e=>e.includes(`*`)?le(w(e)?e:C(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):w(e)?e:C(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!w(this.config.automd.output)&&(this.config.automd.output=C(this.config.automd.output,this.config.projectRoot)),this.config.automd.generators??={},this.config.automd.toc!==!1&&(this.config.automd.generators.toc??={name:`toc`,generate:e=>{let t=this.config.automd.toc??{};return{contents:ge(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all(S(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await me(t,this.config.automd);if(n.hasIssues&&this.config.automd.allowIssues===!1)throw Error(`AutoMD found issues in file "${e}". Please resolve the issues or set \`allowIssues\` to true in the plugin configuration to ignore them.`);n.hasChanged&&await this.fs.write(C(this.config.automd.output?ce(this.config.automd.output)?ue(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});function H(e){return A(e)?e:Array.isArray(e)&&e.length>0?H(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function U(e,t){return!!(H(t)&&e.some(e=>Array.isArray(e)&&H(e[0])===H(t)))}function W(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?k(t[0])?t[0](e):t[0]:k(t)?t(e):t}catch{return t[0]}}function G(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&k(r[2])&&!r[2](t,n)){e.log(D.TRACE,`Skipping filtered Babel plugin ${j.bold.cyanBright(H(r)||`unnamed`)} for ${n}`);return}return r.length>2?[W(e,r),r[1],r[2]]:[W(e,r),r[1],null]}return[W(e,r),{},null]}let K=M;`default`in K&&(K=K.default);const q=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#D8B4FE`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`,`#8B5CF6`],Me=(e,t)=>(n,...r)=>e(n,` ${j.inverse.hex(q[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%q.length]||q[0])(` ${P(t)} `)} ${r.join(` `)} `);function Ne(e,t){let n=n=>N((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let o=Me(n.log,e);o(D.TRACE,`Initializing the ${j.bold.cyanBright(e)} Babel plugin`);let s=t({log:o,name:e,api:r,options:i,context:n,dirname:a});return s.name=e,o(D.TRACE,`Completed initialization of the ${j.bold.cyanBright(e)} Babel plugin`),s});return n.$$name=e,n}function J(e,t){Ie(e.scope.getProgramParent().path,t)}function Pe(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function Fe(e){let t=new Map;return e.traverse({ImportDeclaration(e){Pe(e)&&t.set(e.node.source.value,e)}}),t}function Ie(e,t){Fe(e).get(t.module)||e.unshiftContainer(`body`,F.importDeclaration([F.importSpecifier(F.identifier(t.name||t.imported),F.identifier(t.imported))],F.stringLiteral(t.module)))}var Le=(e={})=>({name:`babel`,config(){if(be(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=E(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if(O(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(D.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(D.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>G(this,t,n,e)).filter((e,t,n)=>e&&!U(n,e)),i=this.config.transform.babel.presets.map(e=>G(this,t,n,e)).filter((e,t,n)=>e&&!U(n,e));if(Array.isArray(r)&&r.length===0&&Array.isArray(i)&&i.length===0)return{code:t,id:n};[`ts`,`cts`,`mts`,`tsx`].includes(ye(n))&&!U(r,`@babel/plugin-syntax-typescript`)&&!U(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:ve(n)===`.tsx`}]);let a=await _e(t,{highlightCode:!0,code:!0,ast:!1,cloneInputAst:!1,comments:!0,sourceType:`module`,configFile:!1,babelrc:!1,envName:this.config.mode,caller:{name:this.config.framework},...this.config.transform.babel??{},filename:n,plugins:r.map(t=>Array.isArray(t)&&t.length>=2?[t[0],E(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],E(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!a?.code)throw Error(`Powerlines - Babel plugin failed to compile ${n}`);return{code:a.code,id:n}}});function Y(e,t){return Z(e.type,t??e.getDefaultValue())}function X(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function Z(e,n){return De(n)?`undefined`:Ee(n)?`null`:e.kind===t.ReflectionKind.boolean?String(n).trim().toLowerCase()===`true`?`true`:`false`:e.kind===t.ReflectionKind.string||e.kind===t.ReflectionKind.literal&&I(e.literal)?X(n):e.kind===t.ReflectionKind.enum?Re(e).kind===t.ReflectionKind.string?X(n):`${String(n)}`:e.kind===t.ReflectionKind.union?Be(e)?X(n):`${String(n)}`:e.kind===t.ReflectionKind.array?X(V.stringify(n)):e.kind===t.ReflectionKind.object||e.kind===t.ReflectionKind.objectLiteral?V.stringify(n):e.kind===t.ReflectionKind.property||e.kind===t.ReflectionKind.parameter?Z(e.type,n):String(n)}function Re(e){if(e.kind!==t.ReflectionKind.enum)throw Error(`Expected a TypeEnum, but received ${e.kind}.`);let n=B(e.values.filter(e=>e!=null),e=>I(e)?{kind:t.ReflectionKind.string}:{kind:t.ReflectionKind.number});if(n.length===0)throw Error(`No valid enum members could be found.`);return n[0]&&I(n[0])?{kind:t.ReflectionKind.string}:{kind:t.ReflectionKind.number}}function ze(e){if(e.kind===t.ReflectionKind.union&&e.types.length>0)return B(e.types,e=>e.kind);throw Error(`Expected a TypeUnion, but received ${e.kind}.`)}function Be(e){return ze(e).some(e=>e.kind===t.ReflectionKind.string||e.kind===t.ReflectionKind.literal&&I(e.literal))}const Q=Ne(`env`,({log:e,context:r})=>{function a(t,n,i=!1){let a=r.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(t.name){let o=r.config.env.prefix.find(e=>t.name&&t.name.startsWith(e)&&(r.env.types.env?.hasProperty(t.name.replace(`${e}_`,``))||a.some(n=>n.getAlias().includes(t.name.replace(`${e}_`,``))))),s=t.name;if(o&&(s=t.name.replace(`${o}_`,``)),e(D.TRACE,`Environment variable ${s} found in ${n.filename||`unknown file`}.`),r.env.types.env?.hasProperty(s)||a.some(e=>e.getAlias().includes(s))){let e=r.env.types.env.hasProperty(s)?r.env.types.env.getProperty(s):a.find(e=>e.getAlias().includes(s));if(!e||e.isIgnored())return;if(r.env.used.env.hasProperty(s)||r.env.used.env.addProperty(e.property),r.config.env.inject&&i){let t=r.env.parsed?.[s];if(t===void 0){let e=r.config.env.prefix.find(e=>r.env.parsed[`${e.replace(/_$/g,``)}_${s}`]);e&&(t=r.env.parsed[`${e.replace(/_$/g,``)}_${s}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${s}\` is not defined in the .env configuration files`);return Y(e,t)}}else throw Error(`The "${s}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${n.filename?n.filename:`unknown`}.
2
2
 
3
3
  The following environment configuration names are defined in the \`env\` type definition: \n${r.env.types.env?.getPropertyNames().sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` - ${String(e)} ${a.some(t=>t.getNameAsString()===String(e)&&t.getAlias().length>0)?`(Alias: ${a?.find(t=>t.getNameAsString()===String(e))?.getAlias().join(`, `)})`:``}`).join(`
4
4
  `)} \n\nUsing the following env prefix: \n${r.config.env.prefix.map(e=>` - ${e}`).join(`
5
- `)} \n\nPlease 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. \n\n`)}}return{visitor:{MemberExpression(e,t){if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`$storm`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),Y(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()){let n=e.get(`property`)?.node;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),Y(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()){let n=e.get(`property`)?.node;if(!n.name)return;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),Y(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()){let n=e.get(`property`)?.node;if(!n.name)return;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),Y(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){e(D.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let a=t.ReflectionClass.from({kind:t.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),o=_(r,`env`);o&&De(o)&&(e(D.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),a=(0,t.resolveClassType)((0,t.deserializeType)(n(new Ce.Message(Ee(o),!1).getRoot(i).types)))),e(D.TRACE,`Adding new variables to env reflection at ${o}.`),a.getProperties().filter(e=>e.getNameAsString()&&!r.env.used.env.hasProperty(e.getNameAsString())).forEach(e=>{r.env.used.env.addProperty({...e,name:e.getNameAsString(),description:e.getDescription()??`The ${e.getNameAsString()} variable.`,default:e.getDefaultValue(),optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,visibility:e.getVisibility(),type:e.getType(),tags:e.getTags()})})}}}),Be=e=>de({name:`env`,async generate(){let t=T(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function Ve(e,t){let n=await l(e,t);return n.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(t=>{n.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0: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(e=>e!==t).concat(e.name),title:e.getTitle()||P(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),n}const $=(n={})=>[Fe(n.babel),{name:`env`,async config(){this.log(D.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let e={env:E(n,{types:{},prefix:[]}),transform:{babel:{plugins:[Q]}}};if(e.env.types)e.env.types=L(e.env.types);else{this.log(D.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let t=await g(this);e.env.types=L(`${t.file}#${t.name}`)}if(e.env.secrets)e.env.secrets=L(e.env.secrets);else{let t=await p(this);e.env.secrets=L(`${t.file}#${t.name}`)}return e.env.prefix=S(e.env.prefix??[]).reduce((e,t)=>{let n=B(t);return e.includes(n)||e.push(n),e},[...xe,`POWERLINES_`]),e.env.prefix=e.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),e},async configResolved(){if(this.log(D.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=E({parsed:await h(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&R(c(this,`env`)))this.log(D.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await l(this,`env`),R(_(this,`env`))&&(this.env.used.env=await v(this)),R(c(this,`secrets`))&&(this.env.types.secrets=await l(this,`secrets`)),R(_(this,`secrets`))&&(this.env.used.secrets=await u(this));else{if(this.env.types.env=await e(this,this.config.env.types?.file?O(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:z(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await d(this,this.env.types.env,`env`),this.env.types.secrets=await y(this,this.config.env.secrets?.file?O(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:z(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await d(this,this.env.types.secrets,`secrets`),this.log(D.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let n=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await h(this,this.config.env)).forEach(([e,t])=>{let r=this.config.env.prefix.reduce((t,n)=>e.replace(/_$/g,``).startsWith(n)?e.replace(/_$/g,``).slice(n.length):t,e),i=n.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(t)}),this.env.used.env=new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await m(this,this.env.used.env,`env`),this.env.types.secrets&&(await d(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await m(this,this.env.used.secrets,`secrets`))}},async prepare(){return this.log(D.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render(Oe(b,{defaultConfig:this.config.env.defaultConfig}))},async docs(){this.log(D.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=z(this.config.projectRoot,`docs`,`generated`);R(e)||await Se(e);let n=await l(this,`env`),r=z(e,`env.md`);this.log(D.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${P(this.config.framework)||`Powerlines`} -->
5
+ `)} \n\nPlease 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. \n\n`)}}return{visitor:{MemberExpression(e,t){if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`$storm`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),J(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()){let n=e.get(`property`)?.node;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),J(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()){let n=e.get(`property`)?.node;if(!n.name)return;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),J(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()){let n=e.get(`property`)?.node;if(!n.name)return;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),J(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){e(D.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let a=t.ReflectionClass.from({kind:t.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),o=_(r,`env`);o&&ke(o)&&(e(D.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),a=(0,t.resolveClassType)((0,t.deserializeType)(n(new Te.Message(Oe(o),!1).getRoot(i).types)))),e(D.TRACE,`Adding new variables to env reflection at ${o}.`),a.getProperties().filter(e=>e.getNameAsString()&&!r.env.used.env.hasProperty(e.getNameAsString())).forEach(e=>{r.env.used.env.addProperty({...e,name:e.getNameAsString(),description:e.getDescription()??`The ${e.getNameAsString()} variable.`,default:e.getDefaultValue(),optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0:void 0,visibility:e.getVisibility(),type:e.getType(),tags:e.getTags()})})}}}),Ve=e=>de({name:`env`,async generate(){let t=T(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function He(e,t){let n=await l(e,t);return n.getProperties().forEach(e=>{e.getAlias().filter(Boolean).forEach(t=>{n.addProperty({name:t,optional:e.isOptional()?!0:void 0,readonly:e.isReadonly()?!0: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(e=>e!==t).concat(e.name),title:e.getTitle()||P(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),n}const $=(n={})=>[Le(n.babel),{name:`env`,async config(){this.log(D.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let e={env:E(n,{types:{},prefix:[]}),transform:{babel:{plugins:[Q]}}};if(e.env.types)e.env.types=L(e.env.types);else{this.log(D.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let t=await g(this);e.env.types=L(`${t.file}#${t.name}`)}if(e.env.secrets)e.env.secrets=L(e.env.secrets);else{let t=await p(this);e.env.secrets=L(`${t.file}#${t.name}`)}return e.env.prefix=S(e.env.prefix??[]).reduce((e,t)=>{let n=we(t);return e.includes(n)||e.push(n),e},[...Se,`POWERLINES_`]),e.env.prefix=e.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),e},async configResolved(){if(this.log(D.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=E({parsed:await h(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&R(c(this,`env`)))this.log(D.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await l(this,`env`),R(_(this,`env`))&&(this.env.used.env=await v(this)),R(c(this,`secrets`))&&(this.env.types.secrets=await l(this,`secrets`)),R(_(this,`secrets`))&&(this.env.used.secrets=await u(this));else{if(this.env.types.env=await e(this,this.config.env.types?.file?O(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:z(this.config.projectRoot,this.config.env.types?.file):void 0,this.config.env.types?.name),!this.env.types.env)throw Error(`Failed to find the environment configuration type reflection in the context.`);if(await d(this,this.env.types.env,`env`),this.env.types.secrets=await y(this,this.config.env.secrets?.file?O(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:z(this.config.projectRoot,this.config.env.secrets?.file):void 0,this.config.env.secrets?.name),!this.env.types.secrets)throw Error(`Failed to find the secrets configuration type reflection in the context.`);await d(this,this.env.types.secrets,`secrets`),this.log(D.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let n=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await h(this,this.config.env)).forEach(([e,t])=>{let r=this.config.env.prefix.reduce((t,n)=>e.replace(/_$/g,``).startsWith(n)?e.replace(/_$/g,``).slice(n.length):t,e),i=n.find(e=>e?.getAlias().reverse().includes(r));(this.env.types.env?.hasProperty(r)||i)&&this.env.types.env.getProperty(r).setDefaultValue(t)}),this.env.used.env=new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.env),await m(this,this.env.used.env,`env`),this.env.types.secrets&&(await d(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters used by the ${this.config.name?`${this.config.name} application`:`application`}.`,types:[]},this.env.types.secrets),await m(this,this.env.used.secrets,`secrets`))}},async prepare(){return this.log(D.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render(Ae(b,{defaultConfig:this.config.env.defaultConfig}))},async docs(){this.log(D.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=z(this.config.projectRoot,`docs`,`generated`);R(e)||await Ce(e);let n=await l(this,`env`),r=z(e,`env.md`);this.log(D.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${P(this.config.framework)||`Powerlines`} -->
6
6
 
7
7
  Below is a list of environment variables used by the [${this.packageJson.name}](https://www.npmjs.com/package/${this.packageJson.name}) package. These values can be updated in the \`.env\` file in the root of the project. The variables in the list below are used as configuration parameters to drive the processing of the application. The data contained in these variables are **not** considered sensitive or confidential. Any values provided in these variables will be available in plain text to the public.
8
8
 
@@ -11,4 +11,4 @@ Below is a list of environment variables used by the [${this.packageJson.name}](
11
11
  ${n.getProperties().filter(e=>e.getNameAsString()!==`__POWERLINES_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(e=>`| ${e.getNameAsString().trim()} | ${(e.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
12
12
  `,``)??``).trim()} | ${(0,t.stringifyType)(e.getType()).trim().replaceAll(` | `,`, or `)} | ${e.hasDefault()?String(e.getDefaultValue())?.includes(`"`)?e.getDefaultValue():`\`${e.getDefaultValue()}\``:``} | ${e.isValueRequired()?``:`✔`} |`).join(`
13
13
  `)}
14
- `)},async buildEnd(){let e=_(this,`env`);this.log(D.TRACE,`Writing env reflection types to ${e}.`),await m(this,this.env.used.env,`env`)}},{name:`env:automd-generator`,config(){return{automd:E(n.automd??{},{generators:{env:Be(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},ke(n.automd)];var He=$;export{a as BaseEnv,ie as BaseSecrets,b as EnvBuiltin,x as EnvDocs,se as EnvTypeDefinition,oe as createEnvReflection,re as createReflectionResource,s as createSecretsReflection,Ve as createTemplateReflection,He as default,Q as envBabelPlugin,ee as formatEnvField,g as getEnvDefaultTypeDefinition,_ as getEnvReflectionsPath,c as getEnvTypeReflectionsPath,p as getSecretsDefaultTypeDefinition,h as loadEnv,ne as loadEnvFromContext,ae as mergeEnvReflections,r as mergeSecretsReflections,$ as plugin,v as readEnvReflection,l as readEnvTypeReflection,u as readSecretsReflection,e as reflectEnv,y as reflectSecrets,o as removeEnvPrefix,te as resolveRuntimeTypeFile,m as writeEnvReflection,f as writeEnvReflectionSync,d as writeEnvTypeReflection};
14
+ `)},async buildEnd(){let e=_(this,`env`);this.log(D.TRACE,`Writing env reflection types to ${e}.`),await m(this,this.env.used.env,`env`)}},{name:`env:automd-generator`,config(){return{automd:E(n.automd??{},{generators:{env:Ve(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},je(n.automd)];var Ue=$;export{a as BaseEnv,ie as BaseSecrets,b as EnvBuiltin,x as EnvDocs,se as EnvTypeDefinition,oe as createEnvReflection,re as createReflectionResource,s as createSecretsReflection,He as createTemplateReflection,Ue as default,Q as envBabelPlugin,ee as formatEnvField,g as getEnvDefaultTypeDefinition,_ as getEnvReflectionsPath,c as getEnvTypeReflectionsPath,p as getSecretsDefaultTypeDefinition,h as loadEnv,ne as loadEnvFromContext,ae as mergeEnvReflections,r as mergeSecretsReflections,$ as plugin,v as readEnvReflection,l as readEnvTypeReflection,u as readSecretsReflection,e as reflectEnv,y as reflectSecrets,o as removeEnvPrefix,te as resolveRuntimeTypeFile,m as writeEnvReflection,f as writeEnvReflectionSync,d as writeEnvTypeReflection};
@@ -1,8 +1,8 @@
1
- import { a as BabelResolvedConfig, c as UserConfig, n as SecretsInterface, o as ResolvedConfig, s as BabelUserConfig, t as EnvInterface, u as PluginContext } from "./runtime-B7kcxFAf.mjs";
1
+ import { a as BabelResolvedConfig, c as UserConfig, n as SecretsInterface, o as ResolvedConfig, s as BabelUserConfig, t as EnvInterface, u as PluginContext } from "./runtime-CRLPiOqf.mjs";
2
2
  import { Config } from "automd";
3
3
  import { DotenvParseOutput } from "@stryke/env/types";
4
4
  import * as $ from "@stryke/capnp";
5
- import "@alloy-js/core";
5
+ import { PrintTreeOptions } from "@alloy-js/core";
6
6
  import "@alloy-js/typescript";
7
7
  import { Children as Children$1 } from "@alloy-js/core/jsx-runtime";
8
8
  import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
@@ -1575,7 +1575,29 @@ type Reflection<T extends Record<string, any> = Record<string, any>> = type_d_ex
1575
1575
  };
1576
1576
  //#endregion
1577
1577
  //#region ../plugin-alloy/src/types/plugin.d.ts
1578
- type AlloyPluginResolvedConfig = ResolvedConfig;
1578
+ type AlloyPluginOptions = Partial<PrintTreeOptions> & {
1579
+ /**
1580
+ * If true, the Alloy framework is used to generate Typescript output files.
1581
+ *
1582
+ * @defaultValue true
1583
+ */
1584
+ typescript?: boolean;
1585
+ /**
1586
+ * If true, the Alloy framework is used to generate JSON output files.
1587
+ *
1588
+ * @defaultValue false
1589
+ */
1590
+ json?: boolean;
1591
+ /**
1592
+ * If true, the Alloy framework is used to generate Markdown output files.
1593
+ *
1594
+ * @defaultValue false
1595
+ */
1596
+ markdown?: boolean;
1597
+ };
1598
+ type AlloyPluginResolvedConfig = ResolvedConfig & {
1599
+ alloy: AlloyPluginOptions;
1600
+ };
1579
1601
  type AlloyPluginContext<TResolvedConfig extends AlloyPluginResolvedConfig = AlloyPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
1580
1602
  render: <TContext extends AlloyPluginContext>(this: TContext, children: Children$1) => Promise<void>;
1581
1603
  };
@@ -1,5 +1,6 @@
1
- import { a as BabelResolvedConfig, c as UserConfig, n as SecretsInterface, o as ResolvedConfig, s as BabelUserConfig, t as EnvInterface, u as PluginContext } from "./runtime-Bo02eIQ-.cjs";
2
- import { Children } from "@alloy-js/core/jsx-runtime";
1
+ import { a as BabelResolvedConfig, c as UserConfig, n as SecretsInterface, o as ResolvedConfig, s as BabelUserConfig, t as EnvInterface, u as PluginContext } from "./runtime-rhT2IfSg.cjs";
2
+ import { PrintTreeOptions } from "@alloy-js/core";
3
+ import { Children as Children$1 } from "@alloy-js/core/jsx-runtime";
3
4
  import * as $ from "@stryke/capnp";
4
5
  import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
5
6
  import { Config } from "automd";
@@ -1573,9 +1574,31 @@ type Reflection<T extends Record<string, any> = Record<string, any>> = type_d_ex
1573
1574
  };
1574
1575
  //#endregion
1575
1576
  //#region ../plugin-alloy/src/types/plugin.d.ts
1576
- type AlloyPluginResolvedConfig = ResolvedConfig;
1577
+ type AlloyPluginOptions = Partial<PrintTreeOptions> & {
1578
+ /**
1579
+ * If true, the Alloy framework is used to generate Typescript output files.
1580
+ *
1581
+ * @defaultValue true
1582
+ */
1583
+ typescript?: boolean;
1584
+ /**
1585
+ * If true, the Alloy framework is used to generate JSON output files.
1586
+ *
1587
+ * @defaultValue false
1588
+ */
1589
+ json?: boolean;
1590
+ /**
1591
+ * If true, the Alloy framework is used to generate Markdown output files.
1592
+ *
1593
+ * @defaultValue false
1594
+ */
1595
+ markdown?: boolean;
1596
+ };
1597
+ type AlloyPluginResolvedConfig = ResolvedConfig & {
1598
+ alloy: AlloyPluginOptions;
1599
+ };
1577
1600
  type AlloyPluginContext<TResolvedConfig extends AlloyPluginResolvedConfig = AlloyPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
1578
- render: <TContext extends AlloyPluginContext>(this: TContext, children: Children) => Promise<void>;
1601
+ render: <TContext extends AlloyPluginContext>(this: TContext, children: Children$1) => Promise<void>;
1579
1602
  };
1580
1603
  //#endregion
1581
1604
  //#region ../plugin-automd/src/types/toc.d.ts
@@ -1686,7 +1709,7 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
1686
1709
  * @remarks
1687
1710
  * This configuration is used as the base configuration when loading environment variables, and will be overridden by any values found in the `.env` file or the process environment.
1688
1711
  */
1689
- defaultConfig?: Children;
1712
+ defaultConfig?: Children$1;
1690
1713
  /**
1691
1714
  * Babel configuration options to use when injecting environment variables into the source code.
1692
1715
  *
@@ -1303,7 +1303,7 @@ type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions
1303
1303
  /**
1304
1304
  * A configuration tuple for a Powerlines plugin.
1305
1305
  */
1306
- type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | Plugin<TContext>[] | Promise<Plugin<TContext> | Plugin<TContext>[]> | PluginConfigTuple<TContext> | PluginConfigObject<TContext>;
1306
+ type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | PluginConfigTuple<TContext> | PluginConfigObject<TContext> | Promise<PluginConfig<TContext>> | PluginConfig<TContext>[];
1307
1307
  type ProjectType = "application" | "library";
1308
1308
  type BabelUserConfig = Parameters<typeof transformAsync>[1] & {
1309
1309
  /**
@@ -1301,7 +1301,7 @@ type PluginConfigObject<TContext extends PluginContext = PluginContext, TOptions
1301
1301
  /**
1302
1302
  * A configuration tuple for a Powerlines plugin.
1303
1303
  */
1304
- type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | Plugin<TContext>[] | Promise<Plugin<TContext> | Plugin<TContext>[]> | PluginConfigTuple<TContext> | PluginConfigObject<TContext>;
1304
+ type PluginConfig<TContext extends PluginContext = PluginContext> = string | PluginFactory<TContext, void> | Plugin<TContext> | PluginConfigTuple<TContext> | PluginConfigObject<TContext> | Promise<PluginConfig<TContext>> | PluginConfig<TContext>[];
1305
1305
  type ProjectType = "application" | "library";
1306
1306
  type BabelUserConfig = Parameters<typeof transformAsync>[1] & {
1307
1307
  /**
@@ -1,4 +1,4 @@
1
- import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-CPy0CKXL.cjs";
2
- import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-Bo02eIQ-.cjs";
1
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-vBgCrEuY.cjs";
2
+ import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-rhT2IfSg.cjs";
3
3
  import "../index-B_e8BwCm.cjs";
4
4
  export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface };
@@ -1,4 +1,4 @@
1
- import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-Cz3MZ6FL.mjs";
2
- import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-B7kcxFAf.mjs";
1
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-CuDS8_K8.mjs";
2
+ import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-CRLPiOqf.mjs";
3
3
  import "../index-DCQ5Y2ED.mjs";
4
4
  export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface };
@@ -1,3 +1,3 @@
1
- import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-CPy0CKXL.cjs";
2
- import "../runtime-Bo02eIQ-.cjs";
1
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-vBgCrEuY.cjs";
2
+ import "../runtime-rhT2IfSg.cjs";
3
3
  export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType };
@@ -1,3 +1,3 @@
1
- import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-Cz3MZ6FL.mjs";
2
- import "../runtime-B7kcxFAf.mjs";
1
+ import { a as EnvType, c as __ΩEnvPluginResolvedConfig, i as EnvPluginUserConfig, l as __ΩEnvPluginUserConfig, n as EnvPluginOptions, o as __ΩEnvPluginContext, r as EnvPluginResolvedConfig, s as __ΩEnvPluginOptions, t as EnvPluginContext, u as __ΩEnvType } from "../plugin-CuDS8_K8.mjs";
2
+ import "../runtime-CRLPiOqf.mjs";
3
3
  export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType };
@@ -1,2 +1,2 @@
1
- import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-Bo02eIQ-.cjs";
1
+ import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-rhT2IfSg.cjs";
2
2
  export { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface };
@@ -1,2 +1,2 @@
1
- import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-B7kcxFAf.mjs";
1
+ import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-CRLPiOqf.mjs";
2
2
  export { EnvInterface, SecretsInterface, __ΩEnvInterface, __ΩSecretsInterface };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-env",
3
- "version": "0.14.5",
3
+ "version": "0.14.7",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
6
6
  "repository": {
@@ -193,10 +193,10 @@
193
193
  "@alloy-js/markdown": "^0.21.0",
194
194
  "@babel/core": "^7.28.5",
195
195
  "@babel/types": "^7.28.5",
196
- "@powerlines/plugin-alloy": "^0.14.0",
197
- "@powerlines/plugin-automd": "^0.1.102",
198
- "@powerlines/plugin-babel": "^0.12.111",
199
- "@powerlines/plugin-plugin": "^0.12.54",
196
+ "@powerlines/plugin-alloy": "^0.15.1",
197
+ "@powerlines/plugin-automd": "^0.1.104",
198
+ "@powerlines/plugin-babel": "^0.12.113",
199
+ "@powerlines/plugin-plugin": "^0.12.56",
200
200
  "@storm-software/config-tools": "^1.188.74",
201
201
  "@stryke/capnp": "^0.12.51",
202
202
  "@stryke/env": "^0.20.43",
@@ -205,18 +205,18 @@
205
205
  "@stryke/string-format": "^0.12.29",
206
206
  "@stryke/type-checks": "^0.5.14",
207
207
  "@stryke/types": "^0.10.28",
208
- "powerlines": "^0.36.7"
208
+ "powerlines": "^0.36.9"
209
209
  },
210
210
  "devDependencies": {
211
211
  "@alloy-js/babel-preset": "^0.2.1",
212
212
  "@babel/preset-typescript": "^7.28.5",
213
- "@powerlines/plugin-alloy": "^0.14.0",
214
- "@powerlines/plugin-plugin": "^0.12.54",
215
- "@powerlines/nx": "^0.11.33",
213
+ "@powerlines/plugin-alloy": "^0.15.1",
214
+ "@powerlines/plugin-plugin": "^0.12.56",
215
+ "@powerlines/nx": "^0.11.35",
216
216
  "@types/node": "^24.10.4",
217
217
  "typescript": "^5.9.3",
218
218
  "vite": "8.0.0-beta.2"
219
219
  },
220
220
  "publishConfig": { "access": "public" },
221
- "gitHead": "abbf694ae460ab6f58ae645a000cabf4a4fdac80"
221
+ "gitHead": "e9fb959df894f1aa67074af9fbb126978a450a45"
222
222
  }