Skip to content

Commit 1cade69

Browse files
committed
verify(ui-import): apply objectui#25723's reader patch (dff61d5c8) on the ui/ tree (objectstack#25697, DO NOT MERGE)
Preview of objectui branch claude/project-thread-dwhq6r at dff61d5c8 (sub-issue 2b, objectstack#25723): readers of pnpm-workspace.yaml / pnpm-lock.yaml / turbo.json / the root manifest resolve the workspace root upward through scripts/workspace-root.mjs, and the five e2e specs root on uiRoot(). Lets Type Check UI reach its type-check step and Build & E2E UI reach the browser so run 3 can read their minutes. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSDL3SFtJaKzcymvCD8RsU
1 parent 1a76fa5 commit 1cade69

44 files changed

Lines changed: 981 additions & 421 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Tooling-only change (objectstack#25723): the scripts, gate tests and e2e specs that read `pnpm-workspace.yaml`, `pnpm-lock.yaml`, the root manifest's `pnpm` block or `turbo.json` resolve the file through `scripts/workspace-root.mjs`, which answers the same path in this repository and one level up when the tree is the objectstack monorepo's `ui/`. The two package test files touched (`@object-ui/cli`, `@object-ui/i18n`) read this repository's own workspace manifest; no published behaviour changes.

‎ui/e2e/dashboard-metric-tile-height.spec.ts‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { readFileSync } from 'node:fs';
55
import { createRequire } from 'node:module';
66
import os from 'node:os';
77
import path from 'node:path';
8-
import { fileURLToPath, pathToFileURL } from 'node:url';
8+
import { pathToFileURL } from 'node:url';
9+
import { uiRoot } from '../scripts/ui-root.mjs';
910

1011
/**
1112
* GEOMETRY pin for objectui#12704: a one-row dashboard metric tile is as tall
@@ -60,20 +61,11 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
6061
* workspace `dist/`, and their `exports` point there.
6162
*/
6263

63-
const REPO_ROOT = (() => {
64-
// Rooted on this file, never on `process.cwd()` (AGENTS.md: tests read the
65-
// filesystem relative to their own file). Bare `import.meta.url`, walked up.
66-
let dir = path.dirname(fileURLToPath(import.meta.url));
67-
for (let i = 0; i < 10; i++) {
68-
try {
69-
readFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'utf8');
70-
return dir;
71-
} catch {
72-
dir = path.dirname(dir);
73-
}
74-
}
75-
throw new Error('could not locate the repo root from ' + import.meta.url);
76-
})();
64+
// The objectui tree, resolved from `scripts/ui-root.mjs`'s own location -- the
65+
// one fact true standalone and under the objectstack monorepo's `ui/`. Walking up
66+
// to `pnpm-workspace.yaml` found the OBJECTSTACK root there (objectstack#25723),
67+
// and the sources this spec reads live under this tree's `packages/`.
68+
const REPO_ROOT = uiRoot();
7769

7870
const source = (rel: string) => path.join(REPO_ROOT, rel);
7971

‎ui/e2e/record-header-title-width.spec.ts‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { compile } from 'tailwindcss';
33
import { readFileSync } from 'node:fs';
44
import { fileURLToPath } from 'node:url';
55
import path from 'node:path';
6+
import { uiRoot } from '../scripts/ui-root.mjs';
67

78
/**
89
* GEOMETRY pin for the record-header title/action width arbitration on the two
@@ -46,21 +47,11 @@ import path from 'node:path';
4647
* produces, not a worst case invented to make a floor look necessary.
4748
*/
4849

49-
const REPO_ROOT = (() => {
50-
// Rooted on this file, never on `process.cwd()` — AGENTS.md's
51-
// "tests read the filesystem relative to their own file" rule. Bare
52-
// `import.meta.url`, walked up; never `new URL(<relative>, import.meta.url)`.
53-
let dir = path.dirname(fileURLToPath(import.meta.url));
54-
for (let i = 0; i < 10; i++) {
55-
try {
56-
readFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'utf8');
57-
return dir;
58-
} catch {
59-
dir = path.dirname(dir);
60-
}
61-
}
62-
throw new Error('could not locate the repo root from ' + import.meta.url);
63-
})();
50+
// The objectui tree, resolved from `scripts/ui-root.mjs`'s own location -- the
51+
// one fact true standalone and under the objectstack monorepo's `ui/`. Walking up
52+
// to `pnpm-workspace.yaml` found the OBJECTSTACK root there (objectstack#25723),
53+
// and the sources this spec reads live under this tree's `packages/`.
54+
const REPO_ROOT = uiRoot();
6455

