@component-compass/cli 0.1.0 → 0.1.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.
@@ -0,0 +1,56 @@
1
+ import { compileAliasPattern } from "./tsconfig-loader.js";
2
+ // Compile each workspace package's `package.json#exports` map into a flat list
3
+ // of AliasEntrys for the resolver. Supports two shapes:
4
+ //
5
+ // - Constant: "./types" -> "./types.ts" matches <pkgName>/types exactly.
6
+ // - Pattern: "./icons/<star>" -> "./icons/<star>.tsx" matches <pkgName>/icons/X,
7
+ // substituting X into the target.
8
+ //
9
+ // Skipped (filed as follow-ups if a real consumer hits them):
10
+ // - Conditional exports ({"import":..., "require":...} — non-string value)
11
+ // - null targets (Node's deny form)
12
+ // - Multi-wildcard targets (subpath or target containing more than one *)
13
+ // - Non-subpath keys (the "." self-reference, "#imports", conditional roots)
14
+ // - Bare-string exports (sugar for the "." main-entry case)
15
+ //
16
+ // Within a package, entries sort by static-prefix length descending so more-
17
+ // specific subpaths (e.g. "./icons/special") beat patterns (e.g. "./icons/<star>")
18
+ // for the same spec — matches the Node.js exports-map specificity rule.
19
+ export function buildWorkspaceExportEntries(graph) {
20
+ const out = [];
21
+ for (const pkg of graph.packages) {
22
+ const exports = pkg.packageJson.exports;
23
+ if (exports === null || exports === undefined)
24
+ continue;
25
+ if (typeof exports !== "object")
26
+ continue;
27
+ if (Array.isArray(exports))
28
+ continue;
29
+ const subpaths = Object.entries(exports)
30
+ .filter(([key]) => key.startsWith("./") && key !== "./")
31
+ .sort(([a], [b]) => staticPrefixLength(b) - staticPrefixLength(a));
32
+ for (const [subpath, target] of subpaths) {
33
+ if (target === null)
34
+ continue;
35
+ if (typeof target !== "string")
36
+ continue;
37
+ if (target.includes("**"))
38
+ continue;
39
+ if (target.split("*").length > 2)
40
+ continue;
41
+ // "./icons/*" + "@example/icons" → "@example/icons/icons/*"
42
+ const fullPattern = `${pkg.name}${subpath.slice(1)}`;
43
+ out.push({
44
+ pattern: compileAliasPattern(fullPattern),
45
+ targets: [target],
46
+ base: pkg.absolutePath,
47
+ });
48
+ }
49
+ }
50
+ return out;
51
+ }
52
+ function staticPrefixLength(subpath) {
53
+ const starIdx = subpath.indexOf("*");
54
+ return starIdx === -1 ? subpath.length : starIdx;
55
+ }
56
+ //# sourceMappingURL=workspace-exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-exports.js","sourceRoot":"","sources":["../../src/walker/workspace-exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,+EAA+E;AAC/E,wDAAwD;AACxD,EAAE;AACF,4EAA4E;AAC5E,qFAAqF;AACrF,sCAAsC;AACtC,EAAE;AACF,8DAA8D;AAC9D,6EAA6E;AAC7E,sCAAsC;AACtC,4EAA4E;AAC5E,+EAA+E;AAC/E,8DAA8D;AAC9D,EAAE;AACF,6EAA6E;AAC7E,mFAAmF;AACnF,wEAAwE;AACxE,MAAM,UAAU,2BAA2B,CAAC,KAAqB;IAC/D,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC;QACxC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS;YAAE,SAAS;QACxD,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,SAAS;QAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,SAAS;QAErC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,OAAkC,CAAC;aAChE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,IAAI,CAAC;aACvD,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QAErE,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzC,IAAI,MAAM,KAAK,IAAI;gBAAE,SAAS;YAC9B,IAAI,OAAO,MAAM,KAAK,QAAQ;gBAAE,SAAS;YACzC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,SAAS;YACpC,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;gBAAE,SAAS;YAE3C,4DAA4D;YAC5D,MAAM,WAAW,GAAG,GAAG,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,GAAG,CAAC,IAAI,CAAC;gBACP,OAAO,EAAE,mBAAmB,CAAC,WAAW,CAAC;gBACzC,OAAO,EAAE,CAAC,MAAM,CAAC;gBACjB,IAAI,EAAE,GAAG,CAAC,YAAY;aACvB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AACnD,CAAC"}
@@ -25,6 +25,7 @@ export type WorkspacePackage = {
25
25
  workspaces?: string[] | {
26
26
  packages?: string[];
27
27
  };
28
+ exports?: unknown;
28
29
  };
