@powerlines/plugin-crypto 0.10.32 → 0.10.33
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/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/{chunk-X42XA8SV.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/alloy/src/core/components/output.cjs +1 -0
- package/dist/alloy/src/core/components/output.mjs +1 -0
- package/dist/alloy/src/core/components/single-line-comment.cjs +1 -0
- package/dist/alloy/src/core/components/single-line-comment.mjs +1 -0
- package/dist/alloy/src/core/components/source-file.cjs +1 -0
- package/dist/alloy/src/core/components/source-file.mjs +1 -0
- package/dist/alloy/src/core/contexts/context.cjs +1 -0
- package/dist/alloy/src/core/contexts/context.mjs +1 -0
- package/dist/alloy/src/core/contexts/reflection.cjs +1 -0
- package/dist/alloy/src/core/contexts/reflection.mjs +1 -0
- package/dist/alloy/src/create-plugin.cjs +2 -0
- package/dist/alloy/src/create-plugin.mjs +2 -0
- package/dist/alloy/src/helpers/refkey.cjs +1 -0
- package/dist/alloy/src/helpers/refkey.mjs +1 -0
- package/dist/alloy/src/markdown/components/markdown-file.cjs +1 -0
- package/dist/alloy/src/markdown/components/markdown-file.mjs +1 -0
- package/dist/alloy/src/markdown/components/markdown-table.cjs +1 -0
- package/dist/alloy/src/markdown/components/markdown-table.mjs +1 -0
- package/dist/alloy/src/markdown/contexts/markdown-table.cjs +1 -0
- package/dist/alloy/src/markdown/contexts/markdown-table.mjs +1 -0
- package/dist/alloy/src/typescript/components/builtin-file.cjs +1 -0
- package/dist/alloy/src/typescript/components/builtin-file.mjs +1 -0
- package/dist/alloy/src/typescript/components/tsdoc-reflection.cjs +1 -0
- package/dist/alloy/src/typescript/components/tsdoc-reflection.mjs +1 -0
- package/dist/alloy/src/typescript/components/tsdoc.cjs +1 -0
- package/dist/alloy/src/typescript/components/tsdoc.mjs +1 -0
- package/dist/alloy/src/typescript/components/typescript-file.cjs +1 -0
- package/dist/alloy/src/typescript/components/typescript-file.mjs +1 -0
- package/dist/alloy/src/typescript/components/typescript-interface.cjs +1 -0
- package/dist/alloy/src/typescript/components/typescript-interface.mjs +1 -0
- package/dist/alloy/src/typescript/components/typescript-object.cjs +1 -0
- package/dist/alloy/src/typescript/components/typescript-object.mjs +1 -0
- package/dist/components/crypto.cjs +133 -0
- package/dist/components/crypto.d.cts +13 -0
- package/dist/components/crypto.d.mts +13 -0
- package/dist/components/crypto.mjs +133 -0
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.mts +1 -0
- package/dist/components/index.mjs +1 -0
- package/dist/deepkit/schemas/reflection.cjs +1 -0
- package/dist/deepkit/schemas/reflection.d.cts +1560 -0
- package/dist/deepkit/schemas/reflection.d.mts +1560 -0
- package/dist/deepkit/schemas/reflection.mjs +1 -0
- package/dist/deepkit/schemas/reflection2.cjs +1 -0
- package/dist/deepkit/schemas/reflection2.mjs +1 -0
- package/dist/deepkit/src/capnp.cjs +1 -0
- package/dist/deepkit/src/capnp.mjs +1 -0
- package/dist/deepkit/src/reflect-type.cjs +1 -0
- package/dist/deepkit/src/reflect-type.mjs +1 -0
- package/dist/deepkit/src/resolve-reflections.cjs +1 -0
- package/dist/deepkit/src/resolve-reflections.mjs +1 -0
- package/dist/deepkit/src/types.d.cts +10 -0
- package/dist/deepkit/src/types.d.mts +10 -0
- package/dist/deepkit/src/utilities.cjs +1 -0
- package/dist/deepkit/src/utilities.mjs +1 -0
- package/dist/deepkit/src/vendor/type.cjs +1 -0
- package/dist/deepkit/src/vendor/type.d.cts +7 -0
- package/dist/deepkit/src/vendor/type.d.mts +7 -0
- package/dist/deepkit/src/vendor/type.mjs +1 -0
- package/dist/index.cjs +1 -208
- package/dist/index.d.cts +4 -12
- package/dist/index.d.mts +5 -12
- package/dist/index.mjs +1 -205
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +1 -0
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +1 -0
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +1 -0
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +1 -0
- package/dist/plugin-babel/src/helpers/filters.cjs +1 -0
- package/dist/plugin-babel/src/helpers/filters.mjs +1 -0
- package/dist/plugin-babel/src/helpers/index.cjs +1 -0
- package/dist/plugin-babel/src/helpers/index.mjs +1 -0
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +1 -0
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +1 -0
- package/dist/plugin-babel/src/helpers/options.cjs +1 -0
- package/dist/plugin-babel/src/helpers/options.mjs +1 -0
- package/dist/plugin-babel/src/index.cjs +1 -0
- package/dist/plugin-babel/src/index.mjs +1 -0
- package/dist/plugin-babel/src/types/index.d.mts +1 -0
- package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
- package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
- package/dist/plugin-env/src/babel/index.cjs +1 -0
- package/dist/plugin-env/src/babel/index.mjs +1 -0
- package/dist/plugin-env/src/babel/plugin.cjs +5 -0
- package/dist/plugin-env/src/babel/plugin.mjs +5 -0
- package/dist/plugin-env/src/components/docs.cjs +1 -0
- package/dist/plugin-env/src/components/docs.mjs +1 -0
- package/dist/plugin-env/src/components/env.cjs +34 -0
- package/dist/plugin-env/src/components/env.mjs +31 -0
- package/dist/plugin-env/src/components/index.cjs +1 -0
- package/dist/plugin-env/src/components/index.mjs +1 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +1 -0
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +1 -0
- package/dist/plugin-env/src/helpers/index.cjs +1 -0
- package/dist/plugin-env/src/helpers/index.mjs +1 -0
- package/dist/plugin-env/src/helpers/load.cjs +1 -0
- package/dist/plugin-env/src/helpers/load.mjs +1 -0
- package/dist/plugin-env/src/helpers/persistence.cjs +1 -0
- package/dist/plugin-env/src/helpers/persistence.mjs +1 -0
- package/dist/plugin-env/src/helpers/reflect.cjs +1 -0
- package/dist/plugin-env/src/helpers/reflect.mjs +1 -0
- package/dist/plugin-env/src/helpers/source-file-env.cjs +1 -0
- package/dist/plugin-env/src/helpers/source-file-env.mjs +1 -0
- package/dist/plugin-env/src/helpers/template-helpers.cjs +1 -0
- package/dist/plugin-env/src/helpers/template-helpers.mjs +1 -0
- package/dist/plugin-env/src/index.cjs +16 -0
- package/dist/plugin-env/src/index.mjs +16 -0
- package/dist/plugin-env/src/types/plugin.d.cts +135 -0
- package/dist/plugin-env/src/types/plugin.d.mts +136 -0
- package/dist/plugin-env/src/types/runtime.d.cts +792 -0
- package/dist/plugin-env/src/types/runtime.d.mts +792 -0
- package/dist/powerlines/src/lib/build/esbuild.cjs +14 -0
- package/dist/powerlines/src/lib/build/esbuild.mjs +14 -0
- package/dist/powerlines/src/lib/entry.cjs +1 -0
- package/dist/powerlines/src/lib/entry.mjs +1 -0
- package/dist/powerlines/src/lib/logger.cjs +1 -0
- package/dist/powerlines/src/lib/logger.mjs +1 -0
- package/dist/powerlines/src/lib/utilities/bundle.cjs +1 -0
- package/dist/powerlines/src/lib/utilities/bundle.mjs +1 -0
- package/dist/powerlines/src/lib/utilities/file-header.cjs +10 -0
- package/dist/powerlines/src/lib/utilities/file-header.mjs +10 -0
- package/dist/powerlines/src/lib/utilities/resolve.cjs +1 -0
- package/dist/powerlines/src/lib/utilities/resolve.mjs +1 -0
- package/dist/powerlines/src/plugin-utils/helpers.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/helpers.mjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
- package/dist/powerlines/src/plugin-utils/paths.mjs +1 -0
- package/dist/powerlines/src/types/babel.d.cts +22 -0
- package/dist/powerlines/src/types/babel.d.mts +22 -0
- package/dist/powerlines/src/types/build.d.cts +139 -0
- package/dist/powerlines/src/types/build.d.mts +139 -0
- package/dist/powerlines/src/types/commands.d.cts +8 -0
- package/dist/powerlines/src/types/commands.d.mts +9 -0
- package/dist/powerlines/src/types/config.d.cts +356 -0
- package/dist/powerlines/src/types/config.d.mts +357 -0
- package/dist/powerlines/src/types/context.d.cts +358 -0
- package/dist/powerlines/src/types/context.d.mts +360 -0
- package/dist/powerlines/src/types/fs.d.cts +458 -0
- package/dist/powerlines/src/types/fs.d.mts +458 -0
- package/dist/powerlines/src/types/hooks.d.mts +2 -0
- package/dist/powerlines/src/types/plugin.d.cts +232 -0
- package/dist/powerlines/src/types/plugin.d.mts +232 -0
- package/dist/powerlines/src/types/resolved.d.cts +82 -0
- package/dist/powerlines/src/types/resolved.d.mts +82 -0
- package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
- package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
- package/dist/types/index.cjs +0 -1
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +41 -1
- package/dist/types/plugin.d.mts +41 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +8 -8
- package/dist/index-CEgs-Dz2.d.cts +0 -1
- package/dist/index-D9zIjQH9.d.mts +0 -1
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/plugin-DzeYlbKJ.mjs +0 -1
- package/dist/plugin-Eengqhgj.d.mts +0 -4207
- package/dist/plugin-QQeJHnEx.d.cts +0 -4208
- package/dist/types-BKeuN6sy.mjs +0 -1
- package/dist/types-DHkg7xmX.cjs +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@babel/generator`);t=e.__toESM(t),require(`@babel/parser`);let n=t.default;`default`in n&&(n=n.default);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@babel/generator";import"@babel/parser";let t=e;`default`in t&&(t=t.default);export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../powerlines/src/lib/logger.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`chalk`);r=e.__toESM(r);let i=require(`@babel/helper-plugin-utils`);function a(e,a){let o=o=>(0,i.declare)((i,s,c)=>{i.cache.using(()=>o.meta.checksum),i.assertVersion(`^7.0.0-0`);let l=t.extendLog(o.log,e);l(n.LogLevelLabel.TRACE,`Initializing the ${r.default.bold.cyanBright(e)} Babel plugin`);let u=a({log:l,name:e,api:i,options:s,context:o,dirname:c});return u.name=e,l(n.LogLevelLabel.TRACE,`Completed initialization of the ${r.default.bold.cyanBright(e)} Babel plugin`),u});return o.$$name=e,o}exports.createBabelPlugin=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{extendLog as e}from"../../../powerlines/src/lib/logger.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import n from"chalk";import{declare as r}from"@babel/helper-plugin-utils";function i(i,a){let o=o=>r((r,s,c)=>{r.cache.using(()=>o.meta.checksum),r.assertVersion(`^7.0.0-0`);let l=e(o.log,i);l(t.TRACE,`Initializing the ${n.bold.cyanBright(i)} Babel plugin`);let u=a({log:l,name:i,api:r,options:s,context:o,dirname:c});return u.name=i,l(t.TRACE,`Completed initialization of the ${n.bold.cyanBright(i)} Babel plugin`),u});return o.$$name=i,o}export{i as createBabelPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/type-checks/is-set-string`),n=require(`@stryke/type-checks/is-function`);require(`@stryke/type-checks/is-object`);function r(e){return(0,t.isSetString)(e)?e:Array.isArray(e)&&e.length>0?r(e[0]):e.$$name||e.name?e.$$name||e.name:void 0}function i(e,t){return!!(r(t)&&e.some(e=>Array.isArray(e)&&r(e[0])===r(t)))}exports.getPluginName=r,exports.isDuplicatePlugin=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isSetString as e}from"@stryke/type-checks/is-set-string";import{isFunction as t}from"@stryke/type-checks/is-function";import"@stryke/type-checks/is-object";function n(t){return e(t)?t:Array.isArray(t)&&t.length>0?n(t[0]):t.$$name||t.name?t.$$name||t.name:void 0}function r(e,t){return!!(n(t)&&e.some(e=>Array.isArray(e)&&n(e[0])===n(t)))}export{n as getPluginName,r as isDuplicatePlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./filters.cjs`),t=require(`./options.cjs`);require(`./ast-utils.cjs`);const n=require(`./create-plugin.cjs`),r=require(`./module-helpers.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPluginName as e,isDuplicatePlugin as t}from"./filters.mjs";import{resolveBabelPlugin as n,resolvePluginFunction as r}from"./options.mjs";import"./ast-utils.mjs";import{createBabelPlugin as i}from"./create-plugin.mjs";import{addImport as a,addImportsToProgram as o}from"./module-helpers.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);require(`./ast-utils.cjs`);let t=require(`@babel/types`);t=e.__toESM(t);let n=require(`@stryke/type-checks/is-string`);function r(e,t){o(e.scope.getProgramParent().path,t)}function i(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function a(e){let t=new Map;return e.traverse({ImportDeclaration(e){i(e)&&t.set(e.node.source.value,e)}}),t}function o(e,n){a(e).get(n.module)||e.unshiftContainer(`body`,t.importDeclaration([t.importSpecifier(t.identifier(n.name||n.imported),t.identifier(n.imported))],t.stringLiteral(n.module)))}exports.addImport=r,exports.addImportsToProgram=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./ast-utils.mjs";import*as e from"@babel/types";import{isString as t}from"@stryke/type-checks/is-string";function n(e,t){a(e.scope.getProgramParent().path,t)}function r(e){return e.get(`specifiers`).filter(Boolean).every(e=>e?.isImportSpecifier())&&e.node.importKind!==`type`&&e.node.importKind!==`typeof`}function i(e){let t=new Map;return e.traverse({ImportDeclaration(e){r(e)&&t.set(e.node.source.value,e)}}),t}function a(t,n){i(t).get(n.module)||t.unshiftContainer(`body`,e.importDeclaration([e.importSpecifier(e.identifier(n.name||n.imported),e.identifier(n.imported))],e.stringLiteral(n.module)))}export{n as addImport,a as addImportsToProgram};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`./filters.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`@stryke/type-checks/is-function`),i=require(`chalk`);i=e.__toESM(i);function a(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?(0,r.isFunction)(t[0])?t[0](e):t[0]:(0,r.isFunction)(t)?t(e):t}catch{return t[0]}}function o(e,o,s,c){if(Array.isArray(c)&&c.length>0&&c[0]){if(c.length>2&&c[2]&&(0,r.isFunction)(c[2])&&!c[2](o,s)){e.log(n.LogLevelLabel.TRACE,`Skipping filtered Babel plugin ${i.default.bold.cyanBright(t.getPluginName(c)||`unnamed`)} for ${s}`);return}return c.length>2?[a(e,c),c[1],c[2]]:[a(e,c),c[1],null]}return[a(e,c),{},null]}exports.resolveBabelPlugin=o,exports.resolvePluginFunction=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPluginName as e}from"./filters.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import{isFunction as n}from"@stryke/type-checks/is-function";import r from"chalk";function i(e,t){try{return Array.isArray(t)&&t.length>0&&t[0]?n(t[0])?t[0](e):t[0]:n(t)?t(e):t}catch{return t[0]}}function a(a,o,s,c){if(Array.isArray(c)&&c.length>0&&c[0]){if(c.length>2&&c[2]&&n(c[2])&&!c[2](o,s)){a.log(t.TRACE,`Skipping filtered Babel plugin ${r.bold.cyanBright(e(c)||`unnamed`)} for ${s}`);return}return c.length>2?[i(a,c),c[1],c[2]]:[i(a,c),c[1],null]}return[i(a,c),{},null]}export{a as resolveBabelPlugin,i as resolvePluginFunction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`./helpers/filters.cjs`),n=require(`./helpers/options.cjs`),r=require(`./helpers/create-plugin.cjs`),i=require(`./helpers/module-helpers.cjs`);require(`./helpers/index.cjs`);let a=require(`@storm-software/config-tools/types`),o=require(`@stryke/path/is-parent-path`),s=require(`@stryke/type-checks/is-set-object`),c=require(`@babel/core`),l=require(`@stryke/path/file-path-fns`),u=require(`defu`);u=e.__toESM(u);const d=(e={})=>({name:`babel`,config(){if((0,s.isSetObject)(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=(0,u.default)(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(r,i){if((0,o.isParentPath)(i,this.powerlinesPath)||r.includes(`/* @storm-ignore */`)||r.includes(`/* @storm-disable */`))return this.log(a.LogLevelLabel.TRACE,`Skipping Babel transformation for: ${i}`),{code:r,id:i};this.log(a.LogLevelLabel.TRACE,`Babel transforming file: ${i}`);let s=this.config.transform.babel.plugins.map(e=>n.resolveBabelPlugin(this,r,i,e)).filter((e,n,r)=>e&&!t.isDuplicatePlugin(r,e)),d=this.config.transform.babel.presets.map(e=>n.resolveBabelPlugin(this,r,i,e)).filter((e,n,r)=>e&&!t.isDuplicatePlugin(r,e));if(Array.isArray(s)&&s.length===0&&Array.isArray(d)&&d.length===0)return{code:r,id:i};[`ts`,`cts`,`mts`,`tsx`].includes((0,l.findFileExtensionSafe)(i))&&!t.isDuplicatePlugin(s,`@babel/plugin-syntax-typescript`)&&!t.isDuplicatePlugin(d,`@babel/preset-typescript`)&&s.unshift([`@babel/plugin-syntax-typescript`,{isTSX:(0,l.findFileExtension)(i)===`.tsx`}]);let f=await(0,c.transformAsync)(r,{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:i,plugins:s.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,u.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:d.map(t=>Array.isArray(t)&&t.length>=2?[t[0],(0,u.default)(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!f?.code)throw Error(`Powerlines - Babel plugin failed to compile ${i}`);return{code:f.code,id:i}}});var f=d;exports.default=f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPluginName as e,isDuplicatePlugin as t}from"./helpers/filters.mjs";import{resolveBabelPlugin as n,resolvePluginFunction as r}from"./helpers/options.mjs";import{createBabelPlugin as i}from"./helpers/create-plugin.mjs";import{addImport as a,addImportsToProgram as o}from"./helpers/module-helpers.mjs";import"./helpers/index.mjs";import{LogLevelLabel as s}from"@storm-software/config-tools/types";import{isParentPath as c}from"@stryke/path/is-parent-path";import{isSetObject as l}from"@stryke/type-checks/is-set-object";import{transformAsync as u}from"@babel/core";import{findFileExtension as d,findFileExtensionSafe as f}from"@stryke/path/file-path-fns";import p from"defu";var m=(e={})=>({name:`babel`,config(){if(l(e))return{transform:{babel:e}}},configResolved:{order:`pre`,handler(){this.devDependencies[`@babel/core`]=`^7.28.4`,this.config.transform.babel=p(this.config.transform.babel??{},{plugins:[],presets:[]})}},async transform(r,i){if(c(i,this.powerlinesPath)||r.includes(`/* @storm-ignore */`)||r.includes(`/* @storm-disable */`))return this.log(s.TRACE,`Skipping Babel transformation for: ${i}`),{code:r,id:i};this.log(s.TRACE,`Babel transforming file: ${i}`);let a=this.config.transform.babel.plugins.map(e=>n(this,r,i,e)).filter((e,n,r)=>e&&!t(r,e)),o=this.config.transform.babel.presets.map(e=>n(this,r,i,e)).filter((e,n,r)=>e&&!t(r,e));if(Array.isArray(a)&&a.length===0&&Array.isArray(o)&&o.length===0)return{code:r,id:i};[`ts`,`cts`,`mts`,`tsx`].includes(f(i))&&!t(a,`@babel/plugin-syntax-typescript`)&&!t(o,`@babel/preset-typescript`)&&a.unshift([`@babel/plugin-syntax-typescript`,{isTSX:d(i)===`.tsx`}]);let l=await u(r,{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:i,plugins:a.map(t=>Array.isArray(t)&&t.length>=2?[t[0],p(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean),presets:o.map(t=>Array.isArray(t)&&t.length>=2?[t[0],p(t.length>1&&t[1]?t[1]:{},{options:e})]:t).filter(Boolean)});if(!l?.code)throw Error(`Powerlines - Babel plugin failed to compile ${i}`);return{code:l.code,id:i}}});export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "./plugin.mjs";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BabelUserConfig, UserConfig } from "../../../powerlines/src/types/config.cjs";
|
|
2
|
+
import { BabelResolvedConfig, ResolvedConfig } from "../../../powerlines/src/types/resolved.cjs";
|
|
3
|
+
import { PluginContext } from "../../../powerlines/src/types/context.cjs";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-babel/src/types/plugin.d.ts
|
|
6
|
+
type BabelPluginOptions = Partial<BabelUserConfig>;
|
|
7
|
+
type BabelPluginUserConfig = UserConfig;
|
|
8
|
+
interface BabelPluginResolvedConfig extends ResolvedConfig {
|
|
9
|
+
transform: {
|
|
10
|
+
babel: BabelResolvedConfig;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type BabelPluginContext<TResolvedConfig extends BabelPluginResolvedConfig = BabelPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BabelUserConfig, UserConfig } from "../../../powerlines/src/types/config.mjs";
|
|
2
|
+
import { BabelResolvedConfig, ResolvedConfig } from "../../../powerlines/src/types/resolved.mjs";
|
|
3
|
+
import { PluginContext } from "../../../powerlines/src/types/context.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-babel/src/types/plugin.d.ts
|
|
6
|
+
type BabelPluginOptions = Partial<BabelUserConfig>;
|
|
7
|
+
type BabelPluginUserConfig = UserConfig;
|
|
8
|
+
interface BabelPluginResolvedConfig extends ResolvedConfig {
|
|
9
|
+
transform: {
|
|
10
|
+
babel: BabelResolvedConfig;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
type BabelPluginContext<TResolvedConfig extends BabelPluginResolvedConfig = BabelPluginResolvedConfig> = PluginContext<TResolvedConfig>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./plugin.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{envBabelPlugin as e}from"./plugin.mjs";export{};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../deepkit/src/vendor/type.cjs`),n=require(`../../../plugin-babel/src/helpers/create-plugin.cjs`),r=require(`../../../plugin-babel/src/helpers/module-helpers.cjs`),i=require(`../../../deepkit/src/capnp.cjs`),a=require(`../../../deepkit/schemas/reflection2.cjs`),o=require(`../../../deepkit/src/utilities.cjs`),s=require(`../helpers/persistence.cjs`);let c=require(`@storm-software/config-tools/types`),l=require(`@stryke/capnp`);l=e.__toESM(l);let u=require(`@stryke/fs/buffer`),d=require(`node:fs`);const f=n.createBabelPlugin(`env`,({log:e,context:n})=>{function f(t,r,i=!1){let a=n.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(t.name){let s=n.config.env.prefix.find(e=>t.name&&t.name.startsWith(e)&&(n.env.types.env?.hasProperty(t.name.replace(`${e}_`,``))||a.some(n=>n.getAlias().includes(t.name.replace(`${e}_`,``))))),l=t.name;if(s&&(l=t.name.replace(`${s}_`,``)),e(c.LogLevelLabel.TRACE,`Environment variable ${l} found in ${r.filename||`unknown file`}.`),n.env.types.env?.hasProperty(l)||a.some(e=>e.getAlias().includes(l))){let e=n.env.types.env.hasProperty(l)?n.env.types.env.getProperty(l):a.find(e=>e.getAlias().includes(l));if(!e||e.isIgnored())return;if(n.env.used.env.hasProperty(l)||n.env.used.env.addProperty(e.property),n.config.env.inject&&i){let t=n.env.parsed?.[l];if(t===void 0){let e=n.config.env.prefix.find(e=>n.env.parsed[`${e.replace(/_$/g,``)}_${l}`]);e&&(t=n.env.parsed[`${e.replace(/_$/g,``)}_${l}`])}if(t??=e.getDefaultValue(),e.isValueRequired()&&t===void 0)throw Error(`Environment variable \`${l}\` is not defined in the .env configuration files`);return o.stringifyDefaultValue(e,t)}}else throw Error(`The "${l}" 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
|
+
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
|
+
`)} \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;f(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),r.addImport(e,{module:`storm:env`,name:`env`,imported:`env`})}else if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isCallExpression({callee:{name:`useStorm`,type:`Identifier`}})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;f(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),r.addImport(e,{module:`storm:env`,name:`env`,imported:`env`})}else if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isIdentifier({name:`process`})&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;if(!n.name)return;f(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),r.addImport(e,{module:`storm:env`,name:`env`,imported:`env`})}else if(e.get(`object`)?.get(`property`)?.isIdentifier({name:`env`})&&e.get(`object`)?.get(`object`)?.isMetaProperty()&&e.get(`property`)?.isIdentifier()){let n=e.get(`property`)?.node;if(!n.name)return;f(n,t,!1),e.replaceWithSourceString(`env.${n.name}`),r.addImport(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){e(c.LogLevelLabel.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let r=t.type_exports.ReflectionClass.from({kind:t.type_exports.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),o=s.getEnvReflectionsPath(n,`env`);o&&(0,d.existsSync)(o)&&(e(c.LogLevelLabel.TRACE,`Environment reflection file found at ${o}, reading existing reflection.`),r=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(i.convertFromCapnp(new l.Message((0,u.readFileBufferSync)(o),!1).getRoot(a.SerializedTypes).types)))),e(c.LogLevelLabel.TRACE,`Adding new variables to env reflection at ${o}.`),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()})})}}});exports.envBabelPlugin=f;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{type_exports as e}from"../../../deepkit/src/vendor/type.mjs";import{createBabelPlugin as t}from"../../../plugin-babel/src/helpers/create-plugin.mjs";import{addImport as n}from"../../../plugin-babel/src/helpers/module-helpers.mjs";import{convertFromCapnp as r}from"../../../deepkit/src/capnp.mjs";import{SerializedTypes as i}from"../../../deepkit/schemas/reflection2.mjs";import{stringifyDefaultValue as a}from"../../../deepkit/src/utilities.mjs";import{getEnvReflectionsPath as o}from"../helpers/persistence.mjs";import{LogLevelLabel as s}from"@storm-software/config-tools/types";import*as c from"@stryke/capnp";import{readFileBufferSync as l}from"@stryke/fs/buffer";import{existsSync as u}from"node:fs";const d=t(`env`,({log:t,context:d})=>{function f(e,n,r=!1){let i=d.env.types.env?.getProperties().filter(e=>e.getAlias().length>0);if(e.name){let o=d.config.env.prefix.find(t=>e.name&&e.name.startsWith(t)&&(d.env.types.env?.hasProperty(e.name.replace(`${t}_`,``))||i.some(n=>n.getAlias().includes(e.name.replace(`${t}_`,``))))),c=e.name;if(o&&(c=e.name.replace(`${o}_`,``)),t(s.TRACE,`Environment variable ${c} found in ${n.filename||`unknown file`}.`),d.env.types.env?.hasProperty(c)||i.some(e=>e.getAlias().includes(c))){let e=d.env.types.env.hasProperty(c)?d.env.types.env.getProperty(c):i.find(e=>e.getAlias().includes(c));if(!e||e.isIgnored())return;if(d.env.used.env.hasProperty(c)||d.env.used.env.addProperty(e.property),d.config.env.inject&&r){let t=d.env.parsed?.[c];if(t===void 0){let e=d.config.env.prefix.find(e=>d.env.parsed[`${e.replace(/_$/g,``)}_${c}`]);e&&(t=d.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 a(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 ${n.filename?n.filename:`unknown`}.
|
|
2
|
+
|
|
3
|
+
The following environment configuration names are defined in the \`env\` type definition: \n${d.env.types.env?.getPropertyNames().sort((e,t)=>String(e).localeCompare(String(t))).map(e=>` - ${String(e)} ${i.some(t=>t.getNameAsString()===String(e)&&t.getAlias().length>0)?`(Alias: ${i?.find(t=>t.getNameAsString()===String(e))?.getAlias().join(`, `)})`:``}`).join(`
|
|
4
|
+
`)} \n\nUsing the following env prefix: \n${d.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 r=e.get(`property`)?.node;f(r,t,!1),e.replaceWithSourceString(`env.${r.name}`),n(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 r=e.get(`property`)?.node;f(r,t,!1),e.replaceWithSourceString(`env.${r.name}`),n(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 r=e.get(`property`)?.node;if(!r.name)return;f(r,t,!1),e.replaceWithSourceString(`env.${r.name}`),n(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 r=e.get(`property`)?.node;if(!r.name)return;f(r,t,!1),e.replaceWithSourceString(`env.${r.name}`),n(e,{module:`storm:env`,name:`env`,imported:`env`})}}},post(){t(s.TRACE,`Adding environment variables from ${this.filename||`unknown file`} to env.json.`);let n=e.ReflectionClass.from({kind:e.ReflectionKind.objectLiteral,description:`An object containing the environment variables used by the application.`,types:[]}),a=o(d,`env`);a&&u(a)&&(t(s.TRACE,`Environment reflection file found at ${a}, reading existing reflection.`),n=(0,e.resolveClassType)((0,e.deserializeType)(r(new c.Message(l(a),!1).getRoot(i).types)))),t(s.TRACE,`Adding new variables to env reflection at ${a}.`),n.getProperties().filter(e=>e.getNameAsString()&&!d.env.used.env.hasProperty(e.getNameAsString())).forEach(e=>{d.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()})})}}});export{d as envBabelPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../../alloy/src/core/contexts/context.cjs`),require(`../../../deepkit/src/vendor/type.cjs`),require(`../helpers/create-reflection-resource.cjs`),require(`../../../alloy/src/markdown/components/markdown-file.cjs`),require(`../../../alloy/src/markdown/components/markdown-table.cjs`);let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@alloy-js/core`),n=require(`@stryke/path/join`);require(`@alloy-js/markdown`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../../../alloy/src/core/contexts/context.mjs";import"../../../deepkit/src/vendor/type.mjs";import"../helpers/create-reflection-resource.mjs";import"../../../alloy/src/markdown/components/markdown-file.mjs";import"../../../alloy/src/markdown/components/markdown-table.mjs";import{createComponent as e,createIntrinsic as t}from"@alloy-js/core/jsx-runtime";import{Show as n,code as r}from"@alloy-js/core";import{joinPaths as i}from"@stryke/path/join";import"@alloy-js/markdown";export{};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../alloy/src/core/contexts/context.cjs`),n=require(`../../../deepkit/src/vendor/type.cjs`),r=require(`../../../alloy/src/helpers/refkey.cjs`),i=require(`../../../alloy/src/typescript/components/tsdoc.cjs`),a=require(`../../../alloy/src/typescript/components/builtin-file.cjs`),o=require(`../../../alloy/src/typescript/components/typescript-interface.cjs`),s=require(`../../../alloy/src/typescript/components/typescript-object.cjs`),c=require(`../helpers/load.cjs`),l=require(`../helpers/create-reflection-resource.cjs`);let u=require(`@alloy-js/core/jsx-runtime`),d=require(`@alloy-js/core`),f=require(`defu`);f=e.__toESM(f);let p=require(`@stryke/string-format/title-case`),m=require(`@stryke/type-checks/is-null`),h=require(`@alloy-js/typescript`);function g(e){let[{defaultValue:n,reflection:r}]=(0,d.splitProps)(e,[`defaultValue`,`reflection`]),i=t.usePowerlines();return[(0,u.createComponent)(o.TypeScriptInterface,{name:` EnvBase`,extends:[`EnvInterface`],defaultValue:n,reflection:r,export:!0}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(h.TypeDeclaration,{name:`Env`,export:!0,get children(){return d.code` {
|
|
2
|
+
[Key in keyof EnvBase as Key ${i?.config.env.prefix.map(e=>`| \`${e.replace(/_$/g,``)}_\${Key}\``).join(` `)}]: EnvBase[Key];
|
|
3
|
+
}
|
|
4
|
+
`}})]}function _(e){let[{context:t,name:n}]=(0,d.splitProps)(e,[`context`,`name`]);return t?d.code`propertyName === "${n}" || propertyName.replace(/^(${t.config.env.prefix.sort((e,t)=>e.startsWith(t)?-1:t.startsWith(e)?1:e.localeCompare(t)).map(e=>`${e.replace(/_$/,``)}_`).join(`|`)})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${n.toLowerCase().replace(/[\s\-_]+/g,``)}"`:null}function v(e){let[{context:t,property:n,index:r}]=(0,d.splitProps)(e,[`context`,`property`,`index`]);return t?[r===0?(0,u.createComponent)(h.IfStatement,{get condition(){return[(0,u.createComponent)(_,{get name(){return n.getNameAsString()},context:t}),(0,u.createComponent)(d.Show,{get when(){return(0,u.memo)(()=>!!n.getAlias())()&&n.getAlias().length>0},get children(){return[d.code` || `,(0,u.createComponent)(d.For,{get each(){return n.getAlias()},joiner:d.code` || `,children:e=>(0,u.createComponent)(_,{name:e,context:t})})]}})]},get children(){return d.code`return target["${n.getNameAsString()}"];`}}):(0,u.createComponent)(h.ElseIfClause,{get condition(){return[(0,u.createComponent)(_,{get name(){return n.getNameAsString()},context:t}),(0,u.createComponent)(d.Show,{get when(){return(0,u.memo)(()=>!!n.getAlias())()&&n.getAlias().length>0},get children(){return[d.code` || `,(0,u.createComponent)(d.For,{get each(){return n.getAlias()},joiner:d.code` || `,children:e=>(0,u.createComponent)(_,{name:e,context:t})})]}})]},get children(){return d.code`return target["${n.getNameAsString()}"];`}})]:null}function y(e){let[{context:t,property:n,index:r}]=(0,d.splitProps)(e,[`context`,`property`,`index`]);return t?[r===0?(0,u.createComponent)(h.IfStatement,{get condition(){return[(0,u.createComponent)(_,{get name(){return n.getNameAsString()},context:t}),(0,u.createComponent)(d.Show,{get when(){return(0,u.memo)(()=>!!n.getAlias())()&&n.getAlias().length>0},get children(){return[d.code` || `,(0,u.createComponent)(d.For,{get each(){return n.getAlias()},joiner:d.code` || `,children:e=>(0,u.createComponent)(_,{name:e,context:t})})]}})]},get children(){return d.code`
|
|
5
|
+
target["${n.getNameAsString()}"] = newValue;
|
|
6
|
+
return true;
|
|
7
|
+
`}}):(0,u.createComponent)(h.ElseIfClause,{get condition(){return[(0,u.createComponent)(_,{get name(){return n.getNameAsString()},context:t}),(0,u.createComponent)(d.Show,{get when(){return(0,u.memo)(()=>!!n.getAlias())()&&n.getAlias().length>0},get children(){return[d.code` || `,(0,u.createComponent)(d.For,{get each(){return n.getAlias()},joiner:d.code` || `,children:e=>(0,u.createComponent)(_,{name:e,context:t})})]}})]},get children(){return d.code`
|
|
8
|
+
target["${n.getNameAsString()}"] = newValue;
|
|
9
|
+
return true;
|
|
10
|
+
`}})]:null}const b=r.refkey(`createEnv`),x=r.refkey(`env`),S=r.refkey(`EnvSerializer`);function C(e){let[{defaultConfig:r},o]=(0,d.splitProps)(e,[`defaultConfig`]),_=t.usePowerlines(),C=(0,d.computed)(()=>_&&c.loadEnvFromContext(_,process.env)),w=l.createReflectionResource(_),T=(0,d.computed)(()=>new n.type_exports.ReflectionClass({kind:n.type_exports.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${(0,p.titleCase)(_?.config?.name)} project.`,types:[]},w.data??void 0)),E=(0,d.computed)(()=>w.data?.getProperties().filter(e=>!e.isIgnored()).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString()))??[]),D=(0,d.computed)(()=>w.data?.getProperties().filter(e=>!e.isIgnored()&&!e.isReadonly()).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString()))??[]);return(0,u.createComponent)(a.BuiltinFile,(0,u.mergeProps)(o,{id:`env`,description:`The Powerlines environment configuration module provides an interface to define environment configuration parameters.`,get imports(){return(0,f.default)({"@powerlines/deepkit/vendor/type":[`Type`,`stringify`,`serializer`,`serializeFunction`,`deserializeFunction`,`ReflectionKind`,`TemplateState`,`Serializer`,`TypeProperty`,`TypePropertySignature`],"@powerlines/plugin-env/types/runtime":[{name:`EnvInterface`}]},o.imports??{})},get children(){return[(0,u.createComponent)(d.Show,{get when(){return!(0,m.isNull)(w.data)},get children(){return[(0,u.createComponent)(g,{get defaultValue(){return C.value},get reflection(){return w.data}}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{})]}}),(0,u.createComponent)(s.TypescriptObject,{name:`initialEnv`,type:`Partial<EnvBase>`,defaultValue:C,reflection:T,export:!0,const:!0}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(i.TSDoc,{heading:`The environment configuration serializer for the Powerlines application.`,get children(){return[(0,u.createComponent)(i.TSDocLink,{children:`https://deepkit.io/docs/serialization/serializers`}),(0,u.createComponent)(i.TSDocLink,{children:`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}),(0,u.createComponent)(i.TSDocRemarks,{children:`This serializer is used to serialize and deserialize the Powerlines environment configuration.`})]}}),(0,u.createComponent)(h.ClassDeclaration,{refkey:S,name:`EnvSerializer`,extends:`Serializer`,export:!0,get children(){return(0,u.createComponent)(h.ClassMethod,{name:`constructor`,public:!0,children:d.code`
|
|
11
|
+
super("env");
|
|
12
|
+
|
|
13
|
+
this.deserializeRegistry.register(
|
|
14
|
+
ReflectionKind.boolean,
|
|
15
|
+
(type: Type, state: TemplateState) => {
|
|
16
|
+
state.addSetter(
|
|
17
|
+
\`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
`})}}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(i.TSDoc,{heading:`A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.`,get children(){return[(0,u.createComponent)(i.TSDocLink,{children:`https://deepkit.io/docs/serialization/serializers`}),(0,u.createComponent)(i.TSDocLink,{children:`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}),(0,u.createComponent)(i.TSDocRemarks,{children:`This serializer is used to serialize and deserialize the Powerlines environment configuration.`})]}}),(0,u.createComponent)(h.VarDeclaration,{name:`envSerializer`,export:!1,const:!0,get initializer(){return(0,u.createComponent)(h.NewExpression,{args:[],target:`EnvSerializer`})}}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(i.TSDoc,{heading:`Serialize a environment configuration object to JSON data objects (not a JSON string).`,get children(){return[(0,u.createComponent)(i.TSDocRemarks,{children:`The resulting JSON object can be stringified using JSON.stringify().`}),(0,u.createComponent)(i.TSDocExample,{children:`const json = serializeEnv(env);`}),(0,u.createComponent)(i.TSDocThrows,{children:`ValidationError when serialization or validation fails.`})]}}),(0,u.createComponent)(h.VarDeclaration,{name:`serializeEnv`,export:!0,const:!0,initializer:`serializeFunction<EnvBase>(envSerializer)`}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(i.TSDoc,{heading:`Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.`,get children(){return[(0,u.createComponent)(i.TSDocRemarks,{children:`Types that are already correct will be used as-is.`}),(0,u.createComponent)(i.TSDocExample,{children:`const env = deserializeEnv(json);`}),(0,u.createComponent)(i.TSDocThrows,{children:`ValidationError when deserialization fails.`})]}}),(0,u.createComponent)(h.VarDeclaration,{name:`deserializeEnv`,export:!0,const:!0,initializer:`deserializeFunction<EnvBase>(envSerializer)`}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(i.TSDoc,{heading:`Initializes the Powerlines environment configuration module.`,get children(){return[(0,u.createComponent)(i.TSDocRemarks,{children:`This function initializes the Powerlines environment configuration object.`}),(0,u.createComponent)(i.TSDocParam,{name:`environmentConfig`,children:`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}),(0,u.createComponent)(i.TSDocReturns,{children:`The initialized Powerlines configuration object.`})]}}),(0,u.createComponent)(d.Show,{get when(){return!!_?.entryPath},get children(){return(0,u.createComponent)(h.FunctionDeclaration,{refkey:b,async:!1,export:!0,name:`createEnv`,parameters:[{name:`environmentConfig`,type:`Partial<Env>`,optional:!1,default:`{}`}],returnType:`Env`,get children(){return[d.code`
|
|
22
|
+
return new Proxy<Env>(
|
|
23
|
+
deserializeEnv({
|
|
24
|
+
...initialEnv,
|
|
25
|
+
...environmentConfig
|
|
26
|
+
}) as Env,
|
|
27
|
+
{
|
|
28
|
+
get: (target: EnvBase, propertyName: string) => { `,(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(d.For,{each:E,children:(e,t)=>(0,u.createComponent)(v,{index:t,context:_,property:e})}),d.code`
|
|
29
|
+
return undefined;
|
|
30
|
+
}, `,(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),d.code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(d.For,{each:D,ender:d.code` else `,children:(e,t)=>(0,u.createComponent)(y,{index:t,context:_,property:e})}),(0,u.createIntrinsic)(`hbr`,{}),d.code`return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
`]}})}}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createIntrinsic)(`hbr`,{}),(0,u.createComponent)(h.VarDeclaration,{refkey:x,name:`env`,type:`Env`,export:!0,const:!0,get initializer(){return[d.code`createEnv(`,r||`{}`,d.code` as Partial<Env>)`]}})]}}))}exports.EnvBuiltin=C,exports.EnvTypeDefinition=g;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{usePowerlines as e}from"../../../alloy/src/core/contexts/context.mjs";import{type_exports as t}from"../../../deepkit/src/vendor/type.mjs";import{refkey as n}from"../../../alloy/src/helpers/refkey.mjs";import{TSDoc as r,TSDocExample as i,TSDocLink as a,TSDocParam as o,TSDocRemarks as s,TSDocReturns as c,TSDocThrows as l}from"../../../alloy/src/typescript/components/tsdoc.mjs";import{BuiltinFile as u}from"../../../alloy/src/typescript/components/builtin-file.mjs";import{TypeScriptInterface as d}from"../../../alloy/src/typescript/components/typescript-interface.mjs";import{TypescriptObject as f}from"../../../alloy/src/typescript/components/typescript-object.mjs";import{loadEnvFromContext as p}from"../helpers/load.mjs";import{createReflectionResource as m}from"../helpers/create-reflection-resource.mjs";import{createComponent as h,createIntrinsic as g,memo as _,mergeProps as v}from"@alloy-js/core/jsx-runtime";import{For as y,Show as b,code as x,computed as S,splitProps as C}from"@alloy-js/core";import w from"defu";import{titleCase as T}from"@stryke/string-format/title-case";import{isNull as E}from"@stryke/type-checks/is-null";import{ClassDeclaration as D,ClassMethod as O,ElseIfClause as k,FunctionDeclaration as A,IfStatement as j,NewExpression as M,TypeDeclaration as N,VarDeclaration as P}from"@alloy-js/typescript";function F(t){let[{defaultValue:n,reflection:r}]=C(t,[`defaultValue`,`reflection`]),i=e();return[h(d,{name:` EnvBase`,extends:[`EnvInterface`],defaultValue:n,reflection:r,export:!0}),g(`hbr`,{}),g(`hbr`,{}),h(N,{name:`Env`,export:!0,get children(){return x` {
|
|
2
|
+
[Key in keyof EnvBase as Key ${i?.config.env.prefix.map(e=>`| \`${e.replace(/_$/g,``)}_\${Key}\``).join(` `)}]: EnvBase[Key];
|
|
3
|
+
}
|
|
4
|
+
`}})]}function I(e){let[{context:t,name:n}]=C(e,[`context`,`name`]);return t?x`propertyName === "${n}" || propertyName.replace(/^(${t.config.env.prefix.sort((e,t)=>e.startsWith(t)?-1:t.startsWith(e)?1:e.localeCompare(t)).map(e=>`${e.replace(/_$/,``)}_`).join(`|`)})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${n.toLowerCase().replace(/[\s\-_]+/g,``)}"`:null}function L(e){let[{context:t,property:n,index:r}]=C(e,[`context`,`property`,`index`]);return t?[h(r===0?j:k,{get condition(){return[h(I,{get name(){return n.getNameAsString()},context:t}),h(b,{get when(){return _(()=>!!n.getAlias())()&&n.getAlias().length>0},get children(){return[x` || `,h(y,{get each(){return n.getAlias()},joiner:x` || `,children:e=>h(I,{name:e,context:t})})]}})]},get children(){return x`return target["${n.getNameAsString()}"];`}})]:null}function R(e){let[{context:t,property:n,index:r}]=C(e,[`context`,`property`,`index`]);return t?[h(r===0?j:k,{get condition(){return[h(I,{get name(){return n.getNameAsString()},context:t}),h(b,{get when(){return _(()=>!!n.getAlias())()&&n.getAlias().length>0},get children(){return[x` || `,h(y,{get each(){return n.getAlias()},joiner:x` || `,children:e=>h(I,{name:e,context:t})})]}})]},get children(){return x`
|
|
5
|
+
target["${n.getNameAsString()}"] = newValue;
|
|
6
|
+
return true;
|
|
7
|
+
`}})]:null}const z=n(`createEnv`),B=n(`env`),V=n(`EnvSerializer`);function H(n){let[{defaultConfig:d},_]=C(n,[`defaultConfig`]),k=e(),j=S(()=>k&&p(k,process.env)),N=m(k),I=S(()=>new t.ReflectionClass({kind:t.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the ${T(k?.config?.name)} project.`,types:[]},N.data??void 0)),H=S(()=>N.data?.getProperties().filter(e=>!e.isIgnored()).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString()))??[]),U=S(()=>N.data?.getProperties().filter(e=>!e.isIgnored()&&!e.isReadonly()).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString()))??[]);return h(u,v(_,{id:`env`,description:`The Powerlines environment configuration module provides an interface to define environment configuration parameters.`,get imports(){return w({"@powerlines/deepkit/vendor/type":[`Type`,`stringify`,`serializer`,`serializeFunction`,`deserializeFunction`,`ReflectionKind`,`TemplateState`,`Serializer`,`TypeProperty`,`TypePropertySignature`],"@powerlines/plugin-env/types/runtime":[{name:`EnvInterface`}]},_.imports??{})},get children(){return[h(b,{get when(){return!E(N.data)},get children(){return[h(F,{get defaultValue(){return j.value},get reflection(){return N.data}}),g(`hbr`,{}),g(`hbr`,{})]}}),h(f,{name:`initialEnv`,type:`Partial<EnvBase>`,defaultValue:j,reflection:I,export:!0,const:!0}),g(`hbr`,{}),g(`hbr`,{}),h(r,{heading:`The environment configuration serializer for the Powerlines application.`,get children(){return[h(a,{children:`https://deepkit.io/docs/serialization/serializers`}),h(a,{children:`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}),h(s,{children:`This serializer is used to serialize and deserialize the Powerlines environment configuration.`})]}}),h(D,{refkey:V,name:`EnvSerializer`,extends:`Serializer`,export:!0,get children(){return h(O,{name:`constructor`,public:!0,children:x`
|
|
8
|
+
super("env");
|
|
9
|
+
|
|
10
|
+
this.deserializeRegistry.register(
|
|
11
|
+
ReflectionKind.boolean,
|
|
12
|
+
(type: Type, state: TemplateState) => {
|
|
13
|
+
state.addSetter(
|
|
14
|
+
\`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
`})}}),g(`hbr`,{}),g(`hbr`,{}),h(r,{heading:`A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.`,get children(){return[h(a,{children:`https://deepkit.io/docs/serialization/serializers`}),h(a,{children:`https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918`}),h(s,{children:`This serializer is used to serialize and deserialize the Powerlines environment configuration.`})]}}),h(P,{name:`envSerializer`,export:!1,const:!0,get initializer(){return h(M,{args:[],target:`EnvSerializer`})}}),g(`hbr`,{}),g(`hbr`,{}),h(r,{heading:`Serialize a environment configuration object to JSON data objects (not a JSON string).`,get children(){return[h(s,{children:`The resulting JSON object can be stringified using JSON.stringify().`}),h(i,{children:`const json = serializeEnv(env);`}),h(l,{children:`ValidationError when serialization or validation fails.`})]}}),h(P,{name:`serializeEnv`,export:!0,const:!0,initializer:`serializeFunction<EnvBase>(envSerializer)`}),g(`hbr`,{}),g(`hbr`,{}),h(r,{heading:`Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.`,get children(){return[h(s,{children:`Types that are already correct will be used as-is.`}),h(i,{children:`const env = deserializeEnv(json);`}),h(l,{children:`ValidationError when deserialization fails.`})]}}),h(P,{name:`deserializeEnv`,export:!0,const:!0,initializer:`deserializeFunction<EnvBase>(envSerializer)`}),g(`hbr`,{}),g(`hbr`,{}),h(r,{heading:`Initializes the Powerlines environment configuration module.`,get children(){return[h(s,{children:`This function initializes the Powerlines environment configuration object.`}),h(o,{name:`environmentConfig`,children:`The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`}),h(c,{children:`The initialized Powerlines configuration object.`})]}}),h(b,{get when(){return!!k?.entryPath},get children(){return h(A,{refkey:z,async:!1,export:!0,name:`createEnv`,parameters:[{name:`environmentConfig`,type:`Partial<Env>`,optional:!1,default:`{}`}],returnType:`Env`,get children(){return[x`
|
|
19
|
+
return new Proxy<Env>(
|
|
20
|
+
deserializeEnv({
|
|
21
|
+
...initialEnv,
|
|
22
|
+
...environmentConfig
|
|
23
|
+
}) as Env,
|
|
24
|
+
{
|
|
25
|
+
get: (target: EnvBase, propertyName: string) => { `,g(`hbr`,{}),h(y,{each:H,children:(e,t)=>h(L,{index:t,context:k,property:e})}),x`
|
|
26
|
+
return undefined;
|
|
27
|
+
}, `,g(`hbr`,{}),g(`hbr`,{}),x` set: (target: EnvBase, propertyName: string, newValue: any) => { `,g(`hbr`,{}),h(y,{each:U,ender:x` else `,children:(e,t)=>h(R,{index:t,context:k,property:e})}),g(`hbr`,{}),x`return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
`]}})}}),g(`hbr`,{}),g(`hbr`,{}),g(`hbr`,{}),h(P,{refkey:B,name:`env`,type:`Env`,export:!0,const:!0,get initializer(){return[x`createEnv(`,d||`{}`,x` as Partial<Env>)`]}})]}}))}export{H as EnvBuiltin,F as EnvTypeDefinition};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./env.cjs`);require(`./docs.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EnvBuiltin as e,EnvTypeDefinition as t}from"./env.mjs";import"./docs.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../deepkit/src/vendor/type.cjs`),n=require(`./persistence.cjs`),r=require(`./load.cjs`);let i=require(`@alloy-js/core`),a=require(`@stryke/string-format/title-case`);function o(e){let o=(0,i.computed)(()=>e&&r.loadEnvFromContext(e,process.env));return(0,i.createResource)(async()=>{if(!e)return new t.type_exports.ReflectionClass({kind:t.type_exports.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the Powerlines project.`,types:[]});let r=await n.readEnvTypeReflection(e,`env`);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,a.titleCase)(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),r.getProperties().forEach(e=>{e.setDefaultValue(o.value?.[e.getNameAsString()]??e.getAlias().reduce((e,t)=>e??o.value?.[t],void 0)??e.getDefaultValue())}),r})}exports.createReflectionResource=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{type_exports as e}from"../../../deepkit/src/vendor/type.mjs";import{readEnvTypeReflection as t}from"./persistence.mjs";import{loadEnvFromContext as n}from"./load.mjs";import{computed as r,createResource as i}from"@alloy-js/core";import{titleCase as a}from"@stryke/string-format/title-case";function o(o){let s=r(()=>o&&n(o,process.env));return i(async()=>{if(!o)return new e.ReflectionClass({kind:e.ReflectionKind.objectLiteral,description:`The initial environment configuration state for the Powerlines project.`,types:[]});let n=await t(o,`env`);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()||a(e.name),readonly:e.isReadonly(),permission:e.getPermission(),domain:e.getDomain()}})})}),n.getProperties().forEach(e=>{e.setDefaultValue(s.value?.[e.getNameAsString()]??e.getAlias().reduce((e,t)=>e??s.value?.[t],void 0)??e.getDefaultValue())}),n})}export{o as createReflectionResource};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./reflect.cjs`),t=require(`./persistence.cjs`),n=require(`./source-file-env.cjs`),r=require(`./load.cjs`),i=require(`./create-reflection-resource.cjs`);require(`./template-helpers.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{BaseEnv as e,BaseSecrets as t,createEnvReflection as n,createSecretsReflection as r,mergeEnvReflections as i,mergeSecretsReflections as a,reflectEnv as o,reflectSecrets as s}from"./reflect.mjs";import{getEnvDefaultTypeDefinition as c,getEnvReflectionsPath as l,getEnvTypeReflectionsPath as u,getSecretsDefaultTypeDefinition as d,readEnvReflection as f,readEnvTypeReflection as p,readSecretsReflection as m,resolveRuntimeTypeFile as h,writeEnvReflection as g,writeEnvTypeReflection as _}from"./persistence.mjs";import{removeEnvPrefix as v}from"./source-file-env.mjs";import{loadEnv as y,loadEnvFromContext as b}from"./load.mjs";import{createReflectionResource as x}from"./create-reflection-resource.mjs";import"./template-helpers.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`./source-file-env.cjs`);let n=require(`@stryke/type-checks/is-set-string`),r=require(`@stryke/type-checks/is-set-object`),i=require(`defu`);i=e.__toESM(i);let a=require(`@stryke/path/join-paths`),o=require(`@stryke/env/load-env`),s=require(`@stryke/string-format/kebab-case`),c=require(`c12`);async function l(e,n,r){let a=await(0,o.loadEnv)(r,n);if(e.additionalFiles&&e.additionalFiles?.length>0){let t=await Promise.all(e.additionalFiles.map(async e=>(0,o.loadEnvFile)(e,r)));for(let e of t)a=(0,i.default)(e,a)}return t.removeEnvPrefix(a)}async function u(e,t,n,r,o,s){let[u,d]=await Promise.all([l(e,n,t),(0,c.loadConfig)({cwd:t,name:`storm`,envName:n,defaults:{NAME:o.name?.replace(`@${s.namespace}/`,``),MODE:n,ORG:s.organization},globalRc:!0,packageJson:!0,dotenv:!0,jitiOptions:{fsCache:(0,a.joinPaths)(r,`jiti`),moduleCache:!0}})]);return(0,i.default)(u,d.config,s)}function d(e,t){return(0,i.default)({APP_NAME:(0,s.kebabCase)(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,``)),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${(0,s.kebabCase)(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:(0,n.isSetString)(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode===`development`,STACKTRACE:e.workspaceConfig.mode===`development`,ENVIRONMENT:e.environment},(0,r.isSetObject)(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((e,n)=>(e[n.name]=t[n.name]??n.getDefaultValue(),e),{}):{})}async function f(e,t){let[n,r,a]=await Promise.all([u(t,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return(0,i.default)(d(e,process.env),n,r,a)}exports.loadEnv=f,exports.loadEnvFromContext=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{removeEnvPrefix as e}from"./source-file-env.mjs";import{isSetString as t}from"@stryke/type-checks/is-set-string";import{isSetObject as n}from"@stryke/type-checks/is-set-object";import r from"defu";import{joinPaths as i}from"@stryke/path/join-paths";import{loadEnv as a,loadEnvFile as o}from"@stryke/env/load-env";import{kebabCase as s}from"@stryke/string-format/kebab-case";import{loadConfig as c}from"c12";async function l(t,n,i){let s=await a(i,n);if(t.additionalFiles&&t.additionalFiles?.length>0){let e=await Promise.all(t.additionalFiles.map(async e=>o(e,i)));for(let t of e)s=r(t,s)}return e(s)}async function u(e,t,n,a,o,s){let[u,d]=await Promise.all([l(e,n,t),c({cwd:t,name:`storm`,envName:n,defaults:{NAME:o.name?.replace(`@${s.namespace}/`,``),MODE:n,ORG:s.organization},globalRc:!0,packageJson:!0,dotenv:!0,jitiOptions:{fsCache:i(a,`jiti`),moduleCache:!0}})]);return r(u,d.config,s)}function d(e,i){return r({APP_NAME:s(e.config.name||e.packageJson.name?.replace(`/${e.workspaceConfig.namespace}`,``)),APP_VERSION:e.packageJson.version,BUILD_ID:e.meta.buildId,BUILD_TIMESTAMP:new Date(e.meta.timestamp).toISOString(),BUILD_CHECKSUM:e.meta.checksum,RELEASE_ID:e.meta.releaseId,RELEASE_TAG:`${s(e.config.name)}@${e.packageJson.version}`,DEFAULT_LOCALE:e.workspaceConfig.locale,DEFAULT_TIMEZONE:e.workspaceConfig.timezone,LOG_LEVEL:e.config.logLevel,ERROR_URL:e.workspaceConfig.error?.url,ORGANIZATION:t(e.workspaceConfig.organization)?e.workspaceConfig.organization:e.workspaceConfig.organization?.name,PLATFORM:e.config.build.platform,MODE:e.workspaceConfig.mode,DEBUG:e.workspaceConfig.mode===`development`,STACKTRACE:e.workspaceConfig.mode===`development`,ENVIRONMENT:e.environment},n(e?.env?.types?.env)?e.env.types.env?.getProperties().reduce((e,t)=>(e[t.name]=i[t.name]??t.getDefaultValue(),e),{}):{})}async function f(e,t){let[n,i,a]=await Promise.all([u(t,e.config.projectRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.workspaceConfig.workspaceRoot,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig),u(t,e.envPaths.config,e.config.mode,e.cachePath,e.packageJson,e.workspaceConfig)]);return r(d(e,process.env),n,i,a)}export{f as loadEnv,d as loadEnvFromContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../deepkit/src/vendor/type.cjs`),n=require(`../../../deepkit/src/capnp.cjs`),r=require(`../../../deepkit/schemas/reflection2.cjs`),i=require(`../../../deepkit/src/resolve-reflections.cjs`),a=require(`./reflect.cjs`);let o=require(`@stryke/capnp`);o=e.__toESM(o);let s=require(`@stryke/fs/buffer`),c=require(`node:fs`),l=require(`@stryke/path/join-paths`),u=require(`@stryke/fs/resolve`),d=require(`@stryke/type-checks/is-empty-object`);async function f(e){return(0,u.resolvePackage)(`@powerlines/plugin-env/types/runtime`,{paths:[e.workspaceConfig.workspaceRoot,(0,l.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot)]})}async function p(e){return{file:await f(e),name:`EnvInterface`}}async function m(e){return{file:await f(e),name:`SecretsInterface`}}function h(e,t=`env`){return(0,l.joinPaths)(i.getReflectionsPath(e),`env`,`${t}-types.bin`)}async function g(e,i=`env`){let l=h(e,i);if(!(0,c.existsSync)(l)){if(!e.env.types.env||(0,d.isEmptyObject)(e.env.types.env)){let t=a.createEnvReflection(e),n=new o.Message;t.messageRoot=n.initRoot(r.SerializedTypes),t.dataBuffer=n.toArrayBuffer(),e.env.types.env=t,await _(e,e.env.types.env,i)}return e.env.types.env}let u=await(0,s.readFileBuffer)(l),f=new o.Message(u,!1).getRoot(r.SerializedTypes),p=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(n.convertFromCapnp(f.types)));return e.env.types[i]=p,e.env.types[i].messageRoot=f,e.env.types[i].dataBuffer=u,p}async function _(e,t,i=`env`){let a=t.serializeType(),c=new o.Message;n.convertToCapnp(a,c.initRoot(r.SerializedTypes)._initTypes(a.length)),await(0,s.writeFileBuffer)(h(e,i),c.toArrayBuffer())}function v(e,t){return(0,l.joinPaths)(i.getReflectionsPath(e),`env`,`${t}.bin`)}async function y(e){let i=v(e,`env`);if(!(0,c.existsSync)(i)){if(e.env.types.env||(e.env.types.env=await g(e,`env`)),!e.env.used.env||(0,d.isEmptyObject)(e.env.used.env)){let n=a.createEnvReflection(e,{type:{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters that are used (at least once) by the ${e.config.name?`${e.config.name} application`:`application`}.`,types:[]},superReflection:e.env.types.env});n.name=`Env`;let i=new o.Message;n.messageRoot=i.initRoot(r.SerializedTypes),n.dataBuffer=i.toArrayBuffer(),e.env.used.env=n,await x(e,e.env.used.env,`env`)}return e.env.used.env}let l=await(0,s.readFileBuffer)(i),u=new o.Message(l,!1).getRoot(r.SerializedTypes),f=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(n.convertFromCapnp(u.types)));return e.env.used.env=f,e.env.used.env.messageRoot=u,e.env.used.env.dataBuffer=l,f}async function b(e){let i=v(e,`secrets`);if(!(0,c.existsSync)(i)){if(e.env.types.secrets||(e.env.types.secrets=await g(e,`secrets`)),!e.env.used.secrets||(0,d.isEmptyObject)(e.env.used.secrets)){let n=a.createEnvReflection(e,{type:{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters that are used (at least once) by the ${e.config.name?`${e.config.name} application`:`application`}.`,types:[]},superReflection:e.env.types.secrets});n.name=`Secrets`;let i=new o.Message;n.messageRoot=i.initRoot(r.SerializedTypes),n.dataBuffer=i.toArrayBuffer(),e.env.used.secrets=n,await x(e,e.env.used.secrets,`secrets`)}return e.env.used.secrets}let l=await(0,s.readFileBuffer)(i),u=new o.Message(l,!1).getRoot(r.SerializedTypes),f=(0,t.type_exports.resolveClassType)((0,t.type_exports.deserializeType)(n.convertFromCapnp(u.types)));return e.env.used.secrets=f,e.env.used.secrets.messageRoot=u,e.env.used.secrets.dataBuffer=l,f}async function x(e,t,i=`env`){let a=t.serializeType(),c=new o.Message;n.convertToCapnp(a,c.initRoot(r.SerializedTypes)._initTypes(a.length)),await(0,s.writeFileBuffer)(v(e,i),c.toArrayBuffer())}exports.getEnvDefaultTypeDefinition=p,exports.getEnvReflectionsPath=v,exports.getEnvTypeReflectionsPath=h,exports.getSecretsDefaultTypeDefinition=m,exports.readEnvReflection=y,exports.readEnvTypeReflection=g,exports.readSecretsReflection=b,exports.resolveRuntimeTypeFile=f,exports.writeEnvReflection=x,exports.writeEnvTypeReflection=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{type_exports as e}from"../../../deepkit/src/vendor/type.mjs";import{convertFromCapnp as t,convertToCapnp as n}from"../../../deepkit/src/capnp.mjs";import{SerializedTypes as r}from"../../../deepkit/schemas/reflection2.mjs";import{getReflectionsPath as i}from"../../../deepkit/src/resolve-reflections.mjs";import{createEnvReflection as a}from"./reflect.mjs";import*as o from"@stryke/capnp";import{readFileBuffer as s,writeFileBuffer as c}from"@stryke/fs/buffer";import{existsSync as l}from"node:fs";import{joinPaths as u}from"@stryke/path/join-paths";import{resolvePackage as d}from"@stryke/fs/resolve";import{isEmptyObject as f}from"@stryke/type-checks/is-empty-object";async function p(e){return d(`@powerlines/plugin-env/types/runtime`,{paths:[e.workspaceConfig.workspaceRoot,u(e.workspaceConfig.workspaceRoot,e.config.projectRoot)]})}async function m(e){return{file:await p(e),name:`EnvInterface`}}async function h(e){return{file:await p(e),name:`SecretsInterface`}}function g(e,t=`env`){return u(i(e),`env`,`${t}-types.bin`)}async function _(n,i=`env`){let c=g(n,i);if(!l(c)){if(!n.env.types.env||f(n.env.types.env)){let e=a(n),t=new o.Message;e.messageRoot=t.initRoot(r),e.dataBuffer=t.toArrayBuffer(),n.env.types.env=e,await v(n,n.env.types.env,i)}return n.env.types.env}let u=await s(c),d=new o.Message(u,!1).getRoot(r),p=(0,e.resolveClassType)((0,e.deserializeType)(t(d.types)));return n.env.types[i]=p,n.env.types[i].messageRoot=d,n.env.types[i].dataBuffer=u,p}async function v(e,t,i=`env`){let a=t.serializeType(),s=new o.Message;n(a,s.initRoot(r)._initTypes(a.length)),await c(g(e,i),s.toArrayBuffer())}function y(e,t){return u(i(e),`env`,`${t}.bin`)}async function b(n){let i=y(n,`env`);if(!l(i)){if(n.env.types.env||(n.env.types.env=await _(n,`env`)),!n.env.used.env||f(n.env.used.env)){let t=a(n,{type:{kind:e.ReflectionKind.objectLiteral,typeName:`Env`,description:`An object containing the environment configuration parameters that are used (at least once) by the ${n.config.name?`${n.config.name} application`:`application`}.`,types:[]},superReflection:n.env.types.env});t.name=`Env`;let i=new o.Message;t.messageRoot=i.initRoot(r),t.dataBuffer=i.toArrayBuffer(),n.env.used.env=t,await S(n,n.env.used.env,`env`)}return n.env.used.env}let c=await s(i),u=new o.Message(c,!1).getRoot(r),d=(0,e.resolveClassType)((0,e.deserializeType)(t(u.types)));return n.env.used.env=d,n.env.used.env.messageRoot=u,n.env.used.env.dataBuffer=c,d}async function x(n){let i=y(n,`secrets`);if(!l(i)){if(n.env.types.secrets||(n.env.types.secrets=await _(n,`secrets`)),!n.env.used.secrets||f(n.env.used.secrets)){let t=a(n,{type:{kind:e.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`An object containing the secret configuration parameters that are used (at least once) by the ${n.config.name?`${n.config.name} application`:`application`}.`,types:[]},superReflection:n.env.types.secrets});t.name=`Secrets`;let i=new o.Message;t.messageRoot=i.initRoot(r),t.dataBuffer=i.toArrayBuffer(),n.env.used.secrets=t,await S(n,n.env.used.secrets,`secrets`)}return n.env.used.secrets}let c=await s(i),u=new o.Message(c,!1).getRoot(r),d=(0,e.resolveClassType)((0,e.deserializeType)(t(u.types)));return n.env.used.secrets=d,n.env.used.secrets.messageRoot=u,n.env.used.secrets.dataBuffer=c,d}async function S(e,t,i=`env`){let a=t.serializeType(),s=new o.Message;n(a,s.initRoot(r)._initTypes(a.length)),await c(y(e,i),s.toArrayBuffer())}export{m as getEnvDefaultTypeDefinition,y as getEnvReflectionsPath,g as getEnvTypeReflectionsPath,h as getSecretsDefaultTypeDefinition,b as readEnvReflection,_ as readEnvTypeReflection,x as readSecretsReflection,p as resolveRuntimeTypeFile,S as writeEnvReflection,v as writeEnvTypeReflection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../../deepkit/src/vendor/type.cjs`),n=require(`../../../deepkit/src/reflect-type.cjs`),r=require(`./persistence.cjs`);let i=require(`@stryke/path/is-parent-path`),a=require(`@stryke/string-format/title-case`),o=require(`@stryke/path/join-paths`);function s(e,n){return d(e,{type:(0,t.type_exports.merge)(n.map(e=>e.type))})}function c(e,n){return f(e,{type:(0,t.type_exports.merge)(n.map(e=>e.type))})}var l=class{PLATFORM=`neutral`;MODE=`production`;DEBUG=!1;TEST=!1;MINIMAL=!1;NO_COLOR=!1;FORCE_COLOR=!1;FORCE_HYPERLINK=!1;STACKTRACE=!1;INCLUDE_ERROR_DATA=!1;CI=!1},u=class{};function d(e,n={}){let r=n.superReflection??new t.type_exports.ReflectionClass({kind:t.type_exports.ReflectionKind.class,description:`The base environment configuration definition for the ${(0,a.titleCase)(e.config.name)} project.`,classType:l,types:[],implements:[{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`EnvInterface`,description:`The environment configuration interface definition for the ${(0,a.titleCase)(e.config.name)} project.`,types:[]}]});r.name=`Env`;let i=new t.type_exports.ReflectionClass(n.type??{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Env`,description:`A schema describing the list of available environment variables that can be used by the ${e.config.name?`${(0,a.titleCase)(e.config.name)} application`:`application`}.`,types:[]},r);return i.name=`Env`,i}function f(e,n={}){let r=n.superReflection??new t.type_exports.ReflectionClass({kind:t.type_exports.ReflectionKind.class,description:`The base secrets configuration definition for the ${(0,a.titleCase)(e.config.name)} project.`,classType:u,types:[],implements:[{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`SecretsInterface`,description:`The secrets configuration interface definition for the ${(0,a.titleCase)(e.config.name)} project.`,types:[]}]});r.name=`Secrets`;let i=new t.type_exports.ReflectionClass(n.type??{kind:t.type_exports.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`A schema describing the list of available environment secrets that can be used by the ${e.config.name?`${(0,a.titleCase)(e.config.name)} application`:`application`}.`,types:[]},r);return i.name=`Secrets`,i}async function p(e,a,c){let l;a&&(l=(0,t.type_exports.resolveClassType)(await n.reflectType(e,{file:(0,i.isParentPath)(a,e.workspaceConfig.workspaceRoot)?a:(0,o.joinPaths)(e.workspaceConfig.workspaceRoot,a),name:c},{skipNodeModulesBundle:!0})));let u=await n.reflectType(e,await r.getEnvDefaultTypeDefinition(e));return s(e,[await r.readEnvTypeReflection(e,`env`),l,(0,t.type_exports.resolveClassType)(u)].filter(Boolean))}async function m(e,a,s){let l;a&&(l=(0,t.type_exports.resolveClassType)(await n.reflectType(e,{file:(0,i.isParentPath)(a,e.workspaceConfig.workspaceRoot)?a:(0,o.joinPaths)(e.workspaceConfig.workspaceRoot,a),name:s},{skipNodeModulesBundle:!0})));let u=await n.reflectType(e,await r.getSecretsDefaultTypeDefinition(e));return c(e,[await r.readSecretsReflection(e),l,(0,t.type_exports.resolveClassType)(u)].filter(Boolean))}exports.BaseEnv=l,exports.BaseSecrets=u,exports.createEnvReflection=d,exports.createSecretsReflection=f,exports.mergeEnvReflections=s,exports.mergeSecretsReflections=c,exports.reflectEnv=p,exports.reflectSecrets=m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{type_exports as e}from"../../../deepkit/src/vendor/type.mjs";import{reflectType as t}from"../../../deepkit/src/reflect-type.mjs";import{getEnvDefaultTypeDefinition as n,getSecretsDefaultTypeDefinition as r,readEnvTypeReflection as i,readSecretsReflection as a}from"./persistence.mjs";import{isParentPath as o}from"@stryke/path/is-parent-path";import{titleCase as s}from"@stryke/string-format/title-case";import{joinPaths as c}from"@stryke/path/join-paths";function l(t,n){return p(t,{type:(0,e.merge)(n.map(e=>e.type))})}function u(t,n){return m(t,{type:(0,e.merge)(n.map(e=>e.type))})}var d=class{PLATFORM=`neutral`;MODE=`production`;DEBUG=!1;TEST=!1;MINIMAL=!1;NO_COLOR=!1;FORCE_COLOR=!1;FORCE_HYPERLINK=!1;STACKTRACE=!1;INCLUDE_ERROR_DATA=!1;CI=!1},f=class{};function p(t,n={}){let r=n.superReflection??new e.ReflectionClass({kind:e.ReflectionKind.class,description:`The base environment configuration definition for the ${s(t.config.name)} project.`,classType:d,types:[],implements:[{kind:e.ReflectionKind.objectLiteral,typeName:`EnvInterface`,description:`The environment configuration interface definition for the ${s(t.config.name)} project.`,types:[]}]});r.name=`Env`;let i=new e.ReflectionClass(n.type??{kind:e.ReflectionKind.objectLiteral,typeName:`Env`,description:`A schema describing the list of available environment variables that can be used by the ${t.config.name?`${s(t.config.name)} application`:`application`}.`,types:[]},r);return i.name=`Env`,i}function m(t,n={}){let r=n.superReflection??new e.ReflectionClass({kind:e.ReflectionKind.class,description:`The base secrets configuration definition for the ${s(t.config.name)} project.`,classType:f,types:[],implements:[{kind:e.ReflectionKind.objectLiteral,typeName:`SecretsInterface`,description:`The secrets configuration interface definition for the ${s(t.config.name)} project.`,types:[]}]});r.name=`Secrets`;let i=new e.ReflectionClass(n.type??{kind:e.ReflectionKind.objectLiteral,typeName:`Secrets`,description:`A schema describing the list of available environment secrets that can be used by the ${t.config.name?`${s(t.config.name)} application`:`application`}.`,types:[]},r);return i.name=`Secrets`,i}async function h(r,a,s){let u;a&&(u=(0,e.resolveClassType)(await t(r,{file:o(a,r.workspaceConfig.workspaceRoot)?a:c(r.workspaceConfig.workspaceRoot,a),name:s},{skipNodeModulesBundle:!0})));let d=await t(r,await n(r));return l(r,[await i(r,`env`),u,(0,e.resolveClassType)(d)].filter(Boolean))}async function g(n,i,s){let l;i&&(l=(0,e.resolveClassType)(await t(n,{file:o(i,n.workspaceConfig.workspaceRoot)?i:c(n.workspaceConfig.workspaceRoot,i),name:s},{skipNodeModulesBundle:!0})));let d=await t(n,await r(n));return u(n,[await a(n),l,(0,e.resolveClassType)(d)].filter(Boolean))}export{d as BaseEnv,f as BaseSecrets,p as createEnvReflection,m as createSecretsReflection,l as mergeEnvReflections,u as mergeSecretsReflections,h as reflectEnv,g as reflectSecrets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/type-checks/is-string`),n=require(`@stryke/env/types`),r=require(`@stryke/string-format/camel-case`);function i(e){if((0,t.isString)(e)){let t=n.ENV_PREFIXES.reduce((e,t)=>(e.startsWith(t)&&(e=e.slice(t.length)),e),e.toUpperCase());for(;t.startsWith(`_`);)t=t.slice(1);return t}return Object.keys(e).reduce((t,n)=>{let r=i(n);return r&&(t[r]=e[n]),t},{})}exports.removeEnvPrefix=i;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isString as e}from"@stryke/type-checks/is-string";import{ENV_PREFIXES as t}from"@stryke/env/types";import{camelCase as n}from"@stryke/string-format/camel-case";function r(n){if(e(n)){let e=t.reduce((e,t)=>(e.startsWith(t)&&(e=e.slice(t.length)),e),n.toUpperCase());for(;e.startsWith(`_`);)e=e.slice(1);return e}return Object.keys(n).reduce((e,t)=>{let i=r(t);return i&&(e[i]=n[t]),e},{})}export{r as removeEnvPrefix};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./persistence.cjs`);let e=require(`@stryke/string-format/title-case`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./persistence.mjs";import{titleCase as e}from"@stryke/string-format/title-case";export{};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.cjs`),t=require(`../../alloy/src/create-plugin.cjs`),n=require(`../../deepkit/src/vendor/type.cjs`),r=require(`../../plugin-babel/src/index.cjs`),i=require(`./helpers/reflect.cjs`),a=require(`./helpers/persistence.cjs`),o=require(`./babel/plugin.cjs`),s=require(`./helpers/source-file-env.cjs`),c=require(`./helpers/load.cjs`),l=require(`./helpers/create-reflection-resource.cjs`),u=require(`./components/env.cjs`);require(`./babel/index.cjs`),require(`./components/index.cjs`),require(`./helpers/index.cjs`);let d=require(`@alloy-js/core/jsx-runtime`),f=require(`@storm-software/config-tools/types`),p=require(`@stryke/path/is-parent-path`),m=require(`defu`);m=e.__toESM(m);let h=require(`@stryke/convert/parse-type-definition`),g=require(`@stryke/convert/to-array`),_=require(`@stryke/env/types`),v=require(`@stryke/fs/exists`),y=require(`@stryke/fs/helpers`),b=require(`@stryke/path/join`),x=require(`@stryke/string-format/constant-case`);const S=t.createAlloyPlugin((e={})=>({name:`env`,dependsOn:[r.default(e.babel)],async config(){this.log(f.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:(0,m.default)(e,{types:{},prefix:[]}),transform:{babel:{plugins:[o.envBabelPlugin]}}};if(t.env.types)t.env.types=(0,h.parseTypeDefinition)(t.env.types);else{this.log(f.LogLevelLabel.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let e=await a.getEnvDefaultTypeDefinition(this);t.env.types=(0,h.parseTypeDefinition)(`${e.file}#${e.name}`)}if(t.env.secrets)t.env.secrets=(0,h.parseTypeDefinition)(t.env.secrets);else{let e=await a.getSecretsDefaultTypeDefinition(this);t.env.secrets=(0,h.parseTypeDefinition)(`${e.file}#${e.name}`)}return t.env.prefix=(0,g.toArray)(t.env.prefix??[]).reduce((e,t)=>{let n=(0,x.constantCase)(t);return e.includes(n)||e.push(n),e},[..._.ENV_PREFIXES,`POWERLINES_`]),t.env.prefix=t.env.prefix.reduce((e,t)=>(e.includes(t.replace(/_$/g,``))||e.push(t.replace(/_$/g,``)),e),[]),t},async configResolved(){if(this.log(f.LogLevelLabel.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=(0,m.default)({parsed:await c.loadEnv(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&(0,v.existsSync)(a.getEnvTypeReflectionsPath(this,`env`)))this.log(f.LogLevelLabel.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await a.readEnvTypeReflection(this,`env`),(0,v.existsSync)(a.getEnvReflectionsPath(this,`env`))&&(this.env.used.env=await a.readEnvReflection(this)),(0,v.existsSync)(a.getEnvTypeReflectionsPath(this,`secrets`))&&(this.env.types.secrets=await a.readEnvTypeReflection(this,`secrets`)),(0,v.existsSync)(a.getEnvReflectionsPath(this,`secrets`))&&(this.env.used.secrets=await a.readSecretsReflection(this));else{if(this.env.types.env=await i.reflectEnv(this,this.config.env.types?.file?(0,p.isParentPath)(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:(0,b.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 a.writeEnvTypeReflection(this,this.env.types.env,`env`),this.env.types.secrets=await i.reflectSecrets(this,this.config.env.secrets?.file?(0,p.isParentPath)(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:(0,b.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 a.writeEnvTypeReflection(this,this.env.types.secrets,`secrets`),this.log(f.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 e=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await c.loadEnv(this,this.config.env)).forEach(([t,n])=>{let r=this.config.env.prefix.reduce((e,n)=>t.replace(/_$/g,``).startsWith(n)?t.replace(/_$/g,``).slice(n.length):e,t),i=e.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 n.type_exports.ReflectionClass({kind:n.type_exports.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 a.writeEnvReflection(this,this.env.used.env,`env`),this.env.types.secrets&&(await a.writeEnvTypeReflection(this,this.env.types.secrets,`secrets`),this.env.used.secrets=new n.type_exports.ReflectionClass({kind:n.type_exports.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 a.writeEnvReflection(this,this.env.used.secrets,`secrets`))}},render(){let e=this;return this.log(f.LogLevelLabel.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),(0,d.createComponent)(u.EnvBuiltin,{get defaultConfig(){return e.config.env.defaultConfig}})},async docs(){this.log(f.LogLevelLabel.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=(0,b.joinPaths)(this.config.projectRoot,`docs`,`generated`);(0,v.existsSync)(e)||await(0,y.createDirectory)(e);let t=await a.readEnvTypeReflection(this,`env`),r=(0,b.joinPaths)(e,`env.md`);this.log(f.LogLevelLabel.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by Powerlines -->
|
|
2
|
+
|
|
3
|
+
# Environment variables configuration
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## Environment Configuration
|
|
8
|
+
|
|
9
|
+
The below list of environment variables 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.
|
|
10
|
+
|
|
11
|
+
| Name | Description | Type | Default Value | Required |
|
|
12
|
+
| ---- | ----------- | ---- | ------------- | :------: |
|
|
13
|
+
${t.getProperties().filter(e=>e.getNameAsString()!==`__STORM_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(e=>`| ${e.getNameAsString().trim()} | ${(e.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
|
|
14
|
+
`,``)??``).trim()} | ${(0,n.type_exports.stringifyType)(e.getType()).trim().replaceAll(` | `,`, or `)} | ${e.hasDefault()?String(e.getDefaultValue())?.includes(`"`)?e.getDefaultValue():`\`${e.getDefaultValue()}\``:``} | ${e.isValueRequired()?``:`✔`} |`).join(`
|
|
15
|
+
`)}
|
|
16
|
+
`)},async buildEnd(){let e=a.getEnvReflectionsPath(this,`env`);this.log(f.LogLevelLabel.TRACE,`Writing env reflection types to ${e}.`),await a.writeEnvReflection(this,this.env.used.env,`env`)}}));var C=S;exports.default=C;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{createAlloyPlugin as e}from"../../alloy/src/create-plugin.mjs";import{type_exports as t}from"../../deepkit/src/vendor/type.mjs";import n from"../../plugin-babel/src/index.mjs";import{BaseEnv as r,BaseSecrets as i,createEnvReflection as a,createSecretsReflection as o,mergeEnvReflections as s,mergeSecretsReflections as c,reflectEnv as l,reflectSecrets as u}from"./helpers/reflect.mjs";import{getEnvDefaultTypeDefinition as d,getEnvReflectionsPath as f,getEnvTypeReflectionsPath as p,getSecretsDefaultTypeDefinition as m,readEnvReflection as h,readEnvTypeReflection as g,readSecretsReflection as _,resolveRuntimeTypeFile as v,writeEnvReflection as y,writeEnvTypeReflection as b}from"./helpers/persistence.mjs";import{envBabelPlugin as x}from"./babel/plugin.mjs";import{removeEnvPrefix as S}from"./helpers/source-file-env.mjs";import{loadEnv as C,loadEnvFromContext as w}from"./helpers/load.mjs";import{createReflectionResource as T}from"./helpers/create-reflection-resource.mjs";import{EnvBuiltin as E,EnvTypeDefinition as D}from"./components/env.mjs";import"./babel/index.mjs";import"./components/index.mjs";import"./helpers/index.mjs";import{createComponent as O}from"@alloy-js/core/jsx-runtime";import{LogLevelLabel as k}from"@storm-software/config-tools/types";import{isParentPath as A}from"@stryke/path/is-parent-path";import j from"defu";import{parseTypeDefinition as M}from"@stryke/convert/parse-type-definition";import{toArray as N}from"@stryke/convert/to-array";import{ENV_PREFIXES as P}from"@stryke/env/types";import{existsSync as F}from"@stryke/fs/exists";import{createDirectory as I}from"@stryke/fs/helpers";import{joinPaths as L}from"@stryke/path/join";import{constantCase as R}from"@stryke/string-format/constant-case";var z=e((e={})=>({name:`env`,dependsOn:[n(e.babel)],async config(){this.log(k.TRACE,"Providing default configuration for the Powerlines `env` build plugin.");let t={env:j(e,{types:{},prefix:[]}),transform:{babel:{plugins:[x]}}};if(t.env.types)t.env.types=M(t.env.types);else{this.log(k.WARN,"The `env.types` configuration parameter was not provided. Please ensure this is expected.");let e=await d(this);t.env.types=M(`${e.file}#${e.name}`)}if(t.env.secrets)t.env.secrets=M(t.env.secrets);else{let e=await m(this);t.env.secrets=M(`${e.file}#${e.name}`)}return t.env.prefix=N(t.env.prefix??[]).reduce((e,t)=>{let n=R(t);return e.includes(n)||e.push(n),e},[...P,`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(k.TRACE,`Environment plugin configuration has been resolved for the Powerlines project.`),this.config.env.inject??=this.config.projectType===`application`,this.env=j({parsed:await C(this,this.config.env)},this.env??{},{types:{env:{}},used:{env:{},secrets:{}},parsed:{},injected:{}}),this.config.command!==`prepare`&&this.persistedMeta?.checksum===this.meta.checksum&&F(p(this,`env`)))this.log(k.TRACE,`Skipping reflection initialization as the meta checksum has not changed.`),this.env.types.env=await g(this,`env`),F(f(this,`env`))&&(this.env.used.env=await h(this)),F(p(this,`secrets`))&&(this.env.types.secrets=await g(this,`secrets`)),F(f(this,`secrets`))&&(this.env.used.secrets=await _(this));else{if(this.env.types.env=await l(this,this.config.env.types?.file?A(this.config.env.types?.file,this.workspaceConfig.workspaceRoot)?this.config.env.types?.file:L(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 b(this,this.env.types.env,`env`),this.env.types.secrets=await u(this,this.config.env.secrets?.file?A(this.config.env.secrets?.file,this.workspaceConfig.workspaceRoot)?this.config.env.secrets?.file:L(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 b(this,this.env.types.secrets,`secrets`),this.log(k.TRACE,`Resolved ${this.env.types.env.getProperties().length??0} environment configuration parameters and ${this.env.types.secrets?.getProperties().length??0} secret configuration parameters`);let e=this.env.types.env.getProperties().filter(e=>e.getAlias().length>0);Object.entries(await C(this,this.config.env)).forEach(([t,n])=>{let r=this.config.env.prefix.reduce((e,n)=>t.replace(/_$/g,``).startsWith(n)?t.replace(/_$/g,``).slice(n.length):e,t),i=e.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 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 y(this,this.env.used.env,`env`),this.env.types.secrets&&(await b(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 y(this,this.env.used.secrets,`secrets`))}},render(){let e=this;return this.log(k.TRACE,`Preparing the Environment runtime artifacts for the Powerlines project.`),O(E,{get defaultConfig(){return e.config.env.defaultConfig}})},async docs(){this.log(k.TRACE,`Writing Environment documentation for the Powerlines project artifacts.`);let e=L(this.config.projectRoot,`docs`,`generated`);F(e)||await I(e);let n=await g(this,`env`),r=L(e,`env.md`);this.log(k.TRACE,`Documenting environment variables configuration in "${r}"`),await this.fs.write(r,`<!-- Generated by Powerlines -->
|
|
2
|
+
|
|
3
|
+
# Environment variables configuration
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
## Environment Configuration
|
|
8
|
+
|
|
9
|
+
The below list of environment variables 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.
|
|
10
|
+
|
|
11
|
+
| Name | Description | Type | Default Value | Required |
|
|
12
|
+
| ---- | ----------- | ---- | ------------- | :------: |
|
|
13
|
+
${n.getProperties().filter(e=>e.getNameAsString()!==`__STORM_INJECTED__`).sort((e,t)=>e.getNameAsString().localeCompare(t.getNameAsString())).map(e=>`| ${e.getNameAsString().trim()} | ${(e.getDescription()?.replaceAll(`\r`,``)?.replaceAll(`
|
|
14
|
+
`,``)??``).trim()} | ${(0,t.stringifyType)(e.getType()).trim().replaceAll(` | `,`, or `)} | ${e.hasDefault()?String(e.getDefaultValue())?.includes(`"`)?e.getDefaultValue():`\`${e.getDefaultValue()}\``:``} | ${e.isValueRequired()?``:`✔`} |`).join(`
|
|
15
|
+
`)}
|
|
16
|
+
`)},async buildEnd(){let e=f(this,`env`);this.log(k.TRACE,`Writing env reflection types to ${e}.`),await y(this,this.env.used.env,`env`)}}));export{z as default};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Reflection } from "../../../deepkit/src/types.cjs";
|
|
2
|
+
import { BabelPluginContext, BabelPluginOptions, BabelPluginResolvedConfig, BabelPluginUserConfig } from "../../../plugin-babel/src/types/plugin.cjs";
|
|
3
|
+
import { EnvInterface, SecretsInterface } from "./runtime.cjs";
|
|
4
|
+
import { DotenvConfiguration, TypeDefinition, TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
5
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
6
|
+
import { DotenvParseOutput } from "@stryke/env/types";
|
|
7
|
+
|
|
8
|
+
//#region ../plugin-env/src/types/plugin.d.ts
|
|
9
|
+
type EnvPluginOptions = Omit<DotenvConfiguration, "types"> & {
|
|
10
|
+
/**
|
|
11
|
+
* A path to the type definition for the expected env configuration parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `":"` or `"#"` character. For example: `"./src/types/env.ts#ConfigConfiguration"`.
|
|
12
|
+
*/
|
|
13
|
+
types?: TypeDefinitionParameter;
|
|
14
|
+
/**
|
|
15
|
+
* A path to the type definition for the expected env secret parameters. This value can include both a path to the typescript file and the name of the type definition to use separated by a `":"` or `"#"` character. For example: `"./src/types/env.ts#ConfigSecrets"`.
|
|
16
|
+
*/
|
|
17
|
+
secrets?: TypeDefinitionParameter;
|
|
18
|
+
/**
|
|
19
|
+
* An additional prefix (or list of additional prefixes) to apply to the environment variables
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* By default, the plugin will use the `POWERLINES_` prefix. This option is useful for avoiding conflicts with other environment variables.
|
|
23
|
+
*/
|
|
24
|
+
prefix?: string | string[];
|
|
25
|
+
/**
|
|
26
|
+
* Should the plugin inject the env variables in the source code with their values?
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* This option is set to `true` when building an application project.
|
|
30
|
+
*
|
|
31
|
+
* @defaultValue false
|
|
32
|
+
*/
|
|
33
|
+
inject?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The default configuration to use when loading environment variables.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* 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.
|
|
39
|
+
*/
|
|
40
|
+
defaultConfig?: Children;
|
|
41
|
+
/**
|
|
42
|
+
* Babel configuration options to use when injecting environment variables into the source code.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* This option allows you to customize the Babel transformation process used to inject environment variables into the source code. If not provided, the plugin will use default Babel settings.
|
|
46
|
+
*/
|
|
47
|
+
babel?: BabelPluginOptions;
|
|
48
|
+
};
|
|
49
|
+
type EnvPluginUserConfig = BabelPluginUserConfig & {
|
|
50
|
+
env: EnvPluginOptions;
|
|
51
|
+
};
|
|
52
|
+
type EnvPluginResolvedConfig = BabelPluginResolvedConfig & {
|
|
53
|
+
env: Required<Pick<DotenvConfiguration, "additionalFiles">> & Required<Pick<EnvPluginOptions, "defaultConfig">> & {
|
|
54
|
+
/**
|
|
55
|
+
* The type definition for the expected env variable parameters
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* This value is parsed from the {@link EnvPluginOptions.types} option.
|
|
59
|
+
*/
|
|
60
|
+
types: TypeDefinition;
|
|
61
|
+
/**
|
|
62
|
+
* The type definition for the expected env secret parameters
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* This value is parsed from the {@link EnvPluginOptions.secrets} option.
|
|
66
|
+
*/
|
|
67
|
+
secrets: TypeDefinition;
|
|
68
|
+
/**
|
|
69
|
+
* Should the plugin inject the env variables in the source code with their values?
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* This value is the result of reflecting the {@link EnvPluginOptions.inject} option.
|
|
73
|
+
*/
|
|
74
|
+
inject: EnvPluginOptions["inject"];
|
|
75
|
+
/**
|
|
76
|
+
* The prefix used for environment variables
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* This value is used to filter environment variables that are loaded from the .env file and the process environment.
|
|
80
|
+
*/
|
|
81
|
+
prefix: string[];
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
interface EnvPluginContext<TResolvedConfig extends EnvPluginResolvedConfig = EnvPluginResolvedConfig> extends BabelPluginContext<TResolvedConfig> {
|
|
85
|
+
env: {
|
|
86
|
+
/**
|
|
87
|
+
* The type definitions reflection for the env variables and secrets
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* These reflections contains the structure of the expected environment variables and secrets as defined by the type definitions provided in the plugin configuration.
|
|
91
|
+
*/
|
|
92
|
+
types: {
|
|
93
|
+
/**
|
|
94
|
+
* The type definitions for the expected env variables
|
|
95
|
+
*/
|
|
96
|
+
env: Reflection;
|
|
97
|
+
/**
|
|
98
|
+
* The type definitions for the expected env secrets
|
|
99
|
+
*/
|
|
100
|
+
secrets: Reflection;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* The current **used** environment variables and secrets reflection
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* This reflection contains the structure of the current environment variables and secrets as defined during the plugin initialization by extracting the values from the source code.
|
|
107
|
+
*/
|
|
108
|
+
used: {
|
|
109
|
+
/**
|
|
110
|
+
* The current env variables reflection
|
|
111
|
+
*/
|
|
112
|
+
env: Reflection<EnvInterface>;
|
|
113
|
+
/**
|
|
114
|
+
* The current env secrets reflection
|
|
115
|
+
*/
|
|
116
|
+
secrets: Reflection<SecretsInterface>;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* The parsed .env configuration object
|
|
120
|
+
*
|
|
121
|
+
* @remarks
|
|
122
|
+
* This value is the result of loading the .env configuration file found in the project root directory and merging it with the values provided at {@link EnvPluginOptions.values}
|
|
123
|
+
*/
|
|
124
|
+
parsed: DotenvParseOutput;
|
|
125
|
+
/**
|
|
126
|
+
* The injected environment variables and secrets reflection
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* This reflection contains the structure of the injected environment variables and secrets that were injected into the source code during the build process.
|
|
130
|
+
*/
|
|
131
|
+
injected: Reflection;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { EnvPluginContext, EnvPluginOptions, EnvPluginResolvedConfig, EnvPluginUserConfig };
|