basalt-ui 2.21.0 → 2.23.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/CHANGELOG.md +60 -0
- package/MIGRATING.md +452 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +73 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +6 -0
- package/dist/charts/CartesianChart.d.ts +10 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +12 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +39 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +101 -22
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +38 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +18 -1
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +25 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +152 -72
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +21 -6
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +52 -17
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +43 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +75 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +13 -17
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +2 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +5 -2
- package/dist/charts/types.d.ts +18 -8
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +68 -4
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +202 -36
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +17 -1
- package/dist/cli/shot/playwright.d.ts +13 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +4 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- package/dist/controls/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +83 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +84 -5
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +100 -15
- package/dist/dashboard/meter-parts.d.ts +9 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +276 -74
- package/dist/dashboard/meter.d.ts +54 -65
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +21 -4
- package/dist/dashboard/meter.module.css +76 -0
- package/dist/dashboard/meter.module.css.d.ts +6 -0
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -5
- package/dist/dashboard/stat-card.module.css +36 -0
- package/dist/dashboard/stat-group.module.css +7 -0
- package/dist/dashboard/stat-strip.d.ts +22 -6
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +104 -60
- package/dist/dashboard/stat-strip.module.css +122 -53
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +7 -1
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +3 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +0 -5
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +43 -4
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +37 -0
- package/dist/theme/controls.module.css.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -27
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- package/dist/tokens/palette.d.ts +11 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +11 -10
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +42 -22
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +83 -3
- package/src/charts/Bars.tsx +7 -0
- package/src/charts/CartesianChart.tsx +18 -3
- package/src/charts/ChartCard.tsx +54 -13
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +135 -25
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +50 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +253 -87
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +81 -26
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +131 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +13 -17
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +9 -4
- package/src/charts/types.ts +18 -8
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +266 -35
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +20 -4
- package/src/cli/shot/types.ts +5 -0
- package/src/cli/tokens-css.ts +18 -20
- package/src/controls/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +83 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +107 -69
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +207 -24
- package/src/dashboard/meter-parts.tsx +349 -67
- package/src/dashboard/meter.module.css +76 -0
- package/src/dashboard/meter.module.css.d.ts +6 -0
- package/src/dashboard/meter.tsx +72 -18
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +36 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-group.module.css +7 -0
- package/src/dashboard/stat-strip.module.css +122 -53
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +176 -91
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/index.ts +0 -5
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +43 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +37 -0
- package/src/theme/controls.module.css.d.ts +2 -0
- package/src/theme/index.ts +22 -32
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +11 -10
- package/src/tokens/status-text.ts +2 -0
package/src/charts/types.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { StoredChartSpec } from '@tanstack/charts/types/core'
|
|
|
6
6
|
import type { BasaltProps } from '../common/props'
|
|
7
7
|
import type { ContainerClass } from '../tokens/size-classes'
|
|
8
8
|
import type { CurveName } from './curves'
|
|
9
|
+
import type { RefLabelPosition } from './ref-label'
|
|
9
10
|
|
|
10
11
|
/** What `x` may return. The value type picks the x scale (§ 9.4): `Date` → time, `number` → linear,
|
|
11
12
|
* `string` → point (lines) or band (bars). */
|
|
@@ -27,8 +28,10 @@ export type ChartSeries<T> = {
|
|
|
27
28
|
mark?: 'line' | 'bar' | 'area' | undefined
|
|
28
29
|
/** Default `'solid'`; `'dashed'` is `VX.dashArray` on the line, the legend and the tooltip. */
|
|
29
30
|
dash?: 'solid' | 'dashed' | undefined
|
|
30
|
-
/** Interpolation between points. Default `'
|
|
31
|
-
*
|
|
31
|
+
/** Interpolation between points. Default `'linear'`: discrete values (a daily total, a monthly
|
|
32
|
+
* rate) are joined by straight segments, never by a smoothed curve with crossings between points
|
|
33
|
+
* that never happened. `'monotone'` is an opt-in for a continuous measure; a piecewise-constant
|
|
34
|
+
* quantity (a price tier, a config value) is a step. */
|
|
32
35
|
curve?: CurveName | undefined
|
|
33
36
|
strokeWidth?: number | undefined
|
|
34
37
|
/**
|
|
@@ -155,11 +158,17 @@ export type RefLine = {
|
|
|
155
158
|
dashed?: boolean | undefined
|
|
156
159
|
axis?: 'left' | 'right' | undefined
|
|
157
160
|
/**
|
|
158
|
-
* Names the line on the plot: a small muted caption
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
+
* Names the line on the plot: a small muted caption on one of four spots (the plot's end or
|
|
162
|
+
* start, above or below the line). It follows the legend toggle. The ink is `--vx-ink2`, never
|
|
163
|
+
* the line colour.
|
|
161
164
|
*/
|
|
162
165
|
label?: string | undefined
|
|
166
|
+
/**
|
|
167
|
+
* Pins the caption's spot. Default: the first spot (the plot's right end above the line; the left
|
|
168
|
+
* end for a right-axis line) that stays inside the plot and that no data line runs through, so a
|
|
169
|
+
* line in the top or bottom quarter, or one a series ends on, moves its caption.
|
|
170
|
+
*/
|
|
171
|
+
labelPosition?: RefLabelPosition | undefined
|
|
163
172
|
/**
|
|
164
173
|
* Names the line in the legend (its color, dashed as `dashed`; a toggle hides the line), so a
|
|
165
174
|
* threshold needs no always-`null` series. `mark` is the swatch shape. Default `'line'`. The
|
|
@@ -190,8 +199,9 @@ export type ChartTooltipRow = {
|
|
|
190
199
|
}
|
|
191
200
|
|
|
192
201
|
export type ChartTooltipConfig<T, X extends ChartX = ChartX> = {
|
|
193
|
-
/** The tooltip title. Default:
|
|
194
|
-
* `
|
|
202
|
+
/** The tooltip title. Default: a Date x reads weekday, day, month and year in the page locale
|
|
203
|
+
* (`Tue 1 Sep 2026`; a non-day instant adds its time) whatever `formatX` shortens the ticks to;
|
|
204
|
+
* any other x goes through `formatX`. */
|
|
195
205
|
formatHeader?: ((x: X, d: T) => string) | undefined
|
|
196
206
|
/** Rows after the per-series rows (a total, a zone badge, a context line). `visible`/`hidden` are
|
|
197
207
|
* the legend's split, so a row never names a series the plot no longer draws. */
|
|
@@ -311,7 +321,7 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
311
321
|
xDomain?: readonly [X, X] | undefined
|
|
312
322
|
/**
|
|
313
323
|
* Tick label for an x value. Default: compact numbers, strings verbatim, and dates by tick step
|
|
314
|
-
* (`HH:MM` with the day on midnight, `
|
|
324
|
+
* (`HH:MM` with the day on midnight, the day (`4 Oct`, in the page locale), a month with the year on January; a label recurs
|
|
315
325
|
* only behind a day or year label).
|
|
316
326
|
*/
|
|
317
327
|
formatX?: ((x: X) => string) | undefined
|
|
@@ -370,7 +370,7 @@ export function seedTsconfigExtends(cwd: string): string | null {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
const SEED_HINT = 'node_modules/basalt-ui/agent/templates/main.tpl'
|
|
373
|
-
const ROUTER_PLUGIN_FIX =
|
|
373
|
+
export const ROUTER_PLUGIN_FIX =
|
|
374
374
|
"Fix: `bun add -D @tanstack/router-plugin`, add `tanstackRouter({ target: 'react', autoCodeSplitting: true })` " +
|
|
375
375
|
"from '@tanstack/router-plugin/vite' to `plugins` in vite.config.ts (before react()), then run vite once " +
|
|
376
376
|
'to generate src/routeTree.gen.ts — or define the tree in code (`createRootRoute` + `createRoute`), drop the routeTree.gen import and pass the tree to createBasaltRouter.'
|
package/src/cli/init.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the managed-file manifest engine back from `./index`, this package's shared CLI helpers, and the
|
|
4
4
|
* oxlint-preset plugin reader from `./sync` (also called there).
|
|
5
5
|
*/
|
|
6
|
-
import { existsSync } from 'node:fs'
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
7
7
|
import { resolve } from 'node:path'
|
|
8
8
|
|
|
9
9
|
import { deriveSpacing } from '../tokens/core'
|
|
@@ -34,7 +34,8 @@ import {
|
|
|
34
34
|
writeFileEnsuringDir,
|
|
35
35
|
writeUnit,
|
|
36
36
|
} from './index'
|
|
37
|
-
import { seedTsconfigExtends } from './doctor-upgrade'
|
|
37
|
+
import { ROUTER_PLUGIN_FIX, seedTsconfigExtends } from './doctor-upgrade'
|
|
38
|
+
import { routerSeedDest } from './router-wiring'
|
|
38
39
|
import { readOxlintPresetPlugins } from './sync'
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -57,6 +58,70 @@ const KEPT_FILE_COST: Record<string, string> = {
|
|
|
57
58
|
'DESIGN.md': 'the design brief Claude reads is yours, not the seeded one.',
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
/** One line at a time (string literals keep their inner spaces): trimmed, `;`, trailing `,` and `"` quotes undone. */
|
|
62
|
+
const normalise = (code: string): string =>
|
|
63
|
+
code
|
|
64
|
+
.split('\n')
|
|
65
|
+
.map((line) =>
|
|
66
|
+
line
|
|
67
|
+
.trim()
|
|
68
|
+
.replace(/[;,]$/, '')
|
|
69
|
+
.replace(/"([^"']*)"/g, "'$1'"),
|
|
70
|
+
)
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.join('\n')
|
|
73
|
+
|
|
74
|
+
const viteTemplate = (css: boolean, app: string): string => `import { StrictMode } from 'react'
|
|
75
|
+
import { createRoot } from 'react-dom/client'
|
|
76
|
+
${css ? "import './index.css'" : ''}
|
|
77
|
+
import App from '${app}'
|
|
78
|
+
|
|
79
|
+
createRoot(document.getElementById('root')!).render(
|
|
80
|
+
<StrictMode>
|
|
81
|
+
<App />
|
|
82
|
+
</StrictMode>,
|
|
83
|
+
)`
|
|
84
|
+
|
|
85
|
+
const STOCK_MAINS = [true, false].flatMap((css) =>
|
|
86
|
+
['.tsx', ''].map((ext) => normalise(viteTemplate(css, './App' + ext))),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
/** Whether `text` is create-vite's react-ts `main.tsx`, untouched (formatting aside): never an edited file. */
|
|
90
|
+
export const isStockViteMain = (text: string): boolean => STOCK_MAINS.includes(normalise(text))
|
|
91
|
+
|
|
92
|
+
const ALSO_REQUIRED_PEERS = ['motion']
|
|
93
|
+
|
|
94
|
+
/** The required peers of `.` (plus the ones `styles.css` imports) the app does not declare yet, with their ranges. */
|
|
95
|
+
function missingPeers(cwd: string, pkgRoot: string): Record<string, string> {
|
|
96
|
+
const shipped = JSON.parse(readFileSync(resolve(pkgRoot, 'package.json'), 'utf8')) as {
|
|
97
|
+
peerDependencies?: Record<string, string>
|
|
98
|
+
peerDependenciesMeta?: Record<string, { optional?: boolean }>
|
|
99
|
+
}
|
|
100
|
+
const app = JSON.parse(readFileSync(resolve(cwd, 'package.json'), 'utf8')) as Record<
|
|
101
|
+
string,
|
|
102
|
+
Record<string, string> | undefined
|
|
103
|
+
>
|
|
104
|
+
const declared = new Set(
|
|
105
|
+
['dependencies', 'devDependencies', 'peerDependencies'].flatMap((k) =>
|
|
106
|
+
Object.keys(app[k] ?? {}),
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
return Object.fromEntries(
|
|
110
|
+
Object.entries(shipped.peerDependencies ?? {}).filter(
|
|
111
|
+
([name]) =>
|
|
112
|
+
!declared.has(name) &&
|
|
113
|
+
(shipped.peerDependenciesMeta?.[name]?.optional !== true ||
|
|
114
|
+
ALSO_REQUIRED_PEERS.includes(name)),
|
|
115
|
+
),
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const hasRouterPlugin = (cwd: string): boolean =>
|
|
120
|
+
['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs'].some((f) => {
|
|
121
|
+
const abs = resolve(cwd, f)
|
|
122
|
+
return existsSync(abs) && readFileSync(abs, 'utf8').includes('@tanstack/router-plugin')
|
|
123
|
+
})
|
|
124
|
+
|
|
60
125
|
/** What happened to a kept `.oxlintrc.json`, by the merge result (null: `--no-merge-lint`). */
|
|
61
126
|
function oxlintrcCost(merge: MergeLintResult | null): string {
|
|
62
127
|
if (merge === 'added' || merge === 'already') {
|
|
@@ -149,6 +214,12 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
149
214
|
)
|
|
150
215
|
const files = managedFiles(placement, ctx.pkgRoot).filter((f) => !skippedSeeds.has(f.dest))
|
|
151
216
|
|
|
217
|
+
const mainDest = routerSeedDest(placement.appRel, 'main')
|
|
218
|
+
const mainPath = resolve(cwd, mainDest)
|
|
219
|
+
const stockMain =
|
|
220
|
+
!skippedSeeds.has(mainDest) &&
|
|
221
|
+
existsSync(mainPath) &&
|
|
222
|
+
isStockViteMain(readFileSync(mainPath, 'utf8'))
|
|
152
223
|
const writtenFiles: string[] = []
|
|
153
224
|
const keptFiles: string[] = []
|
|
154
225
|
const missingSources: string[] = []
|
|
@@ -163,7 +234,7 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
163
234
|
// Whole files (managed + seed) are skip-if-exists on init; a marker-spliced region always
|
|
164
235
|
// inserts/updates itself inside its host file.
|
|
165
236
|
const destExists = existsSync(resolve(cwd, file.dest))
|
|
166
|
-
if (!file.markers && destExists) {
|
|
237
|
+
if (!file.markers && destExists && !(stockMain && file.dest === mainDest)) {
|
|
167
238
|
// Already present — keep the consumer's copy untouched. Record the SHIPPED hash (normalized,
|
|
168
239
|
// same ledger form `writeUnit` uses) so a later sync treats a pre-existing-but-different file
|
|
169
240
|
// as locally drifted (skip unless --force), never silently clobbering a file the consumer
|
|
@@ -186,6 +257,28 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
186
257
|
const mergeLint: MergeLintResult | null =
|
|
187
258
|
scaffoldFlags.noMergeLint === true ? null : mergeOxlintExtends(cwd, ctx.vars.OXLINT_PRESET_PATH)
|
|
188
259
|
|
|
260
|
+
// The entry was seeded above or kept; either way the app still needs the peers it imports and the router plugin.
|
|
261
|
+
const keptUnwired =
|
|
262
|
+
keptFiles.includes(mainDest) && !/from ['"]basalt-ui['"/]/.test(readFileSync(mainPath, 'utf8'))
|
|
263
|
+
const advice: string[] = []
|
|
264
|
+
if (stockMain || keptUnwired) {
|
|
265
|
+
const missing = missingPeers(cwd, ctx.pkgRoot)
|
|
266
|
+
const count = Object.keys(missing).length
|
|
267
|
+
if (count > 0 && stockMain) {
|
|
268
|
+
patchPackageJson(cwd, (pkg) => {
|
|
269
|
+
pkg['dependencies'] = { ...(pkg['dependencies'] as Record<string, string>), ...missing }
|
|
270
|
+
return true
|
|
271
|
+
})
|
|
272
|
+
advice.push(
|
|
273
|
+
`added ${count} missing peers to package.json; run \`bun install\` (init does not).`,
|
|
274
|
+
)
|
|
275
|
+
} else if (count > 0) {
|
|
276
|
+
const specs = Object.entries(missing).map(([name, range]) => `${name}@${range}`)
|
|
277
|
+
advice.push(`missing peers: \`bun add ${specs.join(' ')}\`.`)
|
|
278
|
+
}
|
|
279
|
+
if (!hasRouterPlugin(cwd)) advice.push(ROUTER_PLUGIN_FIX.replace(/^Fix: /, 'router plugin: '))
|
|
280
|
+
}
|
|
281
|
+
|
|
189
282
|
manifest.basaltVersion = ctx.vars.BASALT_VERSION
|
|
190
283
|
manifest.spacingScale = { ...deriveSpacing(0).scale }
|
|
191
284
|
writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}\n`)
|
|
@@ -194,6 +287,10 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
194
287
|
`basalt-ui init: ${writtenFiles.length} written, ${keptFiles.length} kept, manifest at ${MANIFEST_PATH}`,
|
|
195
288
|
)
|
|
196
289
|
reportPrune(pruned)
|
|
290
|
+
if (stockMain) {
|
|
291
|
+
console.log(`basalt-ui init: seeded ${mainDest} (it was the unmodified Vite template).`)
|
|
292
|
+
}
|
|
293
|
+
for (const line of advice) console.log(`basalt-ui init: ${line}`)
|
|
197
294
|
if (missingSources.length > 0) {
|
|
198
295
|
console.log(
|
|
199
296
|
`basalt-ui init: ${missingSources.length} shipped asset(s) not present, skipped: ${missingSources.join(', ')}`,
|