@fluid-app/fluid-cli-theme-dev 0.1.18 → 0.1.20
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/.turbo/turbo-build.log +5 -5
- package/.turbo/turbo-typecheck.log +1 -1
- package/dist/index.mjs +31 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/commands/lint.ts +24 -13
- package/src/theme/file.ts +17 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-app/fluid-cli-theme-dev",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Fluid CLI plugin for theme developer workflows — dev server, push, pull, init",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"typescript": "^5",
|
|
37
37
|
"@fluid-app/api-client-core": "0.1.0",
|
|
38
38
|
"@fluid-app/theme-schema": "0.1.0",
|
|
39
|
-
"@fluid-app/
|
|
40
|
-
"@fluid-app/
|
|
39
|
+
"@fluid-app/themes-api-client": "0.1.0",
|
|
40
|
+
"@fluid-app/typescript-config": "0.0.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18.0.0"
|
package/src/commands/lint.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Command } from "commander";
|
|
|
3
3
|
import {
|
|
4
4
|
findMissingSectionReferences,
|
|
5
5
|
validateSchemaText,
|
|
6
|
+
VALID_SETTING_TYPES,
|
|
6
7
|
type BlocksSchemaType,
|
|
7
8
|
type Diagnostic,
|
|
8
9
|
type TemplateInput,
|
|
@@ -15,19 +16,14 @@ interface FileDiagnostics {
|
|
|
15
16
|
diagnostics: Diagnostic[];
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
// A theme section is defined by a liquid file under `
|
|
19
|
-
// Returns the section name a `{% section %}` tag would reference, or
|
|
20
|
-
// the file is not a section definition. Handles both the flat layout
|
|
21
|
-
// (`
|
|
22
|
-
// (`templates/sections/hero/index.liquid`).
|
|
19
|
+
// A theme section is defined by a liquid file under the top-level `sections/`
|
|
20
|
+
// directory. Returns the section name a `{% section %}` tag would reference, or
|
|
21
|
+
// null if the file is not a section definition. Handles both the flat layout
|
|
22
|
+
// (`sections/hero.liquid`) and the nested one (`sections/hero/index.liquid`).
|
|
23
23
|
function sectionNameOf(relativePath: string): string | null {
|
|
24
24
|
const parts = relativePath.split(/[/\\]/);
|
|
25
|
-
if (
|
|
26
|
-
parts[
|
|
27
|
-
parts[1] === "sections" &&
|
|
28
|
-
parts.length >= 3
|
|
29
|
-
) {
|
|
30
|
-
return parts[2]!.replace(/\.liquid$/, "");
|
|
25
|
+
if (parts[0] === "sections" && parts.length >= 2) {
|
|
26
|
+
return parts[1]!.replace(/\.liquid$/, "");
|
|
31
27
|
}
|
|
32
28
|
return null;
|
|
33
29
|
}
|
|
@@ -118,6 +114,18 @@ export function createLintCommand(): Command {
|
|
|
118
114
|
}
|
|
119
115
|
}
|
|
120
116
|
|
|
117
|
+
// Surface the canonical setting types once (not in every diagnostic) so a
|
|
118
|
+
// consumer fixing an "Invalid settings type" error has the valid set to
|
|
119
|
+
// hand without it bloating each message.
|
|
120
|
+
const hasInvalidSettingType = results.some(({ diagnostics }) =>
|
|
121
|
+
diagnostics.some(
|
|
122
|
+
(d) =>
|
|
123
|
+
d.target?.kind === "setting" &&
|
|
124
|
+
d.target.field === "type" &&
|
|
125
|
+
d.target.settingType !== undefined,
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
|
|
121
129
|
if (opts.json) {
|
|
122
130
|
console.log(
|
|
123
131
|
JSON.stringify({
|
|
@@ -125,6 +133,9 @@ export function createLintCommand(): Command {
|
|
|
125
133
|
errors,
|
|
126
134
|
warnings,
|
|
127
135
|
filesChecked: liquidFiles.length,
|
|
136
|
+
...(hasInvalidSettingType
|
|
137
|
+
? { validSettingTypes: VALID_SETTING_TYPES }
|
|
138
|
+
: {}),
|
|
128
139
|
files: results,
|
|
129
140
|
}),
|
|
130
141
|
);
|
|
@@ -153,8 +164,8 @@ function printText(
|
|
|
153
164
|
d.severity === "error"
|
|
154
165
|
? chalk.red("error".padEnd(7))
|
|
155
166
|
: chalk.yellow("warning".padEnd(7));
|
|
156
|
-
// Only the first line —
|
|
157
|
-
// carry a
|
|
167
|
+
// Only the first line — a few messages (e.g. the `Invalid JSON:` parse
|
|
168
|
+
// error) carry a multi-line body that `--json` preserves in full.
|
|
158
169
|
const message = d.message.split("\n")[0];
|
|
159
170
|
console.log(` ${label} ${message}`);
|
|
160
171
|
}
|
package/src/theme/file.ts
CHANGED
|
@@ -14,6 +14,18 @@ import {
|
|
|
14
14
|
type BlocksSchemaType,
|
|
15
15
|
} from "@fluid-app/theme-schema";
|
|
16
16
|
|
|
17
|
+
// Top-level theme folders that are not page templates. Everything else at the
|
|
18
|
+
// top level (home_page, product, page, footer, navbar, …) is a page template.
|
|
19
|
+
const NON_TEMPLATE_DIRS = new Set([
|
|
20
|
+
"sections",
|
|
21
|
+
"blocks",
|
|
22
|
+
"components",
|
|
23
|
+
"layouts",
|
|
24
|
+
"config",
|
|
25
|
+
"assets",
|
|
26
|
+
"locales",
|
|
27
|
+
]);
|
|
28
|
+
|
|
17
29
|
export class ThemeFile {
|
|
18
30
|
readonly absolutePath: string;
|
|
19
31
|
readonly relativePath: string;
|
|
@@ -72,16 +84,12 @@ export class ThemeFile {
|
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
get isTemplate(): boolean {
|
|
75
|
-
//
|
|
76
|
-
//
|
|
87
|
+
// Page templates (home_page, product, footer, navbar, …) live in top-level
|
|
88
|
+
// page-type folders and expect blocks as objects. The reserved categories
|
|
89
|
+
// below either expect blocks as arrays (sections, blocks, components) or
|
|
90
|
+
// carry no block schema (layouts, config, assets, locales).
|
|
77
91
|
const parts = this.relativePath.split(/[/\\]/);
|
|
78
|
-
return (
|
|
79
|
-
parts[0] === "templates" &&
|
|
80
|
-
parts.length >= 3 &&
|
|
81
|
-
parts[1] !== "sections" &&
|
|
82
|
-
parts[1] !== "blocks" &&
|
|
83
|
-
parts[1] !== "components"
|
|
84
|
-
);
|
|
92
|
+
return parts.length >= 2 && !NON_TEMPLATE_DIRS.has(parts[0]!);
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
validateSchema(): Diagnostic[] {
|