1 line
15 KiB
Plaintext
1 line
15 KiB
Plaintext
{"version":3,"sources":["expo.js"],"names":["loginOrRegister","user","appJsonPath","join","process","cwd","JSON","readFile","appJson","parse","expo","ios","bundleIdentifier","platform","console","log","cyan","prompt","name","message","iosBundleIdentifier","android","package","androidPackage","writeFile","detachAsync","stdin","pause","resolve","toString","pkgJson","main","devDependencies","scripts","start","build","eject","versionsAsync","versions","sdkTag","sdkVersions","sdkVersion","expoReactNativeTag","reactNativeVersion","silent","code","green","warn","yellow","detach","getCurrentUserAsync","currentUser","loggedInQuestions","type","nickname","choices","value","stayLoggedIn","logoutAsync","questions","action","githubAuthAsync","registerAsync","usernamePasswordAuthAsync","loginAsync","Error","validate","validator","answers","data","username","password","val","trim","registeredUser","AUTH_CLIENT_ID","initialize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;sFAeO;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACcA,iBADd;;AAAA;AACCC,gBADD;AAGCC,uBAHD,GAGe,eAAKC,IAAL,CAAUC,QAAQC,GAAR,EAAV,EAAyB,UAAzB,CAHf;AAAA,0BAIWC,IAJX;AAAA;AAAA,mBAI4B,kBAAIC,QAAJ,CAAaL,WAAb,CAJ5B;;AAAA;AAAA;AAICM,mBAJD,eAIgBC,KAJhB;;AAAA,kBAMD,CAAC,CAACD,QAAQE,IAAR,CAAaC,GAAd,IAAqB,CAACH,QAAQE,IAAR,CAAaC,GAAb,CAAiBC,gBAAxC,KAA6DR,QAAQS,QAAR,KAAqB,QANjF;AAAA;AAAA;AAAA;;AAOHC,oBAAQC,GAAR,wLAIA,gBAAMC,IAAN,CAAW,kGAAX,CAJA;AAPG;AAAA,mBAcmC,mBAASC,MAAT,CAAgB,CACpD;AACEC,oBAAM,qBADR;AAEEC,uBAAS;AAFX,aADoD,CAAhB,CAdnC;;AAAA;AAAA;AAcKC,+BAdL,SAcKA,mBAdL;;;AAqBHZ,oBAAQE,IAAR,CAAaC,GAAb,GAAmBH,QAA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AY,4BAAZ,CAAZ;;AA7DF,8CA+DS4B,cA/DT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;kBAAeZ,a;;;;;AAvOf;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AAEA;;;;AAIA,IAAMa,iBAAiB,kCAAvB;AACA,UAAYC,UAAZ,CAAuBD,cAAvB;;AAoLA,SAASR,SAAT,CAAmBK,GAAnB,EAAyC;AACvC,MAAIA,IAAIC,IAAJ,OAAe,EAAnB,EAAuB;AACrB,WAAO,KAAP;AACD;AACD,SAAO,IAAP;AACD","file":"expo.js","sourcesContent":["// @flow\n\nimport chalk from 'chalk';\nimport fse from 'fs-extra';\nimport inquirer from 'inquirer';\nimport path from 'path';\nimport install from '../util/install';\n\nimport { Detach, User as UserManager, Versions } from 'xdl';\n\nimport type { User } from 'xdl/build/User';\n\nconst AUTH_CLIENT_ID = 'MGQh3rK3WZFWhJ91BShagHggMOhrE6nR';\nUserManager.initialize(AUTH_CLIENT_ID);\n\nexport async function detach() {\n const user = await loginOrRegister();\n\n const appJsonPath = path.join(process.cwd(), 'app.json');\n const appJson = JSON.parse(await fse.readFile(appJsonPath));\n\n if ((!appJson.expo.ios || !appJson.expo.ios.bundleIdentifier) && process.platform === 'darwin') {\n console.log(\n `\nYou'll need to specify an iOS bundle identifier. It must be unique on the App Store if you want to\npublish it there. See this StackOverflow question for more information:\n ${chalk.cyan('https://stackoverflow.com/questions/11347470/what-does-bundle-identifier-mean-in-the-ios-project')}\n`\n );\n const { iosBundleIdentifier } = await inquirer.prompt([\n {\n name: 'iosBundleIdentifier',\n message: 'What would you like your iOS bundle identifier to be?',\n },\n ]);\n\n appJson.expo.ios = appJson.expo.ios || {};\n appJson.expo.ios.bundleIdentifier = iosBundleIdentifier;\n }\n\n // check for android.package field, prompt interactively\n if (!appJson.expo.android || !appJson.expo.android.package) {\n console.log(\n `\nYou'll need to specify an Android package name. It must be unique on the Play Store if you want to\npublish it there. See this StackOverflow question for more information:\n ${chalk.cyan('https://stackoverflow.com/questions/6273892/android-package-name-convention')}\n`\n );\n\n const { androidPackage } = await inquirer.prompt([\n {\n name: 'androidPackage',\n message: 'What would you like your Android package name to be?',\n },\n ]);\n\n appJson.expo.android = appJson.expo.android || {};\n appJson.expo.android.package = androidPackage;\n }\n\n // update app.json file with new contents\n await fse.writeFile(appJsonPath, JSON.stringify(appJson, null, 2));\n\n await Detach.detachAsync(process.cwd());\n // yesno lib doesn't properly shut down. without this the command won't exit\n process.stdin.pause();\n\n const pkgJson = JSON.parse((await fse.readFile(path.resolve('package.json'))).toString());\n\n pkgJson.main = 'node_modules/expo/AppEntry.js';\n\n delete pkgJson.devDependencies['react-native-scripts'];\n delete pkgJson.scripts.start;\n delete pkgJson.scripts.build;\n delete pkgJson.scripts.eject;\n delete pkgJson.scripts.android;\n delete pkgJson.scripts.ios;\n\n const versions = await Versions.versionsAsync();\n const sdkTag = versions.sdkVersions[appJson.expo.sdkVersion].expoReactNativeTag;\n\n await fse.writeFile('package.json', JSON.stringify(pkgJson, null, 2));\n\n console.log('Installing the Expo fork of react-native...');\n const reactNativeVersion = `https://github.com/expo/react-native/archive/${sdkTag}.tar.gz`;\n const {\n code,\n } = await install(process.cwd(), 'react-native', reactNativeVersion, {\n silent: true,\n });\n\n if (code === 0) {\n console.log(`${chalk.green('Successfully set up ExpoKit!')}`);\n } else {\n console.warn(\n `\n ${chalk.yellow('Unable to install the Expo fork of react-native.')}\n ${chalk.yellow(`Please install react-native@${reactNativeVersion} before continuing.`)}\n `\n );\n }\n\n console.log(\n `\n You'll need to use Expo's XDE to run this project:\n ${chalk.cyan('https://docs.expo.io/versions/latest/introduction/installation.html')}\n\n For further instructions, please read ExpoKit's build documentation:\n ${chalk.cyan('https://docs.expo.io/versions/latest/guides/expokit.html')}\n `\n );\n}\n\nasync function loginOrRegister(): Promise<?User> {\n console.log(chalk.yellow('\\nAn Expo account is required to proceed.\\n'));\n const currentUser = await UserManager.getCurrentUserAsync();\n\n if (currentUser) {\n const loggedInQuestions = [\n {\n type: 'list',\n name: 'stayLoggedIn',\n message: `It appears you're already logged in to Expo as \\\n${chalk.green(currentUser.nickname)}, would you like to continue with this account?`,\n choices: [\n {\n name: `Yes, continue as ${currentUser.nickname}.`,\n value: true,\n },\n {\n name: \"No, I'd like to start a new session.\",\n value: false,\n },\n ],\n },\n ];\n\n const { stayLoggedIn } = await inquirer.prompt(loggedInQuestions);\n\n if (stayLoggedIn) {\n return currentUser;\n } else {\n await UserManager.logoutAsync();\n console.log(chalk.green('\\nSuccessfully logged out!\\n'));\n }\n }\n\n const questions = [\n {\n type: 'list',\n name: 'action',\n message: 'How would you like to authenticate?',\n choices: [\n {\n name: 'Make a new Expo account',\n value: 'register',\n },\n {\n name: 'Log in with an existing Expo account',\n value: 'existingUser',\n },\n {\n name: 'Cancel',\n value: 'cancel',\n },\n ],\n },\n ];\n\n const { action } = await inquirer.prompt(questions);\n\n if (action === 'github') {\n return await githubAuthAsync();\n } else if (action === 'register') {\n return await registerAsync();\n } else if (action === 'existingUser') {\n return await usernamePasswordAuthAsync();\n } else {\n return null;\n }\n}\n\nasync function githubAuthAsync(): Promise<User> {\n let user = await UserManager.loginAsync('github');\n if (user) {\n console.log(chalk.green(`\\nSuccessfully logged in as ${user.nickname} with GitHub!`));\n return user;\n } else {\n throw new Error('Unexpected Error: No user returned from the API');\n }\n}\n\nfunction validator(val: string): boolean {\n if (val.trim() === '') {\n return false;\n }\n return true;\n}\n\nasync function usernamePasswordAuthAsync(): Promise<User> {\n const questions = [\n {\n type: 'input',\n name: 'username',\n message: 'Username/Email Address:',\n validate: validator,\n },\n {\n type: 'password',\n name: 'password',\n message: 'Password:',\n validate: validator,\n },\n ];\n\n const answers = await inquirer.prompt(questions);\n\n const data = {\n username: answers.username,\n password: answers.password,\n };\n\n let user = await UserManager.loginAsync('user-pass', data);\n\n if (user) {\n console.log(chalk.green(`\\nSuccessfully logged in as ${user.nickname}!`));\n return user;\n } else {\n throw new Error('Unexpected Error: No user returned from the Expo API');\n }\n}\n\nasync function registerAsync(): Promise<User> {\n console.log(\n `\nThanks for signing up for Expo!\nJust a few questions:\n`\n );\n\n const questions = [\n {\n type: 'input',\n name: 'givenName',\n message: 'First (Given) Name:',\n validate: validator,\n },\n {\n type: 'input',\n name: 'familyName',\n message: 'Last (Family) Name:',\n validate: validator,\n },\n {\n type: 'input',\n name: 'username',\n message: 'Username:',\n validate: validator,\n },\n {\n type: 'input',\n name: 'email',\n message: 'Email Address:',\n validate: validator,\n },\n {\n type: 'password',\n name: 'password',\n message: 'Password:',\n validate: validator,\n },\n {\n type: 'password',\n name: 'passwordRepeat',\n message: 'Password Repeat:',\n validate(val, answers) {\n if (val.trim() === '') {\n return false;\n }\n if (val.trim() !== answers.password.trim()) {\n return `Passwords don't match!`;\n }\n return true;\n },\n },\n ];\n\n const answers = await inquirer.prompt(questions);\n\n const registeredUser = await UserManager.registerAsync({\n ...answers,\n });\n\n console.log(chalk.green('\\nRegistration successful!'));\n\n return registeredUser;\n}\n"]} |