one
Version:
One is a new React Framework that makes Vite serve both native and web.
46 lines (45 loc) • 2.23 kB
JavaScript
import * as fs from "fs";
import * as path from "path";
function getBundleIdFromConfig(root) {
var appJsonPath = path.join(root, "app.json");
if (fs.existsSync(appJsonPath)) try {
var _appConfig_expo_ios,
_appConfig_expo,
_appConfig_expo_android,
_appConfig_expo1,
_appConfig_expo2,
_appConfig_expo3,
appConfig = JSON.parse(fs.readFileSync(appJsonPath, "utf-8"));
return !((_appConfig_expo = appConfig.expo) === null || _appConfig_expo === void 0 || (_appConfig_expo_ios = _appConfig_expo.ios) === null || _appConfig_expo_ios === void 0) && _appConfig_expo_ios.bundleIdentifier ? appConfig.expo.ios.bundleIdentifier : !((_appConfig_expo1 = appConfig.expo) === null || _appConfig_expo1 === void 0 || (_appConfig_expo_android = _appConfig_expo1.android) === null || _appConfig_expo_android === void 0) && _appConfig_expo_android.package ? appConfig.expo.android.package : !((_appConfig_expo2 = appConfig.expo) === null || _appConfig_expo2 === void 0) && _appConfig_expo2.slug ? appConfig.expo.slug : !((_appConfig_expo3 = appConfig.expo) === null || _appConfig_expo3 === void 0) && _appConfig_expo3.name ? appConfig.expo.name.toLowerCase().replace(/\s+/g, "-") : appConfig.name ? appConfig.name.toLowerCase().replace(/\s+/g, "-") : void 0;
} catch {
return;
}
}
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