dotsec 1.0.0-alpha.36 → 1.0.0-alpha.38

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/cli/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Ne=Object.create;var U=Object.defineProperty,qe=Object.defineProperties,Ke=Object.getOwnPropertyDescriptor,We=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,Ue=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable;var se=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,s=(e,t)=>{for(var r in t||(t={}))re.call(t,r)&&se(e,r,t[r]);if(ie)for(var r of ie(t))Je.call(t,r)&&se(e,r,t[r]);return e},P=(e,t)=>qe(e,We(t)),Me=e=>U(e,"__esModule",{value:!0});var Be=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ge(t))!re.call(e,n)&&n!=="default"&&U(e,n,{get:()=>t[n],enumerable:!(r=Ke(t,n))||r.enumerable});return e},h=e=>Be(Me(U(e!=null?Ne(Ue(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Ve=h(require("commander"));var N="dotsec.config.ts",ae=[N],B=".sec",Y=".env",k={};var ce=h(require("fs")),pe=h(require("node:path"));function Ye(e){try{return new Function(`return ${e.trim()}`)()}catch{return{}}}var le=async e=>{try{return Ye(await ce.default.promises.readFile(e,"utf8"))}catch(t){throw t instanceof Error?new Error(`Failed to parse ${pe.default.relative(process.cwd(),e)}: ${t.message}`):t}};var me=h(require("bundle-require")),de=h(require("joycon")),fe=h(require("path")),ue=async e=>{var i,l,p,a;let t=process.cwd(),n=await new de.default().resolve({files:e?[e]:[...ae,"package.json"],cwd:t,stopDir:fe.default.parse(t).root,packageKey:"dotsec"});if(e&&n===null)throw new Error(`Could not find config file ${e}`);if(n){if(n.endsWith(".json")){let c=await le(n),o;return n.endsWith("package.json")&&c.dotsec!==void 0?o=c.dotsec:o=c,{source:"json",contents:P(s(s({},k),o),{defaults:P(s(s({},o==null?void 0:o.defaults),k.defaults),{plugins:s(s({},(i=o==null?void 0:o.defaults)==null?void 0:i.plugins),(l=k.defaults)==null?void 0:l.plugins)}),push:s({},o==null?void 0:o.push)})}}else if(n.endsWith(".ts")){let c=await(0,me.bundleRequire)({filepath:n}),o=c.mod.dotsec||c.mod.default||c.mod;return{source:"ts",contents:P(s(s({},k),o),{defaults:P(s(s({},o==null?void 0:o.defaults),k.defaults),{plugins:s(s({},(p=o==null?void 0:o.defaults)==null?void 0:p.plugins),(a=k.defaults)==null?void 0:a.plugins)}),push:s({},o==null?void 0:o.push)})}}}return{source:"defaultConfig",contents:k}};var z=async e=>Promise.resolve().then(()=>h(require(e.name))).then(t=>t.default);var q=h(require("node:fs/promises")),ge=h(require("node:path")),ye=h(require("prompts")),J=async e=>await q.default.readFile(e,"utf-8"),V=async(e,t)=>await q.default.writeFile(e,t,"utf-8"),ze=async e=>{try{return await(0,q.stat)(e),!0}catch{return!1}},L=async({filePath:e,skip:t})=>{let r;return await ze(e)&&t!==!0?r=await(0,ye.default)({type:"confirm",name:"overwrite",message:()=>`Overwrite './${ge.default.relative(process.cwd(),e)}' ?`}):r=void 0,r};var he=h(require("chalk")),Ct=require("cli-table");var S=e=>he.default.yellow.bold(e);var Ee=h(require("commander"));var j={option:["--env-file <envFile>",`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${Y}' file in current directory.`,Y],env:"ENV_FILE"},_={option:["--sec-file <secFile>",`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${B}' file in current directory.`,B],env:"SEC_FILE"},K={option:["--with-env, --withEnv","Run command using a dot env file"]},W={option:["--with-sec, --withSec","Run command with a dotsec file"]},T={option:["--yes","Skip confirmation prompts"]};var Qe={decrypt:{inheritsFrom:["dotsec"],options:{envFile:j,secFile:_,yes:T}}},Oe=Qe;var Xe={dotsec:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",N],plugin:["--plugin <plugin>","Comma-separated list of plugins to use"]}}},G=Xe;var Ze={encrypt:{inheritsFrom:["dotsec"],options:{envFile:j,secFile:_,yes:T}}},Ce=Ze;var et={init:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",N],envFile:j,secFile:_,yes:T}}},we=et;var tt={pull:{inheritsFrom:["dotsec"],options:{withEnv:K,withSec:W,envFile:j,secFile:_,yes:T}}},M=tt;var ot={runEnvOnly:{inheritsFrom:["dotsec"],usage:"[commandArgs...]",options:{envFile:j,yes:T},description:"Run a command in a separate process and populate env with contents of a dotenv file.",helpText:`Examples:
1
+ var Ke=Object.create;var J=Object.defineProperty,We=Object.defineProperties,Ge=Object.getOwnPropertyDescriptor,Ue=Object.getOwnPropertyDescriptors,Je=Object.getOwnPropertyNames,re=Object.getOwnPropertySymbols,Me=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable;var ae=(e,t,r)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var r in t||(t={}))se.call(t,r)&&ae(e,r,t[r]);if(re)for(var r of re(t))Be.call(t,r)&&ae(e,r,t[r]);return e},P=(e,t)=>We(e,Ue(t)),ze=e=>J(e,"__esModule",{value:!0});var Qe=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Je(t))!se.call(e,o)&&o!=="default"&&J(e,o,{get:()=>t[o],enumerable:!(r=Ge(t,o))||r.enumerable});return e},h=e=>Qe(ze(J(e!=null?Ke(Me(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Re=h(require("commander"));var q="dotsec.config.ts",ce=[q],z=".sec",Q=".env",V={};var pe=h(require("fs")),le=h(require("node:path"));function Xe(e){try{return new Function(`return ${e.trim()}`)()}catch{return{}}}var me=async e=>{try{return Xe(await pe.default.promises.readFile(e,"utf8"))}catch(t){throw t instanceof Error?new Error(`Failed to parse ${le.default.relative(process.cwd(),e)}: ${t.message}`):t}};var de=h(require("bundle-require")),fe=h(require("joycon")),ue=h(require("path")),ge=async e=>{var n,a,l,s;let t=process.cwd(),o=await new fe.default().resolve({files:e?[e]:[...ce,"package.json"],cwd:t,stopDir:ue.default.parse(t).root,packageKey:"dotsec"});if(e&&o===null)throw new Error(`Could not find config file ${e}`);if(o){if(o.endsWith(".json")){let p=await me(o),i;return o.endsWith("package.json")&&p.dotsec!==void 0?i=p.dotsec:i=p,{source:"json",contents:P(c(c({},V),i),{defaults:P(c(c({},i==null?void 0:i.defaults),V.defaults),{plugins:c(c({},(n=i==null?void 0:i.defaults)==null?void 0:n.plugins),(a=V.defaults)==null?void 0:a.plugins)}),push:c({},i==null?void 0:i.push)})}}else if(o.endsWith(".ts")){let p=await(0,de.bundleRequire)({filepath:o}),i=p.mod.dotsec||p.mod.default||p.mod;return{source:"ts",contents:P(c(c({},V),i),{defaults:P(c(c({},i==null?void 0:i.defaults),V.defaults),{plugins:c(c({},(l=i==null?void 0:i.defaults)==null?void 0:l.plugins),(s=V.defaults)==null?void 0:s.plugins)}),push:c({},i==null?void 0:i.push)})}}}return{source:"defaultConfig",contents:V}};var X=async e=>Promise.resolve().then(()=>h(require(e.name))).then(t=>t.default);var ye=h(require("commander")),_=(e,t,r)=>{e&&Object.values(e).map(o=>{let n;if(Array.isArray(o)){let[a,l,s]=o;n={flags:a,description:l,defaultValue:s}}else{let{flags:a,description:l,defaultValue:s,env:p,fn:i}=o;n={flags:a,description:l,defaultValue:s,env:p,fn:i}}if(n){let a=new ye.Option(n.flags,n.description);n.fn&&a.argParser(n.fn),n.defaultValue&&a.default(n.defaultValue),n.env&&a.env(n.env),r&&a.makeOptionMandatory(!0),t.addOption(a)}})};var K=h(require("node:fs/promises")),he=h(require("node:path")),Ce=h(require("prompts")),M=async e=>await K.default.readFile(e,"utf-8"),N=async(e,t)=>await K.default.writeFile(e,t,"utf-8"),Ye=async e=>{try{return await(0,K.stat)(e),!0}catch{return!1}},R=async({filePath:e,skip:t})=>{let r;return await Ye(e)&&t!==!0?r=await(0,Ce.default)({type:"confirm",name:"overwrite",message:()=>`Overwrite './${he.default.relative(process.cwd(),e)}' ?`}):r=void 0,r};var Oe=h(require("chalk")),Et=require("cli-table");var x=e=>Oe.default.yellow.bold(e);var Fe=h(require("commander"));var T={option:["--env-file <envFile>",`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${Q}' file in current directory.`,Q],env:"ENV_FILE"},k={option:["--sec-file, <secFile>",`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${z}' file in current directory.`,z],env:"SEC_FILE"},W={option:["--with-env, --withEnv","Run command using a dot env file"]},G={option:["--with-sec, --withSec","Run command with a dotsec file"]},j={option:["--yes","Skip confirmation prompts"]};var Ze={decrypt:{inheritsFrom:["dotsec"],options:{envFile:T,secFile:k,yes:j}}},we=Ze;var et={dotsec:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",q],plugin:["--plugin <plugin>","Comma-separated list of plugins to use"]}}},U=et;var tt={encrypt:{inheritsFrom:["dotsec"],options:{envFile:T,secFile:k,yes:j}}},ve=tt;var ot={init:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",q],envFile:T,secFile:k,yes:j}}},De=ot;var nt={pull:{inheritsFrom:["dotsec"],options:{withEnv:W,withSec:G,envFile:T,secFile:k,yes:j}}},B=nt;var it={runEnvOnly:{inheritsFrom:["dotsec"],usage:"[commandArgs...]",options:{envFile:T,yes:j},description:"Run a command in a separate process and populate env with contents of a dotenv file.",helpText:`Examples:
2
2
 
3
3
  Run a command with a .env file
4
4
 
@@ -13,7 +13,7 @@ Run a command with a specific ENV_FILE variable
13
13
 
14
14
  $ ENV_FILE=.env.dev dotsec run echo "hello world"
15
15
 
16
- `},run:{inheritsFrom:["dotsec"],options:{withEnv:K,withSec:W,envFile:j,secFile:_,yes:T},usage:"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]",description:`Run a command in a separate process and populate env with either
16
+ `},run:{inheritsFrom:["dotsec"],options:{withEnv:W,withSec:G,envFile:T,secFile:k,yes:j},usage:"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]",description:`Run a command in a separate process and populate env with either
17
17
  - contents of a dotenv file
18
18
  - decrypted values of a dotsec file.
19
19
 
@@ -37,5 +37,5 @@ $ dotsec run --with-sec echo "hello world"
37
37
  Run a command with a specific .sec file
38
38
 
39
39
  $ dotsec run --with-sec --sec-file .sec.dev echo "hello world"
40
- `},push:{options:P(s({},G.dotsec.options),{withEnv:K,withSec:W,envFile:j,secFile:_,yes:T}),requiredOptions:s({},G.dotsec.requiredOptions)}},ve=ot;var nt=s(s(s(s(s(s(s({},G),we),Ce),Oe),ve),M),M);var it=e=>Array.isArray(e)?{option:e}:e,De=(e,t)=>{let r=it(e),[n,i,l]=r.option,p=new Ee.Option(n,i);return l&&p.default(l),r.env&&p.env(r.env),(t==null?void 0:t.required)&&p.makeOptionMandatory(!0),p},$=(e,t)=>{let r=nt[t||e.name()];if(r){let{options:n,requiredOptions:i,description:l,usage:p,helpText:a}=r;n&&Object.values(n).forEach(c=>{let o=De(c);e.addOption(o)}),i&&Object.values(i).forEach(c=>{let o=De(c,{required:!0});e.addOption(o)}),l&&e.description(l),p&&e.description(p),a&&e.description(a)}};var rt=async(e,t)=>{let{dotsecConfig:r,decryptHandlers:n}=t,i=e.enablePositionalOptions().passThroughOptions().command("decrypt").action(async(p,a)=>{var c;try{let{envFile:o,secFile:m,engine:f,yes:E}=a.optsWithGlobals(),D=f||((c=r==null?void 0:r.defaults)==null?void 0:c.encryptionEngine),F=(n||[]).find(w=>w.triggerOptionValue===D);if(!F)throw new Error(`No decryption plugin found, available decryption engine(s): ${t.decryptHandlers.map(w=>`--${w.triggerOptionValue}`).join(", ")}`);let u=[...Object.keys(F.options||{}),...Object.keys(F.requiredOptions||{})],d=Object.fromEntries(u.map(w=>[w,p[w]])),g=await J(m),O=await F.handler(s({ciphertext:g},d)),y=await L({filePath:o,skip:E});(y===void 0||y.overwrite===!0)&&(await V(o,O),console.log(`Wrote plaintext contents of ${S(m)} file to ${S(o)}`))}catch(o){console.error(S(o.message)),a.help()}});t.decryptHandlers.map(p=>{let{options:a,requiredOptions:c}=p;a&&Object.values(a).map(o=>{i.option(...o)}),c&&Object.values(c).map(o=>{i.option(...o)})});let l=t.decryptHandlers.map(p=>p.triggerOptionValue);return i.option("--engine <engine>",`Encryption engine${l.length>0?"s":""} to use: ${l.join(", "),l.length===1?l[0]:void 0}`,l.length===1?l[0]:void 0),$(i),i},Fe=rt;var st=async(e,t)=>{let{encryptHandlers:r,dotsecConfig:n}=t,i=e.enablePositionalOptions().passThroughOptions().command("encrypt").action(async(a,c)=>{var o;try{let{envFile:m,secFile:f,engine:E,yes:D}=c.optsWithGlobals(),F=E||((o=n==null?void 0:n.defaults)==null?void 0:o.encryptionEngine),u=(r||[]).find(C=>C.triggerOptionValue===F);if(!u)throw new Error(`No encryption plugin found, available encryption engine(s): ${t.encryptHandlers.map(C=>C.triggerOptionValue).join(", ")}`);let d=[...Object.keys(u.options||{}),...Object.keys(u.requiredOptions||{})],g=Object.fromEntries(d.map(C=>[C,a[C]])),O=await J(m),y=await u.handler(s({plaintext:O},g)),w=await L({filePath:f,skip:D});(w===void 0||w.overwrite===!0)&&(await V(f,y),console.log(`Wrote encrypted contents of ${S(m)} file to ${S(f)}`))}catch(m){console.error(S(m.message)),c.help()}});t.encryptHandlers.map(a=>{let{options:c,requiredOptions:o}=a;c&&Object.values(c).map(m=>{i.option(...m)}),o&&Object.values(o).map(m=>{i.option(...m)})});let l=t.encryptHandlers.map(a=>a.triggerOptionValue),p=t.encryptHandlers.map(a=>a.encryptionEngineName);return i.option("--engine <engine>",`Encryption engine${l.length>0?"s":""}: ${l.join(", "),l.length===1?l[0]:void 0}`),$(i),i.description(`Encrypt .env file using ${p.join(", ")}`),i},Pe=st;var be=h(require("node:fs")),v=h(require("typescript")),xe=e=>{let t=v.createPrinter(),r=be.default.readFileSync(e.configFile,"utf8"),n=c=>o=>{function m(f){var E,D,F,u,d,g,O,y,w,C,b,x,R,Z,ee,te,oe,ne;if(f=v.visitEachChild(f,m,c),f.kind===v.SyntaxKind.StringLiteral){let I=(D=(E=f==null?void 0:f.parent)==null?void 0:E.parent)==null?void 0:D.parent;if(((d=(u=(F=e.config)==null?void 0:F.aws)==null?void 0:u.kms)==null?void 0:d.keyAlias)&&((g=I==null?void 0:I.getChildAt(0))==null?void 0:g.getText())==="kms"){let H=(O=I==null?void 0:I.parent)==null?void 0:O.parent;if((H==null?void 0:H.getChildAt(0).getText())==="aws")return v.createStringLiteral((C=(w=(y=e.config)==null?void 0:y.aws)==null?void 0:w.kms)==null?void 0:C.keyAlias)}if(((x=(b=e.config)==null?void 0:b.aws)==null?void 0:x.region)&&((Z=(R=f==null?void 0:f.parent)==null?void 0:R.getChildAt(0))==null?void 0:Z.getText())==="region"){let H=(te=(ee=f==null?void 0:f.parent)==null?void 0:ee.parent)==null?void 0:te.parent;if((H==null?void 0:H.getChildAt(0).getText())==="aws")return v.createStringLiteral((ne=(oe=e.config)==null?void 0:oe.aws)==null?void 0:ne.region)}}return f}return v.visitNode(o,m)},i=v.createSourceFile("test.ts",r,v.ScriptTarget.ES2015,!0,v.ScriptKind.TS),l=v.transform(i,[n]),p=l.transformed[0],a=t.printFile(p);return l.dispose(),a};var Se=h(require("node:path")),at=async e=>{let t=e.enablePositionalOptions().passThroughOptions().command("init").action(async(r,n)=>{let{configFile:i,yes:l}=n.optsWithGlobals();try{let p=xe({configFile:Se.default.resolve(__dirname,"../../src/templates/dotsec.config.ts")}),a=await L({filePath:i,skip:l});(a===void 0||a.overwrite===!0)&&(await V(i,p),console.log(`Wrote config file to ${S(i)}`))}catch(p){n.error(p)}});return $(t),t},je=at;var Te=h(require("dotenv")),$e=h(require("dotenv-expand")),Q=h(require("node:fs")),ct=async(e,t)=>{let{dotsecConfig:r,handlers:n}=t,i=e.enablePositionalOptions().passThroughOptions().command("push").action(async(l,p)=>{var a,c,o;try{let{envFile:m,secFile:f,withEnv:E,withSec:D,engine:F,yes:u}=p.optsWithGlobals(),d=F||((a=r==null?void 0:r.defaults)==null?void 0:a.encryptionEngine),g=(c=(n||[]).find(b=>{var x;return((x=b.decrypt)==null?void 0:x.triggerOptionValue)===d}))==null?void 0:c.decrypt,O=(o=(n||[]).find(b=>{var x;return((x=b.push)==null?void 0:x.triggerOptionValue)===d}))==null?void 0:o.push;if(!O)throw new Error("No push plugin found!");let y=[...Object.keys((g==null?void 0:g.options)||{}),...Object.keys((g==null?void 0:g.requiredOptions)||{}),...Object.keys((O==null?void 0:O.options)||{}),...Object.keys((O==null?void 0:O.requiredOptions)||{})],w=Object.fromEntries(y.map(b=>[b,l[b]]));if(E&&D)throw new Error("Cannot use both --with-env and --with-sec");let C;if(E||!(E||D)){if(!m)throw new Error("No dotenv file specified in --env-file option");C=Q.default.readFileSync(m,"utf8")}else if(D){if(!f)throw new Error("No dotsec file specified in --sec-file option");if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${n.map(x=>{var R;return`--${(R=x.decrypt)==null?void 0:R.triggerOptionValue}`}).join(", ")}`);let b=Q.default.readFileSync(f,"utf8");C=await g.handler(s({ciphertext:b},w))}if(C){let b=(0,Te.parse)(C),x=(0,$e.expand)({ignoreProcessEnv:!0,parsed:s(s({},process.env),b)});x.parsed&&await O.handler(s({push:x.parsed,yes:u},w))}else throw new Error("No .env or .sec file provided")}catch(m){console.error(m),process.exit(1)}});return $(i),i},_e=ct;var X=h(require("node:fs")),Ae=h(require("dotenv")),ke=h(require("dotenv-expand"));var He=h(require("node:child_process")),pt=(e,t)=>{let{dotsecConfig:r,decryptHandlers:n}=t||{},i=n!==void 0&&n.length>0,l=e.command("run <command...>").allowUnknownOption(!0).enablePositionalOptions().passThroughOptions().showHelpAfterError(!0).action(async(p,a,c)=>{var o;console.log("yo");try{let{envFile:m,secFile:f,withEnv:E,withSec:D,engine:F}=c.optsWithGlobals();if(console.log({envFile:m,secFile:f,withEnv:E,withSec:D,engine:F}),E&&D)throw new Error("Cannot use both --with-env and --with-sec");let u;if(E||!(E||D)||i===!1){if(console.log("ENV ONLY"),!m)throw new Error("No dotenv file specified in --env-file option");u=X.default.readFileSync(m,"utf8"),console.log("envCOntents",u)}else if(D){if(!f)throw new Error("No dotsec file specified in --sec-file option");let d=F||((o=r==null?void 0:r.defaults)==null?void 0:o.encryptionEngine),g=(n||[]).find(C=>C.triggerOptionValue===d);if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${(n||[]).map(C=>`--${C.triggerOptionValue}`).join(", ")}`);let O=[...Object.keys(g.options||{}),...Object.keys(g.requiredOptions||{})],y=Object.fromEntries(O.map(C=>[C,a[C]])),w=X.default.readFileSync(f,"utf8");u=await g.handler(s({ciphertext:w},y))}if(u){let d=(0,Ae.parse)(u),g=(0,ke.expand)({ignoreProcessEnv:!0,parsed:s(s({},process.env),d)}),[O,...y]=p,w=(0,He.spawnSync)(O,[...y],{stdio:"inherit",shell:!1,encoding:"utf-8",env:P(s(s({},g.parsed),process.env),{__DOTSEC_ENV__:JSON.stringify(Object.keys(d))})});w.status!==0&&process.exit(w.status||1)}else throw new Error("No .env or .sec file provided")}catch(m){console.error(S(m.message)),c.help()}});if($(l,i?"run":"runEnvOnly"),i){n==null||n.map(a=>{let{options:c,requiredOptions:o}=a;c&&Object.values(c).map(m=>{l.option(...m)}),o&&Object.values(o).map(m=>{l.option(...m)})});let p=n==null?void 0:n.map(a=>a.triggerOptionValue);l.option("--engine <engine>",`Encryption engine${p.length>0?"s":""}: ${p.join(", "),p.length===1?p[0]:void 0}`)}return l},Ie=pt;var Le=h(require("ajv")),Re=h(require("yargs-parser")),lt={keyword:"separator",type:"string",metaSchema:{type:"string",description:"value separator"},modifying:!0,valid:!0,errors:!1,compile:e=>(t,r)=>{if(r){let{parentData:n,parentDataProperty:i}=r;return n[i]=t===""?[]:t.split(e),!0}else return!1}},A=new Ve.Command;(async()=>{var f,E,D,F;let e=(0,Re.default)(process.argv),t=[];e.plugin&&(Array.isArray(e.plugin)?t.push(...e.plugin):t.push(e.plugin));let r=[...Array.isArray(e.config)?e.config:[e.config],...Array.isArray(e.c)?e.c:[e.c]][0],{contents:n={}}=await ue(r),{defaults:i,push:l}=n;A.name("dotsec").description(".env, but secure").version("1.0.0").enablePositionalOptions().action((u,d)=>{d.help()}),$(A);let p=new Le.default({allErrors:!0,removeAdditional:!0,useDefaults:!0,coerceTypes:!0,allowUnionTypes:!0,addUsedSchema:!1,keywords:[lt]}),a={};if(t.length>0)for(let u of t){let g=await(await z({name:u}))({dotsecConfig:n,ajv:p});a[g.name]=u,t.length===1&&(n.defaults=P(s({},n.defaults),{encryptionEngine:String(g.name),plugins:P(s({},(f=n.defaults)==null?void 0:f.plugins),{[g.name]:s({},(D=(E=n.defaults)==null?void 0:E.plugins)==null?void 0:D[g.name])})}))}(i==null?void 0:i.encryptionEngine)&&(((F=i==null?void 0:i.plugins)==null?void 0:F[i.encryptionEngine])||(i.plugins=P(s({},i.plugins),{[i.encryptionEngine]:{}}))),(i==null?void 0:i.plugins)&&Object.entries(i==null?void 0:i.plugins).forEach(([u,d])=>{(d==null?void 0:d.module)?a[u]=d==null?void 0:d.module:a[u]=`@dotsec/plugin-${u}`}),Object.values(l||{}).forEach(u=>{Object.keys(u).forEach(d=>{a[d]||(a[d]=`@dotsec/plugin-${d}`)})});let c=[],o=[],m=[];for(let u of Object.keys(a)){let d=a[u],g=await z({name:d}),{addCliCommand:O,cliHandlers:y}=await g({ajv:p,dotsecConfig:n});(y==null?void 0:y.encrypt)&&c.push(y.encrypt),(y==null?void 0:y.decrypt)&&(o.push(y.decrypt),(y==null?void 0:y.push)&&m.push({push:y.push,decrypt:y.decrypt})),O&&O({program:A})}c.length&&await Pe(A,{dotsecConfig:n,encryptHandlers:c}),o.length&&await Fe(A,{dotsecConfig:n,decryptHandlers:o}),m.length&&await _e(A,{dotsecConfig:n,handlers:m}),await je(A),await Ie(A,{dotsecConfig:n,decryptHandlers:o}),await A.parse()})();
40
+ `},push:{options:P(c({},U.dotsec.options),{withEnv:W,withSec:G,envFile:T,secFile:k,yes:j}),requiredOptions:c({},U.dotsec.requiredOptions)}},Ee=it;var rt=c(c(c(c(c(c(c({},U),De),ve),we),Ee),B),B);var st=e=>Array.isArray(e)?{option:e}:e,Pe=(e,t)=>{var p,i,m;let r=st(e),[o,n,a]=r.option,l=(m=(i=(p=t==null?void 0:t.dotsecConfig)==null?void 0:p.defaults)==null?void 0:i.options)==null?void 0:m[t==null?void 0:t.optionKey];console.log("defaultOptionValueFromConfig",t==null?void 0:t.optionKey,l);let s=new Fe.Option(o,n+(l?". Default from config.":""));return a&&s.default(l||a),r.env&&s.env(r.env),(t==null?void 0:t.required)&&s.makeOptionMandatory(!0),s},$=e=>{let{program:t,commandName:r,dotsecConfig:o}=e,n=rt[r||t.name()];if(n){let{options:a,requiredOptions:l,description:s,usage:p,helpText:i}=n;a&&Object.keys(a).forEach(m=>{let d=a[m],O=Pe(d,{dotsecConfig:o,optionKey:m});t.addOption(O)}),l&&Object.keys(l).forEach(m=>{let d=l[m],O=Pe(d,{required:!0,dotsecConfig:o,optionKey:m});t.addOption(O)}),s&&t.description(s),p&&t.description(p),i&&t.description(i)}};var at=async(e,t)=>{let{dotsecConfig:r,decryptHandlers:o}=t,n=e.enablePositionalOptions().passThroughOptions().command("decrypt").action(async(l,s)=>{var p;try{let{envFile:i,secFile:m,engine:d,yes:O}=s.optsWithGlobals(),F=d||((p=r==null?void 0:r.defaults)==null?void 0:p.encryptionEngine),E=(o||[]).find(v=>v.triggerOptionValue===F);if(!E)throw new Error(`No decryption plugin found, available decryption engine(s): ${t.decryptHandlers.map(v=>`--${v.triggerOptionValue}`).join(", ")}`);console.log("Decrypting with",x(E.encryptionEngineName||E.triggerOptionValue),"engine");let f=[...Object.keys(E.options||{}),...Object.keys(E.requiredOptions||{})],u=Object.fromEntries(f.map(v=>[v,l[v]])),g=await M(m),C=await E.handler(c({ciphertext:g},u)),y=await R({filePath:i,skip:O});(y===void 0||y.overwrite===!0)&&(await N(i,C),console.log(`Wrote plaintext contents of ${x(m)} file to ${x(i)}`))}catch(i){console.error(x(i.message)),s.help()}});t.decryptHandlers.map(l=>{let{options:s,requiredOptions:p}=l;_(s,n),_(p,n,!0)});let a=t.decryptHandlers.map(l=>l.triggerOptionValue);return n.option("--engine <engine>",`Encryption engine${a.length>0?"s":""} to use: ${a.length===1?a[0]:a.join(", ")}`,a.length===1?a[0]:void 0),$({program:n,dotsecConfig:r}),n},xe=at;var ct=async(e,t)=>{let{encryptHandlers:r,dotsecConfig:o}=t,n=e.enablePositionalOptions().passThroughOptions().command("encrypt").action(async(s,p)=>{var i;try{let{envFile:m,secFile:d,engine:O,yes:F}=p.optsWithGlobals(),E=O||((i=o==null?void 0:o.defaults)==null?void 0:i.encryptionEngine),f=(r||[]).find(w=>w.triggerOptionValue===E);if(!f)throw new Error(`No encryption plugin found, available encryption engine(s): ${t.encryptHandlers.map(w=>w.triggerOptionValue).join(", ")}`);console.log("Encrypting with",x(f.encryptionEngineName||f.triggerOptionValue),"engine");let u=[...Object.keys(f.options||{}),...Object.keys(f.requiredOptions||{})],g=Object.fromEntries(u.map(w=>[w,s[w]])),C=await M(m),y=await f.handler(c({plaintext:C},g)),v=await R({filePath:d,skip:F});(v===void 0||v.overwrite===!0)&&(await N(d,y),console.log(`Wrote encrypted contents of ${x(m)} file to ${x(d)}`))}catch(m){console.error(x(m.message)),p.help()}});t.encryptHandlers.map(s=>{let{options:p,requiredOptions:i}=s;_(p,n),_(i,n,!0)});let a=t.encryptHandlers.map(s=>s.triggerOptionValue),l=t.encryptHandlers.map(s=>s.encryptionEngineName);return n.option("--engine <engine>",`Encryption engine${a.length>0?"s":""}: ${a.length===1?a[0]:a.join(", ")}`),$({program:n,dotsecConfig:o}),n.description(`Encrypt .env file using ${l.join(", ")}`),n},be=ct;var Se=h(require("node:fs")),D=h(require("typescript")),Te=e=>{let t=D.createPrinter(),r=Se.default.readFileSync(e.configFile,"utf8"),o=p=>i=>{function m(d){var O,F,E,f,u,g,C,y,v,w,b,S,L,ee,te,oe,ne,ie;if(d=D.visitEachChild(d,m,p),d.kind===D.SyntaxKind.StringLiteral){let I=(F=(O=d==null?void 0:d.parent)==null?void 0:O.parent)==null?void 0:F.parent;if(((u=(f=(E=e.config)==null?void 0:E.aws)==null?void 0:f.kms)==null?void 0:u.keyAlias)&&((g=I==null?void 0:I.getChildAt(0))==null?void 0:g.getText())==="kms"){let H=(C=I==null?void 0:I.parent)==null?void 0:C.parent;if((H==null?void 0:H.getChildAt(0).getText())==="aws")return D.createStringLiteral((w=(v=(y=e.config)==null?void 0:y.aws)==null?void 0:v.kms)==null?void 0:w.keyAlias)}if(((S=(b=e.config)==null?void 0:b.aws)==null?void 0:S.region)&&((ee=(L=d==null?void 0:d.parent)==null?void 0:L.getChildAt(0))==null?void 0:ee.getText())==="region"){let H=(oe=(te=d==null?void 0:d.parent)==null?void 0:te.parent)==null?void 0:oe.parent;if((H==null?void 0:H.getChildAt(0).getText())==="aws")return D.createStringLiteral((ie=(ne=e.config)==null?void 0:ne.aws)==null?void 0:ie.region)}}return d}return D.visitNode(i,m)},n=D.createSourceFile("test.ts",r,D.ScriptTarget.ES2015,!0,D.ScriptKind.TS),a=D.transform(n,[o]),l=a.transformed[0],s=t.printFile(l);return a.dispose(),s};var je=h(require("node:path")),pt=async(e,t)=>{let{dotsecConfig:r}=t,o=e.enablePositionalOptions().passThroughOptions().command("init").action(async(n,a)=>{let{configFile:l,yes:s}=a.optsWithGlobals();try{let p=Te({configFile:je.default.resolve(__dirname,"../../src/templates/dotsec.config.ts")}),i=await R({filePath:l,skip:s});(i===void 0||i.overwrite===!0)&&(await N(l,p),console.log(`Wrote config file to ${x(l)}`))}catch(p){a.error(p)}});return $({program:o,dotsecConfig:r}),o},$e=pt;var ke=h(require("dotenv")),_e=h(require("dotenv-expand")),Y=h(require("node:fs")),lt=async(e,t)=>{let{dotsecConfig:r,handlers:o}=t,n=e.enablePositionalOptions().passThroughOptions().command("push").action(async(a,l)=>{var s,p,i;try{let{envFile:m,secFile:d,withEnv:O,withSec:F,engine:E,yes:f}=l.optsWithGlobals(),u=E||((s=r==null?void 0:r.defaults)==null?void 0:s.encryptionEngine),g=(p=(o||[]).find(b=>{var S;return((S=b.decrypt)==null?void 0:S.triggerOptionValue)===u}))==null?void 0:p.decrypt,C=(i=(o||[]).find(b=>{var S;return((S=b.push)==null?void 0:S.triggerOptionValue)===u}))==null?void 0:i.push;if(!C)throw new Error("No push plugin found!");let y=[...Object.keys((g==null?void 0:g.options)||{}),...Object.keys((g==null?void 0:g.requiredOptions)||{}),...Object.keys((C==null?void 0:C.options)||{}),...Object.keys((C==null?void 0:C.requiredOptions)||{})],v=Object.fromEntries(y.map(b=>[b,a[b]]));if(O&&F)throw new Error("Cannot use both --with-env and --with-sec");let w;if(O||!(O||F)){if(!m)throw new Error("No dotenv file specified in --env-file option");w=Y.default.readFileSync(m,"utf8")}else if(F){if(!d)throw new Error("No dotsec file specified in --sec-file option");if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${o.map(S=>{var L;return`--${(L=S.decrypt)==null?void 0:L.triggerOptionValue}`}).join(", ")}`);let b=Y.default.readFileSync(d,"utf8");w=await g.handler(c({ciphertext:b},v))}if(w){let b=(0,ke.parse)(w),S=(0,_e.expand)({ignoreProcessEnv:!0,parsed:c(c({},process.env),b)});S.parsed&&await C.handler(c({push:S.parsed,yes:f},v))}else throw new Error("No .env or .sec file provided")}catch(m){console.error(m),process.exit(1)}});return $({program:n,dotsecConfig:r}),n},Ae=lt;var Z=h(require("node:fs")),Ve=h(require("dotenv")),He=h(require("dotenv-expand"));var Ie=h(require("node:child_process")),mt=(e,t)=>{let{dotsecConfig:r,decryptHandlers:o}=t||{},n=o!==void 0&&o.length>0,a=e.command("run <command...>").allowUnknownOption(!0).enablePositionalOptions().passThroughOptions().showHelpAfterError(!0).action(async(l,s,p)=>{var i;try{let{envFile:m,secFile:d,withEnv:O,withSec:F,engine:E}=p.optsWithGlobals();if(O&&F)throw new Error("Cannot use both --with-env and --with-sec");let f;if(O||!(O||F)||n===!1){if(!m)throw new Error("No dotenv file specified in --env-file option");f=Z.default.readFileSync(m,"utf8")}else if(F){if(!d)throw new Error("No dotsec file specified in --sec-file option");let u=E||((i=r==null?void 0:r.defaults)==null?void 0:i.encryptionEngine),g=(o||[]).find(w=>w.triggerOptionValue===u);if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${(o||[]).map(w=>`--${w.triggerOptionValue}`).join(", ")}`);let C=[...Object.keys(g.options||{}),...Object.keys(g.requiredOptions||{})],y=Object.fromEntries(C.map(w=>[w,s[w]])),v=Z.default.readFileSync(d,"utf8");f=await g.handler(c({ciphertext:v},y))}if(f){let u=(0,Ve.parse)(f),g=(0,He.expand)({ignoreProcessEnv:!0,parsed:c(c({},process.env),u)}),[C,...y]=l,v=(0,Ie.spawnSync)(C,[...y],{stdio:"inherit",shell:!1,encoding:"utf-8",env:P(c(c({},g.parsed),process.env),{__DOTSEC_ENV__:JSON.stringify(Object.keys(u))})});v.status!==0&&process.exit(v.status||1)}else throw new Error("No .env or .sec file provided")}catch(m){console.error(x(m.message)),p.help()}});if($({program:a,commandName:n?"run":"runEnvOnly",dotsecConfig:r}),n){o==null||o.map(s=>{let{options:p,requiredOptions:i}=s;_(p,a),_(i,a,!0)});let l=o==null?void 0:o.map(s=>s.triggerOptionValue);a.option("--engine <engine>",`Encryption engine${l.length>0?"s":""}: ${l.join(", "),l.length===1?l[0]:void 0}`)}return a},Ne=mt;var Le=h(require("ajv")),qe=h(require("yargs-parser")),dt={keyword:"separator",type:"string",metaSchema:{type:"string",description:"value separator"},modifying:!0,valid:!0,errors:!1,compile:e=>(t,r)=>{if(r){let{parentData:o,parentDataProperty:n}=r;return o[n]=t===""?[]:t.split(e),!0}else return!1}},A=new Re.Command;(async()=>{var d,O,F,E;let e=(0,qe.default)(process.argv),t=[];e.plugin&&(Array.isArray(e.plugin)?t.push(...e.plugin):t.push(e.plugin));let r=[...Array.isArray(e.config)?e.config:[e.config],...Array.isArray(e.c)?e.c:[e.c]][0],{contents:o={}}=await ge(r),{defaults:n,push:a}=o;A.name("dotsec").description(".env, but secure").version("1.0.0").enablePositionalOptions().action((f,u)=>{u.help()}),$({program:A,dotsecConfig:o});let l=new Le.default({allErrors:!0,removeAdditional:!0,useDefaults:!0,coerceTypes:!0,allowUnionTypes:!0,addUsedSchema:!1,keywords:[dt]}),s={};if(t.length>0)for(let f of t){let g=await(await X({name:f}))({dotsecConfig:o,ajv:l,configFile:r});s[g.name]=f,t.length===1&&(o.defaults=P(c({},o.defaults),{encryptionEngine:String(g.name),plugins:P(c({},(d=o.defaults)==null?void 0:d.plugins),{[g.name]:c({},(F=(O=o.defaults)==null?void 0:O.plugins)==null?void 0:F[g.name])})}))}(n==null?void 0:n.encryptionEngine)&&(((E=n==null?void 0:n.plugins)==null?void 0:E[n.encryptionEngine])||(n.plugins=P(c({},n.plugins),{[n.encryptionEngine]:{}}))),(n==null?void 0:n.plugins)&&Object.entries(n==null?void 0:n.plugins).forEach(([f,u])=>{(u==null?void 0:u.module)?s[f]=u==null?void 0:u.module:s[f]=`@dotsec/plugin-${f}`}),Object.values(a||{}).forEach(f=>{Object.keys(f).forEach(u=>{s[u]||(s[u]=`@dotsec/plugin-${u}`)})});let p=[],i=[],m=[];for(let f of Object.keys(s)){let u=s[f],g=await X({name:u}),{addCliCommand:C,cliHandlers:y}=await g({ajv:l,dotsecConfig:o,configFile:r});(y==null?void 0:y.encrypt)&&p.push(y.encrypt),(y==null?void 0:y.decrypt)&&(i.push(y.decrypt),(y==null?void 0:y.push)&&m.push({push:y.push,decrypt:y.decrypt})),C&&C({program:A})}p.length&&await be(A,{dotsecConfig:o,encryptHandlers:p}),i.length&&await xe(A,{dotsecConfig:o,decryptHandlers:i}),m.length&&(await Ae(A,{dotsecConfig:o,handlers:m}),await $e(A,{dotsecConfig:o}),await Ne(A,{dotsecConfig:o,decryptHandlers:i}),await A.parse())})();
41
41
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/cli/index.ts", "../../src/constants.ts", "../../src/lib/json.ts", "../../src/lib/getConfig.ts", "../../src/lib/loadDotsecPlugin.ts", "../../src/lib/io.ts", "../../src/utils/logging.ts", "../../src/cli/options/index.ts", "../../src/cli/options/sharedOptions.ts", "../../src/cli/options/decrypt.ts", "../../src/cli/options/dotsec.ts", "../../src/cli/options/encrypt.ts", "../../src/cli/options/init.ts", "../../src/cli/options/push.ts", "../../src/cli/options/run.ts", "../../src/cli/commands/decrypt.ts", "../../src/cli/commands/encrypt.ts", "../../src/lib/transformer.ts", "../../src/cli/commands/init.ts", "../../src/cli/commands/push.ts", "../../src/cli/commands/run.ts"],
4
- "sourcesContent": ["import { Command } from \"commander\";\n\nimport { getMagicalConfig } from \"../lib/getConfig\";\nimport { loadDotsecPlugin } from \"../lib/loadDotsecPlugin\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginEncryptHandler,\n\tDotsecCliPluginPushHandler,\n\tDotsecPluginConfig,\n} from \"../types/plugin\";\nimport addDecryptProgram from \"./commands/decrypt\";\nimport addEncryptProgram from \"./commands/encrypt\";\nimport addInitCommand from \"./commands/init\";\nimport addPushProgram from \"./commands/push\";\nimport addRunCommand from \"./commands/run\";\nimport { setProgramOptions } from \"./options\";\nimport Ajv, { KeywordDefinition } from \"ajv\";\nimport yargsParser from \"yargs-parser\";\n\nconst separator: KeywordDefinition = {\n\tkeyword: \"separator\",\n\ttype: \"string\",\n\tmetaSchema: {\n\t\ttype: \"string\",\n\t\tdescription: \"value separator\",\n\t},\n\tmodifying: true,\n\tvalid: true,\n\terrors: false,\n\tcompile: (schema) => (data, ctx) => {\n\t\tif (ctx) {\n\t\t\tconst { parentData, parentDataProperty } = ctx;\n\t\t\tparentData[parentDataProperty] = data === \"\" ? [] : data.split(schema);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t},\n};\n\nconst program = new Command();\n\n(async () => {\n\tconst parsedOptions = yargsParser(process.argv);\n\tconst argvPluginModules: string[] = [];\n\tif (parsedOptions.plugin) {\n\t\tif (Array.isArray(parsedOptions.plugin)) {\n\t\t\targvPluginModules.push(...parsedOptions.plugin);\n\t\t} else {\n\t\t\targvPluginModules.push(parsedOptions.plugin);\n\t\t}\n\t}\n\t// if (parsedOptions.p) {\n\t// \tif (Array.isArray(parsedOptions.p)) {\n\t// \t\targvPluginModules.push(...parsedOptions.p);\n\t// \t} else {\n\t// \t\targvPluginModules.push(parsedOptions.p);\n\t// \t}\n\t// }\n\n\tconst configFile = [\n\t\t...(Array.isArray(parsedOptions.config)\n\t\t\t? parsedOptions.config\n\t\t\t: [parsedOptions.config]),\n\t\t...(Array.isArray(parsedOptions.c) ? parsedOptions.c : [parsedOptions.c]),\n\t]?.[0];\n\n\tconst { contents: config = {} } = await getMagicalConfig(configFile);\n\tconst { defaults, push: pushVariables } = config;\n\n\tprogram\n\t\t.name(\"dotsec\")\n\t\t.description(\".env, but secure\")\n\t\t.version(\"1.0.0\")\n\t\t.enablePositionalOptions()\n\t\t.action((_options, other: Command) => {\n\t\t\tother.help();\n\t\t});\n\tsetProgramOptions(program);\n\tconst ajv = new Ajv({\n\t\tallErrors: true,\n\t\tremoveAdditional: true,\n\t\tuseDefaults: true,\n\t\tcoerceTypes: true,\n\t\tallowUnionTypes: true,\n\t\taddUsedSchema: false,\n\t\tkeywords: [separator],\n\t});\n\t// if we have plugins in the cli, we need to define them in pluginModules\n\tconst pluginModules: { [key: string]: string } = {};\n\tif (argvPluginModules.length > 0) {\n\t\tfor (const pluginModule of argvPluginModules) {\n\t\t\t// let's load em up\n\t\t\tconst plugin = await loadDotsecPlugin({ name: pluginModule });\n\n\t\t\t// good, let's fire 'em up\n\t\t\tconst loadedPlugin = await plugin({ dotsecConfig: config, ajv });\n\t\t\tpluginModules[loadedPlugin.name] = pluginModule;\n\n\t\t\tif (argvPluginModules.length === 1) {\n\t\t\t\t// if we only have one plugin, let's set it as the default\n\t\t\t\tconfig.defaults = {\n\t\t\t\t\t...config.defaults,\n\t\t\t\t\tencryptionEngine: String(loadedPlugin.name),\n\t\t\t\t\tplugins: {\n\t\t\t\t\t\t...config.defaults?.plugins,\n\t\t\t\t\t\t[loadedPlugin.name]: {\n\t\t\t\t\t\t\t...config.defaults?.plugins?.[loadedPlugin.name],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tif (defaults?.encryptionEngine) {\n\t\tif (!defaults?.plugins?.[defaults.encryptionEngine]) {\n\t\t\tdefaults.plugins = {\n\t\t\t\t...defaults.plugins,\n\t\t\t\t[defaults.encryptionEngine]: {},\n\t\t\t};\n\t\t}\n\t}\n\tif (defaults?.plugins) {\n\t\tObject.entries(defaults?.plugins).forEach(\n\t\t\t([pluginName, pluginModule]: [string, DotsecPluginConfig]) => {\n\t\t\t\tif (pluginModule?.module) {\n\t\t\t\t\tpluginModules[pluginName] = pluginModule?.module;\n\t\t\t\t} else {\n\t\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tObject.values(pushVariables || {}).forEach((pushVariable) => {\n\t\tObject.keys(pushVariable).forEach((pluginName) => {\n\t\t\tif (!pluginModules[pluginName]) {\n\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t}\n\t\t});\n\t});\n\n\t// configure encryption command\n\tconst cliPluginEncryptHandlers: DotsecCliPluginEncryptHandler[] = [];\n\tconst cliPluginDecryptHandlers: DotsecCliPluginDecryptHandler[] = [];\n\tconst cliPluginPushHandlers: {\n\t\tpush: DotsecCliPluginPushHandler;\n\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t}[] = [];\n\n\tfor (const pluginName of Object.keys(pluginModules)) {\n\t\tconst pluginModule = pluginModules[pluginName];\n\t\tconst initDotsecPlugin = await loadDotsecPlugin({ name: pluginModule });\n\t\tconst { addCliCommand, cliHandlers: cli } = await initDotsecPlugin({\n\t\t\tajv,\n\t\t\tdotsecConfig: config,\n\t\t});\n\n\t\tif (cli?.encrypt) {\n\t\t\tcliPluginEncryptHandlers.push(cli.encrypt);\n\t\t}\n\t\tif (cli?.decrypt) {\n\t\t\tcliPluginDecryptHandlers.push(cli.decrypt);\n\t\t\tif (cli?.push) {\n\t\t\t\tcliPluginPushHandlers.push({ push: cli.push, decrypt: cli.decrypt });\n\t\t\t}\n\t\t}\n\n\t\tif (addCliCommand) {\n\t\t\taddCliCommand({ program });\n\t\t}\n\t}\n\tif (cliPluginEncryptHandlers.length) {\n\t\tawait addEncryptProgram(program, {\n\t\t\tdotsecConfig: config,\n\t\t\tencryptHandlers: cliPluginEncryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginDecryptHandlers.length) {\n\t\tawait addDecryptProgram(program, {\n\t\t\tdotsecConfig: config,\n\t\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginPushHandlers.length) {\n\t\tawait addPushProgram(program, {\n\t\t\tdotsecConfig: config,\n\t\t\thandlers: cliPluginPushHandlers,\n\t\t});\n\t}\n\n\t// add other commands\n\tawait addInitCommand(program);\n\tawait addRunCommand(program, {\n\t\tdotsecConfig: config,\n\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t});\n\tawait program.parse();\n})();\n", "import { DotsecConfig } from \"./types/config\";\n\nexport const DOTSEC_DEFAULT_CONFIG_FILE = \"dotsec.config.ts\";\nexport const DOTSEC_CONFIG_FILES = [DOTSEC_DEFAULT_CONFIG_FILE];\nexport const DOTSEC_DEFAULT_DOTSEC_FILENAME = \".sec\";\nexport const DOTSEC_DEFAULT_DOTENV_FILENAME = \".env\";\nexport const defaultConfig: DotsecConfig = {};\n", "import fs from \"fs\";\nimport path from \"node:path\";\n\n/**\n * Parse JSONC\n * @date 12/7/2022 - 12:48:45 PM\n *\n * @export\n * @param {string} data\n * @returns {*}\n */\nexport function jsoncParse(data: string) {\n\ttry {\n\t\treturn new Function(`return ${data.trim()}`)();\n\t} catch {\n\t\t// Silently ignore any error\n\t\t// That's what tsc/jsonc-parser did after all\n\t\treturn {};\n\t}\n}\n\n/**\n * Load JSON\n * @date 12/7/2022 - 12:48:57 PM\n *\n * @async\n * @param {string} filepath\n * @returns {unknown}\n */\nexport const loadJson = async (filepath: string) => {\n\ttry {\n\t\treturn jsoncParse(await fs.promises.readFile(filepath, \"utf8\"));\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to parse ${path.relative(process.cwd(), filepath)}: ${\n\t\t\t\t\terror.message\n\t\t\t\t}`,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t}\n};\n", "import { DOTSEC_CONFIG_FILES, defaultConfig } from \"../constants\";\nimport { DotsecConfig } from \"../types/config\";\nimport { DotsecConfigAndSource } from \"../types/plugin\";\nimport { loadJson } from \"./json\";\nimport { bundleRequire } from \"bundle-require\";\nimport JoyCon from \"joycon\";\nimport path from \"path\";\n\nexport const getMagicalConfig = async (\n\tfilename?: string,\n): Promise<DotsecConfigAndSource> => {\n\tconst cwd = process.cwd();\n\tconst configJoycon = new JoyCon();\n\tconst configPath = await configJoycon.resolve({\n\t\tfiles: filename ? [filename] : [...DOTSEC_CONFIG_FILES, \"package.json\"],\n\t\tcwd,\n\t\tstopDir: path.parse(cwd).root,\n\t\tpackageKey: \"dotsec\",\n\t});\n\tif (filename && configPath === null) {\n\t\tthrow new Error(`Could not find config file ${filename}`);\n\t}\n\tif (configPath) {\n\t\tif (configPath.endsWith(\".json\")) {\n\t\t\tconst rawData = (await loadJson(configPath)) as Partial<DotsecConfig>;\n\n\t\t\tlet data: Partial<DotsecConfig>;\n\n\t\t\tif (\n\t\t\t\tconfigPath.endsWith(\"package.json\") &&\n\t\t\t\t(rawData as { dotsec: Partial<DotsecConfig> }).dotsec !== undefined\n\t\t\t) {\n\t\t\t\tdata = (rawData as { dotsec: Partial<DotsecConfig> }).dotsec;\n\t\t\t} else {\n\t\t\t\tdata = rawData as Partial<DotsecConfig>;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsource: \"json\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t} else if (configPath.endsWith(\".ts\")) {\n\t\t\tconst bundleRequireResult = await bundleRequire({\n\t\t\t\tfilepath: configPath,\n\t\t\t});\n\t\t\tconst data = (bundleRequireResult.mod.dotsec ||\n\t\t\t\tbundleRequireResult.mod.default ||\n\t\t\t\tbundleRequireResult.mod) as Partial<DotsecConfig>;\n\n\t\t\treturn {\n\t\t\t\tsource: \"ts\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn { source: \"defaultConfig\", contents: defaultConfig };\n};\n", "import { DotsecPluginModule } from \"../types/plugin\";\n\nexport const loadDotsecPlugin = async (options: {\n\tname: string;\n}): Promise<DotsecPluginModule> => {\n\treturn import(options.name).then((imported) => {\n\t\treturn imported.default;\n\t});\n};\n", "import fs, { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport prompts from \"prompts\";\n\nexport const readContentsFromFile = async (\n\tfilePath: string,\n): Promise<string> => {\n\treturn await fs.readFile(filePath, \"utf-8\");\n};\n\nexport const writeContentsToFile = async (\n\tfilePath: string,\n\tcontents: string,\n): Promise<void> => {\n\treturn await fs.writeFile(filePath, contents, \"utf-8\");\n};\n\nexport const fileExists = async (source: string): Promise<boolean> => {\n\ttry {\n\t\tawait stat(source);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const promptOverwriteIfFileExists = async ({\n\tfilePath,\n\tskip,\n}: {\n\tfilePath: string;\n\tskip?: boolean;\n}) => {\n\tlet overwriteResponse: prompts.Answers<\"overwrite\"> | undefined;\n\n\tif ((await fileExists(filePath)) && skip !== true) {\n\t\toverwriteResponse = await prompts({\n\t\t\ttype: \"confirm\",\n\t\t\tname: \"overwrite\",\n\t\t\tmessage: () => {\n\t\t\t\treturn `Overwrite './${path.relative(process.cwd(), filePath)}' ?`;\n\t\t\t},\n\t\t});\n\t} else {\n\t\toverwriteResponse = undefined;\n\t}\n\treturn overwriteResponse;\n};\n", "import chalk from \"chalk\"\nimport Table = require(\"cli-table\")\nexport { Table }\n\nlet _logger: Pick<Console, \"info\" | \"error\" | \"table\">\nexport const getLogger = () => {\n\tif (!_logger) {\n\t\t_logger = console\n\t}\n\n\treturn _logger\n}\nexport const writeLine = (str: string) => {\n\tprocess.stdout.write(str)\n}\nexport const emphasis = (str: string): string => chalk.yellowBright(str)\nexport const strong = (str: string): string => chalk.yellow.bold(str)\n\nexport const clientLogger = {\n\tdebug(content: object) {\n\t\tconsole.log(content)\n\t},\n\tinfo(content: object) {\n\t\tconsole.log(content)\n\t},\n\twarn(content: object) {\n\t\tconsole.log(content)\n\t},\n\terror(content: object) {\n\t\tconsole.error(content)\n\t},\n}\n", "import { Command, Option } from \"commander\";\n\nimport decryptCommandDefaults from \"./decrypt\";\nimport dotsecCommandDefaults from \"./dotsec\";\nimport encryptCommandDefaults from \"./encrypt\";\nimport initCommandDefaults from \"./init\";\nimport pullCommandDefaults from \"./push\";\nimport pushCommandDefaults from \"./push\";\nimport runCommandDefaults from \"./run\";\nimport {\n\tCommandOption,\n\tDotSecCommandDefaults,\n\tDotSecCommandOptions,\n\tDotSecCommandsDefaults,\n\tExpandedCommandOption,\n} from \"./types\";\n\nexport const commandOptions: DotSecCommandsDefaults = {\n\t...dotsecCommandDefaults,\n\t...initCommandDefaults,\n\t...encryptCommandDefaults,\n\t...decryptCommandDefaults,\n\t...runCommandDefaults,\n\t...pushCommandDefaults,\n\t...pullCommandDefaults,\n};\n\nconst getInheritedOptions = (\n\tcopts: DotSecCommandsDefaults,\n\tcommandName: string,\n\tresult: {\n\t\toptions?: DotSecCommandOptions;\n\t\trequiredOptions?: DotSecCommandOptions;\n\t} = {},\n): DotSecCommandDefaults | undefined => {\n\tconst command = copts[commandName];\n\tif (command) {\n\t\tif (command.inheritsFrom) {\n\t\t\treturn command?.inheritsFrom.reduce(\n\t\t\t\t(acc, inheritedCommandName) => {\n\t\t\t\t\treturn getInheritedOptions(copts, inheritedCommandName, acc);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...command,\n\t\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\t\trequiredOptions: {\n\t\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t...command,\n\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\trequiredOptions: {\n\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n};\n\nconst expandCommandOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n): ExpandedCommandOption => {\n\tif (Array.isArray(commandOption)) {\n\t\treturn {\n\t\t\toption: commandOption,\n\t\t};\n\t} else {\n\t\treturn commandOption;\n\t}\n};\n\nconst createOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n\toptions?: { required?: boolean },\n): Option => {\n\tconst expandedCommandOption = expandCommandOption(commandOption);\n\tconst [option, description, defaultValue] = expandedCommandOption.option;\n\tconst newOption = new Option(option, description);\n\tif (defaultValue) {\n\t\tnewOption.default(defaultValue);\n\t}\n\tif (expandedCommandOption.env) {\n\t\tnewOption.env(expandedCommandOption.env);\n\t}\n\tif (options?.required) {\n\t\tnewOption.makeOptionMandatory(true);\n\t}\n\treturn newOption;\n};\nexport const setProgramOptions = (program: Command, commandName?: string) => {\n\tconst programOptions = commandOptions[commandName || program.name()];\n\t// const programOptions = getInheritedOptions(\n\t// \tcommandOptions,\n\t// \tcommandName || program.name(),\n\t// );\n\n\tif (programOptions) {\n\t\tconst { options, requiredOptions, description, usage, helpText } =\n\t\t\tprogramOptions;\n\t\tif (options) {\n\t\t\tObject.values(options).forEach((commandOption) => {\n\t\t\t\tconst newOption = createOption(commandOption);\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.values(requiredOptions).forEach((requiredOption) => {\n\t\t\t\tconst newOption = createOption(requiredOption, { required: true });\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (description) {\n\t\t\tprogram.description(description);\n\t\t}\n\t\tif (usage) {\n\t\t\tprogram.description(usage);\n\t\t}\n\t\tif (helpText) {\n\t\t\tprogram.description(helpText);\n\t\t}\n\t}\n};\n", "import {\n\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n} from \"../../constants\";\nimport { ExpandedCommandOption } from \"./types\";\n\nexport const envFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--env-file <envFile>\",\n\t\t`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTENV_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\t],\n\tenv: \"ENV_FILE\",\n};\nexport const secFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--sec-file <secFile>\",\n\t\t`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTSEC_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n\t],\n\tenv: \"SEC_FILE\",\n};\n\nexport const withEnvOption: ExpandedCommandOption = {\n\toption: [\"--with-env, --withEnv\", \"Run command using a dot env file\"],\n};\n\nexport const withSecOption: ExpandedCommandOption = {\n\toption: [\"--with-sec, --withSec\", \"Run command with a dotsec file\"],\n};\n\nexport const yesOption: ExpandedCommandOption = {\n\toption: [\"--yes\", \"Skip confirmation prompts\"],\n};\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst decryptCommandDefaults: DotSecCommandsDefaults = {\n\tdecrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default decryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst dotsecCommandDefaults: DotSecCommandsDefaults = {\n\tdotsec: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\t\t\tplugin: [\"--plugin <plugin>\", \"Comma-separated list of plugins to use\"],\n\t\t},\n\t},\n};\n\nexport default dotsecCommandDefaults;\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst encryptCommandDefaults: DotSecCommandsDefaults = {\n\tencrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default encryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst initCommandDefaults: DotSecCommandsDefaults = {\n\tinit: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default initCommandDefaults;\n", "import {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst pullCommandDefaults: DotSecCommandsDefaults = {\n\tpull: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default pullCommandDefaults;\n", "import dotsecCommandDefaults from \"./dotsec\";\nimport {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst runCommandDefaults: DotSecCommandsDefaults = {\n\trunEnvOnly: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\tusage: \"[commandArgs...]\",\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tdescription:\n\t\t\t\"Run a command in a separate process and populate env with contents of a dotenv file.\",\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --env-file .env.dev echo \"hello world\"\n\n${\"Run a command with a specific ENV_FILE variable\"}\n\n$ ENV_FILE=.env.dev dotsec run echo \"hello world\"\n\n`,\n\t},\n\trun: {\n\t\tinheritsFrom: [\"dotsec\"],\n\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tusage:\n\t\t\t\"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]\",\n\t\tdescription: `Run a command in a separate process and populate env with either \n\t\t\t- contents of a dotenv file\n\t\t\t- decrypted values of a dotsec file.\n\nThe --withEnv option will take precedence over the --withSec option. If neither are specified, the --withEnv option will be used by default.`,\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --with-env --env-file .env.dev echo \"hello world\"\n\n\n${\"Run a command with a .sec file\"}\n\n$ dotsec run --with-sec echo \"hello world\"\n\n\n${\"Run a command with a specific .sec file\"}\n\n$ dotsec run --with-sec --sec-file .sec.dev echo \"hello world\"\n`,\n\t},\n\tpush: {\n\t\toptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.options,\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.requiredOptions,\n\t\t},\n\t},\n};\n\nexport default runCommandDefaults;\n", "import {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { DecryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"decrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<DecryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${options.decryptHandlers\n\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\t// get current dot env file\n\t\t\t\tconst dotsecString = await readContentsFromFile(secFile);\n\n\t\t\t\tconst plaintext = await pluginCliDecrypt.handler({\n\t\t\t\t\tciphertext: dotsecString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotenvOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: envFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotenvOverwriteResponse === undefined ||\n\t\t\t\t\tdotenvOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(envFile, plaintext);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote plaintext contents of ${strong(secFile)} file to ${strong(\n\t\t\t\t\t\t\tenvFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.decryptHandlers.map((decryption) => {\n\t\tconst { options, requiredOptions } = decryption;\n\t\tif (options) {\n\t\t\tObject.values(options).map((option) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...option);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.values(requiredOptions).map((requiredOption) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...requiredOption);\n\t\t\t});\n\t\t}\n\t});\n\n\tconst engines = options.decryptHandlers.map((e) => e.triggerOptionValue);\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"} to use: ${\n\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t}`,\n\t\tengines.length === 1 ? engines[0] : undefined,\n\t);\n\tsetProgramOptions(subProgram);\n\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { EncryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginEncryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tencryptHandlers: DotsecCliPluginEncryptHandler[];\n\t\tdotsecConfig: DotsecConfig;\n\t},\n) => {\n\tconst { encryptHandlers, dotsecConfig } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"encrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<EncryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\t\t\t\tconst pluginCliEncrypt = (encryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliEncrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No encryption plugin found, available encryption engine(s): ${options.encryptHandlers\n\t\t\t\t\t\t\t.map((e) => e.triggerOptionValue)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst dotenvString = await readContentsFromFile(envFile);\n\n\t\t\t\tconst cipherText = await pluginCliEncrypt.handler({\n\t\t\t\t\tplaintext: dotenvString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotsecOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: secFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotsecOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(secFile, cipherText);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote encrypted contents of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\tsecFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.encryptHandlers.map((encryption) => {\n\t\tconst { options, requiredOptions } = encryption;\n\t\tif (options) {\n\t\t\tObject.values(options).map((option) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...option);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.values(requiredOptions).map((requiredOption) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...requiredOption);\n\t\t\t});\n\t\t}\n\t});\n\n\tconst engines = options.encryptHandlers.map((e) => e.triggerOptionValue);\n\tconst encryptionEngineNames = options.encryptHandlers.map(\n\t\t(e) => e.encryptionEngineName,\n\t);\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t}`,\n\t\t// engines.length === 1 ? engines[0] : undefined,\n\t);\n\tsetProgramOptions(subProgram);\n\tsubProgram.description(\n\t\t`Encrypt .env file using ${encryptionEngineNames.join(\", \")}`,\n\t);\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import fs from \"node:fs\";\nimport * as ts from \"typescript\";\n\nexport const patchConfigFile = (options: {\n\tconfigFile: string;\n\tconfig?: {\n\t\taws?: {\n\t\t\tregion?: string;\n\t\t\tkms?: {\n\t\t\t\tkeyAlias?: string;\n\t\t\t};\n\t\t};\n\t};\n}) => {\n\tconst printer: ts.Printer = ts.createPrinter();\n\tconst source = fs.readFileSync(options.configFile, \"utf8\");\n\n\tconst transformer =\n\t\t<T extends ts.Node>(context: ts.TransformationContext) =>\n\t\t(rootNode: T) => {\n\t\t\tfunction visit(node: ts.Node): ts.Node {\n\t\t\t\tnode = ts.visitEachChild(node, visit, context);\n\t\t\t\tif (node.kind === ts.SyntaxKind.StringLiteral) {\n\t\t\t\t\tconst kmsNode = node?.parent?.parent?.parent;\n\t\t\t\t\tif (options.config?.aws?.kms?.keyAlias) {\n\t\t\t\t\t\tif (kmsNode?.getChildAt(0)?.getText() === \"kms\") {\n\t\t\t\t\t\t\tconst awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(\n\t\t\t\t\t\t\t\t\toptions.config?.aws?.kms?.keyAlias,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (options.config?.aws?.region) {\n\t\t\t\t\t\tif (node?.parent?.getChildAt(0)?.getText() === \"region\") {\n\t\t\t\t\t\t\tconst awsNode = node?.parent?.parent?.parent;\n\n\t\t\t\t\t\t\t// const awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(options.config?.aws?.region);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\treturn ts.visitNode(rootNode, visit);\n\t\t};\n\n\tconst sourceFile: ts.SourceFile = ts.createSourceFile(\n\t\t\"test.ts\",\n\t\tsource,\n\t\tts.ScriptTarget.ES2015,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\t// Options may be passed to transform\n\tconst result: ts.TransformationResult<ts.SourceFile> =\n\t\tts.transform<ts.SourceFile>(sourceFile, [transformer]);\n\n\tconst transformedSourceFile: ts.SourceFile = result.transformed[0];\n\n\tconst transformedSource = printer.printFile(transformedSourceFile);\n\tresult.dispose();\n\n\treturn transformedSource;\n};\n", "import { promptOverwriteIfFileExists, writeContentsToFile } from \"../../lib/io\";\nimport { InitCommandOptions } from \"../../types\";\nimport { Command } from \"commander\";\n\nimport { patchConfigFile } from \"../../lib/transformer\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport path from \"node:path\";\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n};\n\nconst addInitProgram = async (program: Command) => {\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"init\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\tconst { configFile, yes } = command.optsWithGlobals<InitCommandOptions>();\n\n\t\t\ttry {\n\t\t\t\tconst patchedConfigTemplate = patchConfigFile({\n\t\t\t\t\tconfigFile: path.resolve(\n\t\t\t\t\t\t__dirname,\n\t\t\t\t\t\t\"../../src/templates/dotsec.config.ts\",\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t\tconst dotsecConfigOverwriteResponse = await promptOverwriteIfFileExists(\n\t\t\t\t\t{\n\t\t\t\t\t\tfilePath: configFile,\n\t\t\t\t\t\tskip: yes,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdotsecConfigOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecConfigOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(configFile, patchedConfigTemplate);\n\t\t\t\t\tconsole.log(`Wrote config file to ${strong(configFile)}`);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcommand.error(e);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions(subProgram);\n\n\treturn subProgram;\n};\n\nexport default addInitProgram;\n", "import { PushCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginPushHandler,\n} from \"../../types/plugin\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\nimport fs from \"node:fs\";\n\n/**\n * Decrypts, and pushes the contents of a .env file to AWS SSM, AWS Secrets Manager or GitHub Actions Secrets\n * @date 12/7/2022 - 9:16:48 AM\n *\n * @async\n * @param {Command} program\n * @returns {unknown}\n */\nconst addPushProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\thandlers: {\n\t\t\tpush: DotsecCliPluginPushHandler;\n\t\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t\t}[];\n\t},\n) => {\n\tconst { dotsecConfig, handlers } = options;\n\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"push\")\n\t\t.action(async (_options: Record<string, string>, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\twithEnv,\n\t\t\t\t\twithSec,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<PushCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\tconst pluginCliDecrypt = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.decrypt?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.decrypt;\n\n\t\t\t\tconst pluginCliPush = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.push?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.push;\n\n\t\t\t\tif (!pluginCliPush) {\n\t\t\t\t\tthrow new Error(\"No push plugin found!\");\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.requiredOptions || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t}\n\n\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\tif (withEnv || !(withEnv || withSec)) {\n\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t}\n\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t} else if (withSec) {\n\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${handlers\n\t\t\t\t\t\t\t\t.map((e) => `--${e.decrypt?.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (envContents) {\n\t\t\t\t\t// convert to object\n\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t// expand env vars\n\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tif (expandedEnvVars.parsed) {\n\t\t\t\t\t\tawait pluginCliPush.handler({\n\t\t\t\t\t\t\tpush: expandedEnvVars.parsed,\n\t\t\t\t\t\t\tyes,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions(subProgram);\n\n\treturn subProgram;\n};\n\nexport default addPushProgram;\n", "import fs from \"node:fs\";\n\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\n\nimport { RunCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { spawnSync } from \"node:child_process\";\nconst addRunProgam = (\n\tprogram: Command,\n\toptions?: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers?: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options || {};\n\n\t// is there an encryption engine?\n\tconst hasDecryptEngine =\n\t\tdecryptHandlers !== undefined && decryptHandlers.length > 0;\n\n\tconst subProgram = program\n\t\t.command(\"run <command...>\")\n\t\t.allowUnknownOption(true)\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.showHelpAfterError(true)\n\t\t.action(\n\t\t\tasync (\n\t\t\t\tcommands: string[],\n\t\t\t\t_options: Record<string, string>,\n\t\t\t\tcommand: Command,\n\t\t\t) => {\n\t\t\t\tconsole.log(\"yo\");\n\n\t\t\t\ttry {\n\t\t\t\t\tconst { envFile, secFile, withEnv, withSec, engine } =\n\t\t\t\t\t\tcommand.optsWithGlobals<RunCommandOptions>();\n\t\t\t\t\tconsole.log({ envFile, secFile, withEnv, withSec, engine });\n\t\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t\t}\n\n\t\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\t\tif (withEnv || !(withEnv || withSec) || hasDecryptEngine === false) {\n\t\t\t\t\t\tconsole.log(\"ENV ONLY\");\n\t\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t\t\tconsole.log(\"envCOntents\", envContents);\n\t\t\t\t\t} else if (withSec) {\n\t\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst encryptionEngine =\n\t\t\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${(\n\t\t\t\t\t\t\t\t\tdecryptHandlers || []\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t\t\t];\n\n\t\t\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (envContents) {\n\t\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t\t// expand env vars\n\t\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst [userCommand, ...userCommandArgs] = commands;\n\t\t\t\t\t\tconst spawn = spawnSync(userCommand, [...userCommandArgs], {\n\t\t\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\t\t\tshell: false,\n\t\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t\t...expandedEnvVars.parsed,\n\t\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\t\t__DOTSEC_ENV__: JSON.stringify(Object.keys(dotenvVars)),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (spawn.status !== 0) {\n\t\t\t\t\t\t\tprocess.exit(spawn.status || 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\t\tcommand.help();\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\tsetProgramOptions(subProgram, hasDecryptEngine ? \"run\" : \"runEnvOnly\");\n\n\tif (hasDecryptEngine) {\n\t\tdecryptHandlers?.map((run) => {\n\t\t\tconst { options, requiredOptions } = run;\n\t\t\tif (options) {\n\t\t\t\tObject.values(options).map((option) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tsubProgram.option(...option);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (requiredOptions) {\n\t\t\t\tObject.values(requiredOptions).map((requiredOption) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tsubProgram.option(...requiredOption);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tconst engines = decryptHandlers?.map((e) => e.triggerOptionValue);\n\n\t\tsubProgram.option(\n\t\t\t\"--engine <engine>\",\n\t\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t\t}`,\n\t\t\t// engines.length === 1 ? engines[0] : undefined,\n\t\t);\n\t}\n\treturn subProgram;\n};\n\nexport default addRunProgam;\n"],
5
- "mappings": "k4BAAA,OAAwB,wBCEjB,GAAM,GAA6B,mBAC7B,GAAsB,CAAC,GACvB,EAAiC,OACjC,EAAiC,OACjC,EAA8B,GCN3C,OAAe,iBACf,GAAiB,wBAUV,YAAoB,EAAc,CACxC,GAAI,CACH,MAAO,IAAI,UAAS,UAAU,EAAK,iBAClC,CAGD,MAAO,IAYF,GAAM,IAAW,KAAO,IAAqB,CACnD,GAAI,CACH,MAAO,IAAW,KAAM,YAAG,SAAS,SAAS,EAAU,eAC/C,EAAP,CACD,KAAI,aAAiB,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GAC5D,EAA4D,GAC5D,EAGA,GAEN,OAAW,KAAc,QAAO,KAAK,GAAgB,CACpD,GAAM,GAAe,EAAc,GAC7B,EAAmB,KAAM,GAAiB,CAAE,KAAM,IAClD,CAAE,gBAAe,YAAa,GAAQ,KAAM,GAAiB,CAClE,MACA,aAAc,IAGf,AAAI,kBAAK,UACR,EAAyB,KAAK,EAAI,SAE/B,kBAAK,UACR,GAAyB,KAAK,EAAI,SAC9B,kBAAK,OACR,EAAsB,KAAK,CAAE,KAAM,EAAI,KAAM,QAAS,EAAI,WAIxD,GACH,EAAc,CAAE,YAGlB,AAAI,EAAyB,QAC5B,KAAM,IAAkB,EAAS,CAChC,aAAc,EACd,gBAAiB,IAGf,EAAyB,QAC5B,KAAM,IAAkB,EAAS,CAChC,aAAc,EACd,gBAAiB,IAGf,EAAsB,QACzB,KAAM,IAAe,EAAS,CAC7B,aAAc,EACd,SAAU,IAKZ,KAAM,IAAe,GACrB,KAAM,IAAc,EAAS,CAC5B,aAAc,EACd,gBAAiB,IAElB,KAAM,GAAQ",
3
+ "sources": ["../../src/cli/index.ts", "../../src/constants.ts", "../../src/lib/json.ts", "../../src/lib/getConfig.ts", "../../src/lib/loadDotsecPlugin.ts", "../../src/lib/addPluginOptions.ts", "../../src/lib/io.ts", "../../src/utils/logging.ts", "../../src/cli/options/index.ts", "../../src/cli/options/sharedOptions.ts", "../../src/cli/options/decrypt.ts", "../../src/cli/options/dotsec.ts", "../../src/cli/options/encrypt.ts", "../../src/cli/options/init.ts", "../../src/cli/options/push.ts", "../../src/cli/options/run.ts", "../../src/cli/commands/decrypt.ts", "../../src/cli/commands/encrypt.ts", "../../src/lib/transformer.ts", "../../src/cli/commands/init.ts", "../../src/cli/commands/push.ts", "../../src/cli/commands/run.ts"],
4
+ "sourcesContent": ["import { Command } from \"commander\";\n\nimport { getMagicalConfig } from \"../lib/getConfig\";\nimport { loadDotsecPlugin } from \"../lib/loadDotsecPlugin\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginEncryptHandler,\n\tDotsecCliPluginPushHandler,\n\tDotsecPluginConfig,\n} from \"../types/plugin\";\nimport addDecryptProgram from \"./commands/decrypt\";\nimport addEncryptProgram from \"./commands/encrypt\";\nimport addInitCommand from \"./commands/init\";\nimport addPushProgram from \"./commands/push\";\nimport addRunCommand from \"./commands/run\";\nimport { setProgramOptions } from \"./options\";\nimport Ajv, { KeywordDefinition } from \"ajv\";\nimport yargsParser from \"yargs-parser\";\n\nconst separator: KeywordDefinition = {\n\tkeyword: \"separator\",\n\ttype: \"string\",\n\tmetaSchema: {\n\t\ttype: \"string\",\n\t\tdescription: \"value separator\",\n\t},\n\tmodifying: true,\n\tvalid: true,\n\terrors: false,\n\tcompile: (schema) => (data, ctx) => {\n\t\tif (ctx) {\n\t\t\tconst { parentData, parentDataProperty } = ctx;\n\t\t\tparentData[parentDataProperty] = data === \"\" ? [] : data.split(schema);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t},\n};\n\nconst program = new Command();\n\n(async () => {\n\tconst parsedOptions = yargsParser(process.argv);\n\tconst argvPluginModules: string[] = [];\n\tif (parsedOptions.plugin) {\n\t\tif (Array.isArray(parsedOptions.plugin)) {\n\t\t\targvPluginModules.push(...parsedOptions.plugin);\n\t\t} else {\n\t\t\targvPluginModules.push(parsedOptions.plugin);\n\t\t}\n\t}\n\t// if (parsedOptions.p) {\n\t// \tif (Array.isArray(parsedOptions.p)) {\n\t// \t\targvPluginModules.push(...parsedOptions.p);\n\t// \t} else {\n\t// \t\targvPluginModules.push(parsedOptions.p);\n\t// \t}\n\t// }\n\tconst configFile = [\n\t\t...(Array.isArray(parsedOptions.config)\n\t\t\t? parsedOptions.config\n\t\t\t: [parsedOptions.config]),\n\t\t...(Array.isArray(parsedOptions.c) ? parsedOptions.c : [parsedOptions.c]),\n\t]?.[0];\n\n\tconst { contents: dotsecConfig = {} } = await getMagicalConfig(configFile);\n\tconst { defaults, push: pushVariables } = dotsecConfig;\n\n\tprogram\n\t\t.name(\"dotsec\")\n\t\t.description(\".env, but secure\")\n\t\t.version(\"1.0.0\")\n\t\t.enablePositionalOptions()\n\t\t.action((_options, other: Command) => {\n\t\t\tother.help();\n\t\t});\n\tsetProgramOptions({ program, dotsecConfig: dotsecConfig });\n\tconst ajv = new Ajv({\n\t\tallErrors: true,\n\t\tremoveAdditional: true,\n\t\tuseDefaults: true,\n\t\tcoerceTypes: true,\n\t\tallowUnionTypes: true,\n\t\taddUsedSchema: false,\n\t\tkeywords: [separator],\n\t});\n\t// if we have plugins in the cli, we need to define them in pluginModules\n\tconst pluginModules: { [key: string]: string } = {};\n\tif (argvPluginModules.length > 0) {\n\t\tfor (const pluginModule of argvPluginModules) {\n\t\t\t// let's load em up\n\t\t\tconst plugin = await loadDotsecPlugin({ name: pluginModule });\n\n\t\t\t// good, let's fire 'em up\n\t\t\tconst loadedPlugin = await plugin({\n\t\t\t\tdotsecConfig: dotsecConfig,\n\t\t\t\tajv,\n\t\t\t\tconfigFile,\n\t\t\t});\n\t\t\tpluginModules[loadedPlugin.name] = pluginModule;\n\n\t\t\tif (argvPluginModules.length === 1) {\n\t\t\t\t// if we only have one plugin, let's set it as the default\n\t\t\t\tdotsecConfig.defaults = {\n\t\t\t\t\t...dotsecConfig.defaults,\n\t\t\t\t\tencryptionEngine: String(loadedPlugin.name),\n\t\t\t\t\tplugins: {\n\t\t\t\t\t\t...dotsecConfig.defaults?.plugins,\n\t\t\t\t\t\t[loadedPlugin.name]: {\n\t\t\t\t\t\t\t...dotsecConfig.defaults?.plugins?.[loadedPlugin.name],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tif (defaults?.encryptionEngine) {\n\t\tif (!defaults?.plugins?.[defaults.encryptionEngine]) {\n\t\t\tdefaults.plugins = {\n\t\t\t\t...defaults.plugins,\n\t\t\t\t[defaults.encryptionEngine]: {},\n\t\t\t};\n\t\t}\n\t}\n\tif (defaults?.plugins) {\n\t\tObject.entries(defaults?.plugins).forEach(\n\t\t\t([pluginName, pluginModule]: [string, DotsecPluginConfig]) => {\n\t\t\t\tif (pluginModule?.module) {\n\t\t\t\t\tpluginModules[pluginName] = pluginModule?.module;\n\t\t\t\t} else {\n\t\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tObject.values(pushVariables || {}).forEach((pushVariable) => {\n\t\tObject.keys(pushVariable).forEach((pluginName) => {\n\t\t\tif (!pluginModules[pluginName]) {\n\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t}\n\t\t});\n\t});\n\n\t// configure encryption command\n\tconst cliPluginEncryptHandlers: DotsecCliPluginEncryptHandler[] = [];\n\tconst cliPluginDecryptHandlers: DotsecCliPluginDecryptHandler[] = [];\n\tconst cliPluginPushHandlers: {\n\t\tpush: DotsecCliPluginPushHandler;\n\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t}[] = [];\n\n\tfor (const pluginName of Object.keys(pluginModules)) {\n\t\tconst pluginModule = pluginModules[pluginName];\n\t\tconst initDotsecPlugin = await loadDotsecPlugin({ name: pluginModule });\n\t\tconst { addCliCommand, cliHandlers: cli } = await initDotsecPlugin({\n\t\t\tajv,\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tconfigFile,\n\t\t});\n\n\t\tif (cli?.encrypt) {\n\t\t\tcliPluginEncryptHandlers.push(cli.encrypt);\n\t\t}\n\t\tif (cli?.decrypt) {\n\t\t\tcliPluginDecryptHandlers.push(cli.decrypt);\n\t\t\tif (cli?.push) {\n\t\t\t\tcliPluginPushHandlers.push({ push: cli.push, decrypt: cli.decrypt });\n\t\t\t}\n\t\t}\n\n\t\tif (addCliCommand) {\n\t\t\taddCliCommand({ program });\n\t\t}\n\t}\n\tif (cliPluginEncryptHandlers.length) {\n\t\tawait addEncryptProgram(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tencryptHandlers: cliPluginEncryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginDecryptHandlers.length) {\n\t\tawait addDecryptProgram(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginPushHandlers.length) {\n\t\tawait addPushProgram(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\thandlers: cliPluginPushHandlers,\n\t\t});\n\n\t\t// add other commands\n\t\tawait addInitCommand(program, { dotsecConfig: dotsecConfig });\n\t\tawait addRunCommand(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t\t});\n\t\tawait program.parse();\n\t}\n})();\n", "import { DotsecConfig } from \"./types/config\";\n\nexport const DOTSEC_DEFAULT_CONFIG_FILE = \"dotsec.config.ts\";\nexport const DOTSEC_CONFIG_FILES = [DOTSEC_DEFAULT_CONFIG_FILE];\nexport const DOTSEC_DEFAULT_DOTSEC_FILENAME = \".sec\";\nexport const DOTSEC_DEFAULT_DOTENV_FILENAME = \".env\";\nexport const defaultConfig: DotsecConfig = {};\n", "import fs from \"fs\";\nimport path from \"node:path\";\n\n/**\n * Parse JSONC\n * @date 12/7/2022 - 12:48:45 PM\n *\n * @export\n * @param {string} data\n * @returns {*}\n */\nexport function jsoncParse(data: string) {\n\ttry {\n\t\treturn new Function(`return ${data.trim()}`)();\n\t} catch {\n\t\t// Silently ignore any error\n\t\t// That's what tsc/jsonc-parser did after all\n\t\treturn {};\n\t}\n}\n\n/**\n * Load JSON\n * @date 12/7/2022 - 12:48:57 PM\n *\n * @async\n * @param {string} filepath\n * @returns {unknown}\n */\nexport const loadJson = async (filepath: string) => {\n\ttry {\n\t\treturn jsoncParse(await fs.promises.readFile(filepath, \"utf8\"));\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to parse ${path.relative(process.cwd(), filepath)}: ${\n\t\t\t\t\terror.message\n\t\t\t\t}`,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t}\n};\n", "import { DOTSEC_CONFIG_FILES, defaultConfig } from \"../constants\";\nimport { DotsecConfig } from \"../types/config\";\nimport { DotsecConfigAndSource } from \"../types/plugin\";\nimport { loadJson } from \"./json\";\nimport { bundleRequire } from \"bundle-require\";\nimport JoyCon from \"joycon\";\nimport path from \"path\";\n\nexport const getMagicalConfig = async (\n\tfilename?: string,\n): Promise<DotsecConfigAndSource> => {\n\tconst cwd = process.cwd();\n\tconst configJoycon = new JoyCon();\n\tconst configPath = await configJoycon.resolve({\n\t\tfiles: filename ? [filename] : [...DOTSEC_CONFIG_FILES, \"package.json\"],\n\t\tcwd,\n\t\tstopDir: path.parse(cwd).root,\n\t\tpackageKey: \"dotsec\",\n\t});\n\tif (filename && configPath === null) {\n\t\tthrow new Error(`Could not find config file ${filename}`);\n\t}\n\tif (configPath) {\n\t\tif (configPath.endsWith(\".json\")) {\n\t\t\tconst rawData = (await loadJson(configPath)) as Partial<DotsecConfig>;\n\n\t\t\tlet data: Partial<DotsecConfig>;\n\n\t\t\tif (\n\t\t\t\tconfigPath.endsWith(\"package.json\") &&\n\t\t\t\t(rawData as { dotsec: Partial<DotsecConfig> }).dotsec !== undefined\n\t\t\t) {\n\t\t\t\tdata = (rawData as { dotsec: Partial<DotsecConfig> }).dotsec;\n\t\t\t} else {\n\t\t\t\tdata = rawData as Partial<DotsecConfig>;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsource: \"json\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t} else if (configPath.endsWith(\".ts\")) {\n\t\t\tconst bundleRequireResult = await bundleRequire({\n\t\t\t\tfilepath: configPath,\n\t\t\t});\n\t\t\tconst data = (bundleRequireResult.mod.dotsec ||\n\t\t\t\tbundleRequireResult.mod.default ||\n\t\t\t\tbundleRequireResult.mod) as Partial<DotsecConfig>;\n\n\t\t\treturn {\n\t\t\t\tsource: \"ts\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn { source: \"defaultConfig\", contents: defaultConfig };\n};\n", "import { DotsecPluginModule } from \"../types/plugin\";\n\nexport const loadDotsecPlugin = async (options: {\n\tname: string;\n}): Promise<DotsecPluginModule> => {\n\treturn import(options.name).then((imported) => {\n\t\treturn imported.default;\n\t});\n};\n", "import { DotsecCliOption } from \"../types/plugin\";\nimport { Command, Option } from \"commander\";\n\nexport const addPluginOptions = (\n\toptions:\n\t\t| {\n\t\t\t\t[x: string]: DotsecCliOption;\n\t\t }\n\t\t| undefined,\n\tcommand: Command,\n\tmandatory?: boolean,\n) => {\n\tif (options) {\n\t\tObject.values(options).map((option) => {\n\t\t\tlet optionProps:\n\t\t\t\t| {\n\t\t\t\t\t\tflags: string;\n\t\t\t\t\t\tdescription?: string;\n\t\t\t\t\t\tdefaultValue?: string | boolean | string[];\n\t\t\t\t\t\tfn?: (value: string, previous: unknown) => unknown;\n\t\t\t\t\t\tregexp?: RegExp;\n\t\t\t\t\t\tenv?: string;\n\t\t\t\t }\n\t\t\t\t| undefined;\n\t\t\tif (Array.isArray(option)) {\n\t\t\t\tconst [flags, description, defaultValue] = option;\n\t\t\t\toptionProps = {\n\t\t\t\t\tflags,\n\t\t\t\t\tdescription,\n\t\t\t\t\tdefaultValue,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tconst { flags, description, defaultValue, env, fn } = option;\n\t\t\t\toptionProps = {\n\t\t\t\t\tflags,\n\t\t\t\t\tdescription,\n\t\t\t\t\tdefaultValue,\n\t\t\t\t\tenv,\n\t\t\t\t\tfn,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (optionProps) {\n\t\t\t\tconst newOption = new Option(\n\t\t\t\t\toptionProps.flags,\n\t\t\t\t\toptionProps.description,\n\t\t\t\t);\n\t\t\t\tif (optionProps.fn) {\n\t\t\t\t\tnewOption.argParser(optionProps.fn);\n\t\t\t\t}\n\t\t\t\tif (optionProps.defaultValue) {\n\t\t\t\t\tnewOption.default(optionProps.defaultValue);\n\t\t\t\t}\n\t\t\t\tif (optionProps.env) {\n\t\t\t\t\tnewOption.env(optionProps.env);\n\t\t\t\t}\n\t\t\t\tif (mandatory) {\n\t\t\t\t\tnewOption.makeOptionMandatory(true);\n\t\t\t\t}\n\t\t\t\tcommand.addOption(newOption);\n\t\t\t}\n\t\t});\n\t}\n};\n", "import fs, { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport prompts from \"prompts\";\n\nexport const readContentsFromFile = async (\n\tfilePath: string,\n): Promise<string> => {\n\treturn await fs.readFile(filePath, \"utf-8\");\n};\n\nexport const writeContentsToFile = async (\n\tfilePath: string,\n\tcontents: string,\n): Promise<void> => {\n\treturn await fs.writeFile(filePath, contents, \"utf-8\");\n};\n\nexport const fileExists = async (source: string): Promise<boolean> => {\n\ttry {\n\t\tawait stat(source);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const promptOverwriteIfFileExists = async ({\n\tfilePath,\n\tskip,\n}: {\n\tfilePath: string;\n\tskip?: boolean;\n}) => {\n\tlet overwriteResponse: prompts.Answers<\"overwrite\"> | undefined;\n\n\tif ((await fileExists(filePath)) && skip !== true) {\n\t\toverwriteResponse = await prompts({\n\t\t\ttype: \"confirm\",\n\t\t\tname: \"overwrite\",\n\t\t\tmessage: () => {\n\t\t\t\treturn `Overwrite './${path.relative(process.cwd(), filePath)}' ?`;\n\t\t\t},\n\t\t});\n\t} else {\n\t\toverwriteResponse = undefined;\n\t}\n\treturn overwriteResponse;\n};\n", "import chalk from \"chalk\"\nimport Table = require(\"cli-table\")\nexport { Table }\n\nlet _logger: Pick<Console, \"info\" | \"error\" | \"table\">\nexport const getLogger = () => {\n\tif (!_logger) {\n\t\t_logger = console\n\t}\n\n\treturn _logger\n}\nexport const writeLine = (str: string) => {\n\tprocess.stdout.write(str)\n}\nexport const emphasis = (str: string): string => chalk.yellowBright(str)\nexport const strong = (str: string): string => chalk.yellow.bold(str)\n\nexport const clientLogger = {\n\tdebug(content: object) {\n\t\tconsole.log(content)\n\t},\n\tinfo(content: object) {\n\t\tconsole.log(content)\n\t},\n\twarn(content: object) {\n\t\tconsole.log(content)\n\t},\n\terror(content: object) {\n\t\tconsole.error(content)\n\t},\n}\n", "import { DotsecConfig } from \"../../types/index\";\nimport { Command, Option } from \"commander\";\n\nimport decryptCommandDefaults from \"./decrypt\";\nimport dotsecCommandDefaults from \"./dotsec\";\nimport encryptCommandDefaults from \"./encrypt\";\nimport initCommandDefaults from \"./init\";\nimport pullCommandDefaults from \"./push\";\nimport pushCommandDefaults from \"./push\";\nimport runCommandDefaults from \"./run\";\nimport {\n\tCommandOption,\n\tDotSecCommandDefaults,\n\tDotSecCommandOptions,\n\tDotSecCommandsDefaults,\n\tExpandedCommandOption,\n} from \"./types\";\n\nexport const commandOptions: DotSecCommandsDefaults = {\n\t...dotsecCommandDefaults,\n\t...initCommandDefaults,\n\t...encryptCommandDefaults,\n\t...decryptCommandDefaults,\n\t...runCommandDefaults,\n\t...pushCommandDefaults,\n\t...pullCommandDefaults,\n};\n\nconst getInheritedOptions = (\n\tcopts: DotSecCommandsDefaults,\n\tcommandName: string,\n\tresult: {\n\t\toptions?: DotSecCommandOptions;\n\t\trequiredOptions?: DotSecCommandOptions;\n\t} = {},\n): DotSecCommandDefaults | undefined => {\n\tconst command = copts[commandName];\n\tif (command) {\n\t\tif (command.inheritsFrom) {\n\t\t\treturn command?.inheritsFrom.reduce(\n\t\t\t\t(acc, inheritedCommandName) => {\n\t\t\t\t\treturn getInheritedOptions(copts, inheritedCommandName, acc);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...command,\n\t\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\t\trequiredOptions: {\n\t\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t...command,\n\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\trequiredOptions: {\n\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n};\n\nconst expandCommandOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n): ExpandedCommandOption => {\n\tif (Array.isArray(commandOption)) {\n\t\treturn {\n\t\t\toption: commandOption,\n\t\t};\n\t} else {\n\t\treturn commandOption;\n\t}\n};\n\nconst createOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n\toptions: {\n\t\trequired?: boolean;\n\t\tdotsecConfig?: DotsecConfig;\n\t\toptionKey: string;\n\t},\n): Option => {\n\tconst expandedCommandOption = expandCommandOption(commandOption);\n\tconst [option, description, defaultValue] = expandedCommandOption.option;\n\tconst defaultOptionValueFromConfig =\n\t\toptions?.dotsecConfig?.defaults?.options?.[options?.optionKey];\n\tconsole.log(\n\t\t\"defaultOptionValueFromConfig\",\n\t\toptions?.optionKey,\n\t\tdefaultOptionValueFromConfig,\n\t);\n\tconst newOption = new Option(\n\t\toption,\n\t\tdescription +\n\t\t\t(defaultOptionValueFromConfig ? \". Default from config.\" : \"\"),\n\t);\n\tif (defaultValue) {\n\t\tnewOption.default(defaultOptionValueFromConfig || defaultValue);\n\t}\n\tif (expandedCommandOption.env) {\n\t\tnewOption.env(expandedCommandOption.env);\n\t}\n\tif (options?.required) {\n\t\tnewOption.makeOptionMandatory(true);\n\t}\n\treturn newOption;\n};\nexport const setProgramOptions = (params: {\n\tprogram: Command;\n\tcommandName?: string;\n\tdotsecConfig: DotsecConfig;\n}) => {\n\tconst { program, commandName, dotsecConfig } = params;\n\tconst programOptions = commandOptions[commandName || program.name()];\n\n\tif (programOptions) {\n\t\tconst { options, requiredOptions, description, usage, helpText } =\n\t\t\tprogramOptions;\n\t\tif (options) {\n\t\t\tObject.keys(options).forEach((optionKey) => {\n\t\t\t\tconst commandOption = options[optionKey];\n\t\t\t\tconst newOption = createOption(commandOption, {\n\t\t\t\t\tdotsecConfig,\n\t\t\t\t\toptionKey,\n\t\t\t\t});\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.keys(requiredOptions).forEach((requiredOptionKey) => {\n\t\t\t\tconst requiredOption = requiredOptions[requiredOptionKey];\n\t\t\t\tconst newOption = createOption(requiredOption, {\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdotsecConfig,\n\t\t\t\t\toptionKey: requiredOptionKey,\n\t\t\t\t});\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (description) {\n\t\t\tprogram.description(description);\n\t\t}\n\t\tif (usage) {\n\t\t\tprogram.description(usage);\n\t\t}\n\t\tif (helpText) {\n\t\t\tprogram.description(helpText);\n\t\t}\n\t}\n};\n", "import {\n\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n} from \"../../constants\";\nimport { ExpandedCommandOption } from \"./types\";\n\nexport const envFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--env-file <envFile>\",\n\t\t`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTENV_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\t],\n\tenv: \"ENV_FILE\",\n};\nexport const secFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--sec-file, <secFile>\",\n\t\t`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTSEC_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n\t],\n\tenv: \"SEC_FILE\",\n};\n\nexport const withEnvOption: ExpandedCommandOption = {\n\toption: [\"--with-env, --withEnv\", \"Run command using a dot env file\"],\n};\n\nexport const withSecOption: ExpandedCommandOption = {\n\toption: [\"--with-sec, --withSec\", \"Run command with a dotsec file\"],\n};\n\nexport const yesOption: ExpandedCommandOption = {\n\toption: [\"--yes\", \"Skip confirmation prompts\"],\n};\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst decryptCommandDefaults: DotSecCommandsDefaults = {\n\tdecrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default decryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst dotsecCommandDefaults: DotSecCommandsDefaults = {\n\tdotsec: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\t\t\tplugin: [\"--plugin <plugin>\", \"Comma-separated list of plugins to use\"],\n\t\t},\n\t},\n};\n\nexport default dotsecCommandDefaults;\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst encryptCommandDefaults: DotSecCommandsDefaults = {\n\tencrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default encryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst initCommandDefaults: DotSecCommandsDefaults = {\n\tinit: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default initCommandDefaults;\n", "import {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst pullCommandDefaults: DotSecCommandsDefaults = {\n\tpull: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default pullCommandDefaults;\n", "import dotsecCommandDefaults from \"./dotsec\";\nimport {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst runCommandDefaults: DotSecCommandsDefaults = {\n\trunEnvOnly: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\tusage: \"[commandArgs...]\",\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tdescription:\n\t\t\t\"Run a command in a separate process and populate env with contents of a dotenv file.\",\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --env-file .env.dev echo \"hello world\"\n\n${\"Run a command with a specific ENV_FILE variable\"}\n\n$ ENV_FILE=.env.dev dotsec run echo \"hello world\"\n\n`,\n\t},\n\trun: {\n\t\tinheritsFrom: [\"dotsec\"],\n\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tusage:\n\t\t\t\"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]\",\n\t\tdescription: `Run a command in a separate process and populate env with either \n\t\t\t- contents of a dotenv file\n\t\t\t- decrypted values of a dotsec file.\n\nThe --withEnv option will take precedence over the --withSec option. If neither are specified, the --withEnv option will be used by default.`,\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --with-env --env-file .env.dev echo \"hello world\"\n\n\n${\"Run a command with a .sec file\"}\n\n$ dotsec run --with-sec echo \"hello world\"\n\n\n${\"Run a command with a specific .sec file\"}\n\n$ dotsec run --with-sec --sec-file .sec.dev echo \"hello world\"\n`,\n\t},\n\tpush: {\n\t\toptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.options,\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.requiredOptions,\n\t\t},\n\t},\n};\n\nexport default runCommandDefaults;\n", "import { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { DecryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"decrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<DecryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${options.decryptHandlers\n\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"Decrypting with\",\n\t\t\t\t\tstrong(\n\t\t\t\t\t\tpluginCliDecrypt.encryptionEngineName ||\n\t\t\t\t\t\t\tpluginCliDecrypt.triggerOptionValue,\n\t\t\t\t\t),\n\t\t\t\t\t\"engine\",\n\t\t\t\t);\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\t// get current dot env file\n\t\t\t\tconst dotsecString = await readContentsFromFile(secFile);\n\n\t\t\t\tconst plaintext = await pluginCliDecrypt.handler({\n\t\t\t\t\tciphertext: dotsecString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotenvOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: envFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotenvOverwriteResponse === undefined ||\n\t\t\t\t\tdotenvOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(envFile, plaintext);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote plaintext contents of ${strong(secFile)} file to ${strong(\n\t\t\t\t\t\t\tenvFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.decryptHandlers.map((decryption) => {\n\t\tconst { options, requiredOptions } = decryption;\n\t\taddPluginOptions(options, subProgram);\n\t\taddPluginOptions(requiredOptions, subProgram, true);\n\t});\n\n\tconst engines = options.decryptHandlers.map((e) => e.triggerOptionValue);\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"} to use: ${\n\t\t\tengines.length === 1 ? engines[0] : engines.join(\", \")\n\t\t}`,\n\t\tengines.length === 1 ? engines[0] : undefined,\n\t);\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { EncryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginEncryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tencryptHandlers: DotsecCliPluginEncryptHandler[];\n\t\tdotsecConfig: DotsecConfig;\n\t},\n) => {\n\tconst { encryptHandlers, dotsecConfig } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"encrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<EncryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\t\t\t\tconst pluginCliEncrypt = (encryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliEncrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No encryption plugin found, available encryption engine(s): ${options.encryptHandlers\n\t\t\t\t\t\t\t.map((e) => e.triggerOptionValue)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"Encrypting with\",\n\t\t\t\t\tstrong(\n\t\t\t\t\t\tpluginCliEncrypt.encryptionEngineName ||\n\t\t\t\t\t\t\tpluginCliEncrypt.triggerOptionValue,\n\t\t\t\t\t),\n\t\t\t\t\t\"engine\",\n\t\t\t\t);\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst dotenvString = await readContentsFromFile(envFile);\n\n\t\t\t\tconst cipherText = await pluginCliEncrypt.handler({\n\t\t\t\t\tplaintext: dotenvString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotsecOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: secFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotsecOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(secFile, cipherText);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote encrypted contents of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\tsecFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.encryptHandlers.map((encryptionHandler) => {\n\t\tconst { options, requiredOptions } = encryptionHandler;\n\t\taddPluginOptions(options, subProgram);\n\t\taddPluginOptions(requiredOptions, subProgram, true);\n\t});\n\tconst engines = options.encryptHandlers.map((e) => e.triggerOptionValue);\n\tconst encryptionEngineNames = options.encryptHandlers.map(\n\t\t(e) => e.encryptionEngineName,\n\t);\n\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\tengines.length === 1 ? engines[0] : engines.join(\", \")\n\t\t}`,\n\t);\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\tsubProgram.description(\n\t\t`Encrypt .env file using ${encryptionEngineNames.join(\", \")}`,\n\t);\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import fs from \"node:fs\";\nimport * as ts from \"typescript\";\n\nexport const patchConfigFile = (options: {\n\tconfigFile: string;\n\tconfig?: {\n\t\taws?: {\n\t\t\tregion?: string;\n\t\t\tkms?: {\n\t\t\t\tkeyAlias?: string;\n\t\t\t};\n\t\t};\n\t};\n}) => {\n\tconst printer: ts.Printer = ts.createPrinter();\n\tconst source = fs.readFileSync(options.configFile, \"utf8\");\n\n\tconst transformer =\n\t\t<T extends ts.Node>(context: ts.TransformationContext) =>\n\t\t(rootNode: T) => {\n\t\t\tfunction visit(node: ts.Node): ts.Node {\n\t\t\t\tnode = ts.visitEachChild(node, visit, context);\n\t\t\t\tif (node.kind === ts.SyntaxKind.StringLiteral) {\n\t\t\t\t\tconst kmsNode = node?.parent?.parent?.parent;\n\t\t\t\t\tif (options.config?.aws?.kms?.keyAlias) {\n\t\t\t\t\t\tif (kmsNode?.getChildAt(0)?.getText() === \"kms\") {\n\t\t\t\t\t\t\tconst awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(\n\t\t\t\t\t\t\t\t\toptions.config?.aws?.kms?.keyAlias,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (options.config?.aws?.region) {\n\t\t\t\t\t\tif (node?.parent?.getChildAt(0)?.getText() === \"region\") {\n\t\t\t\t\t\t\tconst awsNode = node?.parent?.parent?.parent;\n\n\t\t\t\t\t\t\t// const awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(options.config?.aws?.region);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\treturn ts.visitNode(rootNode, visit);\n\t\t};\n\n\tconst sourceFile: ts.SourceFile = ts.createSourceFile(\n\t\t\"test.ts\",\n\t\tsource,\n\t\tts.ScriptTarget.ES2015,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\t// Options may be passed to transform\n\tconst result: ts.TransformationResult<ts.SourceFile> =\n\t\tts.transform<ts.SourceFile>(sourceFile, [transformer]);\n\n\tconst transformedSourceFile: ts.SourceFile = result.transformed[0];\n\n\tconst transformedSource = printer.printFile(transformedSourceFile);\n\tresult.dispose();\n\n\treturn transformedSource;\n};\n", "import { promptOverwriteIfFileExists, writeContentsToFile } from \"../../lib/io\";\nimport { DotsecConfig, InitCommandOptions } from \"../../types\";\nimport { Command } from \"commander\";\n\nimport { patchConfigFile } from \"../../lib/transformer\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport path from \"node:path\";\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n};\n\nconst addInitProgram = async (\n\tprogram: Command,\n\toptions: { dotsecConfig: DotsecConfig },\n) => {\n\tconst { dotsecConfig } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"init\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\tconst { configFile, yes } = command.optsWithGlobals<InitCommandOptions>();\n\n\t\t\ttry {\n\t\t\t\tconst patchedConfigTemplate = patchConfigFile({\n\t\t\t\t\tconfigFile: path.resolve(\n\t\t\t\t\t\t__dirname,\n\t\t\t\t\t\t\"../../src/templates/dotsec.config.ts\",\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t\tconst dotsecConfigOverwriteResponse = await promptOverwriteIfFileExists(\n\t\t\t\t\t{\n\t\t\t\t\t\tfilePath: configFile,\n\t\t\t\t\t\tskip: yes,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdotsecConfigOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecConfigOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(configFile, patchedConfigTemplate);\n\t\t\t\t\tconsole.log(`Wrote config file to ${strong(configFile)}`);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcommand.error(e);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\n\treturn subProgram;\n};\n\nexport default addInitProgram;\n", "import { PushCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginPushHandler,\n} from \"../../types/plugin\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\nimport fs from \"node:fs\";\n\n/**\n * Decrypts, and pushes the contents of a .env file to AWS SSM, AWS Secrets Manager or GitHub Actions Secrets\n * @date 12/7/2022 - 9:16:48 AM\n *\n * @async\n * @param {Command} program\n * @returns {unknown}\n */\nconst addPushProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\thandlers: {\n\t\t\tpush: DotsecCliPluginPushHandler;\n\t\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t\t}[];\n\t},\n) => {\n\tconst { dotsecConfig, handlers } = options;\n\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"push\")\n\t\t.action(async (_options: Record<string, string>, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\twithEnv,\n\t\t\t\t\twithSec,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<PushCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\tconst pluginCliDecrypt = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.decrypt?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.decrypt;\n\n\t\t\t\tconst pluginCliPush = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.push?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.push;\n\n\t\t\t\tif (!pluginCliPush) {\n\t\t\t\t\tthrow new Error(\"No push plugin found!\");\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.requiredOptions || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t}\n\n\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\tif (withEnv || !(withEnv || withSec)) {\n\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t}\n\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t} else if (withSec) {\n\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${handlers\n\t\t\t\t\t\t\t\t.map((e) => `--${e.decrypt?.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (envContents) {\n\t\t\t\t\t// convert to object\n\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t// expand env vars\n\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tif (expandedEnvVars.parsed) {\n\t\t\t\t\t\tawait pluginCliPush.handler({\n\t\t\t\t\t\t\tpush: expandedEnvVars.parsed,\n\t\t\t\t\t\t\tyes,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\n\treturn subProgram;\n};\n\nexport default addPushProgram;\n", "import fs from \"node:fs\";\n\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\n\nimport { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport { RunCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { spawnSync } from \"node:child_process\";\nconst addRunProgam = (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers?: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options || {};\n\n\t// is there an encryption engine?\n\tconst hasDecryptEngine =\n\t\tdecryptHandlers !== undefined && decryptHandlers.length > 0;\n\n\tconst subProgram = program\n\t\t.command(\"run <command...>\")\n\t\t.allowUnknownOption(true)\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.showHelpAfterError(true)\n\t\t.action(\n\t\t\tasync (\n\t\t\t\tcommands: string[],\n\t\t\t\t_options: Record<string, string>,\n\t\t\t\tcommand: Command,\n\t\t\t) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { envFile, secFile, withEnv, withSec, engine } =\n\t\t\t\t\t\tcommand.optsWithGlobals<RunCommandOptions>();\n\t\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t\t}\n\n\t\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\t\tif (withEnv || !(withEnv || withSec) || hasDecryptEngine === false) {\n\t\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t\t} else if (withSec) {\n\t\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst encryptionEngine =\n\t\t\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${(\n\t\t\t\t\t\t\t\t\tdecryptHandlers || []\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t\t\t];\n\n\t\t\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (envContents) {\n\t\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t\t// expand env vars\n\t\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst [userCommand, ...userCommandArgs] = commands;\n\t\t\t\t\t\tconst spawn = spawnSync(userCommand, [...userCommandArgs], {\n\t\t\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\t\t\tshell: false,\n\t\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t\t...expandedEnvVars.parsed,\n\t\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\t\t__DOTSEC_ENV__: JSON.stringify(Object.keys(dotenvVars)),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (spawn.status !== 0) {\n\t\t\t\t\t\t\tprocess.exit(spawn.status || 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\t\tcommand.help();\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\tsetProgramOptions({\n\t\tprogram: subProgram,\n\t\tcommandName: hasDecryptEngine ? \"run\" : \"runEnvOnly\",\n\t\tdotsecConfig,\n\t});\n\n\tif (hasDecryptEngine) {\n\t\tdecryptHandlers?.map((run) => {\n\t\t\tconst { options, requiredOptions } = run;\n\t\t\taddPluginOptions(options, subProgram);\n\t\t\taddPluginOptions(requiredOptions, subProgram, true);\n\t\t});\n\t\tconst engines = decryptHandlers?.map((e) => e.triggerOptionValue);\n\n\t\tsubProgram.option(\n\t\t\t\"--engine <engine>\",\n\t\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t\t}`,\n\t\t\t// engines.length === 1 ? engines[0] : undefined,\n\t\t);\n\t}\n\treturn subProgram;\n};\n\nexport default addRunProgam;\n"],
5
+ "mappings": "k4BAAA,OAAwB,wBCEjB,GAAM,GAA6B,mBAC7B,GAAsB,CAAC,GACvB,EAAiC,OACjC,EAAiC,OACjC,EAA8B,GCN3C,OAAe,iBACf,GAAiB,wBAUV,YAAoB,EAAc,CACxC,GAAI,CACH,MAAO,IAAI,UAAS,UAAU,EAAK,iBAClC,CAGD,MAAO,IAYF,GAAM,IAAW,KAAO,IAAqB,CACnD,GAAI,CACH,MAAO,IAAW,KAAM,YAAG,SAAS,SAAS,EAAU,eAC/C,EAAP,CACD,KAAI,aAAiB,OACd,GAAI,OACT,mBAAmB,WAAK,SAAS,QAAQ,MAAO,OAC/C,EAAM,WAIF,ICpCT,OAA8B,6BAC9B,GAAmB,qBACnB,GAAiB,mBAEJ,GAAm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getOwnPropertyDescriptor,Pe=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,xe=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var oe=(e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,s=(e,t)=>{for(var r in t||(t={}))te.call(t,r)&&oe(e,r,t[r]);if(ee)for(var r of ee(t))Se.call(t,r)&&oe(e,r,t[r]);return e},D=(e,t)=>De(e,Pe(t)),je=e=>K(e,"__esModule",{value:!0});var U=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var Te=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of be(t))!te.call(e,n)&&n!=="default"&&K(e,n,{get:()=>t[n],enumerable:!(r=Fe(t,n))||r.enumerable});return e},ne=e=>Te(je(K(e!=null?Ee(xe(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);import{Command as ht}from"commander";var L="dotsec.config.ts",ie=[L],J=".sec",M=".env",_={};import $e from"fs";import _e from"node:path";function Ae(e){try{return new Function(`return ${e.trim()}`)()}catch{return{}}}var re=async e=>{try{return Ae(await $e.promises.readFile(e,"utf8"))}catch(t){throw t instanceof Error?new Error(`Failed to parse ${_e.relative(process.cwd(),e)}: ${t.message}`):t}};import{bundleRequire as ke}from"bundle-require";import He from"joycon";import Ie from"path";var se=async e=>{var i,l,p,a;let t=process.cwd(),n=await new He().resolve({files:e?[e]:[...ie,"package.json"],cwd:t,stopDir:Ie.parse(t).root,packageKey:"dotsec"});if(e&&n===null)throw new Error(`Could not find config file ${e}`);if(n){if(n.endsWith(".json")){let c=await re(n),o;return n.endsWith("package.json")&&c.dotsec!==void 0?o=c.dotsec:o=c,{source:"json",contents:D(s(s({},_),o),{defaults:D(s(s({},o==null?void 0:o.defaults),_.defaults),{plugins:s(s({},(i=o==null?void 0:o.defaults)==null?void 0:i.plugins),(l=_.defaults)==null?void 0:l.plugins)}),push:s({},o==null?void 0:o.push)})}}else if(n.endsWith(".ts")){let c=await ke({filepath:n}),o=c.mod.dotsec||c.mod.default||c.mod;return{source:"ts",contents:D(s(s({},_),o),{defaults:D(s(s({},o==null?void 0:o.defaults),_.defaults),{plugins:s(s({},(p=o==null?void 0:o.defaults)==null?void 0:p.plugins),(a=_.defaults)==null?void 0:a.plugins)}),push:s({},o==null?void 0:o.push)})}}}return{source:"defaultConfig",contents:_}};var B=async e=>Promise.resolve().then(()=>ne(U(e.name))).then(t=>t.default);import ae,{stat as Ve}from"node:fs/promises";import Le from"node:path";import Re from"prompts";var W=async e=>await ae.readFile(e,"utf-8"),H=async(e,t)=>await ae.writeFile(e,t,"utf-8"),Ne=async e=>{try{return await Ve(e),!0}catch{return!1}},I=async({filePath:e,skip:t})=>{let r;return await Ne(e)&&t!==!0?r=await Re({type:"confirm",name:"overwrite",message:()=>`Overwrite './${Le.relative(process.cwd(),e)}' ?`}):r=void 0,r};import qe from"chalk";var Lt=U("cli-table");var b=e=>qe.yellow.bold(e);import{Option as Be}from"commander";var x={option:["--env-file <envFile>",`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${M}' file in current directory.`,M],env:"ENV_FILE"},T={option:["--sec-file <secFile>",`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${J}' file in current directory.`,J],env:"SEC_FILE"},R={option:["--with-env, --withEnv","Run command using a dot env file"]},N={option:["--with-sec, --withSec","Run command with a dotsec file"]},S={option:["--yes","Skip confirmation prompts"]};var Ke={decrypt:{inheritsFrom:["dotsec"],options:{envFile:x,secFile:T,yes:S}}},ce=Ke;var We={dotsec:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",L],plugin:["--plugin <plugin>","Comma-separated list of plugins to use"]}}},q=We;var Ge={encrypt:{inheritsFrom:["dotsec"],options:{envFile:x,secFile:T,yes:S}}},pe=Ge;var Ue={init:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",L],envFile:x,secFile:T,yes:S}}},le=Ue;var Je={pull:{inheritsFrom:["dotsec"],options:{withEnv:R,withSec:N,envFile:x,secFile:T,yes:S}}},G=Je;var Me={runEnvOnly:{inheritsFrom:["dotsec"],usage:"[commandArgs...]",options:{envFile:x,yes:S},description:"Run a command in a separate process and populate env with contents of a dotenv file.",helpText:`Examples:
1
+ var Ee=Object.create;var W=Object.defineProperty,Fe=Object.defineProperties,Pe=Object.getOwnPropertyDescriptor,xe=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertyNames,te=Object.getOwnPropertySymbols,Se=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var ne=(e,t,r)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,c=(e,t)=>{for(var r in t||(t={}))oe.call(t,r)&&ne(e,r,t[r]);if(te)for(var r of te(t))Te.call(t,r)&&ne(e,r,t[r]);return e},E=(e,t)=>Fe(e,xe(t)),je=e=>W(e,"__esModule",{value:!0});var J=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var $e=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of be(t))!oe.call(e,o)&&o!=="default"&&W(e,o,{get:()=>t[o],enumerable:!(r=Pe(t,o))||r.enumerable});return e},ie=e=>$e(je(W(e!=null?Ee(Se(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);import{Command as Ot}from"commander";var R="dotsec.config.ts",re=[R],M=".sec",B=".env",_={};import ke from"fs";import _e from"node:path";function Ae(e){try{return new Function(`return ${e.trim()}`)()}catch{return{}}}var se=async e=>{try{return Ae(await ke.promises.readFile(e,"utf8"))}catch(t){throw t instanceof Error?new Error(`Failed to parse ${_e.relative(process.cwd(),e)}: ${t.message}`):t}};import{bundleRequire as Ve}from"bundle-require";import He from"joycon";import Ie from"path";var ae=async e=>{var n,a,l,s;let t=process.cwd(),o=await new He().resolve({files:e?[e]:[...re,"package.json"],cwd:t,stopDir:Ie.parse(t).root,packageKey:"dotsec"});if(e&&o===null)throw new Error(`Could not find config file ${e}`);if(o){if(o.endsWith(".json")){let p=await se(o),i;return o.endsWith("package.json")&&p.dotsec!==void 0?i=p.dotsec:i=p,{source:"json",contents:E(c(c({},_),i),{defaults:E(c(c({},i==null?void 0:i.defaults),_.defaults),{plugins:c(c({},(n=i==null?void 0:i.defaults)==null?void 0:n.plugins),(a=_.defaults)==null?void 0:a.plugins)}),push:c({},i==null?void 0:i.push)})}}else if(o.endsWith(".ts")){let p=await Ve({filepath:o}),i=p.mod.dotsec||p.mod.default||p.mod;return{source:"ts",contents:E(c(c({},_),i),{defaults:E(c(c({},i==null?void 0:i.defaults),_.defaults),{plugins:c(c({},(l=i==null?void 0:i.defaults)==null?void 0:l.plugins),(s=_.defaults)==null?void 0:s.plugins)}),push:c({},i==null?void 0:i.push)})}}}return{source:"defaultConfig",contents:_}};var z=async e=>Promise.resolve().then(()=>ie(J(e.name))).then(t=>t.default);import{Option as Ne}from"commander";var $=(e,t,r)=>{e&&Object.values(e).map(o=>{let n;if(Array.isArray(o)){let[a,l,s]=o;n={flags:a,description:l,defaultValue:s}}else{let{flags:a,description:l,defaultValue:s,env:p,fn:i}=o;n={flags:a,description:l,defaultValue:s,env:p,fn:i}}if(n){let a=new Ne(n.flags,n.description);n.fn&&a.argParser(n.fn),n.defaultValue&&a.default(n.defaultValue),n.env&&a.env(n.env),r&&a.makeOptionMandatory(!0),t.addOption(a)}})};import ce,{stat as Re}from"node:fs/promises";import Le from"node:path";import qe from"prompts";var G=async e=>await ce.readFile(e,"utf-8"),H=async(e,t)=>await ce.writeFile(e,t,"utf-8"),Ke=async e=>{try{return await Re(e),!0}catch{return!1}},I=async({filePath:e,skip:t})=>{let r;return await Ke(e)&&t!==!0?r=await qe({type:"confirm",name:"overwrite",message:()=>`Overwrite './${Le.relative(process.cwd(),e)}' ?`}):r=void 0,r};import We from"chalk";var Wt=J("cli-table");var F=e=>We.yellow.bold(e);import{Option as Qe}from"commander";var b={option:["--env-file <envFile>",`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${B}' file in current directory.`,B],env:"ENV_FILE"},j={option:["--sec-file, <secFile>",`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${M}' file in current directory.`,M],env:"SEC_FILE"},L={option:["--with-env, --withEnv","Run command using a dot env file"]},q={option:["--with-sec, --withSec","Run command with a dotsec file"]},S={option:["--yes","Skip confirmation prompts"]};var Ge={decrypt:{inheritsFrom:["dotsec"],options:{envFile:b,secFile:j,yes:S}}},pe=Ge;var Ue={dotsec:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",R],plugin:["--plugin <plugin>","Comma-separated list of plugins to use"]}}},K=Ue;var Je={encrypt:{inheritsFrom:["dotsec"],options:{envFile:b,secFile:j,yes:S}}},le=Je;var Me={init:{options:{verbose:["--verbose","Verbose output",!1],configFile:["-c, --config-file, --configFile <configFile>","Config file",R],envFile:b,secFile:j,yes:S}}},me=Me;var Be={pull:{inheritsFrom:["dotsec"],options:{withEnv:L,withSec:q,envFile:b,secFile:j,yes:S}}},U=Be;var ze={runEnvOnly:{inheritsFrom:["dotsec"],usage:"[commandArgs...]",options:{envFile:b,yes:S},description:"Run a command in a separate process and populate env with contents of a dotenv file.",helpText:`Examples:
2
2
 
3
3
  Run a command with a .env file
4
4
 
@@ -13,7 +13,7 @@ Run a command with a specific ENV_FILE variable
13
13
 
14
14
  $ ENV_FILE=.env.dev dotsec run echo "hello world"
15
15
 
16
- `},run:{inheritsFrom:["dotsec"],options:{withEnv:R,withSec:N,envFile:x,secFile:T,yes:S},usage:"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]",description:`Run a command in a separate process and populate env with either
16
+ `},run:{inheritsFrom:["dotsec"],options:{withEnv:L,withSec:q,envFile:b,secFile:j,yes:S},usage:"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]",description:`Run a command in a separate process and populate env with either
17
17
  - contents of a dotenv file
18
18
  - decrypted values of a dotsec file.
19
19
 
@@ -37,5 +37,5 @@ $ dotsec run --with-sec echo "hello world"
37
37
  Run a command with a specific .sec file
38
38
 
39
39
  $ dotsec run --with-sec --sec-file .sec.dev echo "hello world"
40
- `},push:{options:D(s({},q.dotsec.options),{withEnv:R,withSec:N,envFile:x,secFile:T,yes:S}),requiredOptions:s({},q.dotsec.requiredOptions)}},me=Me;var Ye=s(s(s(s(s(s(s({},q),le),pe),ce),me),G),G);var ze=e=>Array.isArray(e)?{option:e}:e,de=(e,t)=>{let r=ze(e),[n,i,l]=r.option,p=new Be(n,i);return l&&p.default(l),r.env&&p.env(r.env),(t==null?void 0:t.required)&&p.makeOptionMandatory(!0),p},j=(e,t)=>{let r=Ye[t||e.name()];if(r){let{options:n,requiredOptions:i,description:l,usage:p,helpText:a}=r;n&&Object.values(n).forEach(c=>{let o=de(c);e.addOption(o)}),i&&Object.values(i).forEach(c=>{let o=de(c,{required:!0});e.addOption(o)}),l&&e.description(l),p&&e.description(p),a&&e.description(a)}};var Qe=async(e,t)=>{let{dotsecConfig:r,decryptHandlers:n}=t,i=e.enablePositionalOptions().passThroughOptions().command("decrypt").action(async(p,a)=>{var c;try{let{envFile:o,secFile:m,engine:f,yes:w}=a.optsWithGlobals(),v=f||((c=r==null?void 0:r.defaults)==null?void 0:c.encryptionEngine),E=(n||[]).find(C=>C.triggerOptionValue===v);if(!E)throw new Error(`No decryption plugin found, available decryption engine(s): ${t.decryptHandlers.map(C=>`--${C.triggerOptionValue}`).join(", ")}`);let u=[...Object.keys(E.options||{}),...Object.keys(E.requiredOptions||{})],d=Object.fromEntries(u.map(C=>[C,p[C]])),g=await W(m),h=await E.handler(s({ciphertext:g},d)),y=await I({filePath:o,skip:w});(y===void 0||y.overwrite===!0)&&(await H(o,h),console.log(`Wrote plaintext contents of ${b(m)} file to ${b(o)}`))}catch(o){console.error(b(o.message)),a.help()}});t.decryptHandlers.map(p=>{let{options:a,requiredOptions:c}=p;a&&Object.values(a).map(o=>{i.option(...o)}),c&&Object.values(c).map(o=>{i.option(...o)})});let l=t.decryptHandlers.map(p=>p.triggerOptionValue);return i.option("--engine <engine>",`Encryption engine${l.length>0?"s":""} to use: ${l.join(", "),l.length===1?l[0]:void 0}`,l.length===1?l[0]:void 0),j(i),i},fe=Qe;var Xe=async(e,t)=>{let{encryptHandlers:r,dotsecConfig:n}=t,i=e.enablePositionalOptions().passThroughOptions().command("encrypt").action(async(a,c)=>{var o;try{let{envFile:m,secFile:f,engine:w,yes:v}=c.optsWithGlobals(),E=w||((o=n==null?void 0:n.defaults)==null?void 0:o.encryptionEngine),u=(r||[]).find(O=>O.triggerOptionValue===E);if(!u)throw new Error(`No encryption plugin found, available encryption engine(s): ${t.encryptHandlers.map(O=>O.triggerOptionValue).join(", ")}`);let d=[...Object.keys(u.options||{}),...Object.keys(u.requiredOptions||{})],g=Object.fromEntries(d.map(O=>[O,a[O]])),h=await W(m),y=await u.handler(s({plaintext:h},g)),C=await I({filePath:f,skip:v});(C===void 0||C.overwrite===!0)&&(await H(f,y),console.log(`Wrote encrypted contents of ${b(m)} file to ${b(f)}`))}catch(m){console.error(b(m.message)),c.help()}});t.encryptHandlers.map(a=>{let{options:c,requiredOptions:o}=a;c&&Object.values(c).map(m=>{i.option(...m)}),o&&Object.values(o).map(m=>{i.option(...m)})});let l=t.encryptHandlers.map(a=>a.triggerOptionValue),p=t.encryptHandlers.map(a=>a.encryptionEngineName);return i.option("--engine <engine>",`Encryption engine${l.length>0?"s":""}: ${l.join(", "),l.length===1?l[0]:void 0}`),j(i),i.description(`Encrypt .env file using ${p.join(", ")}`),i},ue=Xe;import Ze from"node:fs";import{ScriptKind as st,ScriptTarget as rt,SyntaxKind as ot,createPrinter as et,createSourceFile as it,createStringLiteral as ye,transform as at,visitEachChild as tt,visitNode as nt}from"typescript";var ge=e=>{let t=et(),r=Ze.readFileSync(e.configFile,"utf8"),n=c=>o=>{function m(f){var w,v,E,u,d,g,h,y,C,O,F,P,V,Y,z,Q,X,Z;if(f=tt(f,m,c),f.kind===ot.StringLiteral){let k=(v=(w=f==null?void 0:f.parent)==null?void 0:w.parent)==null?void 0:v.parent;if(((d=(u=(E=e.config)==null?void 0:E.aws)==null?void 0:u.kms)==null?void 0:d.keyAlias)&&((g=k==null?void 0:k.getChildAt(0))==null?void 0:g.getText())==="kms"){let A=(h=k==null?void 0:k.parent)==null?void 0:h.parent;if((A==null?void 0:A.getChildAt(0).getText())==="aws")return ye((O=(C=(y=e.config)==null?void 0:y.aws)==null?void 0:C.kms)==null?void 0:O.keyAlias)}if(((P=(F=e.config)==null?void 0:F.aws)==null?void 0:P.region)&&((Y=(V=f==null?void 0:f.parent)==null?void 0:V.getChildAt(0))==null?void 0:Y.getText())==="region"){let A=(Q=(z=f==null?void 0:f.parent)==null?void 0:z.parent)==null?void 0:Q.parent;if((A==null?void 0:A.getChildAt(0).getText())==="aws")return ye((Z=(X=e.config)==null?void 0:X.aws)==null?void 0:Z.region)}}return f}return nt(o,m)},i=it("test.ts",r,rt.ES2015,!0,st.TS),l=at(i,[n]),p=l.transformed[0],a=t.printFile(p);return l.dispose(),a};import ct from"node:path";var pt=async e=>{let t=e.enablePositionalOptions().passThroughOptions().command("init").action(async(r,n)=>{let{configFile:i,yes:l}=n.optsWithGlobals();try{let p=ge({configFile:ct.resolve(__dirname,"../../src/templates/dotsec.config.ts")}),a=await I({filePath:i,skip:l});(a===void 0||a.overwrite===!0)&&(await H(i,p),console.log(`Wrote config file to ${b(i)}`))}catch(p){n.error(p)}});return j(t),t},he=pt;import{parse as lt}from"dotenv";import{expand as mt}from"dotenv-expand";import Oe from"node:fs";var dt=async(e,t)=>{let{dotsecConfig:r,handlers:n}=t,i=e.enablePositionalOptions().passThroughOptions().command("push").action(async(l,p)=>{var a,c,o;try{let{envFile:m,secFile:f,withEnv:w,withSec:v,engine:E,yes:u}=p.optsWithGlobals(),d=E||((a=r==null?void 0:r.defaults)==null?void 0:a.encryptionEngine),g=(c=(n||[]).find(F=>{var P;return((P=F.decrypt)==null?void 0:P.triggerOptionValue)===d}))==null?void 0:c.decrypt,h=(o=(n||[]).find(F=>{var P;return((P=F.push)==null?void 0:P.triggerOptionValue)===d}))==null?void 0:o.push;if(!h)throw new Error("No push plugin found!");let y=[...Object.keys((g==null?void 0:g.options)||{}),...Object.keys((g==null?void 0:g.requiredOptions)||{}),...Object.keys((h==null?void 0:h.options)||{}),...Object.keys((h==null?void 0:h.requiredOptions)||{})],C=Object.fromEntries(y.map(F=>[F,l[F]]));if(w&&v)throw new Error("Cannot use both --with-env and --with-sec");let O;if(w||!(w||v)){if(!m)throw new Error("No dotenv file specified in --env-file option");O=Oe.readFileSync(m,"utf8")}else if(v){if(!f)throw new Error("No dotsec file specified in --sec-file option");if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${n.map(P=>{var V;return`--${(V=P.decrypt)==null?void 0:V.triggerOptionValue}`}).join(", ")}`);let F=Oe.readFileSync(f,"utf8");O=await g.handler(s({ciphertext:F},C))}if(O){let F=lt(O),P=mt({ignoreProcessEnv:!0,parsed:s(s({},process.env),F)});P.parsed&&await h.handler(s({push:P.parsed,yes:u},C))}else throw new Error("No .env or .sec file provided")}catch(m){console.error(m),process.exit(1)}});return j(i),i},Ce=dt;import we from"node:fs";import{parse as ft}from"dotenv";import{expand as ut}from"dotenv-expand";import{spawnSync as gt}from"node:child_process";var yt=(e,t)=>{let{dotsecConfig:r,decryptHandlers:n}=t||{},i=n!==void 0&&n.length>0,l=e.command("run <command...>").allowUnknownOption(!0).enablePositionalOptions().passThroughOptions().showHelpAfterError(!0).action(async(p,a,c)=>{var o;console.log("yo");try{let{envFile:m,secFile:f,withEnv:w,withSec:v,engine:E}=c.optsWithGlobals();if(console.log({envFile:m,secFile:f,withEnv:w,withSec:v,engine:E}),w&&v)throw new Error("Cannot use both --with-env and --with-sec");let u;if(w||!(w||v)||i===!1){if(console.log("ENV ONLY"),!m)throw new Error("No dotenv file specified in --env-file option");u=we.readFileSync(m,"utf8"),console.log("envCOntents",u)}else if(v){if(!f)throw new Error("No dotsec file specified in --sec-file option");let d=E||((o=r==null?void 0:r.defaults)==null?void 0:o.encryptionEngine),g=(n||[]).find(O=>O.triggerOptionValue===d);if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${(n||[]).map(O=>`--${O.triggerOptionValue}`).join(", ")}`);let h=[...Object.keys(g.options||{}),...Object.keys(g.requiredOptions||{})],y=Object.fromEntries(h.map(O=>[O,a[O]])),C=we.readFileSync(f,"utf8");u=await g.handler(s({ciphertext:C},y))}if(u){let d=ft(u),g=ut({ignoreProcessEnv:!0,parsed:s(s({},process.env),d)}),[h,...y]=p,C=gt(h,[...y],{stdio:"inherit",shell:!1,encoding:"utf-8",env:D(s(s({},g.parsed),process.env),{__DOTSEC_ENV__:JSON.stringify(Object.keys(d))})});C.status!==0&&process.exit(C.status||1)}else throw new Error("No .env or .sec file provided")}catch(m){console.error(b(m.message)),c.help()}});if(j(l,i?"run":"runEnvOnly"),i){n==null||n.map(a=>{let{options:c,requiredOptions:o}=a;c&&Object.values(c).map(m=>{l.option(...m)}),o&&Object.values(o).map(m=>{l.option(...m)})});let p=n==null?void 0:n.map(a=>a.triggerOptionValue);l.option("--engine <engine>",`Encryption engine${p.length>0?"s":""}: ${p.join(", "),p.length===1?p[0]:void 0}`)}return l},ve=yt;import Ot from"ajv";import Ct from"yargs-parser";var wt={keyword:"separator",type:"string",metaSchema:{type:"string",description:"value separator"},modifying:!0,valid:!0,errors:!1,compile:e=>(t,r)=>{if(r){let{parentData:n,parentDataProperty:i}=r;return n[i]=t===""?[]:t.split(e),!0}else return!1}},$=new ht;(async()=>{var f,w,v,E;let e=Ct(process.argv),t=[];e.plugin&&(Array.isArray(e.plugin)?t.push(...e.plugin):t.push(e.plugin));let r=[...Array.isArray(e.config)?e.config:[e.config],...Array.isArray(e.c)?e.c:[e.c]][0],{contents:n={}}=await se(r),{defaults:i,push:l}=n;$.name("dotsec").description(".env, but secure").version("1.0.0").enablePositionalOptions().action((u,d)=>{d.help()}),j($);let p=new Ot({allErrors:!0,removeAdditional:!0,useDefaults:!0,coerceTypes:!0,allowUnionTypes:!0,addUsedSchema:!1,keywords:[wt]}),a={};if(t.length>0)for(let u of t){let g=await(await B({name:u}))({dotsecConfig:n,ajv:p});a[g.name]=u,t.length===1&&(n.defaults=D(s({},n.defaults),{encryptionEngine:String(g.name),plugins:D(s({},(f=n.defaults)==null?void 0:f.plugins),{[g.name]:s({},(v=(w=n.defaults)==null?void 0:w.plugins)==null?void 0:v[g.name])})}))}(i==null?void 0:i.encryptionEngine)&&(((E=i==null?void 0:i.plugins)==null?void 0:E[i.encryptionEngine])||(i.plugins=D(s({},i.plugins),{[i.encryptionEngine]:{}}))),(i==null?void 0:i.plugins)&&Object.entries(i==null?void 0:i.plugins).forEach(([u,d])=>{(d==null?void 0:d.module)?a[u]=d==null?void 0:d.module:a[u]=`@dotsec/plugin-${u}`}),Object.values(l||{}).forEach(u=>{Object.keys(u).forEach(d=>{a[d]||(a[d]=`@dotsec/plugin-${d}`)})});let c=[],o=[],m=[];for(let u of Object.keys(a)){let d=a[u],g=await B({name:d}),{addCliCommand:h,cliHandlers:y}=await g({ajv:p,dotsecConfig:n});(y==null?void 0:y.encrypt)&&c.push(y.encrypt),(y==null?void 0:y.decrypt)&&(o.push(y.decrypt),(y==null?void 0:y.push)&&m.push({push:y.push,decrypt:y.decrypt})),h&&h({program:$})}c.length&&await ue($,{dotsecConfig:n,encryptHandlers:c}),o.length&&await fe($,{dotsecConfig:n,decryptHandlers:o}),m.length&&await Ce($,{dotsecConfig:n,handlers:m}),await he($),await ve($,{dotsecConfig:n,decryptHandlers:o}),await $.parse()})();
40
+ `},push:{options:E(c({},K.dotsec.options),{withEnv:L,withSec:q,envFile:b,secFile:j,yes:S}),requiredOptions:c({},K.dotsec.requiredOptions)}},de=ze;var Xe=c(c(c(c(c(c(c({},K),me),le),pe),de),U),U);var Ye=e=>Array.isArray(e)?{option:e}:e,fe=(e,t)=>{var p,i,m;let r=Ye(e),[o,n,a]=r.option,l=(m=(i=(p=t==null?void 0:t.dotsecConfig)==null?void 0:p.defaults)==null?void 0:i.options)==null?void 0:m[t==null?void 0:t.optionKey];console.log("defaultOptionValueFromConfig",t==null?void 0:t.optionKey,l);let s=new Qe(o,n+(l?". Default from config.":""));return a&&s.default(l||a),r.env&&s.env(r.env),(t==null?void 0:t.required)&&s.makeOptionMandatory(!0),s},T=e=>{let{program:t,commandName:r,dotsecConfig:o}=e,n=Xe[r||t.name()];if(n){let{options:a,requiredOptions:l,description:s,usage:p,helpText:i}=n;a&&Object.keys(a).forEach(m=>{let d=a[m],C=fe(d,{dotsecConfig:o,optionKey:m});t.addOption(C)}),l&&Object.keys(l).forEach(m=>{let d=l[m],C=fe(d,{required:!0,dotsecConfig:o,optionKey:m});t.addOption(C)}),s&&t.description(s),p&&t.description(p),i&&t.description(i)}};var Ze=async(e,t)=>{let{dotsecConfig:r,decryptHandlers:o}=t,n=e.enablePositionalOptions().passThroughOptions().command("decrypt").action(async(l,s)=>{var p;try{let{envFile:i,secFile:m,engine:d,yes:C}=s.optsWithGlobals(),D=d||((p=r==null?void 0:r.defaults)==null?void 0:p.encryptionEngine),v=(o||[]).find(w=>w.triggerOptionValue===D);if(!v)throw new Error(`No decryption plugin found, available decryption engine(s): ${t.decryptHandlers.map(w=>`--${w.triggerOptionValue}`).join(", ")}`);console.log("Decrypting with",F(v.encryptionEngineName||v.triggerOptionValue),"engine");let f=[...Object.keys(v.options||{}),...Object.keys(v.requiredOptions||{})],u=Object.fromEntries(f.map(w=>[w,l[w]])),g=await G(m),h=await v.handler(c({ciphertext:g},u)),y=await I({filePath:i,skip:C});(y===void 0||y.overwrite===!0)&&(await H(i,h),console.log(`Wrote plaintext contents of ${F(m)} file to ${F(i)}`))}catch(i){console.error(F(i.message)),s.help()}});t.decryptHandlers.map(l=>{let{options:s,requiredOptions:p}=l;$(s,n),$(p,n,!0)});let a=t.decryptHandlers.map(l=>l.triggerOptionValue);return n.option("--engine <engine>",`Encryption engine${a.length>0?"s":""} to use: ${a.length===1?a[0]:a.join(", ")}`,a.length===1?a[0]:void 0),T({program:n,dotsecConfig:r}),n},ue=Ze;var et=async(e,t)=>{let{encryptHandlers:r,dotsecConfig:o}=t,n=e.enablePositionalOptions().passThroughOptions().command("encrypt").action(async(s,p)=>{var i;try{let{envFile:m,secFile:d,engine:C,yes:D}=p.optsWithGlobals(),v=C||((i=o==null?void 0:o.defaults)==null?void 0:i.encryptionEngine),f=(r||[]).find(O=>O.triggerOptionValue===v);if(!f)throw new Error(`No encryption plugin found, available encryption engine(s): ${t.encryptHandlers.map(O=>O.triggerOptionValue).join(", ")}`);console.log("Encrypting with",F(f.encryptionEngineName||f.triggerOptionValue),"engine");let u=[...Object.keys(f.options||{}),...Object.keys(f.requiredOptions||{})],g=Object.fromEntries(u.map(O=>[O,s[O]])),h=await G(m),y=await f.handler(c({plaintext:h},g)),w=await I({filePath:d,skip:D});(w===void 0||w.overwrite===!0)&&(await H(d,y),console.log(`Wrote encrypted contents of ${F(m)} file to ${F(d)}`))}catch(m){console.error(F(m.message)),p.help()}});t.encryptHandlers.map(s=>{let{options:p,requiredOptions:i}=s;$(p,n),$(i,n,!0)});let a=t.encryptHandlers.map(s=>s.triggerOptionValue),l=t.encryptHandlers.map(s=>s.encryptionEngineName);return n.option("--engine <engine>",`Encryption engine${a.length>0?"s":""}: ${a.length===1?a[0]:a.join(", ")}`),T({program:n,dotsecConfig:o}),n.description(`Encrypt .env file using ${l.join(", ")}`),n},ge=et;import tt from"node:fs";import{ScriptKind as ct,ScriptTarget as at,SyntaxKind as it,createPrinter as ot,createSourceFile as st,createStringLiteral as he,transform as pt,visitEachChild as nt,visitNode as rt}from"typescript";var ye=e=>{let t=ot(),r=tt.readFileSync(e.configFile,"utf8"),o=p=>i=>{function m(d){var C,D,v,f,u,g,h,y,w,O,P,x,N,Q,X,Y,Z,ee;if(d=nt(d,m,p),d.kind===it.StringLiteral){let V=(D=(C=d==null?void 0:d.parent)==null?void 0:C.parent)==null?void 0:D.parent;if(((u=(f=(v=e.config)==null?void 0:v.aws)==null?void 0:f.kms)==null?void 0:u.keyAlias)&&((g=V==null?void 0:V.getChildAt(0))==null?void 0:g.getText())==="kms"){let A=(h=V==null?void 0:V.parent)==null?void 0:h.parent;if((A==null?void 0:A.getChildAt(0).getText())==="aws")return he((O=(w=(y=e.config)==null?void 0:y.aws)==null?void 0:w.kms)==null?void 0:O.keyAlias)}if(((x=(P=e.config)==null?void 0:P.aws)==null?void 0:x.region)&&((Q=(N=d==null?void 0:d.parent)==null?void 0:N.getChildAt(0))==null?void 0:Q.getText())==="region"){let A=(Y=(X=d==null?void 0:d.parent)==null?void 0:X.parent)==null?void 0:Y.parent;if((A==null?void 0:A.getChildAt(0).getText())==="aws")return he((ee=(Z=e.config)==null?void 0:Z.aws)==null?void 0:ee.region)}}return d}return rt(i,m)},n=st("test.ts",r,at.ES2015,!0,ct.TS),a=pt(n,[o]),l=a.transformed[0],s=t.printFile(l);return a.dispose(),s};import lt from"node:path";var mt=async(e,t)=>{let{dotsecConfig:r}=t,o=e.enablePositionalOptions().passThroughOptions().command("init").action(async(n,a)=>{let{configFile:l,yes:s}=a.optsWithGlobals();try{let p=ye({configFile:lt.resolve(__dirname,"../../src/templates/dotsec.config.ts")}),i=await I({filePath:l,skip:s});(i===void 0||i.overwrite===!0)&&(await H(l,p),console.log(`Wrote config file to ${F(l)}`))}catch(p){a.error(p)}});return T({program:o,dotsecConfig:r}),o},Ce=mt;import{parse as dt}from"dotenv";import{expand as ft}from"dotenv-expand";import Oe from"node:fs";var ut=async(e,t)=>{let{dotsecConfig:r,handlers:o}=t,n=e.enablePositionalOptions().passThroughOptions().command("push").action(async(a,l)=>{var s,p,i;try{let{envFile:m,secFile:d,withEnv:C,withSec:D,engine:v,yes:f}=l.optsWithGlobals(),u=v||((s=r==null?void 0:r.defaults)==null?void 0:s.encryptionEngine),g=(p=(o||[]).find(P=>{var x;return((x=P.decrypt)==null?void 0:x.triggerOptionValue)===u}))==null?void 0:p.decrypt,h=(i=(o||[]).find(P=>{var x;return((x=P.push)==null?void 0:x.triggerOptionValue)===u}))==null?void 0:i.push;if(!h)throw new Error("No push plugin found!");let y=[...Object.keys((g==null?void 0:g.options)||{}),...Object.keys((g==null?void 0:g.requiredOptions)||{}),...Object.keys((h==null?void 0:h.options)||{}),...Object.keys((h==null?void 0:h.requiredOptions)||{})],w=Object.fromEntries(y.map(P=>[P,a[P]]));if(C&&D)throw new Error("Cannot use both --with-env and --with-sec");let O;if(C||!(C||D)){if(!m)throw new Error("No dotenv file specified in --env-file option");O=Oe.readFileSync(m,"utf8")}else if(D){if(!d)throw new Error("No dotsec file specified in --sec-file option");if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${o.map(x=>{var N;return`--${(N=x.decrypt)==null?void 0:N.triggerOptionValue}`}).join(", ")}`);let P=Oe.readFileSync(d,"utf8");O=await g.handler(c({ciphertext:P},w))}if(O){let P=dt(O),x=ft({ignoreProcessEnv:!0,parsed:c(c({},process.env),P)});x.parsed&&await h.handler(c({push:x.parsed,yes:f},w))}else throw new Error("No .env or .sec file provided")}catch(m){console.error(m),process.exit(1)}});return T({program:n,dotsecConfig:r}),n},we=ut;import ve from"node:fs";import{parse as gt}from"dotenv";import{expand as yt}from"dotenv-expand";import{spawnSync as ht}from"node:child_process";var Ct=(e,t)=>{let{dotsecConfig:r,decryptHandlers:o}=t||{},n=o!==void 0&&o.length>0,a=e.command("run <command...>").allowUnknownOption(!0).enablePositionalOptions().passThroughOptions().showHelpAfterError(!0).action(async(l,s,p)=>{var i;try{let{envFile:m,secFile:d,withEnv:C,withSec:D,engine:v}=p.optsWithGlobals();if(C&&D)throw new Error("Cannot use both --with-env and --with-sec");let f;if(C||!(C||D)||n===!1){if(!m)throw new Error("No dotenv file specified in --env-file option");f=ve.readFileSync(m,"utf8")}else if(D){if(!d)throw new Error("No dotsec file specified in --sec-file option");let u=v||((i=r==null?void 0:r.defaults)==null?void 0:i.encryptionEngine),g=(o||[]).find(O=>O.triggerOptionValue===u);if(!g)throw new Error(`No decryption plugin found, available decryption engine(s): ${(o||[]).map(O=>`--${O.triggerOptionValue}`).join(", ")}`);let h=[...Object.keys(g.options||{}),...Object.keys(g.requiredOptions||{})],y=Object.fromEntries(h.map(O=>[O,s[O]])),w=ve.readFileSync(d,"utf8");f=await g.handler(c({ciphertext:w},y))}if(f){let u=gt(f),g=yt({ignoreProcessEnv:!0,parsed:c(c({},process.env),u)}),[h,...y]=l,w=ht(h,[...y],{stdio:"inherit",shell:!1,encoding:"utf-8",env:E(c(c({},g.parsed),process.env),{__DOTSEC_ENV__:JSON.stringify(Object.keys(u))})});w.status!==0&&process.exit(w.status||1)}else throw new Error("No .env or .sec file provided")}catch(m){console.error(F(m.message)),p.help()}});if(T({program:a,commandName:n?"run":"runEnvOnly",dotsecConfig:r}),n){o==null||o.map(s=>{let{options:p,requiredOptions:i}=s;$(p,a),$(i,a,!0)});let l=o==null?void 0:o.map(s=>s.triggerOptionValue);a.option("--engine <engine>",`Encryption engine${l.length>0?"s":""}: ${l.join(", "),l.length===1?l[0]:void 0}`)}return a},De=Ct;import wt from"ajv";import vt from"yargs-parser";var Dt={keyword:"separator",type:"string",metaSchema:{type:"string",description:"value separator"},modifying:!0,valid:!0,errors:!1,compile:e=>(t,r)=>{if(r){let{parentData:o,parentDataProperty:n}=r;return o[n]=t===""?[]:t.split(e),!0}else return!1}},k=new Ot;(async()=>{var d,C,D,v;let e=vt(process.argv),t=[];e.plugin&&(Array.isArray(e.plugin)?t.push(...e.plugin):t.push(e.plugin));let r=[...Array.isArray(e.config)?e.config:[e.config],...Array.isArray(e.c)?e.c:[e.c]][0],{contents:o={}}=await ae(r),{defaults:n,push:a}=o;k.name("dotsec").description(".env, but secure").version("1.0.0").enablePositionalOptions().action((f,u)=>{u.help()}),T({program:k,dotsecConfig:o});let l=new wt({allErrors:!0,removeAdditional:!0,useDefaults:!0,coerceTypes:!0,allowUnionTypes:!0,addUsedSchema:!1,keywords:[Dt]}),s={};if(t.length>0)for(let f of t){let g=await(await z({name:f}))({dotsecConfig:o,ajv:l,configFile:r});s[g.name]=f,t.length===1&&(o.defaults=E(c({},o.defaults),{encryptionEngine:String(g.name),plugins:E(c({},(d=o.defaults)==null?void 0:d.plugins),{[g.name]:c({},(D=(C=o.defaults)==null?void 0:C.plugins)==null?void 0:D[g.name])})}))}(n==null?void 0:n.encryptionEngine)&&(((v=n==null?void 0:n.plugins)==null?void 0:v[n.encryptionEngine])||(n.plugins=E(c({},n.plugins),{[n.encryptionEngine]:{}}))),(n==null?void 0:n.plugins)&&Object.entries(n==null?void 0:n.plugins).forEach(([f,u])=>{(u==null?void 0:u.module)?s[f]=u==null?void 0:u.module:s[f]=`@dotsec/plugin-${f}`}),Object.values(a||{}).forEach(f=>{Object.keys(f).forEach(u=>{s[u]||(s[u]=`@dotsec/plugin-${u}`)})});let p=[],i=[],m=[];for(let f of Object.keys(s)){let u=s[f],g=await z({name:u}),{addCliCommand:h,cliHandlers:y}=await g({ajv:l,dotsecConfig:o,configFile:r});(y==null?void 0:y.encrypt)&&p.push(y.encrypt),(y==null?void 0:y.decrypt)&&(i.push(y.decrypt),(y==null?void 0:y.push)&&m.push({push:y.push,decrypt:y.decrypt})),h&&h({program:k})}p.length&&await ge(k,{dotsecConfig:o,encryptHandlers:p}),i.length&&await ue(k,{dotsecConfig:o,decryptHandlers:i}),m.length&&(await we(k,{dotsecConfig:o,handlers:m}),await Ce(k,{dotsecConfig:o}),await De(k,{dotsecConfig:o,decryptHandlers:i}),await k.parse())})();
41
41
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/cli/index.ts", "../../src/constants.ts", "../../src/lib/json.ts", "../../src/lib/getConfig.ts", "../../src/lib/loadDotsecPlugin.ts", "../../src/lib/io.ts", "../../src/utils/logging.ts", "../../src/cli/options/index.ts", "../../src/cli/options/sharedOptions.ts", "../../src/cli/options/decrypt.ts", "../../src/cli/options/dotsec.ts", "../../src/cli/options/encrypt.ts", "../../src/cli/options/init.ts", "../../src/cli/options/push.ts", "../../src/cli/options/run.ts", "../../src/cli/commands/decrypt.ts", "../../src/cli/commands/encrypt.ts", "../../src/lib/transformer.ts", "../../src/cli/commands/init.ts", "../../src/cli/commands/push.ts", "../../src/cli/commands/run.ts"],
4
- "sourcesContent": ["import { Command } from \"commander\";\n\nimport { getMagicalConfig } from \"../lib/getConfig\";\nimport { loadDotsecPlugin } from \"../lib/loadDotsecPlugin\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginEncryptHandler,\n\tDotsecCliPluginPushHandler,\n\tDotsecPluginConfig,\n} from \"../types/plugin\";\nimport addDecryptProgram from \"./commands/decrypt\";\nimport addEncryptProgram from \"./commands/encrypt\";\nimport addInitCommand from \"./commands/init\";\nimport addPushProgram from \"./commands/push\";\nimport addRunCommand from \"./commands/run\";\nimport { setProgramOptions } from \"./options\";\nimport Ajv, { KeywordDefinition } from \"ajv\";\nimport yargsParser from \"yargs-parser\";\n\nconst separator: KeywordDefinition = {\n\tkeyword: \"separator\",\n\ttype: \"string\",\n\tmetaSchema: {\n\t\ttype: \"string\",\n\t\tdescription: \"value separator\",\n\t},\n\tmodifying: true,\n\tvalid: true,\n\terrors: false,\n\tcompile: (schema) => (data, ctx) => {\n\t\tif (ctx) {\n\t\t\tconst { parentData, parentDataProperty } = ctx;\n\t\t\tparentData[parentDataProperty] = data === \"\" ? [] : data.split(schema);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t},\n};\n\nconst program = new Command();\n\n(async () => {\n\tconst parsedOptions = yargsParser(process.argv);\n\tconst argvPluginModules: string[] = [];\n\tif (parsedOptions.plugin) {\n\t\tif (Array.isArray(parsedOptions.plugin)) {\n\t\t\targvPluginModules.push(...parsedOptions.plugin);\n\t\t} else {\n\t\t\targvPluginModules.push(parsedOptions.plugin);\n\t\t}\n\t}\n\t// if (parsedOptions.p) {\n\t// \tif (Array.isArray(parsedOptions.p)) {\n\t// \t\targvPluginModules.push(...parsedOptions.p);\n\t// \t} else {\n\t// \t\targvPluginModules.push(parsedOptions.p);\n\t// \t}\n\t// }\n\n\tconst configFile = [\n\t\t...(Array.isArray(parsedOptions.config)\n\t\t\t? parsedOptions.config\n\t\t\t: [parsedOptions.config]),\n\t\t...(Array.isArray(parsedOptions.c) ? parsedOptions.c : [parsedOptions.c]),\n\t]?.[0];\n\n\tconst { contents: config = {} } = await getMagicalConfig(configFile);\n\tconst { defaults, push: pushVariables } = config;\n\n\tprogram\n\t\t.name(\"dotsec\")\n\t\t.description(\".env, but secure\")\n\t\t.version(\"1.0.0\")\n\t\t.enablePositionalOptions()\n\t\t.action((_options, other: Command) => {\n\t\t\tother.help();\n\t\t});\n\tsetProgramOptions(program);\n\tconst ajv = new Ajv({\n\t\tallErrors: true,\n\t\tremoveAdditional: true,\n\t\tuseDefaults: true,\n\t\tcoerceTypes: true,\n\t\tallowUnionTypes: true,\n\t\taddUsedSchema: false,\n\t\tkeywords: [separator],\n\t});\n\t// if we have plugins in the cli, we need to define them in pluginModules\n\tconst pluginModules: { [key: string]: string } = {};\n\tif (argvPluginModules.length > 0) {\n\t\tfor (const pluginModule of argvPluginModules) {\n\t\t\t// let's load em up\n\t\t\tconst plugin = await loadDotsecPlugin({ name: pluginModule });\n\n\t\t\t// good, let's fire 'em up\n\t\t\tconst loadedPlugin = await plugin({ dotsecConfig: config, ajv });\n\t\t\tpluginModules[loadedPlugin.name] = pluginModule;\n\n\t\t\tif (argvPluginModules.length === 1) {\n\t\t\t\t// if we only have one plugin, let's set it as the default\n\t\t\t\tconfig.defaults = {\n\t\t\t\t\t...config.defaults,\n\t\t\t\t\tencryptionEngine: String(loadedPlugin.name),\n\t\t\t\t\tplugins: {\n\t\t\t\t\t\t...config.defaults?.plugins,\n\t\t\t\t\t\t[loadedPlugin.name]: {\n\t\t\t\t\t\t\t...config.defaults?.plugins?.[loadedPlugin.name],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tif (defaults?.encryptionEngine) {\n\t\tif (!defaults?.plugins?.[defaults.encryptionEngine]) {\n\t\t\tdefaults.plugins = {\n\t\t\t\t...defaults.plugins,\n\t\t\t\t[defaults.encryptionEngine]: {},\n\t\t\t};\n\t\t}\n\t}\n\tif (defaults?.plugins) {\n\t\tObject.entries(defaults?.plugins).forEach(\n\t\t\t([pluginName, pluginModule]: [string, DotsecPluginConfig]) => {\n\t\t\t\tif (pluginModule?.module) {\n\t\t\t\t\tpluginModules[pluginName] = pluginModule?.module;\n\t\t\t\t} else {\n\t\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tObject.values(pushVariables || {}).forEach((pushVariable) => {\n\t\tObject.keys(pushVariable).forEach((pluginName) => {\n\t\t\tif (!pluginModules[pluginName]) {\n\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t}\n\t\t});\n\t});\n\n\t// configure encryption command\n\tconst cliPluginEncryptHandlers: DotsecCliPluginEncryptHandler[] = [];\n\tconst cliPluginDecryptHandlers: DotsecCliPluginDecryptHandler[] = [];\n\tconst cliPluginPushHandlers: {\n\t\tpush: DotsecCliPluginPushHandler;\n\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t}[] = [];\n\n\tfor (const pluginName of Object.keys(pluginModules)) {\n\t\tconst pluginModule = pluginModules[pluginName];\n\t\tconst initDotsecPlugin = await loadDotsecPlugin({ name: pluginModule });\n\t\tconst { addCliCommand, cliHandlers: cli } = await initDotsecPlugin({\n\t\t\tajv,\n\t\t\tdotsecConfig: config,\n\t\t});\n\n\t\tif (cli?.encrypt) {\n\t\t\tcliPluginEncryptHandlers.push(cli.encrypt);\n\t\t}\n\t\tif (cli?.decrypt) {\n\t\t\tcliPluginDecryptHandlers.push(cli.decrypt);\n\t\t\tif (cli?.push) {\n\t\t\t\tcliPluginPushHandlers.push({ push: cli.push, decrypt: cli.decrypt });\n\t\t\t}\n\t\t}\n\n\t\tif (addCliCommand) {\n\t\t\taddCliCommand({ program });\n\t\t}\n\t}\n\tif (cliPluginEncryptHandlers.length) {\n\t\tawait addEncryptProgram(program, {\n\t\t\tdotsecConfig: config,\n\t\t\tencryptHandlers: cliPluginEncryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginDecryptHandlers.length) {\n\t\tawait addDecryptProgram(program, {\n\t\t\tdotsecConfig: config,\n\t\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginPushHandlers.length) {\n\t\tawait addPushProgram(program, {\n\t\t\tdotsecConfig: config,\n\t\t\thandlers: cliPluginPushHandlers,\n\t\t});\n\t}\n\n\t// add other commands\n\tawait addInitCommand(program);\n\tawait addRunCommand(program, {\n\t\tdotsecConfig: config,\n\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t});\n\tawait program.parse();\n})();\n", "import { DotsecConfig } from \"./types/config\";\n\nexport const DOTSEC_DEFAULT_CONFIG_FILE = \"dotsec.config.ts\";\nexport const DOTSEC_CONFIG_FILES = [DOTSEC_DEFAULT_CONFIG_FILE];\nexport const DOTSEC_DEFAULT_DOTSEC_FILENAME = \".sec\";\nexport const DOTSEC_DEFAULT_DOTENV_FILENAME = \".env\";\nexport const defaultConfig: DotsecConfig = {};\n", "import fs from \"fs\";\nimport path from \"node:path\";\n\n/**\n * Parse JSONC\n * @date 12/7/2022 - 12:48:45 PM\n *\n * @export\n * @param {string} data\n * @returns {*}\n */\nexport function jsoncParse(data: string) {\n\ttry {\n\t\treturn new Function(`return ${data.trim()}`)();\n\t} catch {\n\t\t// Silently ignore any error\n\t\t// That's what tsc/jsonc-parser did after all\n\t\treturn {};\n\t}\n}\n\n/**\n * Load JSON\n * @date 12/7/2022 - 12:48:57 PM\n *\n * @async\n * @param {string} filepath\n * @returns {unknown}\n */\nexport const loadJson = async (filepath: string) => {\n\ttry {\n\t\treturn jsoncParse(await fs.promises.readFile(filepath, \"utf8\"));\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to parse ${path.relative(process.cwd(), filepath)}: ${\n\t\t\t\t\terror.message\n\t\t\t\t}`,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t}\n};\n", "import { DOTSEC_CONFIG_FILES, defaultConfig } from \"../constants\";\nimport { DotsecConfig } from \"../types/config\";\nimport { DotsecConfigAndSource } from \"../types/plugin\";\nimport { loadJson } from \"./json\";\nimport { bundleRequire } from \"bundle-require\";\nimport JoyCon from \"joycon\";\nimport path from \"path\";\n\nexport const getMagicalConfig = async (\n\tfilename?: string,\n): Promise<DotsecConfigAndSource> => {\n\tconst cwd = process.cwd();\n\tconst configJoycon = new JoyCon();\n\tconst configPath = await configJoycon.resolve({\n\t\tfiles: filename ? [filename] : [...DOTSEC_CONFIG_FILES, \"package.json\"],\n\t\tcwd,\n\t\tstopDir: path.parse(cwd).root,\n\t\tpackageKey: \"dotsec\",\n\t});\n\tif (filename && configPath === null) {\n\t\tthrow new Error(`Could not find config file ${filename}`);\n\t}\n\tif (configPath) {\n\t\tif (configPath.endsWith(\".json\")) {\n\t\t\tconst rawData = (await loadJson(configPath)) as Partial<DotsecConfig>;\n\n\t\t\tlet data: Partial<DotsecConfig>;\n\n\t\t\tif (\n\t\t\t\tconfigPath.endsWith(\"package.json\") &&\n\t\t\t\t(rawData as { dotsec: Partial<DotsecConfig> }).dotsec !== undefined\n\t\t\t) {\n\t\t\t\tdata = (rawData as { dotsec: Partial<DotsecConfig> }).dotsec;\n\t\t\t} else {\n\t\t\t\tdata = rawData as Partial<DotsecConfig>;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsource: \"json\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t} else if (configPath.endsWith(\".ts\")) {\n\t\t\tconst bundleRequireResult = await bundleRequire({\n\t\t\t\tfilepath: configPath,\n\t\t\t});\n\t\t\tconst data = (bundleRequireResult.mod.dotsec ||\n\t\t\t\tbundleRequireResult.mod.default ||\n\t\t\t\tbundleRequireResult.mod) as Partial<DotsecConfig>;\n\n\t\t\treturn {\n\t\t\t\tsource: \"ts\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn { source: \"defaultConfig\", contents: defaultConfig };\n};\n", "import { DotsecPluginModule } from \"../types/plugin\";\n\nexport const loadDotsecPlugin = async (options: {\n\tname: string;\n}): Promise<DotsecPluginModule> => {\n\treturn import(options.name).then((imported) => {\n\t\treturn imported.default;\n\t});\n};\n", "import fs, { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport prompts from \"prompts\";\n\nexport const readContentsFromFile = async (\n\tfilePath: string,\n): Promise<string> => {\n\treturn await fs.readFile(filePath, \"utf-8\");\n};\n\nexport const writeContentsToFile = async (\n\tfilePath: string,\n\tcontents: string,\n): Promise<void> => {\n\treturn await fs.writeFile(filePath, contents, \"utf-8\");\n};\n\nexport const fileExists = async (source: string): Promise<boolean> => {\n\ttry {\n\t\tawait stat(source);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const promptOverwriteIfFileExists = async ({\n\tfilePath,\n\tskip,\n}: {\n\tfilePath: string;\n\tskip?: boolean;\n}) => {\n\tlet overwriteResponse: prompts.Answers<\"overwrite\"> | undefined;\n\n\tif ((await fileExists(filePath)) && skip !== true) {\n\t\toverwriteResponse = await prompts({\n\t\t\ttype: \"confirm\",\n\t\t\tname: \"overwrite\",\n\t\t\tmessage: () => {\n\t\t\t\treturn `Overwrite './${path.relative(process.cwd(), filePath)}' ?`;\n\t\t\t},\n\t\t});\n\t} else {\n\t\toverwriteResponse = undefined;\n\t}\n\treturn overwriteResponse;\n};\n", "import chalk from \"chalk\"\nimport Table = require(\"cli-table\")\nexport { Table }\n\nlet _logger: Pick<Console, \"info\" | \"error\" | \"table\">\nexport const getLogger = () => {\n\tif (!_logger) {\n\t\t_logger = console\n\t}\n\n\treturn _logger\n}\nexport const writeLine = (str: string) => {\n\tprocess.stdout.write(str)\n}\nexport const emphasis = (str: string): string => chalk.yellowBright(str)\nexport const strong = (str: string): string => chalk.yellow.bold(str)\n\nexport const clientLogger = {\n\tdebug(content: object) {\n\t\tconsole.log(content)\n\t},\n\tinfo(content: object) {\n\t\tconsole.log(content)\n\t},\n\twarn(content: object) {\n\t\tconsole.log(content)\n\t},\n\terror(content: object) {\n\t\tconsole.error(content)\n\t},\n}\n", "import { Command, Option } from \"commander\";\n\nimport decryptCommandDefaults from \"./decrypt\";\nimport dotsecCommandDefaults from \"./dotsec\";\nimport encryptCommandDefaults from \"./encrypt\";\nimport initCommandDefaults from \"./init\";\nimport pullCommandDefaults from \"./push\";\nimport pushCommandDefaults from \"./push\";\nimport runCommandDefaults from \"./run\";\nimport {\n\tCommandOption,\n\tDotSecCommandDefaults,\n\tDotSecCommandOptions,\n\tDotSecCommandsDefaults,\n\tExpandedCommandOption,\n} from \"./types\";\n\nexport const commandOptions: DotSecCommandsDefaults = {\n\t...dotsecCommandDefaults,\n\t...initCommandDefaults,\n\t...encryptCommandDefaults,\n\t...decryptCommandDefaults,\n\t...runCommandDefaults,\n\t...pushCommandDefaults,\n\t...pullCommandDefaults,\n};\n\nconst getInheritedOptions = (\n\tcopts: DotSecCommandsDefaults,\n\tcommandName: string,\n\tresult: {\n\t\toptions?: DotSecCommandOptions;\n\t\trequiredOptions?: DotSecCommandOptions;\n\t} = {},\n): DotSecCommandDefaults | undefined => {\n\tconst command = copts[commandName];\n\tif (command) {\n\t\tif (command.inheritsFrom) {\n\t\t\treturn command?.inheritsFrom.reduce(\n\t\t\t\t(acc, inheritedCommandName) => {\n\t\t\t\t\treturn getInheritedOptions(copts, inheritedCommandName, acc);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...command,\n\t\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\t\trequiredOptions: {\n\t\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t...command,\n\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\trequiredOptions: {\n\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n};\n\nconst expandCommandOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n): ExpandedCommandOption => {\n\tif (Array.isArray(commandOption)) {\n\t\treturn {\n\t\t\toption: commandOption,\n\t\t};\n\t} else {\n\t\treturn commandOption;\n\t}\n};\n\nconst createOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n\toptions?: { required?: boolean },\n): Option => {\n\tconst expandedCommandOption = expandCommandOption(commandOption);\n\tconst [option, description, defaultValue] = expandedCommandOption.option;\n\tconst newOption = new Option(option, description);\n\tif (defaultValue) {\n\t\tnewOption.default(defaultValue);\n\t}\n\tif (expandedCommandOption.env) {\n\t\tnewOption.env(expandedCommandOption.env);\n\t}\n\tif (options?.required) {\n\t\tnewOption.makeOptionMandatory(true);\n\t}\n\treturn newOption;\n};\nexport const setProgramOptions = (program: Command, commandName?: string) => {\n\tconst programOptions = commandOptions[commandName || program.name()];\n\t// const programOptions = getInheritedOptions(\n\t// \tcommandOptions,\n\t// \tcommandName || program.name(),\n\t// );\n\n\tif (programOptions) {\n\t\tconst { options, requiredOptions, description, usage, helpText } =\n\t\t\tprogramOptions;\n\t\tif (options) {\n\t\t\tObject.values(options).forEach((commandOption) => {\n\t\t\t\tconst newOption = createOption(commandOption);\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.values(requiredOptions).forEach((requiredOption) => {\n\t\t\t\tconst newOption = createOption(requiredOption, { required: true });\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (description) {\n\t\t\tprogram.description(description);\n\t\t}\n\t\tif (usage) {\n\t\t\tprogram.description(usage);\n\t\t}\n\t\tif (helpText) {\n\t\t\tprogram.description(helpText);\n\t\t}\n\t}\n};\n", "import {\n\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n} from \"../../constants\";\nimport { ExpandedCommandOption } from \"./types\";\n\nexport const envFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--env-file <envFile>\",\n\t\t`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTENV_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\t],\n\tenv: \"ENV_FILE\",\n};\nexport const secFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--sec-file <secFile>\",\n\t\t`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTSEC_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n\t],\n\tenv: \"SEC_FILE\",\n};\n\nexport const withEnvOption: ExpandedCommandOption = {\n\toption: [\"--with-env, --withEnv\", \"Run command using a dot env file\"],\n};\n\nexport const withSecOption: ExpandedCommandOption = {\n\toption: [\"--with-sec, --withSec\", \"Run command with a dotsec file\"],\n};\n\nexport const yesOption: ExpandedCommandOption = {\n\toption: [\"--yes\", \"Skip confirmation prompts\"],\n};\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst decryptCommandDefaults: DotSecCommandsDefaults = {\n\tdecrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default decryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst dotsecCommandDefaults: DotSecCommandsDefaults = {\n\tdotsec: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\t\t\tplugin: [\"--plugin <plugin>\", \"Comma-separated list of plugins to use\"],\n\t\t},\n\t},\n};\n\nexport default dotsecCommandDefaults;\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst encryptCommandDefaults: DotSecCommandsDefaults = {\n\tencrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default encryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst initCommandDefaults: DotSecCommandsDefaults = {\n\tinit: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default initCommandDefaults;\n", "import {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst pullCommandDefaults: DotSecCommandsDefaults = {\n\tpull: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default pullCommandDefaults;\n", "import dotsecCommandDefaults from \"./dotsec\";\nimport {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst runCommandDefaults: DotSecCommandsDefaults = {\n\trunEnvOnly: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\tusage: \"[commandArgs...]\",\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tdescription:\n\t\t\t\"Run a command in a separate process and populate env with contents of a dotenv file.\",\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --env-file .env.dev echo \"hello world\"\n\n${\"Run a command with a specific ENV_FILE variable\"}\n\n$ ENV_FILE=.env.dev dotsec run echo \"hello world\"\n\n`,\n\t},\n\trun: {\n\t\tinheritsFrom: [\"dotsec\"],\n\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tusage:\n\t\t\t\"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]\",\n\t\tdescription: `Run a command in a separate process and populate env with either \n\t\t\t- contents of a dotenv file\n\t\t\t- decrypted values of a dotsec file.\n\nThe --withEnv option will take precedence over the --withSec option. If neither are specified, the --withEnv option will be used by default.`,\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --with-env --env-file .env.dev echo \"hello world\"\n\n\n${\"Run a command with a .sec file\"}\n\n$ dotsec run --with-sec echo \"hello world\"\n\n\n${\"Run a command with a specific .sec file\"}\n\n$ dotsec run --with-sec --sec-file .sec.dev echo \"hello world\"\n`,\n\t},\n\tpush: {\n\t\toptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.options,\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.requiredOptions,\n\t\t},\n\t},\n};\n\nexport default runCommandDefaults;\n", "import {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { DecryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"decrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<DecryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${options.decryptHandlers\n\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\t// get current dot env file\n\t\t\t\tconst dotsecString = await readContentsFromFile(secFile);\n\n\t\t\t\tconst plaintext = await pluginCliDecrypt.handler({\n\t\t\t\t\tciphertext: dotsecString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotenvOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: envFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotenvOverwriteResponse === undefined ||\n\t\t\t\t\tdotenvOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(envFile, plaintext);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote plaintext contents of ${strong(secFile)} file to ${strong(\n\t\t\t\t\t\t\tenvFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.decryptHandlers.map((decryption) => {\n\t\tconst { options, requiredOptions } = decryption;\n\t\tif (options) {\n\t\t\tObject.values(options).map((option) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...option);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.values(requiredOptions).map((requiredOption) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...requiredOption);\n\t\t\t});\n\t\t}\n\t});\n\n\tconst engines = options.decryptHandlers.map((e) => e.triggerOptionValue);\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"} to use: ${\n\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t}`,\n\t\tengines.length === 1 ? engines[0] : undefined,\n\t);\n\tsetProgramOptions(subProgram);\n\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { EncryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginEncryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tencryptHandlers: DotsecCliPluginEncryptHandler[];\n\t\tdotsecConfig: DotsecConfig;\n\t},\n) => {\n\tconst { encryptHandlers, dotsecConfig } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"encrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<EncryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\t\t\t\tconst pluginCliEncrypt = (encryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliEncrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No encryption plugin found, available encryption engine(s): ${options.encryptHandlers\n\t\t\t\t\t\t\t.map((e) => e.triggerOptionValue)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst dotenvString = await readContentsFromFile(envFile);\n\n\t\t\t\tconst cipherText = await pluginCliEncrypt.handler({\n\t\t\t\t\tplaintext: dotenvString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotsecOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: secFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotsecOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(secFile, cipherText);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote encrypted contents of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\tsecFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.encryptHandlers.map((encryption) => {\n\t\tconst { options, requiredOptions } = encryption;\n\t\tif (options) {\n\t\t\tObject.values(options).map((option) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...option);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.values(requiredOptions).map((requiredOption) => {\n\t\t\t\t// @ts-ignore\n\t\t\t\tsubProgram.option(...requiredOption);\n\t\t\t});\n\t\t}\n\t});\n\n\tconst engines = options.encryptHandlers.map((e) => e.triggerOptionValue);\n\tconst encryptionEngineNames = options.encryptHandlers.map(\n\t\t(e) => e.encryptionEngineName,\n\t);\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t}`,\n\t\t// engines.length === 1 ? engines[0] : undefined,\n\t);\n\tsetProgramOptions(subProgram);\n\tsubProgram.description(\n\t\t`Encrypt .env file using ${encryptionEngineNames.join(\", \")}`,\n\t);\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import fs from \"node:fs\";\nimport * as ts from \"typescript\";\n\nexport const patchConfigFile = (options: {\n\tconfigFile: string;\n\tconfig?: {\n\t\taws?: {\n\t\t\tregion?: string;\n\t\t\tkms?: {\n\t\t\t\tkeyAlias?: string;\n\t\t\t};\n\t\t};\n\t};\n}) => {\n\tconst printer: ts.Printer = ts.createPrinter();\n\tconst source = fs.readFileSync(options.configFile, \"utf8\");\n\n\tconst transformer =\n\t\t<T extends ts.Node>(context: ts.TransformationContext) =>\n\t\t(rootNode: T) => {\n\t\t\tfunction visit(node: ts.Node): ts.Node {\n\t\t\t\tnode = ts.visitEachChild(node, visit, context);\n\t\t\t\tif (node.kind === ts.SyntaxKind.StringLiteral) {\n\t\t\t\t\tconst kmsNode = node?.parent?.parent?.parent;\n\t\t\t\t\tif (options.config?.aws?.kms?.keyAlias) {\n\t\t\t\t\t\tif (kmsNode?.getChildAt(0)?.getText() === \"kms\") {\n\t\t\t\t\t\t\tconst awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(\n\t\t\t\t\t\t\t\t\toptions.config?.aws?.kms?.keyAlias,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (options.config?.aws?.region) {\n\t\t\t\t\t\tif (node?.parent?.getChildAt(0)?.getText() === \"region\") {\n\t\t\t\t\t\t\tconst awsNode = node?.parent?.parent?.parent;\n\n\t\t\t\t\t\t\t// const awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(options.config?.aws?.region);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\treturn ts.visitNode(rootNode, visit);\n\t\t};\n\n\tconst sourceFile: ts.SourceFile = ts.createSourceFile(\n\t\t\"test.ts\",\n\t\tsource,\n\t\tts.ScriptTarget.ES2015,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\t// Options may be passed to transform\n\tconst result: ts.TransformationResult<ts.SourceFile> =\n\t\tts.transform<ts.SourceFile>(sourceFile, [transformer]);\n\n\tconst transformedSourceFile: ts.SourceFile = result.transformed[0];\n\n\tconst transformedSource = printer.printFile(transformedSourceFile);\n\tresult.dispose();\n\n\treturn transformedSource;\n};\n", "import { promptOverwriteIfFileExists, writeContentsToFile } from \"../../lib/io\";\nimport { InitCommandOptions } from \"../../types\";\nimport { Command } from \"commander\";\n\nimport { patchConfigFile } from \"../../lib/transformer\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport path from \"node:path\";\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n};\n\nconst addInitProgram = async (program: Command) => {\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"init\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\tconst { configFile, yes } = command.optsWithGlobals<InitCommandOptions>();\n\n\t\t\ttry {\n\t\t\t\tconst patchedConfigTemplate = patchConfigFile({\n\t\t\t\t\tconfigFile: path.resolve(\n\t\t\t\t\t\t__dirname,\n\t\t\t\t\t\t\"../../src/templates/dotsec.config.ts\",\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t\tconst dotsecConfigOverwriteResponse = await promptOverwriteIfFileExists(\n\t\t\t\t\t{\n\t\t\t\t\t\tfilePath: configFile,\n\t\t\t\t\t\tskip: yes,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdotsecConfigOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecConfigOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(configFile, patchedConfigTemplate);\n\t\t\t\t\tconsole.log(`Wrote config file to ${strong(configFile)}`);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcommand.error(e);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions(subProgram);\n\n\treturn subProgram;\n};\n\nexport default addInitProgram;\n", "import { PushCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginPushHandler,\n} from \"../../types/plugin\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\nimport fs from \"node:fs\";\n\n/**\n * Decrypts, and pushes the contents of a .env file to AWS SSM, AWS Secrets Manager or GitHub Actions Secrets\n * @date 12/7/2022 - 9:16:48 AM\n *\n * @async\n * @param {Command} program\n * @returns {unknown}\n */\nconst addPushProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\thandlers: {\n\t\t\tpush: DotsecCliPluginPushHandler;\n\t\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t\t}[];\n\t},\n) => {\n\tconst { dotsecConfig, handlers } = options;\n\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"push\")\n\t\t.action(async (_options: Record<string, string>, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\twithEnv,\n\t\t\t\t\twithSec,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<PushCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\tconst pluginCliDecrypt = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.decrypt?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.decrypt;\n\n\t\t\t\tconst pluginCliPush = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.push?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.push;\n\n\t\t\t\tif (!pluginCliPush) {\n\t\t\t\t\tthrow new Error(\"No push plugin found!\");\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.requiredOptions || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t}\n\n\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\tif (withEnv || !(withEnv || withSec)) {\n\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t}\n\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t} else if (withSec) {\n\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${handlers\n\t\t\t\t\t\t\t\t.map((e) => `--${e.decrypt?.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (envContents) {\n\t\t\t\t\t// convert to object\n\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t// expand env vars\n\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tif (expandedEnvVars.parsed) {\n\t\t\t\t\t\tawait pluginCliPush.handler({\n\t\t\t\t\t\t\tpush: expandedEnvVars.parsed,\n\t\t\t\t\t\t\tyes,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions(subProgram);\n\n\treturn subProgram;\n};\n\nexport default addPushProgram;\n", "import fs from \"node:fs\";\n\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\n\nimport { RunCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { spawnSync } from \"node:child_process\";\nconst addRunProgam = (\n\tprogram: Command,\n\toptions?: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers?: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options || {};\n\n\t// is there an encryption engine?\n\tconst hasDecryptEngine =\n\t\tdecryptHandlers !== undefined && decryptHandlers.length > 0;\n\n\tconst subProgram = program\n\t\t.command(\"run <command...>\")\n\t\t.allowUnknownOption(true)\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.showHelpAfterError(true)\n\t\t.action(\n\t\t\tasync (\n\t\t\t\tcommands: string[],\n\t\t\t\t_options: Record<string, string>,\n\t\t\t\tcommand: Command,\n\t\t\t) => {\n\t\t\t\tconsole.log(\"yo\");\n\n\t\t\t\ttry {\n\t\t\t\t\tconst { envFile, secFile, withEnv, withSec, engine } =\n\t\t\t\t\t\tcommand.optsWithGlobals<RunCommandOptions>();\n\t\t\t\t\tconsole.log({ envFile, secFile, withEnv, withSec, engine });\n\t\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t\t}\n\n\t\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\t\tif (withEnv || !(withEnv || withSec) || hasDecryptEngine === false) {\n\t\t\t\t\t\tconsole.log(\"ENV ONLY\");\n\t\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t\t\tconsole.log(\"envCOntents\", envContents);\n\t\t\t\t\t} else if (withSec) {\n\t\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst encryptionEngine =\n\t\t\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${(\n\t\t\t\t\t\t\t\t\tdecryptHandlers || []\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t\t\t];\n\n\t\t\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (envContents) {\n\t\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t\t// expand env vars\n\t\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst [userCommand, ...userCommandArgs] = commands;\n\t\t\t\t\t\tconst spawn = spawnSync(userCommand, [...userCommandArgs], {\n\t\t\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\t\t\tshell: false,\n\t\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t\t...expandedEnvVars.parsed,\n\t\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\t\t__DOTSEC_ENV__: JSON.stringify(Object.keys(dotenvVars)),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (spawn.status !== 0) {\n\t\t\t\t\t\t\tprocess.exit(spawn.status || 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\t\tcommand.help();\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\tsetProgramOptions(subProgram, hasDecryptEngine ? \"run\" : \"runEnvOnly\");\n\n\tif (hasDecryptEngine) {\n\t\tdecryptHandlers?.map((run) => {\n\t\t\tconst { options, requiredOptions } = run;\n\t\t\tif (options) {\n\t\t\t\tObject.values(options).map((option) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tsubProgram.option(...option);\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (requiredOptions) {\n\t\t\t\tObject.values(requiredOptions).map((requiredOption) => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tsubProgram.option(...requiredOption);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tconst engines = decryptHandlers?.map((e) => e.triggerOptionValue);\n\n\t\tsubProgram.option(\n\t\t\t\"--engine <engine>\",\n\t\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t\t}`,\n\t\t\t// engines.length === 1 ? engines[0] : undefined,\n\t\t);\n\t}\n\treturn subProgram;\n};\n\nexport default addRunProgam;\n"],
5
- "mappings": "oqCAAA,qCCEO,GAAM,GAA6B,mBAC7B,GAAsB,CAAC,GACvB,EAAiC,OACjC,EAAiC,OACjC,EAA8B,GCN3C,mBACA,0BAUO,YAAoB,EAAc,CACxC,GAAI,CACH,MAAO,IAAI,UAAS,UAAU,EAAK,iBAClC,CAGD,MAAO,IAYF,GAAM,IAAW,KAAO,IAAqB,CACnD,GAAI,CACH,MAAO,IAAW,KAAM,IAAG,SAAS,SAAS,EAAU,eAC/C,EAAP,CACD,KAAI,aAAiB,OACd,GAAI,OACT,mBAAmB,GAAK,SAAS,QAAQ,MAAO,OAC/C,EAAM,WAIF,ICpCT,gDACA,uBACA,qBAEO,GAAM,IAAmB,KAC/B,IACoC,CAVrC,YA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,UACR,GAAyB,KAAK,EAAI,SAC9B,kBAAK,OACR,EAAsB,KAAK,CAAE,KAAM,EAAI,KAAM,QAAS,EAAI,WAIxD,GACH,EAAc,CAAE,YAGlB,AAAI,EAAyB,QAC5B,KAAM,IAAkB,EAAS,CAChC,aAAc,EACd,gBAAiB,IAGf,EAAyB,QAC5B,KAAM,IAAkB,EAAS,CAChC,aAAc,EACd,gBAAiB,IAGf,EAAsB,QACzB,KAAM,IAAe,EAAS,CAC7B,aAAc,EACd,SAAU,IAKZ,KAAM,IAAe,GACrB,KAAM,IAAc,EAAS,CAC5B,aAAc,EACd,gBAAiB,IAElB,KAAM,GAAQ",
3
+ "sources": ["../../src/cli/index.ts", "../../src/constants.ts", "../../src/lib/json.ts", "../../src/lib/getConfig.ts", "../../src/lib/loadDotsecPlugin.ts", "../../src/lib/addPluginOptions.ts", "../../src/lib/io.ts", "../../src/utils/logging.ts", "../../src/cli/options/index.ts", "../../src/cli/options/sharedOptions.ts", "../../src/cli/options/decrypt.ts", "../../src/cli/options/dotsec.ts", "../../src/cli/options/encrypt.ts", "../../src/cli/options/init.ts", "../../src/cli/options/push.ts", "../../src/cli/options/run.ts", "../../src/cli/commands/decrypt.ts", "../../src/cli/commands/encrypt.ts", "../../src/lib/transformer.ts", "../../src/cli/commands/init.ts", "../../src/cli/commands/push.ts", "../../src/cli/commands/run.ts"],
4
+ "sourcesContent": ["import { Command } from \"commander\";\n\nimport { getMagicalConfig } from \"../lib/getConfig\";\nimport { loadDotsecPlugin } from \"../lib/loadDotsecPlugin\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginEncryptHandler,\n\tDotsecCliPluginPushHandler,\n\tDotsecPluginConfig,\n} from \"../types/plugin\";\nimport addDecryptProgram from \"./commands/decrypt\";\nimport addEncryptProgram from \"./commands/encrypt\";\nimport addInitCommand from \"./commands/init\";\nimport addPushProgram from \"./commands/push\";\nimport addRunCommand from \"./commands/run\";\nimport { setProgramOptions } from \"./options\";\nimport Ajv, { KeywordDefinition } from \"ajv\";\nimport yargsParser from \"yargs-parser\";\n\nconst separator: KeywordDefinition = {\n\tkeyword: \"separator\",\n\ttype: \"string\",\n\tmetaSchema: {\n\t\ttype: \"string\",\n\t\tdescription: \"value separator\",\n\t},\n\tmodifying: true,\n\tvalid: true,\n\terrors: false,\n\tcompile: (schema) => (data, ctx) => {\n\t\tif (ctx) {\n\t\t\tconst { parentData, parentDataProperty } = ctx;\n\t\t\tparentData[parentDataProperty] = data === \"\" ? [] : data.split(schema);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t},\n};\n\nconst program = new Command();\n\n(async () => {\n\tconst parsedOptions = yargsParser(process.argv);\n\tconst argvPluginModules: string[] = [];\n\tif (parsedOptions.plugin) {\n\t\tif (Array.isArray(parsedOptions.plugin)) {\n\t\t\targvPluginModules.push(...parsedOptions.plugin);\n\t\t} else {\n\t\t\targvPluginModules.push(parsedOptions.plugin);\n\t\t}\n\t}\n\t// if (parsedOptions.p) {\n\t// \tif (Array.isArray(parsedOptions.p)) {\n\t// \t\targvPluginModules.push(...parsedOptions.p);\n\t// \t} else {\n\t// \t\targvPluginModules.push(parsedOptions.p);\n\t// \t}\n\t// }\n\tconst configFile = [\n\t\t...(Array.isArray(parsedOptions.config)\n\t\t\t? parsedOptions.config\n\t\t\t: [parsedOptions.config]),\n\t\t...(Array.isArray(parsedOptions.c) ? parsedOptions.c : [parsedOptions.c]),\n\t]?.[0];\n\n\tconst { contents: dotsecConfig = {} } = await getMagicalConfig(configFile);\n\tconst { defaults, push: pushVariables } = dotsecConfig;\n\n\tprogram\n\t\t.name(\"dotsec\")\n\t\t.description(\".env, but secure\")\n\t\t.version(\"1.0.0\")\n\t\t.enablePositionalOptions()\n\t\t.action((_options, other: Command) => {\n\t\t\tother.help();\n\t\t});\n\tsetProgramOptions({ program, dotsecConfig: dotsecConfig });\n\tconst ajv = new Ajv({\n\t\tallErrors: true,\n\t\tremoveAdditional: true,\n\t\tuseDefaults: true,\n\t\tcoerceTypes: true,\n\t\tallowUnionTypes: true,\n\t\taddUsedSchema: false,\n\t\tkeywords: [separator],\n\t});\n\t// if we have plugins in the cli, we need to define them in pluginModules\n\tconst pluginModules: { [key: string]: string } = {};\n\tif (argvPluginModules.length > 0) {\n\t\tfor (const pluginModule of argvPluginModules) {\n\t\t\t// let's load em up\n\t\t\tconst plugin = await loadDotsecPlugin({ name: pluginModule });\n\n\t\t\t// good, let's fire 'em up\n\t\t\tconst loadedPlugin = await plugin({\n\t\t\t\tdotsecConfig: dotsecConfig,\n\t\t\t\tajv,\n\t\t\t\tconfigFile,\n\t\t\t});\n\t\t\tpluginModules[loadedPlugin.name] = pluginModule;\n\n\t\t\tif (argvPluginModules.length === 1) {\n\t\t\t\t// if we only have one plugin, let's set it as the default\n\t\t\t\tdotsecConfig.defaults = {\n\t\t\t\t\t...dotsecConfig.defaults,\n\t\t\t\t\tencryptionEngine: String(loadedPlugin.name),\n\t\t\t\t\tplugins: {\n\t\t\t\t\t\t...dotsecConfig.defaults?.plugins,\n\t\t\t\t\t\t[loadedPlugin.name]: {\n\t\t\t\t\t\t\t...dotsecConfig.defaults?.plugins?.[loadedPlugin.name],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tif (defaults?.encryptionEngine) {\n\t\tif (!defaults?.plugins?.[defaults.encryptionEngine]) {\n\t\t\tdefaults.plugins = {\n\t\t\t\t...defaults.plugins,\n\t\t\t\t[defaults.encryptionEngine]: {},\n\t\t\t};\n\t\t}\n\t}\n\tif (defaults?.plugins) {\n\t\tObject.entries(defaults?.plugins).forEach(\n\t\t\t([pluginName, pluginModule]: [string, DotsecPluginConfig]) => {\n\t\t\t\tif (pluginModule?.module) {\n\t\t\t\t\tpluginModules[pluginName] = pluginModule?.module;\n\t\t\t\t} else {\n\t\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tObject.values(pushVariables || {}).forEach((pushVariable) => {\n\t\tObject.keys(pushVariable).forEach((pluginName) => {\n\t\t\tif (!pluginModules[pluginName]) {\n\t\t\t\tpluginModules[pluginName] = `@dotsec/plugin-${pluginName}`;\n\t\t\t}\n\t\t});\n\t});\n\n\t// configure encryption command\n\tconst cliPluginEncryptHandlers: DotsecCliPluginEncryptHandler[] = [];\n\tconst cliPluginDecryptHandlers: DotsecCliPluginDecryptHandler[] = [];\n\tconst cliPluginPushHandlers: {\n\t\tpush: DotsecCliPluginPushHandler;\n\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t}[] = [];\n\n\tfor (const pluginName of Object.keys(pluginModules)) {\n\t\tconst pluginModule = pluginModules[pluginName];\n\t\tconst initDotsecPlugin = await loadDotsecPlugin({ name: pluginModule });\n\t\tconst { addCliCommand, cliHandlers: cli } = await initDotsecPlugin({\n\t\t\tajv,\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tconfigFile,\n\t\t});\n\n\t\tif (cli?.encrypt) {\n\t\t\tcliPluginEncryptHandlers.push(cli.encrypt);\n\t\t}\n\t\tif (cli?.decrypt) {\n\t\t\tcliPluginDecryptHandlers.push(cli.decrypt);\n\t\t\tif (cli?.push) {\n\t\t\t\tcliPluginPushHandlers.push({ push: cli.push, decrypt: cli.decrypt });\n\t\t\t}\n\t\t}\n\n\t\tif (addCliCommand) {\n\t\t\taddCliCommand({ program });\n\t\t}\n\t}\n\tif (cliPluginEncryptHandlers.length) {\n\t\tawait addEncryptProgram(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tencryptHandlers: cliPluginEncryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginDecryptHandlers.length) {\n\t\tawait addDecryptProgram(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t\t});\n\t}\n\tif (cliPluginPushHandlers.length) {\n\t\tawait addPushProgram(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\thandlers: cliPluginPushHandlers,\n\t\t});\n\n\t\t// add other commands\n\t\tawait addInitCommand(program, { dotsecConfig: dotsecConfig });\n\t\tawait addRunCommand(program, {\n\t\t\tdotsecConfig: dotsecConfig,\n\t\t\tdecryptHandlers: cliPluginDecryptHandlers,\n\t\t});\n\t\tawait program.parse();\n\t}\n})();\n", "import { DotsecConfig } from \"./types/config\";\n\nexport const DOTSEC_DEFAULT_CONFIG_FILE = \"dotsec.config.ts\";\nexport const DOTSEC_CONFIG_FILES = [DOTSEC_DEFAULT_CONFIG_FILE];\nexport const DOTSEC_DEFAULT_DOTSEC_FILENAME = \".sec\";\nexport const DOTSEC_DEFAULT_DOTENV_FILENAME = \".env\";\nexport const defaultConfig: DotsecConfig = {};\n", "import fs from \"fs\";\nimport path from \"node:path\";\n\n/**\n * Parse JSONC\n * @date 12/7/2022 - 12:48:45 PM\n *\n * @export\n * @param {string} data\n * @returns {*}\n */\nexport function jsoncParse(data: string) {\n\ttry {\n\t\treturn new Function(`return ${data.trim()}`)();\n\t} catch {\n\t\t// Silently ignore any error\n\t\t// That's what tsc/jsonc-parser did after all\n\t\treturn {};\n\t}\n}\n\n/**\n * Load JSON\n * @date 12/7/2022 - 12:48:57 PM\n *\n * @async\n * @param {string} filepath\n * @returns {unknown}\n */\nexport const loadJson = async (filepath: string) => {\n\ttry {\n\t\treturn jsoncParse(await fs.promises.readFile(filepath, \"utf8\"));\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to parse ${path.relative(process.cwd(), filepath)}: ${\n\t\t\t\t\terror.message\n\t\t\t\t}`,\n\t\t\t);\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t}\n};\n", "import { DOTSEC_CONFIG_FILES, defaultConfig } from \"../constants\";\nimport { DotsecConfig } from \"../types/config\";\nimport { DotsecConfigAndSource } from \"../types/plugin\";\nimport { loadJson } from \"./json\";\nimport { bundleRequire } from \"bundle-require\";\nimport JoyCon from \"joycon\";\nimport path from \"path\";\n\nexport const getMagicalConfig = async (\n\tfilename?: string,\n): Promise<DotsecConfigAndSource> => {\n\tconst cwd = process.cwd();\n\tconst configJoycon = new JoyCon();\n\tconst configPath = await configJoycon.resolve({\n\t\tfiles: filename ? [filename] : [...DOTSEC_CONFIG_FILES, \"package.json\"],\n\t\tcwd,\n\t\tstopDir: path.parse(cwd).root,\n\t\tpackageKey: \"dotsec\",\n\t});\n\tif (filename && configPath === null) {\n\t\tthrow new Error(`Could not find config file ${filename}`);\n\t}\n\tif (configPath) {\n\t\tif (configPath.endsWith(\".json\")) {\n\t\t\tconst rawData = (await loadJson(configPath)) as Partial<DotsecConfig>;\n\n\t\t\tlet data: Partial<DotsecConfig>;\n\n\t\t\tif (\n\t\t\t\tconfigPath.endsWith(\"package.json\") &&\n\t\t\t\t(rawData as { dotsec: Partial<DotsecConfig> }).dotsec !== undefined\n\t\t\t) {\n\t\t\t\tdata = (rawData as { dotsec: Partial<DotsecConfig> }).dotsec;\n\t\t\t} else {\n\t\t\t\tdata = rawData as Partial<DotsecConfig>;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsource: \"json\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t} else if (configPath.endsWith(\".ts\")) {\n\t\t\tconst bundleRequireResult = await bundleRequire({\n\t\t\t\tfilepath: configPath,\n\t\t\t});\n\t\t\tconst data = (bundleRequireResult.mod.dotsec ||\n\t\t\t\tbundleRequireResult.mod.default ||\n\t\t\t\tbundleRequireResult.mod) as Partial<DotsecConfig>;\n\n\t\t\treturn {\n\t\t\t\tsource: \"ts\",\n\t\t\t\tcontents: {\n\t\t\t\t\t...defaultConfig,\n\t\t\t\t\t...data,\n\t\t\t\t\tdefaults: {\n\t\t\t\t\t\t...data?.defaults,\n\t\t\t\t\t\t...defaultConfig.defaults,\n\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t...data?.defaults?.plugins,\n\t\t\t\t\t\t\t...defaultConfig.defaults?.plugins,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tpush: {\n\t\t\t\t\t\t...data?.push,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\treturn { source: \"defaultConfig\", contents: defaultConfig };\n};\n", "import { DotsecPluginModule } from \"../types/plugin\";\n\nexport const loadDotsecPlugin = async (options: {\n\tname: string;\n}): Promise<DotsecPluginModule> => {\n\treturn import(options.name).then((imported) => {\n\t\treturn imported.default;\n\t});\n};\n", "import { DotsecCliOption } from \"../types/plugin\";\nimport { Command, Option } from \"commander\";\n\nexport const addPluginOptions = (\n\toptions:\n\t\t| {\n\t\t\t\t[x: string]: DotsecCliOption;\n\t\t }\n\t\t| undefined,\n\tcommand: Command,\n\tmandatory?: boolean,\n) => {\n\tif (options) {\n\t\tObject.values(options).map((option) => {\n\t\t\tlet optionProps:\n\t\t\t\t| {\n\t\t\t\t\t\tflags: string;\n\t\t\t\t\t\tdescription?: string;\n\t\t\t\t\t\tdefaultValue?: string | boolean | string[];\n\t\t\t\t\t\tfn?: (value: string, previous: unknown) => unknown;\n\t\t\t\t\t\tregexp?: RegExp;\n\t\t\t\t\t\tenv?: string;\n\t\t\t\t }\n\t\t\t\t| undefined;\n\t\t\tif (Array.isArray(option)) {\n\t\t\t\tconst [flags, description, defaultValue] = option;\n\t\t\t\toptionProps = {\n\t\t\t\t\tflags,\n\t\t\t\t\tdescription,\n\t\t\t\t\tdefaultValue,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tconst { flags, description, defaultValue, env, fn } = option;\n\t\t\t\toptionProps = {\n\t\t\t\t\tflags,\n\t\t\t\t\tdescription,\n\t\t\t\t\tdefaultValue,\n\t\t\t\t\tenv,\n\t\t\t\t\tfn,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (optionProps) {\n\t\t\t\tconst newOption = new Option(\n\t\t\t\t\toptionProps.flags,\n\t\t\t\t\toptionProps.description,\n\t\t\t\t);\n\t\t\t\tif (optionProps.fn) {\n\t\t\t\t\tnewOption.argParser(optionProps.fn);\n\t\t\t\t}\n\t\t\t\tif (optionProps.defaultValue) {\n\t\t\t\t\tnewOption.default(optionProps.defaultValue);\n\t\t\t\t}\n\t\t\t\tif (optionProps.env) {\n\t\t\t\t\tnewOption.env(optionProps.env);\n\t\t\t\t}\n\t\t\t\tif (mandatory) {\n\t\t\t\t\tnewOption.makeOptionMandatory(true);\n\t\t\t\t}\n\t\t\t\tcommand.addOption(newOption);\n\t\t\t}\n\t\t});\n\t}\n};\n", "import fs, { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport prompts from \"prompts\";\n\nexport const readContentsFromFile = async (\n\tfilePath: string,\n): Promise<string> => {\n\treturn await fs.readFile(filePath, \"utf-8\");\n};\n\nexport const writeContentsToFile = async (\n\tfilePath: string,\n\tcontents: string,\n): Promise<void> => {\n\treturn await fs.writeFile(filePath, contents, \"utf-8\");\n};\n\nexport const fileExists = async (source: string): Promise<boolean> => {\n\ttry {\n\t\tawait stat(source);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n\nexport const promptOverwriteIfFileExists = async ({\n\tfilePath,\n\tskip,\n}: {\n\tfilePath: string;\n\tskip?: boolean;\n}) => {\n\tlet overwriteResponse: prompts.Answers<\"overwrite\"> | undefined;\n\n\tif ((await fileExists(filePath)) && skip !== true) {\n\t\toverwriteResponse = await prompts({\n\t\t\ttype: \"confirm\",\n\t\t\tname: \"overwrite\",\n\t\t\tmessage: () => {\n\t\t\t\treturn `Overwrite './${path.relative(process.cwd(), filePath)}' ?`;\n\t\t\t},\n\t\t});\n\t} else {\n\t\toverwriteResponse = undefined;\n\t}\n\treturn overwriteResponse;\n};\n", "import chalk from \"chalk\"\nimport Table = require(\"cli-table\")\nexport { Table }\n\nlet _logger: Pick<Console, \"info\" | \"error\" | \"table\">\nexport const getLogger = () => {\n\tif (!_logger) {\n\t\t_logger = console\n\t}\n\n\treturn _logger\n}\nexport const writeLine = (str: string) => {\n\tprocess.stdout.write(str)\n}\nexport const emphasis = (str: string): string => chalk.yellowBright(str)\nexport const strong = (str: string): string => chalk.yellow.bold(str)\n\nexport const clientLogger = {\n\tdebug(content: object) {\n\t\tconsole.log(content)\n\t},\n\tinfo(content: object) {\n\t\tconsole.log(content)\n\t},\n\twarn(content: object) {\n\t\tconsole.log(content)\n\t},\n\terror(content: object) {\n\t\tconsole.error(content)\n\t},\n}\n", "import { DotsecConfig } from \"../../types/index\";\nimport { Command, Option } from \"commander\";\n\nimport decryptCommandDefaults from \"./decrypt\";\nimport dotsecCommandDefaults from \"./dotsec\";\nimport encryptCommandDefaults from \"./encrypt\";\nimport initCommandDefaults from \"./init\";\nimport pullCommandDefaults from \"./push\";\nimport pushCommandDefaults from \"./push\";\nimport runCommandDefaults from \"./run\";\nimport {\n\tCommandOption,\n\tDotSecCommandDefaults,\n\tDotSecCommandOptions,\n\tDotSecCommandsDefaults,\n\tExpandedCommandOption,\n} from \"./types\";\n\nexport const commandOptions: DotSecCommandsDefaults = {\n\t...dotsecCommandDefaults,\n\t...initCommandDefaults,\n\t...encryptCommandDefaults,\n\t...decryptCommandDefaults,\n\t...runCommandDefaults,\n\t...pushCommandDefaults,\n\t...pullCommandDefaults,\n};\n\nconst getInheritedOptions = (\n\tcopts: DotSecCommandsDefaults,\n\tcommandName: string,\n\tresult: {\n\t\toptions?: DotSecCommandOptions;\n\t\trequiredOptions?: DotSecCommandOptions;\n\t} = {},\n): DotSecCommandDefaults | undefined => {\n\tconst command = copts[commandName];\n\tif (command) {\n\t\tif (command.inheritsFrom) {\n\t\t\treturn command?.inheritsFrom.reduce(\n\t\t\t\t(acc, inheritedCommandName) => {\n\t\t\t\t\treturn getInheritedOptions(copts, inheritedCommandName, acc);\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t...command,\n\t\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\t\trequiredOptions: {\n\t\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\treturn {\n\t\t\t\t...command,\n\t\t\t\toptions: { ...result.options, ...command.options },\n\t\t\t\trequiredOptions: {\n\t\t\t\t\t...result.requiredOptions,\n\t\t\t\t\t...command.requiredOptions,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n};\n\nconst expandCommandOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n): ExpandedCommandOption => {\n\tif (Array.isArray(commandOption)) {\n\t\treturn {\n\t\t\toption: commandOption,\n\t\t};\n\t} else {\n\t\treturn commandOption;\n\t}\n};\n\nconst createOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n\toptions: {\n\t\trequired?: boolean;\n\t\tdotsecConfig?: DotsecConfig;\n\t\toptionKey: string;\n\t},\n): Option => {\n\tconst expandedCommandOption = expandCommandOption(commandOption);\n\tconst [option, description, defaultValue] = expandedCommandOption.option;\n\tconst defaultOptionValueFromConfig =\n\t\toptions?.dotsecConfig?.defaults?.options?.[options?.optionKey];\n\tconsole.log(\n\t\t\"defaultOptionValueFromConfig\",\n\t\toptions?.optionKey,\n\t\tdefaultOptionValueFromConfig,\n\t);\n\tconst newOption = new Option(\n\t\toption,\n\t\tdescription +\n\t\t\t(defaultOptionValueFromConfig ? \". Default from config.\" : \"\"),\n\t);\n\tif (defaultValue) {\n\t\tnewOption.default(defaultOptionValueFromConfig || defaultValue);\n\t}\n\tif (expandedCommandOption.env) {\n\t\tnewOption.env(expandedCommandOption.env);\n\t}\n\tif (options?.required) {\n\t\tnewOption.makeOptionMandatory(true);\n\t}\n\treturn newOption;\n};\nexport const setProgramOptions = (params: {\n\tprogram: Command;\n\tcommandName?: string;\n\tdotsecConfig: DotsecConfig;\n}) => {\n\tconst { program, commandName, dotsecConfig } = params;\n\tconst programOptions = commandOptions[commandName || program.name()];\n\n\tif (programOptions) {\n\t\tconst { options, requiredOptions, description, usage, helpText } =\n\t\t\tprogramOptions;\n\t\tif (options) {\n\t\t\tObject.keys(options).forEach((optionKey) => {\n\t\t\t\tconst commandOption = options[optionKey];\n\t\t\t\tconst newOption = createOption(commandOption, {\n\t\t\t\t\tdotsecConfig,\n\t\t\t\t\toptionKey,\n\t\t\t\t});\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (requiredOptions) {\n\t\t\tObject.keys(requiredOptions).forEach((requiredOptionKey) => {\n\t\t\t\tconst requiredOption = requiredOptions[requiredOptionKey];\n\t\t\t\tconst newOption = createOption(requiredOption, {\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdotsecConfig,\n\t\t\t\t\toptionKey: requiredOptionKey,\n\t\t\t\t});\n\n\t\t\t\tprogram.addOption(newOption);\n\t\t\t});\n\t\t}\n\t\tif (description) {\n\t\t\tprogram.description(description);\n\t\t}\n\t\tif (usage) {\n\t\t\tprogram.description(usage);\n\t\t}\n\t\tif (helpText) {\n\t\t\tprogram.description(helpText);\n\t\t}\n\t}\n};\n", "import {\n\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n} from \"../../constants\";\nimport { ExpandedCommandOption } from \"./types\";\n\nexport const envFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--env-file <envFile>\",\n\t\t`Path to .env file. If not provided, will look for value in 'ENV_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTENV_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTENV_FILENAME,\n\t],\n\tenv: \"ENV_FILE\",\n};\nexport const secFileOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--sec-file, <secFile>\",\n\t\t`Path to .sec file. If not provided, will look for value in 'SEC_FILE' environment variable. If not provided, will look for '${DOTSEC_DEFAULT_DOTSEC_FILENAME}' file in current directory.`,\n\t\tDOTSEC_DEFAULT_DOTSEC_FILENAME,\n\t],\n\tenv: \"SEC_FILE\",\n};\n\nexport const withEnvOption: ExpandedCommandOption = {\n\toption: [\"--with-env, --withEnv\", \"Run command using a dot env file\"],\n};\n\nexport const withSecOption: ExpandedCommandOption = {\n\toption: [\"--with-sec, --withSec\", \"Run command with a dotsec file\"],\n};\n\nexport const yesOption: ExpandedCommandOption = {\n\toption: [\"--yes\", \"Skip confirmation prompts\"],\n};\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst decryptCommandDefaults: DotSecCommandsDefaults = {\n\tdecrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default decryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst dotsecCommandDefaults: DotSecCommandsDefaults = {\n\tdotsec: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\t\t\tplugin: [\"--plugin <plugin>\", \"Comma-separated list of plugins to use\"],\n\t\t},\n\t},\n};\n\nexport default dotsecCommandDefaults;\n", "import { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst encryptCommandDefaults: DotSecCommandsDefaults = {\n\tencrypt: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default encryptCommandDefaults;\n", "import { DOTSEC_DEFAULT_CONFIG_FILE } from \"../../constants\";\nimport { envFileOption, secFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst initCommandDefaults: DotSecCommandsDefaults = {\n\tinit: {\n\t\toptions: {\n\t\t\tverbose: [\"--verbose\", \"Verbose output\", false],\n\t\t\tconfigFile: [\n\t\t\t\t\"-c, --config-file, --configFile <configFile>\",\n\t\t\t\t\"Config file\",\n\t\t\t\tDOTSEC_DEFAULT_CONFIG_FILE,\n\t\t\t],\n\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default initCommandDefaults;\n", "import {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst pullCommandDefaults: DotSecCommandsDefaults = {\n\tpull: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t},\n};\n\nexport default pullCommandDefaults;\n", "import dotsecCommandDefaults from \"./dotsec\";\nimport {\n\tenvFileOption,\n\tsecFileOption,\n\twithEnvOption,\n\twithSecOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst runCommandDefaults: DotSecCommandsDefaults = {\n\trunEnvOnly: {\n\t\tinheritsFrom: [\"dotsec\"],\n\t\tusage: \"[commandArgs...]\",\n\t\toptions: {\n\t\t\tenvFile: envFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tdescription:\n\t\t\t\"Run a command in a separate process and populate env with contents of a dotenv file.\",\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --env-file .env.dev echo \"hello world\"\n\n${\"Run a command with a specific ENV_FILE variable\"}\n\n$ ENV_FILE=.env.dev dotsec run echo \"hello world\"\n\n`,\n\t},\n\trun: {\n\t\tinheritsFrom: [\"dotsec\"],\n\n\t\toptions: {\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\n\t\tusage:\n\t\t\t\"[--with-env --env-file .env] [--with-sec --sec-file .sec] [commandArgs...]\",\n\t\tdescription: `Run a command in a separate process and populate env with either \n\t\t\t- contents of a dotenv file\n\t\t\t- decrypted values of a dotsec file.\n\nThe --withEnv option will take precedence over the --withSec option. If neither are specified, the --withEnv option will be used by default.`,\n\t\thelpText: `${\"Examples:\"}\n\n${\"Run a command with a .env file\"}\n\n$ dotsec run echo \"hello world\"\n\n\n${\"Run a command with a specific .env file\"}\n\n$ dotsec run --with-env --env-file .env.dev echo \"hello world\"\n\n\n${\"Run a command with a .sec file\"}\n\n$ dotsec run --with-sec echo \"hello world\"\n\n\n${\"Run a command with a specific .sec file\"}\n\n$ dotsec run --with-sec --sec-file .sec.dev echo \"hello world\"\n`,\n\t},\n\tpush: {\n\t\toptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.options,\n\t\t\twithEnv: withEnvOption,\n\t\t\twithSec: withSecOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\t...dotsecCommandDefaults.dotsec.requiredOptions,\n\t\t},\n\t},\n};\n\nexport default runCommandDefaults;\n", "import { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { DecryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"decrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<DecryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${options.decryptHandlers\n\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"Decrypting with\",\n\t\t\t\t\tstrong(\n\t\t\t\t\t\tpluginCliDecrypt.encryptionEngineName ||\n\t\t\t\t\t\t\tpluginCliDecrypt.triggerOptionValue,\n\t\t\t\t\t),\n\t\t\t\t\t\"engine\",\n\t\t\t\t);\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\t// get current dot env file\n\t\t\t\tconst dotsecString = await readContentsFromFile(secFile);\n\n\t\t\t\tconst plaintext = await pluginCliDecrypt.handler({\n\t\t\t\t\tciphertext: dotsecString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotenvOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: envFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotenvOverwriteResponse === undefined ||\n\t\t\t\t\tdotenvOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(envFile, plaintext);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote plaintext contents of ${strong(secFile)} file to ${strong(\n\t\t\t\t\t\t\tenvFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.decryptHandlers.map((decryption) => {\n\t\tconst { options, requiredOptions } = decryption;\n\t\taddPluginOptions(options, subProgram);\n\t\taddPluginOptions(requiredOptions, subProgram, true);\n\t});\n\n\tconst engines = options.decryptHandlers.map((e) => e.triggerOptionValue);\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"} to use: ${\n\t\t\tengines.length === 1 ? engines[0] : engines.join(\", \")\n\t\t}`,\n\t\tengines.length === 1 ? engines[0] : undefined,\n\t);\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { EncryptCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginEncryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\n\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n} & Record<string, unknown>;\n\nconst addEncryptProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tencryptHandlers: DotsecCliPluginEncryptHandler[];\n\t\tdotsecConfig: DotsecConfig;\n\t},\n) => {\n\tconst { encryptHandlers, dotsecConfig } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"encrypt\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<EncryptCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\t\t\t\tconst pluginCliEncrypt = (encryptHandlers || []).find((handler) => {\n\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t});\n\n\t\t\t\tif (!pluginCliEncrypt) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`No encryption plugin found, available encryption engine(s): ${options.encryptHandlers\n\t\t\t\t\t\t\t.map((e) => e.triggerOptionValue)\n\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"Encrypting with\",\n\t\t\t\t\tstrong(\n\t\t\t\t\t\tpluginCliEncrypt.encryptionEngineName ||\n\t\t\t\t\t\t\tpluginCliEncrypt.triggerOptionValue,\n\t\t\t\t\t),\n\t\t\t\t\t\"engine\",\n\t\t\t\t);\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliEncrypt.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst dotenvString = await readContentsFromFile(envFile);\n\n\t\t\t\tconst cipherText = await pluginCliEncrypt.handler({\n\t\t\t\t\tplaintext: dotenvString,\n\t\t\t\t\t...allOptionsValues,\n\t\t\t\t});\n\n\t\t\t\tconst dotsecOverwriteResponse = await promptOverwriteIfFileExists({\n\t\t\t\t\tfilePath: secFile,\n\t\t\t\t\tskip: yes,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tdotsecOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(secFile, cipherText);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote encrypted contents of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\tsecFile,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\tcommand.help();\n\t\t\t}\n\t\t});\n\n\toptions.encryptHandlers.map((encryptionHandler) => {\n\t\tconst { options, requiredOptions } = encryptionHandler;\n\t\taddPluginOptions(options, subProgram);\n\t\taddPluginOptions(requiredOptions, subProgram, true);\n\t});\n\tconst engines = options.encryptHandlers.map((e) => e.triggerOptionValue);\n\tconst encryptionEngineNames = options.encryptHandlers.map(\n\t\t(e) => e.encryptionEngineName,\n\t);\n\n\tsubProgram.option(\n\t\t\"--engine <engine>\",\n\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\tengines.length === 1 ? engines[0] : engines.join(\", \")\n\t\t}`,\n\t);\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\tsubProgram.description(\n\t\t`Encrypt .env file using ${encryptionEngineNames.join(\", \")}`,\n\t);\n\treturn subProgram;\n};\n\nexport default addEncryptProgram;\n", "import fs from \"node:fs\";\nimport * as ts from \"typescript\";\n\nexport const patchConfigFile = (options: {\n\tconfigFile: string;\n\tconfig?: {\n\t\taws?: {\n\t\t\tregion?: string;\n\t\t\tkms?: {\n\t\t\t\tkeyAlias?: string;\n\t\t\t};\n\t\t};\n\t};\n}) => {\n\tconst printer: ts.Printer = ts.createPrinter();\n\tconst source = fs.readFileSync(options.configFile, \"utf8\");\n\n\tconst transformer =\n\t\t<T extends ts.Node>(context: ts.TransformationContext) =>\n\t\t(rootNode: T) => {\n\t\t\tfunction visit(node: ts.Node): ts.Node {\n\t\t\t\tnode = ts.visitEachChild(node, visit, context);\n\t\t\t\tif (node.kind === ts.SyntaxKind.StringLiteral) {\n\t\t\t\t\tconst kmsNode = node?.parent?.parent?.parent;\n\t\t\t\t\tif (options.config?.aws?.kms?.keyAlias) {\n\t\t\t\t\t\tif (kmsNode?.getChildAt(0)?.getText() === \"kms\") {\n\t\t\t\t\t\t\tconst awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(\n\t\t\t\t\t\t\t\t\toptions.config?.aws?.kms?.keyAlias,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (options.config?.aws?.region) {\n\t\t\t\t\t\tif (node?.parent?.getChildAt(0)?.getText() === \"region\") {\n\t\t\t\t\t\t\tconst awsNode = node?.parent?.parent?.parent;\n\n\t\t\t\t\t\t\t// const awsNode = kmsNode?.parent?.parent;\n\t\t\t\t\t\t\tif (awsNode?.getChildAt(0).getText() === \"aws\") {\n\t\t\t\t\t\t\t\treturn ts.createStringLiteral(options.config?.aws?.region);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\treturn ts.visitNode(rootNode, visit);\n\t\t};\n\n\tconst sourceFile: ts.SourceFile = ts.createSourceFile(\n\t\t\"test.ts\",\n\t\tsource,\n\t\tts.ScriptTarget.ES2015,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\t// Options may be passed to transform\n\tconst result: ts.TransformationResult<ts.SourceFile> =\n\t\tts.transform<ts.SourceFile>(sourceFile, [transformer]);\n\n\tconst transformedSourceFile: ts.SourceFile = result.transformed[0];\n\n\tconst transformedSource = printer.printFile(transformedSourceFile);\n\tresult.dispose();\n\n\treturn transformedSource;\n};\n", "import { promptOverwriteIfFileExists, writeContentsToFile } from \"../../lib/io\";\nimport { DotsecConfig, InitCommandOptions } from \"../../types\";\nimport { Command } from \"commander\";\n\nimport { patchConfigFile } from \"../../lib/transformer\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport path from \"node:path\";\ntype Formats = {\n\tenv?: string;\n\tawsKeyAlias?: string;\n};\n\nconst addInitProgram = async (\n\tprogram: Command,\n\toptions: { dotsecConfig: DotsecConfig },\n) => {\n\tconst { dotsecConfig } = options;\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"init\")\n\t\t.action(async (_options: Formats, command: Command) => {\n\t\t\tconst { configFile, yes } = command.optsWithGlobals<InitCommandOptions>();\n\n\t\t\ttry {\n\t\t\t\tconst patchedConfigTemplate = patchConfigFile({\n\t\t\t\t\tconfigFile: path.resolve(\n\t\t\t\t\t\t__dirname,\n\t\t\t\t\t\t\"../../src/templates/dotsec.config.ts\",\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t\tconst dotsecConfigOverwriteResponse = await promptOverwriteIfFileExists(\n\t\t\t\t\t{\n\t\t\t\t\t\tfilePath: configFile,\n\t\t\t\t\t\tskip: yes,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\tdotsecConfigOverwriteResponse === undefined ||\n\t\t\t\t\tdotsecConfigOverwriteResponse.overwrite === true\n\t\t\t\t) {\n\t\t\t\t\tawait writeContentsToFile(configFile, patchedConfigTemplate);\n\t\t\t\t\tconsole.log(`Wrote config file to ${strong(configFile)}`);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tcommand.error(e);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\n\treturn subProgram;\n};\n\nexport default addInitProgram;\n", "import { PushCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport {\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginPushHandler,\n} from \"../../types/plugin\";\nimport { setProgramOptions } from \"../options\";\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\nimport fs from \"node:fs\";\n\n/**\n * Decrypts, and pushes the contents of a .env file to AWS SSM, AWS Secrets Manager or GitHub Actions Secrets\n * @date 12/7/2022 - 9:16:48 AM\n *\n * @async\n * @param {Command} program\n * @returns {unknown}\n */\nconst addPushProgram = async (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\thandlers: {\n\t\t\tpush: DotsecCliPluginPushHandler;\n\t\t\tdecrypt: DotsecCliPluginDecryptHandler;\n\t\t}[];\n\t},\n) => {\n\tconst { dotsecConfig, handlers } = options;\n\n\tconst subProgram = program\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.command(\"push\")\n\t\t.action(async (_options: Record<string, string>, command: Command) => {\n\t\t\ttry {\n\t\t\t\tconst {\n\t\t\t\t\t// verbose,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\twithEnv,\n\t\t\t\t\twithSec,\n\t\t\t\t\tengine,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<PushCommandOptions>();\n\n\t\t\t\tconst encryptionEngine =\n\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\tconst pluginCliDecrypt = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.decrypt?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.decrypt;\n\n\t\t\t\tconst pluginCliPush = (handlers || []).find((handler) => {\n\t\t\t\t\treturn handler.push?.triggerOptionValue === encryptionEngine;\n\t\t\t\t})?.push;\n\n\t\t\t\tif (!pluginCliPush) {\n\t\t\t\t\tthrow new Error(\"No push plugin found!\");\n\t\t\t\t}\n\n\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliDecrypt?.requiredOptions || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.options || {}),\n\t\t\t\t\t...Object.keys(pluginCliPush?.requiredOptions || {}),\n\t\t\t\t];\n\n\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t}\n\n\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\tif (withEnv || !(withEnv || withSec)) {\n\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t}\n\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t} else if (withSec) {\n\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${handlers\n\t\t\t\t\t\t\t\t.map((e) => `--${e.decrypt?.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (envContents) {\n\t\t\t\t\t// convert to object\n\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t// expand env vars\n\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tif (expandedEnvVars.parsed) {\n\t\t\t\t\t\tawait pluginCliPush.handler({\n\t\t\t\t\t\t\tpush: expandedEnvVars.parsed,\n\t\t\t\t\t\t\tyes,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(e);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t});\n\n\tsetProgramOptions({ program: subProgram, dotsecConfig });\n\n\treturn subProgram;\n};\n\nexport default addPushProgram;\n", "import fs from \"node:fs\";\n\nimport { Command } from \"commander\";\nimport { parse } from \"dotenv\";\nimport { expand } from \"dotenv-expand\";\n\nimport { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport { RunCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport { DotsecCliPluginDecryptHandler } from \"../../types/plugin\";\nimport { strong } from \"../../utils/logging\";\nimport { setProgramOptions } from \"../options\";\nimport { spawnSync } from \"node:child_process\";\nconst addRunProgam = (\n\tprogram: Command,\n\toptions: {\n\t\tdotsecConfig: DotsecConfig;\n\t\tdecryptHandlers?: DotsecCliPluginDecryptHandler[];\n\t},\n) => {\n\tconst { dotsecConfig, decryptHandlers } = options || {};\n\n\t// is there an encryption engine?\n\tconst hasDecryptEngine =\n\t\tdecryptHandlers !== undefined && decryptHandlers.length > 0;\n\n\tconst subProgram = program\n\t\t.command(\"run <command...>\")\n\t\t.allowUnknownOption(true)\n\t\t.enablePositionalOptions()\n\t\t.passThroughOptions()\n\t\t.showHelpAfterError(true)\n\t\t.action(\n\t\t\tasync (\n\t\t\t\tcommands: string[],\n\t\t\t\t_options: Record<string, string>,\n\t\t\t\tcommand: Command,\n\t\t\t) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { envFile, secFile, withEnv, withSec, engine } =\n\t\t\t\t\t\tcommand.optsWithGlobals<RunCommandOptions>();\n\t\t\t\t\tif (withEnv && withSec) {\n\t\t\t\t\t\tthrow new Error(\"Cannot use both --with-env and --with-sec\");\n\t\t\t\t\t}\n\n\t\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\t\tif (withEnv || !(withEnv || withSec) || hasDecryptEngine === false) {\n\t\t\t\t\t\tif (!envFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotenv file specified in --env-file option\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenvContents = fs.readFileSync(envFile, \"utf8\");\n\t\t\t\t\t} else if (withSec) {\n\t\t\t\t\t\tif (!secFile) {\n\t\t\t\t\t\t\tthrow new Error(\"No dotsec file specified in --sec-file option\");\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst encryptionEngine =\n\t\t\t\t\t\t\tengine || dotsecConfig?.defaults?.encryptionEngine;\n\n\t\t\t\t\t\tconst pluginCliDecrypt = (decryptHandlers || []).find((handler) => {\n\t\t\t\t\t\t\treturn handler.triggerOptionValue === encryptionEngine;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (!pluginCliDecrypt) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`No decryption plugin found, available decryption engine(s): ${(\n\t\t\t\t\t\t\t\t\tdecryptHandlers || []\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.map((e) => `--${e.triggerOptionValue}`)\n\t\t\t\t\t\t\t\t\t.join(\", \")}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst allOptionKeys = [\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.options || {}),\n\t\t\t\t\t\t\t...Object.keys(pluginCliDecrypt.requiredOptions || {}),\n\t\t\t\t\t\t];\n\n\t\t\t\t\t\tconst allOptionsValues = Object.fromEntries(\n\t\t\t\t\t\t\tallOptionKeys.map((key) => {\n\t\t\t\t\t\t\t\treturn [key, _options[key]];\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst dotSecContents = fs.readFileSync(secFile, \"utf8\");\n\t\t\t\t\t\tenvContents = await pluginCliDecrypt.handler({\n\t\t\t\t\t\t\tciphertext: dotSecContents,\n\t\t\t\t\t\t\t...allOptionsValues,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (envContents) {\n\t\t\t\t\t\tconst dotenvVars = parse(envContents);\n\t\t\t\t\t\t// expand env vars\n\t\t\t\t\t\tconst expandedEnvVars = expand({\n\t\t\t\t\t\t\tignoreProcessEnv: true,\n\t\t\t\t\t\t\tparsed: {\n\t\t\t\t\t\t\t\t// add standard env variables\n\t\t\t\t\t\t\t\t...(process.env as Record<string, string>),\n\t\t\t\t\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t\t\t\t\t...dotenvVars,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst [userCommand, ...userCommandArgs] = commands;\n\t\t\t\t\t\tconst spawn = spawnSync(userCommand, [...userCommandArgs], {\n\t\t\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t\t\t\tshell: false,\n\t\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t\t...expandedEnvVars.parsed,\n\t\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\t\t__DOTSEC_ENV__: JSON.stringify(Object.keys(dotenvVars)),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (spawn.status !== 0) {\n\t\t\t\t\t\t\tprocess.exit(spawn.status || 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(\"No .env or .sec file provided\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(strong(e.message));\n\t\t\t\t\tcommand.help();\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\tsetProgramOptions({\n\t\tprogram: subProgram,\n\t\tcommandName: hasDecryptEngine ? \"run\" : \"runEnvOnly\",\n\t\tdotsecConfig,\n\t});\n\n\tif (hasDecryptEngine) {\n\t\tdecryptHandlers?.map((run) => {\n\t\t\tconst { options, requiredOptions } = run;\n\t\t\taddPluginOptions(options, subProgram);\n\t\t\taddPluginOptions(requiredOptions, subProgram, true);\n\t\t});\n\t\tconst engines = decryptHandlers?.map((e) => e.triggerOptionValue);\n\n\t\tsubProgram.option(\n\t\t\t\"--engine <engine>\",\n\t\t\t`Encryption engine${engines.length > 0 ? \"s\" : \"\"}: ${\n\t\t\t\t(engines.join(\", \"), engines.length === 1 ? engines[0] : undefined)\n\t\t\t}`,\n\t\t\t// engines.length === 1 ? engines[0] : undefined,\n\t\t);\n\t}\n\treturn subProgram;\n};\n\nexport default addRunProgam;\n"],
5
+ "mappings": "oqCAAA,qCCEO,GAAM,GAA6B,mBAC7B,GAAsB,CAAC,GACvB,EAAiC,OACjC,EAAiC,OACjC,EAA8B,GCN3C,mBACA,0BAUO,YAAoB,EAAc,CACxC,GAAI,CACH,MAAO,IAAI,UAAS,UAAU,EAAK,iBAClC,CAGD,MAAO,IAYF,GAAM,IAAW,KAAO,IAAqB,CACnD,GAAI,CACH,MAAO,IAAW,KAAM,IAAG,SAAS,SAAS,EAAU,eAC/C,EAAP,CACD,KAAI,aAAiB,OACd,GAAI,OACT,mBAAmB,GAAK,SAAS,QAAQ,MAAO,OAC/C,EAAM,WAIF,ICpCT,gDACA,uBACA,qBAEO,GAAM,IAAmB,KAC/B,IACoC,CAVrC,YAWC,GAAM,GAAM,QAAQ,MAEd,EAAa,KAAM,AADJ,IAAI,MACa,QAAQ,CAC7C,MAAO,EAAW,CAAC,GAAY,CAAC,GAAG,GAAqB,gBACxD,MACA,QAAS,GAAK,MAAM,GAAK,KACzB,WAAY,WAEb,GAAI,GAAY,IAAe,KAC9B,KAAM,IAAI,OAAM,8BAA8B,KAE/C,GAAI,GACH,GAAI,EAAW,SAAS,SAAU,C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AC,GAAe,CACjD,AAAK,EAAc,IAClB,GAAc,GAAc,kBAAkB,SAMjD,GAAM,GAA4D,GAC5D,EAA4D,GAC5D,EAGA,GAEN,OAAW,KAAc,QAAO,KAAK,GAAgB,CACpD,GAAM,GAAe,EAAc,GAC7B,EAAmB,KAAM,GAAiB,CAAE,KAAM,IAClD,CAAE,gBAAe,YAAa,GAAQ,KAAM,GAAiB,CAClE,MACA,aAAc,EACd,eAGD,AAAI,kBAAK,UACR,EAAyB,KAAK,EAAI,SAE/B,kBAAK,UACR,GAAyB,KAAK,EAAI,SAC9B,kBAAK,OACR,EAAsB,KAAK,CAAE,KAAM,EAAI,KAAM,QAAS,EAAI,WAIxD,GACH,EAAc,CAAE,YAGlB,AAAI,EAAyB,QAC5B,KAAM,IAAkB,EAAS,CAChC,aAAc,EACd,gBAAiB,IAGf,EAAyB,QAC5B,KAAM,IAAkB,EAAS,CAChC,aAAc,EACd,gBAAiB,IAGf,EAAsB,QACzB,MAAM,IAAe,EAAS,CAC7B,aAAc,EACd,SAAU,IAIX,KAAM,IAAe,EAAS,CAAE,aAAc,IAC9C,KAAM,IAAc,EAAS,CAC5B,aAAc,EACd,gBAAiB,IAElB,KAAM,GAAQ",
6
6
  "names": []
7
7
  }
package/dist/index.d.ts CHANGED
@@ -30,17 +30,14 @@ type DotsecCliOption = [
30
30
  flags: string,
31
31
  description?: string,
32
32
  defaultValue?: string | boolean | string[]
33
- ] | [
34
- flags: string,
35
- description: string,
36
- fn: (value: string, previous: unknown) => unknown,
37
- defaultValue?: unknown
38
- ] | [
39
- flags: string,
40
- description: string,
41
- regexp: RegExp,
42
- defaultValue?: string | boolean | string[]
43
- ];
33
+ ] | {
34
+ flags: string;
35
+ description?: string;
36
+ defaultValue?: string | boolean | string[];
37
+ fn?: (value: string, previous: unknown) => unknown;
38
+ regexp?: RegExp;
39
+ env?: string;
40
+ };
44
41
  type DotsecPluginConfig = {
45
42
  module?: string;
46
43
  config?: {
@@ -53,6 +50,7 @@ type DotsecPluginConfig = {
53
50
  type DotsecPlugins = {
54
51
  plugins: DotsecPlugin;
55
52
  };
53
+ type Meh<T extends DotsecPluginModuleConfig> = T extends DotsecPluginModuleConfig ? T : never;
56
54
  type DotsecPluginModuleConfig = {
57
55
  plugin: DotsecPlugin;
58
56
  api?: Record<string, unknown>;
@@ -66,10 +64,11 @@ type DotsecPluginModuleConfig = {
66
64
  type DotsecPluginModule<T extends DotsecPluginModuleConfig = DotsecPluginModuleConfig> = (options: {
67
65
  dotsecConfig: DotsecConfig;
68
66
  ajv: Ajv;
67
+ configFile: string;
69
68
  }) => Promise<{
70
69
  name: keyof T["plugin"] | string;
71
70
  encryptionEngineName?: string;
72
- api: T["api"] extends Record<string, unknown> ? T["api"] : never;
71
+ api?: T["api"] extends Record<string, unknown> ? T["api"] : never;
73
72
  addCliCommand?: (options: {
74
73
  program: Command;
75
74
  }) => Promise<void>;
@@ -102,6 +101,10 @@ type DotsecConfig<T extends DotsecPlugins = DotsecPlugins> = {
102
101
  module?: T["plugins"][PluginKey]["module"];
103
102
  } & T["plugins"][PluginKey]["config"];
104
103
  };
104
+ options?: {
105
+ envFile?: string;
106
+ secFile?: string;
107
+ };
105
108
  };
106
109
  push?: {
107
110
  [key: string]: {
@@ -142,4 +145,4 @@ declare const writeLine: (str: string) => void;
142
145
  declare const emphasis: (str: string) => string;
143
146
  declare const strong: (str: string) => string;
144
147
 
145
- export { DotsecConfig, DotsecEncryptionEngine, DotsecEncryptionEngineFactory, DotsecEncryptionEngineFactoryProps, DotsecPlugin, DotsecPluginModule, FromEnv, emphasis, promptExecute, resolveFromEnv, strong, writeLine };
148
+ export { DotsecConfig, DotsecEncryptionEngine, DotsecEncryptionEngineFactory, DotsecEncryptionEngineFactoryProps, DotsecPlugin, DotsecPluginModule, FromEnv, Meh, emphasis, promptExecute, resolveFromEnv, strong, writeLine };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var D=Object.create;var n=Object.defineProperty,P=Object.defineProperties,R=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertyNames,l=Object.getOwnPropertySymbols,h=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var m=(e,o,r)=>o in e?n(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,i=(e,o)=>{for(var r in o||(o={}))a.call(o,r)&&m(e,r,o[r]);if(l)for(var r of l(o))F.call(o,r)&&m(e,r,o[r]);return e},g=(e,o)=>P(e,k(o)),u=e=>n(e,"__esModule",{value:!0});var V=(e,o)=>{u(e);for(var r in o)n(e,r,{get:o[r],enumerable:!0})},j=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of L(o))!a.call(e,t)&&t!=="default"&&n(e,t,{get:()=>o[t],enumerable:!(r=R(o,t))||r.enumerable});return e},c=e=>j(u(n(e!=null?D(h(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);V(exports,{Table:()=>v,emphasis:()=>w,promptExecute:()=>E,resolveFromEnv:()=>b,strong:()=>y,writeLine:()=>d});var f=c(require("prompts"));var E=async({skip:e,message:o,execute:r})=>{let t=!1;(e||(await(0,f.default)({type:"confirm",name:"confirm",message:o})).confirm===!0)&&(t=!0),t&&await r()};var x=c(require("dotenv-expand")),b=e=>{var s;let{fromEnvValue:o,env:r,variables:t}=e;return o?(s=(0,x.expand)({ignoreProcessEnv:!0,parsed:g(i(i({},r),t),{RESOLVED:o||""})}).parsed)==null?void 0:s.RESOLVED:""};var p=c(require("chalk")),v=require("cli-table");var d=e=>{process.stdout.write(e)},w=e=>p.default.yellowBright(e),y=e=>p.default.yellow.bold(e);0&&(module.exports={Table,emphasis,promptExecute,resolveFromEnv,strong,writeLine});
1
+ var D=Object.create;var n=Object.defineProperty,P=Object.defineProperties,R=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertyNames,l=Object.getOwnPropertySymbols,L=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var m=(e,o,r)=>o in e?n(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r,i=(e,o)=>{for(var r in o||(o={}))a.call(o,r)&&m(e,r,o[r]);if(l)for(var r of l(o))F.call(o,r)&&m(e,r,o[r]);return e},g=(e,o)=>P(e,k(o)),u=e=>n(e,"__esModule",{value:!0});var V=(e,o)=>{u(e);for(var r in o)n(e,r,{get:o[r],enumerable:!0})},j=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of h(o))!a.call(e,t)&&t!=="default"&&n(e,t,{get:()=>o[t],enumerable:!(r=R(o,t))||r.enumerable});return e},c=e=>j(u(n(e!=null?D(L(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);V(exports,{Table:()=>v,emphasis:()=>w,promptExecute:()=>E,resolveFromEnv:()=>b,strong:()=>y,writeLine:()=>d});var f=c(require("prompts"));var E=async({skip:e,message:o,execute:r})=>{let t=!1;(e||(await(0,f.default)({type:"confirm",name:"confirm",message:o})).confirm===!0)&&(t=!0),t&&await r()};var x=c(require("dotenv-expand")),b=e=>{var s;let{fromEnvValue:o,env:r,variables:t}=e;return o?(s=(0,x.expand)({ignoreProcessEnv:!0,parsed:g(i(i({},r),t),{RESOLVED:o||""})}).parsed)==null?void 0:s.RESOLVED:""};var p=c(require("chalk")),v=require("cli-table");var d=e=>{process.stdout.write(e)},w=e=>p.default.yellowBright(e),y=e=>p.default.yellow.bold(e);0&&(module.exports={Table,emphasis,promptExecute,resolveFromEnv,strong,writeLine});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/utils/prompts.ts", "../src/utils/fromEnv.ts", "../src/utils/logging.ts"],
4
- "sourcesContent": ["export type {\n\tDotsecEncryptionEngine,\n\tDotsecEncryptionEngineFactory,\n\tDotsecEncryptionEngineFactoryProps,\n\tFromEnv,\n\tDotsecPlugin,\n\tDotsecPluginModule,\n\tDotsecConfig,\n} from \"./types\";\nexport { promptExecute } from \"./utils/prompts\";\nexport { resolveFromEnv } from \"./utils/fromEnv\";\n\n// import dotsec from \"./dotsec\";\n// export default dotsec;\n\nexport { Table, emphasis, strong, writeLine } from \"./utils/logging\";\n", "import prompts from \"prompts\";\n\nexport const promptConfirm = async ({\n\tpredicate,\n\tskip,\n\tmessage,\n}: {\n\tpredicate?: (...args: unknown[]) => Promise<boolean> | boolean;\n\tskip?: boolean;\n\tmessage: string;\n}): Promise<boolean> => {\n\tif (skip === true) {\n\t\treturn true;\n\t} else {\n\t\tconst result = predicate ? await predicate() : true;\n\t\tif (result) {\n\t\t\tconst confirmResult = await prompts({\n\t\t\t\ttype: \"confirm\",\n\t\t\t\tname: \"confirm\",\n\t\t\t\tmessage: () => {\n\t\t\t\t\treturn message;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (confirmResult.confirm === true) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n};\n\nexport const promptExecute = async ({\n\tskip,\n\tmessage,\n\texecute,\n}: {\n\tskip?: boolean;\n\tmessage: string;\n\texecute: () => unknown | Promise<unknown>;\n}) => {\n\tlet shouldExecute = false;\n\tif (skip) {\n\t\tshouldExecute = true;\n\t} else {\n\t\tconst promptResponse = await prompts({\n\t\t\ttype: \"confirm\",\n\t\t\tname: \"confirm\",\n\t\t\tmessage,\n\t\t});\n\n\t\tif (promptResponse.confirm === true) {\n\t\t\tshouldExecute = true;\n\t\t}\n\t}\n\n\tif (shouldExecute) {\n\t\tawait execute();\n\t}\n};\n", "import { expand } from \"dotenv-expand\";\n\nexport const resolveFromEnv = (options: {\n\tfromEnvValue?: string;\n\tenv: NodeJS.ProcessEnv;\n\tvariables: Record<string, string>;\n}) => {\n\tconst { fromEnvValue, env, variables } = options;\n\n\tif (!fromEnvValue) {\n\t\treturn \"\";\n\t}\n\n\treturn (\n\t\texpand({\n\t\t\tignoreProcessEnv: true,\n\t\t\tparsed: {\n\t\t\t\t// add standard env variables\n\t\t\t\t...(env as Record<string, string>),\n\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t...variables,\n\t\t\t\tRESOLVED: fromEnvValue || \"\",\n\t\t\t},\n\t\t}) as { parsed?: { RESOLVED?: string } }\n\t).parsed?.RESOLVED;\n};\n", "import chalk from \"chalk\"\nimport Table = require(\"cli-table\")\nexport { Table }\n\nlet _logger: Pick<Console, \"info\" | \"error\" | \"table\">\nexport const getLogger = () => {\n\tif (!_logger) {\n\t\t_logger = console\n\t}\n\n\treturn _logger\n}\nexport const writeLine = (str: string) => {\n\tprocess.stdout.write(str)\n}\nexport const emphasis = (str: string): string => chalk.yellowBright(str)\nexport const strong = (str: string): string => chalk.yellow.bold(str)\n\nexport const clientLogger = {\n\tdebug(content: object) {\n\t\tconsole.log(content)\n\t},\n\tinfo(content: object) {\n\t\tconsole.log(content)\n\t},\n\twarn(content: object) {\n\t\tconsole.log(content)\n\t},\n\terror(content: object) {\n\t\tconsole.error(content)\n\t},\n}\n"],
4
+ "sourcesContent": ["export type {\n\tDotsecEncryptionEngine,\n\tDotsecEncryptionEngineFactory,\n\tDotsecEncryptionEngineFactoryProps,\n\tFromEnv,\n\tDotsecPlugin,\n\tDotsecPluginModule,\n\tMeh,\n\tDotsecConfig,\n} from \"./types\";\nexport { promptExecute } from \"./utils/prompts\";\nexport { resolveFromEnv } from \"./utils/fromEnv\";\n\n// import dotsec from \"./dotsec\";\n// export default dotsec;\n\nexport { Table, emphasis, strong, writeLine } from \"./utils/logging\";\n", "import prompts from \"prompts\";\n\nexport const promptConfirm = async ({\n\tpredicate,\n\tskip,\n\tmessage,\n}: {\n\tpredicate?: (...args: unknown[]) => Promise<boolean> | boolean;\n\tskip?: boolean;\n\tmessage: string;\n}): Promise<boolean> => {\n\tif (skip === true) {\n\t\treturn true;\n\t} else {\n\t\tconst result = predicate ? await predicate() : true;\n\t\tif (result) {\n\t\t\tconst confirmResult = await prompts({\n\t\t\t\ttype: \"confirm\",\n\t\t\t\tname: \"confirm\",\n\t\t\t\tmessage: () => {\n\t\t\t\t\treturn message;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (confirmResult.confirm === true) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n};\n\nexport const promptExecute = async ({\n\tskip,\n\tmessage,\n\texecute,\n}: {\n\tskip?: boolean;\n\tmessage: string;\n\texecute: () => unknown | Promise<unknown>;\n}) => {\n\tlet shouldExecute = false;\n\tif (skip) {\n\t\tshouldExecute = true;\n\t} else {\n\t\tconst promptResponse = await prompts({\n\t\t\ttype: \"confirm\",\n\t\t\tname: \"confirm\",\n\t\t\tmessage,\n\t\t});\n\n\t\tif (promptResponse.confirm === true) {\n\t\t\tshouldExecute = true;\n\t\t}\n\t}\n\n\tif (shouldExecute) {\n\t\tawait execute();\n\t}\n};\n", "import { expand } from \"dotenv-expand\";\n\nexport const resolveFromEnv = (options: {\n\tfromEnvValue?: string;\n\tenv: NodeJS.ProcessEnv;\n\tvariables: Record<string, string>;\n}) => {\n\tconst { fromEnvValue, env, variables } = options;\n\n\tif (!fromEnvValue) {\n\t\treturn \"\";\n\t}\n\n\treturn (\n\t\texpand({\n\t\t\tignoreProcessEnv: true,\n\t\t\tparsed: {\n\t\t\t\t// add standard env variables\n\t\t\t\t...(env as Record<string, string>),\n\t\t\t\t// add custom env variables, either from .env or .sec, (or empty object if none)\n\t\t\t\t...variables,\n\t\t\t\tRESOLVED: fromEnvValue || \"\",\n\t\t\t},\n\t\t}) as { parsed?: { RESOLVED?: string } }\n\t).parsed?.RESOLVED;\n};\n", "import chalk from \"chalk\"\nimport Table = require(\"cli-table\")\nexport { Table }\n\nlet _logger: Pick<Console, \"info\" | \"error\" | \"table\">\nexport const getLogger = () => {\n\tif (!_logger) {\n\t\t_logger = console\n\t}\n\n\treturn _logger\n}\nexport const writeLine = (str: string) => {\n\tprocess.stdout.write(str)\n}\nexport const emphasis = (str: string): string => chalk.yellowBright(str)\nexport const strong = (str: string): string => chalk.yellow.bold(str)\n\nexport const clientLogger = {\n\tdebug(content: object) {\n\t\tconsole.log(content)\n\t},\n\tinfo(content: object) {\n\t\tconsole.log(content)\n\t},\n\twarn(content: object) {\n\t\tconsole.log(content)\n\t},\n\terror(content: object) {\n\t\tconsole.error(content)\n\t},\n}\n"],
5
5
  "mappings": "s6BAAA,8GCAA,MAAoB,sBAgCb,GAAM,GAAgB,MAAO,CACnC,OACA,UACA,aAKK,CACL,GAAI,GAAgB,GACpB,AAAI,IASC,AANmB,MAAM,cAAQ,CACpC,KAAM,UACN,KAAM,UACN,aAGkB,UAAY,KAC9B,GAAgB,IAId,GACH,KAAM,MCzDR,MAAuB,4BAEV,EAAiB,AAAC,GAIzB,CANN,MAOC,GAAM,CAAE,eAAc,MAAK,aAAc,EAEzC,MAAK,GAKJ,gBAAO,CACN,iBAAkB,GAClB,OAAQ,SAEH,GAED,GAJI,CAKP,SAAU,GAAgB,OAG3B,SAVD,cAUS,SAdF,ICVT,MAAkB,oBACX,EAAQ,QAAQ,aAWhB,GAAM,GAAY,AAAC,GAAgB,CACzC,QAAQ,OAAO,MAAM,IAET,EAAW,AAAC,GAAwB,UAAM,aAAa,GACvD,EAAS,AAAC,GAAwB,UAAM,OAAO,KAAK",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotsec",
3
- "version": "1.0.0-alpha.36",
3
+ "version": "1.0.0-alpha.38",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -65,5 +65,5 @@
65
65
  "typescript": "~4.9.3",
66
66
  "yargs-parser": "^21.1.1"
67
67
  },
68
- "gitHead": "c97eb2d578a4572fa142798ba8197a934fe44b6f"
68
+ "gitHead": "9612873248dee6c2c015d322b12952411fff352f"
69
69
  }