one
Version:
One is a new React Framework that makes Vite serve both native and web.
61 lines (60 loc) • 1.74 kB
JavaScript
import * as fs from "node:fs";
import * as path from "node:path";
function getBundleIdFromConfig(root) {
const appJsonPath = path.join(root, "app.json");
if (!fs.existsSync(appJsonPath)) {
return void 0;
}
try {
const appConfig = JSON.parse(fs.readFileSync(appJsonPath, "utf-8"));
if (appConfig.expo?.ios?.bundleIdentifier) {
return appConfig.expo.ios.bundleIdentifier;
}
if (appConfig.expo?.android?.package) {
return appConfig.expo.android.package;
}
if (appConfig.expo?.slug) {
return appConfig.expo.slug;
}
if (appConfig.expo?.name) {
return appConfig.expo.name.toLowerCase().replace(/\s+/g, "-");
}
if (appConfig.name) {
return appConfig.name.toLowerCase().replace(/\s+/g, "-");
}
return void 0;
} catch {
return void 0;
}
}
const MAX_PORT = 65535;
function getAvailablePort(preferredPort, excludePort) {
return new Promise((resolve, reject) => {
import("node:net").then(netModule => {
const tryPort = port => {
if (port > MAX_PORT) {
reject(new Error(`No available port found between ${preferredPort} and ${MAX_PORT}`));
return;
}
if (port === excludePort) {
tryPort(port + 1);
return;
}
const server = netModule.createServer();
server.once("error", () => {
server.close();
tryPort(port + 1);
});
server.once("listening", () => {
server.close(() => {
resolve(port);
});
});
server.listen(port, "0.0.0.0");
};
tryPort(preferredPort);
});
});
}
export { getAvailablePort, getBundleIdFromConfig };
//# sourceMappingURL=utils.mjs.map