Skip to content

Commit 840e073

Browse files
committed
chore(boundaries): ratchet platform's edges into routes and the workspace surface
platform/lib may not import app/o at all. The rest of platform and platform/lib's reach into app/workspace are counted per file, one baseline section per rule, and only shrink.
1 parent d05d9a5 commit 840e073

3 files changed

Lines changed: 253 additions & 73 deletions

File tree

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,59 @@
11
{
2-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/connected-accounts-section.tsx": 1,
3-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/databricks-modal.tsx": 1,
4-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/group-access.tsx": 1,
5-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/group-people.tsx": 1,
6-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/group-providers.tsx": 1,
7-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/people-invite-modal.tsx": 1,
8-
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/slack-member-setup-modal.tsx": 1,
9-
"apps/sim/platform/app/(shell)/settings/_components/sections/data-drains/data-drains-section.tsx": 1,
10-
"apps/sim/platform/app/(shell)/settings/_components/sections/data-drains/drain-create.tsx": 1,
11-
"apps/sim/platform/app/(shell)/settings/_components/sections/data-drains/drain-detail.tsx": 1,
12-
"apps/sim/platform/app/(shell)/settings/_components/sections/data-retention/data-retention-section.tsx": 2,
13-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/assistant-apps.tsx": 1,
14-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/generic-secrets.tsx": 1,
15-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/integrations-section.tsx": 3,
16-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/policy-modal.tsx": 2,
17-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/provider-detail.tsx": 3,
18-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/slack-account-setup.tsx": 1,
19-
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/source-detail.tsx": 2,
20-
"apps/sim/platform/app/(shell)/settings/_components/sections/mothership/mothership-section.tsx": 1,
21-
"apps/sim/platform/app/(shell)/settings/_components/sections/search-slack/search-slack-section.tsx": 1,
22-
"apps/sim/platform/app/(shell)/settings/_components/sections/security/security-section.tsx": 2,
23-
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/domains-panel.tsx": 1,
24-
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/group-mappings.tsx": 2,
25-
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/provider-form.tsx": 1,
26-
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/require-sso.tsx": 1,
27-
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/scim-panel.tsx": 1,
28-
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/sso-section.tsx": 2
2+
"viewDataHooks": {
3+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/connected-accounts-section.tsx": 1,
4+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/databricks-modal.tsx": 1,
5+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/group-access.tsx": 1,
6+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/group-people.tsx": 1,
7+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/group-providers.tsx": 1,
8+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/people-invite-modal.tsx": 1,
9+
"apps/sim/platform/app/(shell)/settings/_components/sections/connected-accounts/slack-member-setup-modal.tsx": 1,
10+
"apps/sim/platform/app/(shell)/settings/_components/sections/data-drains/data-drains-section.tsx": 1,
11+
"apps/sim/platform/app/(shell)/settings/_components/sections/data-drains/drain-create.tsx": 1,
12+
"apps/sim/platform/app/(shell)/settings/_components/sections/data-drains/drain-detail.tsx": 1,
13+
"apps/sim/platform/app/(shell)/settings/_components/sections/data-retention/data-retention-section.tsx": 2,
14+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/assistant-apps.tsx": 1,
15+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/generic-secrets.tsx": 1,
16+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/integrations-section.tsx": 3,
17+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/policy-modal.tsx": 2,
18+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/provider-detail.tsx": 3,
19+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/slack-account-setup.tsx": 1,
20+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/source-detail.tsx": 2,
21+
"apps/sim/platform/app/(shell)/settings/_components/sections/mothership/mothership-section.tsx": 1,
22+
"apps/sim/platform/app/(shell)/settings/_components/sections/search-slack/search-slack-section.tsx": 1,
23+
"apps/sim/platform/app/(shell)/settings/_components/sections/security/security-section.tsx": 2,
24+
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/domains-panel.tsx": 1,
25+
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/group-mappings.tsx": 2,
26+
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/provider-form.tsx": 1,
27+
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/require-sso.tsx": 1,
28+
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/scim-panel.tsx": 1,
29+
"apps/sim/platform/app/(shell)/settings/_components/sections/sso/sso-section.tsx": 2
30+
},
31+
"platformToRoutes": {
32+
"apps/sim/platform/app/(shell)/_components/conversation/page-composer.tsx": 1,
33+
"apps/sim/platform/app/(shell)/_components/conversation/page-conversation.tsx": 1,
34+
"apps/sim/platform/app/(shell)/_components/conversation/share-dialog.tsx": 2,
35+
"apps/sim/platform/app/(shell)/_components/conversation/use-page-conversation-effects.ts": 1,
36+
"apps/sim/platform/app/(shell)/_components/search/source-row.tsx": 2,
37+
"apps/sim/platform/app/(shell)/integrations/_components/integrations-page/integrations-route.tsx": 1,
38+
"apps/sim/platform/app/(shell)/integrations/_components/tool-permissions/tool-permissions-panel.tsx": 1,
39+
"apps/sim/platform/app/(shell)/search/_components/search-surface/search-surface.tsx": 1,
40+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/integrations-section.tsx": 1,
41+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/provider-detail.tsx": 1,
42+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/slack-account-setup.tsx": 1,
43+
"apps/sim/platform/app/(shell)/settings/_components/sections/integrations/source-setup-host.tsx": 1,
44+
"apps/sim/platform/app/(shell)/settings/_components/sections/search-slack/search-slack-section.tsx": 1
45+
},
46+
"platformLibToWorkspace": {
47+
"apps/sim/platform/lib/data/access-control/editor.ts": 1,
48+
"apps/sim/platform/lib/data/account.ts": 1,
49+
"apps/sim/platform/lib/data/audit-logs/feed.ts": 1,
50+
"apps/sim/platform/lib/data/billing.ts": 1,
51+
"apps/sim/platform/lib/data/chat-list.ts": 1,
52+
"apps/sim/platform/lib/data/home-model.ts": 1,
53+
"apps/sim/platform/lib/data/organization-search.ts": 1,
54+
"apps/sim/platform/lib/data/preferences.ts": 2,
55+
"apps/sim/platform/lib/data/recently-deleted.ts": 1,
56+
"apps/sim/platform/lib/data/settings-navigation.ts": 1,
57+
"apps/sim/platform/lib/data/whitelabeling.ts": 1
58+
}
2959
}

