@master/css-mcp 2.0.0-rc.76 → 2.0.0-rc.78
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 +34 -4
- package/dist/bin/index.js +1 -1
- package/dist/classes.d.ts +237 -0
- package/dist/classes.js +224 -0
- package/dist/compare.d.ts +71 -0
- package/dist/compare.js +131 -0
- package/dist/context.js +2 -2
- package/dist/contributor.d.ts +150 -0
- package/dist/contributor.js +497 -0
- package/dist/directives.d.ts +133 -0
- package/dist/directives.js +158 -0
- package/dist/document.d.ts +25 -0
- package/dist/document.js +51 -0
- package/dist/format.d.ts +57 -0
- package/dist/format.js +81 -0
- package/dist/index.d.ts +1 -1
- package/dist/language.js +2 -20
- package/dist/manifest-query.d.ts +149 -0
- package/dist/manifest-query.js +159 -0
- package/dist/manifest-summary.d.ts +48 -0
- package/dist/manifest-summary.js +56 -0
- package/dist/scan.d.ts +1 -1
- package/dist/scan.js +2 -2
- package/dist/server.js +202 -3
- package/dist/setup.d.ts +63 -0
- package/dist/setup.js +168 -0
- package/package.json +11 -9
package/dist/setup.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { getErrorMessage } from "./result.js";
|
|
2
|
+
import { loadWorkspaceManifest } from "./project.js";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { findCSSManifestEntryFiles } from "@master/css-project/entries";
|
|
6
|
+
import { resolveMasterCSSWorkspacePackages } from "@master/css-project/workspace";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
//#region src/setup.ts
|
|
9
|
+
const SETUP_AUDIT_VERSION = 1;
|
|
10
|
+
const LOCKFILES = {
|
|
11
|
+
pnpm: "pnpm-lock.yaml",
|
|
12
|
+
npm: "package-lock.json",
|
|
13
|
+
yarn: "yarn.lock",
|
|
14
|
+
bun: "bun.lockb"
|
|
15
|
+
};
|
|
16
|
+
const MASTER_CSS_PACKAGES = [
|
|
17
|
+
"@master/css",
|
|
18
|
+
"@master/css-cli",
|
|
19
|
+
"@master/css-mcp",
|
|
20
|
+
"@master/css-runtime",
|
|
21
|
+
"@master/css-language-server",
|
|
22
|
+
"@master/css.vite",
|
|
23
|
+
"@master/css.webpack",
|
|
24
|
+
"@master/css.next",
|
|
25
|
+
"@master/css.nuxt",
|
|
26
|
+
"@master/css.astro",
|
|
27
|
+
"@master/css.svelte",
|
|
28
|
+
"@master/eslint-plugin-css"
|
|
29
|
+
];
|
|
30
|
+
const INTEGRATION_PACKAGES = [
|
|
31
|
+
"@master/css-cli",
|
|
32
|
+
"@master/css.vite",
|
|
33
|
+
"@master/css.webpack",
|
|
34
|
+
"@master/css.next",
|
|
35
|
+
"@master/css.nuxt",
|
|
36
|
+
"@master/css.astro",
|
|
37
|
+
"@master/css.svelte",
|
|
38
|
+
"@master/eslint-plugin-css"
|
|
39
|
+
];
|
|
40
|
+
function getDependencies(packageJSON) {
|
|
41
|
+
return {
|
|
42
|
+
...packageJSON?.dependencies,
|
|
43
|
+
...packageJSON?.devDependencies,
|
|
44
|
+
...packageJSON?.peerDependencies,
|
|
45
|
+
...packageJSON?.optionalDependencies
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function readPackageJSON(context) {
|
|
49
|
+
const filePath = join(context.root, "package.json");
|
|
50
|
+
try {
|
|
51
|
+
return {
|
|
52
|
+
filePath,
|
|
53
|
+
value: JSON.parse(await readFile(filePath, "utf8"))
|
|
54
|
+
};
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return {
|
|
57
|
+
filePath,
|
|
58
|
+
error: getErrorMessage(error)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function detectPackageManager(context, packageJSON) {
|
|
63
|
+
const lockfiles = Object.entries(LOCKFILES).filter(([, filename]) => existsSync(join(context.root, filename))).map(([name, filename]) => ({
|
|
64
|
+
name,
|
|
65
|
+
filePath: join(context.root, filename)
|
|
66
|
+
}));
|
|
67
|
+
const declared = typeof packageJSON?.packageManager === "string" ? packageJSON.packageManager : void 0;
|
|
68
|
+
return {
|
|
69
|
+
declared,
|
|
70
|
+
lockfiles,
|
|
71
|
+
inferred: declared?.split("@")[0] || lockfiles[0]?.name || "unknown"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function detectDeclaredPackages(packageJSON) {
|
|
75
|
+
const dependencies = getDependencies(packageJSON);
|
|
76
|
+
return MASTER_CSS_PACKAGES.filter((name) => dependencies[name]).map((name) => ({
|
|
77
|
+
name,
|
|
78
|
+
version: dependencies[name]
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
function detectIntegrations(packageJSON) {
|
|
82
|
+
const dependencies = getDependencies(packageJSON);
|
|
83
|
+
const scripts = packageJSON?.scripts || {};
|
|
84
|
+
const packages = INTEGRATION_PACKAGES.filter((name) => dependencies[name]).map((name) => ({
|
|
85
|
+
type: "package",
|
|
86
|
+
name,
|
|
87
|
+
version: dependencies[name]
|
|
88
|
+
}));
|
|
89
|
+
const scriptHints = Object.entries(scripts).filter(([, script]) => /master-css|@master\/css|mcss/.test(script)).map(([name, script]) => ({
|
|
90
|
+
type: "script",
|
|
91
|
+
name,
|
|
92
|
+
command: script
|
|
93
|
+
}));
|
|
94
|
+
return [...packages, ...scriptHints];
|
|
95
|
+
}
|
|
96
|
+
function pushDiagnostic(diagnostics, severity, code, message, data) {
|
|
97
|
+
diagnostics.push({
|
|
98
|
+
code,
|
|
99
|
+
severity,
|
|
100
|
+
message,
|
|
101
|
+
...data ? { data } : {}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function resolveStatus(diagnostics) {
|
|
105
|
+
if (diagnostics.some((diagnostic) => diagnostic.severity === "error")) return "error";
|
|
106
|
+
if (diagnostics.some((diagnostic) => diagnostic.severity === "warning")) return "warning";
|
|
107
|
+
return "ok";
|
|
108
|
+
}
|
|
109
|
+
async function auditSetup(context) {
|
|
110
|
+
const [packageJSONResult, manifest, discoveredEntries] = await Promise.all([
|
|
111
|
+
readPackageJSON(context),
|
|
112
|
+
loadWorkspaceManifest(context),
|
|
113
|
+
findCSSManifestEntryFiles(context.root).catch(() => [])
|
|
114
|
+
]);
|
|
115
|
+
const packageJSON = packageJSONResult.value;
|
|
116
|
+
const packageManager = detectPackageManager(context, packageJSON);
|
|
117
|
+
const declaredPackages = detectDeclaredPackages(packageJSON);
|
|
118
|
+
const integrations = detectIntegrations(packageJSON);
|
|
119
|
+
const resolvedPackages = resolveMasterCSSWorkspacePackages(context.root);
|
|
120
|
+
const diagnostics = [];
|
|
121
|
+
if (!packageJSON) pushDiagnostic(diagnostics, "warning", "package-json-unreadable", `Unable to read package.json: ${packageJSONResult.error}`, { filePath: packageJSONResult.filePath });
|
|
122
|
+
if (!declaredPackages.some((pkg) => pkg.name === "@master/css")) pushDiagnostic(diagnostics, "warning", "missing-master-css-package", "package.json does not declare @master/css.");
|
|
123
|
+
if (!resolvedPackages.css) pushDiagnostic(diagnostics, "error", "unresolved-master-css-package", "The @master/css package could not be resolved from this workspace.", { errors: resolvedPackages.errors });
|
|
124
|
+
if (!manifest.entries.length && !discoveredEntries.length) pushDiagnostic(diagnostics, "error", "missing-manifest-entry", "No Master CSS entry stylesheet was discovered.");
|
|
125
|
+
if (manifest.status === "error") pushDiagnostic(diagnostics, "error", "manifest-load-error", `Failed to load the Master CSS manifest: ${manifest.error}`);
|
|
126
|
+
for (const warning of manifest.warnings) pushDiagnostic(diagnostics, "warning", "manifest-warning", warning);
|
|
127
|
+
for (const error of resolvedPackages.errors) {
|
|
128
|
+
if (error.name === "@master/css") continue;
|
|
129
|
+
pushDiagnostic(diagnostics, "info", "package-resolution-info", error.message, { packageName: error.name });
|
|
130
|
+
}
|
|
131
|
+
if (!integrations.length) pushDiagnostic(diagnostics, "info", "no-integration-hint", "No Master CSS CLI, framework integration, or ESLint package was detected in package.json.");
|
|
132
|
+
const status = resolveStatus(diagnostics);
|
|
133
|
+
return {
|
|
134
|
+
version: SETUP_AUDIT_VERSION,
|
|
135
|
+
root: context.root,
|
|
136
|
+
status,
|
|
137
|
+
packageManager,
|
|
138
|
+
packageJSON: {
|
|
139
|
+
filePath: packageJSONResult.filePath,
|
|
140
|
+
loaded: Boolean(packageJSON),
|
|
141
|
+
...packageJSONResult.error ? { error: packageJSONResult.error } : {}
|
|
142
|
+
},
|
|
143
|
+
packages: {
|
|
144
|
+
declared: declaredPackages,
|
|
145
|
+
resolved: resolvedPackages
|
|
146
|
+
},
|
|
147
|
+
integrations,
|
|
148
|
+
manifest: {
|
|
149
|
+
status: manifest.status,
|
|
150
|
+
entries: manifest.entries.length ? manifest.entries : discoveredEntries,
|
|
151
|
+
dependencies: manifest.dependencies,
|
|
152
|
+
warnings: manifest.warnings,
|
|
153
|
+
...manifest.status === "error" ? { error: manifest.error } : {}
|
|
154
|
+
},
|
|
155
|
+
diagnostics,
|
|
156
|
+
summary: {
|
|
157
|
+
status,
|
|
158
|
+
entries: (manifest.entries.length ? manifest.entries : discoveredEntries).length,
|
|
159
|
+
declaredPackages: declaredPackages.length,
|
|
160
|
+
integrations: integrations.length,
|
|
161
|
+
errors: diagnostics.filter((diagnostic) => diagnostic.severity === "error").length,
|
|
162
|
+
warnings: diagnostics.filter((diagnostic) => diagnostic.severity === "warning").length,
|
|
163
|
+
info: diagnostics.filter((diagnostic) => diagnostic.severity === "info").length
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
export { auditSetup };
|
package/package.json
CHANGED
|
@@ -53,16 +53,18 @@
|
|
|
53
53
|
"fast-glob": "^3.3.3",
|
|
54
54
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
55
55
|
"zod": "^4.4.3",
|
|
56
|
-
"@master/css-
|
|
57
|
-
"@master/css-
|
|
58
|
-
"@master/css-language-service": "^2.0.0-rc.
|
|
59
|
-
"@master/css-
|
|
60
|
-
"@master/css-
|
|
61
|
-
"@master/css-
|
|
62
|
-
"@master/css-
|
|
63
|
-
"@master/css-
|
|
56
|
+
"@master/css-compiler": "^2.0.0-rc.78",
|
|
57
|
+
"@master/css-engine": "^2.0.0-rc.78",
|
|
58
|
+
"@master/css-language-service": "^2.0.0-rc.78",
|
|
59
|
+
"@master/css-lexer": "^2.0.0-rc.78",
|
|
60
|
+
"@master/css-diagnostics": "^2.0.0-rc.78",
|
|
61
|
+
"@master/css-lint": "^2.0.0-rc.78",
|
|
62
|
+
"@master/css-project": "^2.0.0-rc.78",
|
|
63
|
+
"@master/css-preset": "^2.0.0-rc.78",
|
|
64
|
+
"@master/css-server": "^2.0.0-rc.78",
|
|
65
|
+
"@master/css-validator": "^2.0.0-rc.78"
|
|
64
66
|
},
|
|
65
|
-
"version": "2.0.0-rc.
|
|
67
|
+
"version": "2.0.0-rc.78",
|
|
66
68
|
"scripts": {
|
|
67
69
|
"build": "tsdown --config ../../shared/tsdown-package.config.ts",
|
|
68
70
|
"dev": "tsdown --config ../../shared/tsdown-package.config.ts --watch",
|