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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tamagui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"bin": "./run.js",
|
|
6
6
|
"files": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"test-disabled": "NODE_ENV=test node -r esbuild-register ../../../node_modules/.bin/playwright test integration.test.ts",
|
|
19
19
|
"test:debug": "bun run test --debug",
|
|
20
20
|
"test": "bun run build:test && vitest run",
|
|
21
|
+
"test:web": "bun run test",
|
|
21
22
|
"build:test": "bun run build",
|
|
22
23
|
"prerelease": "rimraf ./dist/",
|
|
23
24
|
"prepublish": "bun run build",
|
|
@@ -35,12 +36,11 @@
|
|
|
35
36
|
"opener": "^1.5.2",
|
|
36
37
|
"prompts": "2.1.0",
|
|
37
38
|
"rimraf": "^5.0.1",
|
|
38
|
-
"validate-npm-package-name": "3.0.0"
|
|
39
|
-
"zx": "^8.5.5"
|
|
39
|
+
"validate-npm-package-name": "3.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@playwright/test": "^1.49.1",
|
|
43
|
-
"@tamagui/build": "2.
|
|
43
|
+
"@tamagui/build": "2.1.0",
|
|
44
44
|
"@types/async-retry": "1.4.2",
|
|
45
45
|
"@types/cross-spawn": "^6.0.2",
|
|
46
46
|
"@types/node": "^22.1.0",
|
package/dist/index.js
DELETED
|
@@ -1,612 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
9
|
-
for (let key of __getOwnPropNames(from))
|
|
10
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
14
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
15
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
16
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
17
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
18
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
19
|
-
mod
|
|
20
|
-
));
|
|
21
|
-
|
|
22
|
-
// src/index.ts
|
|
23
|
-
var import_node_child_process3 = require("node:child_process"), import_node_fs2 = __toESM(require("node:fs")), import_node_path4 = __toESM(require("node:path")), import_node_process = require("node:process"), import_chalk8 = __toESM(require("chalk")), import_commander = __toESM(require("commander")), import_detect_package_manager = require("detect-package-manager"), import_fs_extra2 = require("fs-extra"), import_opener = __toESM(require("opener")), import_prompts4 = __toESM(require("prompts")), import_zx2 = require("zx");
|
|
24
|
-
|
|
25
|
-
// package.json
|
|
26
|
-
var package_default = {
|
|
27
|
-
name: "create-tamagui",
|
|
28
|
-
version: "2.0.0-rc.8",
|
|
29
|
-
gitHead: "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
30
|
-
bin: "./run.js",
|
|
31
|
-
files: [
|
|
32
|
-
"run.js",
|
|
33
|
-
"dist"
|
|
34
|
-
],
|
|
35
|
-
sideEffects: !1,
|
|
36
|
-
main: "dist/index.cjs",
|
|
37
|
-
publishConfig: {
|
|
38
|
-
access: "public"
|
|
39
|
-
},
|
|
40
|
-
scripts: {
|
|
41
|
-
start: "./run.js",
|
|
42
|
-
"//": "disabling for now need to migrate to new stack",
|
|
43
|
-
"test-disabled": "NODE_ENV=test node -r esbuild-register ../../../node_modules/.bin/playwright test integration.test.ts",
|
|
44
|
-
"test:debug": "bun run test --debug",
|
|
45
|
-
test: "bun run build:test && vitest run",
|
|
46
|
-
"build:test": "bun run build",
|
|
47
|
-
prerelease: "rimraf ./dist/",
|
|
48
|
-
prepublish: "bun run build",
|
|
49
|
-
build: "tamagui-build --skip-types --bundle",
|
|
50
|
-
watch: "bun run build --watch",
|
|
51
|
-
clean: "tamagui-build clean",
|
|
52
|
-
"clean:build": "tamagui-build clean:build"
|
|
53
|
-
},
|
|
54
|
-
dependencies: {
|
|
55
|
-
"@expo/package-manager": "^1.1.2",
|
|
56
|
-
chalk: "^4.1.2",
|
|
57
|
-
commander: "2.20.0",
|
|
58
|
-
"detect-package-manager": "^3.0.1",
|
|
59
|
-
"fs-extra": "^11.2.0",
|
|
60
|
-
opener: "^1.5.2",
|
|
61
|
-
prompts: "2.1.0",
|
|
62
|
-
rimraf: "^5.0.1",
|
|
63
|
-
"validate-npm-package-name": "3.0.0",
|
|
64
|
-
zx: "^8.5.5"
|
|
65
|
-
},
|
|
66
|
-
devDependencies: {
|
|
67
|
-
"@playwright/test": "^1.49.1",
|
|
68
|
-
"@tamagui/build": "workspace:*",
|
|
69
|
-
"@types/async-retry": "1.4.2",
|
|
70
|
-
"@types/cross-spawn": "^6.0.2",
|
|
71
|
-
"@types/node": "^22.1.0",
|
|
72
|
-
"@types/opener": "^1.4.3",
|
|
73
|
-
"@types/prompts": "2.0.1",
|
|
74
|
-
"@types/rimraf": "3.0.0",
|
|
75
|
-
"@types/tar": "4.0.3",
|
|
76
|
-
"@types/validate-npm-package-name": "3.0.0",
|
|
77
|
-
"async-retry": "1.3.1",
|
|
78
|
-
cpy: "7.3.0",
|
|
79
|
-
"cross-spawn": "6.0.5",
|
|
80
|
-
"esbuild-register": "^3.6.0",
|
|
81
|
-
got: "10.7.0",
|
|
82
|
-
tar: "4.4.10",
|
|
83
|
-
tempy: "^3.1.0",
|
|
84
|
-
"update-check": "1.5.4",
|
|
85
|
-
vitest: "4.0.4",
|
|
86
|
-
"wait-port": "^0.3.0"
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// src/create-tamagui-constants.ts
|
|
91
|
-
var IS_TEST = process.env.NODE_ENV === "test";
|
|
92
|
-
|
|
93
|
-
// src/helpers/asciiArts.ts
|
|
94
|
-
var import_chalk2 = __toESM(require("chalk"));
|
|
95
|
-
|
|
96
|
-
// src/helpers/rainbowChalk.ts
|
|
97
|
-
var import_chalk = __toESM(require("chalk")), rainbowColors = [
|
|
98
|
-
"#f76808",
|
|
99
|
-
"#f5d90a",
|
|
100
|
-
"#30a46c",
|
|
101
|
-
"#0091ff",
|
|
102
|
-
"#8e4ec6",
|
|
103
|
-
"#d6409f",
|
|
104
|
-
"#e5484d"
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
// src/helpers/asciiArts.ts
|
|
108
|
-
var tamaguiRainbowAsciiArt = (function() {
|
|
109
|
-
let char0_1 = import_chalk2.default.hex(rainbowColors[0])("\u2580\u2588\u2580"), char0_2 = import_chalk2.default.hex(rainbowColors[0])(" \u2588 "), char1_1 = import_chalk2.default.hex(rainbowColors[1])("\u2584\u2580\u2588"), char1_2 = import_chalk2.default.hex(rainbowColors[1])("\u2588\u2580\u2588"), char2_1 = import_chalk2.default.hex(rainbowColors[2])("\u2588\u2580\u2584\u2580\u2588"), char2_2 = import_chalk2.default.hex(rainbowColors[2])("\u2588 \u2580 \u2588"), char3_1 = import_chalk2.default.hex(rainbowColors[3])("\u2584\u2580\u2588"), char3_2 = import_chalk2.default.hex(rainbowColors[3])("\u2588\u2580\u2588"), char4_1 = import_chalk2.default.hex(rainbowColors[4])("\u2588\u2580\u2580"), char4_2 = import_chalk2.default.hex(rainbowColors[4])("\u2588\u2584\u2588"), char5_1 = import_chalk2.default.hex(rainbowColors[5])("\u2588 \u2588"), char5_2 = import_chalk2.default.hex(rainbowColors[5])("\u2588\u2584\u2588"), char6_1 = import_chalk2.default.hex(rainbowColors[6])("\u2588"), char6_2 = import_chalk2.default.hex(rainbowColors[6])("\u2588");
|
|
110
|
-
return `${char0_1}\u2003${char1_1}\u2003${char2_1}\u2003${char3_1}\u2003${char4_1}\u2003${char5_1}\u2003${char6_1}
|
|
111
|
-
${char0_2}\u2003${char1_2}\u2003${char2_2}\u2003${char3_2}\u2003${char4_2}\u2003${char5_2}\u2003${char6_2}
|
|
112
|
-
`;
|
|
113
|
-
})(), 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
|
|
114
|
-
\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
|
|
115
|
-
\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
|
|
116
|
-
\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
|
|
117
|
-
\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
|
|
118
|
-
\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`, tamaguiDuckAsciiArt = ` \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588
|
|
119
|
-
\u2588\u2588 \u2588\u2588
|
|
120
|
-
\u2588\u2588 \u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588
|
|
121
|
-
\u2588\u2588 \u2588\u2588 \u2588\u2588
|
|
122
|
-
\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588
|
|
123
|
-
\u2588\u2588 \u2588\u2588
|
|
124
|
-
\u2588\u2588 \u2588\u2588\u2588\u2588
|
|
125
|
-
\u2588\u2588 \u2588\u2588
|
|
126
|
-
\u2588\u2588 \u2588\u2588 `;
|
|
127
|
-
|
|
128
|
-
// src/helpers/cloneStarter.ts
|
|
129
|
-
var import_node_child_process = require("node:child_process"), import_node_os = require("node:os"), import_node_path = require("node:path"), import_chalk3 = __toESM(require("chalk")), import_fs_extra = require("fs-extra"), import_rimraf = require("rimraf"), import_zx = require("zx"), open = require("opener"), exec = (cmd, options) => (console.info("$ ", cmd), (0, import_node_child_process.execSync)(cmd, {
|
|
130
|
-
stdio: process.env.DEBUG ? "inherit" : "ignore",
|
|
131
|
-
...options
|
|
132
|
-
})), tamaguiDir = (0, import_node_path.join)((0, import_node_os.homedir)(), ".tamagui-repo-cache"), targetGitDir = "", cloneStarter = async (template, resolvedProjectPath, projectName) => {
|
|
133
|
-
targetGitDir = (0, import_node_path.join)(tamaguiDir, "tamagui", template.repo.url.split("/").at(-1)), console.info(), await setupTamaguiDotDir(template);
|
|
134
|
-
let starterDir = (0, import_node_path.join)(targetGitDir, ...template.repo.dir);
|
|
135
|
-
console.info(), console.info(
|
|
136
|
-
`Copying starter from ${starterDir} into ${import_chalk3.default.blueBright(projectName)}...`
|
|
137
|
-
), console.info(), await (0, import_fs_extra.copy)(starterDir, resolvedProjectPath), await (0, import_rimraf.rimraf)(`${resolvedProjectPath}/.git`), console.info(import_chalk3.default.green(`${projectName} created!`)), console.info();
|
|
138
|
-
};
|
|
139
|
-
async function setupTamaguiDotDir(template) {
|
|
140
|
-
if (console.info(`Setting up ${import_chalk3.default.blueBright(targetGitDir)}...`), process.env.GITHUB_HEAD_REF)
|
|
141
|
-
try {
|
|
142
|
-
await import_zx.$`cd ${targetGitDir} && git switch -c ${process.env.GITHUB_HEAD_REF}`;
|
|
143
|
-
} catch {
|
|
144
|
-
}
|
|
145
|
-
let branch = template.repo.branch;
|
|
146
|
-
await (0, import_fs_extra.ensureDir)(tamaguiDir), (0, import_zx.cd)(tamaguiDir);
|
|
147
|
-
let isInSubDir = template.repo.dir.length > 0, sourceGitRepo = template.repo.url, sourceGitRepoSshFallback = template.repo.sshFallback;
|
|
148
|
-
if (await (0, import_fs_extra.pathExists)(targetGitDir))
|
|
149
|
-
await (0, import_fs_extra.pathExists)((0, import_node_path.join)(targetGitDir, ".git")) || (console.error(`Corrupt Tamagui directory, please delete ${targetGitDir} and re-run`), process.exit(1));
|
|
150
|
-
else {
|
|
151
|
-
console.info("Cloning tamagui base directory"), console.info();
|
|
152
|
-
let cmd = `git clone --branch ${branch} ${isInSubDir ? "--depth 1 --sparse --filter=blob:none " : ""}${sourceGitRepo} "${targetGitDir}"`;
|
|
153
|
-
try {
|
|
154
|
-
try {
|
|
155
|
-
console.info(`$ ${cmd}`), console.info(), exec(cmd);
|
|
156
|
-
} catch (error) {
|
|
157
|
-
if (cmd.includes("https://")) {
|
|
158
|
-
console.info("https failed - trying with ssh now...");
|
|
159
|
-
let sshCmd = cmd.replace(sourceGitRepo, sourceGitRepoSshFallback);
|
|
160
|
-
console.info(`$ ${sshCmd}`), console.info(), exec(sshCmd);
|
|
161
|
-
} else
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
} catch (error) {
|
|
165
|
-
throw error instanceof Error && (template.value === "takeout-pro" || template.value === "takeout-pro-classic") && error?.stderr?.includes("Repository not found") && (console.info(
|
|
166
|
-
import_chalk3.default.yellow(
|
|
167
|
-
"You don't have access to this starter. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info."
|
|
168
|
-
)
|
|
169
|
-
), open("https://tamagui.dev/takeout"), process.exit(0)), error;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
isInSubDir && (exec("git sparse-checkout set code/starters", { cwd: targetGitDir }), console.info());
|
|
173
|
-
try {
|
|
174
|
-
let remoteName = getDefaultRemoteName();
|
|
175
|
-
if (await (0, import_fs_extra.pathExists)((0, import_node_path.join)(targetGitDir, ".git"))) {
|
|
176
|
-
let cmd2 = `git pull --rebase --allow-unrelated-histories --depth 1 ${remoteName} ${branch}`;
|
|
177
|
-
try {
|
|
178
|
-
exec(cmd2, {
|
|
179
|
-
cwd: targetGitDir
|
|
180
|
-
});
|
|
181
|
-
} catch {
|
|
182
|
-
exec(cmd2, {
|
|
183
|
-
cwd: targetGitDir
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
console.info();
|
|
187
|
-
} else
|
|
188
|
-
console.warn(
|
|
189
|
-
`Warning: ${targetGitDir} is not a git repository. Skipping pull operation.`
|
|
190
|
-
);
|
|
191
|
-
} catch (err) {
|
|
192
|
-
await (0, import_fs_extra.remove)(targetGitDir), console.info(`Error updating: ${err.message} ${err.stack}`), console.info(
|
|
193
|
-
"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="
|
|
194
|
-
), process.exit(1);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
var getDefaultRemoteName = () => {
|
|
198
|
-
try {
|
|
199
|
-
return (0, import_fs_extra.pathExists)((0, import_node_path.join)(targetGitDir, ".git")) ? (0, import_node_child_process.execSync)("git remote", { cwd: targetGitDir }).toString().trim().split(`
|
|
200
|
-
`)[0] || "origin" : (console.warn(
|
|
201
|
-
'Warning: Not in a git repository. Using default remote name "origin".'
|
|
202
|
-
), "origin");
|
|
203
|
-
} catch (error) {
|
|
204
|
-
return console.warn("Error getting default remote name:", error), console.warn('Using default remote name "origin".'), "origin";
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// src/helpers/getProjectName.ts
|
|
209
|
-
var import_node_path2 = __toESM(require("node:path")), import_chalk4 = __toESM(require("chalk")), import_prompts = __toESM(require("prompts"));
|
|
210
|
-
|
|
211
|
-
// src/helpers/validateNpmPackage.ts
|
|
212
|
-
var import_validate_npm_package_name = __toESM(require("validate-npm-package-name"));
|
|
213
|
-
function validateNpmName(name) {
|
|
214
|
-
let nameValidation = (0, import_validate_npm_package_name.default)(name);
|
|
215
|
-
return nameValidation.validForNewPackages ? { valid: !0 } : {
|
|
216
|
-
valid: !1,
|
|
217
|
-
problems: [...nameValidation.errors || [], ...nameValidation.warnings || []]
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// src/helpers/getProjectName.ts
|
|
222
|
-
var getProjectName = async (projectPath2) => {
|
|
223
|
-
if (typeof projectPath2 == "string" && (projectPath2 = projectPath2.trim()), !projectPath2) {
|
|
224
|
-
let res = await (0, import_prompts.default)({
|
|
225
|
-
type: "text",
|
|
226
|
-
name: "path",
|
|
227
|
-
message: "Project name:",
|
|
228
|
-
initial: "myapp",
|
|
229
|
-
validate: (name) => {
|
|
230
|
-
let validation = validateNpmName(import_node_path2.default.basename(import_node_path2.default.resolve(name)));
|
|
231
|
-
return validation.valid ? !0 : "Invalid project name: " + validation.problems[0];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
typeof res.path == "string" && (projectPath2 = res.path.trim());
|
|
235
|
-
}
|
|
236
|
-
return projectPath2 || (console.info(), console.info("Please specify the project directory:"), console.info(
|
|
237
|
-
` ${import_chalk4.default.cyan(package_default.name)} ${import_chalk4.default.green("<project-directory>")}`
|
|
238
|
-
), 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;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
// src/helpers/getTemplateInfo.ts
|
|
242
|
-
var import_prompts3 = __toESM(require("prompts"));
|
|
243
|
-
|
|
244
|
-
// src/templates.ts
|
|
245
|
-
var import_chalk7 = __toESM(require("chalk"));
|
|
246
|
-
|
|
247
|
-
// src/steps/starter-free.ts
|
|
248
|
-
var import_chalk5 = __toESM(require("chalk")), packageManager = "bun", runCommand = (scriptName) => `${packageManager} run ${scriptName}`, main = async ({ isFullClone, projectName }) => {
|
|
249
|
-
console.info("Note: you need bun for this repo."), isFullClone && console.info(`${import_chalk5.default.green.bold(
|
|
250
|
-
"Done!"
|
|
251
|
-
)} created a new project under ./${projectName}
|
|
252
|
-
|
|
253
|
-
visit your project:
|
|
254
|
-
${import_chalk5.default.green("cd")} ${projectName}
|
|
255
|
-
`), console.info(`
|
|
256
|
-
To start the Next.js development server, run:
|
|
257
|
-
${import_chalk5.default.green(runCommand("web"))}
|
|
258
|
-
|
|
259
|
-
To start Expo Go for mobile development, run:
|
|
260
|
-
${import_chalk5.default.green(runCommand("native"))}
|
|
261
|
-
|
|
262
|
-
You can also create Expo development builds by doing:
|
|
263
|
-
|
|
264
|
-
${import_chalk5.default.green("cd apps/expo")}
|
|
265
|
-
then:
|
|
266
|
-
${import_chalk5.default.green(runCommand("ios"))}
|
|
267
|
-
or...
|
|
268
|
-
${import_chalk5.default.green(runCommand("android"))}
|
|
269
|
-
|
|
270
|
-
Be sure to replace yourprojectsname in app.json with the uid you'd like for your app.
|
|
271
|
-
`);
|
|
272
|
-
}, starter_free_default = main;
|
|
273
|
-
|
|
274
|
-
// src/steps/takeout.ts
|
|
275
|
-
var import_node_child_process2 = require("node:child_process"), import_node_fs = require("node:fs"), import_promises = __toESM(require("node:fs/promises")), import_node_path3 = __toESM(require("node:path")), import_chalk6 = __toESM(require("chalk")), import_prompts2 = __toESM(require("prompts"));
|
|
276
|
-
var packageManager2 = "bun", runCommand2 = (scriptName) => `${packageManager2} run ${scriptName}`, main2 = async ({ isFullClone, projectName, projectPath: projectPath2 }) => {
|
|
277
|
-
console.info(`
|
|
278
|
-
${tamaguiRainbowAsciiArt.split(`
|
|
279
|
-
`).map((line) => ` ${line}`).join(`
|
|
280
|
-
`)}
|
|
281
|
-
${takeoutAsciiArt}
|
|
282
|
-
|
|
283
|
-
`), console.info();
|
|
284
|
-
let { setupSupabase } = await (0, import_prompts2.default)({
|
|
285
|
-
name: "setupSupabase",
|
|
286
|
-
message: "Set up Supabase?",
|
|
287
|
-
type: "confirm",
|
|
288
|
-
initial: !0
|
|
289
|
-
});
|
|
290
|
-
if (setupSupabase) {
|
|
291
|
-
console.info();
|
|
292
|
-
let { startLocalSupabase } = await (0, import_prompts2.default)({
|
|
293
|
-
name: "startLocalSupabase",
|
|
294
|
-
type: "confirm",
|
|
295
|
-
message: "Start local Supabase instance for you? (Requires Docker)",
|
|
296
|
-
initial: !0
|
|
297
|
-
});
|
|
298
|
-
if (startLocalSupabase && await runRetryableCommand("bun run supa start")) {
|
|
299
|
-
console.info();
|
|
300
|
-
let { setUpSupabaseEnv } = await (0, import_prompts2.default)({
|
|
301
|
-
name: "setUpSupabaseEnv",
|
|
302
|
-
type: "confirm",
|
|
303
|
-
message: "Do you want us to add the local env variables for you? This will create a file called .env.local.",
|
|
304
|
-
initial: !0
|
|
305
|
-
});
|
|
306
|
-
if (setUpSupabaseEnv) {
|
|
307
|
-
let envs = getEnvFromSupabaseStatus(
|
|
308
|
-
(0, import_node_child_process2.execSync)("bun run supa status").toString()
|
|
309
|
-
), newEnvContent = Object.entries(envs).map(([key, value]) => `${key}=${value}`).join(`
|
|
310
|
-
`);
|
|
311
|
-
(0, import_node_fs.existsSync)(import_node_path3.default.join(projectPath2, ".env.local")) && (0, import_node_fs.readFileSync)(import_node_path3.default.join(projectPath2, ".env.local")).toString() !== newEnvContent && (0, import_node_fs.renameSync)(
|
|
312
|
-
import_node_path3.default.join(projectPath2, ".env.local"),
|
|
313
|
-
import_node_path3.default.join(projectPath2, `.env.local.old-${Number(/* @__PURE__ */ new Date())}`)
|
|
314
|
-
), await import_promises.default.writeFile(import_node_path3.default.join(projectPath2, "./.env.local"), newEnvContent);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
console.info();
|
|
318
|
-
let { setupRemoteSupabase } = await (0, import_prompts2.default)({
|
|
319
|
-
name: "setupRemoteSupabase",
|
|
320
|
-
type: "confirm",
|
|
321
|
-
message: "Link remote Supabase instance for you? (Create a project on https://app.supabase.com/projects first)",
|
|
322
|
-
initial: !0
|
|
323
|
-
});
|
|
324
|
-
setupRemoteSupabase && (await runRetryableCommand("npx supabase login"), console.info(), await linkSupabase());
|
|
325
|
-
}
|
|
326
|
-
isFullClone && console.info(`
|
|
327
|
-
${import_chalk6.default.green.bold("Done!")} created a new project under ./${projectName}
|
|
328
|
-
|
|
329
|
-
visit your project:
|
|
330
|
-
${import_chalk6.default.green(" cd")} ${projectName}
|
|
331
|
-
`), console.info(`
|
|
332
|
-
To start the Next.js development server, run:
|
|
333
|
-
${import_chalk6.default.green(runCommand2("web"))}
|
|
334
|
-
|
|
335
|
-
To start developing with Expo for native, run:
|
|
336
|
-
${import_chalk6.default.green(runCommand2("native"))}
|
|
337
|
-
|
|
338
|
-
To start developing for Expo dev build, run:
|
|
339
|
-
${import_chalk6.default.green(runCommand2("ios"))}
|
|
340
|
-
${import_chalk6.default.green(runCommand2("android"))}
|
|
341
|
-
|
|
342
|
-
To run Supabase scripts, cd into the supabase package:
|
|
343
|
-
${import_chalk6.default.green("cd supabase")}
|
|
344
|
-
|
|
345
|
-
${import_chalk6.default.green("yarn reset")} - Resets local database
|
|
346
|
-
${import_chalk6.default.green("yarn generate")} - Generates new types
|
|
347
|
-
|
|
348
|
-
Find info on the rest of the scripts in ${import_chalk6.default.cyan("supabase/README.md")}
|
|
349
|
-
|
|
350
|
-
If you've purchased and gained access to font and icon packages, you can run:
|
|
351
|
-
${import_chalk6.default.green("yarn add:icon")}
|
|
352
|
-
${import_chalk6.default.green("yarn add:font")}
|
|
353
|
-
`);
|
|
354
|
-
}, takeout_default = main2;
|
|
355
|
-
async function runRetryableCommand(cmd, retriesCount = 0) {
|
|
356
|
-
try {
|
|
357
|
-
return (0, import_node_child_process2.execSync)(cmd, { stdio: "inherit" }), !0;
|
|
358
|
-
} catch {
|
|
359
|
-
let { tryAgain } = await (0, import_prompts2.default)({
|
|
360
|
-
name: "tryAgain",
|
|
361
|
-
message: "An error occurred. Do you want to try again?",
|
|
362
|
-
type: "confirm",
|
|
363
|
-
initial: !0
|
|
364
|
-
});
|
|
365
|
-
if (tryAgain)
|
|
366
|
-
await runRetryableCommand(cmd, retriesCount + 1);
|
|
367
|
-
else
|
|
368
|
-
return console.info(
|
|
369
|
-
import_chalk6.default.yellow(
|
|
370
|
-
`\u26A0\uFE0F Skipping this step. You can try running this command later. The failed command was \`${import_chalk6.default.underline(
|
|
371
|
-
cmd
|
|
372
|
-
)}\`.`
|
|
373
|
-
)
|
|
374
|
-
), !1;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
async function linkSupabase() {
|
|
378
|
-
let { supabaseRefId } = await (0, import_prompts2.default)({
|
|
379
|
-
name: "supabaseRefId",
|
|
380
|
-
type: "text",
|
|
381
|
-
message: "Enter your supabase project's ID (e.g. abcdefghijklmnopqrst)",
|
|
382
|
-
initial: !0
|
|
383
|
-
}), cmd = `npx supabase link --project-ref ${supabaseRefId.trim()}`;
|
|
384
|
-
try {
|
|
385
|
-
return (0, import_node_child_process2.execSync)(cmd, {
|
|
386
|
-
stdio: "inherit"
|
|
387
|
-
}), !0;
|
|
388
|
-
} catch {
|
|
389
|
-
let { tryAgain } = await (0, import_prompts2.default)({
|
|
390
|
-
name: "tryAgain",
|
|
391
|
-
message: "An error occurred. Do you want to try again?",
|
|
392
|
-
type: "confirm",
|
|
393
|
-
initial: !0
|
|
394
|
-
});
|
|
395
|
-
if (tryAgain)
|
|
396
|
-
await linkSupabase();
|
|
397
|
-
else
|
|
398
|
-
return console.info(
|
|
399
|
-
import_chalk6.default.yellow(
|
|
400
|
-
`\u26A0\uFE0F Skipping this step. You can try running this command later. The failed command was \`${import_chalk6.default.underline(
|
|
401
|
-
cmd
|
|
402
|
-
)}\`.`
|
|
403
|
-
)
|
|
404
|
-
), !1;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
function getEnvFromSupabaseStatus(status) {
|
|
408
|
-
return {
|
|
409
|
-
NEXT_PUBLIC_SUPABASE_URL: status.match(/API URL: (.*)/)?.[1],
|
|
410
|
-
NEXT_PUBLIC_SUPABASE_GRAPHQL_URL: status.match(/GraphQL URL: (.*)/)?.[1],
|
|
411
|
-
SUPABASE_DB_URL: status.match(/DB URL: (.*)/)?.[1],
|
|
412
|
-
NEXT_PUBLIC_SUPABASE_ANON_KEY: status.match(/anon key: (.*)/)?.[1],
|
|
413
|
-
SUPABASE_SERVICE_ROLE: status.match(/service_role key: (.*)/)?.[1],
|
|
414
|
-
SUPABASE_JWT_SECRET: status.match(/JWT secret: (.*)/)?.[1]
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// src/templates.ts
|
|
419
|
-
var templates = [
|
|
420
|
-
{
|
|
421
|
-
title: `${import_chalk7.default.bold.underline(
|
|
422
|
-
`\u{1F961} ${import_chalk7.default.magenta("Takeout")} ${import_chalk7.default.green("Free")}`
|
|
423
|
-
)} - Full stack starter: https://tamagui.dev/takeout`,
|
|
424
|
-
value: "takeout-free",
|
|
425
|
-
type: "free",
|
|
426
|
-
hidden: !1,
|
|
427
|
-
packageManager: "bun",
|
|
428
|
-
repo: {
|
|
429
|
-
url: "https://github.com/tamagui/takeout-free",
|
|
430
|
-
sshFallback: "git@github.com:tamagui/takeout-free.git",
|
|
431
|
-
dir: [],
|
|
432
|
-
branch: "main"
|
|
433
|
-
},
|
|
434
|
-
extraSteps: starter_free_default
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
title: `${import_chalk7.default.bold.underline(
|
|
438
|
-
`\u{1F961} ${import_chalk7.default.magenta("Takeout")} ${import_chalk7.default.red("Pro")}`
|
|
439
|
-
)} - Full featured starter: https://tamagui.dev/takeout`,
|
|
440
|
-
value: "takeout-pro",
|
|
441
|
-
type: "premium",
|
|
442
|
-
packageManager: "yarn",
|
|
443
|
-
hidden: !1,
|
|
444
|
-
repo: {
|
|
445
|
-
url: "https://github.com/tamagui/takeout2",
|
|
446
|
-
sshFallback: "git@github.com:tamagui/takeout2.git",
|
|
447
|
-
dir: [],
|
|
448
|
-
branch: "main"
|
|
449
|
-
},
|
|
450
|
-
extraSteps: takeout_default
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
title: `${import_chalk7.default.bold.underline(
|
|
454
|
-
`\u{1F961} ${import_chalk7.default.magenta("Takeout")} ${import_chalk7.default.yellow("Pro Classic")}`
|
|
455
|
-
)} - Original Pro starter: https://tamagui.dev/takeout`,
|
|
456
|
-
value: "takeout-pro-classic",
|
|
457
|
-
type: "premium",
|
|
458
|
-
packageManager: "yarn",
|
|
459
|
-
hidden: !1,
|
|
460
|
-
repo: {
|
|
461
|
-
url: "https://github.com/tamagui/takeout",
|
|
462
|
-
sshFallback: "git@github.com:tamagui/takeout.git",
|
|
463
|
-
dir: [],
|
|
464
|
-
branch: "main"
|
|
465
|
-
},
|
|
466
|
-
extraSteps: takeout_default
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
title: "Next + Expo - Production ready monorepo",
|
|
470
|
-
value: "starter-free",
|
|
471
|
-
type: "free",
|
|
472
|
-
hidden: !1,
|
|
473
|
-
packageManager: "yarn",
|
|
474
|
-
repo: {
|
|
475
|
-
url: process.env.STARTER_FREE_REPO_SOURCE || "https://github.com/tamagui/starter-free.git",
|
|
476
|
-
sshFallback: "git@github.com:tamagui/starter-free.git",
|
|
477
|
-
dir: [],
|
|
478
|
-
branch: "main"
|
|
479
|
-
},
|
|
480
|
-
extraSteps: starter_free_default
|
|
481
|
-
}
|
|
482
|
-
];
|
|
483
|
-
|
|
484
|
-
// src/helpers/getTemplateInfo.ts
|
|
485
|
-
var validTemplates = templates.map(({ value }) => value).join(", "), getTemplateInfo = async (template) => {
|
|
486
|
-
let res = getValidTemplate(template);
|
|
487
|
-
return template && !res && (console.warn(`template ${template} is not valid. valid options: ${validTemplates}`), process.exit(1)), res || (template = (await (0, import_prompts3.default)({
|
|
488
|
-
name: "template",
|
|
489
|
-
type: "select",
|
|
490
|
-
message: "Pick a template:",
|
|
491
|
-
choices: templates.filter((t) => !t.hidden)
|
|
492
|
-
})).template), res = getValidTemplate(`${template}`), res || (console.warn(`template ${template} is not valid. valid options: ${validTemplates}`), process.exit(1)), res;
|
|
493
|
-
}, getValidTemplate = (template) => typeof template == "string" && templates.find(({ value }) => value === template);
|
|
494
|
-
|
|
495
|
-
// src/helpers/installDependencies.ts
|
|
496
|
-
var PackageManager = __toESM(require("@expo/package-manager"));
|
|
497
|
-
async function installDependencies(projectRoot, packageManager3) {
|
|
498
|
-
if (process.env.VITEST) {
|
|
499
|
-
console.warn("Skipping dependency installation because Vitest 2 is running.");
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
let options = { cwd: projectRoot };
|
|
503
|
-
packageManager3 === "yarn" ? await new PackageManager.YarnPackageManager(options).installAsync() : packageManager3 === "pnpm" ? await new PackageManager.PnpmPackageManager(options).installAsync() : packageManager3 === "bun" ? await new PackageManager.BunPackageManager(options).installAsync() : await new PackageManager.NpmPackageManager(options).installAsync();
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
// src/index.ts
|
|
507
|
-
var projectPath = "";
|
|
508
|
-
IS_TEST && console.info("\u{1F9D0} Running create-tamagui in test mode \u{1F9D0}");
|
|
509
|
-
function exit() {
|
|
510
|
-
process.exit(0);
|
|
511
|
-
}
|
|
512
|
-
process.on("SIGTERM", exit);
|
|
513
|
-
process.on("SIGINT", exit);
|
|
514
|
-
var program = new import_commander.default.Command(package_default.name).version(package_default.version).arguments("<project-directory>").action((name) => {
|
|
515
|
-
projectPath = name;
|
|
516
|
-
}).option("--info", "Just shows the setup guide for the starter.").option(
|
|
517
|
-
"--template <template>, -t <template>",
|
|
518
|
-
"Choose between four or more starter templates.",
|
|
519
|
-
""
|
|
520
|
-
).allowUnknownOption().usage(
|
|
521
|
-
`${import_chalk8.default.green("<project-directory>")} [options]
|
|
522
|
-
|
|
523
|
-
Example usage:
|
|
524
|
-
|
|
525
|
-
${import_chalk8.default.blueBright(`npx ${package_default.name} next-expo`)}`
|
|
526
|
-
).parse(process.argv);
|
|
527
|
-
process.argv.includes("--version") && (console.info(package_default.version), process.exit(0));
|
|
528
|
-
var info = !!program.info;
|
|
529
|
-
async function run() {
|
|
530
|
-
try {
|
|
531
|
-
if (info) {
|
|
532
|
-
let template2 = await getTemplateInfo(program.template);
|
|
533
|
-
template2?.extraSteps && await template2.extraSteps({
|
|
534
|
-
isFullClone: !1,
|
|
535
|
-
projectName: import_node_path4.default.basename((0, import_node_process.cwd)()),
|
|
536
|
-
projectPath: (0, import_node_process.cwd)()
|
|
537
|
-
}), process.exit(0);
|
|
538
|
-
}
|
|
539
|
-
console.info(), console.info(
|
|
540
|
-
import_chalk8.default.bold(
|
|
541
|
-
' Note: You may need to run "npm create tamagui@latest" to get the latest version!'
|
|
542
|
-
)
|
|
543
|
-
), console.info(), console.info(), console.info(tamaguiRainbowAsciiArt), console.info(import_chalk8.default.bold("Creating tamagui app...")), Number.parseFloat(
|
|
544
|
-
(0, import_node_child_process3.execSync)("git --version").toString().replace("git version ", "").trim()
|
|
545
|
-
) < 2.27 && (console.error(`
|
|
546
|
-
|
|
547
|
-
\u26A0\uFE0F Tamagui can't install: Git version must be >= 2.27
|
|
548
|
-
|
|
549
|
-
`), process.exit(1)), projectPath ||= await getProjectName(projectPath);
|
|
550
|
-
let template = await getTemplateInfo(program.template);
|
|
551
|
-
template.type === "premium" && ((await (0, import_prompts4.default)({
|
|
552
|
-
type: "confirm",
|
|
553
|
-
name: "purchased",
|
|
554
|
-
message: "Have you purchased Takeout on https://tamagui.dev/takeout"
|
|
555
|
-
})).purchased || ((0, import_opener.default)("https://tamagui.dev/takeout"), console.info(
|
|
556
|
-
`
|
|
557
|
-
Opening Takeout website - once you purchase you can restart the create process. Thank you!
|
|
558
|
-
`
|
|
559
|
-
), process.exit(0))), console.info();
|
|
560
|
-
let resolvedProjectPath = import_node_path4.default.resolve(process.cwd(), projectPath), projectName = import_node_path4.default.basename(resolvedProjectPath), { valid, problems } = validateNpmName(projectName);
|
|
561
|
-
valid || (console.error(
|
|
562
|
-
`Could not create a project called ${import_chalk8.default.red(
|
|
563
|
-
`"${projectName}"`
|
|
564
|
-
)} because of npm naming restrictions:`
|
|
565
|
-
), problems.forEach((p) => console.error(` ${import_chalk8.default.red.bold("*")} ${p}`)), process.exit(1)), import_node_fs2.default.existsSync(resolvedProjectPath) && (console.info(), console.info(
|
|
566
|
-
import_chalk8.default.red("\u{1F6A8} [tamagui] error"),
|
|
567
|
-
`You tried to make a project called ${import_chalk8.default.underline(
|
|
568
|
-
import_chalk8.default.blueBright(projectName)
|
|
569
|
-
)}, but a folder with that name already exists: ${import_chalk8.default.blueBright(
|
|
570
|
-
resolvedProjectPath
|
|
571
|
-
)}
|
|
572
|
-
|
|
573
|
-
${import_chalk8.default.bold(import_chalk8.default.red("Please pick a different project name \u{1F978}"))}`
|
|
574
|
-
), console.info(), console.info(), process.exit(1)), console.info(), console.info(`Creating a new tamagui app ${import_chalk8.default.blueBright(resolvedProjectPath)}...`), import_node_fs2.default.mkdirSync(resolvedProjectPath), console.info(import_chalk8.default.green(`${projectName} folder created.`));
|
|
575
|
-
try {
|
|
576
|
-
await cloneStarter(template, resolvedProjectPath, projectName), (0, import_zx2.cd)(resolvedProjectPath), console.info();
|
|
577
|
-
} catch (e) {
|
|
578
|
-
console.error(`[tamagui] Failed to copy example into ${resolvedProjectPath}
|
|
579
|
-
|
|
580
|
-
`, e), process.exit(1);
|
|
581
|
-
}
|
|
582
|
-
updatePackageJsonName(projectName, resolvedProjectPath), console.info("Installing packages. This might take a couple of minutes."), console.info();
|
|
583
|
-
let packageManager3 = ("packageManager" in template ? template.packageManager : void 0) || await (0, import_detect_package_manager.detect)();
|
|
584
|
-
try {
|
|
585
|
-
console.info("installing with " + packageManager3), await installDependencies(resolvedProjectPath, packageManager3);
|
|
586
|
-
} catch (e) {
|
|
587
|
-
console.error("[tamagui] error installing with " + packageManager3 + `
|
|
588
|
-
${e}`), process.exit(1);
|
|
589
|
-
}
|
|
590
|
-
await template?.extraSteps?.({
|
|
591
|
-
isFullClone: !0,
|
|
592
|
-
projectName,
|
|
593
|
-
projectPath: resolvedProjectPath
|
|
594
|
-
}), console.info(), console.info(import_chalk8.default.gray(tamaguiDuckAsciiArt)), process.exit(0);
|
|
595
|
-
} catch (error) {
|
|
596
|
-
console.error("An unexpected error occurred:", error), process.exit(1);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
function updatePackageJsonName(projectName, dir) {
|
|
600
|
-
let packageJsonPath = import_node_path4.default.join(dir, "package.json");
|
|
601
|
-
if ((0, import_fs_extra2.existsSync)(packageJsonPath)) {
|
|
602
|
-
let contentWithUpdatedName = (0, import_fs_extra2.readFileSync)(packageJsonPath).toString().replace(
|
|
603
|
-
/("name": ")(.*)(",)/,
|
|
604
|
-
`$1${projectName}$3`
|
|
605
|
-
);
|
|
606
|
-
(0, import_fs_extra2.writeFileSync)(packageJsonPath, contentWithUpdatedName);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
run().catch((error) => {
|
|
610
|
-
console.error("An unexpected error occurred:", error), process.exit(1);
|
|
611
|
-
});
|
|
612
|
-
//# sourceMappingURL=index.js.map
|