@tamagui/cli 2.7.7 → 3.0.0-beta.643.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/dist/add.cjs +77 -87
- package/dist/build.cjs +415 -277
- package/dist/cli.cjs +343 -340
- package/dist/generate-prompt.cjs +344 -357
- package/dist/generate.cjs +46 -54
- package/dist/index.cjs +2 -1
- package/dist/migrate.cjs +370 -0
- package/dist/setup-prompt.cjs +158 -0
- package/dist/to-tailwind-default-config.cjs +778 -0
- package/dist/to-tailwind.cjs +214 -0
- package/dist/update-template.cjs +44 -52
- package/dist/update.cjs +15 -18
- package/dist/upgrade.cjs +407 -398
- package/dist/utils.cjs +85 -101
- package/metro.cjs +1 -0
- package/metro.d.ts +1 -0
- package/metro.mjs +1 -0
- package/package.json +41 -12
- package/src/build.ts +574 -363
- package/src/cli.ts +96 -12
- package/src/generate-prompt.ts +16 -24
- package/src/migrate.ts +354 -0
- package/src/setup-prompt.ts +139 -0
- package/src/to-tailwind-default-config.ts +755 -0
- package/src/to-tailwind.ts +313 -0
- package/src/utils.ts +11 -9
- package/types/add.d.ts +1 -1
- package/types/add.d.ts.map +1 -1
- package/types/build.d.ts +1 -1
- package/types/build.d.ts.map +1 -1
- package/types/migrate.d.ts +7 -0
- package/types/migrate.d.ts.map +1 -0
- package/types/setup-prompt.d.ts +3 -0
- package/types/setup-prompt.d.ts.map +1 -0
- package/types/to-tailwind-default-config.d.ts +53 -0
- package/types/to-tailwind-default-config.d.ts.map +1 -0
- package/types/to-tailwind.d.ts +16 -0
- package/types/to-tailwind.d.ts.map +1 -0
- package/types/utils.d.ts.map +1 -1
- package/vite.cjs +1 -0
- package/vite.d.ts +1 -0
- package/vite.mjs +1 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var to_tailwind_exports = {};
|
|
23
|
+
__export(to_tailwind_exports, { toTailwind: () => toTailwind });
|
|
24
|
+
module.exports = __toCommonJS(to_tailwind_exports);
|
|
25
|
+
var import_promises = require("node:fs/promises");
|
|
26
|
+
var import_node_path = require("node:path");
|
|
27
|
+
var import_to_tailwind_default_config = require("./to-tailwind-default-config.cjs");
|
|
28
|
+
const codeFileExtensions = /* @__PURE__ */ new Set([
|
|
29
|
+
".js",
|
|
30
|
+
".jsx",
|
|
31
|
+
".ts",
|
|
32
|
+
".tsx"
|
|
33
|
+
]);
|
|
34
|
+
const defaultFileGlob = "**/*.{js,jsx,ts,tsx}";
|
|
35
|
+
const ignoredGlobs = ["**/node_modules/**", "**/.git/**"];
|
|
36
|
+
const { glob } = require("glob");
|
|
37
|
+
const { createTwoFilesPatch } = require("diff");
|
|
38
|
+
async function toTailwind({ patterns, write = false, cwd = process.cwd(), configPath, useDefaultConfig = false, renameDom = false }) {
|
|
39
|
+
if (!patterns.length) {
|
|
40
|
+
throw new Error("Usage: tamagui to-tailwind <paths/glob> [--write] [--config <path> | --use-default-config] [--rename-dom]");
|
|
41
|
+
}
|
|
42
|
+
if (write && !configPath && !useDefaultConfig) {
|
|
43
|
+
throw new Error("--write requires either --config <path> (app token/media grammar) or --use-default-config (acknowledge the bundled defaults).");
|
|
44
|
+
}
|
|
45
|
+
const { transformConfig, usedDefault } = await loadTransformConfig(configPath, useDefaultConfig, cwd);
|
|
46
|
+
if (usedDefault && !useDefaultConfig) {
|
|
47
|
+
console.warn("[to-tailwind] WARNING: no --config given — bare token names pass through and bundled media/shorthands are used. pass --config <path> to enforce app domains.");
|
|
48
|
+
}
|
|
49
|
+
transformConfig.renameComponents = renameDom;
|
|
50
|
+
const files = await collectFiles(patterns, cwd);
|
|
51
|
+
const { findParseError } = require("@tamagui/to-tailwind");
|
|
52
|
+
if (typeof findParseError !== "function") {
|
|
53
|
+
throw new Error("@tamagui/to-tailwind did not export findParseError — aborting because transactional parse safety is unavailable");
|
|
54
|
+
}
|
|
55
|
+
const sources = /* @__PURE__ */ new Map();
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
const source = await (0, import_promises.readFile)(file, "utf8");
|
|
58
|
+
sources.set(file, source);
|
|
59
|
+
const err = findParseError(source);
|
|
60
|
+
if (err) {
|
|
61
|
+
throw new Error(`parse error in ${(0, import_node_path.relative)(cwd, file) || file}: ${err} \u2014 aborted, no files written`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const tamaguiToTailwind = loadTamaguiToTailwind();
|
|
65
|
+
let changed = 0;
|
|
66
|
+
let written = 0;
|
|
67
|
+
for (const file of files) {
|
|
68
|
+
const source = sources.get(file);
|
|
69
|
+
const transformed = tamaguiToTailwind(source, transformConfig);
|
|
70
|
+
if (transformed === source) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
changed++;
|
|
74
|
+
if (write) {
|
|
75
|
+
await (0, import_promises.writeFile)(file, transformed);
|
|
76
|
+
written++;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
process.stdout.write(createDiff(file, source, transformed, cwd));
|
|
80
|
+
}
|
|
81
|
+
if (files.length === 0) {
|
|
82
|
+
console.info("No files matched.");
|
|
83
|
+
} else if (changed === 0) {
|
|
84
|
+
console.info(`No to-tailwind changes found in ${files.length} file(s).`);
|
|
85
|
+
} else if (write) {
|
|
86
|
+
console.info(`Converted ${changed} of ${files.length} file(s).`);
|
|
87
|
+
} else {
|
|
88
|
+
console.info(`
|
|
89
|
+
[dry-run] ${changed} of ${files.length} file(s) would change. Run with --write to apply.`);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
files: files.length,
|
|
93
|
+
changed,
|
|
94
|
+
written
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async function collectFiles(patterns, cwd) {
|
|
98
|
+
const files = /* @__PURE__ */ new Set();
|
|
99
|
+
for (const pattern of patterns) {
|
|
100
|
+
const resolved = (0, import_node_path.resolve)(cwd, pattern);
|
|
101
|
+
const existing = await (0, import_promises.stat)(resolved).catch(() => null);
|
|
102
|
+
if (existing?.isDirectory()) {
|
|
103
|
+
for (const file of await glob(defaultFileGlob, {
|
|
104
|
+
cwd: resolved,
|
|
105
|
+
absolute: true,
|
|
106
|
+
nodir: true,
|
|
107
|
+
ignore: ignoredGlobs
|
|
108
|
+
})) {
|
|
109
|
+
files.add((0, import_node_path.resolve)(file));
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (existing?.isFile()) {
|
|
114
|
+
if (isCodeFile(resolved)) {
|
|
115
|
+
files.add(resolved);
|
|
116
|
+
}
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
for (const file of await glob(pattern, {
|
|
120
|
+
cwd,
|
|
121
|
+
absolute: true,
|
|
122
|
+
nodir: true,
|
|
123
|
+
ignore: ignoredGlobs
|
|
124
|
+
})) {
|
|
125
|
+
if (isCodeFile(file)) {
|
|
126
|
+
files.add((0, import_node_path.resolve)(file));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return [...files].sort();
|
|
131
|
+
}
|
|
132
|
+
function createDiff(file, source, transformed, cwd) {
|
|
133
|
+
const displayPath = toPosixPath((0, import_node_path.relative)(cwd, file) || file);
|
|
134
|
+
return createTwoFilesPatch(displayPath, displayPath, source, transformed, "before", "after", { context: 3 });
|
|
135
|
+
}
|
|
136
|
+
function isCodeFile(file) {
|
|
137
|
+
return codeFileExtensions.has((0, import_node_path.extname)(file));
|
|
138
|
+
}
|
|
139
|
+
function toPosixPath(path) {
|
|
140
|
+
return path.split(import_node_path.sep).join("/");
|
|
141
|
+
}
|
|
142
|
+
async function loadTransformConfig(configPath, useDefaultConfig, cwd) {
|
|
143
|
+
if (!configPath) {
|
|
144
|
+
if (useDefaultConfig) {
|
|
145
|
+
return {
|
|
146
|
+
transformConfig: { grammarConfig: import_to_tailwind_default_config.bundledDefaultGrammarConfig },
|
|
147
|
+
usedDefault: true
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
transformConfig: {},
|
|
152
|
+
usedDefault: true
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const resolved = (0, import_node_path.resolve)(cwd, configPath);
|
|
156
|
+
let mod;
|
|
157
|
+
try {
|
|
158
|
+
mod = require(resolved);
|
|
159
|
+
} catch (requireErr) {
|
|
160
|
+
try {
|
|
161
|
+
mod = await import(resolved);
|
|
162
|
+
} catch {
|
|
163
|
+
throw new Error(`--config ${configPath} could not be loaded (${requireErr.message}) \u2014 aborted (not falling back to defaults).`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const config = mod?.config ?? mod?.default ?? mod?.tamaguiConfig ?? mod;
|
|
167
|
+
const tokens = config?.tokens;
|
|
168
|
+
const fonts = config?.fonts;
|
|
169
|
+
const themes = config?.themes;
|
|
170
|
+
const media = config?.media;
|
|
171
|
+
const shorthands = config?.shorthands;
|
|
172
|
+
const isObj = (v) => v != null && typeof v === "object" && !Array.isArray(v);
|
|
173
|
+
const bad = (msg) => {
|
|
174
|
+
throw new Error(`--config ${configPath} has a malformed shape: ${msg} \u2014 aborted.`);
|
|
175
|
+
};
|
|
176
|
+
if (tokens !== void 0) {
|
|
177
|
+
if (!isObj(tokens)) bad("`tokens` must be an object");
|
|
178
|
+
for (const category of [
|
|
179
|
+
"space",
|
|
180
|
+
"size",
|
|
181
|
+
"radius",
|
|
182
|
+
"zIndex",
|
|
183
|
+
"color"
|
|
184
|
+
]) {
|
|
185
|
+
if (tokens[category] !== void 0 && !isObj(tokens[category])) {
|
|
186
|
+
bad(`\`tokens.${category}\` must be an object`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (fonts !== void 0 && !isObj(fonts)) bad("`fonts` must be an object");
|
|
191
|
+
if (themes !== void 0 && !isObj(themes)) bad("`themes` must be an object");
|
|
192
|
+
if (media !== void 0 && !isObj(media)) bad("`media` must be an object");
|
|
193
|
+
if (shorthands !== void 0 && !isObj(shorthands)) bad("`shorthands` must be an object");
|
|
194
|
+
if (!tokens && !fonts && !themes && !media && !shorthands) {
|
|
195
|
+
bad("exposes no { tokens, fonts, themes, media, shorthands }");
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
transformConfig: {
|
|
199
|
+
tokens,
|
|
200
|
+
fonts,
|
|
201
|
+
themes,
|
|
202
|
+
media,
|
|
203
|
+
shorthands
|
|
204
|
+
},
|
|
205
|
+
usedDefault: false
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function loadTamaguiToTailwind() {
|
|
209
|
+
const { tamaguiToTailwind } = require("@tamagui/to-tailwind");
|
|
210
|
+
if (typeof tamaguiToTailwind !== "function") {
|
|
211
|
+
throw new Error("@tamagui/to-tailwind did not export tamaguiToTailwind");
|
|
212
|
+
}
|
|
213
|
+
return tamaguiToTailwind;
|
|
214
|
+
}
|
package/dist/update-template.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,66 +6,57 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var update_template_exports = {};
|
|
35
|
-
__export(update_template_exports, {
|
|
36
|
-
updateTemplate: () => updateTemplate
|
|
37
|
-
});
|
|
29
|
+
__export(update_template_exports, { updateTemplate: () => updateTemplate });
|
|
38
30
|
module.exports = __toCommonJS(update_template_exports);
|
|
39
31
|
var import_chalk = __toESM(require("chalk"));
|
|
40
32
|
var import_node_child_process = require("node:child_process");
|
|
41
33
|
function updateTemplate(templateUrl, ignoredPatterns = []) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
34
|
+
const templateName = templateUrl.split("/").pop()?.split(".")[0] || "template";
|
|
35
|
+
const remoteName = `${templateName}-template`;
|
|
36
|
+
const addRemoteCommand = `git remote add ${remoteName} ${templateUrl}`;
|
|
37
|
+
const rmRemoteCommand = `git remote remove ${remoteName}`;
|
|
38
|
+
try {
|
|
39
|
+
(0, import_node_child_process.execSync)(addRemoteCommand);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error instanceof Error && error.toString().includes("already exists")) {
|
|
42
|
+
(0, import_node_child_process.execSync)(rmRemoteCommand);
|
|
43
|
+
(0, import_node_child_process.execSync)(addRemoteCommand);
|
|
44
|
+
} else {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
(0, import_node_child_process.execSync)(`git fetch --all`);
|
|
49
|
+
try {
|
|
50
|
+
(0, import_node_child_process.execSync)(`git merge takeout-template/main --allow-unrelated-histories`);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof Error && error.message.includes("unresolved conflict")) {
|
|
53
|
+
console.info(tamaguiLog("We've merged the latest changes. Please resolve the conflicts and commit the merge."));
|
|
54
|
+
} else {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
(0, import_node_child_process.execSync)(`git reset HEAD ${ignoredPatterns.join(" ")}`);
|
|
67
59
|
}
|
|
68
60
|
function tamaguiLog(message) {
|
|
69
|
-
|
|
70
|
-
}
|
|
61
|
+
return `${import_chalk.default.green("[Tamagui]")} ${message}`;
|
|
62
|
+
}
|
package/dist/update.cjs
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var update_exports = {};
|
|
24
|
-
__export(update_exports, {
|
|
25
|
-
update: () => update
|
|
26
|
-
});
|
|
23
|
+
__export(update_exports, { update: () => update });
|
|
27
24
|
module.exports = __toCommonJS(update_exports);
|
|
28
|
-
const update = async () => {};
|
|
25
|
+
const update = async () => {};
|