onsystem 0.11.0 → 0.11.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
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-Csqts7Eq.js";
3
- import { a as notReadNotices, i as missingDependencies, o as explainProject, s as librariesLeftOut, t as serveStdio } from "./stdio-0TpyqZaD.js";
4
- import { r as loadTarget } from "./workspace-Dbxubo9n.js";
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-D7ppJYbd.js";
3
+ import { a as notReadNotices, i as missingDependencies, o as explainProject, s as librariesLeftOut, t as serveStdio } from "./stdio-c3Y34to3.js";
4
+ import { r as loadTarget } from "./workspace-DUgzMLGs.js";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import { escapePath, glob } from "tinyglobby";
@@ -678,7 +678,8 @@ const APP_STYLESHEETS = [
678
678
  * from a registry is read through its `exports` alone, when they point at the
679
679
  * component sources it publishes, not from `dist/` back to `src/`.
680
680
  * 4. A flat folder of components that wrap a primitives library, the way React
681
- * Aria's Tailwind starter ships them (`src/Button.tsx`, `src/Checkbox.tsx`).
681
+ * Aria's Tailwind starter ships them (`src/Button.tsx`, `src/Checkbox.tsx`), or the
682
+ * same files copied into an app's `src/components/`, `components/` or `app/components/`.
682
683
  *
683
684
  * With more than one design system, the one the root's code imports most comes first
684
685
  * (`designSystems`). A candidate whose globs match no file is skipped. Returns undefined
@@ -818,7 +819,7 @@ function detectProject(root, tsconfig, trace, declared, packages = new PackageFi
818
819
  };
819
820
  }
820
821
  let flatWhy = "no package.json";
