@component-compass/cli 0.0.0-pr-3-8916f3c-20260507150423 → 0.0.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 +4 -8
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts +2 -3
- package/dist/commands/init.js +62 -50
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/scan.js +51 -34
- package/dist/commands/scan.js.map +1 -1
- package/dist/graph/builder.d.ts +25 -0
- package/dist/graph/builder.js +176 -0
- package/dist/graph/builder.js.map +1 -0
- package/dist/identity.d.ts +0 -12
- package/dist/identity.js +0 -25
- package/dist/identity.js.map +1 -1
- package/dist/reporter/index.d.ts +2 -3
- package/dist/reporter/index.js +2 -10
- package/dist/reporter/index.js.map +1 -1
- package/dist/reporter/json.d.ts +2 -6
- package/dist/reporter/json.js +3 -7
- package/dist/reporter/json.js.map +1 -1
- package/dist/reporter/stdout.d.ts +2 -2
- package/dist/reporter/stdout.js +23 -11
- package/dist/reporter/stdout.js.map +1 -1
- package/dist/reporter/types.d.ts +69 -0
- package/dist/reporter/types.js +2 -0
- package/dist/reporter/types.js.map +1 -0
- package/dist/rollup.js +1 -0
- package/dist/rollup.js.map +1 -1
- package/package.json +9 -9
- package/schema/config.schema.json +2 -1
- package/dist/occurrences.d.ts +0 -12
- package/dist/occurrences.js +0 -42
- package/dist/occurrences.js.map +0 -1
- package/dist/seeds.d.ts +0 -28
- package/dist/seeds.js +0 -109
- package/dist/seeds.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -56,14 +56,8 @@ async function main(argv) {
|
|
|
56
56
|
return r.exitCode;
|
|
57
57
|
}
|
|
58
58
|
if (cmd === "init") {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return 0;
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
process.stderr.write(`init failed: ${errorStack(err)}\n`);
|
|
65
|
-
return 1;
|
|
66
|
-
}
|
|
59
|
+
const flags = parseFlags(rest);
|
|
60
|
+
return await runInit({ cwd: process.cwd(), discover: flags.discover ?? false });
|
|
67
61
|
}
|
|
68
62
|
log.error(`Unknown command: ${cmd}\n${HELP}`);
|
|
69
63
|
return 2;
|
|
@@ -95,6 +89,8 @@ function parseFlags(args) {
|
|
|
95
89
|
if (next)
|
|
96
90
|
out.failOn = next;
|
|
97
91
|
}
|
|
92
|
+
else if (a === "--discover")
|
|
93
|
+
out.discover = true;
|
|
98
94
|
else if (a === "--repo-id") {
|
|
99
95
|
const next = args[++i];
|
|
100
96
|
if (next)
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG1D,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;CAkBZ,CAAC;AAEF,KAAK,UAAU,IAAI,CAAC,IAAc;IAChC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QACrC,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAA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|
|
3
|
+
discover: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function runInit(opts: InitOptions): Promise<
|
|
6
|
-
export declare function runInitCli(_argv: string[]): Promise<number>;
|
|
5
|
+
export declare function runInit(opts: InitOptions): Promise<number>;
|
package/dist/commands/init.js
CHANGED
|
@@ -1,61 +1,73 @@
|
|
|
1
|
-
import { writeFile,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const TEMPLATE = (repoId) => ({
|
|
5
|
-
$schema: "https://unpkg.com/@component-compass/cli/schema/config.schema.json",
|
|
6
|
-
repoId,
|
|
7
|
-
include: ["src/**/*.{ts,tsx,jsx,js,vue,html}"],
|
|
8
|
-
exclude: ["**/*.{test,spec,stories}.*", "**/node_modules/**"],
|
|
9
|
-
packageScopes: [],
|
|
10
|
-
captureValues: false,
|
|
11
|
-
output: "./component-compass.json",
|
|
12
|
-
tagRules: [],
|
|
13
|
-
});
|
|
1
|
+
import { writeFile, readdir, readFile, stat } from "node:fs/promises";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
14
4
|
export async function runInit(opts) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await stat(out);
|
|
20
|
-
throw new Error(`Config already exists at ${out}. Refusing to overwrite.`);
|
|
5
|
+
const target = resolve(opts.cwd, "component-compass.config.json");
|
|
6
|
+
if (existsSync(target)) {
|
|
7
|
+
process.stderr.write(`Refusing to overwrite ${target}. Delete it first if you want to re-init.\n`);
|
|
8
|
+
return 2;
|
|
21
9
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
const manifests = opts.discover ? await discoverManifests(opts.cwd) : [];
|
|
11
|
+
const cfg = {
|
|
12
|
+
$schema: "https://unpkg.com/@component-compass/cli/schema/config.schema.json",
|
|
13
|
+
manifests,
|
|
14
|
+
include: ["src/**/*.{ts,tsx,js,jsx,html,vue}"],
|
|
15
|
+
exclude: [
|
|
16
|
+
"**/*.{test,spec,stories}.*",
|
|
17
|
+
"**/node_modules/**",
|
|
18
|
+
"**/dist/**",
|
|
19
|
+
],
|
|
20
|
+
captureValues: false,
|
|
21
|
+
output: "./component-compass.json",
|
|
22
|
+
};
|
|
23
|
+
await writeFile(target, `${JSON.stringify(cfg, null, 2)}\n`, "utf8");
|
|
24
|
+
process.stdout.write(`Wrote ${target}\n`);
|
|
25
|
+
if (opts.discover && manifests.length > 0) {
|
|
26
|
+
process.stdout.write(`Discovered manifests: ${manifests.join(", ")}\n`);
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
const cfg = TEMPLATE(repoId);
|
|
34
|
-
await writeFile(out, `${JSON.stringify(cfg, null, 2)}\n`, "utf8");
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
|
-
console.log(`Wrote ${out}.\nEdit packageScopes to declare which DS packages to track.`);
|
|
28
|
+
return 0;
|
|
37
29
|
}
|
|
38
|
-
async function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
async function discoverManifests(cwd) {
|
|
31
|
+
const root = join(cwd, "node_modules");
|
|
32
|
+
if (!existsSync(root))
|
|
33
|
+
return [];
|
|
34
|
+
const out = [];
|
|
35
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
36
|
+
for (const e of entries) {
|
|
37
|
+
if (!e.isDirectory())
|
|
38
|
+
continue;
|
|
39
|
+
if (e.name.startsWith("@")) {
|
|
40
|
+
const scopeDir = join(root, e.name);
|
|
41
|
+
const subs = await readdir(scopeDir, { withFileTypes: true });
|
|
42
|
+
for (const s of subs) {
|
|
43
|
+
if (s.isDirectory()) {
|
|
44
|
+
const found = await checkPackage(`${e.name}/${s.name}`, join(scopeDir, s.name));
|
|
45
|
+
if (found)
|
|
46
|
+
out.push(found);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const found = await checkPackage(e.name, join(root, e.name));
|
|
52
|
+
if (found)
|
|
53
|
+
out.push(found);
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
|
-
return
|
|
56
|
+
return out;
|
|
49
57
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
58
|
+
async function checkPackage(name, dir) {
|
|
59
|
+
const pkgPath = join(dir, "package.json");
|
|
52
60
|
try {
|
|
53
|
-
await
|
|
54
|
-
|
|
61
|
+
const raw = await readFile(pkgPath, "utf8");
|
|
62
|
+
const pkg = JSON.parse(raw);
|
|
63
|
+
if (typeof pkg.customElements !== "string")
|
|
64
|
+
return undefined;
|
|
65
|
+
const cemPath = join(dir, pkg.customElements);
|
|
66
|
+
await stat(cemPath);
|
|
67
|
+
return name;
|
|
55
68
|
}
|
|
56
|
-
catch
|
|
57
|
-
|
|
58
|
-
return 1;
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
73
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAOrC,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAiB;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,+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AAC,CAAC;QAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgC,CAAC;QAC3D,IAAI,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;QAC9C,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/commands/scan.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
|
-
import { isAbsolute, resolve } from "node:path";
|
|
2
|
+
import { basename, isAbsolute, resolve } from "node:path";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { loadConfig, ConfigError } from "../config/loader.js";
|
|
5
5
|
import { runDiscovery } from "../manifest/run-discovery.js";
|
|
@@ -12,15 +12,16 @@ import { reactPlugin } from "@component-compass/parser-react";
|
|
|
12
12
|
import { htmlPlugin } from "@component-compass/parser-html";
|
|
13
13
|
import { litTemplatePlugin } from "@component-compass/parser-lit";
|
|
14
14
|
import { vuePlugin } from "@component-compass/parser-vue";
|
|
15
|
+
import { buildGraph } from "../graph/builder.js";
|
|
15
16
|
import { writeJson } from "../reporter/json.js";
|
|
16
17
|
import { printSummary } from "../reporter/stdout.js";
|
|
17
18
|
import { buildScanEnvelope } from "../envelope/index.js";
|
|
19
|
+
import { readPackageName } from "../util/pkg.js";
|
|
20
|
+
import { readGitCommit } from "../util/git.js";
|
|
18
21
|
import { isPnpProject } from "../util/pnp-check.js";
|
|
19
22
|
import { Logger } from "../util/log.js";
|
|
20
23
|
import { errorMessage } from "@component-compass/ast-utils";
|
|
21
|
-
import {
|
|
22
|
-
import { parseResultsToOccurrences } from "../occurrences.js";
|
|
23
|
-
import { buildScanOutput } from "../reporter/index.js";
|
|
24
|
+
import { relativizePath } from "../util/posix.js";
|
|
24
25
|
export async function runScan(opts) {
|
|
25
26
|
const log = new Logger(opts.quiet);
|
|
26
27
|
const t0 = performance.now();
|
|
@@ -60,7 +61,8 @@ export async function runScan(opts) {
|
|
|
60
61
|
log.warn(`[component-compass] cycle detected in re-export chain at ${d.file}. Truncating.`);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
const
|
|
64
|
+
const compIndexResult = buildComponentIndex(cems);
|
|
65
|
+
const { warnings: compIndexWarnings, ...compIndexBase } = compIndexResult;
|
|
64
66
|
const localIndex = await buildLocalIndex({ repoRoot: cfg.configDir });
|
|
65
67
|
const compIndex = { ...compIndexBase, local: localIndex };
|
|
66
68
|
const files = await walkFiles({
|
|
@@ -68,8 +70,12 @@ export async function runScan(opts) {
|
|
|
68
70
|
include: cfg.include,
|
|
69
71
|
exclude: cfg.exclude,
|
|
70
72
|
});
|
|
73
|
+
const initialWarnings = [...compIndexWarnings];
|
|
71
74
|
if (files.length === 0) {
|
|
72
|
-
|
|
75
|
+
initialWarnings.push({
|
|
76
|
+
code: "EMPTY_INCLUDE",
|
|
77
|
+
message: `No files matched include globs: ${cfg.include.join(", ")}`,
|
|
78
|
+
});
|
|
73
79
|
}
|
|
74
80
|
const dispatcher = new Dispatcher([reactPlugin, htmlPlugin, litTemplatePlugin, vuePlugin]);
|
|
75
81
|
const resolveImportOpts = {
|
|
@@ -98,50 +104,61 @@ export async function runScan(opts) {
|
|
|
98
104
|
}));
|
|
99
105
|
}
|
|
100
106
|
catch (err) {
|
|
101
|
-
|
|
107
|
+
initialWarnings.push({
|
|
108
|
+
code: "PARSE_FAILURE",
|
|
109
|
+
message: errorMessage(err),
|
|
110
|
+
file,
|
|
111
|
+
// line: 0 means "unknown" — plugin threw without a recoverable location.
|
|
112
|
+
line: 0,
|
|
113
|
+
});
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
116
|
}
|
|
105
117
|
const t1 = performance.now();
|
|
118
|
+
const repoName = (await readPackageName(cfg.configDir)) ?? (basename(cfg.configDir) || "unknown");
|
|
119
|
+
const commit = await readGitCommit(cfg.configDir);
|
|
120
|
+
const repoMeta = {
|
|
121
|
+
name: repoName,
|
|
122
|
+
root: cfg.configDir,
|
|
123
|
+
};
|
|
124
|
+
if (commit)
|
|
125
|
+
repoMeta.commit = commit;
|
|
126
|
+
const manifestsMeta = cems.map((c) => {
|
|
127
|
+
const ref = {
|
|
128
|
+
source: c.kind === "cem" ? "cem" : c.manifest.source,
|
|
129
|
+
package: c.packageName,
|
|
130
|
+
path: relativizePath(c.path, cfg.configDir),
|
|
131
|
+
};
|
|
132
|
+
if (c.packageVersion)
|
|
133
|
+
ref.version = c.packageVersion;
|
|
134
|
+
return ref;
|
|
135
|
+
});
|
|
106
136
|
const envelope = buildScanEnvelope({
|
|
107
137
|
cwd: cfg.configDir,
|
|
108
138
|
cliRepoIdFlag: opts.repoId,
|
|
109
139
|
});
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const partialStats = {
|
|
140
|
+
const graph = buildGraph({
|
|
141
|
+
index: compIndex,
|
|
142
|
+
results,
|
|
114
143
|
filesScanned: files.length,
|
|
115
|
-
filesWithUsage: countFilesWithUsage(occurrences),
|
|
116
144
|
scanDurationMs: Math.round(t1 - t0),
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
tool: { name: "component-compass", version: envelope.toolVersion },
|
|
146
|
+
repo: repoMeta,
|
|
147
|
+
manifests: manifestsMeta,
|
|
148
|
+
captureValues: cfg.captureValues,
|
|
149
|
+
extraWarnings: initialWarnings,
|
|
150
|
+
envelope,
|
|
151
|
+
});
|
|
119
152
|
const outputPath = isAbsolute(cfg.output) ? cfg.output : resolve(cfg.configDir, cfg.output);
|
|
120
|
-
await writeJson(
|
|
121
|
-
if (!opts.quiet)
|
|
122
|
-
printSummary(
|
|
123
|
-
}
|
|
153
|
+
await writeJson(graph, outputPath);
|
|
154
|
+
if (!opts.quiet)
|
|
155
|
+
printSummary(graph, outputPath);
|
|
124
156
|
let exitCode = 0;
|
|
125
157
|
if (opts.failOn === "deprecated-usage") {
|
|
126
|
-
const hasDeprecated =
|
|
127
|
-
c.stats.occurrenceCount > 0);
|
|
158
|
+
const hasDeprecated = graph.components.some((c) => c.deprecated !== false && c.occurrences.length > 0);
|
|
128
159
|
if (hasDeprecated)
|
|
129
160
|
exitCode = 1;
|
|
130
161
|
}
|
|
131
162
|
return { exitCode };
|
|
132
163
|
}
|
|
133
|
-
function countFilesWithUsage(occurrences) {
|
|
134
|
-
const files = new Set();
|
|
135
|
-
for (const o of occurrences)
|
|
136
|
-
files.add(o.filePath);
|
|
137
|
-
return files.size;
|
|
138
|
-
}
|
|
139
|
-
function manifestsToRefs(manifests) {
|
|
140
|
-
return manifests.map((m) => ({
|
|
141
|
-
source: m.kind === "cem" ? "cem" : m.manifest.source,
|
|
142
|
-
package: m.packageName,
|
|
143
|
-
path: m.path,
|
|
144
|
-
version: m.packageVersion ?? null,
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
164
|
//# sourceMappingURL=scan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,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E,aAAa;QACxB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,aAAa,EAAE,eAAe;QAC9B,QAAQ;KACT,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5F,MAAM,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAEnC,IAAI,CAAC,IAAI,CAAC,KAAK;QAAE,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAEjD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,IAAI,CAAC,MAAM,KAAK,kBAAkB,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,KAAK,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAC1D,CAAC;QACF,IAAI,aAAa;YAAE,QAAQ,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ScanEnvelope } from "@component-compass/plugin-core";
|
|
2
|
+
import type { ComponentIndex } from "../manifest/types.js";
|
|
3
|
+
import type { ParseResult } from "@component-compass/plugin-core";
|
|
4
|
+
import type { Warning } from "../types.js";
|
|
5
|
+
import type { OutputDocument, OutputManifestRef } from "../reporter/types.js";
|
|
6
|
+
export type BuildGraphOptions = {
|
|
7
|
+
index: ComponentIndex;
|
|
8
|
+
results: ParseResult[];
|
|
9
|
+
filesScanned: number;
|
|
10
|
+
scanDurationMs: number;
|
|
11
|
+
tool: {
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
};
|
|
15
|
+
repo: {
|
|
16
|
+
name: string;
|
|
17
|
+
root: string;
|
|
18
|
+
commit?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
manifests: OutputManifestRef[];
|
|
21
|
+
captureValues: boolean;
|
|
22
|
+
extraWarnings?: Warning[];
|
|
23
|
+
envelope: ScanEnvelope;
|
|
24
|
+
};
|
|
25
|
+
export declare function buildGraph(opts: BuildGraphOptions): OutputDocument;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { serialiseComponentId, compareComponentId } from "@component-compass/plugin-core";
|
|
2
|
+
import { relativizePath } from "../util/posix.js";
|
|
3
|
+
export function buildGraph(opts) {
|
|
4
|
+
const componentsById = new Map();
|
|
5
|
+
const occurrencesByCompId = new Map();
|
|
6
|
+
const graph = {};
|
|
7
|
+
const filesWithUsage = new Set();
|
|
8
|
+
const warnings = [...(opts.extraWarnings ?? [])];
|
|
9
|
+
for (const r of opts.results) {
|
|
10
|
+
warnings.push(...r.warnings);
|
|
11
|
+
for (const occ of r.occurrences) {
|
|
12
|
+
const key = serialiseComponentId(occ.componentId);
|
|
13
|
+
const indexed = opts.index.byId.get(key);
|
|
14
|
+
filesWithUsage.add(occ.loc.file);
|
|
15
|
+
const outOcc = toOutputOccurrence(occ, opts.captureValues);
|
|
16
|
+
let bucket = occurrencesByCompId.get(key);
|
|
17
|
+
if (!bucket) {
|
|
18
|
+
bucket = [];
|
|
19
|
+
occurrencesByCompId.set(key, bucket);
|
|
20
|
+
}
|
|
21
|
+
bucket.push(outOcc);
|
|
22
|
+
if (!componentsById.has(key)) {
|
|
23
|
+
// Manifest-indexed components retain their full manifest metadata.
|
|
24
|
+
// For occurrences with no byId entry — opportunistic externals
|
|
25
|
+
// (Persona B), local-source identities (in-repo definitions), and
|
|
26
|
+
// unknown-source identities (unmapped hyphenated tags) — synthesise
|
|
27
|
+
// a minimal OutputComponent from the occurrence's componentId so the
|
|
28
|
+
// emission reaches the JSON output.
|
|
29
|
+
componentsById.set(key, indexed ? makeOutputComponent(indexed) : synthesiseOutputComponent(occ.componentId));
|
|
30
|
+
}
|
|
31
|
+
const fileKey = occ.loc.file;
|
|
32
|
+
let list = graph[fileKey];
|
|
33
|
+
if (!list) {
|
|
34
|
+
list = [];
|
|
35
|
+
graph[fileKey] = list;
|
|
36
|
+
}
|
|
37
|
+
if (!list.some((g) => serialiseComponentId(g) === key))
|
|
38
|
+
list.push(occ.componentId);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
for (const [key, occs] of occurrencesByCompId) {
|
|
42
|
+
const comp = componentsById.get(key);
|
|
43
|
+
if (!comp)
|
|
44
|
+
continue;
|
|
45
|
+
occs.sort(compareOccurrence);
|
|
46
|
+
comp.occurrences = occs;
|
|
47
|
+
}
|
|
48
|
+
const components = [...componentsById.values()].sort((a, b) => compareComponentId(componentIdOf(a), componentIdOf(b)));
|
|
49
|
+
const root = opts.repo.root;
|
|
50
|
+
for (const c of components)
|
|
51
|
+
for (const o of c.occurrences)
|
|
52
|
+
o.file = relativizePath(o.file, root);
|
|
53
|
+
const relativisedGraph = {};
|
|
54
|
+
for (const [file, entries] of Object.entries(graph)) {
|
|
55
|
+
relativisedGraph[relativizePath(file, root)] = entries;
|
|
56
|
+
}
|
|
57
|
+
for (const w of warnings) {
|
|
58
|
+
if ("file" in w && w.file)
|
|
59
|
+
w.file = relativizePath(w.file, root);
|
|
60
|
+
}
|
|
61
|
+
const repo = { name: opts.repo.name, root: opts.repo.root };
|
|
62
|
+
if (opts.repo.commit !== undefined)
|
|
63
|
+
repo.commit = opts.repo.commit;
|
|
64
|
+
const manifestsSorted = [...opts.manifests].sort((a, b) => a.package.localeCompare(b.package));
|
|
65
|
+
return {
|
|
66
|
+
envelope: opts.envelope,
|
|
67
|
+
components,
|
|
68
|
+
schemaVersion: "2.0.0",
|
|
69
|
+
scannedAt: new Date().toISOString(),
|
|
70
|
+
tool: opts.tool,
|
|
71
|
+
repo,
|
|
72
|
+
manifests: manifestsSorted,
|
|
73
|
+
stats: {
|
|
74
|
+
filesScanned: opts.filesScanned,
|
|
75
|
+
filesWithUsage: filesWithUsage.size,
|
|
76
|
+
scanDurationMs: opts.scanDurationMs,
|
|
77
|
+
componentsDetected: components.length,
|
|
78
|
+
totalOccurrences: components.reduce((n, c) => n + c.occurrences.length, 0),
|
|
79
|
+
},
|
|
80
|
+
graph: sortGraph(relativisedGraph),
|
|
81
|
+
warnings,
|
|
82
|
+
extensions: {},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function makeOutputComponent(indexed) {
|
|
86
|
+
if (indexed.kind === "custom-element") {
|
|
87
|
+
const out = {
|
|
88
|
+
kind: "custom-element",
|
|
89
|
+
tagName: indexed.tagName,
|
|
90
|
+
source: indexed.source,
|
|
91
|
+
deprecated: indexed.deprecated,
|
|
92
|
+
props: indexed.props,
|
|
93
|
+
occurrences: [],
|
|
94
|
+
extensions: {},
|
|
95
|
+
};
|
|
96
|
+
if (indexed.events && indexed.events.length > 0)
|
|
97
|
+
out.events = indexed.events;
|
|
98
|
+
if (indexed.slots && indexed.slots.length > 0)
|
|
99
|
+
out.slots = indexed.slots;
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
kind: indexed.kind,
|
|
104
|
+
source: indexed.source,
|
|
105
|
+
export: indexed.export,
|
|
106
|
+
deprecated: indexed.deprecated,
|
|
107
|
+
props: indexed.props,
|
|
108
|
+
occurrences: [],
|
|
109
|
+
extensions: {},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function synthesiseOutputComponent(id) {
|
|
113
|
+
if (id.kind === "custom-element") {
|
|
114
|
+
return {
|
|
115
|
+
kind: "custom-element",
|
|
116
|
+
tagName: id.tagName,
|
|
117
|
+
source: id.source,
|
|
118
|
+
deprecated: false,
|
|
119
|
+
props: [],
|
|
120
|
+
occurrences: [],
|
|
121
|
+
extensions: {},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
kind: id.kind,
|
|
126
|
+
source: id.source,
|
|
127
|
+
export: id.export,
|
|
128
|
+
deprecated: false,
|
|
129
|
+
props: [],
|
|
130
|
+
occurrences: [],
|
|
131
|
+
extensions: {},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function componentIdOf(c) {
|
|
135
|
+
if (c.kind === "custom-element")
|
|
136
|
+
return { kind: "custom-element", tagName: c.tagName, source: c.source };
|
|
137
|
+
return { kind: c.kind, export: c.export, source: c.source };
|
|
138
|
+
}
|
|
139
|
+
function toOutputOccurrence(occ, captureValues) {
|
|
140
|
+
const props = {};
|
|
141
|
+
for (const p of occ.props) {
|
|
142
|
+
if (captureValues && p.literalValue !== undefined && !p.isDynamic) {
|
|
143
|
+
props[p.name] = p.literalValue;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
props[p.name] = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const out = {
|
|
150
|
+
file: occ.loc.file,
|
|
151
|
+
line: occ.loc.line,
|
|
152
|
+
column: occ.loc.column,
|
|
153
|
+
via: occ.via,
|
|
154
|
+
props,
|
|
155
|
+
};
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
function compareOccurrence(a, b) {
|
|
159
|
+
if (a.file !== b.file)
|
|
160
|
+
return a.file.localeCompare(b.file);
|
|
161
|
+
if (a.line !== b.line)
|
|
162
|
+
return a.line - b.line;
|
|
163
|
+
return a.column - b.column;
|
|
164
|
+
}
|
|
165
|
+
function sortGraph(g) {
|
|
166
|
+
const keys = Object.keys(g).sort();
|
|
167
|
+
const out = {};
|
|
168
|
+
for (const k of keys) {
|
|
169
|
+
const arr = g[k];
|
|
170
|
+
if (!arr)
|
|
171
|
+
continue;
|
|
172
|
+
out[k] = [...arr].sort(compareComponentId);
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AAI,CAAC,GAAG;YAAE,SAAS;QACnB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/identity.d.ts
CHANGED
|
@@ -32,15 +32,3 @@ export type IdentityInputs = {
|
|
|
32
32
|
};
|
|
33
33
|
export declare function computeOutputIdentity(inputs: IdentityInputs): OutputIdentity;
|
|
34
34
|
export declare function computeStableId(identity: OutputIdentity): string;
|
|
35
|
-
/**
|
|
36
|
-
* Produce the same stable id as `computeStableId` from a raw `ComponentId`
|
|
37
|
-
* (as emitted by parsers), without needing to first build an `OutputIdentity`.
|
|
38
|
-
*
|
|
39
|
-
* This is used in `occurrences.ts` so that occurrence `componentId` fields
|
|
40
|
-
* hash-match the `id` values produced by `buildComponentSeeds` → `rollupOccurrencesToComponents`
|
|
41
|
-
* can correctly correlate occurrences to seeds.
|
|
42
|
-
*
|
|
43
|
-
* For local components, `repoId` is absent from the `ComponentId` source, so
|
|
44
|
-
* we use `""` — matching the `repoId: ""` convention in `buildComponentSeeds`.
|
|
45
|
-
*/
|
|
46
|
-
export declare function computeStableIdFromComponentId(c: ComponentId): string;
|
package/dist/identity.js
CHANGED
|
@@ -64,29 +64,4 @@ export function computeStableId(identity) {
|
|
|
64
64
|
}
|
|
65
65
|
return sha1Short(`rc::${identity.packageName}::${identity.exportName}`);
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Produce the same stable id as `computeStableId` from a raw `ComponentId`
|
|
69
|
-
* (as emitted by parsers), without needing to first build an `OutputIdentity`.
|
|
70
|
-
*
|
|
71
|
-
* This is used in `occurrences.ts` so that occurrence `componentId` fields
|
|
72
|
-
* hash-match the `id` values produced by `buildComponentSeeds` → `rollupOccurrencesToComponents`
|
|
73
|
-
* can correctly correlate occurrences to seeds.
|
|
74
|
-
*
|
|
75
|
-
* For local components, `repoId` is absent from the `ComponentId` source, so
|
|
76
|
-
* we use `""` — matching the `repoId: ""` convention in `buildComponentSeeds`.
|
|
77
|
-
*/
|
|
78
|
-
export function computeStableIdFromComponentId(c) {
|
|
79
|
-
if (c.source.type === "local") {
|
|
80
|
-
const exportOrTag = c.kind === "custom-element" ? c.tagName : c.export;
|
|
81
|
-
// repoId is not carried on ComponentId.source; use "" to match the
|
|
82
|
-
// repoId: "" convention in buildComponentSeeds (seeds for local
|
|
83
|
-
// components are keyed the same way).
|
|
84
|
-
return sha1Short(`local::::${c.source.filePath}::${exportOrTag}::${c.kind}`);
|
|
85
|
-
}
|
|
86
|
-
const pkg = c.source.type === "external" ? c.source.package : "unknown";
|
|
87
|
-
if (c.kind === "custom-element") {
|
|
88
|
-
return sha1Short(`ce::${pkg}::${c.tagName}`);
|
|
89
|
-
}
|
|
90
|
-
return sha1Short(`rc::${pkg}::${c.export}`);
|
|
91
|
-
}
|
|
92
67
|
//# sourceMappingURL=identity.js.map
|
package/dist/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAczC,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IAC1D,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACzD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;IACxC,MAAM,KAAK,GAA4B,OAAO;QAC5C,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,UAAU,CAAC;IAEjB,MAAM,QAAQ,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,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACtC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,CAAS,EAAU,EAAE,CACtC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE1D,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,IAAI,QAAQ,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QAC/B,OAAO,SAAS,CACd,UAAU,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,IAAI,EAAE,CAC5F,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC,OAAO,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/reporter/index.d.ts
CHANGED
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* It does no IO; downstream JSON / stdout reporters consume the result.
|
|
9
9
|
*/
|
|
10
|
-
import type { ManifestComponent,
|
|
10
|
+
import type { ManifestComponent, OutputManifest, OutputOccurrence, ScanEnvelope, ScanOutput } from "@component-compass/plugin-core";
|
|
11
11
|
import { type ComponentSeed } from "../rollup.js";
|
|
12
|
-
export
|
|
13
|
-
export declare function buildScanOutput(envelope: ScanEnvelope, manifests: ManifestRef[], partialStats: PartialScanStats, seeds: ComponentSeed[], occurrences: OutputOccurrence[]): ScanOutput;
|
|
12
|
+
export declare function buildScanOutput(envelope: ScanEnvelope, seeds: ComponentSeed[], occurrences: OutputOccurrence[]): ScanOutput;
|
|
14
13
|
/**
|
|
15
14
|
* Pure converter: project a rich `ManifestComponent` (plugin-core domain
|
|
16
15
|
* model) onto the artifact-shape `OutputManifest` consumed by the JSON
|
package/dist/reporter/index.js
CHANGED
|
@@ -8,18 +8,10 @@
|
|
|
8
8
|
* It does no IO; downstream JSON / stdout reporters consume the result.
|
|
9
9
|
*/
|
|
10
10
|
import { rollupOccurrencesToComponents } from "../rollup.js";
|
|
11
|
-
export function buildScanOutput(envelope,
|
|
12
|
-
const components = rollupOccurrencesToComponents(occurrences, seeds);
|
|
13
|
-
const stats = {
|
|
14
|
-
...partialStats,
|
|
15
|
-
componentsDetected: components.length,
|
|
16
|
-
totalOccurrences: occurrences.length,
|
|
17
|
-
};
|
|
11
|
+
export function buildScanOutput(envelope, seeds, occurrences) {
|
|
18
12
|
return {
|
|
19
13
|
envelope,
|
|
20
|
-
|
|
21
|
-
stats,
|
|
22
|
-
components,
|
|
14
|
+
components: rollupOccurrencesToComponents(occurrences, seeds),
|
|
23
15
|
occurrences,
|
|
24
16
|
};
|
|
25
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reporter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,EAAE,6BAA6B,EAAsB,MAAM,cAAc,CAAC;AAEjF,MAAM,UAAU,eAAe,CAC7B,QAAsB,EACtB,KAAsB,EACtB,WAA+B;IAE/B,OAAO;QACL,QAAQ;QACR,UAAU,EAAE,6BAA6B,CAAC,WAAW,EAAE,KAAK,CAAC;QAC7D,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"}
|
package/dist/reporter/json.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import type {
|
|
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>;
|
|
1
|
+
import type { OutputDocument } from "./types.js";
|
|
2
|
+
export declare function writeJson(doc: OutputDocument, path: string): Promise<void>;
|
package/dist/reporter/json.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { writeFile, mkdir } from "node:fs/promises";
|
|
2
2
|
import { dirname } from "node:path";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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");
|
|
3
|
+
export async function writeJson(doc, path) {
|
|
4
|
+
await mkdir(dirname(path), { recursive: true });
|
|
5
|
+
await writeFile(path, JSON.stringify(doc, null, 2), "utf8");
|
|
10
6
|
}
|
|
11
7
|
//# sourceMappingURL=json.js.map
|
|
@@ -1 +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
|
|
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,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAmB,EAAE,IAAY;IAC/D,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function printSummary(
|
|
1
|
+
import type { OutputDocument } from "./types.js";
|
|
2
|
+
export declare function printSummary(doc: OutputDocument, outputPath: string): void;
|
package/dist/reporter/stdout.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export function printSummary(
|
|
2
|
-
const { envelope, components,
|
|
1
|
+
export function printSummary(doc, outputPath) {
|
|
2
|
+
const { envelope, stats, components, warnings } = doc;
|
|
3
3
|
const lines = [];
|
|
4
4
|
lines.push("");
|
|
5
5
|
lines.push("component-compass scan");
|
|
6
6
|
lines.push("──────────────────────");
|
|
7
7
|
lines.push(`scanId: ${envelope.scanId}`);
|
|
8
8
|
lines.push(`repoId: ${envelope.repoId}`);
|
|
9
|
+
lines.push(`commit: ${envelope.commitSha ?? "(none)"}`);
|
|
10
|
+
lines.push(`branch: ${envelope.branch ?? "(none)"}`);
|
|
9
11
|
lines.push(`timestamp: ${envelope.timestamp}`);
|
|
10
12
|
lines.push("");
|
|
11
13
|
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
14
|
lines.push("");
|
|
15
15
|
const sorted = [...components]
|
|
16
|
-
.sort((a, b) => b.
|
|
16
|
+
.sort((a, b) => b.occurrences.length - a.occurrences.length)
|
|
17
17
|
.slice(0, 5);
|
|
18
18
|
if (sorted.length > 0) {
|
|
19
19
|
lines.push("Top by usage:");
|
|
@@ -22,19 +22,31 @@ export function printSummary(out, outputPath) {
|
|
|
22
22
|
for (const [i, c] of sorted.entries()) {
|
|
23
23
|
const label = labels[i] ?? "";
|
|
24
24
|
const pad = " ".repeat(widest - label.length + 2);
|
|
25
|
-
lines.push(` ${label}${pad}${c.
|
|
25
|
+
lines.push(` ${label}${pad}${c.occurrences.length} [${c.kind}]`);
|
|
26
26
|
}
|
|
27
27
|
lines.push("");
|
|
28
28
|
}
|
|
29
|
+
if (warnings.length > 0) {
|
|
30
|
+
const grouped = new Map();
|
|
31
|
+
for (const w of warnings)
|
|
32
|
+
grouped.set(w.code, (grouped.get(w.code) ?? 0) + 1);
|
|
33
|
+
lines.push(`⚠ ${warnings.length} warnings (see component-compass.json#/warnings)`);
|
|
34
|
+
for (const [code, count] of grouped)
|
|
35
|
+
lines.push(` - ${code} × ${count}`);
|
|
36
|
+
lines.push("");
|
|
37
|
+
}
|
|
29
38
|
lines.push(`→ ${outputPath}`);
|
|
30
39
|
lines.push("");
|
|
31
40
|
process.stdout.write(lines.join("\n"));
|
|
32
41
|
}
|
|
33
42
|
function componentLabel(c) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
if (c.kind === "custom-element")
|
|
44
|
+
return c.tagName;
|
|
45
|
+
const sourceLabel = c.source.type === "external"
|
|
46
|
+
? c.source.package
|
|
47
|
+
: c.source.type === "local"
|
|
48
|
+
? c.source.filePath
|
|
49
|
+
: "(unknown)";
|
|
50
|
+
return `${sourceLabel}::${c.export}`;
|
|
39
51
|
}
|
|
40
52
|
//# sourceMappingURL=stdout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdout.js","sourceRoot":"","sources":["../../src/reporter/stdout.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"stdout.js","sourceRoot":"","sources":["../../src/reporter/stdout.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAmB,EAAE,UAAkB;IAClE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;IACtD,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,QAAQ,CAAC,SAAS,IAAI,QAAQ,EAAE,CAAC,CAAC;IAC3D,KAAK,CAAC,IAAI,CAAC,cAAc,QAAQ,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,CAAC,cAAc,QAAQ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AAG,WAAW,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ComponentId, ComponentSource, ManifestProp, ManifestEvent, ManifestSlot, ScanEnvelope } from "@component-compass/plugin-core";
|
|
2
|
+
import type { OccurrenceVia } from "@component-compass/plugin-core";
|
|
3
|
+
import type { Warning } from "../types.js";
|
|
4
|
+
export type OutputManifestRef = {
|
|
5
|
+
source: "cem" | "react" | "vue";
|
|
6
|
+
package: string;
|
|
7
|
+
path: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
};
|
|
10
|
+
export type OutputOccurrence = {
|
|
11
|
+
file: string;
|
|
12
|
+
line: number;
|
|
13
|
+
column: number;
|
|
14
|
+
via: OccurrenceVia;
|
|
15
|
+
props: Record<string, string | number | boolean | null>;
|
|
16
|
+
};
|
|
17
|
+
type ComponentBase = {
|
|
18
|
+
source: ComponentSource;
|
|
19
|
+
deprecated: boolean | string;
|
|
20
|
+
props: ManifestProp[];
|
|
21
|
+
occurrences: OutputOccurrence[];
|
|
22
|
+
extensions: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export type OutputComponent = (ComponentBase & {
|
|
25
|
+
kind: "custom-element";
|
|
26
|
+
tagName: string;
|
|
27
|
+
events?: ManifestEvent[];
|
|
28
|
+
slots?: ManifestSlot[];
|
|
29
|
+
cssParts?: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
}>;
|
|
32
|
+
cssProperties?: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
}>;
|
|
35
|
+
}) | (ComponentBase & {
|
|
36
|
+
kind: "react-component";
|
|
37
|
+
export: string;
|
|
38
|
+
}) | (ComponentBase & {
|
|
39
|
+
kind: "vue-component";
|
|
40
|
+
export: string;
|
|
41
|
+
});
|
|
42
|
+
export type GraphEntry = ComponentId;
|
|
43
|
+
export type OutputDocument = {
|
|
44
|
+
envelope: ScanEnvelope;
|
|
45
|
+
components: OutputComponent[];
|
|
46
|
+
schemaVersion: "2.0.0";
|
|
47
|
+
scannedAt: string;
|
|
48
|
+
tool: {
|
|
49
|
+
name: string;
|
|
50
|
+
version: string;
|
|
51
|
+
};
|
|
52
|
+
repo: {
|
|
53
|
+
name: string;
|
|
54
|
+
root: string;
|
|
55
|
+
commit?: string;
|
|
56
|
+
};
|
|
57
|
+
manifests: OutputManifestRef[];
|
|
58
|
+
stats: {
|
|
59
|
+
filesScanned: number;
|
|
60
|
+
filesWithUsage: number;
|
|
61
|
+
scanDurationMs: number;
|
|
62
|
+
componentsDetected: number;
|
|
63
|
+
totalOccurrences: number;
|
|
64
|
+
};
|
|
65
|
+
graph: Record<string, GraphEntry[]>;
|
|
66
|
+
warnings: Warning[];
|
|
67
|
+
extensions: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/reporter/types.ts"],"names":[],"mappings":""}
|
package/dist/rollup.js
CHANGED
package/dist/rollup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../src/rollup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAqBH,MAAM,gBAAgB,GAAG,CAAC,CAAmB,EAAU,EAAE,CACvD,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAElC,MAAM,SAAS,GAAG,CAAC,CAAiB,EAAmC,EAAE,CACvE,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,WAAW,IAAI,CAAC,CAAC;AAE1D,MAAM,SAAS,GAAG,GAAqB,EAAE,CAAC,CAAC;IACzC,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,cAAc,EAAE,CAAC;CAClB,CAAC,CAAC;AA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,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;YACL,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;SACvC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@component-compass/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
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",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
|
-
"compass": "dist/cli.js",
|
|
11
|
-
"component-compass": "dist/cli.js"
|
|
10
|
+
"compass": "./dist/cli.js",
|
|
11
|
+
"component-compass": "./dist/cli.js"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
@@ -35,12 +35,12 @@
|
|
|
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/parser-html": "0.0.
|
|
40
|
-
"@component-compass/parser-lit": "0.0.
|
|
41
|
-
"@component-compass/parser-react": "0.0.
|
|
42
|
-
"@component-compass/parser-vue": "0.0.
|
|
43
|
-
"@component-compass/plugin-core": "0.0.
|
|
38
|
+
"@component-compass/ast-utils": "^0.0.1",
|
|
39
|
+
"@component-compass/parser-html": "^0.0.1",
|
|
40
|
+
"@component-compass/parser-lit": "^0.0.1",
|
|
41
|
+
"@component-compass/parser-react": "^0.0.1",
|
|
42
|
+
"@component-compass/parser-vue": "^0.0.1",
|
|
43
|
+
"@component-compass/plugin-core": "^0.0.1",
|
|
44
44
|
"@vue/compiler-sfc": "^3.5.33",
|
|
45
45
|
"ajv": "^8.20.0",
|
|
46
46
|
"glob": "^13.0.0",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"repoId": { "type": "string", "minLength": 1 },
|
|
11
11
|
"packageScopes": {
|
|
12
12
|
"type": "array",
|
|
13
|
-
"items": { "type": "string", "minLength": 1 }
|
|
13
|
+
"items": { "type": "string", "minLength": 1 },
|
|
14
|
+
"minItems": 1
|
|
14
15
|
},
|
|
15
16
|
"manifestSources": {
|
|
16
17
|
"type": "object",
|
package/dist/occurrences.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project parser-emitted occurrences onto the artifact-shape OutputOccurrence
|
|
3
|
-
* stream, preserving the three-state attribute model:
|
|
4
|
-
* - literal value (when captureValues is true and source value was static),
|
|
5
|
-
* - { __dynamic: DynamicKind } marker (always, when source was non-literal),
|
|
6
|
-
* - null (when captureValues is false and source was static, OR when source
|
|
7
|
-
* value was literal null).
|
|
8
|
-
*
|
|
9
|
-
* Pure function; no I/O.
|
|
10
|
-
*/
|
|
11
|
-
import type { OutputOccurrence, ParseResult } from "@component-compass/plugin-core";
|
|
12
|
-
export declare function parseResultsToOccurrences(results: ParseResult[], captureValues: boolean): OutputOccurrence[];
|
package/dist/occurrences.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project parser-emitted occurrences onto the artifact-shape OutputOccurrence
|
|
3
|
-
* stream, preserving the three-state attribute model:
|
|
4
|
-
* - literal value (when captureValues is true and source value was static),
|
|
5
|
-
* - { __dynamic: DynamicKind } marker (always, when source was non-literal),
|
|
6
|
-
* - null (when captureValues is false and source was static, OR when source
|
|
7
|
-
* value was literal null).
|
|
8
|
-
*
|
|
9
|
-
* Pure function; no I/O.
|
|
10
|
-
*/
|
|
11
|
-
import { computeStableIdFromComponentId } from "./identity.js";
|
|
12
|
-
export function parseResultsToOccurrences(results, captureValues) {
|
|
13
|
-
const out = [];
|
|
14
|
-
for (const result of results) {
|
|
15
|
-
for (const occ of result.occurrences) {
|
|
16
|
-
const props = {};
|
|
17
|
-
for (const p of occ.props) {
|
|
18
|
-
if (p.isDynamic) {
|
|
19
|
-
// dynamicKind should always be set when isDynamic is true (per
|
|
20
|
-
// scan-types.ts), but defend against malformed parser output.
|
|
21
|
-
props[p.name] = { __dynamic: p.dynamicKind ?? "expr" };
|
|
22
|
-
}
|
|
23
|
-
else if (captureValues && p.literalValue !== undefined) {
|
|
24
|
-
props[p.name] = p.literalValue;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
props[p.name] = null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
out.push({
|
|
31
|
-
componentId: computeStableIdFromComponentId(occ.componentId),
|
|
32
|
-
filePath: occ.loc.file,
|
|
33
|
-
line: occ.loc.line,
|
|
34
|
-
column: occ.loc.column,
|
|
35
|
-
via: occ.via,
|
|
36
|
-
props,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return out;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=occurrences.js.map
|
package/dist/occurrences.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"occurrences.js","sourceRoot":"","sources":["../src/occurrences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAE/D,MAAM,UAAU,yBAAyB,CACvC,OAAsB,EACtB,aAAsB;IAEtB,MAAM,GAAG,GAAuB,EAAE,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,KAAK,GAAmC,EAAE,CAAC;YACjD,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;gBAC1B,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;oBAChB,+DAA+D;oBAC/D,8DAA8D;oBAC9D,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,WAAW,IAAI,MAAM,EAAE,CAAC;gBACzD,CAAC;qBAAM,IAAI,aAAa,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;oBACzD,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC;gBACjC,CAAC;qBAAM,CAAC;oBACN,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;gBACvB,CAAC;YACH,CAAC;YACD,GAAG,CAAC,IAAI,CAAC;gBACP,WAAW,EAAE,8BAA8B,CAAC,GAAG,CAAC,WAAW,CAAC;gBAC5D,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI;gBACtB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI;gBAClB,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM;gBACtB,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,KAAK;aACN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/seeds.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
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
|
package/dist/seeds.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAChE,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AAIvB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAqB,EACrB,YAA2B,EAC3B,QAA+B;IAE/B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEnD,gEAAgE;IAChE,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,WAAW,GACf,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QACjE,MAAM,WAAW,GAAG,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAE9B,MAAM,QAAQ,GAAG,qBAAqB,CAAC;YACrC,WAAW;YAC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