@expo/cli 0.1.5 → 0.2.2
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/CHANGELOG.md +133 -0
- package/build/bin/cli +83 -4
- package/build/bin/cli.map +1 -1
- package/build/src/api/getNativeModuleVersions.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
- package/build/src/customize/customizeAsync.js +40 -0
- package/build/src/customize/customizeAsync.js.map +1 -0
- package/build/src/customize/generate.js +77 -0
- package/build/src/customize/generate.js.map +1 -0
- package/build/src/customize/index.js +41 -0
- package/build/src/customize/index.js.map +1 -0
- package/build/src/customize/resolveOptions.js +18 -0
- package/build/src/customize/resolveOptions.js.map +1 -0
- package/build/src/customize/templates.js +118 -0
- package/build/src/customize/templates.js.map +1 -0
- package/build/src/export/createMetadataJson.js +10 -7
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/exportApp.js +32 -0
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +2 -3
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +52 -35
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +14 -10
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +27 -48
- package/build/src/export/printBundleSizes.js.map +1 -1
- package/build/src/export/resolveOptions.js +44 -5
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +2 -1
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +37 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -0
- package/build/src/export/web/index.js +66 -0
- package/build/src/export/web/index.js.map +1 -0
- package/build/src/export/web/resolveOptions.js +13 -0
- package/build/src/export/web/resolveOptions.js.map +1 -0
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/checkPackages.js +2 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/index.js +1 -0
- package/build/src/install/index.js.map +1 -1
- package/build/src/install/installAsync.js +13 -5
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js +12 -65
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
- package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
- package/build/src/log.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +5 -23
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +18 -12
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +11 -12
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +17 -0
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +2 -1
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -5
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveInstallApkName.js +5 -26
- package/build/src/run/android/resolveInstallApkName.js.map +1 -1
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
- package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +29 -31
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/interface/KeyPressHandler.js +2 -0
- package/build/src/start/interface/KeyPressHandler.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +5 -5
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +3 -2
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +4 -24
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +17 -32
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/AndroidSdk.js +41 -0
- package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
- package/build/src/start/platforms/android/activateWindow.js +4 -4
- package/build/src/start/platforms/android/activateWindow.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +8 -3
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/android/adbReverse.js +3 -2
- package/build/src/start/platforms/android/adbReverse.js.map +1 -1
- package/build/src/start/platforms/android/gradle.js +2 -2
- package/build/src/start/platforms/android/gradle.js.map +1 -1
- package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
- package/build/src/start/platforms/ios/xcrun.js +2 -23
- package/build/src/start/platforms/ios/xcrun.js.map +1 -1
- package/build/src/start/project/devices.js +2 -0
- package/build/src/start/project/devices.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +6 -5
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +15 -8
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +15 -5
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +4 -0
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -3
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +5 -0
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +11 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/resolveFromProject.js +8 -0
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
- package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
- package/build/src/start/server/platformBundlers.js +18 -0
- package/build/src/start/server/platformBundlers.js.map +1 -0
- package/build/src/start/server/webTemplate.js +68 -0
- package/build/src/start/server/webTemplate.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/server/webpack/compile.js +64 -0
- package/build/src/start/server/webpack/compile.js.map +1 -0
- package/build/src/start/startAsync.js +21 -17
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +5 -2
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/downloadAppAsync.js +3 -2
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/downloadExpoGoAsync.js +7 -32
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
- package/build/src/utils/editor.js +3 -2
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/exit.js +4 -25
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +6 -2
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/nodeModules.js +13 -102
- package/build/src/utils/nodeModules.js.map +1 -1
- package/build/src/utils/npm.js +3 -24
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/ora.js +1 -13
- package/build/src/utils/ora.js.map +1 -1
- package/build/src/utils/progress.js +46 -0
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/prompts.js +4 -4
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/tar.js +3 -0
- package/build/src/utils/tar.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +9 -2
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/utils/variadic.js +47 -0
- package/build/src/utils/variadic.js.map +1 -0
- package/package.json +13 -8
- package/static/template/babel.config.js +6 -0
- package/static/template/index.html +117 -0
- package/static/template/metro.config.js +4 -0
- package/static/template/serve.json +13 -0
- package/static/template/webpack.config.js +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/prebuildAsync.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/prebuildAsync.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\n\nimport { installAsync } from '../install/installAsync';\nimport { env } from '../utils/env';\nimport { clearNodeModulesAsync } from '../utils/nodeModules';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { clearNativeFolder, promptToClearMalformedNativeProjectsAsync } from './clearNativeFolder';\nimport { configureProjectAsync } from './configureProjectAsync';\nimport { ensureConfigAsync } from './ensureConfigAsync';\nimport { assertPlatforms, ensureValidPlatforms, resolveTemplateOption } from './resolveOptions';\nimport { updateFromTemplateAsync } from './updateFromTemplate';\n\nconst debug = require('debug')('expo:prebuild') as typeof console.log;\n\nexport type PrebuildResults = {\n /** Expo config. */\n exp: ExpoConfig;\n /** Indicates if the process created new files. */\n hasNewProjectFiles: boolean;\n /** The platforms that were prebuilt. */\n platforms: ModPlatform[];\n /** Indicates if pod install was run. */\n podInstall: boolean;\n /** Indicates if node modules were installed. */\n nodeInstall: boolean;\n};\n\n/**\n * Entry point into the prebuild process, delegates to other helpers to perform various steps.\n *\n * 0. Attempt to clean the project folders.\n * 1. Create native projects (ios, android).\n * 2. Install node modules.\n * 3. Apply config to native projects.\n * 4. Install CocoaPods.\n */\nexport async function prebuildAsync(\n projectRoot: string,\n options: {\n /** Should install node modules and cocoapods. */\n install?: boolean;\n /** List of platforms to prebuild. */\n platforms: ModPlatform[];\n /** Should delete the native folders before attempting to prebuild. */\n clean?: boolean;\n /** URL or file path to the prebuild template. */\n template?: string;\n /** Name of the node package manager to install with. */\n packageManager?: {\n npm?: boolean;\n yarn?: boolean;\n pnpm?: boolean;\n };\n /** List of node modules to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<PrebuildResults | null> {\n if (options.clean) {\n const { maybeBailOnGitStatusAsync } = await import('../utils/git');\n // Clean the project folders...\n if (await maybeBailOnGitStatusAsync()) {\n return null;\n }\n // Clear the native folders before syncing\n await clearNativeFolder(projectRoot, options.platforms);\n } else {\n // Check if the existing project folders are malformed.\n await promptToClearMalformedNativeProjectsAsync(projectRoot, options.platforms);\n }\n\n // Warn if the project is attempting to prebuild an unsupported platform (iOS on Windows).\n options.platforms = ensureValidPlatforms(options.platforms);\n // Assert if no platforms are left over after filtering.\n assertPlatforms(options.platforms);\n\n // Get the Expo config, create it if missing.\n const { exp, pkg } = await ensureConfigAsync(projectRoot, { platforms: options.platforms });\n\n // Create native projects from template.\n const { hasNewProjectFiles, needsPodInstall, hasNewDependencies } = await updateFromTemplateAsync(\n projectRoot,\n {\n exp,\n pkg,\n template: options.template != null ? resolveTemplateOption(options.template) : undefined,\n platforms: options.platforms,\n skipDependencyUpdate: options.skipDependencyUpdate,\n }\n );\n\n // Install node modules\n if (options.install) {\n if (hasNewDependencies && options.packageManager?.npm) {\n await clearNodeModulesAsync(projectRoot);\n }\n\n await installAsync([], {\n ...options.packageManager,\n silent: !env.EXPO_DEBUG,\n });\n }\n\n // Apply Expo config to native projects\n const configSyncingStep = logNewSection('Config syncing');\n try {\n await profile(configureProjectAsync)(projectRoot, {\n platforms: options.platforms,\n });\n configSyncingStep.succeed('Config synced');\n } catch (error) {\n configSyncingStep.fail('Config sync failed');\n throw error;\n }\n\n // Install CocoaPods\n let podsInstalled: boolean = false;\n // err towards running pod install less because it's slow and users can easily run npx pod-install afterwards.\n if (options.platforms.includes('ios') && options.install && needsPodInstall) {\n const { installCocoaPodsAsync } = await import('../utils/cocoapods');\n\n podsInstalled = await installCocoaPodsAsync(projectRoot);\n } else {\n debug('Skipped pod install');\n }\n\n return {\n nodeInstall: !!options.install,\n podInstall: !podsInstalled,\n platforms: options.platforms,\n hasNewProjectFiles,\n exp,\n };\n}\n"],"names":["prebuildAsync","debug","require","projectRoot","options","clean","maybeBailOnGitStatusAsync","clearNativeFolder","platforms","promptToClearMalformedNativeProjectsAsync","ensureValidPlatforms","assertPlatforms","exp","pkg","ensureConfigAsync","hasNewProjectFiles","needsPodInstall","hasNewDependencies","updateFromTemplateAsync","template","resolveTemplateOption","undefined","skipDependencyUpdate","install","packageManager","npm","clearNodeModulesAsync","installAsync","silent","env","EXPO_DEBUG","configSyncingStep","logNewSection","profile","configureProjectAsync","succeed","error","fail","podsInstalled","includes","installCocoaPodsAsync","nodeInstall","podInstall"],"mappings":"AAAA;;;;QAsCsBA,aAAa,GAAbA,aAAa;AAnCN,IAAA,aAAyB,WAAzB,yBAAyB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc,CAAA;AACI,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;AAC9B,IAAA,IAAc,WAAd,cAAc,CAAA;AACpB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACmC,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AAC5D,IAAA,sBAAyB,WAAzB,yBAAyB,CAAA;AAC7B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACsB,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AACvD,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAE9D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,AAAsB,AAAC;AAwB/D,eAAeF,aAAa,CACjCG,WAAmB,EACnBC,OAiBC,EACgC;IACjC,IAAIA,OAAO,CAACC,KAAK,EAAE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AAG,MAAM;mDAAO,oBAAoB;UAAC,AAAC;QAErEF,aAAa,GAAG,MAAME,qBAAqB,CAACrC,WAAW,CAAC,CAAC;KAC1D,MAAM;QACLF,KAAK,CAAC,qBAAqB,CAAC,CAAC;KAC9B;IAED,OAAO;QACLwC,WAAW,EAAE,CAAC,CAACrC,OAAO,CAACmB,OAAO;QAC9BmB,UAAU,EAAE,CAACJ,aAAa;QAC1B9B,SAAS,EAAEJ,OAAO,CAACI,SAAS;QAC5BO,kBAAkB;QAClBH,GAAG;KACJ,CAAC;CACH"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
exports.resolvePackageManagerOptions = resolvePackageManagerOptions;
|
|
5
6
|
exports.resolveTemplateOption = resolveTemplateOption;
|
|
6
7
|
exports.resolveSkipDependencyUpdate = resolveSkipDependencyUpdate;
|
|
7
8
|
exports.resolvePlatformOption = resolvePlatformOption;
|
|
@@ -40,6 +41,22 @@ function _interopRequireWildcard(obj) {
|
|
|
40
41
|
return newObj;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
44
|
+
function resolvePackageManagerOptions(args) {
|
|
45
|
+
const managers = {
|
|
46
|
+
npm: args["--npm"],
|
|
47
|
+
yarn: args["--yarn"],
|
|
48
|
+
pnpm: args["--pnpm"]
|
|
49
|
+
};
|
|
50
|
+
if ([
|
|
51
|
+
managers.npm,
|
|
52
|
+
managers.pnpm,
|
|
53
|
+
managers.yarn,
|
|
54
|
+
!!args["--no-install"]
|
|
55
|
+
].filter(Boolean).length > 1) {
|
|
56
|
+
throw new _errors.CommandError("BAD_ARGS", "Specify at most one of: --no-install, --npm, --pnpm, --yarn");
|
|
57
|
+
}
|
|
58
|
+
return managers;
|
|
59
|
+
}
|
|
43
60
|
function resolveTemplateOption(template) {
|
|
44
61
|
if ((0, _url).validateUrl(template)) {
|
|
45
62
|
return template;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/resolveOptions.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { CommandError } from '../utils/errors';\nimport { validateUrl } from '../utils/url';\n\n/** Resolves a template option as a URL or file path pointing to a tar file. */\nexport function resolveTemplateOption(template: string) {\n if (validateUrl(template)) {\n return template;\n }\n const templatePath = path.resolve(template);\n assert(fs.existsSync(templatePath), 'template file does not exist: ' + templatePath);\n assert(\n fs.statSync(templatePath).isFile(),\n 'template must be a tar file created by running `npm pack` in a project: ' + templatePath\n );\n\n return templatePath;\n}\n\n/** Resolves dependencies to skip from a string joined by `,`. Example: `react-native,expo,lodash` */\nexport function resolveSkipDependencyUpdate(value: any) {\n if (!value || typeof value !== 'string') {\n return [];\n }\n return value.split(',');\n}\n\n/** Returns an array of platforms based on the input platform identifier and runtime constraints. */\nexport function resolvePlatformOption(\n platform: string = 'all',\n { loose }: { loose?: boolean } = {}\n): ModPlatform[] {\n switch (platform) {\n case 'ios':\n return ['ios'];\n case 'android':\n return ['android'];\n case 'all':\n if (loose || process.platform !== 'win32') {\n return ['android', 'ios'];\n }\n return ['android'];\n default:\n throw new CommandError(`Unsupported platform \"${platform}\". Options are: ios, android, all`);\n }\n}\n\n/** Warns and filters out unsupported platforms based on the runtime constraints. Essentially this means no iOS on Windows devices. */\nexport function ensureValidPlatforms(platforms: ModPlatform[]): ModPlatform[] {\n // Skip ejecting for iOS on Windows\n if (process.platform === 'win32' && platforms.includes('ios')) {\n Log.warn(\n chalk`⚠️ Skipping generating the iOS native project files. Run {bold expo eject} again from macOS or Linux to generate the iOS project.\\n`\n );\n return platforms.filter((platform) => platform !== 'ios');\n }\n return platforms;\n}\n\n/** Asserts platform length must be greater than zero. */\nexport function assertPlatforms(platforms: ModPlatform[]) {\n if (!platforms?.length) {\n throw new CommandError('At least one platform must be enabled when syncing');\n }\n}\n"],"names":["resolveTemplateOption","resolveSkipDependencyUpdate","resolvePlatformOption","ensureValidPlatforms","assertPlatforms","Log","template","validateUrl","templatePath","path","resolve","assert","fs","existsSync","statSync","isFile","value","split","platform","loose","process","
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/resolveOptions.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { CommandError } from '../utils/errors';\nimport { validateUrl } from '../utils/url';\n\nexport function resolvePackageManagerOptions(args: any) {\n const managers: Record<string, boolean> = {\n npm: args['--npm'],\n yarn: args['--yarn'],\n pnpm: args['--pnpm'],\n };\n\n if (\n [managers.npm, managers.pnpm, managers.yarn, !!args['--no-install']].filter(Boolean).length > 1\n ) {\n throw new CommandError(\n 'BAD_ARGS',\n 'Specify at most one of: --no-install, --npm, --pnpm, --yarn'\n );\n }\n\n return managers;\n}\n\n/** Resolves a template option as a URL or file path pointing to a tar file. */\nexport function resolveTemplateOption(template: string) {\n if (validateUrl(template)) {\n return template;\n }\n const templatePath = path.resolve(template);\n assert(fs.existsSync(templatePath), 'template file does not exist: ' + templatePath);\n assert(\n fs.statSync(templatePath).isFile(),\n 'template must be a tar file created by running `npm pack` in a project: ' + templatePath\n );\n\n return templatePath;\n}\n\n/** Resolves dependencies to skip from a string joined by `,`. Example: `react-native,expo,lodash` */\nexport function resolveSkipDependencyUpdate(value: any) {\n if (!value || typeof value !== 'string') {\n return [];\n }\n return value.split(',');\n}\n\n/** Returns an array of platforms based on the input platform identifier and runtime constraints. */\nexport function resolvePlatformOption(\n platform: string = 'all',\n { loose }: { loose?: boolean } = {}\n): ModPlatform[] {\n switch (platform) {\n case 'ios':\n return ['ios'];\n case 'android':\n return ['android'];\n case 'all':\n if (loose || process.platform !== 'win32') {\n return ['android', 'ios'];\n }\n return ['android'];\n default:\n throw new CommandError(`Unsupported platform \"${platform}\". Options are: ios, android, all`);\n }\n}\n\n/** Warns and filters out unsupported platforms based on the runtime constraints. Essentially this means no iOS on Windows devices. */\nexport function ensureValidPlatforms(platforms: ModPlatform[]): ModPlatform[] {\n // Skip ejecting for iOS on Windows\n if (process.platform === 'win32' && platforms.includes('ios')) {\n Log.warn(\n chalk`⚠️ Skipping generating the iOS native project files. Run {bold expo eject} again from macOS or Linux to generate the iOS project.\\n`\n );\n return platforms.filter((platform) => platform !== 'ios');\n }\n return platforms;\n}\n\n/** Asserts platform length must be greater than zero. */\nexport function assertPlatforms(platforms: ModPlatform[]) {\n if (!platforms?.length) {\n throw new CommandError('At least one platform must be enabled when syncing');\n }\n}\n"],"names":["resolvePackageManagerOptions","resolveTemplateOption","resolveSkipDependencyUpdate","resolvePlatformOption","ensureValidPlatforms","assertPlatforms","Log","args","managers","npm","yarn","pnpm","filter","Boolean","length","CommandError","template","validateUrl","templatePath","path","resolve","assert","fs","existsSync","statSync","isFile","value","split","platform","loose","process","platforms","includes","warn","chalk"],"mappings":"AAAA;;;;QAUgBA,4BAA4B,GAA5BA,4BAA4B;QAoB5BC,qBAAqB,GAArBA,qBAAqB;QAerBC,2BAA2B,GAA3BA,2BAA2B;QAQ3BC,qBAAqB,GAArBA,qBAAqB;QAoBrBC,oBAAoB,GAApBA,oBAAoB;QAYpBC,eAAe,GAAfA,eAAe;AApFZ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACc,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,SAASN,4BAA4B,CAACO,IAAS,EAAE;IACtD,MAAMC,QAAQ,GAA4B;QACxCC,GAAG,EAAEF,IAAI,CAAC,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EAAuB,GAAG,EAAE,EACpB;IACf,OAAQD,QAAQ;QACd,KAAK,KAAK;YACR,OAAO;gBAAC,KAAK;aAAC,CAAC;QACjB,KAAK,SAAS;YACZ,OAAO;gBAAC,SAAS;aAAC,CAAC;QACrB,KAAK,KAAK;YACR,IAAIC,KAAK,IAAIC,OAAO,CAACF,QAAQ,KAAK,OAAO,EAAE;gBACzC,OAAO;oBAAC,SAAS;oBAAE,KAAK;iBAAC,CAAC;aAC3B;YACD,OAAO;gBAAC,SAAS;aAAC,CAAC;QACrB;YACE,MAAM,IAAIb,OAAY,aAAA,CAAC,CAAC,sBAAsB,EAAEa,QAAQ,CAAC,iCAAiC,CAAC,CAAC,CAAC;KAChG;CACF;AAGM,SAASxB,oBAAoB,CAAC2B,SAAwB,EAAiB;IAC5E,mCAAmC;IACnC,IAAID,OAAO,CAACF,QAAQ,KAAK,OAAO,IAAIG,SAAS,CAACC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC7D1B,GAAG,CAAC2B,IAAI,CACNC,MAAK,QAAA,CAAC,wIAAoI,CAAC,CAC5I,CAAC;QACF,OAAOH,SAAS,CAACnB,MAAM,CAAC,CAACgB,QAAQ,GAAKA,QAAQ,KAAK,KAAK;QAAA,CAAC,CAAC;KAC3D;IACD,OAAOG,SAAS,CAAC;CAClB;AAGM,SAAS1B,eAAe,CAAC0B,SAAwB,EAAE;IACxD,IAAI,CAACA,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEjB,MAAM,CAAA,EAAE;QACtB,MAAM,IAAIC,OAAY,aAAA,CAAC,oDAAoD,CAAC,CAAC;KAC9E;CACF"}
|
|
@@ -39,6 +39,7 @@ function _interopRequireWildcard(obj) {
|
|
|
39
39
|
return newObj;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
const debug = require("debug")("expo:prebuild:resolveTemplate");
|
|
42
43
|
async function cloneTemplateAsync({ templateDirectory , template , exp , ora }) {
|
|
43
44
|
if (template) {
|
|
44
45
|
await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);
|
|
@@ -97,7 +98,7 @@ async function downloadAndExtractRepoAsync(root, { username , name , branch , fi
|
|
|
97
98
|
const projectName = _path.default.basename(root);
|
|
98
99
|
const strip = filePath ? filePath.split("/").length + 1 : 1;
|
|
99
100
|
const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;
|
|
100
|
-
|
|
101
|
+
debug("Downloading tarball from:", url);
|
|
101
102
|
await (0, _npm).extractNpmTarballFromUrlAsync(url, {
|
|
102
103
|
cwd: root,
|
|
103
104
|
name: projectName,
|
|
@@ -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\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 Log.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","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","debug","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","repoInfo","repoUrl","URL","error","code","fail","resolve","fs","existsSync","CommandError","extractLocalNpm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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;AACiC,IAAA,OAAiB,WAAjB,iBAAi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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"}
|
|
@@ -46,7 +46,7 @@ function _interopRequireWildcard(obj) {
|
|
|
46
46
|
async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , skipDependencyUpdate }) {
|
|
47
47
|
const updatingPackageJsonStep = (0, _ora).logNewSection("Updating your package.json scripts, dependencies, and main file");
|
|
48
48
|
const templatePkg = (0, _config).getPackageJson(templateDirectory);
|
|
49
|
-
const results =
|
|
49
|
+
const results = modifyPackageJson(projectRoot, {
|
|
50
50
|
templatePkg,
|
|
51
51
|
pkg,
|
|
52
52
|
skipDependencyUpdate
|
|
@@ -72,7 +72,7 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
|
|
|
72
72
|
* @param props.pkg Current package.json as JSON.
|
|
73
73
|
* @param props.skipDependencyUpdate Array of dependencies to skip updating.
|
|
74
74
|
* @returns
|
|
75
|
-
*/ function
|
|
75
|
+
*/ function modifyPackageJson(projectRoot, { templatePkg , pkg , skipDependencyUpdate }) {
|
|
76
76
|
updatePkgScripts({
|
|
77
77
|
pkg
|
|
78
78
|
});
|
|
@@ -101,10 +101,10 @@ function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDepe
|
|
|
101
101
|
...pkg1.dependencies
|
|
102
102
|
});
|
|
103
103
|
const requiredDependencies = [
|
|
104
|
+
"expo",
|
|
105
|
+
"expo-splash-screen",
|
|
104
106
|
"react",
|
|
105
|
-
"react-native
|
|
106
|
-
"react-native",
|
|
107
|
-
"expo-updates",
|
|
107
|
+
"react-native"
|
|
108
108
|
].filter((depKey)=>!!defaultDependencies[depKey]
|
|
109
109
|
);
|
|
110
110
|
const symlinkedPackages = [];
|
|
@@ -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 = [\n 'react',\n 'react-native-unimodules',\n 'react-native',\n 'expo-updates',\n ].filter((depKey) => !!defaultDependencies[depKey]);\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;QA4FrBC,qBAAqB,GAArBA,qBAAqB;QA0ErBC,qBAAqB,GAArBA,qBAAqB;QAcrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;QAKdC,qBAAqB,GAArBA,qBAAqB;AAxTa,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,kBAAkB,CAACT,WAAW,EAAE;QAC9CM,WAAW;QACXJ,GAAG;QACHC,oBAAoB;KACrB,CAAC,AAAC;IAEH,MAAMO,GAAE,QAAA,CAACC,QAAQ,C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AAQ,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 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,oBAAoB;KACrB,CAAC,AAAC;IAEH,MAAMO,GAAE,QAAA,CAACC,QAAQ,CAACC,SAAS,CACzBC,KAAI,QAAA,CAACC,OAAO,CAACd,WAAW,EAAE,cAAc,CAAC,EAC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D,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"}
|
|
@@ -5,44 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.resolveInstallApkNameAsync = resolveInstallApkNameAsync;
|
|
6
6
|
var _fs = _interopRequireDefault(require("fs"));
|
|
7
7
|
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var Log = _interopRequireWildcard(require("../../log"));
|
|
9
8
|
var _adb = require("../../start/platforms/android/adb");
|
|
10
9
|
function _interopRequireDefault(obj) {
|
|
11
10
|
return obj && obj.__esModule ? obj : {
|
|
12
11
|
default: obj
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
if (obj && obj.__esModule) {
|
|
17
|
-
return obj;
|
|
18
|
-
} else {
|
|
19
|
-
var newObj = {};
|
|
20
|
-
if (obj != null) {
|
|
21
|
-
for(var key in obj){
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
23
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
24
|
-
if (desc.get || desc.set) {
|
|
25
|
-
Object.defineProperty(newObj, key, desc);
|
|
26
|
-
} else {
|
|
27
|
-
newObj[key] = obj[key];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
newObj.default = obj;
|
|
33
|
-
return newObj;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
14
|
+
const debug = require("debug")("expo:run:android:resolveInstallApkName");
|
|
36
15
|
async function resolveInstallApkNameAsync(device, { appName , buildType , flavors , apkVariantDirectory }) {
|
|
37
16
|
const availableCPUs = await (0, _adb).getDeviceABIsAsync(device);
|
|
38
17
|
availableCPUs.push(_adb.DeviceABI.universal);
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
debug("Supported ABIs: " + availableCPUs.join(", "));
|
|
19
|
+
debug("Searching for APK: " + apkVariantDirectory);
|
|
41
20
|
// Check for cpu specific builds first
|
|
42
21
|
for (const availableCPU of availableCPUs){
|
|
43
22
|
const apkName = getApkFileName(appName, buildType, flavors, availableCPU);
|
|
44
23
|
const apkPath = _path.default.join(apkVariantDirectory, apkName);
|
|
45
|
-
|
|
24
|
+
debug("Checking for APK at:", apkPath);
|
|
46
25
|
if (_fs.default.existsSync(apkPath)) {
|
|
47
26
|
return apkName;
|
|
48
27
|
}
|
|
@@ -50,7 +29,7 @@ async function resolveInstallApkNameAsync(device, { appName , buildType , flavor
|
|
|
50
29
|
// Otherwise use the default apk named after the variant: app-debug.apk
|
|
51
30
|
const apkName = getApkFileName(appName, buildType, flavors);
|
|
52
31
|
const apkPath = _path.default.join(apkVariantDirectory, apkName);
|
|
53
|
-
|
|
32
|
+
debug("Checking for fallback APK at:", apkPath);
|
|
54
33
|
if (_fs.default.existsSync(apkPath)) {
|
|
55
34
|
return apkName;
|
|
56
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/run/android/resolveInstallApkName.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/run/android/resolveInstallApkName.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { Device, DeviceABI, getDeviceABIsAsync } from '../../start/platforms/android/adb';\nimport { GradleProps } from './resolveGradleProps';\n\nconst debug = require('debug')('expo:run:android:resolveInstallApkName') as typeof console.log;\n\nexport async function resolveInstallApkNameAsync(\n device: Pick<Device, 'name' | 'pid'>,\n { appName, buildType, flavors, apkVariantDirectory }: GradleProps\n) {\n const availableCPUs = await getDeviceABIsAsync(device);\n availableCPUs.push(DeviceABI.universal);\n\n debug('Supported ABIs: ' + availableCPUs.join(', '));\n debug('Searching for APK: ' + apkVariantDirectory);\n\n // Check for cpu specific builds first\n for (const availableCPU of availableCPUs) {\n const apkName = getApkFileName(appName, buildType, flavors, availableCPU);\n const apkPath = path.join(apkVariantDirectory, apkName);\n debug('Checking for APK at:', apkPath);\n if (fs.existsSync(apkPath)) {\n return apkName;\n }\n }\n\n // Otherwise use the default apk named after the variant: app-debug.apk\n const apkName = getApkFileName(appName, buildType, flavors);\n const apkPath = path.join(apkVariantDirectory, apkName);\n debug('Checking for fallback APK at:', apkPath);\n if (fs.existsSync(apkPath)) {\n return apkName;\n }\n\n return null;\n}\n\nfunction getApkFileName(\n appName: string,\n buildType: string,\n flavors?: string[] | null,\n cpuArch?: string | null\n) {\n let apkName = `${appName}-`;\n if (flavors) {\n apkName += flavors.reduce((rest, flavor) => `${rest}${flavor}-`, '');\n }\n if (cpuArch) {\n apkName += `${cpuArch}-`;\n }\n apkName += `${buildType}.apk`;\n\n return apkName;\n}\n"],"names":["resolveInstallApkNameAsync","debug","require","device","appName","buildType","flavors","apkVariantDirectory","availableCPUs","getDeviceABIsAsync","push","DeviceABI","universal","join","availableCPU","apkName","getApkFileName","apkPath","path","fs","existsSync","cpuArch","reduce","rest","flavor"],"mappings":"AAAA;;;;QAQsBA,0BAA0B,GAA1BA,0BAA0B;AARjC,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM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D,IAAIE,GAAE,QAAA,CAACC,UAAU,CAACH,OAAO,CAAC,EAAE;QAC1B,OAAOF,OAAO,CAAC;KAChB;IAED,OAAO,IAAI,CAAC;CACb;AAED,SAASC,cAAc,CACrBZ,OAAe,EACfC,SAAiB,EACjBC,OAAyB,EACzBe,OAAuB,EACvB;IACA,IAAIN,OAAO,GAAG,CAAC,EAAEX,OAAO,CAAC,CAAC,CAAC,AAAC;IAC5B,IAAIE,OAAO,EAAE;QACXS,OAAO,IAAIT,OAAO,CAACgB,MAAM,CAAC,CAACC,IAAI,EAAEC,MAAM,GAAK,CAAC,EAAED,IAAI,CAAC,EAAEC,MAAM,CAAC,CAAC,CAAC;QAAA,EAAE,EAAE,CAAC,CAAC;KACtE;IACD,IAAIH,OAAO,EAAE;QACXN,OAAO,IAAI,CAAC,EAAEM,OAAO,CAAC,CAAC,CAAC,CAAC;KAC1B;IACDN,OAAO,IAAI,CAAC,EAAEV,SAAS,CAAC,IAAI,CAAC,CAAC;IAE9B,OAAOU,OAAO,CAAC;CAChB"}
|
|
@@ -32,6 +32,7 @@ function _interopRequireWildcard(obj) {
|
|
|
32
32
|
return newObj;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
const debug = require("debug")("expo:doctor:apple:simulatorApp");
|
|
35
36
|
async function getSimulatorAppIdAsync() {
|
|
36
37
|
try {
|
|
37
38
|
return (await (0, _osascript).execAsync('id of app "Simulator"')).trim();
|
|
@@ -51,6 +52,7 @@ class SimulatorAppPrerequisite extends _prerequisite.Prerequisite {
|
|
|
51
52
|
if (result !== "com.apple.iphonesimulator" && result !== "com.apple.CoreSimulator.SimulatorTrampoline") {
|
|
52
53
|
throw new _prerequisite.PrerequisiteCommandError("SIMULATOR_APP", "Simulator is installed but is identified as '" + result + "'; don't know what that is.");
|
|
53
54
|
}
|
|
55
|
+
debug(`Simulator app id: ${result}`);
|
|
54
56
|
try {
|
|
55
57
|
// make sure we can run simctl
|
|
56
58
|
await (0, _spawnAsync).default("xcrun", [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/apple/SimulatorAppPrerequisite.ts"],"sourcesContent":["import { execAsync } from '@expo/osascript';\nimport spawnAsync from '@expo/spawn-async';\n\nimport * as Log from '../../../log';\nimport { Prerequisite, PrerequisiteCommandError } from '../Prerequisite';\n\nasync function getSimulatorAppIdAsync(): Promise<string | null> {\n try {\n return (await execAsync('id of app \"Simulator\"')).trim();\n } catch {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n }\n return null;\n}\n\nexport class SimulatorAppPrerequisite extends Prerequisite {\n static instance = new SimulatorAppPrerequisite();\n\n async assertImplementation(): Promise<void> {\n const result = await getSimulatorAppIdAsync();\n if (!result) {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Can't determine id of Simulator app; the Simulator is most likely not installed on this machine. Run `sudo xcode-select -s /Applications/Xcode.app`\"\n );\n }\n if (\n result !== 'com.apple.iphonesimulator' &&\n result !== 'com.apple.CoreSimulator.SimulatorTrampoline'\n ) {\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Simulator is installed but is identified as '\" + result + \"'; don't know what that is.\"\n );\n }\n\n try {\n // make sure we can run simctl\n await spawnAsync('xcrun', ['simctl', 'help']);\n } catch (error: any) {\n Log.warn(`Unable to run simctl:\\n${error.toString()}`);\n throw new PrerequisiteCommandError(\n 'SIMCTL',\n 'xcrun is not configured correctly. Ensure `sudo xcode-select --reset` works before running this command again.'\n );\n }\n }\n}\n"],"names":["Log","getSimulatorAppIdAsync","execAsync","trim","SimulatorAppPrerequisite","Prerequisite","instance","assertImplementation","result","PrerequisiteCommandError","spawnAsync","error","warn","toString"],"mappings":"AAAA;;;;AAA0B,IAAA,UAAiB,WAAjB,iBAAiB,CAAA;AACpB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAE9BA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACwC,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExE,eAAeC,sBAAsB,GAA2B;IAC9D,IAAI;QACF,OAAO,CAAC,MAAMC,CAAAA,GAAAA,UAAS,AAAyB,CAAA,UAAzB,CAAC,uBAAuB,CAAC,CAAC,CAACC,IAAI,EAAE,CAAC;KAC1D,CAAC,OAAM;IACN,kGAAkG;KACnG;IACD,OAAO,IAAI,CAAC;CACb;AAEM,MAAMC,wBAAwB,SAASC,aAAY,aAAA;IACxD,OAAOC,QAAQ,GAAG,IAAIF,wBAAwB,EAAE,CAAC;IAEjD,MAAMG,oBAAoB,GAAkB;QAC1C,MAAMC,MAAM,GAAG,MAAMP,sBAAsB,EAAE,AAAC;QAC9C,IAAI,CAACO,MAAM,EAAE;YACX,kGAAkG;YAClG,MAAM,IAAIC,aAAwB,yBAAA,CAChC,eAAe,EACf,qJAAqJ,CACtJ,CAAC;SACH;QACD,IACED,MAAM,KAAK,2BAA2B,IACtCA,MAAM,KAAK,6CAA6C,EACxD;YACA,MAAM,IAAIC,aAAwB,yBAAA,CAChC,eAAe,EACf,+CAA+C,GAAGD,MAAM,GAAG,6BAA6B,CACzF,CAAC;SACH;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/apple/SimulatorAppPrerequisite.ts"],"sourcesContent":["import { execAsync } from '@expo/osascript';\nimport spawnAsync from '@expo/spawn-async';\n\nimport * as Log from '../../../log';\nimport { Prerequisite, PrerequisiteCommandError } from '../Prerequisite';\n\nconst debug = require('debug')('expo:doctor:apple:simulatorApp') as typeof console.log;\n\nasync function getSimulatorAppIdAsync(): Promise<string | null> {\n try {\n return (await execAsync('id of app \"Simulator\"')).trim();\n } catch {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n }\n return null;\n}\n\nexport class SimulatorAppPrerequisite extends Prerequisite {\n static instance = new SimulatorAppPrerequisite();\n\n async assertImplementation(): Promise<void> {\n const result = await getSimulatorAppIdAsync();\n if (!result) {\n // This error may occur in CI where the users intends to install just the simulators but no Xcode.\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Can't determine id of Simulator app; the Simulator is most likely not installed on this machine. Run `sudo xcode-select -s /Applications/Xcode.app`\"\n );\n }\n if (\n result !== 'com.apple.iphonesimulator' &&\n result !== 'com.apple.CoreSimulator.SimulatorTrampoline'\n ) {\n throw new PrerequisiteCommandError(\n 'SIMULATOR_APP',\n \"Simulator is installed but is identified as '\" + result + \"'; don't know what that is.\"\n );\n }\n debug(`Simulator app id: ${result}`);\n\n try {\n // make sure we can run simctl\n await spawnAsync('xcrun', ['simctl', 'help']);\n } catch (error: any) {\n Log.warn(`Unable to run simctl:\\n${error.toString()}`);\n throw new PrerequisiteCommandError(\n 'SIMCTL',\n 'xcrun is not configured correctly. Ensure `sudo xcode-select --reset` works before running this command again.'\n );\n }\n }\n}\n"],"names":["Log","debug","require","getSimulatorAppIdAsync","execAsync","trim","SimulatorAppPrerequisite","Prerequisite","instance","assertImplementation","result","PrerequisiteCommandError","spawnAsync","error","warn","toString"],"mappings":"AAAA;;;;AAA0B,IAAA,UAAiB,WAAjB,iBAAiB,CAAA;AACpB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAE9BA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACwC,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,gCAAgC,CAAC,AAAsB,AAAC;AAEvF,eAAeC,sBAAsB,GAA2B;IAC9D,IAAI;QACF,OAAO,CAAC,MAAMC,CAAAA,GAAAA,UAAS,AAAyB,CAAA,UAAzB,CAAC,uBAAuB,CAAC,CAAC,CAACC,IAAI,EAAE,CAAC;KAC1D,CAAC,OAAM;IACN,kGAAkG;KACnG;IACD,OAAO,IAAI,CAAC;CACb;AAEM,MAAMC,wBAAwB,SAASC,aAAY,aAAA;IACxD,OAAOC,QAAQ,GAAG,IAAIF,wBAAwB,EAAE,CAAC;IAEjD,MAAMG,oBAAoB,GAAkB;QAC1C,MAAMC,MAAM,GAAG,MAAMP,sBAAsB,EAAE,AAAC;QAC9C,IAAI,CAACO,MAAM,EAAE;YACX,kGAAkG;YAClG,MAAM,IAAIC,aAAwB,yBAAA,CAChC,eAAe,EACf,qJAAqJ,CACtJ,CAAC;SACH;QACD,IACED,MAAM,KAAK,2BAA2B,IACtCA,MAAM,KAAK,6CAA6C,EACxD;YACA,MAAM,IAAIC,aAAwB,yBAAA,CAChC,eAAe,EACf,+CAA+C,GAAGD,MAAM,GAAG,6BAA6B,CACzF,CAAC;SACH;QACDT,KAAK,CAAC,CAAC,kBAAkB,EAAES,MAAM,CAAC,CAAC,CAAC,CAAC;QAErC,IAAI;YACF,8BAA8B;YAC9B,MAAME,CAAAA,GAAAA,WAAU,AAA6B,CAAA,QAA7B,CAAC,OAAO,EAAE;gBAAC,QAAQ;gBAAE,MAAM;aAAC,CAAC,CAAC;SAC/C,CAAC,OAAOC,KAAK,EAAO;YACnBb,GAAG,CAACc,IAAI,CAAC,CAAC,uBAAuB,EAAED,KAAK,CAACE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;YACvD,MAAM,IAAIJ,aAAwB,yBAAA,CAChC,QAAQ,EACR,gHAAgH,CACjH,CAAC;SACH;KACF;CACF;QAlCYL,wBAAwB,GAAxBA,wBAAwB"}
|
|
@@ -36,6 +36,7 @@ function _interopRequireWildcard(obj) {
|
|
|
36
36
|
return newObj;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
const debug = require("debug")("expo:doctor:apple:xcode");
|
|
39
40
|
// Based on the RN docs (Aug 2020).
|
|
40
41
|
const MIN_XCODE_VERSION = 9.4;
|
|
41
42
|
const APP_STORE_ID = "497799835";
|
|
@@ -98,6 +99,7 @@ class XcodePrerequisite extends _prerequisite.Prerequisite {
|
|
|
98
99
|
* Ensure Xcode is installed and recent enough to be used with Expo.
|
|
99
100
|
*/ async assertImplementation() {
|
|
100
101
|
const version = (0, _profile).profile(getXcodeVersionAsync)();
|
|
102
|
+
debug(`Xcode version: ${version}`);
|
|
101
103
|
if (!version) {
|
|
102
104
|
// Almost certainly Xcode isn't installed.
|
|
103
105
|
await promptToOpenAppStoreAsync(`Xcode needs to be installed (don't worry, you won't have to use it), would you like to continue to the App Store?`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/apple/XcodePrerequisite.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { AbortCommandError } from '../../../utils/errors';\nimport { profile } from '../../../utils/profile';\nimport { confirmAsync } from '../../../utils/prompts';\nimport { Prerequisite } from '../Prerequisite';\n\n// Based on the RN docs (Aug 2020).\nconst MIN_XCODE_VERSION = 9.4;\nconst APP_STORE_ID = '497799835';\n\nconst SUGGESTED_XCODE_VERSION = `${MIN_XCODE_VERSION}.0`;\n\nconst promptToOpenAppStoreAsync = async (message: string) => {\n // This prompt serves no purpose accept informing the user what to do next, we could just open the App Store but it could be confusing if they don't know what's going on.\n const confirm = await confirmAsync({ initial: true, message });\n if (confirm) {\n Log.log(`Going to the App Store, re-run Expo when Xcode has finished installing.`);\n openAppStore(APP_STORE_ID);\n }\n};\n\n/** Exposed for testing, use `getXcodeVersion` */\nexport const getXcodeVersionAsync = (): string | null | false => {\n try {\n const last = execSync('xcodebuild -version', { stdio: 'pipe' })\n .toString()\n .match(/^Xcode (\\d+\\.\\d+)/)?.[1];\n // Convert to a semver string\n if (last) {\n const version = `${last}.0`;\n\n if (!semver.valid(version)) {\n // Not sure why this would happen, if it does we should add a more confident error message.\n Log.error(`Xcode version is in an unknown format: ${version}`);\n return false;\n }\n\n return version;\n }\n // not sure what's going on\n Log.error(\n 'Unable to check Xcode version. Command ran successfully but no version number was found.'\n );\n } catch {\n // not installed\n }\n return null;\n};\n\n/**\n * Open a link to the App Store. Just link in mobile apps, **never** redirect without prompting first.\n *\n * @param appId\n */\nfunction openAppStore(appId: string) {\n const link = getAppStoreLink(appId);\n execSync(`open ${link}`, { stdio: 'ignore' });\n}\n\nfunction getAppStoreLink(appId: string): string {\n if (process.platform === 'darwin') {\n // TODO: Is there ever a case where the macappstore isn't available on mac?\n return `macappstore://itunes.apple.com/app/id${appId}`;\n }\n return `https://apps.apple.com/us/app/id${appId}`;\n}\n\nexport class XcodePrerequisite extends Prerequisite {\n static instance = new XcodePrerequisite();\n\n /**\n * Ensure Xcode is installed and recent enough to be used with Expo.\n */\n async assertImplementation(): Promise<void> {\n const version = profile(getXcodeVersionAsync)();\n if (!version) {\n // Almost certainly Xcode isn't installed.\n await promptToOpenAppStoreAsync(\n `Xcode needs to be installed (don't worry, you won't have to use it), would you like to continue to the App Store?`\n );\n throw new AbortCommandError();\n }\n\n if (semver.lt(version, SUGGESTED_XCODE_VERSION)) {\n // Xcode version is too old.\n await promptToOpenAppStoreAsync(\n `Xcode (${version}) needs to be updated to at least version ${MIN_XCODE_VERSION}, would you like to continue to the App Store?`\n );\n throw new AbortCommandError();\n }\n }\n}\n"],"names":["Log","MIN_XCODE_VERSION","APP_STORE_ID","SUGGESTED_XCODE_VERSION","promptToOpenAppStoreAsync","message","confirm","confirmAsync","initial","log","openAppStore","getXcodeVersionAsync","execSync","last","stdio","toString","match","version","semver","valid","error","appId","link","getAppStoreLink","process","platform","XcodePrerequisite","Prerequisite","instance","assertImplementation","profile","AbortCommandError","lt"],"mappings":"AAAA;;;;;AAAyB,IAAA,aAAe,WAAf,eAAe,CAAA;AACrB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACmB,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACjC,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACnB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;AACxB,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,mCAAmC;AACnC,MAAMC,iBAAiB,GAAG,GAAG,AAAC;AAC9B,MAAMC,YAAY,GAAG,WAAW,AAAC;AAEjC,MAAMC,uBAAuB,GAAG,CAAC,EAAEF,iBAAiB,CAAC,EAAE,CAAC,AAAC;AAEzD,MAAMG,yBAAyB,GAAG,OAAOC,OAAe,GAAK;IAC3D,0KAA0K;IAC1K,MAAMC,OAAO,GAAG,MAAMC,CAAAA,GAAAA,QAAY,AAA4B,CAAA,aAA5B,CAAC;QAAEC,OAAO,EAAE,IAAI;QAAEH,OAAO;KAAE,CAAC,AAAC;IAC/D,IAAIC,OAAO,EAAE;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/apple/XcodePrerequisite.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { AbortCommandError } from '../../../utils/errors';\nimport { profile } from '../../../utils/profile';\nimport { confirmAsync } from '../../../utils/prompts';\nimport { Prerequisite } from '../Prerequisite';\n\nconst debug = require('debug')('expo:doctor:apple:xcode') as typeof console.log;\n\n// Based on the RN docs (Aug 2020).\nconst MIN_XCODE_VERSION = 9.4;\nconst APP_STORE_ID = '497799835';\n\nconst SUGGESTED_XCODE_VERSION = `${MIN_XCODE_VERSION}.0`;\n\nconst promptToOpenAppStoreAsync = async (message: string) => {\n // This prompt serves no purpose accept informing the user what to do next, we could just open the App Store but it could be confusing if they don't know what's going on.\n const confirm = await confirmAsync({ initial: true, message });\n if (confirm) {\n Log.log(`Going to the App Store, re-run Expo when Xcode has finished installing.`);\n openAppStore(APP_STORE_ID);\n }\n};\n\n/** Exposed for testing, use `getXcodeVersion` */\nexport const getXcodeVersionAsync = (): string | null | false => {\n try {\n const last = execSync('xcodebuild -version', { stdio: 'pipe' })\n .toString()\n .match(/^Xcode (\\d+\\.\\d+)/)?.[1];\n // Convert to a semver string\n if (last) {\n const version = `${last}.0`;\n\n if (!semver.valid(version)) {\n // Not sure why this would happen, if it does we should add a more confident error message.\n Log.error(`Xcode version is in an unknown format: ${version}`);\n return false;\n }\n\n return version;\n }\n // not sure what's going on\n Log.error(\n 'Unable to check Xcode version. Command ran successfully but no version number was found.'\n );\n } catch {\n // not installed\n }\n return null;\n};\n\n/**\n * Open a link to the App Store. Just link in mobile apps, **never** redirect without prompting first.\n *\n * @param appId\n */\nfunction openAppStore(appId: string) {\n const link = getAppStoreLink(appId);\n execSync(`open ${link}`, { stdio: 'ignore' });\n}\n\nfunction getAppStoreLink(appId: string): string {\n if (process.platform === 'darwin') {\n // TODO: Is there ever a case where the macappstore isn't available on mac?\n return `macappstore://itunes.apple.com/app/id${appId}`;\n }\n return `https://apps.apple.com/us/app/id${appId}`;\n}\n\nexport class XcodePrerequisite extends Prerequisite {\n static instance = new XcodePrerequisite();\n\n /**\n * Ensure Xcode is installed and recent enough to be used with Expo.\n */\n async assertImplementation(): Promise<void> {\n const version = profile(getXcodeVersionAsync)();\n debug(`Xcode version: ${version}`);\n if (!version) {\n // Almost certainly Xcode isn't installed.\n await promptToOpenAppStoreAsync(\n `Xcode needs to be installed (don't worry, you won't have to use it), would you like to continue to the App Store?`\n );\n throw new AbortCommandError();\n }\n\n if (semver.lt(version, SUGGESTED_XCODE_VERSION)) {\n // Xcode version is too old.\n await promptToOpenAppStoreAsync(\n `Xcode (${version}) needs to be updated to at least version ${MIN_XCODE_VERSION}, would you like to continue to the App Store?`\n );\n throw new AbortCommandError();\n }\n }\n}\n"],"names":["Log","debug","require","MIN_XCODE_VERSION","APP_STORE_ID","SUGGESTED_XCODE_VERSION","promptToOpenAppStoreAsync","message","confirm","confirmAsync","initial","log","openAppStore","getXcodeVersionAsync","execSync","last","stdio","toString","match","version","semver","valid","error","appId","link","getAppStoreLink","process","platform","XcodePrerequisite","Prerequisite","instance","assertImplementation","profile","AbortCommandError","lt"],"mappings":"AAAA;;;;;AAAyB,IAAA,aAAe,WAAf,eAAe,CAAA;AACrB,IAAA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e,EAAEkB,OAAO,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,CAACA,OAAO,EAAE;YACZ,0CAA0C;YAC1C,MAAMb,yBAAyB,CAC7B,CAAC,iHAAiH,CAAC,CACpH,CAAC;YACF,MAAM,IAAI2B,OAAiB,kBAAA,EAAE,CAAC;SAC/B;QAED,IAAIb,OAAM,QAAA,CAACc,EAAE,CAACf,OAAO,EAAEd,uBAAuB,CAAC,EAAE;YAC/C,4BAA4B;YAC5B,MAAMC,yBAAyB,CAC7B,CAAC,OAAO,EAAEa,OAAO,CAAC,0CAA0C,EAAEhB,iBAAiB,CAAC,8CAA8C,CAAC,CAChI,CAAC;YACF,MAAM,IAAI8B,OAAiB,kBAAA,EAAE,CAAC;SAC/B;KACF;CACF;QAzBYL,iBAAiB,GAAjBA,iBAAiB"}
|
|
@@ -36,16 +36,17 @@ function _interopRequireWildcard(obj) {
|
|
|
36
36
|
return newObj;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
const debug = require("debug")("expo:doctor:dependencies:bundledNativeModules");
|
|
39
40
|
async function getVersionedNativeModulesAsync(projectRoot, sdkVersion) {
|
|
40
41
|
if (sdkVersion !== "UNVERSIONED" && !_settings.APISettings.isOffline) {
|
|
41
42
|
try {
|
|
42
|
-
|
|
43
|
+
debug("Fetching bundled native modules from the server...");
|
|
43
44
|
return await (0, _getNativeModuleVersions).getNativeModuleVersionsAsync(sdkVersion);
|
|
44
45
|
} catch {
|
|
45
46
|
Log.warn(_chalk.default`Unable to reach Expo servers. Falling back to using the cached dependency map ({bold bundledNativeModules.json}) from the package "{bold expo}" installed in your project.`);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
debug("Fetching bundled native modules from the local JSON file...");
|
|
49
50
|
return await getBundledNativeModulesAsync(projectRoot);
|
|
50
51
|
}
|
|
51
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/bundledNativeModules.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\n\nimport { getNativeModuleVersionsAsync } from '../../../api/getNativeModuleVersions';\nimport { APISettings } from '../../../api/settings';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\n\nexport type BundledNativeModules = Record<string, string>;\n\n/**\n * Gets the bundledNativeModules.json for a given SDK version:\n * - Tries to fetch the data from the /sdks/:sdkVersion/native-modules API endpoint.\n * - If the data is missing on the server (it can happen for SDKs that are yet fully released)\n * or there's a downtime, reads the local .json file from the \"expo\" package.\n * - For UNVERSIONED, returns the local .json file contents.\n */\nexport async function getVersionedNativeModulesAsync(\n projectRoot: string,\n sdkVersion: string\n): Promise<BundledNativeModules> {\n if (sdkVersion !== 'UNVERSIONED' && !APISettings.isOffline) {\n try {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/bundledNativeModules.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\n\nimport { getNativeModuleVersionsAsync } from '../../../api/getNativeModuleVersions';\nimport { APISettings } from '../../../api/settings';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')(\n 'expo:doctor:dependencies:bundledNativeModules'\n) as typeof console.log;\n\nexport type BundledNativeModules = Record<string, string>;\n\n/**\n * Gets the bundledNativeModules.json for a given SDK version:\n * - Tries to fetch the data from the /sdks/:sdkVersion/native-modules API endpoint.\n * - If the data is missing on the server (it can happen for SDKs that are yet fully released)\n * or there's a downtime, reads the local .json file from the \"expo\" package.\n * - For UNVERSIONED, returns the local .json file contents.\n */\nexport async function getVersionedNativeModulesAsync(\n projectRoot: string,\n sdkVersion: string\n): Promise<BundledNativeModules> {\n if (sdkVersion !== 'UNVERSIONED' && !APISettings.isOffline) {\n try {\n debug('Fetching bundled native modules from the server...');\n return await getNativeModuleVersionsAsync(sdkVersion);\n } catch {\n Log.warn(\n chalk`Unable to reach Expo servers. Falling back to using the cached dependency map ({bold bundledNativeModules.json}) from the package \"{bold expo}\" installed in your project.`\n );\n }\n }\n\n debug('Fetching bundled native modules from the local JSON file...');\n return await getBundledNativeModulesAsync(projectRoot);\n}\n\n/**\n * Get the legacy static `bundledNativeModules.json` file\n * that's shipped with the version of `expo` that the project has installed.\n */\nasync function getBundledNativeModulesAsync(projectRoot: string): Promise<BundledNativeModules> {\n // TODO: Revisit now that this code is in the `expo` package.\n const bundledNativeModulesPath = resolveFrom.silent(\n projectRoot,\n 'expo/bundledNativeModules.json'\n );\n if (!bundledNativeModulesPath) {\n Log.log();\n throw new CommandError(\n chalk`The dependency map {bold expo/bundledNativeModules.json} cannot be found, please ensure you have the package \"{bold expo}\" installed in your project.`\n );\n }\n return await JsonFile.readAsync<BundledNativeModules>(bundledNativeModulesPath);\n}\n"],"names":["getVersionedNativeModulesAsync","Log","debug","require","projectRoot","sdkVersion","APISettings","isOffline","getNativeModuleVersionsAsync","warn","chalk","getBundledNativeModulesAsync","bundledNativeModulesPath","resolveFrom","silent","log","CommandError","JsonFile","readAsync"],"mappings":"AAAA;;;;QAsBsBA,8BAA8B,GAA9BA,8BAA8B;AAtB/B,IAAA,SAAiB,kCAAjB,iBAAiB,EAAA;AACpB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEO,IAAA,wBAAsC,WAAtC,sCAAsC,CAAA;AACvD,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACvCC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,+CAA+C,CAChD,AAAsB,AAAC;AAWjB,eAAeH,8BAA8B,CAClDI,WAAmB,EACnBC,UAAkB,EACa;IAC/B,IAAIA,UAAU,K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