@bridge-ds/core 0.19.0 → 0.20.0
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/LICENSE +17 -0
- package/bridge.config.schema.json +5 -0
- package/dist/audit/index.js +3 -3
- package/dist/config.d.ts +5 -0
- package/dist/fidelity.d.ts +12 -1
- package/dist/figma-fix-run.d.ts +103 -0
- package/dist/gap-case.d.ts +1 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +741 -317
- package/dist/index.js.map +1 -1
- package/dist/measure-location.d.ts +42 -0
- package/dist/measure-workflow.d.ts +48 -0
- package/dist/measured-only.d.ts +2 -0
- package/dist/node/index.js +11 -8
- package/dist/node/index.js.map +1 -1
- package/dist/{prod-branch-Bdx_2bRQ.js → prod-branch-CJZwMfVD.js} +61 -59
- package/dist/prod-branch-CJZwMfVD.js.map +1 -0
- package/dist/repo-model.d.ts +2 -0
- package/dist/{repo-source-m0Tc603o.js → repo-source-CshjjC7x.js} +323 -244
- package/dist/repo-source-CshjjC7x.js.map +1 -0
- package/dist/{report-DFPKygfk.js → report-CE-jHAuw.js} +2 -2
- package/dist/{report-DFPKygfk.js.map → report-CE-jHAuw.js.map} +1 -1
- package/dist/review-gate.d.ts +6 -0
- package/dist/suggestion-review.d.ts +43 -2
- package/dist/suggestions-github.d.ts +12 -1
- package/dist/tier1-publish.d.ts +48 -0
- package/package.json +1 -1
- package/dist/prod-branch-Bdx_2bRQ.js.map +0 -1
- package/dist/repo-source-m0Tc603o.js.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** The data branch the automatic measure publishes to: the requests branch the plugin already writes to. */
|
|
2
|
+
export declare const MEASURE_BRANCH = "bridge-requests";
|
|
3
|
+
/** The story shots folder `bridge specs --measure --shots` writes next to measured-specs.json. */
|
|
4
|
+
export declare const MEASURED_SHOTS_DIR = "measured-shots";
|
|
5
|
+
/** The workflow that keeps the measure fresh, in the team's repo. */
|
|
6
|
+
export declare const MEASURE_WORKFLOW_FILE = ".github/workflows/bridge-measure.yml";
|
|
7
|
+
/** The one action that turns the measure on, as Studio and the plugin name it. */
|
|
8
|
+
export declare const MEASURE_SETUP_ACTION = "Set up automatic measure";
|
|
9
|
+
/** What a designer reads when there is no measure yet: calm, and the next step. */
|
|
10
|
+
export declare const MEASURE_MISSING_TEXT = "Bridge hasn't measured your components yet. A developer turns it on once: Set up automatic measure.";
|
|
11
|
+
/** How a developer turns it on, in lines (the copied request, the MCP tools, the CLI). */
|
|
12
|
+
export declare function measureSetupSteps(repo?: string): string[];
|
|
13
|
+
/** Where a measure was found: the repo at the ref read, or the measure branch. */
|
|
14
|
+
export interface FoundMeasure {
|
|
15
|
+
text: string;
|
|
16
|
+
/** Its path, the same in both places. */
|
|
17
|
+
path: string;
|
|
18
|
+
/** Undefined: the repo (at the ref the reader works on); else the branch it came from. */
|
|
19
|
+
branch?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Reads one file: from the repo at the reader's ref, or from a named branch. Undefined when it is not there. */
|
|
22
|
+
export interface MeasureFiles {
|
|
23
|
+
repo(path: string): Promise<string | null | undefined>;
|
|
24
|
+
/** Undefined when the reader cannot reach GitHub (local, no token): only the repo is read then. */
|
|
25
|
+
branch?: ((path: string, branch: string) => Promise<string | null | undefined>) | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The measure, where the readers agree it lives: `path` in the repo first (a measure committed on purpose), else on
|
|
29
|
+
* the measure branch (the automatic measure). Undefined when neither has it. A branch read that fails (no access, the
|
|
30
|
+
* network) counts as not there: the caller then says the measure is missing, calmly.
|
|
31
|
+
*/
|
|
32
|
+
export declare function findMeasure(files: MeasureFiles, path?: string): Promise<FoundMeasure | undefined>;
|
|
33
|
+
/** "measured-specs.json" or "measured-specs.json on bridge-requests". */
|
|
34
|
+
export declare const measureFromWords: (m: Pick<FoundMeasure, "path" | "branch">) => string;
|
|
35
|
+
/** The folder a measure's shot paths are relative to: the folder of measured-specs.json ('' at the root). */
|
|
36
|
+
export declare const measureDir: (path: string) => string;
|
|
37
|
+
/** Thrown by readers when there is no measure: the message is the designer sentence, the steps follow for a developer. */
|
|
38
|
+
export declare class MeasureMissingError extends Error {
|
|
39
|
+
readonly code = "measure-missing";
|
|
40
|
+
readonly steps: string[];
|
|
41
|
+
constructor(repo?: string, extra?: string[]);
|
|
42
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** The published CLI the template runs: the first version with every measure flag the workflow passes. */
|
|
2
|
+
export declare const MEASURE_CLI_PACKAGE = "@bridge-ds/cli@^0.13.0";
|
|
3
|
+
/** What the measure reads in each story: every variant, in these states, the variables, a shot of each. */
|
|
4
|
+
export declare const MEASURE_FLAGS = "--variants --states rest,hover,active,disabled --tokens --shots --check";
|
|
5
|
+
/** Files whose change can change what the Storybook draws, when nothing more precise is known. */
|
|
6
|
+
export declare const MEASURE_DEFAULT_PATHS: string[];
|
|
7
|
+
export interface MeasureWorkflowOptions {
|
|
8
|
+
/** The default branch (bridge.config.json repo.defaultBranch). Default main. */
|
|
9
|
+
defaultBranch?: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The deployed Storybook (bridge.config.json previews.production.storybook). Set: the workflow measures it once a
|
|
12
|
+
* deploy of it succeeds. Empty: it builds Storybook in the run and measures that build (any Storybook, private ones too).
|
|
13
|
+
*/
|
|
14
|
+
storybookUrl?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Deployed Storybook only: a word of the deploy's status or environment name ("Vercel – bridge-storybook"), so the
|
|
17
|
+
* measure follows the Storybook deploy, not another app's. Default "storybook".
|
|
18
|
+
*/
|
|
19
|
+
deployName?: string | undefined;
|
|
20
|
+
/** Install command. Default `npm ci`. */
|
|
21
|
+
install?: string | undefined;
|
|
22
|
+
/** Built Storybook only: the build command and its output folder. Default `npm run build-storybook`, storybook-static. */
|
|
23
|
+
buildCommand?: string | undefined;
|
|
24
|
+
storybookDir?: string | undefined;
|
|
25
|
+
/** What changes the Storybook (a push touching these measures again). Default MEASURE_DEFAULT_PATHS. */
|
|
26
|
+
paths?: readonly string[] | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The CLI command. Default `npx --yes <MEASURE_CLI_PACKAGE>`. This repository runs its own build
|
|
29
|
+
* (`node packages/cli/dist/index.js`), with `prepare` building it.
|
|
30
|
+
*/
|
|
31
|
+
cli?: string | undefined;
|
|
32
|
+
/** Commands run after the install, before the measure (this repository builds the CLI). */
|
|
33
|
+
prepare?: string | undefined;
|
|
34
|
+
/** Node: a version, or `file:<path>` for node-version-file. Default 20. */
|
|
35
|
+
node?: string | undefined;
|
|
36
|
+
/** The header comment. Default: the template's, for teams. */
|
|
37
|
+
header?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The options a team's bridge.config.json gives (parsed JSON, any shape): its default branch, its deployed Storybook
|
|
41
|
+
* (previews.production.storybook) and what changes the Storybook (the folder of its components, its tokens, the
|
|
42
|
+
* Storybook config). Missing parts are left to the defaults.
|
|
43
|
+
*/
|
|
44
|
+
export declare function measureWorkflowOptionsFromConfig(config: unknown): MeasureWorkflowOptions;
|
|
45
|
+
/** The comment teams read at the top of the file: what it does, when, with which token, and the optional secret. */
|
|
46
|
+
export declare const MEASURE_WORKFLOW_HEADER = "# Bridge measure: keeps the measure of your components fresh, so Claude can fix what differs in Figma.\n# Copy it to .github/workflows/bridge-measure.yml in your design system repository, or let Bridge add it: Studio, Settings,\n# For developers, Set up automatic measure (a pull request), or `npx @bridge-ds/cli measure setup`.\n#\n# It measures what your Storybook really draws (`bridge specs --measure`, headless Chrome): every variant at rest, on\n# hover, pressed and disabled, the CSS variables behind each value, and a screenshot of each. It publishes\n# measured-specs.json and measured-shots/ to the `bridge-requests` branch, next to figma-fidelity.json (the Figma plugin's\n# Compare with code). The Claude fix tools, the Figma plugin (\"Ask Claude to fix it\") and Studio read it there.\n# It commits only when the measure changed.\n#\n# When: after each deploy of your Storybook (deployed Storybook), or on each push to the default branch that changes it\n# (built here), every Monday as a fallback, and by hand (Actions, Bridge measure, Run workflow).\n#\n# Token: only the GITHUB_TOKEN of this run, with `contents: write` to push the `bridge-requests` branch. Your\n# default branch is never written. No secret to add.\n# A Storybook behind a login: set it up without an address (`npx @bridge-ds/cli measure setup --build`), the run then\n# builds Storybook itself. If installing needs a private registry, add an NPM_TOKEN repository secret (optional); the\n# install step passes it as NODE_AUTH_TOKEN.\n# Docs: https://bridge.floriangouloubi.com/docs/automatic-measure/";
|
|
47
|
+
/** The workflow YAML. */
|
|
48
|
+
export declare function measureWorkflowYaml(o?: MeasureWorkflowOptions): string;
|
package/dist/measured-only.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export type MeasuredShots = Record<string, Record<string, VariantShot>>;
|
|
|
20
20
|
/** Every set the measure can give, by component (the last segment of a story's title: "Figma variants/Radio" is Radio). */
|
|
21
21
|
export declare function specsFromMeasure(file: MeasuredSpecsFile | FixedMeasuredSpecsFile, opts?: {
|
|
22
22
|
known?: ((path: string) => boolean) | undefined;
|
|
23
|
+
/** One set only (its name, compared like the fix tools compare it): what one component's gap case needs. */
|
|
24
|
+
only?: string | undefined;
|
|
23
25
|
}): {
|
|
24
26
|
specs: ComponentSpecsFile;
|
|
25
27
|
report: MeasuredOnlyReport;
|
package/dist/node/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import { execFile, execFileSync } from "node:child_process";
|
|
|
2
2
|
import { mkdtemp, rm, mkdir, writeFile, lstat, readFile } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join, resolve, relative, dirname, sep, posix } from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
import { aV, C,
|
|
7
|
-
import { K as selectTokenFiles,
|
|
5
|
+
import { bp as assertSafeBranch, c as collectHistory, p as packageDirCandidates, a as parseChangelog, m as mergeReleases, r as releasesFromTags, b as buildReport, di as prNumberFromSubject, dI as specHash, ef as validateComponentSpec, K as hashSpec, cp as iconComponentName, F as variantKeyOf, e9 as tokenCssVar, aG as COMPONENT_SPECS_VERSION, J as COLOR_FIELDS, dQ as suggestionAppliedComment, a2 as gitBlobSha, dg as planSuggestionApply, aq as normalizeRepoPath, dF as sharedTokenPrefix, ec as tokenVariablePath, ep as withSrgbColors, dL as storybookIframeUrl, c_ as parseBoxShadow } from "../repo-source-CshjjC7x.js";
|
|
6
|
+
import { aV, C, c6, cL, I, d1, H } from "../repo-source-CshjjC7x.js";
|
|
7
|
+
import { K as selectTokenFiles, ah as globToRegExp, N as loadConfig, L as LayeredTokenSet, V as CONFIG_FILE, a0 as layoutOptions, a1 as buildTokenSet, b9 as defaultContext, B as resolve$1, af as slugify, c2 as protectedBranchesOf, _ as baseBranchOf } from "../prod-branch-CJZwMfVD.js";
|
|
8
8
|
import { statSync, readFileSync, existsSync, writeFileSync, readdirSync } from "node:fs";
|
|
9
|
-
import { i as isAuditable, Q as planCssFixes, O as parseAllowlist, d as DesignSystemIndex, l as buildAuditReport, o as compareWithBaseline, b as AUDIT_IGNORE_DIRS } from "../report-
|
|
9
|
+
import { i as isAuditable, Q as planCssFixes, O as parseAllowlist, d as DesignSystemIndex, l as buildAuditReport, o as compareWithBaseline, b as AUDIT_IGNORE_DIRS } from "../report-CE-jHAuw.js";
|
|
10
10
|
import ts from "typescript";
|
|
11
11
|
function git(root, args, opts = {}) {
|
|
12
12
|
return new Promise((resolve2, reject) => {
|
|
@@ -5183,7 +5183,10 @@ function measuredToSpec(m, o = {}) {
|
|
|
5183
5183
|
if (!m.root) return out;
|
|
5184
5184
|
const used = /* @__PURE__ */ new Set();
|
|
5185
5185
|
const idFor = (n, isRoot, inherited) => {
|
|
5186
|
-
if (isRoot)
|
|
5186
|
+
if (isRoot) {
|
|
5187
|
+
used.add("root");
|
|
5188
|
+
return "root";
|
|
5189
|
+
}
|
|
5187
5190
|
const cls = (n.classes ?? []).map(localClassName).find((c) => /^[A-Za-z]/.test(c) && c.length < 40 && !isUtilityClass(c));
|
|
5188
5191
|
let base = cls ?? (n.pseudo ? `${inherited ?? "root"}-${n.pseudo}` : n.kind === "text" ? inherited ? `${inherited}-text` : "text" : n.kind === "icon" ? "icon" : n.tag);
|
|
5189
5192
|
base = base.replace(/[^A-Za-z0-9-]+/g, "-").toLowerCase() || "part";
|
|
@@ -5458,7 +5461,7 @@ export {
|
|
|
5458
5461
|
draftedCodeHash,
|
|
5459
5462
|
draftedSpec,
|
|
5460
5463
|
entryFor,
|
|
5461
|
-
|
|
5464
|
+
c6 as evalCalc,
|
|
5462
5465
|
expandDecl,
|
|
5463
5466
|
fileDiff,
|
|
5464
5467
|
findDesignSystemRoot,
|
|
@@ -5485,7 +5488,7 @@ export {
|
|
|
5485
5488
|
localRepoRef,
|
|
5486
5489
|
localTags,
|
|
5487
5490
|
markMeasuredRoot,
|
|
5488
|
-
|
|
5491
|
+
cL as markUsedTokens,
|
|
5489
5492
|
matchComplex,
|
|
5490
5493
|
measureRendered,
|
|
5491
5494
|
measureStory,
|
|
@@ -5499,7 +5502,7 @@ export {
|
|
|
5499
5502
|
overridesDirOf,
|
|
5500
5503
|
I as pairParts,
|
|
5501
5504
|
parseCssModule,
|
|
5502
|
-
|
|
5505
|
+
d1 as parseMeasuredSpecsFile,
|
|
5503
5506
|
parseSelector,
|
|
5504
5507
|
parseTransitions,
|
|
5505
5508
|
pickStoriesToMeasure,
|