@fluid-app/fluid-cli-theme-dev 0.1.521 → 0.1.523
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 +33 -0
- package/dist/index.mjs +665 -61
- package/dist/index.mjs.map +1 -1
- package/dist/skills/themes-review/SKILL.md +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -476,7 +476,7 @@ var MemberPreviewError = class extends Error {
|
|
|
476
476
|
this.status = status;
|
|
477
477
|
}
|
|
478
478
|
};
|
|
479
|
-
function isRecord$
|
|
479
|
+
function isRecord$6(value) {
|
|
480
480
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
481
481
|
}
|
|
482
482
|
function isId(value) {
|
|
@@ -491,11 +491,11 @@ function isProductionPath(value) {
|
|
|
491
491
|
return new URL(value, "http://preview.invalid").pathname === value && !value.startsWith("/_members");
|
|
492
492
|
}
|
|
493
493
|
function parseMemberMetadata(value) {
|
|
494
|
-
if (!isRecord$
|
|
494
|
+
if (!isRecord$6(value) || !Array.isArray(value.members_sites) || !Array.isArray(value.system_screens)) throw new MemberPreviewError("This server does not provide compatible member preview metadata.");
|
|
495
495
|
const sites = value.members_sites.map((site) => {
|
|
496
|
-
if (!isRecord$
|
|
496
|
+
if (!isRecord$6(site) || !isId(site.id) || typeof site.name !== "string" || !Array.isArray(site.pages)) throw new MemberPreviewError("Invalid member site metadata.");
|
|
497
497
|
const pages = site.pages.map((page) => {
|
|
498
|
-
if (!isRecord$
|
|
498
|
+
if (!isRecord$6(page) || !isId(page.id) || typeof page.title !== "string" || !isProductionPath(page.path) || typeof page.published !== "boolean" || !(page.template_id === void 0 || page.template_id === null || isId(page.template_id))) throw new MemberPreviewError("Invalid member page metadata.");
|
|
499
499
|
return {
|
|
500
500
|
id: page.id,
|
|
501
501
|
title: page.title,
|
|
@@ -515,7 +515,7 @@ function parseMemberMetadata(value) {
|
|
|
515
515
|
return {
|
|
516
516
|
members_sites: sites,
|
|
517
517
|
system_screens: value.system_screens.map((screen) => {
|
|
518
|
-
if (!isRecord$
|
|
518
|
+
if (!isRecord$6(screen) || typeof screen.key !== "string" || !/^[a-z][a-z0-9_-]*$/.test(screen.key)) throw new MemberPreviewError("Invalid system screen metadata.");
|
|
519
519
|
return { key: screen.key };
|
|
520
520
|
})
|
|
521
521
|
};
|
|
@@ -555,8 +555,8 @@ function memberPreviewUrl(path, selection) {
|
|
|
555
555
|
return url.pathname + url.search + url.hash;
|
|
556
556
|
}
|
|
557
557
|
function parseMemberRender(value, themeId, selection, pageId, screenKey = null) {
|
|
558
|
-
const preview = isRecord$
|
|
559
|
-
if (!isRecord$
|
|
558
|
+
const preview = isRecord$6(value) ? value.preview : void 0;
|
|
559
|
+
if (!isRecord$6(preview) || preview.contract_version !== 1 || preview.mode !== "sample" || preview.theme_id !== themeId || preview.members_site_id !== selection.members_site_id || preview.members_page_id !== pageId || preview.system_screen_key !== screenKey || typeof preview.html_content !== "string" || !(preview.page_stylesheet === null || typeof preview.page_stylesheet === "string") || !(preview.template_stylesheet === null || typeof preview.template_stylesheet === "string")) throw new MemberPreviewError("Incompatible member preview response. Update the server and CLI together.");
|
|
560
560
|
return {
|
|
561
561
|
html: preview.html_content,
|
|
562
562
|
styles: preview.page_stylesheet ?? "",
|
|
@@ -579,7 +579,7 @@ async function readPreviewMetadata(address, themeId) {
|
|
|
579
579
|
console.warn("Member preview is unavailable. Start an updated theme dev server to list member pages.");
|
|
580
580
|
return;
|
|
581
581
|
}
|
|
582
|
-
if (!isRecord$
|
|
582
|
+
if (!isRecord$6(value) || value.mode !== "sample") throw new Error("The running server does not provide compatible preview metadata.");
|
|
583
583
|
if (value.theme_id !== themeId) throw new Error(`The running server is not serving theme #${themeId}. Use its theme ID or restart theme dev.`);
|
|
584
584
|
if (!Array.isArray(value.supported_system_screens) || !value.supported_system_screens.every((key) => typeof key === "string")) throw new Error("The running server does not provide preview capabilities.");
|
|
585
585
|
return {
|
|
@@ -610,6 +610,26 @@ async function validateMemberDestination(address, themeId, path) {
|
|
|
610
610
|
//#endregion
|
|
611
611
|
//#region ../../api-clients/themes/src/namespaces/v0.ts
|
|
612
612
|
/**
|
|
613
|
+
* Lists all theme templates
|
|
614
|
+
* Lists the templates available to a theme: the theme's own templates, global templates it has not overridden, and — when you filter by `themeable_type` — active templates from installed droplets. Requires a company admin user or company API token with the `application_themes` view permission. The list is not paginated.
|
|
615
|
+
*
|
|
616
|
+
* @param client - Fetch client instance
|
|
617
|
+
* @param [params] - params
|
|
618
|
+
*/
|
|
619
|
+
async function listThemeTemplates(client, params) {
|
|
620
|
+
return client.get(`/api/application_theme_templates`, params);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Deletes a theme template
|
|
624
|
+
* Deletes a template, along with any region rules that point at it. If it was the default for its type, another template is promoted to default. Requires the `application_themes` update permission. Global templates, droplet-provided templates, and page types managed by a dedicated endpoint are refused with 403; a template still referenced elsewhere returns 409.
|
|
625
|
+
*
|
|
626
|
+
* @param client - Fetch client instance
|
|
627
|
+
* @param id - id
|
|
628
|
+
*/
|
|
629
|
+
async function deleteThemeTemplate(client, id) {
|
|
630
|
+
return client.delete(`/api/application_theme_templates/${id}`);
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
613
633
|
* List application themes
|
|
614
634
|
* Get all application themes with optional filters
|
|
615
635
|
*
|
|
@@ -1592,6 +1612,164 @@ function findMissingTemplateTypes(presentTypes) {
|
|
|
1592
1612
|
return missing;
|
|
1593
1613
|
}
|
|
1594
1614
|
//#endregion
|
|
1615
|
+
//#region ../../platform/theme-schema/src/member-sites.ts
|
|
1616
|
+
const RESERVED_MEMBER_PAGE_SLUGS = new Set([
|
|
1617
|
+
"messaging",
|
|
1618
|
+
"contacts",
|
|
1619
|
+
"my-site",
|
|
1620
|
+
"profile",
|
|
1621
|
+
"orders",
|
|
1622
|
+
"subscriptions",
|
|
1623
|
+
"media",
|
|
1624
|
+
"playlists",
|
|
1625
|
+
"auth",
|
|
1626
|
+
"api",
|
|
1627
|
+
"accounts"
|
|
1628
|
+
]);
|
|
1629
|
+
const CHAIN_LAYOUT_NAMES = new Set([
|
|
1630
|
+
"none",
|
|
1631
|
+
"member",
|
|
1632
|
+
"theme"
|
|
1633
|
+
]);
|
|
1634
|
+
/**
|
|
1635
|
+
* Check `members_sites.json` against the rules the server applies when it
|
|
1636
|
+
* imports the manifest (`Themes::MemberConfigurationValidator` and
|
|
1637
|
+
* `Themes::MemberConfigurationResolver`), so a broken manifest is caught
|
|
1638
|
+
* before a push uploads it. `themePaths` holds the theme's file paths,
|
|
1639
|
+
* relative to its root, that a page template or site layout can resolve to.
|
|
1640
|
+
*
|
|
1641
|
+
* Covers the version; the `sites`, `menus`, `menu_references` and (when
|
|
1642
|
+
* present) `templates` arrays, site `pages` arrays, and their entries being
|
|
1643
|
+
* objects; the fields of each site and page and their basic types; page templates and site layouts that have no file; duplicate site
|
|
1644
|
+
* keys, page keys and per-site page slugs; and reserved page slugs. Each
|
|
1645
|
+
* diagnostic's target carries the JSON path the server would report. A
|
|
1646
|
+
* legacy array manifest only warns: the server still converts it.
|
|
1647
|
+
*/
|
|
1648
|
+
function findMemberManifestDiagnostics(content, themePaths) {
|
|
1649
|
+
const diagnostics = [];
|
|
1650
|
+
const report = (severity, pointer, message) => {
|
|
1651
|
+
diagnostics.push({
|
|
1652
|
+
severity,
|
|
1653
|
+
message,
|
|
1654
|
+
target: {
|
|
1655
|
+
kind: "member_manifest",
|
|
1656
|
+
pointer
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
};
|
|
1660
|
+
let document;
|
|
1661
|
+
try {
|
|
1662
|
+
document = JSON.parse(content);
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
report("error", "$", `Invalid JSON: ${error.message}`);
|
|
1665
|
+
return diagnostics;
|
|
1666
|
+
}
|
|
1667
|
+
if (Array.isArray(document)) {
|
|
1668
|
+
if (document.length > 0) report("warning", "$", "legacy array manifest: still accepted, but convert it to a version 2 document");
|
|
1669
|
+
return diagnostics;
|
|
1670
|
+
}
|
|
1671
|
+
if (!isRecord$5(document)) {
|
|
1672
|
+
report("error", "$", "members_sites.json must contain a JSON object");
|
|
1673
|
+
return diagnostics;
|
|
1674
|
+
}
|
|
1675
|
+
if (document.version !== 2) report("error", "$.version", `unsupported version ${JSON.stringify(document.version ?? null)}: members_sites.json must be version 2`);
|
|
1676
|
+
const objects = (entries, path) => {
|
|
1677
|
+
if (!Array.isArray(entries)) {
|
|
1678
|
+
report("error", path, "must be an array");
|
|
1679
|
+
return [];
|
|
1680
|
+
}
|
|
1681
|
+
return entries.flatMap((entry, index) => {
|
|
1682
|
+
const entryPath = `${path}[${index}]`;
|
|
1683
|
+
if (isRecord$5(entry)) return [[entry, entryPath]];
|
|
1684
|
+
report("error", entryPath, "must be an object");
|
|
1685
|
+
return [];
|
|
1686
|
+
});
|
|
1687
|
+
};
|
|
1688
|
+
const sites = objects(document.sites, "$.sites");
|
|
1689
|
+
objects(document.menus, "$.menus");
|
|
1690
|
+
objects(document.menu_references, "$.menu_references");
|
|
1691
|
+
if (Object.hasOwn(document, "templates")) objects(document.templates, "$.templates");
|
|
1692
|
+
const siteKeys = /* @__PURE__ */ new Set();
|
|
1693
|
+
const pageKeys = /* @__PURE__ */ new Set();
|
|
1694
|
+
const shape = (entry, path, fields) => {
|
|
1695
|
+
for (const [field, check] of Object.entries(fields)) {
|
|
1696
|
+
if (!Object.hasOwn(entry, field)) {
|
|
1697
|
+
report("error", `${path}.${field}`, `missing required field '${field}'`);
|
|
1698
|
+
continue;
|
|
1699
|
+
}
|
|
1700
|
+
const problem = check(entry[field]);
|
|
1701
|
+
if (problem) report("error", `${path}.${field}`, problem);
|
|
1702
|
+
}
|
|
1703
|
+
for (const field of Object.keys(entry)) if (!Object.hasOwn(fields, field)) report("error", `${path}.${field}`, `unsupported field '${field}'`);
|
|
1704
|
+
};
|
|
1705
|
+
sites.forEach(([siteEntry, sitePath]) => {
|
|
1706
|
+
shape(siteEntry, sitePath, SITE_FIELDS);
|
|
1707
|
+
if (isRecord$5(siteEntry.rule)) shape(siteEntry.rule, `${sitePath}.rule`, RULE_FIELDS);
|
|
1708
|
+
if (typeof siteEntry.key === "string" && !addNew(siteKeys, siteEntry.key)) report("error", `${sitePath}.key`, `duplicate site key '${siteEntry.key}'`);
|
|
1709
|
+
const layout = siteEntry.layout_name;
|
|
1710
|
+
if (typeof layout === "string" && layout.trim() !== "" && !CHAIN_LAYOUT_NAMES.has(layout) && !themePaths.has(`layouts/${layout}.liquid`)) report("error", `${sitePath}.layout_name`, `layout '${layout}' not found: add layouts/${layout}.liquid or use a layout the theme has`);
|
|
1711
|
+
const slugs = /* @__PURE__ */ new Set();
|
|
1712
|
+
(Object.hasOwn(siteEntry, "pages") ? objects(siteEntry.pages, `${sitePath}.pages`) : []).forEach(([pageEntry, pagePath]) => {
|
|
1713
|
+
shape(pageEntry, pagePath, PAGE_FIELDS);
|
|
1714
|
+
if (typeof pageEntry.key === "string" && !addNew(pageKeys, pageEntry.key)) report("error", `${pagePath}.key`, `duplicate page key '${pageEntry.key}'`);
|
|
1715
|
+
const slug = pageEntry.slug;
|
|
1716
|
+
if (typeof slug === "string") {
|
|
1717
|
+
if (RESERVED_MEMBER_PAGE_SLUGS.has(slug)) report("error", `${pagePath}.slug`, `page slug '${slug}' is reserved for a system route`);
|
|
1718
|
+
else if (!addNew(slugs, slug)) report("error", `${pagePath}.slug`, `duplicate page slug '${slug}' in this site`);
|
|
1719
|
+
}
|
|
1720
|
+
const templatePath = pageEntry.template_path;
|
|
1721
|
+
if (typeof templatePath === "string" && !themePaths.has(templatePath)) report("error", `${pagePath}.template_path`, `page template ${templatePath} not found`);
|
|
1722
|
+
});
|
|
1723
|
+
});
|
|
1724
|
+
return diagnostics;
|
|
1725
|
+
}
|
|
1726
|
+
const RUBY_WHITESPACE = " \n\v\f\r \0";
|
|
1727
|
+
const text = (value) => {
|
|
1728
|
+
if (typeof value !== "string") return "must be a string";
|
|
1729
|
+
return [...value].every((character) => RUBY_WHITESPACE.includes(character)) ? "must not be blank" : void 0;
|
|
1730
|
+
};
|
|
1731
|
+
const optionalText = (value) => value === null || typeof value === "string" ? void 0 : "must be null or a string";
|
|
1732
|
+
const flag = (value) => typeof value === "boolean" ? void 0 : "must be a boolean";
|
|
1733
|
+
const integer = (value) => Number.isInteger(value) ? void 0 : "must be an integer";
|
|
1734
|
+
const object = (value) => isRecord$5(value) ? void 0 : "must be an object";
|
|
1735
|
+
const strings = (value) => {
|
|
1736
|
+
if (!Array.isArray(value)) return "must be an array of strings";
|
|
1737
|
+
if (value.some((entry) => text(entry) !== void 0)) return "must hold only non-blank strings";
|
|
1738
|
+
return new Set(value).size === value.length ? void 0 : "must not repeat an entry";
|
|
1739
|
+
};
|
|
1740
|
+
const anything = () => void 0;
|
|
1741
|
+
const SITE_FIELDS = {
|
|
1742
|
+
key: text,
|
|
1743
|
+
name: text,
|
|
1744
|
+
active: flag,
|
|
1745
|
+
default: flag,
|
|
1746
|
+
position: integer,
|
|
1747
|
+
layout_name: optionalText,
|
|
1748
|
+
rule: object,
|
|
1749
|
+
menu_key: optionalText,
|
|
1750
|
+
pages: anything
|
|
1751
|
+
};
|
|
1752
|
+
const PAGE_FIELDS = {
|
|
1753
|
+
key: text,
|
|
1754
|
+
title: text,
|
|
1755
|
+
slug: text,
|
|
1756
|
+
published: flag,
|
|
1757
|
+
template_path: optionalText
|
|
1758
|
+
};
|
|
1759
|
+
const RULE_FIELDS = {
|
|
1760
|
+
country_codes: strings,
|
|
1761
|
+
member_type_slugs: strings
|
|
1762
|
+
};
|
|
1763
|
+
/** Add `value` to `seen`, returning false when it was already there. */
|
|
1764
|
+
function addNew(seen, value) {
|
|
1765
|
+
if (seen.has(value)) return false;
|
|
1766
|
+
seen.add(value);
|
|
1767
|
+
return true;
|
|
1768
|
+
}
|
|
1769
|
+
function isRecord$5(entry) {
|
|
1770
|
+
return typeof entry === "object" && entry !== null && !Array.isArray(entry);
|
|
1771
|
+
}
|
|
1772
|
+
//#endregion
|
|
1595
1773
|
//#region src/theme/file.ts
|
|
1596
1774
|
const NON_TEMPLATE_DIRS = new Set([
|
|
1597
1775
|
"sections",
|
|
@@ -2030,8 +2208,8 @@ var MemberPreview = class {
|
|
|
2030
2208
|
application_theme_id: this.theme.id,
|
|
2031
2209
|
themeable_type: "members_page"
|
|
2032
2210
|
});
|
|
2033
|
-
const templates = isRecord$
|
|
2034
|
-
for (const template of templates) if (isRecord$
|
|
2211
|
+
const templates = isRecord$6(body) && Array.isArray(body.templates) ? body.templates : [];
|
|
2212
|
+
for (const template of templates) if (isRecord$6(template) && isId(template.id) && template.application_theme_id === this.theme.id && template.themeable_type === "members_page" && typeof template.name === "string" && /^[^/\\]+$/.test(template.name) && template.name !== "." && template.name !== "..") names.set(template.id, template.name);
|
|
2035
2213
|
} catch (error) {
|
|
2036
2214
|
const message = error instanceof Error ? error.message : String(error);
|
|
2037
2215
|
console.warn(`[Members] Could not read member page templates (${message}); page template paths are left out.`);
|
|
@@ -2116,7 +2294,7 @@ var MemberPreview = class {
|
|
|
2116
2294
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
2117
2295
|
res.end(req.method === "HEAD" ? void 0 : html);
|
|
2118
2296
|
} catch (error) {
|
|
2119
|
-
const status = error instanceof MemberPreviewError ? error.status : isRecord$
|
|
2297
|
+
const status = error instanceof MemberPreviewError ? error.status : isRecord$6(error) && typeof error.status === "number" && [
|
|
2120
2298
|
401,
|
|
2121
2299
|
403,
|
|
2122
2300
|
404,
|
|
@@ -2705,7 +2883,7 @@ function memberDependencyPaths(document, availablePaths, deletedPaths = [], chan
|
|
|
2705
2883
|
if (!path.endsWith("/index.liquid")) continue;
|
|
2706
2884
|
for (const suffix of ["variables.json", "styles.css"]) {
|
|
2707
2885
|
const sibling = path.replace(/index\.liquid$/, suffix);
|
|
2708
|
-
if ((suffix === "styles.css" ? changedPaths : availablePaths).has(sibling)
|
|
2886
|
+
if ((suffix === "styles.css" ? changedPaths : availablePaths).has(sibling)) dependencies.add(sibling);
|
|
2709
2887
|
}
|
|
2710
2888
|
}
|
|
2711
2889
|
for (const path of dependencies) if (isRetiredTemplateKey(path)) dependencies.delete(path);
|
|
@@ -2727,22 +2905,17 @@ function planThemeUploads(themeRoot, changedFiles, deletedPaths = []) {
|
|
|
2727
2905
|
if (Array.isArray(parsed)) return individualUploads(changedFiles);
|
|
2728
2906
|
if (!isRecord$3(parsed)) throw new Error("members_sites.json must contain a JSON object.");
|
|
2729
2907
|
const { document, removed } = withoutRetiredTemplates(parsed);
|
|
2730
|
-
const content = removed.length > 0 ?
|
|
2908
|
+
const content = removed.length > 0 ? serializeMemberDocument(document) : manifestContent;
|
|
2731
2909
|
const dependencies = memberDependencyPaths(document, new Set(localFiles.map((file) => file.relativePath)), deletedPaths, new Set(changedFiles.map((file) => file.relativePath)));
|
|
2732
|
-
for (const path of deletedPaths) if (dependencies.has(path)) throw new Error(`
|
|
2733
|
-
|
|
2734
|
-
if (!memberChanged && removed.length === 0) return changedFiles.map((file) => ({ file }));
|
|
2910
|
+
for (const path of deletedPaths) if (dependencies.has(path)) throw new Error(`members_sites.json still lists ${path}. Remove it from members_sites.json to delete the file.`);
|
|
2911
|
+
if (!changedFiles.some((file) => file.relativePath === "members_sites.json" || dependencies.has(file.relativePath))) return changedFiles.map((file) => ({ file }));
|
|
2735
2912
|
const availableFiles = new Map(localFiles.map((file) => [file.relativePath, file]));
|
|
2736
2913
|
const unavailable = [...dependencies].find((path) => {
|
|
2737
2914
|
const file = availableFiles.get(path);
|
|
2738
2915
|
return !file || !file.isText || themeRoot.ignore.ignore(path);
|
|
2739
2916
|
});
|
|
2740
|
-
if (unavailable) {
|
|
2741
|
-
if (!memberChanged) return changedFiles.map((file) => ({ file }));
|
|
2742
|
-
throw new Error(`Member dependency must be an available text file: ${unavailable}`);
|
|
2743
|
-
}
|
|
2917
|
+
if (unavailable) throw new Error(`Member dependency must be an available text file: ${unavailable}`);
|
|
2744
2918
|
const memberFiles = [...dependencies].map((path) => availableFiles.get(path));
|
|
2745
|
-
if (removed.length > 0) manifest.write(content);
|
|
2746
2919
|
const uploads = changedFiles.filter((file) => file.relativePath !== "members_sites.json" && !dependencies.has(file.relativePath)).map((file) => ({ file }));
|
|
2747
2920
|
uploads.push({
|
|
2748
2921
|
file: manifest,
|
|
@@ -2754,6 +2927,26 @@ function planThemeUploads(themeRoot, changedFiles, deletedPaths = []) {
|
|
|
2754
2927
|
return uploads;
|
|
2755
2928
|
}
|
|
2756
2929
|
/**
|
|
2930
|
+
* The bytes Fluid receives for a local members_sites.json. Planning never
|
|
2931
|
+
* rewrites the developer's file, so change detection compares these instead:
|
|
2932
|
+
* once Fluid holds the cleaned document, a retired reference left in the
|
|
2933
|
+
* local file must not make it look changed on every later sync.
|
|
2934
|
+
*/
|
|
2935
|
+
function syncedMemberConfigurationContent(content) {
|
|
2936
|
+
let parsed;
|
|
2937
|
+
try {
|
|
2938
|
+
parsed = JSON.parse(content);
|
|
2939
|
+
} catch {
|
|
2940
|
+
return content;
|
|
2941
|
+
}
|
|
2942
|
+
if (!isRecord$3(parsed)) return content;
|
|
2943
|
+
const { document, removed } = withoutRetiredTemplates(parsed);
|
|
2944
|
+
return removed.length > 0 ? serializeMemberDocument(document) : content;
|
|
2945
|
+
}
|
|
2946
|
+
function serializeMemberDocument(document) {
|
|
2947
|
+
return `${JSON.stringify(document, null, 2)}\n`;
|
|
2948
|
+
}
|
|
2949
|
+
/**
|
|
2757
2950
|
* Drop references to retired template types. The server rejects the whole
|
|
2758
2951
|
* document for one, which would also hold back every member site and menu it
|
|
2759
2952
|
* carries.
|
|
@@ -2796,6 +2989,14 @@ function individualUploads(files) {
|
|
|
2796
2989
|
function isRecord$3(entry) {
|
|
2797
2990
|
return typeof entry === "object" && entry !== null && !Array.isArray(entry);
|
|
2798
2991
|
}
|
|
2992
|
+
/**
|
|
2993
|
+
* Files that can only reach Fluid inside a member bundle. While the manifest
|
|
2994
|
+
* cannot be planned or is refused, these wait for it; everything else keeps
|
|
2995
|
+
* syncing on its own.
|
|
2996
|
+
*/
|
|
2997
|
+
function isHeldWithMemberConfiguration(path) {
|
|
2998
|
+
return path === "members_sites.json" || path.startsWith("members_page/");
|
|
2999
|
+
}
|
|
2799
3000
|
/** Removing an older file is not an instruction to erase a member site. */
|
|
2800
3001
|
function assertMemberConfigurationRetained(deletedPaths) {
|
|
2801
3002
|
if (deletedPaths.includes("members_sites.json")) throw new Error("Keep members_sites.json. To remove member configuration, upload an explicit empty versioned document instead of deleting or renaming the file.");
|
|
@@ -2989,7 +3190,12 @@ var Syncer = class {
|
|
|
2989
3190
|
}
|
|
2990
3191
|
}
|
|
2991
3192
|
hasChanged(file) {
|
|
2992
|
-
|
|
3193
|
+
const remoteChecksum = this.checksums.get(file.relativePath);
|
|
3194
|
+
if (file.relativePath === "members_sites.json" && file.isText) {
|
|
3195
|
+
const synced = syncedMemberConfigurationContent(file.read());
|
|
3196
|
+
return createHash("sha256").update(synced).digest("hex") !== remoteChecksum;
|
|
3197
|
+
}
|
|
3198
|
+
return file.checksum() !== remoteChecksum;
|
|
2993
3199
|
}
|
|
2994
3200
|
remoteKeys() {
|
|
2995
3201
|
return [...this.remoteResources.keys()];
|
|
@@ -2999,6 +3205,43 @@ var Syncer = class {
|
|
|
2999
3205
|
const resource = this.remoteResources.get(key);
|
|
3000
3206
|
return resource?.content != null || isManagedAssetResource(resource);
|
|
3001
3207
|
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Files the member configuration Fluid last accepted references, or null
|
|
3210
|
+
* when it cannot be read. While a newer bundle is held, that configuration
|
|
3211
|
+
* stays active, so none of these may be deleted or replaced on their own.
|
|
3212
|
+
*/
|
|
3213
|
+
async acceptedMemberDependencies() {
|
|
3214
|
+
const resource = this.remoteResources.get(MEMBER_CONFIGURATION_KEY);
|
|
3215
|
+
if (!resource) return /* @__PURE__ */ new Set();
|
|
3216
|
+
let content = memberContent(resource.content);
|
|
3217
|
+
let remotePaths = new Set(this.remoteKeys());
|
|
3218
|
+
if (!content) {
|
|
3219
|
+
const local = this.themeRoot.file(MEMBER_CONFIGURATION_KEY);
|
|
3220
|
+
if (resource.checksum && local.exists && !this.hasChanged(local)) content = local.read();
|
|
3221
|
+
else try {
|
|
3222
|
+
const listed = (await listThemeResources(this.api, this.themeId)).application_theme_resources ?? [];
|
|
3223
|
+
const accepted = listed.find((entry) => entry.key === MEMBER_CONFIGURATION_KEY);
|
|
3224
|
+
if (!accepted) return /* @__PURE__ */ new Set();
|
|
3225
|
+
content = memberContent(accepted.content);
|
|
3226
|
+
remotePaths = new Set(listed.flatMap((entry) => entry.key ?? []));
|
|
3227
|
+
if (content && accepted.checksum === resource.checksum) this.setRemoteResource({
|
|
3228
|
+
...resource,
|
|
3229
|
+
content
|
|
3230
|
+
});
|
|
3231
|
+
} catch {
|
|
3232
|
+
return null;
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
let document;
|
|
3236
|
+
try {
|
|
3237
|
+
document = JSON.parse(content);
|
|
3238
|
+
} catch {
|
|
3239
|
+
return null;
|
|
3240
|
+
}
|
|
3241
|
+
if (typeof document !== "object" || document === null) return /* @__PURE__ */ new Set();
|
|
3242
|
+
if (Array.isArray(document)) return /* @__PURE__ */ new Set();
|
|
3243
|
+
return memberDependencyPaths(document, remotePaths);
|
|
3244
|
+
}
|
|
3002
3245
|
/** Snapshot of remote checksums (key → sha256). Available after fetchChecksums() or downloadAll(). */
|
|
3003
3246
|
remoteChecksums() {
|
|
3004
3247
|
return Object.fromEntries(this.checksums);
|
|
@@ -3689,7 +3932,26 @@ var Syncer = class {
|
|
|
3689
3932
|
const localPaths = new Set(localFiles.map((file) => file.relativePath));
|
|
3690
3933
|
if (opts.delete) for (const key of this.assetManifest.keys()) localPaths.add(key);
|
|
3691
3934
|
const toDelete = opts.delete ? this.remoteKeys().filter((key) => key !== "members_sites.json" && this.canDeleteRemoteResource(key) && !localPaths.has(key) && !this.themeRoot.ignore.ignore(key)) : [];
|
|
3692
|
-
const
|
|
3935
|
+
const changedFiles = localFiles.filter((f) => f.exists && this.hasChanged(f));
|
|
3936
|
+
let plannedUploads;
|
|
3937
|
+
try {
|
|
3938
|
+
plannedUploads = planThemeUploads(this.themeRoot, changedFiles, toDelete);
|
|
3939
|
+
} catch (error) {
|
|
3940
|
+
if (!opts.holdMemberConfiguration) throw error;
|
|
3941
|
+
result.memberConfigurationHeld = formatError(error);
|
|
3942
|
+
plannedUploads = changedFiles.map((file) => ({ file }));
|
|
3943
|
+
}
|
|
3944
|
+
const bundled = plannedUploads.some((upload) => upload.memberConfiguration);
|
|
3945
|
+
const accepted = opts.holdMemberConfiguration && (bundled || result.memberConfigurationHeld) ? await this.acceptedMemberDependencies() : /* @__PURE__ */ new Set();
|
|
3946
|
+
const waitsForBundle = (path) => accepted === null || accepted.has(path);
|
|
3947
|
+
if (result.memberConfigurationHeld) {
|
|
3948
|
+
const held = (path) => isHeldWithMemberConfiguration(path) || waitsForBundle(path);
|
|
3949
|
+
result.heldChanges = changedFiles.map((file) => file.relativePath).filter(held);
|
|
3950
|
+
plannedUploads = plannedUploads.filter(({ file }) => !held(file.relativePath));
|
|
3951
|
+
} else if (bundled) {
|
|
3952
|
+
const after = (upload) => !upload.memberConfiguration && waitsForBundle(upload.file.relativePath);
|
|
3953
|
+
plannedUploads = [...plannedUploads.filter((upload) => !after(upload)), ...plannedUploads.filter(after)];
|
|
3954
|
+
}
|
|
3693
3955
|
if (opts.linkManagedAssets) {
|
|
3694
3956
|
result.linked = await this.linkManagedAssets(opts.linkManagedAssets);
|
|
3695
3957
|
baseSha = this.lastKnownRemoteSha ?? baseSha;
|
|
@@ -3702,6 +3964,10 @@ var Syncer = class {
|
|
|
3702
3964
|
let done = 0;
|
|
3703
3965
|
for (const upload of toUpload) {
|
|
3704
3966
|
const { file } = upload;
|
|
3967
|
+
if (result.memberConfigurationHeld && !upload.memberConfiguration && waitsForBundle(file.relativePath)) {
|
|
3968
|
+
(result.heldChanges ??= []).push(file.relativePath);
|
|
3969
|
+
continue;
|
|
3970
|
+
}
|
|
3705
3971
|
if (file.relativePath === "members_sites.json" && result.errors.length > 0) {
|
|
3706
3972
|
result.errors.push("Skipped members_sites.json because a dependency upload failed.");
|
|
3707
3973
|
break;
|
|
@@ -3713,18 +3979,25 @@ var Syncer = class {
|
|
|
3713
3979
|
result.uploaded += 1 + (upload.memberConfiguration?.files.length ?? 0);
|
|
3714
3980
|
} catch (e) {
|
|
3715
3981
|
if (e instanceof PushConflictError) throw e;
|
|
3716
|
-
|
|
3982
|
+
if (upload.memberConfiguration && opts.holdMemberConfiguration) result.memberConfigurationHeld = formatError(e);
|
|
3983
|
+
else result.errors.push(`Upload ${file.relativePath}: ${formatError(e)}`);
|
|
3717
3984
|
}
|
|
3718
3985
|
done += 1 + (upload.memberConfiguration?.files.length ?? 0);
|
|
3719
3986
|
opts.onProgress?.(done, uploadCount);
|
|
3720
3987
|
}
|
|
3721
|
-
if (opts.delete && result.errors.length === 0)
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3988
|
+
if (opts.delete && result.errors.length === 0) {
|
|
3989
|
+
const held = result.memberConfigurationHeld !== void 0;
|
|
3990
|
+
const keepsRemote = (key) => held && (isHeldWithMemberConfiguration(key) || waitsForBundle(key));
|
|
3991
|
+
const deletions = toDelete.filter((key) => !keepsRemote(key));
|
|
3992
|
+
if (held) result.heldRemovals = toDelete.filter(keepsRemote);
|
|
3993
|
+
for (const key of deletions) try {
|
|
3994
|
+
await this.deleteRemoteFile(key, baseSha);
|
|
3995
|
+
baseSha = this.lastKnownRemoteSha;
|
|
3996
|
+
result.deleted++;
|
|
3997
|
+
} catch (e) {
|
|
3998
|
+
if (e instanceof PushConflictError) throw e;
|
|
3999
|
+
result.errors.push(`Delete ${key}: ${formatError(e)}`);
|
|
4000
|
+
}
|
|
3728
4001
|
}
|
|
3729
4002
|
return result;
|
|
3730
4003
|
}
|
|
@@ -3794,6 +4067,10 @@ function isNestedBinaryThemeAsset(file) {
|
|
|
3794
4067
|
function isManagedAssetResource(resource) {
|
|
3795
4068
|
return resource?.resource_type === "FileResource" && typeof resource.url === "string" && resource.url.length > 0;
|
|
3796
4069
|
}
|
|
4070
|
+
function memberContent(content) {
|
|
4071
|
+
if (typeof content === "string") return content;
|
|
4072
|
+
return content == null ? "" : JSON.stringify(content);
|
|
4073
|
+
}
|
|
3797
4074
|
function remoteResourceFromState(state) {
|
|
3798
4075
|
return {
|
|
3799
4076
|
key: state.key,
|
|
@@ -4095,6 +4372,13 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4095
4372
|
}
|
|
4096
4373
|
};
|
|
4097
4374
|
const pendingUpdates = /* @__PURE__ */ new Set();
|
|
4375
|
+
const heldChanges = /* @__PURE__ */ new Set();
|
|
4376
|
+
const heldRemovals = /* @__PURE__ */ new Set();
|
|
4377
|
+
const bundledPaths = /* @__PURE__ */ new Set();
|
|
4378
|
+
const holdsWithMembers = (path) => isHeldWithMemberConfiguration(path) || bundledPaths.has(path);
|
|
4379
|
+
const reportHeld = (reason) => {
|
|
4380
|
+
console.error(`\n[Watcher] Member sites not synced: ${reason}\n[Watcher] Other files keep syncing. Held member edits and deletions are sent with the next members_sites.json Fluid accepts.`);
|
|
4381
|
+
};
|
|
4098
4382
|
console.log(`\nSyncing theme ${theme.name} (#${theme.id})…`);
|
|
4099
4383
|
const progress = (done, total) => {
|
|
4100
4384
|
process.stdout.write(`\r Uploading ${done}/${total} files…`);
|
|
@@ -4104,6 +4388,7 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4104
4388
|
validate: opts.validate,
|
|
4105
4389
|
linkManagedAssets: { replace: true },
|
|
4106
4390
|
pendingBinaryAssets: true,
|
|
4391
|
+
holdMemberConfiguration: true,
|
|
4107
4392
|
onProgress: progress
|
|
4108
4393
|
});
|
|
4109
4394
|
let syncResult;
|
|
@@ -4124,6 +4409,7 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4124
4409
|
baseSha: syncer.remoteSha(),
|
|
4125
4410
|
remoteState: opts.initialSync,
|
|
4126
4411
|
skipPreflight: true,
|
|
4412
|
+
holdMemberConfiguration: true,
|
|
4127
4413
|
onProgress: progress
|
|
4128
4414
|
}) : await uploadFromRemoteIndex();
|
|
4129
4415
|
} else syncResult = await uploadFromRemoteIndex();
|
|
@@ -4138,6 +4424,13 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4138
4424
|
for (const e of syncResult.errors) console.error(` ${e}`);
|
|
4139
4425
|
if (syncResult.uploaded + syncResult.deleted === 0) process.exit(1);
|
|
4140
4426
|
}
|
|
4427
|
+
if (syncResult.memberConfigurationHeld) {
|
|
4428
|
+
invalidateRemoteState();
|
|
4429
|
+
heldChanges.add(MEMBER_CONFIGURATION_KEY);
|
|
4430
|
+
for (const path of syncResult.heldChanges ?? []) heldChanges.add(path);
|
|
4431
|
+
for (const path of syncResult.heldRemovals ?? []) heldRemovals.add(path);
|
|
4432
|
+
reportHeld(syncResult.memberConfigurationHeld);
|
|
4433
|
+
}
|
|
4141
4434
|
if (syncResult.errors.length === 0) recordRemoteState();
|
|
4142
4435
|
const SYNC_IDLE_MS = 2e3;
|
|
4143
4436
|
let lastArrivedAt = 0;
|
|
@@ -4184,19 +4477,49 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4184
4477
|
await syncInFlight;
|
|
4185
4478
|
}
|
|
4186
4479
|
if (remoteWritesBlocked) return;
|
|
4187
|
-
|
|
4480
|
+
const localFiles = themeRoot.files();
|
|
4481
|
+
const localByPath = new Map(localFiles.map((file) => [file.relativePath, file]));
|
|
4482
|
+
const changed = [...modified, ...added];
|
|
4483
|
+
const changedPaths = new Set(changed.map((file) => file.relativePath));
|
|
4484
|
+
for (const path of heldChanges) {
|
|
4485
|
+
const file = localByPath.get(path);
|
|
4486
|
+
if (file && !changedPaths.has(path)) changed.push(file);
|
|
4487
|
+
}
|
|
4488
|
+
const removedPaths = removed.map((file) => file.relativePath).filter((path) => !themeRoot.ignore.ignore(path));
|
|
4489
|
+
for (const path of heldRemovals) if (!localByPath.has(path) && !removedPaths.includes(path)) removedPaths.push(path);
|
|
4188
4490
|
try {
|
|
4189
|
-
assertNoCaseCollisions(
|
|
4190
|
-
assertMemberConfigurationRetained(
|
|
4191
|
-
uploads = planThemeUploads(themeRoot, [...modified, ...added], removed.filter((file) => !themeRoot.ignore.ignore(file.relativePath)).map((file) => file.relativePath));
|
|
4491
|
+
assertNoCaseCollisions(localFiles.map((file) => file.relativePath));
|
|
4492
|
+
assertMemberConfigurationRetained(removedPaths);
|
|
4192
4493
|
} catch (error) {
|
|
4193
4494
|
console.error(`\n[Watcher] Sync blocked: ${String(error)}`);
|
|
4194
4495
|
return;
|
|
4195
4496
|
}
|
|
4497
|
+
let uploads;
|
|
4498
|
+
let memberHeldReason;
|
|
4499
|
+
try {
|
|
4500
|
+
uploads = planThemeUploads(themeRoot, changed, removedPaths);
|
|
4501
|
+
} catch (error) {
|
|
4502
|
+
memberHeldReason = formatError(error);
|
|
4503
|
+
uploads = changed.map((file) => ({ file }));
|
|
4504
|
+
}
|
|
4505
|
+
const bundled = uploads.some((upload) => upload.memberConfiguration);
|
|
4506
|
+
const accepted = bundled || memberHeldReason ? await syncer.acceptedMemberDependencies() : /* @__PURE__ */ new Set();
|
|
4507
|
+
const waitsForBundle = (path) => accepted === null || accepted.has(path);
|
|
4508
|
+
if (memberHeldReason) uploads = uploads.filter(({ file }) => !holdsWithMembers(file.relativePath) && !waitsForBundle(file.relativePath));
|
|
4509
|
+
else if (bundled) {
|
|
4510
|
+
const after = (upload) => !upload.memberConfiguration && waitsForBundle(upload.file.relativePath);
|
|
4511
|
+
uploads = [...uploads.filter((upload) => !after(upload)), ...uploads.filter(after)];
|
|
4512
|
+
}
|
|
4513
|
+
for (const { memberConfiguration } of uploads) {
|
|
4514
|
+
if (!memberConfiguration) continue;
|
|
4515
|
+
bundledPaths.clear();
|
|
4516
|
+
for (const file of memberConfiguration.files) bundledPaths.add(file.relativePath);
|
|
4517
|
+
}
|
|
4196
4518
|
let wroteRemote = false;
|
|
4197
4519
|
const memberTransfer = uploads.some((upload) => upload.memberConfiguration || upload.file.relativePath === "members_sites.json");
|
|
4198
4520
|
for (const upload of uploads) {
|
|
4199
4521
|
const { file } = upload;
|
|
4522
|
+
if (memberHeldReason && !upload.memberConfiguration && waitsForBundle(file.relativePath)) continue;
|
|
4200
4523
|
const uploadFiles = [file, ...upload.memberConfiguration?.files ?? []];
|
|
4201
4524
|
if (opts.validate) for (const candidate of uploadFiles) {
|
|
4202
4525
|
if (!candidate.isLiquid) continue;
|
|
@@ -4224,6 +4547,10 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4224
4547
|
break;
|
|
4225
4548
|
}
|
|
4226
4549
|
invalidateRemoteState();
|
|
4550
|
+
if (upload.memberConfiguration) {
|
|
4551
|
+
memberHeldReason = formatError(e);
|
|
4552
|
+
continue;
|
|
4553
|
+
}
|
|
4227
4554
|
console.error(`\n[Watcher] Upload failed: ${file.relativePath}: ${e}`);
|
|
4228
4555
|
remoteWritesBlocked = wroteRemote || memberTransfer;
|
|
4229
4556
|
if (remoteWritesBlocked) console.error("[Watcher] Restart theme dev to retry the incomplete transfer.");
|
|
@@ -4233,23 +4560,29 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4233
4560
|
}
|
|
4234
4561
|
}
|
|
4235
4562
|
if (remoteWritesBlocked) return;
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4563
|
+
const keepsRemote = (path) => memberHeldReason !== void 0 && (holdsWithMembers(path) || waitsForBundle(path));
|
|
4564
|
+
if (memberHeldReason) {
|
|
4565
|
+
for (const file of changed) if (keepsRemote(file.relativePath)) heldChanges.add(file.relativePath);
|
|
4566
|
+
if (localByPath.has("members_sites.json")) heldChanges.add(MEMBER_CONFIGURATION_KEY);
|
|
4567
|
+
for (const path of removedPaths) if (keepsRemote(path)) heldRemovals.add(path);
|
|
4568
|
+
reportHeld(memberHeldReason);
|
|
4569
|
+
} else heldChanges.clear();
|
|
4570
|
+
const deletions = removedPaths.filter((path) => !keepsRemote(path));
|
|
4571
|
+
for (const path of deletions) try {
|
|
4572
|
+
await syncer.deleteRemoteFile(path, syncer.remoteSha());
|
|
4573
|
+
heldRemovals.delete(path);
|
|
4574
|
+
wroteRemote = true;
|
|
4575
|
+
console.log(` ✓ removed ${path}`);
|
|
4576
|
+
} catch (error) {
|
|
4577
|
+
if (error instanceof PushConflictError) {
|
|
4578
|
+
blockRemoteWrites(error);
|
|
4579
|
+
break;
|
|
4252
4580
|
}
|
|
4581
|
+
invalidateRemoteState();
|
|
4582
|
+
remoteWritesBlocked = wroteRemote || memberTransfer;
|
|
4583
|
+
console.error(`[Watcher] Delete failed: ${path}: ${error}`);
|
|
4584
|
+
if (remoteWritesBlocked) console.error("[Watcher] Restart theme dev to retry the incomplete transfer.");
|
|
4585
|
+
return;
|
|
4253
4586
|
}
|
|
4254
4587
|
if (remoteWritesBlocked) return;
|
|
4255
4588
|
if (wroteRemote) {
|
|
@@ -5223,7 +5556,7 @@ async function diffAgainstShadow(themeRoot, shadow) {
|
|
|
5223
5556
|
localByKey.set(file.relativePath, file);
|
|
5224
5557
|
const headBlob = await shadow.blobAtHead(file.relativePath);
|
|
5225
5558
|
if (!headBlob && headPathSet.has(file.relativePath)) throw new Error(`Could not read the local theme shadow: ${file.relativePath}`);
|
|
5226
|
-
const localBuf = file.isText ? Buffer.from(file.read()) : file.readBinary();
|
|
5559
|
+
const localBuf = file.isText ? Buffer.from(file.relativePath === "members_sites.json" ? syncedMemberConfigurationContent(file.read()) : file.read()) : file.readBinary();
|
|
5227
5560
|
if (headBlob && headBlob.equals(localBuf)) continue;
|
|
5228
5561
|
changed.push(file);
|
|
5229
5562
|
}
|
|
@@ -5500,7 +5833,161 @@ async function requestSyncActor(api, timeoutMs) {
|
|
|
5500
5833
|
}
|
|
5501
5834
|
}
|
|
5502
5835
|
//#endregion
|
|
5836
|
+
//#region src/theme/native-widgets.ts
|
|
5837
|
+
/**
|
|
5838
|
+
* A theme's own copies of Fluid native widgets.
|
|
5839
|
+
*
|
|
5840
|
+
* A member page places a native widget by URI
|
|
5841
|
+
* (`{% section 'fluid://native/widgets/<key>' %}`), and Fluid owns the
|
|
5842
|
+
* template behind it: a global template named `fluid_native_<key>`. A theme
|
|
5843
|
+
* customizes one through its own COPY, made by
|
|
5844
|
+
* `POST /api/v202604/themes/:id/native-widget-copies`: a theme template of
|
|
5845
|
+
* the same name that replaces the widget at every placement in that theme.
|
|
5846
|
+
* Deleting the copy as a template returns the theme to Fluid's original.
|
|
5847
|
+
*
|
|
5848
|
+
* The copy keeps its original's template type. Fluid's originals are
|
|
5849
|
+
* `sections` today and are moving to the `widgets` type, and Rails reads a
|
|
5850
|
+
* copy of either type, so a theme can hold `sections/fluid_native_<key>/`,
|
|
5851
|
+
* `widgets/fluid_native_<key>/`, or both. Everything here handles both.
|
|
5852
|
+
*
|
|
5853
|
+
* A `fluid_native_<key>/` folder pushed to a theme without a copy of that
|
|
5854
|
+
* type becomes a plain template that replaces nothing, so the copy is always
|
|
5855
|
+
* made on the server before its files are edited locally.
|
|
5856
|
+
*/
|
|
5857
|
+
/** The template types a native widget and its copy can have. */
|
|
5858
|
+
const NATIVE_WIDGET_TYPES = ["sections", "widgets"];
|
|
5859
|
+
const NAME_PREFIX = "fluid_native_";
|
|
5860
|
+
/** Catalog keys are short lowercase slugs (`acct`, `sales_goal`). Anything
|
|
5861
|
+
* else is not a widget and must never reach a path or an API URL. */
|
|
5862
|
+
const NATIVE_WIDGET_KEY_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
5863
|
+
function isNativeWidgetKey(key) {
|
|
5864
|
+
return NATIVE_WIDGET_KEY_RE.test(key);
|
|
5865
|
+
}
|
|
5866
|
+
function isNativeWidgetType(type) {
|
|
5867
|
+
return NATIVE_WIDGET_TYPES.includes(type);
|
|
5868
|
+
}
|
|
5869
|
+
/** The folder a widget's copy of `type` is pulled into, relative to the
|
|
5870
|
+
* theme root. */
|
|
5871
|
+
function nativeWidgetFolder(key, type = "sections") {
|
|
5872
|
+
return `${type}/${NAME_PREFIX}${key}`;
|
|
5873
|
+
}
|
|
5874
|
+
/** The folder a copy is pulled into. A copy that does not state its type
|
|
5875
|
+
* is the older `sections` kind. */
|
|
5876
|
+
function copyFolder(key, copy) {
|
|
5877
|
+
return nativeWidgetFolder(key, isNativeWidgetType(copy.themeable_type) ? copy.themeable_type : "sections");
|
|
5878
|
+
}
|
|
5879
|
+
/**
|
|
5880
|
+
* Make the theme's copy of a native widget, or return the copy it already
|
|
5881
|
+
* has. Rails answers 201 for a new copy and 200 for an existing one, so a
|
|
5882
|
+
* repeat call is safe.
|
|
5883
|
+
*/
|
|
5884
|
+
async function copyNativeWidget(api, themeId, key) {
|
|
5885
|
+
return (await api.request(`/api/v202604/themes/${themeId}/native-widget-copies`, {
|
|
5886
|
+
method: "POST",
|
|
5887
|
+
body: { native_widget_key: key }
|
|
5888
|
+
})).template;
|
|
5889
|
+
}
|
|
5890
|
+
/**
|
|
5891
|
+
* The theme's copies of native widgets, by widget key, of either template
|
|
5892
|
+
* type. A key normally has one copy; it has two only when the theme holds
|
|
5893
|
+
* both a `sections` and a `widgets` copy.
|
|
5894
|
+
*/
|
|
5895
|
+
async function listNativeWidgetCopies(api, themeId, query = NAME_PREFIX) {
|
|
5896
|
+
const listed = await Promise.all(NATIVE_WIDGET_TYPES.map(async (type) => {
|
|
5897
|
+
return ((await listThemeTemplates(api, {
|
|
5898
|
+
application_theme_id: themeId,
|
|
5899
|
+
themeable_type: type,
|
|
5900
|
+
query
|
|
5901
|
+
}))?.templates ?? []).map((template) => template ? {
|
|
5902
|
+
...template,
|
|
5903
|
+
themeable_type: type
|
|
5904
|
+
} : template);
|
|
5905
|
+
}));
|
|
5906
|
+
const copies = /* @__PURE__ */ new Map();
|
|
5907
|
+
for (const template of listed.flat()) {
|
|
5908
|
+
const key = template?.customized_native_widget_key;
|
|
5909
|
+
if (template && key && template.name === `${NAME_PREFIX}${key}`) copies.set(key, [...copies.get(key) ?? [], template]);
|
|
5910
|
+
}
|
|
5911
|
+
return copies;
|
|
5912
|
+
}
|
|
5913
|
+
/** The `sections/fluid_native_<key>/` and `widgets/fluid_native_<key>/`
|
|
5914
|
+
* folders in the theme, sorted by folder. */
|
|
5915
|
+
function localNativeWidgets(themeRoot) {
|
|
5916
|
+
const found = /* @__PURE__ */ new Map();
|
|
5917
|
+
for (const file of themeRoot.files()) {
|
|
5918
|
+
const match = /^(sections|widgets)\/fluid_native_([^/]+)\//.exec(file.relativePath);
|
|
5919
|
+
if (!match || !isNativeWidgetKey(match[2])) continue;
|
|
5920
|
+
const widget = {
|
|
5921
|
+
key: match[2],
|
|
5922
|
+
type: match[1]
|
|
5923
|
+
};
|
|
5924
|
+
found.set(nativeWidgetFolder(widget.key, widget.type), widget);
|
|
5925
|
+
}
|
|
5926
|
+
return [...found.keys()].sort().map((folder) => found.get(folder));
|
|
5927
|
+
}
|
|
5928
|
+
/**
|
|
5929
|
+
* Local `fluid_native_<key>/` folders the theme has no copy of that type
|
|
5930
|
+
* for. Pushing one makes a plain template that never replaces the widget.
|
|
5931
|
+
*/
|
|
5932
|
+
async function uncopiedNativeWidgets(api, themeId, themeRoot) {
|
|
5933
|
+
const local = localNativeWidgets(themeRoot);
|
|
5934
|
+
if (local.length === 0) return [];
|
|
5935
|
+
const copies = await listNativeWidgetCopies(api, themeId);
|
|
5936
|
+
return local.filter(({ key, type }) => !(copies.get(key) ?? []).some((copy) => copyFolder(key, copy) === nativeWidgetFolder(key, type)));
|
|
5937
|
+
}
|
|
5938
|
+
/** One line per uncopied folder, telling the person how to make its copy. */
|
|
5939
|
+
function uncopiedNativeWidgetWarning(widgets) {
|
|
5940
|
+
return ["Native widget folders without a theme copy:", ...widgets.map(({ key, type }) => ` ${nativeWidgetFolder(key, type)}/ has no copy on this theme; run \`fluid theme widget copy ${key}\` first, or it is pushed as a plain ${type === "widgets" ? "widget" : "section"} that does not replace the widget.`)].join("\n");
|
|
5941
|
+
}
|
|
5942
|
+
/**
|
|
5943
|
+
* Return a native widget to Fluid's original: delete every copy the theme
|
|
5944
|
+
* has of it, then remove its `sections/` and `widgets/` folders. A copy that
|
|
5945
|
+
* is already gone (404) is not an error; any other refusal stops the reset
|
|
5946
|
+
* before a local folder is touched.
|
|
5947
|
+
*/
|
|
5948
|
+
async function resetNativeWidget(api, themeRoot, key, copies) {
|
|
5949
|
+
let deletedCopies = 0;
|
|
5950
|
+
for (const copy of copies) {
|
|
5951
|
+
if (copy.id == null) continue;
|
|
5952
|
+
try {
|
|
5953
|
+
await deleteThemeTemplate(api, copy.id);
|
|
5954
|
+
deletedCopies += 1;
|
|
5955
|
+
} catch (error) {
|
|
5956
|
+
if (!(error instanceof ApiError && error.status === 404)) throw error;
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
const removedFolders = [];
|
|
5960
|
+
for (const type of NATIVE_WIDGET_TYPES) {
|
|
5961
|
+
const folder = nativeWidgetFolder(key, type);
|
|
5962
|
+
const absolute = join(themeRoot.root, folder);
|
|
5963
|
+
if (!existsSync(absolute)) continue;
|
|
5964
|
+
rmSync(absolute, {
|
|
5965
|
+
recursive: true,
|
|
5966
|
+
force: true
|
|
5967
|
+
});
|
|
5968
|
+
removedFolders.push(folder);
|
|
5969
|
+
}
|
|
5970
|
+
return {
|
|
5971
|
+
deletedCopies,
|
|
5972
|
+
removedFolders
|
|
5973
|
+
};
|
|
5974
|
+
}
|
|
5975
|
+
//#endregion
|
|
5503
5976
|
//#region src/commands/push.ts
|
|
5977
|
+
/**
|
|
5978
|
+
* Warn about `sections/` or `widgets/` `fluid_native_<key>/` folders the
|
|
5979
|
+
* theme has no copy of that type for: pushed, each becomes a plain template
|
|
5980
|
+
* that never replaces the widget. Only a warning, so a failed lookup never
|
|
5981
|
+
* stops the push.
|
|
5982
|
+
*/
|
|
5983
|
+
async function warnUncopiedNativeWidgets(api, themeId, themeRoot) {
|
|
5984
|
+
try {
|
|
5985
|
+
const uncopied = await uncopiedNativeWidgets(api, themeId, themeRoot);
|
|
5986
|
+
if (uncopied.length > 0) console.warn(chalk.yellow(uncopiedNativeWidgetWarning(uncopied)));
|
|
5987
|
+
} catch (error) {
|
|
5988
|
+
console.warn(chalk.yellow(` Could not check native widget copies: ${formatError(error)}`));
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5504
5991
|
function createPushCommand() {
|
|
5505
5992
|
return new Command("push").description("Push local theme files to a remote theme").option("-t, --theme <name-or-id>", "Theme name or ID to push to").option("-n, --nodelete", "Do not delete remote files missing locally").option("-f, --force", "Skip local Liquid validation and the server-side merge check").option("-p, --publish", "Publish the theme after pushing").option("-u, --unpublished", "Create a new unpublished theme and push to it").option("--auto-baseline", "When no local baseline exists, record the server's current state as the baseline and push only what differs locally (never modifies local files, never deletes server-only files)").option("--root <path>", "Theme root directory", ".").action(async (opts) => {
|
|
5506
5993
|
requireToken();
|
|
@@ -5538,6 +6025,7 @@ function createPushCommand() {
|
|
|
5538
6025
|
theme = (await getApplicationTheme(api, config.themeId)).application_theme;
|
|
5539
6026
|
if (theme.status === "development") console.warn(chalk.yellow(` ${theme.name} (#${theme.id}) is a development theme: a scratch copy made by \`fluid theme dev\`, not a theme your storefront serves. This push updates only that copy. To update the real theme, run \`fluid theme pull -t <theme-id>\` here to bind the project to it, or pass --theme.`));
|
|
5540
6027
|
} else theme = await selectTheme(api, "Select a theme to push to");
|
|
6028
|
+
await warnUncopiedNativeWidgets(api, theme.id, themeRoot);
|
|
5541
6029
|
if (config && !mayBindTheme(config, theme)) {
|
|
5542
6030
|
const own = getDevTheme(devThemeKey(config.company, themeRoot.root));
|
|
5543
6031
|
if (own?.id !== theme.id) {
|
|
@@ -6804,6 +7292,8 @@ function createLintCommand() {
|
|
|
6804
7292
|
file: f,
|
|
6805
7293
|
content: f.read()
|
|
6806
7294
|
}));
|
|
7295
|
+
const memberManifest = files.find((f) => f.relativePath === MEMBER_CONFIGURATION_KEY);
|
|
7296
|
+
const filesChecked = liquidFiles.length + scriptFiles.length + (memberManifest ? 1 : 0);
|
|
6807
7297
|
const byFile = /* @__PURE__ */ new Map();
|
|
6808
7298
|
const record = (path, diagnostic) => {
|
|
6809
7299
|
const existing = byFile.get(path);
|
|
@@ -6828,6 +7318,10 @@ function createLintCommand() {
|
|
|
6828
7318
|
for (const missing of findMissingSectionReferences(referrers, existingSectionNames)) record(missing.templatePath, missing.diagnostic);
|
|
6829
7319
|
const presentTemplateTypes = new Set(liquidFiles.map(({ file }) => file).filter((f) => f.isTemplate && f.name === "index.liquid").map((f) => f.relativePath.split(/[/\\]/)[0]));
|
|
6830
7320
|
for (const missing of findMissingTemplateTypes(presentTemplateTypes)) record(missing.expectedPath, missing.diagnostic);
|
|
7321
|
+
if (memberManifest) {
|
|
7322
|
+
const themePaths = new Set(files.map((f) => f.relativePath));
|
|
7323
|
+
for (const diagnostic of findMemberManifestDiagnostics(memberManifest.read(), themePaths)) record(MEMBER_CONFIGURATION_KEY, diagnostic);
|
|
7324
|
+
}
|
|
6831
7325
|
const results = [...byFile.entries()].map(([path, diagnostics]) => ({
|
|
6832
7326
|
path,
|
|
6833
7327
|
diagnostics
|
|
@@ -6841,11 +7335,11 @@ function createLintCommand() {
|
|
|
6841
7335
|
ok: errors === 0,
|
|
6842
7336
|
errors,
|
|
6843
7337
|
warnings,
|
|
6844
|
-
filesChecked
|
|
7338
|
+
filesChecked,
|
|
6845
7339
|
...hasInvalidSettingType ? { validSettingTypes: VALID_SETTING_TYPES } : {},
|
|
6846
7340
|
files: results
|
|
6847
7341
|
}));
|
|
6848
|
-
else printText(results, errors, warnings,
|
|
7342
|
+
else printText(results, errors, warnings, filesChecked);
|
|
6849
7343
|
process.exit(errors > 0 ? 1 : 0);
|
|
6850
7344
|
});
|
|
6851
7345
|
}
|
|
@@ -12878,6 +13372,7 @@ function resolveThemeId(opts) {
|
|
|
12878
13372
|
if (!config) throw new Error("No .fluid-theme.json here. Run `fluid theme pull` to bind this project to a theme, or pass --theme <id>.");
|
|
12879
13373
|
return config.themeId;
|
|
12880
13374
|
}
|
|
13375
|
+
/** The theme root: --root, else the theme root the workspace resolves from cwd. */
|
|
12881
13376
|
function resolveRoot(root) {
|
|
12882
13377
|
if (root !== ".") return root;
|
|
12883
13378
|
const workspace = findWorkspace();
|
|
@@ -12897,7 +13392,7 @@ function stagingJson(status) {
|
|
|
12897
13392
|
operation: status.operation
|
|
12898
13393
|
};
|
|
12899
13394
|
}
|
|
12900
|
-
async function run(opts, action) {
|
|
13395
|
+
async function run$1(opts, action) {
|
|
12901
13396
|
try {
|
|
12902
13397
|
await action();
|
|
12903
13398
|
} catch (error) {
|
|
@@ -12929,26 +13424,26 @@ function report(status, json) {
|
|
|
12929
13424
|
console.log(describeStaging(status));
|
|
12930
13425
|
if (status.branch?.preview_url) console.log(`Preview: ${chalk.cyan(status.branch.preview_url)}`);
|
|
12931
13426
|
}
|
|
12932
|
-
function withThemeOptions(command) {
|
|
13427
|
+
function withThemeOptions$1(command) {
|
|
12933
13428
|
return command.option("-t, --theme <id>", "Production theme ID (defaults to .fluid-theme.json)").option("--root <path>", "Theme root directory", ".").option("--json", "Emit JSON");
|
|
12934
13429
|
}
|
|
12935
13430
|
function createStagingCommand() {
|
|
12936
|
-
const status = withThemeOptions(new Command("status").description("Show the theme's staging branch and its preview link")).action((opts) => run(opts, async () => {
|
|
13431
|
+
const status = withThemeOptions$1(new Command("status").description("Show the theme's staging branch and its preview link")).action((opts) => run$1(opts, async () => {
|
|
12937
13432
|
requireToken();
|
|
12938
13433
|
report(await readStagingStatus(createApiClient(), resolveThemeId(opts)), opts.json);
|
|
12939
13434
|
}));
|
|
12940
|
-
const request = withThemeOptions(new Command("request").description("Create the theme's staging branch (or follow the one being created)")).action((opts) => run(opts, async () => {
|
|
13435
|
+
const request = withThemeOptions$1(new Command("request").description("Create the theme's staging branch (or follow the one being created)")).action((opts) => run$1(opts, async () => {
|
|
12941
13436
|
requireToken();
|
|
12942
13437
|
report(await ensureStaging(createApiClient(), resolveThemeId(opts)), opts.json);
|
|
12943
13438
|
}));
|
|
12944
|
-
const wait = withThemeOptions(new Command("wait").description("Wait until staging is ready or has failed")).option("--timeout <seconds>", "Give up after this many seconds", "600").action((opts) => run(opts, async () => {
|
|
13439
|
+
const wait = withThemeOptions$1(new Command("wait").description("Wait until staging is ready or has failed")).option("--timeout <seconds>", "Give up after this many seconds", "600").action((opts) => run$1(opts, async () => {
|
|
12945
13440
|
requireToken();
|
|
12946
13441
|
const timeoutMs = Number(opts.timeout) * 1e3;
|
|
12947
13442
|
const settled = await waitForStaging(createApiClient(), resolveThemeId(opts), { timeoutMs });
|
|
12948
13443
|
report(settled, opts.json);
|
|
12949
13444
|
if (settled.branch?.state !== "ready") process.exitCode = 1;
|
|
12950
13445
|
}));
|
|
12951
|
-
const publish = withThemeOptions(new Command("publish").description("Publish this directory's theme files to staging; production is not touched")).action((opts) => run(opts, async () => {
|
|
13446
|
+
const publish = withThemeOptions$1(new Command("publish").description("Publish this directory's theme files to staging; production is not touched")).action((opts) => run$1(opts, async () => {
|
|
12952
13447
|
requireToken();
|
|
12953
13448
|
const root = new ThemeRoot(resolveRoot(opts.root));
|
|
12954
13449
|
if (!root.isValid()) throw new Error(`'${root.root}' does not look like a theme directory.`);
|
|
@@ -12964,9 +13459,117 @@ function createStagingCommand() {
|
|
|
12964
13459
|
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);
|
|
12965
13460
|
}
|
|
12966
13461
|
//#endregion
|
|
13462
|
+
//#region src/commands/widget.ts
|
|
13463
|
+
function requireKey(key) {
|
|
13464
|
+
if (!isNativeWidgetKey(key)) throw new Error(`"${key}" is not a native widget key (lowercase letters, digits, "_" and "-").`);
|
|
13465
|
+
}
|
|
13466
|
+
/**
|
|
13467
|
+
* The theme a widget command changes, once it is known that the follow-up
|
|
13468
|
+
* pull may write it into `root`. A development theme that is not the one
|
|
13469
|
+
* this directory is bound to is refused here, before anything changes, the
|
|
13470
|
+
* same way `fluid theme pull` refuses it; otherwise the copy or reset would
|
|
13471
|
+
* land on that theme and its pull would then stop, leaving this directory
|
|
13472
|
+
* out of step with both.
|
|
13473
|
+
*/
|
|
13474
|
+
async function targetTheme(api, themeId, root) {
|
|
13475
|
+
const { application_theme: theme } = await getApplicationTheme(api, themeId);
|
|
13476
|
+
const config = readThemeConfig(root);
|
|
13477
|
+
if (config && !mayBindTheme(config, theme)) throw new Error(developmentThemeRefusal(config, theme));
|
|
13478
|
+
return theme;
|
|
13479
|
+
}
|
|
13480
|
+
/**
|
|
13481
|
+
* True when the theme is the company's live (published) theme, the one its
|
|
13482
|
+
* storefront and members are served. A copy or reset there changes what
|
|
13483
|
+
* members see at once.
|
|
13484
|
+
*/
|
|
13485
|
+
function isLiveTheme(theme) {
|
|
13486
|
+
return theme.status === "active";
|
|
13487
|
+
}
|
|
13488
|
+
const LIVE_THEME_NOTE = "It is the live theme, so members see the change immediately.";
|
|
13489
|
+
/** Ask the person at the terminal; anything but a yes declines. */
|
|
13490
|
+
async function confirm(message) {
|
|
13491
|
+
const { confirmed } = await prompts({
|
|
13492
|
+
type: "confirm",
|
|
13493
|
+
name: "confirmed",
|
|
13494
|
+
message,
|
|
13495
|
+
initial: false
|
|
13496
|
+
}, { onCancel: () => process.exit(130) });
|
|
13497
|
+
return confirmed === true;
|
|
13498
|
+
}
|
|
13499
|
+
/**
|
|
13500
|
+
* An ordinary `fluid theme pull` of the theme into the checkout. It brings
|
|
13501
|
+
* the copy's files down AND records them in the sync baseline, so the next
|
|
13502
|
+
* push neither refuses as "server has changed" nor treats the files as new.
|
|
13503
|
+
*/
|
|
13504
|
+
async function pullTheme(themeId, root) {
|
|
13505
|
+
await createPullCommand().parseAsync([
|
|
13506
|
+
"--yes",
|
|
13507
|
+
"-t",
|
|
13508
|
+
String(themeId),
|
|
13509
|
+
"--root",
|
|
13510
|
+
root
|
|
13511
|
+
], { from: "user" });
|
|
13512
|
+
}
|
|
13513
|
+
async function run(action) {
|
|
13514
|
+
try {
|
|
13515
|
+
await action();
|
|
13516
|
+
} catch (error) {
|
|
13517
|
+
console.error(chalk.red(formatError(error)));
|
|
13518
|
+
process.exitCode = 1;
|
|
13519
|
+
}
|
|
13520
|
+
}
|
|
13521
|
+
function withThemeOptions(command) {
|
|
13522
|
+
return command.option("-t, --theme <id>", "Theme ID to change (defaults to .fluid-theme.json)").option("--root <path>", "Theme root directory", ".").option("-y, --yes", "Skip confirmation prompt");
|
|
13523
|
+
}
|
|
13524
|
+
function createWidgetCommand() {
|
|
13525
|
+
const copy = withThemeOptions(new Command("copy").argument("<key>", "Native widget key, such as acct").description("Make the theme's copy of a native widget and pull it into fluid_native_<key>/ (asks first on the live theme)")).action((key, opts) => run(async () => {
|
|
13526
|
+
requireKey(key);
|
|
13527
|
+
requireToken();
|
|
13528
|
+
const root = resolveRoot(opts.root);
|
|
13529
|
+
const themeId = resolveThemeId(opts);
|
|
13530
|
+
const api = createApiClient();
|
|
13531
|
+
const theme = await targetTheme(api, themeId, root);
|
|
13532
|
+
if (!opts.yes && isLiveTheme(theme)) {
|
|
13533
|
+
if (!await confirm(`Copy ${key} on theme #${themeId}? ${LIVE_THEME_NOTE} The copy replaces Fluid's ${key} at every placement on it.`)) {
|
|
13534
|
+
console.log("Aborted.");
|
|
13535
|
+
return;
|
|
13536
|
+
}
|
|
13537
|
+
}
|
|
13538
|
+
const template = await copyNativeWidget(api, themeId, key);
|
|
13539
|
+
console.log(`Theme #${themeId} has its copy of ${chalk.bold(key)} (template #${template.id}). Pulling it into ${copyFolder(key, template)}/…`);
|
|
13540
|
+
await pullTheme(themeId, root);
|
|
13541
|
+
}));
|
|
13542
|
+
const reset = withThemeOptions(new Command("reset").argument("<key>", "Native widget key, such as acct").description("Delete the theme's copy of a native widget and remove its fluid_native_<key>/ folder")).action((key, opts) => run(async () => {
|
|
13543
|
+
requireKey(key);
|
|
13544
|
+
requireToken();
|
|
13545
|
+
const root = resolveRoot(opts.root);
|
|
13546
|
+
const themeId = resolveThemeId(opts);
|
|
13547
|
+
const api = createApiClient();
|
|
13548
|
+
const theme = await targetTheme(api, themeId, root);
|
|
13549
|
+
const copies = (await listNativeWidgetCopies(api, themeId, `fluid_native_${key}`)).get(key) ?? [];
|
|
13550
|
+
const folders = NATIVE_WIDGET_TYPES.map((type) => nativeWidgetFolder(key, type)).filter((folder) => existsSync(join(root, folder)));
|
|
13551
|
+
if (copies.length === 0 && folders.length === 0) {
|
|
13552
|
+
console.log(`Theme #${themeId} has no copy of ${key}, and there is no ${nativeWidgetFolder(key)}/ or ${nativeWidgetFolder(key, "widgets")}/ here. Nothing to reset.`);
|
|
13553
|
+
return;
|
|
13554
|
+
}
|
|
13555
|
+
if (!opts.yes) {
|
|
13556
|
+
const live = copies.length > 0 && isLiveTheme(theme) ? ` ${LIVE_THEME_NOTE}` : "";
|
|
13557
|
+
if (!await confirm(`Reset ${key} to Fluid's original? This deletes ${[copies.length > 0 && `theme #${themeId}'s copy`, ...folders.map((folder) => `${folder}/`)].filter(Boolean).join(" and ")}, including your changes.${live}`)) {
|
|
13558
|
+
console.log("Aborted.");
|
|
13559
|
+
return;
|
|
13560
|
+
}
|
|
13561
|
+
}
|
|
13562
|
+
const outcome = await resetNativeWidget(api, new ThemeRoot(root), key, copies);
|
|
13563
|
+
const done = [outcome.deletedCopies > 0 && `deleted theme #${themeId}'s copy`, ...outcome.removedFolders.map((folder) => `removed ${folder}/`)].filter(Boolean);
|
|
13564
|
+
console.log(`Reset ${chalk.bold(key)}: ${done.join(" and ") || "nothing left to remove"}.`);
|
|
13565
|
+
await pullTheme(themeId, root);
|
|
13566
|
+
}));
|
|
13567
|
+
return new Command("widget").description("Customize Fluid native widgets through the theme's own copy of each").addCommand(copy).addCommand(reset);
|
|
13568
|
+
}
|
|
13569
|
+
//#endregion
|
|
12967
13570
|
//#region src/commands/theme.ts
|
|
12968
13571
|
function registerThemeCommand(ctx) {
|
|
12969
|
-
const cmd = new Command("theme").description("Theme developer workflow — dev server, push, pull, lint, init, skills, crawl, compare");
|
|
13572
|
+
const cmd = new Command("theme").description("Theme developer workflow — dev server, push, pull, lint, init, skills, crawl, compare, widget");
|
|
12970
13573
|
cmd.addCommand(createDevCommand());
|
|
12971
13574
|
cmd.addCommand(createPushCommand());
|
|
12972
13575
|
cmd.addCommand(createPullCommand());
|
|
@@ -12977,6 +13580,7 @@ function registerThemeCommand(ctx) {
|
|
|
12977
13580
|
cmd.addCommand(createCrawlCommand());
|
|
12978
13581
|
cmd.addCommand(createCompareCommand());
|
|
12979
13582
|
cmd.addCommand(createStagingCommand());
|
|
13583
|
+
cmd.addCommand(createWidgetCommand());
|
|
12980
13584
|
ctx.program.addCommand(cmd);
|
|
12981
13585
|
}
|
|
12982
13586
|
//#endregion
|