Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
UserSettings.getAsync('sendTo').then((sendTo) => {
this.setState({sendTo});
}, (err) => {
// Probably means that there's no saved value here; not a huge deal
// console.error("Error getting sendTo:", err);
});
Exp.recentValidExpsAsync().then((recentExps) => {
this.setState({recentExps});
}, (err) => {
console.error("Couldn't get list of recent Exps :(", err);
});
// this._versionStringAsync().then((vs) => {
// this.setState({versionString: vs});
// }, (err) => {
// console.error("Couldn't get version string :(", err);
_publishClickedAsync = async () => {
let confirmBeforePublish = await UserSettings.getAsync('confirmBeforePublish', true);
if (confirmBeforePublish) {
let { dialog } = remote;
// Yes = 0
// Yes, don't ask again = 1
// No = 2
var choice = dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'question',
buttons: ['Yes', `Yes, don't ask again`, 'No'],
title: 'Confirm',
message: 'This will make your experience publicly accessible. Continue?',
});
if (choice === 1) {
await UserSettings.mergeAsync({ confirmBeforePublish: false });
async function askForMobileNumberAsync() {
var phoneNumberFromSettings = await UserSettings.getAsync('phoneNumber', null);
console.log("Enter a mobile number or e-mail and we'll send a link to your phone.");
var answers = await inquirerAsync.promptAsync([{
type: 'input',
name: 'mobileNumber',
message: "Your mobile number or e-mail" + (phoneNumberFromSettings ? " (space to not send anything)" : '') + ":",
default: phoneNumberFromSettings,
}]);
return answers.mobileNumber.trim();
}
log(chalk.gray('Starting project at', projectDir));
let rootPath = path.resolve(projectDir);
let devToolsUrl = await DevToolsServer.startAsync(rootPath);
log(`Expo DevTools is running at ${chalk.underline(devToolsUrl)}`);
const { exp } = await ProjectUtils.readConfigJsonAsync(projectDir);
if (exp === null) {
log.warn('No Expo configuration found. Are you sure this is a project directory?');
process.exit(1);
}
const nonInteractive = options.parent && options.parent.nonInteractive;
if (!nonInteractive && !exp.isDetached) {
if (await UserSettings.getAsync('openDevToolsAtStartup', true)) {
log(`Opening DevTools in the browser... (press ${chalk.bold`shift-d`} to disable)`);
opn(devToolsUrl, { wait: false });
} else {
log(
`Press ${chalk.bold`d`} to open DevTools now, or ${chalk.bold`shift-d`} to always open it automatically.`
);
}
}
const startOpts = await parseStartOptionsAsync(projectDir, options);
await Project.startAsync(rootPath, startOpts);
await Web.logURL(projectDir);
const url = await UrlUtils.constructManifestUrlAsync(projectDir);
const localAddress = await UrlUtils.constructManifestUrlAsync(projectDir, {
hostType: 'localhost'
})
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(localAddress)
if (!success) {
log(chalk.red(msg))
}
printUsage()
return
}
case 's': {
stopWaitingForCommand()
const lanAddress = await UrlUtils.constructManifestUrlAsync(projectDir, {
hostType: 'lan'
})
const defaultRecipient = await UserSettings.getAsync('sendTo', null)
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
const handleKeypress = (chr, key) => {
if (key && key.name === 'escape') {
cleanup()
cancel()
}
}
const cleanup = () => {
rl.close()
process.stdin.removeListener('keypress', handleKeypress)
startWaitingForCommand()
}
const cancel = () => {
const localAddress = await UrlUtils.constructManifestUrlAsync(process.cwd(), {
hostType: 'localhost',
});
const { success, msg } = await Simulator.openUrlInSimulatorSafeAsync(localAddress);
if (!success) {
log(chalk.red(msg));
}
printUsage();
return;
}
case 's': {
stopWaitingForCommand();
const lanAddress = await UrlUtils.constructManifestUrlAsync(process.cwd(), {
hostType: 'lan',
});
const defaultRecipient = await UserSettings.getAsync('sendTo', null);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const handleKeypress = (chr, key) => {
if (key && key.name === 'escape') {
cleanup();
cancel();
}
};
const cleanup = () => {
rl.close();
process.stdin.removeListener('keypress', handleKeypress);
startWaitingForCommand();
};
const cancel = () => {
async function getRecipient(sendTo) {
let recipient;
if (sendTo) {
if (typeof sendTo !== 'boolean') {
recipient = sendTo;
} else {
recipient = await UserSettings.getAsync('sendTo', null);
}
if (!recipient) {
recipient = await askUser.askForSendToAsync();
}
}
return recipient;
}
_loadTemplatesAsync = async () => {
let versions = await Api.versionsAsync();
let dir = await UserSettings.getAsync('defaultNewProjectDir', os.homedir());
this.setState({
isLoading: false,
templates: versions.templatesv2,
selectedTemplate: versions.templatesv2[0],
projectDirectory: dir,
});
};
.asyncAction(async options => {
const user = await User.ensureLoggedInAsync();
const { username } = user;
let normalizedUsername = username.replace(/[^0-9a-zA-Z]/g, '');
let sandboxBundleId = await UserSettings.getAsync('sandboxBundleId', null);
if (!sandboxBundleId) {
sandboxBundleId = UrlUtils.randomIdentifier(5);
await UserSettings.mergeAsync({ sandboxBundleId });
}
options.type = 'client';
options.releaseChannel = 'default';
options.hardcodeRevisionId = 'eb310d00-2af3-11e8-9906-3ba982c41215';
let projectDir = path.join(UserSettings.dotExpoHomeDirectory(), 'expo-home');
rimraf.sync(projectDir);
mkdirp.sync(projectDir);
let modifiedAppJSON = HOME_APP_JSON;
modifiedAppJSON.expo.ios.bundleIdentifier = `host.exp.${normalizedUsername}-${sandboxBundleId}`;
modifiedAppJSON.expo.ios.config.actualBundleIdentifier =