@expo/cli 0.1.0 → 0.1.3

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.
Files changed (113) hide show
  1. package/build/bin/cli +38 -11
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/config/index.js +7 -17
  4. package/build/src/config/index.js.map +1 -1
  5. package/build/src/export/createBundles.js +62 -0
  6. package/build/src/export/createBundles.js.map +1 -0
  7. package/build/src/export/createMetadataJson.js +36 -0
  8. package/build/src/export/createMetadataJson.js.map +1 -0
  9. package/build/src/export/exportApp.js +102 -0
  10. package/build/src/export/exportApp.js.map +1 -0
  11. package/build/src/export/exportAssets.js +106 -0
  12. package/build/src/export/exportAssets.js.map +1 -0
  13. package/build/src/export/exportAsync.js +49 -0
  14. package/build/src/export/exportAsync.js.map +1 -0
  15. package/build/src/export/fork-bundleAsync.js +138 -0
  16. package/build/src/export/fork-bundleAsync.js.map +1 -0
  17. package/build/src/export/getPublicExpoManifest.js +28 -0
  18. package/build/src/export/getPublicExpoManifest.js.map +1 -0
  19. package/build/src/export/getResolvedLocales.js +35 -0
  20. package/build/src/export/getResolvedLocales.js.map +1 -0
  21. package/build/src/export/index.js +77 -0
  22. package/build/src/export/index.js.map +1 -0
  23. package/build/src/export/printBundleSizes.js +122 -0
  24. package/build/src/export/printBundleSizes.js.map +1 -0
  25. package/build/src/export/resolveOptions.js +24 -0
  26. package/build/src/export/resolveOptions.js.map +1 -0
  27. package/build/src/export/saveAssets.js +65 -0
  28. package/build/src/export/saveAssets.js.map +1 -0
  29. package/build/src/export/writeContents.js +108 -0
  30. package/build/src/export/writeContents.js.map +1 -0
  31. package/build/src/install/index.js +13 -40
  32. package/build/src/install/index.js.map +1 -1
  33. package/build/src/login/index.js +6 -20
  34. package/build/src/login/index.js.map +1 -1
  35. package/build/src/logout/index.js +2 -17
  36. package/build/src/logout/index.js.map +1 -1
  37. package/build/src/prebuild/index.js +10 -21
  38. package/build/src/prebuild/index.js.map +1 -1
  39. package/build/src/prebuild/prebuildAsync.js +1 -1
  40. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  41. package/build/src/register/index.js +2 -17
  42. package/build/src/register/index.js.map +1 -1
  43. package/build/src/run/android/index.js +97 -0
  44. package/build/src/run/android/index.js.map +1 -0
  45. package/build/src/run/android/resolveDevice.js +23 -0
  46. package/build/src/run/android/resolveDevice.js.map +1 -0
  47. package/build/src/run/android/resolveGradleProps.js +37 -0
  48. package/build/src/run/android/resolveGradleProps.js.map +1 -0
  49. package/build/src/run/android/resolveInstallApkName.js +72 -0
  50. package/build/src/run/android/resolveInstallApkName.js.map +1 -0
  51. package/build/src/run/android/resolveLaunchProps.js +32 -0
  52. package/build/src/run/android/resolveLaunchProps.js.map +1 -0
  53. package/build/src/run/android/resolveOptions.js +25 -0
  54. package/build/src/run/android/resolveOptions.js.map +1 -0
  55. package/build/src/run/android/runAndroidAsync.js +74 -0
  56. package/build/src/run/android/runAndroidAsync.js.map +1 -0
  57. package/build/src/run/ensureNativeProject.js +33 -0
  58. package/build/src/run/ensureNativeProject.js.map +1 -0
  59. package/build/src/run/hints.js +22 -0
  60. package/build/src/run/hints.js.map +1 -0
  61. package/build/src/run/resolveBundlerProps.js +31 -0
  62. package/build/src/run/resolveBundlerProps.js.map +1 -0
  63. package/build/src/run/startBundler.js +76 -0
  64. package/build/src/run/startBundler.js.map +1 -0
  65. package/build/src/start/index.js +29 -39
  66. package/build/src/start/index.js.map +1 -1
  67. package/build/src/start/platforms/ExpoGoInstaller.js +4 -1
  68. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  69. package/build/src/start/platforms/PlatformManager.js +25 -0
  70. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  71. package/build/src/start/platforms/android/ADBServer.js +3 -1
  72. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  73. package/build/src/start/platforms/android/AndroidDeviceManager.js +13 -1
  74. package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
  75. package/build/src/start/platforms/android/activateWindow.js +2 -0
  76. package/build/src/start/platforms/android/activateWindow.js.map +1 -1
  77. package/build/src/start/platforms/android/adb.js +37 -4
  78. package/build/src/start/platforms/android/adb.js.map +1 -1
  79. package/build/src/start/platforms/android/gradle.js +86 -0
  80. package/build/src/start/platforms/android/gradle.js.map +1 -0
  81. package/build/src/start/server/BundlerDevServer.js +62 -2
  82. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  83. package/build/src/start/server/UrlCreator.js +2 -1
  84. package/build/src/start/server/UrlCreator.js.map +1 -1
  85. package/build/src/start/server/metro/MetroBundlerDevServer.js +11 -14
  86. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  87. package/build/src/start/server/metro/instantiateMetro.js +22 -9
  88. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  89. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  90. package/build/src/start/server/middleware/createDevServerMiddleware.js +2 -2
  91. package/build/src/start/server/middleware/createDevServerMiddleware.js.map +1 -1
  92. package/build/src/start/server/middleware/resolveAssets.js +4 -1
  93. package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
  94. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +10 -14
  95. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  96. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  97. package/build/src/utils/args.js +14 -0
  98. package/build/src/utils/args.js.map +1 -1
  99. package/build/src/utils/array.js +29 -0
  100. package/build/src/utils/array.js.map +1 -1
  101. package/build/src/utils/dir.js +5 -1
  102. package/build/src/utils/dir.js.map +1 -1
  103. package/build/src/utils/downloadAppAsync.js +3 -0
  104. package/build/src/utils/downloadAppAsync.js.map +1 -1
  105. package/build/src/utils/downloadExpoGoAsync.js +11 -5
  106. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  107. package/build/src/utils/env.js +3 -0
  108. package/build/src/utils/env.js.map +1 -1
  109. package/build/src/utils/resolveArgs.js +94 -0
  110. package/build/src/utils/resolveArgs.js.map +1 -0
  111. package/build/src/whoami/index.js +1 -17
  112. package/build/src/whoami/index.js.map +1 -1
  113. package/package.json +18 -13
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.bundleAsync = bundleAsync;
6
+ var _config = require("@expo/config");
7
+ var _hermesBundler = require("@expo/dev-server/build/HermesBundler");
8
+ var _importMetroFromProject = require("@expo/dev-server/build/metro/importMetroFromProject");
9
+ var _chalk = _interopRequireDefault(require("chalk"));
10
+ var _metroCore = require("metro-core");
11
+ var _metroTerminalReporter = require("../start/server/metro/MetroTerminalReporter");
12
+ function _interopRequireDefault(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function getExpoMetroConfig(projectRoot, { logger }) {
18
+ try {
19
+ return (0, _importMetroFromProject).importExpoMetroConfigFromProject(projectRoot);
20
+ } catch {
21
+ // If expo isn't installed, use the unversioned config and warn about installing expo.
22
+ }
23
+ const unversionedVersion = require("@expo/metro-config/package.json").version;
24
+ logger.info({
25
+ tag: "expo"
26
+ }, _chalk.default.gray(`\u203A Unversioned ${_chalk.default.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${_chalk.default.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`));
27
+ return require("@expo/metro-config");
28
+ }
29
+ let nextBuildID = 0;
30
+ async function bundleAsync(projectRoot, expoConfig, options, bundles) {
31
+ const metro = (0, _importMetroFromProject).importMetroFromProject(projectRoot);
32
+ const Server = (0, _importMetroFromProject).importMetroServerFromProject(projectRoot);
33
+ let reportEvent;
34
+ const terminal = new _metroCore.Terminal(process.stdout);
35
+ const terminalReporter = new _metroTerminalReporter.MetroTerminalReporter(projectRoot, terminal);
36
+ const reporter = {
37
+ update (event) {
38
+ terminalReporter.update(event);
39
+ if (reportEvent) {
40
+ reportEvent(event);
41
+ }
42
+ }
43
+ };
44
+ const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);
45
+ const config = await ExpoMetroConfig.loadAsync(projectRoot, {
46
+ reporter,
47
+ ...options
48
+ });
49
+ const buildID = `bundle_${nextBuildID++}`;
50
+ // @ts-expect-error
51
+ const metroServer = await metro.runMetro(config, {
52
+ watch: false
53
+ });
54
+ const buildAsync = async (bundle)=>{
55
+ var _dev, _minify;
56
+ const bundleOptions = {
57
+ ...Server.DEFAULT_BUNDLE_OPTIONS,
58
+ bundleType: "bundle",
59
+ platform: bundle.platform,
60
+ entryFile: bundle.entryPoint,
61
+ dev: (_dev = bundle.dev) != null ? _dev : false,
62
+ minify: (_minify = bundle.minify) != null ? _minify : !bundle.dev,
63
+ inlineSourceMap: false,
64
+ sourceMapUrl: bundle.sourceMapUrl,
65
+ createModuleIdFactory: config.serializer.createModuleIdFactory,
66
+ onProgress: (transformedFileCount, totalFileCount)=>{
67
+ if (!options.quiet) {
68
+ reporter.update({
69
+ buildID,
70
+ type: "bundle_transform_progressed",
71
+ transformedFileCount,
72
+ totalFileCount
73
+ });
74
+ }
75
+ }
76
+ };
77
+ var _dev1, _minify1;
78
+ reporter.update({
79
+ buildID,
80
+ type: "bundle_build_started",
81
+ bundleDetails: {
82
+ bundleType: bundleOptions.bundleType,
83
+ platform: bundle.platform,
84
+ entryFile: bundle.entryPoint,
85
+ dev: (_dev1 = bundle.dev) != null ? _dev1 : false,
86
+ minify: (_minify1 = bundle.minify) != null ? _minify1 : false
87
+ }
88
+ });
89
+ const { code , map } = await metroServer.build(bundleOptions);
90
+ const assets = await metroServer.getAssets(bundleOptions);
91
+ reporter.update({
92
+ buildID,
93
+ type: "bundle_build_done"
94
+ });
95
+ return {
96
+ code,
97
+ map,
98
+ assets
99
+ };
100
+ };
101
+ const maybeAddHermesBundleAsync = async (bundle, bundleOutput)=>{
102
+ const { platform } = bundle;
103
+ const isHermesManaged = (0, _hermesBundler).isEnableHermesManaged(expoConfig, platform);
104
+ const paths = (0, _config).getConfigFilePaths(projectRoot);
105
+ var _dynamicConfigPath, ref;
106
+ const configFilePath = (ref = (_dynamicConfigPath = paths.dynamicConfigPath) != null ? _dynamicConfigPath : paths.staticConfigPath) != null ? ref : "app.json";
107
+ await (0, _hermesBundler).maybeThrowFromInconsistentEngineAsync(projectRoot, configFilePath, platform, isHermesManaged);
108
+ if (isHermesManaged) {
109
+ const platformTag = _chalk.default.bold({
110
+ ios: "iOS",
111
+ android: "Android",
112
+ web: "Web"
113
+ }[platform] || platform);
114
+ options.logger.info({
115
+ tag: "expo"
116
+ }, `💿 ${platformTag} Building Hermes bytecode for the bundle`);
117
+ const hermesBundleOutput = await (0, _hermesBundler).buildHermesBundleAsync(projectRoot, bundleOutput.code, bundleOutput.map, bundle.minify);
118
+ bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;
119
+ bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;
120
+ }
121
+ return bundleOutput;
122
+ };
123
+ try {
124
+ const intermediateOutputs = await Promise.all(bundles.map((bundle)=>buildAsync(bundle)
125
+ ));
126
+ const bundleOutputs = [];
127
+ for(let i = 0; i < bundles.length; ++i){
128
+ // hermesc does not support parallel building even we spawn processes.
129
+ // we should build them sequentially.
130
+ bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));
131
+ }
132
+ return bundleOutputs;
133
+ } finally{
134
+ metroServer.end();
135
+ }
136
+ }
137
+
138
+ //# sourceMappingURL=fork-bundleAsync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import Log from '@expo/bunyan';\nimport { ExpoConfig, getConfigFilePaths } from '@expo/config';\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from '@expo/dev-server/build/HermesBundler';\nimport {\n importExpoMetroConfigFromProject,\n importMetroFromProject,\n importMetroServerFromProject,\n} from '@expo/dev-server/build/metro/importMetroFromProject';\nimport { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { MetroTerminalReporter } from '../start/server/metro/MetroTerminalReporter';\n\nexport type MetroDevServerOptions = LoadOptions & {\n logger: Log;\n quiet?: boolean;\n};\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nfunction getExpoMetroConfig(\n projectRoot: string,\n { logger }: Pick<MetroDevServerOptions, 'logger'>\n): typeof import('@expo/metro-config') {\n try {\n return importExpoMetroConfigFromProject(projectRoot);\n } catch {\n // If expo isn't installed, use the unversioned config and warn about installing expo.\n }\n\n const unversionedVersion = require('@expo/metro-config/package.json').version;\n logger.info(\n { tag: 'expo' },\n chalk.gray(\n `\\u203A Unversioned ${chalk.bold`@expo/metro-config@${unversionedVersion}`} is being used. Bundling apps may not work as expected, and is subject to breaking changes. Install ${chalk.bold`expo`} or set the app.json sdkVersion to use a stable version of @expo/metro-config.`\n )\n );\n\n return require('@expo/metro-config');\n}\n\nlet nextBuildID = 0;\n\n// Fork of @expo/dev-server bundleAsync to add Metro logging back.\n\nexport async function bundleAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n options: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n const metro = importMetroFromProject(projectRoot);\n const Server = importMetroServerFromProject(projectRoot);\n\n let reportEvent: ((event: any) => void) | undefined;\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n };\n\n const ExpoMetroConfig = getExpoMetroConfig(projectRoot, options);\n\n const config = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n const buildID = `bundle_${nextBuildID++}`;\n\n // @ts-expect-error\n const metroServer = await metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const bundleOptions: Metro.BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n bundleType: 'bundle',\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: bundle.minify ?? !bundle.dev,\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n if (!options.quiet) {\n reporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n }\n },\n };\n reporter.update({\n buildID,\n type: 'bundle_build_started',\n bundleDetails: {\n bundleType: bundleOptions.bundleType,\n platform: bundle.platform,\n entryFile: bundle.entryPoint,\n dev: bundle.dev ?? false,\n minify: bundle.minify ?? false,\n },\n });\n const { code, map } = await metroServer.build(bundleOptions);\n const assets = (await metroServer.getAssets(\n bundleOptions\n )) as readonly BundleAssetWithFileHashes[];\n reporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets };\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n options.logger.info(\n { tag: 'expo' },\n `💿 ${platformTag} Building Hermes bytecode for the bundle`\n );\n const hermesBundleOutput = await buildHermesBundleAsync(\n projectRoot,\n bundleOutput.code,\n bundleOutput.map,\n bundle.minify\n );\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } finally {\n metroServer.end();\n }\n}\n"],"names":["bundleAsync","getExpoMetroConfig","projectRoot","logger","importExpoMetroConfigFromProject","unversionedVersion","require","version","info","tag","chalk","gray","bold","nextBuildID","expoConfig","options","bundles","metro","importMetroFromProject","Server","importMetroServerFromProject","reportEvent","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","ExpoMetroConfig","config","loadAsync","buildID","metroServer","runMetro","watch","buildAsync","bundle","bundleOptions","DEFAULT_BUNDLE_OPTIONS","bundleType","platform","entryFile","entryPoint","dev","minify","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","quiet","type","bundleDetails","code","map","build","assets","getAssets","maybeAddHermesBundleAsync","bundleOutput","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","platformTag","ios","android","web","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","Promise","all","bundleOutputs","i","length","push","end"],"mappings":"AAAA;;;;QAkEsBA,WAAW,GAAXA,WAAW;AAjEc,IAAA,OAAc,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CAAC;KACrB,AAAC;IAEF,IAAI;QACF,MAAMmB,mBAAmB,GAAG,MAAMC,OAAO,CAACC,GAAG,CAACrE,OAAO,CAAC2C,GAAG,CAAC,CAACpB,MAAM,GAAKD,UAAU,CAACC,MAAM,CAAC;QAAA,CAAC,CAAC,AAAC;QAC3F,MAAM+C,aAAa,GAAmB,EAAE,AAAC;QACzC,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGvE,OAAO,CAACwE,MAAM,EAAE,EAAED,CAAC,CAAE;YACvC,sEAAsE;YACtE,qCAAqC;YACrCD,aAAa,CAACG,IAAI,CAAC,MAAM1B,yBAAyB,CAAC/C,OAAO,CAACuE,CAAC,CAAC,EAAEJ,mBAAmB,CAACI,CAAC,CAAC,CAAC,CAAC,CAAC;SACzF;QACD,OAAOD,aAAa,CAAC;KACtB,QAAS;QACRnD,WAAW,CAACuD,GAAG,EAAE,CAAC;KACnB;CACF"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.getPublicExpoManifestAsync = getPublicExpoManifestAsync;
6
+ var _config = require("@expo/config");
7
+ var _env = require("../utils/env");
8
+ var _errors = require("../utils/errors");
9
+ var _getResolvedLocales = require("./getResolvedLocales");
10
+ async function getPublicExpoManifestAsync(projectRoot) {
11
+ // Read the config in public mode which strips the `hooks`.
12
+ const { exp } = (0, _config).getConfig(projectRoot, {
13
+ isPublicConfig: true,
14
+ // This shouldn't be needed since the CLI is vendored in `expo`.
15
+ skipSDKVersionRequirement: true
16
+ });
17
+ // Only allow projects to be published with UNVERSIONED if a correct token is set in env
18
+ if (exp.sdkVersion === "UNVERSIONED" && !_env.env.EXPO_SKIP_MANIFEST_VALIDATION_TOKEN) {
19
+ throw new _errors.CommandError("INVALID_OPTIONS", "Cannot publish with sdkVersion UNVERSIONED.");
20
+ }
21
+ return {
22
+ ...exp,
23
+ locales: await (0, _getResolvedLocales).getResolvedLocalesAsync(projectRoot, exp),
24
+ sdkVersion: exp.sdkVersion
25
+ };
26
+ }
27
+
28
+ //# sourceMappingURL=getPublicExpoManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/getPublicExpoManifest.ts"],"sourcesContent":["import { ExpoAppManifest, getConfig } from '@expo/config';\n\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { getResolvedLocalesAsync } from './getResolvedLocales';\n\n/** Get the public Expo manifest from the local project config. */\nexport async function getPublicExpoManifestAsync(projectRoot: string): Promise<ExpoAppManifest> {\n // Read the config in public mode which strips the `hooks`.\n const { exp } = getConfig(projectRoot, {\n isPublicConfig: true,\n // This shouldn't be needed since the CLI is vendored in `expo`.\n skipSDKVersionRequirement: true,\n });\n\n // Only allow projects to be published with UNVERSIONED if a correct token is set in env\n if (exp.sdkVersion === 'UNVERSIONED' && !env.EXPO_SKIP_MANIFEST_VALIDATION_TOKEN) {\n throw new CommandError('INVALID_OPTIONS', 'Cannot publish with sdkVersion UNVERSIONED.');\n }\n\n return {\n ...exp,\n locales: await getResolvedLocalesAsync(projectRoot, exp),\n sdkVersion: exp.sdkVersion!,\n };\n}\n"],"names":["getPublicExpoManifestAsync","projectRoot","exp","getConfig","isPublicConfig","skipSDKVersionRequirement","sdkVersion","env","EXPO_SKIP_MANIFEST_VALIDATION_TOKEN","CommandError","locales","getResolvedLocalesAsync"],"mappings":"AAAA;;;;QAOsBA,0BAA0B,GAA1BA,0BAA0B;AAPL,IAAA,OAAc,WAAd,cAAc,CAAA;AAErC,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACN,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAGvD,eAAeA,0BAA0B,CAACC,WAAmB,EAA4B;IAC9F,2DAA2D;IAC3D,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGC,CAAAA,GAAAA,OAAS,AAIvB,CAAA,UAJuB,CAACF,WAAW,EAAE;QACrCG,cAAc,EAAE,IAAI;QACpB,gEAAgE;QAChEC,yBAAyB,EAAE,IAAI;KAChC,CAAC,AAAC;IAEH,wFAAwF;IACxF,IAAIH,GAAG,CAACI,UAAU,KAAK,aAAa,IAAI,CAACC,IAAG,IAAA,CAACC,mCAAmC,EAAE;QAChF,MAAM,IAAIC,OAAY,aAAA,CAAC,iBAAiB,EAAE,6CAA6C,CAAC,CAAC;KAC1F;IAED,OAAO;QACL,GAAGP,GAAG;QACNQ,OAAO,EAAE,MAAMC,CAAAA,GAAAA,mBAAuB,AAAkB,CAAA,wBAAlB,CAACV,WAAW,EAAEC,GAAG,CAAC;QACxDI,UAAU,EAAEJ,GAAG,CAACI,UAAU;KAC3B,CAAC;CACH"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.getResolvedLocalesAsync = getResolvedLocalesAsync;
6
+ var _jsonFile = _interopRequireDefault(require("@expo/json-file"));
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _errors = require("../utils/errors");
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ async function getResolvedLocalesAsync(projectRoot, exp) {
15
+ if (!exp.locales) {
16
+ return {};
17
+ }
18
+ const locales = {};
19
+ for (const [lang, localeJsonPath] of Object.entries(exp.locales)){
20
+ if (typeof localeJsonPath === "string") {
21
+ try {
22
+ locales[lang] = await _jsonFile.default.readAsync(_path.default.join(projectRoot, localeJsonPath));
23
+ } catch (error) {
24
+ throw new _errors.CommandError("EXPO_CONFIG", JSON.stringify(error));
25
+ }
26
+ } else {
27
+ // In the off chance that someone defined the locales json in the config, pass it directly to the object.
28
+ // We do this to make the types more elegant.
29
+ locales[lang] = localeJsonPath;
30
+ }
31
+ }
32
+ return locales;
33
+ }
34
+
35
+ //# sourceMappingURL=getResolvedLocales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/getResolvedLocales.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport JsonFile, { JSONObject } from '@expo/json-file';\nimport path from 'path';\n\nimport { CommandError } from '../utils/errors';\n\ntype LocaleMap = Record<string, JSONObject>;\n\n// Similar to how we resolve locales in `@expo/config-plugins`\nexport async function getResolvedLocalesAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'locales'>\n): Promise<LocaleMap> {\n if (!exp.locales) {\n return {};\n }\n\n const locales: LocaleMap = {};\n for (const [lang, localeJsonPath] of Object.entries(exp.locales)) {\n if (typeof localeJsonPath === 'string') {\n try {\n locales[lang] = await JsonFile.readAsync(path.join(projectRoot, localeJsonPath));\n } catch (error: any) {\n throw new CommandError('EXPO_CONFIG', JSON.stringify(error));\n }\n } else {\n // In the off chance that someone defined the locales json in the config, pass it directly to the object.\n // We do this to make the types more elegant.\n locales[lang] = localeJsonPath;\n }\n }\n return locales;\n}\n"],"names":["getResolvedLocalesAsync","projectRoot","exp","locales","lang","localeJsonPath","Object","entries","JsonFile","readAsync","path","join","error","CommandError","JSON","stringify"],"mappings":"AAAA;;;;QASsBA,uBAAuB,GAAvBA,uBAAuB;AARR,IAAA,SAAiB,kCAAjB,iBAAiB,EAAA;AACrC,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEM,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;;;;;;AAKvC,eAAeA,uBAAuB,CAC3CC,WAAmB,EACnBC,GAAgC,EACZ;IACpB,IAAI,CAACA,GAAG,CAACC,OAAO,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IAED,MAAMA,OAAO,GAAc,EAAE,AAAC;IAC9B,KAAK,MAAM,CAACC,IAAI,EAAEC,cAAc,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,GAAG,CAACC,OAAO,CAAC,CAAE;QAChE,IAAI,OAAOE,cAAc,KAAK,QAAQ,EAAE;YACtC,IAAI;gBACFF,OAAO,CAACC,IAAI,CAAC,GAAG,MAAMI,SAAQ,QAAA,CAACC,SAAS,CAACC,KAAI,QAAA,CAACC,IAAI,CAACV,WAAW,EAAEI,cAAc,CAAC,CAAC,CAAC;aAClF,CAAC,OAAOO,KAAK,EAAO;gBACnB,MAAM,IAAIC,OAAY,aAAA,CAAC,aAAa,EAAEC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC,CAAC,CAAC;aAC9D;SACF,MAAM;YACL,yGAAyG;YACzG,6CAA6C;YAC7CT,OAAO,CAACC,IAAI,CAAC,GAAGC,cAAc,CAAC;SAChC;KACF;IACD,OAAOF,OAAO,CAAC;CAChB"}
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.expoExport = void 0;
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _args = require("../utils/args");
9
+ var _errors = require("../utils/errors");
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
+ const expoExport = async (argv)=>{
37
+ const args = (0, _args).assertArgs({
38
+ // Types
39
+ "--help": Boolean,
40
+ "--clear": Boolean,
41
+ "--dump-assetmap": Boolean,
42
+ "--dev": Boolean,
43
+ "--dump-sourcemap": Boolean,
44
+ "--max-workers": Number,
45
+ "--output-dir": String,
46
+ // Aliases
47
+ "-h": "--help",
48
+ // '-s': '--dump-sourcemap',
49
+ // '-d': '--dump-assetmap',
50
+ "-c": "--clear"
51
+ }, argv);
52
+ if (args["--help"]) {
53
+ (0, _args).printHelp(`Export the static files of the app for hosting it on a web server`, _chalk.default`npx expo export {dim <dir>}`, [
54
+ _chalk.default`<dir> Directory of the Expo project. {dim Default: Current working directory}`,
55
+ _chalk.default`--platform <all|android|ios> Platforms: android, ios, all. {dim Default: all}`,
56
+ `--dev Configure static files for developing locally using a non-https server`,
57
+ _chalk.default`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,
58
+ `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,
59
+ `--dump-assetmap Dump the asset map for further processing`,
60
+ `--dump-sourcemap Dump the source map for debugging the JS bundle`,
61
+ `-c, --clear Clear the bundler cache`,
62
+ `-h, --help Usage info`,
63
+ ].join("\n"));
64
+ }
65
+ const projectRoot = (0, _args).getProjectRoot(args);
66
+ const { resolveOptionsAsync } = await Promise.resolve().then(function() {
67
+ return _interopRequireWildcard(require("./resolveOptions"));
68
+ });
69
+ const options = await resolveOptionsAsync(args).catch(_errors.logCmdError);
70
+ const { exportAsync } = await Promise.resolve().then(function() {
71
+ return _interopRequireWildcard(require("./exportAsync"));
72
+ });
73
+ return exportAsync(projectRoot, options).catch(_errors.logCmdError);
74
+ };
75
+ exports.expoExport = expoExport;
76
+
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoExport: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clear': Boolean,\n '--dump-assetmap': Boolean,\n '--dev': Boolean,\n '--dump-sourcemap': Boolean,\n '--max-workers': Number,\n '--output-dir': String,\n // Aliases\n '-h': '--help',\n // '-s': '--dump-sourcemap',\n // '-d': '--dump-assetmap',\n '-c': '--clear',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Export the static files of the app for hosting it on a web server`,\n chalk`npx expo export {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n chalk`--platform <all|android|ios> Platforms: android, ios, all. {dim Default: all}`,\n `--dev Configure static files for developing locally using a non-https server`,\n chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,\n `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,\n `--dump-assetmap Dump the asset map for further processing`,\n `--dump-sourcemap Dump the source map for debugging the JS bundle`,\n `-c, --clear Clear the bundler cache`,\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const projectRoot = getProjectRoot(args);\n const { resolveOptionsAsync } = await import('./resolveOptions');\n const options = await resolveOptionsAsync(args).catch(logCmdError);\n\n const { exportAsync } = await import('./exportAsync');\n return exportAsync(projectRoot, options).catch(logCmdError);\n};\n"],"names":["expoExport","argv","args","assertArgs","Boolean","Number","String","printHelp","chalk","join","projectRoot","getProjectRoot","resolveOptionsAsync","options","catch","logCmdError","exportAsync"],"mappings":"AAAA;;;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAG6B,IAAA,KAAe,WAAf,eAAe,CAAA;AACzC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMA,UAAU,GAAY,OAAOC,IAAI,GAAK;IACjD,MAAMC,IAAI,GAAGC,CAAAA,GAAAA,KAAU,AAiBtB,CAAA,WAjBsB,CACrB;QACE,QAAQ;QACR,QAAQ,EAAEC,OAAO;QACjB,SAAS,EAAEA,OAAO;QAClB,iBAAiB,EAAEA,OAAO;QAC1B,OAAO,EAAEA,OAAO;QAChB,kBAAkB,EAAEA,OAAO;QAC3B,eAAe,EAAEC,MAAM;QACvB,cAAc,EAAEC,MAAM;QACtB,UAAU;QACV,IAAI,EAAE,QAAQ;QACd,4BAA4B;QAC5B,2BAA2B;QAC3B,IAAI,EAAE,SAAS;KAChB,EACDL,IAAI,CACL,AAAC;IAEF,IAAIC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAClBK,CAAAA,GAAAA,KAAS,AAcR,CAAA,UAdQ,CACP,CAAC,iEAAiE,CAAC,EACnEC,MAAK,QAAA,CAAC,2BAA2B,CAAC,EAClC;YACEA,MAAK,QAAA,CAAC,qGAAqG,CAAC;YAC5GA,MAAK,QAAA,CAAC,8EAA8E,CAAC;YACrF,CAAC,oGAAoG,CAAC;YACtGA,MAAK,QAAA,CAAC,8FAA8F,CAAC;YACrG,CAAC,mFAAmF,CAAC;YACrF,CAAC,uEAAuE,CAAC;YACzE,CAAC,6EAA6E,CAAC;YAC/E,CAAC,qDAAqD,CAAC;YACvD,CAAC,wCAAwC,CAAC;SAC3C,CAACC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;KACH;IAED,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,KAAc,AAAM,CAAA,eAAN,CAACT,IAAI,CAAC,AAAC;IACzC,MAAM,EAAEU,mBAAmB,CAAA,EAAE,GAAG,MAAM;+CAAO,kBAAkB;MAAC,AAAC;IACjE,MAAMC,OAAO,GAAG,MAAMD,mBAAmB,CAACV,IAAI,CAAC,CAACY,KAAK,CAACC,OAAW,YAAA,CAAC,AAAC;IAEnE,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAG,MAAM;+CAAO,eAAe;MAAC,AAAC;IACtD,OAAOA,WAAW,CAACN,WAAW,EAAEG,OAAO,CAAC,CAACC,KAAK,CAACC,OAAW,YAAA,CAAC,CAAC;CAC7D,AAAC;QA5CWf,UAAU,GAAVA,UAAU"}
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.printBundleSizes = printBundleSizes;
6
+ exports.createFilesTable = createFilesTable;
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _prettyBytes = _interopRequireDefault(require("pretty-bytes"));
9
+ var _textTable = _interopRequireDefault(require("text-table"));
10
+ var Log = _interopRequireWildcard(require("../log"));
11
+ var _ansi = require("../utils/ansi");
12
+ var _link = require("../utils/link");
13
+ function _interopRequireDefault(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ function _interopRequireWildcard(obj) {
19
+ if (obj && obj.__esModule) {
20
+ return obj;
21
+ } else {
22
+ var newObj = {};
23
+ if (obj != null) {
24
+ for(var key in obj){
25
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
26
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
27
+ if (desc.get || desc.set) {
28
+ Object.defineProperty(newObj, key, desc);
29
+ } else {
30
+ newObj[key] = obj[key];
31
+ }
32
+ }
33
+ }
34
+ }
35
+ newObj.default = obj;
36
+ return newObj;
37
+ }
38
+ }
39
+ function printBundleSizes(bundles) {
40
+ var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
41
+ const files = [];
42
+ if ((ref = bundles.ios) == null ? void 0 : ref.hermesBytecodeBundle) {
43
+ files.push([
44
+ "index.ios.js (Hermes)",
45
+ bundles.ios.hermesBytecodeBundle
46
+ ]);
47
+ } else if ((ref1 = bundles.ios) == null ? void 0 : ref1.code) {
48
+ files.push([
49
+ "index.ios.js",
50
+ bundles.ios.code
51
+ ]);
52
+ }
53
+ if ((ref2 = bundles.android) == null ? void 0 : ref2.hermesBytecodeBundle) {
54
+ files.push([
55
+ "index.android.js (Hermes)",
56
+ bundles.android.hermesBytecodeBundle
57
+ ]);
58
+ } else if ((ref3 = bundles.android) == null ? void 0 : ref3.code) {
59
+ files.push([
60
+ "index.android.js",
61
+ bundles.android.code
62
+ ]);
63
+ }
64
+ // Account for inline source maps
65
+ if ((ref4 = bundles.ios) == null ? void 0 : ref4.hermesSourcemap) {
66
+ files.push([
67
+ _chalk.default.dim("index.ios.js.map (Hermes)"),
68
+ bundles.ios.hermesSourcemap
69
+ ]);
70
+ } else if ((ref5 = bundles.ios) == null ? void 0 : ref5.map) {
71
+ files.push([
72
+ _chalk.default.dim("index.ios.js.map"),
73
+ bundles.ios.map
74
+ ]);
75
+ }
76
+ if ((ref6 = bundles.android) == null ? void 0 : ref6.hermesSourcemap) {
77
+ files.push([
78
+ _chalk.default.dim("index.android.js.map (Hermes)"),
79
+ bundles.android.hermesSourcemap
80
+ ]);
81
+ } else if ((ref7 = bundles.android) == null ? void 0 : ref7.map) {
82
+ files.push([
83
+ _chalk.default.dim("index.android.js.map"),
84
+ bundles.android.map
85
+ ]);
86
+ }
87
+ Log.log();
88
+ Log.log(createFilesTable(files));
89
+ Log.log();
90
+ Log.log(_chalk.default`💡 JavaScript bundle sizes affect startup time. {dim ${(0, _link).learnMore(`https://expo.fyi/javascript-bundle-sizes`)}}`);
91
+ Log.log();
92
+ return files;
93
+ }
94
+ function createFilesTable(files) {
95
+ const tableData = files.map((item, index)=>{
96
+ const fileBranch = index === 0 ? "\u250C" : index === files.length - 1 ? "\u2514" : "\u251C";
97
+ return [
98
+ `${fileBranch} ${item[0]}`,
99
+ (0, _prettyBytes).default(Buffer.byteLength(item[1], "utf8"))
100
+ ];
101
+ });
102
+ var ref;
103
+ return (0, _textTable).default([
104
+ [
105
+ "Bundle",
106
+ "Size"
107
+ ].map((v)=>_chalk.default.underline(v)
108
+ ),
109
+ ...tableData
110
+ ], {
111
+ align: [
112
+ "l",
113
+ "r"
114
+ ],
115
+ stringLength: (str)=>{
116
+ var ref8;
117
+ return (ref = (ref8 = (0, _ansi).stripAnsi(str)) == null ? void 0 : ref8.length) != null ? ref : 0;
118
+ }
119
+ });
120
+ }
121
+
122
+ //# sourceMappingURL=printBundleSizes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/printBundleSizes.ts"],"sourcesContent":["import { Platform } from '@expo/config';\nimport { BundleOutput } from '@expo/dev-server';\nimport chalk from 'chalk';\nimport prettyBytes from 'pretty-bytes';\nimport table from 'text-table';\n\nimport * as Log from '../log';\nimport { stripAnsi } from '../utils/ansi';\nimport { learnMore } from '../utils/link';\n\nexport function printBundleSizes(bundles: Partial<Record<Platform, BundleOutput>>) {\n const files: [string, string | Uint8Array][] = [];\n\n if (bundles.ios?.hermesBytecodeBundle) {\n files.push(['index.ios.js (Hermes)', bundles.ios.hermesBytecodeBundle]);\n } else if (bundles.ios?.code) {\n files.push(['index.ios.js', bundles.ios.code]);\n }\n if (bundles.android?.hermesBytecodeBundle) {\n files.push(['index.android.js (Hermes)', bundles.android.hermesBytecodeBundle]);\n } else if (bundles.android?.code) {\n files.push(['index.android.js', bundles.android.code]);\n }\n\n // Account for inline source maps\n if (bundles.ios?.hermesSourcemap) {\n files.push([chalk.dim('index.ios.js.map (Hermes)'), bundles.ios.hermesSourcemap]);\n } else if (bundles.ios?.map) {\n files.push([chalk.dim('index.ios.js.map'), bundles.ios.map]);\n }\n if (bundles.android?.hermesSourcemap) {\n files.push([chalk.dim('index.android.js.map (Hermes)'), bundles.android.hermesSourcemap]);\n } else if (bundles.android?.map) {\n files.push([chalk.dim('index.android.js.map'), bundles.android.map]);\n }\n\n Log.log();\n Log.log(createFilesTable(files));\n Log.log();\n Log.log(\n chalk`💡 JavaScript bundle sizes affect startup time. {dim ${learnMore(\n `https://expo.fyi/javascript-bundle-sizes`\n )}}`\n );\n Log.log();\n\n return files;\n}\n\nexport function createFilesTable(files: [string, string | Uint8Array][]): string {\n const tableData = files.map((item, index) => {\n const fileBranch = index === 0 ? '┌' : index === files.length - 1 ? '└' : '├';\n\n return [`${fileBranch} ${item[0]}`, prettyBytes(Buffer.byteLength(item[1], 'utf8'))];\n });\n return table([['Bundle', 'Size'].map((v) => chalk.underline(v)), ...tableData], {\n align: ['l', 'r'],\n stringLength: (str) => stripAnsi(str)?.length ?? 0,\n });\n}\n"],"names":["printBundleSizes","createFilesTable","Log","bundles","files","ios","hermesBytecodeBundle","push","code","android","hermesSourcemap","chalk","dim","map","log","learnMore","tableData","item","index","fileBranch","length","prettyBytes","Buffer","byteLength","stripAnsi","table","v","underline","align","stringLength","str"],"mappings":"AAAA;;;;QAUgBA,gBAAgB,GAAhBA,gBAAgB;QAuChBC,gBAAgB,GAAhBA,gBAAgB;AA/Cd,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AACpB,IAAA,UAAY,kCAAZ,YAAY,EAAA;AAElBC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACW,IAAA,KAAe,WAAf,eAAe,CAAA;AACf,IAAA,KAAe,WAAf,eAAe,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,SAASF,gBAAgB,CAACG,OAAgD,EAAE;QAG7EA,GAAW,EAEJA,IAAW,EAGlBA,IAAe,EAERA,IAAe,EAKtBA,IAAW,EAEJA,IAAW,EAGlBA,IAAe,EAERA,IAAe;IArB1B,MAAMC,KAAK,GAAoC,EAAE,AAAC;IAElD,IAAID,CAAAA,GAAW,GAAXA,OAAO,CAACE,GAAG,SAAsB,GAAjCF,KAAAA,CAAiC,GAAjCA,GAAW,CAAEG,oBAAoB,EAAE;QACrCF,KAAK,CAACG,IAAI,CAAC;YAAC,uBAAuB;YAAEJ,OAAO,CAACE,GAAG,CAACC,oBAAoB;SAAC,CAAC,CAAC;KACzE,MAAM,IAAIH,CAAAA,IAAW,GAAXA,OAAO,CAACE,GAAG,SAAM,GAAjBF,KAAAA,CAAiB,GAAjBA,IAAW,CAAEK,IAAI,EAAE;QAC5BJ,KAAK,CAACG,IAAI,CAAC;YAAC,cAAc;YAAEJ,OAAO,CAACE,GAAG,CAACG,IAAI;SAAC,CAAC,CAAC;KAChD;IACD,IAAIL,CAAAA,IAAe,GAAfA,OAAO,CAACM,OAAO,SAAsB,GAArCN,KAAAA,CAAqC,GAArCA,IAAe,CAAEG,oBAAoB,EAAE;QACzCF,KAAK,CAAC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AS;KAAC,EAAE;QAC9EY,KAAK,EAAE;YAAC,GAAG;YAAE,GAAG;SAAC;QACjBC,YAAY,EAAE,CAACC,GAAG;gBAAKN,IAAc;YAAdA,OAAAA,CAAAA,GAAsB,GAAtBA,CAAAA,IAAc,GAAdA,CAAAA,GAAAA,KAAS,AAAK,CAAA,UAAL,CAACM,GAAG,CAAC,SAAQ,GAAtBN,KAAAA,CAAsB,GAAtBA,IAAc,CAAEJ,MAAM,YAAtBI,GAAsB,GAAI,CAAC,CAAA;SAAA;KACnD,CAAC,CAAC;CACJ"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.resolveOptionsAsync = resolveOptionsAsync;
6
+ var _resolveOptions = require("../prebuild/resolveOptions");
7
+ async function resolveOptionsAsync(args) {
8
+ var ref;
9
+ const platforms = (0, _resolveOptions).resolvePlatformOption((ref = args["--platform"]) != null ? ref : "all", {
10
+ loose: true
11
+ });
12
+ var ref1;
13
+ return {
14
+ outputDir: (ref1 = args["--output-dir"]) != null ? ref1 : "dist",
15
+ platforms,
16
+ clear: !!args["--clear"],
17
+ dev: !!args["--dev"],
18
+ maxWorkers: args["--max-workers"],
19
+ dumpAssetmap: !!args["--dump-assetmap"],
20
+ dumpSourcemap: !!args["--dump-sourcemap"]
21
+ };
22
+ }
23
+
24
+ //# sourceMappingURL=resolveOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/resolveOptions.ts"],"sourcesContent":["import { ModPlatform } from '@expo/config-plugins';\n\nimport { resolvePlatformOption } from '../prebuild/resolveOptions';\n\nexport type Options = {\n outputDir: string;\n platforms: ModPlatform[];\n maxWorkers?: number;\n dev: boolean;\n clear: boolean;\n dumpAssetmap: boolean;\n dumpSourcemap: boolean;\n};\n\nexport async function resolveOptionsAsync(args: any): Promise<Options> {\n const platforms = resolvePlatformOption(args['--platform'] ?? 'all', { loose: true });\n\n return {\n outputDir: args['--output-dir'] ?? 'dist',\n platforms,\n clear: !!args['--clear'],\n dev: !!args['--dev'],\n maxWorkers: args['--max-workers'],\n dumpAssetmap: !!args['--dump-assetmap'],\n dumpSourcemap: !!args['--dump-sourcemap'],\n };\n}\n"],"names":["resolveOptionsAsync","args","platforms","resolvePlatformOption","loose","outputDir","clear","dev","maxWorkers","dumpAssetmap","dumpSourcemap"],"mappings":"AAAA;;;;QAcsBA,mBAAmB,GAAnBA,mBAAmB;AAZH,IAAA,eAA4B,WAA5B,4BAA4B,CAAA;AAY3D,eAAeA,mBAAmB,CAACC,IAAS,EAAoB;QAC7BA,GAAkB;IAA1D,MAAMC,SAAS,GAAGC,CAAAA,GAAAA,eAAqB,AAA8C,CAAA,sBAA9C,CAACF,CAAAA,GAAkB,GAAlBA,IAAI,CAAC,YAAY,CAAC,YAAlBA,GAAkB,GAAI,KAAK,EAAE;QAAEG,KAAK,EAAE,IAAI;KAAE,CAAC,AAAC;QAGzEH,IAAoB;IADjC,OAAO;QACLI,SAAS,EAAEJ,CAAAA,IAAoB,GAApBA,IAAI,CAAC,cAAc,CAAC,YAApBA,IAAoB,GAAI,MAAM;QACzCC,SAAS;QACTI,KAAK,EAAE,CAAC,CAACL,IAAI,CAAC,SAAS,CAAC;QACxBM,GAAG,EAAE,CAAC,CAACN,IAAI,CAAC,OAAO,CAAC;QACpBO,UAAU,EAAEP,IAAI,CAAC,eAAe,CAAC;QACjCQ,YAAY,EAAE,CAAC,CAACR,IAAI,CAAC,iBAAiB,CAAC;QACvCS,aAAa,EAAE,CAAC,CAACT,IAAI,CAAC,kBAAkB,CAAC;KAC1C,CAAC;CACH"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.saveAssetsAsync = saveAssetsAsync;
6
+ var _path = _interopRequireDefault(require("path"));
7
+ var Log = _interopRequireWildcard(require("../log"));
8
+ var _array = require("../utils/array");
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
+ function logAssetTask(projectRoot, action, pathName) {
37
+ Log.debug(`${action} ${pathName}`);
38
+ const relativePath = pathName.replace(projectRoot, "");
39
+ Log.log(`${action} ${relativePath}`);
40
+ }
41
+ function collectAssetPaths(assets) {
42
+ // Collect paths by key, also effectively handles duplicates in the array
43
+ const paths = {};
44
+ assets.forEach((asset)=>{
45
+ asset.files.forEach((path, index)=>{
46
+ paths[asset.fileHashes[index]] = path;
47
+ });
48
+ });
49
+ return paths;
50
+ }
51
+ async function saveAssetsAsync(projectRoot, { assets , outputDir }) {
52
+ // Collect paths by key, also effectively handles duplicates in the array
53
+ const paths = collectAssetPaths(assets);
54
+ // save files one chunk at a time
55
+ for (const keys of (0, _array).chunk(Object.entries(paths), 5)){
56
+ await Promise.all(keys.map(([key, pathName])=>{
57
+ logAssetTask(projectRoot, "saving", pathName);
58
+ // copy file over to assetPath
59
+ return (0, _dir).copyAsync(pathName, _path.default.join(outputDir, "assets", key));
60
+ }));
61
+ }
62
+ Log.log("Files successfully saved.");
63
+ }
64
+
65
+ //# sourceMappingURL=saveAssets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/export/saveAssets.ts"],"sourcesContent":["import { BundleAssetWithFileHashes } from '@expo/dev-server';\nimport path from 'path';\n\nimport * as Log from '../log';\nimport { chunk } from '../utils/array';\nimport { copyAsync } from '../utils/dir';\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nfunction logAssetTask(projectRoot: string, action: 'uploading' | 'saving', pathName: string) {\n Log.debug(`${action} ${pathName}`);\n\n const relativePath = pathName.replace(projectRoot, '');\n Log.log(`${action} ${relativePath}`);\n}\n\nfunction collectAssetPaths(assets: Asset[]): Record<string, string> {\n // Collect paths by key, also effectively handles duplicates in the array\n const paths: { [fileHash: string]: string } = {};\n assets.forEach((asset) => {\n asset.files.forEach((path: string, index: number) => {\n paths[asset.fileHashes[index]] = path;\n });\n });\n return paths;\n}\n\nexport async function saveAssetsAsync(\n projectRoot: string,\n { assets, outputDir }: { assets: Asset[]; outputDir: string }\n) {\n // Collect paths by key, also effectively handles duplicates in the array\n const paths = collectAssetPaths(assets);\n\n // save files one chunk at a time\n for (const keys of chunk(Object.entries(paths), 5)) {\n await Promise.all(\n keys.map(([key, pathName]) => {\n logAssetTask(projectRoot, 'saving', pathName);\n // copy file over to assetPath\n return copyAsync(pathName, path.join(outputDir, 'assets', key));\n })\n );\n }\n Log.log('Files successfully saved.');\n}\n"],"names":["saveAssetsAsync","Log","logAssetTask","projectRoot","action","pathName","debug","relativePath","replace","log","collectAssetPaths","assets","paths","forEach","asset","files","path","index","fileHashes","outputDir","keys","chunk","Object","entries","Promise","all","map","key","copyAsync","join"],"mappings":"AAAA;;;;QA6BsBA,eAAe,GAAfA,eAAe;AA5BpB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEXC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACO,IAAA,MAAgB,WAAhB,gBAAgB,CAAA;AACZ,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMxC,SAASC,YAAY,CAACC,WAAmB,EAAEC,MAA8B,EAAEC,QAAgB,EAAE;IAC3FJ,GAA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