@tamagui/cli 2.7.7 → 3.0.0-beta.643.1
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/dist/add.cjs +77 -87
- package/dist/build.cjs +415 -277
- package/dist/cli.cjs +343 -340
- package/dist/generate-prompt.cjs +344 -357
- package/dist/generate.cjs +46 -54
- package/dist/index.cjs +2 -1
- package/dist/migrate.cjs +370 -0
- package/dist/setup-prompt.cjs +158 -0
- package/dist/to-tailwind-default-config.cjs +778 -0
- package/dist/to-tailwind.cjs +214 -0
- package/dist/update-template.cjs +44 -52
- package/dist/update.cjs +15 -18
- package/dist/upgrade.cjs +407 -398
- package/dist/utils.cjs +85 -101
- package/metro.cjs +1 -0
- package/metro.d.ts +1 -0
- package/metro.mjs +1 -0
- package/package.json +41 -12
- package/src/build.ts +574 -363
- package/src/cli.ts +96 -12
- package/src/generate-prompt.ts +16 -24
- package/src/migrate.ts +354 -0
- package/src/setup-prompt.ts +139 -0
- package/src/to-tailwind-default-config.ts +755 -0
- package/src/to-tailwind.ts +313 -0
- package/src/utils.ts +11 -9
- package/types/add.d.ts +1 -1
- package/types/add.d.ts.map +1 -1
- package/types/build.d.ts +1 -1
- package/types/build.d.ts.map +1 -1
- package/types/migrate.d.ts +7 -0
- package/types/migrate.d.ts.map +1 -0
- package/types/setup-prompt.d.ts +3 -0
- package/types/setup-prompt.d.ts.map +1 -0
- package/types/to-tailwind-default-config.d.ts +53 -0
- package/types/to-tailwind-default-config.d.ts.map +1 -0
- package/types/to-tailwind.d.ts +16 -0
- package/types/to-tailwind.d.ts.map +1 -0
- package/types/utils.d.ts.map +1 -1
- package/vite.cjs +1 -0
- package/vite.d.ts +1 -0
- package/vite.mjs +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// The agent brief for setting Tamagui up in a project that has never had it.
|
|
2
|
+
// `tamagui migrate --from v2` is the sibling for projects that already run v2.
|
|
3
|
+
//
|
|
4
|
+
// Both are printed by the CLI rather than kept only in docs so that whatever
|
|
5
|
+
// version a user installs describes itself, instead of an agent reading a docs
|
|
6
|
+
// page written against a different release.
|
|
7
|
+
|
|
8
|
+
export function printSetupPrompt() {
|
|
9
|
+
process.stdout.write(getSetupPrompt())
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getSetupPrompt() {
|
|
13
|
+
return `You are adding Tamagui v3 to a project that does not use it yet.
|
|
14
|
+
|
|
15
|
+
Work like a careful coding agent:
|
|
16
|
+
|
|
17
|
+
- Read the project first: package manager, bundler, framework, TypeScript config,
|
|
18
|
+
and whether it targets web, native, or both. Every choice below depends on it.
|
|
19
|
+
- Make the smallest install that actually runs, then verify it before adding more.
|
|
20
|
+
- Do not restyle existing components as part of setup.
|
|
21
|
+
- Do not publish packages, rotate secrets, or change production infrastructure.
|
|
22
|
+
- Stop and report if a step cannot be completed rather than guessing around it.
|
|
23
|
+
|
|
24
|
+
## 1. Check the baseline
|
|
25
|
+
|
|
26
|
+
Tamagui v3 requires React 19+, TypeScript 5+, and, for native apps, React Native
|
|
27
|
+
0.81+ with the New Architecture enabled. Web-only apps have no React Native
|
|
28
|
+
version requirement. If the project is below any of these, say so and stop.
|
|
29
|
+
|
|
30
|
+
## 2. Install
|
|
31
|
+
|
|
32
|
+
Tamagui v3 is currently a beta on the \`beta\` dist-tag. Resolve it once and pin
|
|
33
|
+
every package to the same version, because a mixed install silently produces two
|
|
34
|
+
copies of the runtime and styles that do nothing.
|
|
35
|
+
|
|
36
|
+
\`\`\`bash
|
|
37
|
+
V=$(npm view tamagui@beta version)
|
|
38
|
+
npm i tamagui@$V @tamagui/config@$V
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
\`tamagui\` is a superset of \`@tamagui/core\`. Install \`@tamagui/core\` alone
|
|
42
|
+
only for a styling-only install with no UI kit.
|
|
43
|
+
|
|
44
|
+
## 3. Create the config
|
|
45
|
+
|
|
46
|
+
\`\`\`tsx
|
|
47
|
+
// tamagui.config.ts
|
|
48
|
+
import { defaultConfig } from '@tamagui/config/v6'
|
|
49
|
+
import { createTamagui } from 'tamagui'
|
|
50
|
+
|
|
51
|
+
export const config = createTamagui(defaultConfig)
|
|
52
|
+
|
|
53
|
+
declare module 'tamagui' {
|
|
54
|
+
interface TamaguiCustomConfig extends typeof config {}
|
|
55
|
+
}
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
Pick an animation driver explicitly and import it from \`@tamagui/config\`:
|
|
59
|
+
\`animations-css\` (web), \`animations-rn\`, \`animations-reanimated\`, or
|
|
60
|
+
\`animations-motion\`. Do not install \`@tamagui/theme-builder\` or any v5 builder
|
|
61
|
+
package; they are not part of v3.
|
|
62
|
+
|
|
63
|
+
## 4. Wrap the app
|
|
64
|
+
|
|
65
|
+
\`\`\`tsx
|
|
66
|
+
import { TamaguiProvider, View } from 'tamagui'
|
|
67
|
+
import { config } from './tamagui.config'
|
|
68
|
+
|
|
69
|
+
export default function App() {
|
|
70
|
+
return (
|
|
71
|
+
<TamaguiProvider config={config} defaultTheme="light">
|
|
72
|
+
<View width={200} height={200} bg="background" />
|
|
73
|
+
</TamaguiProvider>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
\`\`\`
|
|
77
|
+
|
|
78
|
+
## 5. Wire the bundler
|
|
79
|
+
|
|
80
|
+
Add the adapter for the bundler this project actually uses, and no others:
|
|
81
|
+
|
|
82
|
+
- Vite: \`@tamagui/vite-plugin\`, or \`@tamagui/cli/vite\`
|
|
83
|
+
- Metro: \`@tamagui/metro-plugin\`, or \`@tamagui/cli/metro\`
|
|
84
|
+
- Next.js: \`@tamagui/next-plugin\`
|
|
85
|
+
- Turbopack: the \`tamagui build\` precompile step
|
|
86
|
+
|
|
87
|
+
There is no Webpack plugin in v3.
|
|
88
|
+
|
|
89
|
+
The compiler is an optimization, not a requirement. If wiring it is not
|
|
90
|
+
straightforward, skip it, note that you skipped it, and confirm the app runs
|
|
91
|
+
first.
|
|
92
|
+
|
|
93
|
+
## 6. Write styles the v3 way
|
|
94
|
+
|
|
95
|
+
This is the part most likely to be written as if it were v2. In v3, token and
|
|
96
|
+
theme names are bare, and conditions are flat clauses inside the value:
|
|
97
|
+
|
|
98
|
+
\`\`\`tsx
|
|
99
|
+
<View bg="background hover:background-hover" p="4 sm:6" />
|
|
100
|
+
\`\`\`
|
|
101
|
+
|
|
102
|
+
- No \`$\` sigils: \`bg="background"\`, not \`bg="$background"\`.
|
|
103
|
+
- No condition objects: there is no \`hoverStyle={{ ... }}\` and no \`$sm={{ ... }}\`.
|
|
104
|
+
- Modifiers chain left to right and read as prefixes: \`hover:sm:small\`.
|
|
105
|
+
- Clauses work on variant props too, not just style props, so
|
|
106
|
+
\`size="large sm:small"\` selects a different variant value per condition.
|
|
107
|
+
- When two clauses both apply, the winner is decided by specificity, not by
|
|
108
|
+
source order: first by platform (\`ios:\` beats \`native:\` beats unprefixed),
|
|
109
|
+
then by how many conditions the clause carries, then by category
|
|
110
|
+
(media < container < theme < group < state). Writing a clause later in the
|
|
111
|
+
string does not make it win.
|
|
112
|
+
- A chain is capped at five distinct non-platform conditions.
|
|
113
|
+
|
|
114
|
+
## 7. Verify before reporting success
|
|
115
|
+
|
|
116
|
+
\`\`\`bash
|
|
117
|
+
npx tamagui check
|
|
118
|
+
\`\`\`
|
|
119
|
+
|
|
120
|
+
\`tamagui check\` reports version mismatches, duplicate installs, lockfile
|
|
121
|
+
problems, a missing config, and any v2 style syntax left in source. Then run the
|
|
122
|
+
project's own typecheck and build, and start the app and confirm a Tamagui
|
|
123
|
+
component renders with its styles applied. A passing typecheck is not sufficient:
|
|
124
|
+
flat values are strings, so a misspelled token compiles cleanly and only shows up
|
|
125
|
+
at runtime.
|
|
126
|
+
|
|
127
|
+
## 8. Give the agent the project's own vocabulary
|
|
128
|
+
|
|
129
|
+
Once the app runs, generate a description of this project's actual tokens,
|
|
130
|
+
themes, and components so later prompts do not guess at them:
|
|
131
|
+
|
|
132
|
+
\`\`\`bash
|
|
133
|
+
npx tamagui generate-prompt
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
That writes \`tamagui-prompt.md\`. Keep it in the repo and regenerate it when the
|
|
137
|
+
config changes.
|
|
138
|
+
`
|
|
139
|
+
}
|