deepstrike 7.0.0 → 9.0.0
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/cli.js +64 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -23235,6 +23235,13 @@ var writeSecretFileIfMissing = async () => {
|
|
|
23235
23235
|
`, "utf8");
|
|
23236
23236
|
return true;
|
|
23237
23237
|
};
|
|
23238
|
+
var writeSecretFileOverwrite = async (clientSecret) => {
|
|
23239
|
+
const filePath = path5.join(getDeepstrikeDir(), SECRET_INPUT_FILE_NAME);
|
|
23240
|
+
await ensureDir(getDeepstrikeDir());
|
|
23241
|
+
await fs6.writeFile(filePath, `AZURE_CLIENT_SECRET=${clientSecret}
|
|
23242
|
+
`, "utf8");
|
|
23243
|
+
return filePath;
|
|
23244
|
+
};
|
|
23238
23245
|
var appendGitignoreRules = async (projectRoot) => {
|
|
23239
23246
|
const gitignorePath = path5.join(projectRoot, ".gitignore");
|
|
23240
23247
|
const rules = [
|
|
@@ -23291,12 +23298,14 @@ var printHelp = () => {
|
|
|
23291
23298
|
const text = `deepstrike
|
|
23292
23299
|
|
|
23293
23300
|
Usage:
|
|
23301
|
+
deepstrike bootstrap <clientSecret>
|
|
23294
23302
|
deepstrike init
|
|
23295
23303
|
deepstrike create <environment>
|
|
23296
23304
|
deepstrike push <environment>
|
|
23297
23305
|
deepstrike pull <environment>
|
|
23298
23306
|
deepstrike export <environment>
|
|
23299
23307
|
deepstrike import <dotfilePath> <environment>
|
|
23308
|
+
deepstrike add-secret <environment> <secretName> <secretValue> [--push]
|
|
23300
23309
|
|
|
23301
23310
|
Notes:
|
|
23302
23311
|
Config directory: ${deepstrikeDirName}
|
|
@@ -23305,6 +23314,18 @@ Notes:
|
|
|
23305
23314
|
`;
|
|
23306
23315
|
process.stdout.write(text);
|
|
23307
23316
|
};
|
|
23317
|
+
var bootstrapCommand = async (clientSecret) => {
|
|
23318
|
+
const projectRoot = getProjectRoot();
|
|
23319
|
+
const wrotePath = await writeSecretFileOverwrite(clientSecret);
|
|
23320
|
+
const updatedGitignore = await appendGitignoreRules(projectRoot);
|
|
23321
|
+
process.stdout.write(`Wrote secret input file: ${path5.relative(projectRoot, wrotePath)}
|
|
23322
|
+
`);
|
|
23323
|
+
process.stdout.write(updatedGitignore ? `.gitignore updated.
|
|
23324
|
+
` : `.gitignore already up to date.
|
|
23325
|
+
`);
|
|
23326
|
+
process.stdout.write(`Next: deepstrike init
|
|
23327
|
+
`);
|
|
23328
|
+
};
|
|
23308
23329
|
var initCommand = async () => {
|
|
23309
23330
|
const projectRoot = getProjectRoot();
|
|
23310
23331
|
const deepstrikeDir = getDeepstrikeDir();
|
|
@@ -23427,12 +23448,44 @@ var importCommand = async (dotfilePathRaw, environmentRaw) => {
|
|
|
23427
23448
|
process.stdout.write(`Imported ${updatedCount} value${updatedCount === 1 ? "" : "s"} into ${targetSecretsFilePath} from ${dotfilePath}
|
|
23428
23449
|
`);
|
|
23429
23450
|
};
|
|
23451
|
+
var addSecretCommand = async (environmentRaw, secretName, secretValue, shouldPush) => {
|
|
23452
|
+
await ensureDir(getDeepstrikeDir());
|
|
23453
|
+
const templateFile = await readTemplateFile();
|
|
23454
|
+
const templateSecretNames = templateFile.secretNames ?? [];
|
|
23455
|
+
if (!templateSecretNames.includes(secretName)) {
|
|
23456
|
+
const updatedTemplateFile = { ...templateFile, secretNames: [...templateSecretNames, secretName] };
|
|
23457
|
+
await fs6.writeFile(getEnvTemplatePath(), JSON.stringify(updatedTemplateFile, null, 4) + `
|
|
23458
|
+
`, "utf8");
|
|
23459
|
+
}
|
|
23460
|
+
const environmentFilePath = path5.join(deepstrikeDirName, formatEnvironmentFileName(environmentRaw));
|
|
23461
|
+
if (!await fileExists(environmentFilePath)) {
|
|
23462
|
+
await createEmptySecretsFile(environmentRaw);
|
|
23463
|
+
}
|
|
23464
|
+
const environmentSecretsFile = await readEnvironmentSecretsFile(environmentRaw);
|
|
23465
|
+
const existingSecrets = environmentSecretsFile.secrets ?? [];
|
|
23466
|
+
const updatedSecrets = existingSecrets.some((secret) => secret.name === secretName) ? existingSecrets.map((secret) => secret.name === secretName ? { ...secret, value: secretValue } : secret) : [...existingSecrets, { name: secretName, value: secretValue }];
|
|
23467
|
+
const updatedEnvironmentFile = { ...environmentSecretsFile, secrets: updatedSecrets };
|
|
23468
|
+
await fs6.writeFile(environmentFilePath, JSON.stringify(updatedEnvironmentFile, null, 4) + `
|
|
23469
|
+
`, "utf8");
|
|
23470
|
+
process.stdout.write(`Added secret ${secretName} to ${environmentFilePath}
|
|
23471
|
+
`);
|
|
23472
|
+
if (shouldPush) {
|
|
23473
|
+
await pushCommand(environmentRaw);
|
|
23474
|
+
}
|
|
23475
|
+
};
|
|
23430
23476
|
var main = async () => {
|
|
23431
23477
|
const [, , command, ...args] = process.argv;
|
|
23432
23478
|
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
23433
23479
|
printHelp();
|
|
23434
23480
|
return;
|
|
23435
23481
|
}
|
|
23482
|
+
if (command === "bootstrap") {
|
|
23483
|
+
const clientSecret = args[0];
|
|
23484
|
+
if (!clientSecret)
|
|
23485
|
+
throw new Error("bootstrap requires <clientSecret>");
|
|
23486
|
+
await bootstrapCommand(clientSecret);
|
|
23487
|
+
return;
|
|
23488
|
+
}
|
|
23436
23489
|
if (command === "init") {
|
|
23437
23490
|
await initCommand();
|
|
23438
23491
|
return;
|
|
@@ -23473,6 +23526,17 @@ var main = async () => {
|
|
|
23473
23526
|
await importCommand(dotfilePath, environment);
|
|
23474
23527
|
return;
|
|
23475
23528
|
}
|
|
23529
|
+
if (command === "add-secret") {
|
|
23530
|
+
const environment = args[0];
|
|
23531
|
+
const secretName = args[1];
|
|
23532
|
+
const secretValue = args[2];
|
|
23533
|
+
const shouldPush = args.includes("--push");
|
|
23534
|
+
if (!environment || !secretName || secretValue === undefined) {
|
|
23535
|
+
throw new Error("add-secret requires <environment> <secretName> <secretValue> [--push]");
|
|
23536
|
+
}
|
|
23537
|
+
await addSecretCommand(environment, secretName, secretValue, shouldPush);
|
|
23538
|
+
return;
|
|
23539
|
+
}
|
|
23476
23540
|
throw new Error(`Unknown command: ${command}`);
|
|
23477
23541
|
};
|
|
23478
23542
|
main().catch((error) => {
|
package/package.json
CHANGED