@tamagui/cli 2.7.7 → 3.0.0-0.canary.1791057742817
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 +421 -278
- package/dist/cli.cjs +410 -340
- package/dist/generate-prompt.cjs +37 -386
- package/dist/generate.cjs +45 -54
- package/dist/icons.cjs +263 -0
- package/dist/index.cjs +1 -1
- package/dist/migrate.cjs +443 -0
- package/dist/preview-theme.cjs +70 -0
- package/dist/setup-prompt.cjs +216 -0
- package/dist/to-tailwind-default-config.cjs +874 -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 +45 -14
- package/src/build.ts +579 -361
- package/src/cli.ts +171 -24
- package/src/generate-prompt.ts +18 -526
- package/src/icons.ts +308 -0
- package/src/migrate.ts +428 -0
- package/src/preview-theme.ts +54 -0
- package/src/setup-prompt.ts +192 -0
- package/src/to-tailwind-default-config.ts +852 -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 +2 -2
- package/types/generate-prompt.d.ts.map +1 -1
- package/types/icons.d.ts +14 -0
- package/types/icons.d.ts.map +1 -0
- package/types/migrate.d.ts +7 -0
- package/types/migrate.d.ts.map +1 -0
- package/types/preview-theme.d.ts +8 -0
- package/types/preview-theme.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
package/dist/cli.cjs
CHANGED
|
@@ -5,370 +5,440 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
15
|
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
17
|
+
value: mod,
|
|
18
|
+
enumerable: true
|
|
24
19
|
}) : target, mod));
|
|
25
20
|
var import_arg = __toESM(require("arg"));
|
|
26
21
|
var import_chalk = __toESM(require("chalk"));
|
|
27
22
|
var import_utils = require("./utils.cjs");
|
|
28
|
-
|
|
29
|
-
process.on(_, () => {
|
|
30
|
-
(0, import_utils.disposeAll)();
|
|
31
|
-
process.exit();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
23
|
+
process.on("exit", import_utils.disposeAll);
|
|
34
24
|
const COMMAND_MAP = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
25
|
+
check: {
|
|
26
|
+
description: `Checks flat style values, inconsistent versions, duplicate installs, lockfile issues, and missing config.`,
|
|
27
|
+
shorthands: [],
|
|
28
|
+
flags: {
|
|
29
|
+
"--help": Boolean,
|
|
30
|
+
"--debug": Boolean,
|
|
31
|
+
"--verbose": Boolean,
|
|
32
|
+
"--styles-only": Boolean,
|
|
33
|
+
"--deps-only": Boolean,
|
|
34
|
+
"--strict": Boolean
|
|
35
|
+
},
|
|
36
|
+
async run() {
|
|
37
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
38
|
+
const options = await (0, import_utils.getOptions)({
|
|
39
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false,
|
|
40
|
+
loadTamaguiOptions: flags2["--strict"] && !flags2["--deps-only"]
|
|
41
|
+
});
|
|
42
|
+
if (!flags2["--styles-only"]) {
|
|
43
|
+
const { checkDeps } = require("@tamagui/static/checkDeps");
|
|
44
|
+
await checkDeps(options.paths.root);
|
|
45
|
+
}
|
|
46
|
+
if (flags2["--deps-only"]) return;
|
|
47
|
+
if (flags2["--strict"]) {
|
|
48
|
+
if (!options.tamaguiOptions.config) {
|
|
49
|
+
throw new Error("Strict style checking requires a Tamagui config.");
|
|
50
|
+
}
|
|
51
|
+
const { loadTamagui } = require("@tamagui/static/loadTamagui");
|
|
52
|
+
process.env.TAMAGUI_KEEP_THEMES = "1";
|
|
53
|
+
const loaded = await loadTamagui({
|
|
54
|
+
...options.tamaguiOptions,
|
|
55
|
+
platform: "web"
|
|
56
|
+
}, true);
|
|
57
|
+
if (!loaded?.tamaguiConfig) {
|
|
58
|
+
throw new Error("Unable to load the Tamagui config for strict style checking.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const { checkStyleFiles, formatCheckResults, MissingConfigArtifactError } = require("@tamagui/language-service/check");
|
|
62
|
+
try {
|
|
63
|
+
const result = checkStyleFiles({
|
|
64
|
+
root: options.paths.root,
|
|
65
|
+
configPath: options.paths.conf,
|
|
66
|
+
strict: flags2["--strict"]
|
|
67
|
+
});
|
|
68
|
+
console.info(formatCheckResults(result));
|
|
69
|
+
if (result.diagnosticCount > 0) process.exitCode = 1;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (error instanceof MissingConfigArtifactError && !flags2["--strict"]) {
|
|
72
|
+
console.warn(import_chalk.default.yellow(`skipping flat value check: ${error.message}`));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
generate: {
|
|
80
|
+
description: `Builds your entire tamagui configuration and outputs any CSS.`,
|
|
81
|
+
shorthands: [],
|
|
82
|
+
flags: {
|
|
83
|
+
"--help": Boolean,
|
|
84
|
+
"--debug": Boolean,
|
|
85
|
+
"--verbose": Boolean
|
|
86
|
+
},
|
|
87
|
+
async run() {
|
|
88
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
89
|
+
const options = await (0, import_utils.getOptions)({
|
|
90
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false,
|
|
91
|
+
loadTamaguiOptions: true
|
|
92
|
+
});
|
|
93
|
+
const { loadTamagui } = require("@tamagui/static/loadTamagui");
|
|
94
|
+
process.env.TAMAGUI_KEEP_THEMES = "1";
|
|
95
|
+
await loadTamagui({
|
|
96
|
+
...options.tamaguiOptions,
|
|
97
|
+
platform: "web"
|
|
98
|
+
}, true);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"generate-css": {
|
|
102
|
+
shorthands: [],
|
|
103
|
+
description: `Generate the tamagui.generated.css file from your config`,
|
|
104
|
+
flags: {
|
|
105
|
+
"--help": Boolean,
|
|
106
|
+
"--debug": Boolean,
|
|
107
|
+
"--verbose": Boolean,
|
|
108
|
+
"--output": String
|
|
109
|
+
},
|
|
110
|
+
async run() {
|
|
111
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
112
|
+
const options = await (0, import_utils.getOptions)({
|
|
113
|
+
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false,
|
|
114
|
+
loadTamaguiOptions: true
|
|
115
|
+
});
|
|
116
|
+
const outputPath = flags2["--output"] || options.tamaguiOptions.outputCSS || "./tamagui.generated.css";
|
|
117
|
+
const { loadTamagui } = require("@tamagui/static/loadTamagui");
|
|
118
|
+
process.env.TAMAGUI_KEEP_THEMES = "1";
|
|
119
|
+
await loadTamagui({
|
|
120
|
+
...options.tamaguiOptions,
|
|
121
|
+
outputCSS: outputPath,
|
|
122
|
+
platform: "web"
|
|
123
|
+
});
|
|
124
|
+
console.info(`Generated CSS to ${outputPath}`);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"generate-themes": {
|
|
128
|
+
shorthands: [],
|
|
129
|
+
description: `Use to pre-build your themes`,
|
|
130
|
+
flags: {
|
|
131
|
+
"--help": Boolean,
|
|
132
|
+
"--debug": Boolean,
|
|
133
|
+
"--verbose": Boolean
|
|
134
|
+
},
|
|
135
|
+
async run() {
|
|
136
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
137
|
+
const options = await (0, import_utils.getOptions)({ debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false });
|
|
138
|
+
const [_cmd, inPath, outPath] = _;
|
|
139
|
+
if (!inPath || !outPath) {
|
|
140
|
+
throw new Error(`Must supply both input and output paths, missing one (inPath: ${inPath}, outPath: ${outPath})`);
|
|
141
|
+
}
|
|
142
|
+
const { generateThemes, writeGeneratedThemes } = require("@tamagui/generate-themes");
|
|
143
|
+
try {
|
|
144
|
+
const generated = await generateThemes(inPath);
|
|
145
|
+
if (generated) {
|
|
146
|
+
await writeGeneratedThemes(options.paths.dotDir, outPath, generated);
|
|
147
|
+
console.info(`Successfully generated themes to ${outPath}`);
|
|
148
|
+
} else {
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
console.error(`Error generating themes: ${err}`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
add: {
|
|
158
|
+
shorthands: [],
|
|
159
|
+
description: `Use to add fonts and icons to your monorepo.`,
|
|
160
|
+
flags: {
|
|
161
|
+
"--help": Boolean,
|
|
162
|
+
"--debug": Boolean,
|
|
163
|
+
"--verbose": Boolean
|
|
164
|
+
},
|
|
165
|
+
async run() {
|
|
166
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
167
|
+
const { installGeneratedPackage } = require("./add.cjs");
|
|
168
|
+
const [cmd, type, path] = _;
|
|
169
|
+
await installGeneratedPackage(type, path);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
icons: {
|
|
173
|
+
shorthands: [],
|
|
174
|
+
description: `Generate themed SVG icon components from Lucide, Heroicons, Phosphor, or a folder of svgs.`,
|
|
175
|
+
usage: `$ tamagui icons add Search ChevronDown
|
|
176
|
+
$ tamagui icons add Copy --from phosphor --weight bold
|
|
177
|
+
$ tamagui icons add Clipboard --from heroicons --variant solid
|
|
178
|
+
$ tamagui icons add Logo --from ./assets/icons --out src/icons
|
|
179
|
+
$ tamagui icons add Search=magnifying-glass --from phosphor`,
|
|
180
|
+
flags: {
|
|
181
|
+
"--help": Boolean,
|
|
182
|
+
"--from": String,
|
|
183
|
+
"--weight": String,
|
|
184
|
+
"--variant": String,
|
|
185
|
+
"--out": String
|
|
186
|
+
},
|
|
187
|
+
async run() {
|
|
188
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
189
|
+
const [_cmd, subcommand, ...names] = _;
|
|
190
|
+
if (subcommand !== "add") {
|
|
191
|
+
throw new Error("usage: tamagui icons add <Name...> [--from] [--out]");
|
|
192
|
+
}
|
|
193
|
+
const { addIcons } = require("./icons.cjs");
|
|
194
|
+
await addIcons({
|
|
195
|
+
names,
|
|
196
|
+
from: flags2["--from"],
|
|
197
|
+
weight: flags2["--weight"],
|
|
198
|
+
variant: flags2["--variant"],
|
|
199
|
+
out: flags2["--out"]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
build: {
|
|
204
|
+
shorthands: ["b"],
|
|
205
|
+
description: `Use to pre-build a Tamagui component directory. Use -- to run a command after optimization, then auto-restore files.`,
|
|
206
|
+
flags: {
|
|
207
|
+
"--help": Boolean,
|
|
208
|
+
"--debug": Boolean,
|
|
209
|
+
"--verbose": Boolean,
|
|
210
|
+
"--dry-run": Boolean,
|
|
211
|
+
"--target": String,
|
|
212
|
+
"--include": String,
|
|
213
|
+
"--exclude": String,
|
|
214
|
+
"--output": String,
|
|
215
|
+
"--output-around": Boolean,
|
|
216
|
+
"--expect-optimizations": Number
|
|
217
|
+
},
|
|
218
|
+
async run() {
|
|
219
|
+
const argvSeparatorIdx = process.argv.indexOf("--");
|
|
220
|
+
let runCommand;
|
|
221
|
+
if (argvSeparatorIdx !== -1) {
|
|
222
|
+
runCommand = process.argv.slice(argvSeparatorIdx + 1);
|
|
223
|
+
const argsBeforeSeparator = process.argv.slice(0, argvSeparatorIdx);
|
|
224
|
+
process.argv = argsBeforeSeparator;
|
|
225
|
+
}
|
|
226
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
227
|
+
const [_command, dir] = _;
|
|
228
|
+
const dryRun = flags2["--dry-run"] || false;
|
|
229
|
+
const debug = flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false;
|
|
230
|
+
const { build } = require("./build.cjs");
|
|
231
|
+
const options = await (0, import_utils.getOptions)({ debug });
|
|
232
|
+
await build({
|
|
233
|
+
...options,
|
|
234
|
+
dir,
|
|
235
|
+
include: flags2["--include"],
|
|
236
|
+
target: flags2["--target"] || "both",
|
|
237
|
+
exclude: flags2["--exclude"],
|
|
238
|
+
output: flags2["--output"],
|
|
239
|
+
outputAround: flags2["--output-around"],
|
|
240
|
+
expectOptimizations: flags2["--expect-optimizations"],
|
|
241
|
+
runCommand,
|
|
242
|
+
dryRun
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
upgrade: {
|
|
247
|
+
shorthands: ["up"],
|
|
248
|
+
description: `Upgrade all tamagui packages in your workspace to the latest version`,
|
|
249
|
+
flags: {
|
|
250
|
+
"--help": Boolean,
|
|
251
|
+
"--debug": Boolean,
|
|
252
|
+
"--from": String,
|
|
253
|
+
"--to": String,
|
|
254
|
+
"--changelog-only": Boolean,
|
|
255
|
+
"--dry-run": Boolean
|
|
256
|
+
},
|
|
257
|
+
async run() {
|
|
258
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
259
|
+
const { upgrade } = require("./upgrade.cjs");
|
|
260
|
+
await upgrade({
|
|
261
|
+
from: flags2["--from"],
|
|
262
|
+
to: flags2["--to"],
|
|
263
|
+
changelogOnly: flags2["--changelog-only"],
|
|
264
|
+
dryRun: flags2["--dry-run"],
|
|
265
|
+
debug: flags2["--debug"]
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
setup: {
|
|
270
|
+
shorthands: [],
|
|
271
|
+
description: `Print an AI-agent prompt for adding Tamagui to a project for the first time`,
|
|
272
|
+
usage: `$ tamagui setup`,
|
|
273
|
+
flags: { "--help": Boolean },
|
|
274
|
+
async run() {
|
|
275
|
+
const { printSetupPrompt } = require("./setup-prompt.cjs");
|
|
276
|
+
printSetupPrompt();
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
migrate: {
|
|
280
|
+
shorthands: [],
|
|
281
|
+
description: `Print an AI-agent prompt for migrating a Tamagui app to v3`,
|
|
282
|
+
usage: `$ tamagui migrate --from v2
|
|
283
|
+
$ tamagui migrate --from v1`,
|
|
284
|
+
flags: {
|
|
285
|
+
"--help": Boolean,
|
|
286
|
+
"--from": String
|
|
287
|
+
},
|
|
288
|
+
async run() {
|
|
289
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
290
|
+
const [_cmd, fromArg] = _;
|
|
291
|
+
const { printMigrationPrompt } = require("./migrate.cjs");
|
|
292
|
+
printMigrationPrompt({ from: flags2["--from"] || fromArg });
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
"to-tailwind": {
|
|
296
|
+
shorthands: [],
|
|
297
|
+
description: `Convert Tamagui JSX props in files or globs to Tailwind className syntax`,
|
|
298
|
+
flags: {
|
|
299
|
+
"--help": Boolean,
|
|
300
|
+
"--write": Boolean,
|
|
301
|
+
"--config": String,
|
|
302
|
+
"--use-default-config": Boolean,
|
|
303
|
+
"--rename-dom": Boolean
|
|
304
|
+
},
|
|
305
|
+
async run() {
|
|
306
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
307
|
+
const { toTailwind } = require("./to-tailwind.cjs");
|
|
308
|
+
const [_cmd, ...patterns] = _;
|
|
309
|
+
await toTailwind({
|
|
310
|
+
patterns,
|
|
311
|
+
write: flags2["--write"],
|
|
312
|
+
configPath: flags2["--config"],
|
|
313
|
+
useDefaultConfig: flags2["--use-default-config"],
|
|
314
|
+
renameDom: flags2["--rename-dom"]
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
"update-template": {
|
|
319
|
+
shorthands: ["ut"],
|
|
320
|
+
description: `Used to update your git repo with the source template. (e.g. Takeout)`,
|
|
321
|
+
flags: {
|
|
322
|
+
"--help": Boolean,
|
|
323
|
+
"--template-repo": String,
|
|
324
|
+
"--ignored-patterns": String
|
|
325
|
+
},
|
|
326
|
+
async run() {
|
|
327
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
328
|
+
const { updateTemplate } = require("./update-template.cjs");
|
|
329
|
+
if (!flags2["--template-repo"]) {
|
|
330
|
+
throw new Error("--template-repo is required");
|
|
331
|
+
}
|
|
332
|
+
await updateTemplate(flags2["--template-repo"], flags2["--ignored-patterns"]?.split(" "));
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
"generate-prompt": {
|
|
336
|
+
shorthands: [],
|
|
337
|
+
description: `Generate an LLM-friendly markdown file from your Tamagui config`,
|
|
338
|
+
flags: {
|
|
339
|
+
"--help": Boolean,
|
|
340
|
+
"--debug": Boolean,
|
|
341
|
+
"--output": String
|
|
342
|
+
},
|
|
343
|
+
async run() {
|
|
344
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
345
|
+
const { generatePrompt } = require("./generate-prompt.cjs");
|
|
346
|
+
const options = await (0, import_utils.getOptions)({
|
|
347
|
+
debug: flags2["--debug"] ? true : false,
|
|
348
|
+
loadTamaguiOptions: true
|
|
349
|
+
});
|
|
350
|
+
await generatePrompt({
|
|
351
|
+
...options,
|
|
352
|
+
output: flags2["--output"]
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
"preview-theme": {
|
|
357
|
+
shorthands: ["preview"],
|
|
358
|
+
description: `Preview a theme configuration in the browser on tamagui.dev/theme`,
|
|
359
|
+
usage: `$ tamagui preview-theme ./theme.json
|
|
360
|
+
$ tamagui preview-theme --theme '{"palettes": ...}'
|
|
361
|
+
$ tamagui preview-theme ./theme.json --print`,
|
|
362
|
+
flags: {
|
|
363
|
+
"--help": Boolean,
|
|
364
|
+
"--theme": String,
|
|
365
|
+
"--url": String,
|
|
366
|
+
"--print": Boolean
|
|
367
|
+
},
|
|
368
|
+
async run() {
|
|
369
|
+
const { _, ...flags2 } = (0, import_arg.default)(this.flags);
|
|
370
|
+
const [_cmd, themeArg] = _;
|
|
371
|
+
const { previewTheme } = require("./preview-theme.cjs");
|
|
372
|
+
await previewTheme({
|
|
373
|
+
theme: flags2["--theme"],
|
|
374
|
+
themeArg,
|
|
375
|
+
url: flags2["--url"],
|
|
376
|
+
print: flags2["--print"]
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
}
|
|
309
380
|
};
|
|
310
|
-
const commandEntries = Object.keys(COMMAND_MAP).flatMap(command2 => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
381
|
+
const commandEntries = Object.keys(COMMAND_MAP).flatMap((command2) => {
|
|
382
|
+
const definition2 = COMMAND_MAP[command2];
|
|
383
|
+
const entries = [command2, ...definition2.shorthands].map((cmd) => {
|
|
384
|
+
return [cmd, definition2];
|
|
385
|
+
});
|
|
386
|
+
return entries;
|
|
316
387
|
});
|
|
317
388
|
const commands = Object.fromEntries(commandEntries);
|
|
318
|
-
const {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
"--help": Boolean,
|
|
323
|
-
"--version": Boolean
|
|
324
|
-
}, {
|
|
325
|
-
permissive: true
|
|
326
|
-
});
|
|
389
|
+
const { _: [command], ...flags } = (0, import_arg.default)({
|
|
390
|
+
"--help": Boolean,
|
|
391
|
+
"--version": Boolean
|
|
392
|
+
}, { permissive: true });
|
|
327
393
|
if (flags["--version"]) {
|
|
328
|
-
|
|
329
|
-
|
|
394
|
+
console.info(require("../package.json").version);
|
|
395
|
+
process.exit(0);
|
|
330
396
|
}
|
|
331
397
|
if (!command && flags["--help"]) {
|
|
332
|
-
|
|
398
|
+
console.info(`$ tamagui
|
|
333
399
|
|
|
334
400
|
commands:
|
|
335
401
|
|
|
336
|
-
${Object.keys(COMMAND_MAP).map(key => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
402
|
+
${Object.keys(COMMAND_MAP).map((key) => {
|
|
403
|
+
return ` ${key}`;
|
|
404
|
+
}).join("\n")}`);
|
|
405
|
+
process.exit(0);
|
|
340
406
|
}
|
|
341
407
|
if (!(command in commands)) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
408
|
+
console.error();
|
|
409
|
+
console.warn(import_chalk.default.yellow(`Not a valid command: ${command}`));
|
|
410
|
+
process.exit(1);
|
|
345
411
|
}
|
|
346
412
|
const definition = commands[command];
|
|
347
413
|
main();
|
|
348
414
|
async function main() {
|
|
349
|
-
|
|
350
|
-
|
|
415
|
+
if (flags["--help"]) {
|
|
416
|
+
console.info(`
|
|
351
417
|
$ tamagui ${command}: ${definition.description}
|
|
352
418
|
`);
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
419
|
+
if ("usage" in definition && definition.usage) {
|
|
420
|
+
console.info(`Usage:
|
|
421
|
+
${definition.usage}
|
|
422
|
+
`);
|
|
423
|
+
}
|
|
424
|
+
console.info(`Flags:
|
|
425
|
+
${Object.entries(definition.flags).map(([k, v]) => ` ${k} (${v.name})`).join("\n")}`);
|
|
426
|
+
process.exit(0);
|
|
427
|
+
}
|
|
428
|
+
const { _, ...cmdFlags } = (0, import_arg.default)(definition.flags);
|
|
429
|
+
if (cmdFlags["--help"]) {
|
|
430
|
+
console.info(`$ tamagui ${_}
|
|
362
431
|
|
|
363
432
|
Flags: ${JSON.stringify(cmdFlags, null, 2)}
|
|
364
433
|
|
|
365
434
|
`);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
435
|
+
process.exit(0);
|
|
436
|
+
}
|
|
437
|
+
try {
|
|
438
|
+
await definition.run();
|
|
439
|
+
} catch (err) {
|
|
440
|
+
console.error(`Error running command: ${err.message}`);
|
|
441
|
+
process.exit(1);
|
|
442
|
+
}
|
|
443
|
+
process.exit(process.exitCode ?? 0);
|
|
444
|
+
}
|