@tamagui/cli 1.101.0 → 1.101.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.
- package/package.json +8 -8
- package/types/build.d.ts +1 -1
- package/types/utils.d.ts.map +1 -1
- package/dist/add.mjs +0 -64
- package/dist/build.mjs +0 -37
- package/dist/cli.mjs +0 -250
- package/dist/generate.mjs +0 -27
- package/dist/index.mjs +0 -2
- package/dist/studio.mjs +0 -108
- package/dist/update-template.mjs +0 -23
- package/dist/update.mjs +0 -2
- package/dist/utils.mjs +0 -72
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/cli",
|
|
3
|
-
"version": "1.101.
|
|
3
|
+
"version": "1.101.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"types": "./types/index.d.ts",
|
|
6
6
|
"main": "dist",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"clean:build": "tamagui-build clean:build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tamagui/create-theme": "1.101.
|
|
27
|
-
"@tamagui/generate-themes": "1.101.
|
|
28
|
-
"@tamagui/static": "1.101.
|
|
29
|
-
"@tamagui/types": "1.101.
|
|
30
|
-
"@tamagui/vite-plugin": "1.101.
|
|
26
|
+
"@tamagui/create-theme": "1.101.1",
|
|
27
|
+
"@tamagui/generate-themes": "1.101.1",
|
|
28
|
+
"@tamagui/static": "1.101.1",
|
|
29
|
+
"@tamagui/types": "1.101.1",
|
|
30
|
+
"@tamagui/vite-plugin": "1.101.1",
|
|
31
31
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
32
32
|
"arg": "^5.0.2",
|
|
33
33
|
"chalk": "^4.1.2",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"opener": "^1.5.2",
|
|
50
50
|
"prompts": "2.1.0",
|
|
51
51
|
"ts-morph": "^15.1.0",
|
|
52
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.5.2",
|
|
53
53
|
"url": "^0.11.0",
|
|
54
54
|
"vite": "6.0.0-alpha.17",
|
|
55
55
|
"vite-plugin-entry-shaking": "^0.4.3",
|
|
56
56
|
"vite-tsconfig-paths": "^4.3.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@tamagui/build": "1.101.
|
|
59
|
+
"@tamagui/build": "1.101.1",
|
|
60
60
|
"@types/chokidar": "^2.1.3",
|
|
61
61
|
"@types/marked": "^5.0.0"
|
|
62
62
|
}
|
package/types/build.d.ts
CHANGED
package/types/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAKzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIxE,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,CAuC5D;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAKzD;AAiBD,eAAO,MAAM,WAAW,SAChB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAKzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIxE,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,CAuC5D;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAKzD;AAiBD,eAAO,MAAM,WAAW,SAChB,OAAO,CAAC,cAAc,CAAC,KAC5B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAUnC,CAAA;AAID,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,IAAI,QAE7C;AAED,wBAAgB,UAAU,SAEzB"}
|
package/dist/add.mjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { existsSync, rmSync } from "node:fs";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
import { pascalCase } from "change-case";
|
|
8
|
-
import FSExtra from "fs-extra";
|
|
9
|
-
import { marked } from "marked";
|
|
10
|
-
import TerminalRenderer from "marked-terminal";
|
|
11
|
-
import open from "opener";
|
|
12
|
-
import prompts from "prompts";
|
|
13
|
-
const {
|
|
14
|
-
copy,
|
|
15
|
-
ensureDir,
|
|
16
|
-
readFileSync
|
|
17
|
-
} = FSExtra;
|
|
18
|
-
marked.setOptions({
|
|
19
|
-
headerIds: !1,
|
|
20
|
-
mangle: !1,
|
|
21
|
-
renderer: new TerminalRenderer()
|
|
22
|
-
});
|
|
23
|
-
const home = homedir(),
|
|
24
|
-
tamaguiDir = path.join(home, ".tamagui"),
|
|
25
|
-
generatedPackageTypes = ["font", "icon"],
|
|
26
|
-
installGeneratedPackage = async (type, packagesPath) => {
|
|
27
|
-
if (packagesPath = packagesPath || path.join(process.cwd(), "packages"), !generatedPackageTypes.includes(type)) throw new Error(`${type ? `Type "${type}" is Not supported.` : "No type provided."} Supported types: ${generatedPackageTypes.join(", ")}`);
|
|
28
|
-
const repoName = type === "font" ? "tamagui-google-fonts" : "tamagui-iconify";
|
|
29
|
-
console.info(`Setting up ${chalk.blueBright(tamaguiDir)}...`), await ensureDir(tamaguiDir);
|
|
30
|
-
const tempDir = path.join(tamaguiDir, repoName);
|
|
31
|
-
existsSync(tempDir) && rmSync(tempDir, {
|
|
32
|
-
recursive: !0
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
process.chdir(tamaguiDir);
|
|
36
|
-
try {
|
|
37
|
-
console.info("Attempting to clone with SSH"), execSync(`git clone -n --depth=1 --branch generated --filter=tree:0 git@github.com:tamagui/${repoName}.git`);
|
|
38
|
-
} catch {
|
|
39
|
-
console.info("SSH failed - Attempting to c lone with HTTPS"), execSync(`git clone -n --depth=1 --branch generated --filter=tree:0 https://github.com/tamagui/${repoName}`);
|
|
40
|
-
}
|
|
41
|
-
process.chdir(tempDir), execSync(["git sparse-checkout set --no-cone meta", "git checkout"].join(" && "));
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (error instanceof Error) throw error?.stderr.includes("Repository not found") && (console.info(chalk.yellow(`You don't have access to Tamagui ${type === "font" ? "fonts" : "icons"}. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info.`)), open("https://tamagui.dev/takeout"), process.exit(0)), error;
|
|
44
|
-
}
|
|
45
|
-
const meta = JSON.parse(await readFile(path.join(tamaguiDir, repoName, "meta", "data.json")).then(r => r.toString()));
|
|
46
|
-
console.info(chalk.gray("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."));
|
|
47
|
-
const result = await prompts({
|
|
48
|
-
name: "packageName",
|
|
49
|
-
type: "autocomplete",
|
|
50
|
-
message: type === "icon" ? "Pick an icon pack:" : type === "font" ? "Pick a font:" : "Pick one:",
|
|
51
|
-
choices: Object.entries(meta).map(([slug, data]) => ({
|
|
52
|
-
title: type === "font" ? `${slug}: ${data.weights.length} weights, ${data.styles.length} styles, ${data.subsets.length} subsets (https://fonts.google.com/specimen/${pascalCase(slug)})` : `${data.name}: ${data.total} icons, ${data.license.title} license (${data.author.url})`,
|
|
53
|
-
value: slug
|
|
54
|
-
}))
|
|
55
|
-
}),
|
|
56
|
-
packageName = `${type}-${result.packageName}`,
|
|
57
|
-
packageDir = path.join(tempDir, "packages", packageName);
|
|
58
|
-
process.chdir(tempDir), execSync([`git sparse-checkout set --no-cone packages/${packageName}`, "git checkout"].join(" && "));
|
|
59
|
-
const finalDir = path.join(packagesPath, packageName);
|
|
60
|
-
await ensureDir(packagesPath), await copy(packageDir, finalDir), console.info(), console.info(chalk.green(`Created the package under ${finalDir}`)), console.info();
|
|
61
|
-
const readmePath = path.join(finalDir, "README.md");
|
|
62
|
-
existsSync(readmePath) && console.info(marked.parse(readFileSync(readmePath).toString()));
|
|
63
|
-
};
|
|
64
|
-
export { generatedPackageTypes, installGeneratedPackage };
|
package/dist/build.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import { createExtractor, extractToClassNames, loadTamaguiBuildConfigSync } from "@tamagui/static";
|
|
3
|
-
import chokidar from "chokidar";
|
|
4
|
-
import { readFile } from "fs-extra";
|
|
5
|
-
import MicroMatch from "micromatch";
|
|
6
|
-
const build = async options => {
|
|
7
|
-
const sourceDir = options.dir ?? ".",
|
|
8
|
-
promises = [],
|
|
9
|
-
targets = ["web"],
|
|
10
|
-
buildOptions = loadTamaguiBuildConfigSync(options.tamaguiOptions);
|
|
11
|
-
await new Promise(res => {
|
|
12
|
-
chokidar.watch(sourceDir, {
|
|
13
|
-
// persistent: true,
|
|
14
|
-
}).on("add", relativePath => {
|
|
15
|
-
if (options.exclude && MicroMatch.contains(relativePath, options.exclude) || options.include && !MicroMatch.contains(relativePath, options.include)) return;
|
|
16
|
-
const sourcePath = resolve(process.cwd(), relativePath);
|
|
17
|
-
promises.push((async () => {
|
|
18
|
-
await Promise.all(targets.map(async target => {
|
|
19
|
-
process.env.TAMAGUI_TARGET = target, options.debug && (process.env.NODE_ENV ||= "development");
|
|
20
|
-
const source = await readFile(sourcePath, "utf-8"),
|
|
21
|
-
extractor = createExtractor(),
|
|
22
|
-
out = await extractToClassNames({
|
|
23
|
-
extractor,
|
|
24
|
-
source,
|
|
25
|
-
sourcePath,
|
|
26
|
-
options: buildOptions,
|
|
27
|
-
shouldPrintDebug: options.debug || !1
|
|
28
|
-
});
|
|
29
|
-
console.log("go", out);
|
|
30
|
-
}));
|
|
31
|
-
})());
|
|
32
|
-
}).on("ready", () => {
|
|
33
|
-
res();
|
|
34
|
-
});
|
|
35
|
-
}), await Promise.all(promises);
|
|
36
|
-
};
|
|
37
|
-
export { build };
|
package/dist/cli.mjs
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import arg from "arg";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { generatedPackageTypes } from "./add.js";
|
|
4
|
-
import { disposeAll, getOptions } from "./utils.mjs";
|
|
5
|
-
import { loadTamagui, checkDeps } from "@tamagui/static";
|
|
6
|
-
["exit", "SIGINT"].forEach(_ => {
|
|
7
|
-
process.on(_, () => {
|
|
8
|
-
disposeAll(), process.exit();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
const COMMAND_MAP = {
|
|
12
|
-
check: {
|
|
13
|
-
description: "Checks your dependencies for inconsistent versions.",
|
|
14
|
-
shorthands: [],
|
|
15
|
-
flags: {
|
|
16
|
-
"--help": Boolean,
|
|
17
|
-
"--debug": Boolean,
|
|
18
|
-
"--verbose": Boolean
|
|
19
|
-
},
|
|
20
|
-
async run() {
|
|
21
|
-
const {
|
|
22
|
-
_,
|
|
23
|
-
...flags2
|
|
24
|
-
} = arg(this.flags),
|
|
25
|
-
options = await getOptions({
|
|
26
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1,
|
|
27
|
-
loadTamaguiOptions: !0
|
|
28
|
-
}),
|
|
29
|
-
instance = await checkDeps(options.paths.root, {
|
|
30
|
-
depType: ["dependencies", "devDependencies"]
|
|
31
|
-
}),
|
|
32
|
-
isNonTamaguiNamedDep = {
|
|
33
|
-
"react-native-web-lite": !0,
|
|
34
|
-
"react-native-web-internals": !0
|
|
35
|
-
};
|
|
36
|
-
for (const dep of instance.getDependencies()) !dep.name.includes("tamagui") && !isNonTamaguiNamedDep[dep.name] || dep.isMismatching && console.warn(`-------------------------------------------------------------------------------------------------
|
|
37
|
-
|
|
38
|
-
\u26A0\uFE0F [tamagui] Mis-matching dependency version found in: ${dep.name}
|
|
39
|
-
|
|
40
|
-
This will cause errors in your app. To fix, make sure all tamagui dependencies
|
|
41
|
-
in your repo are on on the same version.
|
|
42
|
-
|
|
43
|
-
Other versions used in the repo: ${dep.versions.map(version => version.version).join(", ")}
|
|
44
|
-
|
|
45
|
-
-------------------------------------------------------------------------------------------------`);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
generate: {
|
|
49
|
-
description: "Builds your entire tamagui configuration and outputs any CSS.",
|
|
50
|
-
shorthands: [],
|
|
51
|
-
flags: {
|
|
52
|
-
"--help": Boolean,
|
|
53
|
-
"--debug": Boolean,
|
|
54
|
-
"--verbose": Boolean
|
|
55
|
-
},
|
|
56
|
-
async run() {
|
|
57
|
-
const {
|
|
58
|
-
_,
|
|
59
|
-
...flags2
|
|
60
|
-
} = arg(this.flags),
|
|
61
|
-
options = await getOptions({
|
|
62
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1,
|
|
63
|
-
loadTamaguiOptions: !0
|
|
64
|
-
});
|
|
65
|
-
process.env.TAMAGUI_KEEP_THEMES = "1", await loadTamagui({
|
|
66
|
-
...options.tamaguiOptions,
|
|
67
|
-
platform: "web"
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
"generate-themes": {
|
|
72
|
-
shorthands: ["gt"],
|
|
73
|
-
description: "Use to pre-build your themes",
|
|
74
|
-
flags: {
|
|
75
|
-
"--help": Boolean,
|
|
76
|
-
"--debug": Boolean,
|
|
77
|
-
"--verbose": Boolean
|
|
78
|
-
},
|
|
79
|
-
async run() {
|
|
80
|
-
const {
|
|
81
|
-
_,
|
|
82
|
-
...flags2
|
|
83
|
-
} = arg(this.flags),
|
|
84
|
-
options = await getOptions({
|
|
85
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1
|
|
86
|
-
}),
|
|
87
|
-
[_cmd, inPath, outPath] = _;
|
|
88
|
-
if (!inPath || !outPath) throw new Error(`Must supply both input and output paths, missing one (inPath: ${inPath}, outPath: ${outPath})`);
|
|
89
|
-
const {
|
|
90
|
-
generateThemes,
|
|
91
|
-
writeGeneratedThemes
|
|
92
|
-
} = require("@tamagui/generate-themes");
|
|
93
|
-
try {
|
|
94
|
-
const generated = await generateThemes(inPath);
|
|
95
|
-
await writeGeneratedThemes(options.paths.dotDir, outPath, generated);
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error(`Error generating themes: ${err}`);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
console.info(`Successfully generated themes to ${outPath}`);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
add: {
|
|
104
|
-
shorthands: ["a"],
|
|
105
|
-
description: `Use to add fonts and icons to your monorepo. Supported types: ${generatedPackageTypes.join(", ")}`,
|
|
106
|
-
flags: {
|
|
107
|
-
"--help": Boolean,
|
|
108
|
-
"--debug": Boolean,
|
|
109
|
-
"--verbose": Boolean
|
|
110
|
-
},
|
|
111
|
-
async run() {
|
|
112
|
-
const {
|
|
113
|
-
_,
|
|
114
|
-
...flags2
|
|
115
|
-
} = arg(this.flags),
|
|
116
|
-
{
|
|
117
|
-
installGeneratedPackage
|
|
118
|
-
} = require("./add.js"),
|
|
119
|
-
[cmd, type, path] = _;
|
|
120
|
-
await installGeneratedPackage(type, path);
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
build: {
|
|
124
|
-
shorthands: ["b"],
|
|
125
|
-
description: "Use to pre-build a Tamagui component directory",
|
|
126
|
-
flags: {
|
|
127
|
-
"--help": Boolean,
|
|
128
|
-
"--debug": Boolean,
|
|
129
|
-
"--verbose": Boolean,
|
|
130
|
-
"--include": String,
|
|
131
|
-
"--exclude": String
|
|
132
|
-
},
|
|
133
|
-
async run() {
|
|
134
|
-
const {
|
|
135
|
-
_,
|
|
136
|
-
...flags2
|
|
137
|
-
} = arg(this.flags),
|
|
138
|
-
[dir] = _,
|
|
139
|
-
{
|
|
140
|
-
build
|
|
141
|
-
} = await import("./build.js"),
|
|
142
|
-
options = await getOptions({
|
|
143
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1
|
|
144
|
-
});
|
|
145
|
-
await build({
|
|
146
|
-
...options,
|
|
147
|
-
dir,
|
|
148
|
-
include: flags2["--include"],
|
|
149
|
-
exclude: flags2["--exclude"]
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
// update: {
|
|
154
|
-
// shorthands: [],
|
|
155
|
-
// description: `Update all tamagui packages within a monorepo`,
|
|
156
|
-
// flags: {},
|
|
157
|
-
// async run() {
|
|
158
|
-
// const { update } = await import('./update')
|
|
159
|
-
// await update()
|
|
160
|
-
// },
|
|
161
|
-
// },
|
|
162
|
-
studio: {
|
|
163
|
-
shorthands: ["s"],
|
|
164
|
-
description: "Studio",
|
|
165
|
-
flags: {
|
|
166
|
-
"--help": Boolean,
|
|
167
|
-
"--debug": Boolean,
|
|
168
|
-
"--verbose": Boolean,
|
|
169
|
-
"--remote": Boolean,
|
|
170
|
-
"--build": Boolean
|
|
171
|
-
},
|
|
172
|
-
async run() {
|
|
173
|
-
const {
|
|
174
|
-
_,
|
|
175
|
-
...flags2
|
|
176
|
-
} = arg(this.flags),
|
|
177
|
-
{
|
|
178
|
-
studio
|
|
179
|
-
} = require("./studio"),
|
|
180
|
-
options = await getOptions({
|
|
181
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1
|
|
182
|
-
});
|
|
183
|
-
await studio(options, flags2["--remote"], flags2["--build"]);
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
"update-template": {
|
|
187
|
-
shorthands: ["ut"],
|
|
188
|
-
description: "Used to update your git repo with the source template. (e.g. Takeout)",
|
|
189
|
-
flags: {
|
|
190
|
-
"--help": Boolean,
|
|
191
|
-
"--template-repo": String,
|
|
192
|
-
"--ignored-patterns": String
|
|
193
|
-
},
|
|
194
|
-
async run() {
|
|
195
|
-
const {
|
|
196
|
-
_,
|
|
197
|
-
...flags2
|
|
198
|
-
} = arg(this.flags),
|
|
199
|
-
{
|
|
200
|
-
updateTemplate
|
|
201
|
-
} = require("./update-template");
|
|
202
|
-
if (!flags2["--template-repo"]) throw new Error("--template-repo is required");
|
|
203
|
-
await updateTemplate(flags2["--template-repo"], flags2["--ignored-patterns"]?.split(" "));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
commandEntries = Object.keys(COMMAND_MAP).flatMap(command2 => {
|
|
208
|
-
const definition2 = COMMAND_MAP[command2];
|
|
209
|
-
return [command2, ...definition2.shorthands].map(cmd => [cmd, definition2]);
|
|
210
|
-
}),
|
|
211
|
-
commands = Object.fromEntries(commandEntries),
|
|
212
|
-
{
|
|
213
|
-
_: [command],
|
|
214
|
-
...flags
|
|
215
|
-
} = arg({
|
|
216
|
-
"--help": Boolean,
|
|
217
|
-
"--version": Boolean
|
|
218
|
-
}, {
|
|
219
|
-
permissive: !0
|
|
220
|
-
});
|
|
221
|
-
flags["--version"] && (console.info(require("../package.json").version), process.exit(0));
|
|
222
|
-
!command && flags["--help"] && (console.info(`$ tamagui
|
|
223
|
-
|
|
224
|
-
commands:
|
|
225
|
-
|
|
226
|
-
${Object.keys(COMMAND_MAP).map(key => ` ${key}`).join(`
|
|
227
|
-
`)}`), process.exit(0));
|
|
228
|
-
command in commands || (console.error(), console.warn(chalk.yellow(`Not a valid command: ${command}`)), process.exit(1));
|
|
229
|
-
const definition = commands[command];
|
|
230
|
-
main();
|
|
231
|
-
async function main() {
|
|
232
|
-
flags["--help"] && (console.info(`
|
|
233
|
-
$ tamagui ${command}: ${definition.description}
|
|
234
|
-
`), console.info(`Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`), process.exit(0));
|
|
235
|
-
const {
|
|
236
|
-
_,
|
|
237
|
-
...cmdFlags
|
|
238
|
-
} = arg(definition.flags);
|
|
239
|
-
cmdFlags["--help"] && (console.info(`$ tamagui ${_}
|
|
240
|
-
|
|
241
|
-
Flags: ${JSON.stringify(cmdFlags, null, 2)}
|
|
242
|
-
|
|
243
|
-
`), process.exit(0));
|
|
244
|
-
try {
|
|
245
|
-
await definition.run();
|
|
246
|
-
} catch (err) {
|
|
247
|
-
console.error(`Error running command: ${err.message}`);
|
|
248
|
-
}
|
|
249
|
-
process.exit(0);
|
|
250
|
-
}
|
package/dist/generate.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import { Project } from "ts-morph";
|
|
4
|
-
import { loadTamagui } from "./utils.mjs";
|
|
5
|
-
async function generateTypes(options) {
|
|
6
|
-
const types = await getTypes(options);
|
|
7
|
-
await fs.writeJSON(options.paths.types, types, {
|
|
8
|
-
spaces: 2
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
async function getTypes(options) {
|
|
12
|
-
const tamagui = await loadTamagui(options.tamaguiOptions);
|
|
13
|
-
if (!tamagui) throw new Error("No tamagui config");
|
|
14
|
-
const nameToPaths = tamagui.nameToPaths || [],
|
|
15
|
-
uniqueViewExportingPaths = new Set(Object.keys(nameToPaths).map(name => `${[...nameToPaths[name]][0]}.ts*`)),
|
|
16
|
-
files = new Project({
|
|
17
|
-
compilerOptions: {
|
|
18
|
-
noEmit: !1,
|
|
19
|
-
declaration: !0,
|
|
20
|
-
emitDeclarationOnly: !0
|
|
21
|
-
},
|
|
22
|
-
skipAddingFilesFromTsConfig: !0,
|
|
23
|
-
tsConfigFilePath: options.tsconfigPath
|
|
24
|
-
}).addSourceFilesAtPaths([...uniqueViewExportingPaths]);
|
|
25
|
-
return Object.fromEntries(files.flatMap(x => [...x.getExportedDeclarations()].map(([k, v]) => [k, v[0].getType().getApparentType().getProperties().map(prop => [prop.getEscapedName(), prop.getValueDeclaration()?.getType().getText()])])));
|
|
26
|
-
}
|
|
27
|
-
export { generateTypes, getTypes };
|
package/dist/index.mjs
DELETED
package/dist/studio.mjs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { watchTamaguiConfig } from "@tamagui/static";
|
|
4
|
-
import viteReactPlugin from "@vitejs/plugin-react-swc";
|
|
5
|
-
import chalk from "chalk";
|
|
6
|
-
import express from "express";
|
|
7
|
-
import fs, { ensureDir } from "fs-extra";
|
|
8
|
-
import { createProxyMiddleware } from "http-proxy-middleware";
|
|
9
|
-
import { build, createServer } from "vite";
|
|
10
|
-
import viteInspect from "vite-plugin-inspect";
|
|
11
|
-
import viteTsConfigPaths from "vite-tsconfig-paths";
|
|
12
|
-
const resolve = "url" in import.meta ? createRequire(import.meta.url).resolve : require.resolve,
|
|
13
|
-
studio = async (options, isRemote = !1, isBuild = !1) => {
|
|
14
|
-
const {
|
|
15
|
-
tamaguiExtractPlugin,
|
|
16
|
-
tamaguiPlugin
|
|
17
|
-
} = await import("@tamagui/vite-plugin");
|
|
18
|
-
await ensureDir(options.paths.dotDir);
|
|
19
|
-
const configWatchPromise = watchTamaguiConfig(options.tamaguiOptions);
|
|
20
|
-
let localServerPromise = new Promise(() => {});
|
|
21
|
-
if (isRemote) console.log("Open ", chalk.green("https://studio.tamagui.dev"), " to load studio");else {
|
|
22
|
-
process.env.VITE_IS_LOCAL = "1", process.stdout.on("error", err => {
|
|
23
|
-
err.code == "EPIPE" && process.exit(0);
|
|
24
|
-
});
|
|
25
|
-
const {
|
|
26
|
-
default: getPort
|
|
27
|
-
} = await import("get-port"),
|
|
28
|
-
{
|
|
29
|
-
paths
|
|
30
|
-
} = options,
|
|
31
|
-
root = dirname(dirname(resolve("@tamagui/studio"))),
|
|
32
|
-
[serverPort, vitePort] = await Promise.all([getPort({
|
|
33
|
-
port: 1421
|
|
34
|
-
}), getPort({
|
|
35
|
-
port: 1422
|
|
36
|
-
})]),
|
|
37
|
-
targets = [resolve("@tamagui/lucide-icons").replace("/dist/cjs/index.js", ""), resolve("@tamagui/demos").replace("/dist/cjs/index.js", "")],
|
|
38
|
-
viteConfig = {
|
|
39
|
-
root,
|
|
40
|
-
server: {
|
|
41
|
-
host: options.host,
|
|
42
|
-
port: vitePort,
|
|
43
|
-
hmr: !0,
|
|
44
|
-
cors: !0
|
|
45
|
-
},
|
|
46
|
-
build: {
|
|
47
|
-
rollupOptions: {}
|
|
48
|
-
},
|
|
49
|
-
plugins: [viteReactPlugin({
|
|
50
|
-
tsDecorators: !0
|
|
51
|
-
}), tamaguiPlugin({
|
|
52
|
-
components: ["tamagui"]
|
|
53
|
-
}), tamaguiExtractPlugin({
|
|
54
|
-
config: "./src/tamagui.config.ts",
|
|
55
|
-
disableExtraction: !0,
|
|
56
|
-
components: ["tamagui"]
|
|
57
|
-
}), viteTsConfigPaths(),
|
|
58
|
-
// await entryShakingPlugin({
|
|
59
|
-
// targets,
|
|
60
|
-
// }),
|
|
61
|
-
viteInspect()],
|
|
62
|
-
define: {
|
|
63
|
-
"process.env.TAMAGUI_KEEP_THEMES": "true",
|
|
64
|
-
global: "window"
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
if (isBuild) return await build(viteConfig);
|
|
68
|
-
const server = await createServer(viteConfig);
|
|
69
|
-
await server.listen();
|
|
70
|
-
const info = server.httpServer?.address(),
|
|
71
|
-
app = express();
|
|
72
|
-
app.disable("x-powered-by"), app.use(express.static(paths.dotDir, {
|
|
73
|
-
maxAge: "2h"
|
|
74
|
-
})), app.get("/conf.json", async (req, res) => {
|
|
75
|
-
const conf = await fs.readJSON(paths.conf);
|
|
76
|
-
res.status(200).json(conf);
|
|
77
|
-
}), app.get("/pingz", async (req, res) => {
|
|
78
|
-
res.status(200).json({
|
|
79
|
-
hi: !0
|
|
80
|
-
});
|
|
81
|
-
}), app.get("/api/tamagui.config.json", async (req, res) => {
|
|
82
|
-
try {
|
|
83
|
-
res.status(200).json(await fs.readJSON(paths.conf));
|
|
84
|
-
} catch (err) {
|
|
85
|
-
res.status(500).json({
|
|
86
|
-
error: `${err.message}`
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}), app.get("/api/tamagui.themes.json", async (req, res) => {
|
|
90
|
-
try {
|
|
91
|
-
res.status(200).json(await fs.readJSON(join(paths.dotDir, "theme-builder.json")));
|
|
92
|
-
} catch (err) {
|
|
93
|
-
res.status(500).json({
|
|
94
|
-
error: `${err.message}`
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
const target = `http://${info.address}:${vitePort}`;
|
|
99
|
-
app.use("/", createProxyMiddleware({
|
|
100
|
-
target,
|
|
101
|
-
ws: !0
|
|
102
|
-
}));
|
|
103
|
-
const appServer = app.listen(serverPort);
|
|
104
|
-
localServerPromise = new Promise(res => appServer.on("close", res)), console.log("Listening on", chalk.green(`http://localhost:${serverPort}`));
|
|
105
|
-
}
|
|
106
|
-
await Promise.allSettled([configWatchPromise, localServerPromise]);
|
|
107
|
-
};
|
|
108
|
-
export { studio };
|
package/dist/update-template.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { execSync } from "child_process";
|
|
3
|
-
function updateTemplate(templateUrl, ignoredPatterns = []) {
|
|
4
|
-
const remoteName = `${templateUrl.split("/").pop()?.split(".")[0] || "template"}-template`,
|
|
5
|
-
addRemoteCommand = `git remote add ${remoteName} ${templateUrl}`,
|
|
6
|
-
rmRemoteCommand = `git remote remove ${remoteName}`;
|
|
7
|
-
try {
|
|
8
|
-
execSync(addRemoteCommand);
|
|
9
|
-
} catch (error) {
|
|
10
|
-
if (error instanceof Error && error.toString().includes("already exists")) execSync(rmRemoteCommand), execSync(addRemoteCommand);else throw error;
|
|
11
|
-
}
|
|
12
|
-
execSync("git fetch --all");
|
|
13
|
-
try {
|
|
14
|
-
execSync("git merge takeout-template/main --allow-unrelated-histories");
|
|
15
|
-
} catch (error) {
|
|
16
|
-
if (error instanceof Error && error.message.includes("unresolved conflict")) console.info(tamaguiLog("We've merged the latest changes. Please resolve the conflicts and commit the merge."));else throw error;
|
|
17
|
-
}
|
|
18
|
-
execSync(`git reset HEAD ${ignoredPatterns.join(" ")}`);
|
|
19
|
-
}
|
|
20
|
-
function tamaguiLog(message) {
|
|
21
|
-
return `${chalk.green("[Tamagui]")} ${message}`;
|
|
22
|
-
}
|
|
23
|
-
export { updateTemplate };
|
package/dist/update.mjs
DELETED
package/dist/utils.mjs
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
|
-
import { loadTamaguiBuildConfigSync, loadTamagui as loadTamaguiStatic } from "@tamagui/static";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import fs, { pathExists, readJSON } from "fs-extra";
|
|
5
|
-
async function getOptions({
|
|
6
|
-
root = process.cwd(),
|
|
7
|
-
tsconfigPath = "tsconfig.json",
|
|
8
|
-
tamaguiOptions,
|
|
9
|
-
host,
|
|
10
|
-
debug,
|
|
11
|
-
loadTamaguiOptions
|
|
12
|
-
} = {}) {
|
|
13
|
-
const tsConfigFilePath = join(root, tsconfigPath);
|
|
14
|
-
ensure(await fs.pathExists(tsConfigFilePath), `No tsconfig found: ${tsConfigFilePath}`);
|
|
15
|
-
const dotDir = join(root, ".tamagui");
|
|
16
|
-
let pkgJson = {},
|
|
17
|
-
config = "";
|
|
18
|
-
try {
|
|
19
|
-
config = await getDefaultTamaguiConfigPath(), pkgJson = await readJSON(join(root, "package.json"));
|
|
20
|
-
} catch {}
|
|
21
|
-
const filledOptions = {
|
|
22
|
-
platform: "native",
|
|
23
|
-
components: ["tamagui"],
|
|
24
|
-
config,
|
|
25
|
-
...tamaguiOptions
|
|
26
|
-
},
|
|
27
|
-
finalOptions = loadTamaguiOptions ? loadTamaguiBuildConfigSync(filledOptions) : filledOptions;
|
|
28
|
-
return {
|
|
29
|
-
mode: process.env.NODE_ENV === "production" ? "production" : "development",
|
|
30
|
-
root,
|
|
31
|
-
host: host || "127.0.0.1",
|
|
32
|
-
pkgJson,
|
|
33
|
-
debug,
|
|
34
|
-
tsconfigPath,
|
|
35
|
-
tamaguiOptions: finalOptions,
|
|
36
|
-
paths: {
|
|
37
|
-
root,
|
|
38
|
-
dotDir,
|
|
39
|
-
conf: join(dotDir, "tamagui.config.json"),
|
|
40
|
-
types: join(dotDir, "types.json")
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function ensure(condition, message) {
|
|
45
|
-
condition || (console.error(chalk.red.bold("Error:"), chalk.yellow(`${message}`)), process.exit(1));
|
|
46
|
-
}
|
|
47
|
-
const defaultPaths = ["tamagui.config.ts", join("src", "tamagui.config.ts")];
|
|
48
|
-
let cachedPath = "";
|
|
49
|
-
async function getDefaultTamaguiConfigPath() {
|
|
50
|
-
if (cachedPath) return cachedPath;
|
|
51
|
-
const existing = (await Promise.all(defaultPaths.map(path => pathExists(path)))).findIndex(x => !!x),
|
|
52
|
-
found = defaultPaths[existing];
|
|
53
|
-
if (!found) throw new Error("No found tamagui.config.ts");
|
|
54
|
-
return cachedPath = found, found;
|
|
55
|
-
}
|
|
56
|
-
let cached = null;
|
|
57
|
-
const loadTamagui = async opts => {
|
|
58
|
-
const loaded = await loadTamaguiStatic({
|
|
59
|
-
config: await getDefaultTamaguiConfigPath(),
|
|
60
|
-
components: ["tamagui"],
|
|
61
|
-
...opts
|
|
62
|
-
});
|
|
63
|
-
return loaded && (cached = loaded), loaded;
|
|
64
|
-
},
|
|
65
|
-
disposers = /* @__PURE__ */new Set();
|
|
66
|
-
function registerDispose(cb) {
|
|
67
|
-
disposers.add(cb);
|
|
68
|
-
}
|
|
69
|
-
function disposeAll() {
|
|
70
|
-
disposers.forEach(cb => cb());
|
|
71
|
-
}
|
|
72
|
-
export { disposeAll, ensure, getOptions, loadTamagui, registerDispose };
|