@tamagui/cli 2.0.0-rc.3 → 2.0.0-rc.31
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/build.cjs +80 -26
- package/dist/cli.cjs +29 -15
- package/dist/generate-prompt.cjs +8 -6
- package/dist/generate.cjs +0 -0
- package/dist/utils.cjs +26 -14
- package/package.json +9 -8
- package/src/build.ts +190 -56
- package/src/cli.ts +20 -73
- package/src/generate-prompt.ts +1 -1
- package/src/utils.ts +13 -8
- package/types/build.d.ts +3 -0
- package/types/build.d.ts.map +1 -1
- package/types/generate-prompt.d.ts.map +1 -1
- package/types/utils.d.ts.map +1 -1
- package/dist/add.js +0 -91
- package/dist/add.js.map +0 -6
- package/dist/build.js +0 -188
- package/dist/build.js.map +0 -6
- package/dist/cli.js +0 -266
- package/dist/cli.js.map +0 -6
- package/dist/generate-prompt.js +0 -392
- package/dist/generate-prompt.js.map +0 -6
- package/dist/generate.js +0 -62
- package/dist/generate.js.map +0 -6
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -6
- package/dist/update-template.js +0 -57
- package/dist/update-template.js.map +0 -6
- package/dist/update.js +0 -22
- package/dist/update.js.map +0 -6
- package/dist/upgrade.js +0 -319
- package/dist/upgrade.js.map +0 -6
- package/dist/utils.js +0 -92
- package/dist/utils.js.map +0 -6
package/src/build.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { CLIResolvedOptions, TamaguiOptions } from '@tamagui/types'
|
|
|
9
9
|
import chokidar from 'chokidar'
|
|
10
10
|
import { copyFile, mkdir, readFile, rm, stat, writeFile } from 'fs-extra'
|
|
11
11
|
import MicroMatch from 'micromatch'
|
|
12
|
-
import { basename, dirname, extname, join, resolve } from 'node:path'
|
|
12
|
+
import { basename, dirname, extname, join, relative, resolve } from 'node:path'
|
|
13
13
|
import { tmpdir } from 'node:os'
|
|
14
14
|
import { execSync } from 'node:child_process'
|
|
15
15
|
import { createHash } from 'node:crypto'
|
|
@@ -56,14 +56,42 @@ export const build = async (
|
|
|
56
56
|
dir?: string
|
|
57
57
|
include?: string
|
|
58
58
|
exclude?: string
|
|
59
|
+
output?: string
|
|
60
|
+
outputAround?: boolean
|
|
59
61
|
expectOptimizations?: number
|
|
60
62
|
runCommand?: string[]
|
|
63
|
+
dryRun?: boolean
|
|
61
64
|
}
|
|
62
65
|
): Promise<BuildResult> => {
|
|
63
66
|
const sourceDir = options.dir ?? '.'
|
|
67
|
+
const outputDir = options.output
|
|
68
|
+
const outputAround = options.outputAround || false
|
|
64
69
|
const promises: Promise<void>[] = []
|
|
70
|
+
const isDryRun = options.dryRun || false
|
|
71
|
+
|
|
72
|
+
if (isDryRun) {
|
|
73
|
+
console.info('[dry-run] no files will be written\n')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// create output directory if specified
|
|
77
|
+
if (outputDir) {
|
|
78
|
+
await mkdir(outputDir, { recursive: true })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const loadedOptions = loadTamaguiBuildConfigSync(options.tamaguiOptions)
|
|
82
|
+
|
|
83
|
+
// when running CLI build directly, ignore disable since user explicitly wants to build
|
|
84
|
+
if (loadedOptions.disable) {
|
|
85
|
+
console.warn(
|
|
86
|
+
`[tamagui] Note: "disable" option in tamagui.build.ts is being ignored for CLI build command`
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
const buildOptions = {
|
|
90
|
+
...loadedOptions,
|
|
91
|
+
disable: false,
|
|
92
|
+
disableExtraction: false,
|
|
93
|
+
}
|
|
65
94
|
|
|
66
|
-
const buildOptions = loadTamaguiBuildConfigSync(options.tamaguiOptions)
|
|
67
95
|
const targets =
|
|
68
96
|
options.target === 'both' || !options.target
|
|
69
97
|
? (['web', 'native'] as const)
|
|
@@ -86,10 +114,10 @@ export const build = async (
|
|
|
86
114
|
: `${sourceDir}/**/*.{tsx,jsx}` // Directory
|
|
87
115
|
|
|
88
116
|
await new Promise<void>((res) => {
|
|
89
|
-
chokidar
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
117
|
+
const watcher = chokidar.watch(watchPattern, {
|
|
118
|
+
ignoreInitial: false,
|
|
119
|
+
})
|
|
120
|
+
watcher
|
|
93
121
|
.on('add', (relativePath) => {
|
|
94
122
|
const sourcePath = resolve(process.cwd(), relativePath)
|
|
95
123
|
|
|
@@ -102,7 +130,9 @@ export const build = async (
|
|
|
102
130
|
|
|
103
131
|
allFiles.push(sourcePath)
|
|
104
132
|
})
|
|
105
|
-
.on('ready', () =>
|
|
133
|
+
.on('ready', () => {
|
|
134
|
+
watcher.close().then(() => res())
|
|
135
|
+
})
|
|
106
136
|
})
|
|
107
137
|
|
|
108
138
|
// Now determine what to optimize for each file
|
|
@@ -205,6 +235,10 @@ export const build = async (
|
|
|
205
235
|
// Read original source ONCE for both targets
|
|
206
236
|
const originalSource = await readFile(sourcePath, 'utf-8')
|
|
207
237
|
|
|
238
|
+
if (isDryRun) {
|
|
239
|
+
console.info(`\n${sourcePath} [${filePlatforms.join(', ')}]`)
|
|
240
|
+
}
|
|
241
|
+
|
|
208
242
|
// Build web version from original source
|
|
209
243
|
if (filePlatforms.includes('web')) {
|
|
210
244
|
process.env.TAMAGUI_TARGET = 'web'
|
|
@@ -230,28 +264,61 @@ export const build = async (
|
|
|
230
264
|
stats.styled += out.stats.styled
|
|
231
265
|
stats.found += out.stats.found
|
|
232
266
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
267
|
+
if (isDryRun) {
|
|
268
|
+
const jsContent =
|
|
269
|
+
typeof out.js === 'string' ? out.js : out.js.toString('utf-8')
|
|
270
|
+
if (out.styles) {
|
|
271
|
+
console.info(`\ncss:\n${out.styles}`)
|
|
272
|
+
}
|
|
273
|
+
console.info(`\njs:\n${jsContent}`)
|
|
274
|
+
} else {
|
|
275
|
+
// compute relative path to preserve directory structure in output
|
|
276
|
+
const relPath = outputDir
|
|
277
|
+
? relative(resolve(sourceDir), sourcePath)
|
|
278
|
+
: basename(sourcePath)
|
|
279
|
+
const cssName = '_' + basename(sourcePath, extname(sourcePath))
|
|
280
|
+
const outputBase = outputDir
|
|
281
|
+
? join(outputDir, dirname(relPath))
|
|
282
|
+
: dirname(sourcePath)
|
|
283
|
+
|
|
284
|
+
// ensure output subdirectory exists
|
|
285
|
+
if (outputDir) {
|
|
286
|
+
await mkdir(outputBase, { recursive: true })
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const stylePath = join(outputBase, cssName + '.css')
|
|
290
|
+
const cssImport = `import "./${cssName}.css"`
|
|
291
|
+
const jsContent =
|
|
292
|
+
typeof out.js === 'string' ? out.js : out.js.toString('utf-8')
|
|
293
|
+
const code = insertCssImport(jsContent, cssImport)
|
|
294
|
+
|
|
295
|
+
// Determine output path for JS (preserve directory structure)
|
|
296
|
+
const webOutputPath = outputDir ? join(outputDir, relPath) : sourcePath
|
|
297
|
+
|
|
298
|
+
// Track original file before modifying (skip if using output dir)
|
|
299
|
+
if (!outputDir) {
|
|
300
|
+
await trackFile(sourcePath)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Write web output
|
|
304
|
+
await writeFile(webOutputPath, code, 'utf-8')
|
|
305
|
+
if (!outputDir) {
|
|
306
|
+
await recordMtime(sourcePath)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// CSS file is new, track for cleanup (skip if using output dir)
|
|
310
|
+
await writeFile(stylePath, out.styles, 'utf-8')
|
|
311
|
+
if (!outputDir) {
|
|
312
|
+
// Note: CSS files are new (generated), we'll delete them on restore
|
|
313
|
+
trackedFiles.push({
|
|
314
|
+
path: stylePath,
|
|
315
|
+
hardlinkPath: '', // Empty means delete on restore
|
|
316
|
+
mtimeAfterWrite: (await stat(stylePath)).mtimeMs,
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
} else if (isDryRun) {
|
|
321
|
+
console.info(` web: no output`)
|
|
255
322
|
}
|
|
256
323
|
}
|
|
257
324
|
|
|
@@ -270,34 +337,95 @@ export const build = async (
|
|
|
270
337
|
nativeTamaguiOptions
|
|
271
338
|
)
|
|
272
339
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const isPlatformSpecific = /\.(web|native|ios|android)\.(tsx|jsx)$/.test(
|
|
279
|
-
sourcePath
|
|
280
|
-
)
|
|
281
|
-
if (!isPlatformSpecific && filePlatforms.length > 1) {
|
|
282
|
-
// Base file building both targets - create separate .native.tsx
|
|
283
|
-
nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, '.native.$1')
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (nativeOut.code) {
|
|
287
|
-
// Track original if overwriting existing file
|
|
288
|
-
if (nativeOutputPath === sourcePath || filePlatforms.length === 1) {
|
|
289
|
-
await trackFile(nativeOutputPath)
|
|
340
|
+
if (isDryRun) {
|
|
341
|
+
if (nativeOut.code) {
|
|
342
|
+
console.info(`\nnative:\n${nativeOut.code}`)
|
|
343
|
+
} else {
|
|
344
|
+
console.info(` native: no output`)
|
|
290
345
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
// If
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
346
|
+
} else {
|
|
347
|
+
// Determine output path:
|
|
348
|
+
// - If --output-around, write .native.tsx next to source
|
|
349
|
+
// - If --output specified, preserve directory structure
|
|
350
|
+
// - If this IS a .native.tsx file, overwrite it
|
|
351
|
+
// - If building both targets from base file, create .native.tsx
|
|
352
|
+
// - If single native target, overwrite source
|
|
353
|
+
let nativeOutputPath = sourcePath
|
|
354
|
+
const isPlatformSpecific = /\.(web|native|ios|android)\.(tsx|jsx)$/.test(
|
|
355
|
+
sourcePath
|
|
356
|
+
)
|
|
357
|
+
const needsNativeSuffix =
|
|
358
|
+
!isPlatformSpecific && (filePlatforms.length > 1 || outputAround)
|
|
359
|
+
|
|
360
|
+
if (outputAround) {
|
|
361
|
+
// Output .native.tsx next to source file
|
|
362
|
+
nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, '.native.$1')
|
|
363
|
+
// Check if file exists - error if so
|
|
364
|
+
const exists = await stat(nativeOutputPath).catch(() => null)
|
|
365
|
+
if (exists) {
|
|
366
|
+
throw new Error(
|
|
367
|
+
`--output-around: ${nativeOutputPath} already exists. Remove it first or use --output instead.`
|
|
368
|
+
)
|
|
369
|
+
}
|
|
370
|
+
} else if (outputDir) {
|
|
371
|
+
// preserve directory structure in output
|
|
372
|
+
const relPath = relative(resolve(sourceDir), sourcePath)
|
|
373
|
+
// add .native suffix when building both targets to avoid overwriting web output
|
|
374
|
+
const outputRelPath = needsNativeSuffix
|
|
375
|
+
? relPath.replace(/\.(tsx|jsx)$/, '.native.$1')
|
|
376
|
+
: relPath
|
|
377
|
+
nativeOutputPath = join(outputDir, outputRelPath)
|
|
378
|
+
// ensure output subdirectory exists
|
|
379
|
+
await mkdir(dirname(nativeOutputPath), { recursive: true })
|
|
380
|
+
} else if (needsNativeSuffix) {
|
|
381
|
+
// Base file building both targets - create separate .native.tsx
|
|
382
|
+
nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, '.native.$1')
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (nativeOut.code) {
|
|
386
|
+
// check if extraction actually happened by looking for our markers
|
|
387
|
+
const hasExtraction =
|
|
388
|
+
nativeOut.code.includes('__ReactNativeStyleSheet') ||
|
|
389
|
+
nativeOut.code.includes('_withStableStyle')
|
|
390
|
+
if (hasExtraction) {
|
|
391
|
+
stats.filesProcessed++
|
|
392
|
+
// count styled wrappers as flattened (native extraction flattens styles)
|
|
393
|
+
const wrapperMatches = nativeOut.code.match(/_withStableStyle/g)
|
|
394
|
+
if (wrapperMatches) {
|
|
395
|
+
stats.flattened += wrapperMatches.length
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Track original if overwriting existing file (skip if using output dir or outputAround)
|
|
400
|
+
if (
|
|
401
|
+
!outputDir &&
|
|
402
|
+
!outputAround &&
|
|
403
|
+
(nativeOutputPath === sourcePath || filePlatforms.length === 1)
|
|
404
|
+
) {
|
|
405
|
+
await trackFile(nativeOutputPath)
|
|
406
|
+
}
|
|
407
|
+
await writeFile(nativeOutputPath, nativeOut.code, 'utf-8')
|
|
408
|
+
if (!outputDir && !outputAround) {
|
|
409
|
+
await recordMtime(nativeOutputPath)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// If creating new .native.tsx, track for deletion (skip if using output dir or outputAround)
|
|
413
|
+
if (
|
|
414
|
+
!outputDir &&
|
|
415
|
+
!outputAround &&
|
|
416
|
+
nativeOutputPath !== sourcePath &&
|
|
417
|
+
filePlatforms.length > 1
|
|
418
|
+
) {
|
|
419
|
+
trackedFiles.push({
|
|
420
|
+
path: nativeOutputPath,
|
|
421
|
+
hardlinkPath: '', // Empty = delete on restore
|
|
422
|
+
mtimeAfterWrite: (await stat(nativeOutputPath)).mtimeMs,
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (outputAround) {
|
|
427
|
+
console.info(` → ${nativeOutputPath}`)
|
|
428
|
+
}
|
|
301
429
|
}
|
|
302
430
|
}
|
|
303
431
|
}
|
|
@@ -307,6 +435,12 @@ export const build = async (
|
|
|
307
435
|
|
|
308
436
|
await Promise.all(promises)
|
|
309
437
|
|
|
438
|
+
if (isDryRun) {
|
|
439
|
+
console.info(
|
|
440
|
+
`\n${stats.filesProcessed} files | ${stats.found} found | ${stats.optimized} optimized | ${stats.flattened} flattened | ${stats.styled} styled\n`
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
|
|
310
444
|
// Verify expected optimizations if specified
|
|
311
445
|
if (options.expectOptimizations !== undefined) {
|
|
312
446
|
const totalOptimizations = stats.optimized + stats.flattened
|
package/src/cli.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import arg from 'arg'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
3
|
|
|
4
|
-
import { generatedPackageTypes } from './add'
|
|
5
4
|
import { disposeAll, getOptions } from './utils'
|
|
6
|
-
import { loadTamagui, checkDeps } from '@tamagui/static'
|
|
7
5
|
|
|
8
6
|
// exit handlers
|
|
9
7
|
;['exit', 'SIGINT'].forEach((_) => {
|
|
@@ -15,7 +13,7 @@ import { loadTamagui, checkDeps } from '@tamagui/static'
|
|
|
15
13
|
|
|
16
14
|
const COMMAND_MAP = {
|
|
17
15
|
check: {
|
|
18
|
-
description: `Checks
|
|
16
|
+
description: `Checks for inconsistent versions, duplicate installs, lockfile issues, and missing config.`,
|
|
19
17
|
shorthands: [],
|
|
20
18
|
flags: {
|
|
21
19
|
'--help': Boolean,
|
|
@@ -26,9 +24,8 @@ const COMMAND_MAP = {
|
|
|
26
24
|
const { _, ...flags } = arg(this.flags)
|
|
27
25
|
const options = await getOptions({
|
|
28
26
|
debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,
|
|
29
|
-
loadTamaguiOptions: true,
|
|
30
27
|
})
|
|
31
|
-
|
|
28
|
+
const { checkDeps } = require('@tamagui/static/checkDeps')
|
|
32
29
|
await checkDeps(options.paths.root)
|
|
33
30
|
},
|
|
34
31
|
},
|
|
@@ -47,13 +44,14 @@ const COMMAND_MAP = {
|
|
|
47
44
|
debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,
|
|
48
45
|
loadTamaguiOptions: true,
|
|
49
46
|
})
|
|
47
|
+
const { loadTamagui } = require('@tamagui/static/loadTamagui')
|
|
50
48
|
process.env.TAMAGUI_KEEP_THEMES = '1'
|
|
51
49
|
await loadTamagui({
|
|
52
50
|
...options.tamaguiOptions,
|
|
53
51
|
platform: 'web',
|
|
54
52
|
})
|
|
55
53
|
|
|
56
|
-
//
|
|
54
|
+
// also generate prompt to .tamagui/prompt.md
|
|
57
55
|
const { generatePrompt } = require('./generate-prompt')
|
|
58
56
|
const { join } = require('node:path')
|
|
59
57
|
await generatePrompt({
|
|
@@ -82,6 +80,7 @@ const COMMAND_MAP = {
|
|
|
82
80
|
const outputPath =
|
|
83
81
|
flags['--output'] || options.tamaguiOptions.outputCSS || './tamagui.generated.css'
|
|
84
82
|
|
|
83
|
+
const { loadTamagui } = require('@tamagui/static/loadTamagui')
|
|
85
84
|
process.env.TAMAGUI_KEEP_THEMES = '1'
|
|
86
85
|
await loadTamagui({
|
|
87
86
|
...options.tamaguiOptions,
|
|
@@ -133,9 +132,7 @@ const COMMAND_MAP = {
|
|
|
133
132
|
|
|
134
133
|
add: {
|
|
135
134
|
shorthands: [],
|
|
136
|
-
description: `Use to add fonts and icons to your monorepo
|
|
137
|
-
', '
|
|
138
|
-
)}`,
|
|
135
|
+
description: `Use to add fonts and icons to your monorepo.`,
|
|
139
136
|
flags: {
|
|
140
137
|
'--help': Boolean,
|
|
141
138
|
'--debug': Boolean,
|
|
@@ -145,9 +142,6 @@ const COMMAND_MAP = {
|
|
|
145
142
|
const { _, ...flags } = arg(this.flags)
|
|
146
143
|
const { installGeneratedPackage } = require('./add')
|
|
147
144
|
const [cmd, type, path] = _
|
|
148
|
-
// const options = await getOptions({
|
|
149
|
-
// debug: flags['--debug'] ? (flags['--verbose'] ? 'verbose' : true) : false,
|
|
150
|
-
// })
|
|
151
145
|
await installGeneratedPackage(type, path)
|
|
152
146
|
},
|
|
153
147
|
},
|
|
@@ -159,9 +153,12 @@ const COMMAND_MAP = {
|
|
|
159
153
|
'--help': Boolean,
|
|
160
154
|
'--debug': Boolean,
|
|
161
155
|
'--verbose': Boolean,
|
|
156
|
+
'--dry-run': Boolean,
|
|
162
157
|
'--target': String,
|
|
163
158
|
'--include': String,
|
|
164
159
|
'--exclude': String,
|
|
160
|
+
'--output': String,
|
|
161
|
+
'--output-around': Boolean,
|
|
165
162
|
'--expect-optimizations': Number,
|
|
166
163
|
},
|
|
167
164
|
async run() {
|
|
@@ -180,9 +177,16 @@ const COMMAND_MAP = {
|
|
|
180
177
|
const { _, ...flags } = arg(this.flags)
|
|
181
178
|
const [_command, dir] = _
|
|
182
179
|
|
|
180
|
+
const dryRun = flags['--dry-run'] || false
|
|
181
|
+
const debug = flags['--debug']
|
|
182
|
+
? flags['--verbose']
|
|
183
|
+
? ('verbose' as const)
|
|
184
|
+
: true
|
|
185
|
+
: false
|
|
186
|
+
|
|
183
187
|
const { build } = require('./build.cjs')
|
|
184
188
|
const options = await getOptions({
|
|
185
|
-
debug
|
|
189
|
+
debug,
|
|
186
190
|
})
|
|
187
191
|
await build({
|
|
188
192
|
...options,
|
|
@@ -190,8 +194,11 @@ const COMMAND_MAP = {
|
|
|
190
194
|
include: flags['--include'],
|
|
191
195
|
target: (flags['--target'] as 'web' | 'native' | 'both' | undefined) || 'both',
|
|
192
196
|
exclude: flags['--exclude'],
|
|
197
|
+
output: flags['--output'],
|
|
198
|
+
outputAround: flags['--output-around'],
|
|
193
199
|
expectOptimizations: flags['--expect-optimizations'],
|
|
194
200
|
runCommand,
|
|
201
|
+
dryRun,
|
|
195
202
|
})
|
|
196
203
|
},
|
|
197
204
|
},
|
|
@@ -351,63 +358,3 @@ async function main() {
|
|
|
351
358
|
|
|
352
359
|
process.exit(0)
|
|
353
360
|
}
|
|
354
|
-
|
|
355
|
-
function showHelp(definition: CommandDefinition, flags: { '--help'?: boolean }) {
|
|
356
|
-
if (flags['--help']) {
|
|
357
|
-
console.info(`$ ${definition}`)
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// async function main() {
|
|
362
|
-
// const options = await getOptions({
|
|
363
|
-
// host: flags['--host'],
|
|
364
|
-
// })
|
|
365
|
-
|
|
366
|
-
// switch (command) {
|
|
367
|
-
// // build
|
|
368
|
-
// case 'b':
|
|
369
|
-
// case 'build': {
|
|
370
|
-
// const { build } = await import('./build')
|
|
371
|
-
// break
|
|
372
|
-
// }
|
|
373
|
-
|
|
374
|
-
// // generate
|
|
375
|
-
// case 'generate':
|
|
376
|
-
// case 'gen': {
|
|
377
|
-
// const { generateTamaguiConfig: generateTamgauiConfig } = await import(
|
|
378
|
-
// './tamaguiConfigUtils.js'
|
|
379
|
-
// )
|
|
380
|
-
// const { generateTypes } = await import('./generate')
|
|
381
|
-
|
|
382
|
-
// if (props[0] === 'types') {
|
|
383
|
-
// await generateTypes(options)
|
|
384
|
-
// return
|
|
385
|
-
// }
|
|
386
|
-
// if (props[0] === 'config') {
|
|
387
|
-
// await generateTamgauiConfig(options)
|
|
388
|
-
// return
|
|
389
|
-
// }
|
|
390
|
-
|
|
391
|
-
// await Promise.all([
|
|
392
|
-
// // all
|
|
393
|
-
// generateTypes(options),
|
|
394
|
-
// generateTamgauiConfig(options),
|
|
395
|
-
// ])
|
|
396
|
-
// break
|
|
397
|
-
// }
|
|
398
|
-
|
|
399
|
-
// // for now, dev === serve, eventually serve can be just prod mode
|
|
400
|
-
// case 'dev': {
|
|
401
|
-
// const { dev } = await import('./dev')
|
|
402
|
-
// await dev(options)
|
|
403
|
-
// break
|
|
404
|
-
// }
|
|
405
|
-
|
|
406
|
-
// default: {
|
|
407
|
-
// if (!command || flags['--help']) {
|
|
408
|
-
// }
|
|
409
|
-
// console.warn(chalk.yellow(`No command found ${command}`))
|
|
410
|
-
// process.exit(1)
|
|
411
|
-
// }
|
|
412
|
-
// }
|
|
413
|
-
// }
|
package/src/generate-prompt.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { join } from 'node:path'
|
|
2
2
|
import * as FS from 'fs-extra'
|
|
3
|
-
import { loadTamagui } from '@tamagui/static'
|
|
4
3
|
import type { CLIResolvedOptions } from '@tamagui/types'
|
|
5
4
|
|
|
6
5
|
interface GeneratePromptOptions extends CLIResolvedOptions {
|
|
@@ -11,6 +10,7 @@ export async function generatePrompt(options: GeneratePromptOptions) {
|
|
|
11
10
|
const { paths, output } = options
|
|
12
11
|
|
|
13
12
|
// Regenerate the config first
|
|
13
|
+
const { loadTamagui } = require('@tamagui/static/loadTamagui')
|
|
14
14
|
process.env.TAMAGUI_KEEP_THEMES = '1'
|
|
15
15
|
await loadTamagui({
|
|
16
16
|
...options.tamaguiOptions,
|
package/src/utils.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { TamaguiOptions, TamaguiProjectInfo } from '@tamagui/static'
|
|
2
|
-
import {
|
|
3
|
-
loadTamaguiBuildConfigSync,
|
|
4
|
-
loadTamagui as loadTamaguiStatic,
|
|
5
|
-
} from '@tamagui/static'
|
|
6
2
|
import type { CLIResolvedOptions, CLIUserOptions } from '@tamagui/types'
|
|
7
3
|
import chalk from 'chalk'
|
|
8
4
|
import fs, { pathExists, readJSON } from 'fs-extra'
|
|
@@ -23,7 +19,13 @@ export async function getOptions({
|
|
|
23
19
|
config = await getDefaultTamaguiConfigPath()
|
|
24
20
|
pkgJson = await readJSON(join(root, 'package.json'))
|
|
25
21
|
} catch {
|
|
26
|
-
|
|
22
|
+
if (loadTamaguiOptions) {
|
|
23
|
+
console.warn(
|
|
24
|
+
chalk.yellow(
|
|
25
|
+
`Warning: no tamagui.config.ts found in ${root}. Commands that need a config may fail.`
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const filledOptions = {
|
|
@@ -33,9 +35,11 @@ export async function getOptions({
|
|
|
33
35
|
...tamaguiOptions,
|
|
34
36
|
} satisfies TamaguiOptions
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
let finalOptions: TamaguiOptions = filledOptions
|
|
39
|
+
if (loadTamaguiOptions) {
|
|
40
|
+
const { loadTamaguiBuildConfigSync } = require('@tamagui/static/loadTamagui')
|
|
41
|
+
finalOptions = loadTamaguiBuildConfigSync(filledOptions)
|
|
42
|
+
}
|
|
39
43
|
|
|
40
44
|
return {
|
|
41
45
|
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
|
@@ -79,6 +83,7 @@ async function getDefaultTamaguiConfigPath() {
|
|
|
79
83
|
export const loadTamagui = async (
|
|
80
84
|
opts: Partial<TamaguiOptions>
|
|
81
85
|
): Promise<TamaguiProjectInfo | null> => {
|
|
86
|
+
const { loadTamagui: loadTamaguiStatic } = require('@tamagui/static/loadTamagui')
|
|
82
87
|
const loaded = await loadTamaguiStatic({
|
|
83
88
|
components: ['tamagui'],
|
|
84
89
|
...opts,
|
package/types/build.d.ts
CHANGED
|
@@ -25,7 +25,10 @@ export declare const build: (options: CLIResolvedOptions & {
|
|
|
25
25
|
dir?: string;
|
|
26
26
|
include?: string;
|
|
27
27
|
exclude?: string;
|
|
28
|
+
output?: string;
|
|
29
|
+
outputAround?: boolean;
|
|
28
30
|
expectOptimizations?: number;
|
|
29
31
|
runCommand?: string[];
|
|
32
|
+
dryRun?: boolean;
|
|
30
33
|
}) => Promise<BuildResult>;
|
|
31
34
|
//# sourceMappingURL=build.d.ts.map
|
package/types/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAA;AASxE,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,WAAW,EAAE,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAW5E;AAED,eAAO,MAAM,KAAK,GAChB,SAAS,kBAAkB,GAAG;IAC5B,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAA;AASxE,MAAM,MAAM,UAAU,GAAG;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,WAAW,EAAE,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAW5E;AAED,eAAO,MAAM,KAAK,GAChB,SAAS,kBAAkB,GAAG;IAC5B,MAAM,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;IAClC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,KACA,OAAO,CAAC,WAAW,CA2ZrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-prompt.d.ts","sourceRoot":"","sources":["../src/generate-prompt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-prompt.d.ts","sourceRoot":"","sources":["../src/generate-prompt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD,UAAU,qBAAsB,SAAQ,kBAAkB;IACxD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,iBA8BlE"}
|
package/types/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAKxE,wBAAsB,UAAU,CAAC,EAC/B,IAAoB,EACpB,YAA8B,EAC9B,cAAc,EACd,IAAI,EACJ,KAAK,EACL,kBAAkB,GACnB,GAAE,OAAO,CAAC,cAAc,CAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6C5D;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAKzD;AAiBD,eAAO,MAAM,WAAW,GACtB,MAAM,OAAO,CAAC,cAAc,CAAC,KAC5B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAQnC,CAAA;AAID,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,QAE7C;AAED,wBAAgB,UAAU,SAEzB"}
|