@component-compass/cli 0.0.0-pr-3-8916f3c-20260507145532
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 +5 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +110 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +61 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/scan.d.ts +12 -0
- package/dist/commands/scan.js +147 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/config/loader.d.ts +6 -0
- package/dist/config/loader.js +62 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +32 -0
- package/dist/config/schema.js +15 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/tag-rules.d.ts +2 -0
- package/dist/config/tag-rules.js +34 -0
- package/dist/config/tag-rules.js.map +1 -0
- package/dist/dispatcher.d.ts +8 -0
- package/dist/dispatcher.js +22 -0
- package/dist/dispatcher.js.map +1 -0
- package/dist/envelope/git.d.ts +13 -0
- package/dist/envelope/git.js +69 -0
- package/dist/envelope/git.js.map +1 -0
- package/dist/envelope/index.d.ts +10 -0
- package/dist/envelope/index.js +57 -0
- package/dist/envelope/index.js.map +1 -0
- package/dist/envelope/repo-id.d.ts +16 -0
- package/dist/envelope/repo-id.js +40 -0
- package/dist/envelope/repo-id.js.map +1 -0
- package/dist/identity.d.ts +46 -0
- package/dist/identity.js +92 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/local-index/detect-react.d.ts +2 -0
- package/dist/local-index/detect-react.js +128 -0
- package/dist/local-index/detect-react.js.map +1 -0
- package/dist/local-index/detect-vue.d.ts +2 -0
- package/dist/local-index/detect-vue.js +164 -0
- package/dist/local-index/detect-vue.js.map +1 -0
- package/dist/local-index/detect-wc.d.ts +2 -0
- package/dist/local-index/detect-wc.js +74 -0
- package/dist/local-index/detect-wc.js.map +1 -0
- package/dist/local-index/index.d.ts +6 -0
- package/dist/local-index/index.js +31 -0
- package/dist/local-index/index.js.map +1 -0
- package/dist/local-index/types.d.ts +2 -0
- package/dist/local-index/types.js +2 -0
- package/dist/local-index/types.js.map +1 -0
- package/dist/local-index/walker.d.ts +11 -0
- package/dist/local-index/walker.js +47 -0
- package/dist/local-index/walker.js.map +1 -0
- package/dist/manifest/barrel-parser.d.ts +22 -0
- package/dist/manifest/barrel-parser.js +62 -0
- package/dist/manifest/barrel-parser.js.map +1 -0
- package/dist/manifest/discovery.d.ts +24 -0
- package/dist/manifest/discovery.js +194 -0
- package/dist/manifest/discovery.js.map +1 -0
- package/dist/manifest/index.d.ts +6 -0
- package/dist/manifest/index.js +98 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/resolver.d.ts +30 -0
- package/dist/manifest/resolver.js +136 -0
- package/dist/manifest/resolver.js.map +1 -0
- package/dist/manifest/run-discovery.d.ts +12 -0
- package/dist/manifest/run-discovery.js +46 -0
- package/dist/manifest/run-discovery.js.map +1 -0
- package/dist/manifest/types.d.ts +3 -0
- package/dist/manifest/types.js +2 -0
- package/dist/manifest/types.js.map +1 -0
- package/dist/occurrences.d.ts +12 -0
- package/dist/occurrences.js +42 -0
- package/dist/occurrences.js.map +1 -0
- package/dist/reporter/index.d.ts +25 -0
- package/dist/reporter/index.js +50 -0
- package/dist/reporter/index.js.map +1 -0
- package/dist/reporter/json.d.ts +6 -0
- package/dist/reporter/json.js +11 -0
- package/dist/reporter/json.js.map +1 -0
- package/dist/reporter/stdout.d.ts +2 -0
- package/dist/reporter/stdout.js +40 -0
- package/dist/reporter/stdout.js.map +1 -0
- package/dist/rollup.d.ts +21 -0
- package/dist/rollup.js +78 -0
- package/dist/rollup.js.map +1 -0
- package/dist/seeds.d.ts +28 -0
- package/dist/seeds.js +109 -0
- package/dist/seeds.js.map +1 -0
- package/dist/types/brand.d.ts +11 -0
- package/dist/types/brand.js +5 -0
- package/dist/types/brand.js.map +1 -0
- package/dist/types/component-id.d.ts +2 -0
- package/dist/types/component-id.js +2 -0
- package/dist/types/component-id.js.map +1 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/util/git.d.ts +1 -0
- package/dist/util/git.js +13 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/log.d.ts +7 -0
- package/dist/util/log.js +17 -0
- package/dist/util/log.js.map +1 -0
- package/dist/util/pkg.d.ts +1 -0
- package/dist/util/pkg.js +13 -0
- package/dist/util/pkg.js.map +1 -0
- package/dist/util/pnp-check.d.ts +1 -0
- package/dist/util/pnp-check.js +6 -0
- package/dist/util/pnp-check.js.map +1 -0
- package/dist/util/posix.d.ts +2 -0
- package/dist/util/posix.js +18 -0
- package/dist/util/posix.js.map +1 -0
- package/dist/walker/files.d.ts +6 -0
- package/dist/walker/files.js +12 -0
- package/dist/walker/files.js.map +1 -0
- package/dist/walker/resolve-import.d.ts +9 -0
- package/dist/walker/resolve-import.js +119 -0
- package/dist/walker/resolve-import.js.map +1 -0
- package/examples/github-actions-workflow.yml +20 -0
- package/package.json +63 -0
- package/schema/config.schema.json +61 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reporter assembly entry points.
|
|
3
|
+
*
|
|
4
|
+
* `buildScanOutput` is the pure, in-memory composition that folds the scan
|
|
5
|
+
* envelope, per-component seeds, and the flat occurrence stream into the
|
|
6
|
+
* two-grain `ScanOutput` shape exported by `@component-compass/plugin-core`.
|
|
7
|
+
*
|
|
8
|
+
* It does no IO; downstream JSON / stdout reporters consume the result.
|
|
9
|
+
*/
|
|
10
|
+
import type { ManifestComponent, ManifestRef, OutputManifest, OutputOccurrence, ScanEnvelope, ScanOutput, ScanStats } from "@component-compass/plugin-core";
|
|
11
|
+
import { type ComponentSeed } from "../rollup.js";
|
|
12
|
+
export type PartialScanStats = Pick<ScanStats, "filesScanned" | "filesWithUsage" | "scanDurationMs">;
|
|
13
|
+
export declare function buildScanOutput(envelope: ScanEnvelope, manifests: ManifestRef[], partialStats: PartialScanStats, seeds: ComponentSeed[], occurrences: OutputOccurrence[]): ScanOutput;
|
|
14
|
+
/**
|
|
15
|
+
* Pure converter: project a rich `ManifestComponent` (plugin-core domain
|
|
16
|
+
* model) onto the artifact-shape `OutputManifest` consumed by the JSON
|
|
17
|
+
* report. Only fields the v1 output contract recognises are carried over —
|
|
18
|
+
* lifecycle (verbatim) and per-prop `default`. Props without a declared
|
|
19
|
+
* default are omitted from the output map; absent input lifecycle yields an
|
|
20
|
+
* absent output `lifecycle` field (not `null`, not a synthesised default).
|
|
21
|
+
*
|
|
22
|
+
* Returns `null` when no manifest entry was matched for the component, so
|
|
23
|
+
* downstream `OutputComponent.manifest` can be set directly.
|
|
24
|
+
*/
|
|
25
|
+
export declare function manifestComponentToOutput(m: ManifestComponent | undefined): OutputManifest | null;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reporter assembly entry points.
|
|
3
|
+
*
|
|
4
|
+
* `buildScanOutput` is the pure, in-memory composition that folds the scan
|
|
5
|
+
* envelope, per-component seeds, and the flat occurrence stream into the
|
|
6
|
+
* two-grain `ScanOutput` shape exported by `@component-compass/plugin-core`.
|
|
7
|
+
*
|
|
8
|
+
* It does no IO; downstream JSON / stdout reporters consume the result.
|
|
9
|
+
*/
|
|
10
|
+
import { rollupOccurrencesToComponents } from "../rollup.js";
|
|
11
|
+
export function buildScanOutput(envelope, manifests, partialStats, seeds, occurrences) {
|
|
12
|
+
const components = rollupOccurrencesToComponents(occurrences, seeds);
|
|
13
|
+
const stats = {
|
|
14
|
+
...partialStats,
|
|
15
|
+
componentsDetected: components.length,
|
|
16
|
+
totalOccurrences: occurrences.length,
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
envelope,
|
|
20
|
+
manifests,
|
|
21
|
+
stats,
|
|
22
|
+
components,
|
|
23
|
+
occurrences,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Pure converter: project a rich `ManifestComponent` (plugin-core domain
|
|
28
|
+
* model) onto the artifact-shape `OutputManifest` consumed by the JSON
|
|
29
|
+
* report. Only fields the v1 output contract recognises are carried over —
|
|
30
|
+
* lifecycle (verbatim) and per-prop `default`. Props without a declared
|
|
31
|
+
* default are omitted from the output map; absent input lifecycle yields an
|
|
32
|
+
* absent output `lifecycle` field (not `null`, not a synthesised default).
|
|
33
|
+
*
|
|
34
|
+
* Returns `null` when no manifest entry was matched for the component, so
|
|
35
|
+
* downstream `OutputComponent.manifest` can be set directly.
|
|
36
|
+
*/
|
|
37
|
+
export function manifestComponentToOutput(m) {
|
|
38
|
+
if (!m)
|
|
39
|
+
return null;
|
|
40
|
+
const props = {};
|
|
41
|
+
for (const p of m.props) {
|
|
42
|
+
if (p.default !== undefined)
|
|
43
|
+
props[p.name] = { default: p.default };
|
|
44
|
+
}
|
|
45
|
+
const out = { props };
|
|
46
|
+
if (m.lifecycle !== undefined)
|
|
47
|
+
out.lifecycle = m.lifecycle;
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH,OAAO,EAAE,6BAA6B,EAAsB,MAAM,cAAc,CAAC;AAOjF,MAAM,UAAU,eAAe,CAC7B,QAAsB,EACtB,SAAwB,EACxB,YAA8B,EAC9B,KAAsB,EACtB,WAA+B;IAE/B,MAAM,UAAU,GAAG,6BAA6B,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACrE,MAAM,KAAK,GAAc;QACvB,GAAG,YAAY;QACf,kBAAkB,EAAE,UAAU,CAAC,MAAM;QACrC,gBAAgB,EAAE,WAAW,CAAC,MAAM;KACrC,CAAC;IACF,OAAO;QACL,QAAQ;QACR,SAAS;QACT,KAAK;QACL,UAAU;QACV,WAAW;KACZ,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,yBAAyB,CACvC,CAAgC;IAEhC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,KAAK,GAAyC,EAAE,CAAC;IACvD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACtE,CAAC;IACD,MAAM,GAAG,GAAmB,EAAE,KAAK,EAAE,CAAC;IACtC,IAAI,CAAC,CAAC,SAAS,KAAK,SAAS;QAAE,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;IAC3D,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ScanOutput } from "@component-compass/plugin-core";
|
|
2
|
+
/**
|
|
3
|
+
* Writes the v2 ScanOutput artifact to disk as pretty-printed JSON.
|
|
4
|
+
* Creates parent directories as needed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function writeJson(output: ScanOutput, outputPath: string): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the v2 ScanOutput artifact to disk as pretty-printed JSON.
|
|
5
|
+
* Creates parent directories as needed.
|
|
6
|
+
*/
|
|
7
|
+
export async function writeJson(output, outputPath) {
|
|
8
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
9
|
+
await writeFile(outputPath, `${JSON.stringify(output, null, 2)}\n`, "utf8");
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/reporter/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAkB,EAAE,UAAkB;IACpE,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function printSummary(out, outputPath) {
|
|
2
|
+
const { envelope, components, stats } = out;
|
|
3
|
+
const lines = [];
|
|
4
|
+
lines.push("");
|
|
5
|
+
lines.push("component-compass scan");
|
|
6
|
+
lines.push("──────────────────────");
|
|
7
|
+
lines.push(`scanId: ${envelope.scanId}`);
|
|
8
|
+
lines.push(`repoId: ${envelope.repoId}`);
|
|
9
|
+
lines.push(`timestamp: ${envelope.timestamp}`);
|
|
10
|
+
lines.push("");
|
|
11
|
+
lines.push(`Scanned ${stats.filesScanned} files in ${(stats.scanDurationMs / 1000).toFixed(1)}s — ${stats.filesWithUsage} files use design system components`);
|
|
12
|
+
lines.push(`Components detected: ${stats.componentsDetected}`);
|
|
13
|
+
lines.push(`Total occurrences: ${stats.totalOccurrences}`);
|
|
14
|
+
lines.push("");
|
|
15
|
+
const sorted = [...components]
|
|
16
|
+
.sort((a, b) => b.stats.occurrenceCount - a.stats.occurrenceCount)
|
|
17
|
+
.slice(0, 5);
|
|
18
|
+
if (sorted.length > 0) {
|
|
19
|
+
lines.push("Top by usage:");
|
|
20
|
+
const labels = sorted.map(componentLabel);
|
|
21
|
+
const widest = Math.max(...labels.map((l) => l.length));
|
|
22
|
+
for (const [i, c] of sorted.entries()) {
|
|
23
|
+
const label = labels[i] ?? "";
|
|
24
|
+
const pad = " ".repeat(widest - label.length + 2);
|
|
25
|
+
lines.push(` ${label}${pad}${c.stats.occurrenceCount} [${c.identity.kind}]`);
|
|
26
|
+
}
|
|
27
|
+
lines.push("");
|
|
28
|
+
}
|
|
29
|
+
lines.push(`→ ${outputPath}`);
|
|
30
|
+
lines.push("");
|
|
31
|
+
process.stdout.write(lines.join("\n"));
|
|
32
|
+
}
|
|
33
|
+
function componentLabel(c) {
|
|
34
|
+
const { identity } = c;
|
|
35
|
+
if (identity.kind === "custom-element")
|
|
36
|
+
return identity.tagName ?? "(unknown)";
|
|
37
|
+
const pkg = identity.packageName ?? identity.filePath ?? "(unknown)";
|
|
38
|
+
return `${pkg}::${identity.exportName ?? "(unknown)"}`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=stdout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdout.js","sourceRoot":"","sources":["../../src/reporter/stdout.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAe,EAAE,UAAkB;IAC9D,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAC5C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACrC,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACrC,KAAK,CAAC,IAAI,CAAC,cAAc,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,KAAK,CAAC,IAAI,CAAC,cAAc,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,KAAK,CAAC,IAAI,CAAC,cAAc,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,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAClD,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,eAAe,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;QACjF,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC,CAAC;IAC9B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,CAAkB;IACxC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IACvB,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB;QAAE,OAAO,QAAQ,CAAC,OAAO,IAAI,WAAW,CAAC;IAC/E,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,QAAQ,IAAI,WAAW,CAAC;IACrE,OAAO,GAAG,GAAG,KAAK,QAAQ,CAAC,UAAU,IAAI,WAAW,EAAE,CAAC;AACzD,CAAC"}
|
package/dist/rollup.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folds a flat occurrence stream plus per-component seeds (identity + manifest
|
|
3
|
+
* + derivedTags) into the rolled `OutputComponent[]` shape.
|
|
4
|
+
*
|
|
5
|
+
* Math invariant per prop:
|
|
6
|
+
* sum(distribution.values) + dynamic + omitted === stats.occurrenceCount
|
|
7
|
+
* `defaultApplied` is a SUBSET of `omitted` (the slice where the manifest
|
|
8
|
+
* declares a default), not additive.
|
|
9
|
+
*
|
|
10
|
+
* Components with zero occurrences still emit identity + zeroed stats so that
|
|
11
|
+
* design-system components present in the repo via `tagRules` surface even
|
|
12
|
+
* when not yet used.
|
|
13
|
+
*/
|
|
14
|
+
import type { OutputComponent, OutputIdentity, OutputManifest, OutputOccurrence } from "@component-compass/plugin-core";
|
|
15
|
+
export type ComponentSeed = {
|
|
16
|
+
id: string;
|
|
17
|
+
identity: OutputIdentity;
|
|
18
|
+
derivedTags: string[];
|
|
19
|
+
manifest: OutputManifest | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function rollupOccurrencesToComponents(occurrences: OutputOccurrence[], seeds: ComponentSeed[]): OutputComponent[];
|
package/dist/rollup.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folds a flat occurrence stream plus per-component seeds (identity + manifest
|
|
3
|
+
* + derivedTags) into the rolled `OutputComponent[]` shape.
|
|
4
|
+
*
|
|
5
|
+
* Math invariant per prop:
|
|
6
|
+
* sum(distribution.values) + dynamic + omitted === stats.occurrenceCount
|
|
7
|
+
* `defaultApplied` is a SUBSET of `omitted` (the slice where the manifest
|
|
8
|
+
* declares a default), not additive.
|
|
9
|
+
*
|
|
10
|
+
* Components with zero occurrences still emit identity + zeroed stats so that
|
|
11
|
+
* design-system components present in the repo via `tagRules` surface even
|
|
12
|
+
* when not yet used.
|
|
13
|
+
*/
|
|
14
|
+
const stringifyLiteral = (v) => v === null ? "null" : String(v);
|
|
15
|
+
const isDynamic = (v) => typeof v === "object" && v !== null && "__dynamic" in v;
|
|
16
|
+
const emptyDist = () => ({
|
|
17
|
+
distribution: {},
|
|
18
|
+
dynamic: 0,
|
|
19
|
+
omitted: 0,
|
|
20
|
+
defaultApplied: 0,
|
|
21
|
+
});
|
|
22
|
+
export function rollupOccurrencesToComponents(occurrences, seeds) {
|
|
23
|
+
const byId = new Map();
|
|
24
|
+
for (const o of occurrences) {
|
|
25
|
+
const list = byId.get(o.componentId);
|
|
26
|
+
if (list) {
|
|
27
|
+
list.push(o);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
byId.set(o.componentId, [o]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return seeds.map((seed) => {
|
|
34
|
+
const occs = byId.get(seed.id) ?? [];
|
|
35
|
+
const fileSet = new Set();
|
|
36
|
+
const propsSeen = new Set();
|
|
37
|
+
for (const o of occs) {
|
|
38
|
+
fileSet.add(o.filePath);
|
|
39
|
+
for (const name of Object.keys(o.props))
|
|
40
|
+
propsSeen.add(name);
|
|
41
|
+
}
|
|
42
|
+
// Manifest-declared props with no occurrence usage still need a slot so
|
|
43
|
+
// the rollup can surface "prop X is universally unused / always defaulted".
|
|
44
|
+
for (const name of Object.keys(seed.manifest?.props ?? {}))
|
|
45
|
+
propsSeen.add(name);
|
|
46
|
+
const props = {};
|
|
47
|
+
for (const name of propsSeen) {
|
|
48
|
+
const dist = emptyDist();
|
|
49
|
+
const hasDefault = seed.manifest?.props?.[name]?.default !== undefined;
|
|
50
|
+
for (const o of occs) {
|
|
51
|
+
if (!(name in o.props)) {
|
|
52
|
+
dist.omitted += 1;
|
|
53
|
+
if (hasDefault)
|
|
54
|
+
dist.defaultApplied += 1;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// Narrow: presence is guaranteed by the `in` check above.
|
|
58
|
+
const value = o.props[name];
|
|
59
|
+
if (isDynamic(value)) {
|
|
60
|
+
dist.dynamic += 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const key = stringifyLiteral(value);
|
|
64
|
+
dist.distribution[key] = (dist.distribution[key] ?? 0) + 1;
|
|
65
|
+
}
|
|
66
|
+
props[name] = dist;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
id: seed.id,
|
|
70
|
+
identity: seed.identity,
|
|
71
|
+
derivedTags: seed.derivedTags,
|
|
72
|
+
manifest: seed.manifest,
|
|
73
|
+
stats: { occurrenceCount: occs.length, fileCount: fileSet.size },
|
|
74
|
+
props,
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=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CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YAC7D,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE;YAChE,KAAK;SACN,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/seeds.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds per-component seeds from the resolved `ComponentIndex`, parser-emitted
|
|
3
|
+
* occurrences, and the workspace tag rules. Seeds are the per-component input to
|
|
4
|
+
* `rollupOccurrencesToComponents`: they carry identity, derivedTags, and manifest
|
|
5
|
+
* enrichment but no occurrence data (that is merged separately during rollup).
|
|
6
|
+
*
|
|
7
|
+
* Pure function; no I/O.
|
|
8
|
+
*/
|
|
9
|
+
import type { ComponentIndex, ParseResult } from "@component-compass/plugin-core";
|
|
10
|
+
import type { TagRule } from "./config/schema.js";
|
|
11
|
+
import type { ComponentSeed } from "./rollup.js";
|
|
12
|
+
/**
|
|
13
|
+
* Project the manifest index AND parser-emitted occurrences into ComponentSeeds.
|
|
14
|
+
*
|
|
15
|
+
* Two sources contribute:
|
|
16
|
+
* 1. Manifest-indexed components — full enrichment via `manifestComponentToOutput`.
|
|
17
|
+
* 2. Components observed in parser walks but absent from the index — emitted
|
|
18
|
+
* with `manifest: null` so they surface in `components[]` per the
|
|
19
|
+
* realignment principle ("manifest is enrichment, not gate").
|
|
20
|
+
*
|
|
21
|
+
* Dedupe by stable id; manifest-indexed seeds win.
|
|
22
|
+
*
|
|
23
|
+
* Scope derivation follows the three-lane model in identity.ts:
|
|
24
|
+
* - local → source.type === "local"
|
|
25
|
+
* - ds → external + derivedTags.length > 0
|
|
26
|
+
* - external → external + no matching tag rules
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildComponentSeeds(index: ComponentIndex, parseResults: ParseResult[], tagRules: TagRule[] | undefined): ComponentSeed[];
|
package/dist/seeds.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds per-component seeds from the resolved `ComponentIndex`, parser-emitted
|
|
3
|
+
* occurrences, and the workspace tag rules. Seeds are the per-component input to
|
|
4
|
+
* `rollupOccurrencesToComponents`: they carry identity, derivedTags, and manifest
|
|
5
|
+
* enrichment but no occurrence data (that is merged separately during rollup).
|
|
6
|
+
*
|
|
7
|
+
* Pure function; no I/O.
|
|
8
|
+
*/
|
|
9
|
+
import { evaluateTagRules } from "./config/tag-rules.js";
|
|
10
|
+
import { manifestComponentToOutput } from "./reporter/index.js";
|
|
11
|
+
import { computeOutputIdentity, computeStableId, computeStableIdFromComponentId, } from "./identity.js";
|
|
12
|
+
/**
|
|
13
|
+
* Project the manifest index AND parser-emitted occurrences into ComponentSeeds.
|
|
14
|
+
*
|
|
15
|
+
* Two sources contribute:
|
|
16
|
+
* 1. Manifest-indexed components — full enrichment via `manifestComponentToOutput`.
|
|
17
|
+
* 2. Components observed in parser walks but absent from the index — emitted
|
|
18
|
+
* with `manifest: null` so they surface in `components[]` per the
|
|
19
|
+
* realignment principle ("manifest is enrichment, not gate").
|
|
20
|
+
*
|
|
21
|
+
* Dedupe by stable id; manifest-indexed seeds win.
|
|
22
|
+
*
|
|
23
|
+
* Scope derivation follows the three-lane model in identity.ts:
|
|
24
|
+
* - local → source.type === "local"
|
|
25
|
+
* - ds → external + derivedTags.length > 0
|
|
26
|
+
* - external → external + no matching tag rules
|
|
27
|
+
*/
|
|
28
|
+
export function buildComponentSeeds(index, parseResults, tagRules) {
|
|
29
|
+
const seedsById = new Map();
|
|
30
|
+
// 1. Manifest-indexed components first (so they win on dedupe).
|
|
31
|
+
for (const entry of index.byId.values()) {
|
|
32
|
+
const componentId = indexedToComponentId(entry);
|
|
33
|
+
const packageName = entry.source.type === "external" ? entry.source.package : null;
|
|
34
|
+
const derivedTags = evaluateTagRules(packageName, tagRules);
|
|
35
|
+
const via = defaultVia(entry);
|
|
36
|
+
const identity = computeOutputIdentity({
|
|
37
|
+
componentId,
|
|
38
|
+
via,
|
|
39
|
+
derivedTags,
|
|
40
|
+
repoId: "",
|
|
41
|
+
});
|
|
42
|
+
const id = computeStableId(identity);
|
|
43
|
+
const manifest = manifestComponentToOutput(entry);
|
|
44
|
+
seedsById.set(id, { id, identity, derivedTags, manifest });
|
|
45
|
+
}
|
|
46
|
+
// 2. Components observed in parser walks but not yet seeded.
|
|
47
|
+
// Emitted with manifest: null per the realignment principle.
|
|
48
|
+
for (const result of parseResults) {
|
|
49
|
+
for (const occ of result.occurrences) {
|
|
50
|
+
const id = computeStableIdFromComponentId(occ.componentId);
|
|
51
|
+
if (seedsById.has(id))
|
|
52
|
+
continue;
|
|
53
|
+
const packageName = occ.componentId.source.type === "external"
|
|
54
|
+
? occ.componentId.source.package
|
|
55
|
+
: null;
|
|
56
|
+
const derivedTags = evaluateTagRules(packageName, tagRules);
|
|
57
|
+
const identity = computeOutputIdentity({
|
|
58
|
+
componentId: occ.componentId,
|
|
59
|
+
via: defaultViaForKind(occ.componentId),
|
|
60
|
+
derivedTags,
|
|
61
|
+
repoId: "",
|
|
62
|
+
});
|
|
63
|
+
seedsById.set(id, { id, identity, derivedTags, manifest: null });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return [...seedsById.values()];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Convert an `IndexedComponent` to a `ComponentId` for use with
|
|
70
|
+
* `computeOutputIdentity`. `IndexedComponent` extends `ManifestComponent`
|
|
71
|
+
* which shares the same `source` / `kind` / `export` / `tagName` fields.
|
|
72
|
+
*/
|
|
73
|
+
function indexedToComponentId(c) {
|
|
74
|
+
if (c.kind === "custom-element") {
|
|
75
|
+
return {
|
|
76
|
+
kind: "custom-element",
|
|
77
|
+
tagName: c.tagName,
|
|
78
|
+
source: c.source,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
kind: c.kind,
|
|
83
|
+
export: c.export,
|
|
84
|
+
source: c.source,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Infer a default `via` for a manifest-indexed seed based on component kind.
|
|
89
|
+
* Only `via.kind` is consumed by `computeOutputIdentity`; the required
|
|
90
|
+
* `specifier`/`import` fields on `direct-import` are not meaningful for
|
|
91
|
+
* zero-occurrence seeds and are left as empty strings.
|
|
92
|
+
*/
|
|
93
|
+
function defaultVia(c) {
|
|
94
|
+
if (c.kind === "custom-element") {
|
|
95
|
+
return { kind: "html-tag" };
|
|
96
|
+
}
|
|
97
|
+
return { kind: "direct-import", specifier: "", import: "" };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Infer a default `via` for an occurrence-observed seed based on the
|
|
101
|
+
* component's kind. Used when seeding a component that has no manifest entry.
|
|
102
|
+
*/
|
|
103
|
+
function defaultViaForKind(c) {
|
|
104
|
+
if (c.kind === "custom-element") {
|
|
105
|
+
return { kind: "html-tag" };
|
|
106
|
+
}
|
|
107
|
+
return { kind: "direct-import", specifier: "", import: "" };
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=seeds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seeds.js","sourceRoot":"","sources":["../src/seeds.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACh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,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CAAC,CAAc;IACvC,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type { TagName, WrapperId } from "@component-compass/plugin-core";
|
|
2
|
+
export { asTagName, asWrapperId } from "@component-compass/plugin-core";
|
|
3
|
+
declare const __brand: unique symbol;
|
|
4
|
+
type Brand<K, T> = K & {
|
|
5
|
+
readonly [__brand]: T;
|
|
6
|
+
};
|
|
7
|
+
export type ComponentId = Brand<string, "ComponentId">;
|
|
8
|
+
export type PackageName = Brand<string, "PackageName">;
|
|
9
|
+
/** Unsafe constructors — use only at the data-ingest boundary. */
|
|
10
|
+
export declare const asComponentId: (s: string) => ComponentId;
|
|
11
|
+
export declare const asPackageName: (s: string) => PackageName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.js","sourceRoot":"","sources":["../../src/types/brand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAQxE,kEAAkE;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAe,EAAE,CAAC,CAAgB,CAAC;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAe,EAAE,CAAC,CAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-id.js","sourceRoot":"","sources":["../../src/types/component-id.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { Loc, WarningCode, Warning } from "@component-compass/plugin-core";
|
|
2
|
+
export type { TagRule } from "./config/schema.js";
|
|
3
|
+
import type { TagRule } from "./config/schema.js";
|
|
4
|
+
export type ResolvedConfig = {
|
|
5
|
+
configPath: string;
|
|
6
|
+
configDir: string;
|
|
7
|
+
repoId: string;
|
|
8
|
+
packageScopes: string[];
|
|
9
|
+
manifestSources?: Record<string, string[]>;
|
|
10
|
+
include: string[];
|
|
11
|
+
exclude: string[];
|
|
12
|
+
captureValues: boolean;
|
|
13
|
+
output: string;
|
|
14
|
+
tsconfigPath?: string;
|
|
15
|
+
aliases?: Record<string, string[]>;
|
|
16
|
+
tagRules?: TagRule[];
|
|
17
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readGitCommit(root: string): Promise<string | undefined>;
|
package/dist/util/git.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const exec = promisify(execFile);
|
|
4
|
+
export async function readGitCommit(root) {
|
|
5
|
+
try {
|
|
6
|
+
const { stdout } = await exec("git", ["rev-parse", "HEAD"], { cwd: root });
|
|
7
|
+
return stdout.trim();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/util/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAY;IAC9C,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/util/log.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
quiet;
|
|
3
|
+
constructor(quiet = false) {
|
|
4
|
+
this.quiet = quiet;
|
|
5
|
+
}
|
|
6
|
+
info(msg) {
|
|
7
|
+
if (!this.quiet)
|
|
8
|
+
process.stdout.write(`${msg}\n`);
|
|
9
|
+
}
|
|
10
|
+
warn(msg) {
|
|
11
|
+
process.stderr.write(`⚠ ${msg}\n`);
|
|
12
|
+
}
|
|
13
|
+
error(msg) {
|
|
14
|
+
process.stderr.write(`error: ${msg}\n`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/util/log.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAM;IACG;IAApB,YAAoB,QAAQ,KAAK;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IACrC,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,CAAC,GAAW;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,KAAK,CAAC,GAAW;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readPackageName(root: string): Promise<string | undefined>;
|
package/dist/util/pkg.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
export async function readPackageName(root) {
|
|
4
|
+
try {
|
|
5
|
+
const raw = await readFile(join(root, "package.json"), "utf8");
|
|
6
|
+
const p = JSON.parse(raw);
|
|
7
|
+
return p.name;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=pkg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../src/util/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAsB,CAAC;QAC/C,OAAO,CAAC,CAAC,IAAI,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPnpProject(root: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnp-check.js","sourceRoot":"","sources":["../../src/util/pnp-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { relative as nodeRelative, isAbsolute } from "node:path";
|
|
2
|
+
import { posixPath } from "@component-compass/ast-utils";
|
|
3
|
+
// posixPath is now owned by ast-utils so parser packages can import it without
|
|
4
|
+
// depending on the CLI. Re-exported here so existing CLI-internal imports still
|
|
5
|
+
// resolve.
|
|
6
|
+
export { posixPath } from "@component-compass/ast-utils";
|
|
7
|
+
// Returns `file` as a posix path relative to `root`. Files outside `root`
|
|
8
|
+
// (e.g. resolved manifest paths in node_modules above the repo) keep their
|
|
9
|
+
// original posix-normalized form.
|
|
10
|
+
export function relativizePath(file, root) {
|
|
11
|
+
if (!isAbsolute(file))
|
|
12
|
+
return posixPath(file);
|
|
13
|
+
const rel = nodeRelative(root, file);
|
|
14
|
+
if (rel === "" || rel.startsWith(".."))
|
|
15
|
+
return posixPath(file);
|
|
16
|
+
return posixPath(rel);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=posix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posix.js","sourceRoot":"","sources":["../../src/util/posix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,+EAA+E;AAC/E,gFAAgF;AAChF,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,0EAA0E;AAC1E,2EAA2E;AAC3E,kCAAkC;AAClC,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY;IACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { glob } from "glob";
|
|
2
|
+
export async function walkFiles(opts) {
|
|
3
|
+
const matched = await glob(opts.include, {
|
|
4
|
+
cwd: opts.root,
|
|
5
|
+
nodir: true,
|
|
6
|
+
absolute: true,
|
|
7
|
+
ignore: opts.exclude,
|
|
8
|
+
dot: false,
|
|
9
|
+
});
|
|
10
|
+
return matched;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/walker/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAiB;IAC/C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACvC,GAAG,EAAE,IAAI,CAAC,IAAI;QACd,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI,CAAC,OAAO;QACpB,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type CreateImportResolverOptions = {
|
|
2
|
+
repoRoot: string;
|
|
3
|
+
/** Map of alias pattern → array of target patterns, both using `*` as the wildcard. */
|
|
4
|
+
aliases?: Record<string, string[]>;
|
|
5
|
+
/** Absolute path to a tsconfig.json whose `compilerOptions.paths` should layer in. */
|
|
6
|
+
tsconfigPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ResolveImport = (from: string, spec: string) => string | null;
|
|
9
|
+
export declare function createImportResolver(opts: CreateImportResolverOptions): ResolveImport;
|