@fluid-app/fluid-cli-theme-dev 0.1.522 → 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/dist/index.mjs +373 -54
- 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 {
|
|
@@ -1612,6 +1612,164 @@ function findMissingTemplateTypes(presentTypes) {
|
|
|
1612
1612
|
return missing;
|
|
1613
1613
|
}
|
|
1614
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
|
|
1615
1773
|
//#region src/theme/file.ts
|
|
1616
1774
|
const NON_TEMPLATE_DIRS = new Set([
|
|
1617
1775
|
"sections",
|
|
@@ -2050,8 +2208,8 @@ var MemberPreview = class {
|
|
|
2050
2208
|
application_theme_id: this.theme.id,
|
|
2051
2209
|
themeable_type: "members_page"
|
|
2052
2210
|
});
|
|
2053
|
-
const templates = isRecord$
|
|
2054
|
-
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);
|
|
2055
2213
|
} catch (error) {
|
|
2056
2214
|
const message = error instanceof Error ? error.message : String(error);
|
|
2057
2215
|
console.warn(`[Members] Could not read member page templates (${message}); page template paths are left out.`);
|
|
@@ -2136,7 +2294,7 @@ var MemberPreview = class {
|
|
|
2136
2294
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
2137
2295
|
res.end(req.method === "HEAD" ? void 0 : html);
|
|
2138
2296
|
} catch (error) {
|
|
2139
|
-
const status = error instanceof MemberPreviewError ? error.status : isRecord$
|
|
2297
|
+
const status = error instanceof MemberPreviewError ? error.status : isRecord$6(error) && typeof error.status === "number" && [
|
|
2140
2298
|
401,
|
|
2141
2299
|
403,
|
|
2142
2300
|
404,
|
|
@@ -2725,7 +2883,7 @@ function memberDependencyPaths(document, availablePaths, deletedPaths = [], chan
|
|
|
2725
2883
|
if (!path.endsWith("/index.liquid")) continue;
|
|
2726
2884
|
for (const suffix of ["variables.json", "styles.css"]) {
|
|
2727
2885
|
const sibling = path.replace(/index\.liquid$/, suffix);
|
|
2728
|
-
if ((suffix === "styles.css" ? changedPaths : availablePaths).has(sibling)
|
|
2886
|
+
if ((suffix === "styles.css" ? changedPaths : availablePaths).has(sibling)) dependencies.add(sibling);
|
|
2729
2887
|
}
|
|
2730
2888
|
}
|
|
2731
2889
|
for (const path of dependencies) if (isRetiredTemplateKey(path)) dependencies.delete(path);
|
|
@@ -2747,22 +2905,17 @@ function planThemeUploads(themeRoot, changedFiles, deletedPaths = []) {
|
|
|
2747
2905
|
if (Array.isArray(parsed)) return individualUploads(changedFiles);
|
|
2748
2906
|
if (!isRecord$3(parsed)) throw new Error("members_sites.json must contain a JSON object.");
|
|
2749
2907
|
const { document, removed } = withoutRetiredTemplates(parsed);
|
|
2750
|
-
const content = removed.length > 0 ?
|
|
2908
|
+
const content = removed.length > 0 ? serializeMemberDocument(document) : manifestContent;
|
|
2751
2909
|
const dependencies = memberDependencyPaths(document, new Set(localFiles.map((file) => file.relativePath)), deletedPaths, new Set(changedFiles.map((file) => file.relativePath)));
|
|
2752
|
-
for (const path of deletedPaths) if (dependencies.has(path)) throw new Error(`
|
|
2753
|
-
|
|
2754
|
-
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 }));
|
|
2755
2912
|
const availableFiles = new Map(localFiles.map((file) => [file.relativePath, file]));
|
|
2756
2913
|
const unavailable = [...dependencies].find((path) => {
|
|
2757
2914
|
const file = availableFiles.get(path);
|
|
2758
2915
|
return !file || !file.isText || themeRoot.ignore.ignore(path);
|
|
2759
2916
|
});
|
|
2760
|
-
if (unavailable) {
|
|
2761
|
-
if (!memberChanged) return changedFiles.map((file) => ({ file }));
|
|
2762
|
-
throw new Error(`Member dependency must be an available text file: ${unavailable}`);
|
|
2763
|
-
}
|
|
2917
|
+
if (unavailable) throw new Error(`Member dependency must be an available text file: ${unavailable}`);
|
|
2764
2918
|
const memberFiles = [...dependencies].map((path) => availableFiles.get(path));
|
|
2765
|
-
if (removed.length > 0) manifest.write(content);
|
|
2766
2919
|
const uploads = changedFiles.filter((file) => file.relativePath !== "members_sites.json" && !dependencies.has(file.relativePath)).map((file) => ({ file }));
|
|
2767
2920
|
uploads.push({
|
|
2768
2921
|
file: manifest,
|
|
@@ -2774,6 +2927,26 @@ function planThemeUploads(themeRoot, changedFiles, deletedPaths = []) {
|
|
|
2774
2927
|
return uploads;
|
|
2775
2928
|
}
|
|
2776
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
|
+
/**
|
|
2777
2950
|
* Drop references to retired template types. The server rejects the whole
|
|
2778
2951
|
* document for one, which would also hold back every member site and menu it
|
|
2779
2952
|
* carries.
|
|
@@ -2816,6 +2989,14 @@ function individualUploads(files) {
|
|
|
2816
2989
|
function isRecord$3(entry) {
|
|
2817
2990
|
return typeof entry === "object" && entry !== null && !Array.isArray(entry);
|
|
2818
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
|
+
}
|
|
2819
3000
|
/** Removing an older file is not an instruction to erase a member site. */
|
|
2820
3001
|
function assertMemberConfigurationRetained(deletedPaths) {
|
|
2821
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.");
|
|
@@ -3009,7 +3190,12 @@ var Syncer = class {
|
|
|
3009
3190
|
}
|
|
3010
3191
|
}
|
|
3011
3192
|
hasChanged(file) {
|
|
3012
|
-
|
|
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;
|
|
3013
3199
|
}
|
|
3014
3200
|
remoteKeys() {
|
|
3015
3201
|
return [...this.remoteResources.keys()];
|
|
@@ -3019,6 +3205,43 @@ var Syncer = class {
|
|
|
3019
3205
|
const resource = this.remoteResources.get(key);
|
|
3020
3206
|
return resource?.content != null || isManagedAssetResource(resource);
|
|
3021
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
|
+
}
|
|
3022
3245
|
/** Snapshot of remote checksums (key → sha256). Available after fetchChecksums() or downloadAll(). */
|
|
3023
3246
|
remoteChecksums() {
|
|
3024
3247
|
return Object.fromEntries(this.checksums);
|
|
@@ -3709,7 +3932,26 @@ var Syncer = class {
|
|
|
3709
3932
|
const localPaths = new Set(localFiles.map((file) => file.relativePath));
|
|
3710
3933
|
if (opts.delete) for (const key of this.assetManifest.keys()) localPaths.add(key);
|
|
3711
3934
|
const toDelete = opts.delete ? this.remoteKeys().filter((key) => key !== "members_sites.json" && this.canDeleteRemoteResource(key) && !localPaths.has(key) && !this.themeRoot.ignore.ignore(key)) : [];
|
|
3712
|
-
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
|
+
}
|
|
3713
3955
|
if (opts.linkManagedAssets) {
|
|
3714
3956
|
result.linked = await this.linkManagedAssets(opts.linkManagedAssets);
|
|
3715
3957
|
baseSha = this.lastKnownRemoteSha ?? baseSha;
|
|
@@ -3722,6 +3964,10 @@ var Syncer = class {
|
|
|
3722
3964
|
let done = 0;
|
|
3723
3965
|
for (const upload of toUpload) {
|
|
3724
3966
|
const { file } = upload;
|
|
3967
|
+
if (result.memberConfigurationHeld && !upload.memberConfiguration && waitsForBundle(file.relativePath)) {
|
|
3968
|
+
(result.heldChanges ??= []).push(file.relativePath);
|
|
3969
|
+
continue;
|
|
3970
|
+
}
|
|
3725
3971
|
if (file.relativePath === "members_sites.json" && result.errors.length > 0) {
|
|
3726
3972
|
result.errors.push("Skipped members_sites.json because a dependency upload failed.");
|
|
3727
3973
|
break;
|
|
@@ -3733,18 +3979,25 @@ var Syncer = class {
|
|
|
3733
3979
|
result.uploaded += 1 + (upload.memberConfiguration?.files.length ?? 0);
|
|
3734
3980
|
} catch (e) {
|
|
3735
3981
|
if (e instanceof PushConflictError) throw e;
|
|
3736
|
-
|
|
3982
|
+
if (upload.memberConfiguration && opts.holdMemberConfiguration) result.memberConfigurationHeld = formatError(e);
|
|
3983
|
+
else result.errors.push(`Upload ${file.relativePath}: ${formatError(e)}`);
|
|
3737
3984
|
}
|
|
3738
3985
|
done += 1 + (upload.memberConfiguration?.files.length ?? 0);
|
|
3739
3986
|
opts.onProgress?.(done, uploadCount);
|
|
3740
3987
|
}
|
|
3741
|
-
if (opts.delete && result.errors.length === 0)
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
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
|
+
}
|
|
3748
4001
|
}
|
|
3749
4002
|
return result;
|
|
3750
4003
|
}
|
|
@@ -3814,6 +4067,10 @@ function isNestedBinaryThemeAsset(file) {
|
|
|
3814
4067
|
function isManagedAssetResource(resource) {
|
|
3815
4068
|
return resource?.resource_type === "FileResource" && typeof resource.url === "string" && resource.url.length > 0;
|
|
3816
4069
|
}
|
|
4070
|
+
function memberContent(content) {
|
|
4071
|
+
if (typeof content === "string") return content;
|
|
4072
|
+
return content == null ? "" : JSON.stringify(content);
|
|
4073
|
+
}
|
|
3817
4074
|
function remoteResourceFromState(state) {
|
|
3818
4075
|
return {
|
|
3819
4076
|
key: state.key,
|
|
@@ -4115,6 +4372,13 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4115
4372
|
}
|
|
4116
4373
|
};
|
|
4117
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
|
+
};
|
|
4118
4382
|
console.log(`\nSyncing theme ${theme.name} (#${theme.id})…`);
|
|
4119
4383
|
const progress = (done, total) => {
|
|
4120
4384
|
process.stdout.write(`\r Uploading ${done}/${total} files…`);
|
|
@@ -4124,6 +4388,7 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4124
4388
|
validate: opts.validate,
|
|
4125
4389
|
linkManagedAssets: { replace: true },
|
|
4126
4390
|
pendingBinaryAssets: true,
|
|
4391
|
+
holdMemberConfiguration: true,
|
|
4127
4392
|
onProgress: progress
|
|
4128
4393
|
});
|
|
4129
4394
|
let syncResult;
|
|
@@ -4144,6 +4409,7 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4144
4409
|
baseSha: syncer.remoteSha(),
|
|
4145
4410
|
remoteState: opts.initialSync,
|
|
4146
4411
|
skipPreflight: true,
|
|
4412
|
+
holdMemberConfiguration: true,
|
|
4147
4413
|
onProgress: progress
|
|
4148
4414
|
}) : await uploadFromRemoteIndex();
|
|
4149
4415
|
} else syncResult = await uploadFromRemoteIndex();
|
|
@@ -4158,6 +4424,13 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4158
4424
|
for (const e of syncResult.errors) console.error(` ${e}`);
|
|
4159
4425
|
if (syncResult.uploaded + syncResult.deleted === 0) process.exit(1);
|
|
4160
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
|
+
}
|
|
4161
4434
|
if (syncResult.errors.length === 0) recordRemoteState();
|
|
4162
4435
|
const SYNC_IDLE_MS = 2e3;
|
|
4163
4436
|
let lastArrivedAt = 0;
|
|
@@ -4204,19 +4477,49 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4204
4477
|
await syncInFlight;
|
|
4205
4478
|
}
|
|
4206
4479
|
if (remoteWritesBlocked) return;
|
|
4207
|
-
|
|
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);
|
|
4208
4490
|
try {
|
|
4209
|
-
assertNoCaseCollisions(
|
|
4210
|
-
assertMemberConfigurationRetained(
|
|
4211
|
-
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);
|
|
4212
4493
|
} catch (error) {
|
|
4213
4494
|
console.error(`\n[Watcher] Sync blocked: ${String(error)}`);
|
|
4214
4495
|
return;
|
|
4215
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
|
+
}
|
|
4216
4518
|
let wroteRemote = false;
|
|
4217
4519
|
const memberTransfer = uploads.some((upload) => upload.memberConfiguration || upload.file.relativePath === "members_sites.json");
|
|
4218
4520
|
for (const upload of uploads) {
|
|
4219
4521
|
const { file } = upload;
|
|
4522
|
+
if (memberHeldReason && !upload.memberConfiguration && waitsForBundle(file.relativePath)) continue;
|
|
4220
4523
|
const uploadFiles = [file, ...upload.memberConfiguration?.files ?? []];
|
|
4221
4524
|
if (opts.validate) for (const candidate of uploadFiles) {
|
|
4222
4525
|
if (!candidate.isLiquid) continue;
|
|
@@ -4244,6 +4547,10 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4244
4547
|
break;
|
|
4245
4548
|
}
|
|
4246
4549
|
invalidateRemoteState();
|
|
4550
|
+
if (upload.memberConfiguration) {
|
|
4551
|
+
memberHeldReason = formatError(e);
|
|
4552
|
+
continue;
|
|
4553
|
+
}
|
|
4247
4554
|
console.error(`\n[Watcher] Upload failed: ${file.relativePath}: ${e}`);
|
|
4248
4555
|
remoteWritesBlocked = wroteRemote || memberTransfer;
|
|
4249
4556
|
if (remoteWritesBlocked) console.error("[Watcher] Restart theme dev to retry the incomplete transfer.");
|
|
@@ -4253,23 +4560,29 @@ async function startDevServer(api, theme, themeRoot, opts, onReady) {
|
|
|
4253
4560
|
}
|
|
4254
4561
|
}
|
|
4255
4562
|
if (remoteWritesBlocked) return;
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
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;
|
|
4272
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;
|
|
4273
4586
|
}
|
|
4274
4587
|
if (remoteWritesBlocked) return;
|
|
4275
4588
|
if (wroteRemote) {
|
|
@@ -5243,7 +5556,7 @@ async function diffAgainstShadow(themeRoot, shadow) {
|
|
|
5243
5556
|
localByKey.set(file.relativePath, file);
|
|
5244
5557
|
const headBlob = await shadow.blobAtHead(file.relativePath);
|
|
5245
5558
|
if (!headBlob && headPathSet.has(file.relativePath)) throw new Error(`Could not read the local theme shadow: ${file.relativePath}`);
|
|
5246
|
-
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();
|
|
5247
5560
|
if (headBlob && headBlob.equals(localBuf)) continue;
|
|
5248
5561
|
changed.push(file);
|
|
5249
5562
|
}
|
|
@@ -6979,6 +7292,8 @@ function createLintCommand() {
|
|
|
6979
7292
|
file: f,
|
|
6980
7293
|
content: f.read()
|
|
6981
7294
|
}));
|
|
7295
|
+
const memberManifest = files.find((f) => f.relativePath === MEMBER_CONFIGURATION_KEY);
|
|
7296
|
+
const filesChecked = liquidFiles.length + scriptFiles.length + (memberManifest ? 1 : 0);
|
|
6982
7297
|
const byFile = /* @__PURE__ */ new Map();
|
|
6983
7298
|
const record = (path, diagnostic) => {
|
|
6984
7299
|
const existing = byFile.get(path);
|
|
@@ -7003,6 +7318,10 @@ function createLintCommand() {
|
|
|
7003
7318
|
for (const missing of findMissingSectionReferences(referrers, existingSectionNames)) record(missing.templatePath, missing.diagnostic);
|
|
7004
7319
|
const presentTemplateTypes = new Set(liquidFiles.map(({ file }) => file).filter((f) => f.isTemplate && f.name === "index.liquid").map((f) => f.relativePath.split(/[/\\]/)[0]));
|
|
7005
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
|
+
}
|
|
7006
7325
|
const results = [...byFile.entries()].map(([path, diagnostics]) => ({
|
|
7007
7326
|
path,
|
|
7008
7327
|
diagnostics
|
|
@@ -7016,11 +7335,11 @@ function createLintCommand() {
|
|
|
7016
7335
|
ok: errors === 0,
|
|
7017
7336
|
errors,
|
|
7018
7337
|
warnings,
|
|
7019
|
-
filesChecked
|
|
7338
|
+
filesChecked,
|
|
7020
7339
|
...hasInvalidSettingType ? { validSettingTypes: VALID_SETTING_TYPES } : {},
|
|
7021
7340
|
files: results
|
|
7022
7341
|
}));
|
|
7023
|
-
else printText(results, errors, warnings,
|
|
7342
|
+
else printText(results, errors, warnings, filesChecked);
|
|
7024
7343
|
process.exit(errors > 0 ? 1 : 0);
|
|
7025
7344
|
});
|
|
7026
7345
|
}
|