@tamagui/cli 2.7.7 → 3.0.0-beta.1097.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 +76 -87
- package/dist/build.cjs +425 -278
- package/dist/cli.cjs +361 -340
- package/dist/generate-prompt.cjs +484 -362
- package/dist/generate.cjs +45 -54
- package/dist/index.cjs +1 -1
- package/dist/migrate.cjs +437 -0
- package/dist/setup-prompt.cjs +216 -0
- package/dist/to-tailwind-default-config.cjs +789 -0
- package/dist/to-tailwind.cjs +213 -0
- package/dist/update-template.cjs +43 -52
- package/dist/update.cjs +14 -18
- package/dist/upgrade.cjs +417 -401
- package/dist/utils.cjs +84 -101
- package/metro.cjs +1 -0
- package/metro.d.ts +1 -0
- package/metro.mjs +1 -0
- package/package.json +43 -13
- package/src/build.ts +594 -362
- package/src/cli.ts +113 -12
- package/src/generate-prompt.ts +428 -329
- package/src/migrate.ts +422 -0
- package/src/setup-prompt.ts +192 -0
- package/src/to-tailwind-default-config.ts +767 -0
- package/src/to-tailwind.ts +313 -0
- package/src/upgrade.ts +30 -33
- 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 +2 -1
- package/types/build.d.ts.map +1 -1
- package/types/generate-prompt.d.ts +6 -2
- package/types/generate-prompt.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 +5 -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/upgrade.d.ts.map +1 -1
- 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,216 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var setup_prompt_exports = {};
|
|
28
|
+
__export(setup_prompt_exports, {
|
|
29
|
+
getSetupPrompt: () => getSetupPrompt,
|
|
30
|
+
printSetupPrompt: () => printSetupPrompt,
|
|
31
|
+
resolveStyleValueSyntax: () => resolveStyleValueSyntax,
|
|
32
|
+
setupPrompt: () => setupPrompt
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(setup_prompt_exports);
|
|
35
|
+
var import_prompts = __toESM(require("prompts"));
|
|
36
|
+
async function resolveStyleValueSyntax(setting) {
|
|
37
|
+
if (setting === "string" || setting === "object" || setting === "both") {
|
|
38
|
+
return setting;
|
|
39
|
+
}
|
|
40
|
+
if (!process.stdin.isTTY) {
|
|
41
|
+
return "both";
|
|
42
|
+
}
|
|
43
|
+
const response = await (0, import_prompts.default)({
|
|
44
|
+
type: "select",
|
|
45
|
+
name: "syntax",
|
|
46
|
+
message: "Which style value syntax would you like to document?",
|
|
47
|
+
choices: [
|
|
48
|
+
{
|
|
49
|
+
title: "both - document both string and object syntax",
|
|
50
|
+
value: "both"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
title: "string - e.g. bg=\"red hover:blue\"",
|
|
54
|
+
value: "string"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: "object - e.g. bg={{ default: \"red\", hover: \"blue\" }}",
|
|
58
|
+
value: "object"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
initial: 0
|
|
62
|
+
});
|
|
63
|
+
return response.syntax || "both";
|
|
64
|
+
}
|
|
65
|
+
async function setupPrompt(options) {
|
|
66
|
+
const { generatePrompt } = require("./generate-prompt.cjs");
|
|
67
|
+
return await generatePrompt(options);
|
|
68
|
+
}
|
|
69
|
+
function printSetupPrompt(syntax) {
|
|
70
|
+
if (syntax) {
|
|
71
|
+
process.stdout.write(getSetupPrompt(syntax));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!process.stdin.isTTY) {
|
|
75
|
+
process.stdout.write(getSetupPrompt("both"));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
resolveStyleValueSyntax().then((chosen) => {
|
|
79
|
+
process.stdout.write(getSetupPrompt(chosen));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function getSetupPrompt(syntax = "both") {
|
|
83
|
+
const styleExample = syntax === "string" ? "```tsx\n<View bg=\"background hover:background-hover\" p=\"4 sm:6\" />\n```" : syntax === "object" ? "```tsx\n<View bg={{ default: 'background', hover: 'background-hover' }} p={{ default: '4', sm: '6' }} />\n```" : `\`\`\`tsx
|
|
84
|
+
// string form
|
|
85
|
+
<View bg="background hover:background-hover" p="4 sm:6" />
|
|
86
|
+
|
|
87
|
+
// object form
|
|
88
|
+
<View bg={{ default: 'background', hover: 'background-hover' }} p={{ default: '4', sm: '6' }} />
|
|
89
|
+
\`\`\``;
|
|
90
|
+
return `You are adding Tamagui v3 to a project that does not use it yet.
|
|
91
|
+
|
|
92
|
+
Work like a careful coding agent:
|
|
93
|
+
|
|
94
|
+
- Read the project first: package manager, bundler, framework, TypeScript config,
|
|
95
|
+
and whether it targets web, native, or both. Every choice below depends on it.
|
|
96
|
+
- Make the smallest install that actually runs, then verify it before adding more.
|
|
97
|
+
- Do not restyle existing components as part of setup.
|
|
98
|
+
- Do not publish packages, rotate secrets, or change production infrastructure.
|
|
99
|
+
- Stop and report if a step cannot be completed rather than guessing around it.
|
|
100
|
+
|
|
101
|
+
## 1. Check the baseline
|
|
102
|
+
|
|
103
|
+
Tamagui v3 requires React 19+, TypeScript 5+, and, for native apps, React Native
|
|
104
|
+
0.81+ with the New Architecture enabled. Web-only apps have no React Native
|
|
105
|
+
version requirement. If the project is below any of these, say so and stop.
|
|
106
|
+
|
|
107
|
+
## 2. Install
|
|
108
|
+
|
|
109
|
+
Tamagui v3 is currently a beta on the \`beta\` dist-tag. Resolve it once and pin
|
|
110
|
+
every package to the same version, because a mixed install silently produces two
|
|
111
|
+
copies of the runtime and styles that do nothing.
|
|
112
|
+
|
|
113
|
+
\`\`\`bash
|
|
114
|
+
V=$(npm view tamagui@beta version)
|
|
115
|
+
npm i tamagui@$V @tamagui/config@$V
|
|
116
|
+
\`\`\`
|
|
117
|
+
|
|
118
|
+
\`tamagui\` is a superset of \`@tamagui/core\`. Install \`@tamagui/core\` alone
|
|
119
|
+
only for a styling-only install with no UI kit.
|
|
120
|
+
|
|
121
|
+
## 3. Create the config
|
|
122
|
+
|
|
123
|
+
\`\`\`tsx
|
|
124
|
+
// tamagui.config.ts
|
|
125
|
+
import { defaultConfig } from '@tamagui/config/v6'
|
|
126
|
+
import { createTamagui } from 'tamagui'
|
|
127
|
+
|
|
128
|
+
export const config = createTamagui(defaultConfig)
|
|
129
|
+
|
|
130
|
+
type AppConfig = typeof config
|
|
131
|
+
|
|
132
|
+
declare module 'tamagui' {
|
|
133
|
+
interface TamaguiCustomConfig extends AppConfig {}
|
|
134
|
+
}
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
Pick an animation driver explicitly and import it from \`@tamagui/config\`:
|
|
138
|
+
\`animations-css\` (web), \`animations-rn\`, \`animations-reanimated\`, or
|
|
139
|
+
\`animations-motion\`. Do not install \`@tamagui/theme-builder\` or any v5 builder
|
|
140
|
+
package; they are not part of v3.
|
|
141
|
+
|
|
142
|
+
## 4. Wrap the app
|
|
143
|
+
|
|
144
|
+
\`\`\`tsx
|
|
145
|
+
import { TamaguiProvider, View } from 'tamagui'
|
|
146
|
+
import { config } from './tamagui.config'
|
|
147
|
+
|
|
148
|
+
export default function App() {
|
|
149
|
+
return (
|
|
150
|
+
<TamaguiProvider config={config} defaultTheme="light">
|
|
151
|
+
<View w={200} h={200} bg="background" />
|
|
152
|
+
</TamaguiProvider>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
## 5. Wire the bundler
|
|
158
|
+
|
|
159
|
+
Add the adapter for the bundler this project actually uses, and no others:
|
|
160
|
+
|
|
161
|
+
- Vite: \`@tamagui/vite-plugin\`, or \`@tamagui/cli/vite\`
|
|
162
|
+
- Metro: \`@tamagui/metro-plugin\`, or \`@tamagui/cli/metro\`
|
|
163
|
+
- Next.js: \`@tamagui/next-plugin\`
|
|
164
|
+
- Turbopack: the \`tamagui build\` precompile step
|
|
165
|
+
|
|
166
|
+
There is no Webpack plugin in v3.
|
|
167
|
+
|
|
168
|
+
The compiler is an optimization, not a requirement. If wiring it is not
|
|
169
|
+
straightforward, skip it, note that you skipped it, and confirm the app runs
|
|
170
|
+
first.
|
|
171
|
+
|
|
172
|
+
## 6. Write styles the v3 way
|
|
173
|
+
|
|
174
|
+
This is the part most likely to be written as if it were v2. In v3, token and
|
|
175
|
+
theme names are bare, and conditions are flat clauses inside the value:
|
|
176
|
+
|
|
177
|
+
${styleExample}
|
|
178
|
+
|
|
179
|
+
- No \`$\` sigils: \`bg="background"\`, not \`bg="$background"\`.
|
|
180
|
+
- No condition objects: there is no \`hoverStyle={{ ... }}\` and no \`$sm={{ ... }}\`.
|
|
181
|
+
- Modifiers chain left to right and read as prefixes: \`hover:sm:small\`.
|
|
182
|
+
- Clauses work on variant props too, not just style props, so
|
|
183
|
+
\`size="lg sm:sm"\` selects a different variant value per condition.
|
|
184
|
+
- When two clauses both apply, the winner is decided by specificity, not by
|
|
185
|
+
source order: first by platform (\`ios:\` beats \`native:\` beats unprefixed),
|
|
186
|
+
then by how many conditions the clause carries, then by category
|
|
187
|
+
(media < container < theme < group < state). Writing a clause later in the
|
|
188
|
+
string does not make it win.
|
|
189
|
+
- A chain is capped at five distinct non-platform conditions.
|
|
190
|
+
|
|
191
|
+
## 7. Verify before reporting success
|
|
192
|
+
|
|
193
|
+
\`\`\`bash
|
|
194
|
+
npx tamagui check --strict
|
|
195
|
+
\`\`\`
|
|
196
|
+
|
|
197
|
+
\`tamagui check --strict\` reports version mismatches, duplicate installs, lockfile
|
|
198
|
+
problems, a missing config, and any v2 style syntax left in source. Then run the
|
|
199
|
+
project's own typecheck and build, and start the app and confirm a Tamagui
|
|
200
|
+
component renders with its styles applied. A passing typecheck is not sufficient:
|
|
201
|
+
single-token values are checked when \`settings.allowedStyleValues\` is enabled,
|
|
202
|
+
but conditional payloads also need the strict checker.
|
|
203
|
+
|
|
204
|
+
## 8. Give the agent the project's own vocabulary
|
|
205
|
+
|
|
206
|
+
Once the app runs, generate a description of this project's actual tokens,
|
|
207
|
+
themes, and components so later prompts do not guess at them:
|
|
208
|
+
|
|
209
|
+
\`\`\`bash
|
|
210
|
+
npx tamagui generate-prompt
|
|
211
|
+
\`\`\`
|
|
212
|
+
|
|
213
|
+
That writes \`tamagui-prompt.md\`. Keep it in the repo and regenerate it when the
|
|
214
|
+
config changes.
|
|
215
|
+
`;
|
|
216
|
+
}
|