@squadbase/vantage 0.2.2 → 0.3.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 +2 -2
- package/dist/{chunk-UHZ7XSAN.js → chunk-5UGRNXHC.js} +61 -21
- package/dist/chunk-5UGRNXHC.js.map +1 -0
- package/dist/cli.js +380 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/vite/index.js +1 -1
- package/docs/en/changelog.md +71 -0
- package/docs/en/cli-reference.md +59 -5
- package/docs/en/components.md +2 -1
- package/docs/en/getting-started.md +6 -3
- package/docs/en/routing.md +27 -1
- package/docs/en/ui-and-theming.md +4 -2
- package/docs/ja/changelog.md +65 -0
- package/docs/ja/cli-reference.md +59 -5
- package/docs/ja/components.md +3 -2
- package/docs/ja/getting-started.md +6 -3
- package/docs/ja/routing.md +26 -1
- package/docs/ja/ui-and-theming.md +4 -2
- package/package.json +1 -1
- package/skills/vantage-add-feature/SKILL.md +26 -7
- package/skills/vantage-app/SKILL.md +9 -5
- package/templates/AGENTS.md +54 -8
- package/dist/chunk-UHZ7XSAN.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime/define-page.ts","../src/index.ts"],"names":[],"mappings":";;;AAyCO,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,OAAO,MAAA;AACT;;;AChCO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { ComponentType, ReactNode } from \"react\"\n\n/**\n * Optional per-page configuration. The only required part of a page module is\n * its default-exported component; `definePage` covers everything else.\n */\nexport interface PageConfig {\n /** Document title applied when this route is active. */\n title?: string\n /** Description metadata for the page. */\n description?: string\n /**\n * Short label for navigation built from `useRoutes()`. Defaults to `title`,\n * which is often too long for a nav (\"Overview · Acme Analytics\").\n */\n navLabel?: string\n /**\n * Component rendered while the route is loading.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n pendingComponent?: ComponentType\n /**\n * Component rendered when the route throws.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n errorComponent?: ComponentType<{ error: unknown }>\n /**\n * Validate/transform the URL search params for this route.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n validateSearch?: (search: Record<string, unknown>) => Record<string, unknown>\n}\n\n/**\n * Declare optional page configuration.\n *\n * ```tsx\n * export const page = definePage({ title: \"Monthly Analysis\" })\n * export default function MonthlyAnalysis() { return <div/> }\n * ```\n */\nexport function definePage(config: PageConfig): PageConfig {\n return config\n}\n\n/** Convenience type for a Vantage page component. */\nexport type PageComponent = ComponentType & { (): ReactNode }\n","/**\n * `@squadbase/vantage` — public runtime surface.\n *\n * The only import most pages need. Server state lives in\n * `@squadbase/vantage/query`, navigation in `@squadbase/vantage/router`,\n * UI in `@squadbase/vantage/ui`, and API types in `@squadbase/vantage/server`.\n */\nexport { definePage } from \"./runtime/define-page\"\nexport type { PageConfig, PageComponent } from \"./runtime/define-page\"\n\n/** Framework version, kept in sync with package.json at build time. */\nexport const VERSION = \"0.
|
|
1
|
+
{"version":3,"sources":["../src/runtime/define-page.ts","../src/index.ts"],"names":[],"mappings":";;;AAyCO,SAAS,WAAW,MAAA,EAAgC;AACzD,EAAA,OAAO,MAAA;AACT;;;AChCO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import type { ComponentType, ReactNode } from \"react\"\n\n/**\n * Optional per-page configuration. The only required part of a page module is\n * its default-exported component; `definePage` covers everything else.\n */\nexport interface PageConfig {\n /** Document title applied when this route is active. */\n title?: string\n /** Description metadata for the page. */\n description?: string\n /**\n * Short label for navigation built from `useRoutes()`. Defaults to `title`,\n * which is often too long for a nav (\"Overview · Acme Analytics\").\n */\n navLabel?: string\n /**\n * Component rendered while the route is loading.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n pendingComponent?: ComponentType\n /**\n * Component rendered when the route throws.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n errorComponent?: ComponentType<{ error: unknown }>\n /**\n * Validate/transform the URL search params for this route.\n * (Reserved — not yet applied to Vantage's code-split routes in the prototype.)\n */\n validateSearch?: (search: Record<string, unknown>) => Record<string, unknown>\n}\n\n/**\n * Declare optional page configuration.\n *\n * ```tsx\n * export const page = definePage({ title: \"Monthly Analysis\" })\n * export default function MonthlyAnalysis() { return <div/> }\n * ```\n */\nexport function definePage(config: PageConfig): PageConfig {\n return config\n}\n\n/** Convenience type for a Vantage page component. */\nexport type PageComponent = ComponentType & { (): ReactNode }\n","/**\n * `@squadbase/vantage` — public runtime surface.\n *\n * The only import most pages need. Server state lives in\n * `@squadbase/vantage/query`, navigation in `@squadbase/vantage/router`,\n * UI in `@squadbase/vantage/ui`, and API types in `@squadbase/vantage/server`.\n */\nexport { definePage } from \"./runtime/define-page\"\nexport type { PageConfig, PageComponent } from \"./runtime/define-page\"\n\n/** Framework version, kept in sync with package.json at build time. */\nexport const VERSION = \"0.3.0\"\n"]}
|
package/dist/vite/index.js
CHANGED
package/docs/en/changelog.md
CHANGED
|
@@ -9,6 +9,77 @@ What changed in each Vantage release. Newest is on top.
|
|
|
9
9
|
> minor release may include backwards-incompatible changes. A patch is limited to
|
|
10
10
|
> backwards-compatible additions and bug fixes.
|
|
11
11
|
|
|
12
|
+
## v0.3.0
|
|
13
|
+
|
|
14
|
+
Vantage now recognises `src/` as a place to put pages. This carries a
|
|
15
|
+
backwards-incompatible change (what gets scanned in a project that has a `src/`),
|
|
16
|
+
so per the 0.x policy it goes out as a minor.
|
|
17
|
+
|
|
18
|
+
Apps pinned to `"@squadbase/vantage": "^0.2.0"` will not pick up 0.3.0 — bump the
|
|
19
|
+
range to `^0.3.0`.
|
|
20
|
+
|
|
21
|
+
> [!WARNING]
|
|
22
|
+
> **In a project with a `src/`, only `src/` is scanned for pages.** `src/` used to be
|
|
23
|
+
> an ordinary directory, so `src/App.tsx` served `/src/App`. From 0.3.0, `src/`
|
|
24
|
+
> becomes the page-scan root and drops out of the URL (`src/sales/index.tsx` →
|
|
25
|
+
> `/sales`). **Pages and `styles.css` left at the project root are no longer
|
|
26
|
+
> scanned**, and `vantage check` reports them as `SRC_DIR_SPLIT`. Projects without a
|
|
27
|
+
> `src/` behave exactly as before.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **The page-scan root is decided by whether `src/` exists**
|
|
32
|
+
(see [File-based routing](routing)) — pages live inside `<root>/src` when it
|
|
33
|
+
exists, at the project root otherwise. Nothing is configured; it is detected. A
|
|
34
|
+
one-file app can stay at the root and move into `src/` once it grows. `server/`
|
|
35
|
+
and `public/` always stay at the project root, and `src/server/` is never scanned.
|
|
36
|
+
- **`styles.css` is read from the same side as the pages** — `src/styles.css` when
|
|
37
|
+
the project has a `src/`.
|
|
38
|
+
- **`vantage add page` / `add ui` / `add block` write relative to the page-scan
|
|
39
|
+
root** (`src/reports/index.tsx`, `src/components/ui/data-table.tsx`).
|
|
40
|
+
- **Quick mode given a page file** now resolves the root by walking up to the
|
|
41
|
+
nearest `package.json` — `vantage ./demo/src/index.tsx` runs in `./demo` (it used
|
|
42
|
+
to take the parent directory, landing in `./demo/src`).
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- **`SRC_DIR_SPLIT` (error)** — raised when `src/` exists but pages or `styles.css`
|
|
47
|
+
were left at the project root, or when `src/server/` exists. Each of those is a
|
|
48
|
+
"you placed it and nothing happened" failure, so it is an error rather than a
|
|
49
|
+
warning.
|
|
50
|
+
- **`SUSPICIOUS_ROUTE_DIR` (warning)** — raised when a URL comes out of a
|
|
51
|
+
scaffolding-looking directory such as `pages/`, `app/` or `utils/`
|
|
52
|
+
(`pages/report.tsx` → `/pages/report`). Page scanning works off a deny list, so
|
|
53
|
+
any name not on it silently becomes a URL. Scanning is not stopped, so you can
|
|
54
|
+
ignore the warning when the URL is intentional.
|
|
55
|
+
- The bundled `AGENTS.md` gained a "directory structure" section, and the skills
|
|
56
|
+
(`vantage-app`, `vantage-add-feature`) follow it. Placed copies of `AGENTS.md`
|
|
57
|
+
are synced by `vantage upgrade`.
|
|
58
|
+
|
|
59
|
+
## v0.2.3
|
|
60
|
+
|
|
61
|
+
`vantage routes` can be narrowed to one side of the map, and can print the spec of
|
|
62
|
+
every route. Additions only, so it is backwards-compatible.
|
|
63
|
+
|
|
64
|
+
### Added
|
|
65
|
+
|
|
66
|
+
- **`vantage routes` takes `--pages` / `--apis`** (see
|
|
67
|
+
[CLI reference](cli-reference)) — pages only (plus layout / 404 / error), or
|
|
68
|
+
API routes only. They are not exclusive: passing both, or neither, prints
|
|
69
|
+
everything exactly as before.
|
|
70
|
+
- **`--detail` adds each route's static spec** — for a page, the `definePage`
|
|
71
|
+
title / navLabel / description and its path params; for an API, **per method**,
|
|
72
|
+
the query keys read through `searchParams`, the request body (`json` /
|
|
73
|
+
`formData` / `text`, with its keys when destructured), the response status,
|
|
74
|
+
content type and object keys, and the status and message of every `HttpError`.
|
|
75
|
+
It answers "how do I call this endpoint?" without opening the handler.
|
|
76
|
+
- With `--json`, every entry gains a `spec`. The existing keys (`route`,
|
|
77
|
+
`file`, `dynamic`, `params`) are untouched, so current readers keep working.
|
|
78
|
+
- Everything is **inferred by reading the source** — like `check`, your code is
|
|
79
|
+
never imported or executed. Keys assembled at runtime, or input and output
|
|
80
|
+
hidden inside helper functions, will not show up: treat the output as a
|
|
81
|
+
**draft** of the spec, not a contract.
|
|
82
|
+
|
|
12
83
|
## v0.2.2
|
|
13
84
|
|
|
14
85
|
`vantage add skill` now scans for where the skills already are, and charts follow
|
package/docs/en/cli-reference.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
| `vantage build` | Build client + optional server → `dist/` |
|
|
13
13
|
| `vantage preview` | Run the production build locally (fullstack default `:4173`; spa via Vite preview) |
|
|
14
14
|
| `vantage check` | Static checks (routes, boundaries, forbidden files). Exit 1 on error |
|
|
15
|
-
| `vantage routes` | Print the page + API URL map |
|
|
15
|
+
| `vantage routes` | Print the page + API URL map (`--pages` / `--apis` for one side only, `--detail` for each route's spec) |
|
|
16
16
|
| `vantage add <kind> <name>` | Scaffold or place a `page` / `api` / `ui` / `block` / `skill` / `agents` (`--force` to overwrite; `skill` scans for copies already placed and skips them, `--dir` picks the destination) |
|
|
17
17
|
| `vantage docs [name]` | Show the bundled guide and component reference |
|
|
18
18
|
| `vantage search <query>` | Search that same reference in full text (natural language or `--regex`) |
|
|
@@ -26,8 +26,9 @@ first argument isn't a known command but points at a filesystem path, Vantage st
|
|
|
26
26
|
path as the root (printing `quick dev → <path>`).
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
vantage ./demo
|
|
30
|
-
vantage ./demo/index.tsx
|
|
29
|
+
vantage ./demo # folder → run dev inside it
|
|
30
|
+
vantage ./demo/index.tsx # page file → the folder holding its package.json
|
|
31
|
+
vantage ./demo/src/index.tsx # same with a src/ layout (the root is ./demo)
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
Path resolution rules:
|
|
@@ -35,7 +36,7 @@ Path resolution rules:
|
|
|
35
36
|
| Path you pass | Root that's used |
|
|
36
37
|
|---|---|
|
|
37
38
|
| A directory | the directory itself |
|
|
38
|
-
| A `.tsx` / `.jsx` page file | its parent
|
|
39
|
+
| A `.tsx` / `.jsx` page file | the nearest directory above it with a `package.json` (its parent otherwise) |
|
|
39
40
|
| A missing path / anything else | none (`Unknown command` error) |
|
|
40
41
|
|
|
41
42
|
Every root-scoped command except `add`, `docs` and `search` may also take a trailing path positional. You can spell out
|
|
@@ -51,6 +52,57 @@ vantage check ./demo/index.tsx # a file argument still checks its parent directo
|
|
|
51
52
|
> `add`, `docs` and `search` use their positionals for their own arguments (`add page dashboard`,
|
|
52
53
|
> `docs button`, `search date picker`) rather than a path, so they are excluded from this shortcut.
|
|
53
54
|
|
|
55
|
+
## `vantage routes` — the URL map, with specs
|
|
56
|
+
|
|
57
|
+
With no flags it prints the URL map of pages, layouts and API routes. Flags narrow it to **one
|
|
58
|
+
side** or add the **static spec** of every route.
|
|
59
|
+
|
|
60
|
+
| Flag | Meaning |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `--pages` | Pages only (plus layout / 404 / error) |
|
|
63
|
+
| `--apis` | API routes only |
|
|
64
|
+
| `--detail` | Add each route's spec (pages: path params + `definePage` metadata; APIs: methods, request, response) |
|
|
65
|
+
| `--json` | Machine-readable output (with `--detail`, every entry gains a `spec`) |
|
|
66
|
+
|
|
67
|
+
`--pages` and `--apis` are not exclusive — passing both, or neither, prints everything.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
vantage routes --pages # pages only
|
|
71
|
+
vantage routes --apis --detail # APIs with their specs
|
|
72
|
+
vantage routes --detail --json # machine-readable, specs included
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
Pages
|
|
77
|
+
/sales/:customerId sales/[customerId].tsx
|
|
78
|
+
title Customer detail
|
|
79
|
+
params :customerId
|
|
80
|
+
|
|
81
|
+
API
|
|
82
|
+
/api/customers/:id server/api/customers/[id].ts
|
|
83
|
+
GET
|
|
84
|
+
path :id
|
|
85
|
+
response 200 application/json
|
|
86
|
+
error 404 "Customer ${params.id} not found"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`--detail` reads these shapes:
|
|
90
|
+
|
|
91
|
+
| Line | Where it comes from |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `title` / `nav` / `desc` | String literals in `definePage({ ... })` |
|
|
94
|
+
| `params` | `[id]` / `[...rest]` in the filename |
|
|
95
|
+
| Method | HTTP method exports such as `export function GET` |
|
|
96
|
+
| `query` | `searchParams.get/getAll/has("x")` |
|
|
97
|
+
| `body` | `request.json()` / `formData()` / `text()` (plus the keys of `const { a, b } = await request.json()`) |
|
|
98
|
+
| `response` | Status, content type and object-literal keys of `Response.json(…)` / `json(…)` / `new Response(…)` |
|
|
99
|
+
| `error` | `new HttpError(status, "message")` |
|
|
100
|
+
|
|
101
|
+
> [!NOTE]
|
|
102
|
+
> Like `check`, `--detail` is **static text analysis** — your code is never imported or executed. Keys
|
|
103
|
+
> assembled at runtime, or input/output hidden inside helper functions, will not show up. Treat the
|
|
104
|
+
> output as a draft of the spec, not a contract.
|
|
105
|
+
|
|
54
106
|
## `vantage docs` — read the docs from the CLI
|
|
55
107
|
|
|
56
108
|
The content of this site is **bundled into the package**, so `vantage docs` prints it as plain
|
|
@@ -274,15 +326,17 @@ relative paths). See [Build & deploy](build-and-deploy) for details.
|
|
|
274
326
|
|
|
275
327
|
## Static diagnostics (`check`)
|
|
276
328
|
|
|
277
|
-
`vantage check` detects these
|
|
329
|
+
`vantage check` detects these eight diagnostics (six errors, two warnings).
|
|
278
330
|
|
|
279
331
|
| Code | Severity | Meaning |
|
|
280
332
|
|---|---|---|
|
|
281
333
|
| `FORBIDDEN_FILE` | error | A forbidden config file exists at the root |
|
|
334
|
+
| `SRC_DIR_SPLIT` | error | `src/` exists but pages or `styles.css` were left at the project root (or `src/server/` exists) |
|
|
282
335
|
| `ROUTE_CONFLICT` | error | Two files resolve to the same route |
|
|
283
336
|
| `MISSING_DEFAULT_EXPORT` | error | A page has no default export |
|
|
284
337
|
| `INVALID_API_EXPORT` | error | An API exports no valid HTTP method |
|
|
285
338
|
| `CLIENT_IMPORTS_SERVER` | error | Client code imports from `server/` |
|
|
339
|
+
| `SUSPICIOUS_ROUTE_DIR` | warning | A scaffolding-looking directory (`pages/`, `app/`, `utils/`, …) shows up in a URL |
|
|
286
340
|
| `PUBLIC_ENV_MISUSE` | warning | Client reads a non-`PUBLIC_` env variable |
|
|
287
341
|
|
|
288
342
|
None of them import or run your code — the checks are purely static.
|
package/docs/en/components.md
CHANGED
|
@@ -209,7 +209,8 @@ export default function Overview() {
|
|
|
209
209
|
## Theming
|
|
210
210
|
|
|
211
211
|
The look is decided by CSS variables (design tokens). To change colours or radii, override just the
|
|
212
|
-
variables in a `styles.css`
|
|
212
|
+
variables in a `styles.css` placed on the same side as your pages (`src/styles.css` when the project
|
|
213
|
+
has a `src/`) — see [UI & theming](ui-and-theming).
|
|
213
214
|
|
|
214
215
|
## When you want to edit the source
|
|
215
216
|
|
|
@@ -20,7 +20,9 @@ pnpm add @squadbase/vantage
|
|
|
20
20
|
### Write index.tsx
|
|
21
21
|
|
|
22
22
|
Put a single `index.tsx` at the project root. The **default-exported component** becomes the
|
|
23
|
-
route `/`.
|
|
23
|
+
route `/`. To keep pages under `src/`, write `src/index.tsx` instead — **once `src/` exists it
|
|
24
|
+
is the only page-scan root**, and `src/` never shows up in a URL
|
|
25
|
+
(→ [Where pages live](routing)).
|
|
24
26
|
|
|
25
27
|
```tsx
|
|
26
28
|
// index.tsx
|
|
@@ -67,8 +69,9 @@ Instead of `cd`-ing into a project, you can pass its **path directly** to start
|
|
|
67
69
|
Point at a folder or an entry file and `dev` boots on it.
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
|
-
vantage ./demo
|
|
71
|
-
vantage ./demo/index.tsx
|
|
72
|
+
vantage ./demo # folder → run dev inside it
|
|
73
|
+
vantage ./demo/index.tsx # page file → use the folder holding its package.json
|
|
74
|
+
vantage ./demo/src/index.tsx # same with a src/ layout (the root is ./demo)
|
|
72
75
|
```
|
|
73
76
|
|
|
74
77
|
When the first argument isn't a known command but points at a path, Vantage runs `dev` with that
|
package/docs/en/routing.md
CHANGED
|
@@ -4,8 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
In Vantage, **where you place a file is its URL**. You never configure a router.
|
|
6
6
|
|
|
7
|
+
## Where pages live
|
|
8
|
+
|
|
9
|
+
There are two layouts, and which one applies is decided by **whether `src/` exists** — detected,
|
|
10
|
+
never configured.
|
|
11
|
+
|
|
12
|
+
| Project | Page-scan root | The file that becomes `/` |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| Has `src/` | Inside `src/` only | `src/index.tsx` |
|
|
15
|
+
| No `src/` | The project root | `index.tsx` |
|
|
16
|
+
|
|
17
|
+
`src/` itself never appears in a URL (`src/sales/index.tsx` → `/sales`). A one-file app can stay at
|
|
18
|
+
the root; once it grows, create `src/` and move the pages in.
|
|
19
|
+
|
|
20
|
+
> [!WARNING]
|
|
21
|
+
> **The two layouts cannot be mixed.** Once `src/` exists, `.tsx` files at the project root are not
|
|
22
|
+
> scanned and `vantage check` reports `SRC_DIR_SPLIT`. `server/` and `public/` always stay at the
|
|
23
|
+
> project root (`src/server/` is never scanned), and `styles.css` belongs on the same side as the pages.
|
|
24
|
+
|
|
7
25
|
## Page conventions
|
|
8
26
|
|
|
27
|
+
The "File" column below is relative to the page-scan root above.
|
|
28
|
+
|
|
9
29
|
| File | Route |
|
|
10
30
|
|---|---|
|
|
11
31
|
| `index.tsx` | `/` |
|
|
@@ -23,7 +43,7 @@ In Vantage, **where you place a file is its URL**. You never configure a router.
|
|
|
23
43
|
|
|
24
44
|
## Directories that are never routed
|
|
25
45
|
|
|
26
|
-
These directories are never scanned. Put whatever code you like here.
|
|
46
|
+
These directories are never scanned, at any depth. Put whatever code you like here.
|
|
27
47
|
|
|
28
48
|
```text
|
|
29
49
|
components/ Reusable React components
|
|
@@ -33,6 +53,12 @@ server/ API (its presence enables the server)
|
|
|
33
53
|
public/ Static assets
|
|
34
54
|
```
|
|
35
55
|
|
|
56
|
+
> [!WARNING]
|
|
57
|
+
> **Every other directory name becomes a URL segment.** `pages/report.tsx` serves `/pages/report`,
|
|
58
|
+
> `utils/format.tsx` serves `/utils/format`. When routes come out of scaffolding directories like
|
|
59
|
+
> `pages/`, `app/` or `utils/`, `vantage check` raises a `SUSPICIOUS_ROUTE_DIR` warning — move
|
|
60
|
+
> non-page modules into one of the three directories above.
|
|
61
|
+
|
|
36
62
|
## The three spellings of a dynamic param
|
|
37
63
|
|
|
38
64
|
The same param appears in three spellings depending on where it is. **They must match.**
|
|
@@ -53,8 +53,10 @@ import { cn } from "@squadbase/vantage/ui";
|
|
|
53
53
|
|
|
54
54
|
## Override theme tokens
|
|
55
55
|
|
|
56
|
-
Design tokens like colors and radii are CSS variables. To override them, place a `styles.css`
|
|
57
|
-
|
|
56
|
+
Design tokens like colors and radii are CSS variables. To override them, place a `styles.css` **on the
|
|
57
|
+
same side as your pages** — `src/styles.css` if the project has a `src/`, at the project root
|
|
58
|
+
otherwise (→ [Where pages live](routing)) — and override **only CSS variables**. The file is
|
|
59
|
+
auto-imported after the theme.
|
|
58
60
|
|
|
59
61
|
```css
|
|
60
62
|
/* styles.css — CSS variable overrides only */
|
package/docs/ja/changelog.md
CHANGED
|
@@ -8,6 +8,71 @@ Vantage のリリースごとの変更点です。新しいものが上に来ま
|
|
|
8
8
|
> まだプロトタイプ(**0.x**)です。0.x の間は **minor が実質のメジャー**扱いで、後方互換性の
|
|
9
9
|
> ない変更は minor で入ることがあります。patch は後方互換の機能追加とバグ修正のみです。
|
|
10
10
|
|
|
11
|
+
## v0.3.0
|
|
12
|
+
|
|
13
|
+
ページの置き場所として `src/` を認識するようになりました。後方互換でない変更(`src/` を持つ
|
|
14
|
+
プロジェクトの走査範囲)を含むため、0.x の方針に従って minor を上げています。
|
|
15
|
+
|
|
16
|
+
依存を `"@squadbase/vantage": "^0.2.0"` と書いているアプリには 0.3.0 は入りません。
|
|
17
|
+
`^0.3.0` に上げてください。
|
|
18
|
+
|
|
19
|
+
> [!WARNING]
|
|
20
|
+
> **`src/` があるプロジェクトでは、ページ走査が `src/` の中だけになります。** これまで `src/` は
|
|
21
|
+
> ただのディレクトリで、`src/App.tsx` は `/src/App` というルートになっていました。0.3.0 では
|
|
22
|
+
> `src/` があればそこがページ探索ルートになり、`src/` は URL から落ちます
|
|
23
|
+
> (`src/sales/index.tsx` → `/sales`)。**ルート直下に残ったページと `styles.css` は走査されなく
|
|
24
|
+
> なる**ので、`vantage check` が `SRC_DIR_SPLIT` エラーで指摘します。`src/` を持たないアプリの
|
|
25
|
+
> 挙動は変わりません。
|
|
26
|
+
|
|
27
|
+
### 変更
|
|
28
|
+
|
|
29
|
+
- **ページ探索ルートが `src/` の有無だけで決まるようになりました**
|
|
30
|
+
(→ [ファイルベースルーティング](routing))― `<root>/src` があればページはその中だけ、
|
|
31
|
+
無ければルート直下。設定は無く、検出されるだけです。1 ファイルのアプリは直下のままでよく、
|
|
32
|
+
育ったら `src/` を作ってまとめて移せます。`server/` と `public/` は常にプロジェクトルート
|
|
33
|
+
直下で、`src/server/` はスキャンされません。
|
|
34
|
+
- **`styles.css` はページと同じ側から読まれます** ― `src/` があれば `src/styles.css`。
|
|
35
|
+
- **`vantage add page` / `add ui` / `add block` の書き込み先**もページ探索ルート基準になりました
|
|
36
|
+
(`src/reports/index.tsx`・`src/components/ui/data-table.tsx`)。
|
|
37
|
+
- **クイックモードにページファイルを渡したときの root** が、そのファイルから上に辿って最初に
|
|
38
|
+
`package.json` があるディレクトリになりました ― `vantage ./demo/src/index.tsx` の root は
|
|
39
|
+
`./demo` です(これまでは親ディレクトリ固定で `./demo/src` になっていました)。
|
|
40
|
+
|
|
41
|
+
### 追加
|
|
42
|
+
|
|
43
|
+
- **`SRC_DIR_SPLIT`(エラー)** ― `src/` があるのにルート直下にページや `styles.css` が残って
|
|
44
|
+
いる、または `src/server/` がある場合に指摘します。いずれも「置いたのに動かない」形の事故に
|
|
45
|
+
なるため、警告ではなくエラーです。
|
|
46
|
+
- **`SUSPICIOUS_ROUTE_DIR`(警告)** ― `pages/`・`app/`・`utils/` のような足場に見えるディレクトリ
|
|
47
|
+
から URL が生まれたときに知らせます(`pages/report.tsx` → `/pages/report`)。ページ走査は除外
|
|
48
|
+
リスト方式なので、リストに無い名前は黙って URL になります。走査自体は止めないので、意図して
|
|
49
|
+
その URL を作っている場合は無視できます。
|
|
50
|
+
- 同梱の `AGENTS.md` に「ディレクトリ構造」の節が入り、Skill(`vantage-app` /
|
|
51
|
+
`vantage-add-feature`)も追随しました。配置済みの `AGENTS.md` は `vantage upgrade` で
|
|
52
|
+
同期されます。
|
|
53
|
+
|
|
54
|
+
## v0.2.3
|
|
55
|
+
|
|
56
|
+
`vantage routes` を片側だけに絞れるようになり、各ルートの仕様も出せるようになりました。
|
|
57
|
+
すべて追加のみで後方互換です。
|
|
58
|
+
|
|
59
|
+
### 追加
|
|
60
|
+
|
|
61
|
+
- **`vantage routes` に `--pages` / `--apis` が付きました**(→ [CLI リファレンス](cli-reference))
|
|
62
|
+
― ページ(+ layout / 404 / error)だけ、API ルートだけに絞れます。排他ではないので、両方
|
|
63
|
+
付けても、どちらも付けなくても今までどおり全部出ます。
|
|
64
|
+
- **`--detail` で各ルートの静的な仕様を併記します** ― ページは `definePage` の
|
|
65
|
+
title / navLabel / description とパスパラメータ、API は**メソッドごと**に
|
|
66
|
+
`searchParams` で読むクエリキー・リクエストボディ(`json` / `formData` / `text`。
|
|
67
|
+
分割代入していればキーも)・レスポンスの status と content-type とオブジェクトのキー・
|
|
68
|
+
`HttpError` の status とメッセージが並びます。既存 API の呼び方を確かめるのに、
|
|
69
|
+
ハンドラを開かずに済みます。
|
|
70
|
+
- `--json` と併せると、各要素に `spec` が増えます。既存のキー(`route` / `file` /
|
|
71
|
+
`dynamic` / `params`)はそのままなので、今の読み手を壊しません。
|
|
72
|
+
- 取れるのは**ソースを読んだだけの推定**です(`check` と同じく、アプリのコードを import も
|
|
73
|
+
実行もしません)。実行時に組み立てるキーや、ヘルパー関数の中に隠れた入出力は出てきません
|
|
74
|
+
― 仕様の**下書き**であって契約ではありません。
|
|
75
|
+
|
|
11
76
|
## v0.2.2
|
|
12
77
|
|
|
13
78
|
`vantage add skill` が配置先を走査するようになり、チャートがスタイルシートの差し替えにも
|
package/docs/ja/cli-reference.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
| `vantage build` | クライアント + オプションのサーバーをビルド → `dist/` |
|
|
13
13
|
| `vantage preview` | 本番ビルドをローカルで起動(fullstack は既定 `:4173`、spa は Vite プレビュー) |
|
|
14
14
|
| `vantage check` | 静的検査(ルート・境界・禁止ファイル)。エラーがあれば exit 1 |
|
|
15
|
-
| `vantage routes` | ページ + API の URL
|
|
15
|
+
| `vantage routes` | ページ + API の URL マップを表示(`--pages` / `--apis` で片側だけ、`--detail` で仕様つき) |
|
|
16
16
|
| `vantage add <kind> <name>` | `page` / `api` / `ui` / `block` / `skill` / `agents` を雛形生成・配置(`--force` で上書き、`skill` は配置済みを走査してスキップ・`--dir` で配置先を指定) |
|
|
17
17
|
| `vantage docs [name]` | 同梱のガイド + コンポーネントリファレンスを表示 |
|
|
18
18
|
| `vantage search <query>` | 同じリファレンスを全文検索(自然言語 or `--regex`) |
|
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
(ターミナルに `quick dev → <path>` と表示されます)。
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
vantage ./demo
|
|
30
|
-
vantage ./demo/index.tsx
|
|
29
|
+
vantage ./demo # ディレクトリ → その中で dev を起動
|
|
30
|
+
vantage ./demo/index.tsx # ページファイル → その `package.json` があるディレクトリで dev
|
|
31
|
+
vantage ./demo/src/index.tsx # src/ レイアウトでも同じ(root は ./demo)
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
パスの解決ルール:
|
|
@@ -35,7 +36,7 @@ vantage ./demo/index.tsx # ページファイル → 親ディレクトリを
|
|
|
35
36
|
| 渡したパス | root になるもの |
|
|
36
37
|
|---|---|
|
|
37
38
|
| ディレクトリ | そのディレクトリ自身 |
|
|
38
|
-
| `.tsx` / `.jsx` のページファイル |
|
|
39
|
+
| `.tsx` / `.jsx` のページファイル | そこから上に辿って最初に `package.json` があるディレクトリ(無ければ親ディレクトリ) |
|
|
39
40
|
| 存在しないパス・その他 | 該当なし(`Unknown command` エラー) |
|
|
40
41
|
|
|
41
42
|
`add`・`docs`・`search` を除く root スコープの各コマンドも、末尾に path positional を取れます。`dev` を明示しても
|
|
@@ -51,6 +52,57 @@ vantage check ./demo/index.tsx # ファイル指定でも親ディレクトリ
|
|
|
51
52
|
> `add`・`docs`・`search` はパス引数ではなく positional を自分の引数(`add page dashboard`・
|
|
52
53
|
> `docs button`・`search 日付の選択`)に使うため、この短縮形の対象外です。
|
|
53
54
|
|
|
55
|
+
## `vantage routes` — URL マップと仕様
|
|
56
|
+
|
|
57
|
+
引数なしで、ページ・レイアウト・API の URL マップを出します。フラグで**片側だけ**に絞ったり、
|
|
58
|
+
各ルートの**静的な仕様**を足したりできます。
|
|
59
|
+
|
|
60
|
+
| フラグ | 意味 |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `--pages` | ページ(+ layout / 404 / error)だけを表示 |
|
|
63
|
+
| `--apis` | API ルートだけを表示 |
|
|
64
|
+
| `--detail` | 各ルートの仕様を併記(ページはパスパラメータと `definePage` のメタ、API はメソッド・リクエスト・レスポンス) |
|
|
65
|
+
| `--json` | 機械可読出力(`--detail` を付けると各要素に `spec` が付く) |
|
|
66
|
+
|
|
67
|
+
`--pages` と `--apis` は排他ではありません。両方付けても、どちらも付けなくても全部出ます。
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
vantage routes --pages # ページだけ
|
|
71
|
+
vantage routes --apis --detail # API を仕様つきで
|
|
72
|
+
vantage routes --detail --json # 仕様つきの機械可読出力
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
Pages
|
|
77
|
+
/sales/:customerId sales/[customerId].tsx
|
|
78
|
+
title Customer detail
|
|
79
|
+
params :customerId
|
|
80
|
+
|
|
81
|
+
API
|
|
82
|
+
/api/customers/:id server/api/customers/[id].ts
|
|
83
|
+
GET
|
|
84
|
+
path :id
|
|
85
|
+
response 200 application/json
|
|
86
|
+
error 404 "Customer ${params.id} not found"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`--detail` が拾うのは次の書き方です。
|
|
90
|
+
|
|
91
|
+
| 行 | 何を読むか |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `title` / `nav` / `desc` | `definePage({ ... })` の文字列リテラル |
|
|
94
|
+
| `params` | ファイル名の `[id]` / `[...rest]` |
|
|
95
|
+
| メソッド | `export function GET` などの HTTP メソッド export |
|
|
96
|
+
| `query` | `searchParams.get/getAll/has("x")` |
|
|
97
|
+
| `body` | `request.json()` / `formData()` / `text()`(`const { a, b } = await request.json()` ならキーも) |
|
|
98
|
+
| `response` | `Response.json(…)` / `json(…)` / `new Response(…)` の status・content-type・オブジェクトリテラルのキー |
|
|
99
|
+
| `error` | `new HttpError(status, "message")` |
|
|
100
|
+
|
|
101
|
+
> [!NOTE]
|
|
102
|
+
> `--detail` は `check` と同じく**ソースを読むだけの静的解析**で、アプリのコードを import も実行も
|
|
103
|
+
> しません。実行時に組み立てるキーや、ヘルパー関数の中に隠れた入出力は出てきません(出力は
|
|
104
|
+
> 「仕様の下書き」であって契約ではありません)。
|
|
105
|
+
|
|
54
106
|
## `vantage docs` — ドキュメントを CLI で読む
|
|
55
107
|
|
|
56
108
|
このサイトの内容は**パッケージに同梱**されていて、`vantage docs` でそのまま読めます。ネット接続も
|
|
@@ -268,15 +320,17 @@ vantage build --api-base-url https://api.example.com
|
|
|
268
320
|
|
|
269
321
|
## 静的診断(`check`)
|
|
270
322
|
|
|
271
|
-
`vantage check` が検出する診断は次の
|
|
323
|
+
`vantage check` が検出する診断は次の 8 種類です(エラー 6・警告 2)。
|
|
272
324
|
|
|
273
325
|
| コード | 深刻度 | 意味 |
|
|
274
326
|
|---|---|---|
|
|
275
327
|
| `FORBIDDEN_FILE` | エラー | 禁止された設定ファイルがルートに存在する |
|
|
328
|
+
| `SRC_DIR_SPLIT` | エラー | `src/` があるのに、ページ・`styles.css` がルート直下に残っている(または `src/server/`) |
|
|
276
329
|
| `ROUTE_CONFLICT` | エラー | 2 つのファイルが同じルートに解決される |
|
|
277
330
|
| `MISSING_DEFAULT_EXPORT` | エラー | ページに default export がない |
|
|
278
331
|
| `INVALID_API_EXPORT` | エラー | API が有効な HTTP メソッドをエクスポートしていない |
|
|
279
332
|
| `CLIENT_IMPORTS_SERVER` | エラー | クライアントが `server/` から import している |
|
|
333
|
+
| `SUSPICIOUS_ROUTE_DIR` | 警告 | `pages/`・`app/`・`utils/` など、足場に見えるディレクトリ名が URL に出ている |
|
|
280
334
|
| `PUBLIC_ENV_MISUSE` | 警告 | クライアントが `PUBLIC_` 以外の env を読んでいる |
|
|
281
335
|
|
|
282
336
|
いずれもユーザーコードを import・実行しません(純粋に静的な検査です)。
|
package/docs/ja/components.md
CHANGED
|
@@ -208,8 +208,9 @@ export default function Overview() {
|
|
|
208
208
|
|
|
209
209
|
## テーマ
|
|
210
210
|
|
|
211
|
-
見た目は CSS
|
|
212
|
-
`styles.css`
|
|
211
|
+
見た目は CSS 変数(デザイントークン)で決まります。色や角丸を変えたいときは、ページと同じ側に置いた
|
|
212
|
+
`styles.css`(`src/` があれば `src/styles.css`)で変数だけを上書きします — 詳しくは
|
|
213
|
+
[UI とテーマ](ui-and-theming) を参照してください。
|
|
213
214
|
|
|
214
215
|
## ソースを編集したいとき
|
|
215
216
|
|
|
@@ -20,7 +20,9 @@ pnpm add @squadbase/vantage
|
|
|
20
20
|
### index.tsx を書く
|
|
21
21
|
|
|
22
22
|
プロジェクトルートに `index.tsx` を 1 つ置きます。**default export されたコンポーネント**が
|
|
23
|
-
ルート `/`
|
|
23
|
+
ルート `/` になります。ページを `src/` にまとめたい場合は `src/index.tsx` にします ―
|
|
24
|
+
**`src/` があるとページ走査はその中だけ**になり、`src/` は URL に現れません
|
|
25
|
+
(→ [ページを置く場所](routing))。
|
|
24
26
|
|
|
25
27
|
```tsx
|
|
26
28
|
// index.tsx
|
|
@@ -67,8 +69,9 @@ React Fast Refresh がその場で反映します。
|
|
|
67
69
|
エントリファイルをそのまま指すだけで `dev` が立ち上がります。
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
|
-
vantage ./demo
|
|
71
|
-
vantage ./demo/index.tsx
|
|
72
|
+
vantage ./demo # フォルダ → その中で dev を起動
|
|
73
|
+
vantage ./demo/index.tsx # ページファイル → その `package.json` があるフォルダで dev
|
|
74
|
+
vantage ./demo/src/index.tsx # src/ レイアウトでも同じ(root は ./demo)
|
|
72
75
|
```
|
|
73
76
|
|
|
74
77
|
第 1 引数が既知コマンドでなくパスを指すとき、Vantage はそれを root として `dev` を起動します
|
package/docs/ja/routing.md
CHANGED
|
@@ -4,8 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
Vantage のルーティングは **ファイルの配置がそのまま URL** になります。ルーターの設定は書きません。
|
|
6
6
|
|
|
7
|
+
## ページを置く場所
|
|
8
|
+
|
|
9
|
+
置き場所は 2 通りあり、**`src/` があるかどうか**だけで決まります。設定ではなく検出です。
|
|
10
|
+
|
|
11
|
+
| プロジェクト | ページ走査のルート | `/` になるファイル |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `src/` がある | `src/` の中だけ | `src/index.tsx` |
|
|
14
|
+
| `src/` が無い | プロジェクトルート直下 | `index.tsx` |
|
|
15
|
+
|
|
16
|
+
`src/` 自体は URL に現れません(`src/sales/index.tsx` → `/sales`)。1 ファイルのアプリはそのまま
|
|
17
|
+
直下に置け、育ったら `src/` を作ってまとめて移せます。
|
|
18
|
+
|
|
19
|
+
> [!WARNING]
|
|
20
|
+
> **2 つを混ぜることはできません。** `src/` があるとルート直下の `.tsx` は走査されず、
|
|
21
|
+
> `vantage check` が `SRC_DIR_SPLIT` エラーで指摘します。`server/` と `public/` は常にプロジェクト
|
|
22
|
+
> ルート直下(`src/server/` はスキャンされません)、`styles.css` はページと同じ側に置きます。
|
|
23
|
+
|
|
7
24
|
## ページの規約
|
|
8
25
|
|
|
26
|
+
以下の「ファイル」列は、上のページ走査ルートからの相対パスです。
|
|
27
|
+
|
|
9
28
|
| ファイル | ルート |
|
|
10
29
|
|---|---|
|
|
11
30
|
| `index.tsx` | `/` |
|
|
@@ -23,7 +42,7 @@ Vantage のルーティングは **ファイルの配置がそのまま URL**
|
|
|
23
42
|
|
|
24
43
|
## ルーティングされないディレクトリ
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
次のディレクトリは(どの階層でも)決して走査されません。ここには自由にコードを置けます。
|
|
27
46
|
|
|
28
47
|
```text
|
|
29
48
|
components/ 再利用する React コンポーネント
|
|
@@ -33,6 +52,12 @@ server/ API(存在するとサーバーが有効になる)
|
|
|
33
52
|
public/ 静的アセット
|
|
34
53
|
```
|
|
35
54
|
|
|
55
|
+
> [!WARNING]
|
|
56
|
+
> **それ以外のディレクトリ名は URL のセグメントになります。** `pages/report.tsx` は
|
|
57
|
+
> `/pages/report` に、`utils/format.tsx` は `/utils/format` になります。`pages/`・`app/`・
|
|
58
|
+
> `utils/` のような足場ディレクトリからルートが生まれると `vantage check` が
|
|
59
|
+
> `SUSPICIOUS_ROUTE_DIR` 警告を出すので、ページでないモジュールは上の 3 つに移してください。
|
|
60
|
+
|
|
36
61
|
## 動的パラメータの 3 つの綴り
|
|
37
62
|
|
|
38
63
|
同じパラメータが、場所によって 3 つの綴りで現れます。**必ず一致させます。**
|
|
@@ -53,8 +53,10 @@ import { cn } from "@squadbase/vantage/ui";
|
|
|
53
53
|
|
|
54
54
|
## テーマトークンを上書きする
|
|
55
55
|
|
|
56
|
-
色や角丸などのデザイントークンは CSS
|
|
57
|
-
`styles.css` を置き、**CSS
|
|
56
|
+
色や角丸などのデザイントークンは CSS 変数です。上書きしたいときは、**ページと同じ側**に
|
|
57
|
+
`styles.css` を置き、**CSS 変数だけ**を上書きします ― `src/` があれば `src/styles.css`、
|
|
58
|
+
無ければプロジェクトルート直下(→ [ページを置く場所](routing))。このファイルはテーマの後に
|
|
59
|
+
自動 import されます。
|
|
58
60
|
|
|
59
61
|
```css
|
|
60
62
|
/* styles.css — CSS 変数の上書きのみ */
|