@wayai/cli 0.3.282 → 0.3.283

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
@@ -27776,53 +27776,60 @@ async function syncAfterPush(client, hubId, hubFolder, pushed, organizationId) {
27776
27776
  }
27777
27777
  }
27778
27778
  async function pushSingleHub(client, hubId, hubFolder, autoConfirm, organizationId, opts) {
27779
- assertSkillsLayout(hubFolder);
27780
- let remoteConfig;
27779
+ let landed = false;
27781
27780
  try {
27782
- remoteConfig = await client.pull(hubId, organizationId);
27783
- } catch (err) {
27784
- const fallbackConfig = parseHubFolder(hubFolder);
27785
- assertResourcePayloadFitsWithoutPruning(fallbackConfig, err);
27786
- }
27787
- if (!opts?.skipAgentRename) {
27788
- await autoRenameAgentFiles(client, hubId, hubFolder, organizationId, remoteConfig);
27789
- }
27790
- console.log("Parsing local configuration...");
27791
- const localConfig = parseHubFolder(hubFolder);
27792
- const wireConfig = remoteConfig ? prepareResourcePayload(localConfig, remoteConfig) : localConfig;
27793
- console.log("Computing diff...");
27794
- const diffResult = await client.diff(hubId, wireConfig, "push", organizationId);
27795
- printWarnings([...diffResult.warnings, ...pageDesignWarnings(localConfig.pages)]);
27796
- if (shouldWarnIgnoredPreviewLabel(localConfig.preview_label, diffResult.preview_label)) {
27797
- console.warn(
27798
- `Note: preview_label "${localConfig.preview_label}" in hub.yaml is server-owned and ignored on push (server value: ${diffResult.preview_label ?? "none"}). Use \`wayai relabel\` to change it.`
27799
- );
27800
- }
27801
- if (!diffResult.has_changes) {
27802
- const finalFolder = autoRenameHubFolder(hubFolder, localConfig.hub.name, localConfig.hub_environment, hubId, localConfig.preview_label, localConfig.branch_name);
27803
- if (finalFolder === hubFolder) {
27804
- console.log("No changes to push.");
27805
- } else {
27806
- console.log("No changes to push; folder renamed.");
27781
+ assertSkillsLayout(hubFolder);
27782
+ let remoteConfig;
27783
+ try {
27784
+ remoteConfig = await client.pull(hubId, organizationId);
27785
+ } catch (err) {
27786
+ const fallbackConfig = parseHubFolder(hubFolder);
27787
+ assertResourcePayloadFitsWithoutPruning(fallbackConfig, err);
27788
+ }
27789
+ if (!opts?.skipAgentRename) {
27790
+ await autoRenameAgentFiles(client, hubId, hubFolder, organizationId, remoteConfig);
27791
+ }
27792
+ console.log("Parsing local configuration...");
27793
+ const localConfig = parseHubFolder(hubFolder);
27794
+ const wireConfig = remoteConfig ? prepareResourcePayload(localConfig, remoteConfig) : localConfig;
27795
+ console.log("Computing diff...");
27796
+ const diffResult = await client.diff(hubId, wireConfig, "push", organizationId);
27797
+ printWarnings([...diffResult.warnings, ...pageDesignWarnings(localConfig.pages)]);
27798
+ if (shouldWarnIgnoredPreviewLabel(localConfig.preview_label, diffResult.preview_label)) {
27799
+ console.warn(
27800
+ `Note: preview_label "${localConfig.preview_label}" in hub.yaml is server-owned and ignored on push (server value: ${diffResult.preview_label ?? "none"}). Use \`wayai relabel\` to change it.`
27801
+ );
27802
+ }
27803
+ if (!diffResult.has_changes) {
27804
+ landed = true;
27805
+ const finalFolder = autoRenameHubFolder(hubFolder, localConfig.hub.name, localConfig.hub_environment, hubId, localConfig.preview_label, localConfig.branch_name);
27806
+ if (finalFolder === hubFolder) {
27807
+ console.log("No changes to push.");
27808
+ } else {
27809
+ console.log("No changes to push; folder renamed.");
27810
+ }
27811
+ seedScopeIfEmpty("hubs", hubId);
27812
+ return true;
27813
+ }
27814
+ console.log("\nChanges to push:");
27815
+ printDiff(diffResult.summary);
27816
+ if (!autoConfirm) {
27817
+ const ok = await confirm("Push these changes?");
27818
+ if (!ok) {
27819
+ console.log("Cancelled.");
27820
+ return false;
27821
+ }
27807
27822
  }
27823
+ console.log("Pushing changes...");
27824
+ const result = await client.push(hubId, wireConfig, organizationId);
27825
+ printSyncResult(result);
27826
+ landed = true;
27827
+ await syncAfterPush(client, hubId, hubFolder, localConfig, organizationId);
27808
27828
  seedScopeIfEmpty("hubs", hubId);
27809
27829
  return true;
27830
+ } finally {
27831
+ if (!landed) opts?.onNotPushed?.();
27810
27832
  }
27811
- console.log("\nChanges to push:");
27812
- printDiff(diffResult.summary);
27813
- if (!autoConfirm) {
27814
- const ok = await confirm("Push these changes?");
27815
- if (!ok) {
27816
- console.log("Cancelled.");
27817
- return false;
27818
- }
27819
- }
27820
- console.log("Pushing changes...");
27821
- const result = await client.push(hubId, wireConfig, organizationId);
27822
- printSyncResult(result);
27823
- await syncAfterPush(client, hubId, hubFolder, localConfig, organizationId);
27824
- seedScopeIfEmpty("hubs", hubId);
27825
- return true;
27826
27833
  }
27827
27834
  function selectExistingHub(workspaceDir, allHubs, selector, wsLabel) {
27828
27835
  if (selector !== void 0) {
@@ -27896,7 +27903,14 @@ ${content}`;
27896
27903
  }
27897
27904
  writeFileNoFollow(newHub.hubFolder, hubYamlPath, Buffer.from(updated, "utf-8"));
27898
27905
  seedScopeIfEmpty("hubs", hubId);
27899
- await pushSingleHub(client, hubId, newHub.hubFolder, opts.autoConfirm, opts.organizationId, { skipAgentRename: true });
27906
+ const folder = path30.basename(newHub.hubFolder);
27907
+ await pushSingleHub(client, hubId, newHub.hubFolder, opts.autoConfirm, opts.organizationId, {
27908
+ skipAgentRename: true,
27909
+ onNotPushed: () => console.error(
27910
+ `
27911
+ Hub "${createdHub.hub_name}" (${hubId}) was created and its hub_id written to ${folder}/hub.yaml, but its first push did not land. Once the folder is ready, run \`wayai push --hub ${folder}\` (not \`wayai create\`).`
27912
+ )
27913
+ });
27900
27914
  }