6556
const read = (rel: string) => readFileSync(path.join(REPO_ROOT, rel), 'utf8');
6657

‎ui/e2e/sidebar-offcanvas-geometry.spec.ts‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { readFileSync } from 'node:fs';
55
import os from 'node:os';
66
import path from 'node:path';
77
import { fileURLToPath } from 'node:url';
8+
import { uiRoot } from '../scripts/ui-root.mjs';
89

910
/**
1011
* GEOMETRY pin for objectui#11464: the shadcn sidebar's `offcanvas` form drew
@@ -71,20 +72,11 @@ import { fileURLToPath } from 'node:url';
7172
* below `md` the desktop form is `hidden` anyway.
7273
*/
7374

74-
const REPO_ROOT = (() => {
75-
// Rooted on this file, never on `process.cwd()` (AGENTS.md: tests read the
76-
// filesystem relative to their own file). Bare `import.meta.url`, walked up.
77-
let dir = path.dirname(fileURLToPath(import.meta.url));
78-
for (let i = 0; i < 10; i++) {
79-
try {
80-
readFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'utf8');
81-
return dir;
82-
} catch {
83-
dir = path.dirname(dir);
84-
}
85-
}
86-
throw new Error('could not locate the repo root from ' + import.meta.url);
87-
})();
75+
// The objectui tree, resolved from `scripts/ui-root.mjs`'s own location -- the
76+
// one fact true standalone and under the objectstack monorepo's `ui/`. Walking up
77+
// to `pnpm-workspace.yaml` found the OBJECTSTACK root there (objectstack#25723),
78+
// and the sources this spec reads live under this tree's `packages/`.
79+
const REPO_ROOT = uiRoot();
8880

8981
const source = (rel: string) => path.join(REPO_ROOT, rel);
9082

‎ui/e2e/studio-item-header-title-width.spec.ts‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { readFileSync } from 'node:fs';
55
import { createRequire } from 'node:module';
66
import os from 'node:os';
77
import path from 'node:path';
8-
import { fileURLToPath, pathToFileURL } from 'node:url';
8+
import { pathToFileURL } from 'node:url';
9+
import { uiRoot } from '../scripts/ui-root.mjs';
910

1011
/**
1112
* GEOMETRY pin for objectui#12791: in Studio's item header a long api-name
@@ -59,20 +60,11 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
5960
* font draws the title about 17% wider than a local one.
6061
*/
6162

62-
const REPO_ROOT = (() => {
63-
// Rooted on this file, never on `process.cwd()` (AGENTS.md: tests read the
64-
// filesystem relative to their own file). Bare `import.meta.url`, walked up.
65-
let dir = path.dirname(fileURLToPath(import.meta.url));
66-
for (let i = 0; i < 10; i++) {
67-
try {
68-
readFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'utf8');
69-
return dir;
70-
} catch {
71-
dir = path.dirname(dir);
72-
}
73-
}
74-
throw new Error('could not locate the repo root from ' + import.meta.url);
75-
})();
63+
// The objectui tree, resolved from `scripts/ui-root.mjs`'s own location -- the
64+
// one fact true standalone and under the objectstack monorepo's `ui/`. Walking up
65+
// to `pnpm-workspace.yaml` found the OBJECTSTACK root there (objectstack#25723),
66+
// and the sources this spec reads live under this tree's `packages/`.
67+
const REPO_ROOT = uiRoot();
7668

7769
const source = (rel: string) => path.join(REPO_ROOT, rel);
7870

