@expo/cli 0.1.5 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +133 -0
- package/build/bin/cli +83 -4
- package/build/bin/cli.map +1 -1
- package/build/src/api/getNativeModuleVersions.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
- package/build/src/customize/customizeAsync.js +40 -0
- package/build/src/customize/customizeAsync.js.map +1 -0
- package/build/src/customize/generate.js +77 -0
- package/build/src/customize/generate.js.map +1 -0
- package/build/src/customize/index.js +41 -0
- package/build/src/customize/index.js.map +1 -0
- package/build/src/customize/resolveOptions.js +18 -0
- package/build/src/customize/resolveOptions.js.map +1 -0
- package/build/src/customize/templates.js +118 -0
- package/build/src/customize/templates.js.map +1 -0
- package/build/src/export/createMetadataJson.js +10 -7
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/exportApp.js +32 -0
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +2 -3
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +52 -35
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +14 -10
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +27 -48
- package/build/src/export/printBundleSizes.js.map +1 -1
- package/build/src/export/resolveOptions.js +44 -5
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +2 -1
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +37 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -0
- package/build/src/export/web/index.js +66 -0
- package/build/src/export/web/index.js.map +1 -0
- package/build/src/export/web/resolveOptions.js +13 -0
- package/build/src/export/web/resolveOptions.js.map +1 -0
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/checkPackages.js +2 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/index.js +1 -0
- package/build/src/install/index.js.map +1 -1
- package/build/src/install/installAsync.js +13 -5
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js +12 -65
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
- package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
- package/build/src/log.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +5 -23
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +18 -12
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +11 -12
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +17 -0
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +2 -1
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -5
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveInstallApkName.js +5 -26
- package/build/src/run/android/resolveInstallApkName.js.map +1 -1
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
- package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
- package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
- package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
- package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
- package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +29 -31
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/interface/KeyPressHandler.js +2 -0
- package/build/src/start/interface/KeyPressHandler.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +5 -5
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +3 -2
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +4 -24
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +17 -32
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/AndroidSdk.js +41 -0
- package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
- package/build/src/start/platforms/android/activateWindow.js +4 -4
- package/build/src/start/platforms/android/activateWindow.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +8 -3
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/android/adbReverse.js +3 -2
- package/build/src/start/platforms/android/adbReverse.js.map +1 -1
- package/build/src/start/platforms/android/gradle.js +2 -2
- package/build/src/start/platforms/android/gradle.js.map +1 -1
- package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
- package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
- package/build/src/start/platforms/ios/xcrun.js +2 -23
- package/build/src/start/platforms/ios/xcrun.js.map +1 -1
- package/build/src/start/project/devices.js +2 -0
- package/build/src/start/project/devices.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +6 -5
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +15 -8
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +15 -5
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +4 -0
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +10 -3
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +5 -0
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +11 -2
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/resolveFromProject.js +8 -0
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
- package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
- package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
- package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
- package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
- package/build/src/start/server/platformBundlers.js +18 -0
- package/build/src/start/server/platformBundlers.js.map +1 -0
- package/build/src/start/server/webTemplate.js +68 -0
- package/build/src/start/server/webTemplate.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/server/webpack/compile.js +64 -0
- package/build/src/start/server/webpack/compile.js.map +1 -0
- package/build/src/start/startAsync.js +21 -17
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +5 -2
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/downloadAppAsync.js +3 -2
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/downloadExpoGoAsync.js +7 -32
- package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
- package/build/src/utils/editor.js +3 -2
- package/build/src/utils/editor.js.map +1 -1
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/exit.js +4 -25
- package/build/src/utils/exit.js.map +1 -1
- package/build/src/utils/getRunningProcess.js +6 -2
- package/build/src/utils/getRunningProcess.js.map +1 -1
- package/build/src/utils/nodeModules.js +13 -102
- package/build/src/utils/nodeModules.js.map +1 -1
- package/build/src/utils/npm.js +3 -24
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/ora.js +1 -13
- package/build/src/utils/ora.js.map +1 -1
- package/build/src/utils/progress.js +46 -0
- package/build/src/utils/progress.js.map +1 -1
- package/build/src/utils/prompts.js +4 -4
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/utils/tar.js +3 -0
- package/build/src/utils/tar.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +9 -2
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/utils/variadic.js +47 -0
- package/build/src/utils/variadic.js.map +1 -0
- package/package.json +13 -8
- package/static/template/babel.config.js +6 -0
- package/static/template/index.html +117 -0
- package/static/template/metro.config.js +4 -0
- package/static/template/serve.json +13 -0
- package/static/template/webpack.config.js +7 -0
|
@@ -6,10 +6,16 @@ exports.installAsync = installAsync;
|
|
|
6
6
|
exports.installPackagesAsync = installPackagesAsync;
|
|
7
7
|
var _config = require("@expo/config");
|
|
8
8
|
var PackageManager = _interopRequireWildcard(require("@expo/package-manager"));
|
|
9
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
10
|
var Log = _interopRequireWildcard(require("../log"));
|
|
10
11
|
var _getVersionedPackages = require("../start/doctor/dependencies/getVersionedPackages");
|
|
11
12
|
var _findUp = require("../utils/findUp");
|
|
12
13
|
var _checkPackages = require("./checkPackages");
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
13
19
|
function _interopRequireWildcard(obj) {
|
|
14
20
|
if (obj && obj.__esModule) {
|
|
15
21
|
return obj;
|
|
@@ -32,14 +38,17 @@ function _interopRequireWildcard(obj) {
|
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
async function installAsync(packages, options, packageManagerArguments = []) {
|
|
41
|
+
var _projectRoot;
|
|
35
42
|
// Locate the project root based on the process current working directory.
|
|
36
43
|
// This enables users to run `npx expo install` from a subdirectory of the project.
|
|
37
|
-
const projectRoot = (0, _findUp).findUpProjectRootOrAssert(process.cwd());
|
|
44
|
+
const projectRoot = (_projectRoot = options.projectRoot) != null ? _projectRoot : (0, _findUp).findUpProjectRootOrAssert(process.cwd());
|
|
38
45
|
// Resolve the package manager used by the project, or based on the provided arguments.
|
|
39
46
|
const packageManager = PackageManager.createForProject(projectRoot, {
|
|
40
47
|
npm: options.npm,
|
|
41
48
|
yarn: options.yarn,
|
|
42
|
-
|
|
49
|
+
pnpm: options.pnpm,
|
|
50
|
+
log: Log.log,
|
|
51
|
+
silent: options.silent
|
|
43
52
|
});
|
|
44
53
|
if (options.check || options.fix) {
|
|
45
54
|
return await (0, _checkPackages).checkPackagesAsync(projectRoot, {
|
|
@@ -69,7 +78,7 @@ async function installPackagesAsync(projectRoot, { packages , packageManager , s
|
|
|
69
78
|
// sdkVersion is always defined because we don't skipSDKVersionRequirement in getConfig.
|
|
70
79
|
sdkVersion
|
|
71
80
|
});
|
|
72
|
-
Log.log(
|
|
81
|
+
Log.log(_chalk.default`\u203A Installing ${versioning.messages.length ? versioning.messages.join(" and ") + " " : ""}using {bold ${packageManager.name}}`);
|
|
73
82
|
await packageManager.addWithParametersAsync(versioning.packages, packageManagerArguments);
|
|
74
83
|
await applyPluginsAsync(projectRoot, versioning.packages);
|
|
75
84
|
}
|
|
@@ -82,8 +91,7 @@ async function installPackagesAsync(projectRoot, { packages , packageManager , s
|
|
|
82
91
|
});
|
|
83
92
|
try {
|
|
84
93
|
const { exp } = (0, _config).getConfig(projectRoot, {
|
|
85
|
-
skipSDKVersionRequirement: true
|
|
86
|
-
skipPlugins: true
|
|
94
|
+
skipSDKVersionRequirement: true
|
|
87
95
|
});
|
|
88
96
|
// Only auto add plugins if the plugins array is defined or if the project is using SDK +42.
|
|
89
97
|
await autoAddConfigPluginsAsync(projectRoot, exp, // Split any possible NPM tags. i.e. `expo@latest` -> `expo`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/install/installAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\n\nimport * as Log from '../log';\nimport { getVersionedPackagesAsync } from '../start/doctor/dependencies/getVersionedPackages';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { checkPackagesAsync } from './checkPackages';\nimport { Options } from './resolveOptions';\n\nexport async function installAsync(\n packages: string[],\n options: Options,\n packageManagerArguments: string[] = []\n) {\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo install` from a subdirectory of the project.\n const projectRoot = findUpProjectRootOrAssert(process.cwd());\n\n // Resolve the package manager used by the project, or based on the provided arguments.\n const packageManager = PackageManager.createForProject(projectRoot, {\n npm: options.npm,\n yarn: options.yarn,\n log: Log.log,\n });\n\n if (options.check || options.fix) {\n return await checkPackagesAsync(projectRoot, {\n packages,\n options,\n packageManager,\n packageManagerArguments,\n });\n }\n\n // Read the project Expo config without plugins.\n const { exp } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n // Resolve the versioned packages, then install them.\n return installPackagesAsync(projectRoot, {\n packageManager,\n packages,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n}\n\n/** Version packages and install in a project. */\nexport async function installPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n sdkVersion,\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager
|
|
1
|
+
{"version":3,"sources":["../../../src/install/installAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { getVersionedPackagesAsync } from '../start/doctor/dependencies/getVersionedPackages';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { checkPackagesAsync } from './checkPackages';\nimport { Options } from './resolveOptions';\n\nexport async function installAsync(\n packages: string[],\n options: Options & { projectRoot?: string },\n packageManagerArguments: string[] = []\n) {\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo install` from a subdirectory of the project.\n const projectRoot = options.projectRoot ?? findUpProjectRootOrAssert(process.cwd());\n\n // Resolve the package manager used by the project, or based on the provided arguments.\n const packageManager = PackageManager.createForProject(projectRoot, {\n npm: options.npm,\n yarn: options.yarn,\n pnpm: options.pnpm,\n log: Log.log,\n silent: options.silent,\n });\n\n if (options.check || options.fix) {\n return await checkPackagesAsync(projectRoot, {\n packages,\n options,\n packageManager,\n packageManagerArguments,\n });\n }\n\n // Read the project Expo config without plugins.\n const { exp } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n // Resolve the versioned packages, then install them.\n return installPackagesAsync(projectRoot, {\n packageManager,\n packages,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n}\n\n/** Version packages and install in a project. */\nexport async function installPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n sdkVersion,\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager:\n | PackageManager.NpmPackageManager\n | PackageManager.YarnPackageManager\n | PackageManager.PnpmPackageManager;\n /**\n * SDK to version `packages` for.\n * @example '44.0.0'\n */\n sdkVersion: string;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n): Promise<void> {\n const versioning = await getVersionedPackagesAsync(projectRoot, {\n packages,\n // sdkVersion is always defined because we don't skipSDKVersionRequirement in getConfig.\n sdkVersion,\n });\n\n Log.log(\n chalk`\\u203A Installing ${\n versioning.messages.length ? versioning.messages.join(' and ') + ' ' : ''\n }using {bold ${packageManager.name}}`\n );\n\n await packageManager.addWithParametersAsync(versioning.packages, packageManagerArguments);\n\n await applyPluginsAsync(projectRoot, versioning.packages);\n}\n\n/**\n * A convenience feature for automatically applying Expo Config Plugins to the `app.json` after installing them.\n * This should be dropped in favor of autolinking in the future.\n */\nasync function applyPluginsAsync(projectRoot: string, packages: string[]) {\n const { autoAddConfigPluginsAsync } = await import('./utils/autoAddConfigPlugins');\n\n try {\n const { exp } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n\n // Only auto add plugins if the plugins array is defined or if the project is using SDK +42.\n await autoAddConfigPluginsAsync(\n projectRoot,\n exp,\n // Split any possible NPM tags. i.e. `expo@latest` -> `expo`\n packages.map((pkg) => pkg.split('@')[0]).filter(Boolean)\n );\n } catch (error: any) {\n // If we fail to apply plugins, the log a warning and continue.\n if (error.isPluginError) {\n Log.warn(`Skipping config plugin check: ` + error.message);\n return;\n }\n // Any other error, rethrow.\n throw error;\n }\n}\n"],"names":["installAsync","installPackagesAsync","PackageManager","Log","packages","options","packageManagerArguments","projectRoot","findUpProjectRootOrAssert","process","cwd","packageManager","createForProject","npm","yarn","pnpm","log","silent","check","fix","checkPackagesAsync","exp","getConfig","skipPlugins","sdkVersion","versioning","getVersionedPackagesAsync","chalk","messages","length","join","name","addWithParametersAsync","applyPluginsAsync","autoAddConfigPluginsAsync","skipSDKVersionRequirement","map","pkg","split","filter","Boolean","error","isPluginError","warn","message"],"mappings":"AAAA;;;;QAUsBA,YAAY,GAAZA,YAAY;QA4CZC,oBAAoB,GAApBA,oBAAoB;AAtDhB,IAAA,OAAc,WAAd,cAAc,CAAA;AAC5BC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AACR,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AAC2B,IAAA,qBAAmD,WAAnD,mDAAmD,CAAA;AACnD,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACxB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG7C,eAAeH,YAAY,CAChCI,QAAkB,EAClBC,OAA2C,EAC3CC,uBAAiC,GAAG,EAAE,EACtC;QAGoBD,YAAmB;IAFvC,0EAA0E;IAC1E,mFAAmF;IACnF,MAAME,WAAW,GAAGF,CAAAA,YAAmB,GAAnBA,OAAO,CAACE,WAAW,YAAnBF,YAAmB,GAAIG,CAAA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@ -2,78 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.parseVariadicArguments = parseVariadicArguments;
|
|
6
5
|
exports.resolveArgsAsync = resolveArgsAsync;
|
|
7
|
-
var Log = _interopRequireWildcard(require("../log"));
|
|
8
6
|
var _errors = require("../utils/errors");
|
|
9
|
-
|
|
10
|
-
if (obj && obj.__esModule) {
|
|
11
|
-
return obj;
|
|
12
|
-
} else {
|
|
13
|
-
var newObj = {};
|
|
14
|
-
if (obj != null) {
|
|
15
|
-
for(var key in obj){
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
17
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
18
|
-
if (desc.get || desc.set) {
|
|
19
|
-
Object.defineProperty(newObj, key, desc);
|
|
20
|
-
} else {
|
|
21
|
-
newObj[key] = obj[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
newObj.default = obj;
|
|
27
|
-
return newObj;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
7
|
+
var _variadic = require("../utils/variadic");
|
|
30
8
|
function resolveOptions(options) {
|
|
31
9
|
if (options.fix && options.check) {
|
|
32
10
|
throw new _errors.CommandError("BAD_ARGS", "Specify at most one of: --check, --fix");
|
|
33
11
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
12
|
+
if ([
|
|
13
|
+
options.npm,
|
|
14
|
+
options.pnpm,
|
|
15
|
+
options.yarn
|
|
16
|
+
].filter(Boolean).length > 1) {
|
|
17
|
+
throw new _errors.CommandError("BAD_ARGS", "Specify at most one of: --npm, --pnpm, --yarn");
|
|
36
18
|
}
|
|
37
19
|
return {
|
|
38
20
|
...options
|
|
39
21
|
};
|
|
40
22
|
}
|
|
41
|
-
function parseVariadicArguments(argv) {
|
|
42
|
-
const variadic = [];
|
|
43
|
-
const flags = {};
|
|
44
|
-
for (const arg of argv){
|
|
45
|
-
if (!arg.startsWith("-")) {
|
|
46
|
-
variadic.push(arg);
|
|
47
|
-
} else if (arg === "--") {
|
|
48
|
-
break;
|
|
49
|
-
} else {
|
|
50
|
-
flags[arg] = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// Everything after `--` that is not an option is passed to the underlying install command.
|
|
54
|
-
const extras = [];
|
|
55
|
-
const extraOperator = argv.indexOf("--");
|
|
56
|
-
if (extraOperator > -1 && argv.length > extraOperator + 1) {
|
|
57
|
-
const extraArgs = argv.slice(extraOperator + 1);
|
|
58
|
-
if (extraArgs.includes("--")) {
|
|
59
|
-
throw new _errors.CommandError("BAD_ARGS", "Unexpected multiple --");
|
|
60
|
-
}
|
|
61
|
-
extras.push(...extraArgs);
|
|
62
|
-
Log.debug("Extra arguments: " + extras.join(", "));
|
|
63
|
-
}
|
|
64
|
-
Log.debug(`Parsed arguments (variadic: %O, flags: %O, extra: %O)`, variadic, flags, extras);
|
|
65
|
-
return {
|
|
66
|
-
variadic,
|
|
67
|
-
flags,
|
|
68
|
-
extras
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
23
|
async function resolveArgsAsync(argv) {
|
|
72
|
-
const { variadic , extras , flags } = parseVariadicArguments(argv);
|
|
73
|
-
assertUnexpectedObjectKeys([
|
|
24
|
+
const { variadic , extras , flags } = (0, _variadic).parseVariadicArguments(argv);
|
|
25
|
+
(0, _variadic).assertUnexpectedObjectKeys([
|
|
74
26
|
"--check",
|
|
75
27
|
"--fix",
|
|
76
28
|
"--npm",
|
|
29
|
+
"--pnpm",
|
|
77
30
|
"--yarn"
|
|
78
31
|
], flags);
|
|
79
32
|
return {
|
|
@@ -83,17 +36,11 @@ async function resolveArgsAsync(argv) {
|
|
|
83
36
|
fix: !!flags["--fix"],
|
|
84
37
|
check: !!flags["--check"],
|
|
85
38
|
yarn: !!flags["--yarn"],
|
|
86
|
-
npm: !!flags["--npm"]
|
|
39
|
+
npm: !!flags["--npm"],
|
|
40
|
+
pnpm: !!flags["--pnpm"]
|
|
87
41
|
}),
|
|
88
42
|
extras
|
|
89
43
|
};
|
|
90
44
|
}
|
|
91
|
-
function assertUnexpectedObjectKeys(keys, obj) {
|
|
92
|
-
const unexpectedKeys = Object.keys(obj).filter((key)=>!keys.includes(key)
|
|
93
|
-
);
|
|
94
|
-
if (unexpectedKeys.length > 0) {
|
|
95
|
-
throw new _errors.CommandError("BAD_ARGS", `Unexpected: ${unexpectedKeys.join(", ")}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
45
|
|
|
99
46
|
//# sourceMappingURL=resolveOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/install/resolveOptions.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/install/resolveOptions.ts"],"sourcesContent":["import * as PackageManager from '@expo/package-manager';\n\nimport { CommandError } from '../utils/errors';\nimport { assertUnexpectedObjectKeys, parseVariadicArguments } from '../utils/variadic';\n\nexport type Options = Pick<PackageManager.CreateForProjectOptions, 'npm' | 'pnpm' | 'yarn'> & {\n /** Check which packages need to be updated, does not install any provided packages. */\n check?: boolean;\n /** Should the dependencies be fixed automatically. */\n fix?: boolean;\n /** Should disable install output, used for commands like `prebuild` that run install internally. */\n silent?: boolean;\n};\n\nfunction resolveOptions(options: Options): Options {\n if (options.fix && options.check) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --check, --fix');\n }\n if ([options.npm, options.pnpm, options.yarn].filter(Boolean).length > 1) {\n throw new CommandError('BAD_ARGS', 'Specify at most one of: --npm, --pnpm, --yarn');\n }\n return {\n ...options,\n };\n}\n\nexport async function resolveArgsAsync(\n argv: string[]\n): Promise<{ variadic: string[]; options: Options; extras: string[] }> {\n const { variadic, extras, flags } = parseVariadicArguments(argv);\n\n assertUnexpectedObjectKeys(['--check', '--fix', '--npm', '--pnpm', '--yarn'], flags);\n\n return {\n // Variadic arguments like `npx expo install react react-dom` -> ['react', 'react-dom']\n variadic,\n options: resolveOptions({\n fix: !!flags['--fix'],\n check: !!flags['--check'],\n yarn: !!flags['--yarn'],\n npm: !!flags['--npm'],\n pnpm: !!flags['--pnpm'],\n }),\n extras,\n };\n}\n"],"names":["resolveArgsAsync","resolveOptions","options","fix","check","CommandError","npm","pnpm","yarn","filter","Boolean","length","argv","variadic","extras","flags","parseVariadicArguments","assertUnexpectedObjectKeys"],"mappings":"AAAA;;;;QA0BsBA,gBAAgB,GAAhBA,gBAAgB;AAxBT,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACqB,IAAA,SAAmB,WAAnB,mBAAmB,CAAA;AAWtF,SAASC,cAAc,CAACC,OAAgB,EAAW;IACjD,IAAIA,OAAO,CAACC,GAAG,IAAID,OAAO,CAACE,KAAK,EAAE;QAChC,MAAM,IAAIC,OAAY,aAAA,CAAC,UAAU,EAAE,wCAAwC,CAAC,CAAC;KAC9E;IACD,IAAI;QAACH,OAAO,CAACI,GAAG;QAAEJ,OAAO,CAACK,IAAI;QAAEL,OAAO,CAACM,IAAI;KAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;QACxE,MAAM,IAAIN,OAAY,aAAA,CAAC,UAAU,EAAE,+CAA+C,CAAC,CAAC;KACrF;IACD,OAAO;QACL,GAAGH,OAAO;KACX,CAAC;CACH;AAEM,eAAeF,gBAAgB,CACpCY,IAAc,EACuD;IACrE,MAAM,EAAEC,QAAQ,CAAA,EAAEC,MAAM,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGC,CAAAA,GAAAA,SAAsB,AAAM,CAAA,uBAAN,CAACJ,IAAI,CAAC,AAAC;IAEjEK,CAAAA,GAAAA,SAA0B,AAA0D,CAAA,2BAA1D,CAAC;QAAC,SAAS;QAAE,OAAO;QAAE,OAAO;QAAE,QAAQ;QAAE,QAAQ;KAAC,EAAEF,KAAK,CAAC,CAAC;IAErF,OAAO;QACL,uFAAuF;QACvFF,QAAQ;QACRX,OAAO,EAAED,cAAc,CAAC;YACtBE,GAAG,EAAE,CAAC,CAACY,KAAK,CAAC,OAAO,CAAC;YACrBX,KAAK,EAAE,CAAC,CAACW,KAAK,CAAC,SAAS,CAAC;YACzBP,IAAI,EAAE,CAAC,CAACO,KAAK,CAAC,QAAQ,CAAC;YACvBT,GAAG,EAAE,CAAC,CAACS,KAAK,CAAC,OAAO,CAAC;YACrBR,IAAI,EAAE,CAAC,CAACQ,KAAK,CAAC,QAAQ,CAAC;SACxB,CAAC;QACFD,MAAM;KACP,CAAC;CACH"}
|
|
@@ -6,29 +6,8 @@ exports.getNamedPlugins = getNamedPlugins;
|
|
|
6
6
|
exports.autoAddConfigPluginsAsync = autoAddConfigPluginsAsync;
|
|
7
7
|
var _pluginResolver = require("@expo/config-plugins/build/utils/plugin-resolver");
|
|
8
8
|
var _prebuildConfig = require("@expo/prebuild-config");
|
|
9
|
-
var Log = _interopRequireWildcard(require("../../log"));
|
|
10
9
|
var _modifyConfigPlugins = require("../../utils/modifyConfigPlugins");
|
|
11
|
-
|
|
12
|
-
if (obj && obj.__esModule) {
|
|
13
|
-
return obj;
|
|
14
|
-
} else {
|
|
15
|
-
var newObj = {};
|
|
16
|
-
if (obj != null) {
|
|
17
|
-
for(var key in obj){
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
19
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
20
|
-
if (desc.get || desc.set) {
|
|
21
|
-
Object.defineProperty(newObj, key, desc);
|
|
22
|
-
} else {
|
|
23
|
-
newObj[key] = obj[key];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
newObj.default = obj;
|
|
29
|
-
return newObj;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
10
|
+
const debug = require("debug")("expo:install:config-plugins");
|
|
32
11
|
const AUTO_PLUGINS = (0, _prebuildConfig).getAutoPlugins();
|
|
33
12
|
/**
|
|
34
13
|
* Resolve if a package has a config plugin.
|
|
@@ -63,10 +42,10 @@ function getNamedPlugins(plugins) {
|
|
|
63
42
|
return namedPlugins;
|
|
64
43
|
}
|
|
65
44
|
async function autoAddConfigPluginsAsync(projectRoot, exp, packages) {
|
|
66
|
-
|
|
45
|
+
debug("Checking config plugins...");
|
|
67
46
|
const currentPlugins = exp.plugins || [];
|
|
68
47
|
const normalized = getNamedPlugins(currentPlugins);
|
|
69
|
-
|
|
48
|
+
debug(`Existing plugins: ${normalized.join(", ")}`);
|
|
70
49
|
const plugins = packages.filter((pkg)=>{
|
|
71
50
|
if (normalized.includes(pkg)) {
|
|
72
51
|
// already included in plugins array
|
|
@@ -74,9 +53,9 @@ async function autoAddConfigPluginsAsync(projectRoot, exp, packages) {
|
|
|
74
53
|
}
|
|
75
54
|
// Check if the package has a valid plugin. Must be a well-made plugin for it to work with this.
|
|
76
55
|
const plugin = packageHasConfigPlugin(projectRoot, pkg);
|
|
77
|
-
|
|
56
|
+
debug(`Package "${pkg}" has plugin: ${!!plugin}` + (plugin ? ` (args: ${plugin.length})` : ""));
|
|
78
57
|
if (AUTO_PLUGINS.includes(pkg)) {
|
|
79
|
-
|
|
58
|
+
debug(`Package "${pkg}" is an auto plugin, skipping...`);
|
|
80
59
|
return false;
|
|
81
60
|
}
|
|
82
61
|
return !!plugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/install/utils/autoAddConfigPlugins.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport {\n normalizeStaticPlugin,\n resolveConfigPluginFunctionWithInfo,\n} from '@expo/config-plugins/build/utils/plugin-resolver';\nimport { getAutoPlugins } from '@expo/prebuild-config';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../src/install/utils/autoAddConfigPlugins.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport {\n normalizeStaticPlugin,\n resolveConfigPluginFunctionWithInfo,\n} from '@expo/config-plugins/build/utils/plugin-resolver';\nimport { getAutoPlugins } from '@expo/prebuild-config';\n\nimport { attemptAddingPluginsAsync } from '../../utils/modifyConfigPlugins';\n\nconst debug = require('debug')('expo:install:config-plugins') as typeof console.log;\n\nconst AUTO_PLUGINS = getAutoPlugins();\n\n/**\n * Resolve if a package has a config plugin.\n * For sanity, we'll only support config plugins that use the `app.config.js` entry file,\n * this is because a package like `lodash` could be a \"valid\" config plugin and break the prebuild process.\n *\n * @param projectRoot\n * @param packageName\n * @returns\n */\nfunction packageHasConfigPlugin(projectRoot: string, packageName: string) {\n try {\n const info = resolveConfigPluginFunctionWithInfo(projectRoot, packageName);\n if (info.isPluginFile) {\n return info.plugin;\n }\n } catch {}\n return false;\n}\n\n/**\n * Get a list of plugins that were are supplied as string module IDs.\n * @example\n * ```json\n * {\n * \"plugins\": [\n * \"expo-camera\",\n * [\"react-native-firebase\", ...]\n * ]\n * }\n * ```\n * ↓ ↓ ↓ ↓ ↓ ↓\n *\n * `['expo-camera', 'react-native-firebase']`\n *\n */\nexport function getNamedPlugins(plugins: NonNullable<ExpoConfig['plugins']>): string[] {\n const namedPlugins: string[] = [];\n for (const plugin of plugins) {\n try {\n // @ts-ignore\n const [normal] = normalizeStaticPlugin(plugin);\n if (typeof normal === 'string') {\n namedPlugins.push(normal);\n }\n } catch {\n // ignore assertions\n }\n }\n return namedPlugins;\n}\n\n/** Attempts to ensure that non-auto plugins are added to the `app.json` `plugins` array when modules with Expo Config Plugins are installed. */\nexport async function autoAddConfigPluginsAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'plugins'>,\n packages: string[]\n) {\n debug('Checking config plugins...');\n\n const currentPlugins = exp.plugins || [];\n const normalized = getNamedPlugins(currentPlugins);\n\n debug(`Existing plugins: ${normalized.join(', ')}`);\n\n const plugins = packages.filter((pkg) => {\n if (normalized.includes(pkg)) {\n // already included in plugins array\n return false;\n }\n // Check if the package has a valid plugin. Must be a well-made plugin for it to work with this.\n const plugin = packageHasConfigPlugin(projectRoot, pkg);\n\n debug(`Package \"${pkg}\" has plugin: ${!!plugin}` + (plugin ? ` (args: ${plugin.length})` : ''));\n\n if (AUTO_PLUGINS.includes(pkg)) {\n debug(`Package \"${pkg}\" is an auto plugin, skipping...`);\n return false;\n }\n\n return !!plugin;\n });\n\n await attemptAddingPluginsAsync(projectRoot, exp, plugins);\n}\n"],"names":["getNamedPlugins","autoAddConfigPluginsAsync","debug","require","AUTO_PLUGINS","getAutoPlugins","packageHasConfigPlugin","projectRoot","packageName","info","resolveConfigPluginFunctionWithInfo","isPluginFile","plugin","plugins","namedPlugins","normal","normalizeStaticPlugin","push","exp","packages","currentPlugins","normalized","join","filter","pkg","includes","length","attemptAddingPluginsAsync"],"mappings":"AAAA;;;;QAgDgBA,eAAe,GAAfA,eAAe;QAiBTC,yBAAyB,GAAzBA,yBAAyB;AA7DxC,IAAA,eAAkD,WAAlD,kDAAkD,CAAA;AAC1B,IAAA,eAAuB,WAAvB,uBAAuB,CAAA;AAEZ,IAAA,oBAAiC,WAAjC,iCAAiC,CAAA;AAE3E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6BAA6B,CAAC,AAAsB,AAAC;AAEpF,MAAMC,YAAY,GAAGC,CAAAA,GAAAA,eAAc,AAAE,CAAA,eAAF,EAAE,AAAC;AAEtC;;;;;;;;GAQG,CACH,SAASC,sBAAsB,CAACC,WAAmB,EAAEC,WAAmB,EAAE;IACxE,IAAI;QACF,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,eAAmC,AAA0B,CAAA,oCAA1B,CAACH,WAAW,EAAEC,WAAW,CAAC,AAAC;QAC3E,IAAIC,IAAI,CAACE,YAAY,EAAE;YACrB,OAAOF,IAAI,CAACG,MAAM,CAAC;SACpB;KACF,CAAC,OAAM,EAAE;IACV,OAAO,KAAK,CAAC;CACd;AAkBM,SAASZ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ItB,YAAY,CAACqB,QAAQ,CAACD,GAAG,CAAC,EAAE;YAC9BtB,KAAK,CAAC,CAAC,SAAS,EAAEsB,GAAG,CAAC,gCAAgC,CAAC,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;SACd;QAED,OAAO,CAAC,CAACZ,MAAM,CAAC;KACjB,CAAC,AAAC;IAEH,MAAMe,CAAAA,GAAAA,oBAAyB,AAA2B,CAAA,0BAA3B,CAACpB,WAAW,EAAEW,GAAG,EAAEL,OAAO,CAAC,CAAC;CAC5D"}
|
package/build/src/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import chalk from 'chalk';\n\nexport function time(label?: string): void {\n console.time(label);\n}\n\nexport function timeEnd(label?: string): void {\n console.timeEnd(label);\n}\n\nexport function error(...message: string[]): void {\n console.error(...message);\n}\n\n/** Print an error and provide additional info (the stack trace) in debug mode. */\nexport function exception(e: Error): void {\n const { env } = require('./utils/env');\n error(chalk.red(e.toString()) + (env.EXPO_DEBUG ? '\\n' + chalk.gray(e.stack) : ''));\n}\n\nexport function warn(...message: string[]): void {\n console.warn(...message.map((value) => chalk.yellow(value)));\n}\n\nexport function log(...message: string[]): void {\n console.log(...message);\n}\n\nexport function debug(...message: any[]): void {\n if (require('./utils/env').env.EXPO_DEBUG) console.log(...message);\n}\n\n/** Clear the terminal of all text. */\nexport function clear(): void {\n process.stdout.write(process.platform === 'win32' ? '\\x1B[2J\\x1B[0f' : '\\x1B[2J\\x1B[3J\\x1B[H');\n}\n\n/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */\nexport function exit(message: string | Error, code: number = 1): never {\n if (message instanceof Error) {\n exception(message);\n process.exit(code);\n }\n\n if (message) {\n if (code === 0) {\n log(message);\n } else {\n error(message);\n }\n }\n\n process.exit(code);\n}\n\n// The re-export makes auto importing easier.\nexport const Log = {\n time,\n timeEnd,\n error,\n exception,\n warn,\n log,\n debug,\n clear,\n exit,\n};\n"],"names":["time","timeEnd","error","exception","warn","log","debug","clear","exit","label","console","message","e","env","require","chalk","red","toString","EXPO_DEBUG","gray","stack","map","value","yellow","process","stdout","write","platform","code","Error","Log"],"mappings":"AAAA;;;;QAEgBA,IAAI,GAAJA,IAAI;QAIJC,OAAO,GAAPA,OAAO;QAIPC,KAAK,GAALA,KAAK;QAKLC,SAAS,GAATA,SAAS;QAKTC,IAAI,GAAJA,IAAI;QAIJC,GAAG,GAAHA,GAAG;
|
|
1
|
+
{"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import chalk from 'chalk';\n\nexport function time(label?: string): void {\n console.time(label);\n}\n\nexport function timeEnd(label?: string): void {\n console.timeEnd(label);\n}\n\nexport function error(...message: string[]): void {\n console.error(...message);\n}\n\n/** Print an error and provide additional info (the stack trace) in debug mode. */\nexport function exception(e: Error): void {\n const { env } = require('./utils/env');\n error(chalk.red(e.toString()) + (env.EXPO_DEBUG ? '\\n' + chalk.gray(e.stack) : ''));\n}\n\nexport function warn(...message: string[]): void {\n console.warn(...message.map((value) => chalk.yellow(value)));\n}\n\nexport function log(...message: string[]): void {\n console.log(...message);\n}\n\n/** @deprecated use `debug` package with the `expo:` prefix instead. */\nexport function debug(...message: any[]): void {\n if (require('./utils/env').env.EXPO_DEBUG) console.log(...message);\n}\n\n/** Clear the terminal of all text. */\nexport function clear(): void {\n process.stdout.write(process.platform === 'win32' ? '\\x1B[2J\\x1B[0f' : '\\x1B[2J\\x1B[3J\\x1B[H');\n}\n\n/** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */\nexport function exit(message: string | Error, code: number = 1): never {\n if (message instanceof Error) {\n exception(message);\n process.exit(code);\n }\n\n if (message) {\n if (code === 0) {\n log(message);\n } else {\n error(message);\n }\n }\n\n process.exit(code);\n}\n\n// The re-export makes auto importing easier.\nexport const Log = {\n time,\n timeEnd,\n error,\n exception,\n warn,\n log,\n debug,\n clear,\n exit,\n};\n"],"names":["time","timeEnd","error","exception","warn","log","debug","clear","exit","label","console","message","e","env","require","chalk","red","toString","EXPO_DEBUG","gray","stack","map","value","yellow","process","stdout","write","platform","code","Error","Log"],"mappings":"AAAA;;;;QAEgBA,IAAI,GAAJA,IAAI;QAIJC,OAAO,GAAPA,OAAO;QAIPC,KAAK,GAALA,KAAK;QAKLC,SAAS,GAATA,SAAS;QAKTC,IAAI,GAAJA,IAAI;QAIJC,GAAG,GAAHA,GAAG;QAKHC,KAAK,GAALA,KAAK;QAKLC,KAAK,GAALA,KAAK;QAKLC,IAAI,GAAJA,IAAI;;AAvCF,IAAA,MAAO,kCAAP,OAAO,EAAA;;;;;;AAElB,SAASR,IAAI,CAACS,KAAc,EAAQ;IACzCC,OAAO,CAACV,IAAI,CAACS,KAAK,CAAC,CAAC;CACrB;AAEM,SAASR,OAAO,CAACQ,KAAc,EAAQ;IAC5CC,OAAO,CAACT,OAAO,CAACQ,KAAK,CAAC,CAAC;CACxB;AAEM,SAASP,KAAK,CAAC,GAAGS,OAAO,AAAU,EAAQ;IAChDD,OAAO,CAACR,KAAK,IAAIS,OAAO,CAAC,CAAC;CAC3B;AAGM,SAASR,SAAS,CAACS,CAAQ,EAAQ;IACxC,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGC,OAAO,CAAC,aAAa,CAAC,AAAC;IACvCZ,KAAK,CAACa,MAAK,QAAA,CAACC,GAAG,CAACJ,CAAC,CAACK,QAAQ,EAAE,CAAC,GAAG,CAACJ,GAAG,CAACK,UAAU,GAAG,IAAI,GAAGH,MAAK,QAAA,CAACI,IAAI,CAACP,CAAC,CAACQ,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;CACrF;AAEM,SAAShB,IAAI,CAAC,GAAGO,OAAO,AAAU,EAAQ;IAC/CD,OAAO,CAACN,IAAI,IAAIO,OAAO,CAACU,GAAG,CAAC,CAACC,KAAK,GAAKP,MAAK,QAAA,CAACQ,MAAM,CAACD,KAAK,CAAC;IAAA,CAAC,CAAC,CAAC;CAC9D;AAEM,SAASjB,GAAG,CAAC,GAAGM,OAAO,AAAU,EAAQ;IAC9CD,OAAO,CAACL,GAAG,IAAIM,OAAO,CAAC,CAAC;CACzB;AAGM,SAASL,KAAK,CAAC,GAAGK,OAAO,AAAO,EAAQ;IAC7C,IAAIG,OAAO,CAAC,aAAa,CAAC,CAACD,GAAG,CAACK,UAAU,EAAER,OAAO,CAACL,GAAG,IAAIM,OAAO,CAAC,CAAC;CACpE;AAGM,SAASJ,KAAK,GAAS;IAC5BiB,OAAO,CAACC,MAAM,CAACC,KAAK,CAACF,OAAO,CAACG,QAAQ,KAAK,OAAO,GAAG,gBAAgB,GAAG,sBAAsB,CAAC,CAAC;CAChG;AAGM,SAASnB,IAAI,CAACG,OAAuB,EAAEiB,IAAY,GAAG,CAAC,EAAS;IACrE,IAAIjB,OAAO,YAAYkB,KAAK,EAAE;QAC5B1B,SAAS,CAACQ,OAAO,CAAC,CAAC;QACnBa,OAAO,CAAChB,IAAI,CAACoB,IAAI,CAAC,CAAC;KACpB;IAED,IAAIjB,OAAO,EAAE;QACX,IAAIiB,IAAI,KAAK,CAAC,EAAE;YACdvB,GAAG,CAACM,OAAO,CAAC,CAAC;SACd,MAAM;YACLT,KAAK,CAACS,OAAO,CAAC,CAAC;SAChB;KACF;IAEDa,OAAO,CAAChB,IAAI,CAACoB,IAAI,CAAC,CAAC;CACpB;AAGM,MAAME,GAAG,GAAG;IACjB9B,IAAI;IACJC,OAAO;IACPC,KAAK;IACLC,SAAS;IACTC,IAAI;IACJC,GAAG;IACHC,KAAK;IACLC,KAAK;IACLC,IAAI;CACL,AAAC;QAVWsB,GAAG,GAAHA,GAAG"}
|
|
@@ -9,7 +9,6 @@ var _paths = require("@expo/config/paths");
|
|
|
9
9
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
10
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
11
|
var _path = _interopRequireDefault(require("path"));
|
|
12
|
-
var Log = _interopRequireWildcard(require("../log"));
|
|
13
12
|
var _dir = require("../utils/dir");
|
|
14
13
|
var _mergeGitIgnorePaths = require("../utils/mergeGitIgnorePaths");
|
|
15
14
|
var _updatePackageJson = require("./updatePackageJson");
|
|
@@ -18,27 +17,7 @@ function _interopRequireDefault(obj) {
|
|
|
18
17
|
default: obj
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
if (obj && obj.__esModule) {
|
|
23
|
-
return obj;
|
|
24
|
-
} else {
|
|
25
|
-
var newObj = {};
|
|
26
|
-
if (obj != null) {
|
|
27
|
-
for(var key in obj){
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
29
|
-
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
|
30
|
-
if (desc.get || desc.set) {
|
|
31
|
-
Object.defineProperty(newObj, key, desc);
|
|
32
|
-
} else {
|
|
33
|
-
newObj[key] = obj[key];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
newObj.default = obj;
|
|
39
|
-
return newObj;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
20
|
+
const debug = require("debug")("expo:prebuild:copyTemplateFiles");
|
|
42
21
|
/**
|
|
43
22
|
* Return true if the given platforms all have an internal `.gitignore` file.
|
|
44
23
|
*
|
|
@@ -70,7 +49,7 @@ async function copyTemplateFilesAsync(projectRoot, { pkg , templateDirectory , p
|
|
|
70
49
|
copyFilePaths
|
|
71
50
|
});
|
|
72
51
|
const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(templateDirectory, platforms);
|
|
73
|
-
|
|
52
|
+
debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);
|
|
74
53
|
const gitignore = hasPlatformSpecificGitIgnores ? null : (0, _mergeGitIgnorePaths).mergeGitIgnorePaths(_path.default.join(projectRoot, ".gitignore"), _path.default.join(templateDirectory, ".gitignore"));
|
|
75
54
|
return {
|
|
76
55
|
...copyResults,
|
|
@@ -89,6 +68,8 @@ async function copyPathsFromTemplateAsync(/** File path to the project. */ proje
|
|
|
89
68
|
skippedPaths.push(copyFilePath);
|
|
90
69
|
}
|
|
91
70
|
}
|
|
71
|
+
debug(`Copied files:`, copiedPaths);
|
|
72
|
+
debug(`Skipped files:`, copiedPaths);
|
|
92
73
|
return {
|
|
93
74
|
copiedPaths,
|
|
94
75
|
skippedPaths
|
|
@@ -103,6 +84,7 @@ async function copyPathsFromTemplateAsync(/** File path to the project. */ proje
|
|
|
103
84
|
if (!bareEntryFile) {
|
|
104
85
|
targetPaths.push("index.js");
|
|
105
86
|
}
|
|
87
|
+
debug(`Files to copy:`, targetPaths);
|
|
106
88
|
return targetPaths;
|
|
107
89
|
}
|
|
108
90
|
function resolveBareEntryFile(projectRoot, main) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/copyTemplateFiles.ts"],"sourcesContent":["import { PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport { MergeResults } from '@expo/config-plugins/build/utils/generateCode';\nimport { getBareExtensions, getFileWithExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { copySync, directoryExistsAsync } from '../utils/dir';\nimport { mergeGitIgnorePaths } from '../utils/mergeGitIgnorePaths';\nimport { isPkgMainExpoAppEntry } from './updatePackageJson';\n\ntype CopyFilesResults = {\n /** Merge results for the root `.gitignore` file */\n gitignore: MergeResults | null;\n /** List of file paths that were copied from the template into the project. */\n copiedPaths: string[];\n /** List of file paths that were skipped due to a number of factors. */\n skippedPaths: string[];\n};\n\n/**\n * Return true if the given platforms all have an internal `.gitignore` file.\n *\n * @param projectRoot\n * @param platforms\n */\nfunction hasAllPlatformSpecificGitIgnores(projectRoot: string, platforms: ModPlatform[]): boolean {\n return platforms.reduce<boolean>(\n (p, platform) => p && fs.existsSync(path.join(projectRoot, platform, '.gitignore')),\n true\n );\n}\n\n/** Create a custom log message based on the copy file results. */\nexport function createCopyFilesSuccessMessage(\n platforms: ModPlatform[],\n { skippedPaths, gitignore }: CopyFilesResults\n): string {\n let message = `Created native project${platforms.length > 1 ? 's' : ''}`;\n\n if (skippedPaths.length) {\n message += chalk.dim(\n ` | ${skippedPaths.map((path) => chalk.bold(`/${path}`)).join(', ')} already created`\n );\n }\n if (!gitignore) {\n message += chalk.dim(` | gitignore skipped`);\n } else if (!gitignore.didMerge) {\n message += chalk.dim(` | gitignore already synced`);\n } else if (gitignore.didMerge && gitignore.didClear) {\n message += chalk.dim(` | synced gitignore`);\n }\n return message;\n}\n\n/** Copy template files into the project and possibly merge the `.gitignore` files. */\nexport async function copyTemplateFilesAsync(\n projectRoot: string,\n {\n pkg,\n templateDirectory,\n platforms,\n }: {\n /** Project `package.json` as JSON. */\n pkg: PackageJSONConfig;\n /** File path to the template directory. */\n templateDirectory: string;\n /** List of platforms to copy against. */\n platforms: ModPlatform[];\n }\n): Promise<CopyFilesResults> {\n const copyFilePaths = getFilePathsToCopy(projectRoot, pkg, platforms);\n\n const copyResults = await copyPathsFromTemplateAsync(projectRoot, {\n templateDirectory,\n copyFilePaths,\n });\n\n const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(\n templateDirectory,\n platforms\n );\n Log.debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);\n const gitignore = hasPlatformSpecificGitIgnores\n ? null\n : mergeGitIgnorePaths(\n path.join(projectRoot, '.gitignore'),\n path.join(templateDirectory, '.gitignore')\n );\n\n return { ...copyResults, gitignore };\n}\n\nasync function copyPathsFromTemplateAsync(\n /** File path to the project. */\n projectRoot: string,\n {\n templateDirectory,\n copyFilePaths,\n }: {\n /** File path to the template project. */\n templateDirectory: string;\n /** List of relative paths to copy from the template to the project. */\n copyFilePaths: string[];\n }\n): Promise<Pick<CopyFilesResults, 'copiedPaths' | 'skippedPaths'>> {\n const copiedPaths = [];\n const skippedPaths = [];\n for (const copyFilePath of copyFilePaths) {\n const projectPath = path.join(projectRoot, copyFilePath);\n if (!(await directoryExistsAsync(projectPath))) {\n copiedPaths.push(copyFilePath);\n copySync(path.join(templateDirectory, copyFilePath), projectPath);\n } else {\n skippedPaths.push(copyFilePath);\n }\n }\n return { copiedPaths, skippedPaths };\n}\n\n/** Get a list of relative file paths to copy from the template folder. Example: `['ios', 'android', 'index.js']` */\nfunction getFilePathsToCopy(projectRoot: string, pkg: PackageJSONConfig, platforms: ModPlatform[]) {\n const targetPaths: string[] = [...platforms];\n\n const bareEntryFile = resolveBareEntryFile(projectRoot, pkg.main);\n // Only create index.js if we cannot resolve the existing entry point (after replacing the expo entry).\n if (!bareEntryFile) {\n targetPaths.push('index.js');\n }\n\n return targetPaths;\n}\n\nexport function resolveBareEntryFile(projectRoot: string, main: any) {\n // expo app entry is not needed for bare projects.\n if (isPkgMainExpoAppEntry(main)) {\n return null;\n }\n // Look at the `package.json`s `main` field for the main file.\n const resolvedMainField = main ?? './index';\n // Get a list of possible extensions for the main file.\n const extensions = getBareExtensions(['ios', 'android']);\n // Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path.\n return getFileWithExtensions(projectRoot, resolvedMainField, extensions);\n}\n"],"names":["createCopyFilesSuccessMessage","copyTemplateFilesAsync","resolveBareEntryFile","Log","hasAllPlatformSpecificGitIgnores","projectRoot","platforms","reduce","p","platform","fs","existsSync","path","join","skippedPaths","gitignore","message","length","chalk","dim","map","bold","didMerge","didClear","pkg","templateDirectory","copyFilePaths","getFilePathsToCopy","copyResults","copyPathsFromTemplateAsync","hasPlatformSpecificGitIgnores","debug","mergeGitIgnorePaths","copiedPaths","copyFilePath","projectPath","directoryExistsAsync","push","copySync","targetPaths","bareEntryFile","main","isPkgMainExpoAppEntry","resolvedMainField","extensions","getBareExtensions","getFileWithExtensions"],"mappings":"AAAA;;;;QAoCgBA,6BAA6B,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AC,EAAE;QAC/B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,MAAME,iBAAiB,GAAGF,IAAI,WAAJA,IAAI,GAAI,SAAS,AAAC;IAC5C,uDAAuD;IACvD,MAAMG,UAAU,GAAGC,CAAAA,GAAAA,MAAiB,AAAoB,CAAA,kBAApB,CAAC;QAAC,KAAK;QAAE,SAAS;KAAC,CAAC,AAAC;IACzD,oOAAoO;IACpO,OAAOC,CAAAA,GAAAA,MAAqB,AAA4C,CAAA,sBAA5C,CAACzC,WAAW,EAAEsC,iBAAiB,EAAEC,UAAU,CAAC,CAAC;CAC1E"}
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/copyTemplateFiles.ts"],"sourcesContent":["import { PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport { MergeResults } from '@expo/config-plugins/build/utils/generateCode';\nimport { getBareExtensions, getFileWithExtensions } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { copySync, directoryExistsAsync } from '../utils/dir';\nimport { mergeGitIgnorePaths } from '../utils/mergeGitIgnorePaths';\nimport { isPkgMainExpoAppEntry } from './updatePackageJson';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\ntype CopyFilesResults = {\n /** Merge results for the root `.gitignore` file */\n gitignore: MergeResults | null;\n /** List of file paths that were copied from the template into the project. */\n copiedPaths: string[];\n /** List of file paths that were skipped due to a number of factors. */\n skippedPaths: string[];\n};\n\n/**\n * Return true if the given platforms all have an internal `.gitignore` file.\n *\n * @param projectRoot\n * @param platforms\n */\nfunction hasAllPlatformSpecificGitIgnores(projectRoot: string, platforms: ModPlatform[]): boolean {\n return platforms.reduce<boolean>(\n (p, platform) => p && fs.existsSync(path.join(projectRoot, platform, '.gitignore')),\n true\n );\n}\n\n/** Create a custom log message based on the copy file results. */\nexport function createCopyFilesSuccessMessage(\n platforms: ModPlatform[],\n { skippedPaths, gitignore }: CopyFilesResults\n): string {\n let message = `Created native project${platforms.length > 1 ? 's' : ''}`;\n\n if (skippedPaths.length) {\n message += chalk.dim(\n ` | ${skippedPaths.map((path) => chalk.bold(`/${path}`)).join(', ')} already created`\n );\n }\n if (!gitignore) {\n message += chalk.dim(` | gitignore skipped`);\n } else if (!gitignore.didMerge) {\n message += chalk.dim(` | gitignore already synced`);\n } else if (gitignore.didMerge && gitignore.didClear) {\n message += chalk.dim(` | synced gitignore`);\n }\n return message;\n}\n\n/** Copy template files into the project and possibly merge the `.gitignore` files. */\nexport async function copyTemplateFilesAsync(\n projectRoot: string,\n {\n pkg,\n templateDirectory,\n platforms,\n }: {\n /** Project `package.json` as JSON. */\n pkg: PackageJSONConfig;\n /** File path to the template directory. */\n templateDirectory: string;\n /** List of platforms to copy against. */\n platforms: ModPlatform[];\n }\n): Promise<CopyFilesResults> {\n const copyFilePaths = getFilePathsToCopy(projectRoot, pkg, platforms);\n\n const copyResults = await copyPathsFromTemplateAsync(projectRoot, {\n templateDirectory,\n copyFilePaths,\n });\n\n const hasPlatformSpecificGitIgnores = hasAllPlatformSpecificGitIgnores(\n templateDirectory,\n platforms\n );\n debug(`All platforms have an internal gitignore: ${hasPlatformSpecificGitIgnores}`);\n const gitignore = hasPlatformSpecificGitIgnores\n ? null\n : mergeGitIgnorePaths(\n path.join(projectRoot, '.gitignore'),\n path.join(templateDirectory, '.gitignore')\n );\n\n return { ...copyResults, gitignore };\n}\n\nasync function copyPathsFromTemplateAsync(\n /** File path to the project. */\n projectRoot: string,\n {\n templateDirectory,\n copyFilePaths,\n }: {\n /** File path to the template project. */\n templateDirectory: string;\n /** List of relative paths to copy from the template to the project. */\n copyFilePaths: string[];\n }\n): Promise<Pick<CopyFilesResults, 'copiedPaths' | 'skippedPaths'>> {\n const copiedPaths = [];\n const skippedPaths = [];\n for (const copyFilePath of copyFilePaths) {\n const projectPath = path.join(projectRoot, copyFilePath);\n if (!(await directoryExistsAsync(projectPath))) {\n copiedPaths.push(copyFilePath);\n copySync(path.join(templateDirectory, copyFilePath), projectPath);\n } else {\n skippedPaths.push(copyFilePath);\n }\n }\n debug(`Copied files:`, copiedPaths);\n debug(`Skipped files:`, copiedPaths);\n return { copiedPaths, skippedPaths };\n}\n\n/** Get a list of relative file paths to copy from the template folder. Example: `['ios', 'android', 'index.js']` */\nfunction getFilePathsToCopy(projectRoot: string, pkg: PackageJSONConfig, platforms: ModPlatform[]) {\n const targetPaths: string[] = [...platforms];\n\n const bareEntryFile = resolveBareEntryFile(projectRoot, pkg.main);\n // Only create index.js if we cannot resolve the existing entry point (after replacing the expo entry).\n if (!bareEntryFile) {\n targetPaths.push('index.js');\n }\n\n debug(`Files to copy:`, targetPaths);\n return targetPaths;\n}\n\nexport function resolveBareEntryFile(projectRoot: string, main: any) {\n // expo app entry is not needed for bare projects.\n if (isPkgMainExpoAppEntry(main)) {\n return null;\n }\n // Look at the `package.json`s `main` field for the main file.\n const resolvedMainField = main ?? './index';\n // Get a list of possible extensions for the main file.\n const extensions = getBareExtensions(['ios', 'android']);\n // Testing the main field against all of the provided extensions - for legacy reasons we can't use node module resolution as the package.json allows you to pass in a file without a relative path and expect it as a relative path.\n return getFileWithExtensions(projectRoot, resolvedMainField, extensions);\n}\n"],"names":["createCopyFilesSuccessMessage","copyTemplateFilesAsync","resolveBareEntryFile","debug","require","hasAllPlatformSpecificGitIgnores","projectRoot","platforms","reduce","p","platform","fs","existsSync","path","join","skippedPaths","gitignore","message","length","chalk","dim","map","bold","didMerge","didClear","pkg","templateDirectory","copyFilePaths","getFilePathsToCopy","copyResults","copyPathsFromTemplateAsync","hasPlatformSpecificGitIgnores","mergeGitIgnorePaths","copiedPaths","copyFilePath","projectPath","directoryExistsAsync","push","copySync","targetPaths","bareEntryFile","main","isPkgMainExpoAppEntry","resolvedMainField","extensions","getBareExtensions","getFileWithExtensions"],"mappings":"AAAA;;;;QAqCgBA,6BAA6B,GAA7BA,6BAA6B;QAsBvBC,sBAAsB,GAAtBA,sBAAsB;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,WAAW,CAAC;CACpB;AAEM,SAASrC,oBAAoB,CAACI,WAAmB,EAAEmC,IAAS,EAAE;IACnE,kDAAkD;IAClD,IAAIC,CAAAA,GAAAA,kBAAqB,AAAM,CAAA,sBAAN,CAACD,IAAI,CAAC,EAAE;QAC/B,OAAO,IAAI,CAAC;KACb;IACD,8DAA8D;IAC9D,MAAME,iBAAiB,GAAGF,IAAI,WAAJA,IAAI,GAAI,SAAS,AAAC;IAC5C,uDAAuD;IACvD,MAAMG,UAAU,GAAGC,CAAAA,GAAAA,MAAiB,AAAoB,CAAA,kBAApB,CAAC;QAAC,KAAK;QAAE,SAAS;KAAC,CAAC,AAAC;IACzD,oOAAoO;IACpO,OAAOC,CAAAA,GAAAA,MAAqB,AAA4C,CAAA,sBAA5C,CAACxC,WAAW,EAAEqC,iBAAiB,EAAEC,UAAU,CAAC,CAAC;CAC1E"}
|
|
@@ -38,6 +38,8 @@ const expoPrebuild = async (argv)=>{
|
|
|
38
38
|
"--help": Boolean,
|
|
39
39
|
"--clean": Boolean,
|
|
40
40
|
"--npm": Boolean,
|
|
41
|
+
"--pnpm": Boolean,
|
|
42
|
+
"--yarn": Boolean,
|
|
41
43
|
"--no-install": Boolean,
|
|
42
44
|
"--template": String,
|
|
43
45
|
"--platform": String,
|
|
@@ -52,7 +54,9 @@ const expoPrebuild = async (argv)=>{
|
|
|
52
54
|
_chalk.default`<dir> Directory of the Expo project. {dim Default: Current working directory}`,
|
|
53
55
|
`--no-install Skip installing npm packages and CocoaPods`,
|
|
54
56
|
`--clean Delete the native folders and regenerate them before applying changes`,
|
|
55
|
-
_chalk.default`--npm Use npm to install dependencies. {dim Default when
|
|
57
|
+
_chalk.default`--npm Use npm to install dependencies. {dim Default when package-lock.json exists}`,
|
|
58
|
+
_chalk.default`--yarn Use Yarn to install dependencies. {dim Default when yarn.lock exists}`,
|
|
59
|
+
_chalk.default`--pnpm Use pnpm to install dependencies. {dim Default when pnpm-lock.yaml exists}`,
|
|
56
60
|
`--template <template> Project template to clone from. File path pointing to a local tar file or a github repo`,
|
|
57
61
|
_chalk.default`-p, --platform <all|android|ios> Platforms to sync: ios, android, all. {dim Default: all}`,
|
|
58
62
|
`--skip-dependency-update <dependencies> Preserves versions of listed packages in package.json (comma separated list)`,
|
|
@@ -62,7 +66,7 @@ const expoPrebuild = async (argv)=>{
|
|
|
62
66
|
// Load modules after the help prompt so `npx expo prebuild -h` shows as fast as possible.
|
|
63
67
|
const [// ./prebuildAsync
|
|
64
68
|
{ prebuildAsync }, // ./resolveOptions
|
|
65
|
-
{ resolvePlatformOption , resolveSkipDependencyUpdate }, // ../utils/errors
|
|
69
|
+
{ resolvePlatformOption , resolvePackageManagerOptions , resolveSkipDependencyUpdate }, // ../utils/errors
|
|
66
70
|
{ logCmdError }, ] = await Promise.all([
|
|
67
71
|
Promise.resolve().then(function() {
|
|
68
72
|
return _interopRequireWildcard(require("./prebuildAsync"));
|
|
@@ -74,16 +78,18 @@ const expoPrebuild = async (argv)=>{
|
|
|
74
78
|
return _interopRequireWildcard(require("../utils/errors"));
|
|
75
79
|
}),
|
|
76
80
|
]);
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
return (()=>{
|
|
82
|
+
return prebuildAsync((0, _args).getProjectRoot(args), {
|
|
83
|
+
// Parsed options
|
|
84
|
+
clean: args["--clean"],
|
|
85
|
+
packageManager: resolvePackageManagerOptions(args),
|
|
86
|
+
install: !args["--no-install"],
|
|
87
|
+
platforms: resolvePlatformOption(args["--platform"]),
|
|
88
|
+
// TODO: Parse
|
|
89
|
+
skipDependencyUpdate: resolveSkipDependencyUpdate(args["--skip-dependency-update"]),
|
|
90
|
+
template: args["--template"]
|
|
91
|
+
});
|
|
92
|
+
})().catch(logCmdError);
|
|
87
93
|
};
|
|
88
94
|
exports.expoPrebuild = expoPrebuild;
|
|
89
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\n\nexport const expoPrebuild: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clean': Boolean,\n '--npm': Boolean,\n '--no-install': Boolean,\n '--template': String,\n '--platform': String,\n '--skip-dependency-update': String,\n // Aliases\n '-h': '--help',\n '-p': '--platform',\n '-t': '--type',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Create native iOS and Android project files for building natively`,\n chalk`npx expo prebuild {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n `--no-install Skip installing npm packages and CocoaPods`,\n `--clean Delete the native folders and regenerate them before applying changes`,\n chalk`--npm Use npm to install dependencies. {dim Default when Yarn
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\n\nexport const expoPrebuild: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clean': Boolean,\n '--npm': Boolean,\n '--pnpm': Boolean,\n '--yarn': Boolean,\n '--no-install': Boolean,\n '--template': String,\n '--platform': String,\n '--skip-dependency-update': String,\n // Aliases\n '-h': '--help',\n '-p': '--platform',\n '-t': '--type',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Create native iOS and Android project files for building natively`,\n chalk`npx expo prebuild {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n `--no-install Skip installing npm packages and CocoaPods`,\n `--clean Delete the native folders and regenerate them before applying changes`,\n chalk`--npm Use npm to install dependencies. {dim Default when package-lock.json exists}`,\n chalk`--yarn Use Yarn to install dependencies. {dim Default when yarn.lock exists}`,\n chalk`--pnpm Use pnpm to install dependencies. {dim Default when pnpm-lock.yaml exists}`,\n `--template <template> Project template to clone from. File path pointing to a local tar file or a github repo`,\n chalk`-p, --platform <all|android|ios> Platforms to sync: ios, android, all. {dim Default: all}`,\n `--skip-dependency-update <dependencies> Preserves versions of listed packages in package.json (comma separated list)`,\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n // Load modules after the help prompt so `npx expo prebuild -h` shows as fast as possible.\n const [\n // ./prebuildAsync\n { prebuildAsync },\n // ./resolveOptions\n { resolvePlatformOption, resolvePackageManagerOptions, resolveSkipDependencyUpdate },\n // ../utils/errors\n { logCmdError },\n ] = await Promise.all([\n import('./prebuildAsync'),\n import('./resolveOptions'),\n import('../utils/errors'),\n ]);\n\n return (() => {\n return prebuildAsync(getProjectRoot(args), {\n // Parsed options\n clean: args['--clean'],\n\n packageManager: resolvePackageManagerOptions(args),\n install: !args['--no-install'],\n platforms: resolvePlatformOption(args['--platform']),\n // TODO: Parse\n skipDependencyUpdate: resolveSkipDependencyUpdate(args['--skip-dependency-update']),\n template: args['--template'],\n });\n })().catch(logCmdError);\n};\n"],"names":["expoPrebuild","argv","args","assertArgs","Boolean","String","printHelp","chalk","join","prebuildAsync","resolvePlatformOption","resolvePackageManagerOptions","resolveSkipDependencyUpdate","logCmdError","Promise","all","getProjectRoot","clean","packageManager","install","platforms","skipDependencyUpdate","template","catch"],"mappings":"AAAA;;;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAG6B,IAAA,KAAe,WAAf,eAAe,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9D,MAAMA,YAAY,GAAY,OAAOC,IAAI,GAAK;IACnD,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAU,AAkBtB,CAAA,WAlBsB,CACrB;QACE,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,SAAS,EAAEA,OAAO;QAClB,OAAO,EAAEA,OAAO;QA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KAAc,AAAM,CAAA,eAAN,CAACd,IAAI,CAAC,EAAE;YACzC,iBAAiB;YACjBe,KAAK,EAAEf,IAAI,CAAC,SAAS,CAAC;YAEtBgB,cAAc,EAAEP,4BAA4B,CAACT,IAAI,CAAC;YAClDiB,OAAO,EAAE,CAACjB,IAAI,CAAC,cAAc,CAAC;YAC9BkB,SAAS,EAAEV,qBAAqB,CAACR,IAAI,CAAC,YAAY,CAAC,CAAC;YACpD,cAAc;YACdmB,oBAAoB,EAAET,2BAA2B,CAACV,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACnFoB,QAAQ,EAAEpB,IAAI,CAAC,YAAY,CAAC;SAC7B,CAAC,CAAC;KACJ,CAAC,EAAE,CAACqB,KAAK,CAACV,WAAW,CAAC,CAAC;CACzB,AAAC;QAnEWb,YAAY,GAAZA,YAAY"}
|
|
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.prebuildAsync = prebuildAsync;
|
|
6
|
-
var
|
|
6
|
+
var _installAsync = require("../install/installAsync");
|
|
7
|
+
var _env = require("../utils/env");
|
|
7
8
|
var _nodeModules = require("../utils/nodeModules");
|
|
8
9
|
var _ora = require("../utils/ora");
|
|
9
10
|
var _profile = require("../utils/profile");
|
|
@@ -33,6 +34,7 @@ function _interopRequireWildcard(obj) {
|
|
|
33
34
|
return newObj;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
37
|
+
const debug = require("debug")("expo:prebuild");
|
|
36
38
|
async function prebuildAsync(projectRoot, options) {
|
|
37
39
|
if (options.clean) {
|
|
38
40
|
const { maybeBailOnGitStatusAsync } = await Promise.resolve().then(function() {
|
|
@@ -65,16 +67,14 @@ async function prebuildAsync(projectRoot, options) {
|
|
|
65
67
|
skipDependencyUpdate: options.skipDependencyUpdate
|
|
66
68
|
});
|
|
67
69
|
// Install node modules
|
|
68
|
-
const packageManager = (0, _nodeModules).resolvePackageManager({
|
|
69
|
-
install: options.install,
|
|
70
|
-
npm: options.packageManager === "npm",
|
|
71
|
-
yarn: options.packageManager === "yarn"
|
|
72
|
-
});
|
|
73
70
|
if (options.install) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
var ref;
|
|
72
|
+
if (hasNewDependencies && ((ref = options.packageManager) == null ? void 0 : ref.npm)) {
|
|
73
|
+
await (0, _nodeModules).clearNodeModulesAsync(projectRoot);
|
|
74
|
+
}
|
|
75
|
+
await (0, _installAsync).installAsync([], {
|
|
76
|
+
...options.packageManager,
|
|
77
|
+
silent: !_env.env.EXPO_DEBUG
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
// Apply Expo config to native projects
|
|
@@ -97,10 +97,9 @@ async function prebuildAsync(projectRoot, options) {
|
|
|
97
97
|
});
|
|
98
98
|
podsInstalled = await installCocoaPodsAsync(projectRoot);
|
|
99
99
|
} else {
|
|
100
|
-
|
|
100
|
+
debug("Skipped pod install");
|
|
101
101
|
}
|
|
102
102
|
return {
|
|
103
|
-
packageManager,
|
|
104
103
|
nodeInstall: !!options.install,
|
|
105
104
|
podInstall: !podsInstalled,
|
|
106
105
|
platforms: options.platforms,
|