]> git.ardis.lu - envpass/commitdiff
Do not emit end user-facing logs
authorArdis Lu <ardisglu@gmail.com>
Tue, 14 Jul 2026 06:13:27 +0000 (23:13 -0700)
committerArdis Lu <ardisglu@gmail.com>
Tue, 14 Jul 2026 06:13:27 +0000 (23:13 -0700)
Logs intended to improve the final UX should be a separate concern handled by the CLI or the library consumer. Library logs should only be related to debugging the library itself. This separation allows the code closest to the user to provide more tailored instructions (e.g., i18n) to the user.

src/command.js
test/index.test.js

index 218f00226143860e7237775419c5e02f2e27f727..9cbff0e2c2a842d6566d6a64d1e3c8425d71fec0 100644 (file)
@@ -1,4 +1,4 @@
-import { parseEnv, styleText } from 'node:util';
+import { parseEnv } from 'node:util';
 import { readFile, writeFile } from 'node:fs/promises';
 import { execSync } from 'node:child_process';
 /** @import { PathLike } from 'node:fs'; */
@@ -69,9 +69,6 @@ export async function encrypt(options = {}) {
 
     if (prf === null) {
       const { url, prf: prfPromise } = await getPrf(getPrfOptions);
-      if (!getPrfOptions.autoOpen) {
-        logger.info?.(`Open this page in a web browser to complete the passkey flow: ${url}`);
-      }
       prf = await prfPromise;
       if (prf === null) {
         throw new InputError('Unable to get passkey.');
@@ -84,7 +81,6 @@ export async function encrypt(options = {}) {
   if (outFile) {
     await writeFile(outFile, toEnvString(encryptedEnv));
   }
-  logger.info?.(styleText('green', '🎉 Successfully encrypted environment variables!'));
 }
 
 /**
@@ -150,9 +146,6 @@ export async function decrypt(options = {}, { args = [] } = {}) {
 
     if (prf === null) {
       const { url, prf: prfPromise } = await getPrf(getPrfOptions);
-      if (!getPrfOptions.autoOpen) {
-        logger.info?.(`Open this page in a web browser to complete the passkey flow: ${url}`);
-      }
       prf = await prfPromise;
       if (prf === null) {
         throw new InputError('Unable to get passkey.');
@@ -172,7 +165,6 @@ export async function decrypt(options = {}, { args = [] } = {}) {
       await writeFile(outFile, toEnvString(decryptedEnv));
     }
   }
-  logger.info?.(styleText('green', '🎉 Successfully decrypted environment variables!'));
   if (args.length > 0) {
     execSync(args.join(' '), { stdio: 'inherit' });
   }
index d6dbb812ad17162a6db41331ca0aec8d3205c5e0..010889723612333bae36c2d6825e1e87abcddc4e 100644 (file)
@@ -25,12 +25,14 @@ suite('e2e', () => {
     const { page } = await setupPlaywright(t);
     const envFile = await setupEnv(t, STD_ENV);
     mockOpen(t, page);
-    assertConsole(t, { info: 2 });
+    assertConsole(t, { info: 6 });
 
     await fileEqual(envFile, STD_ENV);
-    await encrypt({ inFile: envFile, logger: console });
+    await encrypt({ inFile: envFile });
+    await encrypt({ inFile: envFile, logger: console, alreadyEncryptedValue: 'log' });
     await fileNotEqual(envFile, STD_ENV);
-    await decrypt({ inFile: envFile, logger: console });
+    await decrypt({ inFile: envFile });
+    await decrypt({ inFile: envFile, logger: console, notEncryptedValue: 'log' });
     await fileEqual(envFile, STD_ENV);
   });
   test('does nothing to empty .env file', async (t) => {
This page took 0.041574 seconds and 4 git commands to generate.