jekyll-component-mcp 0.0.0-stage → 1.0.2
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/.github/skills/.gitkeep +0 -0
- package/.github/skills/jekyll-component-mcp/SKILL.md +98 -0
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +167 -2
- package/dist/config/constants.d.ts +46 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +75 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/environment.d.ts +51 -0
- package/dist/config/environment.d.ts.map +1 -0
- package/dist/config/environment.js +102 -0
- package/dist/config/environment.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/frontmatter-parser.d.ts +19 -0
- package/dist/parsers/frontmatter-parser.d.ts.map +1 -0
- package/dist/parsers/frontmatter-parser.js +71 -0
- package/dist/parsers/frontmatter-parser.js.map +1 -0
- package/dist/parsers/liquid-parser.d.ts +33 -0
- package/dist/parsers/liquid-parser.d.ts.map +1 -0
- package/dist/parsers/liquid-parser.js +98 -0
- package/dist/parsers/liquid-parser.js.map +1 -0
- package/dist/parsers/project-scanner.d.ts +29 -0
- package/dist/parsers/project-scanner.d.ts.map +1 -0
- package/dist/parsers/project-scanner.js +194 -0
- package/dist/parsers/project-scanner.js.map +1 -0
- package/dist/parsers/scss-parser.d.ts +26 -0
- package/dist/parsers/scss-parser.d.ts.map +1 -0
- package/dist/parsers/scss-parser.js +90 -0
- package/dist/parsers/scss-parser.js.map +1 -0
- package/dist/security/command-policy.d.ts +21 -0
- package/dist/security/command-policy.d.ts.map +1 -0
- package/dist/security/command-policy.js +48 -0
- package/dist/security/command-policy.js.map +1 -0
- package/dist/security/path-policy.d.ts +31 -0
- package/dist/security/path-policy.d.ts.map +1 -0
- package/dist/security/path-policy.js +127 -0
- package/dist/security/path-policy.js.map +1 -0
- package/dist/security/validation.d.ts +18 -0
- package/dist/security/validation.d.ts.map +1 -0
- package/dist/security/validation.js +59 -0
- package/dist/security/validation.js.map +1 -0
- package/dist/server/context.d.ts +18 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +34 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/create-server.d.ts +8 -0
- package/dist/server/create-server.d.ts.map +1 -0
- package/dist/server/create-server.js +546 -0
- package/dist/server/create-server.js.map +1 -0
- package/dist/services/build-service.d.ts +27 -0
- package/dist/services/build-service.d.ts.map +1 -0
- package/dist/services/build-service.js +85 -0
- package/dist/services/build-service.js.map +1 -0
- package/dist/services/component-service.d.ts +74 -0
- package/dist/services/component-service.d.ts.map +1 -0
- package/dist/services/component-service.js +422 -0
- package/dist/services/component-service.js.map +1 -0
- package/dist/services/documentation-service.d.ts +64 -0
- package/dist/services/documentation-service.d.ts.map +1 -0
- package/dist/services/documentation-service.js +186 -0
- package/dist/services/documentation-service.js.map +1 -0
- package/dist/services/liquid-service.d.ts +31 -0
- package/dist/services/liquid-service.d.ts.map +1 -0
- package/dist/services/liquid-service.js +103 -0
- package/dist/services/liquid-service.js.map +1 -0
- package/dist/services/project-service.d.ts +30 -0
- package/dist/services/project-service.d.ts.map +1 -0
- package/dist/services/project-service.js +102 -0
- package/dist/services/project-service.js.map +1 -0
- package/dist/services/scss-service.d.ts +37 -0
- package/dist/services/scss-service.d.ts.map +1 -0
- package/dist/services/scss-service.js +82 -0
- package/dist/services/scss-service.js.map +1 -0
- package/dist/services/token-service.d.ts +29 -0
- package/dist/services/token-service.d.ts.map +1 -0
- package/dist/services/token-service.js +97 -0
- package/dist/services/token-service.js.map +1 -0
- package/dist/services/validation-service.d.ts +33 -0
- package/dist/services/validation-service.d.ts.map +1 -0
- package/dist/services/validation-service.js +101 -0
- package/dist/services/validation-service.js.map +1 -0
- package/dist/utils/filesystem.d.ts +38 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +131 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/json.d.ts +6 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +20 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +58 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/shell.d.ts +23 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +96 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/yaml.d.ts +15 -0
- package/dist/utils/yaml.d.ts.map +1 -0
- package/dist/utils/yaml.js +34 -0
- package/dist/utils/yaml.js.map +1 -0
- package/package.json +65 -4
- package/skills/SKILL.md +98 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation-service.d.ts","sourceRoot":"","sources":["../../src/services/documentation-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA2E1D,qBAAa,oBAAoB;IAGnB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,OAAO,CAAC,UAAU,CAAmB;gBAER,GAAG,EAAE,aAAa;IAI/C,MAAM,CAAC,KAAK,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,UAAU,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC5F,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG;QACF,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QA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* Component documentation create / update.
|
|
3
|
+
*/
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { assertWriteAllowed } from "../server/context.js";
|
|
6
|
+
import { normalizeComponentName } from "../security/validation.js";
|
|
7
|
+
import { safeExists, safeReadFile, safeWriteFile } from "../utils/filesystem.js";
|
|
8
|
+
import { ComponentService } from "./component-service.js";
|
|
9
|
+
import { logger } from "../utils/logger.js";
|
|
10
|
+
function buildDocsMarkdown(input) {
|
|
11
|
+
const params = input.parameters?.length
|
|
12
|
+
? input.parameters
|
|
13
|
+
: [
|
|
14
|
+
{ name: "label", type: "string", default: '""', description: "Visible label" },
|
|
15
|
+
{ name: "variant", type: "string", default: '"default"', description: "Visual variant" },
|
|
16
|
+
{ name: "class", type: "string", default: '""', description: "Extra CSS classes" },
|
|
17
|
+
];
|
|
18
|
+
const variants = input.variants?.length ? input.variants : ["default"];
|
|
19
|
+
const usage = input.usage ??
|
|
20
|
+
`{% include components/${input.name}.html label="Example" variant="default" %}`;
|
|
21
|
+
return `---
|
|
22
|
+
title: ${input.name}
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# ${input.name}
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
${input.overview ?? `Reusable \`${input.name}\` component for the Jekyll Component Framework.`}
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
\`\`\`liquid
|
|
34
|
+
${usage}
|
|
35
|
+
\`\`\`
|
|
36
|
+
|
|
37
|
+
## Parameters
|
|
38
|
+
|
|
39
|
+
| Name | Type | Default | Description |
|
|
40
|
+
|------|------|---------|-------------|
|
|
41
|
+
${params
|
|
42
|
+
.map((p) => `| ${p.name} | ${p.type ?? "string"} | ${p.default ?? "—"} | ${p.description ?? ""} |`)
|
|
43
|
+
.join("\n")}
|
|
44
|
+
|
|
45
|
+
## Variants
|
|
46
|
+
|
|
47
|
+
${variants.map((v) => `- \`${v}\``).join("\n")}
|
|
48
|
+
|
|
49
|
+
## Example
|
|
50
|
+
|
|
51
|
+
See \`examples/components/${input.name}.html\`.
|
|
52
|
+
|
|
53
|
+
## Accessibility
|
|
54
|
+
|
|
55
|
+
${input.accessibility ?? "- Prefer semantic HTML\n- Ensure keyboard support for interactive variants\n- Provide visible focus styles"}
|
|
56
|
+
|
|
57
|
+
## Notes
|
|
58
|
+
|
|
59
|
+
${input.notes ?? "Generated/updated by jekyll-component-mcp."}
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
export class DocumentationService {
|
|
63
|
+
ctx;
|
|
64
|
+
components;
|
|
65
|
+
constructor(ctx) {
|
|
66
|
+
this.ctx = ctx;
|
|
67
|
+
this.components = new ComponentService(ctx);
|
|
68
|
+
}
|
|
69
|
+
create(input) {
|
|
70
|
+
try {
|
|
71
|
+
assertWriteAllowed(this.ctx, "create");
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
operation: "docs_create",
|
|
77
|
+
error: {
|
|
78
|
+
code: err.code ?? "WRITE_MODE_DENIED",
|
|
79
|
+
message: err.message,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const name = normalizeComponentName(input.name);
|
|
84
|
+
const docsDir = this.ctx.config.paths.docsComponents ??
|
|
85
|
+
path.posix.join(this.ctx.config.paths.docs, "components");
|
|
86
|
+
const filePath = path.posix.join(docsDir, `${name}.md`);
|
|
87
|
+
if (input.dry_run) {
|
|
88
|
+
return {
|
|
89
|
+
success: true,
|
|
90
|
+
operation: "docs_create",
|
|
91
|
+
dry_run: true,
|
|
92
|
+
operations: [{ type: "create", path: filePath }],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const content = buildDocsMarkdown({
|
|
96
|
+
name,
|
|
97
|
+
overview: input.overview,
|
|
98
|
+
variants: input.variants,
|
|
99
|
+
parameters: input.parameters,
|
|
100
|
+
});
|
|
101
|
+
const result = safeWriteFile(this.ctx.config.root, filePath, content, {
|
|
102
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
103
|
+
});
|
|
104
|
+
this.ctx.invalidateCache();
|
|
105
|
+
logger.info("docs_create", { path: result.path });
|
|
106
|
+
return { success: true, operation: "docs_create", path: result.path };
|
|
107
|
+
}
|
|
108
|
+
update(input) {
|
|
109
|
+
try {
|
|
110
|
+
assertWriteAllowed(this.ctx, "update");
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
operation: "docs_update",
|
|
116
|
+
error: {
|
|
117
|
+
code: err.code ?? "WRITE_MODE_DENIED",
|
|
118
|
+
message: err.message,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const name = normalizeComponentName(input.name);
|
|
123
|
+
const detail = this.components.get(name);
|
|
124
|
+
const docsDir = this.ctx.config.paths.docsComponents ??
|
|
125
|
+
path.posix.join(this.ctx.config.paths.docs, "components");
|
|
126
|
+
const filePath = detail?.documentation ?? path.posix.join(docsDir, `${name}.md`);
|
|
127
|
+
// Merge with existing analysis if available
|
|
128
|
+
const variants = input.variants ??
|
|
129
|
+
detail?.variants ??
|
|
130
|
+
["default"];
|
|
131
|
+
const parameters = input.parameters ??
|
|
132
|
+
detail?.parameters?.map((p) => ({
|
|
133
|
+
name: p.name,
|
|
134
|
+
type: "string",
|
|
135
|
+
description: `Detected from Liquid (used ${p.usageCount}×)`,
|
|
136
|
+
}));
|
|
137
|
+
const content = buildDocsMarkdown({
|
|
138
|
+
name,
|
|
139
|
+
overview: input.overview,
|
|
140
|
+
variants,
|
|
141
|
+
parameters,
|
|
142
|
+
accessibility: input.accessibility,
|
|
143
|
+
notes: input.notes,
|
|
144
|
+
});
|
|
145
|
+
if (input.dry_run) {
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
operation: "docs_update",
|
|
149
|
+
path: filePath,
|
|
150
|
+
dry_run: true,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const result = safeWriteFile(this.ctx.config.root, filePath, content, {
|
|
154
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
155
|
+
});
|
|
156
|
+
this.ctx.invalidateCache();
|
|
157
|
+
logger.info("docs_update", { path: result.path, created: result.created });
|
|
158
|
+
return {
|
|
159
|
+
success: true,
|
|
160
|
+
operation: "docs_update",
|
|
161
|
+
path: result.path,
|
|
162
|
+
created: result.created,
|
|
163
|
+
modified: result.modified,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
get(name) {
|
|
167
|
+
const normalized = normalizeComponentName(name);
|
|
168
|
+
const detail = this.components.get(normalized);
|
|
169
|
+
if (detail?.documentation && detail.documentationSource) {
|
|
170
|
+
return { path: detail.documentation, source: detail.documentationSource };
|
|
171
|
+
}
|
|
172
|
+
const docsDir = this.ctx.config.paths.docsComponents ??
|
|
173
|
+
path.posix.join(this.ctx.config.paths.docs, "components");
|
|
174
|
+
const filePath = path.posix.join(docsDir, `${normalized}.md`);
|
|
175
|
+
if (safeExists(this.ctx.config.root, filePath)) {
|
|
176
|
+
return {
|
|
177
|
+
path: filePath,
|
|
178
|
+
source: safeReadFile(this.ctx.config.root, filePath, {
|
|
179
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=documentation-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation-service.js","sourceRoot":"","sources":["../../src/services/documentation-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM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AM,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE;oBACnD,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW;iBACrC,CAAC;aACH,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Liquid includes and layouts — read-only source inspection (never executes Liquid).
|
|
3
|
+
*/
|
|
4
|
+
import type { ServerContext } from "../server/context.js";
|
|
5
|
+
import { analyzeLiquid } from "../parsers/liquid-parser.js";
|
|
6
|
+
export interface LiquidFileInfo {
|
|
7
|
+
name: string;
|
|
8
|
+
path: string;
|
|
9
|
+
kind: "include" | "layout" | "section";
|
|
10
|
+
}
|
|
11
|
+
export interface LiquidFileDetail extends LiquidFileInfo {
|
|
12
|
+
source: string;
|
|
13
|
+
frontMatter: Record<string, unknown>;
|
|
14
|
+
analysis: ReturnType<typeof analyzeLiquid>;
|
|
15
|
+
syntax: {
|
|
16
|
+
errors: string[];
|
|
17
|
+
warnings: string[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare class LiquidService {
|
|
21
|
+
private readonly ctx;
|
|
22
|
+
constructor(ctx: ServerContext);
|
|
23
|
+
listIncludes(): LiquidFileInfo[];
|
|
24
|
+
listLayouts(): LiquidFileInfo[];
|
|
25
|
+
listSections(): LiquidFileInfo[];
|
|
26
|
+
private listInDir;
|
|
27
|
+
getInclude(nameOrPath: string): LiquidFileDetail | null;
|
|
28
|
+
getLayout(nameOrPath: string): LiquidFileDetail | null;
|
|
29
|
+
private getByNameOrPath;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=liquid-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquid-service.d.ts","sourceRoot":"","sources":["../../src/services/liquid-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAqB,MAAM,6BAA6B,CAAC;AAG/E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;IAC3C,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAClD;AAMD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAE/C,YAAY,IAAI,cAAc,EAAE;IAIhC,WAAW,IAAI,cAAc,EAAE;IAI/B,YAAY,IAAI,cAAc,EAAE;IAMhC,OAAO,CAAC,SAAS;IAyBjB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIvD,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAItD,OAAO,CAAC,eAAe;CAoDxB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Liquid includes and layouts — read-only source inspection (never executes Liquid).
|
|
3
|
+
*/
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { safeExists, safeReadFile, safeWalk } from "../utils/filesystem.js";
|
|
6
|
+
import { analyzeLiquid, checkLiquidSyntax } from "../parsers/liquid-parser.js";
|
|
7
|
+
import { extractFrontMatter } from "../utils/yaml.js";
|
|
8
|
+
function basenameNoExt(filePath) {
|
|
9
|
+
return path.basename(filePath, path.extname(filePath)).replace(/^_/, "");
|
|
10
|
+
}
|
|
11
|
+
export class LiquidService {
|
|
12
|
+
ctx;
|
|
13
|
+
constructor(ctx) {
|
|
14
|
+
this.ctx = ctx;
|
|
15
|
+
}
|
|
16
|
+
listIncludes() {
|
|
17
|
+
return this.listInDir(this.ctx.config.paths.includes, "include", 5);
|
|
18
|
+
}
|
|
19
|
+
listLayouts() {
|
|
20
|
+
return this.listInDir(this.ctx.config.paths.layouts, "layout", 3);
|
|
21
|
+
}
|
|
22
|
+
listSections() {
|
|
23
|
+
const sectionsPath = this.ctx.config.paths.sections;
|
|
24
|
+
if (!safeExists(this.ctx.config.root, sectionsPath))
|
|
25
|
+
return [];
|
|
26
|
+
return this.listInDir(sectionsPath, "section", 3);
|
|
27
|
+
}
|
|
28
|
+
listInDir(relDir, kind, maxDepth) {
|
|
29
|
+
const root = this.ctx.config.root;
|
|
30
|
+
if (!safeExists(root, relDir))
|
|
31
|
+
return [];
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const e of safeWalk(root, relDir, {
|
|
34
|
+
maxDepth,
|
|
35
|
+
extensions: [".html", ".liquid", ".md"],
|
|
36
|
+
})) {
|
|
37
|
+
if (e.isDirectory)
|
|
38
|
+
continue;
|
|
39
|
+
// Skip component subdir when listing generic includes (components have their own tools)
|
|
40
|
+
if (kind === "include" && e.relativePath.includes("/components/"))
|
|
41
|
+
continue;
|
|
42
|
+
if (kind === "include" && e.relativePath.includes("/sections/"))
|
|
43
|
+
continue;
|
|
44
|
+
out.push({
|
|
45
|
+
name: basenameNoExt(e.relativePath),
|
|
46
|
+
path: e.relativePath,
|
|
47
|
+
kind,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
51
|
+
}
|
|
52
|
+
getInclude(nameOrPath) {
|
|
53
|
+
return this.getByNameOrPath(nameOrPath, "include");
|
|
54
|
+
}
|
|
55
|
+
getLayout(nameOrPath) {
|
|
56
|
+
return this.getByNameOrPath(nameOrPath, "layout");
|
|
57
|
+
}
|
|
58
|
+
getByNameOrPath(nameOrPath, kind) {
|
|
59
|
+
const root = this.ctx.config.root;
|
|
60
|
+
const list = kind === "include" ? this.listIncludes() : this.listLayouts();
|
|
61
|
+
// Exact path match first
|
|
62
|
+
let match = list.find((f) => f.path === nameOrPath || f.path.endsWith(`/${nameOrPath}`));
|
|
63
|
+
if (!match) {
|
|
64
|
+
const normalized = nameOrPath
|
|
65
|
+
.toLowerCase()
|
|
66
|
+
.replace(/\.(html|liquid|md)$/, "")
|
|
67
|
+
.replace(/[_\s]+/g, "-");
|
|
68
|
+
match = list.find((f) => f.name === normalized ||
|
|
69
|
+
f.name === nameOrPath ||
|
|
70
|
+
f.path.includes(normalized));
|
|
71
|
+
}
|
|
72
|
+
if (!match) {
|
|
73
|
+
// Try direct path under configured dir
|
|
74
|
+
const baseDir = kind === "include" ? this.ctx.config.paths.includes : this.ctx.config.paths.layouts;
|
|
75
|
+
const candidates = [
|
|
76
|
+
nameOrPath,
|
|
77
|
+
path.posix.join(baseDir, nameOrPath),
|
|
78
|
+
path.posix.join(baseDir, `${nameOrPath}.html`),
|
|
79
|
+
path.posix.join(baseDir, `${nameOrPath}.liquid`),
|
|
80
|
+
];
|
|
81
|
+
for (const c of candidates) {
|
|
82
|
+
if (safeExists(root, c)) {
|
|
83
|
+
match = { name: basenameNoExt(c), path: c, kind };
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!match)
|
|
89
|
+
return null;
|
|
90
|
+
const source = safeReadFile(root, match.path, {
|
|
91
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
92
|
+
});
|
|
93
|
+
const { data } = extractFrontMatter(source);
|
|
94
|
+
return {
|
|
95
|
+
...match,
|
|
96
|
+
source,
|
|
97
|
+
frontMatter: data,
|
|
98
|
+
analysis: analyzeLiquid(source),
|
|
99
|
+
syntax: checkLiquidSyntax(source),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=liquid-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquid-service.js","sourceRoot":"","sources":["../../src/services/liquid-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAetD,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,GAAkB;QAAlB,QAAG,GAAH,GAAG,CAAe;IAAG,CAAC;IAEnD,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,YAAY;QACV,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;QACpD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QA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AU,CAAC;gBACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,OAAO,CAAC;gBAC9C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,SAAS,CAAC;aACjD,CAAC;YACF,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;gBAC3B,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;oBACxB,KAAK,GAAG,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;oBAClD,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAExB,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE;YAC5C,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW;SACrC,CAAC,CAAC;QACH,MAAM,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO;YACL,GAAG,KAAK;YACR,MAAM;YACN,WAAW,EAAE,IAAI;YACjB,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC;YAC/B,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;SAClC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level project inspection service.
|
|
3
|
+
*/
|
|
4
|
+
import type { ServerContext } from "../server/context.js";
|
|
5
|
+
import { type ProjectScanResult } from "../parsers/project-scanner.js";
|
|
6
|
+
export interface ProjectInfo {
|
|
7
|
+
root: string;
|
|
8
|
+
jekyll: boolean;
|
|
9
|
+
config: boolean;
|
|
10
|
+
layouts: number;
|
|
11
|
+
includes: number;
|
|
12
|
+
components: number;
|
|
13
|
+
sections: number;
|
|
14
|
+
scss: boolean;
|
|
15
|
+
javascript: boolean;
|
|
16
|
+
documentation: boolean;
|
|
17
|
+
hasBundler: boolean;
|
|
18
|
+
writeMode: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class ProjectService {
|
|
21
|
+
private readonly ctx;
|
|
22
|
+
constructor(ctx: ServerContext);
|
|
23
|
+
getInfo(): ProjectInfo;
|
|
24
|
+
getScan(force?: boolean): ProjectScanResult;
|
|
25
|
+
getConfig(): {
|
|
26
|
+
files: string[];
|
|
27
|
+
data: unknown;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=project-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-service.d.ts","sourceRoot":"","sources":["../../src/services/project-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAKpF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAwCD,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAE/C,OAAO,IAAI,WAAW;IAkBtB,OAAO,CAAC,KAAK,UAAQ,GAAG,iBAAiB;IAWzC,SAAS,IAAI;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;CAmBhD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* High-level project inspection service.
|
|
3
|
+
*/
|
|
4
|
+
import { scanProject } from "../parsers/project-scanner.js";
|
|
5
|
+
import { safeReadFile } from "../utils/filesystem.js";
|
|
6
|
+
import { parseYaml } from "../utils/yaml.js";
|
|
7
|
+
import { logger } from "../utils/logger.js";
|
|
8
|
+
const SENSITIVE_CONFIG_KEYS = new Set([
|
|
9
|
+
"api_key",
|
|
10
|
+
"apikey",
|
|
11
|
+
"secret",
|
|
12
|
+
"token",
|
|
13
|
+
"password",
|
|
14
|
+
"credential",
|
|
15
|
+
"private_key",
|
|
16
|
+
"access_key",
|
|
17
|
+
"auth",
|
|
18
|
+
"aws",
|
|
19
|
+
"github_token",
|
|
20
|
+
"npm_token",
|
|
21
|
+
]);
|
|
22
|
+
function isSensitiveKey(key) {
|
|
23
|
+
const lower = key.toLowerCase();
|
|
24
|
+
for (const s of SENSITIVE_CONFIG_KEYS) {
|
|
25
|
+
if (lower.includes(s))
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
function sanitizeConfig(obj, depth = 0) {
|
|
31
|
+
if (depth > 8)
|
|
32
|
+
return "[truncated]";
|
|
33
|
+
if (obj === null || typeof obj !== "object")
|
|
34
|
+
return obj;
|
|
35
|
+
if (Array.isArray(obj))
|
|
36
|
+
return obj.map((v) => sanitizeConfig(v, depth + 1));
|
|
37
|
+
const out = {};
|
|
38
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
39
|
+
if (isSensitiveKey(k)) {
|
|
40
|
+
out[k] = "[REDACTED]";
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
out[k] = sanitizeConfig(v, depth + 1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
export class ProjectService {
|
|
49
|
+
ctx;
|
|
50
|
+
constructor(ctx) {
|
|
51
|
+
this.ctx = ctx;
|
|
52
|
+
}
|
|
53
|
+
getInfo() {
|
|
54
|
+
const scan = this.getScan();
|
|
55
|
+
return {
|
|
56
|
+
root: this.ctx.config.root,
|
|
57
|
+
jekyll: scan.jekyll,
|
|
58
|
+
config: scan.configFiles.length > 0,
|
|
59
|
+
layouts: scan.layouts.length,
|
|
60
|
+
includes: scan.includes.length,
|
|
61
|
+
components: scan.components.length,
|
|
62
|
+
sections: scan.sections.length,
|
|
63
|
+
scss: scan.scssFiles.length > 0 || scan.directories.scss,
|
|
64
|
+
javascript: scan.jsFiles.length > 0,
|
|
65
|
+
documentation: scan.docsFiles.length > 0,
|
|
66
|
+
hasBundler: scan.hasBundler,
|
|
67
|
+
writeMode: this.ctx.config.writeMode,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
getScan(force = false) {
|
|
71
|
+
if (!force && this.ctx.cache.scanResult) {
|
|
72
|
+
return this.ctx.cache.scanResult;
|
|
73
|
+
}
|
|
74
|
+
logger.debug("Scanning project", { root: this.ctx.config.root });
|
|
75
|
+
const result = scanProject(this.ctx.config);
|
|
76
|
+
this.ctx.cache.scanResult = result;
|
|
77
|
+
this.ctx.cache.scannedAt = Date.now();
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
getConfig() {
|
|
81
|
+
const scan = this.getScan();
|
|
82
|
+
const data = {};
|
|
83
|
+
for (const file of scan.configFiles) {
|
|
84
|
+
try {
|
|
85
|
+
const raw = safeReadFile(this.ctx.config.root, file, {
|
|
86
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
87
|
+
});
|
|
88
|
+
if (file.endsWith(".yml") || file.endsWith(".yaml")) {
|
|
89
|
+
data[file] = sanitizeConfig(parseYaml(raw));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
data[file] = "[unsupported format]";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
data[file] = { error: String(err) };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { files: scan.configFiles, data };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=project-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-service.js","sourceRoot":"","sources":["../../src/services/project-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAA0B,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAiB5C,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,MAAM;IACN,KAAK;IACL,cAAc;IACd,WAAW;CACZ,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,qBAAqB,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IACrC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,GAAY,EAAE,KAAK,GAAG,CAAC;IAC7C,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,aAAa,CAAC;IACpC,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC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gBAC9C,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC;gBACtC,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCSS listing, reading, and light-weight creation.
|
|
3
|
+
*/
|
|
4
|
+
import type { ServerContext } from "../server/context.js";
|
|
5
|
+
import { analyzeScss } from "../parsers/scss-parser.js";
|
|
6
|
+
export declare class ScssService {
|
|
7
|
+
private readonly ctx;
|
|
8
|
+
constructor(ctx: ServerContext);
|
|
9
|
+
list(): {
|
|
10
|
+
files: string[];
|
|
11
|
+
architecture: string[];
|
|
12
|
+
};
|
|
13
|
+
get(relativePath: string): {
|
|
14
|
+
path: string;
|
|
15
|
+
source: string;
|
|
16
|
+
analysis: ReturnType<typeof analyzeScss>;
|
|
17
|
+
};
|
|
18
|
+
create(input: {
|
|
19
|
+
name: string;
|
|
20
|
+
category?: "component" | "section" | "utility" | "token";
|
|
21
|
+
content?: string;
|
|
22
|
+
dry_run?: boolean;
|
|
23
|
+
}): {
|
|
24
|
+
success: boolean;
|
|
25
|
+
path?: string;
|
|
26
|
+
dry_run?: boolean;
|
|
27
|
+
operations?: Array<{
|
|
28
|
+
type: string;
|
|
29
|
+
path: string;
|
|
30
|
+
}>;
|
|
31
|
+
error?: {
|
|
32
|
+
code: string;
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=scss-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scss-service.d.ts","sourceRoot":"","sources":["../../src/services/scss-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAIxD,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAE/C,IAAI,IAAI;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE;IAgBnD,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;KAC1C;IAWD,MAAM,CAAC,KAAK,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;QACzD,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG;QACF,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACnD,KAAK,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3C;CA2CF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCSS listing, reading, and light-weight creation.
|
|
3
|
+
*/
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { assertWriteAllowed } from "../server/context.js";
|
|
6
|
+
import { safeExists, safeReadFile, safeWriteFile, safeWalk } from "../utils/filesystem.js";
|
|
7
|
+
import { analyzeScss } from "../parsers/scss-parser.js";
|
|
8
|
+
import { detectScssArchitecture } from "../parsers/project-scanner.js";
|
|
9
|
+
import { logger } from "../utils/logger.js";
|
|
10
|
+
export class ScssService {
|
|
11
|
+
ctx;
|
|
12
|
+
constructor(ctx) {
|
|
13
|
+
this.ctx = ctx;
|
|
14
|
+
}
|
|
15
|
+
list() {
|
|
16
|
+
const root = this.ctx.config.root;
|
|
17
|
+
const scssRoot = this.ctx.config.paths.scss;
|
|
18
|
+
const files = [];
|
|
19
|
+
if (safeExists(root, scssRoot)) {
|
|
20
|
+
for (const e of safeWalk(root, scssRoot, {
|
|
21
|
+
maxDepth: this.ctx.config.maxScanDepth,
|
|
22
|
+
extensions: [".scss", ".sass", ".css"],
|
|
23
|
+
})) {
|
|
24
|
+
if (!e.isDirectory)
|
|
25
|
+
files.push(e.relativePath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const architecture = detectScssArchitecture(root, scssRoot);
|
|
29
|
+
return { files, architecture };
|
|
30
|
+
}
|
|
31
|
+
get(relativePath) {
|
|
32
|
+
const source = safeReadFile(this.ctx.config.root, relativePath, {
|
|
33
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
path: relativePath,
|
|
37
|
+
source,
|
|
38
|
+
analysis: analyzeScss(source),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
create(input) {
|
|
42
|
+
try {
|
|
43
|
+
assertWriteAllowed(this.ctx, "create");
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
error: {
|
|
49
|
+
code: err.code ?? "WRITE_MODE_DENIED",
|
|
50
|
+
message: err.message,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const name = input.name.replace(/[^a-z0-9-_]/gi, "-").toLowerCase();
|
|
55
|
+
const cat = input.category ?? "component";
|
|
56
|
+
const paths = this.ctx.config.paths;
|
|
57
|
+
let dir = paths.scss;
|
|
58
|
+
if (cat === "component") {
|
|
59
|
+
dir = paths.scssComponents ?? path.posix.join(paths.scss, "components");
|
|
60
|
+
}
|
|
61
|
+
else if (cat === "section") {
|
|
62
|
+
dir = paths.scssSections ?? path.posix.join(paths.scss, "sections");
|
|
63
|
+
}
|
|
64
|
+
const filePath = path.posix.join(dir, `_${name}.scss`);
|
|
65
|
+
const content = input.content ??
|
|
66
|
+
`// ${cat}: ${name}\n.${name.replace(/^_/, "")} {\n // TODO\n}\n`;
|
|
67
|
+
if (input.dry_run) {
|
|
68
|
+
return {
|
|
69
|
+
success: true,
|
|
70
|
+
dry_run: true,
|
|
71
|
+
operations: [{ type: "create", path: filePath }],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const result = safeWriteFile(this.ctx.config.root, filePath, content, {
|
|
75
|
+
maxSize: this.ctx.config.maxFileSize,
|
|
76
|
+
});
|
|
77
|
+
this.ctx.invalidateCache();
|
|
78
|
+
logger.info("scss_create", { path: result.path });
|
|
79
|
+
return { success: true, path: result.path };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=scss-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scss-service.js","sourceRoot":"","sources":["../../src/services/scss-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,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,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aACjD,CAAC;QACJ,CAAC;QAED,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE;YACpE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW;SACrC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design token detection and updates (prefer CSS custom properties).
|
|
3
|
+
*/
|
|
4
|
+
import type { ServerContext } from "../server/context.js";
|
|
5
|
+
import { type ScssToken } from "../parsers/scss-parser.js";
|
|
6
|
+
export declare class TokenService {
|
|
7
|
+
private readonly ctx;
|
|
8
|
+
constructor(ctx: ServerContext);
|
|
9
|
+
list(): {
|
|
10
|
+
tokens: ScssToken[];
|
|
11
|
+
files: string[];
|
|
12
|
+
};
|
|
13
|
+
get(name: string): ScssToken[];
|
|
14
|
+
update(input: {
|
|
15
|
+
file: string;
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
dry_run?: boolean;
|
|
19
|
+
}): {
|
|
20
|
+
success: boolean;
|
|
21
|
+
dry_run?: boolean;
|
|
22
|
+
path?: string;
|
|
23
|
+
error?: {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=token-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-service.d.ts","sourceRoot":"","sources":["../../src/services/token-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAExE,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAE/C,IAAI,IAAI;QAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE;IAwChD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE;IAU9B,MAAM,CAAC,KAAK,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG;QACF,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3C;CAgDF"}
|