dotsec 4.0.0-alpha.7 → 4.0.0-alpha.8

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/bin/dotsec.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('../dist/cli');
3
+ require("../dist/cli");
package/dist/cli/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var je=Object.create;var J=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Le=(n,o,s,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of Ae(o))!He.call(n,e)&&e!==s&&J(n,e,{get:()=>o[e],enumerable:!(t=Ve(o,e))||t.enumerable});return n};var w=(n,o,s)=>(s=n!=null?je(ke(n)):{},Le(o||!n||!n.__esModule?J(s,"default",{value:n,enumerable:!0}):s,n));var Te=require("commander");var Me="dotsec.config.ts",B=[Me],q=".sec",G=".env",_={defaults:{}};var Y=w(require("fs")),z=w(require("path"));function Re(n){try{return new Function(`return ${n.trim()}`)()}catch{return{}}}var Q=async n=>{try{return Re(await Y.default.promises.readFile(n,"utf8"))}catch(o){throw o instanceof Error?new Error(`Failed to parse ${z.default.relative(process.cwd(),n)}: ${o.message}`):o}};var X=require("bundle-require"),Z=w(require("joycon")),ee=w(require("path")),ne=async n=>{let o=process.cwd(),t=await new Z.default().resolve({files:n?[n]:[...B,"package.json"],cwd:o,stopDir:ee.default.parse(o).root,packageKey:"dotsec"});if(n&&t===null)throw new Error(`Could not find config file ${n}`);if(t){if(t.endsWith(".json")){let e=await Q(t),i;return t.endsWith("package.json")&&e.dotsec!==void 0?i=e.dotsec:i=e,{source:"json",contents:{..._,...i,defaults:{...i?.defaults,..._.defaults,plugins:{...i?.defaults?.plugins,..._.defaults?.plugins}},push:{...i?.push}}}}else if(t.endsWith(".ts")){let e=await(0,X.bundleRequire)({filepath:t}),i=e.mod.dotsec||e.mod.default||e.mod;return{source:"ts",contents:{..._,...i,defaults:{...i?.defaults,..._.defaults,plugins:{...i?.defaults?.plugins,..._.defaults?.plugins}},push:{...i?.push}}}}}return{source:"defaultConfig",contents:_}};var W=async n=>import(n.name).then(o=>o.default);var te=require("commander"),F=(n,o,s)=>{n&&Object.values(n).map(t=>{let e;if(Array.isArray(t)){let[i,c,l]=t;e={flags:i,description:c,defaultValue:l}}else{let{flags:i,description:c,defaultValue:l,choices:a,env:r,fn:f}=t;e={flags:i,description:c,defaultValue:l,choices:a,env:r,fn:f}}if(e){let i=new te.Option(e.flags,e.description);e.fn&&i.argParser(e.fn),e.defaultValue&&i.default(e.defaultValue),e.env&&i.env(e.env),s&&i.makeOptionMandatory(!0),e.choices&&i.choices(e.choices),o.addOption(i)}})};var k=w(require("fs/promises")),oe=w(require("path")),ie=w(require("prompts")),V=async n=>await k.default.readFile(n,"utf-8"),I=async(n,o)=>await k.default.writeFile(n,o,"utf-8"),qe=async n=>{try{return await(0,k.stat)(n),!0}catch{return!1}},A=async({filePath:n,skip:o})=>{let s;return await qe(n)&&o!==!0?s=await(0,ie.default)({type:"confirm",name:"overwrite",message:()=>`Overwrite './${oe.default.relative(process.cwd(),n)}' ?`}):s=void 0,s};var re=w(require("chalk")),Ge=w(require("cli-table"));var C=n=>re.default.yellow.bold(n);var ye=require("commander");var S={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 '${G}' file in current directory.`,G],env:"ENV_FILE"},N={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 '${q}' file in current directory.`,q],env:"SEC_FILE"},L={flags:"--using <using>",description:"Wether to use a dot env file or a dot sec file",choices:["env","sec"],env:"DOTSEC_USING"},se={flags:"--using <using>",description:"Wether to use a dot env file or a dot sec file",choices:["env"],env:"DOTSEC_USING"},$={option:["--yes","Skip confirmation prompts"]};var x={option:["-c, --config-file, --configFile <configFile>","Config file"],env:"DOTSEC_CONFIG_FILE"},ae={option:["--plugin <plugin>","Comma-separated list of plugins to use"],env:"DOTSEC_PLUGIN"},ce={option:["--engine <engine>","Encryption engine to use"],env:"DOTSEC_ENGINE"},M={option:["--create-manifest","Create a markdown manifest file. See the --manifest-file option for more information."],env:"CREATE_MANIFEST"},R={option:["--manifest-file-prefix <manifestFilePrefix>","Mmanifest file prefix"],env:"ENCRYPTION_MANIFEST_FILE"};var We={decrypt:{options:{configFile:x,envFile:S,secFile:N,createManifest:M,manifestFilePrefix:R,yes:$},description:"Decrypt a sec file",helpText:`Examples:
1
+ var je=Object.create;var J=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var Le=(t,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of Ae(o))!He.call(t,e)&&e!==s&&J(t,e,{get:()=>o[e],enumerable:!(i=Ve(o,e))||i.enumerable});return t};var D=(t,o,s)=>(s=t!=null?je(ke(t)):{},Le(o||!t||!t.__esModule?J(s,"default",{value:t,enumerable:!0}):s,t));var Te=require("commander");var Me="dotsec.config.ts",B=[Me],q=".sec",G=".env",_={defaults:{}};var Y=D(require("fs")),z=D(require("path"));function Re(t){try{return new Function(`return ${t.trim()}`)()}catch{return{}}}var Q=async t=>{try{return Re(await Y.default.promises.readFile(t,"utf8"))}catch(o){throw o instanceof Error?new Error(`Failed to parse ${z.default.relative(process.cwd(),t)}: ${o.message}`):o}};var X=require("bundle-require"),Z=D(require("joycon")),ee=D(require("path")),ne=async t=>{let o=process.cwd(),i=await new Z.default().resolve({files:t?[t]:[...B,"package.json"],cwd:o,stopDir:ee.default.parse(o).root,packageKey:"dotsec"});if(t&&i===null)throw new Error(`Could not find config file ${t}`);if(i){if(i.endsWith(".json")){let e=await Q(i),n;return i.endsWith("package.json")&&e.dotsec!==void 0?n=e.dotsec:n=e,{source:"json",contents:{..._,...n,defaults:{...n?.defaults,..._.defaults,plugins:{...n?.defaults?.plugins,..._.defaults?.plugins}},push:{...n?.push}}}}else if(i.endsWith(".ts")){let e=await(0,X.bundleRequire)({filepath:i}),n=e.mod.dotsec||e.mod.default||e.mod;return{source:"ts",contents:{..._,...n,defaults:{...n?.defaults,..._.defaults,plugins:{...n?.defaults?.plugins,..._.defaults?.plugins}},push:{...n?.push}}}}}return{source:"defaultConfig",contents:_}};var W=async t=>import(t.name).then(o=>o.default);var te=require("commander"),F=(t,o,s)=>{t&&Object.values(t).map(i=>{let e;if(Array.isArray(i)){let[n,p,l]=i;e={flags:n,description:p,defaultValue:l}}else{let{flags:n,description:p,defaultValue:l,choices:c,env:r,fn:d}=i;e={flags:n,description:p,defaultValue:l,choices:c,env:r,fn:d}}if(e){let n=new te.Option(e.flags,e.description);e.fn&&n.argParser(e.fn),e.defaultValue&&n.default(e.defaultValue),e.env&&n.env(e.env),s&&n.makeOptionMandatory(!0),e.choices&&n.choices(e.choices),o.addOption(n)}})};var k=D(require("fs/promises")),oe=D(require("path")),ie=D(require("prompts")),V=async t=>await k.default.readFile(t,"utf-8"),I=async(t,o)=>await k.default.writeFile(t,o,"utf-8"),qe=async t=>{try{return await(0,k.stat)(t),!0}catch{return!1}},A=async({filePath:t,skip:o})=>{let s;return await qe(t)&&o!==!0?s=await(0,ie.default)({type:"confirm",name:"overwrite",message:()=>`Overwrite './${oe.default.relative(process.cwd(),t)}' ?`}):s=void 0,s};var re=D(require("chalk")),Ge=D(require("cli-table"));var h=t=>re.default.yellow.bold(t);var ye=require("commander");var S={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 '${G}' file in current directory.`,G],env:"ENV_FILE"},N={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 '${q}' file in current directory.`,q],env:"SEC_FILE"},L={flags:"--using <using>",description:"Wether to use a dot env file or a dot sec file",choices:["env","sec"],env:"DOTSEC_USING"},se={flags:"--using <using>",description:"Wether to use a dot env file or a dot sec file",choices:["env"],env:"DOTSEC_USING"},$={option:["--yes","Skip confirmation prompts"]};var x={option:["-c, --config-file, --configFile <configFile>","Config file"],env:"DOTSEC_CONFIG_FILE"},ae={option:["--plugin <plugin>","Comma-separated list of plugins to use"],env:"DOTSEC_PLUGIN"},ce={option:["--engine <engine>","Encryption engine to use"],env:"DOTSEC_ENGINE"},M={option:["--create-manifest","Create a markdown manifest file. See the --manifest-file option for more information."],env:"CREATE_MANIFEST"},R={option:["--manifest-file-prefix <manifestFilePrefix>","Mmanifest file prefix"],env:"ENCRYPTION_MANIFEST_FILE"};var We={decrypt:{options:{configFile:x,envFile:S,secFile:N,createManifest:M,manifestFilePrefix:R,yes:$},description:"Decrypt a sec file",helpText:`Examples:
2
2
 
3
3
 
4
4
  Decrypt .sec file to .env file
@@ -130,39 +130,39 @@ $ dotsec run --with-sec echo "hello world"
130
130
  Run a command with a specific .sec file
131
131
 
132
132
  $ dotsec run --with-sec --sec-file .sec.dev echo "hello world"
133
- `}},ge=Ye;var ze={...le,...fe,...de,...pe,...ge,...me},Qe=n=>{if(Array.isArray(n)){let[o,s,t]=n;return{flags:o,description:s,defaultValue:t}}else{if("option"in n){let[o,s,t]=n.option;return{flags:o,description:s,defaultValue:t,env:n.env}}return n}},ue=(n,o)=>{let s=o?.dotsecConfig?.defaults?.options?.[o?.optionKey],t=Qe(n),e=new ye.Option(t.flags,t.description);return t.fn&&e.argParser(t.fn),t.defaultValue&&e.default(s||t.defaultValue),t.env&&e.env(t.env),o.required&&e.makeOptionMandatory(!0),t.choices&&e.choices(t.choices),e},P=n=>{let{program:o,commandName:s,dotsecConfig:t}=n,e=ze[s||o.name()];if(e){let{options:i,requiredOptions:c,description:l,usage:a,helpText:r}=e;i&&Object.keys(i).forEach(f=>{let m=i[f],d=ue(m,{dotsecConfig:t,optionKey:f});o.addOption(d)}),c&&Object.keys(c).forEach(f=>{let m=c[f],d=ue(m,{required:!0,dotsecConfig:t,optionKey:f});o.addOption(d)}),l&&o.description(l),a&&o.usage(a),r&&o.description(r)}};var Oe=require("dotenv"),Xe=async(n,o)=>{let{dotsecConfig:s,decryptHandlers:t}=o,e=n.enablePositionalOptions().passThroughOptions().command("decrypt").action(async(c,l)=>{try{let{envFile:a,secFile:r,engine:f,createManifest:m,manifestFile:d,yes:p}=l.optsWithGlobals(),O=f||s?.defaults?.encryptionEngine,u=(t||[]).find(h=>h.triggerOptionValue===O);if(!u)throw new Error(`No decryption plugin found, available decryption engine(s): ${o.decryptHandlers.map(h=>`--${h.triggerOptionValue}`).join(", ")}`);console.log("Decrypting with",C(u.encryptionEngineName||u.triggerOptionValue),"engine");let g=[...Object.keys(u.options||{}),...Object.keys(u.requiredOptions||{})],D=Object.fromEntries(g.map(h=>[h,c[h]])),v=await V(r),E=await u.handler({ciphertext:v,...D}),j=await A({filePath:a,skip:p});if((j===void 0||j.overwrite===!0)&&(await I(a,E),console.log(`Wrote plaintext contents of ${C(r)} file to ${C(a)}`)),m||s?.defaults?.options?.createManifest){let h=(0,Oe.parse)(E),y=`# Dotsec decryption manifest
133
+ `}},ue=Ye;var ze={...le,...fe,...de,...pe,...ue,...me},Qe=t=>{if(Array.isArray(t)){let[o,s,i]=t;return{flags:o,description:s,defaultValue:i}}else{if("option"in t){let[o,s,i]=t.option;return{flags:o,description:s,defaultValue:i,env:t.env}}return t}},ge=(t,o)=>{let s=o?.dotsecConfig?.defaults?.options?.[o?.optionKey],i=Qe(t),e=new ye.Option(i.flags,i.description);return i.fn&&e.argParser(i.fn),i.defaultValue&&e.default(s||i.defaultValue),i.env&&e.env(i.env),o.required&&e.makeOptionMandatory(!0),i.choices&&e.choices(i.choices),e},P=t=>{let{program:o,commandName:s,dotsecConfig:i}=t,e=ze[s||o.name()];if(e){let{options:n,requiredOptions:p,description:l,usage:c,helpText:r}=e;n&&Object.keys(n).forEach(d=>{let m=n[d],g=ge(m,{dotsecConfig:i,optionKey:d});o.addOption(g)}),p&&Object.keys(p).forEach(d=>{let m=p[d],g=ge(m,{required:!0,dotsecConfig:i,optionKey:d});o.addOption(g)}),l&&o.description(l),c&&o.usage(c),r&&o.description(r)}};var Oe=require("dotenv"),Xe=async(t,o)=>{let{dotsecConfig:s,decryptHandlers:i}=o,e=t.enablePositionalOptions().passThroughOptions().command("decrypt").action(async(p,l)=>{try{let{envFile:c,secFile:r,engine:d,createManifest:m,manifestFile:g,yes:a}=l.optsWithGlobals(),u=d||s?.defaults?.encryptionEngine,f=(i||[]).find(v=>v.triggerOptionValue===u);if(!f)throw new Error(`No decryption plugin found, available decryption engine(s): ${o.decryptHandlers.map(v=>`--${v.triggerOptionValue}`).join(", ")}`);console.log("Decrypting with",h(f.encryptionEngineName||f.triggerOptionValue),"engine");let C=[...Object.keys(f.options||{}),...Object.keys(f.requiredOptions||{})],y=Object.fromEntries(C.map(v=>[v,p[v]])),E=await V(r),w=await f.handler({ciphertext:E,...y}),j=await A({filePath:c,skip:a});if((j===void 0||j.overwrite===!0)&&(await I(c,w),console.log(`Wrote plaintext contents of ${h(r)} file to ${h(c)}`)),m||s?.defaults?.options?.createManifest){let v=(0,Oe.parse)(w),O=`# Dotsec decryption manifest
134
134
 
135
135
  ## Overview
136
136
 
137
- - plaintext source: ${a}
137
+ - plaintext source: ${c}
138
138
  - ciphertext target: ${r}
139
139
  - created: ${new Date().toUTCString()}
140
- - Decryption engine: ${u.encryptionEngineName||u.triggerOptionValue}
141
- - Decryption engine options: ${JSON.stringify(D)}
140
+ - Decryption engine: ${f.encryptionEngineName||f.triggerOptionValue}
141
+ - Decryption engine options: ${JSON.stringify(y)}
142
142
 
143
143
  ## Variables
144
144
 
145
- | Key |
146
- | --- |
147
- ${Object.keys(h).map(H=>`| \`${H} \`| `).join(`
145
+ | Key |
146
+ | --- |
147
+ ${Object.keys(v).map(H=>`| \`${H} \`| `).join(`
148
148
  `)}
149
- `,b=d||`${a}.decryption-manifest.md`;await I(b,y),console.log(`Wrote manifest of ${C(a)} file to ${C(b)}`)}}catch(a){console.error(C(a.message)),l.help()}});o.decryptHandlers.map(c=>{let{options:l,requiredOptions:a}=c;F(l,e),F(a,e,!0)});let i=o.decryptHandlers.map(c=>c.triggerOptionValue);return e.option("--engine <engine>",`Encryption engine${i.length>0?"s":""} to use: ${i.length===1?i[0]:i.join(", ")}`,i.length===1?i[0]:void 0),P({program:e,dotsecConfig:s}),e},Ce=Xe;var he=require("dotenv"),Ze=async(n,o)=>{let{encryptHandlers:s,dotsecConfig:t}=o,e=n.enablePositionalOptions().passThroughOptions().command("encrypt").action(async(l,a)=>{try{let{envFile:r,secFile:f,engine:m,createManifest:d,manifestFile:p,yes:O}=a.optsWithGlobals(),u=m||t?.defaults?.encryptionEngine,g=(s||[]).find(y=>y.triggerOptionValue===u);if(!g)throw new Error(`No encryption plugin found, available encryption engine(s): ${o.encryptHandlers.map(y=>y.triggerOptionValue).join(", ")}`);let D=[...Object.keys(g.options||{}),...Object.keys(g.requiredOptions||{})],v=Object.fromEntries(D.map(y=>[y,l[y]])),E=await V(r),j=await g.handler({plaintext:E,...v}),h=await A({filePath:f,skip:O});if((h===void 0||h.overwrite===!0)&&(await I(f,j),console.log(`Wrote encrypted contents of ${C(r)} file to ${C(f)}`),d||t?.defaults?.options?.createManifest)){let y=(0,he.parse)(E),b=`# Dotsec encryption manifest
149
+ `,b=g||`${c}.decryption-manifest.md`;await I(b,O),console.log(`Wrote manifest of ${h(c)} file to ${h(b)}`)}}catch(c){console.error(h(c.message)),l.help()}});o.decryptHandlers.map(p=>{let{options:l,requiredOptions:c}=p;F(l,e),F(c,e,!0)});let n=o.decryptHandlers.map(p=>p.triggerOptionValue);return e.option("--engine <engine>",`Encryption engine${n.length>0?"s":""} to use: ${n.length===1?n[0]:n.join(", ")}`,n.length===1?n[0]:void 0),P({program:e,dotsecConfig:s}),e},Ce=Xe;var he=require("dotenv"),Ze=async(t,o)=>{let{encryptHandlers:s,dotsecConfig:i}=o,e=t.enablePositionalOptions().passThroughOptions().command("encrypt").action(async(l,c)=>{try{let{envFile:r,secFile:d,engine:m,createManifest:g,manifestFile:a,yes:u}=c.optsWithGlobals(),f=m||i?.defaults?.encryptionEngine,C=(s||[]).find(O=>O.triggerOptionValue===f);if(!C)throw new Error(`No encryption plugin found, available encryption engine(s): ${o.encryptHandlers.map(O=>O.triggerOptionValue).join(", ")}`);let y=[...Object.keys(C.options||{}),...Object.keys(C.requiredOptions||{})],E=Object.fromEntries(y.map(O=>[O,l[O]])),w=await V(r),j=await C.handler({plaintext:w,...E}),v=await A({filePath:d,skip:u});if((v===void 0||v.overwrite===!0)&&(await I(d,j),console.log(`Wrote encrypted contents of ${h(r)} file to ${h(d)}`),g||i?.defaults?.options?.createManifest)){let O=(0,he.parse)(w),b=`# Dotsec encryption manifest
150
150
 
151
151
  ## Overview
152
152
 
153
153
  - plaintext source: ${r}
154
- - ciphertext target: ${f}
154
+ - ciphertext target: ${d}
155
155
  - created: ${new Date().toUTCString()}
156
- - encryption engine: ${g.encryptionEngineName||g.triggerOptionValue}
157
- - encryption engine options: ${JSON.stringify(v)}
156
+ - encryption engine: ${C.encryptionEngineName||C.triggerOptionValue}
157
+ - encryption engine options: ${JSON.stringify(E)}
158
158
 
159
159
  ## Variables
160
160
 
161
161
  | Key |
162
162
  | --- |
163
- ${Object.keys(y).map(Ne=>`| \`${Ne} \`| `).join(`
163
+ ${Object.keys(O).map(Ne=>`| \`${Ne} \`| `).join(`
164
164
  `)}
165
- `,H=p||`${f}.encryption-manifest.md`;await I(H,b),console.log(`Wrote manifest of ${C(r)} file to ${C(H)}`)}}catch(r){console.error(C(r.message)),a.help()}});o.encryptHandlers.map(l=>{let{options:a,requiredOptions:r}=l;F(a,e),F(r,e,!0)});let i=o.encryptHandlers.map(l=>l.triggerOptionValue),c=o.encryptHandlers.map(l=>l.encryptionEngineName);return e.option("--engine <engine>",`Encryption engine${i.length>0?"s":""}: ${i.length===1?i[0]:i.join(", ")}`,i.length===1?i[0]:void 0),P({program:e,dotsecConfig:t}),e.description(`Encrypt .env file using ${c.join(", ")}`),e},ve=Ze;var Ee=w(require("path")),en=async(n,o)=>{let{dotsecConfig:s}=o,t=n.enablePositionalOptions().passThroughOptions().command("init").action(async(e,i)=>{let{configFile:c="dotsec.config.ts",yes:l}=i.optsWithGlobals();try{let a=await V(Ee.default.resolve(__dirname,"../../src/templates/dotsec.config.ts")),r=await A({filePath:c,skip:l});(r===void 0||r.overwrite===!0)&&(await I(c,a),console.log(`Wrote config file to ${C(c)}`))}catch(a){i.error(a)}});return P({program:t,dotsecConfig:s}),t},we=en;var De=require("dotenv"),xe=require("dotenv-expand"),U=w(require("fs")),nn=async(n,o)=>{let{dotsecConfig:s,handlers:t}=o,e=n.enablePositionalOptions().passThroughOptions().command("push").action(async(r,f)=>{try{let{using:m,envFile:d,secFile:p,engine:O,yes:u}=f.optsWithGlobals(),g=O||s?.defaults?.encryptionEngine,D=(t||[]).find(y=>y.decrypt?.triggerOptionValue===g)?.decrypt,v=(t||[]).find(y=>y.push?.triggerOptionValue===g)?.push;if(!v)throw new Error("No push plugin found!");let E=[...Object.keys(D?.options||{}),...Object.keys(D?.requiredOptions||{}),...Object.keys(v?.options||{}),...Object.keys(v?.requiredOptions||{})],j=Object.fromEntries(E.map(y=>[y,r[y]])),h;if(m==="env"){if(!d)throw new Error("No dotenv file specified in --env-file option");h=U.default.readFileSync(d,"utf8")}else{if(!p)throw new Error("No dotsec file specified in --sec-file option");if(!D)throw new Error(`No decryption plugin found, available decryption engine(s): ${t.map(b=>`--${b.decrypt?.triggerOptionValue}`).join(", ")}`);let y=U.default.readFileSync(p,"utf8");h=await D.handler({ciphertext:y,...j})}if(h){let y=(0,De.parse)(h),b=(0,xe.expand)({ignoreProcessEnv:!0,parsed:{...process.env,...y}});b.parsed&&await v.handler({push:b.parsed,yes:u,...j})}else throw new Error("No .env or .sec file provided")}catch(m){console.error(m),process.exit(1)}});P({program:e,dotsecConfig:s});let i=o.handlers.map(({decrypt:r})=>r.triggerOptionValue);e.option("--engine <engine>",`Encryption engine${i.length>0?"s":""} to use: ${i.length===1?i[0]:i.join(", ")}`,i.length===1?i[0]:void 0);let c={};o.handlers.forEach(r=>{Object.keys(r).map(f=>{let{options:m,requiredOptions:d}=r[f];Object.keys(m||{}).forEach(p=>{c[p]=Array.isArray(m[p])?m[p]:{...c[p],...m[p]}}),Object.keys(d||{}).forEach(p=>{c[p]=Array.isArray(d[p])?d[p]:{...c[p],...d[p],required:!0}})})});let l=[],a=[];return t.forEach(r=>{r.push?.description&&a.push(r.push.description),r.push?.usage&&l.push(r.push.usage)}),a.length>0&&e.description(a.join(`
165
+ `,H=a||`${d}.encryption-manifest.md`;await I(H,b),console.log(`Wrote manifest of ${h(r)} file to ${h(H)}`)}}catch(r){console.error(h(r.message)),c.help()}});o.encryptHandlers.map(l=>{let{options:c,requiredOptions:r}=l;F(c,e),F(r,e,!0)});let n=o.encryptHandlers.map(l=>l.triggerOptionValue),p=o.encryptHandlers.map(l=>l.encryptionEngineName);return e.option("--engine <engine>",`Encryption engine${n.length>0?"s":""}: ${n.length===1?n[0]:n.join(", ")}`,n.length===1?n[0]:void 0),P({program:e,dotsecConfig:i}),e.description(`Encrypt .env file using ${p.join(", ")}`),e},ve=Ze;var Ee=D(require("path")),en=async(t,o)=>{let{dotsecConfig:s}=o,i=t.enablePositionalOptions().passThroughOptions().command("init").action(async(e,n)=>{let{configFile:p="dotsec.config.ts",yes:l}=n.optsWithGlobals();try{let c=await V(Ee.default.resolve(__dirname,"../../src/templates/dotsec.config.ts")),r=await A({filePath:p,skip:l});(r===void 0||r.overwrite===!0)&&(await I(p,c),console.log(`Wrote config file to ${h(p)}`))}catch(c){n.error(c)}});return P({program:i,dotsecConfig:s}),i},we=en;var De=require("dotenv"),xe=require("dotenv-expand"),U=D(require("fs")),nn=async(t,o)=>{let{dotsecConfig:s,handlers:i}=o,e=t.enablePositionalOptions().passThroughOptions().command("push").action(async(r,d)=>{try{let{using:m,envFile:g,secFile:a,engine:u,yes:f}=d.optsWithGlobals(),C=u||s?.defaults?.encryptionEngine,y=(i||[]).find(O=>O.decrypt?.triggerOptionValue===C)?.decrypt,E=(i||[]).find(O=>O.push?.triggerOptionValue===C)?.push;if(!E)throw new Error("No push plugin found!");let w=[...Object.keys(y?.options||{}),...Object.keys(y?.requiredOptions||{}),...Object.keys(E?.options||{}),...Object.keys(E?.requiredOptions||{})],j=Object.fromEntries(w.map(O=>[O,r[O]])),v;if(m==="env"){if(!g)throw new Error("No dotenv file specified in --env-file option");v=U.default.readFileSync(g,"utf8")}else{if(!a)throw new Error("No dotsec file specified in --sec-file option");if(!y)throw new Error(`No decryption plugin found, available decryption engine(s): ${i.map(b=>`--${b.decrypt?.triggerOptionValue}`).join(", ")}`);let O=U.default.readFileSync(a,"utf8");v=await y.handler({ciphertext:O,...j})}if(v){let O=(0,De.parse)(v),b=(0,xe.expand)({ignoreProcessEnv:!0,parsed:{...process.env,...O}});b.parsed&&await E.handler({push:b.parsed,yes:f,...j})}else throw new Error("No .env or .sec file provided")}catch(m){console.error(m),process.exit(1)}});P({program:e,dotsecConfig:s});let n=o.handlers.map(({decrypt:r})=>r.triggerOptionValue);e.option("--engine <engine>",`Encryption engine${n.length>0?"s":""} to use: ${n.length===1?n[0]:n.join(", ")}`,n.length===1?n[0]:void 0);let p={};o.handlers.forEach(r=>{Object.keys(r).map(d=>{let{options:m,requiredOptions:g}=r[d];Object.keys(m||{}).forEach(a=>{p[a]=Array.isArray(m[a])?m[a]:{...p[a],...m[a]}}),Object.keys(g||{}).forEach(a=>{p[a]=Array.isArray(g[a])?g[a]:{...p[a],...g[a],required:!0}})})});let l=[],c=[];return i.forEach(r=>{r.push?.description&&c.push(r.push.description),r.push?.usage&&l.push(r.push.usage)}),c.length>0&&e.description(c.join(`
166
166
  `)),l.length>0&&e.usage(l.join(`
167
- `)),F(Object.fromEntries(Object.entries(c).filter(([r,f])=>f.required!==!0)),e),F(Object.fromEntries(Object.entries(c).filter(([r,f])=>f.required===!0)),e,!0),e},Fe=nn;var K=w(require("fs")),Pe=require("dotenv"),$e=require("dotenv-expand");var be=require("child_process"),tn=(n,o)=>{let{dotsecConfig:s,decryptHandlers:t}=o||{},e=t!==void 0&&t.length>0,i=n.command("run <command...>").allowUnknownOption(!0).enablePositionalOptions().passThroughOptions().showHelpAfterError(!0).action(async(c,l,a)=>{try{let{envFile:r,using:f,secFile:m,engine:d}=a.optsWithGlobals(),p;if(f==="env"||e===!1){if(!r)throw new Error("No dotenv file specified in --env-file option");p=K.default.readFileSync(r,"utf8")}else if(f==="sec"){if(!m)throw new Error("No dotsec file specified in --sec-file option");let O=d||s?.defaults?.encryptionEngine,u=(t||[]).find(E=>E.triggerOptionValue===O);if(!u)throw new Error(`No decryption plugin found, available decryption engine(s): ${(t||[]).map(E=>`--${E.triggerOptionValue}`).join(", ")}`);let g=[...Object.keys(u.options||{}),...Object.keys(u.requiredOptions||{})],D=Object.fromEntries(g.map(E=>[E,l[E]])),v=K.default.readFileSync(m,"utf8");p=await u.handler({ciphertext:v,...D})}if(p){let O=(0,Pe.parse)(p),u=(0,$e.expand)({ignoreProcessEnv:!0,parsed:{...process.env,...O}}),[g,...D]=c,v=(0,be.spawnSync)(g,[...D],{stdio:"inherit",shell:!1,encoding:"utf-8",env:{...u.parsed,...process.env,__DOTSEC_ENV__:JSON.stringify(Object.keys(O))}});v.status!==0&&process.exit(v.status||1)}else throw new Error("No .env or .sec file provided")}catch(r){console.error(C(r.message)),a.help()}});if(P({program:i,commandName:e?"run":"runEnvOnly",dotsecConfig:s}),e){t?.map(l=>{let{options:a,requiredOptions:r}=l;F(a,i),F(r,i,!0)});let c=t?.map(l=>l.triggerOptionValue);i.option("--engine <engine>",`Encryption engine${c.length>0?"s":""}: ${c.join(", "),c.length===1?c[0]:void 0}`)}return i},Se=tn;var _e=w(require("ajv")),Ie=w(require("yargs-parser")),on={keyword:"separator",type:"string",metaSchema:{type:"string",description:"value separator"},modifying:!0,valid:!0,errors:!1,compile:n=>(o,s)=>{if(s){let{parentData:t,parentDataProperty:e}=s;return t[e]=o===""?[]:o.split(n),!0}else return!1}},T=new Te.Command;(async()=>{let n=(0,Ie.default)(process.argv),o=[];n.plugin&&(Array.isArray(n.plugin)?o.push(...n.plugin):o.push(n.plugin));let s=[...Array.isArray(n.configFile)?n.configFile:[n.configFile],...Array.isArray(n.c)?n.c:[n.c]][0]||process.env.DOTSEC_CONFIG_FILE,{contents:t={}}=await ne(s),{defaults:e={},push:i,plugins:c}=t;T.name("dotsec").description(".env, but secure").version("1.0.0").passThroughOptions().action((d,p)=>{p.help()}),P({program:T,dotsecConfig:t});let l=new _e.default({allErrors:!0,removeAdditional:!0,useDefaults:!0,coerceTypes:!0,allowUnionTypes:!0,addUsedSchema:!1,keywords:[on]}),a={};if(c)for(let d of c)e?.plugins?.[d]||(e.plugins={...e.plugins,[d]:{}});if(o.length>0)for(let d of o){let O=await(await W({name:d}))({dotsecConfig:t,ajv:l,configFile:s});a[O.name]=d,o.length===1&&(t.defaults={...t.defaults,encryptionEngine:String(O.name),plugins:{...t.defaults?.plugins,[O.name]:{...t.defaults?.plugins?.[O.name]}}})}e?.encryptionEngine&&(e?.plugins?.[e.encryptionEngine]||(e.plugins={...e.plugins,[e.encryptionEngine]:{}})),e?.plugins&&Object.entries(e?.plugins).forEach(([d,p])=>{p?.name?a[d]=p?.name:a[d]=`@dotsec/plugin-${d}`}),Object.values(i||{}).forEach(d=>{Object.keys(d).forEach(p=>{a[p]||(a[p]=`@dotsec/plugin-${p}`)})});let r=[],f=[],m=[];for(let d of Object.keys(a)){let p=a[d],O=await W({name:p}),{addCliCommand:u,cliHandlers:g}=await O({ajv:l,dotsecConfig:t,configFile:s});g?.encrypt&&r.push(g.encrypt),g?.decrypt&&(f.push(g.decrypt),g?.push&&m.push({push:g.push,decrypt:g.decrypt})),u&&u({program:T})}r.length&&await ve(T,{dotsecConfig:t,encryptHandlers:r}),f.length&&await Ce(T,{dotsecConfig:t,decryptHandlers:f}),m.length&&await Fe(T,{dotsecConfig:t,handlers:m}),await we(T,{dotsecConfig:t}),await Se(T,{dotsecConfig:t,decryptHandlers:f}),await T.parse()})();
167
+ `)),F(Object.fromEntries(Object.entries(p).filter(([r,d])=>d.required!==!0)),e),F(Object.fromEntries(Object.entries(p).filter(([r,d])=>d.required===!0)),e,!0),e},Fe=nn;var K=D(require("fs")),Pe=require("dotenv"),$e=require("dotenv-expand");var be=require("child_process"),tn=(t,o)=>{let{dotsecConfig:s,decryptHandlers:i}=o||{},e=i!==void 0&&i.length>0,n=t.command("run <command...>").allowUnknownOption(!0).enablePositionalOptions().passThroughOptions().showHelpAfterError(!0).action(async(p,l,c)=>{try{let{envFile:r,using:d,secFile:m,engine:g}=c.optsWithGlobals(),a;if(d==="env"||e===!1){if(!r)throw new Error("No dotenv file specified in --env-file option");a=K.default.readFileSync(r,"utf8")}else if(d==="sec"){if(!m)throw new Error("No dotsec file specified in --sec-file option");let u=g||s?.defaults?.encryptionEngine,f=(i||[]).find(w=>w.triggerOptionValue===u);if(!f)throw new Error(`No decryption plugin found, available decryption engine(s): ${(i||[]).map(w=>`--${w.triggerOptionValue}`).join(", ")}`);let C=[...Object.keys(f.options||{}),...Object.keys(f.requiredOptions||{})],y=Object.fromEntries(C.map(w=>[w,l[w]])),E=K.default.readFileSync(m,"utf8");a=await f.handler({ciphertext:E,...y})}if(a){let u=(0,Pe.parse)(a),f=(0,$e.expand)({ignoreProcessEnv:!0,parsed:{...process.env,...u}}),[C,...y]=p,E=(0,be.spawnSync)(C,[...y],{stdio:"inherit",shell:!1,encoding:"utf-8",env:{...f.parsed,...process.env,__DOTSEC_ENV__:JSON.stringify(Object.keys(u))}});E.status!==0&&process.exit(E.status||1)}else throw new Error("No .env or .sec file provided")}catch(r){console.error(h(r.message)),c.help()}});if(P({program:n,commandName:e?"run":"runEnvOnly",dotsecConfig:s}),e){i?.map(l=>{let{options:c,requiredOptions:r}=l;F(c,n),F(r,n,!0)});let p=i?.map(l=>l.triggerOptionValue);n.option("--engine <engine>",`Encryption engine${p.length>0?"s":""}: ${p.join(", "),p.length===1?p[0]:void 0}`)}return n},Se=tn;var _e=D(require("ajv")),Ie=D(require("yargs-parser")),on={keyword:"separator",type:"string",metaSchema:{type:"string",description:"value separator"},modifying:!0,valid:!0,errors:!1,compile:t=>(o,s)=>{if(s){let{parentData:i,parentDataProperty:e}=s;return i[e]=o===""?[]:o.split(t),!0}else return!1}},T=new Te.Command;(async()=>{let t=(0,Ie.default)(process.argv),o=[];t.plugin&&(Array.isArray(t.plugin)?o.push(...t.plugin):o.push(t.plugin));let s=t.configFile||t.c,i=[...Array.isArray(s)?s:[s]][0]||process.env.DOTSEC_CONFIG_FILE,{contents:e={}}=await ne(i),{defaults:n={},push:p,plugins:l}=e;T.name("dotsec").description(".env, but secure").version("1.0.0").passThroughOptions().action((a,u)=>{u.help()}),P({program:T,dotsecConfig:e});let c=new _e.default({allErrors:!0,removeAdditional:!0,useDefaults:!0,coerceTypes:!0,allowUnionTypes:!0,addUsedSchema:!1,keywords:[on]}),r={};if(l)for(let a of l)n?.plugins?.[a]||(n.plugins={...n.plugins,[a]:{}});if(o.length>0)for(let a of o){let f=await(await W({name:a}))({dotsecConfig:e,ajv:c,configFile:i});r[f.name]=a,o.length===1&&(e.defaults={...e.defaults,encryptionEngine:String(f.name),plugins:{...e.defaults?.plugins,[f.name]:{...e.defaults?.plugins?.[f.name]}}})}n?.encryptionEngine&&(n?.plugins?.[n.encryptionEngine]||(n.plugins={...n.plugins,[n.encryptionEngine]:{}})),n?.plugins&&Object.entries(n?.plugins).forEach(([a,u])=>{u?.name?r[a]=u?.name:r[a]=`@dotsec/plugin-${a}`}),Object.values(p||{}).forEach(a=>{Object.keys(a).forEach(u=>{r[u]||(r[u]=`@dotsec/plugin-${u}`)})});let d=[],m=[],g=[];for(let a of Object.keys(r)){let u=r[a],f=await W({name:u}),{addCliCommand:C,cliHandlers:y}=await f({ajv:c,dotsecConfig:e,configFile:i});y?.encrypt&&d.push(y.encrypt),y?.decrypt&&(m.push(y.decrypt),y?.push&&g.push({push:y.push,decrypt:y.decrypt})),C&&C({program:T})}d.length&&await ve(T,{dotsecConfig:e,encryptHandlers:d}),m.length&&await Ce(T,{dotsecConfig:e,decryptHandlers:m}),g.length&&await Fe(T,{dotsecConfig:e,handlers:g}),await we(T,{dotsecConfig:e}),await Se(T,{dotsecConfig:e,decryptHandlers:m}),await T.parse()})();
168
168
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":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/cli/commands/init.ts","../../src/cli/commands/push.ts","../../src/cli/commands/run.ts"],"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\tconst configFile =\n\t\t[\n\t\t\t...(Array.isArray(parsedOptions.configFile)\n\t\t\t\t? parsedOptions.configFile\n\t\t\t\t: [parsedOptions.configFile]),\n\t\t\t...(Array.isArray(parsedOptions.c) ? parsedOptions.c : [parsedOptions.c]),\n\t\t]?.[0] || process.env.DOTSEC_CONFIG_FILE;\n\n\tconst { contents: dotsecConfig = {} } = await getMagicalConfig(configFile);\n\tconst { defaults = {}, push: pushVariables, plugins } = dotsecConfig;\n\tprogram\n\t\t.name(\"dotsec\")\n\t\t.description(\".env, but secure\")\n\t\t.version(\"1.0.0\")\n\t\t.passThroughOptions()\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\n\t// check plugins\n\tif (plugins) {\n\t\tfor (const pluginName of plugins) {\n\t\t\tif (!defaults?.plugins?.[pluginName]) {\n\t\t\t\tdefaults.plugins = {\n\t\t\t\t\t...defaults.plugins,\n\t\t\t\t\t[pluginName]: {},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\t// check argv\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?.name) {\n\t\t\t\t\tpluginModules[pluginName] = pluginModule?.name;\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\t}\n\n\t// add other commands\n\tawait addInitCommand(program, { dotsecConfig: dotsecConfig });\n\tawait addRunCommand(program, {\n\t\tdotsecConfig: dotsecConfig,\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\tdefaults: {\n\t\t// encryptionEngine: \"pke\",\n\t\t// plugins: {\n\t\t// \tpke: {},\n\t\t// },\n\t},\n};\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\tchoices?: 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, choices, 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\tchoices,\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\tif (optionProps.choices) {\n\t\t\t\t\tnewOption.choices(optionProps.choices);\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 from \"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 pushCommandDefaults from \"./push\";\nimport runCommandDefaults from \"./run\";\nimport {\n\tCommandOption,\n\tDeepExpandedCommandOption,\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};\n\nconst expandCommandOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n): DeepExpandedCommandOption => {\n\tif (Array.isArray(commandOption)) {\n\t\tconst [flags, description, defaultValue] = commandOption;\n\t\tconst optionProps = {\n\t\t\tflags,\n\t\t\tdescription,\n\t\t\tdefaultValue,\n\t\t};\n\t\treturn optionProps;\n\t} else {\n\t\tif (\"option\" in commandOption) {\n\t\t\tconst [flags, description, defaultValue] = commandOption.option;\n\t\t\tconst optionProps = {\n\t\t\t\tflags,\n\t\t\t\tdescription,\n\t\t\t\tdefaultValue,\n\t\t\t\tenv: commandOption.env,\n\t\t\t};\n\t\t\treturn optionProps;\n\t\t}\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 defaultOptionValueFromConfig =\n\t\toptions?.dotsecConfig?.defaults?.options?.[options?.optionKey];\n\tconst optionProps = expandCommandOption(commandOption);\n\n\tconst newOption = new Option(optionProps.flags, optionProps.description);\n\tif (optionProps.fn) {\n\t\tnewOption.argParser(optionProps.fn);\n\t}\n\tif (optionProps.defaultValue) {\n\t\tnewOption.default(defaultOptionValueFromConfig || optionProps.defaultValue);\n\t}\n\tif (optionProps.env) {\n\t\tnewOption.env(optionProps.env);\n\t}\n\tif (options.required) {\n\t\tnewOption.makeOptionMandatory(true);\n\t}\n\tif (optionProps.choices) {\n\t\tnewOption.choices(optionProps.choices);\n\t}\n\n\treturn newOption;\n};\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.usage(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 usingOption: ExpandedCommandOption = {\n\tflags: \"--using <using>\",\n\tdescription: \"Wether to use a dot env file or a dot sec file\",\n\tchoices: [\"env\", \"sec\"],\n\tenv: \"DOTSEC_USING\",\n};\n\nexport const usingNoEncryptionEngineOption: ExpandedCommandOption = {\n\tflags: \"--using <using>\",\n\tdescription: \"Wether to use a dot env file or a dot sec file\",\n\tchoices: [\"env\"],\n\tenv: \"DOTSEC_USING\",\n};\n\nexport const yesOption: ExpandedCommandOption = {\n\toption: [\"--yes\", \"Skip confirmation prompts\"],\n};\n\nexport const verboseOption: ExpandedCommandOption = {\n\toption: [\"--verbose\", \"Verbose output\"],\n};\n\nexport const configFileOption: ExpandedCommandOption = {\n\toption: [\"-c, --config-file, --configFile <configFile>\", \"Config file\"],\n\tenv: \"DOTSEC_CONFIG_FILE\",\n};\n\nexport const pluginOption: ExpandedCommandOption = {\n\toption: [\"--plugin <plugin>\", \"Comma-separated list of plugins to use\"],\n\tenv: \"DOTSEC_PLUGIN\",\n};\n\nexport const engineOption: ExpandedCommandOption = {\n\toption: [\"--engine <engine>\", \"Encryption engine to use\"],\n\tenv: \"DOTSEC_ENGINE\",\n};\n\nexport const createManifestOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--create-manifest\",\n\t\t\"Create a markdown manifest file. See the --manifest-file option for more information.\",\n\t],\n\tenv: \"CREATE_MANIFEST\",\n};\n\nexport const manifestFilePrefixOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--manifest-file-prefix <manifestFilePrefix>\",\n\t\t\"Mmanifest file prefix\",\n\t],\n\tenv: \"ENCRYPTION_MANIFEST_FILE\",\n};\n","import {\n\tconfigFileOption,\n\tcreateManifestOption,\n\tenvFileOption,\n\tmanifestFilePrefixOption,\n\tsecFileOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst decryptCommandDefaults: DotSecCommandsDefaults = {\n\tdecrypt: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tcreateManifest: createManifestOption,\n\t\t\tmanifestFilePrefix: manifestFilePrefixOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\tdescription: \"Decrypt a sec file\",\n\t\thelpText: `Examples:\n\n\nDecrypt .sec file to .env file\n\n$ npx dotsec decrypt\n\n\nSpecify a different .sec file\n\n$ npx dotsec decrypt --sec-file .sec.dev\n$ SEC_FILE=.sec.dev npx dotsec decrypt\n\nSpecify a different .env file\n\n$ npx dotsec decrypt --env-file .env.dev\n$ ENV_FILE=.env.dev npx dotsec decrypt\n\nWrite a manifest markdown file\n\n$ npx dotsec decrypt --create-manifest\n$ CREATE_MANIFEST=true npx dotsec decrypt\n\nSpecify a different manifest file\n\n$ npx dotsec decrypt --manifest-file .manifest.dev\n$ MANIFEST_FILE=decryption-manifest.md npx dotsec decrypt\n`,\n\t},\n};\n\nexport default decryptCommandDefaults;\n","import { configFileOption, pluginOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst dotsecCommandDefaults: DotSecCommandsDefaults = {\n\tdotsec: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tplugin: pluginOption,\n\t\t},\n\t},\n};\n\nexport default dotsecCommandDefaults;\n","import {\n\tconfigFileOption,\n\tcreateManifestOption,\n\tenvFileOption,\n\tmanifestFilePrefixOption,\n\tsecFileOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst encryptCommandDefaults: DotSecCommandsDefaults = {\n\tencrypt: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tcreateManifest: createManifestOption,\n\t\t\tmanifestFile: manifestFilePrefixOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\tdescription: \"Encrypt an env file\",\n\t\thelpText: `Examples:\n\n\nEncrypt .env file to .sec file\n\n$ npx dotsec encrypt\n\n\nSpecify a different .env file\n\n$ npx dotsec encrypt --env-file .env.dev\n$ ENV_FILE=.env.dev npx dotsec encrypt\n\n\nSpecify a different .sec file\n\n$ npx dotsec encrypt --sec-file .sec.dev\n$ SEC_FILE=.sec.dev npx dotsec encrypt\n\n\nWrite a manifest markdown file\n\n$ npx dotsec encrypt --create-manifest\n$ CREATE_MANIFEST=true npx dotsec encrypt\n\n\nSpecify a different manifest file\n\n$ npx dotsec encrypt --manifest-file manifest.dev\n$ MANIFEST_FILE=encryption-manifest.md npx dotsec encrypt\n`,\n\t},\n};\n\nexport default encryptCommandDefaults;\n","import { configFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst initCommandDefaults: DotSecCommandsDefaults = {\n\tinit: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\tdescription:\n\t\t\t\"Initialize a dotsec project by creating a dotsec.config.ts file.\",\n\t\thelpText: `Examples:\n\nCreate a dotsec.config.ts file in the current directory\n\n$ npx dotsec init\n\n\nOverwrite an existing dotsec.config.ts file in the current directory\n\n$ npx dotsec init --yes\n\n\nCreate a dotsec config file in the current directory with a specific config file name\n\nBy specifying the --config-file option, you can create a dotsec config file with a specific name.\n\n$ npx dotsec init --config-file dotsec.config.ts\n\n$ DOTSEC_CONFIG_FILE=my.config.ts npx dotsec init\n`,\n\t},\n};\n\nexport default initCommandDefaults;\n","import {\n\tconfigFileOption,\n\tenvFileOption,\n\tsecFileOption,\n\tusingOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst pushCommandDefaults: DotSecCommandsDefaults = {\n\tpush: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\tusing: usingOption,\n\t\t},\n\t\tdescription: \"Push variables from env or sec file to a remote\",\n\t\thelpText: `Examples:\n\nPush variables from .env file to remote\n\n$ npx dotsec push --using env\n$ DOTSEC_USING=env npx dotsec push\n\n\nPush variables from .sec file to remote\n\n$ npx dotsec push --using sec\n$ DOTSEC_USING=sec npx dotsec push\n`,\n\t},\n};\n\nexport default pushCommandDefaults;\n","import {\n\tconfigFileOption,\n\tengineOption,\n\tenvFileOption,\n\tsecFileOption,\n\tusingNoEncryptionEngineOption,\n\tusingOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n/*\n\nrun --env-file=.env --sec-file=.sec --with=env-file\n\n*/\nconst runCommandDefaults: DotSecCommandsDefaults = {\n\trunEnvOnly: {\n\t\tusage: \"--using env [commandArgs...]\",\n\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tyes: yesOption,\n\t\t\tengine: engineOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\tusing: usingNoEncryptionEngineOption,\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\t\t\nRun a command with a .env file\n\t\t\n$ npx dotsec run --using env node -e \\\"console.log(process.env)\\\"\n\n\nRun a command with a specific .env file\n\n$ npx dotsec run --using env --env-file .env node -e \\\"console.log(process.env)\\\"\n\n\nRun a command with a specific ENV_FILE variable\n\n$ ENV_FILE=.env.dev npx dotsec run --using env node -e \\\"console.log(process.env)\\\"\n\n\nYou can also specify 'using' as an environment variable\n\n$ DOTSEC_USING=env npx dotsec run node -e \\\"console.log(process.env)\\\"\n\t\t`,\n\t},\n\trun: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\tusing: usingOption,\n\t\t},\n\n\t\tusage: \"[--using env] [--using 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\t// push: {\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\";\nimport { parse } from \"dotenv\";\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\tcreateManifest,\n\t\t\t\t\tmanifestFile,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<DecryptCommandOptions>();\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\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\n\t\t\t\tif (createManifest || dotsecConfig?.defaults?.options?.createManifest) {\n\t\t\t\t\t// parse raw env contents into key value pairs using the dotenv package\n\t\t\t\t\tconst dotenvVars = parse(plaintext);\n\t\t\t\t\t// expand env vars\n\t\t\t\t\tconst markdownManifest = `# Dotsec decryption manifest \n\n## Overview\n\n- plaintext source: ${envFile}\n- ciphertext target: ${secFile}\n- created: ${new Date().toUTCString()}\n- Decryption engine: ${\n\t\t\t\t\t\tpluginCliDecrypt.encryptionEngineName ||\n\t\t\t\t\t\tpluginCliDecrypt.triggerOptionValue\n\t\t\t\t\t}\n- Decryption engine options: ${JSON.stringify(allOptionsValues)}\n\n## Variables\n\n| Key | \n| --- | \n${Object.keys(dotenvVars)\n\t.map((key) => {\n\t\treturn `| \\`${key} \\`| `;\n\t})\n\t.join(\"\\n\")}\n`;\n\n\t\t\t\t\t// write manifest file, don't prompt to overwrite\n\t\t\t\t\tconst manifestTargetFile =\n\t\t\t\t\t\tmanifestFile || `${envFile}.decryption-manifest.md`;\n\t\t\t\t\tawait writeContentsToFile(manifestTargetFile, markdownManifest);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote manifest of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\tmanifestTargetFile,\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\";\nimport { parse } from \"dotenv\";\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\tcreateManifest,\n\t\t\t\t\tmanifestFile,\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\n\t\t\t\t\tif (\n\t\t\t\t\t\tcreateManifest ||\n\t\t\t\t\t\tdotsecConfig?.defaults?.options?.createManifest\n\t\t\t\t\t) {\n\t\t\t\t\t\t// parse raw env contents into key value pairs using the dotenv package\n\t\t\t\t\t\tconst dotenvVars = parse(dotenvString);\n\t\t\t\t\t\t// expand env vars\n\t\t\t\t\t\tconst markdownManifest = `# Dotsec encryption manifest \n\n## Overview\n\n- plaintext source: ${envFile}\n- ciphertext target: ${secFile}\n- created: ${new Date().toUTCString()}\n- encryption engine: ${\n\t\t\t\t\t\t\tpluginCliEncrypt.encryptionEngineName ||\n\t\t\t\t\t\t\tpluginCliEncrypt.triggerOptionValue\n\t\t\t\t\t\t}\n- encryption engine options: ${JSON.stringify(allOptionsValues)}\n\n## Variables\n\n| Key | \n| --- | \n${Object.keys(dotenvVars)\n\t.map((key) => {\n\t\treturn `| \\`${key} \\`| `;\n\t})\n\t.join(\"\\n\")}\n`;\n\n\t\t\t\t\t\t// write manifest file, don't prompt to overwrite\n\t\t\t\t\t\tconst manifestTargetFile =\n\t\t\t\t\t\t\tmanifestFile || `${secFile}.encryption-manifest.md`;\n\t\t\t\t\t\tawait writeContentsToFile(manifestTargetFile, markdownManifest);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`Wrote manifest of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\t\tmanifestTargetFile,\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\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\tengines.length === 1 ? engines[0] : undefined,\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 {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { DotsecConfig, InitCommandOptions } from \"../../types\";\nimport { Command } from \"commander\";\n\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 = \"dotsec.config.ts\", yes } =\n\t\t\t\tcommand.optsWithGlobals<InitCommandOptions>();\n\t\t\ttry {\n\t\t\t\tconst configTemplate = await readContentsFromFile(\n\t\t\t\t\tpath.resolve(__dirname, \"../../src/templates/dotsec.config.ts\"),\n\t\t\t\t);\n\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, configTemplate);\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 { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport { PushCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport {\n\tDotsecCliOption,\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginPushHandler,\n} from \"../../types/plugin\";\nimport { setProgramOptions } from \"../options/index\";\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\tusing,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\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\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\tlet envContents: string | undefined;\n\n\t\t\t\tif (using === \"env\") {\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 {\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\tconst engines = options.handlers.map(\n\t\t({ decrypt }) => decrypt.triggerOptionValue,\n\t);\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\tconst allOptions: {\n\t\t[x: string]: DotsecCliOption & { required?: boolean };\n\t} = {};\n\toptions.handlers.forEach((handlers) => {\n\t\tObject.keys(handlers).map((handlerName) => {\n\t\t\tconst { options: cliOptions, requiredOptions } = handlers[handlerName];\n\t\t\tObject.keys(cliOptions || {}).forEach((key) => {\n\t\t\t\tallOptions[key] = Array.isArray(cliOptions[key])\n\t\t\t\t\t? cliOptions[key]\n\t\t\t\t\t: { ...allOptions[key], ...cliOptions[key] };\n\t\t\t});\n\t\t\tObject.keys(requiredOptions || {}).forEach((key) => {\n\t\t\t\tallOptions[key] = Array.isArray(requiredOptions[key])\n\t\t\t\t\t? requiredOptions[key]\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...allOptions[key],\n\t\t\t\t\t\t\t...requiredOptions[key],\n\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t };\n\t\t\t});\n\t\t});\n\t});\n\n\tconst usage: string[] = [];\n\tconst descriptions: string[] = [];\n\n\thandlers.forEach((handler) => {\n\t\tif (handler.push?.description) {\n\t\t\tdescriptions.push(handler.push.description);\n\t\t}\n\n\t\tif (handler.push?.usage) {\n\t\t\tusage.push(handler.push.usage);\n\t\t}\n\t});\n\n\tif (descriptions.length > 0) {\n\t\tsubProgram.description(descriptions.join(\"\\n\"));\n\t}\n\n\tif (usage.length > 0) {\n\t\tsubProgram.usage(usage.join(\"\\n\"));\n\t}\n\n\taddPluginOptions(\n\t\tObject.fromEntries(\n\t\t\tObject.entries(allOptions).filter(\n\t\t\t\t([_key, value]) => value.required !== true,\n\t\t\t),\n\t\t),\n\t\tsubProgram,\n\t);\n\taddPluginOptions(\n\t\tObject.fromEntries(\n\t\t\tObject.entries(allOptions).filter(\n\t\t\t\t([_key, value]) => value.required === true,\n\t\t\t),\n\t\t),\n\t\tsubProgram,\n\t\ttrue,\n\t);\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\t// create api here\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, using, secFile, engine } =\n\t\t\t\t\t\tcommand.optsWithGlobals<RunCommandOptions>();\n\n\t\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\t\tif (using === \"env\" || 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 (using === \"sec\") {\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\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"],"mappings":"udAAA,IAAAA,GAAwB,qBCEjB,IAAMC,GAA6B,mBAC7BC,EAAsB,CAACD,EAA0B,EACjDE,EAAiC,OACjCC,EAAiC,OACjCC,EAA8B,C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7DC,EAGA,CAAC,EAEP,QAAWP,KAAc,OAAO,KAAKD,CAAa,EAAG,CACpD,IAAME,EAAeF,EAAcC,CAAU,EACvCQ,EAAmB,MAAML,EAAiB,CAAE,KAAMF,CAAa,CAAC,EAChE,CAAE,cAAAQ,EAAe,YAAaC,CAAI,EAAI,MAAMF,EAAiB,CAClE,IAAAX,EACA,aAAcR,EACd,WAAAD,CACD,CAAC,EAEGsB,GAAK,SACRL,EAAyB,KAAKK,EAAI,OAAO,EAEtCA,GAAK,UACRJ,EAAyB,KAAKI,EAAI,OAAO,EACrCA,GAAK,MACRH,EAAsB,KAAK,CAAE,KAAMG,EAAI,KAAM,QAASA,EAAI,OAAQ,CAAC,GAIjED,GACHA,EAAc,CAAE,QAAAzB,CAAQ,CAAC,EAGvBqB,EAAyB,QAC5B,MAAMM,GAAkB3B,EAAS,CAChC,aAAcK,EACd,gBAAiBgB,CAClB,CAAC,EAEEC,EAAyB,QAC5B,MAAMM,GAAkB5B,EAAS,CAChC,aAAcK,EACd,gBAAiBiB,CAClB,CAAC,EAEEC,EAAsB,QACzB,MAAMM,GAAe7B,EAAS,CAC7B,aAAcK,EACd,SAAUkB,CACX,CAAC,EAIF,MAAMO,GAAe9B,EAAS,CAAE,aAAcK,CAAa,CAAC,EAC5D,MAAM0B,GAAc/B,EAAS,CAC5B,aAAcK,EACd,gBAAiBiB,CAClB,CAAC,EACD,MAAMtB,EAAQ,MAAM,CACrB,GAAG","names":["import_commander","DOTSEC_DEFAULT_CONFIG_FILE","DOTSEC_CONFIG_FILES","DOTSEC_DEFAULT_DOTSEC_FILENAME","DOTSEC_DEFAULT_DOTENV_FILENAME","defaultConfig","import_fs","import_node_path","jsoncParse","data","loadJson","filepath","fs","error","path","import_bundle_require","import_joycon","import_path","getMagicalConfig","filename","cwd","configPath","JoyCon","DOTSEC_CONFIG_FILES","path","rawData","loadJson","data","defaultConfig","bundleRequireResult","loadDotsecPlugin","options","imported","import_commander","addPluginOptions","options","command","mandatory","option","optionProps","flags","description","defaultValue","choices","env","fn","newOption","import_promises","import_node_path","import_prompts","readContentsFromFile","filePath","fs","writeContentsToFile","contents","fileExists","source","promptOverwriteIfFileExists","skip","overwriteResponse","prompts","path","import_chalk","import_cli_table","strong","str","chalk","import_commander","envFileOption","DOTSEC_DEFAULT_DOTENV_FILENAME","secFileOption","DOTSEC_DEFAULT_DOTSEC_FILENAME","usingOption","usingNoEncryptionEngineOption","yesOption","configFileOption","pluginOption","engineOption","createManifestOption","manifestFilePrefixOption","decryptCommandDefaults","configFileOption","envFileOption","secFileOption","createManifestOption","manifestFilePrefixOption","yesOption","decrypt_default","dotsecCommandDefaults","configFileOption","pluginOption","dotsec_default","encryptCommandDefaults","configFileOption","envFileOption","secFileOption","createManifestOption","manifestFilePrefixOption","yesOption","encrypt_default","initCommandDefaults","configFileOption","yesOption","init_default","pushCommandDefaults","configFileOption","envFileOption","secFileOption","yesOption","usingOption","push_default","runCommandDefaults","configFileOption","envFileOption","yesOption","engineOption","usingNoEncryptionEngineOption","secFileOption","usingOption","run_default","commandOptions","dotsec_default","init_default","encrypt_default","decrypt_default","run_default","push_default","expandCommandOption","commandOption","flags","description","defaultValue","createOption","options","defaultOptionValueFromConfig","optionProps","newOption","setProgramOptions","params","program","commandName","dotsecConfig","programOptions","requiredOptions","usage","helpText","optionKey","requiredOptionKey","requiredOption","import_dotenv","addEncryptProgram","program","options","dotsecConfig","decryptHandlers","subProgram","_options","command","envFile","secFile","engine","createManifest","manifestFile","yes","encryptionEngine","pluginCliDecrypt","handler","e","strong","allOptionKeys","allOptionsValues","key","dotsecString","readContentsFromFile","plaintext","dotenvOverwriteResponse","promptOverwriteIfFileExists","writeContentsToFile","dotenvVars","markdownManifest","manifestTargetFile","decryption","requiredOptions","addPluginOptions","engines","setProgramOptions","decrypt_default","import_dotenv","addEncryptProgram","program","options","encryptHandlers","dotsecConfig","subProgram","_options","command","envFile","secFile","engine","createManifest","manifestFile","yes","encryptionEngine","pluginCliEncrypt","handler","e","allOptionKeys","allOptionsValues","key","dotenvString","readContentsFromFile","cipherText","dotsecOverwriteResponse","promptOverwriteIfFileExists","writeContentsToFile","strong","dotenvVars","markdownManifest","manifestTargetFile","encryptionHandler","requiredOptions","addPluginOptions","engines","encryptionEngineNames","setProgramOptions","encrypt_default","import_node_path","addInitProgram","program","options","dotsecConfig","subProgram","_options","command","configFile","yes","configTemplate","readContentsFromFile","path","dotsecConfigOverwriteResponse","promptOverwriteIfFileExists","writeContentsToFile","strong","e","setProgramOptions","init_default","import_dotenv","import_dotenv_expand","import_node_fs","addPushProgram","program","options","dotsecConfig","handlers","subProgram","_options","command","using","envFile","secFile","engine","yes","encryptionEngine","pluginCliDecrypt","handler","pluginCliPush","allOptionKeys","allOptionsValues","key","envContents","fs","e","dotSecContents","dotenvVars","expandedEnvVars","setProgramOptions","engines","decrypt","allOptions","handlerName","cliOptions","requiredOptions","usage","descriptions","addPluginOptions","_key","value","push_default","import_node_fs","import_dotenv","import_dotenv_expand","import_node_child_process","addRunProgam","program","options","dotsecConfig","decryptHandlers","hasDecryptEngine","subProgram","commands","_options","command","envFile","using","secFile","engine","envContents","fs","encryptionEngine","pluginCliDecrypt","handler","e","allOptionKeys","allOptionsValues","key","dotSecContents","dotenvVars","expandedEnvVars","userCommand","userCommandArgs","spawn","strong","setProgramOptions","run","requiredOptions","addPluginOptions","engines","run_default","import_ajv","import_yargs_parser","separator","schema","data","ctx","parentData","parentDataProperty","program","parsedOptions","yargsParser","argvPluginModules","configFile","dotsecConfig","getMagicalConfig","defaults","pushVariables","plugins","_options","other","setProgramOptions","ajv","Ajv","pluginModules","pluginName","pluginModule","loadedPlugin","loadDotsecPlugin","pushVariable","cliPluginEncryptHandlers","cliPluginDecryptHandlers","cliPluginPushHandlers","initDotsecPlugin","addCliCommand","cli","encrypt_default","decrypt_default","push_default","init_default","run_default"]}
1
+ {"version":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/cli/commands/init.ts","../../src/cli/commands/push.ts","../../src/cli/commands/run.ts"],"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\n\tconst someConfigFile = parsedOptions.configFile || parsedOptions.c;\n\n\tconst configFile =\n\t\t[\n\t\t\t...(Array.isArray(someConfigFile) ? someConfigFile : [someConfigFile]),\n\t\t]?.[0] || process.env.DOTSEC_CONFIG_FILE;\n\tconst { contents: dotsecConfig = {} } = await getMagicalConfig(configFile);\n\tconst { defaults = {}, push: pushVariables, plugins } = dotsecConfig;\n\tprogram\n\t\t.name(\"dotsec\")\n\t\t.description(\".env, but secure\")\n\t\t.version(\"1.0.0\")\n\t\t.passThroughOptions()\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\n\t// check plugins\n\tif (plugins) {\n\t\tfor (const pluginName of plugins) {\n\t\t\tif (!defaults?.plugins?.[pluginName]) {\n\t\t\t\tdefaults.plugins = {\n\t\t\t\t\t...defaults.plugins,\n\t\t\t\t\t[pluginName]: {},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\t// check argv\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?.name) {\n\t\t\t\t\tpluginModules[pluginName] = pluginModule?.name;\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\t}\n\n\t// add other commands\n\tawait addInitCommand(program, { dotsecConfig: dotsecConfig });\n\tawait addRunCommand(program, {\n\t\tdotsecConfig: dotsecConfig,\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\tdefaults: {\n\t\t// encryptionEngine: \"pke\",\n\t\t// plugins: {\n\t\t// \tpke: {},\n\t\t// },\n\t},\n};\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\tchoices?: 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, choices, 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\tchoices,\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\tif (optionProps.choices) {\n\t\t\t\t\tnewOption.choices(optionProps.choices);\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 from \"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 pushCommandDefaults from \"./push\";\nimport runCommandDefaults from \"./run\";\nimport {\n\tCommandOption,\n\tDeepExpandedCommandOption,\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};\n\nconst expandCommandOption = (\n\tcommandOption: CommandOption | ExpandedCommandOption,\n): DeepExpandedCommandOption => {\n\tif (Array.isArray(commandOption)) {\n\t\tconst [flags, description, defaultValue] = commandOption;\n\t\tconst optionProps = {\n\t\t\tflags,\n\t\t\tdescription,\n\t\t\tdefaultValue,\n\t\t};\n\t\treturn optionProps;\n\t} else {\n\t\tif (\"option\" in commandOption) {\n\t\t\tconst [flags, description, defaultValue] = commandOption.option;\n\t\t\tconst optionProps = {\n\t\t\t\tflags,\n\t\t\t\tdescription,\n\t\t\t\tdefaultValue,\n\t\t\t\tenv: commandOption.env,\n\t\t\t};\n\t\t\treturn optionProps;\n\t\t}\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 defaultOptionValueFromConfig =\n\t\toptions?.dotsecConfig?.defaults?.options?.[options?.optionKey];\n\tconst optionProps = expandCommandOption(commandOption);\n\n\tconst newOption = new Option(optionProps.flags, optionProps.description);\n\tif (optionProps.fn) {\n\t\tnewOption.argParser(optionProps.fn);\n\t}\n\tif (optionProps.defaultValue) {\n\t\tnewOption.default(defaultOptionValueFromConfig || optionProps.defaultValue);\n\t}\n\tif (optionProps.env) {\n\t\tnewOption.env(optionProps.env);\n\t}\n\tif (options.required) {\n\t\tnewOption.makeOptionMandatory(true);\n\t}\n\tif (optionProps.choices) {\n\t\tnewOption.choices(optionProps.choices);\n\t}\n\n\treturn newOption;\n};\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.usage(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 usingOption: ExpandedCommandOption = {\n\tflags: \"--using <using>\",\n\tdescription: \"Wether to use a dot env file or a dot sec file\",\n\tchoices: [\"env\", \"sec\"],\n\tenv: \"DOTSEC_USING\",\n};\n\nexport const usingNoEncryptionEngineOption: ExpandedCommandOption = {\n\tflags: \"--using <using>\",\n\tdescription: \"Wether to use a dot env file or a dot sec file\",\n\tchoices: [\"env\"],\n\tenv: \"DOTSEC_USING\",\n};\n\nexport const yesOption: ExpandedCommandOption = {\n\toption: [\"--yes\", \"Skip confirmation prompts\"],\n};\n\nexport const verboseOption: ExpandedCommandOption = {\n\toption: [\"--verbose\", \"Verbose output\"],\n};\n\nexport const configFileOption: ExpandedCommandOption = {\n\toption: [\"-c, --config-file, --configFile <configFile>\", \"Config file\"],\n\tenv: \"DOTSEC_CONFIG_FILE\",\n};\n\nexport const pluginOption: ExpandedCommandOption = {\n\toption: [\"--plugin <plugin>\", \"Comma-separated list of plugins to use\"],\n\tenv: \"DOTSEC_PLUGIN\",\n};\n\nexport const engineOption: ExpandedCommandOption = {\n\toption: [\"--engine <engine>\", \"Encryption engine to use\"],\n\tenv: \"DOTSEC_ENGINE\",\n};\n\nexport const createManifestOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--create-manifest\",\n\t\t\"Create a markdown manifest file. See the --manifest-file option for more information.\",\n\t],\n\tenv: \"CREATE_MANIFEST\",\n};\n\nexport const manifestFilePrefixOption: ExpandedCommandOption = {\n\toption: [\n\t\t\"--manifest-file-prefix <manifestFilePrefix>\",\n\t\t\"Mmanifest file prefix\",\n\t],\n\tenv: \"ENCRYPTION_MANIFEST_FILE\",\n};\n","import {\n\tconfigFileOption,\n\tcreateManifestOption,\n\tenvFileOption,\n\tmanifestFilePrefixOption,\n\tsecFileOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst decryptCommandDefaults: DotSecCommandsDefaults = {\n\tdecrypt: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tcreateManifest: createManifestOption,\n\t\t\tmanifestFilePrefix: manifestFilePrefixOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\tdescription: \"Decrypt a sec file\",\n\t\thelpText: `Examples:\n\n\nDecrypt .sec file to .env file\n\n$ npx dotsec decrypt\n\n\nSpecify a different .sec file\n\n$ npx dotsec decrypt --sec-file .sec.dev\n$ SEC_FILE=.sec.dev npx dotsec decrypt\n\nSpecify a different .env file\n\n$ npx dotsec decrypt --env-file .env.dev\n$ ENV_FILE=.env.dev npx dotsec decrypt\n\nWrite a manifest markdown file\n\n$ npx dotsec decrypt --create-manifest\n$ CREATE_MANIFEST=true npx dotsec decrypt\n\nSpecify a different manifest file\n\n$ npx dotsec decrypt --manifest-file .manifest.dev\n$ MANIFEST_FILE=decryption-manifest.md npx dotsec decrypt\n`,\n\t},\n};\n\nexport default decryptCommandDefaults;\n","import { configFileOption, pluginOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst dotsecCommandDefaults: DotSecCommandsDefaults = {\n\tdotsec: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tplugin: pluginOption,\n\t\t},\n\t},\n};\n\nexport default dotsecCommandDefaults;\n","import {\n\tconfigFileOption,\n\tcreateManifestOption,\n\tenvFileOption,\n\tmanifestFilePrefixOption,\n\tsecFileOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst encryptCommandDefaults: DotSecCommandsDefaults = {\n\tencrypt: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tcreateManifest: createManifestOption,\n\t\t\tmanifestFile: manifestFilePrefixOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\tdescription: \"Encrypt an env file\",\n\t\thelpText: `Examples:\n\n\nEncrypt .env file to .sec file\n\n$ npx dotsec encrypt\n\n\nSpecify a different .env file\n\n$ npx dotsec encrypt --env-file .env.dev\n$ ENV_FILE=.env.dev npx dotsec encrypt\n\n\nSpecify a different .sec file\n\n$ npx dotsec encrypt --sec-file .sec.dev\n$ SEC_FILE=.sec.dev npx dotsec encrypt\n\n\nWrite a manifest markdown file\n\n$ npx dotsec encrypt --create-manifest\n$ CREATE_MANIFEST=true npx dotsec encrypt\n\n\nSpecify a different manifest file\n\n$ npx dotsec encrypt --manifest-file manifest.dev\n$ MANIFEST_FILE=encryption-manifest.md npx dotsec encrypt\n`,\n\t},\n};\n\nexport default encryptCommandDefaults;\n","import { configFileOption, yesOption } from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst initCommandDefaults: DotSecCommandsDefaults = {\n\tinit: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\tdescription:\n\t\t\t\"Initialize a dotsec project by creating a dotsec.config.ts file.\",\n\t\thelpText: `Examples:\n\nCreate a dotsec.config.ts file in the current directory\n\n$ npx dotsec init\n\n\nOverwrite an existing dotsec.config.ts file in the current directory\n\n$ npx dotsec init --yes\n\n\nCreate a dotsec config file in the current directory with a specific config file name\n\nBy specifying the --config-file option, you can create a dotsec config file with a specific name.\n\n$ npx dotsec init --config-file dotsec.config.ts\n\n$ DOTSEC_CONFIG_FILE=my.config.ts npx dotsec init\n`,\n\t},\n};\n\nexport default initCommandDefaults;\n","import {\n\tconfigFileOption,\n\tenvFileOption,\n\tsecFileOption,\n\tusingOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n\nconst pushCommandDefaults: DotSecCommandsDefaults = {\n\tpush: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\tusing: usingOption,\n\t\t},\n\t\tdescription: \"Push variables from env or sec file to a remote\",\n\t\thelpText: `Examples:\n\nPush variables from .env file to remote\n\n$ npx dotsec push --using env\n$ DOTSEC_USING=env npx dotsec push\n\n\nPush variables from .sec file to remote\n\n$ npx dotsec push --using sec\n$ DOTSEC_USING=sec npx dotsec push\n`,\n\t},\n};\n\nexport default pushCommandDefaults;\n","import {\n\tconfigFileOption,\n\tengineOption,\n\tenvFileOption,\n\tsecFileOption,\n\tusingNoEncryptionEngineOption,\n\tusingOption,\n\tyesOption,\n} from \"./sharedOptions\";\nimport { DotSecCommandsDefaults } from \"./types\";\n/*\n\nrun --env-file=.env --sec-file=.sec --with=env-file\n\n*/\nconst runCommandDefaults: DotSecCommandsDefaults = {\n\trunEnvOnly: {\n\t\tusage: \"--using env [commandArgs...]\",\n\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tyes: yesOption,\n\t\t\tengine: engineOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\tusing: usingNoEncryptionEngineOption,\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\t\t\nRun a command with a .env file\n\t\t\n$ npx dotsec run --using env node -e \\\"console.log(process.env)\\\"\n\n\nRun a command with a specific .env file\n\n$ npx dotsec run --using env --env-file .env node -e \\\"console.log(process.env)\\\"\n\n\nRun a command with a specific ENV_FILE variable\n\n$ ENV_FILE=.env.dev npx dotsec run --using env node -e \\\"console.log(process.env)\\\"\n\n\nYou can also specify 'using' as an environment variable\n\n$ DOTSEC_USING=env npx dotsec run node -e \\\"console.log(process.env)\\\"\n\t\t`,\n\t},\n\trun: {\n\t\toptions: {\n\t\t\tconfigFile: configFileOption,\n\t\t\tenvFile: envFileOption,\n\t\t\tsecFile: secFileOption,\n\t\t\tyes: yesOption,\n\t\t},\n\t\trequiredOptions: {\n\t\t\tusing: usingOption,\n\t\t},\n\n\t\tusage: \"[--using env] [--using 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\t// push: {\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\";\nimport { parse } from \"dotenv\";\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\tcreateManifest,\n\t\t\t\t\tmanifestFile,\n\t\t\t\t\tyes,\n\t\t\t\t} = command.optsWithGlobals<DecryptCommandOptions>();\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\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\n\t\t\t\tif (createManifest || dotsecConfig?.defaults?.options?.createManifest) {\n\t\t\t\t\t// parse raw env contents into key value pairs using the dotenv package\n\t\t\t\t\tconst dotenvVars = parse(plaintext);\n\t\t\t\t\t// expand env vars\n\t\t\t\t\tconst markdownManifest = `# Dotsec decryption manifest\n\n## Overview\n\n- plaintext source: ${envFile}\n- ciphertext target: ${secFile}\n- created: ${new Date().toUTCString()}\n- Decryption engine: ${\n\t\t\t\t\t\tpluginCliDecrypt.encryptionEngineName ||\n\t\t\t\t\t\tpluginCliDecrypt.triggerOptionValue\n\t\t\t\t\t}\n- Decryption engine options: ${JSON.stringify(allOptionsValues)}\n\n## Variables\n\n| Key |\n| --- |\n${Object.keys(dotenvVars)\n\t.map((key) => {\n\t\treturn `| \\`${key} \\`| `;\n\t})\n\t.join(\"\\n\")}\n`;\n\n\t\t\t\t\t// write manifest file, don't prompt to overwrite\n\t\t\t\t\tconst manifestTargetFile =\n\t\t\t\t\t\tmanifestFile || `${envFile}.decryption-manifest.md`;\n\t\t\t\t\tawait writeContentsToFile(manifestTargetFile, markdownManifest);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Wrote manifest of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\tmanifestTargetFile,\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\";\nimport { parse } from \"dotenv\";\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\tcreateManifest,\n\t\t\t\t\tmanifestFile,\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\n\t\t\t\t\tif (\n\t\t\t\t\t\tcreateManifest ||\n\t\t\t\t\t\tdotsecConfig?.defaults?.options?.createManifest\n\t\t\t\t\t) {\n\t\t\t\t\t\t// parse raw env contents into key value pairs using the dotenv package\n\t\t\t\t\t\tconst dotenvVars = parse(dotenvString);\n\t\t\t\t\t\t// expand env vars\n\t\t\t\t\t\tconst markdownManifest = `# Dotsec encryption manifest \n\n## Overview\n\n- plaintext source: ${envFile}\n- ciphertext target: ${secFile}\n- created: ${new Date().toUTCString()}\n- encryption engine: ${\n\t\t\t\t\t\t\tpluginCliEncrypt.encryptionEngineName ||\n\t\t\t\t\t\t\tpluginCliEncrypt.triggerOptionValue\n\t\t\t\t\t\t}\n- encryption engine options: ${JSON.stringify(allOptionsValues)}\n\n## Variables\n\n| Key | \n| --- | \n${Object.keys(dotenvVars)\n\t.map((key) => {\n\t\treturn `| \\`${key} \\`| `;\n\t})\n\t.join(\"\\n\")}\n`;\n\n\t\t\t\t\t\t// write manifest file, don't prompt to overwrite\n\t\t\t\t\t\tconst manifestTargetFile =\n\t\t\t\t\t\t\tmanifestFile || `${secFile}.encryption-manifest.md`;\n\t\t\t\t\t\tawait writeContentsToFile(manifestTargetFile, markdownManifest);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`Wrote manifest of ${strong(envFile)} file to ${strong(\n\t\t\t\t\t\t\t\tmanifestTargetFile,\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\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\tengines.length === 1 ? engines[0] : undefined,\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 {\n\tpromptOverwriteIfFileExists,\n\treadContentsFromFile,\n\twriteContentsToFile,\n} from \"../../lib/io\";\nimport { DotsecConfig, InitCommandOptions } from \"../../types\";\nimport { Command } from \"commander\";\n\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 = \"dotsec.config.ts\", yes } =\n\t\t\t\tcommand.optsWithGlobals<InitCommandOptions>();\n\t\t\ttry {\n\t\t\t\tconst configTemplate = await readContentsFromFile(\n\t\t\t\t\tpath.resolve(__dirname, \"../../src/templates/dotsec.config.ts\"),\n\t\t\t\t);\n\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, configTemplate);\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 { addPluginOptions } from \"../../lib/addPluginOptions\";\nimport { PushCommandOptions } from \"../../types\";\nimport { DotsecConfig } from \"../../types/config\";\nimport {\n\tDotsecCliOption,\n\tDotsecCliPluginDecryptHandler,\n\tDotsecCliPluginPushHandler,\n} from \"../../types/plugin\";\nimport { setProgramOptions } from \"../options/index\";\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\tusing,\n\t\t\t\t\tenvFile,\n\t\t\t\t\tsecFile,\n\t\t\t\t\tengine,\n\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\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\tlet envContents: string | undefined;\n\n\t\t\t\tif (using === \"env\") {\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 {\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\tconst engines = options.handlers.map(\n\t\t({ decrypt }) => decrypt.triggerOptionValue,\n\t);\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\tconst allOptions: {\n\t\t[x: string]: DotsecCliOption & { required?: boolean };\n\t} = {};\n\toptions.handlers.forEach((handlers) => {\n\t\tObject.keys(handlers).map((handlerName) => {\n\t\t\tconst { options: cliOptions, requiredOptions } = handlers[handlerName];\n\t\t\tObject.keys(cliOptions || {}).forEach((key) => {\n\t\t\t\tallOptions[key] = Array.isArray(cliOptions[key])\n\t\t\t\t\t? cliOptions[key]\n\t\t\t\t\t: { ...allOptions[key], ...cliOptions[key] };\n\t\t\t});\n\t\t\tObject.keys(requiredOptions || {}).forEach((key) => {\n\t\t\t\tallOptions[key] = Array.isArray(requiredOptions[key])\n\t\t\t\t\t? requiredOptions[key]\n\t\t\t\t\t: {\n\t\t\t\t\t\t\t...allOptions[key],\n\t\t\t\t\t\t\t...requiredOptions[key],\n\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t };\n\t\t\t});\n\t\t});\n\t});\n\n\tconst usage: string[] = [];\n\tconst descriptions: string[] = [];\n\n\thandlers.forEach((handler) => {\n\t\tif (handler.push?.description) {\n\t\t\tdescriptions.push(handler.push.description);\n\t\t}\n\n\t\tif (handler.push?.usage) {\n\t\t\tusage.push(handler.push.usage);\n\t\t}\n\t});\n\n\tif (descriptions.length > 0) {\n\t\tsubProgram.description(descriptions.join(\"\\n\"));\n\t}\n\n\tif (usage.length > 0) {\n\t\tsubProgram.usage(usage.join(\"\\n\"));\n\t}\n\n\taddPluginOptions(\n\t\tObject.fromEntries(\n\t\t\tObject.entries(allOptions).filter(\n\t\t\t\t([_key, value]) => value.required !== true,\n\t\t\t),\n\t\t),\n\t\tsubProgram,\n\t);\n\taddPluginOptions(\n\t\tObject.fromEntries(\n\t\t\tObject.entries(allOptions).filter(\n\t\t\t\t([_key, value]) => value.required === true,\n\t\t\t),\n\t\t),\n\t\tsubProgram,\n\t\ttrue,\n\t);\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\t// create api here\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, using, secFile, engine } =\n\t\t\t\t\t\tcommand.optsWithGlobals<RunCommandOptions>();\n\n\t\t\t\t\tlet envContents: string | undefined;\n\n\t\t\t\t\tif (using === \"env\" || 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 (using === \"sec\") {\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\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"],"mappings":"udAAA,IAAAA,GAAwB,qBCEjB,IAAMC,GAA6B,mBAC7BC,EAAsB,CAACD,EAA0B,EACjDE,EAAiC,OACjCC,EAAiC,OACjCC,EAA8B,CAC1C,SAAU,CAKV,CACD,ECbA,IAAAC,EAAe,iBACfC,EAAiB,mBAUV,SAASC,GAAWC,EAAc,CACxC,GAAI,CACH,OAAO,IAAI,SAAS,UAAUA,EAAK,KAAK,GAAG,EAAE,CAC9C,MAAE,CAGD,MAAO,CAAC,CACT,CACD,CAUO,IAAMC,EAAW,MAAOC,GAAqB,CACnD,GAAI,CACH,OAAOH,GAAW,MAAM,EAAAI,QAAG,SAAS,SAASD,EAAU,MAAM,CAAC,CAC/D,OAASE,EAAP,CACD,MAAIA,aAAiB,MACd,IAAI,MACT,mBAAmB,EAAAC,QAAK,SAAS,QAAQ,IAAI,EAAGH,CAAQ,MACvDE,EAAM,SAER,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B,EAAyB,QAC5B,MAAMM,GAAkB5B,EAAS,CAChC,aAAcM,EACd,gBAAiBgB,CAClB,CAAC,EAEEC,EAAyB,QAC5B,MAAMM,GAAkB7B,EAAS,CAChC,aAAcM,EACd,gBAAiBiB,CAClB,CAAC,EAEEC,EAAsB,QACzB,MAAMM,GAAe9B,EAAS,CAC7B,aAAcM,EACd,SAAUkB,CACX,CAAC,EAIF,MAAMO,GAAe/B,EAAS,CAAE,aAAcM,CAAa,CAAC,EAC5D,MAAM0B,GAAchC,EAAS,CAC5B,aAAcM,EACd,gBAAiBiB,CAClB,CAAC,EACD,MAAMvB,EAAQ,MAAM,CACrB,GAAG","names":["import_commander","DOTSEC_DEFAULT_CONFIG_FILE","DOTSEC_CONFIG_FILES","DOTSEC_DEFAULT_DOTSEC_FILENAME","DOTSEC_DEFAULT_DOTENV_FILENAME","defaultConfig","import_fs","import_node_path","jsoncParse","data","loadJson","filepath","fs","error","path","import_bundle_require","import_joycon","import_path","getMagicalConfig","filename","cwd","configPath","JoyCon","DOTSEC_CONFIG_FILES","path","rawData","loadJson","data","defaultConfig","bundleRequireResult","loadDotsecPlugin","options","imported","import_commander","addPluginOptions","options","command","mandatory","option","optionProps","flags","description","defaultValue","choices","env","fn","newOption","import_promises","import_node_path","import_prompts","readContentsFromFile","filePath","fs","writeContentsToFile","contents","fileExists","source","promptOverwriteIfFileExists","skip","overwriteResponse","prompts","path","import_chalk","import_cli_table","strong","str","chalk","import_commander","envFileOption","DOTSEC_DEFAULT_DOTENV_FILENAME","secFileOption","DOTSEC_DEFAULT_DOTSEC_FILENAME","usingOption","usingNoEncryptionEngineOption","yesOption","configFileOption","pluginOption","engineOption","createManifestOption","manifestFilePrefixOption","decryptCommandDefaults","configFileOption","envFileOption","secFileOption","createManifestOption","manifestFilePrefixOption","yesOption","decrypt_default","dotsecCommandDefaults","configFileOption","pluginOption","dotsec_default","encryptCommandDefaults","configFileOption","envFileOption","secFileOption","createManifestOption","manifestFilePrefixOption","yesOption","encrypt_default","initCommandDefaults","configFileOption","yesOption","init_default","pushCommandDefaults","configFileOption","envFileOption","secFileOption","yesOption","usingOption","push_default","runCommandDefaults","configFileOption","envFileOption","yesOption","engineOption","usingNoEncryptionEngineOption","secFileOption","usingOption","run_default","commandOptions","dotsec_default","init_default","encrypt_default","decrypt_default","run_default","push_default","expandCommandOption","commandOption","flags","description","defaultValue","createOption","options","defaultOptionValueFromConfig","optionProps","newOption","setProgramOptions","params","program","commandName","dotsecConfig","programOptions","requiredOptions","usage","helpText","optionKey","requiredOptionKey","requiredOption","import_dotenv","addEncryptProgram","program","options","dotsecConfig","decryptHandlers","subProgram","_options","command","envFile","secFile","engine","createManifest","manifestFile","yes","encryptionEngine","pluginCliDecrypt","handler","e","strong","allOptionKeys","allOptionsValues","key","dotsecString","readContentsFromFile","plaintext","dotenvOverwriteResponse","promptOverwriteIfFileExists","writeContentsToFile","dotenvVars","markdownManifest","manifestTargetFile","decryption","requiredOptions","addPluginOptions","engines","setProgramOptions","decrypt_default","import_dotenv","addEncryptProgram","program","options","encryptHandlers","dotsecConfig","subProgram","_options","command","envFile","secFile","engine","createManifest","manifestFile","yes","encryptionEngine","pluginCliEncrypt","handler","e","allOptionKeys","allOptionsValues","key","dotenvString","readContentsFromFile","cipherText","dotsecOverwriteResponse","promptOverwriteIfFileExists","writeContentsToFile","strong","dotenvVars","markdownManifest","manifestTargetFile","encryptionHandler","requiredOptions","addPluginOptions","engines","encryptionEngineNames","setProgramOptions","encrypt_default","import_node_path","addInitProgram","program","options","dotsecConfig","subProgram","_options","command","configFile","yes","configTemplate","readContentsFromFile","path","dotsecConfigOverwriteResponse","promptOverwriteIfFileExists","writeContentsToFile","strong","e","setProgramOptions","init_default","import_dotenv","import_dotenv_expand","import_node_fs","addPushProgram","program","options","dotsecConfig","handlers","subProgram","_options","command","using","envFile","secFile","engine","yes","encryptionEngine","pluginCliDecrypt","handler","pluginCliPush","allOptionKeys","allOptionsValues","key","envContents","fs","e","dotSecContents","dotenvVars","expandedEnvVars","setProgramOptions","engines","decrypt","allOptions","handlerName","cliOptions","requiredOptions","usage","descriptions","addPluginOptions","_key","value","push_default","import_node_fs","import_dotenv","import_dotenv_expand","import_node_child_process","addRunProgam","program","options","dotsecConfig","decryptHandlers","hasDecryptEngine","subProgram","commands","_options","command","envFile","using","secFile","engine","envContents","fs","encryptionEngine","pluginCliDecrypt","handler","e","allOptionKeys","allOptionsValues","key","dotSecContents","dotenvVars","expandedEnvVars","userCommand","userCommandArgs","spawn","strong","setProgramOptions","run","requiredOptions","addPluginOptions","engines","run_default","import_ajv","import_yargs_parser","separator","schema","data","ctx","parentData","parentDataProperty","program","parsedOptions","yargsParser","argvPluginModules","someConfigFile","configFile","dotsecConfig","getMagicalConfig","defaults","pushVariables","plugins","_options","other","setProgramOptions","ajv","Ajv","pluginModules","pluginName","pluginModule","loadedPlugin","loadDotsecPlugin","pushVariable","cliPluginEncryptHandlers","cliPluginDecryptHandlers","cliPluginPushHandlers","initDotsecPlugin","addCliCommand","cli","encrypt_default","decrypt_default","push_default","init_default","run_default"]}