-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'; */
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.');
if (outFile) {
await writeFile(outFile, toEnvString(encryptedEnv));
}
- logger.info?.(styleText('green', '🎉 Successfully encrypted environment variables!'));
}
/**
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.');
await writeFile(outFile, toEnvString(decryptedEnv));
}
}
- logger.info?.(styleText('green', '🎉 Successfully decrypted environment variables!'));
if (args.length > 0) {
execSync(args.join(' '), { stdio: 'inherit' });
}
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) => {