Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
).ejectMethod;
if (ejectMethod === 'bare') {
await ejectToBareAsync(projectRoot);
log.nested(chalk.green('Ejected successfully!'));
log.newLine();
log.nested(
`Before running your app on iOS, make sure you have CocoaPods installed and initialize the project:`
);
log.nested('');
log.nested(` cd ios`);
log.nested(` pod install`);
log.nested('');
log.nested('Then you can run the project:');
log.nested('');
let packageManager = ConfigUtils.isUsingYarn(projectRoot) ? 'yarn' : 'npm';
log.nested(` ${packageManager === 'npm' ? 'npm run android' : 'yarn android'}`);
log.nested(` ${packageManager === 'npm' ? 'npm run ios' : 'yarn ios'}`);
await warnIfDependenciesRequireAdditionalSetupAsync(projectRoot);
} else if (ejectMethod === 'expokit') {
await loginOrRegisterIfLoggedOut();
await Detach.detachAsync(projectRoot, options);
log(chalk.green('Ejected successfully!'));
} else if (ejectMethod === 'cancel') {
// we don't want to print the survey for cancellations
log('OK! If you change your mind you can run this command again.');
} else {
throw new Error(
`Unrecognized eject method "${ejectMethod}". Valid options are: bare, expokit.`
);
}
}
export function createForProject(projectRoot: string, options: CreateForProjectOptions = {}) {
console.warn(
'`createForProject` is deprecated in favor of `createForProject` from `@expo/package-manager`'
);
let PackageManager;
if (options.npm) {
PackageManager = NpmPackageManager;
} else if (options.yarn) {
PackageManager = YarnPackageManager;
} else if (isUsingYarn(projectRoot)) {
PackageManager = YarnPackageManager;
} else {
PackageManager = NpmPackageManager;
}
return new PackageManager({ cwd: projectRoot });
}
async function ejectToBareAsync(projectRoot: string): Promise {
const useYarn = ConfigUtils.isUsingYarn(projectRoot);
const npmOrYarn = useYarn ? 'yarn' : 'npm';
const { configPath, configName } = ConfigUtils.findConfigFile(projectRoot);
const { exp, pkg } = await ConfigUtils.readConfigJsonAsync(projectRoot);
const configBuffer = await fse.readFile(configPath);
const appJson = configName === 'app.json' ? JSON.parse(configBuffer.toString()) : {};
/**
* Perform validations
*/
if (!exp.sdkVersion) throw new Error(`Couldn't read ${configName}`);
if (!Versions.gteSdkVersion(exp, '34.0.0')) {
throw new Error(`Ejecting to a bare project is only available for SDK 34 and higher`);
}
const port = await getAvailablePortAsync({
defaultPort: options.port,
});
webpackServerPort = port;
ProjectUtils.logInfo(
projectRoot,
WEBPACK_LOG_TAG,
withTag(
`Starting ${serverName} on port ${webpackServerPort} in ${chalk.underline(env.mode)} mode.`
)
);
const protocol = env.https ? 'https' : 'http';
const urls = prepareUrls(protocol, '::', webpackServerPort);
const useYarn = ConfigUtils.isUsingYarn(projectRoot);
const appName = await getProjectNameAsync(projectRoot);
const nonInteractive = validateBoolOption(
'nonInteractive',
options.nonInteractive,
!process.stdout.isTTY
);
let server: DevServer;
devServerInfo = {
urls,
protocol,
useYarn,
appName,
nonInteractive,
port: webpackServerPort!,