create-tamagui 2.0.0-rc.9 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +551 -231
- package/dist/index.native.js +551 -231
- package/package.json +4 -4
- package/dist/index.js +0 -612
- package/dist/index.js.map +0 -6
- package/dist/index.native.js.map +0 -6
package/dist/index.native.js
CHANGED
|
@@ -4,11 +4,14 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
9
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
11
|
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
12
15
|
return to;
|
|
13
16
|
};
|
|
14
17
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -16,24 +19,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
16
19
|
// file that has been converted to a CommonJS file using a Babel-
|
|
17
20
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
18
21
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
19
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
20
23
|
mod
|
|
21
24
|
));
|
|
22
25
|
|
|
23
26
|
// src/index.ts
|
|
24
|
-
var
|
|
27
|
+
var import_chalk10 = __toESM(require("chalk"));
|
|
28
|
+
var import_commander = __toESM(require("commander"));
|
|
29
|
+
var import_detect_package_manager = require("detect-package-manager");
|
|
30
|
+
var import_fs_extra2 = require("fs-extra");
|
|
31
|
+
var import_node_child_process3 = require("node:child_process");
|
|
32
|
+
var import_node_fs3 = __toESM(require("node:fs"));
|
|
33
|
+
var import_node_path4 = __toESM(require("node:path"));
|
|
34
|
+
var import_node_process = require("node:process");
|
|
35
|
+
var import_opener = __toESM(require("opener"));
|
|
36
|
+
var import_prompts4 = __toESM(require("prompts"));
|
|
25
37
|
|
|
26
38
|
// package.json
|
|
27
39
|
var package_default = {
|
|
28
40
|
name: "create-tamagui",
|
|
29
|
-
version: "2.0.0-
|
|
41
|
+
version: "2.0.0-1780094816896",
|
|
30
42
|
gitHead: "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
31
43
|
bin: "./run.js",
|
|
32
44
|
files: [
|
|
33
45
|
"run.js",
|
|
34
46
|
"dist"
|
|
35
47
|
],
|
|
36
|
-
sideEffects:
|
|
48
|
+
sideEffects: false,
|
|
37
49
|
main: "dist/index.cjs",
|
|
38
50
|
publishConfig: {
|
|
39
51
|
access: "public"
|
|
@@ -44,6 +56,7 @@ var package_default = {
|
|
|
44
56
|
"test-disabled": "NODE_ENV=test node -r esbuild-register ../../../node_modules/.bin/playwright test integration.test.ts",
|
|
45
57
|
"test:debug": "bun run test --debug",
|
|
46
58
|
test: "bun run build:test && vitest run",
|
|
59
|
+
"test:web": "bun run test",
|
|
47
60
|
"build:test": "bun run build",
|
|
48
61
|
prerelease: "rimraf ./dist/",
|
|
49
62
|
prepublish: "bun run build",
|
|
@@ -61,8 +74,7 @@ var package_default = {
|
|
|
61
74
|
opener: "^1.5.2",
|
|
62
75
|
prompts: "2.1.0",
|
|
63
76
|
rimraf: "^5.0.1",
|
|
64
|
-
"validate-npm-package-name": "3.0.0"
|
|
65
|
-
zx: "^8.5.5"
|
|
77
|
+
"validate-npm-package-name": "3.0.0"
|
|
66
78
|
},
|
|
67
79
|
devDependencies: {
|
|
68
80
|
"@playwright/test": "^1.49.1",
|
|
@@ -95,7 +107,8 @@ var IS_TEST = process.env.NODE_ENV === "test";
|
|
|
95
107
|
var import_chalk2 = __toESM(require("chalk"));
|
|
96
108
|
|
|
97
109
|
// src/helpers/rainbowChalk.ts
|
|
98
|
-
var import_chalk = __toESM(require("chalk"))
|
|
110
|
+
var import_chalk = __toESM(require("chalk"));
|
|
111
|
+
var rainbowColors = [
|
|
99
112
|
"#f76808",
|
|
100
113
|
"#f5d90a",
|
|
101
114
|
"#30a46c",
|
|
@@ -107,16 +120,31 @@ var import_chalk = __toESM(require("chalk")), rainbowColors = [
|
|
|
107
120
|
|
|
108
121
|
// src/helpers/asciiArts.ts
|
|
109
122
|
var tamaguiRainbowAsciiArt = (function() {
|
|
110
|
-
|
|
123
|
+
const char0_1 = import_chalk2.default.hex(rainbowColors[0])("\u2580\u2588\u2580");
|
|
124
|
+
const char0_2 = import_chalk2.default.hex(rainbowColors[0])(" \u2588 ");
|
|
125
|
+
const char1_1 = import_chalk2.default.hex(rainbowColors[1])("\u2584\u2580\u2588");
|
|
126
|
+
const char1_2 = import_chalk2.default.hex(rainbowColors[1])("\u2588\u2580\u2588");
|
|
127
|
+
const char2_1 = import_chalk2.default.hex(rainbowColors[2])("\u2588\u2580\u2584\u2580\u2588");
|
|
128
|
+
const char2_2 = import_chalk2.default.hex(rainbowColors[2])("\u2588 \u2580 \u2588");
|
|
129
|
+
const char3_1 = import_chalk2.default.hex(rainbowColors[3])("\u2584\u2580\u2588");
|
|
130
|
+
const char3_2 = import_chalk2.default.hex(rainbowColors[3])("\u2588\u2580\u2588");
|
|
131
|
+
const char4_1 = import_chalk2.default.hex(rainbowColors[4])("\u2588\u2580\u2580");
|
|
132
|
+
const char4_2 = import_chalk2.default.hex(rainbowColors[4])("\u2588\u2584\u2588");
|
|
133
|
+
const char5_1 = import_chalk2.default.hex(rainbowColors[5])("\u2588 \u2588");
|
|
134
|
+
const char5_2 = import_chalk2.default.hex(rainbowColors[5])("\u2588\u2584\u2588");
|
|
135
|
+
const char6_1 = import_chalk2.default.hex(rainbowColors[6])("\u2588");
|
|
136
|
+
const char6_2 = import_chalk2.default.hex(rainbowColors[6])("\u2588");
|
|
111
137
|
return `${char0_1}\u2003${char1_1}\u2003${char2_1}\u2003${char3_1}\u2003${char4_1}\u2003${char5_1}\u2003${char6_1}
|
|
112
138
|
${char0_2}\u2003${char1_2}\u2003${char2_2}\u2003${char3_2}\u2003${char4_2}\u2003${char5_2}\u2003${char6_2}
|
|
113
139
|
`;
|
|
114
|
-
})()
|
|
140
|
+
})();
|
|
141
|
+
var takeoutAsciiArt = `\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2591\u2588\u2588\u2588\u2588\u2588\u2557\u2591\u2588\u2588\u2557\u2591\u2591\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2591\u2588\u2588\u2588\u2588\u2588\u2557\u2591\u2588\u2588\u2557\u2591\u2591\u2591\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
115
142
|
\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2591\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D
|
|
116
143
|
\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2550\u255D\u2591\u2588\u2588\u2588\u2588\u2588\u2557\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2588\u2588\u2551\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591
|
|
117
144
|
\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557\u2591\u2588\u2588\u2554\u2550\u2550\u255D\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2588\u2588\u2551\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591
|
|
118
145
|
\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2588\u2588\u2551\u2588\u2588\u2551\u2591\u255A\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2591\u2591\u2591\u2588\u2588\u2551\u2591\u2591\u2591
|
|
119
|
-
\u2591\u2591\u2591\u255A\u2550\u255D\u2591\u2591\u2591\u255A\u2550\u255D\u2591\u2591\u255A\u2550\u255D\u255A\u2550\u255D\u2591\u2591\u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u2591\u255A\u2550\u2550\u2550\u2550\u255D\u2591\u2591\u255A\u2550\u2550\u2550\u2550\u2550\u255D\u2591\u2591\u2591\u2591\u255A\u2550\u255D\u2591\u2591\u2591
|
|
146
|
+
\u2591\u2591\u2591\u255A\u2550\u255D\u2591\u2591\u2591\u255A\u2550\u255D\u2591\u2591\u255A\u2550\u255D\u255A\u2550\u255D\u2591\u2591\u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u2591\u255A\u2550\u2550\u2550\u2550\u255D\u2591\u2591\u255A\u2550\u2550\u2550\u2550\u2550\u255D\u2591\u2591\u2591\u2591\u255A\u2550\u255D\u2591\u2591\u2591`;
|
|
147
|
+
var tamaguiDuckAsciiArt = ` \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588
|
|
120
148
|
\u2588\u2588 \u2588\u2588
|
|
121
149
|
\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588
|
|
122
150
|
\u2588\u2588 \u2588\u2588 \u2588\u2588
|
|
@@ -127,54 +155,106 @@ ${char0_2}\u2003${char1_2}\u2003${char2_2}\u2003${char3_2}\u2003${char4_2}\u2003
|
|
|
127
155
|
\u2588\u2588 \u2588\u2588 `;
|
|
128
156
|
|
|
129
157
|
// src/helpers/cloneStarter.ts
|
|
130
|
-
var import_node_child_process = require("node:child_process")
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
158
|
+
var import_node_child_process = require("node:child_process");
|
|
159
|
+
var import_node_fs = require("node:fs");
|
|
160
|
+
var import_node_os = require("node:os");
|
|
161
|
+
var import_node_path = require("node:path");
|
|
162
|
+
var import_chalk3 = __toESM(require("chalk"));
|
|
163
|
+
var import_fs_extra = require("fs-extra");
|
|
164
|
+
var import_rimraf = require("rimraf");
|
|
165
|
+
var open = require("opener");
|
|
166
|
+
var exec = (cmd, options) => {
|
|
167
|
+
console.info(`$ `, cmd);
|
|
168
|
+
return (0, import_node_child_process.execSync)(cmd, {
|
|
169
|
+
stdio: process.env.DEBUG ? "inherit" : "ignore",
|
|
170
|
+
...options
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
var tamaguiDir = (0, import_node_path.join)((0, import_node_os.homedir)(), ".tamagui-repo-cache");
|
|
174
|
+
var targetGitDir = "";
|
|
175
|
+
var cloneStarter = async (template, resolvedProjectPath, projectName) => {
|
|
176
|
+
targetGitDir = (0, import_node_path.join)(tamaguiDir, "tamagui", template.repo.url.split("/").at(-1));
|
|
177
|
+
console.info();
|
|
178
|
+
await setupTamaguiDotDir(template);
|
|
179
|
+
const starterDir = (0, import_node_path.join)(targetGitDir, ...template.repo.dir);
|
|
180
|
+
console.info();
|
|
181
|
+
console.info(
|
|
137
182
|
`Copying starter from ${starterDir} into ${import_chalk3.default.blueBright(projectName)}...`
|
|
138
|
-
)
|
|
183
|
+
);
|
|
184
|
+
console.info();
|
|
185
|
+
await (0, import_fs_extra.copy)(starterDir, resolvedProjectPath);
|
|
186
|
+
await (0, import_rimraf.rimraf)(`${resolvedProjectPath}/.git`);
|
|
187
|
+
rewriteWorkspaceVersions(resolvedProjectPath);
|
|
188
|
+
console.info(import_chalk3.default.green(`${projectName} created!`));
|
|
189
|
+
console.info();
|
|
139
190
|
};
|
|
140
191
|
async function setupTamaguiDotDir(template) {
|
|
141
|
-
|
|
192
|
+
console.info(`Setting up ${import_chalk3.default.blueBright(targetGitDir)}...`);
|
|
193
|
+
if (process.env.GITHUB_HEAD_REF) {
|
|
142
194
|
try {
|
|
143
|
-
|
|
195
|
+
(0, import_node_child_process.execSync)(`git switch -c ${process.env.GITHUB_HEAD_REF}`, {
|
|
196
|
+
cwd: targetGitDir,
|
|
197
|
+
stdio: "ignore"
|
|
198
|
+
});
|
|
144
199
|
} catch {
|
|
145
200
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
201
|
+
}
|
|
202
|
+
const branch = template.repo.branch;
|
|
203
|
+
await (0, import_fs_extra.ensureDir)(tamaguiDir);
|
|
204
|
+
const isInSubDir = template.repo.dir.length > 0;
|
|
205
|
+
const sourceGitRepo = template.repo.url;
|
|
206
|
+
const sourceGitRepoSshFallback = template.repo.sshFallback;
|
|
207
|
+
if (!await (0, import_fs_extra.pathExists)(targetGitDir)) {
|
|
208
|
+
console.info(`Cloning tamagui base directory`);
|
|
209
|
+
console.info();
|
|
210
|
+
const cmd = `git clone --branch ${branch} ${isInSubDir ? "--depth 1 --sparse --filter=blob:none " : ""}${sourceGitRepo} "${targetGitDir}"`;
|
|
154
211
|
try {
|
|
155
212
|
try {
|
|
156
|
-
console.info(`$ ${cmd}`)
|
|
213
|
+
console.info(`$ ${cmd}`);
|
|
214
|
+
console.info();
|
|
215
|
+
exec(cmd);
|
|
157
216
|
} catch (error) {
|
|
158
217
|
if (cmd.includes("https://")) {
|
|
159
|
-
console.info(
|
|
160
|
-
|
|
161
|
-
console.info(`$ ${sshCmd}`)
|
|
162
|
-
|
|
218
|
+
console.info(`https failed - trying with ssh now...`);
|
|
219
|
+
const sshCmd = cmd.replace(sourceGitRepo, sourceGitRepoSshFallback);
|
|
220
|
+
console.info(`$ ${sshCmd}`);
|
|
221
|
+
console.info();
|
|
222
|
+
exec(sshCmd);
|
|
223
|
+
} else {
|
|
163
224
|
throw error;
|
|
225
|
+
}
|
|
164
226
|
}
|
|
165
227
|
} catch (error) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"
|
|
169
|
-
|
|
170
|
-
|
|
228
|
+
if (error instanceof Error) {
|
|
229
|
+
if (template.value === "takeout-pro" || template.value === "takeout-pro-classic") {
|
|
230
|
+
if (error?.stderr?.includes("Repository not found")) {
|
|
231
|
+
console.info(
|
|
232
|
+
import_chalk3.default.yellow(
|
|
233
|
+
`You don't have access to this starter. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info.`
|
|
234
|
+
)
|
|
235
|
+
);
|
|
236
|
+
open("https://tamagui.dev/takeout");
|
|
237
|
+
process.exit(0);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
throw error;
|
|
171
242
|
}
|
|
243
|
+
} else {
|
|
244
|
+
if (!await (0, import_fs_extra.pathExists)((0, import_node_path.join)(targetGitDir, ".git"))) {
|
|
245
|
+
console.error(`Corrupt Tamagui directory, please delete ${targetGitDir} and re-run`);
|
|
246
|
+
process.exit(1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (isInSubDir) {
|
|
250
|
+
const cmd = `git sparse-checkout set code/starters`;
|
|
251
|
+
exec(cmd, { cwd: targetGitDir });
|
|
252
|
+
console.info();
|
|
172
253
|
}
|
|
173
|
-
isInSubDir && (exec("git sparse-checkout set code/starters", { cwd: targetGitDir }), console.info());
|
|
174
254
|
try {
|
|
175
|
-
|
|
255
|
+
const remoteName = getDefaultRemoteName();
|
|
176
256
|
if (await (0, import_fs_extra.pathExists)((0, import_node_path.join)(targetGitDir, ".git"))) {
|
|
177
|
-
|
|
257
|
+
const cmd2 = `git pull --rebase --allow-unrelated-histories --depth 1 ${remoteName} ${branch}`;
|
|
178
258
|
try {
|
|
179
259
|
exec(cmd2, {
|
|
180
260
|
cwd: targetGitDir
|
|
@@ -185,224 +265,357 @@ async function setupTamaguiDotDir(template) {
|
|
|
185
265
|
});
|
|
186
266
|
}
|
|
187
267
|
console.info();
|
|
188
|
-
} else
|
|
268
|
+
} else {
|
|
189
269
|
console.warn(
|
|
190
270
|
`Warning: ${targetGitDir} is not a git repository. Skipping pull operation.`
|
|
191
271
|
);
|
|
272
|
+
}
|
|
192
273
|
} catch (err) {
|
|
193
|
-
await (0, import_fs_extra.remove)(targetGitDir)
|
|
194
|
-
|
|
195
|
-
|
|
274
|
+
await (0, import_fs_extra.remove)(targetGitDir);
|
|
275
|
+
console.info(`Error updating: ${err.message} ${err.stack}`);
|
|
276
|
+
console.info(
|
|
277
|
+
`We removed the old template cache, so re-running may fix. If not, please file an issue: https://github.com/tamagui/tamagui/issues/new?assignees=&labels=&template=bug_report.md&title=`
|
|
278
|
+
);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function rewriteWorkspaceVersions(projectPath2) {
|
|
283
|
+
const pkgPath = (0, import_node_path.join)(projectPath2, "package.json");
|
|
284
|
+
try {
|
|
285
|
+
const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgPath, "utf-8"));
|
|
286
|
+
if (pkg.workspaces) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const ctPkgPath = require.resolve("create-tamagui/package.json");
|
|
290
|
+
const ctPkg = JSON.parse((0, import_node_fs.readFileSync)(ctPkgPath, "utf-8"));
|
|
291
|
+
const version = `^${ctPkg.version}`;
|
|
292
|
+
let changed = false;
|
|
293
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
294
|
+
const deps = pkg[field];
|
|
295
|
+
if (!deps) continue;
|
|
296
|
+
for (const [key, val] of Object.entries(deps)) {
|
|
297
|
+
if (val === "workspace:*") {
|
|
298
|
+
deps[key] = version;
|
|
299
|
+
changed = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (changed) {
|
|
304
|
+
(0, import_node_fs.writeFileSync)(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
305
|
+
console.info(import_chalk3.default.dim(` Rewrote workspace:* \u2192 ${version}`));
|
|
306
|
+
}
|
|
307
|
+
} catch {
|
|
196
308
|
}
|
|
197
309
|
}
|
|
198
310
|
var getDefaultRemoteName = () => {
|
|
199
311
|
try {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
312
|
+
if (!(0, import_fs_extra.pathExists)((0, import_node_path.join)(targetGitDir, ".git"))) {
|
|
313
|
+
console.warn(
|
|
314
|
+
'Warning: Not in a git repository. Using default remote name "origin".'
|
|
315
|
+
);
|
|
316
|
+
return "origin";
|
|
317
|
+
}
|
|
318
|
+
const remotes = (0, import_node_child_process.execSync)("git remote", { cwd: targetGitDir }).toString().trim().split("\n");
|
|
319
|
+
return remotes[0] || "origin";
|
|
204
320
|
} catch (error) {
|
|
205
|
-
|
|
321
|
+
console.warn("Error getting default remote name:", error);
|
|
322
|
+
console.warn('Using default remote name "origin".');
|
|
323
|
+
return "origin";
|
|
206
324
|
}
|
|
207
325
|
};
|
|
208
326
|
|
|
209
327
|
// src/helpers/getProjectName.ts
|
|
210
|
-
var import_node_path2 = __toESM(require("node:path"))
|
|
328
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
329
|
+
var import_chalk4 = __toESM(require("chalk"));
|
|
330
|
+
var import_prompts = __toESM(require("prompts"));
|
|
211
331
|
|
|
212
332
|
// src/helpers/validateNpmPackage.ts
|
|
213
333
|
var import_validate_npm_package_name = __toESM(require("validate-npm-package-name"));
|
|
214
334
|
function validateNpmName(name) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
valid:
|
|
335
|
+
const nameValidation = (0, import_validate_npm_package_name.default)(name);
|
|
336
|
+
if (nameValidation.validForNewPackages) {
|
|
337
|
+
return { valid: true };
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
valid: false,
|
|
218
341
|
problems: [...nameValidation.errors || [], ...nameValidation.warnings || []]
|
|
219
342
|
};
|
|
220
343
|
}
|
|
221
344
|
|
|
222
345
|
// src/helpers/getProjectName.ts
|
|
223
346
|
var getProjectName = async (projectPath2) => {
|
|
224
|
-
if (typeof projectPath2
|
|
225
|
-
|
|
347
|
+
if (typeof projectPath2 === "string") {
|
|
348
|
+
projectPath2 = projectPath2.trim();
|
|
349
|
+
}
|
|
350
|
+
if (!projectPath2) {
|
|
351
|
+
const res = await (0, import_prompts.default)({
|
|
226
352
|
type: "text",
|
|
227
353
|
name: "path",
|
|
228
354
|
message: "Project name:",
|
|
229
355
|
initial: "myapp",
|
|
230
356
|
validate: (name) => {
|
|
231
|
-
|
|
232
|
-
|
|
357
|
+
const validation = validateNpmName(import_node_path2.default.basename(import_node_path2.default.resolve(name)));
|
|
358
|
+
if (validation.valid) {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
return "Invalid project name: " + validation.problems[0];
|
|
233
362
|
}
|
|
234
363
|
});
|
|
235
|
-
typeof res.path
|
|
364
|
+
if (typeof res.path === "string") {
|
|
365
|
+
projectPath2 = res.path.trim();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (!projectPath2) {
|
|
369
|
+
console.info();
|
|
370
|
+
console.info("Please specify the project directory:");
|
|
371
|
+
console.info(
|
|
372
|
+
` ${import_chalk4.default.cyan(package_default.name)} ${import_chalk4.default.green("<project-directory>")}`
|
|
373
|
+
);
|
|
374
|
+
console.info();
|
|
375
|
+
console.info("For example:");
|
|
376
|
+
console.info(` ${import_chalk4.default.cyan(package_default.name)} ${import_chalk4.default.green("my-tamagui-app")}`);
|
|
377
|
+
console.info();
|
|
378
|
+
console.info(`Run ${import_chalk4.default.cyan(`${package_default.name} --help`)} to see all options.`);
|
|
379
|
+
process.exit(1);
|
|
236
380
|
}
|
|
237
|
-
return projectPath2
|
|
238
|
-
` ${import_chalk4.default.cyan(package_default.name)} ${import_chalk4.default.green("<project-directory>")}`
|
|
239
|
-
), console.info(), console.info("For example:"), console.info(` ${import_chalk4.default.cyan(package_default.name)} ${import_chalk4.default.green("my-tamagui-app")}`), console.info(), console.info(`Run ${import_chalk4.default.cyan(`${package_default.name} --help`)} to see all options.`), process.exit(1)), projectPath2;
|
|
381
|
+
return projectPath2;
|
|
240
382
|
};
|
|
241
383
|
|
|
242
384
|
// src/helpers/getTemplateInfo.ts
|
|
243
385
|
var import_prompts3 = __toESM(require("prompts"));
|
|
244
386
|
|
|
245
387
|
// src/templates.ts
|
|
246
|
-
var
|
|
388
|
+
var import_chalk9 = __toESM(require("chalk"));
|
|
247
389
|
|
|
248
|
-
// src/steps/
|
|
249
|
-
var import_chalk5 = __toESM(require("chalk"))
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
390
|
+
// src/steps/expo-router.ts
|
|
391
|
+
var import_chalk5 = __toESM(require("chalk"));
|
|
392
|
+
var main = async ({ isFullClone, projectName }) => {
|
|
393
|
+
if (isFullClone) {
|
|
394
|
+
console.info(`
|
|
395
|
+
${import_chalk5.default.green.bold("Done!")} created a new project under ./${projectName}
|
|
253
396
|
|
|
254
397
|
visit your project:
|
|
255
398
|
${import_chalk5.default.green("cd")} ${projectName}
|
|
256
|
-
`)
|
|
399
|
+
`);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
var expo_router_default = main;
|
|
403
|
+
|
|
404
|
+
// src/steps/remix.ts
|
|
405
|
+
var import_chalk6 = __toESM(require("chalk"));
|
|
406
|
+
var packageManager = "bun";
|
|
407
|
+
var runCommand = (scriptName) => `${packageManager} run ${scriptName}`;
|
|
408
|
+
var main2 = async ({ isFullClone, projectName }) => {
|
|
409
|
+
if (isFullClone) {
|
|
410
|
+
console.info(`
|
|
411
|
+
${import_chalk6.default.green.bold("Done!")} created a new project under ./${projectName}
|
|
412
|
+
|
|
413
|
+
visit your project:
|
|
414
|
+
${import_chalk6.default.green("cd")} ${projectName}
|
|
415
|
+
`);
|
|
416
|
+
}
|
|
417
|
+
console.info(`
|
|
418
|
+
To start the Remix development server, run:
|
|
419
|
+
${import_chalk6.default.green(runCommand("dev"))}
|
|
420
|
+
`);
|
|
421
|
+
};
|
|
422
|
+
var remix_default = main2;
|
|
423
|
+
|
|
424
|
+
// src/steps/starter-free.ts
|
|
425
|
+
var import_chalk7 = __toESM(require("chalk"));
|
|
426
|
+
var packageManager2 = "bun";
|
|
427
|
+
var runCommand2 = (scriptName) => `${packageManager2} run ${scriptName}`;
|
|
428
|
+
var main3 = async ({ isFullClone, projectName }) => {
|
|
429
|
+
console.info(`Note: you need bun for this repo.`);
|
|
430
|
+
if (isFullClone) {
|
|
431
|
+
console.info(`${import_chalk7.default.green.bold(
|
|
432
|
+
"Done!"
|
|
433
|
+
)} created a new project under ./${projectName}
|
|
434
|
+
|
|
435
|
+
visit your project:
|
|
436
|
+
${import_chalk7.default.green("cd")} ${projectName}
|
|
437
|
+
`);
|
|
438
|
+
}
|
|
439
|
+
console.info(`
|
|
257
440
|
To start the Next.js development server, run:
|
|
258
|
-
${
|
|
441
|
+
${import_chalk7.default.green(runCommand2("web"))}
|
|
259
442
|
|
|
260
443
|
To start Expo Go for mobile development, run:
|
|
261
|
-
${
|
|
444
|
+
${import_chalk7.default.green(runCommand2("native"))}
|
|
262
445
|
|
|
263
446
|
You can also create Expo development builds by doing:
|
|
264
447
|
|
|
265
|
-
${
|
|
448
|
+
${import_chalk7.default.green(`cd apps/expo`)}
|
|
266
449
|
then:
|
|
267
|
-
${
|
|
450
|
+
${import_chalk7.default.green(runCommand2("ios"))}
|
|
268
451
|
or...
|
|
269
|
-
${
|
|
452
|
+
${import_chalk7.default.green(runCommand2("android"))}
|
|
270
453
|
|
|
271
454
|
Be sure to replace yourprojectsname in app.json with the uid you'd like for your app.
|
|
272
455
|
`);
|
|
273
|
-
}
|
|
456
|
+
};
|
|
457
|
+
var starter_free_default = main3;
|
|
274
458
|
|
|
275
459
|
// src/steps/takeout.ts
|
|
276
|
-
var import_node_child_process2 = require("node:child_process")
|
|
277
|
-
var
|
|
460
|
+
var import_node_child_process2 = require("node:child_process");
|
|
461
|
+
var import_node_fs2 = require("node:fs");
|
|
462
|
+
var import_promises = __toESM(require("node:fs/promises"));
|
|
463
|
+
var import_node_path3 = __toESM(require("node:path"));
|
|
464
|
+
var import_chalk8 = __toESM(require("chalk"));
|
|
465
|
+
var import_prompts2 = __toESM(require("prompts"));
|
|
466
|
+
var packageManager3 = "bun";
|
|
467
|
+
var runCommand3 = (scriptName) => `${packageManager3} run ${scriptName}`;
|
|
468
|
+
var main4 = async ({ isFullClone, projectName, projectPath: projectPath2 }) => {
|
|
278
469
|
console.info(`
|
|
279
|
-
${tamaguiRainbowAsciiArt.split(`
|
|
280
|
-
`).map((line) => ` ${line}`).join(`
|
|
281
|
-
`)}
|
|
470
|
+
${tamaguiRainbowAsciiArt.split("\n").map((line) => ` ${line}`).join("\n")}
|
|
282
471
|
${takeoutAsciiArt}
|
|
283
472
|
|
|
284
|
-
`)
|
|
285
|
-
|
|
473
|
+
`);
|
|
474
|
+
console.info();
|
|
475
|
+
const { setupSupabase } = await (0, import_prompts2.default)({
|
|
286
476
|
name: "setupSupabase",
|
|
287
477
|
message: "Set up Supabase?",
|
|
288
478
|
type: "confirm",
|
|
289
|
-
initial:
|
|
479
|
+
initial: true
|
|
290
480
|
});
|
|
291
481
|
if (setupSupabase) {
|
|
292
482
|
console.info();
|
|
293
|
-
|
|
483
|
+
const { startLocalSupabase } = await (0, import_prompts2.default)({
|
|
294
484
|
name: "startLocalSupabase",
|
|
295
485
|
type: "confirm",
|
|
296
486
|
message: "Start local Supabase instance for you? (Requires Docker)",
|
|
297
|
-
initial:
|
|
487
|
+
initial: true
|
|
298
488
|
});
|
|
299
|
-
if (startLocalSupabase
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
import_node_path3.default.join(projectPath2,
|
|
315
|
-
|
|
489
|
+
if (startLocalSupabase) {
|
|
490
|
+
const supabaseStarted = await runRetryableCommand(`bun run supa start`);
|
|
491
|
+
if (supabaseStarted) {
|
|
492
|
+
console.info();
|
|
493
|
+
const { setUpSupabaseEnv } = await (0, import_prompts2.default)({
|
|
494
|
+
name: "setUpSupabaseEnv",
|
|
495
|
+
type: "confirm",
|
|
496
|
+
message: "Do you want us to add the local env variables for you? This will create a file called .env.local.",
|
|
497
|
+
initial: true
|
|
498
|
+
});
|
|
499
|
+
if (setUpSupabaseEnv) {
|
|
500
|
+
const envs = getEnvFromSupabaseStatus(
|
|
501
|
+
(0, import_node_child_process2.execSync)("bun run supa status").toString()
|
|
502
|
+
);
|
|
503
|
+
const newEnvContent = Object.entries(envs).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
504
|
+
if ((0, import_node_fs2.existsSync)(import_node_path3.default.join(projectPath2, ".env.local"))) {
|
|
505
|
+
if ((0, import_node_fs2.readFileSync)(import_node_path3.default.join(projectPath2, ".env.local")).toString() !== newEnvContent) {
|
|
506
|
+
(0, import_node_fs2.renameSync)(
|
|
507
|
+
import_node_path3.default.join(projectPath2, ".env.local"),
|
|
508
|
+
import_node_path3.default.join(projectPath2, `.env.local.old-${Number(/* @__PURE__ */ new Date())}`)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
await import_promises.default.writeFile(import_node_path3.default.join(projectPath2, "./.env.local"), newEnvContent);
|
|
513
|
+
}
|
|
316
514
|
}
|
|
317
515
|
}
|
|
318
516
|
console.info();
|
|
319
|
-
|
|
517
|
+
const { setupRemoteSupabase } = await (0, import_prompts2.default)({
|
|
320
518
|
name: "setupRemoteSupabase",
|
|
321
519
|
type: "confirm",
|
|
322
520
|
message: "Link remote Supabase instance for you? (Create a project on https://app.supabase.com/projects first)",
|
|
323
|
-
initial:
|
|
521
|
+
initial: true
|
|
324
522
|
});
|
|
325
|
-
|
|
523
|
+
if (setupRemoteSupabase) {
|
|
524
|
+
await runRetryableCommand(`npx supabase login`);
|
|
525
|
+
console.info();
|
|
526
|
+
await linkSupabase();
|
|
527
|
+
}
|
|
326
528
|
}
|
|
327
|
-
isFullClone
|
|
328
|
-
|
|
529
|
+
if (isFullClone) {
|
|
530
|
+
console.info(`
|
|
531
|
+
${import_chalk8.default.green.bold("Done!")} created a new project under ./${projectName}
|
|
329
532
|
|
|
330
533
|
visit your project:
|
|
331
|
-
${
|
|
332
|
-
`)
|
|
534
|
+
${import_chalk8.default.green(" cd")} ${projectName}
|
|
535
|
+
`);
|
|
536
|
+
}
|
|
537
|
+
console.info(`
|
|
333
538
|
To start the Next.js development server, run:
|
|
334
|
-
${
|
|
539
|
+
${import_chalk8.default.green(runCommand3("web"))}
|
|
335
540
|
|
|
336
541
|
To start developing with Expo for native, run:
|
|
337
|
-
${
|
|
542
|
+
${import_chalk8.default.green(runCommand3("native"))}
|
|
338
543
|
|
|
339
544
|
To start developing for Expo dev build, run:
|
|
340
|
-
${
|
|
341
|
-
${
|
|
545
|
+
${import_chalk8.default.green(runCommand3("ios"))}
|
|
546
|
+
${import_chalk8.default.green(runCommand3("android"))}
|
|
342
547
|
|
|
343
548
|
To run Supabase scripts, cd into the supabase package:
|
|
344
|
-
${
|
|
549
|
+
${import_chalk8.default.green("cd supabase")}
|
|
345
550
|
|
|
346
|
-
${
|
|
347
|
-
${
|
|
551
|
+
${import_chalk8.default.green("yarn reset")} - Resets local database
|
|
552
|
+
${import_chalk8.default.green("yarn generate")} - Generates new types
|
|
348
553
|
|
|
349
|
-
Find info on the rest of the scripts in ${
|
|
554
|
+
Find info on the rest of the scripts in ${import_chalk8.default.cyan(`supabase/README.md`)}
|
|
350
555
|
|
|
351
556
|
If you've purchased and gained access to font and icon packages, you can run:
|
|
352
|
-
${
|
|
353
|
-
${
|
|
557
|
+
${import_chalk8.default.green("yarn add:icon")}
|
|
558
|
+
${import_chalk8.default.green("yarn add:font")}
|
|
354
559
|
`);
|
|
355
|
-
}
|
|
560
|
+
};
|
|
561
|
+
var takeout_default = main4;
|
|
356
562
|
async function runRetryableCommand(cmd, retriesCount = 0) {
|
|
357
563
|
try {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
564
|
+
(0, import_node_child_process2.execSync)(cmd, { stdio: "inherit" });
|
|
565
|
+
return true;
|
|
566
|
+
} catch (error) {
|
|
567
|
+
const { tryAgain } = await (0, import_prompts2.default)({
|
|
361
568
|
name: "tryAgain",
|
|
362
569
|
message: "An error occurred. Do you want to try again?",
|
|
363
570
|
type: "confirm",
|
|
364
|
-
initial:
|
|
571
|
+
initial: true
|
|
365
572
|
});
|
|
366
|
-
if (tryAgain)
|
|
573
|
+
if (tryAgain) {
|
|
367
574
|
await runRetryableCommand(cmd, retriesCount + 1);
|
|
368
|
-
else
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
`\u26A0\uFE0F Skipping this step. You can try running this command later. The failed command was \`${
|
|
575
|
+
} else {
|
|
576
|
+
console.info(
|
|
577
|
+
import_chalk8.default.yellow(
|
|
578
|
+
`\u26A0\uFE0F Skipping this step. You can try running this command later. The failed command was \`${import_chalk8.default.underline(
|
|
372
579
|
cmd
|
|
373
580
|
)}\`.`
|
|
374
581
|
)
|
|
375
|
-
)
|
|
582
|
+
);
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
376
585
|
}
|
|
377
586
|
}
|
|
378
587
|
async function linkSupabase() {
|
|
379
|
-
|
|
588
|
+
const { supabaseRefId } = await (0, import_prompts2.default)({
|
|
380
589
|
name: "supabaseRefId",
|
|
381
590
|
type: "text",
|
|
382
591
|
message: "Enter your supabase project's ID (e.g. abcdefghijklmnopqrst)",
|
|
383
|
-
initial:
|
|
384
|
-
})
|
|
592
|
+
initial: true
|
|
593
|
+
});
|
|
594
|
+
const cmd = `npx supabase link --project-ref ${supabaseRefId.trim()}`;
|
|
385
595
|
try {
|
|
386
|
-
|
|
596
|
+
(0, import_node_child_process2.execSync)(cmd, {
|
|
387
597
|
stdio: "inherit"
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
|
|
598
|
+
});
|
|
599
|
+
return true;
|
|
600
|
+
} catch (error) {
|
|
601
|
+
const { tryAgain } = await (0, import_prompts2.default)({
|
|
391
602
|
name: "tryAgain",
|
|
392
603
|
message: "An error occurred. Do you want to try again?",
|
|
393
604
|
type: "confirm",
|
|
394
|
-
initial:
|
|
605
|
+
initial: true
|
|
395
606
|
});
|
|
396
|
-
if (tryAgain)
|
|
607
|
+
if (tryAgain) {
|
|
397
608
|
await linkSupabase();
|
|
398
|
-
else
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
`\u26A0\uFE0F Skipping this step. You can try running this command later. The failed command was \`${
|
|
609
|
+
} else {
|
|
610
|
+
console.info(
|
|
611
|
+
import_chalk8.default.yellow(
|
|
612
|
+
`\u26A0\uFE0F Skipping this step. You can try running this command later. The failed command was \`${import_chalk8.default.underline(
|
|
402
613
|
cmd
|
|
403
614
|
)}\`.`
|
|
404
615
|
)
|
|
405
|
-
)
|
|
616
|
+
);
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
406
619
|
}
|
|
407
620
|
}
|
|
408
621
|
function getEnvFromSupabaseStatus(status) {
|
|
@@ -419,62 +632,90 @@ function getEnvFromSupabaseStatus(status) {
|
|
|
419
632
|
// src/templates.ts
|
|
420
633
|
var templates = [
|
|
421
634
|
{
|
|
422
|
-
title: `${
|
|
423
|
-
`\u{1F961} ${
|
|
635
|
+
title: `${import_chalk9.default.bold.underline(
|
|
636
|
+
`\u{1F961} ${import_chalk9.default.magenta("Takeout")} ${import_chalk9.default.green("Free")}`
|
|
424
637
|
)} - Full stack starter: https://tamagui.dev/takeout`,
|
|
425
638
|
value: "takeout-free",
|
|
426
639
|
type: "free",
|
|
427
|
-
hidden:
|
|
640
|
+
hidden: false,
|
|
428
641
|
packageManager: "bun",
|
|
429
642
|
repo: {
|
|
430
|
-
url:
|
|
431
|
-
sshFallback:
|
|
643
|
+
url: `https://github.com/tamagui/takeout-free`,
|
|
644
|
+
sshFallback: `git@github.com:tamagui/takeout-free.git`,
|
|
432
645
|
dir: [],
|
|
433
646
|
branch: "main"
|
|
434
647
|
},
|
|
435
648
|
extraSteps: starter_free_default
|
|
436
649
|
},
|
|
437
650
|
{
|
|
438
|
-
title: `${
|
|
439
|
-
`\u{1F961} ${
|
|
651
|
+
title: `${import_chalk9.default.bold.underline(
|
|
652
|
+
`\u{1F961} ${import_chalk9.default.magenta("Takeout")} ${import_chalk9.default.red("Pro")}`
|
|
440
653
|
)} - Full featured starter: https://tamagui.dev/takeout`,
|
|
441
|
-
value:
|
|
654
|
+
value: `takeout-pro`,
|
|
442
655
|
type: "premium",
|
|
443
656
|
packageManager: "yarn",
|
|
444
|
-
hidden:
|
|
657
|
+
hidden: false,
|
|
445
658
|
repo: {
|
|
446
|
-
url:
|
|
447
|
-
sshFallback:
|
|
659
|
+
url: `https://github.com/tamagui/takeout2`,
|
|
660
|
+
sshFallback: `git@github.com:tamagui/takeout2.git`,
|
|
448
661
|
dir: [],
|
|
449
662
|
branch: "main"
|
|
450
663
|
},
|
|
451
664
|
extraSteps: takeout_default
|
|
452
665
|
},
|
|
453
666
|
{
|
|
454
|
-
title: `${
|
|
455
|
-
`\u{1F961} ${
|
|
667
|
+
title: `${import_chalk9.default.bold.underline(
|
|
668
|
+
`\u{1F961} ${import_chalk9.default.magenta("Takeout")} ${import_chalk9.default.yellow("Pro Classic")}`
|
|
456
669
|
)} - Original Pro starter: https://tamagui.dev/takeout`,
|
|
457
|
-
value:
|
|
670
|
+
value: `takeout-pro-classic`,
|
|
458
671
|
type: "premium",
|
|
459
672
|
packageManager: "yarn",
|
|
460
|
-
hidden:
|
|
673
|
+
hidden: false,
|
|
461
674
|
repo: {
|
|
462
|
-
url:
|
|
463
|
-
sshFallback:
|
|
675
|
+
url: `https://github.com/tamagui/takeout`,
|
|
676
|
+
sshFallback: `git@github.com:tamagui/takeout.git`,
|
|
464
677
|
dir: [],
|
|
465
678
|
branch: "main"
|
|
466
679
|
},
|
|
467
680
|
extraSteps: takeout_default
|
|
468
681
|
},
|
|
469
682
|
{
|
|
470
|
-
title:
|
|
683
|
+
title: `Expo Router - Expo with file-based routing`,
|
|
684
|
+
value: "expo-router",
|
|
685
|
+
type: "free",
|
|
686
|
+
hidden: false,
|
|
687
|
+
packageManager: "bun",
|
|
688
|
+
repo: {
|
|
689
|
+
url: `https://github.com/tamagui/tamagui`,
|
|
690
|
+
sshFallback: `git@github.com:tamagui/tamagui.git`,
|
|
691
|
+
dir: ["code", "starters", "expo-router"],
|
|
692
|
+
branch: "main"
|
|
693
|
+
},
|
|
694
|
+
extraSteps: expo_router_default
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
title: `Remix - Remix with Vite`,
|
|
698
|
+
value: "remix",
|
|
699
|
+
type: "free",
|
|
700
|
+
hidden: false,
|
|
701
|
+
packageManager: "bun",
|
|
702
|
+
repo: {
|
|
703
|
+
url: `https://github.com/tamagui/tamagui`,
|
|
704
|
+
sshFallback: `git@github.com:tamagui/tamagui.git`,
|
|
705
|
+
dir: ["code", "starters", "remix"],
|
|
706
|
+
branch: "main"
|
|
707
|
+
},
|
|
708
|
+
extraSteps: remix_default
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
title: `Next + Expo - Production ready monorepo`,
|
|
471
712
|
value: "starter-free",
|
|
472
713
|
type: "free",
|
|
473
|
-
hidden:
|
|
714
|
+
hidden: false,
|
|
474
715
|
packageManager: "yarn",
|
|
475
716
|
repo: {
|
|
476
|
-
url: process.env.STARTER_FREE_REPO_SOURCE ||
|
|
477
|
-
sshFallback:
|
|
717
|
+
url: process.env.STARTER_FREE_REPO_SOURCE || `https://github.com/tamagui/starter-free.git`,
|
|
718
|
+
sshFallback: `git@github.com:tamagui/starter-free.git`,
|
|
478
719
|
dir: [],
|
|
479
720
|
branch: "main"
|
|
480
721
|
},
|
|
@@ -483,30 +724,54 @@ var templates = [
|
|
|
483
724
|
];
|
|
484
725
|
|
|
485
726
|
// src/helpers/getTemplateInfo.ts
|
|
486
|
-
var validTemplates = templates.map(({ value }) => value).join(", ")
|
|
727
|
+
var validTemplates = templates.map(({ value }) => value).join(", ");
|
|
728
|
+
var getTemplateInfo = async (template) => {
|
|
487
729
|
let res = getValidTemplate(template);
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
730
|
+
if (template && !res) {
|
|
731
|
+
console.warn(`template ${template} is not valid. valid options: ${validTemplates}`);
|
|
732
|
+
process.exit(1);
|
|
733
|
+
}
|
|
734
|
+
if (!res) {
|
|
735
|
+
template = (await (0, import_prompts3.default)({
|
|
736
|
+
name: "template",
|
|
737
|
+
type: "select",
|
|
738
|
+
message: `Pick a template:`,
|
|
739
|
+
choices: templates.filter((t) => !t.hidden)
|
|
740
|
+
})).template;
|
|
741
|
+
}
|
|
742
|
+
res = getValidTemplate(`${template}`);
|
|
743
|
+
if (!res) {
|
|
744
|
+
console.warn(`template ${template} is not valid. valid options: ${validTemplates}`);
|
|
745
|
+
process.exit(1);
|
|
746
|
+
}
|
|
747
|
+
return res;
|
|
748
|
+
};
|
|
749
|
+
var getValidTemplate = (template) => typeof template === "string" && templates.find(({ value }) => value === template);
|
|
495
750
|
|
|
496
751
|
// src/helpers/installDependencies.ts
|
|
497
752
|
var PackageManager = __toESM(require("@expo/package-manager"));
|
|
498
|
-
async function installDependencies(projectRoot,
|
|
753
|
+
async function installDependencies(projectRoot, packageManager4) {
|
|
499
754
|
if (process.env.VITEST) {
|
|
500
755
|
console.warn("Skipping dependency installation because Vitest 2 is running.");
|
|
501
756
|
return;
|
|
502
757
|
}
|
|
503
|
-
|
|
504
|
-
|
|
758
|
+
const options = { cwd: projectRoot };
|
|
759
|
+
if (packageManager4 === "yarn") {
|
|
760
|
+
await new PackageManager.YarnPackageManager(options).installAsync();
|
|
761
|
+
} else if (packageManager4 === "pnpm") {
|
|
762
|
+
await new PackageManager.PnpmPackageManager(options).installAsync();
|
|
763
|
+
} else if (packageManager4 === "bun") {
|
|
764
|
+
await new PackageManager.BunPackageManager(options).installAsync();
|
|
765
|
+
} else {
|
|
766
|
+
await new PackageManager.NpmPackageManager(options).installAsync();
|
|
767
|
+
}
|
|
505
768
|
}
|
|
506
769
|
|
|
507
770
|
// src/index.ts
|
|
508
771
|
var projectPath = "";
|
|
509
|
-
|
|
772
|
+
if (IS_TEST) {
|
|
773
|
+
console.info(`\u{1F9D0} Running create-tamagui in test mode \u{1F9D0}`);
|
|
774
|
+
}
|
|
510
775
|
function exit() {
|
|
511
776
|
process.exit(0);
|
|
512
777
|
}
|
|
@@ -514,93 +779,147 @@ process.on("SIGTERM", exit);
|
|
|
514
779
|
process.on("SIGINT", exit);
|
|
515
780
|
var program = new import_commander.default.Command(package_default.name).version(package_default.version).arguments("<project-directory>").action((name) => {
|
|
516
781
|
projectPath = name;
|
|
517
|
-
}).option(
|
|
518
|
-
|
|
782
|
+
}).option(`--info`, "Just shows the setup guide for the starter.").option(
|
|
783
|
+
`--template <template>, -t <template>`,
|
|
519
784
|
"Choose between four or more starter templates.",
|
|
520
785
|
""
|
|
521
786
|
).allowUnknownOption().usage(
|
|
522
|
-
`${
|
|
787
|
+
`${import_chalk10.default.green("<project-directory>")} [options]
|
|
523
788
|
|
|
524
789
|
Example usage:
|
|
525
790
|
|
|
526
|
-
${
|
|
791
|
+
${import_chalk10.default.blueBright(`npx ${package_default.name} next-expo`)}`
|
|
527
792
|
).parse(process.argv);
|
|
528
|
-
process.argv.includes("--version")
|
|
793
|
+
if (process.argv.includes("--version")) {
|
|
794
|
+
console.info(package_default.version);
|
|
795
|
+
process.exit(0);
|
|
796
|
+
}
|
|
529
797
|
var info = !!program.info;
|
|
530
798
|
async function run() {
|
|
531
799
|
try {
|
|
532
800
|
if (info) {
|
|
533
801
|
let template2 = await getTemplateInfo(program.template);
|
|
534
|
-
template2?.extraSteps
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
802
|
+
if (template2?.extraSteps) {
|
|
803
|
+
await template2.extraSteps({
|
|
804
|
+
isFullClone: false,
|
|
805
|
+
projectName: import_node_path4.default.basename((0, import_node_process.cwd)()),
|
|
806
|
+
projectPath: (0, import_node_process.cwd)()
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
process.exit(0);
|
|
539
810
|
}
|
|
540
|
-
console.info()
|
|
541
|
-
|
|
811
|
+
console.info();
|
|
812
|
+
console.info(
|
|
813
|
+
import_chalk10.default.bold(
|
|
542
814
|
' Note: You may need to run "npm create tamagui@latest" to get the latest version!'
|
|
543
815
|
)
|
|
544
|
-
)
|
|
545
|
-
|
|
546
|
-
|
|
816
|
+
);
|
|
817
|
+
console.info();
|
|
818
|
+
console.info();
|
|
819
|
+
console.info(tamaguiRainbowAsciiArt);
|
|
820
|
+
console.info(import_chalk10.default.bold("Creating tamagui app..."));
|
|
821
|
+
const gitVersionString = Number.parseFloat(
|
|
822
|
+
(0, import_node_child_process3.execSync)(`git --version`).toString().replace(`git version `, "").trim()
|
|
823
|
+
);
|
|
824
|
+
if (gitVersionString < 2.27) {
|
|
825
|
+
console.error(`
|
|
547
826
|
|
|
548
827
|
\u26A0\uFE0F Tamagui can't install: Git version must be >= 2.27
|
|
549
828
|
|
|
550
|
-
`)
|
|
829
|
+
`);
|
|
830
|
+
process.exit(1);
|
|
831
|
+
}
|
|
832
|
+
projectPath || (projectPath = await getProjectName(projectPath));
|
|
551
833
|
let template = await getTemplateInfo(program.template);
|
|
552
|
-
template.type === "premium"
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
834
|
+
if (template.type === "premium") {
|
|
835
|
+
const didPurchase = (await (0, import_prompts4.default)({
|
|
836
|
+
type: "confirm",
|
|
837
|
+
name: "purchased",
|
|
838
|
+
message: `Have you purchased Takeout on https://tamagui.dev/takeout`
|
|
839
|
+
})).purchased;
|
|
840
|
+
if (!didPurchase) {
|
|
841
|
+
(0, import_opener.default)(`https://tamagui.dev/takeout`);
|
|
842
|
+
console.info(
|
|
843
|
+
`
|
|
558
844
|
Opening Takeout website - once you purchase you can restart the create process. Thank you!
|
|
559
845
|
`
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
846
|
+
);
|
|
847
|
+
process.exit(0);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
console.info();
|
|
851
|
+
const resolvedProjectPath = import_node_path4.default.resolve(process.cwd(), projectPath);
|
|
852
|
+
const projectName = import_node_path4.default.basename(resolvedProjectPath);
|
|
853
|
+
const { valid, problems } = validateNpmName(projectName);
|
|
854
|
+
if (!valid) {
|
|
855
|
+
console.error(
|
|
856
|
+
`Could not create a project called ${import_chalk10.default.red(
|
|
857
|
+
`"${projectName}"`
|
|
858
|
+
)} because of npm naming restrictions:`
|
|
859
|
+
);
|
|
860
|
+
problems.forEach((p) => console.error(` ${import_chalk10.default.red.bold("*")} ${p}`));
|
|
861
|
+
process.exit(1);
|
|
862
|
+
}
|
|
863
|
+
if (import_node_fs3.default.existsSync(resolvedProjectPath)) {
|
|
864
|
+
console.info();
|
|
865
|
+
console.info(
|
|
866
|
+
import_chalk10.default.red("\u{1F6A8} [tamagui] error"),
|
|
867
|
+
`You tried to make a project called ${import_chalk10.default.underline(
|
|
868
|
+
import_chalk10.default.blueBright(projectName)
|
|
869
|
+
)}, but a folder with that name already exists: ${import_chalk10.default.blueBright(
|
|
870
|
+
resolvedProjectPath
|
|
871
|
+
)}
|
|
872
|
+
|
|
873
|
+
${import_chalk10.default.bold(import_chalk10.default.red(`Please pick a different project name \u{1F978}`))}`
|
|
874
|
+
);
|
|
875
|
+
console.info();
|
|
876
|
+
console.info();
|
|
877
|
+
process.exit(1);
|
|
878
|
+
}
|
|
879
|
+
console.info();
|
|
880
|
+
console.info(`Creating a new tamagui app ${import_chalk10.default.blueBright(resolvedProjectPath)}...`);
|
|
881
|
+
import_node_fs3.default.mkdirSync(resolvedProjectPath);
|
|
882
|
+
console.info(import_chalk10.default.green(`${projectName} folder created.`));
|
|
576
883
|
try {
|
|
577
|
-
await cloneStarter(template, resolvedProjectPath, projectName)
|
|
884
|
+
await cloneStarter(template, resolvedProjectPath, projectName);
|
|
885
|
+
process.chdir(resolvedProjectPath);
|
|
886
|
+
console.info();
|
|
578
887
|
} catch (e) {
|
|
579
888
|
console.error(`[tamagui] Failed to copy example into ${resolvedProjectPath}
|
|
580
889
|
|
|
581
|
-
`, e)
|
|
890
|
+
`, e);
|
|
891
|
+
process.exit(1);
|
|
582
892
|
}
|
|
583
|
-
updatePackageJsonName(projectName, resolvedProjectPath)
|
|
584
|
-
|
|
893
|
+
updatePackageJsonName(projectName, resolvedProjectPath);
|
|
894
|
+
console.info("Installing packages. This might take a couple of minutes.");
|
|
895
|
+
console.info();
|
|
896
|
+
const packageManager4 = ("packageManager" in template ? template.packageManager : void 0) || await (0, import_detect_package_manager.detect)();
|
|
585
897
|
try {
|
|
586
|
-
console.info("installing with " +
|
|
898
|
+
console.info("installing with " + packageManager4);
|
|
899
|
+
await installDependencies(resolvedProjectPath, packageManager4);
|
|
587
900
|
} catch (e) {
|
|
588
|
-
console.error("[tamagui] error installing with " +
|
|
589
|
-
${e}`)
|
|
901
|
+
console.error("[tamagui] error installing with " + packageManager4 + `
|
|
902
|
+
${e}`);
|
|
903
|
+
process.exit(1);
|
|
590
904
|
}
|
|
591
905
|
await template?.extraSteps?.({
|
|
592
|
-
isFullClone:
|
|
906
|
+
isFullClone: true,
|
|
593
907
|
projectName,
|
|
594
908
|
projectPath: resolvedProjectPath
|
|
595
|
-
})
|
|
909
|
+
});
|
|
910
|
+
console.info();
|
|
911
|
+
console.info(import_chalk10.default.gray(tamaguiDuckAsciiArt));
|
|
912
|
+
process.exit(0);
|
|
596
913
|
} catch (error) {
|
|
597
|
-
console.error("An unexpected error occurred:", error)
|
|
914
|
+
console.error("An unexpected error occurred:", error);
|
|
915
|
+
process.exit(1);
|
|
598
916
|
}
|
|
599
917
|
}
|
|
600
918
|
function updatePackageJsonName(projectName, dir) {
|
|
601
|
-
|
|
919
|
+
const packageJsonPath = import_node_path4.default.join(dir, "package.json");
|
|
602
920
|
if ((0, import_fs_extra2.existsSync)(packageJsonPath)) {
|
|
603
|
-
|
|
921
|
+
const content = (0, import_fs_extra2.readFileSync)(packageJsonPath).toString();
|
|
922
|
+
const contentWithUpdatedName = content.replace(
|
|
604
923
|
/("name": ")(.*)(",)/,
|
|
605
924
|
`$1${projectName}$3`
|
|
606
925
|
);
|
|
@@ -608,6 +927,7 @@ function updatePackageJsonName(projectName, dir) {
|
|
|
608
927
|
}
|
|
609
928
|
}
|
|
610
929
|
run().catch((error) => {
|
|
611
|
-
console.error("An unexpected error occurred:", error)
|
|
930
|
+
console.error("An unexpected error occurred:", error);
|
|
931
|
+
process.exit(1);
|
|
612
932
|
});
|
|
613
933
|
//# sourceMappingURL=index.js.map
|