@expo/cli 0.21.5 → 0.21.7

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 CHANGED
@@ -121,7 +121,7 @@ const args = (0, _arg().default)({
121
121
  });
122
122
  if (args["--version"]) {
123
123
  // Version is added in the build script.
124
- console.log("0.21.5");
124
+ console.log("0.21.7");
125
125
  process.exit(0);
126
126
  }
127
127
  if (args["--non-interactive"]) {
@@ -111,7 +111,7 @@ function wrapFetchWithCredentials(fetchFunction) {
111
111
  return response;
112
112
  } catch (error1) {
113
113
  // When running `expo start`, but wifi or internet has issues
114
- if ("code" in error1 && error1.code === "ENOTFOUND" || "cause" in error1 && "code" in error1.cause && error1.cause.code === "ENOTFOUND" // undici error handling
114
+ if (isNetworkError(error1) || "cause" in error1 && isNetworkError(error1.cause) // undici error handling
115
115
  ) {
116
116
  (0, _settings.disableNetwork)();
117
117
  throw new _errors.CommandError("OFFLINE", "Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.");
@@ -120,6 +120,20 @@ function wrapFetchWithCredentials(fetchFunction) {
120
120
  }
121
121
  };
122
122
  }
123
+ /**
124
+ * Determine if the provided error is related to a network issue.
125
+ * When this returns true, offline mode should be enabled.
126
+ * - `ENOTFOUND` is thrown when the DNS lookup failed
127
+ * - `UND_ERR_CONNECT_TIMEOUT` is thrown after DNS is resolved, but server can't be reached
128
+ *
129
+ * @see https://nodejs.org/api/errors.html
130
+ * @see https://github.com/nodejs/undici#network-address-family-autoselection
131
+ */ function isNetworkError(error) {
132
+ return "code" in error && error.code && [
133
+ "ENOTFOUND",
134
+ "UND_ERR_CONNECT_TIMEOUT"
135
+ ].includes(error.code);
136
+ }
123
137
  const fetchWithOffline = (0, _wrapFetchWithOffline.wrapFetchWithOffline)(_fetch.fetch);
124
138
  const fetchWithBaseUrl = (0, _wrapFetchWithBaseUrl.wrapFetchWithBaseUrl)(fetchWithOffline, (0, _endpoint.getExpoApiBaseUrl)() + "/v2/");
125
139
  const fetchWithProxy = (0, _wrapFetchWithProxy.wrapFetchWithProxy)(fetchWithBaseUrl);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport type { JSONValue } from '@expo/json-file';\nimport path from 'path';\n\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport type { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { fetch } from '../../utils/fetch';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport { getAccessToken, getSession } from '../user/UserSettings';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * An error defining that the server didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the client.\n */\nexport class UnexpectedServerData extends Error {\n readonly name = 'UnexpectedServerData';\n}\n\n/** Validate the response json contains `.data` property, or throw an unexpected server data error */\nexport function getResponseDataOrThrow<T = any>(json: unknown): T {\n if (!!json && typeof json === 'object' && 'data' in json) {\n return json.data as T;\n }\n\n throw new UnexpectedServerData(\n !!json && typeof json === 'object' ? JSON.stringify(json) : 'Unknown data received from server.'\n );\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const response = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n // Handle expected API errors (4xx)\n if (response.status >= 400 && response.status < 500) {\n const body = await response.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n\n return response;\n } catch (error: any) {\n // When running `expo start`, but wifi or internet has issues\n if (\n ('code' in error && error.code === 'ENOTFOUND') || // node-fetch error handling\n ('cause' in error && 'code' in error.cause && error.cause.code === 'ENOTFOUND') // undici error handling\n ) {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetch);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n const { FileSystemResponseCache } =\n require('./cache/FileSystemResponseCache') as typeof import('./cache/FileSystemResponseCache');\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemResponseCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["ApiV2Error","UnexpectedServerError","UnexpectedServerData","getResponseDataOrThrow","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","json","data","JSON","stringify","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","getAccessToken","authorization","getSession","sessionSecret","status","body","text","parse","errors","length","error","includes","cause","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","fetch","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","FileSystemResponseCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;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EAAEK,IAAAA,SAAiB,kBAAA,GAAE,GAAG,MAAM,CAAC,AAAC;AAE9F,MAAMC,cAAc,GAAGC,IAAAA,mBAAkB,mBAAA,EAACJ,gBAAgB,CAAC,AAAC;AAE5D,MAAM1B,oBAAoB,GAAG+B,IAAAA,sBAAqB,sBAAA,EAACpD,wBAAwB,CAACkD,cAAc,CAAC,CAAC,AAAC;AAMtF,SAASjD,iBAAiB,CAAC,EAChC6C,KAAK,EAAGzB,oBAAoB,CAAA,EAC5BgC,cAAc,CAAA,EACdC,GAAG,CAAA,EACHC,SAAS,CAAA,EAMV,EAAa;IACZ,oCAAoC;IACpC,IAAIA,SAAS,IAAIC,IAAG,IAAA,CAACC,SAAS,IAAID,IAAG,IAAA,CAACE,aAAa,EAAE;QACnD,OAAOZ,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAEa,uBAAuB,CAAA,EAAE,GAC/BC,OAAO,CAAC,iCAAiC,CAAC,AAAoD,AAAC;IAEjG,OAAOC,IAAAA,mBAAkB,mBAAA,EACvBf,KAAK,EACL,IAAIa,uBAAuB,CAAC;QAC1BN,cAAc,EAAES,KAAI,EAAA,QAAA,CAACC,IAAI,CAACC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,EAAEX,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;AACJ,CAAC;AAGM,MAAMpD,UAAU,GAAGkD,IAAAA,sBAAqB,sBAAA,EAACpD,wBAAwB,CAACkD,cAAc,CAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../../src/api/rest/client.ts"],"sourcesContent":["import { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport type { JSONValue } from '@expo/json-file';\nimport path from 'path';\n\nimport { wrapFetchWithCache } from './cache/wrapFetchWithCache';\nimport type { FetchLike } from './client.types';\nimport { wrapFetchWithBaseUrl } from './wrapFetchWithBaseUrl';\nimport { wrapFetchWithOffline } from './wrapFetchWithOffline';\nimport { wrapFetchWithProgress } from './wrapFetchWithProgress';\nimport { wrapFetchWithProxy } from './wrapFetchWithProxy';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { fetch } from '../../utils/fetch';\nimport { getExpoApiBaseUrl } from '../endpoint';\nimport { disableNetwork } from '../settings';\nimport { getAccessToken, getSession } from '../user/UserSettings';\n\nexport class ApiV2Error extends Error {\n readonly name = 'ApiV2Error';\n readonly code: string;\n readonly expoApiV2ErrorCode: string;\n readonly expoApiV2ErrorDetails?: JSONValue;\n readonly expoApiV2ErrorServerStack?: string;\n readonly expoApiV2ErrorMetadata?: object;\n\n constructor(response: {\n message: string;\n code: string;\n stack?: string;\n details?: JSONValue;\n metadata?: object;\n }) {\n super(response.message);\n this.code = response.code;\n this.expoApiV2ErrorCode = response.code;\n this.expoApiV2ErrorDetails = response.details;\n this.expoApiV2ErrorServerStack = response.stack;\n this.expoApiV2ErrorMetadata = response.metadata;\n }\n}\n\n/**\n * An Expo server error that didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the server.\n */\nexport class UnexpectedServerError extends Error {\n readonly name = 'UnexpectedServerError';\n}\n\n/**\n * An error defining that the server didn't return the expected error JSON information.\n * The only 'expected' place for this is in testing, all other cases are bugs with the client.\n */\nexport class UnexpectedServerData extends Error {\n readonly name = 'UnexpectedServerData';\n}\n\n/** Validate the response json contains `.data` property, or throw an unexpected server data error */\nexport function getResponseDataOrThrow<T = any>(json: unknown): T {\n if (!!json && typeof json === 'object' && 'data' in json) {\n return json.data as T;\n }\n\n throw new UnexpectedServerData(\n !!json && typeof json === 'object' ? JSON.stringify(json) : 'Unknown data received from server.'\n );\n}\n\n/**\n * @returns a `fetch` function that will inject user authentication information and handle errors from the Expo API.\n */\nexport function wrapFetchWithCredentials(fetchFunction: FetchLike): FetchLike {\n return async function fetchWithCredentials(url, options = {}) {\n if (Array.isArray(options.headers)) {\n throw new Error('request headers must be in object form');\n }\n\n const resolvedHeaders = options.headers ?? ({} as any);\n\n const token = getAccessToken();\n if (token) {\n resolvedHeaders.authorization = `Bearer ${token}`;\n } else {\n const sessionSecret = getSession()?.sessionSecret;\n if (sessionSecret) {\n resolvedHeaders['expo-session'] = sessionSecret;\n }\n }\n\n try {\n const response = await fetchFunction(url, {\n ...options,\n headers: resolvedHeaders,\n });\n\n // Handle expected API errors (4xx)\n if (response.status >= 400 && response.status < 500) {\n const body = await response.text();\n try {\n const data = JSON.parse(body);\n if (data?.errors?.length) {\n throw new ApiV2Error(data.errors[0]);\n }\n } catch (error: any) {\n // Server returned non-json response.\n if (error.message.includes('in JSON at position')) {\n throw new UnexpectedServerError(body);\n }\n throw error;\n }\n }\n\n return response;\n } catch (error: any) {\n // When running `expo start`, but wifi or internet has issues\n if (\n isNetworkError(error) || // node-fetch error handling\n ('cause' in error && isNetworkError(error.cause)) // undici error handling\n ) {\n disableNetwork();\n\n throw new CommandError(\n 'OFFLINE',\n 'Network connection is unreliable. Try again with the environment variable `EXPO_OFFLINE=1` to skip network requests.'\n );\n }\n\n throw error;\n }\n };\n}\n\n/**\n * Determine if the provided error is related to a network issue.\n * When this returns true, offline mode should be enabled.\n * - `ENOTFOUND` is thrown when the DNS lookup failed\n * - `UND_ERR_CONNECT_TIMEOUT` is thrown after DNS is resolved, but server can't be reached\n *\n * @see https://nodejs.org/api/errors.html\n * @see https://github.com/nodejs/undici#network-address-family-autoselection\n */\nfunction isNetworkError(error: Error & { code?: string }) {\n return (\n 'code' in error && error.code && ['ENOTFOUND', 'UND_ERR_CONNECT_TIMEOUT'].includes(error.code)\n );\n}\n\nconst fetchWithOffline = wrapFetchWithOffline(fetch);\n\nconst fetchWithBaseUrl = wrapFetchWithBaseUrl(fetchWithOffline, getExpoApiBaseUrl() + '/v2/');\n\nconst fetchWithProxy = wrapFetchWithProxy(fetchWithBaseUrl);\n\nconst fetchWithCredentials = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n\n/**\n * Create an instance of the fully qualified fetch command (auto authentication and api) but with caching in the '~/.expo' directory.\n * Caching is disabled automatically if the EXPO_NO_CACHE or EXPO_BETA environment variables are enabled.\n */\nexport function createCachedFetch({\n fetch = fetchWithCredentials,\n cacheDirectory,\n ttl,\n skipCache,\n}: {\n fetch?: FetchLike;\n cacheDirectory: string;\n ttl?: number;\n skipCache?: boolean;\n}): FetchLike {\n // Disable all caching in EXPO_BETA.\n if (skipCache || env.EXPO_BETA || env.EXPO_NO_CACHE) {\n return fetch;\n }\n\n const { FileSystemResponseCache } =\n require('./cache/FileSystemResponseCache') as typeof import('./cache/FileSystemResponseCache');\n\n return wrapFetchWithCache(\n fetch,\n new FileSystemResponseCache({\n cacheDirectory: path.join(getExpoHomeDirectory(), cacheDirectory),\n ttl,\n })\n );\n}\n\n/** Instance of fetch with automatic base URL pointing to the Expo API, user credential injection, and API error handling. Caching not included. */\nexport const fetchAsync = wrapFetchWithProgress(wrapFetchWithCredentials(fetchWithProxy));\n"],"names":["ApiV2Error","UnexpectedServerError","UnexpectedServerData","getResponseDataOrThrow","wrapFetchWithCredentials","createCachedFetch","fetchAsync","Error","name","constructor","response","message","code","expoApiV2ErrorCode","expoApiV2ErrorDetails","details","expoApiV2ErrorServerStack","stack","expoApiV2ErrorMetadata","metadata","json","data","JSON","stringify","fetchFunction","fetchWithCredentials","url","options","Array","isArray","headers","resolvedHeaders","token","getAccessToken","authorization","getSession","sessionSecret","status","body","text","parse","errors","length","error","includes","isNetworkError","cause","disableNetwork","CommandError","fetchWithOffline","wrapFetchWithOffline","fetch","fetchWithBaseUrl","wrapFetchWithBaseUrl","getExpoApiBaseUrl","fetchWithProxy","wrapFetchWithProxy","wrapFetchWithProgress","cacheDirectory","ttl","skipCache","env","EXPO_BETA","EXPO_NO_CACHE","FileSystemResponseCache","require","wrapFetchWithCache","path","join","getExpoHomeDirectory"],"mappings":"AAAA;;;;;;;;;;;IAiBaA,UAAU,MAAVA,UAAU;IA4BVC,qBAAqB,MAArBA,qBAAqB;IAQrBC,oBAAoB,MAApBA,oBAAoB;IAKjBC,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AA,EAACJ,gBAAgB,EAAEK,IAAAA,SAAiB,kBAAA,GAAE,GAAG,MAAM,CAAC,AAAC;AAE9F,MAAMC,cAAc,GAAGC,IAAAA,mBAAkB,mBAAA,EAACJ,gBAAgB,CAAC,AAAC;AAE5D,MAAM3B,oBAAoB,GAAGgC,IAAAA,sBAAqB,sBAAA,EAACrD,wBAAwB,CAACmD,cAAc,CAAC,CAAC,AAAC;AAMtF,SAASlD,iBAAiB,CAAC,EAChC8C,KAAK,EAAG1B,oBAAoB,CAAA,EAC5BiC,cAAc,CAAA,EACdC,GAAG,CAAA,EACHC,SAAS,CAAA,EAMV,EAAa;IACZ,oCAAoC;IACpC,IAAIA,SAAS,IAAIC,IAAG,IAAA,CAACC,SAAS,IAAID,IAAG,IAAA,CAACE,aAAa,EAAE;QACnD,OAAOZ,KAAK,CAAC;IACf,CAAC;IAED,MAAM,EAAEa,uBAAuB,CAAA,EAAE,GAC/BC,OAAO,CAAC,iCAAiC,CAAC,AAAoD,AAAC;IAEjG,OAAOC,IAAAA,mBAAkB,mBAAA,EACvBf,KAAK,EACL,IAAIa,uBAAuB,CAAC;QAC1BN,cAAc,EAAES,KAAI,EAAA,QAAA,CAACC,IAAI,CAACC,IAAAA,aAAoB,EAAA,qBAAA,GAAE,EAAEX,cAAc,CAAC;QACjEC,GAAG;KACJ,CAAC,CACH,CAAC;AACJ,CAAC;AAGM,MAAMrD,UAAU,GAAGmD,IAAAA,sBAAqB,sBAAA,EAACrD,wBAAwB,CAACmD,cAAc,CAAC,CAAC,AAAC"}
@@ -15,6 +15,7 @@ _export(exports, {
15
15
  getAccessToken: ()=>getAccessToken,
16
16
  getSession: ()=>getSession,
17
17
  setSessionAsync: ()=>setSessionAsync,
18
+ hasCredentials: ()=>hasCredentials,
18
19
  getAnonymousIdAsync: ()=>getAnonymousIdAsync,
19
20
  getAnonymousId: ()=>getAnonymousId
20
21
  });
@@ -69,6 +70,9 @@ async function setSessionAsync(sessionData) {
69
70
  ensureDir: true
70
71
  });
71
72
  }
73
+ function hasCredentials() {
74
+ return !!getAccessToken() || !!getSession();
75
+ }
72
76
  async function getAnonymousIdAsync() {
73
77
  const settings = getSettings();
74
78
  let id = await settings.getAsync("uuid", null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nexport function getSettingsDirectory() {\n return getExpoHomeDirectory();\n}\n\n/** Return the file path of the settings file */\nexport function getSettingsFilePath(): string {\n return getUserStatePath();\n}\n\n/** Get a new JsonFile instance pointed towards the settings file */\nexport function getSettings(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getSettingsFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nexport function getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\nexport function getSession() {\n return getSettings().get('auth', null);\n}\n\nexport async function setSessionAsync(sessionData?: SessionData) {\n await getSettings().setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport async function getAnonymousIdAsync(): Promise<string> {\n const settings = getSettings();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport function getAnonymousId(): string {\n const settings = getSettings();\n let id = settings.get('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n settings.set('uuid', id);\n }\n\n return id;\n}\n"],"names":["getSettingsDirectory","getSettingsFilePath","getSettings","getAccessToken","getSession","setSessionAsync","getAnonymousIdAsync","getAnonymousId","getExpoHomeDirectory","getUserStatePath","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","process","env","EXPO_TOKEN","get","sessionData","setAsync","default","settings","id","getAsync","crypto","randomUUID","set"],"mappings":"AAAA;;;;;;;;;;;IAuBgBA,oBAAoB,MAApBA,oBAAoB;IAKpBC,mBAAmB,MAAnBA,mBAAmB;IAKnBC,WAAW,MAAXA,WAAW;IAQXC,cAAc,MAAdA,cAAc;IAIdC,UAAU,MAAVA,UAAU;IAIJC,eAAe,MAAfA,eAAe;IAYfC,mBAAmB,MAAnBA,mBAAmB;IAiBzBC,cAAc,MAAdA,cAAc;;;yBA9EyB,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAqBpB,SAASP,oBAAoB,GAAG;IACrC,OAAOQ,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAGM,SAASP,mBAAmB,GAAW;IAC5C,OAAOQ,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAGM,SAASP,WAAW,GAA+B;IACxD,OAAO,IAAIQ,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBT,mBAAmB,EAAE,EAAE;QAC3DU,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAEM,SAASV,cAAc,GAAkB;IAC9C,OAAOW,OAAO,CAACC,GAAG,CAACC,UAAU,IAAI,IAAI,CAAC;AACxC,CAAC;AAEM,SAASZ,UAAU,GAAG;IAC3B,OAAOF,WAAW,EAAE,CAACe,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAEM,eAAeZ,eAAe,CAACa,WAAyB,EAAE;IAC/D,MAAMhB,WAAW,EAAE,CAACiB,QAAQ,CAAC,MAAM,EAAED,WAAW,EAAE;QAChDE,OAAO,EAAE,EAAE;QACXT,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAOM,eAAeL,mBAAmB,GAAoB;IAC3D,MAAMe,QAAQ,GAAGnB,WAAW,EAAE,AAAC;IAC/B,IAAIoB,EAAE,GAAG,MAAMD,QAAQ,CAACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAE/C,IAAI,CAACD,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzB,MAAMJ,QAAQ,CAACF,QAAQ,CAAC,MAAM,EAAEG,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC;AAOM,SAASf,cAAc,GAAW;IACvC,MAAMc,QAAQ,GAAGnB,WAAW,EAAE,AAAC;IAC/B,IAAIoB,EAAE,GAAGD,QAAQ,CAACJ,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAEpC,IAAI,CAACK,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzBJ,QAAQ,CAACK,GAAG,CAAC,MAAM,EAAEJ,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC"}
1
+ {"version":3,"sources":["../../../../src/api/user/UserSettings.ts"],"sourcesContent":["import { getExpoHomeDirectory, getUserStatePath } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport crypto from 'crypto';\n\ntype SessionData = {\n sessionSecret: string;\n // These fields are potentially used by Expo CLI.\n userId: string;\n username: string;\n currentConnection: 'Username-Password-Authentication' | 'Browser-Flow-Authentication';\n};\n\nexport type UserSettingsData = {\n auth?: SessionData | null;\n ignoreBundledBinaries?: string[];\n PATH?: string;\n /** Last development code signing ID used for `npx expo run:ios`. */\n developmentCodeSigningId?: string;\n /** Unique user ID which is generated anonymously and can be cleared locally. */\n uuid?: string;\n};\n\n/** Return the user cache directory. */\nexport function getSettingsDirectory() {\n return getExpoHomeDirectory();\n}\n\n/** Return the file path of the settings file */\nexport function getSettingsFilePath(): string {\n return getUserStatePath();\n}\n\n/** Get a new JsonFile instance pointed towards the settings file */\nexport function getSettings(): JsonFile<UserSettingsData> {\n return new JsonFile<UserSettingsData>(getSettingsFilePath(), {\n ensureDir: true,\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nexport function getAccessToken(): string | null {\n return process.env.EXPO_TOKEN ?? null;\n}\n\nexport function getSession() {\n return getSettings().get('auth', null);\n}\n\nexport async function setSessionAsync(sessionData?: SessionData) {\n await getSettings().setAsync('auth', sessionData, {\n default: {},\n ensureDir: true,\n });\n}\n\n/**\n * Check if there are credentials available, without fetching the user information.\n * This can be used as a faster check to see if users are authenticated.\n * Note, this isn't checking the validity of the credentials.\n */\nexport function hasCredentials() {\n return !!getAccessToken() || !!getSession();\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport async function getAnonymousIdAsync(): Promise<string> {\n const settings = getSettings();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\n/**\n * Get an anonymous and randomly generated identifier.\n * This is used to group telemetry event by unknown actor,\n * and cannot be used to identify a single user.\n */\nexport function getAnonymousId(): string {\n const settings = getSettings();\n let id = settings.get('uuid', null);\n\n if (!id) {\n id = crypto.randomUUID();\n settings.set('uuid', id);\n }\n\n return id;\n}\n"],"names":["getSettingsDirectory","getSettingsFilePath","getSettings","getAccessToken","getSession","setSessionAsync","hasCredentials","getAnonymousIdAsync","getAnonymousId","getExpoHomeDirectory","getUserStatePath","JsonFile","ensureDir","jsonParseErrorDefault","cantReadFileDefault","process","env","EXPO_TOKEN","get","sessionData","setAsync","default","settings","id","getAsync","crypto","randomUUID","set"],"mappings":"AAAA;;;;;;;;;;;IAuBgBA,oBAAoB,MAApBA,oBAAoB;IAKpBC,mBAAmB,MAAnBA,mBAAmB;IAKnBC,WAAW,MAAXA,WAAW;IAQXC,cAAc,MAAdA,cAAc;IAIdC,UAAU,MAAVA,UAAU;IAIJC,eAAe,MAAfA,eAAe;IAYrBC,cAAc,MAAdA,cAAc;IASRC,mBAAmB,MAAnBA,mBAAmB;IAiBzBC,cAAc,MAAdA,cAAc;;;yBAvFyB,iCAAiC;;;;;;;8DACnE,iBAAiB;;;;;;;8DACnB,QAAQ;;;;;;;;;;;AAqBpB,SAASR,oBAAoB,GAAG;IACrC,OAAOS,IAAAA,aAAoB,EAAA,qBAAA,GAAE,CAAC;AAChC,CAAC;AAGM,SAASR,mBAAmB,GAAW;IAC5C,OAAOS,IAAAA,aAAgB,EAAA,iBAAA,GAAE,CAAC;AAC5B,CAAC;AAGM,SAASR,WAAW,GAA+B;IACxD,OAAO,IAAIS,CAAAA,SAAQ,EAAA,CAAA,QAAA,CAAmBV,mBAAmB,EAAE,EAAE;QAC3DW,SAAS,EAAE,IAAI;QACfC,qBAAqB,EAAE,EAAE;QACzBC,mBAAmB,EAAE,EAAE;KACxB,CAAC,CAAC;AACL,CAAC;AAEM,SAASX,cAAc,GAAkB;IAC9C,OAAOY,OAAO,CAACC,GAAG,CAACC,UAAU,IAAI,IAAI,CAAC;AACxC,CAAC;AAEM,SAASb,UAAU,GAAG;IAC3B,OAAOF,WAAW,EAAE,CAACgB,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAEM,eAAeb,eAAe,CAACc,WAAyB,EAAE;IAC/D,MAAMjB,WAAW,EAAE,CAACkB,QAAQ,CAAC,MAAM,EAAED,WAAW,EAAE;QAChDE,OAAO,EAAE,EAAE;QACXT,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;AACL,CAAC;AAOM,SAASN,cAAc,GAAG;IAC/B,OAAO,CAAC,CAACH,cAAc,EAAE,IAAI,CAAC,CAACC,UAAU,EAAE,CAAC;AAC9C,CAAC;AAOM,eAAeG,mBAAmB,GAAoB;IAC3D,MAAMe,QAAQ,GAAGpB,WAAW,EAAE,AAAC;IAC/B,IAAIqB,EAAE,GAAG,MAAMD,QAAQ,CAACE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAE/C,IAAI,CAACD,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzB,MAAMJ,QAAQ,CAACF,QAAQ,CAAC,MAAM,EAAEG,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC;AAOM,SAASf,cAAc,GAAW;IACvC,MAAMc,QAAQ,GAAGpB,WAAW,EAAE,AAAC;IAC/B,IAAIqB,EAAE,GAAGD,QAAQ,CAACJ,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,AAAC;IAEpC,IAAI,CAACK,EAAE,EAAE;QACPA,EAAE,GAAGE,OAAM,EAAA,QAAA,CAACC,UAAU,EAAE,CAAC;QACzBJ,QAAQ,CAACK,GAAG,CAAC,MAAM,EAAEJ,EAAE,CAAC,CAAC;IAC3B,CAAC;IAED,OAAOA,EAAE,CAAC;AACZ,CAAC"}
@@ -153,11 +153,13 @@ class TypeScriptProjectPrerequisite extends _prerequisite.ProjectPrerequisite {
153
153
  // the package and attempts to resolve the module in the same process.
154
154
  {
155
155
  file: "typescript/package.json",
156
- pkg: "typescript"
156
+ pkg: "typescript",
157
+ dev: true
157
158
  },
158
159
  {
159
160
  file: "@types/react/package.json",
160
- pkg: "@types/react"
161
+ pkg: "@types/react",
162
+ dev: true
161
163
  },
162
164
  ]
163
165
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/doctor/typescript/TypeScriptProjectPrerequisite.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { updateTSConfigAsync } from './updateTSConfig';\nimport * as Log from '../../../log';\nimport { fileExistsAsync } from '../../../utils/dir';\nimport { env } from '../../../utils/env';\nimport { memoize } from '../../../utils/fn';\nimport { everyMatchAsync } from '../../../utils/glob';\nimport { ProjectPrerequisite } from '../Prerequisite';\nimport { ensureDependenciesAsync } from '../dependencies/ensureDependenciesAsync';\n\nconst debug = require('debug')('expo:doctor:typescriptSupport') as typeof console.log;\n\nconst warnDisabled = memoize(() => {\n Log.warn('Skipping TypeScript setup: EXPO_NO_TYPESCRIPT_SETUP is enabled.');\n});\n\n/** Ensure the project has the required TypeScript support settings. */\nexport class TypeScriptProjectPrerequisite extends ProjectPrerequisite<boolean> {\n /**\n * Ensure a project that hasn't explicitly disabled typescript support has all the required packages for running in the browser.\n *\n * @returns `true` if the setup finished and no longer needs to be run again.\n */\n async assertImplementation(): Promise<boolean> {\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n warnDisabled();\n return true;\n }\n debug('Ensuring TypeScript support is setup');\n\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n\n // Ensure the project is TypeScript before continuing.\n const intent = await this._getSetupRequirements();\n if (!intent) {\n return false;\n }\n\n // Ensure TypeScript packages are installed\n await this._ensureDependenciesInstalledAsync();\n\n // Update the config\n await updateTSConfigAsync({ tsConfigPath });\n\n return true;\n }\n\n async bootstrapAsync(): Promise<void> {\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n warnDisabled();\n return;\n }\n // Ensure TypeScript packages are installed\n await this._ensureDependenciesInstalledAsync({\n skipPrompt: true,\n isProjectMutable: true,\n });\n\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n\n // Update the config\n await updateTSConfigAsync({ tsConfigPath });\n }\n\n /** Exposed for testing. */\n async _getSetupRequirements(): Promise<{\n /** Indicates that TypeScript support is being bootstrapped. */\n isBootstrapping: boolean;\n } | null> {\n const tsConfigPath = await this._hasTSConfig();\n\n // Enable TS setup if the project has a `tsconfig.json`\n if (tsConfigPath) {\n const content = await fs.readFile(tsConfigPath, { encoding: 'utf8' }).then(\n (txt) => txt.trim(),\n // null when the file doesn't exist.\n () => null\n );\n const isBlankConfig = content === '' || content === '{}';\n return { isBootstrapping: isBlankConfig };\n }\n // This is a somewhat heavy check in larger projects.\n // Test that this is reasonably paced by running expo start in `expo/apps/native-component-list`\n const typescriptFile = await this._queryFirstTypeScriptFileAsync();\n if (typescriptFile) {\n return { isBootstrapping: true };\n }\n\n return null;\n }\n\n /** Exposed for testing. */\n async _ensureDependenciesInstalledAsync({\n exp,\n skipPrompt,\n isProjectMutable,\n }: {\n exp?: ExpoConfig;\n skipPrompt?: boolean;\n isProjectMutable?: boolean;\n } = {}): Promise<boolean> {\n try {\n return await ensureDependenciesAsync(this.projectRoot, {\n exp,\n skipPrompt,\n isProjectMutable,\n installMessage: `It looks like you're trying to use TypeScript but don't have the required dependencies installed.`,\n warningMessage:\n \"If you're not using TypeScript, please remove the TypeScript files from your project\",\n requiredPackages: [\n // use typescript/package.json to skip node module cache issues when the user installs\n // the package and attempts to resolve the module in the same process.\n { file: 'typescript/package.json', pkg: 'typescript' },\n { file: '@types/react/package.json', pkg: '@types/react' },\n ],\n });\n } catch (error) {\n // Reset the cached check so we can re-run the check if the user re-runs the command by pressing 'w' in the Terminal UI.\n this.resetAssertion();\n throw error;\n }\n }\n\n /** Return the first TypeScript file in the project. */\n async _queryFirstTypeScriptFileAsync(): Promise<null | string> {\n try {\n // TODO(Bacon): Use `everyMatch` since a bug causes `anyMatch` to return inaccurate results when used multiple times.\n const results = await everyMatchAsync('**/*.@(ts|tsx)', {\n cwd: this.projectRoot,\n signal: AbortSignal.timeout(5000),\n ignore: [\n '**/@(Carthage|Pods|node_modules)/**',\n '**/*.d.ts',\n '@(ios|android|web|web-build|dist)/**',\n ],\n });\n\n return results[0] ?? null;\n } catch (error: any) {\n if (error.name === 'TimeoutError') {\n return null;\n }\n\n throw error;\n }\n }\n\n async _hasTSConfig(): Promise<string | null> {\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n if (await fileExistsAsync(tsConfigPath)) {\n return tsConfigPath;\n }\n return null;\n }\n}\n"],"names":["TypeScriptProjectPrerequisite","debug","require","warnDisabled","memoize","Log","warn","ProjectPrerequisite","assertImplementation","env","EXPO_NO_TYPESCRIPT_SETUP","tsConfigPath","path","join","projectRoot","intent","_getSetupRequirements","_ensureDependenciesInstalledAsync","updateTSConfigAsync","bootstrapAsync","skipPrompt","isProjectMutable","_hasTSConfig","content","fs","readFile","encoding","then","txt","trim","isBlankConfig","isBootstrapping","typescriptFile","_queryFirstTypeScriptFileAsync","exp","ensureDependenciesAsync","installMessage","warningMessage","requiredPackages","file","pkg","error","resetAssertion","results","everyMatchAsync","cwd","signal","AbortSignal","timeout","ignore","name","fileExistsAsync"],"mappings":"AAAA;;;;+BAoBaA,+BAA6B;;aAA7BA,6BAA6B;;;8DAnB3B,aAAa;;;;;;;8DACX,MAAM;;;;;;gCAEa,kBAAkB;2DACjC,cAAc;qBACH,oBAAoB;qBAChC,oBAAoB;oBAChB,mBAAmB;sBACX,qBAAqB;8BACjB,iBAAiB;yCACb,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjF,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,AAAsB,AAAC;AAEtF,MAAMC,YAAY,GAAGC,IAAAA,GAAO,QAAA,EAAC,IAAM;IACjCC,IAAG,CAACC,IAAI,CAAC,iEAAiE,CAAC,CAAC;AAC9E,CAAC,CAAC,AAAC;AAGI,MAAMN,6BAA6B,SAASO,aAAm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IAAI;YACF,qHAAqH;YACrH,MAAMU,OAAO,GAAG,MAAMC,IAAAA,KAAe,gBAAA,EAAC,gBAAgB,EAAE;gBACtDC,GAAG,EAAE,IAAI,CAAC/B,WAAW;gBACrBgC,MAAM,EAAEC,WAAW,CAACC,OAAO,CAAC,IAAI,CAAC;gBACjCC,MAAM,EAAE;oBACN,qCAAqC;oBACrC,WAAW;oBACX,sCAAsC;iBACvC;aACF,CAAC,AAAC;YAEH,OAAON,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAC5B,EAAE,OAAOF,KAAK,EAAO;YACnB,IAAIA,KAAK,CAACS,IAAI,KAAK,cAAc,EAAE;gBACjC,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAMT,KAAK,CAAC;QACd,CAAC;IACH;UAEMnB,YAAY,GAA2B;QAC3C,MAAMX,YAAY,GAAGC,KAAI,EAAA,QAAA,CAACC,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE,eAAe,CAAC,AAAC;QAClE,IAAI,MAAMqC,IAAAA,IAAe,gBAAA,EAACxC,YAAY,CAAC,EAAE;YACvC,OAAOA,YAAY,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,CAAC;IACd;CACD"}
1
+ {"version":3,"sources":["../../../../../src/start/doctor/typescript/TypeScriptProjectPrerequisite.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { updateTSConfigAsync } from './updateTSConfig';\nimport * as Log from '../../../log';\nimport { fileExistsAsync } from '../../../utils/dir';\nimport { env } from '../../../utils/env';\nimport { memoize } from '../../../utils/fn';\nimport { everyMatchAsync } from '../../../utils/glob';\nimport { ProjectPrerequisite } from '../Prerequisite';\nimport { ensureDependenciesAsync } from '../dependencies/ensureDependenciesAsync';\n\nconst debug = require('debug')('expo:doctor:typescriptSupport') as typeof console.log;\n\nconst warnDisabled = memoize(() => {\n Log.warn('Skipping TypeScript setup: EXPO_NO_TYPESCRIPT_SETUP is enabled.');\n});\n\n/** Ensure the project has the required TypeScript support settings. */\nexport class TypeScriptProjectPrerequisite extends ProjectPrerequisite<boolean> {\n /**\n * Ensure a project that hasn't explicitly disabled typescript support has all the required packages for running in the browser.\n *\n * @returns `true` if the setup finished and no longer needs to be run again.\n */\n async assertImplementation(): Promise<boolean> {\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n warnDisabled();\n return true;\n }\n debug('Ensuring TypeScript support is setup');\n\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n\n // Ensure the project is TypeScript before continuing.\n const intent = await this._getSetupRequirements();\n if (!intent) {\n return false;\n }\n\n // Ensure TypeScript packages are installed\n await this._ensureDependenciesInstalledAsync();\n\n // Update the config\n await updateTSConfigAsync({ tsConfigPath });\n\n return true;\n }\n\n async bootstrapAsync(): Promise<void> {\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n warnDisabled();\n return;\n }\n // Ensure TypeScript packages are installed\n await this._ensureDependenciesInstalledAsync({\n skipPrompt: true,\n isProjectMutable: true,\n });\n\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n\n // Update the config\n await updateTSConfigAsync({ tsConfigPath });\n }\n\n /** Exposed for testing. */\n async _getSetupRequirements(): Promise<{\n /** Indicates that TypeScript support is being bootstrapped. */\n isBootstrapping: boolean;\n } | null> {\n const tsConfigPath = await this._hasTSConfig();\n\n // Enable TS setup if the project has a `tsconfig.json`\n if (tsConfigPath) {\n const content = await fs.readFile(tsConfigPath, { encoding: 'utf8' }).then(\n (txt) => txt.trim(),\n // null when the file doesn't exist.\n () => null\n );\n const isBlankConfig = content === '' || content === '{}';\n return { isBootstrapping: isBlankConfig };\n }\n // This is a somewhat heavy check in larger projects.\n // Test that this is reasonably paced by running expo start in `expo/apps/native-component-list`\n const typescriptFile = await this._queryFirstTypeScriptFileAsync();\n if (typescriptFile) {\n return { isBootstrapping: true };\n }\n\n return null;\n }\n\n /** Exposed for testing. */\n async _ensureDependenciesInstalledAsync({\n exp,\n skipPrompt,\n isProjectMutable,\n }: {\n exp?: ExpoConfig;\n skipPrompt?: boolean;\n isProjectMutable?: boolean;\n } = {}): Promise<boolean> {\n try {\n return await ensureDependenciesAsync(this.projectRoot, {\n exp,\n skipPrompt,\n isProjectMutable,\n installMessage: `It looks like you're trying to use TypeScript but don't have the required dependencies installed.`,\n warningMessage:\n \"If you're not using TypeScript, please remove the TypeScript files from your project\",\n requiredPackages: [\n // use typescript/package.json to skip node module cache issues when the user installs\n // the package and attempts to resolve the module in the same process.\n { file: 'typescript/package.json', pkg: 'typescript', dev: true },\n { file: '@types/react/package.json', pkg: '@types/react', dev: true },\n ],\n });\n } catch (error) {\n // Reset the cached check so we can re-run the check if the user re-runs the command by pressing 'w' in the Terminal UI.\n this.resetAssertion();\n throw error;\n }\n }\n\n /** Return the first TypeScript file in the project. */\n async _queryFirstTypeScriptFileAsync(): Promise<null | string> {\n try {\n // TODO(Bacon): Use `everyMatch` since a bug causes `anyMatch` to return inaccurate results when used multiple times.\n const results = await everyMatchAsync('**/*.@(ts|tsx)', {\n cwd: this.projectRoot,\n signal: AbortSignal.timeout(5000),\n ignore: [\n '**/@(Carthage|Pods|node_modules)/**',\n '**/*.d.ts',\n '@(ios|android|web|web-build|dist)/**',\n ],\n });\n\n return results[0] ?? null;\n } catch (error: any) {\n if (error.name === 'TimeoutError') {\n return null;\n }\n\n throw error;\n }\n }\n\n async _hasTSConfig(): Promise<string | null> {\n const tsConfigPath = path.join(this.projectRoot, 'tsconfig.json');\n if (await fileExistsAsync(tsConfigPath)) {\n return tsConfigPath;\n }\n return null;\n }\n}\n"],"names":["TypeScriptProjectPrerequisite","debug","require","warnDisabled","memoize","Log","warn","ProjectPrerequisite","assertImplementation","env","EXPO_NO_TYPESCRIPT_SETUP","tsConfigPath","path","join","projectRoot","intent","_getSetupRequirements","_ensureDependenciesInstalledAsync","updateTSConfigAsync","bootstrapAsync","skipPrompt","isProjectMutable","_hasTSConfig","content","fs","readFile","encoding","then","txt","trim","isBlankConfig","isBootstrapping","typescriptFile","_queryFirstTypeScriptFileAsync","exp","ensureDependenciesAsync","installMessage","warningMessage","requiredPackages","file","pkg","dev","error","resetAssertion","results","everyMatchAsync","cwd","signal","AbortSignal","timeout","ignore","name","fileExistsAsync"],"mappings":"AAAA;;;;+BAoBaA,+BAA6B;;aAA7BA,6BAA6B;;;8DAnB3B,aAAa;;;;;;;8DACX,MAAM;;;;;;gCAEa,kBAAkB;2DACjC,cAAc;qBACH,oBAAoB;qBAChC,oBAAoB;oBAChB,mBAAmB;sBACX,qBAAqB;8BACjB,iBAAiB;yCACb,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjF,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,AAAsB,AAAC;AAEtF,MAAMC,YAAY,GAAGC,IAAAA,GAAO,QAAA,EAAC,IAAM;IACjCC,IAAG,CAACC,IAAI,CAAC,iEAAiE,CAAC,CAAC;AAC9E,CAAC,CAAC,AAAC;AAGI,MAAMN,6BAA6B,SAASO,aAAmB,oBAAA;IACpE;;;;GAIC,SACKC,oBAAoB,GAAqB;QAC7C,IAAIC,IAAG,IAAA,CAACC,wBAAwB,EAAE;YAChCP,YAAY,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QACDF,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAE9C,MAAMU,YAAY,GAAGC,KAAI,EAAA,QAAA,CAACC,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE,eAAe,CAAC,AAAC;QAElE,sDAAsD;QACtD,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACC,qBAAqB,EAAE,AAAC;QAClD,IAAI,CAACD,MAAM,EAAE;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QAED,2CAA2C;QAC3C,MAAM,IAAI,CAACE,iCAAiC,EAAE,CAAC;QAE/C,oBAAoB;QACpB,MAAMC,IAAAA,eAA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IACH;UAEMpB,YAAY,GAA2B;QAC3C,MAAMX,YAAY,GAAGC,KAAI,EAAA,QAAA,CAACC,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE,eAAe,CAAC,AAAC;QAClE,IAAI,MAAMsC,IAAAA,IAAe,gBAAA,EAACzC,YAAY,CAAC,EAAE;YACvC,OAAOA,YAAY,CAAC;QACtB,CAAC;QACD,OAAO,IAAI,CAAC;IACd;CACD"}
@@ -14,7 +14,7 @@ function _config() {
14
14
  return data;
15
15
  }
16
16
  const _updateDevelopmentSession = require("../../api/updateDevelopmentSession");
17
- const _user = require("../../api/user/user");
17
+ const _userSettings = require("../../api/user/UserSettings");
18
18
  const _env = require("../../utils/env");
19
19
  const _devices = /*#__PURE__*/ _interopRequireWildcard(require("../project/devices"));
20
20
  function _getRequireWildcardCache(nodeInterop) {
@@ -57,9 +57,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
57
57
  return newObj;
58
58
  }
59
59
  const debug = require("debug")("expo:start:server:developmentSession");
60
- async function isAuthenticatedAsync() {
61
- return !!await (0, _user.getUserAsync)().catch(()=>null);
62
- }
63
60
  class DevelopmentSession {
64
61
  constructor(projectRoot, url){
65
62
  this.projectRoot = projectRoot;
@@ -80,7 +77,7 @@ class DevelopmentSession {
80
77
  return;
81
78
  }
82
79
  const deviceIds = await this.getDeviceInstallationIdsAsync();
83
- if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
80
+ if (!(0, _userSettings.hasCredentials)() && !(deviceIds == null ? void 0 : deviceIds.length)) {
84
81
  debug("Development session will not ping because the user is not authenticated and there are no devices.");
85
82
  return;
86
83
  }
@@ -111,7 +108,7 @@ class DevelopmentSession {
111
108
  this.hasActiveSession = false;
112
109
  try {
113
110
  const deviceIds = await this.getDeviceInstallationIdsAsync();
114
- if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
111
+ if (!(0, _userSettings.hasCredentials)() && !(deviceIds == null ? void 0 : deviceIds.length)) {
115
112
  return false;
116
113
  }
117
114
  if (this.url) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n /** If the `startAsync` was successfully called */\n private hasActiveSession = false;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.CI || env.EXPO_OFFLINE) {\n debug(\n env.CI\n ? 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI.'\n : 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n this.hasActiveSession = true;\n }\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Try to close any pending development sessions, but always resolve */\n public async closeAsync(): Promise<boolean> {\n if (env.CI || env.EXPO_OFFLINE || !this.hasActiveSession) {\n return false;\n }\n\n // Clear out the development session, even if the call fails.\n // This blocks subsequent calls to `stopAsync`\n this.hasActiveSession = false;\n\n try {\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return false;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n\n return true;\n } catch (error: any) {\n debug(`Error closing development session API: ${error}`);\n return false;\n }\n }\n}\n"],"names":["DevelopmentSession","debug","require","isAuthenticatedAsync","getUserAsync","catch","constructor","projectRoot","url","hasActiveSession","startAsync","exp","getConfig","runtime","env","CI","EXPO_OFFLINE","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","error","devices","ProjectDevices","getDevicesInfoAsync","map","installationId","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;+BAgBaA,oBAAkB;;aAAlBA,kBAAkB;;;yBAhBO,cAAc;;;;;;0CAK7C,oCAAoC;sBACd,qBAAqB;qBAC9B,iBAAiB;+DACL,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAE7F,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAACC,KAAK,CAAC,IAAM,IAAI,CAAC,AAAC,CAA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AC,CAAC,CAAC;QAC5D,CAAC;IACH;IAEA,4CAA4C,SAC9BH,6BAA6B,GAAsB;QAC/D,MAAM,EAAEI,OAAO,CAAA,EAAE,GAAG,MAAMC,QAAc,CAACC,mBAAmB,CAAC,IAAI,CAACjB,WAAW,CAAC,AAAC;QAC/E,OAAOe,OAAO,CAACG,GAAG,CAAC,CAAC,EAAEC,cAAc,CAAA,EAAE,GAAKA,cAAc,CAAC,CAAC;IAC7D;IAEA,sEAAsE,SACzDC,UAAU,GAAqB;QAC1C,IAAIb,IAAG,IAAA,CAACC,EAAE,IAAID,IAAG,IAAA,CAACE,YAAY,IAAI,CAAC,IAAI,CAACP,gBAAgB,EAAE;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6DAA6D;QAC7D,8CAA8C;QAC9C,IAAI,CAACA,gBAAgB,GAAG,KAAK,CAAC;QAE9B,IAAI;YACF,MAAMQ,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;YAE7D,IAAI,CAAE,MAAMf,oBAAoB,EAAE,AAAC,IAAI,CAACc,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEE,MAAM,CAAA,EAAE;gBACzD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,IAAI,CAACX,GAAG,EAAE;gBACZ,MAAMoB,IAAAA,yBAA4B,6BAAA,EAAC;oBACjCpB,GAAG,EAAE,IAAI,CAACA,GAAG;oBACbS,SAAS;iBACV,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC;QACd,EAAE,OAAOI,KAAK,EAAO;YACnBpB,KAAK,CAAC,CAAC,uCAAuC,EAAEoB,KAAK,CAAC,CAAC,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;IACH;CACD"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { hasCredentials } from '../../api/user/UserSettings';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nexport class DevelopmentSession {\n /** If the `startAsync` was successfully called */\n private hasActiveSession = false;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.CI || env.EXPO_OFFLINE) {\n debug(\n env.CI\n ? 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI.'\n : 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!hasCredentials() && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n this.hasActiveSession = true;\n }\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Try to close any pending development sessions, but always resolve */\n public async closeAsync(): Promise<boolean> {\n if (env.CI || env.EXPO_OFFLINE || !this.hasActiveSession) {\n return false;\n }\n\n // Clear out the development session, even if the call fails.\n // This blocks subsequent calls to `stopAsync`\n this.hasActiveSession = false;\n\n try {\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!hasCredentials() && !deviceIds?.length) {\n return false;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n\n return true;\n } catch (error: any) {\n debug(`Error closing development session API: ${error}`);\n return false;\n }\n }\n}\n"],"names":["DevelopmentSession","debug","require","constructor","projectRoot","url","hasActiveSession","startAsync","exp","getConfig","runtime","env","CI","EXPO_OFFLINE","deviceIds","getDeviceInstallationIdsAsync","hasCredentials","length","updateDevelopmentSessionAsync","error","devices","ProjectDevices","getDevicesInfoAsync","map","installationId","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;+BAYaA,oBAAkB;;aAAlBA,kBAAkB;;;yBAZO,cAAc;;;;;;0CAK7C,oCAAoC;8BACZ,6BAA6B;qBACxC,iBAAiB;+DACL,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAEtF,MAAMF,kBAAkB;IAI7BG,YAEUC,WAAmB,EAEpBC,GAAkB,CACzB;QAHQD,mBAAAA,WAAmB,CAAA;QAEpBC,WAAAA,GAAkB,CAAA;aANnBC,gBAAgB,GAAG,KAAK;IAO7B;IAEH;;;;;;;GAOC,SACYC,UAAU,CAAC,EACtBC,GAAG,EAAGC,IAAAA,OAAS,EAAA,UAAA,EAAC,IAAI,CAACL,WAAW,CAAC,CAACI,GAAG,CAAA,EACrCE,OAAO,CAAA,EAIR,EAAiB;QAChB,IAAI;YACF,IAAIC,IAAG,IAAA,CAACC,EAAE,IAAID,IAAG,IAAA,CAACE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ACP,gBAAgB,EAAE;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6DAA6D;QAC7D,8CAA8C;QAC9C,IAAI,CAACA,gBAAgB,GAAG,KAAK,CAAC;QAE9B,IAAI;YACF,MAAMQ,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;YAE7D,IAAI,CAACC,IAAAA,aAAc,eAAA,GAAE,IAAI,CAACF,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEG,MAAM,CAAA,EAAE;gBAC3C,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,IAAI,CAACZ,GAAG,EAAE;gBACZ,MAAMqB,IAAAA,yBAA4B,6BAAA,EAAC;oBACjCrB,GAAG,EAAE,IAAI,CAACA,GAAG;oBACbS,SAAS;iBACV,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC;QACd,EAAE,OAAOK,KAAK,EAAO;YACnBlB,KAAK,CAAC,CAAC,uCAAuC,EAAEkB,KAAK,CAAC,CAAC,CAAC,CAAC;YACzD,OAAO,KAAK,CAAC;QACf,CAAC;IACH;CACD"}
@@ -83,6 +83,7 @@ function _interopRequireDefault(obj) {
83
83
  return null;
84
84
  }
85
85
  }
86
+ /** By convention, a zero mac address means we have a virtual device, which we'd like to exclude */ const VIRTUAL_MAC_ADDRESS = "00:00:00:00:00:00";
86
87
  /** Determines the internal IP address by opening a socket, then checking the socket address against non-internal network interface assignments
87
88
  * @throws If no address can be determined.
88
89
  */ function getRouteIPAddress() {
@@ -101,7 +102,8 @@ function _interopRequireDefault(obj) {
101
102
  for(let i = 0; assignments && i < assignments.length; i++){
102
103
  const assignment = assignments[i];
103
104
  // Only use IPv4 assigments that aren't internal
104
- if (assignment.family === "IPv4" && !assignment.internal && assignment.address === routeAddress) return routeAddress;
105
+ // Only use IPv4 assignment if it's not a virtual device (e.g. a VPN network interface)
106
+ if (assignment.family === "IPv4" && !assignment.internal && assignment.address === routeAddress && assignment.mac !== VIRTUAL_MAC_ADDRESS) return routeAddress;
105
107
  }
106
108
  }
107
109
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/ip.ts"],"sourcesContent":["import internalIp from 'internal-ip';\nimport { spawnSync } from 'node:child_process';\nimport { isIPv4 } from 'node:net';\nimport { networkInterfaces } from 'node:os';\n\n/** Gets a route address by opening a UDP socket to a publicly routed address.\n * @privateRemarks\n * This is wrapped in `spawnSync` since the original `getIpAddress` utility exported\n * in this module is used synchronosly. An appropriate timeout has been set and UDP\n * ports don't send a message when opened.\n * @throws if `spawnSync` fails\n */\nfunction getRouteAddress(): string | null {\n const { error, status, stdout } = spawnSync(process.execPath, ['-'], {\n // This should be the cheapest method to determine the default route\n // By opening a socket to a publicly routed IP address, we let the default\n // gateway handle this socket, which means the socket's address will be\n // the prioritised route for public IP addresses.\n // It might fall back to `\"0.0.0.0\"` when no network connection is established\n input: `\n var socket = require('dgram').createSocket({ type: 'udp4', reuseAddr: true });\n socket.unref();\n socket.connect(53, '1.1.1.1', function() {\n var address = socket.address();\n socket.close();\n if (address && 'address' in address) {\n process.stdout.write(address.address);\n process.exit(0);\n } else {\n process.exit(1);\n }\n });\n `,\n shell: false,\n timeout: 500,\n encoding: 'utf8',\n windowsVerbatimArguments: false,\n windowsHide: true,\n });\n // We only use the stdout as an IP, if it validates as an IP and we got a zero exit code\n if (status || error) {\n return null;\n } else if (!status && typeof stdout === 'string' && isIPv4(stdout.trim())) {\n return stdout.trim();\n } else {\n return null;\n }\n}\n\n/** Determines the internal IP address by opening a socket, then checking the socket address against non-internal network interface assignments\n * @throws If no address can be determined.\n */\nfunction getRouteIPAddress(): string | null {\n // We check the IP address we get against the available network interfaces\n // It's only an internal IP address if we have a matching address on an interface's IP assignment\n let routeAddress: string | null = null;\n try {\n routeAddress = getRouteAddress();\n } catch {}\n if (!routeAddress) {\n return null;\n }\n const ifaces = networkInterfaces();\n for (const iface in ifaces) {\n const assignments = ifaces[iface];\n for (let i = 0; assignments && i < assignments.length; i++) {\n const assignment = assignments[i];\n // Only use IPv4 assigments that aren't internal\n if (\n assignment.family === 'IPv4' &&\n !assignment.internal &&\n assignment.address === routeAddress\n )\n return routeAddress;\n }\n }\n return null;\n}\n\nexport function getIpAddress(): string {\n return internalIp.v4.sync() || getRouteIPAddress() || '127.0.0.1';\n}\n"],"names":["getIpAddress","getRouteAddress","error","status","stdout","spawnSync","process","execPath","input","shell","timeout","encoding","windowsVerbatimArguments","windowsHide","isIPv4","trim","getRouteIPAddress","routeAddress","ifaces","networkInterfaces","iface","assignments","i","length","assignment","family","internal","address","internalIp","v4","sync"],"mappings":"AAAA;;;;+BA+EgBA,cAAY;;aAAZA,YAAY;;;8DA/EL,aAAa;;;;;;;yBACV,oBAAoB;;;;;;;yBACvB,UAAU;;;;;;;yBACC,SAAS;;;;;;;;;;;AAE3C;;;;;;CAMC,GACD,SAASC,eAAe,GAAkB;IACxC,MAAM,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGC,IAAAA,iBAAS,EAAA,UAAA,EAACC,OAAO,CAACC,QAAQ,EAAE;QAAC,GAAG;KAAC,EAAE;QACnE,oEAAoE;QACpE,0EAA0E;QAC1E,uEAAuE;QACvE,iDAAiD;QACjD,8EAA8E;QAC9EC,KAAK,EAAE,CAAC;;;;;;;;;;;;;IAaR,CAAC;QACDC,KAAK,EAAE,KAAK;QACZC,OAAO,EAAE,GAAG;QACZC,QAAQ,EAAE,MAAM;QAChBC,wBAAwB,EAAE,KAAK;QAC/BC,WAAW,EAAE,IAAI;KAClB,CAAC,AAAC;IACH,wFAAwF;IACxF,IAAIV,MAAM,IAAID,KAAK,EAAE;QACnB,OAAO,IAAI,CAAC;IACd,OAAO,IAAI,CAACC,MAAM,IAAI,OAAOC,MAAM,KAAK,QAAQ,IAAIU,IAAAA,QAAM,EAAA,OAAA,EAACV,MAAM,CAACW,IAAI,EAAE,CAAC,EAAE;QACzE,OAAOX,MAAM,CAACW,IAAI,EAAE,CAAC;IACvB,OAAO;QACL,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;CAEC,GACD,SAASC,iBAAiB,GAAkB;IAC1C,0EAA0E;IAC1E,iGAAiG;IACjG,IAAIC,YAAY,GAAkB,IAAI,AAAC;IACvC,IAAI;QACFA,YAAY,GAAGhB,eAAe,EAAE,CAAC;IACnC,EAAE,OAAM,CAAC,CAAC;IACV,IAAI,CAACgB,YAAY,EAAE;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAMC,MAAM,GAAGC,IAAAA,OAAiB,EAAA,kBAAA,GAAE,AAAC;IACnC,IAAK,MAAMC,KAAK,IAAIF,MAAM,CAAE;QAC1B,MAAMG,WAAW,GAAGH,MAAM,CAACE,KAAK,CAAC,AAAC;QAClC,IAAK,IAAIE,CAAC,GAAG,CAAC,EAAED,WAAW,IAAIC,CAAC,GAAGD,WAAW,CAACE,MAAM,EAAED,CAAC,EAAE,CAAE;YAC1D,MAAME,UAAU,GAAGH,WAAW,CAACC,CAAC,CAAC,AAAC;YAClC,gDAAgD;YAChD,IACEE,UAAU,CAACC,MAAM,KAAK,MAAM,IAC5B,CAACD,UAAU,CAACE,QAAQ,IACpBF,UAAU,CAACG,OAAO,KAAKV,YAAY,EAEnC,OAAOA,YAAY,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,SAASjB,YAAY,GAAW;IACrC,OAAO4B,WAAU,EAAA,QAAA,CAACC,EAAE,CAACC,IAAI,EAAE,IAAId,iBAAiB,EAAE,IAAI,WAAW,CAAC;AACpE,CAAC"}
1
+ {"version":3,"sources":["../../../src/utils/ip.ts"],"sourcesContent":["import internalIp from 'internal-ip';\nimport { spawnSync } from 'node:child_process';\nimport { isIPv4 } from 'node:net';\nimport { networkInterfaces } from 'node:os';\n\n/** Gets a route address by opening a UDP socket to a publicly routed address.\n * @privateRemarks\n * This is wrapped in `spawnSync` since the original `getIpAddress` utility exported\n * in this module is used synchronosly. An appropriate timeout has been set and UDP\n * ports don't send a message when opened.\n * @throws if `spawnSync` fails\n */\nfunction getRouteAddress(): string | null {\n const { error, status, stdout } = spawnSync(process.execPath, ['-'], {\n // This should be the cheapest method to determine the default route\n // By opening a socket to a publicly routed IP address, we let the default\n // gateway handle this socket, which means the socket's address will be\n // the prioritised route for public IP addresses.\n // It might fall back to `\"0.0.0.0\"` when no network connection is established\n input: `\n var socket = require('dgram').createSocket({ type: 'udp4', reuseAddr: true });\n socket.unref();\n socket.connect(53, '1.1.1.1', function() {\n var address = socket.address();\n socket.close();\n if (address && 'address' in address) {\n process.stdout.write(address.address);\n process.exit(0);\n } else {\n process.exit(1);\n }\n });\n `,\n shell: false,\n timeout: 500,\n encoding: 'utf8',\n windowsVerbatimArguments: false,\n windowsHide: true,\n });\n // We only use the stdout as an IP, if it validates as an IP and we got a zero exit code\n if (status || error) {\n return null;\n } else if (!status && typeof stdout === 'string' && isIPv4(stdout.trim())) {\n return stdout.trim();\n } else {\n return null;\n }\n}\n\n/** By convention, a zero mac address means we have a virtual device, which we'd like to exclude */\nconst VIRTUAL_MAC_ADDRESS = '00:00:00:00:00:00';\n\n/** Determines the internal IP address by opening a socket, then checking the socket address against non-internal network interface assignments\n * @throws If no address can be determined.\n */\nfunction getRouteIPAddress(): string | null {\n // We check the IP address we get against the available network interfaces\n // It's only an internal IP address if we have a matching address on an interface's IP assignment\n let routeAddress: string | null = null;\n try {\n routeAddress = getRouteAddress();\n } catch {}\n if (!routeAddress) {\n return null;\n }\n const ifaces = networkInterfaces();\n for (const iface in ifaces) {\n const assignments = ifaces[iface];\n for (let i = 0; assignments && i < assignments.length; i++) {\n const assignment = assignments[i];\n // Only use IPv4 assigments that aren't internal\n // Only use IPv4 assignment if it's not a virtual device (e.g. a VPN network interface)\n if (\n assignment.family === 'IPv4' &&\n !assignment.internal &&\n assignment.address === routeAddress &&\n assignment.mac !== VIRTUAL_MAC_ADDRESS\n )\n return routeAddress;\n }\n }\n return null;\n}\n\nexport function getIpAddress(): string {\n return internalIp.v4.sync() || getRouteIPAddress() || '127.0.0.1';\n}\n"],"names":["getIpAddress","getRouteAddress","error","status","stdout","spawnSync","process","execPath","input","shell","timeout","encoding","windowsVerbatimArguments","windowsHide","isIPv4","trim","VIRTUAL_MAC_ADDRESS","getRouteIPAddress","routeAddress","ifaces","networkInterfaces","iface","assignments","i","length","assignment","family","internal","address","mac","internalIp","v4","sync"],"mappings":"AAAA;;;;+BAoFgBA,cAAY;;aAAZA,YAAY;;;8DApFL,aAAa;;;;;;;yBACV,oBAAoB;;;;;;;yBACvB,UAAU;;;;;;;yBACC,SAAS;;;;;;;;;;;AAE3C;;;;;;CAMC,GACD,SAASC,eAAe,GAAkB;IACxC,MAAM,EAAEC,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAEC,MAAM,CAAA,EAAE,GAAGC,IAAAA,iBAAS,EAAA,UAAA,EAACC,OAAO,CAACC,QAAQ,EAAE;QAAC,GAAG;KAAC,EAAE;QACnE,oEAAoE;QACpE,0EAA0E;QAC1E,uEAAuE;QACvE,iDAAiD;QACjD,8EAA8E;QAC9EC,KAAK,EAAE,CAAC;;;;;;;;;;;;;IAaR,CAAC;QACDC,KAAK,EAAE,KAAK;QACZC,OAAO,EAAE,GAAG;QACZC,QAAQ,EAAE,MAAM;QAChBC,wBAAwB,EAAE,KAAK;QAC/BC,WAAW,EAAE,IAAI;KAClB,CAAC,AAAC;IACH,wFAAwF;IACxF,IAAIV,MAAM,IAAID,KAAK,EAAE;QACnB,OAAO,IAAI,CAAC;IACd,OAAO,IAAI,CAACC,MAAM,IAAI,OAAOC,MAAM,KAAK,QAAQ,IAAIU,IAAAA,QAAM,EAAA,OAAA,EAACV,MAAM,CAACW,IAAI,EAAE,CAAC,EAAE;QACzE,OAAOX,MAAM,CAACW,IAAI,EAAE,CAAC;IACvB,OAAO;QACL,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,iGAAiG,GACjG,MAAMC,mBAAmB,GAAG,mBAAmB,AAAC;AAEhD;;CAEC,GACD,SAASC,iBAAiB,GAAkB;IAC1C,0EAA0E;IAC1E,iGAAiG;IACjG,IAAIC,YAAY,GAAkB,IAAI,AAAC;IACvC,IAAI;QACFA,YAAY,GAAGjB,eAAe,EAAE,CAAC;IACnC,EAAE,OAAM,CAAC,CAAC;IACV,IAAI,CAACiB,YAAY,EAAE;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAMC,MAAM,GAAGC,IAAAA,OAAiB,EAAA,kBAAA,GAAE,AAAC;IACnC,IAAK,MAAMC,KAAK,IAAIF,MAAM,CAAE;QAC1B,MAAMG,WAAW,GAAGH,MAAM,CAACE,KAAK,CAAC,AAAC;QAClC,IAAK,IAAIE,CAAC,GAAG,CAAC,EAAED,WAAW,IAAIC,CAAC,GAAGD,WAAW,CAACE,MAAM,EAAED,CAAC,EAAE,CAAE;YAC1D,MAAME,UAAU,GAAGH,WAAW,CAACC,CAAC,CAAC,AAAC;YAClC,gDAAgD;YAChD,uFAAuF;YACvF,IACEE,UAAU,CAACC,MAAM,KAAK,MAAM,IAC5B,CAACD,UAAU,CAACE,QAAQ,IACpBF,UAAU,CAACG,OAAO,KAAKV,YAAY,IACnCO,UAAU,CAACI,GAAG,KAAKb,mBAAmB,EAEtC,OAAOE,YAAY,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,SAASlB,YAAY,GAAW;IACrC,OAAO8B,WAAU,EAAA,QAAA,CAACC,EAAE,CAACC,IAAI,EAAE,IAAIf,iBAAiB,EAAE,IAAI,WAAW,CAAC;AACpE,CAAC"}
@@ -31,7 +31,7 @@ class FetchClient {
31
31
  this.headers = {
32
32
  accept: "application/json",
33
33
  "content-type": "application/json",
34
- "user-agent": `expo-cli/${"0.21.5"}`,
34
+ "user-agent": `expo-cli/${"0.21.7"}`,
35
35
  authorization: "Basic " + _nodeBuffer().Buffer.from(`${target}:`).toString("base64")
36
36
  };
37
37
  }
@@ -79,7 +79,7 @@ function createContext() {
79
79
  cpu: summarizeCpuInfo(),
80
80
  app: {
81
81
  name: "expo/cli",
82
- version: "0.21.5"
82
+ version: "0.21.7"
83
83
  },
84
84
  ci: _ciInfo().isCI ? {
85
85
  name: _ciInfo().name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/cli",
3
- "version": "0.21.5",
3
+ "version": "0.21.7",
4
4
  "description": "The Expo CLI",
5
5
  "main": "build/bin/cli",
6
6
  "bin": {
@@ -43,7 +43,7 @@
43
43
  "@babel/runtime": "^7.20.0",
44
44
  "@expo/code-signing-certificates": "^0.0.5",
45
45
  "@expo/config": "~10.0.4",
46
- "@expo/config-plugins": "~9.0.3",
46
+ "@expo/config-plugins": "~9.0.10",
47
47
  "@expo/devcert": "^1.1.2",
48
48
  "@expo/env": "~0.4.0",
49
49
  "@expo/image-utils": "^0.6.0",
@@ -52,7 +52,7 @@
52
52
  "@expo/osascript": "^2.0.31",
53
53
  "@expo/package-manager": "^1.5.0",
54
54
  "@expo/plist": "^0.2.0",
55
- "@expo/prebuild-config": "^8.0.16",
55
+ "@expo/prebuild-config": "^8.0.17",
56
56
  "@expo/rudder-sdk-node": "^1.1.1",
57
57
  "@expo/spawn-async": "^1.7.2",
58
58
  "@expo/xcpretty": "^4.3.0",
@@ -167,5 +167,5 @@
167
167
  "tree-kill": "^1.2.2",
168
168
  "tsd": "^0.28.1"
169
169
  },
170
- "gitHead": "9ff989048e66f85facda048e4be78329d8665e7c"
170
+ "gitHead": "8b7a5da5dc407c5242f4c512e892c2ca3506a096"
171
171
  }