@powerlines/plugin-env 0.14.7 → 0.14.9
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/components/docs.cjs +1 -1
- package/dist/components/docs.mjs +1 -1
- package/dist/components/env.cjs +1 -1
- package/dist/components/env.mjs +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/create-reflection-resource-B1734Oqz.mjs +17 -0
- package/dist/create-reflection-resource-JGnGa1lq.cjs +17 -0
- package/dist/docs-B_eQmaOI.mjs +1 -0
- package/dist/docs-ChC5Pu1X.cjs +1 -0
- package/dist/env-Dco1ouC9.mjs +31 -0
- package/dist/env-N-X_-s2s.cjs +34 -0
- package/dist/index.cjs +4 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -3
- package/dist/{plugin-vBgCrEuY.d.cts → plugin-Bub_SPEB.d.cts} +13 -2
- package/dist/{plugin-CuDS8_K8.d.mts → plugin-CbIYUQ4Z.d.mts} +18 -8
- package/dist/{runtime-CRLPiOqf.d.mts → runtime-AfBxUosz.d.mts} +1 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/plugin.d.cts +1 -1
- package/dist/types/plugin.d.mts +2 -2
- package/dist/types/runtime.d.mts +1 -1
- package/package.json +16 -14
- package/dist/create-reflection-resource-BtYlphp1.mjs +0 -17
- package/dist/create-reflection-resource-CdrQyUuT.cjs +0 -17
- package/dist/docs-CMoOO30q.mjs +0 -1
- package/dist/docs-DWXbRrEK.cjs +0 -1
- package/dist/env-Bwys2dqb.mjs +0 -31
- package/dist/env-mhFQyGk4.cjs +0 -34
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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`}.
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./create-reflection-resource-JGnGa1lq.cjs`),t=require(`./env-N-X_-s2s.cjs`),n=require(`./docs-ChC5Pu1X.cjs`);require(`./components-C9bYrQVK.cjs`),require(`./plugin-D5qyQPqC.cjs`),require(`./runtime-Bisl_1Ja.cjs`),require(`./types-MYBaygjr.cjs`);let r=require(`@alloy-js/core/jsx-runtime`),i=require(`@alloy-js/core`),a=require(`@alloy-js/rollup-plugin`);a=e.O(a);let o=require(`@storm-software/config-tools/types`),s=require(`@stryke/json/storm-json`),c=require(`@stryke/path/is-parent-path`),l=require(`@stryke/path/replace`),u=require(`@stryke/type-checks/is-set-string`),d=require(`prettier/doc.js`),f=require(`@stryke/path/append`),p=require(`defu`);p=e.O(p);let m=require(`@stryke/helpers/get-unique`),ee=require(`@stryke/type-checks/is-null`),h=require(`@stryke/type-checks/is-string`),g=require(`@stryke/type-checks/is-undefined`);require(`@stryke/capnp/compile`),require(`@stryke/capnp/helpers`);let _=require(`@stryke/convert/to-array`);require(`@stryke/json`);let v=require(`@stryke/path/join`),te=require(`@stryke/string-format/camel-case`);require(`@stryke/string-format/get-words`),require(`@stryke/string-format/pascal-case`);let y=require(`@stryke/string-format/title-case`);require(`@stryke/type-checks/is-bigint`),require(`@stryke/type-checks/is-number`);let ne=require(`node:child_process`),re=require(`node:util`),ie=require(`@alloy-js/typescript`),ae=require(`@alloy-js/markdown`);require(`@stryke/type-checks/is-boolean`);let b=require(`@stryke/path/join-paths`),oe=require(`@stryke/fs/is-file`),x=require(`@stryke/fs/list-files`),S=require(`@stryke/path/is-type`),C=require(`automd`),se=require(`c12`),w=require(`markdown-toc`);w=e.O(w);let ce=require(`@babel/core`),T=require(`@stryke/path/file-path-fns`),E=require(`@stryke/type-checks/is-set-object`),D=require(`@stryke/type-checks/is-function`);require(`@stryke/type-checks/is-object`);let O=require(`chalk`);O=e.O(O);let k=require(`@babel/generator`);k=e.O(k),require(`@babel/parser`);let le=require(`@babel/helper-plugin-utils`);require(`@storm-software/config-tools/logger`),require(`@storm-software/config-tools/utilities/colors`),require(`@stryke/helpers/noop`);let ue=require(`@stryke/string-format/kebab-case`),A=require(`@babel/types`);A=e.O(A);let j=require(`@stryke/convert/parse-type-definition`),de=require(`@stryke/env/types`),M=require(`@stryke/fs/exists`),fe=require(`@stryke/fs/helpers`),N=require(`@stryke/string-format/constant-case`),P=require(`@stryke/capnp`);P=e.O(P);let F=require(`@stryke/fs/buffer`),I=require(`node:fs`);const L=(0,i.createContext)();function R(e){let[{children:t,context:n,basePath:a},o]=(0,i.splitProps)(e,[`children`,`context`,`basePath`]),s=(0,i.ref)(n),c=(0,i.computed)(()=>a?(0,l.replacePath)(a,s.value.workspaceConfig.workspaceRoot):s.value.workspaceConfig.workspaceRoot);return(0,r.createComponent)(i.Output,(0,r.mergeProps)(o,{get basePath(){return c.value},get children(){return(0,r.createComponent)(L.Provider,{value:{ref:s},get children(){return(0,r.createComponent)(i.Show,{get when(){return!!s.value},children:t})}})}}))}const pe=(0,i.createContext)(),me=(0,i.createNamedContext)(`reflection-property`),he=(0,i.createNamedContext)(`reflection-method`),ge=(0,i.createNamedContext)(`reflection-parameter`);function z(e,t){return V(e.type,t??e.getDefaultValue())}function B(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function V(t,n){return(0,g.isUndefined)(n)?`undefined`:(0,ee.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,h.isString)(t.literal)?B(n):t.kind===e.D.ReflectionKind.enum?_e(t).kind===e.D.ReflectionKind.string?B(n):`${String(n)}`:t.kind===e.D.ReflectionKind.union?ye(t)?B(n):`${String(n)}`:t.kind===e.D.ReflectionKind.array?B(s.StormJSON.stringify(n)):t.kind===e.D.ReflectionKind.object||t.kind===e.D.ReflectionKind.objectLiteral?s.StormJSON.stringify(n):t.kind===e.D.ReflectionKind.property||t.kind===e.D.ReflectionKind.parameter?V(t.type,n):String(n)}function _e(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,h.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,h.isString)(n[0])?{kind:e.D.ReflectionKind.string}:{kind:e.D.ReflectionKind.number}}function ve(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 ye(t){return ve(t).some(t=>t.kind===e.D.ReflectionKind.string||t.kind===e.D.ReflectionKind.literal&&(0,h.isString)(t.literal))}const be=1024*1e6,xe=(0,re.promisify)(ne.exec),Se=(0,i.createNamedContext)(`markdown-table-column`,{}),Ce=(0,i.createContext)({columns:[],data:[]}),we=(e={})=>[{name:`alloy:config`,config(){return{alloy:{typescript:!0,...e},build:{inputOptions:{transform:{jsx:{runtime:`classic`,pragma:`Alloy.createElement`,importSource:`@alloy-js/core`}}},plugins:[(0,a.default)()],external:[`@alloy-js/core`,`@alloy-js/typescript`,`@alloy-js/json`,`@alloy-js/markdown`]}}},async configResolved(){(this.tsconfig.tsconfigJson.compilerOptions?.jsx!==`preserve`||this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource!==`@alloy-js/core`)&&(this.tsconfig.tsconfigJson.compilerOptions??={},this.tsconfig.tsconfigJson.compilerOptions.jsx!==`preserve`&&(this.tsconfig.tsconfigJson.compilerOptions.jsx=`preserve`),this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource!==`@alloy-js/core`&&(this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource=`@alloy-js/core`),await this.fs.write(this.tsconfig.tsconfigFilePath,s.StormJSON.stringify(this.tsconfig.tsconfigJson))),this.devDependencies[`@alloy-js/core`]=`^0.22.0`,this.config.alloy?.typescript!==!1&&(this.devDependencies[`@alloy-js/typescript`]=`^0.22.0`),this.config.alloy?.json===!0&&(this.devDependencies[`@alloy-js/json`]=`^0.22.0`),this.config.alloy?.markdown===!0&&(this.devDependencies[`@alloy-js/markdown`]=`^0.22.0`)}},{name:`alloy:update-context`,configResolved:{order:`pre`,async handler(){this.render=async e=>{let t=this,n=(0,i.renderTree)((0,r.createComponent)(R,{context:t,get basePath(){return t.workspaceConfig.workspaceRoot},children:e}));await Ee(this,n,this.config.alloy)}}}}];var Te=we;async function Ee(e,t,n={}){await(0,i.flushJobsAsync)();let r,a=async(t,s)=>{if(!Array.isArray(s))return;let u=async e=>{for(let t of s)await a(e,t)},d=(0,i.getContextForRenderNode)(s);if(!d)return u(t);if(d.meta?.directory){let e={kind:`directory`,path:d.meta.directory.path,contents:[]};t?t.contents.push(e):r=e,await u(e)}else if(d.meta?.sourceFile){if(!t)throw Error(`Source file doesn't have parent directory. Make sure you have used the Output component.`);let r;if(d.meta?.builtin){if(!d.meta.builtin.id)throw Error("Built-in runtime module doesn't have an ID. Make sure you have used the `<BuiltinFile />` component.");e.log(o.LogLevelLabel.TRACE,`Rendering built-in runtime module with ID: ${d.meta.builtin.id}`),r={kind:`builtin`,id:d.meta.builtin.id,path:(0,l.replacePath)(d.meta.sourceFile.path,e.builtinsPath),filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await H(e,s,n)}}else d.meta?.entry||(0,c.isParentPath)(e.entryPath,d.meta.sourceFile.path)?(e.log(o.LogLevelLabel.TRACE,`Rendering entry module at path: ${d.meta.sourceFile.path}`),r={kind:`entry`,typeDefinition:d.meta.entry?.typeDefinition,path:d.meta.sourceFile.path,filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await H(e,s,n)}):(e.log(o.LogLevelLabel.TRACE,`Rendering source file at path: ${d.meta.sourceFile.path}`),r={kind:`file`,path:d.meta.sourceFile.path,filetype:d.meta.sourceFile.filetype,preset:d.meta.output?.mode,contents:await H(e,s,n)});t.contents.push(r)}else if(d.meta?.copyFile){if(!t)throw Error(`Copy file doesn't have parent directory. Make sure you have used the Output component.`);if(e.log(o.LogLevelLabel.TRACE,`Processing copy file operation from "${d.meta.copyFile.sourcePath}" to "${d.meta.copyFile.path}"`),!d.meta.copyFile.sourcePath)throw Error("Copy file doesn't have a source path. Make sure you have provided a `sourcePath` property to the `meta.copyFile` context.");if(!d.meta.copyFile.path)throw Error("Copy file doesn't have a destination path. Make sure you have provided a `path` property to the `meta.copyFile` context.");t.contents.push({kind:`file`,path:d.meta.copyFile.path,sourcePath:d.meta.copyFile.sourcePath,preset:d.meta.output?.preset})}else await u(t)};await a(void 0,t);let s=async(e,t)=>{for(let n of t.contents)if(n.kind===`directory`)await s(e,n);else if(n.kind===`builtin`)await e.emitBuiltin(n.contents,n.id,n.path);else if(n.kind===`entry`)await e.emitEntry(n.contents,n.path,n.typeDefinition);else if(n.kind===`file`)if(`sourcePath`in n&&n.sourcePath){if(!e.fs.existsSync(n.sourcePath))throw Error(`Source file "${n.sourcePath}" for copy operation does not exist.`);let t=await e.fs.read(n.sourcePath);if(!(0,u.isSetString)(t))throw Error(`Source file "${n.sourcePath}" for copy operation is empty.`);await e.fs.write(n.path,t)}else if(`contents`in n&&(0,u.isSetString)(n.contents))await e.fs.write(n.path,n.contents);else throw Error(`Unexpected output extracted from the render tree: \n\n${JSON.stringify(n,null,2)}`)};await s(e,r)}async function H(e,t,n={}){n.printWidth??=160,n.tabWidth??=2,n.useTabs??=!1,n.insertFinalNewLine??=!0,await(0,i.flushJobsAsync)();let r=d.printer.printDocToString(U(t),n).formatted;return n.insertFinalNewLine&&!r.endsWith(`
|
|
2
|
+
`)?`${r}\n`:r}function U(e){let t=[];for(let n of e)if(typeof n==`string`){let e=n.split(/\r?\n/).flatMap((e,t,n)=>(n.length-1,[e]));t.push(e)}else (0,i.isPrintHook)(n)?t.push(n.print(n.subtree,U)):t.push(U(n));return t}const De=(e={})=>({name:`automd`,async config(){let t=await(0,C.loadConfig)((0,b.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=(0,_.toArray)(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:(0,p.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,_.toArray)(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=(0,_.toArray)(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await(0,se.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,C.resolveConfig)((0,p.default)(this.config.automd,{...e,prefix:(0,_.toArray)(e.prefix??[])}))}this.config.automd.input=(await Promise.all((0,_.toArray)(this.config.automd.input).map(async e=>e.includes(`*`)?(0,x.listFiles)((0,S.isAbsolutePath)(e)?e:(0,f.appendPath)(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):(0,S.isAbsolutePath)(e)?e:(0,f.appendPath)(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!(0,S.isAbsolutePath)(this.config.automd.output)&&(this.config.automd.output=(0,f.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,w.default)(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all((0,_.toArray)(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await(0,C.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,f.appendPath)(this.config.automd.output?(0,oe.isDirectory)(this.config.automd.output)?(0,l.replacePath)(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});var Oe=De;function W(e){return(0,u.isSetString)(e)?e:Array.isArray(e)&&e.length>0?W(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function G(e,t){return!!(W(t)&&e.some(e=>Array.isArray(e)&&W(e[0])===W(t)))}function K(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,D.isFunction)(t[0])?t[0](e):t[0]:(0,D.isFunction)(t)?t(e):t}catch{return t[0]}}function q(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&(0,D.isFunction)(r[2])&&!r[2](t,n)){e.log(o.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${O.default.bold.cyanBright(W(r)||`unnamed`)} for ${n}`);return}return r.length>2?[K(e,r),r[1],r[2]]:[K(e,r),r[1],null]}return[K(e,r),{},null]}let J=k.default;`default`in J&&(J=J.default);const Y=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#D8B4FE`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`,`#8B5CF6`],ke=(e,t)=>(n,...r)=>e(n,` ${O.default.inverse.hex(Y[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%Y.length]||Y[0])(` ${(0,y.titleCase)(t)} `)} ${r.join(` `)} `);function Ae(e,t){let n=n=>(0,le.declare)((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let s=ke(n.log,e);s(o.LogLevelLabel.TRACE,`Initializing the ${O.default.bold.cyanBright(e)} Babel plugin`);let c=t({log:s,name:e,api:r,options:i,context:n,dirname:a});return c.name=e,s(o.LogLevelLabel.TRACE,`Completed initialization of the ${O.default.bold.cyanBright(e)} Babel plugin`),c});return n.$$name=e,n}function X(e,t){Ne(e.scope.getProgramParent().path,t)}function je(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function Me(e){let t=new Map;return e.traverse({ImportDeclaration(e){je(e)&&t.set(e.node.source.value,e)}}),t}function Ne(e,t){Me(e).get(t.module)||e.unshiftContainer(`body`,A.importDeclaration([A.importSpecifier(A.identifier(t.name||t.imported),A.identifier(t.imported))],A.stringLiteral(t.module)))}const Pe=(e={})=>({name:`babel`,config(){if((0,E.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,p.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if((0,c.isParentPath)(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(o.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(o.LogLevelLabel.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>q(this,t,n,e)).filter((e,t,n)=>e&&!G(n,e)),i=this.config.transform.babel.presets.map(e=>q(this,t,n,e)).filter((e,t,n)=>e&&!G(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,T.findFileExtensionSafe)(n))&&!G(r,`@babel/plugin-syntax-typescript`)&&!G(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,T.findFileExtension)(n)===`.tsx`}]);let a=await(0,ce.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,p.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,p.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 Z=Pe;const Q=Ae(`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 s=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}_`,``))))),c=e.name;if(s&&(c=e.name.replace(`${s}_`,``)),t(o.LogLevelLabel.TRACE,`Environment variable ${c} found in ${r.filename||`unknown file`}.`),n.env.types.env?.hasProperty(c)||a.some(e=>e.getAlias().includes(c))){let e=n.env.types.env.hasProperty(c)?n.env.types.env.getProperty(c):a.find(e=>e.getAlias().includes(c));if(!e||e.isIgnored())return;if(n.env.used.env.hasProperty(c)||n.env.used.env.addProperty(e.property),n.config.env.inject&&i){let t=n.env.parsed?.[c];if(t===void 0){let e=n.config.env.prefix.find(e=>n.env.parsed[`${e.replace(/_$/g,``)}_${c}`]);e&&(t=n.env.parsed[`${e.replace(/_$/g,``)}_${c}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${c}\` is not defined in the .env configuration files`);return z(e,t)}}else throw Error(`The "${c}" environment variable is not defined in the \`env\` type definition, but is used in the source code file ${r.filename?r.filename:`unknown`}.
|
|
2
3
|
|
|
3
4
|
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
5
|
`)} \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}`),
|
|
6
|
+
`)} \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}`),X(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}`),X(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}`),X(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}`),X(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){t(o.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,I.existsSync)(i)&&(t(o.LogLevelLabel.TRACE,`Environment reflection file found at ${i}, reading existing reflection.`),r=(0,e.D.resolveClassType)((0,e.D.deserializeType)(e.E(new P.Message((0,F.readFileBufferSync)(i),!1).getRoot(e.T).types)))),t(o.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,C.defineGenerator)({name:`env`,async generate(){let t=(0,b.joinPaths)(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function Ie(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,y.titleCase)(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),r}const $=(n={})=>[Te(n.alloy),Z(n.babel),{name:`env`,async config(){this.log(o.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,p.default)(n,{types:{},prefix:[]}),transform:{babel:{plugins:[Q]}}};if(t.env.types)t.env.types=(0,j.parseTypeDefinition)(t.env.types);else{this.log(o.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,j.parseTypeDefinition)(`${n.file}#${n.name}`)}if(t.env.secrets)t.env.secrets=(0,j.parseTypeDefinition)(t.env.secrets);else{let n=await e.l(this);t.env.secrets=(0,j.parseTypeDefinition)(`${n.file}#${n.name}`)}return t.env.prefix=(0,_.toArray)(t.env.prefix??[]).reduce((e,t)=>{let n=(0,N.constantCase)(t);return e.includes(n)||e.push(n),e},[...de.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(o.LogLevelLabel.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=(0,p.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,M.existsSync)(e.c(this,`env`)))this.log(o.LogLevelLabel.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await e.d(this,`env`),(0,M.existsSync)(e.s(this,`env`))&&(this.env.used.env=await e.u(this)),(0,M.existsSync)(e.c(this,`secrets`))&&(this.env.types.secrets=await e.d(this,`secrets`)),(0,M.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,c.isParentPath)(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:(0,v.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,c.isParentPath)(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:(0,v.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(o.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(){let e=this;return this.log(o.LogLevelLabel.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render((0,r.createComponent)(t.t,{get defaultConfig(){return e.config.env.defaultConfig}}))},async docs(){this.log(o.LogLevelLabel.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let t=(0,v.joinPaths)(this.config.projectRoot,`docs`,`generated`);(0,M.existsSync)(t)||await(0,fe.createDirectory)(t);let n=await e.d(this,`env`),r=(0,v.joinPaths)(t,`env.md`);this.log(o.LogLevelLabel.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${(0,y.titleCase)(this.config.framework)||`Powerlines`} -->
|
|
6
7
|
|
|
7
8
|
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
9
|
|
|
@@ -11,4 +12,4 @@ Below is a list of environment variables used by the [${this.packageJson.name}](
|
|
|
11
12
|
${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
13
|
`,``)??``).trim()} | ${(0,e.D.stringifyType)(t.getType()).trim().replaceAll(` | `,`, or `)} | ${t.hasDefault()?String(t.getDefaultValue())?.includes(`"`)?t.getDefaultValue():`\`${t.getDefaultValue()}\``:``} | ${t.isValueRequired()?``:`✔`} |`).join(`
|
|
13
14
|
`)}
|
|
14
|
-
`)},async buildEnd(){let t=e.s(this,`env`);this.log(
|
|
15
|
+
`)},async buildEnd(){let t=e.s(this,`env`);this.log(o.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,p.default)(n.automd??{},{generators:{env:Fe(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},Oe(n.automd)];var Le=$;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=Ie,exports.default=Le,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,4 +1,4 @@
|
|
|
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-
|
|
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-Bub_SPEB.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";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
5
|
-
import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-
|
|
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-CbIYUQ4Z.mjs";
|
|
5
|
+
import { d as UnresolvedContext, i as __ΩSecretsInterface, l as Context, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "./runtime-AfBxUosz.mjs";
|
|
6
6
|
import "./index-DCQ5Y2ED.mjs";
|
|
7
|
-
import { DotenvParseOutput } from "@stryke/env/types";
|
|
8
7
|
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
8
|
+
import { DotenvParseOutput } from "@stryke/env/types";
|
|
9
9
|
import * as powerlines0 from "powerlines";
|
|
10
10
|
import { Plugin } from "powerlines";
|
|
11
11
|
import { TypeDefinition } from "@stryke/types/configuration";
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
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`}.
|
|
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 ee,i as te,l as f,m as p,n as m,o as h,p as ne,r as re,s as g,t as ie,u as _,v as ae,w as v,x as oe,y as se}from"./create-reflection-resource-B1734Oqz.mjs";import{n as ce,t as y}from"./env-Dco1ouC9.mjs";import{t as le}from"./docs-B_eQmaOI.mjs";import"./components-ByVHjWXF.mjs";import"./plugin-CyRU_Pln.mjs";import"./runtime-g_eXGBBi.mjs";import"./types-DMh7K7VC.mjs";import{createComponent as b,createIntrinsic as ue,memo as de,mergeProps as fe}from"@alloy-js/core/jsx-runtime";import{For as pe,Output as me,Show as he,code as ge,computed as _e,createContext as x,createNamedContext as S,flushJobsAsync as ve,getContextForRenderNode as ye,isPrintHook as be,ref as xe,renderTree as Se,splitProps as Ce}from"@alloy-js/core";import we from"@alloy-js/rollup-plugin";import{LogLevelLabel as C}from"@storm-software/config-tools/types";import{StormJSON as w}from"@stryke/json/storm-json";import{isParentPath as T}from"@stryke/path/is-parent-path";import{replacePath as E}from"@stryke/path/replace";import{isSetString as D}from"@stryke/type-checks/is-set-string";import{printer as Te}from"prettier/doc.js";import{appendPath as O}from"@stryke/path/append";import k from"defu";import{getUniqueBy as A}from"@stryke/helpers/get-unique";import{isNull as Ee}from"@stryke/type-checks/is-null";import{isString as j}from"@stryke/type-checks/is-string";import{isUndefined as De}from"@stryke/type-checks/is-undefined";import"@stryke/capnp/compile";import"@stryke/capnp/helpers";import{toArray as M}from"@stryke/convert/to-array";import"@stryke/json";import{joinPaths as N}from"@stryke/path/join";import{camelCase as Oe}from"@stryke/string-format/camel-case";import"@stryke/string-format/get-words";import"@stryke/string-format/pascal-case";import{titleCase as P}from"@stryke/string-format/title-case";import"@stryke/type-checks/is-bigint";import"@stryke/type-checks/is-number";import{exec as ke}from"node:child_process";import{promisify as Ae}from"node:util";import{VarDeclaration as je}from"@alloy-js/typescript";import{Link as Me}from"@alloy-js/markdown";import"@stryke/type-checks/is-boolean";import{joinPaths as F}from"@stryke/path/join-paths";import{isDirectory as Ne}from"@stryke/fs/is-file";import{listFiles as Pe}from"@stryke/fs/list-files";import{isAbsolutePath as I}from"@stryke/path/is-type";import{defineGenerator as Fe,loadConfig as Ie,resolveConfig as Le,transform as Re}from"automd";import{loadConfig as ze}from"c12";import Be from"markdown-toc";import{transformAsync as Ve}from"@babel/core";import{findFileExtension as He,findFileExtensionSafe as Ue}from"@stryke/path/file-path-fns";import{isSetObject as We}from"@stryke/type-checks/is-set-object";import{isFunction as L}from"@stryke/type-checks/is-function";import"@stryke/type-checks/is-object";import R from"chalk";import Ge from"@babel/generator";import"@babel/parser";import{declare as Ke}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 qe}from"@stryke/string-format/kebab-case";import*as z from"@babel/types";import{parseTypeDefinition as B}from"@stryke/convert/parse-type-definition";import{ENV_PREFIXES as Je}from"@stryke/env/types";import{existsSync as V}from"@stryke/fs/exists";import{createDirectory as Ye}from"@stryke/fs/helpers";import{constantCase as Xe}from"@stryke/string-format/constant-case";import*as Ze from"@stryke/capnp";import{readFileBufferSync as Qe}from"@stryke/fs/buffer";import{existsSync as $e}from"node:fs";const et=x();function tt(e){let[{children:t,context:n,basePath:r},i]=Ce(e,[`children`,`context`,`basePath`]),a=xe(n),o=_e(()=>r?E(r,a.value.workspaceConfig.workspaceRoot):a.value.workspaceConfig.workspaceRoot);return b(me,fe(i,{get basePath(){return o.value},get children(){return b(et.Provider,{value:{ref:a},get children(){return b(he,{get when(){return!!a.value},children:t})}})}}))}x(),S(`reflection-property`),S(`reflection-method`),S(`reflection-parameter`);function nt(e,t){return U(e.type,t??e.getDefaultValue())}function H(e){return`"${String(e).replaceAll(`"`,`\\"`)}"`}function U(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&&j(e.literal)?H(n):e.kind===t.ReflectionKind.enum?rt(e).kind===t.ReflectionKind.string?H(n):`${String(n)}`:e.kind===t.ReflectionKind.union?at(e)?H(n):`${String(n)}`:e.kind===t.ReflectionKind.array?H(w.stringify(n)):e.kind===t.ReflectionKind.object||e.kind===t.ReflectionKind.objectLiteral?w.stringify(n):e.kind===t.ReflectionKind.property||e.kind===t.ReflectionKind.parameter?U(e.type,n):String(n)}function rt(e){if(e.kind!==t.ReflectionKind.enum)throw Error(`Expected a TypeEnum, but received ${e.kind}.`);let n=A(e.values.filter(e=>e!=null),e=>j(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]&&j(n[0])?{kind:t.ReflectionKind.string}:{kind:t.ReflectionKind.number}}function it(e){if(e.kind===t.ReflectionKind.union&&e.types.length>0)return A(e.types,e=>e.kind);throw Error(`Expected a TypeUnion, but received ${e.kind}.`)}function at(e){return it(e).some(e=>e.kind===t.ReflectionKind.string||e.kind===t.ReflectionKind.literal&&j(e.literal))}Ae(ke),S(`markdown-table-column`,{}),x({columns:[],data:[]});var ot=(e={})=>[{name:`alloy:config`,config(){return{alloy:{typescript:!0,...e},build:{inputOptions:{transform:{jsx:{runtime:`classic`,pragma:`Alloy.createElement`,importSource:`@alloy-js/core`}}},plugins:[we()],external:[`@alloy-js/core`,`@alloy-js/typescript`,`@alloy-js/json`,`@alloy-js/markdown`]}}},async configResolved(){(this.tsconfig.tsconfigJson.compilerOptions?.jsx!==`preserve`||this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource!==`@alloy-js/core`)&&(this.tsconfig.tsconfigJson.compilerOptions??={},this.tsconfig.tsconfigJson.compilerOptions.jsx!==`preserve`&&(this.tsconfig.tsconfigJson.compilerOptions.jsx=`preserve`),this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource!==`@alloy-js/core`&&(this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource=`@alloy-js/core`),await this.fs.write(this.tsconfig.tsconfigFilePath,w.stringify(this.tsconfig.tsconfigJson))),this.devDependencies[`@alloy-js/core`]=`^0.22.0`,this.config.alloy?.typescript!==!1&&(this.devDependencies[`@alloy-js/typescript`]=`^0.22.0`),this.config.alloy?.json===!0&&(this.devDependencies[`@alloy-js/json`]=`^0.22.0`),this.config.alloy?.markdown===!0&&(this.devDependencies[`@alloy-js/markdown`]=`^0.22.0`)}},{name:`alloy:update-context`,configResolved:{order:`pre`,async handler(){this.render=async e=>{let t=this,n=Se(b(tt,{context:t,get basePath(){return t.workspaceConfig.workspaceRoot},children:e}));await st(this,n,this.config.alloy)}}}}];async function st(e,t,n={}){await ve();let r,i=async(t,a)=>{if(!Array.isArray(a))return;let o=async e=>{for(let t of a)await i(e,t)},s=ye(a);if(!s)return o(t);if(s.meta?.directory){let e={kind:`directory`,path:s.meta.directory.path,contents:[]};t?t.contents.push(e):r=e,await o(e)}else if(s.meta?.sourceFile){if(!t)throw Error(`Source file doesn't have parent directory. Make sure you have used the Output component.`);let r;if(s.meta?.builtin){if(!s.meta.builtin.id)throw Error("Built-in runtime module doesn't have an ID. Make sure you have used the `<BuiltinFile />` component.");e.log(C.TRACE,`Rendering built-in runtime module with ID: ${s.meta.builtin.id}`),r={kind:`builtin`,id:s.meta.builtin.id,path:E(s.meta.sourceFile.path,e.builtinsPath),filetype:s.meta.sourceFile.filetype,preset:s.meta.output?.mode,contents:await W(e,a,n)}}else s.meta?.entry||T(e.entryPath,s.meta.sourceFile.path)?(e.log(C.TRACE,`Rendering entry module at path: ${s.meta.sourceFile.path}`),r={kind:`entry`,typeDefinition:s.meta.entry?.typeDefinition,path:s.meta.sourceFile.path,filetype:s.meta.sourceFile.filetype,preset:s.meta.output?.mode,contents:await W(e,a,n)}):(e.log(C.TRACE,`Rendering source file at path: ${s.meta.sourceFile.path}`),r={kind:`file`,path:s.meta.sourceFile.path,filetype:s.meta.sourceFile.filetype,preset:s.meta.output?.mode,contents:await W(e,a,n)});t.contents.push(r)}else if(s.meta?.copyFile){if(!t)throw Error(`Copy file doesn't have parent directory. Make sure you have used the Output component.`);if(e.log(C.TRACE,`Processing copy file operation from "${s.meta.copyFile.sourcePath}" to "${s.meta.copyFile.path}"`),!s.meta.copyFile.sourcePath)throw Error("Copy file doesn't have a source path. Make sure you have provided a `sourcePath` property to the `meta.copyFile` context.");if(!s.meta.copyFile.path)throw Error("Copy file doesn't have a destination path. Make sure you have provided a `path` property to the `meta.copyFile` context.");t.contents.push({kind:`file`,path:s.meta.copyFile.path,sourcePath:s.meta.copyFile.sourcePath,preset:s.meta.output?.preset})}else await o(t)};await i(void 0,t);let a=async(e,t)=>{for(let n of t.contents)if(n.kind===`directory`)await a(e,n);else if(n.kind===`builtin`)await e.emitBuiltin(n.contents,n.id,n.path);else if(n.kind===`entry`)await e.emitEntry(n.contents,n.path,n.typeDefinition);else if(n.kind===`file`)if(`sourcePath`in n&&n.sourcePath){if(!e.fs.existsSync(n.sourcePath))throw Error(`Source file "${n.sourcePath}" for copy operation does not exist.`);let t=await e.fs.read(n.sourcePath);if(!D(t))throw Error(`Source file "${n.sourcePath}" for copy operation is empty.`);await e.fs.write(n.path,t)}else if(`contents`in n&&D(n.contents))await e.fs.write(n.path,n.contents);else throw Error(`Unexpected output extracted from the render tree: \n\n${JSON.stringify(n,null,2)}`)};await a(e,r)}async function W(e,t,n={}){n.printWidth??=160,n.tabWidth??=2,n.useTabs??=!1,n.insertFinalNewLine??=!0,await ve();let r=Te.printDocToString(G(t),n).formatted;return n.insertFinalNewLine&&!r.endsWith(`
|
|
2
|
+
`)?`${r}\n`:r}function G(e){let t=[];for(let n of e)if(typeof n==`string`){let e=n.split(/\r?\n/).flatMap((e,t,n)=>(n.length-1,[e]));t.push(e)}else be(n)?t.push(n.print(n.subtree,G)):t.push(G(n));return t}var ct=(e={})=>({name:`automd`,async config(){let t=await Ie(F(this.workspaceConfig.workspaceRoot,this.config.projectRoot),e);return(!t.prefix||!Array.isArray(t.prefix))&&(t.prefix=M(t.prefix??[])),t.prefix.includes(`automd`)||t.prefix.push(`automd`),t.prefix.includes(`powerlines`)||t.prefix.push(`powerlines`),{automd:k(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&&!M(this.config.automd.prefix).includes(this.config.framework)&&(this.config.automd.prefix=M(this.config.automd.prefix).concat(this.config.framework)),this.config.automd.configFile){let{config:e}=await ze({cwd:this.config.automd.dir,configFile:this.config.automd.configFile,defaults:{ignore:[`**/node_modules`,`**/dist`,`**/.*`],dir:this.config.automd.dir}});this.config.automd=Le(k(this.config.automd,{...e,prefix:M(e.prefix??[])}))}this.config.automd.input=(await Promise.all(M(this.config.automd.input).map(async e=>e.includes(`*`)?Pe(I(e)?e:O(e,this.config.projectRoot),{ignore:this.config.automd.ignore}):I(e)?e:O(e,this.config.projectRoot)))).flat(),this.config.automd.output&&!I(this.config.automd.output)&&(this.config.automd.output=O(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:Be(e.block.md,{...t,maxdepth:t.maxDepth,first1:t.firstH1}).content}}})},async docs(){await Promise.all(M(this.config.automd.input).map(async e=>{let t=await this.fs.read(e);if(t){let n=await Re(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(O(this.config.automd.output?Ne(this.config.automd.output)?E(e,this.config.automd.output):this.config.automd.output:e,this.config.projectRoot),n.contents)}}))}});function K(e){return D(e)?e:Array.isArray(e)&&e.length>0?K(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function q(e,t){return!!(K(t)&&e.some(e=>Array.isArray(e)&&K(e[0])===K(t)))}function J(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?L(t[0])?t[0](e):t[0]:L(t)?t(e):t}catch{return t[0]}}function Y(e,t,n,r){if(Array.isArray(r)&&r.length>0&&r[0]){if(r.length>2&&r[2]&&L(r[2])&&!r[2](t,n)){e.log(C.TRACE,`Skipping filtered Babel plugin ${R.bold.cyanBright(K(r)||`unnamed`)} for ${n}`);return}return r.length>2?[J(e,r),r[1],r[2]]:[J(e,r),r[1],null]}return[J(e,r),{},null]}let X=Ge;`default`in X&&(X=X.default);const Z=[`#00A0DD`,`#6FCE4E`,`#FBBF24`,`#F43F5E`,`#3B82F6`,`#A855F7`,`#469592`,`#288EDF`,`#D8B4FE`,`#10B981`,`#EF4444`,`#F0EC56`,`#F472B6`,`#22D3EE`,`#EAB308`,`#84CC16`,`#F87171`,`#0EA5E9`,`#D946EF`,`#FACC15`,`#34D399`,`#8B5CF6`],lt=(e,t)=>(n,...r)=>e(n,` ${R.inverse.hex(Z[t.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>e+t,0)%Z.length]||Z[0])(` ${P(t)} `)} ${r.join(` `)} `);function ut(e,t){let n=n=>Ke((r,i,a)=>{r.cache.using(()=>n.meta.checksum),r.assertVersion(`^7.0.0-0`);let o=lt(n.log,e);o(C.TRACE,`Initializing the ${R.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(C.TRACE,`Completed initialization of the ${R.bold.cyanBright(e)} Babel plugin`),s});return n.$$name=e,n}function Q(e,t){pt(e.scope.getProgramParent().path,t)}function dt(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function ft(e){let t=new Map;return e.traverse({ImportDeclaration(e){dt(e)&&t.set(e.node.source.value,e)}}),t}function pt(e,t){ft(e).get(t.module)||e.unshiftContainer(`body`,z.importDeclaration([z.importSpecifier(z.identifier(t.name||t.imported),z.identifier(t.imported))],z.stringLiteral(t.module)))}var mt=(e={})=>({name:`babel`,config(){if(We(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=k(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(t,n){if(T(n,this.powerlinesPath)||t.includes(`/* @storm-ignore */`)||t.includes(`/* @storm-disable */`))return this.log(C.TRACE,`Skipping Babel transformation for: ${n}`),{code:t,id:n};this.log(C.TRACE,`Babel transforming file: ${n}`);let r=this.config.transform.babel.plugins.map(e=>Y(this,t,n,e)).filter((e,t,n)=>e&&!q(n,e)),i=this.config.transform.babel.presets.map(e=>Y(this,t,n,e)).filter((e,t,n)=>e&&!q(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(Ue(n))&&!q(r,`@babel/plugin-syntax-typescript`)&&!q(i,`@babel/preset-typescript`)&&r.unshift([`@babel/plugin-syntax-typescript`,{isTSX:He(n)===`.tsx`}]);let a=await Ve(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],k(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:i.map(t=>Array.isArray(t)&&t.length>=2?[t[0],k(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}}});const ht=ut(`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(C.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 nt(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
3
|
|
|
3
4
|
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
5
|
`)} \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}`),
|
|
6
|
+
`)} \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}`),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;a(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;a(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;a(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),Q(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){e(C.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=g(r,`env`);o&&$e(o)&&(e(C.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),a=(0,t.resolveClassType)((0,t.deserializeType)(n(new Ze.Message(Qe(o),!1).getRoot(i).types)))),e(C.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()})})}}}),gt=e=>Fe({name:`env`,async generate(){let t=F(e.config.projectRoot,`docs`,`generated`,`env.md`);return e.fs.existsSync(t)?{contents:await e.fs.read(t)||``}:{contents:``}}});async function _t(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={})=>[ot(n.alloy),mt(n.babel),{name:`env`,async config(){this.log(C.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let e={env:k(n,{types:{},prefix:[]}),transform:{babel:{plugins:[ht]}}};if(e.env.types)e.env.types=B(e.env.types);else{this.log(C.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let t=await h(this);e.env.types=B(`${t.file}#${t.name}`)}if(e.env.secrets)e.env.secrets=B(e.env.secrets);else{let t=await f(this);e.env.secrets=B(`${t.file}#${t.name}`)}return e.env.prefix=M(e.env.prefix??[]).reduce((e,t)=>{let n=Xe(t);return e.includes(n)||e.push(n),e},[...Je,`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(C.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=k({parsed:await m(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&V(c(this,`env`)))this.log(C.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await l(this,`env`),V(g(this,`env`))&&(this.env.used.env=await _(this)),V(c(this,`secrets`))&&(this.env.types.secrets=await l(this,`secrets`)),V(g(this,`secrets`))&&(this.env.used.secrets=await u(this));else{if(this.env.types.env=await e(this,this.config.env.types?.file?T(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:N(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 v(this,this.config.env.secrets?.file?T(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:N(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(C.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 m(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 p(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 p(this,this.env.used.secrets,`secrets`))}},async prepare(){let e=this;return this.log(C.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),this.render(b(y,{get defaultConfig(){return e.config.env.defaultConfig}}))},async docs(){this.log(C.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=N(this.config.projectRoot,`docs`,`generated`);V(e)||await Ye(e);let n=await l(this,`env`),r=N(e,`env.md`);this.log(C.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by ${P(this.config.framework)||`Powerlines`} -->
|
|
6
7
|
|
|
7
8
|
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
9
|
|
|
@@ -11,4 +12,4 @@ Below is a list of environment variables used by the [${this.packageJson.name}](
|
|
|
11
12
|
${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
13
|
`,``)??``).trim()} | ${(0,t.stringifyType)(e.getType()).trim().replaceAll(` | `,`, or `)} | ${e.hasDefault()?String(e.getDefaultValue())?.includes(`"`)?e.getDefaultValue():`\`${e.getDefaultValue()}\``:``} | ${e.isValueRequired()?``:`✔`} |`).join(`
|
|
13
14
|
`)}
|
|
14
|
-
`)},async buildEnd(){let e=
|
|
15
|
+
`)},async buildEnd(){let e=g(this,`env`);this.log(C.TRACE,`Writing env reflection types to ${e}.`),await p(this,this.env.used.env,`env`)}},{name:`env:automd-generator`,config(){return{automd:k(n.automd??{},{generators:{env:gt(this)}})}}},{name:`env:vite`,vite:{configResolved(){return{envPrefix:this.config?.env?.prefix}}}},ct(n.automd)];var vt=$;export{a as BaseEnv,ae as BaseSecrets,y as EnvBuiltin,le as EnvDocs,ce as EnvTypeDefinition,se as createEnvReflection,ie as createReflectionResource,s as createSecretsReflection,_t as createTemplateReflection,vt as default,ht as envBabelPlugin,te as formatEnvField,h as getEnvDefaultTypeDefinition,g as getEnvReflectionsPath,c as getEnvTypeReflectionsPath,f as getSecretsDefaultTypeDefinition,m as loadEnv,re as loadEnvFromContext,oe as mergeEnvReflections,r as mergeSecretsReflections,$ as plugin,_ as readEnvReflection,l as readEnvTypeReflection,u as readSecretsReflection,e as reflectEnv,v as reflectSecrets,o as removeEnvPrefix,ne as resolveRuntimeTypeFile,p as writeEnvReflection,ee as writeEnvReflectionSync,d as writeEnvTypeReflection};
|
|
@@ -2,6 +2,7 @@ import { a as BabelResolvedConfig, c as UserConfig, n as SecretsInterface, o as
|
|
|
2
2
|
import { PrintTreeOptions } from "@alloy-js/core";
|
|
3
3
|
import { Children as Children$1 } from "@alloy-js/core/jsx-runtime";
|
|
4
4
|
import * as $ from "@stryke/capnp";
|
|
5
|
+
import "@alloy-js/typescript";
|
|
5
6
|
import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
6
7
|
import { Config } from "automd";
|
|
7
8
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
@@ -1594,6 +1595,9 @@ type AlloyPluginOptions = Partial<PrintTreeOptions> & {
|
|
|
1594
1595
|
*/
|
|
1595
1596
|
markdown?: boolean;
|
|
1596
1597
|
};
|
|
1598
|
+
type AlloyPluginUserConfig = UserConfig & {
|
|
1599
|
+
alloy?: AlloyPluginOptions;
|
|
1600
|
+
};
|
|
1597
1601
|
type AlloyPluginResolvedConfig = ResolvedConfig & {
|
|
1598
1602
|
alloy: AlloyPluginOptions;
|
|
1599
1603
|
};
|
|
@@ -1724,11 +1728,18 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
1724
1728
|
* The README.md file should contain the `<!-- automd:env --><!-- /automd -->` comment block where the documentation will be injected.
|
|
1725
1729
|
*/
|
|
1726
1730
|
automd?: AutoMDPluginOptions;
|
|
1731
|
+
/**
|
|
1732
|
+
* Alloy configuration options to use when injecting environment variables into the source code.
|
|
1733
|
+
*
|
|
1734
|
+
* @remarks
|
|
1735
|
+
* This option allows you to customize the Alloy transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Alloy settings.
|
|
1736
|
+
*/
|
|
1737
|
+
alloy?: AlloyPluginOptions;
|
|
1727
1738
|
};
|
|
1728
|
-
type EnvPluginUserConfig = BabelPluginUserConfig & {
|
|
1739
|
+
type EnvPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & {
|
|
1729
1740
|
env: EnvPluginOptions;
|
|
1730
1741
|
};
|
|
1731
|
-
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
1742
|
+
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & {
|
|
1732
1743
|
env: Required<Pick<DotenvConfiguration, "additionalFiles">> & Required<Pick<EnvPluginOptions, "defaultConfig">> & {
|
|
1733
1744
|
/**
|
|
1734
1745
|
* The type definition for the expected env variable parameters
|
|
@@ -1,10 +1,10 @@
|
|
|
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-
|
|
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-AfBxUosz.mjs";
|
|
2
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { PrintTreeOptions } from "@alloy-js/core";
|
|
4
|
+
import "@alloy-js/typescript";
|
|
2
5
|
import { Config } from "automd";
|
|
3
6
|
import { DotenvParseOutput } from "@stryke/env/types";
|
|
4
7
|
import * as $ from "@stryke/capnp";
|
|
5
|
-
import { PrintTreeOptions } from "@alloy-js/core";
|
|
6
|
-
import "@alloy-js/typescript";
|
|
7
|
-
import { Children as Children$1 } from "@alloy-js/core/jsx-runtime";
|
|
8
8
|
import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
9
9
|
|
|
10
10
|
//#region ../deepkit/src/vendor/type.d.ts
|
|
@@ -1595,11 +1595,14 @@ type AlloyPluginOptions = Partial<PrintTreeOptions> & {
|
|
|
1595
1595
|
*/
|
|
1596
1596
|
markdown?: boolean;
|
|
1597
1597
|
};
|
|
1598
|
+
type AlloyPluginUserConfig = UserConfig & {
|
|
1599
|
+
alloy?: AlloyPluginOptions;
|
|
1600
|
+
};
|
|
1598
1601
|
type AlloyPluginResolvedConfig = ResolvedConfig & {
|
|
1599
1602
|
alloy: AlloyPluginOptions;
|
|
1600
1603
|
};
|
|
1601
1604
|
type AlloyPluginContext<TResolvedConfig extends AlloyPluginResolvedConfig = AlloyPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
|
|
1602
|
-
render: <TContext extends AlloyPluginContext>(this: TContext, children: Children
|
|
1605
|
+
render: <TContext extends AlloyPluginContext>(this: TContext, children: Children) => Promise<void>;
|
|
1603
1606
|
};
|
|
1604
1607
|
//#endregion
|
|
1605
1608
|
//#region ../plugin-automd/src/types/toc.d.ts
|
|
@@ -1710,7 +1713,7 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
1710
1713
|
* @remarks
|
|
1711
1714
|
* 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.
|
|
1712
1715
|
*/
|
|
1713
|
-
defaultConfig?: Children
|
|
1716
|
+
defaultConfig?: Children;
|
|
1714
1717
|
/**
|
|
1715
1718
|
* Babel configuration options to use when injecting environment variables into the source code.
|
|
1716
1719
|
*
|
|
@@ -1725,11 +1728,18 @@ type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
|
1725
1728
|
* The README.md file should contain the `<!-- automd:env --><!-- /automd -->` comment block where the documentation will be injected.
|
|
1726
1729
|
*/
|
|
1727
1730
|
automd?: AutoMDPluginOptions;
|
|
1731
|
+
/**
|
|
1732
|
+
* Alloy configuration options to use when injecting environment variables into the source code.
|
|
1733
|
+
*
|
|
1734
|
+
* @remarks
|
|
1735
|
+
* This option allows you to customize the Alloy transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Alloy settings.
|
|
1736
|
+
*/
|
|
1737
|
+
alloy?: AlloyPluginOptions;
|
|
1728
1738
|
};
|
|
1729
|
-
type EnvPluginUserConfig = BabelPluginUserConfig & {
|
|
1739
|
+
type EnvPluginUserConfig = BabelPluginUserConfig & AlloyPluginUserConfig & {
|
|
1730
1740
|
env: EnvPluginOptions;
|
|
1731
1741
|
};
|
|
1732
|
-
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
1742
|
+
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & AlloyPluginResolvedConfig & {
|
|
1733
1743
|
env: Required<Pick<DotenvConfiguration, "additionalFiles">> & Required<Pick<EnvPluginOptions, "defaultConfig">> & {
|
|
1734
1744
|
/**
|
|
1735
1745
|
* The type definition for the expected env variable parameters
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
1
2
|
import "c12";
|
|
2
3
|
import { PluginItem, PluginObj, PluginPass, transformAsync } from "@babel/core";
|
|
3
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
4
4
|
import { BabelAPI } from "@babel/helper-plugin-utils";
|
|
5
5
|
import { ResolveOptions } from "@stryke/fs/resolve";
|
|
6
6
|
import "esbuild";
|
package/dist/types/index.d.cts
CHANGED
|
@@ -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-
|
|
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-Bub_SPEB.cjs";
|
|
2
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 };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -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-
|
|
2
|
-
import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-
|
|
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-CbIYUQ4Z.mjs";
|
|
2
|
+
import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-AfBxUosz.mjs";
|
|
3
3
|
import "../index-DCQ5Y2ED.mjs";
|
|
4
4
|
export { EnvInterface, EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, SecretsInterface, __ΩEnvInterface, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType, __ΩSecretsInterface };
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -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-
|
|
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-Bub_SPEB.cjs";
|
|
2
2
|
import "../runtime-rhT2IfSg.cjs";
|
|
3
3
|
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType };
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -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-
|
|
2
|
-
import "../runtime-
|
|
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-CbIYUQ4Z.mjs";
|
|
2
|
+
import "../runtime-AfBxUosz.mjs";
|
|
3
3
|
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig, EnvType, __ΩEnvPluginContext, __ΩEnvPluginOptions, __ΩEnvPluginResolvedConfig, __ΩEnvPluginUserConfig, __ΩEnvType };
|
package/dist/types/runtime.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-
|
|
1
|
+
import { i as __ΩSecretsInterface, n as SecretsInterface, r as __ΩEnvInterface, t as EnvInterface } from "../runtime-AfBxUosz.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.
|
|
3
|
+
"version": "0.14.9",
|
|
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": {
|
|
@@ -187,16 +187,17 @@
|
|
|
187
187
|
"files": ["dist/**/*"],
|
|
188
188
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
189
189
|
"dependencies": {
|
|
190
|
-
"
|
|
191
|
-
"@alloy-js/
|
|
192
|
-
"@alloy-js/typescript": "^0.
|
|
193
|
-
"@alloy-js/
|
|
190
|
+
"@alloy-js/core": "^0.22.0",
|
|
191
|
+
"@alloy-js/markdown": "^0.22.0",
|
|
192
|
+
"@alloy-js/typescript": "^0.22.0",
|
|
193
|
+
"@alloy-js/json": "^0.22.0",
|
|
194
194
|
"@babel/core": "^7.28.5",
|
|
195
195
|
"@babel/types": "^7.28.5",
|
|
196
|
-
"@powerlines/
|
|
197
|
-
"@powerlines/plugin-
|
|
198
|
-
"@powerlines/plugin-
|
|
199
|
-
"@powerlines/plugin-
|
|
196
|
+
"@powerlines/deepkit": "^0.5.21",
|
|
197
|
+
"@powerlines/plugin-alloy": "^0.15.3",
|
|
198
|
+
"@powerlines/plugin-automd": "^0.1.106",
|
|
199
|
+
"@powerlines/plugin-babel": "^0.12.115",
|
|
200
|
+
"@powerlines/plugin-plugin": "^0.12.58",
|
|
200
201
|
"@storm-software/config-tools": "^1.188.74",
|
|
201
202
|
"@stryke/capnp": "^0.12.51",
|
|
202
203
|
"@stryke/env": "^0.20.43",
|
|
@@ -205,18 +206,19 @@
|
|
|
205
206
|
"@stryke/string-format": "^0.12.29",
|
|
206
207
|
"@stryke/type-checks": "^0.5.14",
|
|
207
208
|
"@stryke/types": "^0.10.28",
|
|
208
|
-
"
|
|
209
|
+
"automd": "^0.4.2",
|
|
210
|
+
"powerlines": "^0.36.11"
|
|
209
211
|
},
|
|
210
212
|
"devDependencies": {
|
|
211
213
|
"@alloy-js/babel-preset": "^0.2.1",
|
|
212
214
|
"@babel/preset-typescript": "^7.28.5",
|
|
213
|
-
"@powerlines/
|
|
214
|
-
"@powerlines/plugin-
|
|
215
|
-
"@powerlines/
|
|
215
|
+
"@powerlines/nx": "^0.11.37",
|
|
216
|
+
"@powerlines/plugin-alloy": "^0.15.3",
|
|
217
|
+
"@powerlines/plugin-plugin": "^0.12.58",
|
|
216
218
|
"@types/node": "^24.10.4",
|
|
217
219
|
"typescript": "^5.9.3",
|
|
218
220
|
"vite": "8.0.0-beta.2"
|
|
219
221
|
},
|
|
220
222
|
"publishConfig": { "access": "public" },
|
|
221
|
-
"gitHead": "
|
|
223
|
+
"gitHead": "298fe30390297c676ffd571284b2b62f10d8ecc9"
|
|
222
224
|
}
|