@expo/cli 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -10
- package/build/bin/cli +2 -2
- package/build/src/api/graphql/client.js +3 -1
- package/build/src/api/graphql/client.js.map +1 -1
- package/build/src/api/rest/client.js +5 -2
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithProxy.js +25 -0
- package/build/src/api/rest/wrapFetchWithProxy.js.map +1 -0
- package/build/src/export/fork-bundleAsync.js +2 -1
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js +6 -2
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +6 -33
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +2 -2
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +1 -3
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +3 -46
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +2 -1
- package/build/src/run/ios/XcodeBuild.js.map +1 -1
- package/build/src/run/ios/codeSigning/simulatorCodeSigning.js +45 -0
- package/build/src/run/ios/codeSigning/simulatorCodeSigning.js.map +1 -0
- package/build/src/start/doctor/ngrok/NgrokResolver.js +5 -0
- package/build/src/start/doctor/ngrok/NgrokResolver.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +6 -1
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/adbReverse.js +10 -0
- package/build/src/start/platforms/android/adbReverse.js.map +1 -1
- package/build/src/start/resolveOptions.js +1 -1
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +58 -14
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +4 -1
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +20 -5
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +1 -6
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +36 -5
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +4 -2
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +7 -3
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +2 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +1 -1
- package/build/src/start/server/middleware/resolvePlatform.js +3 -2
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +2 -8
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/codesigning.js +3 -0
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/downloadAppAsync.js +1 -2
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/env.js +37 -1
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/npm.js +4 -11
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/url.js +2 -2
- package/build/src/utils/url.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +3 -3
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/utils/variadic.js +18 -0
- package/build/src/utils/variadic.js.map +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport fetch from 'node-fetch';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}) {\n if (template) {\n await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetch(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<void> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n) {\n let repoInfo: RepoInfo | undefined;\n\n if (template) {\n // @ts-ignore\n let repoUrl: URL | undefined;\n\n try {\n // @ts-ignore\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n await extractLocalNpmTarballAsync(templatePath, { cwd: templateDirectory, name: appName });\n return templateDirectory;\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n }\n\n if (repoInfo) {\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n }\n\n return true;\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetch","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","repoInfo","repoUrl","URL","error","code","fail","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","found","text","bold","cyan"],"mappings":"AAAA;;;;QA0BsBA,kBAAkB,GAAlBA,kBAAkB;QAmFlBC,uBAAuB,GAAvBA,uBAAuB;AA5G3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACD,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAEb,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC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ACqC,OAAO,EAAEF,YAAY,CAAC,CAAC;QAEpD,IAAI,CAACC,QAAQ,EAAE;YACbH,WAAW,CAACQ,IAAI,CACd,CAAC,0BAA0B,EAAEO,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,CAAC,EAAE7D,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAC7F,CAAC;YACF,MAAM,IAAI8D,OAAiB,kBAAA,EAAE,CAAC;SAC/B;QAED,MAAMC,KAAK,GAAG,MAAM/B,OAAO,CAACgB,QAAQ,CAAC,AAAC;QAEtC,IAAI,CAACe,KAAK,EAAE;YACVlB,WAAW,CAACQ,IAAI,CACd,CAAC,oCAAoC,EAAEO,MAAK,QAAA,CAACC,GAAG,CAC9C,CAAC,CAAC,EAAE7D,QAAQ,CAAC,CAAC,CAAC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;YACF,MAAM,IAAI8D,OAAiB,kBAAA,EAAE,CAAC;SAC/B;KACF;IAED,IAAId,QAAQ,EAAE;QACZH,WAAW,CAACmB,IAAI,GAAGJ,MAAK,QAAA,CAACK,IAAI,CAC3B,CAAC,4BAA4B,EAAEL,MAAK,QAAA,CAACM,IAAI,CAAClE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;QAEF,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEiD,QAAQ,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;CACb"}
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}) {\n if (template) {\n await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<void> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n) {\n let repoInfo: RepoInfo | undefined;\n\n if (template) {\n // @ts-ignore\n let repoUrl: URL | undefined;\n\n try {\n // @ts-ignore\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n await extractLocalNpmTarballAsync(templatePath, { cwd: templateDirectory, name: appName });\n return templateDirectory;\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n }\n\n if (repoInfo) {\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n }\n\n return true;\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","repoInfo","repoUrl","URL","error","code","fail","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","found","text","bold","cyan"],"mappings":"AAAA;;;;QA0BsBA,kBAAkB,GAAlBA,kBAAkB;QAmFlBC,uBAAuB,GAAvBA,uBAAuB;AA5G3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEA,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACnCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACiC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAK1D,IAAA,IAAc,WAAd,cAAc,CAAA;AACG,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,AAAsB,AAAC;AAS/E,eAAeJ,kBAAkB,CAAC,EACvCK,iBAAiB,CAAA,EACjBC,QAAQ,CAAA,EACRC,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K,GAAG,MAAM/B,OAAO,CAACgB,QAAQ,CAAC,AAAC;QAEtC,IAAI,CAACe,KAAK,EAAE;YACVlB,WAAW,CAACQ,IAAI,CACd,CAAC,oCAAoC,EAAEO,MAAK,QAAA,CAACC,GAAG,CAC9C,CAAC,CAAC,EAAE7D,QAAQ,CAAC,CAAC,CAAC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;YACF,MAAM,IAAI8D,OAAiB,kBAAA,EAAE,CAAC;SAC/B;KACF;IAED,IAAId,QAAQ,EAAE;QACZH,WAAW,CAACmB,IAAI,GAAGJ,MAAK,QAAA,CAACK,IAAI,CAC3B,CAAC,4BAA4B,EAAEL,MAAK,QAAA,CAACM,IAAI,CAAClE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;QAEF,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEiD,QAAQ,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;CACb"}
|
|
@@ -50,7 +50,6 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
50
50
|
template,
|
|
51
51
|
templateDirectory,
|
|
52
52
|
exp,
|
|
53
|
-
pkg,
|
|
54
53
|
platforms
|
|
55
54
|
});
|
|
56
55
|
(0, _profile).profile(_writeMetroConfig.writeMetroConfig)(projectRoot, {
|
|
@@ -73,7 +72,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
73
72
|
* Extract the template and copy the ios and android directories over to the project directory.
|
|
74
73
|
*
|
|
75
74
|
* @return `true` if any project files were created.
|
|
76
|
-
*/ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp ,
|
|
75
|
+
*/ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp , platforms }) {
|
|
77
76
|
const ora = (0, _ora).logNewSection("Creating native project directories (./ios and ./android) and updating .gitignore");
|
|
78
77
|
try {
|
|
79
78
|
await (0, _resolveTemplate).cloneTemplateAsync({
|
|
@@ -83,7 +82,6 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
83
82
|
ora
|
|
84
83
|
});
|
|
85
84
|
const results = await (0, _copyTemplateFiles).copyTemplateFilesAsync(projectRoot, {
|
|
86
|
-
pkg,
|
|
87
85
|
templateDirectory,
|
|
88
86
|
platforms
|
|
89
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { writeMetroConfig } from './writeMetroConfig';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is ejecting, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { writeMetroConfig } from './writeMetroConfig';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is ejecting, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n profile(writeMetroConfig)(projectRoot, { pkg, templateDirectory });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall:\n copiedPaths.includes('ios') ||\n depsResults.hasNewDependencies ||\n depsResults.hasNewDevDependencies,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nasync function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n platforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n platforms: ModPlatform[];\n}): Promise<string[]> {\n const ora = logNewSection(\n 'Creating native project directories (./ios and ./android) and updating .gitignore'\n );\n\n try {\n await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const results = await copyTemplateFilesAsync(projectRoot, {\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return results.copiedPaths;\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail('Failed to create the native project.');\n Log.log(\n chalk.yellow(\n 'You may want to delete the `./ios` and/or `./android` directories before trying again.'\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","profile","cloneTemplateAndCopyToProjectAsync","writeMetroConfig","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","hasNewDependencies","hasNewDevDependencies","ora","logNewSection","cloneTemplateAsync","results","copyTemplateFilesAsync","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;AAhB3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc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;
|
|
6
6
|
exports.updatePkgDependencies = updatePkgDependencies;
|
|
7
7
|
exports.createDependenciesMap = createDependenciesMap;
|
|
8
|
-
exports.isPkgMainExpoAppEntry = isPkgMainExpoAppEntry;
|
|
9
8
|
exports.hashForDependencyMap = hashForDependencyMap;
|
|
10
9
|
exports.createFileHash = createFileHash;
|
|
11
|
-
exports.shouldDeleteMainField = shouldDeleteMainField;
|
|
12
10
|
var _config = require("@expo/config");
|
|
13
11
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
14
12
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
@@ -44,7 +42,7 @@ function _interopRequireWildcard(obj) {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , skipDependencyUpdate }) {
|
|
47
|
-
const updatingPackageJsonStep = (0, _ora).logNewSection("Updating your package.json scripts,
|
|
45
|
+
const updatingPackageJsonStep = (0, _ora).logNewSection("Updating your package.json scripts, and dependencies");
|
|
48
46
|
const templatePkg = (0, _config).getPackageJson(templateDirectory);
|
|
49
47
|
const results = modifyPackageJson(projectRoot, {
|
|
50
48
|
templatePkg,
|
|
@@ -54,10 +52,7 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
|
|
|
54
52
|
await _fs.default.promises.writeFile(_path.default.resolve(projectRoot, "package.json"), // Add new line to match the format of running yarn.
|
|
55
53
|
// This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.
|
|
56
54
|
JSON.stringify(pkg, null, 2) + "\n");
|
|
57
|
-
updatingPackageJsonStep.succeed("Updated package.json
|
|
58
|
-
if (results.removedMainField) {
|
|
59
|
-
Log.log(`\u203A Removed ${_chalk.default.bold(`"main": "${results.removedMainField}"`)} from package.json because we recommend using index.js as main instead\n`);
|
|
60
|
-
}
|
|
55
|
+
updatingPackageJsonStep.succeed("Updated package.json");
|
|
61
56
|
return results;
|
|
62
57
|
}
|
|
63
58
|
/**
|
|
@@ -65,7 +60,6 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
|
|
|
65
60
|
*
|
|
66
61
|
* 1. Update `package.json` `scripts`.
|
|
67
62
|
* 2. Update `package.json` `dependencies` and `devDependencies`.
|
|
68
|
-
* 3. Update `package.json` `main`.
|
|
69
63
|
*
|
|
70
64
|
* @param projectRoot The root directory of the project.
|
|
71
65
|
* @param props.templatePkg Template project package.json as JSON.
|
|
@@ -76,18 +70,11 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
|
|
|
76
70
|
updatePkgScripts({
|
|
77
71
|
pkg
|
|
78
72
|
});
|
|
79
|
-
|
|
73
|
+
return updatePkgDependencies(projectRoot, {
|
|
80
74
|
pkg,
|
|
81
75
|
templatePkg,
|
|
82
76
|
skipDependencyUpdate
|
|
83
77
|
});
|
|
84
|
-
const removedMainField = updatePkgMain({
|
|
85
|
-
pkg
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
...results,
|
|
89
|
-
removedMainField
|
|
90
|
-
};
|
|
91
78
|
}
|
|
92
79
|
function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDependencyUpdate =[] }) {
|
|
93
80
|
if (!pkg1.devDependencies) {
|
|
@@ -189,30 +176,6 @@ function createDependenciesMap(dependencies) {
|
|
|
189
176
|
pkg.scripts.ios = "expo run:ios";
|
|
190
177
|
}
|
|
191
178
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Add new app entry points
|
|
194
|
-
*/ function updatePkgMain({ pkg }) {
|
|
195
|
-
let removedPkgMain = null;
|
|
196
|
-
// Check that the pkg.main doesn't match:
|
|
197
|
-
// - ./node_modules/expo/AppEntry
|
|
198
|
-
// - ./node_modules/expo/AppEntry.js
|
|
199
|
-
// - node_modules/expo/AppEntry.js
|
|
200
|
-
// - expo/AppEntry.js
|
|
201
|
-
// - expo/AppEntry
|
|
202
|
-
if (shouldDeleteMainField(pkg.main)) {
|
|
203
|
-
// Save the custom
|
|
204
|
-
removedPkgMain = pkg.main;
|
|
205
|
-
delete pkg.main;
|
|
206
|
-
}
|
|
207
|
-
return removedPkgMain;
|
|
208
|
-
}
|
|
209
|
-
function isPkgMainExpoAppEntry(input) {
|
|
210
|
-
const main = input || "";
|
|
211
|
-
if (main.startsWith("./")) {
|
|
212
|
-
return main.includes("node_modules/expo/AppEntry");
|
|
213
|
-
}
|
|
214
|
-
return main.includes("expo/AppEntry");
|
|
215
|
-
}
|
|
216
179
|
function normalizeDependencyMap(deps) {
|
|
217
180
|
return Object.keys(deps).map((dependency)=>`${dependency}@${deps[dependency]}`
|
|
218
181
|
).sort();
|
|
@@ -226,11 +189,5 @@ function createFileHash(contents) {
|
|
|
226
189
|
// this doesn't need to be secure, the shorter the better.
|
|
227
190
|
return _crypto.default.createHash("sha1").update(contents).digest("hex");
|
|
228
191
|
}
|
|
229
|
-
function shouldDeleteMainField(main) {
|
|
230
|
-
if (!main || !isPkgMainExpoAppEntry(main)) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
return !(main == null ? void 0 : main.startsWith("index."));
|
|
234
|
-
}
|
|
235
192
|
|
|
236
193
|
//# sourceMappingURL=updatePackageJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/updatePackageJson.ts"],"sourcesContent":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type PackageJsonModificationResults = DependenciesModificationResults & {\n removedMainField: string | null;\n};\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, dependencies, and main file'\n );\n\n const templatePkg = getPackageJson(templateDirectory);\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n\n updatingPackageJsonStep.succeed(\n 'Updated package.json and added index.js entry point for iOS and Android'\n );\n\n if (results.removedMainField) {\n Log.log(\n `\\u203A Removed ${chalk.bold(\n `\"main\": \"${results.removedMainField}\"`\n )} from package.json because we recommend using index.js as main instead\\n`\n );\n }\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` and `devDependencies`.\n * 3. Update `package.json` `main`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): PackageJsonModificationResults {\n updatePkgScripts({ pkg });\n\n const results = updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n\n const removedMainField = updatePkgMain({ pkg });\n\n return { ...results, removedMainField };\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n if (\n // If the local package.json defined the dependency that we want to overwrite...\n pkg.dependencies?.[dependenciesKey]\n ) {\n if (\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })\n ) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n }\n combinedDependencies[dependenciesKey] = defaultDependencies[dependenciesKey];\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.start?.includes('--dev-client')) {\n pkg.scripts.start = 'expo start --dev-client';\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\n/**\n * Add new app entry points\n */\nfunction updatePkgMain({ pkg }: { pkg: PackageJSONConfig }): string | null {\n let removedPkgMain: null | string = null;\n // Check that the pkg.main doesn't match:\n // - ./node_modules/expo/AppEntry\n // - ./node_modules/expo/AppEntry.js\n // - node_modules/expo/AppEntry.js\n // - expo/AppEntry.js\n // - expo/AppEntry\n if (shouldDeleteMainField(pkg.main)) {\n // Save the custom\n removedPkgMain = pkg.main;\n delete pkg.main;\n }\n\n return removedPkgMain;\n}\n\n/**\n * Returns true if the input string matches the default expo main field.\n *\n * - ./node_modules/expo/AppEntry\n * - ./node_modules/expo/AppEntry.js\n * - node_modules/expo/AppEntry.js\n * - expo/AppEntry.js\n * - expo/AppEntry\n *\n * @param input package.json main field\n */\nexport function isPkgMainExpoAppEntry(input?: string): boolean {\n const main = input || '';\n if (main.startsWith('./')) {\n return main.includes('node_modules/expo/AppEntry');\n }\n return main.includes('expo/AppEntry');\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n\nexport function shouldDeleteMainField(main?: any): boolean {\n if (!main || !isPkgMainExpoAppEntry(main)) {\n return false;\n }\n\n return !main?.startsWith('index.');\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","isPkgMainExpoAppEntry","hashForDependencyMap","createFileHash","shouldDeleteMainField","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","removedMainField","log","chalk","bold","updatePkgScripts","updatePkgMain","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","length","map","join","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","start","android","ios","removedPkgMain","main","input","startsWith","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest"],"mappings":"AAAA;;;;QAwBsBA,sBAAsB,GAAtBA,sBAAsB;QAiG5BC,qBAAqB,GAArBA,qBAAqB;QAyFrBC,qBAAqB,GAArBA,qBAAqB;QA0ErBC,qBAAqB,GAArBA,qBAAqB;QAcrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;QAKdC,qBAAqB,GAArBA,qBAAqB;AArTa,IAAA,OAAc,WAAd,cAAc,CAAA;AAC9C,IAAA,MAAO,kCAAP,OAAO,EAAA;AACN,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBrC,eAAeP,sBAAsB,CAC1CQ,WAAmB,EACnB,EACEC,iBAAiB,CAAA,EACjBC,GAAG,CAAA,EACHC,oBAAoB,CAAA,EAKrB,EACyC;IAC1C,MAAMC,uBAAuB,GAAGC,CAAAA,GAAAA,IAAa,AAE5C,CAAA,cAF4C,CAC3C,iEAAiE,CAClE,AAAC;IAEF,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,OAAc,AAAmB,CAAA,eAAnB,CAACN,iBAAiB,CAAC,AAAC;IAEtD,MAAMO,OAAO,GAAGC,iBAAiB,CAACT,WAAW,EAAE;QAC7CM,WAAW;QACXJ,GAAG;QACHC,oBA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M,SAASnE,oBAAoB,CAACiE,IAAqB,GAAG,EAAE,EAAU;IACvE,MAAMG,QAAQ,GAAGJ,sBAAsB,CAACC,IAAI,CAAC,AAAC;IAC9C,MAAMI,UAAU,GAAGD,QAAQ,CAACvB,IAAI,CAAC,IAAI,CAAC,AAAC;IACvC,OAAO5C,cAAc,CAACoE,UAAU,CAAC,CAAC;CACnC;AAEM,SAASpE,cAAc,CAACqE,QAAgB,EAAU;IACvD,0DAA0D;IAC1D,OAAOC,OAAM,QAAA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACH,QAAQ,CAAC,CAACI,MAAM,CAAC,KAAK,CAAC,CAAC;CACjE;AAEM,SAASxE,qBAAqB,CAAC2D,IAAU,EAAW;IACzD,IAAI,CAACA,IAAI,IAAI,CAAC9D,qBAAqB,CAAC8D,IAAI,CAAC,EAAE;QACzC,OAAO,KAAK,CAAC;KACd;IAED,OAAO,EAACA,IAAI,QAAY,GAAhBA,KAAAA,CAAgB,GAAhBA,IAAI,CAAEE,UAAU,CAAC,QAAQ,CAAC,CAAA,CAAC;CACpC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/updatePackageJson.ts"],"sourcesContent":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, and dependencies'\n );\n\n const templatePkg = getPackageJson(templateDirectory);\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n\n updatingPackageJsonStep.succeed('Updated package.json');\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` and `devDependencies`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n) {\n updatePkgScripts({ pkg });\n\n return updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n if (\n // If the local package.json defined the dependency that we want to overwrite...\n pkg.dependencies?.[dependenciesKey]\n ) {\n if (\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })\n ) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n }\n combinedDependencies[dependenciesKey] = defaultDependencies[dependenciesKey];\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.start?.includes('--dev-client')) {\n pkg.scripts.start = 'expo start --dev-client';\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","hashForDependencyMap","createFileHash","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","updatePkgScripts","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","length","log","map","chalk","bold","join","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","start","android","ios","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest"],"mappings":"AAAA;;;;QAoBsBA,sBAAsB,GAAtBA,sBAAsB;QAkF5BC,qBAAqB,GAArBA,qBAAqB;QAyFrBC,qBAAqB,GAArBA,qBAAqB;QAiDrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;AAtPoB,IAAA,OAAc,WAAd,cAAc,CAAA;AAC9C,IAAA,MAAO,kCAAP,OAAO,EAAA;AACN,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACZ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYrC,eAAeL,sBAAsB,CAC1CM,WAAmB,EACnB,EACEC,iBAAiB,CAAA,EACjBC,GAAG,CAAA,EACHC,oBAAoB,CAAA,EAKrB,EACyC;IAC1C,MAAMC,uBAAuB,GAAGC,CAAAA,GAAAA,IAAa,AAE5C,CAAA,cAF4C,CAC3C,sDAAsD,CACvD,AAAC;IAEF,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,OAAc,AAAmB,CAAA,eAAnB,CAACN,iBAAiB,CAAC,AAAC;IAEtD,MAAMO,OAAO,GAAGC,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sBAAsB,CAACC,IAAqB,EAAY;IAC/D,OAAOZ,MAAM,CAACK,IAAI,CAACO,IAAI,CAAC,CACrBnB,GAAG,CAAC,CAACoB,UAAU,GAAK,CAAC,EAAEA,UAAU,CAAC,CAAC,EAAED,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC;IAAA,CAAC,CACxDC,IAAI,EAAE,CAAC;CACX;AAEM,SAAS5D,oBAAoB,CAAC0D,IAAqB,GAAG,EAAE,EAAU;IACvE,MAAMG,QAAQ,GAAGJ,sBAAsB,CAACC,IAAI,CAAC,AAAC;IAC9C,MAAMI,UAAU,GAAGD,QAAQ,CAACnB,IAAI,CAAC,IAAI,CAAC,AAAC;IACvC,OAAOzC,cAAc,CAAC6D,UAAU,CAAC,CAAC;CACnC;AAEM,SAAS7D,cAAc,CAAC8D,QAAgB,EAAU;IACvD,0DAA0D;IAC1D,OAAOC,OAAM,QAAA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACH,QAAQ,CAAC,CAACI,MAAM,CAAC,KAAK,CAAC,CAAC;CACjE"}
|
|
@@ -22,6 +22,7 @@ var _env = require("../../utils/env");
|
|
|
22
22
|
var _errors = require("../../utils/errors");
|
|
23
23
|
var _terminal = require("../../utils/terminal");
|
|
24
24
|
var _configureCodeSigning = require("./codeSigning/configureCodeSigning");
|
|
25
|
+
var _simulatorCodeSigning = require("./codeSigning/simulatorCodeSigning");
|
|
25
26
|
function _interopRequireDefault(obj) {
|
|
26
27
|
return obj && obj.__esModule ? obj : {
|
|
27
28
|
default: obj
|
|
@@ -125,7 +126,7 @@ async function getXcodeBuildArgsAsync(props) {
|
|
|
125
126
|
"-destination",
|
|
126
127
|
`id=${props.device.udid}`,
|
|
127
128
|
];
|
|
128
|
-
if (!props.isSimulator) {
|
|
129
|
+
if (!props.isSimulator || (0, _simulatorCodeSigning).simulatorBuildRequiresCodeSigning(props.projectRoot)) {
|
|
129
130
|
const developmentTeamId = await (0, _configureCodeSigning).ensureDeviceIsCodeSignedForDeploymentAsync(props.projectRoot);
|
|
130
131
|
if (developmentTeamId) {
|
|
131
132
|
args.push(`DEVELOPMENT_TEAM=${developmentTeamId}`, "-allowProvisioningUpdates", "-allowProvisioningDeviceRegistration");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/run/ios/XcodeBuild.ts"],"sourcesContent":["import { ExpoRunFormatter } from '@expo/xcpretty';\nimport chalk from 'chalk';\nimport { spawn, SpawnOptionsWithoutStdio } from 'child_process';\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nimport * as Log from '../../log';\nimport { ensureDirectory } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { AbortCommandError, CommandError } from '../../utils/errors';\nimport { getUserTerminal } from '../../utils/terminal';\nimport { BuildProps, ProjectInfo } from './XcodeBuild.types';\nimport { ensureDeviceIsCodeSignedForDeploymentAsync } from './codeSigning/configureCodeSigning';\n\nexport function logPrettyItem(message: string) {\n Log.log(chalk`{whiteBright \\u203A} ${message}`);\n}\n\n/**\n *\n * @returns '/Users/evanbacon/Library/Developer/Xcode/DerivedData/myapp-gpgjqjodrxtervaufttwnsgimhrx/Build/Products/Debug-iphonesimulator/myapp.app'\n */\nexport function getAppBinaryPath(buildOutput: string) {\n // Matches what's used in \"Bundle React Native code and images\" script.\n // Requires that `-hideShellScriptEnvironment` is not included in the build command (extra logs).\n\n // Like `\\=/Users/evanbacon/Library/Developer/Xcode/DerivedData/Exponent-anpuosnglkxokahjhfszejloqfvo/Build/Products/Debug-iphonesimulator`\n const CONFIGURATION_BUILD_DIR = extractEnvVariableFromBuild(\n buildOutput,\n 'CONFIGURATION_BUILD_DIR'\n ).sort(\n // Longer name means more suffixes, we want the shortest possible one to be first.\n // Massive projects (like Expo Go) can sometimes print multiple different sets of environment variables.\n // This can become an issue with some\n (a, b) => a.length - b.length\n );\n // Like `Exponent.app`\n const UNLOCALIZED_RESOURCES_FOLDER_PATH = extractEnvVariableFromBuild(\n buildOutput,\n 'UNLOCALIZED_RESOURCES_FOLDER_PATH'\n );\n\n const binaryPath = path.join(\n // Use the shortest defined env variable (usually there's just one).\n CONFIGURATION_BUILD_DIR[0],\n // Use the last defined env variable.\n UNLOCALIZED_RESOURCES_FOLDER_PATH[UNLOCALIZED_RESOURCES_FOLDER_PATH.length - 1]\n );\n\n // If the app has a space in the name it'll fail because it isn't escaped properly by Xcode.\n return getEscapedPath(binaryPath);\n}\n\nexport function getEscapedPath(filePath: string): string {\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n const unescapedPath = filePath.split(/\\\\ /).join(' ');\n if (fs.existsSync(unescapedPath)) {\n return unescapedPath;\n }\n throw new CommandError(\n 'XCODE_BUILD',\n `Unexpected: Generated app at path \"${filePath}\" cannot be read, the app cannot be installed. Please report this and build onto a simulator.`\n );\n}\n\nexport function extractEnvVariableFromBuild(buildOutput: string, variableName: string) {\n // Xcode can sometimes escape `=` with a backslash or put the value in quotes\n const reg = new RegExp(`export ${variableName}\\\\\\\\?=(.*)$`, 'mg');\n const matched = [...buildOutput.matchAll(reg)];\n\n if (!matched || !matched.length) {\n throw new CommandError(\n 'XCODE_BUILD',\n `Malformed xcodebuild results: \"${variableName}\" variable was not generated in build output. Please report this issue and run your project with Xcode instead.`\n );\n }\n return matched.map((value) => value[1]).filter(Boolean) as string[];\n}\n\nexport function getProcessOptions({\n packager,\n shouldSkipInitialBundling,\n terminal,\n port,\n}: {\n packager: boolean;\n shouldSkipInitialBundling?: boolean;\n terminal: string | undefined;\n port: number;\n}): SpawnOptionsWithoutStdio {\n const SKIP_BUNDLING = shouldSkipInitialBundling ? '1' : undefined;\n if (packager) {\n return {\n env: {\n ...process.env,\n RCT_TERMINAL: terminal,\n SKIP_BUNDLING,\n RCT_METRO_PORT: port.toString(),\n },\n };\n }\n\n return {\n env: {\n ...process.env,\n RCT_TERMINAL: terminal,\n SKIP_BUNDLING,\n // Always skip launching the packager from a build script.\n // The script is used for people building their project directly from Xcode.\n // This essentially means \"› Running script 'Start Packager'\" does nothing.\n RCT_NO_LAUNCH_PACKAGER: 'true',\n // FORCE_BUNDLING: '0'\n },\n };\n}\n\nexport async function getXcodeBuildArgsAsync(\n props: Pick<\n BuildProps,\n | 'buildCache'\n | 'projectRoot'\n | 'xcodeProject'\n | 'configuration'\n | 'scheme'\n | 'device'\n | 'isSimulator'\n >\n): Promise<string[]> {\n const args = [\n props.xcodeProject.isWorkspace ? '-workspace' : '-project',\n props.xcodeProject.name,\n '-configuration',\n props.configuration,\n '-scheme',\n props.scheme,\n '-destination',\n `id=${props.device.udid}`,\n ];\n\n if (!props.isSimulator) {\n const developmentTeamId = await ensureDeviceIsCodeSignedForDeploymentAsync(props.projectRoot);\n if (developmentTeamId) {\n args.push(\n `DEVELOPMENT_TEAM=${developmentTeamId}`,\n '-allowProvisioningUpdates',\n '-allowProvisioningDeviceRegistration'\n );\n }\n }\n\n // Add last\n if (props.buildCache === false) {\n args.push(\n // Will first clean the derived data folder.\n 'clean',\n // Then build step must be added otherwise the process will simply clean and exit.\n 'build'\n );\n }\n return args;\n}\n\nfunction spawnXcodeBuild(\n args: string[],\n options: SpawnOptionsWithoutStdio,\n { onData }: { onData: (data: string) => void }\n): Promise<{ code: number | null; results: string; error: string }> {\n const buildProcess = spawn('xcodebuild', args, options);\n\n let results = '';\n let error = '';\n\n buildProcess.stdout.on('data', (data: Buffer) => {\n const stringData = data.toString();\n results += stringData;\n onData(stringData);\n });\n\n buildProcess.stderr.on('data', (data: Buffer) => {\n const stringData = data instanceof Buffer ? data.toString() : data;\n error += stringData;\n });\n\n return new Promise(async (resolve, reject) => {\n buildProcess.on('close', (code: number) => {\n resolve({ code, results, error });\n });\n });\n}\n\nasync function spawnXcodeBuildWithFlush(\n args: string[],\n options: SpawnOptionsWithoutStdio,\n { onFlush }: { onFlush: (data: string) => void }\n): Promise<{ code: number | null; results: string; error: string }> {\n let currentBuffer = '';\n\n // Data can be sent in chunks that would have no relevance to our regex\n // this can cause massive slowdowns, so we need to ensure the data is complete before attempting to parse it.\n function flushBuffer() {\n if (!currentBuffer) {\n return;\n }\n\n const data = currentBuffer;\n // Reset buffer.\n currentBuffer = '';\n // Process data.\n onFlush(data);\n }\n\n const data = await spawnXcodeBuild(args, options, {\n onData(stringData) {\n currentBuffer += stringData;\n // Only flush the data if we have a full line.\n if (currentBuffer.endsWith(os.EOL)) {\n flushBuffer();\n }\n },\n });\n\n // Flush log data at the end just in case we missed something.\n flushBuffer();\n return data;\n}\n\nasync function spawnXcodeBuildWithFormat(\n args: string[],\n options: SpawnOptionsWithoutStdio,\n { projectRoot, xcodeProject }: { projectRoot: string; xcodeProject: ProjectInfo }\n): Promise<{ code: number | null; results: string; error: string; formatter: ExpoRunFormatter }> {\n Log.debug(` xcodebuild ${args.join(' ')}`);\n\n logPrettyItem(chalk.bold`Planning build`);\n\n const formatter = ExpoRunFormatter.create(projectRoot, {\n xcodeProject,\n isDebug: env.EXPO_DEBUG,\n });\n\n const results = await spawnXcodeBuildWithFlush(args, options, {\n onFlush(data) {\n // Process data.\n for (const line of formatter.pipe(data)) {\n // Log parsed results.\n Log.log(line);\n }\n },\n });\n\n Log.debug(`Exited with code: ${results.code}`);\n\n if (\n // User cancelled with ctrl-c\n results.code === null ||\n // Build interrupted\n results.code === 75\n ) {\n throw new AbortCommandError();\n }\n\n Log.log(formatter.getBuildSummary());\n\n return { ...results, formatter };\n}\n\nexport async function buildAsync(props: BuildProps): Promise<string> {\n const args = await getXcodeBuildArgsAsync(props);\n\n const { projectRoot, xcodeProject, shouldSkipInitialBundling, port } = props;\n\n const { code, results, formatter, error } = await spawnXcodeBuildWithFormat(\n args,\n getProcessOptions({\n packager: false,\n terminal: getUserTerminal(),\n shouldSkipInitialBundling,\n port,\n }),\n {\n projectRoot,\n xcodeProject,\n }\n );\n\n const logFilePath = writeBuildLogs(projectRoot, results, error);\n\n if (code !== 0) {\n // Determine if the logger found any errors;\n const wasErrorPresented = !!formatter.errors.length;\n\n if (wasErrorPresented) {\n // This has a flaw, if the user is missing a file, and there is a script error, only the missing file error will be shown.\n // They will only see the script error if they fix the missing file and rerun.\n // The flaw can be fixed by catching script errors in the custom logger.\n throw new CommandError(\n `Failed to build iOS project. \"xcodebuild\" exited with error code ${code}.`\n );\n }\n\n _assertXcodeBuildResults(code, results, error, xcodeProject, logFilePath);\n }\n return results;\n}\n\n// Exposed for testing.\nexport function _assertXcodeBuildResults(\n code: number | null,\n results: string,\n error: string,\n xcodeProject: { name: string },\n logFilePath: string\n): void {\n const errorTitle = `Failed to build iOS project. \"xcodebuild\" exited with error code ${code}.`;\n\n const throwWithMessage = (message: string): never => {\n throw new CommandError(\n `${errorTitle}\\nTo view more error logs, try building the app with Xcode directly, by opening ${xcodeProject.name}.\\n\\n` +\n message +\n `Build logs written to ${chalk.underline(logFilePath)}`\n );\n };\n\n const localizedError = error.match(/NSLocalizedFailure = \"(.*)\"/)?.[1];\n\n if (localizedError) {\n throwWithMessage(chalk.bold(localizedError) + '\\n\\n');\n }\n // Show all the log info because often times the error is coming from a shell script,\n // that invoked a node script, that started metro, which threw an error.\n\n throwWithMessage(results + '\\n\\n' + error);\n}\n\nfunction writeBuildLogs(projectRoot: string, buildOutput: string, errorOutput: string) {\n const [logFilePath, errorFilePath] = getErrorLogFilePath(projectRoot);\n\n fs.writeFileSync(logFilePath, buildOutput);\n fs.writeFileSync(errorFilePath, errorOutput);\n return logFilePath;\n}\n\nfunction getErrorLogFilePath(projectRoot: string): [string, string] {\n const folder = path.join(projectRoot, '.expo');\n ensureDirectory(folder);\n return [path.join(folder, 'xcodebuild.log'), path.join(folder, 'xcodebuild-error.log')];\n}\n"],"names":["logPrettyItem","getAppBinaryPath","getEscapedPath","extractEnvVariableFromBuild","getProcessOptions","getXcodeBuildArgsAsync","buildAsync","_assertXcodeBuildResults","Log","message","log","chalk","buildOutput","CONFIGURATION_BUILD_DIR","sort","a","b","length","UNLOCALIZED_RESOURCES_FOLDER_PATH","binaryPath","path","join","filePath","fs","existsSync","unescapedPath","split","CommandError","variableName","reg","RegExp","matched","matchAll","map","value","filter","Boolean","packager","shouldSkipInitialBundling","terminal","port","SKIP_BUNDLING","undefined","env","process","RCT_TERMINAL","RCT_METRO_PORT","toString","RCT_NO_LAUNCH_PACKAGER","props","args","xcodeProject","isWorkspace","name","configuration","scheme","device","udid","isSimulator","developmentTeamId","ensureDeviceIsCodeSignedForDeploymentAsync","projectRoot","push","buildCache","spawnXcodeBuild","options","onData","buildProcess","spawn","results","error","stdout","on","data","stringData","stderr","Buffer","Promise","resolve","reject","code","spawnXcodeBuildWithFlush","onFlush","currentBuffer","flushBuffer","endsWith","os","EOL","spawnXcodeBuildWithFormat","debug","bold","formatter","ExpoRunFormatter","create","isDebug","EXPO_DEBUG","line","pipe","AbortCommandError","getBuildSummary","getUserTerminal","logFilePath","writeBuildLogs","wasErrorPresented","errors","errorTitle","throwWithMessage","underline","localizedError","match","errorOutput","errorFilePath","getErrorLogFilePath","writeFileSync","folder","ensureDirectory"],"mappings":"AAAA;;;;QAegBA,aAAa,GAAbA,aAAa;QAQbC,gBAAgB,GAAhBA,gBAAgB;QA+BhBC,cAAc,GAAdA,cAAc;QAcdC,2BAA2B,GAA3BA,2BAA2B;QAc3BC,iBAAiB,GAAjBA,iBAAiB;QAqCXC,sBAAsB,GAAtBA,sBAAsB;QAsJtBC,UAAU,GAAVA,UAAU;QAwChBC,wBAAwB,GAAxBA,wBAAwB;AArTP,IAAA,SAAgB,WAAhB,gBAAgB,CAAA;AAC/B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACuB,IAAA,aAAe,WAAf,eAAe,CAAA;AAChD,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACJ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACiB,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAC7B,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACW,IAAA,OAAoB,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CsD,CAAAA,GAAAA,IAAe,AAAQ,CAAA,gBAAR,CAACD,MAAM,CAAC,CAAC;IACxB,OAAO;QAAC9F,KAAI,QAAA,CAACC,IAAI,CAAC6F,MAAM,EAAE,gBAAgB,CAAC;QAAE9F,KAAI,QAAA,CAACC,IAAI,CAAC6F,MAAM,EAAE,sBAAsB,CAAC;KAAC,CAAC;CACzF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/run/ios/XcodeBuild.ts"],"sourcesContent":["import { ExpoRunFormatter } from '@expo/xcpretty';\nimport chalk from 'chalk';\nimport { spawn, SpawnOptionsWithoutStdio } from 'child_process';\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nimport * as Log from '../../log';\nimport { ensureDirectory } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { AbortCommandError, CommandError } from '../../utils/errors';\nimport { getUserTerminal } from '../../utils/terminal';\nimport { BuildProps, ProjectInfo } from './XcodeBuild.types';\nimport { ensureDeviceIsCodeSignedForDeploymentAsync } from './codeSigning/configureCodeSigning';\nimport { simulatorBuildRequiresCodeSigning } from './codeSigning/simulatorCodeSigning';\nexport function logPrettyItem(message: string) {\n Log.log(chalk`{whiteBright \\u203A} ${message}`);\n}\n\n/**\n *\n * @returns '/Users/evanbacon/Library/Developer/Xcode/DerivedData/myapp-gpgjqjodrxtervaufttwnsgimhrx/Build/Products/Debug-iphonesimulator/myapp.app'\n */\nexport function getAppBinaryPath(buildOutput: string) {\n // Matches what's used in \"Bundle React Native code and images\" script.\n // Requires that `-hideShellScriptEnvironment` is not included in the build command (extra logs).\n\n // Like `\\=/Users/evanbacon/Library/Developer/Xcode/DerivedData/Exponent-anpuosnglkxokahjhfszejloqfvo/Build/Products/Debug-iphonesimulator`\n const CONFIGURATION_BUILD_DIR = extractEnvVariableFromBuild(\n buildOutput,\n 'CONFIGURATION_BUILD_DIR'\n ).sort(\n // Longer name means more suffixes, we want the shortest possible one to be first.\n // Massive projects (like Expo Go) can sometimes print multiple different sets of environment variables.\n // This can become an issue with some\n (a, b) => a.length - b.length\n );\n // Like `Exponent.app`\n const UNLOCALIZED_RESOURCES_FOLDER_PATH = extractEnvVariableFromBuild(\n buildOutput,\n 'UNLOCALIZED_RESOURCES_FOLDER_PATH'\n );\n\n const binaryPath = path.join(\n // Use the shortest defined env variable (usually there's just one).\n CONFIGURATION_BUILD_DIR[0],\n // Use the last defined env variable.\n UNLOCALIZED_RESOURCES_FOLDER_PATH[UNLOCALIZED_RESOURCES_FOLDER_PATH.length - 1]\n );\n\n // If the app has a space in the name it'll fail because it isn't escaped properly by Xcode.\n return getEscapedPath(binaryPath);\n}\n\nexport function getEscapedPath(filePath: string): string {\n if (fs.existsSync(filePath)) {\n return filePath;\n }\n const unescapedPath = filePath.split(/\\\\ /).join(' ');\n if (fs.existsSync(unescapedPath)) {\n return unescapedPath;\n }\n throw new CommandError(\n 'XCODE_BUILD',\n `Unexpected: Generated app at path \"${filePath}\" cannot be read, the app cannot be installed. Please report this and build onto a simulator.`\n );\n}\n\nexport function extractEnvVariableFromBuild(buildOutput: string, variableName: string) {\n // Xcode can sometimes escape `=` with a backslash or put the value in quotes\n const reg = new RegExp(`export ${variableName}\\\\\\\\?=(.*)$`, 'mg');\n const matched = [...buildOutput.matchAll(reg)];\n\n if (!matched || !matched.length) {\n throw new CommandError(\n 'XCODE_BUILD',\n `Malformed xcodebuild results: \"${variableName}\" variable was not generated in build output. Please report this issue and run your project with Xcode instead.`\n );\n }\n return matched.map((value) => value[1]).filter(Boolean) as string[];\n}\n\nexport function getProcessOptions({\n packager,\n shouldSkipInitialBundling,\n terminal,\n port,\n}: {\n packager: boolean;\n shouldSkipInitialBundling?: boolean;\n terminal: string | undefined;\n port: number;\n}): SpawnOptionsWithoutStdio {\n const SKIP_BUNDLING = shouldSkipInitialBundling ? '1' : undefined;\n if (packager) {\n return {\n env: {\n ...process.env,\n RCT_TERMINAL: terminal,\n SKIP_BUNDLING,\n RCT_METRO_PORT: port.toString(),\n },\n };\n }\n\n return {\n env: {\n ...process.env,\n RCT_TERMINAL: terminal,\n SKIP_BUNDLING,\n // Always skip launching the packager from a build script.\n // The script is used for people building their project directly from Xcode.\n // This essentially means \"› Running script 'Start Packager'\" does nothing.\n RCT_NO_LAUNCH_PACKAGER: 'true',\n // FORCE_BUNDLING: '0'\n },\n };\n}\n\nexport async function getXcodeBuildArgsAsync(\n props: Pick<\n BuildProps,\n | 'buildCache'\n | 'projectRoot'\n | 'xcodeProject'\n | 'configuration'\n | 'scheme'\n | 'device'\n | 'isSimulator'\n >\n): Promise<string[]> {\n const args = [\n props.xcodeProject.isWorkspace ? '-workspace' : '-project',\n props.xcodeProject.name,\n '-configuration',\n props.configuration,\n '-scheme',\n props.scheme,\n '-destination',\n `id=${props.device.udid}`,\n ];\n\n if (!props.isSimulator || simulatorBuildRequiresCodeSigning(props.projectRoot)) {\n const developmentTeamId = await ensureDeviceIsCodeSignedForDeploymentAsync(props.projectRoot);\n if (developmentTeamId) {\n args.push(\n `DEVELOPMENT_TEAM=${developmentTeamId}`,\n '-allowProvisioningUpdates',\n '-allowProvisioningDeviceRegistration'\n );\n }\n }\n\n // Add last\n if (props.buildCache === false) {\n args.push(\n // Will first clean the derived data folder.\n 'clean',\n // Then build step must be added otherwise the process will simply clean and exit.\n 'build'\n );\n }\n return args;\n}\n\nfunction spawnXcodeBuild(\n args: string[],\n options: SpawnOptionsWithoutStdio,\n { onData }: { onData: (data: string) => void }\n): Promise<{ code: number | null; results: string; error: string }> {\n const buildProcess = spawn('xcodebuild', args, options);\n\n let results = '';\n let error = '';\n\n buildProcess.stdout.on('data', (data: Buffer) => {\n const stringData = data.toString();\n results += stringData;\n onData(stringData);\n });\n\n buildProcess.stderr.on('data', (data: Buffer) => {\n const stringData = data instanceof Buffer ? data.toString() : data;\n error += stringData;\n });\n\n return new Promise(async (resolve, reject) => {\n buildProcess.on('close', (code: number) => {\n resolve({ code, results, error });\n });\n });\n}\n\nasync function spawnXcodeBuildWithFlush(\n args: string[],\n options: SpawnOptionsWithoutStdio,\n { onFlush }: { onFlush: (data: string) => void }\n): Promise<{ code: number | null; results: string; error: string }> {\n let currentBuffer = '';\n\n // Data can be sent in chunks that would have no relevance to our regex\n // this can cause massive slowdowns, so we need to ensure the data is complete before attempting to parse it.\n function flushBuffer() {\n if (!currentBuffer) {\n return;\n }\n\n const data = currentBuffer;\n // Reset buffer.\n currentBuffer = '';\n // Process data.\n onFlush(data);\n }\n\n const data = await spawnXcodeBuild(args, options, {\n onData(stringData) {\n currentBuffer += stringData;\n // Only flush the data if we have a full line.\n if (currentBuffer.endsWith(os.EOL)) {\n flushBuffer();\n }\n },\n });\n\n // Flush log data at the end just in case we missed something.\n flushBuffer();\n return data;\n}\n\nasync function spawnXcodeBuildWithFormat(\n args: string[],\n options: SpawnOptionsWithoutStdio,\n { projectRoot, xcodeProject }: { projectRoot: string; xcodeProject: ProjectInfo }\n): Promise<{ code: number | null; results: string; error: string; formatter: ExpoRunFormatter }> {\n Log.debug(` xcodebuild ${args.join(' ')}`);\n\n logPrettyItem(chalk.bold`Planning build`);\n\n const formatter = ExpoRunFormatter.create(projectRoot, {\n xcodeProject,\n isDebug: env.EXPO_DEBUG,\n });\n\n const results = await spawnXcodeBuildWithFlush(args, options, {\n onFlush(data) {\n // Process data.\n for (const line of formatter.pipe(data)) {\n // Log parsed results.\n Log.log(line);\n }\n },\n });\n\n Log.debug(`Exited with code: ${results.code}`);\n\n if (\n // User cancelled with ctrl-c\n results.code === null ||\n // Build interrupted\n results.code === 75\n ) {\n throw new AbortCommandError();\n }\n\n Log.log(formatter.getBuildSummary());\n\n return { ...results, formatter };\n}\n\nexport async function buildAsync(props: BuildProps): Promise<string> {\n const args = await getXcodeBuildArgsAsync(props);\n\n const { projectRoot, xcodeProject, shouldSkipInitialBundling, port } = props;\n\n const { code, results, formatter, error } = await spawnXcodeBuildWithFormat(\n args,\n getProcessOptions({\n packager: false,\n terminal: getUserTerminal(),\n shouldSkipInitialBundling,\n port,\n }),\n {\n projectRoot,\n xcodeProject,\n }\n );\n\n const logFilePath = writeBuildLogs(projectRoot, results, error);\n\n if (code !== 0) {\n // Determine if the logger found any errors;\n const wasErrorPresented = !!formatter.errors.length;\n\n if (wasErrorPresented) {\n // This has a flaw, if the user is missing a file, and there is a script error, only the missing file error will be shown.\n // They will only see the script error if they fix the missing file and rerun.\n // The flaw can be fixed by catching script errors in the custom logger.\n throw new CommandError(\n `Failed to build iOS project. \"xcodebuild\" exited with error code ${code}.`\n );\n }\n\n _assertXcodeBuildResults(code, results, error, xcodeProject, logFilePath);\n }\n return results;\n}\n\n// Exposed for testing.\nexport function _assertXcodeBuildResults(\n code: number | null,\n results: string,\n error: string,\n xcodeProject: { name: string },\n logFilePath: string\n): void {\n const errorTitle = `Failed to build iOS project. \"xcodebuild\" exited with error code ${code}.`;\n\n const throwWithMessage = (message: string): never => {\n throw new CommandError(\n `${errorTitle}\\nTo view more error logs, try building the app with Xcode directly, by opening ${xcodeProject.name}.\\n\\n` +\n message +\n `Build logs written to ${chalk.underline(logFilePath)}`\n );\n };\n\n const localizedError = error.match(/NSLocalizedFailure = \"(.*)\"/)?.[1];\n\n if (localizedError) {\n throwWithMessage(chalk.bold(localizedError) + '\\n\\n');\n }\n // Show all the log info because often times the error is coming from a shell script,\n // that invoked a node script, that started metro, which threw an error.\n\n throwWithMessage(results + '\\n\\n' + error);\n}\n\nfunction writeBuildLogs(projectRoot: string, buildOutput: string, errorOutput: string) {\n const [logFilePath, errorFilePath] = getErrorLogFilePath(projectRoot);\n\n fs.writeFileSync(logFilePath, buildOutput);\n fs.writeFileSync(errorFilePath, errorOutput);\n return logFilePath;\n}\n\nfunction getErrorLogFilePath(projectRoot: string): [string, string] {\n const folder = path.join(projectRoot, '.expo');\n ensureDirectory(folder);\n return [path.join(folder, 'xcodebuild.log'), path.join(folder, 'xcodebuild-error.log')];\n}\n"],"names":["logPrettyItem","getAppBinaryPath","getEscapedPath","extractEnvVariableFromBuild","getProcessOptions","getXcodeBuildArgsAsync","buildAsync","_assertXcodeBuildResults","Log","message","log","chalk","buildOutput","CONFIGURATION_BUILD_DIR","sort","a","b","length","UNLOCALIZED_RESOURCES_FOLDER_PATH","binaryPath","path","join","filePath","fs","existsSync","unescapedPath","split","CommandError","variableName","reg","RegExp","matched","matchAll","map","value","filter","Boolean","packager","shouldSkipInitialBundling","terminal","port","SKIP_BUNDLING","undefined","env","process","RCT_TERMINAL","RCT_METRO_PORT","toString","RCT_NO_LAUNCH_PACKAGER","props","args","xcodeProject","isWorkspace","name","configuration","scheme","device","udid","isSimulator","simulatorBuildRequiresCodeSigning","projectRoot","developmentTeamId","ensureDeviceIsCodeSignedForDeploymentAsync","push","buildCache","spawnXcodeBuild","options","onData","buildProcess","spawn","results","error","stdout","on","data","stringData","stderr","Buffer","Promise","resolve","reject","code","spawnXcodeBuildWithFlush","onFlush","currentBuffer","flushBuffer","endsWith","os","EOL","spawnXcodeBuildWithFormat","debug","bold","formatter","ExpoRunFormatter","create","isDebug","EXPO_DEBUG","line","pipe","AbortCommandError","getBuildSummary","getUserTerminal","logFilePath","writeBuildLogs","wasErrorPresented","errors","errorTitle","throwWithMessage","underline","localizedError","match","errorOutput","errorFilePath","getErrorLogFilePath","writeFileSync","folder","ensureDirectory"],"mappings":"AAAA;;;;QAegBA,aAAa,GAAbA,aAAa;QAQbC,gBAAgB,GAAhBA,gBAAgB;QA+BhBC,cAAc,GAAdA,cAAc;QAcdC,2BAA2B,GAA3BA,2BAA2B;QAc3BC,iBAAiB,GAAjBA,iBAAiB;QAqCXC,sBAAsB,GAAtBA,sBAAsB;QAsJtBC,UAAU,GAAVA,UAAU;QAwChBC,wBAAwB,GAAxBA,wBAAwB;AArTP,IAAA,SAAgB,WAAhB,gBAAgB,CAAA;AAC/B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACuB,IAAA,aAAe,WAAf,eAAe,CAAA;AAChD,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACJ,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF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E,QAAA,CAAC2F,aAAa,CAACZ,WAAW,EAAE1F,WAAW,CAAC,CAAC;IAC3CW,GAAE,QAAA,CAAC2F,aAAa,CAACF,aAAa,EAAED,WAAW,CAAC,CAAC;IAC7C,OAAOT,WAAW,CAAC;CACpB;AAED,SAASW,mBAAmB,CAACrD,WAAmB,EAAoB;IAClE,MAAMuD,MAAM,GAAG/F,KAAI,QAAA,CAACC,IAAI,CAACuC,WAAW,EAAE,OAAO,CAAC,AAAC;IAC/CwD,CAAAA,GAAAA,IAAe,AAAQ,CAAA,gBAAR,CAACD,MAAM,CAAC,CAAC;IACxB,OAAO;QAAC/F,KAAI,QAAA,CAACC,IAAI,CAAC8F,MAAM,EAAE,gBAAgB,CAAC;QAAE/F,KAAI,QAAA,CAACC,IAAI,CAAC8F,MAAM,EAAE,sBAAsB,CAAC;KAAC,CAAC;CACzF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.simulatorBuildRequiresCodeSigning = simulatorBuildRequiresCodeSigning;
|
|
6
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
7
|
+
var _plist = _interopRequireDefault(require("@expo/plist"));
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
function _interopRequireDefault(obj) {
|
|
10
|
+
return obj && obj.__esModule ? obj : {
|
|
11
|
+
default: obj
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const debug = require("debug")("expo:run:ios:codeSigning:simulator");
|
|
15
|
+
// NOTE(EvanBacon): These are entitlements that work in a simulator
|
|
16
|
+
// but still require the project to have development code signing setup.
|
|
17
|
+
// There may be more, but this is fine for now.
|
|
18
|
+
const ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING = [
|
|
19
|
+
"com.apple.developer.associated-domains",
|
|
20
|
+
"com.apple.developer.applesignin",
|
|
21
|
+
];
|
|
22
|
+
function getEntitlements(projectRoot) {
|
|
23
|
+
try {
|
|
24
|
+
const entitlementsPath = _configPlugins.IOSConfig.Entitlements.getEntitlementsPath(projectRoot);
|
|
25
|
+
if (!entitlementsPath || !_fs.default.existsSync(entitlementsPath)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const entitlementsContents = _fs.default.readFileSync(entitlementsPath, "utf8");
|
|
29
|
+
const entitlements = _plist.default.parse(entitlementsContents);
|
|
30
|
+
return entitlements;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
debug("Failed to read entitlements", error);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function simulatorBuildRequiresCodeSigning(projectRoot) {
|
|
37
|
+
const entitlements = getEntitlements(projectRoot);
|
|
38
|
+
if (!entitlements) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING.some((entitlement)=>entitlement in entitlements
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=simulatorCodeSigning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/run/ios/codeSigning/simulatorCodeSigning.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport plist from '@expo/plist';\nimport fs from 'fs';\n\nconst debug = require('debug')('expo:run:ios:codeSigning:simulator');\n\n// NOTE(EvanBacon): These are entitlements that work in a simulator\n// but still require the project to have development code signing setup.\n// There may be more, but this is fine for now.\nconst ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING = [\n 'com.apple.developer.associated-domains',\n 'com.apple.developer.applesignin',\n];\n\nfunction getEntitlements(projectRoot: string): Record<string, any> | null {\n try {\n const entitlementsPath = IOSConfig.Entitlements.getEntitlementsPath(projectRoot);\n if (!entitlementsPath || !fs.existsSync(entitlementsPath)) {\n return null;\n }\n\n const entitlementsContents = fs.readFileSync(entitlementsPath, 'utf8');\n const entitlements = plist.parse(entitlementsContents);\n return entitlements;\n } catch (error) {\n debug('Failed to read entitlements', error);\n }\n return null;\n}\n\n/** @returns true if the simulator build should be code signed for development. */\nexport function simulatorBuildRequiresCodeSigning(projectRoot: string): boolean {\n const entitlements = getEntitlements(projectRoot);\n if (!entitlements) {\n return false;\n }\n return ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING.some((entitlement) => entitlement in entitlements);\n}\n"],"names":["simulatorBuildRequiresCodeSigning","debug","require","ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING","getEntitlements","projectRoot","entitlementsPath","IOSConfig","Entitlements","getEntitlementsPath","fs","existsSync","entitlementsContents","readFileSync","entitlements","plist","parse","error","some","entitlement"],"mappings":"AAAA;;;;QA+BgBA,iCAAiC,GAAjCA,iCAAiC;AA/BvB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC9B,IAAA,MAAa,kCAAb,aAAa,EAAA;AAChB,IAAA,GAAI,kCAAJ,IAAI,EAAA;;;;;;AAEnB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,AAAC;AAErE,mEAAmE;AACnE,wEAAwE;AACxE,+CAA+C;AAC/C,MAAMC,sCAAsC,GAAG;IAC7C,wCAAwC;IACxC,iCAAiC;CAClC,AAAC;AAEF,SAASC,eAAe,CAACC,WAAmB,EAA8B;IACxE,IAAI;QACF,MAAMC,gBAAgB,GAAGC,cAAS,UAAA,CAACC,YAAY,CAACC,mBAAmB,CAACJ,WAAW,CAAC,AAAC;QACjF,IAAI,CAACC,gBAAgB,IAAI,CAACI,GAAE,QAAA,CAACC,UAAU,CAACL,gBAAgB,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC;SACb;QAED,MAAMM,oBAAoB,GAAGF,GAAE,QAAA,CAACG,YAAY,CAACP,gBAAgB,EAAE,MAAM,CAAC,AAAC;QACvE,MAAMQ,YAAY,GAAGC,MAAK,QAAA,CAACC,KAAK,CAACJ,oBAAoB,CAAC,AAAC;QACvD,OAAOE,YAAY,CAAC;KACrB,CAAC,OAAOG,KAAK,EAAE;QACdhB,KAAK,CAAC,6BAA6B,EAAEgB,KAAK,CAAC,CAAC;KAC7C;IACD,OAAO,IAAI,CAAC;CACb;AAGM,SAASjB,iCAAiC,CAACK,WAAmB,EAAW;IAC9E,MAAMS,YAAY,GAAGV,eAAe,CAACC,WAAW,CAAC,AAAC;IAClD,IAAI,CAACS,YAAY,EAAE;QACjB,OAAO,KAAK,CAAC;KACd;IACD,OAAOX,sCAAsC,CAACe,IAAI,CAAC,CAACC,WAAW,GAAKA,WAAW,IAAIL,YAAY;IAAA,CAAC,CAAC;CAClG"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
exports.isNgrokClientError = isNgrokClientError;
|
|
5
6
|
var _externalModule = require("./ExternalModule");
|
|
6
7
|
class NgrokResolver extends _externalModule.ExternalModule {
|
|
7
8
|
constructor(projectRoot){
|
|
@@ -13,5 +14,9 @@ class NgrokResolver extends _externalModule.ExternalModule {
|
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
exports.NgrokResolver = NgrokResolver;
|
|
17
|
+
function isNgrokClientError(error) {
|
|
18
|
+
var ref;
|
|
19
|
+
return error == null ? void 0 : (ref = error.body) == null ? void 0 : ref.msg;
|
|
20
|
+
}
|
|
16
21
|
|
|
17
22
|
//# sourceMappingURL=NgrokResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/ngrok/NgrokResolver.ts"],"sourcesContent":["import { ExternalModule } from './ExternalModule';\n\nexport interface NgrokOptions {\n authtoken?: string;\n port?: string | number | null;\n host?: string;\n httpauth?: string;\n region?: string;\n configPath?: string;\n\n proto?: 'http' | 'tcp' | 'tls';\n addr?: string;\n inspect?: boolean;\n auth?: string;\n host_header?: string;\n bind_tls?: true | false | 'both';\n subdomain?: string;\n hostname?: string;\n crt?: string;\n key?: string;\n client_cas?: string;\n remote_addr?: string;\n}\n\nexport interface NgrokInstance {\n getActiveProcess(): { pid: number };\n connect(\n props: {\n hostname
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/ngrok/NgrokResolver.ts"],"sourcesContent":["import { ExternalModule } from './ExternalModule';\n\nexport interface NgrokClientError {\n body: {\n error_code: number;\n status_code: number;\n msg: string;\n details: {\n err: string;\n };\n };\n}\n\nexport interface NgrokOptions {\n authtoken?: string;\n port?: string | number | null;\n host?: string;\n httpauth?: string;\n region?: string;\n configPath?: string;\n\n proto?: 'http' | 'tcp' | 'tls';\n addr?: string;\n inspect?: boolean;\n auth?: string;\n host_header?: string;\n bind_tls?: true | false | 'both';\n subdomain?: string;\n hostname?: string;\n crt?: string;\n key?: string;\n client_cas?: string;\n remote_addr?: string;\n}\n\nexport interface NgrokInstance {\n getActiveProcess(): { pid: number };\n connect(\n props: {\n hostname?: string;\n configPath: string;\n onStatusChange: (status: string) => void;\n } & NgrokOptions\n ): Promise<string>;\n kill(): Promise<void>;\n}\n\n/** Resolves the ngrok instance from local or globally installed package. */\nexport class NgrokResolver extends ExternalModule<NgrokInstance> {\n constructor(projectRoot: string) {\n super(\n projectRoot,\n {\n name: '@expo/ngrok',\n versionRange: '^4.1.0',\n },\n (packageName) =>\n `The package ${packageName} is required to use tunnels, would you like to install it globally?`\n );\n }\n}\n\nexport function isNgrokClientError(error: any): error is NgrokClientError {\n return error?.body?.msg;\n}\n"],"names":["isNgrokClientError","NgrokResolver","ExternalModule","constructor","projectRoot","name","versionRange","packageName","error","body","msg"],"mappings":"AAAA;;;;QA8DgBA,kBAAkB,GAAlBA,kBAAkB;AA9DH,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAgD1C,MAAMC,aAAa,SAASC,eAAc,eAAA;IAC/CC,YAAYC,WAAmB,CAAE;QAC/B,KAAK,CACHA,WAAW,EACX;YACEC,IAAI,EAAE,aAAa;YACnBC,YAAY,EAAE,QAAQ;SACvB,EACD,CAACC,WAAW,GACV,CAAC,YAAY,EAAEA,WAAW,CAAC,mEAAmE,CAAC;QAAA,CAClG,CAAC;KACH;CACF;QAZYN,aAAa,GAAbA,aAAa;AAcnB,SAASD,kBAAkB,CAACQ,KAAU,EAA6B;QACjEA,GAAW;IAAlB,OAAOA,KAAK,QAAM,GAAXA,KAAAA,CAAW,GAAXA,CAAAA,GAAW,GAAXA,KAAK,CAAEC,IAAI,SAAA,GAAXD,KAAAA,CAAW,GAAXA,GAAW,CAAEE,GAAG,AAAL,CAAM;CACzB"}
|
|
@@ -32,7 +32,12 @@ class PlatformManager {
|
|
|
32
32
|
const redirectUrl = this.props.getRedirectUrl();
|
|
33
33
|
if (redirectUrl) {
|
|
34
34
|
// If the redirect page feature is enabled, check if the project has a resolvable native identifier.
|
|
35
|
-
|
|
35
|
+
let applicationId;
|
|
36
|
+
try {
|
|
37
|
+
applicationId = await this._getAppIdResolver().getAppIdAsync();
|
|
38
|
+
} catch {
|
|
39
|
+
_log.Log.warn(_chalk.default`\u203A Launching in Expo Go. If you want to use a ` + `development build, you need to create and install one first, or, if you already ` + _chalk.default`have a build, add {bold ios.bundleIdentifier} and {bold android.package} to ` + `this project's app config.\n${(0, _link).learnMore("https://docs.expo.dev/development/build/")}`);
|
|
40
|
+
}
|
|
36
41
|
if (applicationId) {
|
|
37
42
|
debug(`Resolving launch URL: (appId: ${applicationId}, redirect URL: ${redirectUrl})`);
|
|
38
43
|
// NOTE(EvanBacon): This adds considerable amount of time to the command, we should consider removing or memoizing it.
|