replicas-cli 0.3.455 → 0.3.456
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.cjs +24 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38877,7 +38877,7 @@ async function resolveReplicasEnvironmentConfig(entrypoint, loadInfra) {
|
|
|
38877
38877
|
selected = target.data;
|
|
38878
38878
|
if (selected.config.infra) return createErrorResult({ message: `${selected.filename}: nested infra pointers are not supported; declare an "environment" section`, code: 400 });
|
|
38879
38879
|
}
|
|
38880
|
-
if (!selected.config.environment) return createErrorResult({ message: `${selected.filename} needs an "environment" section before it can manage an environment`, code: 400 });
|
|
38880
|
+
if (!selected.config.environment) return createErrorResult({ message: `${selected.filename} needs an "environment" section${entrypoint.config.infra ? "" : ' or an "infra" pointer to a file containing one'} before it can manage an environment`, code: 400 });
|
|
38881
38881
|
return createSuccessResult({ filename: selected.filename, config: { ...entrypoint.config, environment: selected.config.environment } });
|
|
38882
38882
|
}
|
|
38883
38883
|
var import_yaml2, REPLICAS_CONFIG_FILENAMES;
|
|
@@ -39106,7 +39106,7 @@ var CLI_VERSION;
|
|
|
39106
39106
|
var init_cli_version = __esm({
|
|
39107
39107
|
"../shared/src/cli-version.ts"() {
|
|
39108
39108
|
"use strict";
|
|
39109
|
-
CLI_VERSION = "0.3.
|
|
39109
|
+
CLI_VERSION = "0.3.456";
|
|
39110
39110
|
}
|
|
39111
39111
|
});
|
|
39112
39112
|
|
|
@@ -56579,20 +56579,35 @@ function printSource({ source }) {
|
|
|
56579
56579
|
function printPreview({ preview: preview2 }) {
|
|
56580
56580
|
console.log(preview2.kind === "file" ? `${preview2.filename} @ ${preview2.file_sha}` : `${preview2.repository_name}/${preview2.filename} @ ${preview2.commit_sha}`);
|
|
56581
56581
|
if (preview2.source_url) console.log(preview2.source_url);
|
|
56582
|
-
|
|
56582
|
+
const requiredBefore = preview2.required_secrets?.before ?? [];
|
|
56583
|
+
const requiredAfter = preview2.required_secrets?.after ?? [];
|
|
56584
|
+
const addedSecrets = requiredAfter.filter((key) => !requiredBefore.includes(key));
|
|
56585
|
+
const removedSecrets = requiredBefore.filter((key) => !requiredAfter.includes(key));
|
|
56586
|
+
if (preview2.blockers.length || preview2.missing_secrets.length) console.log(import_chalk30.default.yellow("Cannot apply this configuration. No changes have been made."));
|
|
56587
|
+
if (!preview2.changes.length && !addedSecrets.length && !removedSecrets.length) console.log("No setting changes. Applying records this configuration.");
|
|
56588
|
+
else console.log("Proposed changes (not applied):");
|
|
56583
56589
|
for (const change of preview2.changes) console.log(` ${change.operation}: ${change.kind} ${change.key}`);
|
|
56590
|
+
for (const key of addedSecrets) console.log(` require: secret ${key}`);
|
|
56591
|
+
for (const key of removedSecrets) console.log(` stop requiring: secret ${key}`);
|
|
56584
56592
|
if (preview2.missing_secrets.length) console.log(import_chalk30.default.yellow(`Missing required secrets: ${preview2.missing_secrets.join(", ")}`));
|
|
56585
56593
|
for (const blocker of preview2.blockers) console.log(import_chalk30.default.red(` Cannot apply: ${blocker}`));
|
|
56586
56594
|
}
|
|
56595
|
+
async function readConfigFile(filename) {
|
|
56596
|
+
let content;
|
|
56597
|
+
try {
|
|
56598
|
+
content = await (0, import_promises2.readFile)(filename, "utf8");
|
|
56599
|
+
} catch (error62) {
|
|
56600
|
+
if (error62 instanceof Error && "code" in error62 && error62.code === "ENOENT") throw new Error(`Configuration file not found: ${filename}`);
|
|
56601
|
+
throw error62;
|
|
56602
|
+
}
|
|
56603
|
+
return { filename, config: parseReplicasConfigString(content, filename) };
|
|
56604
|
+
}
|
|
56587
56605
|
async function sourceInput2(options) {
|
|
56588
56606
|
if (options.file && options.repository) throw new Error("Choose either --file or --repository");
|
|
56589
56607
|
if (options.file) {
|
|
56590
|
-
const filename = options.file;
|
|
56591
|
-
const
|
|
56592
|
-
const result = await resolveReplicasEnvironmentConfig(
|
|
56593
|
-
const target = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(filename), pointer);
|
|
56594
|
-
return createSuccessResult({ filename: target, config: parseReplicasConfigString(await (0, import_promises2.readFile)(target, "utf8"), target) });
|
|
56595
|
-
});
|
|
56608
|
+
const filename = (0, import_node_path3.resolve)(options.file);
|
|
56609
|
+
const entrypoint = await readConfigFile(filename);
|
|
56610
|
+
const result = await resolveReplicasEnvironmentConfig(entrypoint, async (pointer) => createSuccessResult(await readConfigFile((0, import_node_path3.resolve)((0, import_node_path3.dirname)(filename), pointer))));
|
|
56596
56611
|
if (!result.ok) throw new Error(result.error.message);
|
|
56597
56612
|
return { file: { filename: result.data.filename, environment: result.data.config.environment } };
|
|
56598
56613
|
}
|