821
- const flat = own ? fromFlatFolder(root, own, (r) => {
822
+ const flat = own ? fromFlatFolder(root, own, "src", (r) => {
822
823
  flatWhy = r;
823
824
  }) : void 0;
824
825
  if (flat && matchesAny(root, flat)) {
@@ -826,6 +827,19 @@ function detectProject(root, tsconfig, trace, declared, packages = new PackageFi
826
827
  return detection(root, [flat], false, flat.source);
827
828
  }
828
829
  step("a flat src/ of components", false, flatWhy);
830
+ if (!own || !primitivesDependencies(own).length) return void 0;
831
+ for (const folder of COMPONENT_FOLDERS) {
832
+ if (!fs.existsSync(path.join(root, folder))) continue;
833
+ let why = "";
834
+ const inFolder = fromFlatFolder(root, own, folder, (r) => {
835
+ why = r;
836
+ });
837
+ if (inFolder && matchesAny(root, inFolder)) {
838
+ step(`a flat ${folder}/ of components`, true, inFolder.source);
839
+ return detection(root, [inFolder], true, inFolder.source);
840
+ }
841
+ step(`a flat ${folder}/ of components`, false, why || "its components match no file");
842
+ }
829
843
  }
830
844
  /** `12 component files`, for the trace. */
831
845
  function countFiles(root, found) {
@@ -850,8 +864,11 @@ function componentGlob(root, patterns) {
850
864
  function plural(n, one, many = `${one}s`) {
851
865
  return `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`;
852
866
  }
853
- /** Libraries of unstyled primitives that design systems wrap. */
854
- const PRIMITIVES = /^(?:react-aria-components|react-aria|radix-ui|@radix-ui\/react-[\w-]+|@base-ui-components\/react|@base-ui\/react|@headlessui\/react|@ark-ui\/react)(?:\/|$)/;
867
+ /**
868
+ * Libraries of unstyled primitives that design systems wrap. Not Radix's icons
869
+ * (`@radix-ui/react-icons`), which an app's own components import as much as a design system's.
870
+ */
871
+ const PRIMITIVES = /^(?:react-aria-components|react-aria|radix-ui|@radix-ui\/react-(?!icons(?:\/|$))[\w-]+|@base-ui-components\/react|@base-ui\/react|@headlessui\/react|@ark-ui\/react)(?:\/|$)/;
855
872
  /** Files that make `src/` an app rather than a library: entries and route folders. */
856
873
  const APP_ENTRIES = /^(?:main|index|App|app|root|entry-client|entry-server)\.[jt]sx?$/;
857
874
  const APP_FOLDERS = /* @__PURE__ */ new Set([
@@ -859,41 +876,62 @@ const APP_FOLDERS = /* @__PURE__ */ new Set([
859
876
  "pages",
860
877
  "routes"
861
878
  ]);
862
- /** Fewer PascalCase files than this in `src/` are an app's, not a component library. */
879
+ /** Fewer PascalCase files than this in the folder are an app's, not a component library. */
863
880
  const MIN_FLAT_COMPONENTS = 5;
864
881
  /**
865
- * A flat `src/` of components, as React Aria's Tailwind starter has it. It needs all of:
866
- * a dependency on a primitives library, no app entry (`main.tsx`, `App.tsx`) or route
867
- * folder in `src/`, and at least five PascalCase `.tsx`/`.jsx` files at its top level, four
868
- * in five of which import the primitives library. An app whose `src/` holds pages or
869
- * features imports its own components, not primitives, so it does not qualify.
882
+ * An app's folders of components, read like a flat `src/` when they are one: React Aria's
883
+ * starter copied into an app (`src/components/Button.tsx` next to `src/App.tsx`), or into a
884
+ * Next.js app's `components/` or `app/components/`.
870
885
  */
871
- function fromFlatFolder(root, pkg, note = ignore) {
872
- const dependencies = Object.keys({
886
+ const COMPONENT_FOLDERS = [
887
+ "src/components",
888
+ "components",
889
+ "app/components"
890
+ ];
891
+ /** The primitives libraries among a package's dependencies. */
892
+ function primitivesDependencies(pkg) {
893
+ return Object.keys({
873
894
  ...asRecord(pkg.dependencies),
874
895
  ...asRecord(pkg.devDependencies),
875
896
  ...asRecord(pkg.peerDependencies)
876
897
  }).filter((name) => PRIMITIVES.test(name));
898
+ }
899
+ /** `react-aria-components`, or `a primitives library (@radix-ui/react-dialog, @radix-ui/react-slot)`. */
900
+ function primitivesNamed(dependencies) {
901
+ if (dependencies.length <= 1) return dependencies[0] ?? "a primitives library";
902
+ const shown = dependencies.slice(0, 3).join(", ");
903
+ const more = dependencies.length - 3;
904
+ return `a primitives library (${more > 0 ? `${shown} and ${String(more)} more` : shown})`;
905
+ }
906
+ /**
907
+ * A flat folder of components, as React Aria's Tailwind starter has `src/`. It needs all of:
908
+ * a dependency on a primitives library, at least five PascalCase `.tsx`/`.jsx` files at the
909
+ * folder's top level, four in five of which import the primitives library, and, for `src/`,
910
+ * no app entry (`main.tsx`, `App.tsx`) or route folder in it. An app whose folder holds pages
911
+ * or features imports its own components, not primitives, so it does not qualify.
912
+ */
913
+ function fromFlatFolder(root, pkg, folder, note = ignore) {
914
+ const dependencies = primitivesDependencies(pkg);
877
915
  if (!dependencies.length) {
878
916
  note("no dependency on a primitives library (React Aria, Radix, Base UI, Headless UI, Ark UI)");
879
917
  return;
880
918
  }
881
- const dir = path.join(root, "src");
919
+ const dir = path.join(root, folder);
882
920
  let entries;
883
921
  try {
884
922
  entries = fs.readdirSync(dir, { withFileTypes: true });
885
923
  } catch {
886
- note("no src/ folder");
924
+ note(`no ${folder}/ folder`);
887
925
  return;
888
926
  }
889
- const app = entries.find((e) => e.isFile() && APP_ENTRIES.test(e.name) || e.isDirectory() && APP_FOLDERS.has(e.name));
927
+ const app = folder === "src" ? entries.find((e) => e.isFile() && APP_ENTRIES.test(e.name) || e.isDirectory() && APP_FOLDERS.has(e.name)) : void 0;
890
928
  if (app) {
891
929
  note(`src/${app.name} makes src/ an app`);
892
930
  return;
893
931
  }
894
932
  const files = entries.filter((e) => e.isFile() && /^[A-Z][A-Za-z0-9]*\.[jt]sx$/.test(e.name)).map((e) => e.name);
895
933
  if (files.length < MIN_FLAT_COMPONENTS) {
896
- note(`${plural(files.length, "PascalCase .tsx file")} in src/, fewer than ${MIN_FLAT_COMPONENTS}`);
934
+ note(`${plural(files.length, "PascalCase .tsx file")} in ${folder}/, fewer than ${MIN_FLAT_COMPONENTS}`);
897
935
  return;
898
936
  }
899
937
  const libraries = /* @__PURE__ */ new Map();
@@ -914,17 +952,17 @@ function fromFlatFolder(root, pkg, note = ignore) {
914
952
  for (const library of used) libraries.set(library, (libraries.get(library) ?? 0) + 1);
915
953
  }
916
954
  if (wrapping * 5 < files.length * 4) {
917
- note(`${wrapping} of ${files.length} files in src/ import ${dependencies[0] ?? "a primitives library"}, fewer than four in five`);
955
+ note(`${wrapping} of ${files.length} files in ${folder}/ import ${primitivesNamed(dependencies)}, fewer than four in five`);
918
956
  return;
919
957
  }
920
958
  const library = [...libraries].sort((a, b) => b[1] - a[1])[0]?.[0] ?? dependencies[0] ?? "";
921
- const stylesheet = STYLESHEETS.map((f) => path.join(root, f)).find((f) => fs.existsSync(f));
959
+ const stylesheet = folder === "src" ? STYLESHEETS.map((f) => path.join(root, f)).find((f) => fs.existsSync(f)) : void 0;
922
960
  return {
923
- components: ["src/*.{tsx,jsx}"],
961
+ components: [`${folder}/*.{tsx,jsx}`],
924
962
  tokens: stylesheet ? [escapePath(relativePath(root, stylesheet))] : [],
925
963
  imports: [],
926
964
  dirs: [dir],
927
- source: `src/ (${String(files.length)} components wrapping ${library})`
965
+ source: `${folder}/ (${String(files.length)} components wrapping ${library})`
928
966
  };
929
967
  }
930
968
  function detection(root, found, withDefaults, source) {
@@ -12308,7 +12346,7 @@ function isObject(value) {
12308
12346
  // package.json
12309
12347
  var name = "onsystem";
12310
12348
  // src/version.ts
12311
- const VERSION = "0.11.0";
12349
+ const VERSION = "0.11.1";
12312
12350
  const NAME = name;
12313
12351
  // src/lint/sarif.ts
12314
12352
  const SCHEMA = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json";
@@ -1,5 +1,5 @@
1
- import { At as relativePath, a as fingerprint, i as componentFiles, ot as excludedBy, r as buildModel } from "./design-system-Csqts7Eq.js";
2
- import { r as loadTarget } from "./workspace-Dbxubo9n.js";
1
+ import { At as relativePath, a as fingerprint, i as componentFiles, ot as excludedBy, r as buildModel } from "./design-system-D7ppJYbd.js";
2
+ import { r as loadTarget } from "./workspace-DUgzMLGs.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
package/dist/eslint.js CHANGED
@@ -1,4 +1,4 @@
1
- import { At as relativePath, N as RULES, Q as DEFAULT_TEST_FOLDERS, X as DEFAULT_SEVERITY, Z as DEFAULT_TEST_EXCLUDE, m as checkSource, rt as RULE_IDS, t as DesignSystem, ut as rulesFor, v as NAME, y as VERSION } from "./design-system-Csqts7Eq.js";
1
+ import { At as relativePath, N as RULES, Q as DEFAULT_TEST_FOLDERS, X as DEFAULT_SEVERITY, Z as DEFAULT_TEST_EXCLUDE, m as checkSource, rt as RULE_IDS, t as DesignSystem, ut as rulesFor, v as NAME, y as VERSION } from "./design-system-D7ppJYbd.js";
2
2
  import path from "node:path";
3
3
  import { MessageChannel, Worker, receiveMessageOnPort } from "node:worker_threads";
4
4
  // src/eslint/bridge.ts
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { F as loadTokens, G as parseDoc, H as parseDesignMd, I as mergeTokens, K as extractComponents, L as toDesignMd, N as RULES, P as TokenIndex, R as toDtcg, U as parseCssTokens, V as parseDtcgTokens, W as attachDocs, _ as formatDiagnostics, a as fingerprint, at as defineConfig, ct as loadConfig, f as searchComponents, ft as findVariantDefinitions, it as configJsonSchema, m as checkSource, n as DesignSystemHost, o as loadDesignSystem, p as applyFixes, r as buildModel, rt as RULE_IDS, t as DesignSystem, y as VERSION } from "./design-system-Csqts7Eq.js";
2
- import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-0TpyqZaD.js";
1
+ import { F as loadTokens, G as parseDoc, H as parseDesignMd, I as mergeTokens, K as extractComponents, L as toDesignMd, N as RULES, P as TokenIndex, R as toDtcg, U as parseCssTokens, V as parseDtcgTokens, W as attachDocs, _ as formatDiagnostics, a as fingerprint, at as defineConfig, ct as loadConfig, f as searchComponents, ft as findVariantDefinitions, it as configJsonSchema, m as checkSource, n as DesignSystemHost, o as loadDesignSystem, p as applyFixes, r as buildModel, rt as RULE_IDS, t as DesignSystem, y as VERSION } from "./design-system-D7ppJYbd.js";
2
+ import { n as INSTRUCTIONS, r as createServer, t as serveStdio } from "./stdio-c3Y34to3.js";
3
3
  export { DesignSystem, DesignSystemHost, INSTRUCTIONS, RULES, RULE_IDS, TokenIndex, VERSION, applyFixes, attachDocs, buildModel, checkSource, configJsonSchema, createServer, defineConfig, extractComponents, findVariantDefinitions, fingerprint, formatDiagnostics, loadConfig, loadDesignSystem, loadTokens, mergeTokens, parseCssTokens, parseDesignMd, parseDoc, parseDtcgTokens, searchComponents, serveStdio, toDesignMd, toDtcg };
@@ -1,5 +1,5 @@
1
- import { At as relativePath, Ct as isWorkspaceRoot, Dt as isInside, Et as SCRIPT_FILE, Ft as truncate, It as unique, J as ConfigError, Lt as defaultProjectConfig, Mt as closest, Nt as json, Pt as plural, X as DEFAULT_SEVERITY, bt as detectProject, ct as loadConfig, d as descriptionOf, dt as formatPx, f as searchComponents, gt as notReadYet, h as uncheckedNotice, ht as libraryTitle, kt as pathOf, mt as LIBRARY_IDS, n as DesignSystemHost, ot as excludedBy, pt as LIBRARIES, q as CONFIG_FILES, r as buildModel, rt as RULE_IDS, tt as LEGACY_CONFIG_FILES, u as buildSearchIndex, v as NAME, xt as findDesignSystemPackage, y as VERSION, z as TOKEN_CATEGORIES } from "./design-system-Csqts7Eq.js";
2
- import { i as projectDirOf, n as hasProjectMarker, r as loadTarget, t as findProjectRoot } from "./workspace-Dbxubo9n.js";
1
+ import { At as relativePath, Ct as isWorkspaceRoot, Dt as isInside, Et as SCRIPT_FILE, Ft as truncate, It as unique, J as ConfigError, Lt as defaultProjectConfig, Mt as closest, Nt as json, Pt as plural, X as DEFAULT_SEVERITY, bt as detectProject, ct as loadConfig, d as descriptionOf, dt as formatPx, f as searchComponents, gt as notReadYet, h as uncheckedNotice, ht as libraryTitle, kt as pathOf, mt as LIBRARY_IDS, n as DesignSystemHost, ot as excludedBy, pt as LIBRARIES, q as CONFIG_FILES, r as buildModel, rt as RULE_IDS, tt as LEGACY_CONFIG_FILES, u as buildSearchIndex, v as NAME, xt as findDesignSystemPackage, y as VERSION, z as TOKEN_CATEGORIES } from "./design-system-D7ppJYbd.js";
2
+ import { i as projectDirOf, n as hasProjectMarker, r as loadTarget, t as findProjectRoot } from "./workspace-DUgzMLGs.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -1,4 +1,4 @@
1
- import { At as relativePath, Ct as isWorkspaceRoot, Dt as isInside, Tt as workspacePatterns, ct as loadConfig, i as componentFiles, lt as loadConfigWith, nt as PROJECT_MARKERS, st as hasOwnConfig, vt as PackageFinder, wt as workspacePackageDirs, xt as findDesignSystemPackage } from "./design-system-Csqts7Eq.js";
1
+ import { At as relativePath, Ct as isWorkspaceRoot, Dt as isInside, Tt as workspacePatterns, ct as loadConfig, i as componentFiles, lt as loadConfigWith, nt as PROJECT_MARKERS, st as hasOwnConfig, vt as PackageFinder, wt as workspacePackageDirs, xt as findDesignSystemPackage } from "./design-system-D7ppJYbd.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import os from "node:os";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onsystem",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "mcpName": "io.github.dgesteves/onsystem",
5
5
  "description": "Keeps coding agents on your design system: catches palette colors, native elements and APIs your system lacks, at every edit and pull request, with the fix. Set it up once in your design-system package; every app in your monorepo gets it.",
6
6
  "keywords": [