‎ui/e2e/toast-under-modal.spec.ts‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { readFileSync } from 'node:fs';
55
import os from 'node:os';
66
import path from 'node:path';
77
import { fileURLToPath } from 'node:url';
8+
import { uiRoot } from '../scripts/ui-root.mjs';
89

910
/**
1011
* objectui#11723: a toast's Undo and close buttons were dead while the record
@@ -71,20 +72,11 @@ import { fileURLToPath } from 'node:url';
7172
* under `e2e/` imports one.
7273
*/
7374

74-
const REPO_ROOT = (() => {
75-
// Rooted on this file, never on `process.cwd()` (AGENTS.md: tests read the
76-
// filesystem relative to their own file). Bare `import.meta.url`, walked up.
77-
let dir = path.dirname(fileURLToPath(import.meta.url));
78-
for (let i = 0; i < 10; i++) {
79-
try {
80-
readFileSync(path.join(dir, 'pnpm-workspace.yaml'), 'utf8');
81-
return dir;
82-
} catch {
83-
dir = path.dirname(dir);
84-
}
85-
}
86-
throw new Error('could not locate the repo root from ' + import.meta.url);
87-
})();
75+
// The objectui tree, resolved from `scripts/ui-root.mjs`'s own location -- the
76+
// one fact true standalone and under the objectstack monorepo's `ui/`. Walking up
77+
// to `pnpm-workspace.yaml` found the OBJECTSTACK root there (objectstack#25723),
78+
// and the sources this spec reads live under this tree's `packages/`.
79+
const REPO_ROOT = uiRoot();
8880

8981
const source = (rel: string) => path.join(REPO_ROOT, rel);
9082

‎ui/packages/cli/src/__tests__/workspace-vite.test.ts‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
workspacePackageDirs,
4444
workspaceSourceAliases
4545
} from '../utils/workspace-vite.js';
46+
import { workspaceGlobs, workspaceRoot } from '../../../../scripts/workspace-root.mjs';
4647

