replicas-cli 0.3.454 → 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.
Files changed (2) hide show
  1. package/dist/index.cjs +24 -10
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -26672,7 +26672,6 @@ var init_preferences = __esm({
26672
26672
  auto_draft_prs: false,
26673
26673
  open_prs_in_graphite: false,
26674
26674
  open_links_in_desktop_app: false,
26675
- port_forwarding: false,
26676
26675
  local_control: false,
26677
26676
  spotify_controls: false,
26678
26677
  appshot_shortcut: "command",
@@ -38878,7 +38877,7 @@ async function resolveReplicasEnvironmentConfig(entrypoint, loadInfra) {
38878
38877
  selected = target.data;
38879
38878
  if (selected.config.infra) return createErrorResult({ message: `${selected.filename}: nested infra pointers are not supported; declare an "environment" section`, code: 400 });
38880
38879
  }
38881
- 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 });
38882
38881
  return createSuccessResult({ filename: selected.filename, config: { ...entrypoint.config, environment: selected.config.environment } });
38883
38882
  }
38884
38883
  var import_yaml2, REPLICAS_CONFIG_FILENAMES;
@@ -39107,7 +39106,7 @@ var CLI_VERSION;
39107
39106
  var init_cli_version = __esm({
39108
39107
  "../shared/src/cli-version.ts"() {
39109
39108
  "use strict";
39110
- CLI_VERSION = "0.3.454";
39109
+ CLI_VERSION = "0.3.456";
39111
39110
  }
39112
39111
  });
39113
39112
 
@@ -56580,20 +56579,35 @@ function printSource({ source }) {
56580
56579
  function printPreview({ preview: preview2 }) {
56581
56580
  console.log(preview2.kind === "file" ? `${preview2.filename} @ ${preview2.file_sha}` : `${preview2.repository_name}/${preview2.filename} @ ${preview2.commit_sha}`);
56582
56581
  if (preview2.source_url) console.log(preview2.source_url);
56583
- if (!preview2.changes.length) console.log("No setting changes. Applying records this configuration.");
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):");
56584
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}`);
56585
56592
  if (preview2.missing_secrets.length) console.log(import_chalk30.default.yellow(`Missing required secrets: ${preview2.missing_secrets.join(", ")}`));
56586
56593
  for (const blocker of preview2.blockers) console.log(import_chalk30.default.red(` Cannot apply: ${blocker}`));
56587
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
+ }
56588
56605
  async function sourceInput2(options) {
56589
56606
  if (options.file && options.repository) throw new Error("Choose either --file or --repository");
56590
56607
  if (options.file) {
56591
- const filename = options.file;
56592
- const config3 = parseReplicasConfigString(await (0, import_promises2.readFile)(filename, "utf8"), filename);
56593
- const result = await resolveReplicasEnvironmentConfig({ filename, config: config3 }, async (pointer) => {
56594
- const target = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(filename), pointer);
56595
- return createSuccessResult({ filename: target, config: parseReplicasConfigString(await (0, import_promises2.readFile)(target, "utf8"), target) });
56596
- });
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))));
56597
56611
  if (!result.ok) throw new Error(result.error.message);
56598
56612
  return { file: { filename: result.data.filename, environment: result.data.config.environment } };
56599
56613
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.454",
3
+ "version": "0.3.456",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {