@fluid-app/fluid-cli-theme-dev 0.1.543 → 0.1.544
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 +83 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1089,6 +1089,45 @@ const RETIRED_TEMPLATE_TYPES = new Set([
|
|
|
1089
1089
|
"members_dashboard",
|
|
1090
1090
|
"members_login"
|
|
1091
1091
|
]);
|
|
1092
|
+
/**
|
|
1093
|
+
* Template types the resources API accepts as the first folder of a
|
|
1094
|
+
* `<type>/<name>/<file>` key: Rails' `Themes::Template::SUPPORTED_THEMEABLE_TYPES`
|
|
1095
|
+
* (the `themeable_type` enum less the retired types). Any other folder, such as
|
|
1096
|
+
* an app extension package kept beside the theme, answers 404 on upload.
|
|
1097
|
+
* `apps/rails/test/models/themes/cli_template_types_test.rb` keeps this list
|
|
1098
|
+
* in step with the enum.
|
|
1099
|
+
*/
|
|
1100
|
+
const SUPPORTED_TEMPLATE_TYPES = new Set([
|
|
1101
|
+
"product",
|
|
1102
|
+
"medium",
|
|
1103
|
+
"enrollment_pack",
|
|
1104
|
+
"shop_page",
|
|
1105
|
+
"navbar",
|
|
1106
|
+
"library",
|
|
1107
|
+
"page",
|
|
1108
|
+
"components",
|
|
1109
|
+
"library_navbar",
|
|
1110
|
+
"sections",
|
|
1111
|
+
"locales",
|
|
1112
|
+
"footer",
|
|
1113
|
+
"layouts",
|
|
1114
|
+
"category_page",
|
|
1115
|
+
"collection_page",
|
|
1116
|
+
"cart_page",
|
|
1117
|
+
"config",
|
|
1118
|
+
"home_page",
|
|
1119
|
+
"mysite",
|
|
1120
|
+
"join_page",
|
|
1121
|
+
"collection",
|
|
1122
|
+
"post",
|
|
1123
|
+
"category",
|
|
1124
|
+
"post_page",
|
|
1125
|
+
"blocks",
|
|
1126
|
+
"error_page",
|
|
1127
|
+
"members_page",
|
|
1128
|
+
"llms_txt",
|
|
1129
|
+
"widgets"
|
|
1130
|
+
]);
|
|
1092
1131
|
function isRetiredTemplateKey(relativePath) {
|
|
1093
1132
|
const [prefix] = normalizeThemeResourceKey(relativePath).split("/");
|
|
1094
1133
|
return prefix !== void 0 && RETIRED_TEMPLATE_TYPES.has(prefix);
|
|
@@ -1119,7 +1158,29 @@ function isThemeResourceKey(relativePath) {
|
|
|
1119
1158
|
const fileName = segments.at(-1);
|
|
1120
1159
|
if (!prefix || !fileName || segments.length < 2) return false;
|
|
1121
1160
|
if (prefix === "assets" || prefix === "config" || prefix === "locales" || prefix === "layouts") return true;
|
|
1122
|
-
return segments.length >= 3 && COMPOSITE_RESOURCE_FILE_NAMES.has(fileName);
|
|
1161
|
+
return segments.length >= 3 && SUPPORTED_TEMPLATE_TYPES.has(prefix) && COMPOSITE_RESOURCE_FILE_NAMES.has(fileName);
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Local files shaped like a template (`<folder>/<name>/index.liquid` and the
|
|
1165
|
+
* like) whose first folder is not a Fluid template type. Sync leaves them
|
|
1166
|
+
* out; push lists them so a misplaced section is not dropped without a word.
|
|
1167
|
+
*/
|
|
1168
|
+
function isUnsupportedTemplateKey(relativePath) {
|
|
1169
|
+
const key = normalizeThemeResourceKey(relativePath);
|
|
1170
|
+
if (!hasSafeSegments(key) || isRetiredTemplateKey(key)) return false;
|
|
1171
|
+
const segments = key.split("/");
|
|
1172
|
+
const prefix = segments[0];
|
|
1173
|
+
return segments.length >= 3 && prefix !== void 0 && prefix !== "assets" && !SUPPORTED_TEMPLATE_TYPES.has(prefix) && COMPOSITE_RESOURCE_FILE_NAMES.has(segments.at(-1) ?? "");
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Push warning for template-shaped files outside Fluid's template folders.
|
|
1177
|
+
* It names their top-level folders because nothing else in them is pushed
|
|
1178
|
+
* either: an extension package's assets and locales stay behind with its
|
|
1179
|
+
* sections.
|
|
1180
|
+
*/
|
|
1181
|
+
function unsupportedTemplateWarning(paths) {
|
|
1182
|
+
const folders = [...new Set(paths.map((path) => `${normalizeThemeResourceKey(path).split("/")[0]}/`))];
|
|
1183
|
+
return ` Not pushing ${folders.join(", ")}: Fluid has no template type for ` + (folders.length === 1 ? "that folder" : "those folders") + `, so none of its files reach the theme, assets included. Template files found: ${paths.join(", ")}. To push a section, move it to sections/<name>/index.liquid and its assets to assets/, or add the folder to .fluidignore.`;
|
|
1123
1184
|
}
|
|
1124
1185
|
//#endregion
|
|
1125
1186
|
//#region ../../platform/theme-schema/src/types.ts
|
|
@@ -1903,6 +1964,14 @@ var ThemeRoot = class {
|
|
|
1903
1964
|
templateAttachedFiles() {
|
|
1904
1965
|
return this.glob(this.root).filter((f) => /^[^/]+\/.+\/assets\//.test(f.relativePath) && !this.ignore.ignore(f.relativePath));
|
|
1905
1966
|
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Template-shaped files under a folder that is not a Fluid template type
|
|
1969
|
+
* (an app extension package, say). files() leaves them out; push names
|
|
1970
|
+
* them so the person pushing knows they did not land.
|
|
1971
|
+
*/
|
|
1972
|
+
unsupportedTemplateFiles() {
|
|
1973
|
+
return this.glob(this.root).filter((f) => isUnsupportedTemplateKey(f.relativePath) && !this.ignore.ignore(f.relativePath));
|
|
1974
|
+
}
|
|
1906
1975
|
isResourcePath(pathOrFile) {
|
|
1907
1976
|
return isThemeResourceKey(this.file(pathOrFile).relativePath);
|
|
1908
1977
|
}
|
|
@@ -3931,7 +4000,7 @@ var Syncer = class {
|
|
|
3931
4000
|
let baseSha = opts.baseSha ?? (opts.guardFetchedRemote && !opts.remoteState ? this.remoteSha() : null);
|
|
3932
4001
|
const localPaths = new Set(localFiles.map((file) => file.relativePath));
|
|
3933
4002
|
if (opts.delete) for (const key of this.assetManifest.keys()) localPaths.add(key);
|
|
3934
|
-
const toDelete = opts.delete ? this.remoteKeys().filter((key) => key !== "members_sites.json" && this.canDeleteRemoteResource(key) && !localPaths.has(key) && !this.themeRoot.ignore.ignore(key)) : [];
|
|
4003
|
+
const toDelete = opts.delete ? this.remoteKeys().filter((key) => key !== "members_sites.json" && isThemeResourceKey(key) && this.canDeleteRemoteResource(key) && !localPaths.has(key) && !this.themeRoot.ignore.ignore(key)) : [];
|
|
3935
4004
|
const changedFiles = localFiles.filter((f) => f.exists && this.hasChanged(f));
|
|
3936
4005
|
let plannedUploads;
|
|
3937
4006
|
try {
|
|
@@ -5565,6 +5634,7 @@ async function diffAgainstShadow(themeRoot, shadow) {
|
|
|
5565
5634
|
if (themeRoot.ignore.ignore(key)) continue;
|
|
5566
5635
|
if (assetManifest.has(key)) continue;
|
|
5567
5636
|
if (isStylesheetKey(key)) continue;
|
|
5637
|
+
if (!isThemeResourceKey(key)) continue;
|
|
5568
5638
|
deleted.push(key);
|
|
5569
5639
|
}
|
|
5570
5640
|
return {
|
|
@@ -5988,6 +6058,16 @@ async function warnUncopiedNativeWidgets(api, themeId, themeRoot) {
|
|
|
5988
6058
|
console.warn(chalk.yellow(` Could not check native widget copies: ${formatError(error)}`));
|
|
5989
6059
|
}
|
|
5990
6060
|
}
|
|
6061
|
+
/**
|
|
6062
|
+
* Fluid has no template type for these folders, so push leaves them out (the
|
|
6063
|
+
* resources API would answer 404). Name them so a section authored in the
|
|
6064
|
+
* wrong place, and the assets beside it, are not missing without a word.
|
|
6065
|
+
*/
|
|
6066
|
+
function warnUnsupportedTemplateFiles(themeRoot) {
|
|
6067
|
+
const skipped = themeRoot.unsupportedTemplateFiles();
|
|
6068
|
+
if (skipped.length === 0) return;
|
|
6069
|
+
console.warn(chalk.yellow(unsupportedTemplateWarning(skipped.map((file) => file.relativePath))));
|
|
6070
|
+
}
|
|
5991
6071
|
function createPushCommand() {
|
|
5992
6072
|
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) => {
|
|
5993
6073
|
requireToken();
|
|
@@ -6026,6 +6106,7 @@ function createPushCommand() {
|
|
|
6026
6106
|
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.`));
|
|
6027
6107
|
} else theme = await selectTheme(api, "Select a theme to push to");
|
|
6028
6108
|
await warnUncopiedNativeWidgets(api, theme.id, themeRoot);
|
|
6109
|
+
warnUnsupportedTemplateFiles(themeRoot);
|
|
6029
6110
|
if (config && !mayBindTheme(config, theme)) {
|
|
6030
6111
|
const own = getDevTheme(devThemeKey(config.company, themeRoot.root));
|
|
6031
6112
|
if (own?.id !== theme.id) {
|