@expo/cli 0.7.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/bin/cli +17 -3
- package/build/bin/cli.map +1 -1
- package/build/src/api/getExpoGoIntermediateCertificate.js +0 -2
- package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
- package/build/src/api/getProjectDevelopmentCertificate.js +0 -2
- package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
- package/build/src/api/graphql/queries/AppQuery.js +39 -0
- package/build/src/api/graphql/queries/AppQuery.js.map +1 -0
- package/build/src/api/graphql/queries/UserQuery.js +10 -3
- package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
- package/build/src/api/graphql/types/App.js +23 -0
- package/build/src/api/graphql/types/App.js.map +1 -0
- package/build/src/api/signManifest.js +0 -12
- package/build/src/api/signManifest.js.map +1 -1
- package/build/src/api/user/UserSettings.js.map +1 -1
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/config/configAsync.js +3 -0
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/customize/customizeAsync.js +3 -0
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/export/createBundles.js +8 -3
- package/build/src/export/createBundles.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +23 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -0
- package/build/src/export/embed/index.js +117 -0
- package/build/src/export/embed/index.js.map +1 -0
- package/build/src/export/embed/resolveOptions.js +63 -0
- package/build/src/export/embed/resolveOptions.js.map +1 -0
- package/build/src/export/exportApp.js +58 -31
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +17 -0
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +3 -0
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +179 -0
- package/build/src/export/exportStaticAsync.js.map +1 -0
- package/build/src/export/fork-bundleAsync.js +15 -43
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/html.js +21 -0
- package/build/src/export/html.js.map +1 -0
- package/build/src/export/index.js +5 -1
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +2 -2
- package/build/src/export/printBundleSizes.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -0
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +3 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/writeContents.js +5 -2
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/graphql/generated.js +462 -0
- package/build/src/graphql/generated.js.map +1 -0
- package/build/src/install/checkPackages.js +6 -0
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/installAsync.js +18 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +6 -1
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +3 -33
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/ensureConfigAsync.js +1 -12
- package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +7 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +7 -8
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +5 -0
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +6 -8
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +33 -47
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +48 -0
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -0
- package/build/src/run/android/runAndroidAsync.js +4 -0
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +25 -19
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
- package/build/src/run/ios/options/resolveNativeScheme.js +13 -4
- package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +3 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/run/startBundler.js +4 -0
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +12 -6
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +13 -2
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +12 -4
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +31 -5
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js +6 -0
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +1 -0
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/index.js +3 -1
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +1 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +16 -2
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +33 -2
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +167 -0
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +262 -3
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +2 -34
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/externals.js +72 -0
- package/build/src/start/server/metro/externals.js.map +1 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js +77 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/index.js +2 -2
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +1 -3
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +47 -48
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +137 -0
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +51 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -0
- package/build/src/start/server/metro/resolveFromProject.js +26 -3
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/router.js +15 -2
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +107 -0
- package/build/src/start/server/metro/runServer-fork.js.map +1 -0
- package/build/src/start/server/metro/symbolicate.js +6 -0
- package/build/src/start/server/metro/symbolicate.js.map +1 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +70 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js +188 -45
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/CreateFileMiddleware.js +6 -3
- package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +113 -47
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +59 -20
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +27 -0
- package/build/src/start/server/type-generation/expo-env.js.map +1 -0
- package/build/src/start/server/type-generation/index.js +57 -0
- package/build/src/start/server/type-generation/index.js.map +1 -0
- package/build/src/start/server/type-generation/routes.js +291 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -0
- package/build/src/start/server/type-generation/tsconfig.js +89 -0
- package/build/src/start/server/type-generation/tsconfig.js.map +1 -0
- package/build/src/start/server/webTemplate.js +20 -4
- package/build/src/start/server/webTemplate.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -6
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/startAsync.js +30 -8
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +11 -4
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/getMetroProperties.js +1 -1
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/codesigning.js +31 -7
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/dir.js +16 -6
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +6 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/mergeGitIgnorePaths.js +42 -0
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/nodeEnv.js +11 -0
- package/build/src/utils/nodeEnv.js.map +1 -0
- package/build/src/utils/resolveArgs.js +43 -0
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/strings.js +24 -0
- package/build/src/utils/strings.js.map +1 -0
- package/build/src/utils/template.js +21 -0
- package/build/src/utils/template.js.map +1 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js +61 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -0
- package/build/src/utils/tsconfig/loadTsConfigPaths.js +69 -0
- package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -0
- package/build/src/utils/tsconfig/matchTsConfigPathAlias.js +88 -0
- package/build/src/utils/tsconfig/matchTsConfigPathAlias.js.map +1 -0
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +41 -0
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -0
- package/package.json +16 -10
- package/static/template/metro.config.js +4 -1
- package/build/src/api/getProject.js +0 -19
- package/build/src/api/getProject.js.map +0 -1
- package/build/src/api/graphql/generated.js +0 -113
- package/build/src/api/graphql/generated.js.map +0 -1
- package/build/src/prebuild/writeMetroConfig.js +0 -89
- package/build/src/prebuild/writeMetroConfig.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
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
|
|
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 { setNodeEnv } from '../utils/nodeEnv';\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 setNodeEnv('development');\n require('@expo/env').load(projectRoot);\n\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 npm: !!options.packageManager?.npm,\n yarn: !!options.packageManager?.yarn,\n pnpm: !!options.packageManager?.pnpm,\n silent: !(env.EXPO_DEBUG || env.CI),\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","setNodeEnv","load","clean","maybeBailOnGitStatusAsync","clearNativeFolder","platforms","promptToClearMalformedNativeProjectsAsync","ensureValidPlatforms","assertPlatforms","exp","pkg","ensureConfigAsync","hasNewProjectFiles","needsPodInstall","hasNewDependencies","updateFromTemplateAsync","template","resolveTemplateOption","undefined","skipDependencyUpdate","install","packageManager","npm","clearNodeModulesAsync","installAsync","yarn","pnpm","silent","env","EXPO_DEBUG","CI","configSyncingStep","logNewSection","profile","configureProjectAsync","succeed","error","fail","podsInstalled","includes","installCocoaPodsAsync","nodeInstall","podInstall"],"mappings":"AAAA;;;;QAuCsBA,aAAa,GAAbA,aAAa;AApCN,IAAA,aAAyB,WAAzB,yBAAyB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc,CAAA;AACP,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACP,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;IACjCC,CAAAA,GAAAA,QAAU,AAAe,CAAA,WAAf,CAAC,aAAa,CAAC,CAAC;IAC1BH,OAAO,CAAC,WAAW,CA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,CAAC,AAAC;IAC1D,IAAI;QACF,MAAMC,CAAAA,GAAAA,QAAO,AAAuB,CAAA,QAAvB,CAACC,sBAAqB,sBAAA,CAAC,CAACpC,WAAW,EAAE;YAChDO,SAAS,EAAEN,OAAO,CAACM,SAAS;SAC7B,CAAC,CAAC;QACH0B,iBAAiB,CAACI,OAAO,CAAC,eAAe,CAAC,CAAC;KAC5C,CAAC,OAAOC,KAAK,EAAE;QACdL,iBAAiB,CAACM,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC7C,MAAMD,KAAK,CAAC;KACb;IAED,oBAAoB;IACpB,IAAIE,aAAa,GAAY,KAAK,AAAC;IACnC,8GAA8G;IAC9G,IAAIvC,OAAO,CAACM,SAAS,CAACkC,QAAQ,CAAC,KAAK,CAAC,IAAIxC,OAAO,CAACqB,OAAO,IAAIP,eAAe,EAAE;QAC3E,MAAM,EAAE2B,qBAAqB,CAAA,EAAE,GAAG,MAAM;mDAAO,oBAAoB;UAAC,AAAC;QAErEF,aAAa,GAAG,MAAME,qBAAqB,CAAC1C,WAAW,CAAC,CAAC;KAC1D,MAAM;QACLF,KAAK,CAAC,qBAAqB,CAAC,CAAC;KAC9B;IAED,OAAO;QACL6C,WAAW,EAAE,CAAC,CAAC1C,OAAO,CAACqB,OAAO;QAC9BsB,UAAU,EAAE,CAACJ,aAAa;QAC1BjC,SAAS,EAAEN,OAAO,CAACM,SAAS;QAC5BO,kBAAkB;QAClBH,GAAG;KACJ,CAAC;CACH"}
|
|
@@ -83,17 +83,16 @@ function resolvePlatformOption(platform = "all", { loose } = {}) {
|
|
|
83
83
|
"android"
|
|
84
84
|
];
|
|
85
85
|
case "all":
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
];
|
|
91
|
-
}
|
|
92
|
-
return [
|
|
86
|
+
return loose || process.platform !== "win32" ? [
|
|
87
|
+
"android",
|
|
88
|
+
"ios"
|
|
89
|
+
] : [
|
|
93
90
|
"android"
|
|
94
91
|
];
|
|
95
92
|
default:
|
|
96
|
-
|
|
93
|
+
return [
|
|
94
|
+
platform
|
|
95
|
+
];
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
function ensureValidPlatforms(platforms) {
|
|
@@ -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\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
|
|
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 return loose || process.platform !== 'win32' ? ['android', 'ios'] : ['android'];\n default:\n return [platform as ModPlatform];\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;QAiBrBC,oBAAoB,GAApBA,oBAAoB;QAYpBC,eAAe,GAAfA,eAAe;AAjFZ,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,OAAO,CAAC;QAClBG,IAAI,EAAEH,IAAI,CAAC,QAAQ,CAAC;QACpBI,IAAI,EAAEJ,IAAI,CAAC,QAAQ,CAAC;KACrB,AAAC;IAEF,IACE;QAACC,QAAQ,CAACC,GAAG;QAAED,QAAQ,CAACG,IAAI;QAAEH,QAAQ,CAACE,IAAI;QAAE,CAAC,CAACH,IAAI,CAAC,cAAc,CAAC;KAAC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E,KAAK;aAAC,GAAG;gBAAC,SAAS;aAAC,CAAC;QAClF;YACE,OAAO;gBAACA,QAAQ;aAAgB,CAAC;KACpC;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"}
|
|
@@ -122,6 +122,11 @@ async function resolveTemplateArgAsync(templateDirectory, oraInstance, appName,
|
|
|
122
122
|
throw error;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
// On Windows, we can actually create a URL from a local path
|
|
126
|
+
// Double-check if the created URL is not a path to avoid mixing up URLs and paths
|
|
127
|
+
if (process.platform === "win32" && repoUrl && _path.default.isAbsolute(repoUrl.toString())) {
|
|
128
|
+
repoUrl = undefined;
|
|
129
|
+
}
|
|
125
130
|
if (!repoUrl) {
|
|
126
131
|
const templatePath = _path.default.resolve(template);
|
|
127
132
|
if (!_fs.default.existsSync(templatePath)) {
|
|
@@ -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 { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}) {\n if (template) {\n await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<void> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n) {\n let repoInfo: RepoInfo | undefined;\n\n if (template) {\n // @ts-ignore\n let repoUrl: URL | undefined;\n\n try {\n // @ts-ignore\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n await extractLocalNpmTarballAsync(templatePath, { cwd: templateDirectory, name: appName });\n return templateDirectory;\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n }\n\n if (repoInfo) {\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n }\n\n return true;\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","repoInfo","repoUrl","URL","error","code","fail","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","found","text","bold","cyan"],"mappings":"AAAA;;;;QA0BsBA,kBAAkB,GAAlBA,kBAAkB;QAmFlBC,uBAAuB,GAAvBA,uBAAuB;AA5G3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEA,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACnCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACiC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAK1D,IAAA,IAAc,WAAd,cAAc,CAAA;AACG,IAAA,IAAc,WAAd,cAAc,C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0BAA0B,EAAEO,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,CAAC,EAAE7D,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAC7F,CAAC;YACF,MAAM,IAAI8D,OAAiB,kBAAA,EAAE,CAAC;SAC/B;QAED,MAAMC,KAAK,GAAG,MAAM/B,OAAO,CAACgB,QAAQ,CAAC,AAAC;QAEtC,IAAI,CAACe,KAAK,EAAE;YACVlB,WAAW,CAACQ,IAAI,CACd,CAAC,oCAAoC,EAAEO,MAAK,QAAA,CAACC,GAAG,CAC9C,CAAC,CAAC,EAAE7D,QAAQ,CAAC,CAAC,CAAC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;YACF,MAAM,IAAI8D,OAAiB,kBAAA,EAAE,CAAC;SAC/B;KACF;IAED,IAAId,QAAQ,EAAE;QACZH,WAAW,CAACmB,IAAI,GAAGJ,MAAK,QAAA,CAACK,IAAI,CAC3B,CAAC,4BAA4B,EAAEL,MAAK,QAAA,CAACM,IAAI,CAAClE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;QAEF,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEiD,QAAQ,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;CACb"}
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config-types';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}) {\n if (template) {\n await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<void> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n) {\n let repoInfo: RepoInfo | undefined;\n\n if (template) {\n // @ts-ignore\n let repoUrl: URL | undefined;\n\n try {\n // @ts-ignore\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n await extractLocalNpmTarballAsync(templatePath, { cwd: templateDirectory, name: appName });\n return templateDirectory;\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n }\n\n if (repoInfo) {\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n }\n\n return true;\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","repoInfo","repoUrl","URL","error","code","fail","process","platform","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","found","text","bold","cyan"],"mappings":"AAAA;;;;QA0BsBA,kBAAkB,GAAlBA,kBAAkB;QAmFlBC,uBAAuB,GAAvBA,uBAAuB;AA5G3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEA,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACnCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACiC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAK1D,IAAA,IAAc,WAAd,cAAc,CAAA;AACG,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,AAAsB,AAAC;AAS/E,eAAeJ,kBAAkB,CAAC,EACvC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ACC,QAAQ,EAAE;YACbH,WAAW,CAACQ,IAAI,CACd,CAAC,0BAA0B,EAAEW,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEjE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAC7F,CAAC;YACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;SAC/B;QAED,MAAMC,KAAK,GAAG,MAAMnC,OAAO,CAACgB,QAAQ,CAAC,AAAC;QAEtC,IAAI,CAACmB,KAAK,EAAE;YACVtB,WAAW,CAACQ,IAAI,CACd,CAAC,oCAAoC,EAAEW,MAAK,QAAA,CAACC,GAAG,CAC9C,CAAC,CAAC,EAAEjE,QAAQ,CAAC,CAAC,CAAC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;YACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;SAC/B;KACF;IAED,IAAIlB,QAAQ,EAAE;QACZH,WAAW,CAACuB,IAAI,GAAGJ,MAAK,QAAA,CAACK,IAAI,CAC3B,CAAC,4BAA4B,EAAEL,MAAK,QAAA,CAACM,IAAI,CAACtE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;QAEF,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEiD,QAAQ,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;CACb"}
|
|
@@ -11,7 +11,7 @@ var _profile = require("../utils/profile");
|
|
|
11
11
|
var _copyTemplateFiles = require("./copyTemplateFiles");
|
|
12
12
|
var _resolveTemplate = require("./resolveTemplate");
|
|
13
13
|
var _updatePackageJson = require("./updatePackageJson");
|
|
14
|
-
var
|
|
14
|
+
var _validateTemplatePlatforms = require("./validateTemplatePlatforms");
|
|
15
15
|
function _interopRequireDefault(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
17
17
|
default: obj
|
|
@@ -50,13 +50,8 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
50
50
|
template,
|
|
51
51
|
templateDirectory,
|
|
52
52
|
exp,
|
|
53
|
-
pkg,
|
|
54
53
|
platforms
|
|
55
54
|
});
|
|
56
|
-
(0, _profile).profile(_writeMetroConfig.writeMetroConfig)(projectRoot, {
|
|
57
|
-
pkg,
|
|
58
|
-
templateDirectory
|
|
59
|
-
});
|
|
60
55
|
const depsResults = await (0, _profile).profile(_updatePackageJson.updatePackageJSONAsync)(projectRoot, {
|
|
61
56
|
templateDirectory,
|
|
62
57
|
pkg,
|
|
@@ -73,7 +68,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
73
68
|
* Extract the template and copy the ios and android directories over to the project directory.
|
|
74
69
|
*
|
|
75
70
|
* @return `true` if any project files were created.
|
|
76
|
-
*/ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp ,
|
|
71
|
+
*/ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp , platforms: unknownPlatforms }) {
|
|
77
72
|
const ora = (0, _ora).logNewSection("Creating native project directories (./ios and ./android) and updating .gitignore");
|
|
78
73
|
try {
|
|
79
74
|
await (0, _resolveTemplate).cloneTemplateAsync({
|
|
@@ -82,8 +77,11 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
82
77
|
exp,
|
|
83
78
|
ora
|
|
84
79
|
});
|
|
80
|
+
const platforms = await (0, _validateTemplatePlatforms).validateTemplatePlatforms({
|
|
81
|
+
templateDirectory,
|
|
82
|
+
platforms: unknownPlatforms
|
|
83
|
+
});
|
|
85
84
|
const results = await (0, _copyTemplateFiles).copyTemplateFilesAsync(projectRoot, {
|
|
86
|
-
pkg,
|
|
87
85
|
templateDirectory,
|
|
88
86
|
platforms
|
|
89
87
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\nimport { copyTemplateFilesAsync, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { validateTemplatePlatforms } from './validateTemplatePlatforms';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is ejecting, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall:\n copiedPaths.includes('ios') ||\n depsResults.hasNewDependencies ||\n depsResults.hasNewDevDependencies,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nasync function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n platforms: unknownPlatforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n platforms: ModPlatform[];\n}): Promise<string[]> {\n const ora = logNewSection(\n 'Creating native project directories (./ios and ./android) and updating .gitignore'\n );\n\n try {\n await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const platforms = await validateTemplatePlatforms({\n templateDirectory,\n platforms: unknownPlatforms,\n });\n\n const results = await copyTemplateFilesAsync(projectRoot, {\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return results.copiedPaths;\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail('Failed to create the native project.');\n Log.log(\n chalk.yellow(\n 'You may want to delete the `./ios` and/or `./android` directories before trying again.'\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","profile","cloneTemplateAndCopyToProjectAsync","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","hasNewDependencies","hasNewDevDependencies","unknownPlatforms","ora","logNewSection","cloneTemplateAsync","validateTemplatePlatforms","results","copyTemplateFilesAsync","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;AAhB3B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACgC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAClC,IAAA,IAAc,WAAd,cAAc,CAAA;AACpB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AAC4B,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACxD,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACkB,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnD,IAAA,0BAA6B,WAA7B,6BAA6B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOhE,eAAeD,uBAAuB,CAC3CE,WAAmB,EACnB,EACEC,GAAG,CAAA,EACHC,GAAG,CAAA,EACHC,QAAQ,CAAA,EACRC,iBAAiB,CAAA,EACjBC,SAAS,CAAA,EACTC,oBAAoB,CAAA,EAcrB,EAQD;IACA,IAAI,CAACF,iBAAiB,EAAE;QACtB,MAAMG,SAAS,GAAG,MAAM;mDAAO,OAAO;UAAC,AAAC;QACxCH,iBAAiB,GAAGG,SAAS,CAACC,SAAS,EAAE,CAAC;KAC3C;IAED,MAAMC,WAAW,GAAG,MAAMC,CAAAA,GAAAA,QAAO,AAAoC,CAAA,QAApC,CAACC,kCAAkC,CAAC,CAAC;QACpEX,WAAW;QACXG,QAAQ;QACRC,iBAAiB;QACjBH,GAAG;QACHI,SAAS;KACV,CAAC,AAAC;IAEH,MAAMO,WAAW,GAAG,MAAMF,CAAAA,GAAAA,QAAO,AAAwB,CAAA,QAAxB,CAACG,kBAAsB,uBAAA,CAAC,CAACb,WAAW,EAAE;QACrEI,iBAAiB;QACjBF,GAAG;QACHI,oBAAoB;KACrB,CAAC,AAAC;IAEH,OAAO;QACLQ,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AC;SACtB;QACDX,GAAG,CAACY,IAAI,CAAC,sCAAsC,CAAC,CAAC;QACjDlC,GAAG,CAACmC,GAAG,CACLC,MAAK,QAAA,CAACC,MAAM,CACV,wFAAwF,CACzF,CACF,CAAC;QACF,MAAM,IAAIC,OAAW,YAAA,CAACR,CAAC,CAAC,CAAC;KAC1B;CACF"}
|
|
@@ -5,15 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
exports.updatePackageJSONAsync = updatePackageJSONAsync;
|
|
6
6
|
exports.updatePkgDependencies = updatePkgDependencies;
|
|
7
7
|
exports.createDependenciesMap = createDependenciesMap;
|
|
8
|
-
exports.isPkgMainExpoAppEntry = isPkgMainExpoAppEntry;
|
|
9
8
|
exports.hashForDependencyMap = hashForDependencyMap;
|
|
10
9
|
exports.createFileHash = createFileHash;
|
|
11
|
-
exports.shouldDeleteMainField = shouldDeleteMainField;
|
|
12
10
|
var _config = require("@expo/config");
|
|
13
11
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
14
12
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
15
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
16
14
|
var _path = _interopRequireDefault(require("path"));
|
|
15
|
+
var _semver = require("semver");
|
|
17
16
|
var Log = _interopRequireWildcard(require("../log"));
|
|
18
17
|
var _isModuleSymlinked = require("../utils/isModuleSymlinked");
|
|
19
18
|
var _ora = require("../utils/ora");
|
|
@@ -55,9 +54,6 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
|
|
|
55
54
|
// This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.
|
|
56
55
|
JSON.stringify(pkg, null, 2) + "\n");
|
|
57
56
|
updatingPackageJsonStep.succeed("Updated package.json and added index.js entry point for iOS and Android");
|
|
58
|
-
if (results.removedMainField) {
|
|
59
|
-
Log.log(`\u203A Removed ${_chalk.default.bold(`"main": "${results.removedMainField}"`)} from package.json because we recommend using index.js as main instead\n`);
|
|
60
|
-
}
|
|
61
57
|
return results;
|
|
62
58
|
}
|
|
63
59
|
/**
|
|
@@ -76,18 +72,12 @@ async function updatePackageJSONAsync(projectRoot, { templateDirectory , pkg , s
|
|
|
76
72
|
updatePkgScripts({
|
|
77
73
|
pkg
|
|
78
74
|
});
|
|
79
|
-
|
|
75
|
+
// TODO: Move to `npx expo-doctor`
|
|
76
|
+
return updatePkgDependencies(projectRoot, {
|
|
80
77
|
pkg,
|
|
81
78
|
templatePkg,
|
|
82
79
|
skipDependencyUpdate
|
|
83
80
|
});
|
|
84
|
-
const removedMainField = updatePkgMain({
|
|
85
|
-
pkg
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
...results,
|
|
89
|
-
removedMainField
|
|
90
|
-
};
|
|
91
81
|
}
|
|
92
82
|
function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDependencyUpdate =[] }) {
|
|
93
83
|
if (!pkg1.devDependencies) {
|
|
@@ -100,6 +90,11 @@ function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDepe
|
|
|
100
90
|
...defaultDependencies,
|
|
101
91
|
...pkg1.dependencies
|
|
102
92
|
});
|
|
93
|
+
const addWhenMissingDependencies = [
|
|
94
|
+
"react",
|
|
95
|
+
"react-native"
|
|
96
|
+
].filter((depKey)=>!!defaultDependencies[depKey]
|
|
97
|
+
);
|
|
103
98
|
const requiredDependencies = [
|
|
104
99
|
"expo",
|
|
105
100
|
"expo-splash-screen",
|
|
@@ -108,12 +103,13 @@ function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDepe
|
|
|
108
103
|
].filter((depKey)=>!!defaultDependencies[depKey]
|
|
109
104
|
);
|
|
110
105
|
const symlinkedPackages = [];
|
|
106
|
+
const nonRecommendedPackages = [];
|
|
111
107
|
for (const dependenciesKey of requiredDependencies){
|
|
112
|
-
var
|
|
113
|
-
|
|
108
|
+
var ref;
|
|
109
|
+
// If the local package.json defined the dependency that we want to overwrite...
|
|
114
110
|
if ((ref = pkg1.dependencies) == null ? void 0 : ref[dependenciesKey]) {
|
|
115
|
-
|
|
116
|
-
(0, _isModuleSymlinked).isModuleSymlinked(projectRoot, {
|
|
111
|
+
// Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).
|
|
112
|
+
if ((0, _isModuleSymlinked).isModuleSymlinked(projectRoot, {
|
|
117
113
|
moduleId: dependenciesKey,
|
|
118
114
|
isSilent: true
|
|
119
115
|
})) {
|
|
@@ -121,9 +117,25 @@ function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDepe
|
|
|
121
117
|
symlinkedPackages.push(dependenciesKey);
|
|
122
118
|
continue;
|
|
123
119
|
}
|
|
120
|
+
// Do not modify manually skipped dependencies
|
|
124
121
|
if (skipDependencyUpdate.includes(dependenciesKey)) {
|
|
125
122
|
continue;
|
|
126
123
|
}
|
|
124
|
+
// Ensure the package only needs to be added when missing
|
|
125
|
+
if (addWhenMissingDependencies.includes(dependenciesKey)) {
|
|
126
|
+
let projectHasRecommended = null;
|
|
127
|
+
// Check if the version intersects with the recommended versions
|
|
128
|
+
try {
|
|
129
|
+
projectHasRecommended = (0, _semver).intersects(pkg1.dependencies[dependenciesKey], String(defaultDependencies[dependenciesKey]));
|
|
130
|
+
} catch {
|
|
131
|
+
// If the version is invalid, just warn the user
|
|
132
|
+
}
|
|
133
|
+
// When the versions can't be parsed `null`, or does not intersect `false`, warn the user
|
|
134
|
+
if (projectHasRecommended !== true) {
|
|
135
|
+
nonRecommendedPackages.push(`${dependenciesKey}@${defaultDependencies[dependenciesKey]}`);
|
|
136
|
+
}
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
127
139
|
}
|
|
128
140
|
combinedDependencies[dependenciesKey] = defaultDependencies[dependenciesKey];
|
|
129
141
|
}
|
|
@@ -131,6 +143,10 @@ function updatePkgDependencies(projectRoot, { pkg: pkg1 , templatePkg , skipDepe
|
|
|
131
143
|
Log.log(`\u203A Using symlinked ${symlinkedPackages.map((pkg)=>_chalk.default.bold(pkg)
|
|
132
144
|
).join(", ")} instead of recommended version(s).`);
|
|
133
145
|
}
|
|
146
|
+
if (nonRecommendedPackages.length) {
|
|
147
|
+
Log.warn(`\u203A Using current versions instead of recommended ${nonRecommendedPackages.map((pkg)=>_chalk.default.bold(pkg)
|
|
148
|
+
).join(", ")}.`);
|
|
149
|
+
}
|
|
134
150
|
const combinedDevDependencies = createDependenciesMap({
|
|
135
151
|
...defaultDevDependencies,
|
|
136
152
|
...pkg1.devDependencies
|
|
@@ -189,30 +205,6 @@ function createDependenciesMap(dependencies) {
|
|
|
189
205
|
pkg.scripts.ios = "expo run:ios";
|
|
190
206
|
}
|
|
191
207
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Add new app entry points
|
|
194
|
-
*/ function updatePkgMain({ pkg }) {
|
|
195
|
-
let removedPkgMain = null;
|
|
196
|
-
// Check that the pkg.main doesn't match:
|
|
197
|
-
// - ./node_modules/expo/AppEntry
|
|
198
|
-
// - ./node_modules/expo/AppEntry.js
|
|
199
|
-
// - node_modules/expo/AppEntry.js
|
|
200
|
-
// - expo/AppEntry.js
|
|
201
|
-
// - expo/AppEntry
|
|
202
|
-
if (shouldDeleteMainField(pkg.main)) {
|
|
203
|
-
// Save the custom
|
|
204
|
-
removedPkgMain = pkg.main;
|
|
205
|
-
delete pkg.main;
|
|
206
|
-
}
|
|
207
|
-
return removedPkgMain;
|
|
208
|
-
}
|
|
209
|
-
function isPkgMainExpoAppEntry(input) {
|
|
210
|
-
const main = input || "";
|
|
211
|
-
if (main.startsWith("./")) {
|
|
212
|
-
return main.includes("node_modules/expo/AppEntry");
|
|
213
|
-
}
|
|
214
|
-
return main.includes("expo/AppEntry");
|
|
215
|
-
}
|
|
216
208
|
function normalizeDependencyMap(deps) {
|
|
217
209
|
return Object.keys(deps).map((dependency)=>`${dependency}@${deps[dependency]}`
|
|
218
210
|
).sort();
|
|
@@ -226,11 +218,5 @@ function createFileHash(contents) {
|
|
|
226
218
|
// this doesn't need to be secure, the shorter the better.
|
|
227
219
|
return _crypto.default.createHash("sha1").update(contents).digest("hex");
|
|
228
220
|
}
|
|
229
|
-
function shouldDeleteMainField(main) {
|
|
230
|
-
if (!main || !isPkgMainExpoAppEntry(main)) {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
return !(main == null ? void 0 : main.startsWith("index."));
|
|
234
|
-
}
|
|
235
221
|
|
|
236
222
|
//# sourceMappingURL=updatePackageJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/updatePackageJson.ts"],"sourcesContent":["import { getPackageJson, PackageJSONConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type PackageJsonModificationResults = DependenciesModificationResults & {\n removedMainField: string | null;\n};\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, dependencies, and main file'\n );\n\n const templatePkg = getPackageJson(templateDirectory);\n\n const results = modifyPackageJson(projectRoot, {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n });\n\n await fs.promises.writeFile(\n path.resolve(projectRoot, 'package.json'),\n // Add new line to match the format of running yarn.\n // This prevents the `package.json` from changing when running `prebuild --no-install` multiple times.\n JSON.stringify(pkg, null, 2) + '\\n'\n );\n\n updatingPackageJsonStep.succeed(\n 'Updated package.json and added index.js entry point for iOS and Android'\n );\n\n if (results.removedMainField) {\n Log.log(\n `\\u203A Removed ${chalk.bold(\n `\"main\": \"${results.removedMainField}\"`\n )} from package.json because we recommend using index.js as main instead\\n`\n );\n }\n\n return results;\n}\n\n/**\n * Make required modifications to the `package.json` file as a JSON object.\n *\n * 1. Update `package.json` `scripts`.\n * 2. Update `package.json` `dependencies` and `devDependencies`.\n * 3. Update `package.json` `main`.\n *\n * @param projectRoot The root directory of the project.\n * @param props.templatePkg Template project package.json as JSON.\n * @param props.pkg Current package.json as JSON.\n * @param props.skipDependencyUpdate Array of dependencies to skip updating.\n * @returns\n */\nfunction modifyPackageJson(\n projectRoot: string,\n {\n templatePkg,\n pkg,\n skipDependencyUpdate,\n }: {\n templatePkg: PackageJSONConfig;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): PackageJsonModificationResults {\n updatePkgScripts({ pkg });\n\n const results = updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n\n const removedMainField = updatePkgMain({ pkg });\n\n return { ...results, removedMainField };\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n if (\n // If the local package.json defined the dependency that we want to overwrite...\n pkg.dependencies?.[dependenciesKey]\n ) {\n if (\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })\n ) {\n // If the package is in the project's package.json and it's symlinked, then skip overwriting it.\n symlinkedPackages.push(dependenciesKey);\n continue;\n }\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n }\n combinedDependencies[dependenciesKey] = defaultDependencies[dependenciesKey];\n }\n\n if (symlinkedPackages.length) {\n Log.log(\n `\\u203A Using symlinked ${symlinkedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')} instead of recommended version(s).`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.start?.includes('--dev-client')) {\n pkg.scripts.start = 'expo start --dev-client';\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\n/**\n * Add new app entry points\n */\nfunction updatePkgMain({ pkg }: { pkg: PackageJSONConfig }): string | null {\n let removedPkgMain: null | string = null;\n // Check that the pkg.main doesn't match:\n // - ./node_modules/expo/AppEntry\n // - ./node_modules/expo/AppEntry.js\n // - node_modules/expo/AppEntry.js\n // - expo/AppEntry.js\n // - expo/AppEntry\n if (shouldDeleteMainField(pkg.main)) {\n // Save the custom\n removedPkgMain = pkg.main;\n delete pkg.main;\n }\n\n return removedPkgMain;\n}\n\n/**\n * Returns true if the input string matches the default expo main field.\n *\n * - ./node_modules/expo/AppEntry\n * - ./node_modules/expo/AppEntry.js\n * - node_modules/expo/AppEntry.js\n * - expo/AppEntry.js\n * - expo/AppEntry\n *\n * @param input package.json main field\n */\nexport function isPkgMainExpoAppEntry(input?: string): boolean {\n const main = input || '';\n if (main.startsWith('./')) {\n return main.includes('node_modules/expo/AppEntry');\n }\n return main.includes('expo/AppEntry');\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n\nexport function shouldDeleteMainField(main?: any): boolean {\n if (!main || !isPkgMainExpoAppEntry(main)) {\n return false;\n }\n\n return !main?.startsWith('index.');\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","isPkgMainExpoAppEntry","hashForDependencyMap","createFileHash","shouldDeleteMainField","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","removedMainField","log","chalk","bold","updatePkgScripts","updatePkgMain","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","requiredDependencies","filter","depKey","symlinkedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","length","map","join","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","start","android","ios","removedPkgMain","main","input","startsWith","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest"],"mappings":"AAAA;;;;QAwBsBA,sBAAsB,GAAtBA,sBAAsB;QAiG5BC,qBAAqB,GAArBA,qBAAqB;QAyFrBC,qBAAqB,GAArBA,qBAAqB;QA0ErBC,qBAAqB,GAArBA,qBAAqB;QAcrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GA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D,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';\nimport { intersects as semverIntersects } from 'semver';\n\nimport * as Log from '../log';\nimport { isModuleSymlinked } from '../utils/isModuleSymlinked';\nimport { logNewSection } from '../utils/ora';\n\nexport type DependenciesMap = { [key: string]: string | number };\n\nexport type DependenciesModificationResults = {\n /** Indicates that new values were added to the `dependencies` object in the `package.json`. */\n hasNewDependencies: boolean;\n /** Indicates that new values were added to the `devDependencies` object in the `package.json`. */\n hasNewDevDependencies: boolean;\n};\n\n/** Modifies the `package.json` with `modifyPackageJson` and format/displays the results. */\nexport async function updatePackageJSONAsync(\n projectRoot: string,\n {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n }: {\n templateDirectory: string;\n pkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): Promise<DependenciesModificationResults> {\n const updatingPackageJsonStep = logNewSection(\n 'Updating your package.json scripts, 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 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) {\n updatePkgScripts({ pkg });\n\n // TODO: Move to `npx expo-doctor`\n return updatePkgDependencies(projectRoot, {\n pkg,\n templatePkg,\n skipDependencyUpdate,\n });\n}\n\n/**\n * Update package.json dependencies by combining the dependencies in the project we are ejecting\n * with the dependencies in the template project. Does the same for devDependencies.\n *\n * - The template may have some dependencies beyond react/react-native/react-native-unimodules,\n * for example RNGH and Reanimated. We should prefer the version that is already being used\n * in the project for those, but swap the react/react-native/react-native-unimodules versions\n * with the ones in the template.\n * - The same applies to expo-updates -- since some native project configuration may depend on the\n * version, we should always use the version of expo-updates in the template.\n *\n * > Exposed for testing.\n */\nexport function updatePkgDependencies(\n projectRoot: string,\n {\n pkg,\n templatePkg,\n skipDependencyUpdate = [],\n }: {\n pkg: PackageJSONConfig;\n templatePkg: PackageJSONConfig;\n skipDependencyUpdate?: string[];\n }\n): DependenciesModificationResults {\n if (!pkg.devDependencies) {\n pkg.devDependencies = {};\n }\n const { dependencies, devDependencies } = templatePkg;\n const defaultDependencies = createDependenciesMap(dependencies);\n const defaultDevDependencies = createDependenciesMap(devDependencies);\n\n const combinedDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDependencies,\n ...pkg.dependencies,\n });\n\n const addWhenMissingDependencies = ['react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n const requiredDependencies = ['expo', 'expo-splash-screen', 'react', 'react-native'].filter(\n (depKey) => !!defaultDependencies[depKey]\n );\n\n const symlinkedPackages: string[] = [];\n const nonRecommendedPackages: string[] = [];\n\n for (const dependenciesKey of requiredDependencies) {\n // If the local package.json defined the dependency that we want to overwrite...\n if (pkg.dependencies?.[dependenciesKey]) {\n // Then ensure it isn't symlinked (i.e. the user has a custom version in their yarn workspace).\n if (isModuleSymlinked(projectRoot, { moduleId: dependenciesKey, isSilent: true })) {\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\n // Do not modify manually skipped dependencies\n if (skipDependencyUpdate.includes(dependenciesKey)) {\n continue;\n }\n\n // Ensure the package only needs to be added when missing\n if (addWhenMissingDependencies.includes(dependenciesKey)) {\n let projectHasRecommended: boolean | null = null;\n // Check if the version intersects with the recommended versions\n try {\n projectHasRecommended = semverIntersects(\n pkg.dependencies[dependenciesKey],\n String(defaultDependencies[dependenciesKey])\n );\n } catch {\n // If the version is invalid, just warn the user\n }\n // When the versions can't be parsed `null`, or does not intersect `false`, warn the user\n if (projectHasRecommended !== true) {\n nonRecommendedPackages.push(`${dependenciesKey}@${defaultDependencies[dependenciesKey]}`);\n }\n // Do not modify add-only dependencies\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 if (nonRecommendedPackages.length) {\n Log.warn(\n `\\u203A Using current versions instead of recommended ${nonRecommendedPackages\n .map((pkg) => chalk.bold(pkg))\n .join(', ')}.`\n );\n }\n\n const combinedDevDependencies: DependenciesMap = createDependenciesMap({\n ...defaultDevDependencies,\n ...pkg.devDependencies,\n });\n\n // Only change the dependencies if the normalized hash changes, this helps to reduce meaningless changes.\n const hasNewDependencies =\n hashForDependencyMap(pkg.dependencies) !== hashForDependencyMap(combinedDependencies);\n const hasNewDevDependencies =\n hashForDependencyMap(pkg.devDependencies) !== hashForDependencyMap(combinedDevDependencies);\n // Save the dependencies\n if (hasNewDependencies) {\n // Use Object.assign to preserve the original order of dependencies, this makes it easier to see what changed in the git diff.\n pkg.dependencies = Object.assign(pkg.dependencies ?? {}, combinedDependencies);\n }\n if (hasNewDevDependencies) {\n // Same as with dependencies\n pkg.devDependencies = Object.assign(pkg.devDependencies ?? {}, combinedDevDependencies);\n }\n\n return {\n hasNewDependencies,\n hasNewDevDependencies,\n };\n}\n\n/**\n * Create an object of type DependenciesMap a dependencies object or throw if not valid.\n *\n * @param dependencies - ideally an object of type {[key]: string} - if not then this will error.\n */\nexport function createDependenciesMap(dependencies: any): DependenciesMap {\n if (typeof dependencies !== 'object') {\n throw new Error(`Dependency map is invalid, expected object but got ${typeof dependencies}`);\n } else if (!dependencies) {\n return {};\n }\n\n const outputMap: DependenciesMap = {};\n\n for (const key of Object.keys(dependencies)) {\n const value = dependencies[key];\n if (typeof value === 'string') {\n outputMap[key] = value;\n } else {\n throw new Error(\n `Dependency for key \\`${key}\\` should be a \\`string\\`, instead got: \\`{ ${key}: ${JSON.stringify(\n value\n )} }\\``\n );\n }\n }\n return outputMap;\n}\n\n/**\n * Update package.json scripts - `npm start` should default to `expo\n * start --dev-client` rather than `expo start` after ejecting, for example.\n */\nfunction updatePkgScripts({ pkg }: { pkg: PackageJSONConfig }) {\n if (!pkg.scripts) {\n pkg.scripts = {};\n }\n if (!pkg.scripts.start?.includes('--dev-client')) {\n pkg.scripts.start = 'expo start --dev-client';\n }\n if (!pkg.scripts.android?.includes('run')) {\n pkg.scripts.android = 'expo run:android';\n }\n if (!pkg.scripts.ios?.includes('run')) {\n pkg.scripts.ios = 'expo run:ios';\n }\n}\n\nfunction normalizeDependencyMap(deps: DependenciesMap): string[] {\n return Object.keys(deps)\n .map((dependency) => `${dependency}@${deps[dependency]}`)\n .sort();\n}\n\nexport function hashForDependencyMap(deps: DependenciesMap = {}): string {\n const depsList = normalizeDependencyMap(deps);\n const depsString = depsList.join('\\n');\n return createFileHash(depsString);\n}\n\nexport function createFileHash(contents: string): string {\n // this doesn't need to be secure, the shorter the better.\n return crypto.createHash('sha1').update(contents).digest('hex');\n}\n"],"names":["updatePackageJSONAsync","updatePkgDependencies","createDependenciesMap","hashForDependencyMap","createFileHash","Log","projectRoot","templateDirectory","pkg","skipDependencyUpdate","updatingPackageJsonStep","logNewSection","templatePkg","getPackageJson","results","modifyPackageJson","fs","promises","writeFile","path","resolve","JSON","stringify","succeed","updatePkgScripts","devDependencies","dependencies","defaultDependencies","defaultDevDependencies","combinedDependencies","addWhenMissingDependencies","filter","depKey","requiredDependencies","symlinkedPackages","nonRecommendedPackages","dependenciesKey","isModuleSymlinked","moduleId","isSilent","push","includes","projectHasRecommended","semverIntersects","String","length","log","map","chalk","bold","join","warn","combinedDevDependencies","hasNewDependencies","hasNewDevDependencies","Object","assign","Error","outputMap","key","keys","value","scripts","start","android","ios","normalizeDependencyMap","deps","dependency","sort","depsList","depsString","contents","crypto","createHash","update","digest"],"mappings":"AAAA;;;;QAqBsBA,sBAAsB,GAAtBA,sBAAsB;QAsF5BC,qBAAqB,GAArBA,qBAAqB;QAuHrBC,qBAAqB,GAArBA,qBAAqB;QAiDrBC,oBAAoB,GAApBA,oBAAoB;QAMpBC,cAAc,GAAdA,cAAc;AAzRoB,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;AACwB,IAAA,OAAQ,WAAR,QAAQ,CAAA;AAE3CC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACmB,IAAA,kBAA4B,WAA5B,4BAA4B,CAAA;AAChC,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYrC,eAAeL,sBAA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AzBA,IAAe,CAAEiC,QAAQ,CAAC,KAAK,CAAC,CAAA,EAAE;QACrCjC,GAAG,CAACsD,OAAO,CAACG,GAAG,GAAG,cAAc,CAAC;KAClC;CACF;AAED,SAASC,sBAAsB,CAACC,IAAqB,EAAY;IAC/D,OAAOZ,MAAM,CAACK,IAAI,CAACO,IAAI,CAAC,CACrBpB,GAAG,CAAC,CAACqB,UAAU,GAAK,CAAC,EAAEA,UAAU,CAAC,CAAC,EAAED,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC;IAAA,CAAC,CACxDC,IAAI,EAAE,CAAC;CACX;AAEM,SAASlE,oBAAoB,CAACgE,IAAqB,GAAG,EAAE,EAAU;IACvE,MAAMG,QAAQ,GAAGJ,sBAAsB,CAACC,IAAI,CAAC,AAAC;IAC9C,MAAMI,UAAU,GAAGD,QAAQ,CAACpB,IAAI,CAAC,IAAI,CAAC,AAAC;IACvC,OAAO9C,cAAc,CAACmE,UAAU,CAAC,CAAC;CACnC;AAEM,SAASnE,cAAc,CAACoE,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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.validateTemplatePlatforms = validateTemplatePlatforms;
|
|
6
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var Log = _interopRequireWildcard(require("../log"));
|
|
9
|
+
var _dir = require("../utils/dir");
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function _interopRequireWildcard(obj) {
|
|
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
|
+
}
|
|
36
|
+
async function validateTemplatePlatforms({ templateDirectory , platforms }) {
|
|
37
|
+
const existingPlatforms = [];
|
|
38
|
+
for (const platform of platforms){
|
|
39
|
+
if (await (0, _dir).directoryExistsAsync(_path.default.join(templateDirectory, platform))) {
|
|
40
|
+
existingPlatforms.push(platform);
|
|
41
|
+
} else {
|
|
42
|
+
Log.warn(_chalk.default`⚠️ Skipping platform ${platform}. Use a template that contains native files for ${platform} (./${platform}).`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return existingPlatforms;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=validateTemplatePlatforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/validateTemplatePlatforms.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { directoryExistsAsync } from '../utils/dir';\n\nexport async function validateTemplatePlatforms({\n templateDirectory,\n platforms,\n}: {\n templateDirectory: string;\n platforms: ModPlatform[];\n}) {\n const existingPlatforms: ModPlatform[] = [];\n\n for (const platform of platforms) {\n if (await directoryExistsAsync(path.join(templateDirectory, platform))) {\n existingPlatforms.push(platform);\n } else {\n Log.warn(\n chalk`⚠️ Skipping platform ${platform}. Use a template that contains native files for ${platform} (./${platform}).`\n );\n }\n }\n\n return existingPlatforms;\n}\n"],"names":["validateTemplatePlatforms","Log","templateDirectory","platforms","existingPlatforms","platform","directoryExistsAsync","path","join","push","warn","chalk"],"mappings":"AAAA;;;;QAOsBA,yBAAyB,GAAzBA,yBAAyB;AAN7B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACsB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5C,eAAeD,yBAAyB,CAAC,EAC9CE,iBAAiB,CAAA,EACjBC,SAAS,CAAA,EAIV,EAAE;IACD,MAAMC,iBAAiB,GAAkB,EAAE,AAAC;IAE5C,KAAK,MAAMC,QAAQ,IAAIF,SAAS,CAAE;QAChC,IAAI,MAAMG,CAAAA,GAAAA,IAAoB,AAAwC,CAAA,qBAAxC,CAACC,KAAI,QAAA,CAACC,IAAI,CAACN,iBAAiB,EAAEG,QAAQ,CAAC,CAAC,EAAE;YACtED,iBAAiB,CAACK,IAAI,CAACJ,QAAQ,CAAC,CAAC;SAClC,MAAM;YACLJ,GAAG,CAACS,IAAI,CACNC,MAAK,QAAA,CAAC,0BAAsB,EAAEN,QAAQ,CAAC,gDAAgD,EAAEA,QAAQ,CAAC,IAAI,EAAEA,QAAQ,CAAC,EAAE,CAAC,CACrH,CAAC;SACH;KACF;IAED,OAAOD,iBAAiB,CAAC;CAC1B"}
|
|
@@ -6,6 +6,7 @@ exports.runAndroidAsync = runAndroidAsync;
|
|
|
6
6
|
var _path = _interopRequireDefault(require("path"));
|
|
7
7
|
var _log = require("../../log");
|
|
8
8
|
var _gradle = require("../../start/platforms/android/gradle");
|
|
9
|
+
var _nodeEnv = require("../../utils/nodeEnv");
|
|
9
10
|
var _scheme = require("../../utils/scheme");
|
|
10
11
|
var _ensureNativeProject = require("../ensureNativeProject");
|
|
11
12
|
var _hints = require("../hints");
|
|
@@ -20,6 +21,9 @@ function _interopRequireDefault(obj) {
|
|
|
20
21
|
const debug = require("debug")("expo:run:android");
|
|
21
22
|
async function runAndroidAsync(projectRoot, { install , ...options }) {
|
|
22
23
|
var ref;
|
|
24
|
+
// NOTE: This is a guess, the developer can overwrite with `NODE_ENV`.
|
|
25
|
+
(0, _nodeEnv).setNodeEnv(options.variant === "release" ? "production" : "development");
|
|
26
|
+
require("@expo/env").load(projectRoot);
|
|
23
27
|
await (0, _ensureNativeProject).ensureNativeProjectAsync(projectRoot, {
|
|
24
28
|
platform: "android",
|
|
25
29
|
install
|