cf-envsync 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13196,9 +13196,14 @@ async function loadEnvFile(filePath, env2, projectRoot, encryption) {
|
|
|
13196
13196
|
}
|
|
13197
13197
|
if (encryption === "password") {
|
|
13198
13198
|
const envMap = parsePlainEnv(content);
|
|
13199
|
+
const hasEncryptedValues = Object.values(envMap).some((v2) => v2.startsWith("envsync:v1:"));
|
|
13199
13200
|
const password = findPassword(env2, projectRoot);
|
|
13200
|
-
if (!password)
|
|
13201
|
+
if (!password) {
|
|
13202
|
+
if (hasEncryptedValues) {
|
|
13203
|
+
throw new Error(`${filePath} contains encrypted values but no password found. ` + `Set ENVSYNC_PASSWORD${env2 ? `_${env2.toUpperCase()}` : ""} or create .env.password`);
|
|
13204
|
+
}
|
|
13201
13205
|
return envMap;
|
|
13206
|
+
}
|
|
13202
13207
|
return decryptEnvMap(envMap, password);
|
|
13203
13208
|
}
|
|
13204
13209
|
const privateKey = findPrivateKey(env2, projectRoot);
|
|
@@ -14942,6 +14947,15 @@ var init_encrypt = __esm(() => {
|
|
|
14942
14947
|
}
|
|
14943
14948
|
const content = await readFile(envFilePath);
|
|
14944
14949
|
const lines = parseLines(content);
|
|
14950
|
+
const firstEncrypted = lines.find((l2) => l2.key && l2.value && isEnvsyncEncrypted(l2.value.trim()));
|
|
14951
|
+
if (firstEncrypted) {
|
|
14952
|
+
try {
|
|
14953
|
+
decryptValue(firstEncrypted.value.trim(), password);
|
|
14954
|
+
} catch {
|
|
14955
|
+
consola.error(`Password mismatch: cannot decrypt existing value for ${firstEncrypted.key}. ` + `The current password differs from the one used to encrypt existing values.`);
|
|
14956
|
+
process.exit(1);
|
|
14957
|
+
}
|
|
14958
|
+
}
|
|
14945
14959
|
let encryptedCount = 0;
|
|
14946
14960
|
let skippedCount = 0;
|
|
14947
14961
|
const outputLines = [];
|