@fluid-app/fluid-cli-theme-dev 0.1.600 → 0.1.602
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/README.md +13 -0
- package/dist/index.mjs +91 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -493,6 +493,19 @@ replace the widget.
|
|
|
493
493
|
after publishing, since Fluid may rewrite keys; pull to take staging's
|
|
494
494
|
version.
|
|
495
495
|
|
|
496
|
+
### Promoting staging to live
|
|
497
|
+
|
|
498
|
+
`fluid theme staging promote` copies exactly what staging serves onto the
|
|
499
|
+
live theme, all at once. It lists the files it will write and remove and asks
|
|
500
|
+
first; pass `--yes` to skip the question (JSON mode always needs `--yes`). It
|
|
501
|
+
only promotes when the live theme hasn't changed since staging was based on
|
|
502
|
+
it; otherwise it refuses rather than overwrite that change. Images and other
|
|
503
|
+
binary files are copied to assets the live theme owns.
|
|
504
|
+
|
|
505
|
+
`fluid theme staging undo-promote` puts the live theme back as it was before
|
|
506
|
+
the latest promotion, while the live theme still serves exactly what that
|
|
507
|
+
promotion applied.
|
|
508
|
+
|
|
496
509
|
### Comparing with staging
|
|
497
510
|
|
|
498
511
|
`fluid theme staging compare` reports how this directory's files differ from
|
package/dist/index.mjs
CHANGED
|
@@ -13288,6 +13288,18 @@ async function compareBranch(api, themeId, slug, entries) {
|
|
|
13288
13288
|
body: { entries }
|
|
13289
13289
|
}))).comparison;
|
|
13290
13290
|
}
|
|
13291
|
+
/** Where a branch stands against its parent theme, and its latest promotion. */
|
|
13292
|
+
function previewPromotion(api, themeId, slug) {
|
|
13293
|
+
return call(api.get(`${base(themeId)}/branches/${slug}/promotion`));
|
|
13294
|
+
}
|
|
13295
|
+
/** Promote the branch onto its parent theme. */
|
|
13296
|
+
async function promoteBranch(api, themeId, slug) {
|
|
13297
|
+
return (await call(api.request(`${base(themeId)}/branches/${slug}/promotion`, { method: "POST" }))).promotion;
|
|
13298
|
+
}
|
|
13299
|
+
/** Undo a promotion, putting the parent theme back as it was before it. */
|
|
13300
|
+
async function undoPromotion(api, themeId, promotionId) {
|
|
13301
|
+
return (await call(api.request(`${base(themeId)}/branch-promotions/${promotionId}/undo`, { method: "POST" }))).promotion;
|
|
13302
|
+
}
|
|
13291
13303
|
/**
|
|
13292
13304
|
* Upload one declared content as raw bytes. The shared client always sends
|
|
13293
13305
|
* JSON, so this goes through fetch with the same base URL and token.
|
|
@@ -13535,6 +13547,23 @@ async function compareWithStaging(api, themeId, root) {
|
|
|
13535
13547
|
};
|
|
13536
13548
|
}
|
|
13537
13549
|
//#endregion
|
|
13550
|
+
//#region src/theme/staging-promote.ts
|
|
13551
|
+
const STAGING = "staging";
|
|
13552
|
+
/** What promoting staging would change, and its latest promotion. */
|
|
13553
|
+
function readStagingPromotion(api, themeId) {
|
|
13554
|
+
return previewPromotion(api, themeId, STAGING);
|
|
13555
|
+
}
|
|
13556
|
+
/** Promote staging onto the theme. */
|
|
13557
|
+
function promoteStaging(api, themeId) {
|
|
13558
|
+
return promoteBranch(api, themeId, STAGING);
|
|
13559
|
+
}
|
|
13560
|
+
/** Undo staging's latest promotion, if it is still in place. */
|
|
13561
|
+
async function undoStagingPromotion(api, themeId) {
|
|
13562
|
+
const { latest_promotion: latest } = await readStagingPromotion(api, themeId);
|
|
13563
|
+
if (!latest || latest.state !== "promoted") throw new Error("Nothing to undo: staging has no promotion in place.");
|
|
13564
|
+
return undoPromotion(api, themeId, latest.id);
|
|
13565
|
+
}
|
|
13566
|
+
//#endregion
|
|
13538
13567
|
//#region src/commands/staging.ts
|
|
13539
13568
|
/**
|
|
13540
13569
|
* The production theme staging belongs to: --theme, else the theme this
|
|
@@ -13595,6 +13624,21 @@ async function run$1(opts, action) {
|
|
|
13595
13624
|
process.exitCode = 1;
|
|
13596
13625
|
}
|
|
13597
13626
|
}
|
|
13627
|
+
/**
|
|
13628
|
+
* Whether to go ahead with a change to the live theme: --yes, or a yes at the
|
|
13629
|
+
* terminal. JSON mode never prompts, so it needs --yes.
|
|
13630
|
+
*/
|
|
13631
|
+
async function approved(opts, question) {
|
|
13632
|
+
if (opts.yes) return true;
|
|
13633
|
+
if (opts.json || !process.stdin.isTTY) throw new Error("This changes the live theme; pass --yes to go ahead without a prompt.");
|
|
13634
|
+
const { confirmed } = await prompts({
|
|
13635
|
+
type: "confirm",
|
|
13636
|
+
name: "confirmed",
|
|
13637
|
+
message: question,
|
|
13638
|
+
initial: false
|
|
13639
|
+
}, { onCancel: () => process.exit(130) });
|
|
13640
|
+
return confirmed === true;
|
|
13641
|
+
}
|
|
13598
13642
|
function report(status, json) {
|
|
13599
13643
|
if (json) {
|
|
13600
13644
|
console.log(JSON.stringify(stagingJson(status)));
|
|
@@ -13653,7 +13697,53 @@ function createStagingCommand() {
|
|
|
13653
13697
|
for (const path of compared.localOnly) console.log(chalk.green(` local only ${path}`));
|
|
13654
13698
|
for (const path of compared.branchOnly) console.log(chalk.red(` staging only ${path}`));
|
|
13655
13699
|
}));
|
|
13656
|
-
|
|
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 () => {
|
|
13701
|
+
requireToken();
|
|
13702
|
+
const api = createApiClient();
|
|
13703
|
+
const themeId = resolveThemeId(opts);
|
|
13704
|
+
const { preview } = await readStagingPromotion(api, themeId);
|
|
13705
|
+
if (preview.state === "in_sync") {
|
|
13706
|
+
if (opts.json) console.log(JSON.stringify({
|
|
13707
|
+
promotion: null,
|
|
13708
|
+
preview
|
|
13709
|
+
}));
|
|
13710
|
+
else console.log("The live theme already serves what staging does.");
|
|
13711
|
+
return;
|
|
13712
|
+
}
|
|
13713
|
+
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
|
+
}
|
|
13719
|
+
if (!await approved(opts, "Promote staging to the live theme?")) {
|
|
13720
|
+
console.log("Not promoted.");
|
|
13721
|
+
return;
|
|
13722
|
+
}
|
|
13723
|
+
const promotion = await promoteStaging(api, themeId);
|
|
13724
|
+
if (opts.json) {
|
|
13725
|
+
console.log(JSON.stringify({
|
|
13726
|
+
promotion,
|
|
13727
|
+
preview
|
|
13728
|
+
}));
|
|
13729
|
+
return;
|
|
13730
|
+
}
|
|
13731
|
+
console.log(`Promoted: ${preview.writes.length} files written and ${preview.removals.length} removed on the live theme. Undo with \`fluid theme staging undo-promote\`.`);
|
|
13732
|
+
}));
|
|
13733
|
+
const undoPromote = withThemeOptions$1(new Command("undo-promote").description("Put the live theme back as it was before staging's latest promotion")).option("-y, --yes", "Undo without asking").action((opts) => run$1(opts, async () => {
|
|
13734
|
+
requireToken();
|
|
13735
|
+
if (!await approved(opts, "Put the live theme back as it was before the latest promotion?")) {
|
|
13736
|
+
console.log("Not undone.");
|
|
13737
|
+
return;
|
|
13738
|
+
}
|
|
13739
|
+
const promotion = await undoStagingPromotion(createApiClient(), resolveThemeId(opts));
|
|
13740
|
+
if (opts.json) {
|
|
13741
|
+
console.log(JSON.stringify({ promotion }));
|
|
13742
|
+
return;
|
|
13743
|
+
}
|
|
13744
|
+
console.log(`Undid the promotion of ${promotion.promoted_at}${promotion.promoted_by.name ? ` by ${promotion.promoted_by.name}` : ""}.`);
|
|
13745
|
+
}));
|
|
13746
|
+
return new Command("staging").description("Use the theme's staging branch, previewed by a signed link (needs branch environments)").addCommand(status).addCommand(request).addCommand(wait).addCommand(publish).addCommand(promote).addCommand(undoPromote).addCommand(compare);
|
|
13657
13747
|
}
|
|
13658
13748
|
//#endregion
|
|
13659
13749
|
//#region src/commands/widget.ts
|