@realadvisor-sites/kit-core 0.4.1 → 0.5.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/AGENTS.md +158 -148
- package/CHANGELOG.md +91 -0
- package/DESIGN.md +70 -9
- package/README.md +3 -3
- package/bin/sites-kit.mjs +5 -1
- package/lib/render-error.ts +6 -0
- package/package.json +3 -2
- package/tools/critic-calibrate.mjs +95 -0
- package/tools/critic.mjs +397 -0
- package/tools/screenshot.mjs +198 -1
- package/tools/search-map-test.mjs +8 -3
- package/tools/use-fixture.mjs +13 -8
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* pnpm kit test map # http://localhost:4321/listings
|
|
14
14
|
* pnpm kit test map --url http://localhost:4391 --path /proprietes
|
|
15
15
|
*
|
|
16
|
-
* `data` (the agency fixture in src/data/, loadData) checks the cards
|
|
16
|
+
* `data` (the agency fixture in src/data/ or app/data/, loadData) checks the cards
|
|
17
17
|
* against the listings' coordinates; without it those checks are skipped.
|
|
18
18
|
*/
|
|
19
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
19
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
20
20
|
import { pathToFileURL } from 'node:url';
|
|
21
21
|
|
|
22
22
|
const W = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -170,8 +170,13 @@ export async function checkSearchMap({ browser, base, path = '/listings', data =
|
|
|
170
170
|
return ran;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
/** The agency fixture in `<siteDir>/src/data/` (SITES_FIXTURE picks one), or null. */
|
|
173
|
+
/** The agency fixture in `<siteDir>/src/data/` (SITES_FIXTURE picks one) or `<siteDir>/app/data/fixture.json` (React Router), or null. */
|
|
174
174
|
export function loadData(siteDir) {
|
|
175
|
+
const react = new URL('app/data/fixture.json', siteDir);
|
|
176
|
+
if (existsSync(react)) {
|
|
177
|
+
const d = JSON.parse(readFileSync(react, 'utf8'));
|
|
178
|
+
return d?.organisation && Array.isArray(d.listings) ? d : null;
|
|
179
|
+
}
|
|
175
180
|
const dir = new URL('src/data/', siteDir);
|
|
176
181
|
const wanted = process.env.SITES_FIXTURE;
|
|
177
182
|
for (const f of readdirSync(dir).filter((f) => f.endsWith('.json'))) {
|
package/tools/use-fixture.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Put a fixture in
|
|
3
|
+
* Put a fixture in the site's data folder for fixture mode (used when
|
|
4
|
+
* SITES_API_KEY is unset): src/data/ on an Astro site, app/data/fixture.json
|
|
5
|
+
* on a React Router site (react-router.config.ts at the root; its
|
|
6
|
+
* data.server.ts imports that one file).
|
|
4
7
|
* pnpm fixture # the kit's demo-agency.json (the fictional Demo Agency)
|
|
5
8
|
* pnpm fixture demo-agency # same
|
|
6
9
|
* pnpm fixture path/to/file.json
|
|
@@ -24,8 +27,10 @@ const RETIRED = new Set(['jan-skubincan', 'rockwell', 'phoenix-real-estate']);
|
|
|
24
27
|
|
|
25
28
|
const ifEmpty = process.argv.includes('--if-empty');
|
|
26
29
|
const arg = process.argv.slice(2).find((a) => !a.startsWith('--')) ?? process.env.SITES_FIXTURE;
|
|
27
|
-
|
|
28
|
-
const
|
|
30
|
+
const react = ['ts', 'mts', 'js', 'mjs'].some((x) => existsSync(`react-router.config.${x}`));
|
|
31
|
+
const DIR = react ? 'app/data' : 'src/data';
|
|
32
|
+
await mkdir(DIR, { recursive: true });
|
|
33
|
+
const current = (await readdir(DIR)).filter((f) => f.endsWith('.json'));
|
|
29
34
|
if (ifEmpty && current.length) process.exit(0);
|
|
30
35
|
|
|
31
36
|
const named = (name) => [`${FIXTURES}${name}.json`].find(existsSync);
|
|
@@ -34,7 +39,7 @@ let dest;
|
|
|
34
39
|
if (arg && RETIRED.has(arg) && !named(arg)) {
|
|
35
40
|
src = named(DEMO);
|
|
36
41
|
dest = `${arg}.json`;
|
|
37
|
-
if (src) console.warn(`Fixture ${arg} is retired: using the fictional Demo Agency (${DEMO}.json) as
|
|
42
|
+
if (src) console.warn(`Fixture ${arg} is retired: using the fictional Demo Agency (${DEMO}.json) as ${DIR}/${dest}`);
|
|
38
43
|
} else if (arg) {
|
|
39
44
|
src = arg.endsWith('.json') ? [arg].find(existsSync) : named(arg);
|
|
40
45
|
} else {
|
|
@@ -49,7 +54,7 @@ if (!src) {
|
|
|
49
54
|
console.error(`Fixture not found (${arg ?? `${FIXTURES}${DEMO}.json`})`);
|
|
50
55
|
process.exit(1);
|
|
51
56
|
}
|
|
52
|
-
for (const f of current) await rm(
|
|
53
|
-
dest
|
|
54
|
-
await copyFile(src,
|
|
55
|
-
console.log(`Fixture mode uses
|
|
57
|
+
for (const f of current) await rm(`${DIR}/${f}`);
|
|
58
|
+
dest = react ? 'fixture.json' : (dest ?? basename(src));
|
|
59
|
+
await copyFile(src, `${DIR}/${dest}`);
|
|
60
|
+
console.log(`Fixture mode uses ${DIR}/${dest}`);
|