@bearnie/mcp 0.2.0 → 0.3.0
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 +2 -0
- package/dist/index.js +30 -4
- package/dist/install.d.ts +9 -0
- package/dist/install.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,8 @@ Add multiple components in one step. Resolves registry dependencies and installs
|
|
|
127
127
|
|
|
128
128
|
List the Bearnie components already installed in the project, and whether each one is up to date with the registry, modified locally, or missing files. To update an outdated component, run `add_component` with its name (this overwrites local files with the registry version).
|
|
129
129
|
|
|
130
|
+
Styles are compared against the theme recorded in `bearnie.json` (`default`, or any base/accent combination such as `blue`, `slate`, or `slate-blue`). Installing a theme entry such as `styles-slate-blue` via `add_component` switches the theme and updates `bearnie.json`.
|
|
131
|
+
|
|
130
132
|
**Parameters:**
|
|
131
133
|
|
|
132
134
|
- `cwd` (string, optional): Working directory
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,15 @@ function getRegistryPath() {
|
|
|
21
21
|
var DEFAULT_PROJECT_CONFIG = {
|
|
22
22
|
componentsDir: "src/components/bearnie",
|
|
23
23
|
utilsDir: "src/utils",
|
|
24
|
-
stylesDir: "src/styles"
|
|
24
|
+
stylesDir: "src/styles",
|
|
25
|
+
theme: "default"
|
|
25
26
|
};
|
|
27
|
+
function themeEntryName(theme) {
|
|
28
|
+
return theme === "default" ? "styles" : `styles-${theme}`;
|
|
29
|
+
}
|
|
30
|
+
function isThemeEntry(name) {
|
|
31
|
+
return name === "styles" || name.startsWith("styles-");
|
|
32
|
+
}
|
|
26
33
|
async function loadProjectConfig(projectRoot) {
|
|
27
34
|
const configPath = path.join(projectRoot, "bearnie.json");
|
|
28
35
|
try {
|
|
@@ -160,6 +167,20 @@ async function installComponents(projectRoot, names) {
|
|
|
160
167
|
installed.push(name);
|
|
161
168
|
result.npmDependencies.forEach((dep) => npmDependencies.add(dep));
|
|
162
169
|
}
|
|
170
|
+
const themeInstalled = names.find(
|
|
171
|
+
(name) => isThemeEntry(name) && installed.includes(name)
|
|
172
|
+
);
|
|
173
|
+
if (themeInstalled) {
|
|
174
|
+
const theme = themeInstalled === "styles" ? "default" : themeInstalled.replace(/^styles-/, "");
|
|
175
|
+
const configPath = path.join(projectRoot, "bearnie.json");
|
|
176
|
+
try {
|
|
177
|
+
if (await fs.pathExists(configPath) && config.theme !== theme) {
|
|
178
|
+
const raw = await fs.readJson(configPath);
|
|
179
|
+
await fs.writeJson(configPath, { ...raw, theme }, { spaces: 2 });
|
|
180
|
+
}
|
|
181
|
+
} catch {
|
|
182
|
+
}
|
|
183
|
+
}
|
|
163
184
|
return {
|
|
164
185
|
installed,
|
|
165
186
|
npmDependencies: [...npmDependencies],
|
|
@@ -199,10 +220,15 @@ async function listInstalledComponents(projectRoot) {
|
|
|
199
220
|
const index = await fetchIndex();
|
|
200
221
|
if (!index) return null;
|
|
201
222
|
const config = await loadProjectConfig(projectRoot);
|
|
202
|
-
const
|
|
223
|
+
const activeTheme = themeEntryName(config.theme ?? "default");
|
|
224
|
+
const allNames = /* @__PURE__ */ new Set([
|
|
203
225
|
...index.components.map((c) => c.name),
|
|
204
|
-
...(index.utilities ?? []).map((u) => u.name)
|
|
205
|
-
|
|
226
|
+
...(index.utilities ?? []).map((u) => u.name),
|
|
227
|
+
...(index.themes ?? []).map((theme) => themeEntryName(theme))
|
|
228
|
+
]);
|
|
229
|
+
const names = [...allNames].filter(
|
|
230
|
+
(name) => !isThemeEntry(name) || name === activeTheme
|
|
231
|
+
);
|
|
206
232
|
const installed = [];
|
|
207
233
|
for (const name of names) {
|
|
208
234
|
const component = await fetchComponent(name);
|
package/dist/install.d.ts
CHANGED
|
@@ -2,8 +2,14 @@ export interface ProjectConfig {
|
|
|
2
2
|
componentsDir: string;
|
|
3
3
|
utilsDir: string;
|
|
4
4
|
stylesDir: string;
|
|
5
|
+
/** Which color theme is installed ("default", "amber", ...). */
|
|
6
|
+
theme: string;
|
|
5
7
|
}
|
|
6
8
|
export declare const DEFAULT_PROJECT_CONFIG: ProjectConfig;
|
|
9
|
+
/** Registry entry name for a theme: "default" -> styles, "amber" -> styles-amber. */
|
|
10
|
+
export declare function themeEntryName(theme: string): string;
|
|
11
|
+
/** True for the styles/styles-* entries, which all install the same CSS file. */
|
|
12
|
+
export declare function isThemeEntry(name: string): boolean;
|
|
7
13
|
/** Reads bearnie.json from the project root, falling back to defaults. */
|
|
8
14
|
export declare function loadProjectConfig(projectRoot: string): Promise<ProjectConfig>;
|
|
9
15
|
export interface ComponentFile {
|
|
@@ -35,6 +41,9 @@ export interface RegistryIndex {
|
|
|
35
41
|
name: string;
|
|
36
42
|
description: string;
|
|
37
43
|
}>;
|
|
44
|
+
themes?: string[];
|
|
45
|
+
themeBases?: string[];
|
|
46
|
+
themeAccents?: string[];
|
|
38
47
|
}
|
|
39
48
|
export type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
|
|
40
49
|
/** Detects the project's package manager from its lockfile. */
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,sBAAsB,EAAE,aAKpC,CAAC;AAEF,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,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