@expo/cli 0.16.7 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +4 -3
- package/build/bin/cli.map +1 -1
- package/build/src/customize/customizeAsync.js +2 -1
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/customize/typescript.js +1 -1
- package/build/src/customize/typescript.js.map +1 -1
- package/build/src/export/resolveOptions.js +7 -5
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +1 -1
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/web/index.js +1 -1
- package/build/src/export/web/index.js.map +1 -1
- package/build/src/install/installAsync.js +1 -5
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/prebuild/configureProjectAsync.js +7 -1
- package/build/src/prebuild/configureProjectAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +3 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +41 -48
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +9 -8
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +4 -12
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +6 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/platforms/android/ADBServer.js +7 -0
- package/build/src/start/platforms/android/ADBServer.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +4 -3
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +2 -2
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +30 -18
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +18 -7
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +5 -7
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/router.js +17 -0
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -1
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +7 -4
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/CorsMiddleware.js +55 -0
- package/build/src/start/server/middleware/CorsMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ManifestMiddleware.js +5 -5
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/platformBundlers.js +18 -5
- package/build/src/start/server/platformBundlers.js.map +1 -1
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +1 -1
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/startAsync.js +1 -1
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/env.js +3 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/npm.js +12 -4
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/resolveArgs.js +8 -2
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/package.json +3 -3
- package/build/src/start/server/middleware/remoteDevtoolsCorsMiddleware.js +0 -31
- package/build/src/start/server/middleware/remoteDevtoolsCorsMiddleware.js.map +0 -1
- package/build/src/start/server/middleware/remoteDevtoolsSecurityHeadersMiddleware.js +0 -17
- package/build/src/start/server/middleware/remoteDevtoolsSecurityHeadersMiddleware.js.map +0 -1
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
exports.cloneTemplateAsync = cloneTemplateAsync;
|
|
6
6
|
exports.resolveTemplateArgAsync = resolveTemplateArgAsync;
|
|
7
|
+
var _assert = _interopRequireDefault(require("assert"));
|
|
7
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
@@ -42,10 +43,10 @@ function _interopRequireWildcard(obj) {
|
|
|
42
43
|
const debug = require("debug")("expo:prebuild:resolveTemplate");
|
|
43
44
|
async function cloneTemplateAsync({ templateDirectory , template , exp , ora }) {
|
|
44
45
|
if (template) {
|
|
45
|
-
await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);
|
|
46
|
+
return await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);
|
|
46
47
|
} else {
|
|
47
48
|
const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);
|
|
48
|
-
await (0, _npm).downloadAndExtractNpmModuleAsync(templatePackageName, {
|
|
49
|
+
return await (0, _npm).downloadAndExtractNpmModuleAsync(templatePackageName, {
|
|
49
50
|
cwd: templateDirectory,
|
|
50
51
|
name: exp.name
|
|
51
52
|
});
|
|
@@ -99,7 +100,7 @@ async function downloadAndExtractRepoAsync(root, { username , name , branch , fi
|
|
|
99
100
|
const strip = filePath ? filePath.split("/").length + 1 : 1;
|
|
100
101
|
const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;
|
|
101
102
|
debug("Downloading tarball from:", url);
|
|
102
|
-
await (0, _npm).extractNpmTarballFromUrlAsync(url, {
|
|
103
|
+
return await (0, _npm).extractNpmTarballFromUrlAsync(url, {
|
|
103
104
|
cwd: root,
|
|
104
105
|
name: projectName,
|
|
105
106
|
strip,
|
|
@@ -109,55 +110,47 @@ async function downloadAndExtractRepoAsync(root, { username , name , branch , fi
|
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
async function resolveTemplateArgAsync(templateDirectory, oraInstance, appName, template, templatePath) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (error.code !== "ERR_INVALID_URL") {
|
|
121
|
-
oraInstance.fail(error);
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// On Windows, we can actually create a URL from a local path
|
|
126
|
-
// Double-check if the created URL is not a path to avoid mixing up URLs and paths
|
|
127
|
-
if (process.platform === "win32" && repoUrl && _path.default.isAbsolute(repoUrl.toString())) {
|
|
128
|
-
repoUrl = undefined;
|
|
129
|
-
}
|
|
130
|
-
if (!repoUrl) {
|
|
131
|
-
const templatePath = _path.default.resolve(template);
|
|
132
|
-
if (!_fs.default.existsSync(templatePath)) {
|
|
133
|
-
throw new _errors.CommandError(`template file does not exist: ${templatePath}`);
|
|
134
|
-
}
|
|
135
|
-
await (0, _npm).extractLocalNpmTarballAsync(templatePath, {
|
|
136
|
-
cwd: templateDirectory,
|
|
137
|
-
name: appName
|
|
138
|
-
});
|
|
139
|
-
return templateDirectory;
|
|
140
|
-
}
|
|
141
|
-
if (repoUrl.origin !== "https://github.com") {
|
|
142
|
-
oraInstance.fail(`Invalid URL: ${_chalk.default.red(`"${template}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);
|
|
143
|
-
throw new _errors.AbortCommandError();
|
|
144
|
-
}
|
|
145
|
-
repoInfo = await getRepoInfo(repoUrl, templatePath);
|
|
146
|
-
if (!repoInfo) {
|
|
147
|
-
oraInstance.fail(`Found invalid GitHub URL: ${_chalk.default.red(`"${template}"`)}. Please fix the URL and try again.`);
|
|
148
|
-
throw new _errors.AbortCommandError();
|
|
113
|
+
(0, _assert).default(template, "template is required");
|
|
114
|
+
let repoUrl;
|
|
115
|
+
try {
|
|
116
|
+
repoUrl = new URL(template);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error.code !== "ERR_INVALID_URL") {
|
|
119
|
+
oraInstance.fail(error);
|
|
120
|
+
throw error;
|
|
149
121
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
122
|
+
}
|
|
123
|
+
// On Windows, we can actually create a URL from a local path
|
|
124
|
+
// Double-check if the created URL is not a path to avoid mixing up URLs and paths
|
|
125
|
+
if (process.platform === "win32" && repoUrl && _path.default.isAbsolute(repoUrl.toString())) {
|
|
126
|
+
repoUrl = undefined;
|
|
127
|
+
}
|
|
128
|
+
if (!repoUrl) {
|
|
129
|
+
const templatePath = _path.default.resolve(template);
|
|
130
|
+
if (!_fs.default.existsSync(templatePath)) {
|
|
131
|
+
throw new _errors.CommandError(`template file does not exist: ${templatePath}`);
|
|
154
132
|
}
|
|
133
|
+
return await (0, _npm).extractLocalNpmTarballAsync(templatePath, {
|
|
134
|
+
cwd: templateDirectory,
|
|
135
|
+
name: appName
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (repoUrl.origin !== "https://github.com") {
|
|
139
|
+
oraInstance.fail(`Invalid URL: ${_chalk.default.red(`"${template}"`)}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`);
|
|
140
|
+
throw new _errors.AbortCommandError();
|
|
141
|
+
}
|
|
142
|
+
const repoInfo = await getRepoInfo(repoUrl, templatePath);
|
|
143
|
+
if (!repoInfo) {
|
|
144
|
+
oraInstance.fail(`Found invalid GitHub URL: ${_chalk.default.red(`"${template}"`)}. Please fix the URL and try again.`);
|
|
145
|
+
throw new _errors.AbortCommandError();
|
|
155
146
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
147
|
+
const found = await hasRepo(repoInfo);
|
|
148
|
+
if (!found) {
|
|
149
|
+
oraInstance.fail(`Could not locate the repository for ${_chalk.default.red(`"${template}"`)}. Please check that the repository exists and try again.`);
|
|
150
|
+
throw new _errors.AbortCommandError();
|
|
159
151
|
}
|
|
160
|
-
|
|
152
|
+
oraInstance.text = _chalk.default.bold(`Downloading files from repo ${_chalk.default.cyan(template)}. This might take a moment.`);
|
|
153
|
+
return await downloadAndExtractRepoAsync(templateDirectory, repoInfo);
|
|
161
154
|
}
|
|
162
155
|
|
|
163
156
|
//# sourceMappingURL=resolveTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}) {\n if (template) {\n await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<void> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n) {\n let repoInfo: RepoInfo | undefined;\n\n if (template) {\n // @ts-ignore\n let repoUrl: URL | undefined;\n\n try {\n // @ts-ignore\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n await extractLocalNpmTarballAsync(templatePath, { cwd: templateDirectory, name: appName });\n return templateDirectory;\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n }\n\n if (repoInfo) {\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n }\n\n return true;\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","repoInfo","repoUrl","URL","error","code","fail","process","platform","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red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,MAAK,QAAA,CAACK,IAAI,CAC3B,CAAC,4BAA4B,EAAEL,MAAK,QAAA,CAACM,IAAI,CAACtE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;QAEF,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEiD,QAAQ,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;CACb"}
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}): Promise<string> {\n if (template) {\n return await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n return await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<string> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n return await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n): Promise<string> {\n assert(template, 'template is required');\n\n let repoUrl: URL | undefined;\n\n try {\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n return await extractLocalNpmTarballAsync(templatePath, {\n cwd: templateDirectory,\n name: appName,\n });\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n return await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","assert","repoUrl","URL","error","code","fail","process","platform","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballA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,WAAW,CAACwB,IAAI,GAAGL,MAAK,QAAA,CAACM,IAAI,CAC3B,CAAC,4BAA4B,EAAEN,MAAK,QAAA,CAACO,IAAI,CAACvE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;IAEF,OAAO,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEoE,QAAQ,CAAC,CAAC;CACvE"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.updateFromTemplateAsync = updateFromTemplateAsync;
|
|
6
|
+
exports.cloneTemplateAndCopyToProjectAsync = cloneTemplateAndCopyToProjectAsync;
|
|
6
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
7
8
|
var _copyTemplateFiles = require("./copyTemplateFiles");
|
|
8
9
|
var _resolveTemplate = require("./resolveTemplate");
|
|
@@ -45,7 +46,7 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
45
46
|
});
|
|
46
47
|
templateDirectory = temporary.directory();
|
|
47
48
|
}
|
|
48
|
-
const copiedPaths = await (0, _profile).profile(cloneTemplateAndCopyToProjectAsync)({
|
|
49
|
+
const { copiedPaths , templateChecksum } = await (0, _profile).profile(cloneTemplateAndCopyToProjectAsync)({
|
|
49
50
|
projectRoot,
|
|
50
51
|
template,
|
|
51
52
|
templateDirectory,
|
|
@@ -61,20 +62,17 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
61
62
|
hasNewProjectFiles: !!copiedPaths.length,
|
|
62
63
|
// If the iOS folder changes or new packages are added, we should rerun pod install.
|
|
63
64
|
needsPodInstall: copiedPaths.includes("ios") || !!depsResults.changedDependencies.length,
|
|
65
|
+
templateChecksum,
|
|
64
66
|
...depsResults
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
|
-
|
|
68
|
-
* Extract the template and copy the ios and android directories over to the project directory.
|
|
69
|
-
*
|
|
70
|
-
* @return `true` if any project files were created.
|
|
71
|
-
*/ async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp , platforms: unknownPlatforms }) {
|
|
69
|
+
async function cloneTemplateAndCopyToProjectAsync({ projectRoot , templateDirectory , template , exp , platforms: unknownPlatforms }) {
|
|
72
70
|
const platformDirectories = unknownPlatforms.map((platform)=>`./${platform}`
|
|
73
71
|
).reverse().join(" and ");
|
|
74
72
|
const pluralized = unknownPlatforms.length > 1 ? "directories" : "directory";
|
|
75
73
|
const ora = (0, _ora).logNewSection(`Creating native ${pluralized} (${platformDirectories})`);
|
|
76
74
|
try {
|
|
77
|
-
await (0, _resolveTemplate).cloneTemplateAsync({
|
|
75
|
+
const templateChecksum = await (0, _resolveTemplate).cloneTemplateAsync({
|
|
78
76
|
templateDirectory,
|
|
79
77
|
template,
|
|
80
78
|
exp,
|
|
@@ -89,7 +87,10 @@ async function updateFromTemplateAsync(projectRoot, { exp , pkg , template , tem
|
|
|
89
87
|
platforms
|
|
90
88
|
});
|
|
91
89
|
ora.succeed((0, _copyTemplateFiles).createCopyFilesSuccessMessage(platforms, results));
|
|
92
|
-
return
|
|
90
|
+
return {
|
|
91
|
+
copiedPaths: results.copiedPaths,
|
|
92
|
+
templateChecksum
|
|
93
|
+
};
|
|
93
94
|
} catch (e) {
|
|
94
95
|
if (!(e instanceof _errors.AbortCommandError)) {
|
|
95
96
|
Log.error(e.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport { copyTemplateFiles, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { validateTemplatePlatforms } from './validateTemplatePlatforms';\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is prebuilding, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const copiedPaths = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall: copiedPaths.includes('ios') || !!depsResults.changedDependencies.length,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/updateFromTemplate.ts"],"sourcesContent":["import { ExpoConfig, PackageJSONConfig } from '@expo/config';\nimport { ModPlatform } from '@expo/config-plugins';\nimport chalk from 'chalk';\n\nimport { copyTemplateFiles, createCopyFilesSuccessMessage } from './copyTemplateFiles';\nimport { cloneTemplateAsync } from './resolveTemplate';\nimport { DependenciesModificationResults, updatePackageJSONAsync } from './updatePackageJson';\nimport { validateTemplatePlatforms } from './validateTemplatePlatforms';\nimport * as Log from '../log';\nimport { AbortCommandError, SilentError } from '../utils/errors';\nimport { logNewSection } from '../utils/ora';\nimport { profile } from '../utils/profile';\n\n/**\n * Creates local native files from an input template file path.\n *\n * @return `true` if the project is prebuilding, and `false` if it's syncing.\n */\nexport async function updateFromTemplateAsync(\n projectRoot: string,\n {\n exp,\n pkg,\n template,\n templateDirectory,\n platforms,\n skipDependencyUpdate,\n }: {\n /** Expo Config */\n exp: ExpoConfig;\n /** package.json as JSON */\n pkg: PackageJSONConfig;\n /** Template reference ID. */\n template?: string;\n /** Directory to write the template to before copying into the project. */\n templateDirectory?: string;\n /** List of platforms to clone. */\n platforms: ModPlatform[];\n /** List of dependencies to skip updating. */\n skipDependencyUpdate?: string[];\n }\n): Promise<\n {\n /** Indicates if new files were created in the project. */\n hasNewProjectFiles: boolean;\n /** Indicates that the project needs to run `pod install` */\n needsPodInstall: boolean;\n /** The template checksum used to create the native project. */\n templateChecksum: string;\n } & DependenciesModificationResults\n> {\n if (!templateDirectory) {\n const temporary = await import('tempy');\n templateDirectory = temporary.directory();\n }\n\n const { copiedPaths, templateChecksum } = await profile(cloneTemplateAndCopyToProjectAsync)({\n projectRoot,\n template,\n templateDirectory,\n exp,\n platforms,\n });\n\n const depsResults = await profile(updatePackageJSONAsync)(projectRoot, {\n templateDirectory,\n pkg,\n skipDependencyUpdate,\n });\n\n return {\n hasNewProjectFiles: !!copiedPaths.length,\n // If the iOS folder changes or new packages are added, we should rerun pod install.\n needsPodInstall: copiedPaths.includes('ios') || !!depsResults.changedDependencies.length,\n templateChecksum,\n ...depsResults,\n };\n}\n\n/**\n * Extract the template and copy the ios and android directories over to the project directory.\n *\n * @return `true` if any project files were created.\n */\nexport async function cloneTemplateAndCopyToProjectAsync({\n projectRoot,\n templateDirectory,\n template,\n exp,\n platforms: unknownPlatforms,\n}: {\n projectRoot: string;\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n platforms: ModPlatform[];\n}): Promise<{ copiedPaths: string[]; templateChecksum: string }> {\n const platformDirectories = unknownPlatforms\n .map((platform) => `./${platform}`)\n .reverse()\n .join(' and ');\n\n const pluralized = unknownPlatforms.length > 1 ? 'directories' : 'directory';\n const ora = logNewSection(`Creating native ${pluralized} (${platformDirectories})`);\n\n try {\n const templateChecksum = await cloneTemplateAsync({ templateDirectory, template, exp, ora });\n\n const platforms = validateTemplatePlatforms({\n templateDirectory,\n platforms: unknownPlatforms,\n });\n\n const results = copyTemplateFiles(projectRoot, {\n templateDirectory,\n platforms,\n });\n\n ora.succeed(createCopyFilesSuccessMessage(platforms, results));\n\n return {\n copiedPaths: results.copiedPaths,\n templateChecksum,\n };\n } catch (e: any) {\n if (!(e instanceof AbortCommandError)) {\n Log.error(e.message);\n }\n ora.fail(`Failed to create the native ${pluralized}`);\n Log.log(\n chalk.yellow(\n chalk`You may want to delete the {bold ./ios} and/or {bold ./android} directories before trying again.`\n )\n );\n throw new SilentError(e);\n }\n}\n"],"names":["updateFromTemplateAsync","cloneTemplateAndCopyToProjectAsync","Log","projectRoot","exp","pkg","template","templateDirectory","platforms","skipDependencyUpdate","temporary","directory","copiedPaths","templateChecksum","profile","depsResults","updatePackageJSONAsync","hasNewProjectFiles","length","needsPodInstall","includes","changedDependencies","unknownPlatforms","platformDirectories","map","platform","reverse","join","pluralized","ora","logNewSection","cloneTemplateAsync","validateTemplatePlatforms","results","copyTemplateFiles","succeed","createCopyFilesSuccessMessage","e","AbortCommandError","error","message","fail","log","chalk","yellow","SilentError"],"mappings":"AAAA;;;;QAkBsBA,uBAAuB,GAAvBA,uBAAuB;QAkEvBC,kCAAkC,GAAlCA,kCAAkC;AAlFtC,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEwC,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACnD,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACkB,IAAA,kBAAqB,WAArB,qBA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C,OAAOwB,CAAC,EAAO;QACf,IAAI,CAAC,CAACA,CAAC,YAAYC,OAAiB,kBAAA,CAAC,EAAE;YACrCpC,GAAG,CAACqC,KAAK,CAACF,CAAC,CAACG,OAAO,CAAC,CAAC;SACtB;QACDX,GAAG,CAACY,IAAI,CAAC,CAAC,4BAA4B,EAAEb,UAAU,CAAC,CAAC,CAAC,CAAC;QACtD1B,GAAG,CAACwC,GAAG,CACLC,MAAK,QAAA,CAACC,MAAM,CACVD,MAAK,QAAA,CAAC,gGAAgG,CAAC,CACxG,CACF,CAAC;QACF,MAAM,IAAIE,OAAW,YAAA,CAACR,CAAC,CAAC,CAAC;KAC1B;CACF"}
|
|
@@ -91,9 +91,8 @@ skipPrompt =!(0, _interactive).isInteractive() , isProjectMutable =(0, _interact
|
|
|
91
91
|
// Reset the title so it doesn't print twice in interactive mode.
|
|
92
92
|
title = "";
|
|
93
93
|
}
|
|
94
|
-
const installCommand =
|
|
95
|
-
|
|
96
|
-
});
|
|
94
|
+
const installCommand = "npx expo install " + missing.map(({ pkg })=>pkg
|
|
95
|
+
).join(", ");
|
|
97
96
|
const disableMessage = warningMessage;
|
|
98
97
|
const solution = `Please install ${_chalk.default.bold(readableMissingPackages)} by running:\n\n ${_chalk.default.reset.bold(installCommand)}\n\n`;
|
|
99
98
|
// This prevents users from starting a misconfigured JS or TS project by default.
|
|
@@ -103,15 +102,8 @@ skipPrompt =!(0, _interactive).isInteractive() , isProjectMutable =(0, _interact
|
|
|
103
102
|
return (0, _wrapAnsi).default(message, process.stdout.columns || 80);
|
|
104
103
|
}
|
|
105
104
|
function createInstallCommand({ packages }) {
|
|
106
|
-
return "npx expo install " + packages.map(({ pkg
|
|
107
|
-
|
|
108
|
-
return [
|
|
109
|
-
pkg,
|
|
110
|
-
version
|
|
111
|
-
].join("@");
|
|
112
|
-
}
|
|
113
|
-
return pkg;
|
|
114
|
-
}).join(" ");
|
|
105
|
+
return "npx expo install " + packages.map(({ pkg })=>pkg
|
|
106
|
+
).join(" ");
|
|
115
107
|
}
|
|
116
108
|
/** Install packages in the project. */ async function installPackagesAsync(projectRoot, { packages }) {
|
|
117
109
|
const packagesStr = _chalk.default.bold(packages.join(", "));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/ensureDependenciesAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nimport { getMissingPackagesAsync, ResolvedPackage } from './getMissingPackages';\nimport { installAsync } from '../../../install/installAsync';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { logNewSection } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\n\nexport async function ensureDependenciesAsync(\n projectRoot: string,\n {\n exp = getConfig(projectRoot).exp,\n requiredPackages,\n warningMessage,\n installMessage,\n // Don't prompt in CI\n skipPrompt = !isInteractive(),\n isProjectMutable = isInteractive(),\n }: {\n exp?: ExpoConfig;\n installMessage: string;\n warningMessage: string;\n requiredPackages: ResolvedPackage[];\n skipPrompt?: boolean;\n /** Project can be mutated in the current environment. */\n isProjectMutable?: boolean;\n }\n): Promise<boolean> {\n const { missing } = await getMissingPackagesAsync(projectRoot, {\n sdkVersion: exp.sdkVersion,\n requiredPackages,\n });\n if (!missing.length) {\n return true;\n }\n\n // Prompt to install or bail out...\n const readableMissingPackages = missing\n .map(({ pkg, version }) => (version ? [pkg, version].join('@') : pkg))\n .join(', ');\n\n let title = installMessage;\n\n if (skipPrompt && !isProjectMutable) {\n title += '\\n\\n';\n } else {\n let confirm = skipPrompt;\n if (skipPrompt) {\n // Automatically install packages without prompting.\n Log.log(wrapForTerminal(title + ` Installing ${chalk.cyan(readableMissingPackages)}`));\n } else {\n confirm = await confirmAsync({\n message: wrapForTerminal(\n title + ` Would you like to install ${chalk.cyan(readableMissingPackages)}?`\n ),\n initial: true,\n });\n }\n\n if (confirm) {\n // Format with version if available.\n const packages = missing.map(({ pkg, version }) =>\n version ? [pkg, version].join('@') : pkg\n );\n // Install packages with versions\n await installPackagesAsync(projectRoot, {\n packages,\n });\n // Try again but skip prompting twice, simply fail if the packages didn't install correctly.\n return await ensureDependenciesAsync(projectRoot, {\n skipPrompt: true,\n installMessage,\n warningMessage,\n requiredPackages,\n });\n }\n\n // Reset the title so it doesn't print twice in interactive mode.\n title = '';\n }\n\n const installCommand =
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/dependencies/ensureDependenciesAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport wrapAnsi from 'wrap-ansi';\n\nimport { getMissingPackagesAsync, ResolvedPackage } from './getMissingPackages';\nimport { installAsync } from '../../../install/installAsync';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { logNewSection } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\n\nexport async function ensureDependenciesAsync(\n projectRoot: string,\n {\n exp = getConfig(projectRoot).exp,\n requiredPackages,\n warningMessage,\n installMessage,\n // Don't prompt in CI\n skipPrompt = !isInteractive(),\n isProjectMutable = isInteractive(),\n }: {\n exp?: ExpoConfig;\n installMessage: string;\n warningMessage: string;\n requiredPackages: ResolvedPackage[];\n skipPrompt?: boolean;\n /** Project can be mutated in the current environment. */\n isProjectMutable?: boolean;\n }\n): Promise<boolean> {\n const { missing } = await getMissingPackagesAsync(projectRoot, {\n sdkVersion: exp.sdkVersion,\n requiredPackages,\n });\n if (!missing.length) {\n return true;\n }\n\n // Prompt to install or bail out...\n const readableMissingPackages = missing\n .map(({ pkg, version }) => (version ? [pkg, version].join('@') : pkg))\n .join(', ');\n\n let title = installMessage;\n\n if (skipPrompt && !isProjectMutable) {\n title += '\\n\\n';\n } else {\n let confirm = skipPrompt;\n if (skipPrompt) {\n // Automatically install packages without prompting.\n Log.log(wrapForTerminal(title + ` Installing ${chalk.cyan(readableMissingPackages)}`));\n } else {\n confirm = await confirmAsync({\n message: wrapForTerminal(\n title + ` Would you like to install ${chalk.cyan(readableMissingPackages)}?`\n ),\n initial: true,\n });\n }\n\n if (confirm) {\n // Format with version if available.\n const packages = missing.map(({ pkg, version }) =>\n version ? [pkg, version].join('@') : pkg\n );\n // Install packages with versions\n await installPackagesAsync(projectRoot, {\n packages,\n });\n // Try again but skip prompting twice, simply fail if the packages didn't install correctly.\n return await ensureDependenciesAsync(projectRoot, {\n skipPrompt: true,\n installMessage,\n warningMessage,\n requiredPackages,\n });\n }\n\n // Reset the title so it doesn't print twice in interactive mode.\n title = '';\n }\n\n const installCommand = 'npx expo install ' + missing.map(({ pkg }) => pkg).join(', ');\n\n const disableMessage = warningMessage;\n\n const solution = `Please install ${chalk.bold(\n readableMissingPackages\n )} by running:\\n\\n ${chalk.reset.bold(installCommand)}\\n\\n`;\n\n // This prevents users from starting a misconfigured JS or TS project by default.\n throw new CommandError(wrapForTerminal(title + solution + disableMessage + '\\n'));\n}\n\n/** Wrap long messages to fit smaller terminals. */\nfunction wrapForTerminal(message: string): string {\n return wrapAnsi(message, process.stdout.columns || 80);\n}\n\n/** Create the bash install command from a given set of packages and settings. */\nexport function createInstallCommand({\n packages,\n}: {\n packages: {\n file: string;\n pkg: string;\n version?: string | undefined;\n }[];\n}) {\n return 'npx expo install ' + packages.map(({ pkg }) => pkg).join(' ');\n}\n\n/** Install packages in the project. */\nasync function installPackagesAsync(projectRoot: string, { packages }: { packages: string[] }) {\n const packagesStr = chalk.bold(packages.join(', '));\n Log.log();\n const installingPackageStep = logNewSection(`Installing ${packagesStr}`);\n try {\n await installAsync(packages, { projectRoot });\n } catch (e: any) {\n installingPackageStep.fail(`Failed to install ${packagesStr} with error: ${e.message}`);\n throw e;\n }\n installingPackageStep.succeed(`Installed ${packagesStr}`);\n}\n"],"names":["ensureDependenciesAsync","createInstallCommand","Log","projectRoot","exp","getConfig","requiredPackages","warningMessage","installMessage","skipPrompt","isInteractive","isProjectMutable","missing","getMissingPackagesAsync","sdkVersion","length","readableMissingPackages","map","pkg","version","join","title","confirm","log","wrapForTerminal","chalk","cyan","confirmAsync","message","initial","packages","installPackagesAsync","installCommand","disableMessage","solution","bold","reset","CommandError","wrapAnsi","process","stdout","columns","packagesStr","installingPackageStep","logNewSection","installAsync","e","fail","succeed"],"mappings":"AAAA;;;;QAYsBA,uBAAuB,GAAvBA,uBAAuB;QA2F7BC,oBAAoB,GAApBA,oBAAoB;AAvGE,IAAA,OAAc,WAAd,cAAc,CAAA;AAClC,IAAA,MAAO,kCAAP,OAAO,EAAA;AACJ,IAAA,SAAW,kCAAX,WAAW,EAAA;AAEyB,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAClD,IAAA,aAA+B,WAA/B,+BAA+B,CAAA;AAChDC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACtB,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AAC5B,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACrB,IAAA,QAAwB,WAAxB,wBAAwB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,eAAeF,uBAAuB,CAC3CG,WAAmB,EACnB,EACEC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAa,CAAA,UAAb,CAACF,WAAW,CAAC,CAACC,GAAG,CAAA,EAChCE,gBAAgB,CAAA,EAChBC,cAAc,CAAA,EACdC,cAAc,CAAA,EACd,qBAAqB;AACrBC,UAAU,EAAG,CAACC,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,CAAA,EAC7BC,gBAAgB,EAAGD,CAAAA,GAAAA,YAAa,AAAE,CAAA,cAAF,EAAE,CAAA,EASnC,EACiB;IAClB,MAAM,EAAEE,OAAO,CAAA,EAAE,GAAG,MAAMC,CAAAA,GAAAA,mBAAuB,AAG/C,CAAA,wBAH+C,CAACV,WAA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;IAAA,CAAC,CAACE,IAAI,CAAC,GAAG,CAAC,CAAC;CACvE;AAED,uCAAuC,CACvC,eAAeW,oBAAoB,CAAC5B,WAAmB,EAAE,EAAE2B,QAAQ,CAAA,EAA0B,EAAE;IAC7F,MAAMY,WAAW,GAAGjB,MAAK,QAAA,CAACU,IAAI,CAACL,QAAQ,CAACV,IAAI,CAAC,IAAI,CAAC,CAAC,AAAC;IACpDlB,GAAG,CAACqB,GAAG,EAAE,CAAC;IACV,MAAMoB,qBAAqB,GAAGC,CAAAA,GAAAA,IAAa,AAA6B,CAAA,cAA7B,CAAC,CAAC,WAAW,EAAEF,WAAW,CAAC,CAAC,CAAC,AAAC;IACzE,IAAI;QACF,MAAMG,CAAAA,GAAAA,aAAY,AAA2B,CAAA,aAA3B,CAACf,QAAQ,EAAE;YAAE3B,WAAW;SAAE,CAAC,CAAC;KAC/C,CAAC,OAAO2C,CAAC,EAAO;QACfH,qBAAqB,CAACI,IAAI,CAAC,CAAC,kBAAkB,EAAEL,WAAW,CAAC,aAAa,EAAEI,CAAC,CAAClB,OAAO,CAAC,CAAC,CAAC,CAAC;QACxF,MAAMkB,CAAC,CAAC;KACT;IACDH,qBAAqB,CAACK,OAAO,CAAC,CAAC,UAAU,EAAEN,WAAW,CAAC,CAAC,CAAC,CAAC;CAC3D"}
|
|
@@ -73,7 +73,7 @@ class WebSupportProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
|
|
|
73
73
|
pkg: "react-dom"
|
|
74
74
|
},
|
|
75
75
|
];
|
|
76
|
-
const bundler = (0, _platformBundlers).getPlatformBundlers(exp).web;
|
|
76
|
+
const bundler = (0, _platformBundlers).getPlatformBundlers(this.projectRoot, exp).web;
|
|
77
77
|
// Only include webpack-config if bundler is webpack.
|
|
78
78
|
if (bundler === "webpack") {
|
|
79
79
|
requiredPackages.push(// `webpack` and `webpack-dev-server` should be installed in the `@expo/webpack-config`
|
|
@@ -82,6 +82,11 @@ class WebSupportProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
|
|
|
82
82
|
pkg: "@expo/webpack-config",
|
|
83
83
|
dev: true
|
|
84
84
|
});
|
|
85
|
+
} else if (bundler === "metro") {
|
|
86
|
+
requiredPackages.push({
|
|
87
|
+
file: "@expo/metro-runtime/package.json",
|
|
88
|
+
pkg: "@expo/metro-runtime"
|
|
89
|
+
});
|
|
85
90
|
}
|
|
86
91
|
try {
|
|
87
92
|
return await (0, _ensureDependenciesAsync).ensureDependenciesAsync(this.projectRoot, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/doctor/web/WebSupportProjectPrerequisite.ts"],"sourcesContent":["import {\n AppJSONConfig,\n ExpoConfig,\n getConfig,\n getProjectConfigDescriptionWithPaths,\n ProjectConfig,\n} from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { getPlatformBundlers } from '../../server/platformBundlers';\nimport { PrerequisiteCommandError, ProjectPrerequisite } from '../Prerequisite';\nimport { ensureDependenciesAsync } from '../dependencies/ensureDependenciesAsync';\nimport { ResolvedPackage } from '../dependencies/getMissingPackages';\n\nconst debug = require('debug')('expo:doctor:webSupport') as typeof console.log;\n\n/** Ensure the project has the required web support settings. */\nexport class WebSupportProjectPrerequisite extends ProjectPrerequisite {\n /** Ensure a project that hasn't explicitly disabled web support has all the required packages for running in the browser. */\n async assertImplementation(): Promise<void> {\n if (env.EXPO_NO_WEB_SETUP) {\n Log.warn('Skipping web setup: EXPO_NO_WEB_SETUP is enabled.');\n return;\n }\n debug('Ensuring web support is setup');\n\n const result = await this._shouldSetupWebSupportAsync();\n\n // Ensure web packages are installed\n await this._ensureWebDependenciesInstalledAsync({ exp: result.exp });\n }\n\n /** Exposed for testing. */\n async _shouldSetupWebSupportAsync(): Promise<ProjectConfig> {\n const config = getConfig(this.projectRoot);\n\n // Detect if the 'web' string is purposefully missing from the platforms array.\n if (isWebPlatformExcluded(config.rootConfig)) {\n // Get exact config description with paths.\n const configName = getProjectConfigDescriptionWithPaths(this.projectRoot, config);\n throw new PrerequisiteCommandError(\n 'WEB_SUPPORT',\n chalk`Skipping web setup: {bold \"web\"} is not included in the project ${configName} {bold \"platforms\"} array.`\n );\n }\n\n return config;\n }\n\n /** Exposed for testing. */\n async _ensureWebDependenciesInstalledAsync({ exp }: { exp: ExpoConfig }): Promise<boolean> {\n const requiredPackages: ResolvedPackage[] = [\n // use react-native-web/package.json to skip node module cache issues when the user installs\n // the package and attempts to resolve the module in the same process.\n { file: 'react-native-web/package.json', pkg: 'react-native-web' },\n { file: 'react-dom/package.json', pkg: 'react-dom' },\n ];\n\n const bundler = getPlatformBundlers(exp).web;\n // Only include webpack-config if bundler is webpack.\n if (bundler === 'webpack') {\n requiredPackages.push(\n // `webpack` and `webpack-dev-server` should be installed in the `@expo/webpack-config`\n {\n file: '@expo/webpack-config/package.json',\n pkg: '@expo/webpack-config',\n dev: true,\n }\n );\n }\n\n try {\n return await ensureDependenciesAsync(this.projectRoot, {\n // This never seems to work when prompting, installing, and running -- instead just inform the user to run the install command and try again.\n skipPrompt: true,\n isProjectMutable: false,\n exp,\n installMessage: `It looks like you're trying to use web support but don't have the required dependencies installed.`,\n warningMessage: chalk`If you're not using web, please ensure you remove the {bold \"web\"} string from the platforms array in the project Expo config.`,\n requiredPackages,\n });\n } catch (error) {\n // Reset the cached check so we can re-run the check if the user re-runs the command by pressing 'w' in the Terminal UI.\n this.resetAssertion();\n throw error;\n }\n }\n}\n\n/** Return `true` if the `web` platform is purposefully excluded from the project Expo config. */\nexport function isWebPlatformExcluded(rootConfig: AppJSONConfig): boolean {\n // Detect if the 'web' string is purposefully missing from the platforms array.\n const isWebExcluded =\n Array.isArray(rootConfig.expo?.platforms) &&\n !!rootConfig.expo?.platforms.length &&\n !rootConfig.expo?.platforms.includes('web');\n return isWebExcluded;\n}\n"],"names":["isWebPlatformExcluded","Log","debug","require","WebSupportProjectPrerequisite","ProjectPrerequisite","assertImplementation","env","EXPO_NO_WEB_SETUP","warn","result","_shouldSetupWebSupportAsync","_ensureWebDependenciesInstalledAsync","exp","config","getConfig","projectRoot","rootConfig","configName","getProjectConfigDescriptionWithPaths","PrerequisiteCommandError","chalk","requiredPackages","file","pkg","bundler","getPlatformBundlers","web","push","dev","ensureDependenciesAsync","skipPrompt","isProjectMutable","installMessage","warningMessage","error","resetAssertion","isWebExcluded","Array","isArray","expo","platforms","length","includes"],"mappings":"AAAA;;;;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/doctor/web/WebSupportProjectPrerequisite.ts"],"sourcesContent":["import {\n AppJSONConfig,\n ExpoConfig,\n getConfig,\n getProjectConfigDescriptionWithPaths,\n ProjectConfig,\n} from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { getPlatformBundlers } from '../../server/platformBundlers';\nimport { PrerequisiteCommandError, ProjectPrerequisite } from '../Prerequisite';\nimport { ensureDependenciesAsync } from '../dependencies/ensureDependenciesAsync';\nimport { ResolvedPackage } from '../dependencies/getMissingPackages';\n\nconst debug = require('debug')('expo:doctor:webSupport') as typeof console.log;\n\n/** Ensure the project has the required web support settings. */\nexport class WebSupportProjectPrerequisite extends ProjectPrerequisite {\n /** Ensure a project that hasn't explicitly disabled web support has all the required packages for running in the browser. */\n async assertImplementation(): Promise<void> {\n if (env.EXPO_NO_WEB_SETUP) {\n Log.warn('Skipping web setup: EXPO_NO_WEB_SETUP is enabled.');\n return;\n }\n debug('Ensuring web support is setup');\n\n const result = await this._shouldSetupWebSupportAsync();\n\n // Ensure web packages are installed\n await this._ensureWebDependenciesInstalledAsync({ exp: result.exp });\n }\n\n /** Exposed for testing. */\n async _shouldSetupWebSupportAsync(): Promise<ProjectConfig> {\n const config = getConfig(this.projectRoot);\n\n // Detect if the 'web' string is purposefully missing from the platforms array.\n if (isWebPlatformExcluded(config.rootConfig)) {\n // Get exact config description with paths.\n const configName = getProjectConfigDescriptionWithPaths(this.projectRoot, config);\n throw new PrerequisiteCommandError(\n 'WEB_SUPPORT',\n chalk`Skipping web setup: {bold \"web\"} is not included in the project ${configName} {bold \"platforms\"} array.`\n );\n }\n\n return config;\n }\n\n /** Exposed for testing. */\n async _ensureWebDependenciesInstalledAsync({ exp }: { exp: ExpoConfig }): Promise<boolean> {\n const requiredPackages: ResolvedPackage[] = [\n // use react-native-web/package.json to skip node module cache issues when the user installs\n // the package and attempts to resolve the module in the same process.\n { file: 'react-native-web/package.json', pkg: 'react-native-web' },\n { file: 'react-dom/package.json', pkg: 'react-dom' },\n ];\n\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n // Only include webpack-config if bundler is webpack.\n if (bundler === 'webpack') {\n requiredPackages.push(\n // `webpack` and `webpack-dev-server` should be installed in the `@expo/webpack-config`\n {\n file: '@expo/webpack-config/package.json',\n pkg: '@expo/webpack-config',\n dev: true,\n }\n );\n } else if (bundler === 'metro') {\n requiredPackages.push({\n file: '@expo/metro-runtime/package.json',\n pkg: '@expo/metro-runtime',\n });\n }\n\n try {\n return await ensureDependenciesAsync(this.projectRoot, {\n // This never seems to work when prompting, installing, and running -- instead just inform the user to run the install command and try again.\n skipPrompt: true,\n isProjectMutable: false,\n exp,\n installMessage: `It looks like you're trying to use web support but don't have the required dependencies installed.`,\n warningMessage: chalk`If you're not using web, please ensure you remove the {bold \"web\"} string from the platforms array in the project Expo config.`,\n requiredPackages,\n });\n } catch (error) {\n // Reset the cached check so we can re-run the check if the user re-runs the command by pressing 'w' in the Terminal UI.\n this.resetAssertion();\n throw error;\n }\n }\n}\n\n/** Return `true` if the `web` platform is purposefully excluded from the project Expo config. */\nexport function isWebPlatformExcluded(rootConfig: AppJSONConfig): boolean {\n // Detect if the 'web' string is purposefully missing from the platforms array.\n const isWebExcluded =\n Array.isArray(rootConfig.expo?.platforms) &&\n !!rootConfig.expo?.platforms.length &&\n !rootConfig.expo?.platforms.includes('web');\n return isWebExcluded;\n}\n"],"names":["isWebPlatformExcluded","Log","debug","require","WebSupportProjectPrerequisite","ProjectPrerequisite","assertImplementation","env","EXPO_NO_WEB_SETUP","warn","result","_shouldSetupWebSupportAsync","_ensureWebDependenciesInstalledAsync","exp","config","getConfig","projectRoot","rootConfig","configName","getProjectConfigDescriptionWithPaths","PrerequisiteCommandError","chalk","requiredPackages","file","pkg","bundler","getPlatformBundlers","web","push","dev","ensureDependenciesAsync","skipPrompt","isProjectMutable","installMessage","warningMessage","error","resetAssertion","isWebExcluded","Array","isArray","expo","platforms","length","includes"],"mappings":"AAAA;;;;QAiGgBA,qBAAqB,GAArBA,qBAAqB;AA3F9B,IAAA,OAAc,WAAd,cAAc,CAAA;AACH,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACJ,IAAA,iBAA+B,WAA/B,+BAA+B,CAAA;AACL,IAAA,aAAiB,WAAjB,iBAAiB,CAAA;AACvC,IAAA,wBAAyC,WAAzC,yCAAyC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGjF,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,AAAsB,AAAC;AAGxE,MAAMC,6BAA6B,SAASC,aAAmB,oBAAA;IACpE,6HAA6H,CAC7H,MAAMC,oBAAoB,GAAkB;QAC1C,IAAIC,IAAG,IAAA,CAACC,iBAAiB,EAAE;YACzBP,GAAG,CAACQ,IAAI,CAAC,mDAAmD,CAAC,CAAC;YAC9D,OAAO;SACR;QACDP,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAEvC,MAAMQ,MAAM,GAAG,MAAM,IAAI,CAACC,2BAA2B,EAAE,AAAC;QAExD,oCAAoC;QACpC,MAAM,IAAI,CAACC,oCAAoC,CAAC;YAAEC,GAAG,EAAEH,MAAM,CAACG,GAAG;SAAE,CAAC,CAAC;KACtE;IAED,2BAA2B,CAC3B,MAAMF,2BAA2B,GAA2B;QAC1D,MAAMG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AC;SACJ;QAED,IAAI;YACF,OAAO,MAAMM,CAAAA,GAAAA,wBAAuB,AAQlC,CAAA,wBARkC,CAAC,IAAI,CAACd,WAAW,EAAE;gBACrD,6IAA6I;gBAC7Ie,UAAU,EAAE,IAAI;gBAChBC,gBAAgB,EAAE,KAAK;gBACvBnB,GAAG;gBACHoB,cAAc,EAAE,CAAC,kGAAkG,CAAC;gBACpHC,cAAc,EAAEb,MAAK,QAAA,CAAC,8HAA8H,CAAC;gBACrJC,gBAAgB;aACjB,CAAC,CAAC;SACJ,CAAC,OAAOa,KAAK,EAAE;YACd,wHAAwH;YACxH,IAAI,CAACC,cAAc,EAAE,CAAC;YACtB,MAAMD,KAAK,CAAC;SACb;KACF;CACF;QA3EY/B,6BAA6B,GAA7BA,6BAA6B;AA8EnC,SAASJ,qBAAqB,CAACiB,UAAyB,EAAW;QAGxDA,GAAe,EAC3BA,IAAe,EAChBA,IAAe;IAJlB,+EAA+E;IAC/E,MAAMoB,aAAa,GACjBC,KAAK,CAACC,OAAO,CAACtB,CAAAA,GAAe,GAAfA,UAAU,CAACuB,IAAI,SAAW,GAA1BvB,KAAAA,CAA0B,GAA1BA,GAAe,CAAEwB,SAAS,CAAC,IACzC,CAAC,EAACxB,CAAAA,IAAe,GAAfA,UAAU,CAACuB,IAAI,SAAW,GAA1BvB,KAAAA,CAA0B,GAA1BA,IAAe,CAAEwB,SAAS,CAACC,MAAM,CAAA,IACnC,CAACzB,CAAAA,CAAAA,IAAe,GAAfA,UAAU,CAACuB,IAAI,SAAW,GAA1BvB,KAAAA,CAA0B,GAA1BA,IAAe,CAAEwB,SAAS,CAACE,QAAQ,CAAC,KAAK,CAAC,CAAA,AAAC;IAC9C,OAAON,aAAa,CAAC;CACtB"}
|
|
@@ -6,6 +6,7 @@ var _spawnAsync = _interopRequireDefault(require("@expo/spawn-async"));
|
|
|
6
6
|
var _childProcess = require("child_process");
|
|
7
7
|
var _androidSdk = require("./AndroidSdk");
|
|
8
8
|
var _log = require("../../../log");
|
|
9
|
+
var _env = require("../../../utils/env");
|
|
9
10
|
var _errors = require("../../../utils/errors");
|
|
10
11
|
var _exit = require("../../../utils/exit");
|
|
11
12
|
function _interopRequireDefault(obj) {
|
|
@@ -99,6 +100,12 @@ class ADBServer {
|
|
|
99
100
|
if (error.signal === "SIGINT") {
|
|
100
101
|
throw new _errors.AbortCommandError();
|
|
101
102
|
}
|
|
103
|
+
if (error.status === 255 && error.stdout.includes("Bad user number")) {
|
|
104
|
+
var ref;
|
|
105
|
+
var ref1;
|
|
106
|
+
const userNumber = (ref1 = (ref = error.stdout.match(/Bad user number: (.+)/)) == null ? void 0 : ref[1]) != null ? ref1 : _env.env.EXPO_ADB_USER;
|
|
107
|
+
throw new _errors.CommandError("EXPO_ADB_USER", `Invalid ADB user number "${userNumber}" set with environment variable EXPO_ADB_USER. Run "adb shell pm list users" to see valid user numbers.`);
|
|
108
|
+
}
|
|
102
109
|
// TODO: Support heap corruption for adb 29 (process exits with code -1073740940) (windows and linux)
|
|
103
110
|
let errorMessage = (error.stderr || error.stdout || error.message).trim();
|
|
104
111
|
if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/platforms/android/ADBServer.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { execFileSync } from 'child_process';\n\nimport { assertSdkRoot } from './AndroidSdk';\nimport { Log } from '../../../log';\nimport { AbortCommandError } from '../../../utils/errors';\nimport { installExitHooks } from '../../../utils/exit';\n\nconst debug = require('debug')('expo:start:platforms:android:adbServer') as typeof console.log;\n\nconst BEGINNING_OF_ADB_ERROR_MESSAGE = 'error: ';\n\n// This is a tricky class since it controls a system state (side-effects).\n// A more ideal solution would be to implement ADB in JS.\n// The main reason this is a class is to control the flow of testing.\n\nexport class ADBServer {\n isRunning: boolean = false;\n removeExitHook: () => void = () => {};\n\n /** Returns the command line reference to ADB. */\n getAdbExecutablePath(): string {\n try {\n const sdkRoot = assertSdkRoot();\n if (sdkRoot) {\n return `${sdkRoot}/platform-tools/adb`;\n }\n } catch (error: any) {\n Log.warn(error.message);\n }\n\n Log.debug('Failed to resolve the Android SDK path, falling back to global adb executable');\n return 'adb';\n }\n\n /** Start the ADB server. */\n async startAsync(): Promise<boolean> {\n if (this.isRunning) {\n return false;\n }\n // clean up\n this.removeExitHook = installExitHooks(() => {\n if (this.isRunning) {\n this.stopAsync();\n }\n });\n const adb = this.getAdbExecutablePath();\n const result = await this.resolveAdbPromise(spawnAsync(adb, ['start-server']));\n const lines = result.stderr.trim().split(/\\r?\\n/);\n const isStarted = lines.includes('* daemon started successfully');\n this.isRunning = isStarted;\n return isStarted;\n }\n\n /** Kill the ADB server. */\n async stopAsync(): Promise<boolean> {\n debug('Stopping ADB server');\n\n if (!this.isRunning) {\n debug('ADB server is not running');\n return false;\n }\n this.removeExitHook();\n try {\n await this.runAsync(['kill-server']);\n return true;\n } catch (error: any) {\n Log.error('Failed to stop ADB server: ' + error.message);\n return false;\n } finally {\n debug('Stopped ADB server');\n this.isRunning = false;\n }\n }\n\n /** Execute an ADB command with given args. */\n async runAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n debug([adb, ...args].join(' '));\n const result = await this.resolveAdbPromise(spawnAsync(adb, args));\n return result.output.join('\\n');\n }\n\n /** Get ADB file output. Useful for reading device state/settings. */\n async getFileOutputAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n const results = await this.resolveAdbPromise(\n execFileSync(adb, args, {\n encoding: 'latin1',\n stdio: 'pipe',\n })\n );\n debug('[ADB] File output:\\n', results);\n return results;\n }\n\n /** Formats error info. */\n async resolveAdbPromise<T>(promise: T | Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error: any) {\n // User pressed ctrl+c to cancel the process...\n if (error.signal === 'SIGINT') {\n throw new AbortCommandError();\n }\n // TODO: Support heap corruption for adb 29 (process exits with code -1073740940) (windows and linux)\n let errorMessage = (error.stderr || error.stdout || error.message).trim();\n if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {\n errorMessage = errorMessage.substring(BEGINNING_OF_ADB_ERROR_MESSAGE.length);\n }\n error.message = errorMessage;\n throw error;\n }\n }\n}\n"],"names":["debug","require","BEGINNING_OF_ADB_ERROR_MESSAGE","ADBServer","isRunning","removeExitHook","getAdbExecutablePath","sdkRoot","assertSdkRoot","error","Log","warn","message","startAsync","installExitHooks","stopAsync","adb","result","resolveAdbPromise","spawnAsync","lines","stderr","trim","split","isStarted","includes","runAsync","args","join","output","getFileOutputAsync","results","execFileSync","encoding","stdio","promise","signal","AbortCommandError","
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/android/ADBServer.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { execFileSync } from 'child_process';\n\nimport { assertSdkRoot } from './AndroidSdk';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { AbortCommandError, CommandError } from '../../../utils/errors';\nimport { installExitHooks } from '../../../utils/exit';\n\nconst debug = require('debug')('expo:start:platforms:android:adbServer') as typeof console.log;\n\nconst BEGINNING_OF_ADB_ERROR_MESSAGE = 'error: ';\n\n// This is a tricky class since it controls a system state (side-effects).\n// A more ideal solution would be to implement ADB in JS.\n// The main reason this is a class is to control the flow of testing.\n\nexport class ADBServer {\n isRunning: boolean = false;\n removeExitHook: () => void = () => {};\n\n /** Returns the command line reference to ADB. */\n getAdbExecutablePath(): string {\n try {\n const sdkRoot = assertSdkRoot();\n if (sdkRoot) {\n return `${sdkRoot}/platform-tools/adb`;\n }\n } catch (error: any) {\n Log.warn(error.message);\n }\n\n Log.debug('Failed to resolve the Android SDK path, falling back to global adb executable');\n return 'adb';\n }\n\n /** Start the ADB server. */\n async startAsync(): Promise<boolean> {\n if (this.isRunning) {\n return false;\n }\n // clean up\n this.removeExitHook = installExitHooks(() => {\n if (this.isRunning) {\n this.stopAsync();\n }\n });\n const adb = this.getAdbExecutablePath();\n const result = await this.resolveAdbPromise(spawnAsync(adb, ['start-server']));\n const lines = result.stderr.trim().split(/\\r?\\n/);\n const isStarted = lines.includes('* daemon started successfully');\n this.isRunning = isStarted;\n return isStarted;\n }\n\n /** Kill the ADB server. */\n async stopAsync(): Promise<boolean> {\n debug('Stopping ADB server');\n\n if (!this.isRunning) {\n debug('ADB server is not running');\n return false;\n }\n this.removeExitHook();\n try {\n await this.runAsync(['kill-server']);\n return true;\n } catch (error: any) {\n Log.error('Failed to stop ADB server: ' + error.message);\n return false;\n } finally {\n debug('Stopped ADB server');\n this.isRunning = false;\n }\n }\n\n /** Execute an ADB command with given args. */\n async runAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n debug([adb, ...args].join(' '));\n const result = await this.resolveAdbPromise(spawnAsync(adb, args));\n return result.output.join('\\n');\n }\n\n /** Get ADB file output. Useful for reading device state/settings. */\n async getFileOutputAsync(args: string[]): Promise<string> {\n // TODO: Add a global package that installs adb to the path.\n const adb = this.getAdbExecutablePath();\n\n await this.startAsync();\n\n const results = await this.resolveAdbPromise(\n execFileSync(adb, args, {\n encoding: 'latin1',\n stdio: 'pipe',\n })\n );\n debug('[ADB] File output:\\n', results);\n return results;\n }\n\n /** Formats error info. */\n async resolveAdbPromise<T>(promise: T | Promise<T>): Promise<T> {\n try {\n return await promise;\n } catch (error: any) {\n // User pressed ctrl+c to cancel the process...\n if (error.signal === 'SIGINT') {\n throw new AbortCommandError();\n }\n if (error.status === 255 && error.stdout.includes('Bad user number')) {\n const userNumber = error.stdout.match(/Bad user number: (.+)/)?.[1] ?? env.EXPO_ADB_USER;\n throw new CommandError(\n 'EXPO_ADB_USER',\n `Invalid ADB user number \"${userNumber}\" set with environment variable EXPO_ADB_USER. Run \"adb shell pm list users\" to see valid user numbers.`\n );\n }\n // TODO: Support heap corruption for adb 29 (process exits with code -1073740940) (windows and linux)\n let errorMessage = (error.stderr || error.stdout || error.message).trim();\n if (errorMessage.startsWith(BEGINNING_OF_ADB_ERROR_MESSAGE)) {\n errorMessage = errorMessage.substring(BEGINNING_OF_ADB_ERROR_MESSAGE.length);\n }\n\n error.message = errorMessage;\n throw error;\n }\n }\n}\n"],"names":["debug","require","BEGINNING_OF_ADB_ERROR_MESSAGE","ADBServer","isRunning","removeExitHook","getAdbExecutablePath","sdkRoot","assertSdkRoot","error","Log","warn","message","startAsync","installExitHooks","stopAsync","adb","result","resolveAdbPromise","spawnAsync","lines","stderr","trim","split","isStarted","includes","runAsync","args","join","output","getFileOutputAsync","results","execFileSync","encoding","stdio","promise","signal","AbortCommandError","status","stdout","userNumber","match","env","EXPO_ADB_USER","CommandError","errorMessage","startsWith","substring","length"],"mappings":"AAAA;;;;AAAuB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AACb,IAAA,aAAe,WAAf,eAAe,CAAA;AAEd,IAAA,WAAc,WAAd,cAAc,CAAA;AACxB,IAAA,IAAc,WAAd,cAAc,CAAA;AACd,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACQ,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACtC,IAAA,KAAqB,WAArB,qBAAqB,CAAA;;;;;;AAEtD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,wCAAwC,CAAC,AAAsB,AAAC;AAE/F,MAAMC,8BAA8B,GAAG,SAAS,AAAC;AAM1C,MAAMC,SAAS;IACpBC,SAAS,GAAY,KAAK,CAAC;IAC3BC,cAAc,GAAe,IAAM,EAAE,CAAC;IAEtC,iDAAiD,CACjDC,oBAAoB,GAAW;QAC7B,IAAI;YACF,MAAMC,OAAO,GAAGC,CAAAA,GAAAA,WAAa,AAAE,CAAA,cAAF,EAAE,AAAC;YAChC,IAAID,OAAO,EAAE;gBACX,OAAO,CAAC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@ -24,6 +24,7 @@ var _chalk = _interopRequireDefault(require("chalk"));
|
|
|
24
24
|
var _os = _interopRequireDefault(require("os"));
|
|
25
25
|
var _adbserver = require("./ADBServer");
|
|
26
26
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
27
|
+
var _env = require("../../../utils/env");
|
|
27
28
|
var _errors = require("../../../utils/errors");
|
|
28
29
|
var _link = require("../../../utils/link");
|
|
29
30
|
function _interopRequireDefault(obj) {
|
|
@@ -84,7 +85,7 @@ function logUnauthorized(device) {
|
|
|
84
85
|
Log.warn(`\nThis computer is not authorized for developing on ${_chalk.default.bold(device.name)}. ${_chalk.default.dim((0, _link).learnMore("https://expo.fyi/authorize-android-device"))}`);
|
|
85
86
|
}
|
|
86
87
|
async function isPackageInstalledAsync(device, androidPackage) {
|
|
87
|
-
const packages = await getServer().runAsync(adbArgs(device.pid, "shell", "pm", "list", "packages", androidPackage));
|
|
88
|
+
const packages = await getServer().runAsync(adbArgs(device.pid, "shell", "pm", "list", "packages", "--user", _env.env.EXPO_ADB_USER, androidPackage));
|
|
88
89
|
const lines = packages.split(/\r?\n/);
|
|
89
90
|
for(let i = 0; i < lines.length; i++){
|
|
90
91
|
const line = lines[i].trim();
|
|
@@ -114,14 +115,14 @@ async function openUrlAsync(device, { url }) {
|
|
|
114
115
|
return results;
|
|
115
116
|
}
|
|
116
117
|
async function uninstallAsync(device, { appId }) {
|
|
117
|
-
return await getServer().runAsync(adbArgs(device.pid, "uninstall", appId));
|
|
118
|
+
return await getServer().runAsync(adbArgs(device.pid, "uninstall", "--user", _env.env.EXPO_ADB_USER, appId));
|
|
118
119
|
}
|
|
119
120
|
async function getPackageInfoAsync(device, { appId }) {
|
|
120
121
|
return await getServer().runAsync(adbArgs(device.pid, "shell", "dumpsys", "package", appId));
|
|
121
122
|
}
|
|
122
123
|
async function installAsync(device, { filePath }) {
|
|
123
124
|
// TODO: Handle the `INSTALL_FAILED_INSUFFICIENT_STORAGE` error.
|
|
124
|
-
return await getServer().runAsync(adbArgs(device.pid, "install", "-r", "-d", filePath));
|
|
125
|
+
return await getServer().runAsync(adbArgs(device.pid, "install", "-r", "-d", "--user", _env.env.EXPO_ADB_USER, filePath));
|
|
125
126
|
}
|
|
126
127
|
function adbArgs(pid, ...options) {
|
|
127
128
|
const args = [];
|