@wayai/cli 0.3.175 → 0.3.176

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.js CHANGED
@@ -27037,9 +27037,25 @@ async function pullCommand(args2) {
27037
27037
  wroteFiles = true;
27038
27038
  } else {
27039
27039
  let action = "overwrite";
27040
+ let localPayload;
27040
27041
  try {
27041
- const localPayload = parseHubFolder(hubFolder);
27042
- const diffResult = await client.diff(hubId, prepareResourcePayload(localPayload, payload), "pull", organizationId);
27042
+ localPayload = parseHubFolder(hubFolder);
27043
+ } catch (err) {
27044
+ if (isWorkspaceRefusal(err)) throw err;
27045
+ }
27046
+ let diffResult;
27047
+ if (localPayload) {
27048
+ try {
27049
+ diffResult = await client.diff(hubId, prepareResourcePayload(localPayload, payload), "pull", organizationId);
27050
+ } catch (err) {
27051
+ if (!await confirmReplaceWithoutDiff(err, hubFolder, hubId, autoConfirm)) {
27052
+ console.log("Cancelled.");
27053
+ return;
27054
+ }
27055
+ }
27056
+ }
27057
+ if (localPayload && diffResult) {
27058
+ printWarnings(diffResult.warnings);
27043
27059
  const connectionsChanged = !connectionsEqual(localPayload.connections, payload.connections);
27044
27060
  if (!diffResult.has_changes && !connectionsChanged) {
27045
27061
  action = "sync_metadata";
@@ -27058,9 +27074,6 @@ async function pullCommand(args2) {
27058
27074
  }
27059
27075
  action = "apply";
27060
27076
  }
27061
- } catch (err) {
27062
- if (isWorkspaceRefusal(err)) throw err;
27063
- action = "overwrite";
27064
27077
  }
27065
27078
  if (action === "overwrite") console.log("Writing hub configuration...");
27066
27079
  const delta = await materializeHubFolder(hubFolder, payload);
@@ -27082,6 +27095,17 @@ async function pullCommand(args2) {
27082
27095
  await mirrorLinkedProduction2(client, workspaceDir, payload.production_hub_id, organizationId);
27083
27096
  }
27084
27097
  }
27098
+ async function confirmReplaceWithoutDiff(err, hubFolder, hubId, autoConfirm) {
27099
+ console.log("\nThe platform could not compare your local files, so the changes cannot be listed:");
27100
+ console.log(` ${err instanceof Error ? err.message : String(err)}`);
27101
+ if (!autoConfirm) {
27102
+ return confirm("Replace the local files with the platform configuration, discarding any local edits?");
27103
+ }
27104
+ console.error(
27105
+ `Nothing was written: -y replaces local files only with changes it can list. To decide, run \`wayai pull\` without -y. To re-pull fresh, move ${hubFolder} out of the workspace and run \`wayai pull --hub ${hubId}\`.`
27106
+ );
27107
+ throw err;
27108
+ }
27085
27109
  async function writeProductionMirror2(workspaceDir, prodPayload) {
27086
27110
  const folder = resolveHubFolder(workspaceDir, prodPayload.hub_id, prodPayload.hub.name, "production", null, null);
27087
27111
  fs18.mkdirSync(path24.dirname(folder), { recursive: true });