‎scripts/check-monorepo-boundaries.test.ts‎

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,67 @@ describe('package boundary command', () => {
177177
})
178178
})
179179

180+
it('keeps platform/lib from importing a route, even for a type', () => {
181+
withFixture((fixture, audit) => {
182+
const cases = [
183+
["import { Row } from '@/app/o/[organizationId]/row'", false],
184+
["import type { Row } from '@/app/o/[organizationId]/model'", false],
185+
["export { Row } from '../../../app/o/[organizationId]/row'", false],
186+
["const row = import('@/app/o/[organizationId]/row')", false],
187+
["import { value } from '@/app/other/value'", true],
188+
["import { value } from '@/lib/organizations/value'", true],
189+
] as const
190+
for (const [source, allowed] of cases) {
191+
writeFileSync(path.join(fixture, LIB_FILE), `${source}\n`)
192+
const result = audit()
193+
expect.soft(result.status, `${source}\n${result.stderr}`).toBe(allowed ? 0 : 1)
194+
if (!allowed) expect.soft(result.stderr).toContain(`${LIB_FILE}:1`)
195+
}
196+
writeFileSync(path.join(fixture, LIB_FILE), "import { Row } from '@/app/o/row'\n")
197+
audit('--update', '--init')
198+
expect(audit().status).toBe(1)
199+
})
200+
})
201+
202+
it('keeps the rest of platform from importing a route, even for a type', () => {
203+
withFixture((fixture, audit) => {
204+
const designFile = 'apps/sim/platform/design-system/widget.tsx'
205+
mkdirSync(path.join(fixture, 'apps/sim/platform/design-system'), { recursive: true })
206+
for (const file of [VIEW_FILE, designFile]) {
207+
const cases = [
208+
["import { Row } from '@/app/o/[organizationId]/row'", false],
209+
["import type { Row } from '@/app/o/[organizationId]/model'", false],
210+
["const row = import('@/app/o/[organizationId]/row')", false],
211+
["import { Row } from '@/app/workspace/[workspaceId]/row'", true],
212+
] as const
213+
for (const [source, allowed] of cases) {
214+
writeFileSync(path.join(fixture, file), `${source}\n`)
215+
const result = audit()
216+
expect.soft(result.status, `${source}\n${result.stderr}`).toBe(allowed ? 0 : 1)
217+
if (!allowed) expect.soft(result.stderr).toContain(`${file}:1`)
218+
}
219+
rmSync(path.join(fixture, file))
220+
}
221+
})
222+
})
223+
224+
it('keeps platform/lib from importing the workspace surface, even for a type', () => {
225+
withFixture((fixture, audit) => {
226+
const cases = [
227+
["import { Row } from '@/app/workspace/[workspaceId]/row'", false],
228+
["import type { Row } from '@/app/workspace/[workspaceId]/model'", false],
229+
["const row = import('@/app/workspace/providers/row')", false],
230+
["import { value } from '@/hooks/use-value'", true],
231+
] as const
232+
for (const [source, allowed] of cases) {
233+
writeFileSync(path.join(fixture, LIB_FILE), `${source}\n`)
234+
const result = audit()
235+
expect.soft(result.status, `${source}\n${result.stderr}`).toBe(allowed ? 0 : 1)
236+
if (!allowed) expect.soft(result.stderr).toContain(`${LIB_FILE}:1`)
237+
}
238+
})
239+
})
240+
180241
it('keeps a view from reading data around platform/lib/data', () => {
181242
withFixture((fixture, audit) => {
182243
const cases = [
@@ -213,7 +274,9 @@ describe('package boundary command', () => {
213274
writeFileSync(path.join(fixture, VIEW_FILE), two)
214275
expect(audit('--update').status).toBe(1)
215276
expect(audit('--update', '--init').status).toBe(0)
216-
expect(JSON.parse(readFileSync(baselinePath, 'utf8'))).toEqual({ [VIEW_FILE]: 2 })
277+
expect(JSON.parse(readFileSync(baselinePath, 'utf8')).viewDataHooks).toEqual({
278+
[VIEW_FILE]: 2,
279+
})
217280
expect(audit().status).toBe(0)
218281

219282
writeFileSync(
@@ -222,12 +285,44 @@ describe('package boundary command', () => {
222285
)
223286
expect(audit().status).toBe(1)
224287
expect(audit('--update').status).toBe(1)
225-
expect(JSON.parse(readFileSync(baselinePath, 'utf8'))).toEqual({ [VIEW_FILE]: 2 })
288+
expect(JSON.parse(readFileSync(baselinePath, 'utf8')).viewDataHooks).toEqual({
289+
[VIEW_FILE]: 2,
290+
})
226291

227292
writeFileSync(path.join(fixture, VIEW_FILE), one)
228293
expect(audit().status).toBe(1)
229294
expect(audit('--update').status).toBe(0)
230-
expect(JSON.parse(readFileSync(baselinePath, 'utf8'))).toEqual({ [VIEW_FILE]: 1 })
295+
expect(JSON.parse(readFileSync(baselinePath, 'utf8')).viewDataHooks).toEqual({
296+
[VIEW_FILE]: 1,
297+
})
298+
expect(audit().status).toBe(0)
299+
})
300+
})
301+
302+
it.each([
303+
['platformToRoutes', VIEW_FILE, '@/app/o/[organizationId]/row'],
304+
['platformLibToWorkspace', LIB_FILE, '@/app/workspace/[workspaceId]/row'],
305+
])('ratchets %s: a new edge fails, and the baseline only shrinks', (ratchet, file, target) => {
306+
withFixture((fixture, audit) => {
307+
const baselinePath = path.join(fixture, 'scripts/check-monorepo-boundaries.baseline.json')
308+
const counts = () => JSON.parse(readFileSync(baselinePath, 'utf8'))[ratchet]
309+
const one = `import { a } from '${target}'\n`
310+
const two = `${one}import type { b } from '${target}'\n`
311+
312+
writeFileSync(path.join(fixture, file), two)
313+
expect(audit('--update', '--init').status).toBe(0)
314+
expect(counts()).toEqual({ [file]: 2 })
315+
expect(audit().status).toBe(0)
316+
317+
writeFileSync(path.join(fixture, file), `${two}import { c } from '${target}'\n`)
318+
expect(audit().status).toBe(1)
319+
expect(audit('--update').status).toBe(1)
320+
expect(counts()).toEqual({ [file]: 2 })
321+
322+
writeFileSync(path.join(fixture, file), one)
323+
expect(audit().status).toBe(1)
324+
expect(audit('--update').status).toBe(0)
325+
expect(counts()).toEqual({ [file]: 1 })
231326
expect(audit().status).toBe(0)
232327
})
233328
})

0 commit comments

Comments
 (0)