Repository navigation
feat(cli): wire the CLI to the framework it ships #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
afc9ff9
refactor(cli): import the framework instead of reimplementing it
sebyx07 67f0ef8
feat(cli): x dev boots the app instead of serving only /_x
sebyx07 92b8cea
feat(cli): mount the real /_x dashboard and MCP dev server
sebyx07 39b77c8
fix: address PR #17 review comments
sebyx07 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // The `/_x` dev dashboard's own door, reached as `@ultimat3/admin/dev`. | ||
| // | ||
| // A separate door from the package root on purpose: the CLI's only job here is to MOUNT `/_x`, | ||
| // so it must never pull `src/*`'s production Solid component tree into every `x dev` process. | ||
|
|
||
| export { type DevSourceOptions, defaultDevSources, staticDevSources } from './data'; | ||
| export type { | ||
| CacheEdgeFact, | ||
| ColumnFact, | ||
| DevSources, | ||
| DriftFact, | ||
| InvalidationFact, | ||
| JobDefFact, | ||
| JobRunFact, | ||
| JobStepFact, | ||
| LiveQueryFact, | ||
| LiveSubscriberFact, | ||
| MailFact, | ||
| ManifestFact, | ||
| PolicyFact, | ||
| QueueFact, | ||
| RequestTrace, | ||
| RouteFact, | ||
| SpanKind, | ||
| SqlResult, | ||
| TableFact, | ||
| TaskFact, | ||
| TimelineSpan, | ||
| } from './facts'; | ||
| export { type DevPanel, type PanelPayload, panelPayload } from './panel'; | ||
| export { type CachePanelData, cachePanel } from './panel-cache'; | ||
| export { assertReadOnly, type DbPanelData, dbPanel } from './panel-db'; | ||
| export { type JobsPanelData, jobsPanel } from './panel-jobs'; | ||
| export { type LivePanelData, livePanel } from './panel-live'; | ||
| export { type MailPanelData, mailPanel } from './panel-mail'; | ||
| export { type ManifestPanelData, manifestPanel } from './panel-manifest'; | ||
| export { type PolicyPanelData, policyPanel } from './panel-policy'; | ||
| export { type RoutesPanelData, routesPanel } from './panel-routes'; | ||
| export { type TimelinePanelData, timelinePanel } from './panel-timeline'; | ||
| export { | ||
| assertDevOnly, | ||
| DEV_BASE_PATH, | ||
| DEV_PANELS, | ||
| type DevDashboard, | ||
| type DevDashboardOptions, | ||
| devDashboard, | ||
| } from './server'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { describe, expect, test } from 'bun:test'; | ||
| import type { SourceFile } from './app-boundaries'; | ||
| import { checkImportRules, resolveSpecifier } from './app-boundaries'; | ||
|
|
||
| const file = (path: string, source: string): SourceFile => ({ path, source }); | ||
|
|
||
| describe('unit · app boundaries', () => { | ||
| test('site/ importing app/ is a build error, not a warning', () => { | ||
| const findings = checkImportRules([ | ||
| file('apps/web/site/pricing/page.tsx', "import { Chart } from '../../app/charts';"), | ||
| ]); | ||
| expect(findings.map((finding) => finding.code)).toEqual(['X_BOUNDARY_SITE_TO_APP']); | ||
| expect(findings[0]?.at).toBe('apps/web/site/pricing/page.tsx'); | ||
| expect(findings[0]?.fix.length).toBeGreaterThan(0); | ||
| }); | ||
|
|
||
| test('shared/ is a leaf: it may not import a surface', () => { | ||
| const findings = checkImportRules([ | ||
| file('apps/web/shared/ui/button.tsx', "import { useSession } from '../../app/session';"), | ||
| ]); | ||
| expect(findings[0]?.code).toBe('X_BOUNDARY_SHARED_LEAF'); | ||
| }); | ||
|
|
||
| test('app/ may import api/ types but not api/ values', () => { | ||
| const typeOnly = checkImportRules([ | ||
| file('apps/web/app/orders/page.tsx', "import type { Order } from '../../api/orders';"), | ||
| ]); | ||
| expect(typeOnly).toEqual([]); | ||
| const runtime = checkImportRules([ | ||
| file('apps/web/app/orders/page.tsx', "import { placeOrder } from '../../api/orders';"), | ||
| ]); | ||
| expect(runtime[0]?.code).toBe('X_BOUNDARY_APP_TO_API'); | ||
| }); | ||
|
|
||
| test('a route may not touch the database', () => { | ||
| const findings = checkImportRules([ | ||
| file('apps/web/app/orders/page.tsx', "import { db } from '@acme/db';"), | ||
| ]); | ||
| expect(findings[0]?.code).toBe('X_BOUNDARY_ROUTE_TO_DB'); | ||
| // Every fix is a line a caller can paste: a command first, the rest behind a `#`. | ||
| expect(findings[0]?.fix).toStartWith('x g query orders'); | ||
| }); | ||
|
|
||
| test('a service may not know about HTTP', () => { | ||
| const findings = checkImportRules([ | ||
| file('apps/web/app/orders/service.ts', "import { request } from '@ultimat3/http';"), | ||
| ]); | ||
| expect(findings[0]?.code).toBe('X_BOUNDARY_SERVICE_TO_HTTP'); | ||
| expect(findings[0]?.fix).toStartWith('x g action orders'); | ||
| }); | ||
|
|
||
| test('a legal import graph produces no findings', () => { | ||
| expect( | ||
| checkImportRules([ | ||
| file('apps/web/site/page.tsx', "import { Button } from '../shared/ui/button';"), | ||
| file('apps/web/app/orders/repo.ts', "import { db } from '@acme/db';"), | ||
| ]), | ||
| ).toEqual([]); | ||
| }); | ||
|
|
||
| // The upgrade over the CLI's own former check: the import that costs you is two hops away | ||
| // from the file anyone reviewed, and a direct-imports-only walk finds nothing. | ||
| test('a transitive site/ -> shared/ -> app/ chain is caught, and the chain is named', () => { | ||
| const findings = checkImportRules([ | ||
| file('apps/web/site/pricing.tsx', "import { Price } from '../shared/price';"), | ||
| file('apps/web/shared/price.ts', "import { rate } from '../app/rates';"), | ||
| file('apps/web/app/rates.ts', 'export const rate = 1;'), | ||
| ]); | ||
| const codes = findings.map((finding) => finding.code); | ||
| expect(codes).toContain('X_BOUNDARY_SITE_TO_APP'); | ||
| expect(codes).toContain('X_BOUNDARY_SHARED_LEAF'); | ||
| const chained = findings.find((finding) => finding.code === 'X_BOUNDARY_SITE_TO_APP'); | ||
| expect(chained?.cause).toContain('apps/web/site/pricing.tsx'); | ||
| expect(chained?.cause).toContain('apps/web/app/rates.ts'); | ||
| expect(chained?.at).toBe('apps/web/shared/price.ts'); | ||
| }); | ||
|
|
||
| test('a specifier resolves onto the graph key it names, extension and all', () => { | ||
| const keys = new Set(['apps/web/shared/price.ts', 'apps/web/shared/ui/index.tsx']); | ||
| expect(resolveSpecifier('apps/web/site/page.tsx', '../shared/price', keys)).toBe( | ||
| 'apps/web/shared/price.ts', | ||
| ); | ||
| expect(resolveSpecifier('apps/web/site/page.tsx', '../shared/ui', keys)).toBe( | ||
| 'apps/web/shared/ui/index.tsx', | ||
| ); | ||
| expect(resolveSpecifier('apps/web/site/page.tsx', '@ultimat3/http', keys)).toBe( | ||
| '@ultimat3/http', | ||
| ); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.