29
30
  };
30
31
  export type WorkspaceGraph = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@component-compass/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Open-source CLI for measuring design-system component usage across multi-framework consumer repos.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,15 +35,13 @@
35
35
  "dependencies": {
36
36
  "@babel/parser": "7.29.3",
37
37
  "@babel/types": "7.29.0",
38
- "@component-compass/ast-utils": "0.1.0",
39
- "@component-compass/manifest-react": "0.1.0",
40
- "@component-compass/manifest-vue": "0.1.0",
41
- "@component-compass/parser-html": "0.1.0",
42
- "@component-compass/parser-lit": "0.1.0",
43
- "@component-compass/parser-react": "0.1.0",
44
- "@component-compass/parser-vue": "0.1.0",
45
- "@component-compass/plugin-core": "0.1.0",
46
- "@component-compass/reference-graph": "0.1.0",
38
+ "@component-compass/ast-utils": "0.1.2",
39
+ "@component-compass/parser-html": "0.1.2",
40
+ "@component-compass/parser-lit": "0.1.2",
41
+ "@component-compass/parser-react": "0.1.2",
42
+ "@component-compass/parser-vue": "0.1.2",
43
+ "@component-compass/plugin-core": "0.1.2",
44
+ "@component-compass/reference-graph": "0.1.2",
47
45
  "@vue/compiler-sfc": "3.5.33",
48
46
  "ajv": "8.20.0",
49
47
  "glob": "13.0.6",
@@ -1,18 +0,0 @@
1
- import type { DerivedLeafPayload } from "@component-compass/plugin-core";
2
- /**
3
- * Phase 4 hook: extract derived manifest data from leaf source when no
4
- * authored manifest (CEM / CCM) exists.
5
- *
6
- * Fires only for workspace packages — those whose realpath resolves outside
7
- * `node_modules`. Published packages with only a `dist/` tree are skipped;
8
- * both extractor implementations return `null` in that case.
9
- *
10
- * The extractor to run is inferred from the package's source content:
11
- * - `.vue` files present in `src/` → manifest-vue extractor
12
- * - Otherwise → manifest-react extractor (handles TS/JS source)
13
- *
14
- * Pre-MVP: source-mapping config (no source-mapping paradigm for publishing
15
- * packages without source — pre-MVP scope) is out of scope. Only source that
16
- * lives at the default `src/` path is walked.
17
- */
18
- export declare function extractDerivedManifest(leafPackageDir: string): DerivedLeafPayload | null;
@@ -1,47 +0,0 @@
1
- import { extractReactManifestSync } from "@component-compass/manifest-react";
2
- import { extractVueManifestSync } from "@component-compass/manifest-vue";
3
- import { readdirSync, existsSync } from "node:fs";
4
- import { join } from "node:path";
5
- /**
6
- * Phase 4 hook: extract derived manifest data from leaf source when no
7
- * authored manifest (CEM / CCM) exists.
8
- *
9
- * Fires only for workspace packages — those whose realpath resolves outside
10
- * `node_modules`. Published packages with only a `dist/` tree are skipped;
11
- * both extractor implementations return `null` in that case.
12
- *
13
- * The extractor to run is inferred from the package's source content:
14
- * - `.vue` files present in `src/` → manifest-vue extractor
15
- * - Otherwise → manifest-react extractor (handles TS/JS source)
16
- *
17
- * Pre-MVP: source-mapping config (no source-mapping paradigm for publishing
18
- * packages without source — pre-MVP scope) is out of scope. Only source that
19
- * lives at the default `src/` path is walked.
20
- */
21
- export function extractDerivedManifest(leafPackageDir) {
22
- const srcDir = join(leafPackageDir, "src");
23
- if (existsSync(srcDir) && hasVueSources(srcDir)) {
24
- return extractVueManifestSync(leafPackageDir);
25
- }
26
- return extractReactManifestSync(leafPackageDir);
27
- }
28
- function hasVueSources(dir) {
29
- let entries;
30
- try {
31
- entries = readdirSync(dir, { withFileTypes: true });
32
- }
33
- catch {
34
- return false;
35
- }
36
- for (const entry of entries) {
37
- const name = entry.name;
38
- if (entry.isFile() && name.endsWith(".vue"))
39
- return true;
40
- if (entry.isDirectory()) {
41
- if (hasVueSources(join(dir, name)))
42
- return true;
43
- }
44
- }
45
- return false;
46
- }
47
- //# sourceMappingURL=derived-manifest-stub.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"derived-manifest-stub.js","sourceRoot":"","sources":["../../src/manifest/derived-manifest-stub.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAe,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;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