@component-compass/cli 0.0.2 → 0.0.4
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 +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.js +1 -3
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/scan.d.ts +13 -1
- package/dist/commands/scan.js +192 -72
- package/dist/commands/scan.js.map +1 -1
- package/dist/composition-rollup.d.ts +16 -14
- package/dist/composition-rollup.js +33 -43
- package/dist/composition-rollup.js.map +1 -1
- package/dist/config/loader.js +5 -9
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +2 -15
- package/dist/config/schema.js.map +1 -1
- package/dist/envelope/index.d.ts +0 -9
- package/dist/envelope/index.js +1 -46
- package/dist/envelope/index.js.map +1 -1
- package/dist/identity.d.ts +19 -17
- package/dist/identity.js +42 -21
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/local-index/detect-react.d.ts +2 -1
- package/dist/local-index/detect-react.js +269 -72
- package/dist/local-index/detect-react.js.map +1 -1
- package/dist/local-index/detect-vue.d.ts +15 -1
- package/dist/local-index/detect-vue.js +130 -107
- package/dist/local-index/detect-vue.js.map +1 -1
- package/dist/local-index/detect-wc.d.ts +7 -1
- package/dist/local-index/detect-wc.js +56 -60
- package/dist/local-index/detect-wc.js.map +1 -1
- package/dist/local-index/index.d.ts +12 -4
- package/dist/local-index/index.js +40 -25
- package/dist/local-index/index.js.map +1 -1
- package/dist/manifest/barrel-parser.d.ts +10 -0
- package/dist/manifest/barrel-parser.js +11 -0
- package/dist/manifest/barrel-parser.js.map +1 -1
- package/dist/manifest/derived-manifest-stub.d.ts +16 -7
- package/dist/manifest/derived-manifest-stub.js +43 -7
- package/dist/manifest/derived-manifest-stub.js.map +1 -1
- package/dist/manifest/lazy-resolver.d.ts +52 -34
- package/dist/manifest/lazy-resolver.js +269 -69
- package/dist/manifest/lazy-resolver.js.map +1 -1
- package/dist/occurrences.d.ts +4 -4
- package/dist/occurrences.js +49 -9
- package/dist/occurrences.js.map +1 -1
- package/dist/parse-by-ext.d.ts +21 -0
- package/dist/parse-by-ext.js +53 -0
- package/dist/parse-by-ext.js.map +1 -0
- package/dist/reporter/index.d.ts +27 -28
- package/dist/reporter/index.js +99 -58
- package/dist/reporter/index.js.map +1 -1
- package/dist/reporter/stdout.js +4 -4
- package/dist/reporter/stdout.js.map +1 -1
- package/dist/rollup.d.ts +13 -6
- package/dist/rollup.js +9 -6
- package/dist/rollup.js.map +1 -1
- package/dist/scan/cem-index.d.ts +38 -0
- package/dist/scan/cem-index.js +139 -0
- package/dist/scan/cem-index.js.map +1 -0
- package/dist/scan/git-mtime.d.ts +2 -0
- package/dist/scan/git-mtime.js +22 -0
- package/dist/scan/git-mtime.js.map +1 -0
- package/dist/scan/meta.d.ts +5 -0
- package/dist/scan/meta.js +58 -0
- package/dist/scan/meta.js.map +1 -0
- package/dist/scan/stamp-deprecated.d.ts +16 -0
- package/dist/scan/stamp-deprecated.js +33 -0
- package/dist/scan/stamp-deprecated.js.map +1 -0
- package/dist/scan/stamp-version.d.ts +18 -0
- package/dist/scan/stamp-version.js +94 -0
- package/dist/scan/stamp-version.js.map +1 -0
- package/dist/seeds.d.ts +20 -19
- package/dist/seeds.js +136 -68
- package/dist/seeds.js.map +1 -1
- package/dist/types.d.ts +2 -5
- package/dist/util/git.d.ts +8 -0
- package/dist/util/git.js +73 -0
- package/dist/util/git.js.map +1 -1
- package/dist/util/progress.d.ts +21 -0
- package/dist/util/progress.js +54 -0
- package/dist/util/progress.js.map +1 -0
- package/dist/walker/files.d.ts +1 -0
- package/dist/walker/files.js +11 -5
- package/dist/walker/files.js.map +1 -1
- package/dist/workspace/build-graph.d.ts +2 -0
- package/dist/workspace/build-graph.js +117 -0
- package/dist/workspace/build-graph.js.map +1 -0
- package/dist/workspace/declared-deps.d.ts +5 -0
- package/dist/workspace/declared-deps.js +42 -0
- package/dist/workspace/declared-deps.js.map +1 -0
- package/dist/workspace/find-owning-package.d.ts +8 -0
- package/dist/workspace/find-owning-package.js +69 -0
- package/dist/workspace/find-owning-package.js.map +1 -0
- package/dist/workspace/index.d.ts +4 -0
- package/dist/workspace/index.js +4 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/types.d.ts +46 -0
- package/dist/workspace/types.js +13 -0
- package/dist/workspace/types.js.map +1 -0
- package/package.json +15 -7
- package/schema/config.schema.json +2 -24
- package/dist/config/tag-rules.d.ts +0 -2
- package/dist/config/tag-rules.js +0 -34
- package/dist/config/tag-rules.js.map +0 -1
- package/dist/local-index/walker.d.ts +0 -11
- package/dist/local-index/walker.js +0 -47
- package/dist/local-index/walker.js.map +0 -1
- package/dist/manifest/diagnostic-filter.d.ts +0 -12
- package/dist/manifest/diagnostic-filter.js +0 -23
- package/dist/manifest/diagnostic-filter.js.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkspaceGraph, WorkspacePackage } from "./types.js";
|
|
2
|
+
type PkgJson = WorkspacePackage["packageJson"];
|
|
3
|
+
type ReadPkgJson = (path: string) => PkgJson | null;
|
|
4
|
+
export declare function declaredDeps(graph: WorkspaceGraph, read?: ReadPkgJson): string[];
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Union of declared dependencies across the workspace root + every workspace
|
|
3
|
+
* package. Used to warm the lazy resolver's by-tag cache so the resolver knows
|
|
4
|
+
* about every package in the consumer's monorepo, not just the root's deps.
|
|
5
|
+
*
|
|
6
|
+
* Pure; the JSON-read side-effect is injected so tests can drive it without
|
|
7
|
+
* filesystem fixtures.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
const defaultReader = (path) => {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export function declaredDeps(graph, read = defaultReader) {
|
|
20
|
+
const all = new Set();
|
|
21
|
+
collect(read(join(graph.rootPath, "package.json")), all);
|
|
22
|
+
for (const pkg of graph.packages) {
|
|
23
|
+
collect(pkg.packageJson, all);
|
|
24
|
+
}
|
|
25
|
+
return [...all];
|
|
26
|
+
}
|
|
27
|
+
function collect(pkg, into) {
|
|
28
|
+
if (!pkg)
|
|
29
|
+
return;
|
|
30
|
+
for (const bucket of [
|
|
31
|
+
pkg.dependencies,
|
|
32
|
+
pkg.devDependencies,
|
|
33
|
+
pkg.peerDependencies,
|
|
34
|
+
pkg.optionalDependencies,
|
|
35
|
+
]) {
|
|
36
|
+
if (!bucket)
|
|
37
|
+
continue;
|
|
38
|
+
for (const name of Object.keys(bucket))
|
|
39
|
+
into.add(name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=declared-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declared-deps.js","sourceRoot":"","sources":["../../src/workspace/declared-deps.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAMjC,MAAM,aAAa,GAAgB,CAAC,IAAI,EAAE,EAAE;IAC1C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,YAAY,CAC1B,KAAqB,EACrB,OAAoB,aAAa;IAEjC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAE9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEzD,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,OAAO,CAAC,GAAmB,EAAE,IAAiB;IACrD,IAAI,CAAC,GAAG;QAAE,OAAO;IACjB,KAAK,MAAM,MAAM,IAAI;QACnB,GAAG,CAAC,YAAY;QAChB,GAAG,CAAC,eAAe;QACnB,GAAG,CAAC,gBAAgB;QACpB,GAAG,CAAC,oBAAoB;KACzB,EAAE,CAAC;QACF,IAAI,CAAC,MAAM;YAAE,SAAS;QACtB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WorkspaceGraph, WorkspacePackage } from "./types.js";
|
|
2
|
+
export declare function findOwningPackage(graph: WorkspaceGraph, filePath: string): WorkspacePackage | null;
|
|
3
|
+
/**
|
|
4
|
+
* Reset the realpath memoization cache. Call between scans (or in test
|
|
5
|
+
* setup) when filesystem state may have changed. Within a single scan,
|
|
6
|
+
* realpath results are stable and cache hits are correct.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resetFindOwningPackageCache(): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realpath-aware workspace-membership check. Resolves the input path via
|
|
3
|
+
* realpath so node_modules symlinks (yarn/pnpm's usual layout) match their
|
|
4
|
+
* underlying workspace package directories.
|
|
5
|
+
*
|
|
6
|
+
* Returns the WorkspacePackage with the longest absolutePath that is a path
|
|
7
|
+
* prefix of the resolved input. Null when no package owns the file.
|
|
8
|
+
*
|
|
9
|
+
* Performance: realpath results are memoized per scan. Without caching this
|
|
10
|
+
* is the dominant cost on workspace-heavy monorepos — every call did 1 + N
|
|
11
|
+
* realpath syscalls (input + every workspace package, every time). Now it's
|
|
12
|
+
* O(1) on warm cache.
|
|
13
|
+
*/
|
|
14
|
+
import { realpathSync } from "node:fs";
|
|
15
|
+
const realpathCache = new Map();
|
|
16
|
+
export function findOwningPackage(graph, filePath) {
|
|
17
|
+
if (graph.packages.length === 0)
|
|
18
|
+
return null;
|
|
19
|
+
const resolved = resolveRealpath(filePath);
|
|
20
|
+
let best = null;
|
|
21
|
+
let bestPrefixLen = -1;
|
|
22
|
+
for (const pkg of graph.packages) {
|
|
23
|
+
// Realpath the package root too: on macOS tmpdir resolves through
|
|
24
|
+
// /var -> /private/var, and consumers may pass either form into the graph.
|
|
25
|
+
const pkgPath = resolveRealpath(pkg.absolutePath);
|
|
26
|
+
if (!isPathPrefix(pkgPath, resolved))
|
|
27
|
+
continue;
|
|
28
|
+
// Reject paths that fall inside a node_modules under the workspace
|
|
29
|
+
// package: those are vendor packages installed within the workspace
|
|
30
|
+
// (e.g. <app>/node_modules/@vendor/foo), not the workspace's own source.
|
|
31
|
+
// Symlinked sibling workspaces have already collapsed away via realpath.
|
|
32
|
+
if (resolved.slice(pkgPath.length).includes("/node_modules/"))
|
|
33
|
+
continue;
|
|
34
|
+
if (pkgPath.length > bestPrefixLen) {
|
|
35
|
+
best = pkg;
|
|
36
|
+
bestPrefixLen = pkgPath.length;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return best;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Reset the realpath memoization cache. Call between scans (or in test
|
|
43
|
+
* setup) when filesystem state may have changed. Within a single scan,
|
|
44
|
+
* realpath results are stable and cache hits are correct.
|
|
45
|
+
*/
|
|
46
|
+
export function resetFindOwningPackageCache() {
|
|
47
|
+
realpathCache.clear();
|
|
48
|
+
}
|
|
49
|
+
function resolveRealpath(filePath) {
|
|
50
|
+
const hit = realpathCache.get(filePath);
|
|
51
|
+
if (hit !== undefined)
|
|
52
|
+
return hit;
|
|
53
|
+
let resolved;
|
|
54
|
+
try {
|
|
55
|
+
resolved = realpathSync(filePath);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
resolved = filePath;
|
|
59
|
+
}
|
|
60
|
+
realpathCache.set(filePath, resolved);
|
|
61
|
+
return resolved;
|
|
62
|
+
}
|
|
63
|
+
function isPathPrefix(prefix, candidate) {
|
|
64
|
+
if (candidate === prefix)
|
|
65
|
+
return true;
|
|
66
|
+
const withSep = prefix.endsWith("/") ? prefix : `${prefix}/`;
|
|
67
|
+
return candidate.startsWith(withSep);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=find-owning-package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-owning-package.js","sourceRoot":"","sources":["../../src/workspace/find-owning-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEhD,MAAM,UAAU,iBAAiB,CAC/B,KAAqB,EACrB,QAAgB;IAEhB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7C,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,IAAI,GAA4B,IAAI,CAAC;IACzC,IAAI,aAAa,GAAG,CAAC,CAAC,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjC,kEAAkE;QAClE,2EAA2E;QAC3E,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,CAAC,OAAO,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from "./build-graph.js";
|
|
2
|
+
export { declaredDeps } from "./declared-deps.js";
|
|
3
|
+
export { findOwningPackage, resetFindOwningPackageCache, } from "./find-owning-package.js";
|
|
4
|
+
export type { PackageManager, WorkspaceGraph, WorkspacePackage } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workspace/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace graph shape. Built once per scan at scan-start, threaded into the
|
|
3
|
+
* resolver (for workspace-locality classification) and the identity layer
|
|
4
|
+
* (for `OutputIdentity.packageName` enrichment).
|
|
5
|
+
*
|
|
6
|
+
* Two independent axes:
|
|
7
|
+
* - `packageManager` — yarn / npm / pnpm, sniffed from lockfile. Always set.
|
|
8
|
+
* Returns "unknown" when no lockfile is detected (explicit "no signal").
|
|
9
|
+
* - `packages` — workspace packages from pnpm-workspace.yaml or
|
|
10
|
+
* package.json#workspaces. Empty array for single-package repos.
|
|
11
|
+
*/
|
|
12
|
+
export type PackageManager = "yarn" | "npm" | "pnpm" | "unknown";
|
|
13
|
+
export type WorkspacePackage = {
|
|
14
|
+
/** Workspace package name from its `package.json#name`. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Absolute path to the package directory. */
|
|
17
|
+
absolutePath: string;
|
|
18
|
+
/** Parsed `package.json` contents. Cached for `declaredDeps`. */
|
|
19
|
+
packageJson: {
|
|
20
|
+
name?: string;
|
|
21
|
+
dependencies?: Record<string, string>;
|
|
22
|
+
devDependencies?: Record<string, string>;
|
|
23
|
+
peerDependencies?: Record<string, string>;
|
|
24
|
+
optionalDependencies?: Record<string, string>;
|
|
25
|
+
workspaces?: string[] | {
|
|
26
|
+
packages?: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type WorkspaceGraph = {
|
|
31
|
+
/**
|
|
32
|
+
* Detected package manager (lockfile-based). `"unknown"` when no lockfile
|
|
33
|
+
* is present — explicit about not knowing. Independent of workspace
|
|
34
|
+
* detection — set even for single-package repos.
|
|
35
|
+
*/
|
|
36
|
+
packageManager: PackageManager;
|
|
37
|
+
/** Absolute path to the scan's configDir (the workspace root). */
|
|
38
|
+
rootPath: string;
|
|
39
|
+
/** Root package name; "<unnamed>" if missing. */
|
|
40
|
+
rootPackageName: string;
|
|
41
|
+
/**
|
|
42
|
+
* Detected workspace packages from pnpm-workspace.yaml or
|
|
43
|
+
* package.json#workspaces. Empty array for single-package repos.
|
|
44
|
+
*/
|
|
45
|
+
packages: WorkspacePackage[];
|
|
46
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace graph shape. Built once per scan at scan-start, threaded into the
|
|
3
|
+
* resolver (for workspace-locality classification) and the identity layer
|
|
4
|
+
* (for `OutputIdentity.packageName` enrichment).
|
|
5
|
+
*
|
|
6
|
+
* Two independent axes:
|
|
7
|
+
* - `packageManager` — yarn / npm / pnpm, sniffed from lockfile. Always set.
|
|
8
|
+
* Returns "unknown" when no lockfile is detected (explicit "no signal").
|
|
9
|
+
* - `packages` — workspace packages from pnpm-workspace.yaml or
|
|
10
|
+
* package.json#workspaces. Empty array for single-package repos.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/workspace/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@component-compass/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
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,20 +35,28 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/parser": "^7.29.3",
|
|
37
37
|
"@babel/types": "^7.29.0",
|
|
38
|
-
"@component-compass/ast-utils": "^0.0.
|
|
39
|
-
"@component-compass/
|
|
40
|
-
"@component-compass/
|
|
41
|
-
"@component-compass/parser-
|
|
42
|
-
"@component-compass/parser-
|
|
43
|
-
"@component-compass/
|
|
38
|
+
"@component-compass/ast-utils": "^0.0.4",
|
|
39
|
+
"@component-compass/manifest-react": "^0.0.4",
|
|
40
|
+
"@component-compass/manifest-vue": "^0.0.4",
|
|
41
|
+
"@component-compass/parser-html": "^0.0.4",
|
|
42
|
+
"@component-compass/parser-lit": "^0.0.4",
|
|
43
|
+
"@component-compass/parser-react": "^0.0.4",
|
|
44
|
+
"@component-compass/parser-vue": "^0.0.4",
|
|
45
|
+
"@component-compass/plugin-core": "^0.0.4",
|
|
44
46
|
"@vue/compiler-sfc": "^3.5.33",
|
|
45
47
|
"ajv": "^8.20.0",
|
|
46
48
|
"glob": "^13.0.0",
|
|
47
49
|
"globby": "^16.2.0",
|
|
50
|
+
"js-yaml": "^4",
|
|
51
|
+
"oxc-parser": "^0.130.0",
|
|
52
|
+
"oxc-walker": "^1.0.0",
|
|
53
|
+
"parse5": "^8.0.0",
|
|
48
54
|
"picomatch": "^4.0.4",
|
|
49
55
|
"ulid": "^3.0.2"
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
58
|
+
"@oxc-project/types": "^0.130.0",
|
|
59
|
+
"@types/js-yaml": "^4",
|
|
52
60
|
"@types/node": "^24.0.0",
|
|
53
61
|
"@types/picomatch": "^4.0.3",
|
|
54
62
|
"typescript": "^5.9.0",
|
|
@@ -4,14 +4,10 @@
|
|
|
4
4
|
"title": "component-compass config",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"additionalProperties": false,
|
|
7
|
-
"required": ["
|
|
7
|
+
"required": ["include"],
|
|
8
8
|
"properties": {
|
|
9
9
|
"$schema": { "type": "string" },
|
|
10
10
|
"repoId": { "type": "string", "minLength": 1 },
|
|
11
|
-
"packageScopes": {
|
|
12
|
-
"type": "array",
|
|
13
|
-
"items": { "type": "string", "minLength": 1 }
|
|
14
|
-
},
|
|
15
11
|
"include": {
|
|
16
12
|
"type": "array",
|
|
17
13
|
"items": { "type": "string", "minLength": 1 },
|
|
@@ -22,6 +18,7 @@
|
|
|
22
18
|
"items": { "type": "string", "minLength": 1 }
|
|
23
19
|
},
|
|
24
20
|
"captureValues": { "type": "boolean" },
|
|
21
|
+
"gitignore": { "type": "boolean" },
|
|
25
22
|
"output": { "type": "string", "minLength": 1 },
|
|
26
23
|
"tsconfigPath": { "type": "string", "minLength": 1 },
|
|
27
24
|
"aliases": {
|
|
@@ -30,25 +27,6 @@
|
|
|
30
27
|
"type": "array",
|
|
31
28
|
"items": { "type": "string", "minLength": 1 }
|
|
32
29
|
}
|
|
33
|
-
},
|
|
34
|
-
"tagRules": {
|
|
35
|
-
"type": "array",
|
|
36
|
-
"items": {
|
|
37
|
-
"type": "object",
|
|
38
|
-
"required": ["tag", "match"],
|
|
39
|
-
"additionalProperties": false,
|
|
40
|
-
"properties": {
|
|
41
|
-
"tag": { "type": "string", "minLength": 1 },
|
|
42
|
-
"match": {
|
|
43
|
-
"type": "object",
|
|
44
|
-
"required": ["packageName"],
|
|
45
|
-
"additionalProperties": false,
|
|
46
|
-
"properties": {
|
|
47
|
-
"packageName": { "type": "string", "minLength": 1 }
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
30
|
}
|
|
53
31
|
}
|
|
54
32
|
}
|
package/dist/config/tag-rules.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-computes the list of tags that apply to a Component identity given its
|
|
3
|
-
* resolved `packageName` and the user's configured `tagRules`. Pure function;
|
|
4
|
-
* called once per Component during scan-time identity assembly.
|
|
5
|
-
*
|
|
6
|
-
* v1 rules match by `packageName` only, with `*` as the sole glob metacharacter
|
|
7
|
-
* (zero-or-more chars). All other regex metacharacters are escaped so patterns
|
|
8
|
-
* are interpreted literally. See spec §6.
|
|
9
|
-
*
|
|
10
|
-
* Local components (those without a resolved package) have `packageName === null`
|
|
11
|
-
* and never match any rule.
|
|
12
|
-
*/
|
|
13
|
-
const REGEX_META = /[.+?^${}()|[\]\\]/g;
|
|
14
|
-
const cache = new Map();
|
|
15
|
-
function matcher(pattern) {
|
|
16
|
-
const cached = cache.get(pattern);
|
|
17
|
-
if (cached)
|
|
18
|
-
return cached;
|
|
19
|
-
const compiled = new RegExp(`^${pattern.replace(REGEX_META, "\\$&").replace(/\*/g, ".*")}$`);
|
|
20
|
-
cache.set(pattern, compiled);
|
|
21
|
-
return compiled;
|
|
22
|
-
}
|
|
23
|
-
export function evaluateTagRules(packageName, rules) {
|
|
24
|
-
if (packageName === null || !rules || rules.length === 0)
|
|
25
|
-
return [];
|
|
26
|
-
const tags = [];
|
|
27
|
-
for (const rule of rules) {
|
|
28
|
-
if (matcher(rule.match.packageName).test(packageName)) {
|
|
29
|
-
tags.push(rule.tag);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return tags;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=tag-rules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tag-rules.js","sourceRoot":"","sources":["../../src/config/tag-rules.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAExC,SAAS,OAAO,CAAC,OAAe;IAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,QAAQ,GAAG,IAAI,MAAM,CACzB,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAChE,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7B,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,WAA0B,EAC1B,KAA4B;IAE5B,IAAI,WAAW,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpE,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACtD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type WalkedFile = {
|
|
2
|
-
absolutePath: string;
|
|
3
|
-
filePath: string;
|
|
4
|
-
extension: string;
|
|
5
|
-
source: string;
|
|
6
|
-
};
|
|
7
|
-
export type WalkOptions = {
|
|
8
|
-
repoRoot: string;
|
|
9
|
-
extraIgnoreGlobs?: string[];
|
|
10
|
-
};
|
|
11
|
-
export declare function walkLocalSources(opts: WalkOptions): Promise<WalkedFile[]>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { extname, relative } from "node:path";
|
|
3
|
-
import { posixPath } from "@component-compass/ast-utils";
|
|
4
|
-
import { globby } from "globby";
|
|
5
|
-
const DEFAULT_IGNORES = [
|
|
6
|
-
"**/node_modules/**",
|
|
7
|
-
"**/dist/**",
|
|
8
|
-
"**/build/**",
|
|
9
|
-
"**/.next/**",
|
|
10
|
-
"**/.nuxt/**",
|
|
11
|
-
"**/coverage/**",
|
|
12
|
-
"**/*.test.*",
|
|
13
|
-
"**/*.spec.*",
|
|
14
|
-
"**/__tests__/**",
|
|
15
|
-
"**/*.stories.*",
|
|
16
|
-
];
|
|
17
|
-
const DEFAULT_EXTENSIONS = [".tsx", ".jsx", ".ts", ".js", ".vue"];
|
|
18
|
-
export async function walkLocalSources(opts) {
|
|
19
|
-
const ignore = [...DEFAULT_IGNORES, ...(opts.extraIgnoreGlobs ?? [])];
|
|
20
|
-
const matched = await globby(["**/*"], {
|
|
21
|
-
cwd: opts.repoRoot,
|
|
22
|
-
gitignore: true,
|
|
23
|
-
ignore,
|
|
24
|
-
absolute: true,
|
|
25
|
-
onlyFiles: true,
|
|
26
|
-
});
|
|
27
|
-
const out = [];
|
|
28
|
-
for (const abs of matched) {
|
|
29
|
-
if (!DEFAULT_EXTENSIONS.includes(extname(abs)))
|
|
30
|
-
continue;
|
|
31
|
-
let source;
|
|
32
|
-
try {
|
|
33
|
-
source = readFileSync(abs, "utf8");
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
out.push({
|
|
39
|
-
absolutePath: abs,
|
|
40
|
-
filePath: posixPath(relative(opts.repoRoot, abs)),
|
|
41
|
-
extension: extname(abs),
|
|
42
|
-
source,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return out;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=walker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"walker.js","sourceRoot":"","sources":["../../src/local-index/walker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAA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QAAQ,EAAE,GAAG,CAAC,CAAC;YACjD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC;YACvB,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ResolverDiagnostic } from "./lazy-resolver.js";
|
|
2
|
-
/**
|
|
3
|
-
* Builds the predicate scan.ts uses to decide whether a resolver diagnostic
|
|
4
|
-
* should reach stderr.
|
|
5
|
-
*
|
|
6
|
-
* Empty `packageScopes` is the explicit "no filter" signal — every
|
|
7
|
-
* diagnostic surfaces. Otherwise the scopes act as an allowlist matched
|
|
8
|
-
* against the diagnostic's `packageName`. A diagnostic with no resolvable
|
|
9
|
-
* `packageName` is dropped under an active filter (we cannot prove the
|
|
10
|
-
* source is in scope, so it is treated as out-of-scope noise).
|
|
11
|
-
*/
|
|
12
|
-
export declare function buildDiagnosticGate(packageScopes: string[]): (d: ResolverDiagnostic) => boolean;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import picomatch from "picomatch";
|
|
2
|
-
/**
|
|
3
|
-
* Builds the predicate scan.ts uses to decide whether a resolver diagnostic
|
|
4
|
-
* should reach stderr.
|
|
5
|
-
*
|
|
6
|
-
* Empty `packageScopes` is the explicit "no filter" signal — every
|
|
7
|
-
* diagnostic surfaces. Otherwise the scopes act as an allowlist matched
|
|
8
|
-
* against the diagnostic's `packageName`. A diagnostic with no resolvable
|
|
9
|
-
* `packageName` is dropped under an active filter (we cannot prove the
|
|
10
|
-
* source is in scope, so it is treated as out-of-scope noise).
|
|
11
|
-
*/
|
|
12
|
-
export function buildDiagnosticGate(packageScopes) {
|
|
13
|
-
if (packageScopes.length === 0)
|
|
14
|
-
return () => true;
|
|
15
|
-
const matchers = packageScopes.map((p) => picomatch(p));
|
|
16
|
-
return (d) => {
|
|
17
|
-
const pkg = d.packageName;
|
|
18
|
-
if (!pkg)
|
|
19
|
-
return false;
|
|
20
|
-
return matchers.some((m) => m(pkg));
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=diagnostic-filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-filter.js","sourceRoot":"","sources":["../../src/manifest/diagnostic-filter.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAuB;IAEvB,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IAClD,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,CAAC,CAAC,EAAE,EAAE;QACX,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC;QAC1B,IAAI,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QACvB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
|