]> git.ardis.lu - envpass/commitdiff
Add debug level logs
authorArdis Lu <ardisglu@gmail.com>
Wed, 15 Jul 2026 05:03:17 +0000 (22:03 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 15 Jul 2026 05:03:17 +0000 (22:03 -0700)
src/command.js
test/index.test.js

index 9cbff0e2c2a842d6566d6a64d1e3c8425d71fec0..f0935d0dad7dd0b54c5d3d0568b52cf28b258639 100644 (file)
@@ -42,6 +42,7 @@ export async function encrypt(options = {}) {
   } = options;
 
   const env = await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv);
+  logger.debug?.('Environment variables read and parsed.');
   if (Object.keys(env).length === 0) {
     logger.info?.('No environment variables found, aborting.');
     return;
@@ -68,18 +69,24 @@ export async function encrypt(options = {}) {
     }
 
     if (prf === null) {
+      logger.debug?.('PRF is required but not yet set, initiating passkey flow.');
       const { url, prf: prfPromise } = await getPrf(getPrfOptions);
+      logger.debug?.(`Passkey flow initiated at ${url}.`);
       prf = await prfPromise;
       if (prf === null) {
         throw new InputError('Unable to get passkey.');
       }
+      logger.debug?.('Passkey flow successfully completed and PRF set.');
     }
     const encryptedValue = await encryptRaw({ prf, value });
     encryptedEnv[envVar] = encryptedValue;
+    logger.debug?.(`Variable "${envVar}" handled.`);
   }
+  logger.debug?.('All environment variables handled.');
 
   if (outFile) {
     await writeFile(outFile, toEnvString(encryptedEnv));
+    logger.debug?.('Wrote environment variables to file.');
   }
 }
 
@@ -120,6 +127,7 @@ export async function decrypt(options = {}, { args = [] } = {}) {
   } = options;
 
   const env = await readFile(inFile, { encoding: 'utf-8' }).then(parseEnv);
+  logger.debug?.('Environment variables read and parsed.');
   if (Object.keys(env).length === 0) {
     logger.info?.('No environment variables found, aborting.');
     return;
@@ -145,27 +153,35 @@ export async function decrypt(options = {}, { args = [] } = {}) {
     }
 
     if (prf === null) {
+      logger.debug?.('PRF is required but not yet set, initiating passkey flow.');
       const { url, prf: prfPromise } = await getPrf(getPrfOptions);
+      logger.debug?.(`Passkey flow initiated at ${url}.`);
       prf = await prfPromise;
       if (prf === null) {
         throw new InputError('Unable to get passkey.');
       }
+      logger.debug?.('Passkey flow successfully completed and PRF set.');
     }
     const decryptedValue = await decryptRaw({ prf, value: parsedValue });
     decryptedEnv[envVar] = decryptedValue;
+    logger.debug?.(`Variable "${envVar}" handled.`);
   }
+  logger.debug?.('All environment variables handled.');
 
   if (injectInProcess) {
     for (const [envVar, value] of Object.entries(decryptedEnv)) {
       process.env[envVar] = value;
     }
+    logger.debug?.('Injected environment variables to process.env.');
   }
   else {
     if (outFile) {
       await writeFile(outFile, toEnvString(decryptedEnv));
+      logger.debug?.('Wrote environment variables to file.');
     }
   }
   if (args.length > 0) {
+    logger.debug?.('Follow-on command found, executing in child process.');
     execSync(args.join(' '), { stdio: 'inherit' });
   }
 }
\ No newline at end of file
index 010889723612333bae36c2d6825e1e87abcddc4e..e93e6b41d7aaa0b64890f73b71a03d84adc16d3f 100644 (file)
@@ -25,7 +25,7 @@ suite('e2e', () => {
     const { page } = await setupPlaywright(t);
     const envFile = await setupEnv(t, STD_ENV);
     mockOpen(t, page);
-    assertConsole(t, { info: 6 });
+    assertConsole(t, { debug: 6, info: 6, warn: 0, error: 0 });
 
     await fileEqual(envFile, STD_ENV);
     await encrypt({ inFile: envFile });
This page took 0.039725 seconds and 4 git commands to generate.