bleam 0.0.1 → 0.0.3
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/app.cjs +11 -0
- package/dist/app.d.cts +7 -0
- package/dist/app.d.cts.map +1 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +10 -0
- package/dist/app.js.map +1 -0
- package/dist/bundler.cjs +0 -0
- package/dist/bundler.d.cts +28 -0
- package/dist/bundler.d.cts.map +1 -0
- package/dist/bundler.d.ts +28 -0
- package/dist/bundler.d.ts.map +1 -0
- package/dist/bundler.js +1 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/cli.cjs +477 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +470 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.cjs +26 -0
- package/dist/config.d.cts +28 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +25 -0
- package/dist/config.js.map +1 -0
- package/dist/crypto-BNhWeXMj.cjs +15 -0
- package/dist/crypto-Bg8cD8wX.d.cts +8 -0
- package/dist/crypto-Bg8cD8wX.d.cts.map +1 -0
- package/dist/crypto-CCA_hvao.js +11 -0
- package/dist/crypto-CCA_hvao.js.map +1 -0
- package/dist/crypto-IOzbNoJD.d.ts +8 -0
- package/dist/crypto-IOzbNoJD.d.ts.map +1 -0
- package/dist/crypto.cjs +4 -0
- package/dist/crypto.d.cts +2 -0
- package/dist/crypto.d.ts +2 -0
- package/dist/crypto.js +4 -0
- package/dist/dev-protocol.cjs +16 -0
- package/dist/dev-protocol.d.cts +16 -0
- package/dist/dev-protocol.d.cts.map +1 -0
- package/dist/dev-protocol.d.ts +16 -0
- package/dist/dev-protocol.d.ts.map +1 -0
- package/dist/dev-protocol.js +14 -0
- package/dist/dev-protocol.js.map +1 -0
- package/dist/fs-BK7joD1g.js +13 -0
- package/dist/fs-BK7joD1g.js.map +1 -0
- package/dist/fs-CEhcjuN6.d.ts +9 -0
- package/dist/fs-CEhcjuN6.d.ts.map +1 -0
- package/dist/fs-CfE8CHf_.d.cts +9 -0
- package/dist/fs-CfE8CHf_.d.cts.map +1 -0
- package/dist/fs-DKHYTPua.cjs +18 -0
- package/dist/fs.cjs +3 -0
- package/dist/fs.d.cts +2 -0
- package/dist/fs.d.ts +2 -0
- package/dist/fs.js +3 -0
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/native-runtime-BoqybBBf.js +18 -0
- package/dist/native-runtime-BoqybBBf.js.map +1 -0
- package/dist/native-runtime-CdeT0JyQ.cjs +30 -0
- package/dist/native.cjs +132 -0
- package/dist/native.d.cts +64 -0
- package/dist/native.d.cts.map +1 -0
- package/dist/native.d.ts +64 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +133 -0
- package/dist/native.js.map +1 -0
- package/dist/runtime.cjs +0 -0
- package/dist/runtime.d.cts +14 -0
- package/dist/runtime.d.cts.map +1 -0
- package/dist/runtime.d.ts +14 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/metro-config.cjs +75 -0
- package/package.json +81 -22
- package/templates/basic/app.config.ts +3 -0
- package/templates/basic/app.tsx +18 -0
- package/tsconfig.base.json +7 -0
- package/tsconfig.json +3 -0
- package/README.md +0 -1
- package/dist/index.d.mts +0 -9914
- package/dist/index.mjs +0 -1259
package/dist/cli.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
6
|
+
import http from "node:http";
|
|
7
|
+
import os from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
|
+
|
|
11
|
+
//#region src/cli.ts
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const packageRoot = path.dirname(fileURLToPath(new URL("../package.json", import.meta.url)));
|
|
14
|
+
const packageJson = require("../package.json");
|
|
15
|
+
const runtimeVersion = packageJson.version;
|
|
16
|
+
const runtimePlatform = `macos-${process.arch}`;
|
|
17
|
+
function printUsage() {
|
|
18
|
+
console.log(`Usage: bleam <command>
|
|
19
|
+
|
|
20
|
+
Commands:
|
|
21
|
+
new [dir] [--run] Create a new Bleam project
|
|
22
|
+
dev [dir] [--port <port>] Start a Bleam dev server`);
|
|
23
|
+
}
|
|
24
|
+
function invocationRoot() {
|
|
25
|
+
return path.isAbsolute(process.env.PWD ?? "") ? process.env.PWD : process.cwd();
|
|
26
|
+
}
|
|
27
|
+
function parseDevOptions(argv) {
|
|
28
|
+
const root = invocationRoot();
|
|
29
|
+
let projectRoot = root;
|
|
30
|
+
let port = 8082;
|
|
31
|
+
let hasProjectRootArg = false;
|
|
32
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
33
|
+
const arg = argv[index];
|
|
34
|
+
if (arg === "--port" || arg === "-p") {
|
|
35
|
+
const value = argv[++index];
|
|
36
|
+
port = Number(value);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (arg.startsWith("--port=")) {
|
|
40
|
+
port = Number(arg.slice(7));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (arg === "--help" || arg === "-h") {
|
|
44
|
+
printUsage();
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
if (arg.startsWith("-")) throw new Error(`Unknown option: ${arg}`);
|
|
48
|
+
projectRoot = path.resolve(root, arg);
|
|
49
|
+
hasProjectRootArg = true;
|
|
50
|
+
}
|
|
51
|
+
if (!Number.isInteger(port) || port <= 0) throw new Error(`Invalid port: ${port}`);
|
|
52
|
+
if (!hasProjectRootArg && !isBleamProjectRoot(projectRoot)) projectRoot = discoverBleamProjectRoot(projectRoot) ?? projectRoot;
|
|
53
|
+
return {
|
|
54
|
+
projectRoot: path.resolve(projectRoot),
|
|
55
|
+
port
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function parseNewOptions(argv) {
|
|
59
|
+
const root = invocationRoot();
|
|
60
|
+
let projectRoot = root;
|
|
61
|
+
let run = false;
|
|
62
|
+
for (const arg of argv) {
|
|
63
|
+
if (arg === "--run") {
|
|
64
|
+
run = true;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (arg === "--help" || arg === "-h") {
|
|
68
|
+
printUsage();
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
if (arg.startsWith("-")) throw new Error(`Unknown option: ${arg}`);
|
|
72
|
+
projectRoot = path.resolve(root, arg);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
projectRoot,
|
|
76
|
+
run
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function isBleamProjectRoot(projectRoot) {
|
|
80
|
+
return existsSync(path.join(projectRoot, "app.config.ts")) && existsSync(path.join(projectRoot, "app.tsx"));
|
|
81
|
+
}
|
|
82
|
+
function discoverBleamProjectRoot(searchRoot) {
|
|
83
|
+
const ignoredNames = new Set([
|
|
84
|
+
".bleam",
|
|
85
|
+
".expo",
|
|
86
|
+
".git",
|
|
87
|
+
".yarn",
|
|
88
|
+
"build",
|
|
89
|
+
"dist",
|
|
90
|
+
"node_modules",
|
|
91
|
+
"templates"
|
|
92
|
+
]);
|
|
93
|
+
const matches = [];
|
|
94
|
+
function visit(directory) {
|
|
95
|
+
if (matches.length > 1) return;
|
|
96
|
+
if (isBleamProjectRoot(directory)) {
|
|
97
|
+
matches.push(directory);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
101
|
+
if (!entry.isDirectory() || ignoredNames.has(entry.name)) continue;
|
|
102
|
+
visit(path.join(directory, entry.name));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
visit(searchRoot);
|
|
106
|
+
if (matches.length > 1) throw new Error("Multiple Bleam projects found. Run bleam dev <dir>.");
|
|
107
|
+
return matches[0];
|
|
108
|
+
}
|
|
109
|
+
function assertStringField(value, field) {
|
|
110
|
+
if (typeof value !== "string" || value.trim() === "") throw new Error(`app.config.ts must define ${field}`);
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function loadAppConfig(projectRoot) {
|
|
114
|
+
const configPath = path.join(projectRoot, "app.config.ts");
|
|
115
|
+
const loader = `
|
|
116
|
+
const mod = await import(${JSON.stringify(pathToFileURL(configPath).href)});
|
|
117
|
+
const config = mod.default?.default ?? mod.default ?? mod;
|
|
118
|
+
process.stdout.write(JSON.stringify(config));
|
|
119
|
+
`;
|
|
120
|
+
const result = spawnSync(process.execPath, [
|
|
121
|
+
"--import",
|
|
122
|
+
require.resolve("tsx"),
|
|
123
|
+
"--eval",
|
|
124
|
+
loader
|
|
125
|
+
], {
|
|
126
|
+
cwd: projectRoot,
|
|
127
|
+
encoding: "utf8",
|
|
128
|
+
env: {
|
|
129
|
+
...process.env,
|
|
130
|
+
NODE_PATH: [
|
|
131
|
+
path.join(projectRoot, "node_modules"),
|
|
132
|
+
path.join(packageRoot, "node_modules"),
|
|
133
|
+
process.env.NODE_PATH
|
|
134
|
+
].filter(Boolean).join(path.delimiter)
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
if (result.status !== 0) throw new Error(result.stderr.trim() || "Failed to load app.config.ts");
|
|
138
|
+
const value = JSON.parse(result.stdout);
|
|
139
|
+
return {
|
|
140
|
+
name: assertStringField(value.name, "name"),
|
|
141
|
+
version: typeof value.version === "string" ? value.version : void 0,
|
|
142
|
+
bundleIdentifier: typeof value.bundleIdentifier === "string" ? value.bundleIdentifier : void 0,
|
|
143
|
+
teamId: typeof value.teamId === "string" ? value.teamId : void 0
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function assertBleamConfigFiles(projectRoot) {
|
|
147
|
+
if (existsSync(path.join(projectRoot, "app.json"))) throw new Error("Bleam projects use app.config.ts; app.json is not supported.");
|
|
148
|
+
if (!existsSync(path.join(projectRoot, "app.config.ts"))) throw new Error("Missing app.config.ts. Bleam projects must define app.config.ts.");
|
|
149
|
+
if (!existsSync(path.join(projectRoot, "app.tsx"))) throw new Error("Missing app.tsx. Bleam projects must define app.tsx.");
|
|
150
|
+
}
|
|
151
|
+
function readProjectConfig(options) {
|
|
152
|
+
assertBleamConfigFiles(options.projectRoot);
|
|
153
|
+
const config = loadAppConfig(options.projectRoot);
|
|
154
|
+
return {
|
|
155
|
+
name: config.name,
|
|
156
|
+
version: config.version,
|
|
157
|
+
bundleIdentifier: config.bundleIdentifier,
|
|
158
|
+
teamId: config.teamId,
|
|
159
|
+
runtimeVersion,
|
|
160
|
+
sdkVersion: runtimeVersion
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function slugFromName(name) {
|
|
164
|
+
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "bleam-app";
|
|
165
|
+
}
|
|
166
|
+
function nameFromDirectory(projectRoot) {
|
|
167
|
+
const name = path.basename(projectRoot).replace(/[-_]+/g, " ").trim();
|
|
168
|
+
if (!name) return "Bleam App";
|
|
169
|
+
return name.replace(/\b\w/g, (letter) => letter.toUpperCase());
|
|
170
|
+
}
|
|
171
|
+
function createNewProject(options) {
|
|
172
|
+
const templateRoot = path.join(packageRoot, "templates", "basic");
|
|
173
|
+
if (!existsSync(templateRoot)) throw new Error(`Missing basic template: ${templateRoot}`);
|
|
174
|
+
if (existsSync(options.projectRoot) && readdirSync(options.projectRoot).length > 0) throw new Error(`Directory is not empty: ${options.projectRoot}`);
|
|
175
|
+
mkdirSync(options.projectRoot, { recursive: true });
|
|
176
|
+
cpSync(templateRoot, options.projectRoot, { recursive: true });
|
|
177
|
+
writeFileSync(path.join(options.projectRoot, "app.config.ts"), `export default {\n name: ${JSON.stringify(nameFromDirectory(options.projectRoot))},\n}\n`);
|
|
178
|
+
console.log(`Created Bleam project at ${options.projectRoot}`);
|
|
179
|
+
}
|
|
180
|
+
function createDevWorkspace(projectRoot, config) {
|
|
181
|
+
const workspaceRoot = path.join(projectRoot, ".bleam", "dev");
|
|
182
|
+
mkdirSync(workspaceRoot, { recursive: true });
|
|
183
|
+
const workspaceNodeModules = path.join(workspaceRoot, "node_modules");
|
|
184
|
+
if (!existsSync(workspaceNodeModules)) symlinkSync(path.join(packageRoot, "node_modules"), workspaceNodeModules);
|
|
185
|
+
writeFileSync(path.join(workspaceRoot, "app.config.js"), `module.exports = ${JSON.stringify({ expo: {
|
|
186
|
+
name: config.name,
|
|
187
|
+
slug: slugFromName(config.name),
|
|
188
|
+
version: config.version ?? "0.0.0",
|
|
189
|
+
orientation: "default",
|
|
190
|
+
platforms: ["ios"],
|
|
191
|
+
newArchEnabled: true
|
|
192
|
+
} }, null, 2)}\n`);
|
|
193
|
+
writeFileSync(path.join(workspaceRoot, "index.js"), `import { registerApp } from 'bleam/app'\nimport App from ${JSON.stringify(path.join(projectRoot, "app"))}\n\nregisterApp(App)\n`);
|
|
194
|
+
writeFileSync(path.join(workspaceRoot, "metro.config.js"), `const { getDefaultConfig } = require(${JSON.stringify(path.join(packageRoot, "metro-config.cjs"))})\n\nmodule.exports = getDefaultConfig(__dirname)\n`);
|
|
195
|
+
writeFileSync(path.join(workspaceRoot, "package.json"), `${JSON.stringify({
|
|
196
|
+
name: `${slugFromName(config.name)}-bleam-dev`,
|
|
197
|
+
version: config.version ?? "0.0.0",
|
|
198
|
+
private: true,
|
|
199
|
+
main: "index.js",
|
|
200
|
+
dependencies: {
|
|
201
|
+
"@types/react": packageJson.dependencies?.["@types/react"],
|
|
202
|
+
expo: packageJson.dependencies?.expo,
|
|
203
|
+
react: packageJson.dependencies?.react,
|
|
204
|
+
"react-native": packageJson.dependencies?.["react-native"]
|
|
205
|
+
}
|
|
206
|
+
}, null, 2)}\n`);
|
|
207
|
+
writeFileSync(path.join(workspaceRoot, "tsconfig.json"), `${JSON.stringify({
|
|
208
|
+
extends: "bleam/tsconfig",
|
|
209
|
+
include: [path.relative(workspaceRoot, path.join(projectRoot, "app.tsx")), path.relative(workspaceRoot, path.join(projectRoot, "app.config.ts"))]
|
|
210
|
+
}, null, 2)}\n`);
|
|
211
|
+
return workspaceRoot;
|
|
212
|
+
}
|
|
213
|
+
function writeProjectRuntimeConfig(projectRoot, config, origin) {
|
|
214
|
+
const projectConfigPath = path.join(projectRoot, ".bleam", "project.json");
|
|
215
|
+
mkdirSync(path.dirname(projectConfigPath), { recursive: true });
|
|
216
|
+
writeFileSync(projectConfigPath, `${JSON.stringify({
|
|
217
|
+
name: config.name,
|
|
218
|
+
version: config.version,
|
|
219
|
+
bundleIdentifier: config.bundleIdentifier,
|
|
220
|
+
teamId: config.teamId,
|
|
221
|
+
devServer: origin,
|
|
222
|
+
runtimeVersion: config.runtimeVersion,
|
|
223
|
+
sdkVersion: config.sdkVersion
|
|
224
|
+
}, null, 2)}\n`);
|
|
225
|
+
return projectConfigPath;
|
|
226
|
+
}
|
|
227
|
+
function runtimeCacheRoot() {
|
|
228
|
+
return path.join(os.homedir(), "Library", "Caches", "bleam", "runtimes", runtimeVersion, runtimePlatform);
|
|
229
|
+
}
|
|
230
|
+
function localDevelopmentRuntimeAppPath() {
|
|
231
|
+
return path.resolve(packageRoot, "..", "..", "app", "bleam", "build", "Build", "Products", "Debug-maccatalyst", "Bleam.app");
|
|
232
|
+
}
|
|
233
|
+
function runtimeReleaseBaseUrl() {
|
|
234
|
+
return process.env.BLEAM_RUNTIME_RELEASE_BASE_URL ?? "https://github.com/bajedev/bleam-app/releases/download";
|
|
235
|
+
}
|
|
236
|
+
function runtimeArchiveName() {
|
|
237
|
+
return `bleam-runtime-v${runtimeVersion}-${runtimePlatform}.zip`;
|
|
238
|
+
}
|
|
239
|
+
function runtimeArchiveUrl() {
|
|
240
|
+
const tag = encodeURIComponent(`bleam@${runtimeVersion}`);
|
|
241
|
+
return `${runtimeReleaseBaseUrl()}/${tag}/${runtimeArchiveName()}`;
|
|
242
|
+
}
|
|
243
|
+
function sha256(filePath) {
|
|
244
|
+
return createHash("sha256").update(readFileSync(filePath)).digest("hex");
|
|
245
|
+
}
|
|
246
|
+
async function downloadFile(url, destination) {
|
|
247
|
+
const response = await fetch(url);
|
|
248
|
+
if (!response.ok) throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
|
|
249
|
+
writeFileSync(destination, new Uint8Array(await response.arrayBuffer()));
|
|
250
|
+
}
|
|
251
|
+
async function downloadExpectedSha256(url) {
|
|
252
|
+
const response = await fetch(`${url}.sha256`);
|
|
253
|
+
if (!response.ok) return;
|
|
254
|
+
return (await response.text()).trim().split(/\s+/)[0];
|
|
255
|
+
}
|
|
256
|
+
async function downloadRuntimeArtifact() {
|
|
257
|
+
if (process.platform !== "darwin") throw new Error("Bleam runtime artifacts are currently only available on macOS.");
|
|
258
|
+
const cacheRoot = runtimeCacheRoot();
|
|
259
|
+
const cachedAppPath = path.join(cacheRoot, "Bleam.app");
|
|
260
|
+
if (existsSync(cachedAppPath)) return {
|
|
261
|
+
appPath: cachedAppPath,
|
|
262
|
+
version: runtimeVersion,
|
|
263
|
+
platform: runtimePlatform
|
|
264
|
+
};
|
|
265
|
+
mkdirSync(cacheRoot, { recursive: true });
|
|
266
|
+
const archiveUrl = runtimeArchiveUrl();
|
|
267
|
+
const archivePath = path.join(cacheRoot, runtimeArchiveName());
|
|
268
|
+
const extractRoot = path.join(cacheRoot, "extract");
|
|
269
|
+
await downloadFile(archiveUrl, archivePath);
|
|
270
|
+
const expectedSha256 = await downloadExpectedSha256(archiveUrl);
|
|
271
|
+
if (expectedSha256 && sha256(archivePath) !== expectedSha256) {
|
|
272
|
+
rmSync(archivePath, { force: true });
|
|
273
|
+
throw new Error(`Runtime artifact checksum mismatch: ${archiveUrl}`);
|
|
274
|
+
}
|
|
275
|
+
rmSync(extractRoot, {
|
|
276
|
+
recursive: true,
|
|
277
|
+
force: true
|
|
278
|
+
});
|
|
279
|
+
mkdirSync(extractRoot, { recursive: true });
|
|
280
|
+
execFileSync("ditto", [
|
|
281
|
+
"-x",
|
|
282
|
+
"-k",
|
|
283
|
+
archivePath,
|
|
284
|
+
extractRoot
|
|
285
|
+
], { stdio: "ignore" });
|
|
286
|
+
const extractedAppPath = path.join(extractRoot, "Bleam.app");
|
|
287
|
+
if (!existsSync(extractedAppPath)) throw new Error(`Runtime archive did not contain Bleam.app: ${archiveUrl}`);
|
|
288
|
+
rmSync(cachedAppPath, {
|
|
289
|
+
recursive: true,
|
|
290
|
+
force: true
|
|
291
|
+
});
|
|
292
|
+
cpSync(extractedAppPath, cachedAppPath, { recursive: true });
|
|
293
|
+
rmSync(extractRoot, {
|
|
294
|
+
recursive: true,
|
|
295
|
+
force: true
|
|
296
|
+
});
|
|
297
|
+
return {
|
|
298
|
+
appPath: cachedAppPath,
|
|
299
|
+
version: runtimeVersion,
|
|
300
|
+
platform: runtimePlatform
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
async function resolveRuntimeArtifact() {
|
|
304
|
+
const overrideAppPath = process.env.BLEAM_RUNTIME_APP;
|
|
305
|
+
if (overrideAppPath) {
|
|
306
|
+
const appPath = path.resolve(overrideAppPath);
|
|
307
|
+
if (!existsSync(appPath)) throw new Error(`BLEAM_RUNTIME_APP does not exist: ${appPath}`);
|
|
308
|
+
return {
|
|
309
|
+
appPath,
|
|
310
|
+
version: runtimeVersion,
|
|
311
|
+
platform: runtimePlatform
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
const localAppPath = localDevelopmentRuntimeAppPath();
|
|
315
|
+
if (existsSync(localAppPath)) return {
|
|
316
|
+
appPath: localAppPath,
|
|
317
|
+
version: runtimeVersion,
|
|
318
|
+
platform: runtimePlatform
|
|
319
|
+
};
|
|
320
|
+
return downloadRuntimeArtifact();
|
|
321
|
+
}
|
|
322
|
+
function copyRuntimeClient(projectRoot, runtime) {
|
|
323
|
+
const clientAppPath = path.join(projectRoot, ".bleam", "client", "Bleam.app");
|
|
324
|
+
rmSync(clientAppPath, {
|
|
325
|
+
recursive: true,
|
|
326
|
+
force: true
|
|
327
|
+
});
|
|
328
|
+
mkdirSync(path.dirname(clientAppPath), { recursive: true });
|
|
329
|
+
cpSync(runtime.appPath, clientAppPath, { recursive: true });
|
|
330
|
+
return clientAppPath;
|
|
331
|
+
}
|
|
332
|
+
function waitForDevServer(port, timeoutMs = 12e4) {
|
|
333
|
+
return new Promise((resolve, reject) => {
|
|
334
|
+
const startedAt = Date.now();
|
|
335
|
+
const poll = () => {
|
|
336
|
+
const req = http.get(`http://localhost:${port}/status`, (res) => {
|
|
337
|
+
let data = "";
|
|
338
|
+
res.on("data", (chunk) => {
|
|
339
|
+
data += chunk.toString();
|
|
340
|
+
});
|
|
341
|
+
res.on("end", () => {
|
|
342
|
+
if (data.includes("packager-status:running")) {
|
|
343
|
+
resolve();
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
retry();
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
req.on("error", retry);
|
|
350
|
+
req.setTimeout(2e3, () => {
|
|
351
|
+
req.destroy();
|
|
352
|
+
retry();
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
const retry = () => {
|
|
356
|
+
if (Date.now() - startedAt > timeoutMs) {
|
|
357
|
+
reject(/* @__PURE__ */ new Error(`Bleam dev server did not start within ${timeoutMs / 1e3}s`));
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
setTimeout(poll, 500);
|
|
361
|
+
};
|
|
362
|
+
poll();
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function isBleamManifest(value) {
|
|
366
|
+
const manifest = value && typeof value === "object" ? value : {};
|
|
367
|
+
return typeof manifest.name === "string" && typeof manifest.bundleUrl === "string" && manifest.platform === "macos" && manifest.dev === true;
|
|
368
|
+
}
|
|
369
|
+
async function readDevManifest(origin, timeoutMs = 3e4) {
|
|
370
|
+
const manifestUrl = `${origin}/bleam/manifest.json`;
|
|
371
|
+
const startedAt = Date.now();
|
|
372
|
+
while (Date.now() - startedAt <= timeoutMs) {
|
|
373
|
+
try {
|
|
374
|
+
const response = await fetch(manifestUrl, { cache: "no-store" });
|
|
375
|
+
const value = await response.json();
|
|
376
|
+
if (response.ok && isBleamManifest(value)) return value;
|
|
377
|
+
} catch {}
|
|
378
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
379
|
+
}
|
|
380
|
+
throw new Error(`Bleam manifest did not become available: ${manifestUrl}`);
|
|
381
|
+
}
|
|
382
|
+
function openRuntimeClient(appPath, projectConfigPath, manifest) {
|
|
383
|
+
spawn("open", [
|
|
384
|
+
appPath,
|
|
385
|
+
"--args",
|
|
386
|
+
"--bleam-project-config",
|
|
387
|
+
projectConfigPath,
|
|
388
|
+
"--bleam-bundle-url",
|
|
389
|
+
manifest.bundleUrl,
|
|
390
|
+
"--bleam-title",
|
|
391
|
+
manifest.name
|
|
392
|
+
], {
|
|
393
|
+
detached: true,
|
|
394
|
+
stdio: "ignore"
|
|
395
|
+
}).unref();
|
|
396
|
+
}
|
|
397
|
+
async function startDevServer(options) {
|
|
398
|
+
const config = readProjectConfig(options);
|
|
399
|
+
const runtime = await resolveRuntimeArtifact();
|
|
400
|
+
const clientAppPath = copyRuntimeClient(options.projectRoot, runtime);
|
|
401
|
+
const workspaceRoot = createDevWorkspace(options.projectRoot, config);
|
|
402
|
+
const origin = `http://localhost:${options.port}`;
|
|
403
|
+
const projectConfigPath = writeProjectRuntimeConfig(options.projectRoot, config, origin);
|
|
404
|
+
const child = spawn(process.execPath, [
|
|
405
|
+
require.resolve("expo/bin/cli"),
|
|
406
|
+
"start",
|
|
407
|
+
workspaceRoot,
|
|
408
|
+
"--localhost",
|
|
409
|
+
"--port",
|
|
410
|
+
String(options.port)
|
|
411
|
+
], {
|
|
412
|
+
stdio: "inherit",
|
|
413
|
+
env: {
|
|
414
|
+
...process.env,
|
|
415
|
+
BLEAM_DEV: "1",
|
|
416
|
+
BLEAM_PROJECT_ROOT: options.projectRoot,
|
|
417
|
+
BLEAM_DEV_NAME: config.name,
|
|
418
|
+
BLEAM_DEV_ORIGIN: origin,
|
|
419
|
+
BLEAM_DEV_PORT: String(options.port),
|
|
420
|
+
BLEAM_DEV_RUNTIME_VERSION: config.runtimeVersion,
|
|
421
|
+
BLEAM_DEV_SDK_VERSION: config.sdkVersion,
|
|
422
|
+
NODE_PATH: [
|
|
423
|
+
path.join(options.projectRoot, "node_modules"),
|
|
424
|
+
path.join(packageRoot, "node_modules"),
|
|
425
|
+
path.dirname(path.dirname(require.resolve("expo/package.json"))),
|
|
426
|
+
path.dirname(path.dirname(require.resolve("react/package.json"))),
|
|
427
|
+
path.dirname(path.dirname(require.resolve("react-native/package.json"))),
|
|
428
|
+
process.env.NODE_PATH
|
|
429
|
+
].filter(Boolean).join(path.delimiter)
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
const stop = (signal) => {
|
|
433
|
+
child.kill(signal);
|
|
434
|
+
};
|
|
435
|
+
process.on("SIGINT", () => stop("SIGINT"));
|
|
436
|
+
process.on("SIGTERM", () => stop("SIGTERM"));
|
|
437
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
438
|
+
await waitForDevServer(options.port);
|
|
439
|
+
const manifest = await readDevManifest(origin);
|
|
440
|
+
if (process.env.BLEAM_NO_OPEN !== "1") openRuntimeClient(clientAppPath, projectConfigPath, manifest);
|
|
441
|
+
}
|
|
442
|
+
async function main(argv = process.argv.slice(2)) {
|
|
443
|
+
const [command, ...args] = argv;
|
|
444
|
+
if (!command || command === "--help" || command === "-h") {
|
|
445
|
+
printUsage();
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (command === "new") {
|
|
449
|
+
const options = parseNewOptions(args);
|
|
450
|
+
createNewProject(options);
|
|
451
|
+
if (options.run) await startDevServer({
|
|
452
|
+
projectRoot: options.projectRoot,
|
|
453
|
+
port: 8082
|
|
454
|
+
});
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (command === "dev") {
|
|
458
|
+
await startDevServer(parseDevOptions(args));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
throw new Error(`Unknown command: ${command}`);
|
|
462
|
+
}
|
|
463
|
+
main().catch((error) => {
|
|
464
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
465
|
+
process.exit(1);
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
//#endregion
|
|
469
|
+
export { };
|
|
470
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","names":["matches: string[]","value: unknown"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { execFileSync, spawn, spawnSync } from 'node:child_process'\nimport { createHash } from 'node:crypto'\nimport {\n cpSync,\n existsSync,\n mkdirSync,\n readFileSync,\n readdirSync,\n rmSync,\n symlinkSync,\n writeFileSync,\n} from 'node:fs'\nimport http from 'node:http'\nimport { createRequire } from 'node:module'\nimport os from 'node:os'\nimport path from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\nimport type { BleamConfig } from './config'\n\ninterface DevOptions {\n projectRoot: string\n port: number\n}\n\ninterface NewOptions {\n projectRoot: string\n run: boolean\n}\n\ninterface ProjectConfig {\n name: string\n version?: string\n bundleIdentifier?: string\n teamId?: string\n runtimeVersion: string\n sdkVersion: string\n}\n\ninterface RuntimeArtifact {\n appPath: string\n version: string\n platform: string\n}\n\ninterface BleamManifest {\n name: string\n bundleUrl: string\n platform: 'macos'\n dev: boolean\n}\n\nconst require = createRequire(import.meta.url)\nconst packageRoot = path.dirname(\n fileURLToPath(new URL('../package.json', import.meta.url)),\n)\nconst packageJson = require('../package.json') as {\n version: string\n dependencies?: Record<string, string>\n}\nconst runtimeVersion = packageJson.version\nconst runtimePlatform = `macos-${process.arch}`\n\nfunction printUsage() {\n console.log(`Usage: bleam <command>\n\nCommands:\n new [dir] [--run] Create a new Bleam project\n dev [dir] [--port <port>] Start a Bleam dev server`)\n}\n\nfunction invocationRoot() {\n return path.isAbsolute(process.env.PWD ?? '')\n ? process.env.PWD!\n : process.cwd()\n}\n\nfunction parseDevOptions(argv: string[]): DevOptions {\n const root = invocationRoot()\n let projectRoot = root\n let port = 8082\n let hasProjectRootArg = false\n\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index]\n\n if (arg === '--port' || arg === '-p') {\n const value = argv[++index]\n port = Number(value)\n continue\n }\n\n if (arg.startsWith('--port=')) {\n port = Number(arg.slice('--port='.length))\n continue\n }\n\n if (arg === '--help' || arg === '-h') {\n printUsage()\n process.exit(0)\n }\n\n if (arg.startsWith('-')) {\n throw new Error(`Unknown option: ${arg}`)\n }\n\n projectRoot = path.resolve(root, arg)\n hasProjectRootArg = true\n }\n\n if (!Number.isInteger(port) || port <= 0) {\n throw new Error(`Invalid port: ${port}`)\n }\n\n if (!hasProjectRootArg && !isBleamProjectRoot(projectRoot)) {\n projectRoot = discoverBleamProjectRoot(projectRoot) ?? projectRoot\n }\n\n return { projectRoot: path.resolve(projectRoot), port }\n}\n\nfunction parseNewOptions(argv: string[]): NewOptions {\n const root = invocationRoot()\n let projectRoot = root\n let run = false\n\n for (const arg of argv) {\n if (arg === '--run') {\n run = true\n continue\n }\n\n if (arg === '--help' || arg === '-h') {\n printUsage()\n process.exit(0)\n }\n\n if (arg.startsWith('-')) {\n throw new Error(`Unknown option: ${arg}`)\n }\n\n projectRoot = path.resolve(root, arg)\n }\n\n return { projectRoot, run }\n}\n\nfunction isBleamProjectRoot(projectRoot: string) {\n return (\n existsSync(path.join(projectRoot, 'app.config.ts')) &&\n existsSync(path.join(projectRoot, 'app.tsx'))\n )\n}\n\nfunction discoverBleamProjectRoot(searchRoot: string) {\n const ignoredNames = new Set([\n '.bleam',\n '.expo',\n '.git',\n '.yarn',\n 'build',\n 'dist',\n 'node_modules',\n 'templates',\n ])\n const matches: string[] = []\n\n function visit(directory: string) {\n if (matches.length > 1) {\n return\n }\n\n if (isBleamProjectRoot(directory)) {\n matches.push(directory)\n return\n }\n\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n if (!entry.isDirectory() || ignoredNames.has(entry.name)) {\n continue\n }\n\n visit(path.join(directory, entry.name))\n }\n }\n\n visit(searchRoot)\n\n if (matches.length > 1) {\n throw new Error('Multiple Bleam projects found. Run bleam dev <dir>.')\n }\n\n return matches[0]\n}\n\nfunction assertStringField(value: unknown, field: keyof BleamConfig): string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`app.config.ts must define ${field}`)\n }\n return value\n}\n\nfunction loadAppConfig(projectRoot: string): BleamConfig {\n const configPath = path.join(projectRoot, 'app.config.ts')\n const loader = `\n const mod = await import(${JSON.stringify(pathToFileURL(configPath).href)});\n const config = mod.default?.default ?? mod.default ?? mod;\n process.stdout.write(JSON.stringify(config));\n `\n\n const result = spawnSync(\n process.execPath,\n ['--import', require.resolve('tsx'), '--eval', loader],\n {\n cwd: projectRoot,\n encoding: 'utf8',\n env: {\n ...process.env,\n NODE_PATH: [\n path.join(projectRoot, 'node_modules'),\n path.join(packageRoot, 'node_modules'),\n process.env.NODE_PATH,\n ]\n .filter(Boolean)\n .join(path.delimiter),\n },\n },\n )\n\n if (result.status !== 0) {\n throw new Error(result.stderr.trim() || 'Failed to load app.config.ts')\n }\n\n const value = JSON.parse(result.stdout) as Partial<BleamConfig>\n return {\n name: assertStringField(value.name, 'name'),\n version: typeof value.version === 'string' ? value.version : undefined,\n bundleIdentifier:\n typeof value.bundleIdentifier === 'string'\n ? value.bundleIdentifier\n : undefined,\n teamId: typeof value.teamId === 'string' ? value.teamId : undefined,\n }\n}\n\nfunction assertBleamConfigFiles(projectRoot: string) {\n if (existsSync(path.join(projectRoot, 'app.json'))) {\n throw new Error(\n 'Bleam projects use app.config.ts; app.json is not supported.',\n )\n }\n\n if (!existsSync(path.join(projectRoot, 'app.config.ts'))) {\n throw new Error(\n 'Missing app.config.ts. Bleam projects must define app.config.ts.',\n )\n }\n\n if (!existsSync(path.join(projectRoot, 'app.tsx'))) {\n throw new Error('Missing app.tsx. Bleam projects must define app.tsx.')\n }\n}\n\nfunction readProjectConfig(options: DevOptions): ProjectConfig {\n assertBleamConfigFiles(options.projectRoot)\n const config = loadAppConfig(options.projectRoot)\n\n return {\n name: config.name,\n version: config.version,\n bundleIdentifier: config.bundleIdentifier,\n teamId: config.teamId,\n runtimeVersion,\n sdkVersion: runtimeVersion,\n }\n}\n\nfunction slugFromName(name: string) {\n return (\n name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '') || 'bleam-app'\n )\n}\n\nfunction nameFromDirectory(projectRoot: string) {\n const name = path.basename(projectRoot).replace(/[-_]+/g, ' ').trim()\n if (!name) {\n return 'Bleam App'\n }\n\n return name.replace(/\\b\\w/g, (letter) => letter.toUpperCase())\n}\n\nfunction createNewProject(options: NewOptions) {\n const templateRoot = path.join(packageRoot, 'templates', 'basic')\n\n if (!existsSync(templateRoot)) {\n throw new Error(`Missing basic template: ${templateRoot}`)\n }\n\n if (\n existsSync(options.projectRoot) &&\n readdirSync(options.projectRoot).length > 0\n ) {\n throw new Error(`Directory is not empty: ${options.projectRoot}`)\n }\n\n mkdirSync(options.projectRoot, { recursive: true })\n cpSync(templateRoot, options.projectRoot, { recursive: true })\n writeFileSync(\n path.join(options.projectRoot, 'app.config.ts'),\n `export default {\\n name: ${JSON.stringify(nameFromDirectory(options.projectRoot))},\\n}\\n`,\n )\n\n console.log(`Created Bleam project at ${options.projectRoot}`)\n}\n\nfunction createDevWorkspace(projectRoot: string, config: ProjectConfig) {\n const workspaceRoot = path.join(projectRoot, '.bleam', 'dev')\n mkdirSync(workspaceRoot, { recursive: true })\n const workspaceNodeModules = path.join(workspaceRoot, 'node_modules')\n if (!existsSync(workspaceNodeModules)) {\n symlinkSync(path.join(packageRoot, 'node_modules'), workspaceNodeModules)\n }\n\n writeFileSync(\n path.join(workspaceRoot, 'app.config.js'),\n `module.exports = ${JSON.stringify(\n {\n expo: {\n name: config.name,\n slug: slugFromName(config.name),\n version: config.version ?? '0.0.0',\n orientation: 'default',\n platforms: ['ios'],\n newArchEnabled: true,\n },\n },\n null,\n 2,\n )}\\n`,\n )\n\n writeFileSync(\n path.join(workspaceRoot, 'index.js'),\n `import { registerApp } from 'bleam/app'\\nimport App from ${JSON.stringify(path.join(projectRoot, 'app'))}\\n\\nregisterApp(App)\\n`,\n )\n\n writeFileSync(\n path.join(workspaceRoot, 'metro.config.js'),\n `const { getDefaultConfig } = require(${JSON.stringify(path.join(packageRoot, 'metro-config.cjs'))})\\n\\nmodule.exports = getDefaultConfig(__dirname)\\n`,\n )\n\n writeFileSync(\n path.join(workspaceRoot, 'package.json'),\n `${JSON.stringify(\n {\n name: `${slugFromName(config.name)}-bleam-dev`,\n version: config.version ?? '0.0.0',\n private: true,\n main: 'index.js',\n dependencies: {\n '@types/react': packageJson.dependencies?.['@types/react'],\n expo: packageJson.dependencies?.expo,\n react: packageJson.dependencies?.react,\n 'react-native': packageJson.dependencies?.['react-native'],\n },\n },\n null,\n 2,\n )}\\n`,\n )\n\n writeFileSync(\n path.join(workspaceRoot, 'tsconfig.json'),\n `${JSON.stringify(\n {\n extends: 'bleam/tsconfig',\n include: [\n path.relative(workspaceRoot, path.join(projectRoot, 'app.tsx')),\n path.relative(workspaceRoot, path.join(projectRoot, 'app.config.ts')),\n ],\n },\n null,\n 2,\n )}\\n`,\n )\n\n return workspaceRoot\n}\n\nfunction writeProjectRuntimeConfig(\n projectRoot: string,\n config: ProjectConfig,\n origin: string,\n) {\n const projectConfigPath = path.join(projectRoot, '.bleam', 'project.json')\n mkdirSync(path.dirname(projectConfigPath), { recursive: true })\n writeFileSync(\n projectConfigPath,\n `${JSON.stringify(\n {\n name: config.name,\n version: config.version,\n bundleIdentifier: config.bundleIdentifier,\n teamId: config.teamId,\n devServer: origin,\n runtimeVersion: config.runtimeVersion,\n sdkVersion: config.sdkVersion,\n },\n null,\n 2,\n )}\\n`,\n )\n return projectConfigPath\n}\n\nfunction runtimeCacheRoot() {\n return path.join(\n os.homedir(),\n 'Library',\n 'Caches',\n 'bleam',\n 'runtimes',\n runtimeVersion,\n runtimePlatform,\n )\n}\n\nfunction localDevelopmentRuntimeAppPath() {\n return path.resolve(\n packageRoot,\n '..',\n '..',\n 'app',\n 'bleam',\n 'build',\n 'Build',\n 'Products',\n 'Debug-maccatalyst',\n 'Bleam.app',\n )\n}\n\nfunction runtimeReleaseBaseUrl() {\n return (\n process.env.BLEAM_RUNTIME_RELEASE_BASE_URL ??\n 'https://github.com/bajedev/bleam-app/releases/download'\n )\n}\n\nfunction runtimeArchiveName() {\n return `bleam-runtime-v${runtimeVersion}-${runtimePlatform}.zip`\n}\n\nfunction runtimeArchiveUrl() {\n const tag = encodeURIComponent(`bleam@${runtimeVersion}`)\n return `${runtimeReleaseBaseUrl()}/${tag}/${runtimeArchiveName()}`\n}\n\nfunction sha256(filePath: string) {\n return createHash('sha256').update(readFileSync(filePath)).digest('hex')\n}\n\nasync function downloadFile(url: string, destination: string) {\n const response = await fetch(url)\n if (!response.ok) {\n throw new Error(\n `Failed to download ${url}: ${response.status} ${response.statusText}`,\n )\n }\n\n const bytes = new Uint8Array(await response.arrayBuffer())\n writeFileSync(destination, bytes)\n}\n\nasync function downloadExpectedSha256(url: string) {\n const response = await fetch(`${url}.sha256`)\n if (!response.ok) {\n return undefined\n }\n\n const text = await response.text()\n return text.trim().split(/\\s+/)[0]\n}\n\nasync function downloadRuntimeArtifact(): Promise<RuntimeArtifact> {\n if (process.platform !== 'darwin') {\n throw new Error(\n 'Bleam runtime artifacts are currently only available on macOS.',\n )\n }\n\n const cacheRoot = runtimeCacheRoot()\n const cachedAppPath = path.join(cacheRoot, 'Bleam.app')\n if (existsSync(cachedAppPath)) {\n return {\n appPath: cachedAppPath,\n version: runtimeVersion,\n platform: runtimePlatform,\n }\n }\n\n mkdirSync(cacheRoot, { recursive: true })\n const archiveUrl = runtimeArchiveUrl()\n const archivePath = path.join(cacheRoot, runtimeArchiveName())\n const extractRoot = path.join(cacheRoot, 'extract')\n\n await downloadFile(archiveUrl, archivePath)\n const expectedSha256 = await downloadExpectedSha256(archiveUrl)\n if (expectedSha256 && sha256(archivePath) !== expectedSha256) {\n rmSync(archivePath, { force: true })\n throw new Error(`Runtime artifact checksum mismatch: ${archiveUrl}`)\n }\n\n rmSync(extractRoot, { recursive: true, force: true })\n mkdirSync(extractRoot, { recursive: true })\n execFileSync('ditto', ['-x', '-k', archivePath, extractRoot], {\n stdio: 'ignore',\n })\n\n const extractedAppPath = path.join(extractRoot, 'Bleam.app')\n if (!existsSync(extractedAppPath)) {\n throw new Error(`Runtime archive did not contain Bleam.app: ${archiveUrl}`)\n }\n\n rmSync(cachedAppPath, { recursive: true, force: true })\n cpSync(extractedAppPath, cachedAppPath, { recursive: true })\n rmSync(extractRoot, { recursive: true, force: true })\n\n return {\n appPath: cachedAppPath,\n version: runtimeVersion,\n platform: runtimePlatform,\n }\n}\n\nasync function resolveRuntimeArtifact(): Promise<RuntimeArtifact> {\n const overrideAppPath = process.env.BLEAM_RUNTIME_APP\n if (overrideAppPath) {\n const appPath = path.resolve(overrideAppPath)\n if (!existsSync(appPath)) {\n throw new Error(`BLEAM_RUNTIME_APP does not exist: ${appPath}`)\n }\n\n return { appPath, version: runtimeVersion, platform: runtimePlatform }\n }\n\n const localAppPath = localDevelopmentRuntimeAppPath()\n if (existsSync(localAppPath)) {\n return {\n appPath: localAppPath,\n version: runtimeVersion,\n platform: runtimePlatform,\n }\n }\n\n return downloadRuntimeArtifact()\n}\n\nfunction copyRuntimeClient(projectRoot: string, runtime: RuntimeArtifact) {\n const clientAppPath = path.join(projectRoot, '.bleam', 'client', 'Bleam.app')\n rmSync(clientAppPath, { recursive: true, force: true })\n mkdirSync(path.dirname(clientAppPath), { recursive: true })\n cpSync(runtime.appPath, clientAppPath, { recursive: true })\n return clientAppPath\n}\n\nfunction waitForDevServer(port: number, timeoutMs = 120_000) {\n return new Promise<void>((resolve, reject) => {\n const startedAt = Date.now()\n\n const poll = () => {\n const req = http.get(`http://localhost:${port}/status`, (res) => {\n let data = ''\n res.on('data', (chunk) => {\n data += chunk.toString()\n })\n res.on('end', () => {\n if (data.includes('packager-status:running')) {\n resolve()\n return\n }\n\n retry()\n })\n })\n\n req.on('error', retry)\n req.setTimeout(2_000, () => {\n req.destroy()\n retry()\n })\n }\n\n const retry = () => {\n if (Date.now() - startedAt > timeoutMs) {\n reject(\n new Error(\n `Bleam dev server did not start within ${timeoutMs / 1000}s`,\n ),\n )\n return\n }\n\n setTimeout(poll, 500)\n }\n\n poll()\n })\n}\n\nfunction isBleamManifest(value: unknown): value is BleamManifest {\n const manifest =\n value && typeof value === 'object' ? (value as Partial<BleamManifest>) : {}\n\n return (\n typeof manifest.name === 'string' &&\n typeof manifest.bundleUrl === 'string' &&\n manifest.platform === 'macos' &&\n manifest.dev === true\n )\n}\n\nasync function readDevManifest(origin: string, timeoutMs = 30_000) {\n const manifestUrl = `${origin}/bleam/manifest.json`\n const startedAt = Date.now()\n\n while (Date.now() - startedAt <= timeoutMs) {\n try {\n const response = await fetch(manifestUrl, { cache: 'no-store' })\n const value: unknown = await response.json()\n if (response.ok && isBleamManifest(value)) {\n return value\n }\n } catch {\n // Metro can answer /status before custom middleware is ready.\n }\n\n await new Promise((resolve) => setTimeout(resolve, 500))\n }\n\n throw new Error(`Bleam manifest did not become available: ${manifestUrl}`)\n}\n\nfunction openRuntimeClient(\n appPath: string,\n projectConfigPath: string,\n manifest: BleamManifest,\n) {\n const child = spawn(\n 'open',\n [\n appPath,\n '--args',\n '--bleam-project-config',\n projectConfigPath,\n '--bleam-bundle-url',\n manifest.bundleUrl,\n '--bleam-title',\n manifest.name,\n ],\n {\n detached: true,\n stdio: 'ignore',\n },\n )\n child.unref()\n}\n\nasync function startDevServer(options: DevOptions) {\n const config = readProjectConfig(options)\n const runtime = await resolveRuntimeArtifact()\n const clientAppPath = copyRuntimeClient(options.projectRoot, runtime)\n const workspaceRoot = createDevWorkspace(options.projectRoot, config)\n const origin = `http://localhost:${options.port}`\n const projectConfigPath = writeProjectRuntimeConfig(\n options.projectRoot,\n config,\n origin,\n )\n const child = spawn(\n process.execPath,\n [\n require.resolve('expo/bin/cli'),\n 'start',\n workspaceRoot,\n '--localhost',\n '--port',\n String(options.port),\n ],\n {\n stdio: 'inherit',\n env: {\n ...process.env,\n BLEAM_DEV: '1',\n BLEAM_PROJECT_ROOT: options.projectRoot,\n BLEAM_DEV_NAME: config.name,\n BLEAM_DEV_ORIGIN: origin,\n BLEAM_DEV_PORT: String(options.port),\n BLEAM_DEV_RUNTIME_VERSION: config.runtimeVersion,\n BLEAM_DEV_SDK_VERSION: config.sdkVersion,\n NODE_PATH: [\n path.join(options.projectRoot, 'node_modules'),\n path.join(packageRoot, 'node_modules'),\n path.dirname(path.dirname(require.resolve('expo/package.json'))),\n path.dirname(path.dirname(require.resolve('react/package.json'))),\n path.dirname(\n path.dirname(require.resolve('react-native/package.json')),\n ),\n process.env.NODE_PATH,\n ]\n .filter(Boolean)\n .join(path.delimiter),\n },\n },\n )\n\n const stop = (signal: NodeJS.Signals) => {\n child.kill(signal)\n }\n\n process.on('SIGINT', () => stop('SIGINT'))\n process.on('SIGTERM', () => stop('SIGTERM'))\n child.on('exit', (code) => process.exit(code ?? 0))\n\n await waitForDevServer(options.port)\n const manifest = await readDevManifest(origin)\n if (process.env.BLEAM_NO_OPEN !== '1') {\n openRuntimeClient(clientAppPath, projectConfigPath, manifest)\n }\n}\n\nasync function main(argv = process.argv.slice(2)) {\n const [command, ...args] = argv\n\n if (!command || command === '--help' || command === '-h') {\n printUsage()\n return\n }\n\n if (command === 'new') {\n const options = parseNewOptions(args)\n createNewProject(options)\n if (options.run) {\n await startDevServer({ projectRoot: options.projectRoot, port: 8082 })\n }\n return\n }\n\n if (command === 'dev') {\n await startDevServer(parseDevOptions(args))\n return\n }\n\n throw new Error(`Unknown command: ${command}`)\n}\n\nmain().catch((error) => {\n console.error(error instanceof Error ? error.message : String(error))\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;AAsDA,MAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAC9C,MAAM,cAAc,KAAK,QACvB,cAAc,IAAI,IAAI,mBAAmB,OAAO,KAAK,IAAI,CAAC,CAC3D;AACD,MAAM,cAAc,QAAQ,kBAAkB;AAI9C,MAAM,iBAAiB,YAAY;AACnC,MAAM,kBAAkB,SAAS,QAAQ;AAEzC,SAAS,aAAa;AACpB,SAAQ,IAAI;;;;sDAIwC;;AAGtD,SAAS,iBAAiB;AACxB,QAAO,KAAK,WAAW,QAAQ,IAAI,OAAO,GAAG,GACzC,QAAQ,IAAI,MACZ,QAAQ,KAAK;;AAGnB,SAAS,gBAAgB,MAA4B;CACnD,MAAM,OAAO,gBAAgB;CAC7B,IAAI,cAAc;CAClB,IAAI,OAAO;CACX,IAAI,oBAAoB;AAExB,MAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,MAAM,KAAK;AAEjB,MAAI,QAAQ,YAAY,QAAQ,MAAM;GACpC,MAAM,QAAQ,KAAK,EAAE;AACrB,UAAO,OAAO,MAAM;AACpB;;AAGF,MAAI,IAAI,WAAW,UAAU,EAAE;AAC7B,UAAO,OAAO,IAAI,MAAM,EAAiB,CAAC;AAC1C;;AAGF,MAAI,QAAQ,YAAY,QAAQ,MAAM;AACpC,eAAY;AACZ,WAAQ,KAAK,EAAE;;AAGjB,MAAI,IAAI,WAAW,IAAI,CACrB,OAAM,IAAI,MAAM,mBAAmB,MAAM;AAG3C,gBAAc,KAAK,QAAQ,MAAM,IAAI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
|
3
|
+
function defineConfig(config) {
|
|
4
|
+
return config;
|
|
5
|
+
}
|
|
6
|
+
function slugFromName(name) {
|
|
7
|
+
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "bleam-app";
|
|
8
|
+
}
|
|
9
|
+
function createExpoConfig(config) {
|
|
10
|
+
return { expo: {
|
|
11
|
+
name: config.name,
|
|
12
|
+
slug: slugFromName(config.name),
|
|
13
|
+
version: config.version ?? "0.0.0",
|
|
14
|
+
orientation: "default",
|
|
15
|
+
platforms: ["ios"],
|
|
16
|
+
newArchEnabled: true,
|
|
17
|
+
extra: { bleam: {
|
|
18
|
+
runtimeVersion: config.version ?? "0.0.0",
|
|
19
|
+
sdkVersion: config.version ?? "0.0.0"
|
|
20
|
+
} }
|
|
21
|
+
} };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.createExpoConfig = createExpoConfig;
|
|
26
|
+
exports.defineConfig = defineConfig;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/config.d.ts
|
|
2
|
+
interface BleamConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
bundleIdentifier?: string;
|
|
6
|
+
teamId?: string;
|
|
7
|
+
}
|
|
8
|
+
interface BleamInternalExpoConfig {
|
|
9
|
+
expo: {
|
|
10
|
+
name: string;
|
|
11
|
+
slug: string;
|
|
12
|
+
version: string;
|
|
13
|
+
orientation: 'default';
|
|
14
|
+
platforms: ['ios'];
|
|
15
|
+
newArchEnabled: true;
|
|
16
|
+
extra: {
|
|
17
|
+
bleam: {
|
|
18
|
+
runtimeVersion: string;
|
|
19
|
+
sdkVersion: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare function defineConfig(config: BleamConfig): BleamConfig;
|
|
25
|
+
declare function createExpoConfig(config: BleamConfig): BleamInternalExpoConfig;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { BleamConfig, BleamInternalExpoConfig, createExpoConfig, defineConfig };
|
|
28
|
+
//# sourceMappingURL=config.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";UAAiB,WAAA;EAAA,IAAA,EAAA,MAAA;EAOA,OAAA,CAAA,EAAA,MAAA;EAiBD,gBAAY,CAAA,EAAA,MAAA;EAcZ,MAAA,CAAA,EAAA,MAAA;;UA/BC,uBAAA;;;;;;;;;;;;;;;;iBAiBD,YAAA,SAAqB,cAAc;iBAcnC,gBAAA,SAAyB,cAAc"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/config.d.ts
|
|
2
|
+
interface BleamConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
bundleIdentifier?: string;
|
|
6
|
+
teamId?: string;
|
|
7
|
+
}
|
|
8
|
+
interface BleamInternalExpoConfig {
|
|
9
|
+
expo: {
|
|
10
|
+
name: string;
|
|
11
|
+
slug: string;
|
|
12
|
+
version: string;
|
|
13
|
+
orientation: 'default';
|
|
14
|
+
platforms: ['ios'];
|
|
15
|
+
newArchEnabled: true;
|
|
16
|
+
extra: {
|
|
17
|
+
bleam: {
|
|
18
|
+
runtimeVersion: string;
|
|
19
|
+
sdkVersion: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare function defineConfig(config: BleamConfig): BleamConfig;
|
|
25
|
+
declare function createExpoConfig(config: BleamConfig): BleamInternalExpoConfig;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { BleamConfig, BleamInternalExpoConfig, createExpoConfig, defineConfig };
|
|
28
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../src/config.ts"],"sourcesContent":[],"mappings":";UAAiB,WAAA;EAAA,IAAA,EAAA,MAAA;EAOA,OAAA,CAAA,EAAA,MAAA;EAiBD,gBAAY,CAAA,EAAA,MAAA;EAcZ,MAAA,CAAA,EAAA,MAAA;;UA/BC,uBAAA;;;;;;;;;;;;;;;;iBAiBD,YAAA,SAAqB,cAAc;iBAcnC,gBAAA,SAAyB,cAAc"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/config.ts
|
|
2
|
+
function defineConfig(config) {
|
|
3
|
+
return config;
|
|
4
|
+
}
|
|
5
|
+
function slugFromName(name) {
|
|
6
|
+
return name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "bleam-app";
|
|
7
|
+
}
|
|
8
|
+
function createExpoConfig(config) {
|
|
9
|
+
return { expo: {
|
|
10
|
+
name: config.name,
|
|
11
|
+
slug: slugFromName(config.name),
|
|
12
|
+
version: config.version ?? "0.0.0",
|
|
13
|
+
orientation: "default",
|
|
14
|
+
platforms: ["ios"],
|
|
15
|
+
newArchEnabled: true,
|
|
16
|
+
extra: { bleam: {
|
|
17
|
+
runtimeVersion: config.version ?? "0.0.0",
|
|
18
|
+
sdkVersion: config.version ?? "0.0.0"
|
|
19
|
+
} }
|
|
20
|
+
} };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { createExpoConfig, defineConfig };
|
|
25
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["export interface BleamConfig {\n name: string\n version?: string\n bundleIdentifier?: string\n teamId?: string\n}\n\nexport interface BleamInternalExpoConfig {\n expo: {\n name: string\n slug: string\n version: string\n orientation: 'default'\n platforms: ['ios']\n newArchEnabled: true\n extra: {\n bleam: {\n runtimeVersion: string\n sdkVersion: string\n }\n }\n }\n}\n\nexport function defineConfig(config: BleamConfig): BleamConfig {\n return config\n}\n\nfunction slugFromName(name: string) {\n return (\n name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '') || 'bleam-app'\n )\n}\n\nexport function createExpoConfig(config: BleamConfig): BleamInternalExpoConfig {\n return {\n expo: {\n name: config.name,\n slug: slugFromName(config.name),\n version: config.version ?? '0.0.0',\n orientation: 'default',\n platforms: ['ios'],\n newArchEnabled: true,\n extra: {\n bleam: {\n runtimeVersion: config.version ?? '0.0.0',\n sdkVersion: config.version ?? '0.0.0',\n },\n },\n },\n }\n}\n"],"mappings":";AAwBA,SAAgB,aAAa,QAAkC;AAC7D,QAAO;;AAGT,SAAS,aAAa,MAAc;AAClC,QACE,KACG,MAAM,CACN,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,UAAU,GAAG,IAAI;;AAIhC,SAAgB,iBAAiB,QAA8C;AAC7E,QAAO,EACL,MAAM;EACJ,MAAM,OAAO;EACb,MAAM,aAAa,OAAO,KAAK;EAC/B,SAAS,OAAO,WAAW;EAC3B,aAAa;EACb,WAAW,CAAC,MAAM;EAClB,gBAAgB;EAChB,OAAO,EACL,OAAO;GACL,gBAAgB,OAAO,WAAW;GAClC,YAAY,OAAO,WAAW;GAC/B,EACF;EACF,EACF"}
|