@marktiderman/genesis-cli 1.28.0 → 1.29.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/README.md +47 -0
- package/dist/cli.js +595 -420
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +169 -3
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +16 -16
- package/dist/index.js +177 -11
- package/dist/index.js.map +1 -1
- package/dist/starter/__tests__/starter.test.ts +8 -0
- package/dist/starter/fingerprint.config.js +18 -0
- package/dist/verify.d.ts +209 -0
- package/dist/verify.js +549 -0
- package/dist/verify.js.map +1 -0
- package/dist/vite.js +169 -3
- package/dist/vite.js.map +1 -1
- package/package.json +18 -4
|
@@ -136,6 +136,14 @@ describe("fingerprint", () => {
|
|
|
136
136
|
expect(imports).toEqual(["expo/config", "./starter.config", "./src/lib/define-starter"]);
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
+
// Hashed by package.json, a config plugin's package changes the runtime version on every
|
|
140
|
+
// release (a version bump), so an app on npm Genesis would build on every Genesis upgrade.
|
|
141
|
+
it("hashes config plugins by the files they load, plus the rich push Swift", () => {
|
|
142
|
+
const config = read("fingerprint.config.js");
|
|
143
|
+
expect(config).toMatch(/configPluginSourceType:\s*"files"/);
|
|
144
|
+
expect(config).toContain('filePath: "node_modules/@marktiderman/genesis-native/ios"');
|
|
145
|
+
});
|
|
146
|
+
|
|
139
147
|
it("app.config.ts reads no JavaScript-only switch", () => {
|
|
140
148
|
expect(read("app.config.ts")).not.toMatch(/features\.(updates|queryPersistence|queryLifecycle|keyboardScroll|deepLinks|notifications|accountDeletion|wipeSessionOnReinstall|refreshWhileActive|observability|devtools)/);
|
|
141
149
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// What decides the runtime version (and so whether a merge to main ships an over-the-air update or
|
|
2
|
+
// a new store build, deploy-production.yml): Expo's fingerprint of the native project. Config
|
|
3
|
+
// plugins are hashed by the files they load, not by their package.json, so a package's version
|
|
4
|
+
// bump alone (every Genesis release bumps @marktiderman/genesis-native, whose rich push plugin the
|
|
5
|
+
// app loads) doesn't force a new build; a change to the plugin's code still does. The rich push
|
|
6
|
+
// plugin also copies a Swift file into the build, which it reads rather than loads, so that folder
|
|
7
|
+
// is hashed too. docs/NATIVE-RELEASE.md, "Fingerprints".
|
|
8
|
+
/** @type {import('@expo/fingerprint').Config} */
|
|
9
|
+
module.exports = {
|
|
10
|
+
configPluginSourceType: "files",
|
|
11
|
+
extraSources: [
|
|
12
|
+
{
|
|
13
|
+
type: "dir",
|
|
14
|
+
filePath: "node_modules/@marktiderman/genesis-native/ios",
|
|
15
|
+
reasons: ["genesis-native rich push extension (copied into the build)"],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The checks that run inside the page. `domChecks` is passed to Playwright's `page.evaluate`, so it
|
|
5
|
+
* must be self-contained: no imports, no closures, no helpers outside its body. It returns every
|
|
6
|
+
* finding (callers cap what they print, after the allow list), and it leaves the page as it found
|
|
7
|
+
* it: focus, and the scroll position of the window and of every scrolling frame, are restored.
|
|
8
|
+
*/
|
|
9
|
+
interface DomCheckOptions {
|
|
10
|
+
/** The viewport is phone-sized (rule 9 counts floating controls there). */
|
|
11
|
+
phone: boolean;
|
|
12
|
+
/** Touch is on: the 44px hit-area check runs (docs/RESPONSIVE.md rule 3). */
|
|
13
|
+
coarse: boolean;
|
|
14
|
+
/** At most this many focusable elements are focused for the obscured-focus check, those in `main` first. */
|
|
15
|
+
maxFocus: number;
|
|
16
|
+
/** Text is zoomed (WCAG 1.4.4): text clipped by an ancestor that hides overflow is a finding. */
|
|
17
|
+
textZoom?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface DomFinding {
|
|
20
|
+
check: "reflow" | "text-clipped" | "focus-obscured" | "hit-area" | "floating-controls" | "viewport-meta" | "touch-media";
|
|
21
|
+
/** `info` findings are reported but never fail a run (the engine's emulation, not the page). */
|
|
22
|
+
level?: "info";
|
|
23
|
+
/** A short CSS path to the element, ending in its accessible name when it has one. */
|
|
24
|
+
target?: string;
|
|
25
|
+
message: string;
|
|
26
|
+
}
|
|
27
|
+
declare function domChecks(opts: DomCheckOptions): Promise<DomFinding[]>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The conformance matrix: engines × viewports (docs/RESPONSIVE.md rule 10, WCAG 1.4.10).
|
|
31
|
+
*
|
|
32
|
+
* Playwright has no browser zoom. Zooming a 1280×1024 window to 200% or 400% lays the page out
|
|
33
|
+
* in a 640×512 or 320×256 CSS viewport, so zoom is those viewports (device pixel ratio doesn't
|
|
34
|
+
* change layout). A zoomed desktop keeps its mouse: no touch, so the (pointer: fine) and hover
|
|
35
|
+
* layouts at narrow widths are what the zoom viewports test. Phone and tablet widths run with touch.
|
|
36
|
+
*/
|
|
37
|
+
type Engine = "chromium" | "webkit" | "firefox";
|
|
38
|
+
declare const ENGINES: Engine[];
|
|
39
|
+
interface Viewport {
|
|
40
|
+
/** Stable name used in reports and allow entries: `320`, `1280`, `zoom-200`, `zoom-400`. */
|
|
41
|
+
name: string;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
/** Touch on: `hasTouch`, `isMobile`, and the coarse-pointer checks. */
|
|
45
|
+
touch: boolean;
|
|
46
|
+
/** A phone width: rule 9's floating-control count runs. */
|
|
47
|
+
phone: boolean;
|
|
48
|
+
/** The browser's default text size is doubled (WCAG 1.4.4); Chromium only, through its font-size setting. */
|
|
49
|
+
textZoom?: boolean;
|
|
50
|
+
}
|
|
51
|
+
declare const WIDTHS: readonly [320, 375, 768, 1024, 1280, 1440];
|
|
52
|
+
declare function widthViewport(width: number): Viewport;
|
|
53
|
+
declare const ZOOM_VIEWPORTS: Viewport[];
|
|
54
|
+
/**
|
|
55
|
+
* Text at 200% (WCAG 1.4.4), the browser's own text-size setting rather than page zoom: rem and em
|
|
56
|
+
* grow, px doesn't. Chromium only (it sets the setting through CDP).
|
|
57
|
+
*/
|
|
58
|
+
declare const TEXT_ZOOM_VIEWPORT: Viewport;
|
|
59
|
+
/** Every viewport: the six widths, the two zoom levels, then text at 200%. */
|
|
60
|
+
declare function allViewports(widths?: readonly number[]): Viewport[];
|
|
61
|
+
/** Whether an engine runs a viewport: text zoom needs Chromium. */
|
|
62
|
+
declare function runsIn(viewport: Viewport, engine: Engine): boolean;
|
|
63
|
+
/** Playwright context options for a viewport in an engine. */
|
|
64
|
+
declare function contextOptions(viewport: Viewport, engine: Engine): {
|
|
65
|
+
viewport: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
hasTouch: boolean;
|
|
70
|
+
isMobile: boolean;
|
|
71
|
+
reducedMotion: "reduce";
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check one loaded page: axe's WCAG 2.2 A/AA rules (target-size included), then the in-page checks
|
|
76
|
+
* (dom.ts), in that order because the focus check moves focus and scrolls. Read-only: the page
|
|
77
|
+
* gets no input but `focus()`. Animations and transitions are stopped first, so a layout is
|
|
78
|
+
* measured at rest.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
type CheckId = DomFinding["check"] | "axe";
|
|
82
|
+
interface Finding {
|
|
83
|
+
check: CheckId;
|
|
84
|
+
/** `info` findings are reported and never fail a run. */
|
|
85
|
+
level?: "info";
|
|
86
|
+
/** The axe rule id, for `axe` findings. */
|
|
87
|
+
rule?: string;
|
|
88
|
+
target?: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}
|
|
91
|
+
interface CheckPageOptions {
|
|
92
|
+
viewport: Viewport;
|
|
93
|
+
/** Axe rules to leave out everywhere (rare: a rule that misfires on a pattern Genesis ships). */
|
|
94
|
+
disableAxeRules?: string[];
|
|
95
|
+
/** Selectors axe skips (third-party frames). */
|
|
96
|
+
axeExclude?: string[];
|
|
97
|
+
/** Skip the viewport-meta check (a story iframe has Storybook's meta, not the app's). */
|
|
98
|
+
skipMeta?: boolean;
|
|
99
|
+
maxFocus?: number;
|
|
100
|
+
}
|
|
101
|
+
declare const AXE_TAGS: string[];
|
|
102
|
+
/**
|
|
103
|
+
* Doubles the browser's default text size (Chromium's font-size setting, as a person sets it), for
|
|
104
|
+
* the text-200 viewport. Call before `page.goto`.
|
|
105
|
+
*/
|
|
106
|
+
declare function zoomText(page: Page): Promise<void>;
|
|
107
|
+
declare function checkPage(page: Page, opts: CheckPageOptions): Promise<Finding[]>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Known findings, the doctor's way: each entry names what it covers and why, and the list only
|
|
111
|
+
* shrinks (a full run warns on an entry that covered nothing, so it gets removed).
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
interface AllowEntry {
|
|
115
|
+
check: CheckId;
|
|
116
|
+
/** The axe rule, for `axe` entries. */
|
|
117
|
+
rule?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The page: a path (`/items`), a route pattern (`/items/:id`, `/docs/*`), a story id
|
|
120
|
+
* (`story:forms--default`), or a story prefix ending in `*` (`story:forms--*`).
|
|
121
|
+
*/
|
|
122
|
+
page: string;
|
|
123
|
+
/** Viewport names (`320`, `zoom-400`); every viewport when left out. */
|
|
124
|
+
viewports?: string[];
|
|
125
|
+
engines?: Engine[];
|
|
126
|
+
/**
|
|
127
|
+
* The element: the trailing parts of the finding's selector path, matched whole (`table-row >
|
|
128
|
+
* button`; `:nth-of-type()`, `:nth-child()` and generated ids are ignored on both sides), with or
|
|
129
|
+
* without its quoted accessible name, or the name alone (`"Save"`). Any element when left out.
|
|
130
|
+
*/
|
|
131
|
+
target?: string;
|
|
132
|
+
reason: string;
|
|
133
|
+
}
|
|
134
|
+
interface Where {
|
|
135
|
+
page: string;
|
|
136
|
+
viewport: string;
|
|
137
|
+
engine: Engine;
|
|
138
|
+
}
|
|
139
|
+
declare function matchesPage(pattern: string, page: string): boolean;
|
|
140
|
+
/** A target split into its selector parts (no `:nth-…`) and its quoted accessible name. */
|
|
141
|
+
declare function targetParts(target: string): {
|
|
142
|
+
parts: string[];
|
|
143
|
+
name?: string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Whether an entry's target names a finding's element: its accessible name exactly, or the trailing
|
|
147
|
+
* selector parts of the finding's path, each part whole. Never a substring: `html` doesn't match
|
|
148
|
+
* `[data-slot="html-preview"]`, and `#tabs` doesn't match `#tabs-2`. An entry that names an
|
|
149
|
+
* `[aria-label=…]` covers only findings with that same label (a Save entry never covers Delete).
|
|
150
|
+
*/
|
|
151
|
+
declare function matchesTarget(entryTarget: string, findingTarget: string | undefined): boolean;
|
|
152
|
+
/** The entry that covers a finding. A targeted entry always wins over one without a target, wherever each sits in the list. */
|
|
153
|
+
declare function allowFor(entries: AllowEntry[], finding: Finding, where: Where): AllowEntry | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Whether a base entry already allows everything a new entry does: the same check and rule, a page
|
|
156
|
+
* pattern that includes it, at least its viewports and engines, and no target or the same one. A
|
|
157
|
+
* narrowed entry isn't growth.
|
|
158
|
+
*/
|
|
159
|
+
/**
|
|
160
|
+
* Whether every path a page pattern matches is matched by another, segment by segment: a base
|
|
161
|
+
* `:param` covers a static segment or another parameter, only a base `*` covers a `*`, and a base
|
|
162
|
+
* that requires a segment never covers one that's optional. `/demo/:ws` doesn't cover `/demo/*`.
|
|
163
|
+
*/
|
|
164
|
+
declare function patternCovers(base: string, pattern: string): boolean;
|
|
165
|
+
declare function entryCovers(base: AllowEntry, e: AllowEntry): boolean;
|
|
166
|
+
/** Splits findings into the ones an entry covers, `info` notes (never failing), and the rest. */
|
|
167
|
+
declare function applyAllow(entries: AllowEntry[], findings: Finding[], where: Where): {
|
|
168
|
+
allowed: {
|
|
169
|
+
finding: Finding;
|
|
170
|
+
entry: AllowEntry;
|
|
171
|
+
}[];
|
|
172
|
+
notes: Finding[];
|
|
173
|
+
failing: Finding[];
|
|
174
|
+
};
|
|
175
|
+
declare function validateAllow(entries: AllowEntry[]): string[];
|
|
176
|
+
declare function formatFinding(f: Finding): string;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Route patterns, so a run visits one page per route rather than every value of a parameter.
|
|
180
|
+
* React Router's own manifest (`react-router routes --json`) gives the patterns; a concrete path
|
|
181
|
+
* (from a sitemap or a link) is matched to its pattern.
|
|
182
|
+
*/
|
|
183
|
+
interface ReactRouterRoute {
|
|
184
|
+
id: string;
|
|
185
|
+
path?: string;
|
|
186
|
+
index?: boolean;
|
|
187
|
+
file?: string;
|
|
188
|
+
children?: ReactRouterRoute[];
|
|
189
|
+
}
|
|
190
|
+
interface RoutePattern {
|
|
191
|
+
/** The full pattern, `/demo/:ws/clients/:id/:section?`. */
|
|
192
|
+
pattern: string;
|
|
193
|
+
/** The route's id (React Router) or file. */
|
|
194
|
+
id: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Every route that renders a page, with its full pattern: leaves, index routes, and a parent with a
|
|
198
|
+
* path of its own ("" included) and no index child: it renders at its own path too, around an
|
|
199
|
+
* empty outlet. A pathless layout route renders nothing of its own.
|
|
200
|
+
*/
|
|
201
|
+
declare function flattenReactRouterRoutes(routes: ReactRouterRoute[], base?: string): RoutePattern[];
|
|
202
|
+
/** Whether a concrete path matches a pattern (`:param`, `:optional?`, `*` splat, `$param` too). */
|
|
203
|
+
declare function matchesPattern(pattern: string, path: string): boolean;
|
|
204
|
+
/** The pattern a path matches that React Router would pick: the highest-ranked one. */
|
|
205
|
+
declare function patternFor(path: string, patterns: RoutePattern[]): RoutePattern | undefined;
|
|
206
|
+
/** One path per pattern, the first seen; a path that matches no pattern is kept as its own. */
|
|
207
|
+
declare function onePathPerPattern(paths: string[], patterns: RoutePattern[]): string[];
|
|
208
|
+
|
|
209
|
+
export { AXE_TAGS, type AllowEntry, type CheckId, type CheckPageOptions, type DomCheckOptions, type DomFinding, ENGINES, type Engine, type Finding, type ReactRouterRoute, type RoutePattern, TEXT_ZOOM_VIEWPORT, type Viewport, WIDTHS, type Where, ZOOM_VIEWPORTS, allViewports, allowFor, applyAllow, checkPage, contextOptions, domChecks, entryCovers, flattenReactRouterRoutes, formatFinding, matchesPage, matchesPattern, matchesTarget, onePathPerPattern, patternCovers, patternFor, runsIn, targetParts, validateAllow, widthViewport, zoomText };
|