@fabricorg/cli 0.3.4 → 0.3.5

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/fabric.js CHANGED
@@ -57,7 +57,7 @@ import { Command as Command20 } from "commander";
57
57
  // package.json
58
58
  var package_default = {
59
59
  name: "@fabricorg/cli",
60
- version: "0.3.4",
60
+ version: "0.3.5",
61
61
  description: "CLI for the Fabric AI platform",
62
62
  keywords: [
63
63
  "fabric",
@@ -2844,12 +2844,15 @@ function buildInstructionsCommand() {
2844
2844
  });
2845
2845
  });
2846
2846
  instructions.command("push").description(
2847
- "Suggest this checkout's edits to the project's coding instructions"
2847
+ "Propose this checkout's edits to the project's coding instructions, or publish them with --publish"
2848
2848
  ).requiredOption("--project <id>", "Project ID").option("--dest <dir>", "Destination directory (default: cwd)").option("--org <slug>", "Organization context").option(
2849
2849
  "--add <path>",
2850
2850
  "Also send a file the last sync did not write (repeatable)",
2851
2851
  collectAdded,
2852
2852
  []
2853
+ ).option(
2854
+ "--publish",
2855
+ "Publish the change as a new version instead of proposing it (needs a key with instructions:publish)"
2853
2856
  ).option("--dry-run", "Print the change set and send nothing").option("--format <format>", "Output format: text|json").action(function(opts) {
2854
2857
  return __async(this, null, function* () {
2855
2858
  yield run(
@@ -3347,6 +3350,7 @@ function runPush(opts, format) {
3347
3350
  projectId: opts.project,
3348
3351
  destination: root,
3349
3352
  dryRun: Boolean(opts.dryRun),
3353
+ publish: Boolean(opts.publish),
3350
3354
  baseSnapshotId: lock.snapshotId,
3351
3355
  baseVersion: lock.snapshotVersion,
3352
3356
  put: plan.entries.filter((entry) => entry.action === "put").map((entry) => entry.path),
@@ -3355,11 +3359,17 @@ function runPush(opts, format) {
3355
3359
  snapshotId: null,
3356
3360
  version: null,
3357
3361
  proposalStatus: null,
3358
- status: null
3362
+ status: null,
3363
+ published: null
3359
3364
  };
3360
3365
  if (!opts.dryRun) {
3361
3366
  try {
3362
- const submitted = yield client.instructions.submitChange(
3367
+ const submitted = opts.publish ? yield client.instructions.publishChange(
3368
+ opts.project,
3369
+ lock.snapshotId,
3370
+ plan.changes,
3371
+ { org: orgSlugFor(opts) }
3372
+ ) : yield client.instructions.submitChange(
3363
3373
  opts.project,
3364
3374
  lock.snapshotId,
3365
3375
  plan.changes,
@@ -3369,6 +3379,7 @@ function runPush(opts, format) {
3369
3379
  outcome.version = submitted.version;
3370
3380
  outcome.proposalStatus = submitted.proposalStatus;
3371
3381
  outcome.status = submitted.status;
3382
+ outcome.published = submitted.published;
3372
3383
  } catch (error) {
3373
3384
  throw asPushFailure(error);
3374
3385
  }
@@ -3408,6 +3419,16 @@ function asPushFailure(error) {
3408
3419
  }
3409
3420
  function pushVerdict(outcome) {
3410
3421
  var _a2;
3422
+ if (outcome.publish) {
3423
+ if (outcome.published) {
3424
+ return `Published version ${outcome.version}. Run \`fabric instructions sync\` to bring this checkout onto it.`;
3425
+ }
3426
+ if (outcome.status === "FAILED" || outcome.status === "REJECTED") {
3427
+ return `Version ${outcome.version} did not pass its checks (${outcome.status}), so nothing was published; open the project's Coding Instructions tab to see why.`;
3428
+ }
3429
+ const sent = `Sent as version ${outcome.version}. It publishes on its own once its checks pass (${outcome.status}) \u2014 then run \`fabric instructions sync\` to bring this checkout onto it.`;
3430
+ return outcome.status === "READY" ? `${sent} It has passed its checks; its publication state is shown in the project's Coding Instructions tab.` : sent;
3431
+ }
3411
3432
  if (outcome.proposalStatus === "PENDING" && outcome.status === "RECEIVING") {
3412
3433
  return `An earlier attempt is still sending this change; if version ${outcome.version} stays unfinished, cancel it in the project's Coding Instructions tab, or leave it and it is closed out automatically after six hours.`;
3413
3434
  }
@@ -3434,13 +3455,13 @@ function reportPush(outcome) {
3434
3455
  listPaths("deleted", outcome.deleted);
3435
3456
  if (outcome.dryRun) {
3436
3457
  line(
3437
- "Nothing was sent. Without --dry-run this would open a proposal for review."
3458
+ outcome.publish ? "Nothing was sent. Without --dry-run this would create a new version that publishes on its own once its checks pass, with no review." : "Nothing was sent. Without --dry-run this would open a proposal for review."
3438
3459
  );
3439
3460
  return;
3440
3461
  }
3441
3462
  line(pushVerdict(outcome));
3442
3463
  line(
3443
- "Your lock was not changed: it still names the published version, which is what `fabric instructions sync` compares against."
3464
+ outcome.publish ? `Your lock was not changed: it still names version ${outcome.baseVersion}, which is what \`fabric instructions sync\` compares against.` : "Your lock was not changed: it still names the published version, which is what `fabric instructions sync` compares against."
3444
3465
  );
3445
3466
  }
3446
3467
  function runInit(opts, format) {