onsystem 0.10.1 → 0.10.3
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/cli.js +23 -13
- package/dist/{config-BbTW1jKU.d.ts → config-JaNAiR9Z.d.ts} +6 -8
- package/dist/{design-system-CPH4C7-1.js → design-system-7wZoJsMm.js} +240 -121
- package/dist/eslint-worker.d.ts +2 -4
- package/dist/eslint-worker.js +3 -4
- package/dist/eslint.d.ts +0 -2
- package/dist/eslint.js +3 -5
- package/dist/index.d.ts +40 -55
- package/dist/index.js +2 -2
- package/dist/{stdio-BK2kMN1x.js → stdio-B31hp2UZ.js} +182 -57
- package/dist/{workspace-BINqxi7p.js → workspace-C5pMS6Xv.js} +10 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as DEFAULT_TOKENS, A as unrecordedRules, At as
|
|
3
|
-
import { a as notReadNotices, i as missingDependencies, o as explainProject, s as librariesLeftOut, t as serveStdio } from "./stdio-
|
|
4
|
-
import { r as loadTarget } from "./workspace-
|
|
2
|
+
import { $ as DEFAULT_TOKENS, A as unrecordedRules, At as relativePath, B as statusKinds, C as countBaseline, D as pruneBaseline, Dt as isInside, E as onLines, Et as SCRIPT_FILE, It as unique, J as ConfigError, L as toDesignMd, M as writeBaseline, O as readBaseline, Ot as matchesGlob, Pt as plural, R as toDtcg, Rt as readProjectConfig, S as applyBaseline, St as isDesignSystemName, T as goneFiles, Y as DEFAULT_DOCS, _ as formatDiagnostics, _t as PACKAGE_FIELD, b as BASELINE_FILE, bt as detectProject, c as silentLogger, et as FALLBACK_TOKENS, g as escapeData, gt as notReadYet, h as uncheckedNotice, ht as libraryTitle, i as componentFiles, j as updateBaseline, jt as toPosix, k as rulesRun, l as stderrLogger, o as loadDesignSystem, ot as excludedBy, q as CONFIG_FILES, rt as RULE_IDS, s as tokenFiles, tt as LEGACY_CONFIG_FILES, ut as rulesFor, v as NAME, w as findMoves, x as LEGACY_BASELINE_FILE, y as VERSION, yt as declaredConfig } from "./design-system-7wZoJsMm.js";
|
|
3
|
+
import { a as notReadNotices, i as missingDependencies, o as explainProject, s as librariesLeftOut, t as serveStdio } from "./stdio-B31hp2UZ.js";
|
|
4
|
+
import { r as loadTarget } from "./workspace-C5pMS6Xv.js";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { escapePath, glob } from "tinyglobby";
|
|
@@ -10,7 +10,7 @@ import fsp from "node:fs/promises";
|
|
|
10
10
|
import { spawnSync } from "node:child_process";
|
|
11
11
|
import readline from "node:readline/promises";
|
|
12
12
|
import { parseArgs } from "node:util";
|
|
13
|
-
|
|
13
|
+
// src/init.ts
|
|
14
14
|
const SCHEMA = "https://unpkg.com/onsystem/schema.json";
|
|
15
15
|
/** More detected globs than this are files, not folders: zero config keeps them. */
|
|
16
16
|
const MAX_GLOBS = 6;
|
|
@@ -324,7 +324,9 @@ function readManifest(root) {
|
|
|
324
324
|
/**
|
|
325
325
|
* Declares the config in the package's package.json, `"onsystem": "./onsystem.config.json"`,
|
|
326
326
|
* and adds it to `files` when the package lists the files it publishes, so apps that install it
|
|
327
|
-
* get it too. Writes ONSYSTEM.md for the apps' teams unless one exists
|
|
327
|
+
* get it too. Writes ONSYSTEM.md for the apps' teams unless one exists, and adds it to `files`
|
|
328
|
+
* as well, for the teams of apps that install the package, unless `files` leaves it out
|
|
329
|
+
* (`!ONSYSTEM.md`). Returns what it wrote.
|
|
328
330
|
*/
|
|
329
331
|
function declarePackage(root, manifest, name, force, notes) {
|
|
330
332
|
const written = [];
|
|
@@ -336,15 +338,18 @@ function declarePackage(root, manifest, name, force, notes) {
|
|
|
336
338
|
changed = true;
|
|
337
339
|
}
|
|
338
340
|
const files = Array.isArray(json.files) ? json.files : void 0;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
const added = [];
|
|
342
|
+
for (const file of [CONFIG_FILE, GUIDE_FILE]) {
|
|
343
|
+
if (!files || ships(files, file) || file === "ONSYSTEM.md" && excludes(files, file)) continue;
|
|
344
|
+
files.push(file);
|
|
345
|
+
added.push(file);
|
|
341
346
|
changed = true;
|
|
342
347
|
}
|
|
343
348
|
if (changed) {
|
|
344
349
|
fs.writeFileSync(manifest.file, `${JSON.stringify(json, null, manifest.indent)}${manifest.newline ? "\n" : ""}`);
|
|
345
350
|
written.push("package.json");
|
|
346
351
|
}
|
|
347
|
-
notes.push(`This is a design-system package: package.json declares its config ("${PACKAGE_FIELD}": "${value}"${
|
|
352
|
+
notes.push(`This is a design-system package: package.json declares its config ("${PACKAGE_FIELD}": "${value}"${added.length ? `, with ${added.join(" and ")} added to "files"` : ""}), which every app that depends on ${name} reads, under its own config when it has one.`);
|
|
348
353
|
const guide = path.join(root, GUIDE_FILE);
|
|
349
354
|
if (force || !fs.existsSync(guide)) {
|
|
350
355
|
fs.writeFileSync(guide, consumerGuide(name));
|
|
@@ -625,6 +630,14 @@ function aliasFolder(alias, project) {
|
|
|
625
630
|
}
|
|
626
631
|
}
|
|
627
632
|
}
|
|
633
|
+
/** Whether npm's `files` list leaves `file` out with a negated entry: `!ONSYSTEM.md`, `!*.md`. */
|
|
634
|
+
function excludes(files, file) {
|
|
635
|
+
return files.some((entry) => {
|
|
636
|
+
if (typeof entry !== "string" || !entry.startsWith("!")) return false;
|
|
637
|
+
const pattern = entry.slice(1).replace(/^\.?\//, "");
|
|
638
|
+
return pattern === file || matchesGlob(file, pattern);
|
|
639
|
+
});
|
|
640
|
+
}
|
|
628
641
|
/** Whether npm's `files` list publishes `file`, a path relative to the package. */
|
|
629
642
|
function ships(files, file) {
|
|
630
643
|
return files.some((entry) => {
|
|
@@ -685,8 +698,7 @@ function count$1(n, word) {
|
|
|
685
698
|
function andList(items, conjunction = "and") {
|
|
686
699
|
return items.length > 1 ? `${items.slice(0, -1).join(", ")} ${conjunction} ${items.at(-1) ?? ""}` : items.join("");
|
|
687
700
|
}
|
|
688
|
-
|
|
689
|
-
//#region src/cli.ts
|
|
701
|
+
// src/cli.ts
|
|
690
702
|
const DOCS = "https://onsystem.vercel.app/docs";
|
|
691
703
|
const HELP = `${NAME} ${VERSION}
|
|
692
704
|
|
|
@@ -1881,13 +1893,11 @@ function displayPath(cwd, file) {
|
|
|
1881
1893
|
const rel = path.relative(cwd, file);
|
|
1882
1894
|
return rel && !rel.startsWith("..") && !path.isAbsolute(rel) ? rel : file;
|
|
1883
1895
|
}
|
|
1884
|
-
|
|
1885
|
-
//#region src/bin.ts
|
|
1896
|
+
// src/bin.ts
|
|
1886
1897
|
main(process.argv.slice(2)).then((code) => {
|
|
1887
1898
|
process.exitCode = code;
|
|
1888
1899
|
}, (error) => {
|
|
1889
1900
|
process.stderr.write(`${error.stack ?? String(error)}\n`);
|
|
1890
1901
|
process.exitCode = 1;
|
|
1891
1902
|
});
|
|
1892
|
-
//#endregion
|
|
1893
1903
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
//#region src/detect.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* How apps import a design-system module, from a package's `exports`:
|
|
5
4
|
* `@midday/ui/button` → `../../packages/ui/src/components/button.tsx`, or a
|
|
@@ -45,8 +44,6 @@ interface DesignSystemSource {
|
|
|
45
44
|
*/
|
|
46
45
|
registry?: string | undefined;
|
|
47
46
|
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/types.d.ts
|
|
50
47
|
/**
|
|
51
48
|
* The design-system model the server exposes. Everything here is plain JSON so
|
|
52
49
|
* it can be cached on disk and returned as MCP structured content.
|
|
@@ -269,8 +266,6 @@ interface CheckResult {
|
|
|
269
266
|
*/
|
|
270
267
|
skipped?: string;
|
|
271
268
|
}
|
|
272
|
-
//#endregion
|
|
273
|
-
//#region src/libraries/index.d.ts
|
|
274
269
|
/** The ids of the libraries onsystem can read, for the config's `libraries` list. */
|
|
275
270
|
declare const LIBRARY_IDS: readonly ["mui"];
|
|
276
271
|
type LibraryId = (typeof LIBRARY_IDS)[number];
|
|
@@ -287,8 +282,6 @@ interface LibrarySource {
|
|
|
287
282
|
*/
|
|
288
283
|
designSystem?: true | undefined;
|
|
289
284
|
}
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/config.d.ts
|
|
292
285
|
declare const RULE_IDS: readonly ["no-hardcoded-color", "no-hardcoded-spacing", "no-hardcoded-radius", "prefer-design-system-component", "no-unknown-component", "no-unknown-prop", "no-unknown-variant", "icon-button-accessible-name"];
|
|
293
286
|
type RuleId = (typeof RULE_IDS)[number];
|
|
294
287
|
declare const severitySchema: z.ZodEnum<{
|
|
@@ -504,9 +497,14 @@ interface LoadConfigOptions {
|
|
|
504
497
|
* choose, unlike the folder the server was started in.
|
|
505
498
|
*/
|
|
506
499
|
jsonConfigOnly?: boolean | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* With `jsonConfigOnly`: the folder the MCP server was started for (its `--root` or the
|
|
502
|
+
* client's root) when that folder is no project but holds the one read, which the error for a
|
|
503
|
+
* JavaScript or TypeScript config names.
|
|
504
|
+
*/
|
|
505
|
+
jsonConfigWithin?: string | undefined;
|
|
507
506
|
}
|
|
508
507
|
declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
|
|
509
508
|
/** JSON Schema for editor completion in `onsystem.config.json`. */
|
|
510
509
|
declare function configJsonSchema(): Record<string, unknown>;
|
|
511
|
-
//#endregion
|
|
512
510
|
export { TOKEN_CATEGORIES as C, VariantInfo as D, TokenCategory as E, ImportMapping as O, SourceLocation as S, Token as T, DocSection as _, ResolvedRule as a, PropInfo as b, configJsonSchema as c, CheckResult as d, ComponentDocs as f, Diagnostic as g, DesignSystemModel as h, ResolvedConfig as i, defineConfig as l, CompoundVariantInfo as m, LoadConfigOptions as n, RuleId as o, ComponentInfo as p, RULE_IDS as r, RuleOptions as s, Config as t, loadConfig as u, ExampleInfo as v, TextEdit as w, Severity as x, InheritedProps as y };
|