@expo/cli 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +89 -4
- package/build/bin/cli.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 +51 -34
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +15 -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/run/android/runAndroidAsync.js +3 -3
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ensureNativeProject.js +3 -0
- package/build/src/run/ensureNativeProject.js.map +1 -1
- package/build/src/run/hints.js +1 -1
- package/build/src/run/hints.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +275 -0
- package/build/src/run/ios/XcodeBuild.js.map +1 -0
- package/build/src/run/ios/XcodeBuild.types.js +6 -0
- package/build/src/run/ios/XcodeBuild.types.js.map +1 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js +161 -0
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -0
- package/build/src/run/ios/appleDevice/ClientManager.js +161 -0
- package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js +195 -0
- package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js +107 -0
- package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +97 -0
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js +140 -0
- package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +91 -0
- package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js +21 -0
- package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +117 -0
- package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +90 -0
- package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +332 -0
- package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js +115 -0
- package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +126 -0
- package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +74 -0
- package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js +65 -0
- package/build/src/run/ios/appleDevice/protocol/UsbmuxProtocol.js.map +1 -0
- package/build/src/run/ios/codeSigning/Security.js +85 -0
- package/build/src/run/ios/codeSigning/Security.js.map +1 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js +77 -0
- package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +102 -0
- package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -0
- package/build/src/run/ios/codeSigning/settings.js +21 -0
- package/build/src/run/ios/codeSigning/settings.js.map +1 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +76 -0
- package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -0
- package/build/src/run/ios/index.js +98 -0
- package/build/src/run/ios/index.js.map +1 -0
- package/build/src/run/ios/launchApp.js +75 -0
- package/build/src/run/ios/launchApp.js.map +1 -0
- package/build/src/run/ios/options/promptDevice.js +50 -0
- package/build/src/run/ios/options/promptDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveDevice.js +92 -0
- package/build/src/run/ios/options/resolveDevice.js.map +1 -0
- package/build/src/run/ios/options/resolveNativeScheme.js +92 -0
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -0
- package/build/src/run/ios/options/resolveOptions.js +44 -0
- package/build/src/run/ios/options/resolveOptions.js.map +1 -0
- package/build/src/run/ios/options/resolveXcodeProject.js +39 -0
- package/build/src/run/ios/options/resolveXcodeProject.js.map +1 -0
- package/build/src/run/ios/runIosAsync.js +85 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -0
- package/build/src/run/resolveBundlerProps.js +9 -6
- package/build/src/run/resolveBundlerProps.js.map +1 -1
- package/build/src/run/startBundler.js +4 -2
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js +4 -4
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/SecurityBinPrerequisite.js +27 -0
- package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -0
- 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/XcodeDeveloperDiskImagePrerequisite.js +69 -0
- package/build/src/start/doctor/apple/XcodeDeveloperDiskImagePrerequisite.js.map +1 -0
- 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 +32 -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/emulator.js +8 -0
- package/build/src/start/platforms/android/emulator.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/android/promptAndroidDevice.js +1 -5
- package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.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/promptAppleDevice.js +1 -5
- package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +14 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/platforms/ios/simctlLogging.js +220 -0
- package/build/src/start/platforms/ios/simctlLogging.js.map +1 -0
- 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 -1
- 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 +30 -3
- package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
- package/build/src/utils/cocoapods.js +47 -0
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +6 -1
- package/build/src/utils/dir.js.map +1 -1
- 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/plist.js +59 -0
- package/build/src/utils/plist.js.map +1 -0
- package/build/src/utils/progress.js +46 -0
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/prompts.js +19 -3
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/resolveArgs.js +4 -1
- package/build/src/utils/resolveArgs.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/terminal.js +10 -0
- package/build/src/utils/terminal.js.map +1 -0
- 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 +14 -10
- 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
|
@@ -9,34 +9,13 @@ exports.mutatePackagesWithKnownVersionsAsync = mutatePackagesWithKnownVersionsAs
|
|
|
9
9
|
var _jsonFile = _interopRequireDefault(require("@expo/json-file"));
|
|
10
10
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
11
11
|
var _semver = _interopRequireDefault(require("semver"));
|
|
12
|
-
var Log = _interopRequireWildcard(require("../../../log"));
|
|
13
12
|
var _getVersionedPackages = require("./getVersionedPackages");
|
|
14
13
|
function _interopRequireDefault(obj) {
|
|
15
14
|
return obj && obj.__esModule ? obj : {
|
|
16
15
|
default: obj
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
if (obj && obj.__esModule) {
|
|
21
|
-
return obj;
|
|
22
|
-
} else {
|
|
23
|
-
var newObj = {};
|
|
24
|
-
if (obj != null) {
|
|
25
|
-
for(var key in obj){
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
28
|
-
if (desc.get || desc.set) {
|
|
29
|
-
Object.defineProperty(newObj, key, desc);
|
|
30
|
-
} else {
|
|
31
|
-
newObj[key] = obj[key];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
newObj.default = obj;
|
|
37
|
-
return newObj;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
18
|
+
const debug = require("debug")("expo:doctor:dependencies:getMissingPackages");
|
|
40
19
|
function collectMissingPackages(projectRoot, requiredPackages) {
|
|
41
20
|
const resolutions = {};
|
|
42
21
|
const missingPackages = requiredPackages.filter((p)=>{
|
|
@@ -55,7 +34,7 @@ function collectMissingPackages(projectRoot, requiredPackages) {
|
|
|
55
34
|
function versionSatisfiesRequiredPackage(packageJsonFilePath, resolvedPackage) {
|
|
56
35
|
// If the version is specified, check that it satisfies the installed version.
|
|
57
36
|
if (!resolvedPackage.version) {
|
|
58
|
-
|
|
37
|
+
debug(`Required package "${resolvedPackage.pkg}" found (no version constraint specified).`);
|
|
59
38
|
return true;
|
|
60
39
|
}
|
|
61
40
|
const pkgJson = _jsonFile.default.read(packageJsonFilePath);
|
|
@@ -64,7 +43,7 @@ function versionSatisfiesRequiredPackage(packageJsonFilePath, resolvedPackage) {
|
|
|
64
43
|
_semver.default.satisfies(pkgJson.version, resolvedPackage.version)) {
|
|
65
44
|
return true;
|
|
66
45
|
}
|
|
67
|
-
|
|
46
|
+
debug(`Installed package "${resolvedPackage.pkg}" does not satisfy version constraint "${resolvedPackage.version}" (version: "${pkgJson.version}")`);
|
|
68
47
|
return false;
|
|
69
48
|
}
|
|
70
49
|
async function getMissingPackagesAsync(projectRoot, { sdkVersion , requiredPackages }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/getMissingPackages.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/getMissingPackages.ts"],"sourcesContent":["import JsonFile from '@expo/json-file';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport { getCombinedKnownVersionsAsync } from './getVersionedPackages';\n\nconst debug = require('debug')('expo:doctor:dependencies:getMissingPackages') as typeof console.log;\n\nexport type ResolvedPackage = {\n /** Module ID pointing to the library `package.json`. */\n file: string;\n /** NPM package name. */\n pkg: string;\n /** Required version range. */\n version?: string;\n /** If the dependency should be installed as a `devDependency` */\n dev?: boolean;\n};\n\n/** Given a set of required packages, this method returns a list of missing packages. */\nexport function collectMissingPackages(\n projectRoot: string,\n requiredPackages: ResolvedPackage[]\n): {\n missing: ResolvedPackage[];\n resolutions: Record<string, string>;\n} {\n const resolutions: Record<string, string> = {};\n\n const missingPackages = requiredPackages.filter((p) => {\n const resolved = resolveFrom.silent(projectRoot, p.file);\n if (!resolved || !versionSatisfiesRequiredPackage(resolved, p)) {\n return true;\n }\n resolutions[p.pkg] = resolved;\n return false;\n });\n\n return { missing: missingPackages, resolutions };\n}\n\nexport function versionSatisfiesRequiredPackage(\n packageJsonFilePath: string,\n resolvedPackage: Pick<ResolvedPackage, 'version' | 'pkg'>\n): boolean {\n // If the version is specified, check that it satisfies the installed version.\n if (!resolvedPackage.version) {\n debug(`Required package \"${resolvedPackage.pkg}\" found (no version constraint specified).`);\n return true;\n }\n\n const pkgJson = JsonFile.read(packageJsonFilePath);\n if (\n // package.json has version.\n typeof pkgJson.version === 'string' &&\n // semver satisfaction.\n semver.satisfies(pkgJson.version, resolvedPackage.version)\n ) {\n return true;\n }\n debug(\n `Installed package \"${resolvedPackage.pkg}\" does not satisfy version constraint \"${resolvedPackage.version}\" (version: \"${pkgJson.version}\")`\n );\n return false;\n}\n\n/**\n * Collect missing packages given a list of required packages.\n * Any missing packages will be versioned to the known versions for the current SDK.\n *\n * @param projectRoot\n * @param props.requiredPackages list of required packages to check for\n * @returns list of missing packages and resolutions to existing packages.\n */\nexport async function getMissingPackagesAsync(\n projectRoot: string,\n {\n sdkVersion,\n requiredPackages,\n }: {\n sdkVersion?: string;\n requiredPackages: ResolvedPackage[];\n }\n): Promise<{\n missing: ResolvedPackage[];\n resolutions: Record<string, string>;\n}> {\n const results = collectMissingPackages(projectRoot, requiredPackages);\n if (!results.missing.length) {\n return results;\n }\n\n // Ensure the versions are right for the SDK that the project is currently using.\n await mutatePackagesWithKnownVersionsAsync(projectRoot, sdkVersion, results.missing);\n\n return results;\n}\n\nexport async function mutatePackagesWithKnownVersionsAsync(\n projectRoot: string,\n sdkVersion: string | undefined,\n packages: ResolvedPackage[]\n) {\n // Ensure the versions are right for the SDK that the project is currently using.\n const relatedPackages = await getCombinedKnownVersionsAsync({ projectRoot, sdkVersion });\n for (const pkg of packages) {\n if (\n // Only use the SDK versions if the package does not already have a hardcoded version.\n // We do this because some packages have API coded into the CLI which expects an exact version.\n !pkg.version &&\n pkg.pkg in relatedPackages\n ) {\n pkg.version = relatedPackages[pkg.pkg];\n }\n }\n return packages;\n}\n"],"names":["collectMissingPackages","versionSatisfiesRequiredPackage","getMissingPackagesAsync","mutatePackagesWithKnownVersionsAsync","debug","require","projectRoot","requiredPackages","resolutions","missingPackages","filter","p","resolved","resolveFrom","silent","file","pkg","missing","packageJsonFilePath","resolvedPackage","version","pkgJson","JsonFile","read","semver","satisfies","sdkVersion","results","length","packages","relatedPackages","getCombinedKnownVersionsAsync"],"mappings":"AAAA;;;;QAoBgBA,sBAAsB,GAAtBA,sBAAsB;QAqBtBC,+BAA+B,GAA/BA,+BAA+B;QAiCzBC,uBAAuB,GAAvBA,uBAAuB;QAwBvBC,oCAAoC,GAApCA,oCAAoC;AAlGrC,IAAA,SAAiB,kCAAjB,iBAAiB,EAAA;AACd,IAAA,YAAc,kCAAd,cAAc,EAAA;AACnB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEmB,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;;;;;;AAEtE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,AAAsB,AAAC;AAc7F,SAASL,sBAAsB,CACpCM,WAAmB,EACnBC,gBAAmC,EAInC;IACA,MAAMC,WAAW,GAA2B,EAAE,AAAC;IAE/C,MAAMC,eAAe,GAAGF,gBAAgB,CAACG,MAAM,CAAC,CAACC,CAAC,GAAK;QACrD,MAAMC,QAAQ,GAAGC,YAAW,QAAA,CAACC,MAAM,CAACR,WAAW,EAAEK,CAAC,CAACI,IAAI,CAAC,AAAC;QACzD,IAAI,CAACH,Q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C;KAChB;IAED,iFAAiF;IACjF,MAAMxB,oCAAoC,CAACG,WAAW,EAAEoB,UAAU,EAAEC,OAAO,CAACV,OAAO,CAAC,CAAC;IAErF,OAAOU,OAAO,CAAC;CAChB;AAEM,eAAexB,oCAAoC,CACxDG,WAAmB,EACnBoB,UAA8B,EAC9BG,QAA2B,EAC3B;IACA,iFAAiF;IACjF,MAAMC,eAAe,GAAG,MAAMC,CAAAA,GAAAA,qBAA6B,AAA6B,CAAA,8BAA7B,CAAC;QAAEzB,WAAW;QAAEoB,UAAU;KAAE,CAAC,AAAC;IACzF,KAAK,MAAMV,GAAG,IAAIa,QAAQ,CAAE;QAC1B,IACE,sFAAsF;QACtF,+FAA+F;QAC/F,CAACb,GAAG,CAACI,OAAO,IACZJ,GAAG,CAACA,GAAG,IAAIc,eAAe,EAC1B;YACAd,GAAG,CAACI,OAAO,GAAGU,eAAe,CAACd,GAAG,CAACA,GAAG,CAAC,CAAC;SACxC;KACF;IACD,OAAOa,QAAQ,CAAC;CACjB"}
|
|
@@ -8,34 +8,13 @@ exports.getVersionedPackagesAsync = getVersionedPackagesAsync;
|
|
|
8
8
|
exports.getOperationLog = getOperationLog;
|
|
9
9
|
var _npmPackageArg = _interopRequireDefault(require("npm-package-arg"));
|
|
10
10
|
var _getVersions = require("../../../api/getVersions");
|
|
11
|
-
var Log = _interopRequireWildcard(require("../../../log"));
|
|
12
11
|
var _bundledNativeModules = require("./bundledNativeModules");
|
|
13
12
|
function _interopRequireDefault(obj) {
|
|
14
13
|
return obj && obj.__esModule ? obj : {
|
|
15
14
|
default: obj
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
if (obj && obj.__esModule) {
|
|
20
|
-
return obj;
|
|
21
|
-
} else {
|
|
22
|
-
var newObj = {};
|
|
23
|
-
if (obj != null) {
|
|
24
|
-
for(var key in obj){
|
|
25
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
26
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
27
|
-
if (desc.get || desc.set) {
|
|
28
|
-
Object.defineProperty(newObj, key, desc);
|
|
29
|
-
} else {
|
|
30
|
-
newObj[key] = obj[key];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
newObj.default = obj;
|
|
36
|
-
return newObj;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
17
|
+
const debug = require("debug")("expo:doctor:dependencies:getVersionedPackages");
|
|
39
18
|
/** Adds `react-dom`, `react`, and `react-native` to the list of known package versions (`relatedPackages`) */ function normalizeSdkVersionObject(version) {
|
|
40
19
|
if (!version) {
|
|
41
20
|
return {};
|
|
@@ -68,7 +47,7 @@ async function getRemoteVersionsForSdkAsync({ sdkVersion , skipCache } = {}) {
|
|
|
68
47
|
});
|
|
69
48
|
// We only want versioned dependencies so skip if they cannot be found.
|
|
70
49
|
if (!sdkVersion || !(sdkVersion in sdkVersions)) {
|
|
71
|
-
|
|
50
|
+
debug(`Skipping versioned dependencies because the SDK version is not found. (sdkVersion: ${sdkVersion}, available: ${Object.keys(sdkVersions).join(", ")})`);
|
|
72
51
|
return {};
|
|
73
52
|
}
|
|
74
53
|
const version = sdkVersions[sdkVersion];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/getVersionedPackages.ts"],"sourcesContent":["import npmPackageArg from 'npm-package-arg';\n\nimport { getReleasedVersionsAsync, SDKVersion } from '../../../api/getVersions';\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/getVersionedPackages.ts"],"sourcesContent":["import npmPackageArg from 'npm-package-arg';\n\nimport { getReleasedVersionsAsync, SDKVersion } from '../../../api/getVersions';\nimport { getVersionedNativeModulesAsync } from './bundledNativeModules';\n\nconst debug = require('debug')(\n 'expo:doctor:dependencies:getVersionedPackages'\n) as typeof console.log;\n\nexport type DependencyList = Record<string, string>;\n\n/** Adds `react-dom`, `react`, and `react-native` to the list of known package versions (`relatedPackages`) */\nfunction normalizeSdkVersionObject(version?: SDKVersion): Record<string, string> {\n if (!version) {\n return {};\n }\n const { relatedPackages, facebookReactVersion, facebookReactNativeVersion } = version;\n\n const reactVersion = facebookReactVersion\n ? {\n react: facebookReactVersion,\n 'react-dom': facebookReactVersion,\n }\n : undefined;\n\n return {\n ...relatedPackages,\n ...reactVersion,\n 'react-native': facebookReactNativeVersion,\n };\n}\n\n/** Get the known versions for a given SDK, combines all sources. */\nexport async function getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion,\n skipCache,\n}: {\n projectRoot: string;\n sdkVersion?: string;\n skipCache?: boolean;\n}) {\n const bundledNativeModules = sdkVersion\n ? await getVersionedNativeModulesAsync(projectRoot, sdkVersion)\n : {};\n const versionsForSdk = await getRemoteVersionsForSdkAsync({ sdkVersion, skipCache });\n return {\n ...versionsForSdk,\n ...bundledNativeModules,\n };\n}\n\n/** @returns a key/value list of known dependencies and their version (including range). */\nexport async function getRemoteVersionsForSdkAsync({\n sdkVersion,\n skipCache,\n}: { sdkVersion?: string; skipCache?: boolean } = {}): Promise<DependencyList> {\n const sdkVersions = await getReleasedVersionsAsync({ skipCache });\n\n // We only want versioned dependencies so skip if they cannot be found.\n if (!sdkVersion || !(sdkVersion in sdkVersions)) {\n debug(\n `Skipping versioned dependencies because the SDK version is not found. (sdkVersion: ${sdkVersion}, available: ${Object.keys(\n sdkVersions\n ).join(', ')})`\n );\n return {};\n }\n\n const version = sdkVersions[sdkVersion as keyof typeof sdkVersions] as unknown as SDKVersion;\n\n return normalizeSdkVersionObject(version);\n}\n\n/**\n * Versions a list of `packages` against a given `sdkVersion` based on local and remote versioning resources.\n *\n * @param projectRoot\n * @param param1\n * @returns\n */\nexport async function getVersionedPackagesAsync(\n projectRoot: string,\n {\n packages,\n sdkVersion,\n }: {\n /** List of npm packages to process. */\n packages: string[];\n /** Target SDK Version number to version the `packages` for. */\n sdkVersion: string;\n }\n): Promise<{ packages: string[]; messages: string[] }> {\n const versionsForSdk = await getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion,\n skipCache: true,\n });\n\n let nativeModulesCount = 0;\n let othersCount = 0;\n\n const versionedPackages = packages.map((arg) => {\n const { name, type, raw } = npmPackageArg(arg);\n\n if (['tag', 'version', 'range'].includes(type) && name && versionsForSdk[name]) {\n // Unimodule packages from npm registry are modified to use the bundled version.\n // Some packages have the recommended version listed in https://exp.host/--/api/v2/versions.\n nativeModulesCount++;\n return `${name}@${versionsForSdk[name]}`;\n } else {\n // Other packages are passed through unmodified.\n othersCount++;\n return raw;\n }\n });\n\n const messages = getOperationLog({\n othersCount,\n nativeModulesCount,\n sdkVersion,\n });\n\n return {\n packages: versionedPackages,\n messages,\n };\n}\n\n/** Craft a set of messages regarding the install operations. */\nexport function getOperationLog({\n nativeModulesCount,\n sdkVersion,\n othersCount,\n}: {\n nativeModulesCount: number;\n othersCount: number;\n sdkVersion: string;\n}): string[] {\n return [\n nativeModulesCount > 0 &&\n `${nativeModulesCount} SDK ${sdkVersion} compatible native ${\n nativeModulesCount === 1 ? 'module' : 'modules'\n }`,\n othersCount > 0 && `${othersCount} other ${othersCount === 1 ? 'package' : 'packages'}`,\n ].filter(Boolean) as string[];\n}\n"],"names":["getCombinedKnownVersionsAsync","getRemoteVersionsForSdkAsync","getVersionedPackagesAsync","getOperationLog","debug","require","normalizeSdkVersionObject","version","relatedPackages","facebookReactVersion","facebookReactNativeVersion","reactVersion","react","undefined","projectRoot","sdkVersion","skipCache","bundledNativeModules","getVersionedNativeModulesAsync","versionsForSdk","sdkVersions","getReleasedVersionsAsync","Object","keys","join","packages","nativeModulesCount","othersCount","versionedPackages","map","arg","name","type","raw","npmPackageArg","includes","messages","filter","Boolean"],"mappings":"AAAA;;;;QAiCsBA,6BAA6B,GAA7BA,6BAA6B;QAoB7BC,4BAA4B,GAA5BA,4BAA4B;QA4B5BC,yBAAyB,GAAzBA,yBAAy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C,CAAC,CAAC;SAC1C,MAAM;YACL,gDAAgD;YAChDJ,WAAW,EAAE,CAAC;YACd,OAAOM,GAAG,CAAC;SACZ;KACF,CAAC,AAAC;IAEH,MAAMG,QAAQ,GAAGjC,eAAe,CAAC;QAC/BwB,WAAW;QACXD,kBAAkB;QAClBX,UAAU;KACX,CAAC,AAAC;IAEH,OAAO;QACLU,QAAQ,EAAEG,iBAAiB;QAC3BQ,QAAQ;KACT,CAAC;CACH;AAGM,SAASjC,eAAe,CAAC,EAC9BuB,kBAAkB,CAAA,EAClBX,UAAU,CAAA,EACVY,WAAW,CAAA,EAKZ,EAAY;IACX,OAAO;QACLD,kBAAkB,GAAG,CAAC,IACpB,CAAC,EAAEA,kBAAkB,CAAC,KAAK,EAAEX,UAAU,CAAC,mBAAmB,EACzDW,kBAAkB,KAAK,CAAC,GAAG,QAAQ,GAAG,SAAS,CAChD,CAAC;QACJC,WAAW,GAAG,CAAC,IAAI,CAAC,EAAEA,WAAW,CAAC,OAAO,EAAEA,WAAW,KAAK,CAAC,GAAG,SAAS,GAAG,UAAU,CAAC,CAAC;KACxF,CAACU,MAAM,CAACC,OAAO,CAAC,CAAa;CAC/B"}
|
|
@@ -39,6 +39,7 @@ function _interopRequireWildcard(obj) {
|
|
|
39
39
|
return newObj;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
const debug = require("debug")("expo:doctor:dependencies:validate");
|
|
42
43
|
async function validateDependenciesVersionsAsync(projectRoot, exp, pkg, packagesToCheck) {
|
|
43
44
|
const incorrectDeps = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packagesToCheck);
|
|
44
45
|
return logIncorrectDependencies(incorrectDeps);
|
|
@@ -68,21 +69,22 @@ async function getVersionedDependenciesAsync(projectRoot, exp, pkg, packagesToCh
|
|
|
68
69
|
projectRoot,
|
|
69
70
|
sdkVersion: exp.sdkVersion
|
|
70
71
|
});
|
|
71
|
-
|
|
72
|
+
// debug(`Known dependencies: %O`, combinedKnownPackages);
|
|
72
73
|
const resolvedDependencies = (packagesToCheck == null ? void 0 : packagesToCheck.length) ? getFilteredObject(packagesToCheck, {
|
|
73
74
|
...pkg.dependencies,
|
|
74
75
|
...pkg.devDependencies
|
|
75
76
|
}) : pkg.dependencies;
|
|
76
|
-
|
|
77
|
+
debug(`Checking dependencies for ${exp.sdkVersion}: %O`, resolvedDependencies);
|
|
77
78
|
// intersection of packages from package.json and bundled native modules
|
|
78
|
-
const resolvedPackagesToCheck = getPackagesToCheck(resolvedDependencies, combinedKnownPackages);
|
|
79
|
-
|
|
79
|
+
const { known: resolvedPackagesToCheck , unknown } = getPackagesToCheck(resolvedDependencies, combinedKnownPackages);
|
|
80
|
+
debug(`Comparing known versions: %O`, resolvedPackagesToCheck);
|
|
81
|
+
debug(`Skipping packages that cannot be versioned automatically: %O`, unknown);
|
|
80
82
|
// read package versions from the file system (node_modules)
|
|
81
83
|
const packageVersions = await resolvePackageVersionsAsync(projectRoot, resolvedPackagesToCheck);
|
|
82
|
-
|
|
84
|
+
debug(`Package versions: %O`, packageVersions);
|
|
83
85
|
// find incorrect dependencies by comparing the actual package versions with the bundled native module version ranges
|
|
84
86
|
const incorrectDeps = findIncorrectDependencies(packageVersions, combinedKnownPackages);
|
|
85
|
-
|
|
87
|
+
debug(`Incorrect dependencies: %O`, incorrectDeps);
|
|
86
88
|
return incorrectDeps;
|
|
87
89
|
}
|
|
88
90
|
function getFilteredObject(keys, object) {
|
|
@@ -93,13 +95,19 @@ function getFilteredObject(keys, object) {
|
|
|
93
95
|
}
|
|
94
96
|
function getPackagesToCheck(dependencies, bundledNativeModules) {
|
|
95
97
|
const dependencyNames = Object.keys(dependencies != null ? dependencies : {});
|
|
96
|
-
const
|
|
98
|
+
const known = [];
|
|
99
|
+
const unknown = [];
|
|
97
100
|
for (const dependencyName of dependencyNames){
|
|
98
101
|
if (dependencyName in bundledNativeModules) {
|
|
99
|
-
|
|
102
|
+
known.push(dependencyName);
|
|
103
|
+
} else {
|
|
104
|
+
unknown.push(dependencyName);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
return
|
|
107
|
+
return {
|
|
108
|
+
known,
|
|
109
|
+
unknown
|
|
110
|
+
};
|
|
103
111
|
}
|
|
104
112
|
async function resolvePackageVersionsAsync(projectRoot, packages) {
|
|
105
113
|
const packageVersionsFromPackageJSON = await Promise.all(packages.map((packageName)=>getPackageVersionAsync(projectRoot, packageName)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/validateDependenciesVersions.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport JsonFile from '@expo/json-file';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { BundledNativeModules } from './bundledNativeModules';\nimport { getCombinedKnownVersionsAsync } from './getVersionedPackages';\n\ninterface IncorrectDependency {\n packageName: string;\n expectedVersionOrRange: string;\n actualVersion: string;\n}\n\n/**\n * Print a list of incorrect dependency versions.\n *\n * @param projectRoot Expo project root.\n * @param exp Expo project config.\n * @param pkg Project's `package.json`.\n * @param packagesToCheck A list of packages to check, if undefined or empty, all will be checked.\n * @returns `true` if there are no incorrect dependencies.\n */\nexport async function validateDependenciesVersionsAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'sdkVersion'>,\n pkg: PackageJSONConfig,\n packagesToCheck?: string[]\n): Promise<boolean> {\n const incorrectDeps = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packagesToCheck);\n return logIncorrectDependencies(incorrectDeps);\n}\n\nfunction logInvalidDependency({\n packageName,\n expectedVersionOrRange,\n actualVersion,\n}: IncorrectDependency) {\n Log.warn(\n // chalk` - {underline ${packageName}} - expected version: {underline ${expectedVersionOrRange}} - actual version installed: {underline ${actualVersion}}`\n chalk` {bold ${packageName}}{cyan @}{red ${actualVersion}} - expected version: {green ${expectedVersionOrRange}}`\n );\n}\n\nexport function logIncorrectDependencies(incorrectDeps: IncorrectDependency[]) {\n if (!incorrectDeps.length) {\n return true;\n }\n\n Log.warn(chalk`Some dependencies are incompatible with the installed {bold expo} version:`);\n incorrectDeps.forEach((dep) => logInvalidDependency(dep));\n\n const requiredVersions = incorrectDeps.map(\n ({ packageName, expectedVersionOrRange }) => `${packageName}@${expectedVersionOrRange}`\n );\n\n Log.warn(\n 'Your project may not work correctly until you install the correct versions of the packages.\\n' +\n chalk`Install individual packages by running {inverse npx expo install ${requiredVersions.join(\n ' '\n )}}`\n );\n return false;\n}\n\n/**\n * Return a list of versioned dependencies for the project SDK version.\n *\n * @param projectRoot Expo project root.\n * @param exp Expo project config.\n * @param pkg Project's `package.json`.\n * @param packagesToCheck A list of packages to check, if undefined or empty, all will be checked.\n * @returns A list of incorrect dependencies.\n */\nexport async function getVersionedDependenciesAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'sdkVersion'>,\n pkg: PackageJSONConfig,\n packagesToCheck?: string[]\n): Promise<IncorrectDependency[]> {\n // This should never happen under normal circumstances since\n // the CLI is versioned in the `expo` package.\n assert(exp.sdkVersion, 'SDK Version is missing');\n\n // Get from both endpoints and combine the known package versions.\n const combinedKnownPackages = await getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion: exp.sdkVersion,\n });\n Log.debug(`Known dependencies: %O`, combinedKnownPackages);\n\n const resolvedDependencies = packagesToCheck?.length\n ? // Diff the provided packages to ensure we only check against installed packages.\n getFilteredObject(packagesToCheck, { ...pkg.dependencies, ...pkg.devDependencies })\n : // If no packages are provided, check against the `package.json` `dependencies` object.\n pkg.dependencies;\n Log.debug(`Checking dependencies for ${exp.sdkVersion}: %O`, resolvedDependencies);\n\n // intersection of packages from package.json and bundled native modules\n const resolvedPackagesToCheck = getPackagesToCheck(resolvedDependencies, combinedKnownPackages);\n Log.debug(`Comparing known versions: %O`, resolvedPackagesToCheck);\n // read package versions from the file system (node_modules)\n const packageVersions = await resolvePackageVersionsAsync(projectRoot, resolvedPackagesToCheck);\n Log.debug(`Package versions: %O`, packageVersions);\n // find incorrect dependencies by comparing the actual package versions with the bundled native module version ranges\n const incorrectDeps = findIncorrectDependencies(packageVersions, combinedKnownPackages);\n Log.debug(`Incorrect dependencies: %O`, incorrectDeps);\n\n return incorrectDeps;\n}\n\nfunction getFilteredObject(keys: string[], object: Record<string, string>) {\n return keys.reduce<Record<string, string>>((acc, key) => {\n acc[key] = object[key];\n return acc;\n }, {});\n}\n\nfunction getPackagesToCheck(\n dependencies: Record<string, string> | null | undefined,\n bundledNativeModules: BundledNativeModules\n): string[] {\n const dependencyNames = Object.keys(dependencies ?? {});\n const result: string[] = [];\n for (const dependencyName of dependencyNames) {\n if (dependencyName in bundledNativeModules) {\n result.push(dependencyName);\n }\n }\n return result;\n}\n\nasync function resolvePackageVersionsAsync(\n projectRoot: string,\n packages: string[]\n): Promise<Record<string, string>> {\n const packageVersionsFromPackageJSON = await Promise.all(\n packages.map((packageName) => getPackageVersionAsync(projectRoot, packageName))\n );\n return packages.reduce((acc, packageName, idx) => {\n acc[packageName] = packageVersionsFromPackageJSON[idx];\n return acc;\n }, {} as Record<string, string>);\n}\n\nasync function getPackageVersionAsync(projectRoot: string, packageName: string): Promise<string> {\n let packageJsonPath: string | undefined;\n try {\n packageJsonPath = resolveFrom(projectRoot, `${packageName}/package.json`);\n } catch (error: any) {\n // This is a workaround for packages using `exports`. If this doesn't\n // include `package.json`, we have to use the error message to get the location.\n if (error.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {\n packageJsonPath = error.message.match(/(\"exports\"|defined) in (.*)$/i)?.[2];\n }\n }\n if (!packageJsonPath) {\n throw new CommandError(\n `\"${packageName}\" is added as a dependency in your project's package.json but it doesn't seem to be installed. Please run \"yarn\" or \"npm install\" to fix this issue.`\n );\n }\n const packageJson = await JsonFile.readAsync<BundledNativeModules>(packageJsonPath);\n return packageJson.version;\n}\n\nfunction findIncorrectDependencies(\n packageVersions: Record<string, string>,\n bundledNativeModules: BundledNativeModules\n): IncorrectDependency[] {\n const packages = Object.keys(packageVersions);\n const incorrectDeps: IncorrectDependency[] = [];\n for (const packageName of packages) {\n const expectedVersionOrRange = bundledNativeModules[packageName];\n const actualVersion = packageVersions[packageName];\n if (\n typeof expectedVersionOrRange === 'string' &&\n !semver.intersects(expectedVersionOrRange, actualVersion)\n ) {\n incorrectDeps.push({\n packageName,\n expectedVersionOrRange,\n actualVersion,\n });\n }\n }\n return incorrectDeps;\n}\n"],"names":["validateDependenciesVersionsAsync","logIncorrectDependencies","getVersionedDependenciesAsync","Log","projectRoot","exp","pkg","packagesToCheck","incorrectDeps","logInvalidDependency","packageName","expectedVersionOrRange","actualVersion","warn","chalk","length","forEach","dep","requiredVersions","map","join","assert","sdkVersion","combinedKnownPackages","getCombinedKnownVersionsAsync","debug","resolvedDependencies","getFilteredObject","dependencies","devDependencies","resolvedPackagesToCheck","getPackagesToCheck","packageVersions","resolvePackageVersionsAsync","findIncorrectDependencies","keys","object","reduce","acc","key","bundledNativeModules","dependencyNames","Object","result","dependencyName","push","packages","packageVersionsFromPackageJSON","Promise","all","getPackageVersionAsync","idx","packageJsonPath","resolveFrom","error","code","message","match","CommandError","packageJson","JsonFile","readAsync","version","semver","intersects"],"mappings":"AAAA;;;;QA2BsBA,iCAAiC,GAAjCA,iCAAiC;QAqBvCC,wBAAwB,GAAxBA,wBAAwB;QA8BlBC,6BAA6B,GAA7BA,6BAA6B;AA7E9B,IAAA,SAAiB,kCAAjB,iBAAiB,EAAA;AACnB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AACnB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAEN,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;;;;;;;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AJ,aAAa,CAACqC,IAAI,CAAC;gBACjBnC,WAAW;gBACXC,sBAAsB;gBACtBC,aAAa;aACd,CAAC,CAAC;SACJ;KACF;IACD,OAAOJ,aAAa,CAAC;CACtB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/validateDependenciesVersions.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport JsonFile from '@expo/json-file';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { BundledNativeModules } from './bundledNativeModules';\nimport { getCombinedKnownVersionsAsync } from './getVersionedPackages';\n\nconst debug = require('debug')('expo:doctor:dependencies:validate') as typeof console.log;\n\ninterface IncorrectDependency {\n packageName: string;\n expectedVersionOrRange: string;\n actualVersion: string;\n}\n\n/**\n * Print a list of incorrect dependency versions.\n *\n * @param projectRoot Expo project root.\n * @param exp Expo project config.\n * @param pkg Project's `package.json`.\n * @param packagesToCheck A list of packages to check, if undefined or empty, all will be checked.\n * @returns `true` if there are no incorrect dependencies.\n */\nexport async function validateDependenciesVersionsAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'sdkVersion'>,\n pkg: PackageJSONConfig,\n packagesToCheck?: string[]\n): Promise<boolean> {\n const incorrectDeps = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packagesToCheck);\n return logIncorrectDependencies(incorrectDeps);\n}\n\nfunction logInvalidDependency({\n packageName,\n expectedVersionOrRange,\n actualVersion,\n}: IncorrectDependency) {\n Log.warn(\n // chalk` - {underline ${packageName}} - expected version: {underline ${expectedVersionOrRange}} - actual version installed: {underline ${actualVersion}}`\n chalk` {bold ${packageName}}{cyan @}{red ${actualVersion}} - expected version: {green ${expectedVersionOrRange}}`\n );\n}\n\nexport function logIncorrectDependencies(incorrectDeps: IncorrectDependency[]) {\n if (!incorrectDeps.length) {\n return true;\n }\n\n Log.warn(chalk`Some dependencies are incompatible with the installed {bold expo} version:`);\n incorrectDeps.forEach((dep) => logInvalidDependency(dep));\n\n const requiredVersions = incorrectDeps.map(\n ({ packageName, expectedVersionOrRange }) => `${packageName}@${expectedVersionOrRange}`\n );\n\n Log.warn(\n 'Your project may not work correctly until you install the correct versions of the packages.\\n' +\n chalk`Install individual packages by running {inverse npx expo install ${requiredVersions.join(\n ' '\n )}}`\n );\n return false;\n}\n\n/**\n * Return a list of versioned dependencies for the project SDK version.\n *\n * @param projectRoot Expo project root.\n * @param exp Expo project config.\n * @param pkg Project's `package.json`.\n * @param packagesToCheck A list of packages to check, if undefined or empty, all will be checked.\n * @returns A list of incorrect dependencies.\n */\nexport async function getVersionedDependenciesAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'sdkVersion'>,\n pkg: PackageJSONConfig,\n packagesToCheck?: string[]\n): Promise<IncorrectDependency[]> {\n // This should never happen under normal circumstances since\n // the CLI is versioned in the `expo` package.\n assert(exp.sdkVersion, 'SDK Version is missing');\n\n // Get from both endpoints and combine the known package versions.\n const combinedKnownPackages = await getCombinedKnownVersionsAsync({\n projectRoot,\n sdkVersion: exp.sdkVersion,\n });\n // debug(`Known dependencies: %O`, combinedKnownPackages);\n\n const resolvedDependencies = packagesToCheck?.length\n ? // Diff the provided packages to ensure we only check against installed packages.\n getFilteredObject(packagesToCheck, { ...pkg.dependencies, ...pkg.devDependencies })\n : // If no packages are provided, check against the `package.json` `dependencies` object.\n pkg.dependencies;\n debug(`Checking dependencies for ${exp.sdkVersion}: %O`, resolvedDependencies);\n\n // intersection of packages from package.json and bundled native modules\n const { known: resolvedPackagesToCheck, unknown } = getPackagesToCheck(\n resolvedDependencies,\n combinedKnownPackages\n );\n debug(`Comparing known versions: %O`, resolvedPackagesToCheck);\n debug(`Skipping packages that cannot be versioned automatically: %O`, unknown);\n // read package versions from the file system (node_modules)\n const packageVersions = await resolvePackageVersionsAsync(projectRoot, resolvedPackagesToCheck);\n debug(`Package versions: %O`, packageVersions);\n // find incorrect dependencies by comparing the actual package versions with the bundled native module version ranges\n const incorrectDeps = findIncorrectDependencies(packageVersions, combinedKnownPackages);\n debug(`Incorrect dependencies: %O`, incorrectDeps);\n\n return incorrectDeps;\n}\n\nfunction getFilteredObject(keys: string[], object: Record<string, string>) {\n return keys.reduce<Record<string, string>>((acc, key) => {\n acc[key] = object[key];\n return acc;\n }, {});\n}\n\nfunction getPackagesToCheck(\n dependencies: Record<string, string> | null | undefined,\n bundledNativeModules: BundledNativeModules\n): { known: string[]; unknown: string[] } {\n const dependencyNames = Object.keys(dependencies ?? {});\n const known: string[] = [];\n const unknown: string[] = [];\n for (const dependencyName of dependencyNames) {\n if (dependencyName in bundledNativeModules) {\n known.push(dependencyName);\n } else {\n unknown.push(dependencyName);\n }\n }\n return { known, unknown };\n}\n\nasync function resolvePackageVersionsAsync(\n projectRoot: string,\n packages: string[]\n): Promise<Record<string, string>> {\n const packageVersionsFromPackageJSON = await Promise.all(\n packages.map((packageName) => getPackageVersionAsync(projectRoot, packageName))\n );\n return packages.reduce((acc, packageName, idx) => {\n acc[packageName] = packageVersionsFromPackageJSON[idx];\n return acc;\n }, {} as Record<string, string>);\n}\n\nasync function getPackageVersionAsync(projectRoot: string, packageName: string): Promise<string> {\n let packageJsonPath: string | undefined;\n try {\n packageJsonPath = resolveFrom(projectRoot, `${packageName}/package.json`);\n } catch (error: any) {\n // This is a workaround for packages using `exports`. If this doesn't\n // include `package.json`, we have to use the error message to get the location.\n if (error.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {\n packageJsonPath = error.message.match(/(\"exports\"|defined) in (.*)$/i)?.[2];\n }\n }\n if (!packageJsonPath) {\n throw new CommandError(\n `\"${packageName}\" is added as a dependency in your project's package.json but it doesn't seem to be installed. Please run \"yarn\" or \"npm install\" to fix this issue.`\n );\n }\n const packageJson = await JsonFile.readAsync<BundledNativeModules>(packageJsonPath);\n return packageJson.version;\n}\n\nfunction findIncorrectDependencies(\n packageVersions: Record<string, string>,\n bundledNativeModules: BundledNativeModules\n): IncorrectDependency[] {\n const packages = Object.keys(packageVersions);\n const incorrectDeps: IncorrectDependency[] = [];\n for (const packageName of packages) {\n const expectedVersionOrRange = bundledNativeModules[packageName];\n const actualVersion = packageVersions[packageName];\n if (\n typeof expectedVersionOrRange === 'string' &&\n !semver.intersects(expectedVersionOrRange, actualVersion)\n ) {\n incorrectDeps.push({\n packageName,\n expectedVersionOrRange,\n actualVersion,\n });\n }\n }\n return incorrectDeps;\n}\n"],"names":["validateDependenciesVersionsAsync","logIncorrectDependencies","getVersionedDependenciesAsync","Log","debug","require","projectRoot","exp","pkg","packagesToCheck","incorrectDeps","logInvalidDependency","packageName","expectedVersionOrRange","actualVersion","warn","chalk","length","forEach","dep","requiredVersions","map","join","assert","sdkVersion","combinedKnownPackages","getCombinedKnownVersionsAsync","resolvedDependencies","getFilteredObject","dependencies","devDependencies","known","resolvedPackagesToCheck","unknown","getPackagesToCheck","packageVersions","resolvePackageVersionsAsync","findIncorrectDependencies","keys","object","reduce","acc","key","bundledNativeModules","dependencyNames","Object","dependencyName","push","packages","packageVersionsFromPackageJSON","Promise","all","getPackageVersionAsync","idx","packageJsonPath","resolveFrom","error","code","message","match","CommandError","packageJson","JsonFile","readAsync","version","semver","intersects"],"mappings":"AAAA;;;;QA6BsBA,iCAAiC,GAAjCA,iCAAiC;QAqBvCC,wBAAwB,GAAxBA,wBAAwB;QA8BlBC,6BAA6B,GAA7BA,6BAA6B;AA/E9B,IAAA,SAAiB,kCAAjB,iBAAiB,EAAA;AACnB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AACnB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAEN,IAAA,qBAAwB,WAAxB,wBAAwB,CAA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B,GAAG8B,oBAAoB,CAAC/B,WAAW,CAAC,AAAC;QACjE,MAAME,aAAa,GAAGqB,eAAe,CAACvB,WAAW,CAAC,AAAC;QACnD,IACE,OAAOC,sBAAsB,KAAK,QAAQ,IAC1C,CAACoD,OAAM,QAAA,CAACC,UAAU,CAACrD,sBAAsB,EAAEC,aAAa,CAAC,EACzD;YACAJ,aAAa,CAACqC,IAAI,CAAC;gBACjBnC,WAAW;gBACXC,sBAAsB;gBACtBC,aAAa;aACd,CAAC,CAAC;SACJ;KACF;IACD,OAAOJ,aAAa,CAAC;CACtB"}
|
|
@@ -38,6 +38,7 @@ function _interopRequireWildcard(obj) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
var _ref;
|
|
41
|
+
const debug = require("debug")("expo:doctor:externalModule");
|
|
41
42
|
class ExternalModuleVersionError extends _errors.CommandError {
|
|
42
43
|
constructor(message, shouldGloballyInstall){
|
|
43
44
|
super("EXTERNAL_MODULE_VERSION", message);
|
|
@@ -153,7 +154,7 @@ class ExternalModule {
|
|
|
153
154
|
if (error instanceof _errors.CommandError) {
|
|
154
155
|
throw error;
|
|
155
156
|
} else if (error.code !== "MODULE_NOT_FOUND") {
|
|
156
|
-
|
|
157
|
+
debug("Failed to resolve module", error.message);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/ngrok/ExternalModule.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\nimport requireGlobal from 'requireg';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { delayAsync } from '../../../utils/delay';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { confirmAsync } from '../../../utils/prompts';\n\n/** An error that is thrown when a package is installed but doesn't meet the version criteria. */\nexport class ExternalModuleVersionError extends CommandError {\n constructor(message: string, public readonly shouldGloballyInstall: boolean) {\n super('EXTERNAL_MODULE_VERSION', message);\n }\n}\n\ninterface PromptOptions {\n /** Should prompt the user to install, when false the module will just assert on missing packages, default `true`. Ignored when `autoInstall` is true. */\n shouldPrompt?: boolean;\n /** Should automatically install the package without prompting, default `false` */\n autoInstall?: boolean;\n}\n\nexport interface InstallPromptOptions extends PromptOptions {\n /** Should install the package globally, default `false` */\n shouldGloballyInstall?: boolean;\n}\n\nexport interface ResolvePromptOptions extends PromptOptions {\n /**\n * Prefer to install the package globally, this can be overridden if the function\n * detects that a locally installed package simply needs an upgrade, default `false`\n */\n prefersGlobalInstall?: boolean;\n}\n\n/** Resolves a local or globally installed package, prompts to install if missing. */\nexport class ExternalModule<TModule> {\n private instance: TModule | null = null;\n\n constructor(\n /** Project root for checking if the package is installed locally. */\n private projectRoot: string,\n /** Info on the external package. */\n private pkg: {\n /** NPM package name. */\n name: string;\n /** Required semver range, ex: `^1.0.0`. */\n versionRange: string;\n },\n /** A function used to create the installation prompt message. */\n private promptMessage: (pkgName: string) => string\n ) {}\n\n /** Resolve the globally or locally installed instance, or prompt to install. */\n async resolveAsync({\n prefersGlobalInstall,\n ...options\n }: ResolvePromptOptions = {}): Promise<TModule> {\n try {\n return (\n this.getVersioned() ??\n this.installAsync({\n ...options,\n shouldGloballyInstall: prefersGlobalInstall,\n })\n );\n } catch (error: any) {\n if (error instanceof ExternalModuleVersionError) {\n // If the module version in not compliant with the version range,\n // we should prompt the user to install the package where it already exists.\n return this.installAsync({\n ...options,\n shouldGloballyInstall: error.shouldGloballyInstall ?? prefersGlobalInstall,\n });\n }\n throw error;\n }\n }\n\n /** Prompt the user to install the package and try again. */\n async installAsync({\n shouldPrompt = true,\n autoInstall,\n shouldGloballyInstall,\n }: InstallPromptOptions = {}): Promise<TModule> {\n const packageName = [this.pkg.name, this.pkg.versionRange].join('@');\n if (!autoInstall) {\n // Delay the prompt so it doesn't conflict with other dev tool logs\n await delayAsync(100);\n }\n const answer =\n autoInstall ||\n (shouldPrompt &&\n (await confirmAsync({\n message: this.promptMessage(packageName),\n initial: true,\n })));\n if (answer) {\n Log.log(`Installing ${packageName}...`);\n\n // Always use npm for global installs\n const packageManager = shouldGloballyInstall\n ? new PackageManager.NpmPackageManager({\n cwd: this.projectRoot,\n log: Log.log,\n silent: !env.EXPO_DEBUG,\n })\n : PackageManager.createForProject(this.projectRoot, {\n silent: !env.EXPO_DEBUG,\n });\n\n try {\n if (shouldGloballyInstall) {\n await packageManager.addGlobalAsync(packageName);\n } else {\n await packageManager.addDevAsync(packageName);\n }\n Log.log(`Installed ${packageName}`);\n } catch (error: any) {\n error.message = `Failed to install ${packageName} ${\n shouldGloballyInstall ? 'globally' : 'locally'\n }: ${error.message}`;\n throw error;\n }\n return await this.resolveAsync({ shouldPrompt: false });\n }\n\n throw new CommandError(\n 'EXTERNAL_MODULE_AVAILABILITY',\n `Please install ${packageName} and try again`\n );\n }\n\n /** Get the module. */\n get(): TModule | null {\n try {\n return this.getVersioned();\n } catch {\n return null;\n }\n }\n\n /** Get the module, throws if the module is not versioned correctly. */\n getVersioned(): TModule | null {\n this.instance ??= this._resolveModule(true) ?? this._resolveModule(false);\n return this.instance;\n }\n\n /** Exposed for testing. */\n _require(moduleId: string): any {\n return require(moduleId);\n }\n\n /** Resolve a copy that's installed in the project. Exposed for testing. */\n _resolveLocal(moduleId: string): string {\n return resolveFrom(this.projectRoot, moduleId);\n }\n\n /** Resolve a copy that's installed globally. Exposed for testing. */\n _resolveGlobal(moduleId: string): string {\n return requireGlobal.resolve(moduleId);\n }\n\n /** Resolve the module and verify the version. Exposed for testing. */\n _resolveModule(isLocal: boolean): TModule | null {\n const resolver = isLocal ? this._resolveLocal.bind(this) : this._resolveGlobal.bind(this);\n try {\n const packageJsonPath = resolver(`${this.pkg.name}/package.json`);\n const packageJson = this._require(packageJsonPath);\n if (packageJson) {\n if (semver.satisfies(packageJson.version, this.pkg.versionRange)) {\n const modulePath = resolver(this.pkg.name);\n const requiredModule = this._require(modulePath);\n if (requiredModule == null) {\n throw new CommandError(\n 'EXTERNAL_MODULE_EXPORT',\n `${this.pkg.name} exports a nullish value, which is not allowed.`\n );\n }\n return requiredModule;\n }\n throw new ExternalModuleVersionError(\n `Required module '${this.pkg.name}@${packageJson.version}' does not satisfy ${this.pkg.versionRange}. Installed at: ${packageJsonPath}`,\n !isLocal\n );\n }\n } catch (error: any) {\n if (error instanceof CommandError) {\n throw error;\n } else if (error.code !== 'MODULE_NOT_FOUND') {\n Log.debug('[External Module] Failed to resolve module', error.message);\n }\n }\n return null;\n }\n}\n"],"names":["PackageManager","Log","ExternalModuleVersionError","CommandError","constructor","message","shouldGloballyInstall","ExternalModule","projectRoot","pkg","promptMessage","instance","resolveAsync","prefersGlobalInstall","options","getVersioned","installAsync","error","shouldPrompt","autoInstall","packageName","name","versionRange","join","delayAsync","answer","confirmAsync","initial","log","packageManager","NpmPackageManager","cwd","silent","env","EXPO_DEBUG","createForProject","addGlobalAsync","addDevAsync","get","_resolveModule","_require","moduleId","require","_resolveLocal","resolveFrom","_resolveGlobal","requireGlobal","resolve","isLocal","resolver","bind","packageJsonPath","packageJson","semver","satisfies","version","modulePath","requiredModule","code","debug"],"mappings":"AAAA;;;;AAAYA,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AACA,IAAA,SAAU,kCAAV,UAAU,EAAA;AACZ,IAAA,YAAc,kCAAd,cAAc,EAAA;AACnB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACY,IAAA,MAAsB,WAAtB,sBAAsB,CAAA;AAC7B,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACvB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0IjD,IAAI;AAvID,MAAMC,0BAA0B,SAASC,OAAY,aAAA;IAC1DC,YAAYC,OAAe,EAAkBC,qBAA8B,CAAE;QAC3E,KAAK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,EAAE1C,KAAK,CAACZ,OAAO,CAAC,CAAC;aACxE;SACF;QACD,OAAO,IAAI,CAAC;KACb;CACF;QA/JYE,cAAc,GAAdA,cAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/ngrok/ExternalModule.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\nimport requireGlobal from 'requireg';\nimport resolveFrom from 'resolve-from';\nimport semver from 'semver';\n\nimport * as Log from '../../../log';\nimport { delayAsync } from '../../../utils/delay';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { confirmAsync } from '../../../utils/prompts';\n\nconst debug = require('debug')('expo:doctor:externalModule') as typeof console.log;\n\n/** An error that is thrown when a package is installed but doesn't meet the version criteria. */\nexport class ExternalModuleVersionError extends CommandError {\n constructor(message: string, public readonly shouldGloballyInstall: boolean) {\n super('EXTERNAL_MODULE_VERSION', message);\n }\n}\n\ninterface PromptOptions {\n /** Should prompt the user to install, when false the module will just assert on missing packages, default `true`. Ignored when `autoInstall` is true. */\n shouldPrompt?: boolean;\n /** Should automatically install the package without prompting, default `false` */\n autoInstall?: boolean;\n}\n\nexport interface InstallPromptOptions extends PromptOptions {\n /** Should install the package globally, default `false` */\n shouldGloballyInstall?: boolean;\n}\n\nexport interface ResolvePromptOptions extends PromptOptions {\n /**\n * Prefer to install the package globally, this can be overridden if the function\n * detects that a locally installed package simply needs an upgrade, default `false`\n */\n prefersGlobalInstall?: boolean;\n}\n\n/** Resolves a local or globally installed package, prompts to install if missing. */\nexport class ExternalModule<TModule> {\n private instance: TModule | null = null;\n\n constructor(\n /** Project root for checking if the package is installed locally. */\n private projectRoot: string,\n /** Info on the external package. */\n private pkg: {\n /** NPM package name. */\n name: string;\n /** Required semver range, ex: `^1.0.0`. */\n versionRange: string;\n },\n /** A function used to create the installation prompt message. */\n private promptMessage: (pkgName: string) => string\n ) {}\n\n /** Resolve the globally or locally installed instance, or prompt to install. */\n async resolveAsync({\n prefersGlobalInstall,\n ...options\n }: ResolvePromptOptions = {}): Promise<TModule> {\n try {\n return (\n this.getVersioned() ??\n this.installAsync({\n ...options,\n shouldGloballyInstall: prefersGlobalInstall,\n })\n );\n } catch (error: any) {\n if (error instanceof ExternalModuleVersionError) {\n // If the module version in not compliant with the version range,\n // we should prompt the user to install the package where it already exists.\n return this.installAsync({\n ...options,\n shouldGloballyInstall: error.shouldGloballyInstall ?? prefersGlobalInstall,\n });\n }\n throw error;\n }\n }\n\n /** Prompt the user to install the package and try again. */\n async installAsync({\n shouldPrompt = true,\n autoInstall,\n shouldGloballyInstall,\n }: InstallPromptOptions = {}): Promise<TModule> {\n const packageName = [this.pkg.name, this.pkg.versionRange].join('@');\n if (!autoInstall) {\n // Delay the prompt so it doesn't conflict with other dev tool logs\n await delayAsync(100);\n }\n const answer =\n autoInstall ||\n (shouldPrompt &&\n (await confirmAsync({\n message: this.promptMessage(packageName),\n initial: true,\n })));\n if (answer) {\n Log.log(`Installing ${packageName}...`);\n\n // Always use npm for global installs\n const packageManager = shouldGloballyInstall\n ? new PackageManager.NpmPackageManager({\n cwd: this.projectRoot,\n log: Log.log,\n silent: !env.EXPO_DEBUG,\n })\n : PackageManager.createForProject(this.projectRoot, {\n silent: !env.EXPO_DEBUG,\n });\n\n try {\n if (shouldGloballyInstall) {\n await packageManager.addGlobalAsync(packageName);\n } else {\n await packageManager.addDevAsync(packageName);\n }\n Log.log(`Installed ${packageName}`);\n } catch (error: any) {\n error.message = `Failed to install ${packageName} ${\n shouldGloballyInstall ? 'globally' : 'locally'\n }: ${error.message}`;\n throw error;\n }\n return await this.resolveAsync({ shouldPrompt: false });\n }\n\n throw new CommandError(\n 'EXTERNAL_MODULE_AVAILABILITY',\n `Please install ${packageName} and try again`\n );\n }\n\n /** Get the module. */\n get(): TModule | null {\n try {\n return this.getVersioned();\n } catch {\n return null;\n }\n }\n\n /** Get the module, throws if the module is not versioned correctly. */\n getVersioned(): TModule | null {\n this.instance ??= this._resolveModule(true) ?? this._resolveModule(false);\n return this.instance;\n }\n\n /** Exposed for testing. */\n _require(moduleId: string): any {\n return require(moduleId);\n }\n\n /** Resolve a copy that's installed in the project. Exposed for testing. */\n _resolveLocal(moduleId: string): string {\n return resolveFrom(this.projectRoot, moduleId);\n }\n\n /** Resolve a copy that's installed globally. Exposed for testing. */\n _resolveGlobal(moduleId: string): string {\n return requireGlobal.resolve(moduleId);\n }\n\n /** Resolve the module and verify the version. Exposed for testing. */\n _resolveModule(isLocal: boolean): TModule | null {\n const resolver = isLocal ? this._resolveLocal.bind(this) : this._resolveGlobal.bind(this);\n try {\n const packageJsonPath = resolver(`${this.pkg.name}/package.json`);\n const packageJson = this._require(packageJsonPath);\n if (packageJson) {\n if (semver.satisfies(packageJson.version, this.pkg.versionRange)) {\n const modulePath = resolver(this.pkg.name);\n const requiredModule = this._require(modulePath);\n if (requiredModule == null) {\n throw new CommandError(\n 'EXTERNAL_MODULE_EXPORT',\n `${this.pkg.name} exports a nullish value, which is not allowed.`\n );\n }\n return requiredModule;\n }\n throw new ExternalModuleVersionError(\n `Required module '${this.pkg.name}@${packageJson.version}' does not satisfy ${this.pkg.versionRange}. Installed at: ${packageJsonPath}`,\n !isLocal\n );\n }\n } catch (error: any) {\n if (error instanceof CommandError) {\n throw error;\n } else if (error.code !== 'MODULE_NOT_FOUND') {\n debug('Failed to resolve module', error.message);\n }\n }\n return null;\n }\n}\n"],"names":["PackageManager","Log","debug","require","ExternalModuleVersionError","CommandError","constructor","message","shouldGloballyInstall","ExternalModule","projectRoot","pkg","promptMessage","instance","resolveAsync","prefersGlobalInstall","options","getVersioned","installAsync","error","shouldPrompt","autoInstall","packageName","name","versionRange","join","delayAsync","answer","confirmAsync","initial","log","packageManager","NpmPackageManager","cwd","silent","env","EXPO_DEBUG","createForProject","addGlobalAsync","addDevAsync","get","_resolveModule","_require","moduleId","_resolveLocal","resolveFrom","_resolveGlobal","requireGlobal","resolve","isLocal","resolver","bind","packageJsonPath","packageJson","semver","satisfies","version","modulePath","required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AAIrD,OAAY,aAAA,CACpB,wBAAwB,EACxB,CAAC,EAAE,IAAI,CAACM,GAAG,CAACY,IAAI,CAAC,+CAA+C,CAAC,CAClE,CAAC;qBACH;oBACD,OAAOmC,cAAc,CAAC;iBACvB;gBACD,MAAM,IAAItD,0BAA0B,CAClC,CAAC,iBAAiB,EAAE,IAAI,CAACO,GAAG,CAACY,IAAI,CAAC,CAAC,EAAE8B,WAAW,CAACG,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC7C,GAAG,CAACa,YAAY,CAAC,gBAAgB,EAAE4B,eAAe,CAAC,CAAC,EACvI,CAACH,OAAO,CACT,CAAC;aACH;SACF,CAAC,OAAO9B,KAAK,EAAO;YACnB,IAAIA,KAAK,YAAYd,OAAY,aAAA,EAAE;gBACjC,MAAMc,KAAK,CAAC;aACb,MAAM,IAAIA,KAAK,CAACwC,IAAI,KAAK,kBAAkB,EAAE;gBAC5CzD,KAAK,CAAC,0BAA0B,EAAEiB,KAAK,CAACZ,OAAO,CAAC,CAAC;aAClD;SACF;QACD,OAAO,IAAI,CAAC;KACb;CACF;QA/JYE,cAAc,GAAdA,cAAc"}
|
|
@@ -37,13 +37,14 @@ function _interopRequireWildcard(obj) {
|
|
|
37
37
|
return newObj;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
const debug = require("debug")("expo:doctor:typescriptSupport");
|
|
40
41
|
class TypeScriptProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
|
|
41
42
|
/** Ensure a project that hasn't explicitly disabled web support has all the required packages for running in the browser. */ async assertImplementation() {
|
|
42
43
|
if (_env.env.EXPO_NO_TYPESCRIPT_SETUP) {
|
|
43
44
|
Log.warn("Skipping TypeScript setup: EXPO_NO_TYPESCRIPT_SETUP is enabled.");
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
debug("Ensuring TypeScript support is setup");
|
|
47
48
|
const tsConfigPath = _path.default.join(this.projectRoot, "tsconfig.json");
|
|
48
49
|
// Ensure the project is TypeScript before continuing.
|
|
49
50
|
const intent = await this._getSetupRequirements();
|
|
@@ -97,11 +98,11 @@ class TypeScriptProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
|
|
|
97
98
|
pkg: "typescript"
|
|
98
99
|
},
|
|
99
100
|
{
|
|
100
|
-
file: "@types/react/
|
|
101
|
+
file: "@types/react/package.json",
|
|
101
102
|
pkg: "@types/react"
|
|
102
103
|
},
|
|
103
104
|
{
|
|
104
|
-
file: "@types/react-native/
|
|
105
|
+
file: "@types/react-native/package.json",
|
|
105
106
|
pkg: "@types/react-native"
|
|
106
107
|
},
|
|
107
108
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/typescript/TypeScriptProjectPrerequisite.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport * as Log from '../../../log';\nimport { fileExistsAsync } from '../../../utils/dir';\nimport { env } from '../../../utils/env';\nimport { everyMatchAsync, wrapGlobWithTimeout } from '../../../utils/glob';\nimport { ProjectPrerequisite } from '../Prerequisite';\nimport { ensureDependenciesAsync } from '../dependencies/ensureDependenciesAsync';\nimport { updateTSConfigAsync } from './updateTSConfig';\n\n/** Ensure the project has the required TypeScript support settings. */\nexport class TypeScriptProjectPrerequisite extends ProjectPrerequisite {\n /** Ensure a project that hasn't explicitly disabled web support has all the required packages for running in the browser. */\n async assertImplementation(): Promise<void> {\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n Log.warn('Skipping TypeScript setup: EXPO_NO_TYPESCRIPT_SETUP is enabled.');\n return;\n }\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/typescript/TypeScriptProjectPrerequisite.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport * as Log from '../../../log';\nimport { fileExistsAsync } from '../../../utils/dir';\nimport { env } from '../../../utils/env';\nimport { everyMatchAsync, wrapGlobWithTimeout } from '../../../utils/glob';\nimport { ProjectPrerequisite } from '../Prerequisite';\nimport { ensureDependenciesAsync } from '../dependencies/ensureDependenciesAsync';\nimport { updateTSConfigAsync } from './updateTSConfig';\n\nconst debug = require('debug')('expo:doctor:typescriptSupport') as typeof console.log;\n\n/** Ensure the project has the required TypeScript support settings. */\nexport class TypeScriptProjectPrerequisite extends ProjectPrerequisite {\n /** Ensure a project that hasn't explicitly disabled web support has all the required packages for running in the browser. */\n async assertImplementation(): Promise<void> {\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n Log.warn('Skipping TypeScript setup: EXPO_NO_TYPESCRIPT_SETUP is enabled.');\n return;\n }\n debug('Ensuring TypeScript support is setup');\n\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n\n // Ensure the project is TypeScript before continuing.\n const intent = await this._getSetupRequirements();\n if (!intent) {\n return;\n }\n\n // Ensure TypeScript packages are installed\n await this._ensureDependenciesInstalledAsync();\n\n // Update the config\n await updateTSConfigAsync({ tsConfigPath, isBootstrapping: intent.isBootstrapping });\n }\n\n /** Exposed for testing. */\n async _getSetupRequirements(): Promise<{\n /** Indicates that TypeScript support is being bootstrapped. */\n isBootstrapping: boolean;\n } | null> {\n const tsConfigPath = await this._hasTSConfig();\n\n // Enable TS setup if the project has a `tsconfig.json`\n if (tsConfigPath) {\n const content = await fs.readFile(tsConfigPath, { encoding: 'utf8' }).then(\n (txt) => txt.trim(),\n // null when the file doesn't exist.\n () => null\n );\n const isBlankConfig = content === '' || content === '{}';\n return { isBootstrapping: isBlankConfig };\n }\n // This is a somewhat heavy check in larger projects.\n // Test that this is reasonably paced by running expo start in `expo/apps/native-component-list`\n const typescriptFile = await this._queryFirstTypeScriptFileAsync();\n if (typescriptFile) {\n return { isBootstrapping: true };\n }\n\n return null;\n }\n\n /** Exposed for testing. */\n async _ensureDependenciesInstalledAsync({ exp }: { exp?: ExpoConfig } = {}): Promise<boolean> {\n try {\n return await ensureDependenciesAsync(this.projectRoot, {\n exp,\n installMessage: `It looks like you're trying to use TypeScript but don't have the required dependencies installed.`,\n warningMessage:\n \"If you're not using TypeScript, please remove the TypeScript files from your project\",\n requiredPackages: [\n // use typescript/package.json to skip node module cache issues when the user installs\n // the package and attempts to resolve the module in the same process.\n { file: 'typescript/package.json', pkg: 'typescript' },\n { file: '@types/react/package.json', pkg: '@types/react' },\n { file: '@types/react-native/package.json', pkg: '@types/react-native' },\n ],\n });\n } catch (error) {\n // Reset the cached check so we can re-run the check if the user re-runs the command by pressing 'w' in the Terminal UI.\n this.resetAssertion();\n throw error;\n }\n }\n\n /** Return the first TypeScript file in the project. */\n async _queryFirstTypeScriptFileAsync(): Promise<null | string> {\n const results = await wrapGlobWithTimeout(\n () =>\n // TODO(Bacon): Use `everyMatch` since a bug causes `anyMatch` to return inaccurate results when used multiple times.\n everyMatchAsync('**/*.@(ts|tsx)', {\n cwd: this.projectRoot,\n ignore: [\n '**/@(Carthage|Pods|node_modules)/**',\n '**/*.d.ts',\n '@(ios|android|web|web-build|dist)/**',\n ],\n }),\n 5000\n );\n\n if (results === false) {\n return null;\n }\n return results[0] ?? null;\n }\n\n async _hasTSConfig(): Promise<string | null> {\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n if (await fileExistsAsync(tsConfigPath)) {\n return tsConfigPath;\n }\n return null;\n }\n}\n"],"names":["Log","debug","require","TypeScriptProjectPrerequisite","ProjectPrerequisite","assertImplementation","env","EXPO_NO_TYPESCRIPT_SETUP","warn","tsConfigPath","path","join","projectRoot","intent","_getSetupRequirements","_ensureDependenciesInstalledAsync","updateTSConfigAsync","isBootstrapping","_hasTSConfig","content","fs","readFile","encoding","then","txt","trim","isBlankConfig","typescriptFile","_queryFirstTypeScriptFileAsync","exp","ensureDependenciesAsync","installMessage","warningMessage","requiredPackages","file","pkg","error","resetAssertion","results","wrapGlobWithTimeout","everyMatchAsync","cwd","ignore","fileExistsAsync"],"mappings":"AAAA;;;;AACe,IAAA,SAAa,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,IAAI,CAACC,cAAc,EAAE,CAAC;YACtB,MAAMD,KAAK,CAAC;SACb;KACF;IAED,uDAAuD,CACvD,MAAMR,8BAA8B,GAA2B;QAC7D,MAAMU,OAAO,GAAG,MAAMC,CAAAA,GAAAA,KAAmB,AAYxC,CAAA,oBAZwC,CACvC,IACE,qHAAqH;YACrHC,CAAAA,GAAAA,KAAe,AAOb,CAAA,gBAPa,CAAC,gBAAgB,EAAE;gBAChCC,GAAG,EAAE,IAAI,CAAC7B,WAAW;gBACrB8B,MAAM,EAAE;oBACN,qCAAqC;oBACrC,WAAW;oBACX,sCAAsC;iBACvC;aACF,CAAC;QAAA,EACJ,IAAI,CACL,AAAC;QAEF,IAAIJ,OAAO,KAAK,KAAK,EAAE;YACrB,OAAO,IAAI,CAAC;SACb;YACMA,GAAU;QAAjB,OAAOA,CAAAA,GAAU,GAAVA,OAAO,CAAC,CAAC,CAAC,YAAVA,GAAU,GAAI,IAAI,CAAC;KAC3B;IAED,MAAMpB,YAAY,GAA2B;QAC3C,MAAMT,YAAY,GAAGC,KAAI,QAAA,CAACC,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE,eAAe,CAAC,AAAC;QAClE,IAAI,MAAM+B,CAAAA,GAAAA,IAAe,AAAc,CAAA,gBAAd,CAAClC,YAAY,CAAC,EAAE;YACvC,OAAOA,YAAY,CAAC;SACrB;QACD,OAAO,IAAI,CAAC;KACb;CACF;QAvGYN,6BAA6B,GAA7BA,6BAA6B"}
|
|
@@ -7,6 +7,7 @@ var _config = require("@expo/config");
|
|
|
7
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
8
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
9
9
|
var _env = require("../../../utils/env");
|
|
10
|
+
var _platformBundlers = require("../../server/platformBundlers");
|
|
10
11
|
var _prerequisite = require("../Prerequisite");
|
|
11
12
|
var _ensureDependenciesAsync = require("../dependencies/ensureDependenciesAsync");
|
|
12
13
|
function _interopRequireDefault(obj) {
|
|
@@ -35,13 +36,14 @@ function _interopRequireWildcard(obj) {
|
|
|
35
36
|
return newObj;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
const debug = require("debug")("expo:doctor:webSupport");
|
|
38
40
|
class WebSupportProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
|
|
39
41
|
/** Ensure a project that hasn't explicitly disabled web support has all the required packages for running in the browser. */ async assertImplementation() {
|
|
40
42
|
if (_env.env.EXPO_NO_WEB_SETUP) {
|
|
41
43
|
Log.warn("Skipping web setup: EXPO_NO_WEB_SETUP is enabled.");
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
debug("Ensuring web support is setup");
|
|
45
47
|
const result = await this._shouldSetupWebSupportAsync();
|
|
46
48
|
// Ensure web packages are installed
|
|
47
49
|
await this._ensureWebDependenciesInstalledAsync({
|
|
@@ -59,40 +61,39 @@ class WebSupportProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
|
|
|
59
61
|
return config;
|
|
60
62
|
}
|
|
61
63
|
/** Exposed for testing. */ async _ensureWebDependenciesInstalledAsync({ exp }) {
|
|
64
|
+
const requiredPackages = [
|
|
65
|
+
// use react-native-web/package.json to skip node module cache issues when the user installs
|
|
66
|
+
// the package and attempts to resolve the module in the same process.
|
|
67
|
+
{
|
|
68
|
+
file: "react-native-web/package.json",
|
|
69
|
+
pkg: "react-native-web",
|
|
70
|
+
version: "~0.18.1"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
file: "react-dom/package.json",
|
|
74
|
+
pkg: "react-dom",
|
|
75
|
+
version: "^18.0.0"
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
const bundler = (0, _platformBundlers).getPlatformBundlers(exp).web;
|
|
79
|
+
// Only include webpack-config if bundler is webpack.
|
|
80
|
+
if (bundler === "webpack") {
|
|
81
|
+
requiredPackages.push(// `webpack` and `webpack-dev-server` should be installed in the `@expo/webpack-config`
|
|
82
|
+
{
|
|
83
|
+
file: "@expo/webpack-config/package.json",
|
|
84
|
+
pkg: "@expo/webpack-config",
|
|
85
|
+
version: "~0.16.2",
|
|
86
|
+
dev: true
|
|
87
|
+
});
|
|
88
|
+
}
|
|
62
89
|
try {
|
|
63
90
|
return await (0, _ensureDependenciesAsync).ensureDependenciesAsync(this.projectRoot, {
|
|
91
|
+
// This never seems to work when prompting, installing, and running -- instead just inform the user to run the install command and try again.
|
|
92
|
+
skipPrompt: true,
|
|
64
93
|
exp,
|
|
65
94
|
installMessage: `It looks like you're trying to use web support but don't have the required dependencies installed.`,
|
|
66
|
-
warningMessage: _chalk.default`If you're not using web, please remove the {bold "web"} string from the platforms array in the project Expo config.`,
|
|
67
|
-
requiredPackages
|
|
68
|
-
// use react-native-web/package.json to skip node module cache issues when the user installs
|
|
69
|
-
// the package and attempts to resolve the module in the same process.
|
|
70
|
-
{
|
|
71
|
-
file: "react-native-web/package.json",
|
|
72
|
-
pkg: "react-native-web",
|
|
73
|
-
version: "~0.17.1"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
file: "react-dom/package.json",
|
|
77
|
-
pkg: "react-dom",
|
|
78
|
-
version: "^17.0.1"
|
|
79
|
-
},
|
|
80
|
-
// `webpack` and `webpack-dev-server` should be installed in the `@expo/webpack-config`
|
|
81
|
-
// package, but just in case we'll do the check now.
|
|
82
|
-
{
|
|
83
|
-
file: "webpack-dev-server/package.json",
|
|
84
|
-
// https://github.com/expo/expo-cli/pull/4282
|
|
85
|
-
pkg: "webpack-dev-server",
|
|
86
|
-
version: "~3.11.0",
|
|
87
|
-
dev: true
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
file: "@expo/webpack-config/package.json",
|
|
91
|
-
pkg: "@expo/webpack-config",
|
|
92
|
-
version: "~0.16.2",
|
|
93
|
-
dev: true
|
|
94
|
-
},
|
|
95
|
-
]
|
|
95
|
+
warningMessage: _chalk.default`If you're not using web, please ensure you remove the {bold "web"} string from the platforms array in the project Expo config.`,
|
|
96
|
+
requiredPackages
|
|
96
97
|
});
|
|
97
98
|
} catch (error) {
|
|
98
99
|
// Reset the cached check so we can re-run the check if the user re-runs the command by pressing 'w' in the Terminal UI.
|