@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.
Files changed (46) hide show
  1. package/dist/add.cjs +76 -87
  2. package/dist/build.cjs +425 -278
  3. package/dist/cli.cjs +361 -340
  4. package/dist/generate-prompt.cjs +484 -362
  5. package/dist/generate.cjs +45 -54
  6. package/dist/index.cjs +1 -1
  7. package/dist/migrate.cjs +437 -0
  8. package/dist/setup-prompt.cjs +216 -0
  9. package/dist/to-tailwind-default-config.cjs +789 -0
  10. package/dist/to-tailwind.cjs +213 -0
  11. package/dist/update-template.cjs +43 -52
  12. package/dist/update.cjs +14 -18
  13. package/dist/upgrade.cjs +417 -401
  14. package/dist/utils.cjs +84 -101
  15. package/metro.cjs +1 -0
  16. package/metro.d.ts +1 -0
  17. package/metro.mjs +1 -0
  18. package/package.json +43 -13
  19. package/src/build.ts +594 -362
  20. package/src/cli.ts +113 -12
  21. package/src/generate-prompt.ts +428 -329
  22. package/src/migrate.ts +422 -0
  23. package/src/setup-prompt.ts +192 -0
  24. package/src/to-tailwind-default-config.ts +767 -0
  25. package/src/to-tailwind.ts +313 -0
  26. package/src/upgrade.ts +30 -33
  27. package/src/utils.ts +11 -9
  28. package/types/add.d.ts +1 -1
  29. package/types/add.d.ts.map +1 -1
  30. package/types/build.d.ts +2 -1
  31. package/types/build.d.ts.map +1 -1
  32. package/types/generate-prompt.d.ts +6 -2
  33. package/types/generate-prompt.d.ts.map +1 -1
  34. package/types/migrate.d.ts +7 -0
  35. package/types/migrate.d.ts.map +1 -0
  36. package/types/setup-prompt.d.ts +5 -0
  37. package/types/setup-prompt.d.ts.map +1 -0
  38. package/types/to-tailwind-default-config.d.ts +53 -0
  39. package/types/to-tailwind-default-config.d.ts.map +1 -0
  40. package/types/to-tailwind.d.ts +16 -0
  41. package/types/to-tailwind.d.ts.map +1 -0
  42. package/types/upgrade.d.ts.map +1 -1
  43. package/types/utils.d.ts.map +1 -1
  44. package/vite.cjs +1 -0
  45. package/vite.d.ts +1 -0
  46. package/vite.mjs +1 -0
