@tamagui/cli 2.0.0-rc.4 → 2.0.0-rc.40
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 +226 -133
- package/dist/cli.cjs +318 -268
- 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 +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/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,CAA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 +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"}
|
package/dist/add.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var add_exports = {};
|
|
24
|
-
__export(add_exports, {
|
|
25
|
-
generatedPackageTypes: () => generatedPackageTypes,
|
|
26
|
-
installGeneratedPackage: () => installGeneratedPackage
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(add_exports);
|
|
29
|
-
var import_node_child_process = require("node:child_process"), import_node_fs = require("node:fs"), import_promises = require("node:fs/promises"), import_node_os = require("node:os"), import_node_path = __toESM(require("node:path")), import_chalk = __toESM(require("chalk")), import_change_case = require("change-case"), import_fs_extra = require("fs-extra"), import_marked = require("marked"), import_marked_terminal = __toESM(require("marked-terminal")), import_opener = __toESM(require("opener")), import_prompts = __toESM(require("prompts"));
|
|
30
|
-
import_marked.marked.setOptions({
|
|
31
|
-
renderer: new import_marked_terminal.default()
|
|
32
|
-
});
|
|
33
|
-
const home = (0, import_node_os.homedir)(), tamaguiDir = import_node_path.default.join(home, ".tamagui"), generatedPackageTypes = ["font", "icon"], installGeneratedPackage = async (type, packagesPath) => {
|
|
34
|
-
if (packagesPath = packagesPath || import_node_path.default.join(process.cwd(), "packages"), !generatedPackageTypes.includes(type))
|
|
35
|
-
throw new Error(
|
|
36
|
-
`${type ? `Type "${type}" is Not supported.` : "No type provided."} Supported types: ${generatedPackageTypes.join(", ")}`
|
|
37
|
-
);
|
|
38
|
-
const repoName = type === "font" ? "tamagui-google-fonts" : "tamagui-iconify";
|
|
39
|
-
console.info(`Setting up ${import_chalk.default.blueBright(tamaguiDir)}...`), await (0, import_fs_extra.ensureDir)(tamaguiDir);
|
|
40
|
-
const tempDir = import_node_path.default.join(tamaguiDir, repoName);
|
|
41
|
-
(0, import_node_fs.existsSync)(tempDir) && (0, import_node_fs.rmSync)(tempDir, { recursive: !0 });
|
|
42
|
-
try {
|
|
43
|
-
process.chdir(tamaguiDir);
|
|
44
|
-
try {
|
|
45
|
-
console.info("Attempting to clone with SSH"), (0, import_node_child_process.execSync)(
|
|
46
|
-
`git clone -n --depth=1 --branch generated --filter=tree:0 git@github.com:tamagui/${repoName}.git`
|
|
47
|
-
);
|
|
48
|
-
} catch {
|
|
49
|
-
console.info("SSH failed - Attempting to c lone with HTTPS"), (0, import_node_child_process.execSync)(
|
|
50
|
-
`git clone -n --depth=1 --branch generated --filter=tree:0 https://github.com/tamagui/${repoName}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
process.chdir(tempDir), (0, import_node_child_process.execSync)(["git sparse-checkout set --no-cone meta", "git checkout"].join(" && "));
|
|
54
|
-
} catch (error) {
|
|
55
|
-
if (error instanceof Error)
|
|
56
|
-
throw error?.stderr.includes("Repository not found") && (console.info(
|
|
57
|
-
import_chalk.default.yellow(
|
|
58
|
-
`You don't have access to Tamagui ${type === "font" ? "fonts" : "icons"}. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info.`
|
|
59
|
-
)
|
|
60
|
-
), (0, import_opener.default)("https://tamagui.dev/takeout"), process.exit(0)), error;
|
|
61
|
-
}
|
|
62
|
-
const meta = JSON.parse(
|
|
63
|
-
await (0, import_promises.readFile)(import_node_path.default.join(tamaguiDir, repoName, "meta", "data.json")).then(
|
|
64
|
-
(r) => r.toString()
|
|
65
|
-
)
|
|
66
|
-
);
|
|
67
|
-
console.info(
|
|
68
|
-
import_chalk.default.gray(
|
|
69
|
-
"Use \u21E7/\u21E9 to navigate. Use tab to cycle the result. Use Page Up/Page Down (on Mac: fn + \u21E7 / \u21E9) to change page. Hit enter to select the highlighted item below the prompt."
|
|
70
|
-
)
|
|
71
|
-
);
|
|
72
|
-
const result = await (0, import_prompts.default)({
|
|
73
|
-
name: "packageName",
|
|
74
|
-
type: "autocomplete",
|
|
75
|
-
message: type === "icon" ? "Pick an icon pack:" : type === "font" ? "Pick a font:" : "Pick one:",
|
|
76
|
-
choices: Object.entries(meta).map(([slug, data]) => ({
|
|
77
|
-
title: type === "font" ? `${slug}: ${data.weights.length} weights, ${data.styles.length} styles, ${data.subsets.length} subsets (https://fonts.google.com/specimen/${(0, import_change_case.pascalCase)(slug)})` : `${data.name}: ${data.total} icons, ${data.license.title} license (${data.author.url})`,
|
|
78
|
-
value: slug
|
|
79
|
-
}))
|
|
80
|
-
}), packageName = `${type}-${result.packageName}`, packageDir = import_node_path.default.join(tempDir, "packages", packageName);
|
|
81
|
-
process.chdir(tempDir), (0, import_node_child_process.execSync)(
|
|
82
|
-
[`git sparse-checkout set --no-cone packages/${packageName}`, "git checkout"].join(
|
|
83
|
-
" && "
|
|
84
|
-
)
|
|
85
|
-
);
|
|
86
|
-
const finalDir = import_node_path.default.join(packagesPath, packageName);
|
|
87
|
-
await (0, import_fs_extra.ensureDir)(packagesPath), await (0, import_fs_extra.copy)(packageDir, finalDir), console.info(), console.info(import_chalk.default.green(`Created the package under ${finalDir}`)), console.info();
|
|
88
|
-
const readmePath = import_node_path.default.join(finalDir, "README.md");
|
|
89
|
-
(0, import_node_fs.existsSync)(readmePath) && console.info(import_marked.marked.parse((0, import_fs_extra.readFileSync)(readmePath).toString()));
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=add.js.map
|
package/dist/add.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/add.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAyB,+BACzB,iBAAmC,oBACnC,kBAAyB,6BACzB,iBAAwB,oBACxB,mBAAiB,+BAEjB,eAAkB,2BAClB,qBAA2B,wBAC3B,kBAA8C,qBAC9C,gBAAuB,mBACvB,yBAA6B,qCAC7B,gBAAiB,4BACjB,iBAAoB;AAEpB,qBAAO,WAAW;AAAA,EAChB,UAAU,IAAI,uBAAAA,QAAiB;AACjC,CAAC;AAED,MAAM,WAAO,wBAAQ,GACf,aAAa,iBAAAC,QAAK,KAAK,MAAM,UAAU,GAEhC,wBAAwB,CAAC,QAAQ,MAAM,GACvC,0BAA0B,OAAO,MAAc,iBAA0B;AAEpF,MADA,eAAe,gBAAgB,iBAAAA,QAAK,KAAK,QAAQ,IAAI,GAAG,UAAU,GAC9D,CAAC,sBAAsB,SAAS,IAA8C;AAChF,UAAM,IAAI;AAAA,MACR,GACE,OAAO,SAAS,IAAI,wBAAwB,mBAC9C,qBAAqB,sBAAsB,KAAK,IAAI,CAAC;AAA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AAC,MAAM,IAAI,OAAO;AAAA,MACxD,OACE,SAAS,SACL,GAAG,IAAI,KAAK,KAAK,QAAQ,MAAM,aAAa,KAAK,OAAO,MAAM,YAC5D,KAAK,QAAQ,MACf,mDAA+C,+BAAW,IAAI,CAAC,MAC/D,GAAG,KAAK,IAAI,KAAK,KAAK,KAAK,WAAW,KAAK,QAAQ,KAAK,aAAa,KAAK,OAAO,GAAG;AAAA,MAC1F,OAAO;AAAA,IACT,EAAE;AAAA,EACJ,CAAC,GAEK,cAAc,GAAG,IAAI,IAAI,OAAO,WAAW,IAC3C,aAAa,iBAAAH,QAAK,KAAK,SAAS,YAAY,WAAW;AAC7D,UAAQ,MAAM,OAAO,OACrB;AAAA,IACE,CAAC,8CAA8C,WAAW,IAAI,cAAc,EAAE;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,iBAAAA,QAAK,KAAK,cAAc,WAAW;AACpD,YAAM,2BAAU,YAAY,GAC5B,UAAM,sBAAK,YAAY,QAAQ,GAE/B,QAAQ,KAAK,GACb,QAAQ,KAAK,aAAAC,QAAM,MAAM,6BAA6B,QAAQ,EAAE,CAAC,GACjE,QAAQ,KAAK;AAEb,QAAM,aAAa,iBAAAD,QAAK,KAAK,UAAU,WAAW;AAClD,MAAI,2BAAW,UAAU,KACvB,QAAQ,KAAK,qBAAO,UAAM,8BAAa,UAAU,EAAE,SAAS,CAAC,CAAC;AAElE;",
|
|
5
|
-
"names": ["TerminalRenderer", "path", "chalk", "open", "prompts"]
|
|
6
|
-
}
|
package/dist/build.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var build_exports = {};
|
|
24
|
-
__export(build_exports, {
|
|
25
|
-
build: () => build,
|
|
26
|
-
insertCssImport: () => insertCssImport
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(build_exports);
|
|
29
|
-
var import_static = require("@tamagui/static"), import_chokidar = __toESM(require("chokidar")), import_fs_extra = require("fs-extra"), import_micromatch = __toESM(require("micromatch")), import_node_path = require("node:path"), import_node_os = require("node:os"), import_node_child_process = require("node:child_process"), import_node_crypto = require("node:crypto");
|
|
30
|
-
function insertCssImport(jsContent, cssImport) {
|
|
31
|
-
const directiveMatch = jsContent.match(/^(['"])use (client|server)\1;?\n?/);
|
|
32
|
-
if (directiveMatch) {
|
|
33
|
-
const directive = directiveMatch[0], rest = jsContent.slice(directive.length);
|
|
34
|
-
return `${directive}${cssImport}
|
|
35
|
-
${rest}`;
|
|
36
|
-
}
|
|
37
|
-
return `${cssImport}
|
|
38
|
-
${jsContent}`;
|
|
39
|
-
}
|
|
40
|
-
const build = async (options) => {
|
|
41
|
-
const sourceDir = options.dir ?? ".", promises = [], buildOptions = (0, import_static.loadTamaguiBuildConfigSync)(options.tamaguiOptions), targets = options.target === "both" || !options.target ? ["web", "native"] : [options.target], webTamaguiOptions = {
|
|
42
|
-
...buildOptions,
|
|
43
|
-
platform: "web"
|
|
44
|
-
};
|
|
45
|
-
await (0, import_static.loadTamagui)(webTamaguiOptions);
|
|
46
|
-
const allFiles = [], watchPattern = sourceDir.match(/\.(tsx|jsx)$/) ? sourceDir : `${sourceDir}/**/*.{tsx,jsx}`;
|
|
47
|
-
await new Promise((res) => {
|
|
48
|
-
import_chokidar.default.watch(watchPattern, {
|
|
49
|
-
ignoreInitial: !1
|
|
50
|
-
}).on("add", (relativePath) => {
|
|
51
|
-
const sourcePath = (0, import_node_path.resolve)(process.cwd(), relativePath);
|
|
52
|
-
options.exclude && import_micromatch.default.contains(relativePath, options.exclude) || options.include && !import_micromatch.default.contains(relativePath, options.include) || allFiles.push(sourcePath);
|
|
53
|
-
}).on("ready", () => res());
|
|
54
|
-
});
|
|
55
|
-
const fileToTargets = /* @__PURE__ */ new Map();
|
|
56
|
-
for (const sourcePath of allFiles) {
|
|
57
|
-
const platformMatch = sourcePath.match(/\.(web|native|ios|android)\.(tsx|jsx)$/);
|
|
58
|
-
let filePlatforms = [];
|
|
59
|
-
if (platformMatch) {
|
|
60
|
-
const platform = platformMatch[1];
|
|
61
|
-
platform === "web" ? filePlatforms = ["web"] : (platform === "native" || platform === "ios" || platform === "android") && (filePlatforms = ["native"]);
|
|
62
|
-
} else {
|
|
63
|
-
const basePath = sourcePath.replace(/\.(tsx|jsx)$/, ""), hasNative = allFiles.some(
|
|
64
|
-
(f) => f === `${basePath}.native.tsx` || f === `${basePath}.native.jsx` || f === `${basePath}.ios.tsx` || f === `${basePath}.ios.jsx` || f === `${basePath}.android.tsx` || f === `${basePath}.android.jsx`
|
|
65
|
-
), hasWeb = allFiles.some(
|
|
66
|
-
(f) => f === `${basePath}.web.tsx` || f === `${basePath}.web.jsx`
|
|
67
|
-
);
|
|
68
|
-
filePlatforms = targets.filter((target) => !(target === "native" && hasNative || target === "web" && hasWeb)), hasWeb && hasNative && (filePlatforms = []);
|
|
69
|
-
}
|
|
70
|
-
filePlatforms.length > 0 && fileToTargets.set(sourcePath, filePlatforms);
|
|
71
|
-
}
|
|
72
|
-
const stats = {
|
|
73
|
-
filesProcessed: 0,
|
|
74
|
-
optimized: 0,
|
|
75
|
-
flattened: 0,
|
|
76
|
-
styled: 0,
|
|
77
|
-
found: 0
|
|
78
|
-
}, trackedFiles = [], restoreDir = options.runCommand ? (0, import_node_path.join)((0, import_node_os.tmpdir)(), `tamagui-restore-${process.pid}`) : null;
|
|
79
|
-
restoreDir && await (0, import_fs_extra.mkdir)(restoreDir, { recursive: !0 });
|
|
80
|
-
const trackFile = async (filePath) => {
|
|
81
|
-
if (!restoreDir) return;
|
|
82
|
-
const hash = (0, import_node_crypto.createHash)("md5").update(filePath).digest("hex"), backupPath = (0, import_node_path.join)(restoreDir, hash);
|
|
83
|
-
await (0, import_fs_extra.copyFile)(filePath, backupPath), trackedFiles.push({ path: filePath, hardlinkPath: backupPath, mtimeAfterWrite: 0 });
|
|
84
|
-
}, recordMtime = async (filePath) => {
|
|
85
|
-
if (!restoreDir) return;
|
|
86
|
-
const tracked = trackedFiles.find((t) => t.path === filePath);
|
|
87
|
-
if (tracked) {
|
|
88
|
-
const fileStat = await (0, import_fs_extra.stat)(filePath);
|
|
89
|
-
tracked.mtimeAfterWrite = fileStat.mtimeMs;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
for (const [sourcePath, filePlatforms] of fileToTargets)
|
|
93
|
-
promises.push(
|
|
94
|
-
(async () => {
|
|
95
|
-
options.debug && (process.env.NODE_ENV ||= "development");
|
|
96
|
-
const originalSource = await (0, import_fs_extra.readFile)(sourcePath, "utf-8");
|
|
97
|
-
if (filePlatforms.includes("web")) {
|
|
98
|
-
process.env.TAMAGUI_TARGET = "web";
|
|
99
|
-
const extractor = (0, import_static.createExtractor)({
|
|
100
|
-
platform: "web"
|
|
101
|
-
}), out = await (0, import_static.extractToClassNames)({
|
|
102
|
-
extractor,
|
|
103
|
-
source: originalSource,
|
|
104
|
-
sourcePath,
|
|
105
|
-
options: {
|
|
106
|
-
...buildOptions,
|
|
107
|
-
platform: "web"
|
|
108
|
-
},
|
|
109
|
-
shouldPrintDebug: options.debug || !1
|
|
110
|
-
});
|
|
111
|
-
if (out) {
|
|
112
|
-
stats.filesProcessed++, stats.optimized += out.stats.optimized, stats.flattened += out.stats.flattened, stats.styled += out.stats.styled, stats.found += out.stats.found;
|
|
113
|
-
const cssName = "_" + (0, import_node_path.basename)(sourcePath, (0, import_node_path.extname)(sourcePath)), stylePath = (0, import_node_path.join)((0, import_node_path.dirname)(sourcePath), cssName + ".css"), cssImport = `import "./${cssName}.css"`, jsContent = typeof out.js == "string" ? out.js : out.js.toString("utf-8"), code = insertCssImport(jsContent, cssImport);
|
|
114
|
-
await trackFile(sourcePath), await (0, import_fs_extra.writeFile)(sourcePath, code, "utf-8"), await recordMtime(sourcePath), await (0, import_fs_extra.writeFile)(stylePath, out.styles, "utf-8"), trackedFiles.push({
|
|
115
|
-
path: stylePath,
|
|
116
|
-
hardlinkPath: "",
|
|
117
|
-
// Empty means delete on restore
|
|
118
|
-
mtimeAfterWrite: (await (0, import_fs_extra.stat)(stylePath)).mtimeMs
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (filePlatforms.includes("native")) {
|
|
123
|
-
process.env.TAMAGUI_TARGET = "native";
|
|
124
|
-
const nativeTamaguiOptions = {
|
|
125
|
-
...buildOptions,
|
|
126
|
-
platform: "native"
|
|
127
|
-
}, nativeOut = (0, import_static.extractToNative)(
|
|
128
|
-
sourcePath,
|
|
129
|
-
originalSource,
|
|
130
|
-
nativeTamaguiOptions
|
|
131
|
-
);
|
|
132
|
-
let nativeOutputPath = sourcePath;
|
|
133
|
-
!/\.(web|native|ios|android)\.(tsx|jsx)$/.test(
|
|
134
|
-
sourcePath
|
|
135
|
-
) && filePlatforms.length > 1 && (nativeOutputPath = sourcePath.replace(/\.(tsx|jsx)$/, ".native.$1")), nativeOut.code && ((nativeOutputPath === sourcePath || filePlatforms.length === 1) && await trackFile(nativeOutputPath), await (0, import_fs_extra.writeFile)(nativeOutputPath, nativeOut.code, "utf-8"), await recordMtime(nativeOutputPath), nativeOutputPath !== sourcePath && filePlatforms.length > 1 && trackedFiles.push({
|
|
136
|
-
path: nativeOutputPath,
|
|
137
|
-
hardlinkPath: "",
|
|
138
|
-
// Empty = delete on restore
|
|
139
|
-
mtimeAfterWrite: (await (0, import_fs_extra.stat)(nativeOutputPath)).mtimeMs
|
|
140
|
-
}));
|
|
141
|
-
}
|
|
142
|
-
})()
|
|
143
|
-
);
|
|
144
|
-
if (await Promise.all(promises), options.expectOptimizations !== void 0) {
|
|
145
|
-
const totalOptimizations = stats.optimized + stats.flattened;
|
|
146
|
-
totalOptimizations < options.expectOptimizations && (console.error(
|
|
147
|
-
`
|
|
148
|
-
Expected at least ${options.expectOptimizations} optimizations but only got ${totalOptimizations}`
|
|
149
|
-
), console.error(`Stats: ${JSON.stringify(stats, null, 2)}`), process.exit(1)), console.info(
|
|
150
|
-
`
|
|
151
|
-
\u2713 Met optimization target: ${totalOptimizations} >= ${options.expectOptimizations}`
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
if (options.runCommand && options.runCommand.length > 0) {
|
|
155
|
-
const command = options.runCommand.join(" ");
|
|
156
|
-
console.info(`
|
|
157
|
-
Running: ${command}
|
|
158
|
-
`);
|
|
159
|
-
try {
|
|
160
|
-
(0, import_node_child_process.execSync)(command, { stdio: "inherit" });
|
|
161
|
-
} catch (err) {
|
|
162
|
-
console.error(`
|
|
163
|
-
Command failed with exit code ${err.status || 1}`), process.exitCode = err.status || 1;
|
|
164
|
-
} finally {
|
|
165
|
-
await restoreFiles(trackedFiles, restoreDir);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return { stats, trackedFiles };
|
|
169
|
-
};
|
|
170
|
-
async function restoreFiles(trackedFiles, restoreDir) {
|
|
171
|
-
if (!restoreDir || trackedFiles.length === 0) return;
|
|
172
|
-
console.info(`
|
|
173
|
-
Restoring ${trackedFiles.length} files...`);
|
|
174
|
-
let restored = 0, skipped = 0, deleted = 0;
|
|
175
|
-
for (const tracked of trackedFiles)
|
|
176
|
-
try {
|
|
177
|
-
const currentStat = await (0, import_fs_extra.stat)(tracked.path).catch(() => null);
|
|
178
|
-
if (currentStat && currentStat.mtimeMs !== tracked.mtimeAfterWrite) {
|
|
179
|
-
console.warn(` Skipping ${tracked.path} - modified during build`), skipped++;
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
tracked.hardlinkPath === "" ? (await (0, import_fs_extra.rm)(tracked.path, { force: !0 }), deleted++) : (await (0, import_fs_extra.copyFile)(tracked.hardlinkPath, tracked.path), restored++);
|
|
183
|
-
} catch (err) {
|
|
184
|
-
console.warn(` Failed to restore ${tracked.path}: ${err.message}`), skipped++;
|
|
185
|
-
}
|
|
186
|
-
await (0, import_fs_extra.rm)(restoreDir, { recursive: !0, force: !0 }), console.info(` Restored: ${restored}, Deleted: ${deleted}, Skipped: ${skipped}`);
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=build.js.map
|
package/dist/build.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/build.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAMO,4BAEP,kBAAqB,8BACrB,kBAA+D,qBAC/D,oBAAuB,gCACvB,mBAA0D,sBAC1D,iBAAuB,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