4748
const __dirname = dirname(fileURLToPath(import.meta.url));
4849
/** packages/cli/src/__tests__ -> repo root */
@@ -58,19 +59,16 @@ const BARREL_EXTENSIONS = ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx'];
5859
/**
5960
* The workspace's package directories, expanded WITHOUT the helper under test.
6061
*
61-
* Deliberately hand-rolled and deliberately narrow: it understands the two
62-
* pattern shapes this repo's manifest actually uses (a `dir/*` fan-out and a
63-
* literal directory) and throws on anything else, so a manifest that grows a
62+
* The globs come from `scripts/workspace-root.mjs`'s text parser -- a different
63+
* reader from the YAML-and-glob one under test, and one that understands the
64+
* two pattern shapes this repo's manifest actually uses (a `dir/*` fan-out and
65+
* a literal directory) and throws on anything else, so a manifest that grows a
6466
* shape this expectation cannot read fails loudly here instead of quietly
65-
* agreeing with whatever the helper returned.
67+
* agreeing with whatever the helper returned. They are relative to the objectui
68+
* tree in both layouts (objectstack#25723).
6669
*/
6770
function independentWorkspaceDirs(): string[] {
68-
const manifest = readFileSync(join(REPO_ROOT, 'pnpm-workspace.yaml'), 'utf-8');
69-
const patterns: string[] = [];
70-
for (const line of manifest.split('\n')) {
71-
const match = /^\s*-\s*['"]?([^'"#\s]+)['"]?\s*$/.exec(line);
72-
if (match) patterns.push(match[1]);
73-
}
71+
const patterns = workspaceGlobs(REPO_ROOT);
7472
expect(patterns.length).toBeGreaterThan(0);
7573

7674
const dirs: string[] = [];
@@ -109,7 +107,12 @@ function independentAliasablePackages(): Map<string, string> {
109107
return found;
110108
}
111109

112-
const aliases = workspaceSourceAliases(REPO_ROOT);
110+
// The helper under test asks about a pnpm workspace ROOT. Standalone that is
111+
// this repository's root; under the objectstack monorepo it is the parent, whose
112+
// `pnpm-workspace.yaml` declares this tree's packages as `ui/packages/*` and so
113+
// on, and the `@object-ui/*` table it derives is the same set of `src` directories
114+
// the expectation above expands relative to this tree (objectstack#25723).
115+
const aliases = workspaceSourceAliases(workspaceRoot(REPO_ROOT));
113116

114117
describe('workspace alias table (objectui#3890)', () => {
115118
it('covers every @object-ui package the workspace manifest declares', () => {

‎ui/packages/i18n/src/__tests__/machineLocaleCensus-9909.test.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
*/
6767

6868
import { describe, it, expect } from 'vitest';
69+
import { workspaceGlobs as readWorkspaceGlobs } from '../../../../scripts/workspace-root.mjs';
6970
import { existsSync, readdirSync, readFileSync } from 'node:fs';
7071
import path from 'node:path';
7172
import { fileURLToPath } from 'node:url';
@@ -86,12 +87,18 @@ const DEP_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'opti
8687
/* The population */
8788
/* -------------------------------------------------------------------------- */
8889

89-
/** The workspace globs, read from `pnpm-workspace.yaml` rather than restated. */
90+
/**
91+
* The `packages:` globs that describe this tree, relative to `repoRoot`, from
92+
* the one parser in `scripts/workspace-root.mjs` (objectstack#25723): read rather
93+
* than hardcoded so a new workspace root is covered the day it is added, and
94+
* throwing on a shape it does not know rather than skipping it, because a guard
95+
* that silently stops looking at part of the workspace goes on reporting
96+
* success over a shrinking surface. Where the file is -- the objectui root, or
97+
* the monorepo root one level up with its `ui/` prefix stripped -- is the
98+
* helper's question, not this file's.
99+
*/
90100
function workspaceGlobs(): string[] {
91-
const yaml = readFileSync(path.join(repoRoot, 'pnpm-workspace.yaml'), 'utf8');
92-
const block = /^packages:\s*\n((?:[ \t]+-[^\n]*\n?)+)/m.exec(yaml);
93-
if (!block) return [];
94-
return [...block[1].matchAll(/-\s*['"]?([^'"\s#]+)['"]?/g)].map((m) => m[1]);
101+
return readWorkspaceGlobs(repoRoot);
95102
}
96103

97104
function workspacePackageDirs(): string[] {

‎ui/scripts/__tests__/check-dist-completeness.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2+
import { uiTurboConfigPath } from '../workspace-root.mjs';
23
import fs from 'node:fs';
34
import os from 'node:os';
45
import path from 'node:path';
@@ -306,7 +307,7 @@ describe('this repository', () => {
306307
);
307308

308309
it('turbo treats the gate as an input of the builds that run it', () => {
309-
const turbo = JSON.parse(fs.readFileSync(path.join(repoRoot, 'turbo.json'), 'utf8'));
310+
const turbo = JSON.parse(fs.readFileSync(uiTurboConfigPath(), 'utf8'));
310311
// Otherwise editing the gate does not invalidate a single cached build, and
311312
// the new rule is enforced only where nothing was cached.
312313
expect(turbo.tasks.build.inputs).toContain('$TURBO_ROOT$/scripts/check-dist-completeness.mjs');

‎ui/scripts/__tests__/check-installed-spec-pin-claims.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2+
import { lockfilePath } from '../workspace-root.mjs';
23
import { execFileSync } from 'node:child_process';
34
import fs from 'node:fs';
45
import os from 'node:os';
@@ -181,7 +182,7 @@ describe('attribution — a version on the line is not automatically the anchor'
181182
});
182183

183184
describe('the pin, read from two faces', () => {
184-
const lock = pinsFromLockfile(fs.readFileSync(path.join(repoRoot, 'pnpm-lock.yaml'), 'utf8'));
185+
const lock = pinsFromLockfile(fs.readFileSync(lockfilePath(), 'utf8'));
185186
const workspaces = execFileSync('git', ['-C', repoRoot, 'ls-files', '--', '*/package.json'], { encoding: 'utf8' })
186187
.split('\n')
187188
.filter((f) => /^(packages|apps|examples)\/[^/]+\/package\.json$/.test(f))

0 commit comments

Comments
 (0)