UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

62 lines (61 loc) 2.45 kB
import * as fs from "fs"; import * as path from "path"; function getBundleIdFromConfig(root) { var appJsonPath = path.join(root, "app.json"); if (!fs.existsSync(appJsonPath)) { return void 0; } try { var _appConfig_expo_ios, _appConfig_expo, _appConfig_expo_android, _appConfig_expo1, _appConfig_expo2, _appConfig_expo3; var appConfig = JSON.parse(fs.readFileSync(appJsonPath, "utf-8")); if ((_appConfig_expo = appConfig.expo) === null || _appConfig_expo === void 0 ? void 0 : (_appConfig_expo_ios = _appConfig_expo.ios) === null || _appConfig_expo_ios === void 0 ? void 0 : _appConfig_expo_ios.bundleIdentifier) { return appConfig.expo.ios.bundleIdentifier; } if ((_appConfig_expo1 = appConfig.expo) === null || _appConfig_expo1 === void 0 ? void 0 : (_appConfig_expo_android = _appConfig_expo1.android) === null || _appConfig_expo_android === void 0 ? void 0 : _appConfig_expo_android.package) { return appConfig.expo.android.package; } if ((_appConfig_expo2 = appConfig.expo) === null || _appConfig_expo2 === void 0 ? void 0 : _appConfig_expo2.slug) { return appConfig.expo.slug; } if ((_appConfig_expo3 = appConfig.expo) === null || _appConfig_expo3 === void 0 ? void 0 : _appConfig_expo3.name) { return appConfig.expo.name.toLowerCase().replace(/\s+/g, "-"); } if (appConfig.name) { return appConfig.name.toLowerCase().replace(/\s+/g, "-"); } return void 0; } catch (unused) { return void 0; } } var MAX_PORT = 65535; function getAvailablePort(preferredPort, excludePort) { return new Promise(function (resolve, reject) { import("net").then(function (netModule) { var tryPort = function (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; } var server = netModule.createServer(); server.once("error", function () { server.close(); tryPort(port + 1); }); server.once("listening", function () { server.close(function () { resolve(port); }); }); server.listen(port, "0.0.0.0"); }; tryPort(preferredPort); }); }); } export { getAvailablePort, getBundleIdFromConfig }; //# sourceMappingURL=utils.native.js.map