@squadbase/vantage 0.2.3 → 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 +1 -1
- package/dist/{chunk-3QKPNWKJ.js → chunk-5UGRNXHC.js} +61 -21
- package/dist/chunk-5UGRNXHC.js.map +1 -0
- package/dist/cli.js +75 -3
- 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 +47 -0
- package/docs/en/cli-reference.md +7 -4
- 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 +43 -0
- package/docs/ja/cli-reference.md +7 -4
- 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 +14 -5
- package/skills/vantage-app/SKILL.md +9 -5
- package/templates/AGENTS.md +50 -6
- package/dist/chunk-3QKPNWKJ.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,53 @@ 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
|
+
|
|
12
59
|
## v0.2.3
|
|
13
60
|
|
|
14
61
|
`vantage routes` can be narrowed to one side of the map, and can print the spec of
|
package/docs/en/cli-reference.md
CHANGED
|
@@ -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
|
|
@@ -325,15 +326,17 @@ relative paths). See [Build & deploy](build-and-deploy) for details.
|
|
|
325
326
|
|
|
326
327
|
## Static diagnostics (`check`)
|
|
327
328
|
|
|
328
|
-
`vantage check` detects these
|
|
329
|
+
`vantage check` detects these eight diagnostics (six errors, two warnings).
|
|
329
330
|
|
|
330
331
|
| Code | Severity | Meaning |
|
|
331
332
|
|---|---|---|
|
|
332
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) |
|
|
333
335
|
| `ROUTE_CONFLICT` | error | Two files resolve to the same route |
|
|
334
336
|
| `MISSING_DEFAULT_EXPORT` | error | A page has no default export |
|
|
335
337
|
| `INVALID_API_EXPORT` | error | An API exports no valid HTTP method |
|
|
336
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 |
|
|
337
340
|
| `PUBLIC_ENV_MISUSE` | warning | Client reads a non-`PUBLIC_` env variable |
|
|
338
341
|
|
|
339
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,49 @@ 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
|
+
|
|
11
54
|
## v0.2.3
|
|
12
55
|
|
|
13
56
|
`vantage routes` を片側だけに絞れるようになり、各ルートの仕様も出せるようになりました。
|
package/docs/ja/cli-reference.md
CHANGED
|
@@ -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` を明示しても
|
|
@@ -319,15 +320,17 @@ vantage build --api-base-url https://api.example.com
|
|
|
319
320
|
|
|
320
321
|
## 静的診断(`check`)
|
|
321
322
|
|
|
322
|
-
`vantage check` が検出する診断は次の
|
|
323
|
+
`vantage check` が検出する診断は次の 8 種類です(エラー 6・警告 2)。
|
|
323
324
|
|
|
324
325
|
| コード | 深刻度 | 意味 |
|
|
325
326
|
|---|---|---|
|
|
326
327
|
| `FORBIDDEN_FILE` | エラー | 禁止された設定ファイルがルートに存在する |
|
|
328
|
+
| `SRC_DIR_SPLIT` | エラー | `src/` があるのに、ページ・`styles.css` がルート直下に残っている(または `src/server/`) |
|
|
327
329
|
| `ROUTE_CONFLICT` | エラー | 2 つのファイルが同じルートに解決される |
|
|
328
330
|
| `MISSING_DEFAULT_EXPORT` | エラー | ページに default export がない |
|
|
329
331
|
| `INVALID_API_EXPORT` | エラー | API が有効な HTTP メソッドをエクスポートしていない |
|
|
330
332
|
| `CLIENT_IMPORTS_SERVER` | エラー | クライアントが `server/` から import している |
|
|
333
|
+
| `SUSPICIOUS_ROUTE_DIR` | 警告 | `pages/`・`app/`・`utils/` など、足場に見えるディレクトリ名が URL に出ている |
|
|
331
334
|
| `PUBLIC_ENV_MISUSE` | 警告 | クライアントが `PUBLIC_` 以外の env を読んでいる |
|
|
332
335
|
|
|
333
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 変数の上書きのみ */
|
package/package.json
CHANGED
|
@@ -16,8 +16,8 @@ CLI は雛形を出すだけで、規約の遵守はこちらの責任。**追
|
|
|
16
16
|
```bash
|
|
17
17
|
vantage add page <name> # ルートページ(.tsx)
|
|
18
18
|
vantage add api <name> # server/api/**.ts の API モジュール
|
|
19
|
-
vantage add ui <name> # registry から UI ソースを components/ui/ にコピー
|
|
20
|
-
vantage add block <name> # registry からブロックを components/blocks/ にコピー
|
|
19
|
+
vantage add ui <name> # registry から UI ソースを components/ui/ にコピー(src/ があればその中)
|
|
20
|
+
vantage add block <name> # registry からブロックを components/blocks/ にコピー(同上)
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
`--force` で既存ファイルを上書き。`add` の雛形は import に `@squadbase/vantage` を焼き込む。
|
|
@@ -25,12 +25,18 @@ vantage add block <name> # registry からブロックを components/blocks/
|
|
|
25
25
|
## ページを追加する
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
vantage add page monthly-analysis # →
|
|
29
|
-
vantage add page sales/index # →
|
|
28
|
+
vantage add page monthly-analysis # → monthly-analysis.tsx → ルート /monthly-analysis
|
|
29
|
+
vantage add page sales/index # → sales/index.tsx → ルート /sales
|
|
30
30
|
vantage add page "sales/[customerId]" # → 動的ルート /sales/:customerId
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
**引数はページルートからの相対パス**(= ルートそのもの)。`add` は置き場所を自分で判断する ―
|
|
34
|
+
プロジェクトに `src/` があれば `src/monthly-analysis.tsx`、無ければ直下に書く。手でファイルを
|
|
35
|
+
作るときも同じ規則で、**混ぜてはならない**(`src/` があるのに直下に置くと `SRC_DIR_SPLIT`
|
|
36
|
+
エラー。詳細は AGENTS.md の「ディレクトリ構造」)。
|
|
37
|
+
|
|
38
|
+
出力される雛形は `definePage` + デフォルトエクスポートのコンポーネント。ファイル名の規約
|
|
39
|
+
(ページルートからの相対パス):
|
|
34
40
|
|
|
35
41
|
| ファイル | ルート | 用途 |
|
|
36
42
|
| --- | --- | --- |
|
|
@@ -51,6 +57,9 @@ vantage add page "sales/[customerId]" # → 動的ルート /sales/:customerI
|
|
|
51
57
|
- 表示ルート `/foo/:id`
|
|
52
58
|
- リンク `to="/foo/$id"` + `params={{ id }}`、取り出しは `const { id } = useParams()`
|
|
53
59
|
4. `components/`・`hooks/`・`lib/`・`server/`・`public/` はページにならない(ルート走査対象外)。
|
|
60
|
+
**それ以外のディレクトリ名はそのまま URL のセグメントになる** ― `pages/`・`app/`・`utils/`
|
|
61
|
+
のような足場ディレクトリを切ると `/pages/report` のような URL ができる
|
|
62
|
+
(`SUSPICIOUS_ROUTE_DIR` 警告)。ページでないモジュールは上の 3 つに置く。
|
|
54
63
|
|
|
55
64
|
## API を追加する(fullstack)
|
|
56
65
|
|
|
@@ -19,14 +19,17 @@ description: Vantage(@squadbase/vantage)ダッシュボードアプリを一か
|
|
|
19
19
|
3. **データを繋ぐ** — 外部 API か、自前の `server/api` か
|
|
20
20
|
4. **仕上げ** — `check` → `build` → `preview`
|
|
21
21
|
|
|
22
|
-
**各段階の終わりに `vantage check` を通す。** 静的診断(
|
|
23
|
-
API export・env 誤用)はユーザーコードを実行しないので速く、エラーがあれば
|
|
22
|
+
**各段階の終わりに `vantage check` を通す。** 静的診断(禁止ファイル・`src/` の分裂・ルート
|
|
23
|
+
衝突・境界違反・API export・env 誤用)はユーザーコードを実行しないので速く、エラーがあれば
|
|
24
|
+
exit 1 になる。
|
|
24
25
|
まとめて最後に回すと、原因の切り分けが難しくなる。
|
|
25
26
|
|
|
26
27
|
## Step 1 — 骨組み
|
|
27
28
|
|
|
28
29
|
新規なら `package.json` と `index.tsx` の 2 ファイルだけ。設定ファイルは**作らない**
|
|
29
|
-
(`vite.config.*` 等は `vantage check` がエラーにする)
|
|
30
|
+
(`vite.config.*` 等は `vantage check` がエラーにする)。ページを `src/` にまとめたいなら
|
|
31
|
+
`src/index.tsx` にする ― **`src/` があればページ走査はその中だけ**になり、直下に残した `.tsx`
|
|
32
|
+
は無視される(`SRC_DIR_SPLIT` エラー)。どちらか一方に寄せること。
|
|
30
33
|
|
|
31
34
|
```json
|
|
32
35
|
{
|
|
@@ -41,7 +44,7 @@ API export・env 誤用)はユーザーコードを実行しないので速く
|
|
|
41
44
|
"routes": "vantage routes"
|
|
42
45
|
},
|
|
43
46
|
"dependencies": {
|
|
44
|
-
"@squadbase/vantage": "^0.
|
|
47
|
+
"@squadbase/vantage": "^0.3.0",
|
|
45
48
|
"react": "^19.2.7",
|
|
46
49
|
"react-dom": "^19.2.7"
|
|
47
50
|
}
|
|
@@ -54,8 +57,9 @@ API export・env 誤用)はユーザーコードを実行しないので速く
|
|
|
54
57
|
**既存アプリに合流したときは、作る前に現状を読む:**
|
|
55
58
|
|
|
56
59
|
```bash
|
|
57
|
-
vantage routes # 既にあるページと API の URL マップ
|
|
60
|
+
vantage routes # 既にあるページと API の URL マップ(file 列がページの置き場所)
|
|
58
61
|
vantage check # いま壊れていないか(これから出すエラーと切り分ける)
|
|
62
|
+
ls src/ # あればページは src/ の中だけ。無ければプロジェクトルート直下
|
|
59
63
|
ls server/ # あれば fullstack モード。無ければ SPA
|
|
60
64
|
vantage add skill # 配置済みの skill(このファイルの仲間)と、その場所
|
|
61
65
|
```
|
package/templates/AGENTS.md
CHANGED
|
@@ -22,6 +22,9 @@ UI キット・開発サーバー・API サーバー・ビルドはすべて Van
|
|
|
22
22
|
|
|
23
23
|
## 不変条件(破ると静かに壊れる)
|
|
24
24
|
|
|
25
|
+
- **ページは `src/` の中か、プロジェクトルート直下か、どちらか一方。** `src/` があれば走査は
|
|
26
|
+
`src/` だけになり、ルート直下に残した `.tsx` は無視される(`SRC_DIR_SPLIT` エラー)。
|
|
27
|
+
新しいファイルは既にある側に置く(→「ディレクトリ構造」)。
|
|
25
28
|
- **設定ファイルを作らない。** `vite.config.*`・`tailwind.config.*`・`postcss.config.*`・
|
|
26
29
|
`components.json`・`vantage.config.*` はすべて禁止。存在すると `vantage check` がエラーにする
|
|
27
30
|
(`FORBIDDEN_FILE`)。テーマ調整は `styles.css` のトークンで行う。
|
|
@@ -39,6 +42,43 @@ UI キット・開発サーバー・API サーバー・ビルドはすべて Van
|
|
|
39
42
|
ため、変数・関数呼び出し・テンプレート補間は使わない。`page` エクスポートはランタイムでは
|
|
40
43
|
読まれない。
|
|
41
44
|
|
|
45
|
+
## ディレクトリ構造(ページをどこに置くか)
|
|
46
|
+
|
|
47
|
+
**ページの置き場所は 2 通りあり、`src/` があるかどうかだけで決まる。混ぜてはならない。**
|
|
48
|
+
|
|
49
|
+
- `src/` が**ある** → ページは `src/` の中だけ。ルート直下に置いた `.tsx` はルートにならず、
|
|
50
|
+
`SRC_DIR_SPLIT` エラーになる。
|
|
51
|
+
- `src/` が**無い** → ページはプロジェクトルート直下。
|
|
52
|
+
|
|
53
|
+
**ファイルを足す前に `src/` の有無を確認し、既にある側に置く**(`ls` するだけでよい)。URL は
|
|
54
|
+
どちらでも同じで、`src/` は URL に現れない(`src/sales/index.tsx` → `/sales`)。
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
root/
|
|
58
|
+
├── src/ # ある場合、ページはこの中だけ(無ければ以下が root 直下)
|
|
59
|
+
│ ├── index.tsx # /
|
|
60
|
+
│ ├── monthly-analysis.tsx # /monthly-analysis
|
|
61
|
+
│ ├── sales/index.tsx # /sales
|
|
62
|
+
│ ├── _layout.tsx # ルートレイアウト
|
|
63
|
+
│ ├── components/ # ページ走査の対象外(URL にならない)
|
|
64
|
+
│ ├── hooks/ lib/ # 同上
|
|
65
|
+
│ └── styles.css # 任意のグローバル CSS
|
|
66
|
+
├── server/ # 常にプロジェクトルート直下。src/ の中ではない
|
|
67
|
+
│ ├── api/… # /api/*
|
|
68
|
+
│ └── utils.ts
|
|
69
|
+
├── public/ # 静的ファイル。常にプロジェクトルート直下
|
|
70
|
+
├── package.json # managed
|
|
71
|
+
└── tsconfig.json # managed
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- **`server/` と `public/` は常にプロジェクトルート直下。** `src/server/` は決してスキャン
|
|
75
|
+
されない(`SRC_DIR_SPLIT` エラー)。
|
|
76
|
+
- **`styles.css` はページと同じ側**に置く(`src/` があれば `src/styles.css`)。
|
|
77
|
+
- **ディレクトリ名はそのまま URL のセグメントになる。** `pages/`・`app/`・`utils/` のような
|
|
78
|
+
足場ディレクトリを切ると、その名前が URL に出る(`pages/report.tsx` → `/pages/report`)。
|
|
79
|
+
`SUSPICIOUS_ROUTE_DIR` 警告で知らされる。ページでないモジュールは `components/`・`hooks/`・
|
|
80
|
+
`lib/` に置く ― この 3 つ(と `server/`・`public/`)はどの階層でも走査されない。
|
|
81
|
+
|
|
42
82
|
## import サブパスの地図
|
|
43
83
|
|
|
44
84
|
| import 元 | 提供するもの |
|
|
@@ -82,7 +122,7 @@ UI キット・開発サーバー・API サーバー・ビルドはすべて Van
|
|
|
82
122
|
"routes": "vantage routes"
|
|
83
123
|
},
|
|
84
124
|
"dependencies": {
|
|
85
|
-
"@squadbase/vantage": "^0.
|
|
125
|
+
"@squadbase/vantage": "^0.3.0",
|
|
86
126
|
"react": "^19.2.7",
|
|
87
127
|
"react-dom": "^19.2.7"
|
|
88
128
|
}
|
|
@@ -108,12 +148,15 @@ pnpm check # 静的診断(エラーがあれば exit 1)
|
|
|
108
148
|
pnpm routes # ページ/API の URL マップ
|
|
109
149
|
```
|
|
110
150
|
|
|
111
|
-
`server/` ディレクトリが無いので、この構成は **SPA
|
|
151
|
+
`server/` ディレクトリが無いので、この構成は **SPA モード**。ページを直下に置く形だが、
|
|
152
|
+
`src/` を作ってその中に集めてもよい(テンプレートから始めた場合は最初から `src/` がある)。
|
|
153
|
+
どちらか一方に寄せること(→「ディレクトリ構造」)。
|
|
112
154
|
|
|
113
155
|
## ルーティング規約(ファイル名 → ルート)
|
|
114
156
|
|
|
115
|
-
|
|
116
|
-
|
|
157
|
+
ページルート(`src/` があればその中、無ければプロジェクトルート)からの相対パスが、そのまま
|
|
158
|
+
URL になる。各ページは**デフォルトエクスポートの React コンポーネントが必須**(無いと
|
|
159
|
+
`MISSING_DEFAULT_EXPORT`)。以下の「ファイル」列はページルートからの相対パス。
|
|
117
160
|
|
|
118
161
|
| ファイル | ルート |
|
|
119
162
|
| --- | --- |
|
|
@@ -125,7 +168,8 @@ pnpm routes # ページ/API の URL マップ
|
|
|
125
168
|
| `_404.tsx` | Not Found ページ |
|
|
126
169
|
| `_error.tsx` | ルートが throw したときのエラーページ |
|
|
127
170
|
|
|
128
|
-
`components/`・`hooks/`・`lib/`・`server/`・`public/`
|
|
171
|
+
`components/`・`hooks/`・`lib/`・`server/`・`public/` はどの階層でもルート走査の対象外
|
|
172
|
+
(ページにならない)。それ以外のディレクトリ名は URL のセグメントになる(→「ディレクトリ構造」)。
|
|
129
173
|
|
|
130
174
|
```tsx
|
|
131
175
|
import { definePage } from "@squadbase/vantage"
|
|
@@ -302,7 +346,7 @@ vantage search テーブル --limit 5 --json # 機械可読(slug + score + sn
|
|
|
302
346
|
## 検証・ビルド・プレビュー
|
|
303
347
|
|
|
304
348
|
```bash
|
|
305
|
-
pnpm check # 静的診断(
|
|
349
|
+
pnpm check # 静的診断(禁止ファイル・src/ の分裂・ルート衝突・境界・API export・env 誤用)
|
|
306
350
|
pnpm routes # ページ + API の URL マップ
|
|
307
351
|
pnpm build # dist/ に client(+ server)+ vantage-manifest.json
|
|
308
352
|
pnpm preview # 本番ビルドをローカル実行
|