package/dist/cli.cjs CHANGED
@@ -5,370 +5,391 @@ 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
- 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;
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
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
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
- ["exit", "SIGINT"].forEach(_ => {
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
- check: {
36
- description: `Checks for inconsistent versions, duplicate installs, lockfile issues, and missing config.`,
37
- shorthands: [],
38
- flags: {
39
- "--help": Boolean,
40
- "--debug": Boolean,
41
- "--verbose": Boolean
42
- },
43
- async run() {
44
- const {
45
- _,
46
- ...flags2
47
- } = (0, import_arg.default)(this.flags);
48
- const options = await (0, import_utils.getOptions)({
49
- debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false
50
- });
51
- const {
52
- checkDeps
53
- } = require("@tamagui/static/checkDeps");
54
- await checkDeps(options.paths.root);
55
- }
56
- },
57
- generate: {
58
- description: `Builds your entire tamagui configuration and outputs any CSS.`,
59
- shorthands: [],
60
- flags: {
61
- "--help": Boolean,
62
- "--debug": Boolean,
63
- "--verbose": Boolean
64
- },
65
- async run() {
66
- const {
67
- _,
68
- ...flags2
69
- } = (0, import_arg.default)(this.flags);
70
- const options = await (0, import_utils.getOptions)({
71
- debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false,
72
- loadTamaguiOptions: true
73
- });
74
- const {
75
- loadTamagui
76
- } = require("@tamagui/static/loadTamagui");
77
- process.env.TAMAGUI_KEEP_THEMES = "1";
78
- await loadTamagui({
79
- ...options.tamaguiOptions,
80
- platform: "web"
81
- });
82
- const {
83
- generatePrompt
84
- } = require("./generate-prompt.cjs");
85
- const {
86
- join
87
- } = require("node:path");
88
- await generatePrompt({
89
- ...options,
90
- output: join(options.paths.dotDir, "prompt.md")
91
- });
92
- }
93
- },
94
- "generate-css": {
95
- shorthands: [],
96
- description: `Generate the tamagui.generated.css file from your config`,
97
- flags: {
98
- "--help": Boolean,
99
- "--debug": Boolean,
100
- "--verbose": Boolean,
101
- "--output": String
102
- },
103
- async run() {
104
- const {
105
- _,
106
- ...flags2
107
- } = (0, import_arg.default)(this.flags);
108
- const options = await (0, import_utils.getOptions)({
109
- debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false,
110
- loadTamaguiOptions: true
111
- });
112
- const outputPath = flags2["--output"] || options.tamaguiOptions.outputCSS || "./tamagui.generated.css";
113
- const {
114
- loadTamagui
115
- } = require("@tamagui/static/loadTamagui");
116
- process.env.TAMAGUI_KEEP_THEMES = "1";
117
- await loadTamagui({
118
- ...options.tamaguiOptions,
119
- outputCSS: outputPath,
120
- platform: "web"
121
- });
122
- console.info(`Generated CSS to ${outputPath}`);
123
- }
124
- },
125
- "generate-themes": {
126
- shorthands: [],
127
- description: `Use to pre-build your themes`,
128
- flags: {
129
- "--help": Boolean,
130
- "--debug": Boolean,
131
- "--verbose": Boolean
132
- },
133
- async run() {
134
- const {
135
- _,
136
- ...flags2
137
- } = (0, import_arg.default)(this.flags);
138
- const options = await (0, import_utils.getOptions)({
139
- debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false
140
- });
141
- const [_cmd, inPath, outPath] = _;
142
- if (!inPath || !outPath) {
143
- throw new Error(`Must supply both input and output paths, missing one (inPath: ${inPath}, outPath: ${outPath})`);
144
- }
145
- const {
146
- generateThemes,
147
- writeGeneratedThemes
148
- } = require("@tamagui/generate-themes");
149
- try {
150
- const generated = await generateThemes(inPath);
151
- if (generated) {
152
- await writeGeneratedThemes(options.paths.dotDir, outPath, generated);
153
- console.info(`Successfully generated themes to ${outPath}`);
154
- } else {
155
- process.exit(1);
156
- }
157
- } catch (err) {
158
- console.error(`Error generating themes: ${err}`);
159
- return;
160
- }
161
- }
162
- },
163
- add: {
164
- shorthands: [],
165
- description: `Use to add fonts and icons to your monorepo.`,
166
- flags: {
167
- "--help": Boolean,
168
- "--debug": Boolean,
169
- "--verbose": Boolean
170
- },
171
- async run() {
172
- const {
173
- _,
174
- ...flags2
175
- } = (0, import_arg.default)(this.flags);
176
- const {
177
- installGeneratedPackage
178
- } = require("./add.cjs");
179
- const [cmd, type, path] = _;
180
- await installGeneratedPackage(type, path);
181
- }
182
- },
183
- build: {
184
- shorthands: ["b"],
185
- description: `Use to pre-build a Tamagui component directory. Use -- to run a command after optimization, then auto-restore files.`,
186
- flags: {
187
- "--help": Boolean,
188
- "--debug": Boolean,
189
- "--verbose": Boolean,
190
- "--dry-run": Boolean,
191
- "--target": String,
192
- "--include": String,
193
- "--exclude": String,
194
- "--output": String,
195
- "--output-around": Boolean,
196
- "--expect-optimizations": Number
197
- },
198
- async run() {
199
- const argvSeparatorIdx = process.argv.indexOf("--");
200
- let runCommand;
201
- if (argvSeparatorIdx !== -1) {
202
- runCommand = process.argv.slice(argvSeparatorIdx + 1);
203
- const argsBeforeSeparator = process.argv.slice(0, argvSeparatorIdx);
204
- process.argv = argsBeforeSeparator;
205
- }
206
- const {
207
- _,
208
- ...flags2
209
- } = (0, import_arg.default)(this.flags);
210
- const [_command, dir] = _;
211
- const dryRun = flags2["--dry-run"] || false;
212
- const debug = flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false;
213
- const {
214
- build
215
- } = require("./build.cjs");
216
- const options = await (0, import_utils.getOptions)({
217
- debug
218
- });
219
- await build({
220
- ...options,
221
- dir,
222
- include: flags2["--include"],
223
- target: flags2["--target"] || "both",
224
- exclude: flags2["--exclude"],
225
- output: flags2["--output"],
226
- outputAround: flags2["--output-around"],
227
- expectOptimizations: flags2["--expect-optimizations"],
228
- runCommand,
229
- dryRun
230
- });
231
- }
232
- },
233
- upgrade: {
234
- shorthands: ["up"],
235
- description: `Upgrade all tamagui packages in your workspace to the latest version`,
236
- flags: {
237
- "--help": Boolean,
238
- "--debug": Boolean,
239
- "--from": String,
240
- "--to": String,
241
- "--changelog-only": Boolean,
242
- "--dry-run": Boolean
243
- },
244
- async run() {
245
- const {
246
- _,
247
- ...flags2
248
- } = (0, import_arg.default)(this.flags);
249
- const {
250
- upgrade
251
- } = require("./upgrade.cjs");
252
- await upgrade({
253
- from: flags2["--from"],
254
- to: flags2["--to"],
255
- changelogOnly: flags2["--changelog-only"],
256
- dryRun: flags2["--dry-run"],
257
- debug: flags2["--debug"]
258
- });
259
- }
260
- },
261
- "update-template": {
262
- shorthands: ["ut"],
263
- description: `Used to update your git repo with the source template. (e.g. Takeout)`,
264
- flags: {
265
- "--help": Boolean,
266
- "--template-repo": String,
267
- "--ignored-patterns": String
268
- },
269
- async run() {
270
- const {
271
- _,
272
- ...flags2
273
- } = (0, import_arg.default)(this.flags);
274
- const {
275
- updateTemplate
276
- } = require("./update-template.cjs");
277
- if (!flags2["--template-repo"]) {
278
- throw new Error("--template-repo is required");
279
- }
280
- await updateTemplate(flags2["--template-repo"], flags2["--ignored-patterns"]?.split(" "));
281
- }
282
- },
283
- "generate-prompt": {
284
- shorthands: [],
285
- description: `Generate an LLM-friendly markdown file from your Tamagui config`,
286
- flags: {
287
- "--help": Boolean,
288
- "--debug": Boolean,
289
- "--output": String
290
- },
291
- async run() {
292
- const {
293
- _,
294
- ...flags2
295
- } = (0, import_arg.default)(this.flags);
296
- const {
297
- generatePrompt
298
- } = require("./generate-prompt.cjs");
299
- const options = await (0, import_utils.getOptions)({
300
- debug: flags2["--debug"] ? true : false,
301
- loadTamaguiOptions: true
302
- });
303
- await generatePrompt({
304
- ...options,
305
- output: flags2["--output"]
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
+ });
99
+ const { generatePrompt } = require("./generate-prompt.cjs");
100
+ const { join } = require("node:path");
101
+ await generatePrompt({
102
+ ...options,
103
+ output: join(options.paths.dotDir, "prompt.md")
104
+ });
105
+ }
106
+ },
107
+ "generate-css": {
108
+ shorthands: [],
109
+ description: `Generate the tamagui.generated.css file from your config`,
110
+ flags: {
111
+ "--help": Boolean,
112
+ "--debug": Boolean,
113
+ "--verbose": Boolean,
114
+ "--output": String
115
+ },
116
+ async run() {
117
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
118
+ const options = await (0, import_utils.getOptions)({
119
+ debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false,
120
+ loadTamaguiOptions: true
121
+ });
122
+ const outputPath = flags2["--output"] || options.tamaguiOptions.outputCSS || "./tamagui.generated.css";
123
+ const { loadTamagui } = require("@tamagui/static/loadTamagui");
124
+ process.env.TAMAGUI_KEEP_THEMES = "1";
125
+ await loadTamagui({
126
+ ...options.tamaguiOptions,
127
+ outputCSS: outputPath,
128
+ platform: "web"
129
+ });
130
+ console.info(`Generated CSS to ${outputPath}`);
131
+ }
132
+ },
133
+ "generate-themes": {
134
+ shorthands: [],
135
+ description: `Use to pre-build your themes`,
136
+ flags: {
137
+ "--help": Boolean,
138
+ "--debug": Boolean,
139
+ "--verbose": Boolean
140
+ },
141
+ async run() {
142
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
143
+ const options = await (0, import_utils.getOptions)({ debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false });
144
+ const [_cmd, inPath, outPath] = _;
145
+ if (!inPath || !outPath) {
146
+ throw new Error(`Must supply both input and output paths, missing one (inPath: ${inPath}, outPath: ${outPath})`);
147
+ }
148
+ const { generateThemes, writeGeneratedThemes } = require("@tamagui/generate-themes");
149
+ try {
150
+ const generated = await generateThemes(inPath);
151
+ if (generated) {
152
+ await writeGeneratedThemes(options.paths.dotDir, outPath, generated);
153
+ console.info(`Successfully generated themes to ${outPath}`);
154
+ } else {
155
+ process.exit(1);
156
+ }
157
+ } catch (err) {
158
+ console.error(`Error generating themes: ${err}`);
159
+ return;
160
+ }
161
+ }
162
+ },
163
+ add: {
164
+ shorthands: [],
165
+ description: `Use to add fonts and icons to your monorepo.`,
166
+ flags: {
167
+ "--help": Boolean,
168
+ "--debug": Boolean,
169
+ "--verbose": Boolean
170
+ },
171
+ async run() {
172
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
173
+ const { installGeneratedPackage } = require("./add.cjs");
174
+ const [cmd, type, path] = _;
175
+ await installGeneratedPackage(type, path);
176
+ }
177
+ },
178
+ build: {
179
+ shorthands: ["b"],
180
+ description: `Use to pre-build a Tamagui component directory. Use -- to run a command after optimization, then auto-restore files.`,
181
+ flags: {
182
+ "--help": Boolean,
183
+ "--debug": Boolean,
184
+ "--verbose": Boolean,
185
+ "--dry-run": Boolean,
186
+ "--target": String,
187
+ "--include": String,
188
+ "--exclude": String,
189
+ "--output": String,
190
+ "--output-around": Boolean,
191
+ "--expect-optimizations": Number
192
+ },
193
+ async run() {
194
+ const argvSeparatorIdx = process.argv.indexOf("--");
195
+ let runCommand;
196
+ if (argvSeparatorIdx !== -1) {
197
+ runCommand = process.argv.slice(argvSeparatorIdx + 1);
198
+ const argsBeforeSeparator = process.argv.slice(0, argvSeparatorIdx);
199
+ process.argv = argsBeforeSeparator;
200
+ }
201
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
202
+ const [_command, dir] = _;
203
+ const dryRun = flags2["--dry-run"] || false;
204
+ const debug = flags2["--debug"] ? flags2["--verbose"] ? "verbose" : true : false;
205
+ const { build } = require("./build.cjs");
206
+ const options = await (0, import_utils.getOptions)({ debug });
207
+ await build({
208
+ ...options,
209
+ dir,
210
+ include: flags2["--include"],
211
+ target: flags2["--target"] || "both",
212
+ exclude: flags2["--exclude"],
213
+ output: flags2["--output"],
214
+ outputAround: flags2["--output-around"],
215
+ expectOptimizations: flags2["--expect-optimizations"],
216
+ runCommand,
217
+ dryRun
218
+ });
219
+ }
220
+ },
221
+ upgrade: {
222
+ shorthands: ["up"],
223
+ description: `Upgrade all tamagui packages in your workspace to the latest version`,
224
+ flags: {
225
+ "--help": Boolean,
226
+ "--debug": Boolean,
227
+ "--from": String,
228
+ "--to": String,
229
+ "--changelog-only": Boolean,
230
+ "--dry-run": Boolean
231
+ },
232
+ async run() {
233
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
234
+ const { upgrade } = require("./upgrade.cjs");
235
+ await upgrade({
236
+ from: flags2["--from"],
237
+ to: flags2["--to"],
238
+ changelogOnly: flags2["--changelog-only"],
239
+ dryRun: flags2["--dry-run"],
240
+ debug: flags2["--debug"]
241
+ });
242
+ }
243
+ },
244
+ setup: {
245
+ shorthands: [],
246
+ description: `Print an AI-agent prompt for adding Tamagui to a project for the first time`,
247
+ usage: `$ tamagui setup`,
248
+ flags: { "--help": Boolean },
249
+ async run() {
250
+ const { printSetupPrompt } = require("./setup-prompt.cjs");
251
+ printSetupPrompt();
252
+ }
253
+ },
254
+ migrate: {
255
+ shorthands: [],
256
+ description: `Print an AI-agent prompt for migrating a Tamagui app to v3`,
257
+ usage: `$ tamagui migrate --from v2
258
+ $ tamagui migrate --from v1`,
259
+ flags: {
260
+ "--help": Boolean,
261
+ "--from": String
262
+ },
263
+ async run() {
264
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
265
+ const [_cmd, fromArg] = _;
266
+ const { printMigrationPrompt } = require("./migrate.cjs");
267
+ printMigrationPrompt({ from: flags2["--from"] || fromArg });
268
+ }
269
+ },
270
+ "to-tailwind": {
271
+ shorthands: [],
272
+ description: `Convert Tamagui JSX props in files or globs to Tailwind className syntax`,
273
+ flags: {
274
+ "--help": Boolean,
275
+ "--write": Boolean,
276
+ "--config": String,
277
+ "--use-default-config": Boolean,
278
+ "--rename-dom": Boolean
279
+ },
280
+ async run() {
281
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
282
+ const { toTailwind } = require("./to-tailwind.cjs");
283
+ const [_cmd, ...patterns] = _;
284
+ await toTailwind({
285
+ patterns,
286
+ write: flags2["--write"],
287
+ configPath: flags2["--config"],
288
+ useDefaultConfig: flags2["--use-default-config"],
289
+ renameDom: flags2["--rename-dom"]
290
+ });
291
+ }
292
+ },
293
+ "update-template": {
294
+ shorthands: ["ut"],
295
+ description: `Used to update your git repo with the source template. (e.g. Takeout)`,
296
+ flags: {
297
+ "--help": Boolean,
298
+ "--template-repo": String,
299
+ "--ignored-patterns": String
300
+ },
301
+ async run() {
302
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
303
+ const { updateTemplate } = require("./update-template.cjs");
304
+ if (!flags2["--template-repo"]) {
305
+ throw new Error("--template-repo is required");
306
+ }
307
+ await updateTemplate(flags2["--template-repo"], flags2["--ignored-patterns"]?.split(" "));
308
+ }
309
+ },
310
+ "generate-prompt": {
311
+ shorthands: [],
312
+ description: `Generate an LLM-friendly markdown file from your Tamagui config`,
313
+ flags: {
314
+ "--help": Boolean,
315
+ "--debug": Boolean,
316
+ "--output": String
317
+ },
318
+ async run() {
319
+ const { _, ...flags2 } = (0, import_arg.default)(this.flags);
320
+ const { generatePrompt } = require("./generate-prompt.cjs");
321
+ const options = await (0, import_utils.getOptions)({
322
+ debug: flags2["--debug"] ? true : false,
323
+ loadTamaguiOptions: true
324
+ });
325
+ await generatePrompt({
326
+ ...options,
327
+ output: flags2["--output"]
328
+ });
329
+ }
330
+ }
309
331
  };
310
- const commandEntries = Object.keys(COMMAND_MAP).flatMap(command2 => {
311
- const definition2 = COMMAND_MAP[command2];
312
- const entries = [command2, ...definition2.shorthands].map(cmd => {
313
- return [cmd, definition2];
314
- });
315
- return entries;
332
+ const commandEntries = Object.keys(COMMAND_MAP).flatMap((command2) => {
333
+ const definition2 = COMMAND_MAP[command2];
334
+ const entries = [command2, ...definition2.shorthands].map((cmd) => {
335
+ return [cmd, definition2];
336
+ });
337
+ return entries;
316
338
  });
317
339
  const commands = Object.fromEntries(commandEntries);
318
- const {
319
- _: [command],
320
- ...flags
321
- } = (0, import_arg.default)({
322
- "--help": Boolean,
323
- "--version": Boolean
324
- }, {
325
- permissive: true
326
- });
340
+ const { _: [command], ...flags } = (0, import_arg.default)({
341
+ "--help": Boolean,
342
+ "--version": Boolean
343
+ }, { permissive: true });
327
344
  if (flags["--version"]) {
328
- console.info(require("../package.json").version);
329
- process.exit(0);
345
+ console.info(require("../package.json").version);
346
+ process.exit(0);
330
347
  }
331
348
  if (!command && flags["--help"]) {
332
- console.info(`$ tamagui
349
+ console.info(`$ tamagui
333
350
 
334
351
  commands:
335
352
 
336
- ${Object.keys(COMMAND_MAP).map(key => {
337
- return ` ${key}`;
338
- }).join("\n")}`);
339
- process.exit(0);
353
+ ${Object.keys(COMMAND_MAP).map((key) => {
354
+ return ` ${key}`;
355
+ }).join("\n")}`);
356
+ process.exit(0);
340
357
  }
341
358
  if (!(command in commands)) {
342
- console.error();
343
- console.warn(import_chalk.default.yellow(`Not a valid command: ${command}`));
344
- process.exit(1);
359
+ console.error();
360
+ console.warn(import_chalk.default.yellow(`Not a valid command: ${command}`));
361
+ process.exit(1);
345
362
  }
346
363
  const definition = commands[command];
347
364
  main();
348
365
  async function main() {
349
- if (flags["--help"]) {
350
- console.info(`
366
+ if (flags["--help"]) {
367
+ console.info(`
351
368
  $ tamagui ${command}: ${definition.description}
352
369
  `);
353
- console.info(`Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`);
354
- process.exit(0);
355
- }
356
- const {
357
- _,
358
- ...cmdFlags
359
- } = (0, import_arg.default)(definition.flags);
360
- if (cmdFlags["--help"]) {
361
- console.info(`$ tamagui ${_}
370
+ if ("usage" in definition && definition.usage) {
371
+ console.info(`Usage:
372
+ ${definition.usage}
373
+ `);
374
+ }
375
+ console.info(`Flags:
376
+ ${Object.entries(definition.flags).map(([k, v]) => ` ${k} (${v.name})`).join("\n")}`);
377
+ process.exit(0);
378
+ }
379
+ const { _, ...cmdFlags } = (0, import_arg.default)(definition.flags);
380
+ if (cmdFlags["--help"]) {
381
+ console.info(`$ tamagui ${_}
362
382
 
363
383
  Flags: ${JSON.stringify(cmdFlags, null, 2)}
364
384
 
365
385
  `);
366
- process.exit(0);
367
- }
368
- try {
369
- await definition.run();
370
- } catch (err) {
371
- console.error(`Error running command: ${err.message}`);
372
- }
373
- process.exit(0);
374
- }
386
+ process.exit(0);
387
+ }
388
+ try {
389
+ await definition.run();
390
+ } catch (err) {
391
+ console.error(`Error running command: ${err.message}`);
392
+ process.exit(1);
393
+ }
394
+ process.exit(process.exitCode ?? 0);
395
+ }