27901
27915
  function reportUnresolvedPushTarget(reason, existingHubs, newHubs, selector, wsLabel, hint = null) {
27902
27916
  if (reason === "none") {
@@ -28271,7 +28285,8 @@ var init_pull = __esm({
28271
28285
  var create_exports = {};
28272
28286
  __export(create_exports, {
28273
28287
  createCommand: () => createCommand,
28274
- parseArgs: () => parseArgs8
28288
+ parseArgs: () => parseArgs8,
28289
+ reportNoNewHub: () => reportNoNewHub
28275
28290
  });
28276
28291
  import * as path32 from "path";
28277
28292
  import * as fs23 from "fs";
@@ -28291,6 +28306,19 @@ function parseArgs8(args2) {
28291
28306
  }
28292
28307
  return { autoConfirm, folderSelector, label: label2 };
28293
28308
  }
28309
+ function reportNoNewHub(enclosing, existingHubs, wsLabel) {
28310
+ const created = enclosing ? [] : filterPreviewHubs(existingHubs);
28311
+ if (enclosing && isPreviewHub(enclosing)) {
28312
+ const folder = path32.basename(enclosing.hubFolder);
28313
+ console.error(`Hub "${folder}" already exists (${enclosing.hubId}). Use \`wayai push --hub ${folder}\` to update it.`);
28314
+ } else if (created.length > 0) {
28315
+ console.error(`Every hub folder in ${wsLabel}/ is already created. Push one with \`wayai push --hub <folder>\`, or create ${wsLabel}/<hub>/hub.yaml with \`hub: { name: ... }\` for a new hub:`);
28316
+ for (const h of created) console.error(` ${path32.basename(h.hubFolder)} (${h.hubId})`);
28317
+ } else {
28318
+ console.error(`No new (uncreated) hub folders found in ${wsLabel}/. Create ${wsLabel}/<hub>/hub.yaml with \`hub: { name: ... }\` first, then run \`wayai create\`.`);
28319
+ }
28320
+ process.exit(1);
28321
+ }
28294
28322
  async function createCommand(args2) {
28295
28323
  const { autoConfirm, folderSelector, label: label2 } = parseArgs8(args2);
28296
28324
  const repoConfig = requireRepoConfig();
@@ -28318,10 +28346,7 @@ async function createCommand(args2) {
28318
28346
  console.error(`No new (uncreated) hub folder "${folderSelector}" found in ${wsLabel}/. A new hub folder needs a hub.yaml with \`hub: { name: ... }\` and no hub_id.`);
28319
28347
  process.exit(1);
28320
28348
  }
28321
- if (resolution.reason === "none") {
28322
- console.error(`No new (uncreated) hub folders found in ${wsLabel}/. Create ${wsLabel}/<hub>/hub.yaml with \`hub: { name: ... }\` first, then run \`wayai create\`.`);
28323
- process.exit(1);
28324
- }
28349
+ if (resolution.reason === "none") reportNoNewHub(findEnclosingHubFolder(workspaceDir), existingHubs, wsLabel);
28325
28350
  console.error(`Multiple new hub folders found in ${wsLabel}/. Pass the folder name (\`wayai create <folder>\`) or run from inside one:`);
28326
28351
  for (const h of newHubs) {
28327
28352
  console.error(` ${path32.basename(h.hubFolder)} (new \u2014 "${h.hubName}")`);