@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/dist/cli.js
DELETED
|
@@ -1,266 +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 __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
return to;
|
|
11
|
-
};
|
|
12
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
13
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
14
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
15
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
16
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
18
|
-
mod
|
|
19
|
-
));
|
|
20
|
-
var import_arg = __toESM(require("arg")), import_chalk = __toESM(require("chalk")), import_add = require("./add"), import_utils = require("./utils"), import_static = require("@tamagui/static");
|
|
21
|
-
["exit", "SIGINT"].forEach((_) => {
|
|
22
|
-
process.on(_, () => {
|
|
23
|
-
(0, import_utils.disposeAll)(), process.exit();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
const COMMAND_MAP = {
|
|
27
|
-
check: {
|
|
28
|
-
description: "Checks your dependencies for inconsistent versions.",
|
|
29
|
-
shorthands: [],
|
|
30
|
-
flags: {
|
|
31
|
-
"--help": Boolean,
|
|
32
|
-
"--debug": Boolean,
|
|
33
|
-
"--verbose": Boolean
|
|
34
|
-
},
|
|
35
|
-
async run() {
|
|
36
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), options = await (0, import_utils.getOptions)({
|
|
37
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1,
|
|
38
|
-
loadTamaguiOptions: !0
|
|
39
|
-
});
|
|
40
|
-
await (0, import_static.checkDeps)(options.paths.root);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
generate: {
|
|
44
|
-
description: "Builds your entire tamagui configuration and outputs any CSS.",
|
|
45
|
-
shorthands: [],
|
|
46
|
-
flags: {
|
|
47
|
-
"--help": Boolean,
|
|
48
|
-
"--debug": Boolean,
|
|
49
|
-
"--verbose": Boolean
|
|
50
|
-
},
|
|
51
|
-
async run() {
|
|
52
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), options = await (0, import_utils.getOptions)({
|
|
53
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1,
|
|
54
|
-
loadTamaguiOptions: !0
|
|
55
|
-
});
|
|
56
|
-
process.env.TAMAGUI_KEEP_THEMES = "1", await (0, import_static.loadTamagui)({
|
|
57
|
-
...options.tamaguiOptions,
|
|
58
|
-
platform: "web"
|
|
59
|
-
});
|
|
60
|
-
const { generatePrompt } = require("./generate-prompt"), { join } = require("node:path");
|
|
61
|
-
await generatePrompt({
|
|
62
|
-
...options,
|
|
63
|
-
output: join(options.paths.dotDir, "prompt.md")
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"generate-css": {
|
|
68
|
-
shorthands: [],
|
|
69
|
-
description: "Generate the tamagui.generated.css file from your config",
|
|
70
|
-
flags: {
|
|
71
|
-
"--help": Boolean,
|
|
72
|
-
"--debug": Boolean,
|
|
73
|
-
"--verbose": Boolean,
|
|
74
|
-
"--output": String
|
|
75
|
-
},
|
|
76
|
-
async run() {
|
|
77
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), options = await (0, import_utils.getOptions)({
|
|
78
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1,
|
|
79
|
-
loadTamaguiOptions: !0
|
|
80
|
-
}), outputPath = flags2["--output"] || options.tamaguiOptions.outputCSS || "./tamagui.generated.css";
|
|
81
|
-
process.env.TAMAGUI_KEEP_THEMES = "1", await (0, import_static.loadTamagui)({
|
|
82
|
-
...options.tamaguiOptions,
|
|
83
|
-
outputCSS: outputPath,
|
|
84
|
-
platform: "web"
|
|
85
|
-
}), console.info(`Generated CSS to ${outputPath}`);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
"generate-themes": {
|
|
89
|
-
shorthands: [],
|
|
90
|
-
description: "Use to pre-build your themes",
|
|
91
|
-
flags: {
|
|
92
|
-
"--help": Boolean,
|
|
93
|
-
"--debug": Boolean,
|
|
94
|
-
"--verbose": Boolean
|
|
95
|
-
},
|
|
96
|
-
async run() {
|
|
97
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), options = await (0, import_utils.getOptions)({
|
|
98
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1
|
|
99
|
-
}), [_cmd, inPath, outPath] = _;
|
|
100
|
-
if (!inPath || !outPath)
|
|
101
|
-
throw new Error(
|
|
102
|
-
`Must supply both input and output paths, missing one (inPath: ${inPath}, outPath: ${outPath})`
|
|
103
|
-
);
|
|
104
|
-
const { generateThemes, writeGeneratedThemes } = require("@tamagui/generate-themes");
|
|
105
|
-
try {
|
|
106
|
-
const generated = await generateThemes(inPath);
|
|
107
|
-
generated ? (await writeGeneratedThemes(options.paths.dotDir, outPath, generated), console.info(`Successfully generated themes to ${outPath}`)) : process.exit(1);
|
|
108
|
-
} catch (err) {
|
|
109
|
-
console.error(`Error generating themes: ${err}`);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
add: {
|
|
115
|
-
shorthands: [],
|
|
116
|
-
description: `Use to add fonts and icons to your monorepo. Supported types: ${import_add.generatedPackageTypes.join(
|
|
117
|
-
", "
|
|
118
|
-
)}`,
|
|
119
|
-
flags: {
|
|
120
|
-
"--help": Boolean,
|
|
121
|
-
"--debug": Boolean,
|
|
122
|
-
"--verbose": Boolean
|
|
123
|
-
},
|
|
124
|
-
async run() {
|
|
125
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), { installGeneratedPackage } = require("./add"), [cmd, type, path] = _;
|
|
126
|
-
await installGeneratedPackage(type, path);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
build: {
|
|
130
|
-
shorthands: ["b"],
|
|
131
|
-
description: "Use to pre-build a Tamagui component directory. Use -- to run a command after optimization, then auto-restore files.",
|
|
132
|
-
flags: {
|
|
133
|
-
"--help": Boolean,
|
|
134
|
-
"--debug": Boolean,
|
|
135
|
-
"--verbose": Boolean,
|
|
136
|
-
"--target": String,
|
|
137
|
-
"--include": String,
|
|
138
|
-
"--exclude": String,
|
|
139
|
-
"--expect-optimizations": Number
|
|
140
|
-
},
|
|
141
|
-
async run() {
|
|
142
|
-
const argvSeparatorIdx = process.argv.indexOf("--");
|
|
143
|
-
let runCommand;
|
|
144
|
-
if (argvSeparatorIdx !== -1) {
|
|
145
|
-
runCommand = process.argv.slice(argvSeparatorIdx + 1);
|
|
146
|
-
const argsBeforeSeparator = process.argv.slice(0, argvSeparatorIdx);
|
|
147
|
-
process.argv = argsBeforeSeparator;
|
|
148
|
-
}
|
|
149
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), [_command, dir] = _, { build } = require("./build.cjs"), options = await (0, import_utils.getOptions)({
|
|
150
|
-
debug: flags2["--debug"] ? flags2["--verbose"] ? "verbose" : !0 : !1
|
|
151
|
-
});
|
|
152
|
-
await build({
|
|
153
|
-
...options,
|
|
154
|
-
dir,
|
|
155
|
-
include: flags2["--include"],
|
|
156
|
-
target: flags2["--target"] || "both",
|
|
157
|
-
exclude: flags2["--exclude"],
|
|
158
|
-
expectOptimizations: flags2["--expect-optimizations"],
|
|
159
|
-
runCommand
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
upgrade: {
|
|
164
|
-
shorthands: ["up"],
|
|
165
|
-
description: "Upgrade all tamagui packages in your workspace to the latest version",
|
|
166
|
-
flags: {
|
|
167
|
-
"--help": Boolean,
|
|
168
|
-
"--debug": Boolean,
|
|
169
|
-
"--from": String,
|
|
170
|
-
"--to": String,
|
|
171
|
-
"--changelog-only": Boolean,
|
|
172
|
-
"--dry-run": Boolean
|
|
173
|
-
},
|
|
174
|
-
async run() {
|
|
175
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), { upgrade } = require("./upgrade");
|
|
176
|
-
await upgrade({
|
|
177
|
-
from: flags2["--from"],
|
|
178
|
-
to: flags2["--to"],
|
|
179
|
-
changelogOnly: flags2["--changelog-only"],
|
|
180
|
-
dryRun: flags2["--dry-run"],
|
|
181
|
-
debug: flags2["--debug"]
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
"update-template": {
|
|
186
|
-
shorthands: ["ut"],
|
|
187
|
-
description: "Used to update your git repo with the source template. (e.g. Takeout)",
|
|
188
|
-
flags: {
|
|
189
|
-
"--help": Boolean,
|
|
190
|
-
"--template-repo": String,
|
|
191
|
-
"--ignored-patterns": String
|
|
192
|
-
},
|
|
193
|
-
async run() {
|
|
194
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), { updateTemplate } = require("./update-template");
|
|
195
|
-
if (!flags2["--template-repo"])
|
|
196
|
-
throw new Error("--template-repo is required");
|
|
197
|
-
await updateTemplate(
|
|
198
|
-
flags2["--template-repo"],
|
|
199
|
-
flags2["--ignored-patterns"]?.split(" ")
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
"generate-prompt": {
|
|
204
|
-
shorthands: [],
|
|
205
|
-
description: "Generate an LLM-friendly markdown file from your Tamagui config",
|
|
206
|
-
flags: {
|
|
207
|
-
"--help": Boolean,
|
|
208
|
-
"--debug": Boolean,
|
|
209
|
-
"--output": String
|
|
210
|
-
},
|
|
211
|
-
async run() {
|
|
212
|
-
const { _, ...flags2 } = (0, import_arg.default)(this.flags), { generatePrompt } = require("./generate-prompt"), options = await (0, import_utils.getOptions)({
|
|
213
|
-
debug: !!flags2["--debug"],
|
|
214
|
-
loadTamaguiOptions: !0
|
|
215
|
-
});
|
|
216
|
-
await generatePrompt({
|
|
217
|
-
...options,
|
|
218
|
-
output: flags2["--output"]
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}, commandEntries = Object.keys(COMMAND_MAP).flatMap((command2) => {
|
|
223
|
-
const definition2 = COMMAND_MAP[command2];
|
|
224
|
-
return [command2, ...definition2.shorthands].map((cmd) => [cmd, definition2]);
|
|
225
|
-
}), commands = Object.fromEntries(commandEntries), {
|
|
226
|
-
_: [command],
|
|
227
|
-
...flags
|
|
228
|
-
} = (0, import_arg.default)(
|
|
229
|
-
{
|
|
230
|
-
"--help": Boolean,
|
|
231
|
-
"--version": Boolean
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
permissive: !0
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
flags["--version"] && (console.info(require("../package.json").version), process.exit(0));
|
|
238
|
-
!command && flags["--help"] && (console.info(`$ tamagui
|
|
239
|
-
|
|
240
|
-
commands:
|
|
241
|
-
|
|
242
|
-
${Object.keys(COMMAND_MAP).map((key) => ` ${key}`).join(`
|
|
243
|
-
`)}`), process.exit(0));
|
|
244
|
-
command in commands || (console.error(), console.warn(import_chalk.default.yellow(`Not a valid command: ${command}`)), process.exit(1));
|
|
245
|
-
const definition = commands[command];
|
|
246
|
-
main();
|
|
247
|
-
async function main() {
|
|
248
|
-
flags["--help"] && (console.info(`
|
|
249
|
-
$ tamagui ${command}: ${definition.description}
|
|
250
|
-
`), console.info(
|
|
251
|
-
`Flags: ${Object.entries(definition.flags).map(([k, v]) => `${k} (${v.name})`)}`
|
|
252
|
-
), process.exit(0));
|
|
253
|
-
const { _, ...cmdFlags } = (0, import_arg.default)(definition.flags);
|
|
254
|
-
cmdFlags["--help"] && (console.info(`$ tamagui ${_}
|
|
255
|
-
|
|
256
|
-
Flags: ${JSON.stringify(cmdFlags, null, 2)}
|
|
257
|
-
|
|
258
|
-
`), process.exit(0));
|
|
259
|
-
try {
|
|
260
|
-
await definition.run();
|
|
261
|
-
} catch (err) {
|
|
262
|
-
console.error(`Error running command: ${err.message}`);
|
|
263
|
-
}
|
|
264
|
-
process.exit(0);
|
|
265
|
-
}
|
|
266
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/cli.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA,iBAAgB,yBAChB,eAAkB,2BAElB,aAAsC,kBACtC,eAAuC,oBACvC,gBAAuC;AAGtC,CAAC,QAAQ,QAAQ,EAAE,QAAQ,CAAC,MAAM;AACjC,UAAQ,GAAG,GAAG,MAAM;AAClB,iCAAW,GACX,QAAQ,KAAK;AAAA,EACf,CAAC;AACH,CAAC;AAED,MAAM,cAAc;AAAA,EAClB,OAAO;AAAA,IACL,aAAa;AAAA,IACb,YAAY,CAAC;AAAA,IACb,OAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAAA,IACA,MAAM,MAAM;AACV,YAAM,EAAE,GAAG,GAAGA,OAAM,QAAI,WAAAC,SAAI,KAAK,KAAK,GAChC,UAAU,UAAM,yBAAW;AAAA,QAC/B,OAAOD,OAAM,SAAS,IAAKA,OAAM,WAAW,IAAI,YAAY,KAAQ;AAAA,QACpE,oBAAoB;AAAA,MACtB,CAAC;AAED,gBAAM,yBAAU,QAAQ,MAAM,IAAI;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,UAAU;AAAA,IACR,aAAa;AAAA,IACb,YAAY,CAAC;AAAA,IACb,OAAO;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAAA,IACA,MAAM,MAAM;AACV,YAAM,EAAE,GAAG,GAAGA,OAAM,QAAI,WAAAC,SAAI,KAAK,KAAK,GAChC,UAAU,UAAM,yBAAW;AAAA,QAC/B,OAAOD,OAAM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EACvD;AAEA,UAAQ,KAAK,CAAC;AAChB;",
|
|
5
|
-
"names": ["flags", "arg", "command", "definition", "chalk"]
|
|
6
|
-
}
|
package/dist/generate-prompt.js
DELETED
|
@@ -1,392 +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 generate_prompt_exports = {};
|
|
24
|
-
__export(generate_prompt_exports, {
|
|
25
|
-
generatePrompt: () => generatePrompt
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(generate_prompt_exports);
|
|
28
|
-
var import_node_path = require("node:path"), FS = __toESM(require("fs-extra")), import_static = require("@tamagui/static");
|
|
29
|
-
async function generatePrompt(options) {
|
|
30
|
-
const { paths, output } = options;
|
|
31
|
-
process.env.TAMAGUI_KEEP_THEMES = "1", await (0, import_static.loadTamagui)({
|
|
32
|
-
...options.tamaguiOptions,
|
|
33
|
-
platform: "web"
|
|
34
|
-
});
|
|
35
|
-
const configPath = (0, import_node_path.join)(paths.dotDir, "tamagui.config.json");
|
|
36
|
-
if (!FS.existsSync(configPath))
|
|
37
|
-
throw new Error(
|
|
38
|
-
`Config file not found at ${configPath}. Please run 'tamagui generate' first.`
|
|
39
|
-
);
|
|
40
|
-
const config = await FS.readJSON(configPath), markdown = generateMarkdown(config), outputPath = output || (0, import_node_path.join)(process.cwd(), "tamagui-prompt.md");
|
|
41
|
-
await FS.writeFile(outputPath, markdown, "utf-8"), console.info(`
|
|
42
|
-
\u2713 Generated prompt file at ${outputPath}
|
|
43
|
-
`);
|
|
44
|
-
}
|
|
45
|
-
function generateMarkdown(config) {
|
|
46
|
-
const sections = [];
|
|
47
|
-
sections.push(`# Tamagui Configuration
|
|
48
|
-
|
|
49
|
-
`), sections.push(
|
|
50
|
-
`This document provides an overview of the Tamagui configuration for this project.
|
|
51
|
-
|
|
52
|
-
`
|
|
53
|
-
);
|
|
54
|
-
const shorthands = config.tamaguiConfig?.shorthands || {}, reverseShorthands = {};
|
|
55
|
-
for (const [short, full] of Object.entries(shorthands))
|
|
56
|
-
reverseShorthands[full] = short;
|
|
57
|
-
const getPropName = (fullProp) => (config.tamaguiConfig?.settings || {}).onlyAllowShorthands && reverseShorthands[fullProp] ? reverseShorthands[fullProp] : fullProp, settings = config.tamaguiConfig?.settings || {};
|
|
58
|
-
if (Object.keys(settings).length > 0) {
|
|
59
|
-
sections.push(`## Configuration Settings
|
|
60
|
-
|
|
61
|
-
`), sections.push(
|
|
62
|
-
`**IMPORTANT:** These settings affect how you write Tamagui code in this project.
|
|
63
|
-
|
|
64
|
-
`
|
|
65
|
-
), settings.defaultFont && (sections.push(`### Default Font: \`${settings.defaultFont}\`
|
|
66
|
-
|
|
67
|
-
`), sections.push(
|
|
68
|
-
`All text components will use the "${settings.defaultFont}" font family by default.
|
|
69
|
-
|
|
70
|
-
`
|
|
71
|
-
)), settings.onlyAllowShorthands !== void 0 && (sections.push(`### Only Allow Shorthands: \`${settings.onlyAllowShorthands}\`
|
|
72
|
-
|
|
73
|
-
`), settings.onlyAllowShorthands ? (sections.push(`**You MUST use shorthand properties in this project.**
|
|
74
|
-
|
|
75
|
-
`), sections.push(`Full property names are not allowed. For example:
|
|
76
|
-
`), sections.push('- \u2705 `<View w="$10" />` (correct)\n'), sections.push('- \u274C `<View width="$10" />` (will error)\n\n'), sections.push(
|
|
77
|
-
`See the Shorthand Properties section below for all available shorthands.
|
|
78
|
-
|
|
79
|
-
`
|
|
80
|
-
)) : sections.push(`You can use either shorthand or full property names.
|
|
81
|
-
|
|
82
|
-
`)), settings.themeClassNameOnRoot !== void 0 && (sections.push(
|
|
83
|
-
`### Theme Class Name on Root: \`${settings.themeClassNameOnRoot}\`
|
|
84
|
-
|
|
85
|
-
`
|
|
86
|
-
), settings.themeClassNameOnRoot && sections.push(`Theme classes are applied to the root HTML element.
|
|
87
|
-
|
|
88
|
-
`));
|
|
89
|
-
const platform = settings.platform || settings.defaultProps?.platform;
|
|
90
|
-
platform && (sections.push(`### Platform Mode: \`${platform}\`
|
|
91
|
-
|
|
92
|
-
`), platform === "web" ? sections.push(`This project is configured for **web only**.
|
|
93
|
-
|
|
94
|
-
`) : platform === "native" && sections.push(`This project is configured for **React Native only**.
|
|
95
|
-
|
|
96
|
-
`)), settings.webContainerType && (sections.push(`### Web Container Type: \`${settings.webContainerType}\`
|
|
97
|
-
|
|
98
|
-
`), sections.push(`Enables web-specific container query optimizations.
|
|
99
|
-
|
|
100
|
-
`)), JSON.stringify(config.tamaguiConfig).includes("semi-strict-web") && (sections.push("### Mode: `semi-strict-web`\n\n"), sections.push(`This configuration uses semi-strict-web mode, which:
|
|
101
|
-
`), sections.push(`- Optimizes for web performance
|
|
102
|
-
`), sections.push(`- May have limited React Native API support
|
|
103
|
-
`), sections.push(`- Focuses on web-first development
|
|
104
|
-
|
|
105
|
-
`));
|
|
106
|
-
}
|
|
107
|
-
const componentsSection = [], allComponents = [];
|
|
108
|
-
for (const componentModule of config.components) {
|
|
109
|
-
const componentNames = Object.keys(componentModule.nameToInfo);
|
|
110
|
-
allComponents.push(...componentNames);
|
|
111
|
-
}
|
|
112
|
-
const componentGroups = /* @__PURE__ */ new Map(), processed = /* @__PURE__ */ new Set(), sortedComponents = [...allComponents].sort((a, b) => a.length - b.length);
|
|
113
|
-
for (const name of sortedComponents) {
|
|
114
|
-
if (processed.has(name)) continue;
|
|
115
|
-
const children = allComponents.filter(
|
|
116
|
-
(other) => other !== name && other.startsWith(name) && other[name.length]?.match(/[A-Z]/)
|
|
117
|
-
);
|
|
118
|
-
children.length > 0 && (componentGroups.set(name, new Set(children)), processed.add(name), children.forEach((child) => processed.add(child)));
|
|
119
|
-
}
|
|
120
|
-
const standaloneComponents = allComponents.filter((name) => !processed.has(name));
|
|
121
|
-
componentsSection.push(`## Components
|
|
122
|
-
|
|
123
|
-
`), componentsSection.push(`The following components are available:
|
|
124
|
-
|
|
125
|
-
`);
|
|
126
|
-
const allBaseComponents = [
|
|
127
|
-
...standaloneComponents,
|
|
128
|
-
...Array.from(componentGroups.keys())
|
|
129
|
-
].sort();
|
|
130
|
-
for (const name of allBaseComponents)
|
|
131
|
-
if (componentsSection.push(`- ${name}
|
|
132
|
-
`), componentGroups.has(name)) {
|
|
133
|
-
const children = Array.from(componentGroups.get(name)).sort();
|
|
134
|
-
for (const child of children) {
|
|
135
|
-
const suffix = child.slice(name.length);
|
|
136
|
-
componentsSection.push(` - ${name}.${suffix}
|
|
137
|
-
`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
componentsSection.push(`
|
|
141
|
-
`), sections.push(`## Shorthand Properties
|
|
142
|
-
|
|
143
|
-
`), sections.push(`These shorthand properties are available for styling:
|
|
144
|
-
|
|
145
|
-
`);
|
|
146
|
-
const shorthandEntries = Object.entries(shorthands).sort(
|
|
147
|
-
([a], [b]) => a.localeCompare(b)
|
|
148
|
-
);
|
|
149
|
-
sections.push(
|
|
150
|
-
shorthandEntries.map(([short, full]) => `- \`${short}\` \u2192 \`${full}\``).join(`
|
|
151
|
-
`)
|
|
152
|
-
), sections.push(`
|
|
153
|
-
|
|
154
|
-
`), sections.push(`## Themes
|
|
155
|
-
|
|
156
|
-
`);
|
|
157
|
-
const themes = config.tamaguiConfig?.themes || {}, themeNames = Object.keys(themes).sort(), hierarchy = {
|
|
158
|
-
level1: /* @__PURE__ */ new Set(),
|
|
159
|
-
level2: /* @__PURE__ */ new Set(),
|
|
160
|
-
level3: /* @__PURE__ */ new Set(),
|
|
161
|
-
components: /* @__PURE__ */ new Set()
|
|
162
|
-
};
|
|
163
|
-
for (const themeName of themeNames) {
|
|
164
|
-
const parts = themeName.split("_");
|
|
165
|
-
if (parts[0] === "light" || parts[0] === "dark") {
|
|
166
|
-
hierarchy.level1.add(parts[0]), parts.length > 1 && parts[1] && !parts[1].startsWith("alt") && parts[1] !== "active" && parts[1][0] === parts[1][0].toLowerCase() && hierarchy.level2.add(parts[1]);
|
|
167
|
-
for (const part of parts)
|
|
168
|
-
(part.startsWith("alt") || part === "active") && hierarchy.level3.add(part);
|
|
169
|
-
for (const part of parts)
|
|
170
|
-
part[0] && part[0] === part[0].toUpperCase() && part[0] !== part[0].toLowerCase() && hierarchy.components.add(part);
|
|
171
|
-
} else
|
|
172
|
-
parts.length === 1 && hierarchy.level1.add(themeName);
|
|
173
|
-
}
|
|
174
|
-
sections.push(`Themes are organized hierarchically and can be combined:
|
|
175
|
-
|
|
176
|
-
`), hierarchy.level1.size > 0 && (sections.push(`**Level 1 (Base):**
|
|
177
|
-
|
|
178
|
-
`), sections.push(
|
|
179
|
-
Array.from(hierarchy.level1).sort().map((name) => `- ${name}`).join(`
|
|
180
|
-
`)
|
|
181
|
-
), sections.push(`
|
|
182
|
-
|
|
183
|
-
`)), hierarchy.level2.size > 0 && (sections.push(`**Level 2 (Color Schemes):**
|
|
184
|
-
|
|
185
|
-
`), sections.push(
|
|
186
|
-
Array.from(hierarchy.level2).sort().map((name) => `- ${name}`).join(`
|
|
187
|
-
`)
|
|
188
|
-
), sections.push(`
|
|
189
|
-
|
|
190
|
-
`)), hierarchy.level3.size > 0 && (sections.push(`**Level 3 (Variants):**
|
|
191
|
-
|
|
192
|
-
`), sections.push(
|
|
193
|
-
Array.from(hierarchy.level3).sort().map((name) => `- ${name}`).join(`
|
|
194
|
-
`)
|
|
195
|
-
), sections.push(`
|
|
196
|
-
|
|
197
|
-
`)), hierarchy.components.size > 0 && (sections.push(`**Component Themes:**
|
|
198
|
-
|
|
199
|
-
`), sections.push(
|
|
200
|
-
Array.from(hierarchy.components).sort().map((name) => `- ${name}`).join(`
|
|
201
|
-
`)
|
|
202
|
-
), sections.push(`
|
|
203
|
-
|
|
204
|
-
`)), sections.push(`### Theme Usage
|
|
205
|
-
|
|
206
|
-
`), sections.push(
|
|
207
|
-
"Themes are combined hierarchically. For example, `light_blue_alt1_Button` combines:\n"
|
|
208
|
-
), sections.push("- Base: `light`\n"), sections.push("- Color: `blue`\n"), sections.push("- Variant: `alt1`\n"), sections.push("- Component: `Button`\n\n"), sections.push(`**Basic usage:**
|
|
209
|
-
|
|
210
|
-
`), sections.push("```tsx\n"), sections.push(`// Apply a theme to components
|
|
211
|
-
`), sections.push(`export default () => (
|
|
212
|
-
`), sections.push(` <Theme name="dark">
|
|
213
|
-
`), sections.push(` <Button>I'm a dark button</Button>
|
|
214
|
-
`), sections.push(` </Theme>
|
|
215
|
-
`), sections.push(`)
|
|
216
|
-
|
|
217
|
-
`), sections.push(`// Themes nest and combine automatically
|
|
218
|
-
`), sections.push(`export default () => (
|
|
219
|
-
`), sections.push(` <Theme name="dark">
|
|
220
|
-
`), sections.push(` <Theme name="blue">
|
|
221
|
-
`), sections.push(` <Button>Uses dark_blue theme</Button>
|
|
222
|
-
`), sections.push(` </Theme>
|
|
223
|
-
`), sections.push(` </Theme>
|
|
224
|
-
`), sections.push(`)
|
|
225
|
-
`), sections.push("```\n\n"), sections.push(`**Accessing theme values:**
|
|
226
|
-
|
|
227
|
-
`), sections.push("Components can access theme values using `$` token syntax:\n\n"), sections.push("```tsx\n"), sections.push(
|
|
228
|
-
`<View ${getPropName("backgroundColor")}="$background" ${getPropName("color")}="$color" />
|
|
229
|
-
`
|
|
230
|
-
), sections.push("```\n\n"), sections.push(`**Special props:**
|
|
231
|
-
|
|
232
|
-
`), sections.push("- `inverse`: Automatically swaps light \u2194 dark themes\n"), sections.push("- `reset`: Reverts to grandparent theme\n\n"), sections.push(`## Tokens
|
|
233
|
-
|
|
234
|
-
`), sections.push(
|
|
235
|
-
"Tokens are design system values that can be referenced using the `$` prefix.\n\n"
|
|
236
|
-
);
|
|
237
|
-
const tokens = config.tamaguiConfig?.tokens || {};
|
|
238
|
-
if (tokens.space) {
|
|
239
|
-
sections.push(`### Space Tokens
|
|
240
|
-
|
|
241
|
-
`);
|
|
242
|
-
const spaceTokens = Object.entries(tokens.space).sort(([a], [b]) => {
|
|
243
|
-
const numA = parseFloat(a), numB = parseFloat(b);
|
|
244
|
-
return !isNaN(numA) && !isNaN(numB) ? numA - numB : a.localeCompare(b);
|
|
245
|
-
});
|
|
246
|
-
sections.push(
|
|
247
|
-
spaceTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join(`
|
|
248
|
-
`)
|
|
249
|
-
), sections.push(`
|
|
250
|
-
|
|
251
|
-
`);
|
|
252
|
-
}
|
|
253
|
-
if (tokens.size) {
|
|
254
|
-
sections.push(`### Size Tokens
|
|
255
|
-
|
|
256
|
-
`);
|
|
257
|
-
const sizeTokens = Object.entries(tokens.size).sort(([a], [b]) => {
|
|
258
|
-
const numA = parseFloat(a), numB = parseFloat(b);
|
|
259
|
-
return !isNaN(numA) && !isNaN(numB) ? numA - numB : a.localeCompare(b);
|
|
260
|
-
});
|
|
261
|
-
sections.push(
|
|
262
|
-
sizeTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join(`
|
|
263
|
-
`)
|
|
264
|
-
), sections.push(`
|
|
265
|
-
|
|
266
|
-
`);
|
|
267
|
-
}
|
|
268
|
-
if (tokens.radius) {
|
|
269
|
-
sections.push(`### Radius Tokens
|
|
270
|
-
|
|
271
|
-
`);
|
|
272
|
-
const radiusTokens = Object.entries(tokens.radius).sort(([a], [b]) => {
|
|
273
|
-
const numA = parseFloat(a), numB = parseFloat(b);
|
|
274
|
-
return !isNaN(numA) && !isNaN(numB) ? numA - numB : a.localeCompare(b);
|
|
275
|
-
});
|
|
276
|
-
sections.push(
|
|
277
|
-
radiusTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join(`
|
|
278
|
-
`)
|
|
279
|
-
), sections.push(`
|
|
280
|
-
|
|
281
|
-
`);
|
|
282
|
-
}
|
|
283
|
-
if (tokens.zIndex) {
|
|
284
|
-
sections.push(`### Z-Index Tokens
|
|
285
|
-
|
|
286
|
-
`);
|
|
287
|
-
const zIndexTokens = Object.entries(tokens.zIndex).sort(([a], [b]) => {
|
|
288
|
-
const numA = parseFloat(a), numB = parseFloat(b);
|
|
289
|
-
return !isNaN(numA) && !isNaN(numB) ? numA - numB : a.localeCompare(b);
|
|
290
|
-
});
|
|
291
|
-
sections.push(
|
|
292
|
-
zIndexTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join(`
|
|
293
|
-
`)
|
|
294
|
-
), sections.push(`
|
|
295
|
-
|
|
296
|
-
`);
|
|
297
|
-
}
|
|
298
|
-
if (tokens.color) {
|
|
299
|
-
sections.push(`### Color Tokens
|
|
300
|
-
|
|
301
|
-
`);
|
|
302
|
-
const colorTokens = Object.entries(tokens.color).sort(
|
|
303
|
-
([a], [b]) => a.localeCompare(b)
|
|
304
|
-
);
|
|
305
|
-
sections.push(
|
|
306
|
-
colorTokens.map(([key, value]) => `- \`${key}\`: ${formatTokenValue(value)}`).join(`
|
|
307
|
-
`)
|
|
308
|
-
), sections.push(`
|
|
309
|
-
|
|
310
|
-
`);
|
|
311
|
-
}
|
|
312
|
-
if (sections.push(`### Token Usage
|
|
313
|
-
|
|
314
|
-
`), sections.push("Tokens can be used in component props with the `$` prefix:\n\n"), sections.push("```tsx\n"), sections.push(`// Space tokens - for margin, padding, gap
|
|
315
|
-
`), sections.push(
|
|
316
|
-
`<View ${getPropName("padding")}="$4" ${getPropName("gap")}="$2" ${getPropName("margin")}="$3" />
|
|
317
|
-
|
|
318
|
-
`
|
|
319
|
-
), sections.push(`// Size tokens - for width, height, dimensions
|
|
320
|
-
`), sections.push(
|
|
321
|
-
`<View ${getPropName("width")}="$10" ${getPropName("height")}="$6" />
|
|
322
|
-
|
|
323
|
-
`
|
|
324
|
-
), sections.push(`// Color tokens - for colors and backgrounds
|
|
325
|
-
`), sections.push(
|
|
326
|
-
`<View ${getPropName("backgroundColor")}="$blue5" ${getPropName("color")}="$gray12" />
|
|
327
|
-
|
|
328
|
-
`
|
|
329
|
-
), sections.push(`// Radius tokens - for border-radius
|
|
330
|
-
`), sections.push(`<View ${getPropName("borderRadius")}="$4" />
|
|
331
|
-
`), sections.push("```\n\n"), config.tamaguiConfig?.media) {
|
|
332
|
-
sections.push(`## Media Queries
|
|
333
|
-
|
|
334
|
-
`), sections.push(`Available responsive breakpoints:
|
|
335
|
-
|
|
336
|
-
`);
|
|
337
|
-
const media = config.tamaguiConfig.media, mediaEntries = Object.entries(media).sort(([a], [b]) => a.localeCompare(b));
|
|
338
|
-
for (const [name, query] of mediaEntries)
|
|
339
|
-
sections.push(`- **${name}**: ${JSON.stringify(query)}
|
|
340
|
-
`);
|
|
341
|
-
sections.push(`
|
|
342
|
-
`), sections.push(`### Media Query Usage
|
|
343
|
-
|
|
344
|
-
`), sections.push(
|
|
345
|
-
"Media queries can be used as style props or with the `useMedia` hook:\n\n"
|
|
346
|
-
), sections.push("```tsx\n"), sections.push(`// As style props (prefix with $)
|
|
347
|
-
`);
|
|
348
|
-
const firstMediaName = mediaEntries[0]?.[0];
|
|
349
|
-
firstMediaName && sections.push(
|
|
350
|
-
`<View ${getPropName("width")}="100%" $${firstMediaName}={{ ${getPropName("width")}: "50%" }} />
|
|
351
|
-
|
|
352
|
-
`
|
|
353
|
-
), sections.push(`// Using the useMedia hook
|
|
354
|
-
`), sections.push(`const media = useMedia()
|
|
355
|
-
`), firstMediaName && (sections.push(`if (media.${firstMediaName}) {
|
|
356
|
-
`), sections.push(` // Render for this breakpoint
|
|
357
|
-
`), sections.push(`}
|
|
358
|
-
`)), sections.push("```\n\n");
|
|
359
|
-
}
|
|
360
|
-
if (config.tamaguiConfig?.fonts) {
|
|
361
|
-
sections.push(`## Fonts
|
|
362
|
-
|
|
363
|
-
`), sections.push(`Available font families:
|
|
364
|
-
|
|
365
|
-
`);
|
|
366
|
-
const fonts = config.tamaguiConfig.fonts, fontNames = Object.keys(fonts).sort();
|
|
367
|
-
sections.push(fontNames.map((name) => `- ${name}`).join(`
|
|
368
|
-
`)), sections.push(`
|
|
369
|
-
|
|
370
|
-
`);
|
|
371
|
-
}
|
|
372
|
-
if (config.tamaguiConfig?.animations) {
|
|
373
|
-
sections.push(`## Animations
|
|
374
|
-
|
|
375
|
-
`), sections.push(`Available animation presets:
|
|
376
|
-
|
|
377
|
-
`);
|
|
378
|
-
const animations = config.tamaguiConfig.animations;
|
|
379
|
-
if (animations.animations) {
|
|
380
|
-
const animationNames = Object.keys(animations.animations).sort();
|
|
381
|
-
sections.push(animationNames.map((name) => `- ${name}`).join(`
|
|
382
|
-
`)), sections.push(`
|
|
383
|
-
|
|
384
|
-
`);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
return sections.push(...componentsSection), sections.join("");
|
|
388
|
-
}
|
|
389
|
-
function formatTokenValue(value) {
|
|
390
|
-
return typeof value == "object" && value !== null && "val" in value ? String(value.val) : String(value);
|
|
391
|
-
}
|
|
392
|
-
//# sourceMappingURL=generate-prompt.js.map
|