@bridge-ds/visual 0.3.18 → 0.3.20
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/index.js +28 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ var DEFAULT_PRODUCTS = [
|
|
|
82
82
|
];
|
|
83
83
|
var KEY = /^[a-z0-9][a-z0-9-]*$/;
|
|
84
84
|
var REPO = /^[\w.-]+\/[\w.-]+$/;
|
|
85
|
-
var FIELDS = ["key", "name", "repo", "path", "preview", "production", "framework", "default"];
|
|
85
|
+
var FIELDS = ["key", "name", "repo", "design", "path", "preview", "production", "framework", "default"];
|
|
86
86
|
function productProblems(raw) {
|
|
87
87
|
if (raw === void 0) return [];
|
|
88
88
|
if (!Array.isArray(raw)) return ['"products" must be a list of { "key", "name" } objects'];
|
|
@@ -103,6 +103,17 @@ function productProblems(raw) {
|
|
|
103
103
|
else seen.add(o.key);
|
|
104
104
|
if (typeof o.name !== "string" || !o.name.trim()) problems.push(`${at}.name" must be the name people read, such as "Admin demo"`);
|
|
105
105
|
if (o.repo !== void 0 && (typeof o.repo !== "string" || !REPO.test(o.repo))) problems.push(`${at}.repo" must be "owner/name"`);
|
|
106
|
+
if (o.design !== void 0) {
|
|
107
|
+
const d = o.design;
|
|
108
|
+
if (!d || typeof d !== "object" || Array.isArray(d) || typeof d.repo !== "string" || !REPO.test(d.repo)) {
|
|
109
|
+
problems.push(`${at}.design" must be { "repo": "owner/name" }: the design team's copy of the product's repository`);
|
|
110
|
+
} else {
|
|
111
|
+
for (const k of Object.keys(d)) if (k !== "repo" && k !== "preview") problems.push(`${at}.design.${k}" is not a known field (repo, preview)`);
|
|
112
|
+
if (d.preview !== void 0 && (typeof d.preview !== "string" || !/^https?:\/\//.test(d.preview))) problems.push(`${at}.design.preview" must be an http(s) URL template, such as "https://shop-design-git-{branch}.vercel.app"`);
|
|
113
|
+
if (typeof o.repo !== "string") problems.push(`${at}.design" needs "repo" too: the copy is of the product's own repository`);
|
|
114
|
+
else if (d.repo.toLowerCase() === o.repo.toLowerCase()) problems.push(`${at}.design.repo" must be another repository than "repo": the design team's copy, not the developers' repository`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
106
117
|
if (o.path !== void 0) {
|
|
107
118
|
const bad = typeof o.path !== "string" || !o.path.trim() || o.path.startsWith("/") || o.path.split("/").includes("..");
|
|
108
119
|
if (bad) problems.push(`${at}.path" must be a folder relative to the repository root, without a leading "/" or "..", such as "apps/admin"`);
|
|
@@ -117,6 +128,20 @@ function productProblems(raw) {
|
|
|
117
128
|
return problems;
|
|
118
129
|
}
|
|
119
130
|
|
|
131
|
+
// ../core/src/tooling.ts
|
|
132
|
+
function toolingProblems(raw) {
|
|
133
|
+
if (raw === void 0) return [];
|
|
134
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return ['"tooling" must be an object such as { "paths": ["apps/docs-site/"] }'];
|
|
135
|
+
const o = raw;
|
|
136
|
+
const problems = [];
|
|
137
|
+
for (const k of Object.keys(o)) if (k !== "paths" && k !== "scopes") problems.push(`"tooling.${k}" is not a known key (paths, scopes)`);
|
|
138
|
+
const list2 = (k) => o[k] === void 0 || Array.isArray(o[k]) && o[k].every((x) => typeof x === "string" && x.trim().length > 0);
|
|
139
|
+
if (!Array.isArray(o.paths) || !list2("paths")) problems.push('"tooling.paths" must be a list of repository folders or files, such as "apps/docs-site/"');
|
|
140
|
+
else if (o.paths.some((p) => p.replace(/^!/, "").trim().startsWith("/") || p.split("/").includes(".."))) problems.push('"tooling.paths" entries are relative to the repository root, without a leading "/" or ".."');
|
|
141
|
+
if (!list2("scopes")) problems.push('"tooling.scopes" must be a list of pull request title scopes, such as "studio"');
|
|
142
|
+
return problems;
|
|
143
|
+
}
|
|
144
|
+
|
|
120
145
|
// ../core/src/config.ts
|
|
121
146
|
var CONFIG_FILE = "bridge.config.json";
|
|
122
147
|
var CHANGES_MODES = ["suggest", "direct"];
|
|
@@ -270,6 +295,7 @@ function defineConfig(input) {
|
|
|
270
295
|
...g.leadsPublishTier1 === false ? { leadsPublishTier1: false } : {}
|
|
271
296
|
},
|
|
272
297
|
products: input.products?.length ? input.products.map((p) => ({ ...p })) : DEFAULT_PRODUCTS.map((p) => ({ ...p })),
|
|
298
|
+
...input.tooling ? { tooling: { paths: [...input.tooling.paths], ...input.tooling.scopes?.length ? { scopes: [...input.tooling.scopes] } : {} } } : {},
|
|
273
299
|
changes: input.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE,
|
|
274
300
|
...input.storybook?.url ? { storybook: { url: input.storybook.url.trim().replace(/\/+$/, "") } } : {},
|
|
275
301
|
...input.library?.public === true ? { library: { public: true } } : {},
|
|
@@ -424,6 +450,7 @@ function loadConfig(source) {
|
|
|
424
450
|
}
|
|
425
451
|
}
|
|
426
452
|
problems.push(...productProblems(d.products));
|
|
453
|
+
problems.push(...toolingProblems(d.tooling));
|
|
427
454
|
const audit = d.audit;
|
|
428
455
|
if (audit !== void 0) {
|
|
429
456
|
if (!isObj(audit)) problems.push('"audit" must be an object');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridge-ds/visual",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bridge visual impact analysis: screenshots the stories and app screens a design system change touches, at the base and head refs, and pixel-diffs them into before/after/diff images and a JSON manifest.",
|
|
6
6
|
"license": "FSL-1.1-MIT",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"build:package": "node ../../scripts/build-packages.mjs visual"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@bridge-ds/core": "^0.
|
|
50
|
+
"@bridge-ds/core": "^0.26.0",
|
|
51
51
|
"pixelmatch": "7.1.0",
|
|
52
52
|
"playwright-core": "1.63.0",
|
|
53
53
|
"pngjs": "7.0.0"
|