replicas-cli 0.3.654 → 0.3.656

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 +84 -10
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -28471,7 +28471,7 @@ The user gets a form above the chat composer in Replicas, where they can paste a
28471
28471
 
28472
28472
  In workspaces started from Slack, Linear, or an automation, nobody may be watching Replicas, so the command returns right away with a link to the form; share it where you are talking with the user. If the values don't arrive in time, the request stays open. Either way you get a message when the user saves; run the same command again then. If a saved value is wrong, for example the service rejects it, add \`--replace\` to ask for a new one.
28473
28473
 
28474
- A value that starts with \`replicas_ph_\` is a proxied secret. Use it as the real key: Replicas swaps in the real value on HTTPS requests to the hosts the user bound it to, and it works nowhere else, including inside Docker containers.
28474
+ A value that starts with \`replicas_ph_\` is a proxied secret. Use it as the real key: Replicas swaps in the real value on HTTPS requests to the hosts the user bound it to, and it works nowhere else, including inside Docker containers. To proxy a variable or change its hosts, run \`replicas environment vars proxy <env> <key> <host...>\`: the user approves it above the chat, and you get a message with their answer.
28475
28475
 
28476
28476
  ### Environment files
28477
28477
 
@@ -43370,7 +43370,7 @@ var CLI_VERSION;
43370
43370
  var init_cli_version = __esm({
43371
43371
  "../shared/src/cli-version.ts"() {
43372
43372
  "use strict";
43373
- CLI_VERSION = "0.3.654";
43373
+ CLI_VERSION = "0.3.656";
43374
43374
  }
43375
43375
  });
43376
43376
 
@@ -44129,6 +44129,11 @@ var init_workspace_events = __esm({
44129
44129
  workspaceId: external_exports.string(),
44130
44130
  ts: external_exports.string()
44131
44131
  }),
44132
+ external_exports.object({
44133
+ type: external_exports.literal("approval-request.changed"),
44134
+ workspaceId: external_exports.string(),
44135
+ ts: external_exports.string()
44136
+ }),
44132
44137
  external_exports.object({
44133
44138
  type: external_exports.literal("pull-request.changed"),
44134
44139
  prUrl: external_exports.string(),
@@ -54507,6 +54512,29 @@ var init_local_control_requests = __esm({
54507
54512
  }
54508
54513
  });
54509
54514
 
54515
+ // ../shared/src/routes/approval-requests.ts
54516
+ var approvalChangeSchema, approvalRequestSchema, respondApprovalRequestSchema;
54517
+ var init_approval_requests = __esm({
54518
+ "../shared/src/routes/approval-requests.ts"() {
54519
+ "use strict";
54520
+ init_zod();
54521
+ approvalChangeSchema = external_exports.object({
54522
+ kind: external_exports.literal("variable_proxy_hosts"),
54523
+ environment_id: external_exports.string(),
54524
+ environment_name: external_exports.string(),
54525
+ variable_id: external_exports.string(),
54526
+ key: external_exports.string(),
54527
+ proxy_hosts: external_exports.array(external_exports.string())
54528
+ });
54529
+ approvalRequestSchema = external_exports.object({
54530
+ /** Changes whenever the request does, so an answer only counts for the changes the person saw. */
54531
+ id: external_exports.string(),
54532
+ changes: external_exports.array(approvalChangeSchema)
54533
+ });
54534
+ respondApprovalRequestSchema = external_exports.object({ id: external_exports.string(), action: external_exports.enum(["approved", "declined"]) });
54535
+ }
54536
+ });
54537
+
54510
54538
  // ../shared/src/websocket-liveness.ts
54511
54539
  function trackWebSocketLiveness(socket) {
54512
54540
  let answered = true;
@@ -54754,6 +54782,7 @@ var init_src = __esm({
54754
54782
  init_security_app_stand_ins();
54755
54783
  init_variable_requests();
54756
54784
  init_local_control_requests();
54785
+ init_approval_requests();
54757
54786
  init_api_casing();
54758
54787
  init_websocket_liveness();
54759
54788
  init_workspace_target();
@@ -57359,6 +57388,35 @@ async function repositoriesAddCommand(fullName, options) {
57359
57388
  await orgAuthenticatedFetch("/v1/repositories", { method: "POST", body: body2 });
57360
57389
  outputSuccess(`Added ${matched.label}`);
57361
57390
  }
57391
+ async function repositoriesImportGroupCommand(group, options) {
57392
+ const body2 = {
57393
+ group,
57394
+ include_subgroups: options.subgroups !== false
57395
+ };
57396
+ const result = await orgAuthenticatedFetch("/v1/gitlab/groups/import", {
57397
+ method: "POST",
57398
+ body: body2
57399
+ });
57400
+ output2(result, (res) => {
57401
+ const parts = [
57402
+ `Added ${res.added.length}`,
57403
+ res.already_connected > 0 ? `${res.already_connected} already connected` : null,
57404
+ res.failed.length > 0 ? `${res.failed.length} failed` : null
57405
+ ].filter(Boolean);
57406
+ console.log(import_chalk20.default.green(`
57407
+ Imported GitLab group ${res.group}: ${parts.join(", ")} (${res.total} total).
57408
+ `));
57409
+ if (res.has_more) {
57410
+ console.log(import_chalk20.default.yellow("Warning: GitLab returned more projects than the page limit. Import specific subgroups to connect the rest.\n"));
57411
+ }
57412
+ if (res.failed.length > 0) {
57413
+ for (const failure2 of res.failed) {
57414
+ console.log(import_chalk20.default.red(` \u2717 ${failure2.path}: ${failure2.error}`));
57415
+ }
57416
+ console.log();
57417
+ }
57418
+ });
57419
+ }
57362
57420
  async function repositoriesUpdateCommand(repository, options) {
57363
57421
  const [id] = await resolveRepositoryIds([repository]);
57364
57422
  const body2 = { default_branch: options.defaultBranch };
@@ -57572,13 +57630,30 @@ Variables (${environment_variables.length}):
57572
57630
  for (const v2 of environment_variables) printVariable(v2);
57573
57631
  });
57574
57632
  }
57575
- async function envVarsSetCommand(envIdOrName, key2, value, options) {
57633
+ async function findVariableByKey(environmentId, key2) {
57634
+ const { environment_variables } = await orgAuthenticatedFetch(`/v1/environments/${environmentId}/variables`);
57635
+ return environment_variables.find((v2) => v2.key === key2);
57636
+ }
57637
+ async function envVarsProxyCommand(envIdOrName, key2, hosts) {
57576
57638
  ensureOrgApiAuthenticated();
57577
57639
  const id = await resolveEnvironmentId(envIdOrName);
57578
- const existing = await orgAuthenticatedFetch(
57579
- `/v1/environments/${id}/variables`
57640
+ const match = await findVariableByKey(id, key2);
57641
+ if (!match) throw new Error(`No variable named ${key2} in this environment`);
57642
+ const body2 = { proxy_hosts: hosts };
57643
+ const response = await orgAuthenticatedFetch(
57644
+ `/v1/environments/${id}/variables/${match.id}`,
57645
+ { method: "PATCH", body: body2 }
57580
57646
  );
57581
- const match = existing.environment_variables.find((v2) => v2.key === key2);
57647
+ output2(response, (result) => console.log("message" in result ? import_chalk21.default.yellow(`
57648
+ ${result.message}
57649
+ `) : import_chalk21.default.green(`
57650
+ ${key2} is ${result.environment_variable.proxy_hosts.length > 0 ? `sent only to ${result.environment_variable.proxy_hosts.join(", ")}` : "no longer proxied"}.
57651
+ `)));
57652
+ }
57653
+ async function envVarsSetCommand(envIdOrName, key2, value, options) {
57654
+ ensureOrgApiAuthenticated();
57655
+ const id = await resolveEnvironmentId(envIdOrName);
57656
+ const match = await findVariableByKey(id, key2);
57582
57657
  if (match) {
57583
57658
  const body3 = { value, proxy_hosts: options.proxyHost };
57584
57659
  const response2 = await orgAuthenticatedFetch(
@@ -57609,10 +57684,7 @@ async function envVarsDeleteCommand(envIdOrName, keyOrId, options) {
57609
57684
  const id = await resolveEnvironmentId(envIdOrName);
57610
57685
  let variableId = keyOrId;
57611
57686
  if (!UUID_RE.test(keyOrId)) {
57612
- const existing = await orgAuthenticatedFetch(
57613
- `/v1/environments/${id}/variables`
57614
- );
57615
- const match = existing.environment_variables.find((v2) => v2.key === keyOrId);
57687
+ const match = await findVariableByKey(id, keyOrId);
57616
57688
  if (!match) throw new Error(`Variable not found: ${keyOrId}`);
57617
57689
  variableId = match.id;
57618
57690
  }
@@ -62608,6 +62680,7 @@ var init_src2 = __esm({
62608
62680
  repos.command("list").description("List all repositories").action(run(repositoriesListCommand));
62609
62681
  repos.command("available").description("List GitHub and GitLab repositories Replicas can add").option("--provider <provider>", "Filter by provider: github or gitlab").action(run(repositoriesAvailableCommand));
62610
62682
  repos.command("add <owner/name>").description("Add a GitHub or GitLab repository (admins only)").option("-b, --default-branch <branch>", "Default branch (defaults to the repository default)").option("--provider <provider>", "Provider: github or gitlab").action(run(repositoriesAddCommand));
62683
+ repos.command("import-group <group>").description("Connect all projects in a GitLab group (admins only)").option("--no-subgroups", "Only import direct projects in the group, excluding subgroups").action(run(repositoriesImportGroupCommand));
62611
62684
  repos.command("update <name-or-id>").description("Change the default branch of a repository (admins only)").requiredOption("-b, --default-branch <branch>", "New default branch").action(run(repositoriesUpdateCommand));
62612
62685
  repos.command("delete <name-or-id>").description("Remove a repository (admins only)").action(run(repositoriesDeleteCommand));
62613
62686
  repos.command("branches <name-or-id>").description("List branches of a repository").action(run(repositoriesBranchesCommand));
@@ -62664,6 +62737,7 @@ var init_src2 = __esm({
62664
62737
  envConfig.command("disconnect <env>").description("Disconnect Git configuration and preserve current settings").option("-y, --yes", "Disconnect without a confirmation prompt").action(run(environmentConfigDisconnectCommand));
62665
62738
  envVars = environment.command("vars").description("Manage environment variables");
62666
62739
  envVars.command("list <env>").description("List variables in an environment (values masked by default)").option("--reveal", "Show full variable values instead of masking them").action(run(envVarsListCommand));
62740
+ envVars.command("proxy <env> <key> [hosts...]").description("Send an existing variable only to these hosts, keeping its value out of workspaces; no hosts stops proxying it. From a workspace, the user has to approve it").action(run(envVarsProxyCommand));
62667
62741
  envVars.command("set <env> <key> <value>").description("Create or update a variable").option("--proxy-host <hosts...>", "Keep the value out of workspaces: they get a placeholder, swapped for the value only on HTTPS requests to these hosts").action(run(envVarsSetCommand));
62668
62742
  envVars.command("delete <env> <key-or-id>").description("Delete a variable by key or ID").option("-f, --force", "Skip confirmation prompt").action(run(envVarsDeleteCommand));
62669
62743
  if (isAgentMode()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.654",
3
+ "version": "0.3.656",
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": {