@fluid-app/fluid-cli-theme-dev 0.1.607 → 0.1.609
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.mjs +53 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -13292,9 +13292,16 @@ async function compareBranch(api, themeId, slug, entries) {
|
|
|
13292
13292
|
function previewPromotion(api, themeId, slug) {
|
|
13293
13293
|
return call(api.get(`${base(themeId)}/branches/${slug}/promotion`));
|
|
13294
13294
|
}
|
|
13295
|
-
/**
|
|
13296
|
-
|
|
13297
|
-
|
|
13295
|
+
/**
|
|
13296
|
+
* Promote the branch onto its parent theme. With `expectedSnapshotId`, the
|
|
13297
|
+
* server refuses (`branch_changed`) when the branch has moved past the
|
|
13298
|
+
* snapshot that was reviewed, so the live theme gets exactly that one.
|
|
13299
|
+
*/
|
|
13300
|
+
async function promoteBranch(api, themeId, slug, expectedSnapshotId) {
|
|
13301
|
+
return (await call(api.request(`${base(themeId)}/branches/${slug}/promotion`, expectedSnapshotId ? {
|
|
13302
|
+
method: "POST",
|
|
13303
|
+
body: { expected_snapshot_id: expectedSnapshotId }
|
|
13304
|
+
} : { method: "POST" }))).promotion;
|
|
13298
13305
|
}
|
|
13299
13306
|
/** Undo a promotion, putting the parent theme back as it was before it. */
|
|
13300
13307
|
async function undoPromotion(api, themeId, promotionId) {
|
|
@@ -13553,9 +13560,12 @@ const STAGING = "staging";
|
|
|
13553
13560
|
function readStagingPromotion(api, themeId) {
|
|
13554
13561
|
return previewPromotion(api, themeId, STAGING);
|
|
13555
13562
|
}
|
|
13556
|
-
/**
|
|
13557
|
-
|
|
13558
|
-
|
|
13563
|
+
/**
|
|
13564
|
+
* Promote staging onto the theme. Pass the snapshot the person reviewed so
|
|
13565
|
+
* a staging publication since then is refused rather than promoted unseen.
|
|
13566
|
+
*/
|
|
13567
|
+
function promoteStaging(api, themeId, expectedSnapshotId) {
|
|
13568
|
+
return promoteBranch(api, themeId, STAGING, expectedSnapshotId);
|
|
13559
13569
|
}
|
|
13560
13570
|
/** Undo staging's latest promotion, if it is still in place. */
|
|
13561
13571
|
async function undoStagingPromotion(api, themeId) {
|
|
@@ -13624,6 +13634,29 @@ async function run$1(opts, action) {
|
|
|
13624
13634
|
process.exitCode = 1;
|
|
13625
13635
|
}
|
|
13626
13636
|
}
|
|
13637
|
+
/** What promoting staging would do, for people. */
|
|
13638
|
+
function describePromotion(preview) {
|
|
13639
|
+
if (preview.state === "in_sync") {
|
|
13640
|
+
console.log("The live theme already serves what staging does.");
|
|
13641
|
+
return;
|
|
13642
|
+
}
|
|
13643
|
+
if (preview.state === "parent_changed") {
|
|
13644
|
+
console.log("The live theme changed since staging was based on it; promote can't merge that change.");
|
|
13645
|
+
return;
|
|
13646
|
+
}
|
|
13647
|
+
console.log("Promoting staging changes the live theme:");
|
|
13648
|
+
for (const path of preview.writes) console.log(chalk.yellow(` write ${path}`));
|
|
13649
|
+
for (const path of preview.removals) console.log(chalk.red(` remove ${path}`));
|
|
13650
|
+
}
|
|
13651
|
+
/** The latest promotion, for --dry-run's text output. */
|
|
13652
|
+
function describeLatestPromotion(latest) {
|
|
13653
|
+
if (!latest) {
|
|
13654
|
+
console.log("Staging has not been promoted yet.");
|
|
13655
|
+
return;
|
|
13656
|
+
}
|
|
13657
|
+
const by = latest.promoted_by?.name ?? "someone";
|
|
13658
|
+
console.log(latest.state === "undone" ? `Latest promotion: ${latest.promoted_at} by ${by}, undone ${latest.undone_at}.` : `Latest promotion: ${latest.promoted_at} by ${by}; undo it with \`fluid theme staging undo-promote\`.`);
|
|
13659
|
+
}
|
|
13627
13660
|
/**
|
|
13628
13661
|
* Whether to go ahead with a change to the live theme: --yes, or a yes at the
|
|
13629
13662
|
* terminal. JSON mode never prompts, so it needs --yes.
|
|
@@ -13697,11 +13730,21 @@ function createStagingCommand() {
|
|
|
13697
13730
|
for (const path of compared.localOnly) console.log(chalk.green(` local only ${path}`));
|
|
13698
13731
|
for (const path of compared.branchOnly) console.log(chalk.red(` staging only ${path}`));
|
|
13699
13732
|
}));
|
|
13700
|
-
const promote = withThemeOptions$1(new Command("promote").description("Copy what staging serves onto the live theme, all at once, if the live theme hasn't changed since staging was based on it")).option("-y, --yes", "Promote without asking").action((opts) => run$1(opts, async () => {
|
|
13733
|
+
const promote = withThemeOptions$1(new Command("promote").description("Copy what staging serves onto the live theme, all at once, if the live theme hasn't changed since staging was based on it")).option("-y, --yes", "Promote without asking").option("--dry-run", "Show what promoting would change and the latest promotion; nothing is changed").option("--snapshot <id>", "Promote only this staging snapshot (a preview's snapshot_id); refuse if staging has changed since").action((opts) => run$1(opts, async () => {
|
|
13701
13734
|
requireToken();
|
|
13702
13735
|
const api = createApiClient();
|
|
13703
13736
|
const themeId = resolveThemeId(opts);
|
|
13704
|
-
const
|
|
13737
|
+
const read = await readStagingPromotion(api, themeId);
|
|
13738
|
+
const { preview } = read;
|
|
13739
|
+
if (opts.dryRun) {
|
|
13740
|
+
if (opts.json) console.log(JSON.stringify(read));
|
|
13741
|
+
else {
|
|
13742
|
+
describePromotion(preview);
|
|
13743
|
+
describeLatestPromotion(read.latest_promotion);
|
|
13744
|
+
}
|
|
13745
|
+
return;
|
|
13746
|
+
}
|
|
13747
|
+
if (opts.snapshot && preview.snapshot_id && opts.snapshot !== preview.snapshot_id) throw new Error("Staging changed since it was reviewed. Review what promoting would change again before promoting.");
|
|
13705
13748
|
if (preview.state === "in_sync") {
|
|
13706
13749
|
if (opts.json) console.log(JSON.stringify({
|
|
13707
13750
|
promotion: null,
|
|
@@ -13711,16 +13754,12 @@ function createStagingCommand() {
|
|
|
13711
13754
|
return;
|
|
13712
13755
|
}
|
|
13713
13756
|
if (preview.state === "parent_changed") throw new Error("The live theme changed since staging was based on it, so promoting would overwrite that change. Push your files with `fluid theme push` instead.");
|
|
13714
|
-
if (!opts.json)
|
|
13715
|
-
console.log("Promoting staging changes the live theme:");
|
|
13716
|
-
for (const path of preview.writes) console.log(chalk.yellow(` write ${path}`));
|
|
13717
|
-
for (const path of preview.removals) console.log(chalk.red(` remove ${path}`));
|
|
13718
|
-
}
|
|
13757
|
+
if (!opts.json) describePromotion(preview);
|
|
13719
13758
|
if (!await approved(opts, "Promote staging to the live theme?")) {
|
|
13720
13759
|
console.log("Not promoted.");
|
|
13721
13760
|
return;
|
|
13722
13761
|
}
|
|
13723
|
-
const promotion = await promoteStaging(api, themeId);
|
|
13762
|
+
const promotion = await promoteStaging(api, themeId, opts.snapshot ?? preview.snapshot_id);
|
|
13724
13763
|
if (opts.json) {
|
|
13725
13764
|
console.log(JSON.stringify({
|
|
13726
13765
|
promotion,
|