This commit is contained in:
2024-11-30 17:55:00 -05:00
parent 496aa6e73c
commit 5ff6ac9251
3 changed files with 31 additions and 1 deletions
+22
View File
@@ -103,6 +103,19 @@ export const setSecretFile = async ({ absFilePath, secretKey, secretValue }) =>
logger.success(`adding secret for ${absFilePath} with Key ${secretKey.toUpperCase()} done`);
await decryptFile(absFilePath);
};
export const setRawFile = async ({ absFilePath, secretKey, secretValue }) => {
if (!fs.existsSync(absFilePath)) {
logger.error(`Secret ${absFilePath} is not exist`);
}
logger.log(`adding raw secret for ${absFilePath} with Key ${secretKey.toUpperCase()} start`);
const secretFileObjRaw = await fs.readFile(absFilePath, "utf8");
const secretObj = JSON.parse(secretFileObjRaw);
secretObj[secretKey.toUpperCase()] = secretValue;
saveFileIfItChanged(JSON.stringify(secretObj, null, 4), absFilePath);
logger.success(`adding secret for ${absFilePath} with Key ${secretKey.toUpperCase()} done`);
await decryptFile(absFilePath);
};
export const commitSecretMeta = async () => {
const metadataRepoFolderRelative = getJJConfigByKeyChain(`metadataRepo.path`);
@@ -219,6 +232,15 @@ export const secrets = async () => {
process.exit(1);
}
if (process.env.JJ_CLI_ARG_2 == "setRaw") {
await setRawFile({
absFilePath,
secretKey,
secretValue,
});
process.exit(0);
}
if (process.env.JJ_CLI_ARG_2 == "setSecret") {
await setSecretFile({
absFilePath,