@tamagui/cli 2.0.0-rc.9 → 2.0.0
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 +96 -71
- package/dist/build.cjs +214 -139
- package/dist/cli.cjs +318 -272
- package/dist/generate-prompt.cjs +310 -261
- package/dist/generate.cjs +51 -38
- package/dist/update-template.cjs +43 -31
- package/dist/update.cjs +12 -10
- package/dist/upgrade.cjs +274 -162
- package/dist/utils.cjs +69 -44
- package/package.json +9 -8
- package/src/build.ts +124 -25
- package/src/cli.ts +10 -72
- package/src/generate-prompt.ts +1 -1
- package/src/utils.ts +13 -8
- package/types/build.d.ts +2 -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 -210
- package/dist/build.js.map +0 -6
- package/dist/cli.js +0 -268
- 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/dist/utils.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var utils_exports = {};
|
|
33
35
|
__export(utils_exports, {
|
|
34
36
|
disposeAll: () => disposeAll,
|
|
@@ -38,10 +40,9 @@ __export(utils_exports, {
|
|
|
38
40
|
registerDispose: () => registerDispose
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(utils_exports);
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
import_node_path = require("node:path");
|
|
43
|
+
var import_chalk = __toESM(require("chalk"));
|
|
44
|
+
var import_fs_extra = require("fs-extra");
|
|
45
|
+
var import_node_path = require("node:path");
|
|
45
46
|
async function getOptions({
|
|
46
47
|
root = process.cwd(),
|
|
47
48
|
tsconfigPath = "tsconfig.json",
|
|
@@ -51,18 +52,29 @@ async function getOptions({
|
|
|
51
52
|
loadTamaguiOptions
|
|
52
53
|
} = {}) {
|
|
53
54
|
const dotDir = (0, import_node_path.join)(root, ".tamagui");
|
|
54
|
-
let pkgJson = {}
|
|
55
|
-
|
|
55
|
+
let pkgJson = {};
|
|
56
|
+
let config = "";
|
|
56
57
|
try {
|
|
57
|
-
config = await getDefaultTamaguiConfigPath()
|
|
58
|
-
|
|
58
|
+
config = await getDefaultTamaguiConfigPath();
|
|
59
|
+
pkgJson = await (0, import_fs_extra.readJSON)((0, import_node_path.join)(root, "package.json"));
|
|
60
|
+
} catch {
|
|
61
|
+
if (loadTamaguiOptions) {
|
|
62
|
+
console.warn(import_chalk.default.yellow(`Warning: no tamagui.config.ts found in ${root}. Commands that need a config may fail.`));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
59
65
|
const filledOptions = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
platform: "native",
|
|
67
|
+
components: ["tamagui"],
|
|
68
|
+
config,
|
|
69
|
+
...tamaguiOptions
|
|
70
|
+
};
|
|
71
|
+
let finalOptions = filledOptions;
|
|
72
|
+
if (loadTamaguiOptions) {
|
|
73
|
+
const {
|
|
74
|
+
loadTamaguiBuildConfigSync
|
|
75
|
+
} = require("@tamagui/static/loadTamagui");
|
|
76
|
+
finalOptions = loadTamaguiBuildConfigSync(filledOptions);
|
|
77
|
+
}
|
|
66
78
|
return {
|
|
67
79
|
mode: process.env.NODE_ENV === "production" ? "production" : "development",
|
|
68
80
|
root,
|
|
@@ -80,23 +92,36 @@ async function getOptions({
|
|
|
80
92
|
};
|
|
81
93
|
}
|
|
82
94
|
function ensure(condition, message) {
|
|
83
|
-
|
|
95
|
+
if (!condition) {
|
|
96
|
+
console.error(import_chalk.default.red.bold("Error:"), import_chalk.default.yellow(`${message}`));
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
84
99
|
}
|
|
85
100
|
const defaultPaths = ["tamagui.config.ts", (0, import_node_path.join)("src", "tamagui.config.ts")];
|
|
86
101
|
let cachedPath = "";
|
|
87
102
|
async function getDefaultTamaguiConfigPath() {
|
|
88
103
|
if (cachedPath) return cachedPath;
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
const existingPaths = await Promise.all(defaultPaths.map(path => (0, import_fs_extra.pathExists)(path)));
|
|
105
|
+
const existing = existingPaths.findIndex(x => !!x);
|
|
106
|
+
const found = defaultPaths[existing];
|
|
107
|
+
if (!found) {
|
|
108
|
+
throw new Error(`No found tamagui.config.ts`);
|
|
109
|
+
}
|
|
110
|
+
cachedPath = found;
|
|
111
|
+
return found;
|
|
93
112
|
}
|
|
94
|
-
const loadTamagui = async opts =>
|
|
113
|
+
const loadTamagui = async opts => {
|
|
114
|
+
const {
|
|
115
|
+
loadTamagui: loadTamaguiStatic
|
|
116
|
+
} = require("@tamagui/static/loadTamagui");
|
|
117
|
+
const loaded = await loadTamaguiStatic({
|
|
95
118
|
components: ["tamagui"],
|
|
96
119
|
...opts,
|
|
97
120
|
config: opts.config ?? (await getDefaultTamaguiConfigPath())
|
|
98
|
-
})
|
|
99
|
-
|
|
121
|
+
});
|
|
122
|
+
return loaded;
|
|
123
|
+
};
|
|
124
|
+
const disposers = /* @__PURE__ */new Set();
|
|
100
125
|
function registerDispose(cb) {
|
|
101
126
|
disposers.add(cb);
|
|
102
127
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/cli",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tama": "./dist/index.cjs",
|
|
6
6
|
"tamagui": "./dist/index.cjs"
|
|
@@ -22,14 +22,15 @@
|
|
|
22
22
|
"watch": "bun run build --skip-native --watch",
|
|
23
23
|
"clean": "tamagui-build clean",
|
|
24
24
|
"clean:build": "tamagui-build clean:build",
|
|
25
|
-
"test": "vitest run"
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:web": "bun run test"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@tamagui/create-theme": "2.0.0
|
|
29
|
-
"@tamagui/generate-themes": "2.0.0
|
|
30
|
-
"@tamagui/static": "2.0.0
|
|
31
|
-
"@tamagui/types": "2.0.0
|
|
32
|
-
"@tamagui/vite-plugin": "2.0.0
|
|
29
|
+
"@tamagui/create-theme": "2.0.0",
|
|
30
|
+
"@tamagui/generate-themes": "2.0.0",
|
|
31
|
+
"@tamagui/static": "2.0.0",
|
|
32
|
+
"@tamagui/types": "2.0.0",
|
|
33
|
+
"@tamagui/vite-plugin": "2.0.0",
|
|
33
34
|
"arg": "^5.0.2",
|
|
34
35
|
"chalk": "^4.1.2",
|
|
35
36
|
"change-case": "^4.1.2",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"url": "^0.11.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@tamagui/build": "2.0.0
|
|
52
|
+
"@tamagui/build": "2.0.0",
|
|
52
53
|
"@types/chokidar": "^2.1.3",
|
|
53
54
|
"@types/marked": "^5.0.0",
|
|
54
55
|
"vitest": "4.0.4"
|
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,12 +56,16 @@ 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[]
|
|
61
63
|
dryRun?: boolean
|
|
62
64
|
}
|
|
63
65
|
): Promise<BuildResult> => {
|
|
64
66
|
const sourceDir = options.dir ?? '.'
|
|
67
|
+
const outputDir = options.output
|
|
68
|
+
const outputAround = options.outputAround || false
|
|
65
69
|
const promises: Promise<void>[] = []
|
|
66
70
|
const isDryRun = options.dryRun || false
|
|
67
71
|
|
|
@@ -69,7 +73,25 @@ export const build = async (
|
|
|
69
73
|
console.info('[dry-run] no files will be written\n')
|
|
70
74
|
}
|
|
71
75
|
|
|
72
|
-
|
|
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
|
+
}
|
|
94
|
+
|
|
73
95
|
const targets =
|
|
74
96
|
options.target === 'both' || !options.target
|
|
75
97
|
? (['web', 'native'] as const)
|
|
@@ -92,10 +114,10 @@ export const build = async (
|
|
|
92
114
|
: `${sourceDir}/**/*.{tsx,jsx}` // Directory
|
|
93
115
|
|
|
94
116
|
await new Promise<void>((res) => {
|
|
95
|
-
chokidar
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
117
|
+
const watcher = chokidar.watch(watchPattern, {
|
|
118
|
+
ignoreInitial: false,
|
|
119
|
+
})
|
|
120
|
+
watcher
|
|
99
121
|
.on('add', (relativePath) => {
|
|
100
122
|
const sourcePath = resolve(process.cwd(), relativePath)
|
|
101
123
|
|
|
@@ -108,7 +130,9 @@ export const build = async (
|
|
|
108
130
|
|
|
109
131
|
allFiles.push(sourcePath)
|
|
110
132
|
})
|
|
111
|
-
.on('ready', () =>
|
|
133
|
+
.on('ready', () => {
|
|
134
|
+
watcher.close().then(() => res())
|
|
135
|
+
})
|
|
112
136
|
})
|
|
113
137
|
|
|
114
138
|
// Now determine what to optimize for each file
|
|
@@ -248,28 +272,50 @@ export const build = async (
|
|
|
248
272
|
}
|
|
249
273
|
console.info(`\njs:\n${jsContent}`)
|
|
250
274
|
} else {
|
|
275
|
+
// compute relative path to preserve directory structure in output
|
|
276
|
+
const relPath = outputDir
|
|
277
|
+
? relative(resolve(sourceDir), sourcePath)
|
|
278
|
+
: basename(sourcePath)
|
|
251
279
|
const cssName = '_' + basename(sourcePath, extname(sourcePath))
|
|
252
|
-
const
|
|
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')
|
|
253
290
|
const cssImport = `import "./${cssName}.css"`
|
|
254
291
|
const jsContent =
|
|
255
292
|
typeof out.js === 'string' ? out.js : out.js.toString('utf-8')
|
|
256
293
|
const code = insertCssImport(jsContent, cssImport)
|
|
257
294
|
|
|
258
|
-
//
|
|
259
|
-
|
|
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
|
+
}
|
|
260
302
|
|
|
261
303
|
// Write web output
|
|
262
|
-
await writeFile(
|
|
263
|
-
|
|
304
|
+
await writeFile(webOutputPath, code, 'utf-8')
|
|
305
|
+
if (!outputDir) {
|
|
306
|
+
await recordMtime(sourcePath)
|
|
307
|
+
}
|
|
264
308
|
|
|
265
|
-
// CSS file is new, track for cleanup
|
|
309
|
+
// CSS file is new, track for cleanup (skip if using output dir)
|
|
266
310
|
await writeFile(stylePath, out.styles, 'utf-8')
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
+
}
|
|
273
319
|
}
|
|
274
320
|
} else if (isDryRun) {
|
|
275
321
|
console.info(` web: no output`)
|
|
@@ -299,6 +345,8 @@ export const build = async (
|
|
|
299
345
|
}
|
|
300
346
|
} else {
|
|
301
347
|
// Determine output path:
|
|
348
|
+
// - If --output-around, write .native.tsx next to source
|
|
349
|
+
// - If --output specified, preserve directory structure
|
|
302
350
|
// - If this IS a .native.tsx file, overwrite it
|
|
303
351
|
// - If building both targets from base file, create .native.tsx
|
|
304
352
|
// - If single native target, overwrite source
|
|
@@ -306,27 +354,78 @@ export const build = async (
|
|
|
306
354
|
const isPlatformSpecific = /\.(web|native|ios|android)\.(tsx|jsx)$/.test(
|
|
307
355
|
sourcePath
|
|
308
356
|
)
|
|
309
|
-
|
|
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) {
|
|
310
381
|
// Base file building both targets - create separate .native.tsx
|
|
311
382
|
nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, '.native.$1')
|
|
312
383
|
}
|
|
313
384
|
|
|
314
385
|
if (nativeOut.code) {
|
|
315
|
-
//
|
|
316
|
-
|
|
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
|
+
) {
|
|
317
405
|
await trackFile(nativeOutputPath)
|
|
318
406
|
}
|
|
319
407
|
await writeFile(nativeOutputPath, nativeOut.code, 'utf-8')
|
|
320
|
-
|
|
408
|
+
if (!outputDir && !outputAround) {
|
|
409
|
+
await recordMtime(nativeOutputPath)
|
|
410
|
+
}
|
|
321
411
|
|
|
322
|
-
// If creating new .native.tsx, track for deletion
|
|
323
|
-
if (
|
|
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
|
+
) {
|
|
324
419
|
trackedFiles.push({
|
|
325
420
|
path: nativeOutputPath,
|
|
326
421
|
hardlinkPath: '', // Empty = delete on restore
|
|
327
422
|
mtimeAfterWrite: (await stat(nativeOutputPath)).mtimeMs,
|
|
328
423
|
})
|
|
329
424
|
}
|
|
425
|
+
|
|
426
|
+
if (outputAround) {
|
|
427
|
+
console.info(` → ${nativeOutputPath}`)
|
|
428
|
+
}
|
|
330
429
|
}
|
|
331
430
|
}
|
|
332
431
|
}
|
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
|
},
|
|
@@ -163,6 +157,8 @@ const COMMAND_MAP = {
|
|
|
163
157
|
'--target': String,
|
|
164
158
|
'--include': String,
|
|
165
159
|
'--exclude': String,
|
|
160
|
+
'--output': String,
|
|
161
|
+
'--output-around': Boolean,
|
|
166
162
|
'--expect-optimizations': Number,
|
|
167
163
|
},
|
|
168
164
|
async run() {
|
|
@@ -198,6 +194,8 @@ const COMMAND_MAP = {
|
|
|
198
194
|
include: flags['--include'],
|
|
199
195
|
target: (flags['--target'] as 'web' | 'native' | 'both' | undefined) || 'both',
|
|
200
196
|
exclude: flags['--exclude'],
|
|
197
|
+
output: flags['--output'],
|
|
198
|
+
outputAround: flags['--output-around'],
|
|
201
199
|
expectOptimizations: flags['--expect-optimizations'],
|
|
202
200
|
runCommand,
|
|
203
201
|
dryRun,
|
|
@@ -360,63 +358,3 @@ async function main() {
|
|
|
360
358
|
|
|
361
359
|
process.exit(0)
|
|
362
360
|
}
|
|
363
|
-
|
|
364
|
-
function showHelp(definition: CommandDefinition, flags: { '--help'?: boolean }) {
|
|
365
|
-
if (flags['--help']) {
|
|
366
|
-
console.info(`$ ${definition}`)
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// async function main() {
|
|
371
|
-
// const options = await getOptions({
|
|
372
|
-
// host: flags['--host'],
|
|
373
|
-
// })
|
|
374
|
-
|
|
375
|
-
// switch (command) {
|
|
376
|
-
// // build
|
|
377
|
-
// case 'b':
|
|
378
|
-
// case 'build': {
|
|
379
|
-
// const { build } = await import('./build')
|
|
380
|
-
// break
|
|
381
|
-
// }
|
|
382
|
-
|
|
383
|
-
// // generate
|
|
384
|
-
// case 'generate':
|
|
385
|
-
// case 'gen': {
|
|
386
|
-
// const { generateTamaguiConfig: generateTamgauiConfig } = await import(
|
|
387
|
-
// './tamaguiConfigUtils.js'
|
|
388
|
-
// )
|
|
389
|
-
// const { generateTypes } = await import('./generate')
|
|
390
|
-
|
|
391
|
-
// if (props[0] === 'types') {
|
|
392
|
-
// await generateTypes(options)
|
|
393
|
-
// return
|
|
394
|
-
// }
|
|
395
|
-
// if (props[0] === 'config') {
|
|
396
|
-
// await generateTamgauiConfig(options)
|
|
397
|
-
// return
|
|
398
|
-
// }
|
|
399
|
-
|
|
400
|
-
// await Promise.all([
|
|
401
|
-
// // all
|
|
402
|
-
// generateTypes(options),
|
|
403
|
-
// generateTamgauiConfig(options),
|
|
404
|
-
// ])
|
|
405
|
-
// break
|
|
406
|
-
// }
|
|
407
|
-
|
|
408
|
-
// // for now, dev === serve, eventually serve can be just prod mode
|
|
409
|
-
// case 'dev': {
|
|
410
|
-
// const { dev } = await import('./dev')
|
|
411
|
-
// await dev(options)
|
|
412
|
-
// break
|
|
413
|
-
// }
|
|
414
|
-
|
|
415
|
-
// default: {
|
|
416
|
-
// if (!command || flags['--help']) {
|
|
417
|
-
// }
|
|
418
|
-
// console.warn(chalk.yellow(`No command found ${command}`))
|
|
419
|
-
// process.exit(1)
|
|
420
|
-
// }
|
|
421
|
-
// }
|
|
422
|
-
// }
|
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
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;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,KACA,OAAO,CAAC,WAAW,
|
|
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"}
|