@expo/cli 0.21.8 → 0.22.1

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.8");
124
+ console.log("0.22.1");
125
125
  process.exit(0);
126
126
  }
127
127
  if (args["--non-interactive"]) {
@@ -40,6 +40,13 @@ function _resolveFrom() {
40
40
  };
41
41
  return data;
42
42
  }
43
+ function _url() {
44
+ const data = /*#__PURE__*/ _interopRequireDefault(require("url"));
45
+ _url = function() {
46
+ return data;
47
+ };
48
+ return data;
49
+ }
43
50
  const _saveAssets = require("./saveAssets");
44
51
  const _serializeHtml = require("../start/server/metro/serializeHtml");
45
52
  const _domComponentsMiddleware = require("../start/server/middleware/DomComponentsMiddleware");
@@ -53,14 +60,15 @@ function _interopRequireDefault(obj) {
53
60
  const debug = require("debug")("expo:export:exportDomComponents");
54
61
  async function exportDomComponentAsync({ filePath , projectRoot , dev , devServer , isHermes , includeSourceMaps , exp , files }) {
55
62
  var ref;
56
- const virtualEntry = (0, _resolveFrom().default)(projectRoot, "expo/dom/entry.js");
63
+ const virtualEntry = (0, _filePath.toPosixPath)((0, _resolveFrom().default)(projectRoot, "expo/dom/entry.js"));
57
64
  debug("Bundle DOM Component:", filePath);
58
65
  // MUST MATCH THE BABEL PLUGIN!
59
66
  const hash = _crypto().default.createHash("sha1").update(filePath).digest("hex");
60
67
  const outputName = `${_domComponentsMiddleware.DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;
61
- const generatedEntryPath = filePath.startsWith("file://") ? filePath.slice(7) : filePath;
68
+ const generatedEntryPath = (0, _filePath.toPosixPath)(filePath.startsWith("file://") ? _url().default.fileURLToPath(filePath) : filePath);
62
69
  const baseUrl = `/${_domComponentsMiddleware.DOM_COMPONENTS_BUNDLE_DIR}`;
63
- const relativeImport = "./" + _path().default.relative(_path().default.dirname(virtualEntry), generatedEntryPath);
70
+ // The relative import path will be used like URI so it must be POSIX.
71
+ const relativeImport = "./" + _path().default.posix.relative(_path().default.dirname(virtualEntry), generatedEntryPath);
64
72
  // Run metro bundler and create the JS bundles/source maps.
65
73
  const bundle = await devServer.legacySinglePageExportBundleAsync({
66
74
  platform: "web",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportDomComponents.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { type PlatformMetadata } from './createMetadataJson';\nimport { type BundleOutput, type ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { type MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getDomComponentHtml,\n DOM_COMPONENTS_BUNDLE_DIR,\n} from '../start/server/middleware/DomComponentsMiddleware';\nimport { env } from '../utils/env';\nimport { resolveRealEntryFilePath } from '../utils/filePath';\n\nconst debug = require('debug')('expo:export:exportDomComponents') as typeof console.log;\n\n// TODO(EvanBacon): determine how to support DOM Components with hosting.\nexport async function exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps,\n exp,\n files,\n}: {\n filePath: string;\n projectRoot: string;\n dev: boolean;\n devServer: MetroBundlerDevServer;\n isHermes: boolean;\n includeSourceMaps: boolean;\n exp: ExpoConfig;\n files: ExportAssetMap;\n}): Promise<{\n bundle: BundleOutput;\n htmlOutputName: string;\n}> {\n const virtualEntry = resolveFrom(projectRoot, 'expo/dom/entry.js');\n debug('Bundle DOM Component:', filePath);\n // MUST MATCH THE BABEL PLUGIN!\n const hash = crypto.createHash('sha1').update(filePath).digest('hex');\n const outputName = `${DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;\n const generatedEntryPath = filePath.startsWith('file://') ? filePath.slice(7) : filePath;\n const baseUrl = `/${DOM_COMPONENTS_BUNDLE_DIR}`;\n const relativeImport = './' + path.relative(path.dirname(virtualEntry), generatedEntryPath);\n // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.legacySinglePageExportBundleAsync({\n platform: 'web',\n domRoot: encodeURI(relativeImport),\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING,\n mainModuleName: resolveRealEntryFilePath(projectRoot, virtualEntry),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: includeSourceMaps,\n bytecode: false,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: './',\n // Minify may be false because it's skipped on native when Hermes is enabled, default to true.\n minify: true,\n });\n\n const html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: getDomComponentHtml(),\n baseUrl: './',\n });\n\n const serialAssets = bundle.artifacts.map((a) => {\n return {\n ...a,\n filename: path.join(baseUrl, a.filename),\n };\n });\n\n getFilesFromSerialAssets(serialAssets, {\n includeSourceMaps,\n files,\n platform: 'web',\n });\n\n files.set(outputName, {\n contents: html,\n });\n\n return {\n bundle,\n htmlOutputName: outputName,\n };\n}\n\n/**\n * For EAS Updates exports,\n * post-processes the DOM component bundle and updates the asset paths to use flattened MD5 naming.\n */\nexport function updateDomComponentAssetsForMD5Naming({\n domComponentReference,\n nativeBundle,\n domComponentBundle,\n files,\n htmlOutputName,\n}: {\n domComponentReference: string;\n nativeBundle: BundleOutput;\n domComponentBundle: BundleOutput;\n files: ExportAssetMap;\n htmlOutputName: string;\n}): PlatformMetadata['assets'] {\n const assetsMetadata: PlatformMetadata['assets'] = [];\n\n for (const artifact of domComponentBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const artifactAssetName = `/${DOM_COMPONENTS_BUNDLE_DIR}/${artifact.filename}`;\n let source = artifact.source;\n\n // [0] Updates asset paths in the DOM component JS bundle (which is a web bundle)\n for (const asset of domComponentBundle.assets) {\n const prefix = asset.httpServerLocation.startsWith('./')\n ? asset.httpServerLocation.slice(2)\n : asset.httpServerLocation;\n const uri = `${prefix}/${asset.name}.${asset.type}`;\n const regexp = new RegExp(`(uri:\")(${uri})(\")`, 'g');\n const index = asset.scales.findIndex((s) => s === 1) ?? 0; // DOM components (web) uses 1x assets\n const md5 = asset.fileHashes[index];\n source = source.replace(regexp, `$1${md5}.${asset.type}$3`);\n\n const domJsAssetEntity = files.get(artifactAssetName);\n assert(domJsAssetEntity);\n domJsAssetEntity.contents = source;\n }\n\n // [1] Updates JS artifacts in HTML\n const md5 = crypto.createHash('md5').update(source).digest('hex');\n const htmlAssetEntity = files.get(htmlOutputName);\n assert(htmlAssetEntity);\n const regexp = new RegExp(`(<script src=\")(.*${artifact.filename})(\" defer></script>)`, 'g');\n htmlAssetEntity.contents = htmlAssetEntity.contents.toString().replace(regexp, `$1${md5}.js$3`);\n\n assetsMetadata.push({\n path: artifactAssetName.slice(1),\n ext: 'js',\n });\n }\n\n // [2] Updates HTML names from native bundle\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const hash = crypto.createHash('sha1').update(domComponentReference).digest('hex');\n for (const artifact of nativeBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const assetEntity = files.get(artifact.filename);\n assert(assetEntity);\n const regexp = new RegExp(`(['\"])${hash}\\\\.html(['\"])`, 'g');\n assetEntity.contents = assetEntity.contents.toString().replace(regexp, `$1${htmlMd5}.html$2`);\n }\n assetsMetadata.push({\n path: htmlOutputName,\n ext: 'html',\n });\n\n return assetsMetadata;\n}\n"],"names":["exportDomComponentAsync","updateDomComponentAssetsForMD5Naming","debug","require","filePath","projectRoot","dev","devServer","isHermes","includeSourceMaps","exp","files","virtualEntry","resolveFrom","hash","crypto","createHash","update","digest","outputName","DOM_COMPONENTS_BUNDLE_DIR","generatedEntryPath","startsWith","slice","baseUrl","relativeImport","path","relative","dirname","bundle","legacySinglePageExportBundleAsync","platform","domRoot","encodeURI","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRealEntryFilePath","mode","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","minify","html","serializeHtmlWithAssets","isExporting","resources","artifacts","template","getDomComponentHtml","serialAssets","map","a","filename","join","getFilesFromSerialAssets","set","contents","htmlOutputName","domComponentReference","nativeBundle","domComponentBundle","assetsMetadata","artifact","type","artifactAssetName","source","asset","assets","prefix","httpServerLocation","uri","name","regexp","RegExp","index","scales","findIndex","s","md5","fileHashes","replace","domJsAssetEntity","get","assert","htmlAssetEntity","toString","push","ext","htmlContent","htmlMd5","assetEntity"],"mappings":"AAAA;;;;;;;;;;;IAoBsBA,uBAAuB,MAAvBA,uBAAuB;IAgF7BC,oCAAoC,MAApCA,oCAAoC;;;8DAnGjC,QAAQ;;;;;;;8DACR,QAAQ;;;;;;;8DACV,MAAM;;;;;;;8DACC,cAAc;;;;;;4BAG2C,cAAc;+BAEvD,qCAAqC;yCAItE,oDAAoD;qBACvC,cAAc;0BACO,mBAAmB;;;;;;AAE5D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAGjF,eAAeH,uBAAuB,CAAC,EAC5CI,QAAQ,CAAA,EACRC,WAAW,CAAA,EACXC,GAAG,CAAA,EACHC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,iBAAiB,CAAA,EACjBC,GAAG,CAAA,EACHC,KAAK,CAAA,EAUN,EAGE;QAmBkBD,GAAe;IAlBlC,MAAME,YAAY,GAAGC,IAAAA,YAAW,EAAA,QAAA,EAACR,WAAW,EAAE,mBAAmB,CAAC,AAAC;IACnEH,KAAK,CAAC,uBAAuB,EAAEE,QAAQ,CAAC,CAAC;IACzC,+BAA+B;IAC/B,MAAMU,IAAI,GAAGC,OAAM,EAAA,QAAA,CAACC,UAAU,CAAC,MAAM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GpF,KAAK,CAAC4E,GAAG,CAACpB,SAAQ,CAACV,QAAQ,CAAC,AAAC;QACjD+B,IAAAA,OAAM,EAAA,QAAA,EAACO,WAAW,CAAC,CAAC;QACpB,MAAMlB,OAAM,GAAG,IAAIC,MAAM,CAAC,CAAC,MAAM,EAAEhE,IAAI,CAAC,aAAa,CAAC,EAAE,GAAG,CAAC,AAAC;QAC7DiF,WAAW,CAAClC,QAAQ,GAAGkC,WAAW,CAAClC,QAAQ,CAAC6B,QAAQ,EAAE,CAACL,OAAO,CAACR,OAAM,EAAE,CAAC,EAAE,EAAEiB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChG,CAAC;IACD5B,cAAc,CAACyB,IAAI,CAAC;QAClBjE,IAAI,EAAEoC,cAAc;QACpB8B,GAAG,EAAE,MAAM;KACZ,CAAC,CAAC;IAEH,OAAO1B,cAAc,CAAC;AACxB,CAAC"}
1
+ {"version":3,"sources":["../../../src/export/exportDomComponents.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport url from 'url';\n\nimport { type PlatformMetadata } from './createMetadataJson';\nimport { type BundleOutput, type ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { type MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getDomComponentHtml,\n DOM_COMPONENTS_BUNDLE_DIR,\n} from '../start/server/middleware/DomComponentsMiddleware';\nimport { env } from '../utils/env';\nimport { resolveRealEntryFilePath, toPosixPath } from '../utils/filePath';\n\nconst debug = require('debug')('expo:export:exportDomComponents') as typeof console.log;\n\n// TODO(EvanBacon): determine how to support DOM Components with hosting.\nexport async function exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps,\n exp,\n files,\n}: {\n filePath: string;\n projectRoot: string;\n dev: boolean;\n devServer: MetroBundlerDevServer;\n isHermes: boolean;\n includeSourceMaps: boolean;\n exp: ExpoConfig;\n files: ExportAssetMap;\n}): Promise<{\n bundle: BundleOutput;\n htmlOutputName: string;\n}> {\n const virtualEntry = toPosixPath(resolveFrom(projectRoot, 'expo/dom/entry.js'));\n debug('Bundle DOM Component:', filePath);\n // MUST MATCH THE BABEL PLUGIN!\n const hash = crypto.createHash('sha1').update(filePath).digest('hex');\n const outputName = `${DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;\n const generatedEntryPath = toPosixPath(\n filePath.startsWith('file://') ? url.fileURLToPath(filePath) : filePath\n );\n const baseUrl = `/${DOM_COMPONENTS_BUNDLE_DIR}`;\n // The relative import path will be used like URI so it must be POSIX.\n const relativeImport = './' + path.posix.relative(path.dirname(virtualEntry), generatedEntryPath);\n // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.legacySinglePageExportBundleAsync({\n platform: 'web',\n domRoot: encodeURI(relativeImport),\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING,\n mainModuleName: resolveRealEntryFilePath(projectRoot, virtualEntry),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: includeSourceMaps,\n bytecode: false,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: './',\n // Minify may be false because it's skipped on native when Hermes is enabled, default to true.\n minify: true,\n });\n\n const html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: getDomComponentHtml(),\n baseUrl: './',\n });\n\n const serialAssets = bundle.artifacts.map((a) => {\n return {\n ...a,\n filename: path.join(baseUrl, a.filename),\n };\n });\n\n getFilesFromSerialAssets(serialAssets, {\n includeSourceMaps,\n files,\n platform: 'web',\n });\n\n files.set(outputName, {\n contents: html,\n });\n\n return {\n bundle,\n htmlOutputName: outputName,\n };\n}\n\n/**\n * For EAS Updates exports,\n * post-processes the DOM component bundle and updates the asset paths to use flattened MD5 naming.\n */\nexport function updateDomComponentAssetsForMD5Naming({\n domComponentReference,\n nativeBundle,\n domComponentBundle,\n files,\n htmlOutputName,\n}: {\n domComponentReference: string;\n nativeBundle: BundleOutput;\n domComponentBundle: BundleOutput;\n files: ExportAssetMap;\n htmlOutputName: string;\n}): PlatformMetadata['assets'] {\n const assetsMetadata: PlatformMetadata['assets'] = [];\n\n for (const artifact of domComponentBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const artifactAssetName = `/${DOM_COMPONENTS_BUNDLE_DIR}/${artifact.filename}`;\n let source = artifact.source;\n\n // [0] Updates asset paths in the DOM component JS bundle (which is a web bundle)\n for (const asset of domComponentBundle.assets) {\n const prefix = asset.httpServerLocation.startsWith('./')\n ? asset.httpServerLocation.slice(2)\n : asset.httpServerLocation;\n const uri = `${prefix}/${asset.name}.${asset.type}`;\n const regexp = new RegExp(`(uri:\")(${uri})(\")`, 'g');\n const index = asset.scales.findIndex((s) => s === 1) ?? 0; // DOM components (web) uses 1x assets\n const md5 = asset.fileHashes[index];\n source = source.replace(regexp, `$1${md5}.${asset.type}$3`);\n\n const domJsAssetEntity = files.get(artifactAssetName);\n assert(domJsAssetEntity);\n domJsAssetEntity.contents = source;\n }\n\n // [1] Updates JS artifacts in HTML\n const md5 = crypto.createHash('md5').update(source).digest('hex');\n const htmlAssetEntity = files.get(htmlOutputName);\n assert(htmlAssetEntity);\n const regexp = new RegExp(`(<script src=\")(.*${artifact.filename})(\" defer></script>)`, 'g');\n htmlAssetEntity.contents = htmlAssetEntity.contents.toString().replace(regexp, `$1${md5}.js$3`);\n\n assetsMetadata.push({\n path: artifactAssetName.slice(1),\n ext: 'js',\n });\n }\n\n // [2] Updates HTML names from native bundle\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const hash = crypto.createHash('sha1').update(domComponentReference).digest('hex');\n for (const artifact of nativeBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const assetEntity = files.get(artifact.filename);\n assert(assetEntity);\n const regexp = new RegExp(`(['\"])${hash}\\\\.html(['\"])`, 'g');\n assetEntity.contents = assetEntity.contents.toString().replace(regexp, `$1${htmlMd5}.html$2`);\n }\n assetsMetadata.push({\n path: htmlOutputName,\n ext: 'html',\n });\n\n return assetsMetadata;\n}\n"],"names":["exportDomComponentAsync","updateDomComponentAssetsForMD5Naming","debug","require","filePath","projectRoot","dev","devServer","isHermes","includeSourceMaps","exp","files","virtualEntry","toPosixPath","resolveFrom","hash","crypto","createHash","update","digest","outputName","DOM_COMPONENTS_BUNDLE_DIR","generatedEntryPath","startsWith","url","fileURLToPath","baseUrl","relativeImport","path","posix","relative","dirname","bundle","legacySinglePageExportBundleAsync","platform","domRoot","encodeURI","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRealEntryFilePath","mode","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","minify","html","serializeHtmlWithAssets","isExporting","resources","artifacts","template","getDomComponentHtml","serialAssets","map","a","filename","join","getFilesFromSerialAssets","set","contents","htmlOutputName","domComponentReference","nativeBundle","domComponentBundle","assetsMetadata","artifact","type","artifactAssetName","source","asset","assets","prefix","httpServerLocation","slice","uri","name","regexp","RegExp","index","scales","findIndex","s","md5","fileHashes","replace","domJsAssetEntity","get","assert","htmlAssetEntity","toString","push","ext","htmlContent","htmlMd5","assetEntity"],"mappings":"AAAA;;;;;;;;;;;IAqBsBA,uBAAuB,MAAvBA,uBAAuB;IAmF7BC,oCAAoC,MAApCA,oCAAoC;;;8DAvGjC,QAAQ;;;;;;;8DACR,QAAQ;;;;;;;8DACV,MAAM;;;;;;;8DACC,cAAc;;;;;;;8DACtB,KAAK;;;;;;4BAG4D,cAAc;+BAEvD,qCAAqC;yCAItE,oDAAoD;qBACvC,cAAc;0BACoB,mBAAmB;;;;;;AAEzE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,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ddata/xcschemes/*.xcscheme",
70
+ "ios/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme",
71
+ "ios/**/*.xcworkspace/contents.xcworkspacedata",
72
+ // macOS
73
+ "macos/Podfile",
74
+ "macos/**/*.xcodeproj/project.pbxproj",
75
+ "macos/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme",
76
+ "macos/**/*.xcworkspace/contents.xcworkspacedata",
71
77
  ];
72
78
  async function getTemplateFilesToRenameAsync({ cwd , /**
73
79
  * An array of patterns following the rename config format. If omitted, then
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/renameTemplateAppName.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport { glob } from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { ExtractProps } from '../utils/npm';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\nfunction escapeXMLCharacters(original: string): string {\n const noAmps = original.replace('&', '&amp;');\n const noLt = noAmps.replace('<', '&lt;');\n const noGt = noLt.replace('>', '&gt;');\n const noApos = noGt.replace('\"', '\\\\\"');\n return noApos.replace(\"'\", \"\\\\'\");\n}\n\n/**\n * # Background\n *\n * `@expo/cli` and `create-expo` extract a template from a tarball (whether from\n * a local npm project or a GitHub repository), but these templates have a\n * static name that needs to be updated to match whatever app name the user\n * specified.\n *\n * By convention, the app name of all templates is \"HelloWorld\". During\n * extraction, filepaths are transformed via `createEntryResolver()` in\n * `createFileTransform.ts`, but the contents of files are left untouched.\n * Technically, the contents used to be transformed during extraction as well,\n * but due to poor configurability, we've moved to a post-extraction approach.\n *\n * # The new approach: Renaming the app post-extraction\n *\n * In this new approach, we take a list of file patterns, otherwise known as the\n * \"rename config\" to determine explicitly which files – relative to the root of\n * the template – to perform find-and-replace on, to update the app name.\n *\n * ## The rename config\n *\n * The rename config can be passed directly as a string array to\n * `getTemplateFilesToRenameAsync()`.\n *\n * The file patterns are formatted as glob expressions to be interpreted by\n * [fast-glob](https://github.com/mrmlnc/fast-glob). Comments are supported with\n * the `#` symbol, both in the plain-text file and string array formats.\n * Whitespace is trimmed and whitespace-only lines are ignored.\n *\n * If no rename config has been passed directly to\n * `getTemplateFilesToRenameAsync()` then this default rename config will be\n * used instead.\n */\nexport const defaultRenameConfig = [\n // Common\n '!**/node_modules',\n 'app.json',\n\n // Android\n 'android/**/*.gradle',\n 'android/app/BUCK',\n 'android/app/src/**/*.java',\n 'android/app/src/**/*.kt',\n 'android/app/src/**/*.xml',\n\n // iOS\n 'ios/Podfile',\n 'ios/**/*.xcodeproj/project.pbxproj',\n 'ios/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n] as const;\n\n/**\n * Returns a list of files within a template matched by the resolved rename\n * config.\n *\n * The rename config is resolved in the order of preference:\n * Config provided as function param > defaultRenameConfig\n */\nexport async function getTemplateFilesToRenameAsync({\n cwd,\n /**\n * An array of patterns following the rename config format. If omitted, then\n * we fall back to defaultRenameConfig.\n * @see defaultRenameConfig\n */\n renameConfig: userConfig,\n}: Pick<ExtractProps, 'cwd'> & { renameConfig?: string[] }) {\n let config = userConfig ?? defaultRenameConfig;\n\n // Strip comments, trim whitespace, and remove empty lines.\n config = config.map((line) => line.split(/(?<!\\\\)#/, 2)[0].trim()).filter((line) => line !== '');\n\n return await glob(config, {\n cwd,\n // `true` is consistent with .gitignore. Allows `*.xml` to match .xml files\n // in all subdirs.\n baseNameMatch: true,\n dot: true,\n // Prevent climbing out of the template directory in case a template\n // includes a symlink to an external directory.\n followSymbolicLinks: false,\n });\n}\n\nexport async function renameTemplateAppNameAsync({\n cwd,\n name,\n files,\n}: Pick<ExtractProps, 'cwd' | 'name'> & {\n /**\n * An array of files to transform. Usually provided by calling\n * getTemplateFilesToRenameAsync().\n * @see getTemplateFilesToRenameAsync\n */\n files: string[];\n}) {\n debug(`Got files to transform: ${JSON.stringify(files)}`);\n\n await Promise.all(\n files.map(async (file) => {\n const absoluteFilePath = path.resolve(cwd, file);\n\n let contents: string;\n try {\n contents = await fs.promises.readFile(absoluteFilePath, { encoding: 'utf-8' });\n } catch (error) {\n throw new Error(\n `Failed to read template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n\n debug(`Renaming app name in file: ${absoluteFilePath}`);\n\n const safeName = ['.xml', '.plist'].includes(path.extname(file))\n ? escapeXMLCharacters(name)\n : name;\n\n try {\n const replacement = contents\n .replace(/Hello App Display Name/g, safeName)\n .replace(/HelloWorld/g, IOSConfig.XcodeUtils.sanitizedName(safeName))\n .replace(/helloworld/g, IOSConfig.XcodeUtils.sanitizedName(safeName.toLowerCase()));\n\n if (replacement === contents) {\n return;\n }\n\n await fs.promises.writeFile(absoluteFilePath, replacement);\n } catch (error) {\n throw new Error(\n `Failed to overwrite template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n })\n );\n}\n"],"names":["defaultRenameConfig","getTemplateFilesToRenameAsync","renameTemplateAppNameAsync","debug","require","escapeXMLCharacters","original","noAmps","replace","noLt","noGt","noApos","cwd","renameConfig","userConfig","config","map","line","split","trim","filter","glob","baseNameMatch","dot","followSymbolicLinks","name","files","JSON","stringify","Promise","all","file","absoluteFilePath","path","resolve","contents","fs","promises","readFile","encoding","error","Error","cause","safeName","includes","extname","replacement","IOSConfig","XcodeUtils","sanitizedName","toLowerCase","writeFile"],"mappings":"AAAA;;;;;;;;;;;IAmDaA,mBAAmB,MAAnBA,mBAAmB;IAyBVC,6BAA6B,MAA7BA,6BAA6B;IA0B7BC,0BAA0B,MAA1BA,0BAA0B;;;yBAtGtB,sBAAsB;;;;;;;yBAC3B,WAAW;;;;;;;8DACjB,IAAI;;;;;;;8DACF,MAAM;;;;;;;;;;;AAIvB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAExF,SAASC,mBAAmB,CAACC,QAAgB,EAAU;IACrD,MAAMC,MAAM,GAAGD,QAAQ,CAACE,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Q,CAACO,WAAW,EAAE,CAAC,CAAC,AAAC;YAEtF,IAAIJ,WAAW,KAAKX,QAAQ,EAAE;gBAC5B,OAAO;YACT,CAAC;YAED,MAAMC,GAAE,EAAA,QAAA,CAACC,QAAQ,CAACc,SAAS,CAACnB,gBAAgB,EAAEc,WAAW,CAAC,CAAC;QAC7D,EAAE,OAAON,MAAK,EAAE;YACd,MAAM,IAAIC,KAAK,CACb,CAAC,oCAAoC,EAAET,gBAAgB,CAAC,gCAAgC,CAAC,EACzF;gBAAEU,KAAK,EAAEF,MAAK;aAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/prebuild/renameTemplateAppName.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport { glob } from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { ExtractProps } from '../utils/npm';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\nfunction escapeXMLCharacters(original: string): string {\n const noAmps = original.replace('&', '&amp;');\n const noLt = noAmps.replace('<', '&lt;');\n const noGt = noLt.replace('>', '&gt;');\n const noApos = noGt.replace('\"', '\\\\\"');\n return noApos.replace(\"'\", \"\\\\'\");\n}\n\n/**\n * # Background\n *\n * `@expo/cli` and `create-expo` extract a template from a tarball (whether from\n * a local npm project or a GitHub repository), but these templates have a\n * static name that needs to be updated to match whatever app name the user\n * specified.\n *\n * By convention, the app name of all templates is \"HelloWorld\". During\n * extraction, filepaths are transformed via `createEntryResolver()` in\n * `createFileTransform.ts`, but the contents of files are left untouched.\n * Technically, the contents used to be transformed during extraction as well,\n * but due to poor configurability, we've moved to a post-extraction approach.\n *\n * # The new approach: Renaming the app post-extraction\n *\n * In this new approach, we take a list of file patterns, otherwise known as the\n * \"rename config\" to determine explicitly which files – relative to the root of\n * the template – to perform find-and-replace on, to update the app name.\n *\n * ## The rename config\n *\n * The rename config can be passed directly as a string array to\n * `getTemplateFilesToRenameAsync()`.\n *\n * The file patterns are formatted as glob expressions to be interpreted by\n * [fast-glob](https://github.com/mrmlnc/fast-glob). Comments are supported with\n * the `#` symbol, both in the plain-text file and string array formats.\n * Whitespace is trimmed and whitespace-only lines are ignored.\n *\n * If no rename config has been passed directly to\n * `getTemplateFilesToRenameAsync()` then this default rename config will be\n * used instead.\n */\nexport const defaultRenameConfig = [\n // Common\n '!**/node_modules',\n 'app.json',\n\n // Android\n 'android/**/*.gradle',\n 'android/app/BUCK',\n 'android/app/src/**/*.java',\n 'android/app/src/**/*.kt',\n 'android/app/src/**/*.xml',\n\n // iOS\n 'ios/Podfile',\n 'ios/**/*.xcodeproj/project.pbxproj',\n 'ios/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n 'ios/**/*.xcworkspace/contents.xcworkspacedata',\n\n // macOS\n 'macos/Podfile',\n 'macos/**/*.xcodeproj/project.pbxproj',\n 'macos/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n 'macos/**/*.xcworkspace/contents.xcworkspacedata',\n] as const;\n\n/**\n * Returns a list of files within a template matched by the resolved rename\n * config.\n *\n * The rename config is resolved in the order of preference:\n * Config provided as function param > defaultRenameConfig\n */\nexport async function getTemplateFilesToRenameAsync({\n cwd,\n /**\n * An array of patterns following the rename config format. If omitted, then\n * we fall back to defaultRenameConfig.\n * @see defaultRenameConfig\n */\n renameConfig: userConfig,\n}: Pick<ExtractProps, 'cwd'> & { renameConfig?: string[] }) {\n let config = userConfig ?? defaultRenameConfig;\n\n // Strip comments, trim whitespace, and remove empty lines.\n config = config.map((line) => line.split(/(?<!\\\\)#/, 2)[0].trim()).filter((line) => line !== '');\n\n return await glob(config, {\n cwd,\n // `true` is consistent with .gitignore. Allows `*.xml` to match .xml files\n // in all subdirs.\n baseNameMatch: true,\n dot: true,\n // Prevent climbing out of the template directory in case a template\n // includes a symlink to an external directory.\n followSymbolicLinks: false,\n });\n}\n\nexport async function renameTemplateAppNameAsync({\n cwd,\n name,\n files,\n}: Pick<ExtractProps, 'cwd' | 'name'> & {\n /**\n * An array of files to transform. Usually provided by calling\n * getTemplateFilesToRenameAsync().\n * @see getTemplateFilesToRenameAsync\n */\n files: string[];\n}) {\n debug(`Got files to transform: ${JSON.stringify(files)}`);\n\n await Promise.all(\n files.map(async (file) => {\n const absoluteFilePath = path.resolve(cwd, file);\n\n let contents: string;\n try {\n contents = await fs.promises.readFile(absoluteFilePath, { encoding: 'utf-8' });\n } catch (error) {\n throw new Error(\n `Failed to read template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n\n debug(`Renaming app name in file: ${absoluteFilePath}`);\n\n const safeName = ['.xml', '.plist'].includes(path.extname(file))\n ? escapeXMLCharacters(name)\n : name;\n\n try {\n const replacement = contents\n .replace(/Hello App Display Name/g, safeName)\n .replace(/HelloWorld/g, IOSConfig.XcodeUtils.sanitizedName(safeName))\n .replace(/helloworld/g, IOSConfig.XcodeUtils.sanitizedName(safeName.toLowerCase()));\n\n if (replacement === contents) {\n return;\n }\n\n await fs.promises.writeFile(absoluteFilePath, replacement);\n } catch (error) {\n throw new Error(\n `Failed to overwrite template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n })\n );\n}\n"],"names":["defaultRenameConfig","getTemplateFilesToRenameAsync","renameTemplateAppNameAsync","debug","require","escapeXMLCharacters","original","noAmps","replace","noLt","noGt","noApos","cwd","renameConfig","userConfig","config","map","line","split","trim","filter","glob","baseNameMatch","dot","followSymbolicLinks","name","files","JSON","stringify","Promise","all","file","absoluteFilePath","path","resolve","contents","fs","promises","readFile","encoding","error","Error","cause","safeName","includes","extname","replacement","IOSConfig","XcodeUtils","sanitizedName","toLowerCase","writeFile"],"mappings":"AAAA;;;;;;;;;;;IAmDaA,mBAAmB,MAAnBA,mBAAmB;IAgCVC,6BAA6B,MAA7BA,6BAA6B;IA0B7BC,0BAA0B,MAA1BA,0BAA0B;;;yBA7GtB,sBA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I,CAAC,CAAC,GAC5D1B,mBAAmB,CAACoB,IAAI,CAAC,GACzBA,IAAI,AAAC;QAET,IAAI;YACF,MAAMqB,WAAW,GAAGX,QAAQ,CACzB3B,OAAO,4BAA4BmC,QAAQ,CAAC,CAC5CnC,OAAO,gBAAgBuC,cAAS,EAAA,UAAA,CAACC,UAAU,CAACC,aAAa,CAACN,QAAQ,CAAC,CAAC,CACpEnC,OAAO,gBAAgBuC,cAAS,EAAA,UAAA,CAACC,UAAU,CAACC,aAAa,CAACN,QAAQ,CAACO,WAAW,EAAE,CAAC,CAAC,AAAC;YAEtF,IAAIJ,WAAW,KAAKX,QAAQ,EAAE;gBAC5B,OAAO;YACT,CAAC;YAED,MAAMC,GAAE,EAAA,QAAA,CAACC,QAAQ,CAACc,SAAS,CAACnB,gBAAgB,EAAEc,WAAW,CAAC,CAAC;QAC7D,EAAE,OAAON,MAAK,EAAE;YACd,MAAM,IAAIC,KAAK,CACb,CAAC,oCAAoC,EAAET,gBAAgB,CAAC,gCAAgC,CAAC,EACzF;gBAAEU,KAAK,EAAEF,MAAK;aAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -93,7 +93,7 @@ function isCodeSigningConfigured(projectRoot) {
93
93
  }
94
94
  async function configureCodeSigningAsync(projectRoot) {
95
95
  const ids = await _security.findIdentitiesAsync();
96
- const id = await (0, _resolveCertificateSigningIdentity.resolveCertificateSigningIdentityAsync)(ids);
96
+ const id = await (0, _resolveCertificateSigningIdentity.resolveCertificateSigningIdentityAsync)(projectRoot, ids);
97
97
  _log.log(`\u203A Signing and building iOS app with: ${id.codeSigningInfo}`);
98
98
  (0, _xcodeCodeSigning.setAutoCodeSigningInfoForPbxproj)(projectRoot, {
99
99
  appleTeamId: id.appleTeamId
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/run/ios/codeSigning/configureCodeSigning.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { resolveCertificateSigningIdentityAsync } from './resolveCertificateSigningIdentity';\nimport { getCodeSigningInfoForPbxproj, setAutoCodeSigningInfoForPbxproj } from './xcodeCodeSigning';\nimport * as Log from '../../../log';\n\nexport async function ensureDeviceIsCodeSignedForDeploymentAsync(\n projectRoot: string\n): Promise<string | null> {\n if (isCodeSigningConfigured(projectRoot)) {\n return null;\n }\n return configureCodeSigningAsync(projectRoot);\n}\n\nfunction isCodeSigningConfigured(projectRoot: string): boolean {\n // Check if the app already has a development team defined.\n const signingInfo = getCodeSigningInfoForPbxproj(projectRoot);\n\n const allTargetsHaveTeams = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.developmentTeams.length;\n }, true);\n\n if (allTargetsHaveTeams) {\n const teamList = Object.values(signingInfo).reduce<string[]>((prev, curr) => {\n return prev.concat([curr.developmentTeams[0]]);\n }, []);\n Log.log(chalk.dim`\\u203A Auto signing app using team(s): ${teamList.join(', ')}`);\n return true;\n }\n\n const allTargetsHaveProfiles = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.provisioningProfiles.length;\n }, true);\n\n if (allTargetsHaveProfiles) {\n // this indicates that the user has manual code signing setup (possibly for production).\n return true;\n }\n return false;\n}\n\nasync function configureCodeSigningAsync(projectRoot: string) {\n const ids = await Security.findIdentitiesAsync();\n\n const id = await resolveCertificateSigningIdentityAsync(ids);\n\n Log.log(`\\u203A Signing and building iOS app with: ${id.codeSigningInfo}`);\n\n setAutoCodeSigningInfoForPbxproj(projectRoot, {\n appleTeamId: id.appleTeamId!,\n });\n return id.appleTeamId!;\n}\n"],"names":["ensureDeviceIsCodeSignedForDeploymentAsync","projectRoot","isCodeSigningConfigured","configureCodeSigningAsync","signingInfo","getCodeSigningInfoForPbxproj","allTargetsHaveTeams","Object","values","reduce","prev","curr","developmentTeams","length","teamList","concat","Log","log","chalk","dim","join","allTargetsHaveProfiles","provisioningProfiles","ids","Security","findIdentitiesAsync","id","resolveCertificateSigningIdentityAsync","codeSigning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AMC,sBAAsB,GAAGd,MAAM,CAACC,MAAM,CAACJ,WAAW,CAAC,CAACK,MAAM,CAAC,CAACC,IAAI,EAAEC,IAAI,GAAK;QAC/E,OAAOD,IAAI,IAAI,CAAC,CAACC,IAAI,CAACW,oBAAoB,CAACT,MAAM,CAAC;IACpD,CAAC,EAAE,IAAI,CAAC,AAAC;IAET,IAAIQ,sBAAsB,EAAE;QAC1B,wFAAwF;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,eAAelB,yBAAyB,CAACF,WAAmB,EAAE;IAC5D,MAAMsB,GAAG,GAAG,MAAMC,SAAQ,CAACC,mBAAmB,EAAE,AAAC;IAEjD,MAAMC,EAAE,GAAG,MAAMC,IAAAA,kCAAsC,uCAAA,EAACJ,GAAG,CAAC,AAAC;IAE7DP,IAAG,CAACC,GAAG,CAAC,CAAC,0CAA0C,EAAES,EAAE,CAACE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE3EC,IAAAA,iBAAgC,iCAAA,EAAC5B,WAAW,EAAE;QAC5C6B,WAAW,EAAEJ,EAAE,CAACI,WAAW;KAC5B,CAAC,CAAC;IACH,OAAOJ,EAAE,CAACI,WAAW,CAAE;AACzB,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/run/ios/codeSigning/configureCodeSigning.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { resolveCertificateSigningIdentityAsync } from './resolveCertificateSigningIdentity';\nimport { getCodeSigningInfoForPbxproj, setAutoCodeSigningInfoForPbxproj } from './xcodeCodeSigning';\nimport * as Log from '../../../log';\n\nexport async function ensureDeviceIsCodeSignedForDeploymentAsync(\n projectRoot: string\n): Promise<string | null> {\n if (isCodeSigningConfigured(projectRoot)) {\n return null;\n }\n return configureCodeSigningAsync(projectRoot);\n}\n\nfunction isCodeSigningConfigured(projectRoot: string): boolean {\n // Check if the app already has a development team defined.\n const signingInfo = getCodeSigningInfoForPbxproj(projectRoot);\n\n const allTargetsHaveTeams = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.developmentTeams.length;\n }, true);\n\n if (allTargetsHaveTeams) {\n const teamList = Object.values(signingInfo).reduce<string[]>((prev, curr) => {\n return prev.concat([curr.developmentTeams[0]]);\n }, []);\n Log.log(chalk.dim`\\u203A Auto signing app using team(s): ${teamList.join(', ')}`);\n return true;\n }\n\n const allTargetsHaveProfiles = Object.values(signingInfo).reduce((prev, curr) => {\n return prev && !!curr.provisioningProfiles.length;\n }, true);\n\n if (allTargetsHaveProfiles) {\n // this indicates that the user has manual code signing setup (possibly for production).\n return true;\n }\n return false;\n}\n\nasync function configureCodeSigningAsync(projectRoot: string) {\n const ids = await Security.findIdentitiesAsync();\n\n const id = await resolveCertificateSigningIdentityAsync(projectRoot, ids);\n\n Log.log(`\\u203A Signing and building iOS app with: ${id.codeSigningInfo}`);\n\n setAutoCodeSigningInfoForPbxproj(projectRoot, {\n appleTeamId: id.appleTeamId!,\n });\n return id.appleTeamId!;\n}\n"],"names":["ensureDeviceIsCodeSignedForDeploymentAsync","projectRoot","isCodeSigningConfigured","configureCodeSigningAsync","signingInfo","getCodeSigningInfoForPbxproj","allTargetsHaveTeams","Object","values","reduce","prev","curr","developmentTeams","length","teamList","concat","Log","log","chalk","dim","join","allTargetsHaveProfiles","provisioningProfiles","ids","Security","findIdentitiesAsync","id","resolveCertificateSigningIdentityAsync","codeSigningInfo","setAutoCodeSigningInfoForPbxproj","appleTeamId"],"mappings":"AAAA;;;;+BAOsBA,4CAA0C;;aAA1CA,0CAA0C;;;8DAP9C,OAAO;;;;;;gEAEC,YAAY;mDACiB,qCAAqC;kCACb,oBAAoB;2DAC9E,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5B,eAAeA,0CAA0C,CAC9DC,WAAmB,EACK;IACxB,IAAIC,uBAAuB,CAACD,WAAW,CAAC,EAAE;QACxC,OAAO,IAAI,CAAC;IACd,C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yBAAyB,CAACF,WAAmB,EAAE;IAC5D,MAAMsB,GAAG,GAAG,MAAMC,SAAQ,CAACC,mBAAmB,EAAE,AAAC;IAEjD,MAAMC,EAAE,GAAG,MAAMC,IAAAA,kCAAsC,uCAAA,EAAC1B,WAAW,EAAEsB,GAAG,CAAC,AAAC;IAE1EP,IAAG,CAACC,GAAG,CAAC,CAAC,0CAA0C,EAAES,EAAE,CAACE,eAAe,CAAC,CAAC,CAAC,CAAC;IAE3EC,IAAAA,iBAAgC,iCAAA,EAAC5B,WAAW,EAAE;QAC5C6B,WAAW,EAAEJ,EAAE,CAACI,WAAW;KAC5B,CAAC,CAAC;IACH,OAAOJ,EAAE,CAACI,WAAW,CAAE;AACzB,CAAC"}
@@ -13,6 +13,13 @@ _export(exports, {
13
13
  resolveCertificateSigningIdentityAsync: ()=>resolveCertificateSigningIdentityAsync,
14
14
  selectDevelopmentTeamAsync: ()=>selectDevelopmentTeamAsync
15
15
  });
16
+ function _config() {
17
+ const data = require("@expo/config");
18
+ _config = function() {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
16
23
  function _chalk() {
17
24
  const data = /*#__PURE__*/ _interopRequireDefault(require("chalk"));
18
25
  _chalk = function() {
@@ -93,7 +100,8 @@ async function sortDefaultIdToBeginningAsync(identities) {
93
100
  _log.log(`\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\n ${_chalk().default.bold((0, _link.learnMore)("https://expo.fyi/setup-xcode-signing"))}`);
94
101
  throw new _errors.CommandError("No code signing certificates are available to use.");
95
102
  }
96
- async function resolveCertificateSigningIdentityAsync(ids) {
103
+ async function resolveCertificateSigningIdentityAsync(projectRoot, ids) {
104
+ var ref;
97
105
  // The user has no valid code signing identities.
98
106
  if (!ids.length) {
99
107
  assertCodeSigningSetup();
@@ -108,11 +116,27 @@ async function resolveCertificateSigningIdentityAsync(ids) {
108
116
  }
109
117
  // Get identities and sort by the one that the user is most likely to choose.
110
118
  const [identities, preferred] = await sortDefaultIdToBeginningAsync(await _security.resolveIdentitiesAsync(ids));
111
- const selected = await selectDevelopmentTeamAsync(identities, preferred);
112
- // Store the last used value and suggest it as the first value
113
- // next time the user has to select a code signing identity.
114
- await (0, _settings.setLastDeveloperCodeSigningIdAsync)(selected.signingCertificateId);
115
- return selected;
119
+ // Read the config to interact with the `ios.appleTeamId` property
120
+ const { exp } = (0, _config().getConfig)(projectRoot, {
121
+ // We don't need very many fields here, just use the lightest possible read.
122
+ skipSDKVersionRequirement: true,
123
+ skipPlugins: true
124
+ });
125
+ const configuredTeamId = (ref = exp.ios) == null ? void 0 : ref.appleTeamId;
126
+ const configuredIdentity = configuredTeamId ? identities.find((identity)=>identity.appleTeamId === configuredTeamId) : undefined;
127
+ const selectedIdentity = configuredIdentity ?? await selectDevelopmentTeamAsync(identities, preferred);
128
+ await Promise.all([
129
+ // Store the last used value and suggest it as the first value
130
+ // next time the user has to select a code signing identity.
131
+ (0, _settings.setLastDeveloperCodeSigningIdAsync)(selectedIdentity.signingCertificateId),
132
+ // Store the last used team id in the app manifest, when no team id has been configured yet
133
+ configuredTeamId || !selectedIdentity.appleTeamId ? Promise.resolve() : (0, _config().modifyConfigAsync)(projectRoot, {
134
+ ios: {
135
+ appleTeamId: selectedIdentity.appleTeamId
136
+ }
137
+ }),
138
+ ]);
139
+ return selectedIdentity;
116
140
  }
117
141
  async function selectDevelopmentTeamAsync(identities, preferredId) {
118
142
  const index = await (0, _prompts.selectAsync)("Development team for signing the app", identities.map((value, i)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/run/ios/codeSigning/resolveCertificateSigningIdentity.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { getLastDeveloperCodeSigningIdAsync, setLastDeveloperCodeSigningIdAsync } from './settings';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { learnMore } from '../../../utils/link';\nimport { selectAsync } from '../../../utils/prompts';\n\n/**\n * Sort the code signing items so the last selected item (user's default) is the first suggested.\n */\nexport async function sortDefaultIdToBeginningAsync(\n identities: Security.CertificateSigningInfo[]\n): Promise<[Security.CertificateSigningInfo[], string | null]> {\n const lastSelected = await getLastDeveloperCodeSigningIdAsync();\n\n if (lastSelected) {\n let iterations = 0;\n while (identities[0].signingCertificateId !== lastSelected && iterations < identities.length) {\n identities.push(identities.shift()!);\n iterations++;\n }\n }\n return [identities, lastSelected];\n}\n\n/**\n * Assert that the computer needs code signing setup.\n * This links to an FYI page that was user tested internally.\n */\nfunction assertCodeSigningSetup(): never {\n // TODO: We can probably do this too automatically.\n Log.log(\n `\\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\\n ${chalk.bold(\n learnMore('https://expo.fyi/setup-xcode-signing')\n )}`\n );\n\n throw new CommandError('No code signing certificates are available to use.');\n}\n\n/**\n * Resolve the best certificate signing identity from a given list of IDs.\n * - If no IDs: Assert that the user has to setup code signing.\n * - If one ID: Return the first ID.\n * - If multiple IDs: Ask the user to select one, then store the value to be suggested first next time (since users generally use the same ID).\n */\nexport async function resolveCertificateSigningIdentityAsync(\n ids: string[]\n): Promise<Security.CertificateSigningInfo> {\n // The user has no valid code signing identities.\n if (!ids.length) {\n assertCodeSigningSetup();\n }\n\n // One ID available 🤝 Program is not interactive\n //\n // using the the first available option\n if (ids.length === 1 || !isInteractive()) {\n // This method is cheaper than `resolveIdentitiesAsync` and checking the\n // cached user preference so we should use this as early as possible.\n return Security.resolveCertificateSigningInfoAsync(ids[0]);\n }\n\n // Get identities and sort by the one that the user is most likely to choose.\n const [identities, preferred] = await sortDefaultIdToBeginningAsync(\n await Security.resolveIdentitiesAsync(ids)\n );\n\n const selected = await selectDevelopmentTeamAsync(identities, preferred);\n\n // Store the last used value and suggest it as the first value\n // next time the user has to select a code signing identity.\n await setLastDeveloperCodeSigningIdAsync(selected.signingCertificateId);\n\n return selected;\n}\n\n/** Prompt the user to select a development team, highlighting the preferred value based on the user history. */\nexport async function selectDevelopmentTeamAsync(\n identities: Security.CertificateSigningInfo[],\n preferredId: string | null\n): Promise<Security.CertificateSigningInfo> {\n const index = await selectAsync(\n 'Development team for signing the app',\n identities.map((value, i) => {\n const format =\n value.signingCertificateId === preferredId ? chalk.bold : (message: string) => message;\n return {\n // Formatted like: `650 Industries, Inc. (A1BCDEF234) - Apple Development: Evan Bacon (AA00AABB0A)`\n title: format(\n [value.appleTeamName, `(${value.appleTeamId}) -`, value.codeSigningInfo].join(' ')\n ),\n value: i,\n };\n })\n );\n\n return identities[index];\n}\n"],"names":["sortDefaultIdToBeginningAsync","resolveCertificateSigningIdentityAsync","selectDevelopmentTeamAsync","identities","lastSelected","getLastDeveloperCodeSigningIdAsync","iterations","signingCertificateId","length","push","shift","assertCodeSigningSetup","Log","log","chalk","bold","learnMore","CommandError","ids","isInteractive","Security","resolveCertificateSigningInfoAsync","preferred","resolveIdentitiesAsync","selected","setLastDeveloperCodeSigningIdAsync","preferredId","index","selectAsync","map","value","i","format","message","title","appleTeamName","appleTeamId","codeSigningInfo","join"],"mappings":"AAAA;;;;;;;;;;;IAasBA,6BAA6B,MAA7BA,6BAA6B;IAoC7BC,sCAAsC,MAAtCA,sCAAsC;IAgCtCC,0BAA0B,MAA1BA,0BAA0B;;;8DAjF9B,OAAO;;;;;;gEAEC,YAAY;0BACiD,YAAY;2DAC9E,cAAc;wBACN,uBAAuB;6BACtB,4BAA4B;sBAChC,qBAAqB;yBACnB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK7C,eAAeF,6BAA6B,CACjDG,UAA6C,EACgB;IAC7D,MAAMC,YAAY,GAAG,MAAMC,IAAAA,SAAkC,mCAAA,GAAE,AAAC;IAEhE,IAAID,YAAY,EAAE;QAChB,IAAIE,UAAU,GAAG,CAAC,AAAC;QACnB,MAAOH,UAAU,CAAC,CAAC,CAAC,CAACI,oBAAoB,KAAKH,YAAY,IAAIE,UAAU,GAAGH,UAAU,CAACK,MAAM,CAAE;YAC5FL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0BAA0B,CAC9CC,UAA6C,EAC7CuB,WAA0B,EACgB;IAC1C,MAAMC,KAAK,GAAG,MAAMC,IAAAA,QAAW,YAAA,EAC7B,sCAAsC,EACtCzB,UAAU,CAAC0B,GAAG,CAAC,CAACC,KAAK,EAAEC,CAAC,GAAK;QAC3B,MAAMC,MAAM,GACVF,KAAK,CAACvB,oBAAoB,KAAKmB,WAAW,GAAGZ,MAAK,EAAA,QAAA,CAACC,IAAI,GAAG,CAACkB,OAAe,GAAKA,OAAO,AAAC;QACzF,OAAO;YACL,mGAAmG;YACnGC,KAAK,EAAEF,MAAM,CACX;gBAACF,KAAK,CAACK,aAAa;gBAAE,CAAC,CAAC,EAAEL,KAAK,CAACM,WAAW,CAAC,GAAG,CAAC;gBAAEN,KAAK,CAACO,eAAe;aAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CACnF;YACDR,KAAK,EAAEC,CAAC;SACT,CAAC;IACJ,CAAC,CAAC,CACH,AAAC;IAEF,OAAO5B,UAAU,CAACwB,KAAK,CAAC,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/run/ios/codeSigning/resolveCertificateSigningIdentity.ts"],"sourcesContent":["import { getConfig, modifyConfigAsync } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Security from './Security';\nimport { getLastDeveloperCodeSigningIdAsync, setLastDeveloperCodeSigningIdAsync } from './settings';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { isInteractive } from '../../../utils/interactive';\nimport { learnMore } from '../../../utils/link';\nimport { selectAsync } from '../../../utils/prompts';\n\n/**\n * Sort the code signing items so the last selected item (user's default) is the first suggested.\n */\nexport async function sortDefaultIdToBeginningAsync(\n identities: Security.CertificateSigningInfo[]\n): Promise<[Security.CertificateSigningInfo[], string | null]> {\n const lastSelected = await getLastDeveloperCodeSigningIdAsync();\n\n if (lastSelected) {\n let iterations = 0;\n while (identities[0].signingCertificateId !== lastSelected && iterations < identities.length) {\n identities.push(identities.shift()!);\n iterations++;\n }\n }\n return [identities, lastSelected];\n}\n\n/**\n * Assert that the computer needs code signing setup.\n * This links to an FYI page that was user tested internally.\n */\nfunction assertCodeSigningSetup(): never {\n // TODO: We can probably do this too automatically.\n Log.log(\n `\\u203A Your computer requires some additional setup before you can build onto physical iOS devices.\\n ${chalk.bold(\n learnMore('https://expo.fyi/setup-xcode-signing')\n )}`\n );\n\n throw new CommandError('No code signing certificates are available to use.');\n}\n\n/**\n * Resolve the best certificate signing identity from a given list of IDs.\n * - If no IDs: Assert that the user has to setup code signing.\n * - If one ID: Return the first ID.\n * - If multiple IDs: Ask the user to select one, then store the value to be suggested first next time (since users generally use the same ID).\n */\nexport async function resolveCertificateSigningIdentityAsync(\n projectRoot: string,\n ids: string[]\n): Promise<Security.CertificateSigningInfo> {\n // The user has no valid code signing identities.\n if (!ids.length) {\n assertCodeSigningSetup();\n }\n\n // One ID available 🤝 Program is not interactive\n //\n // using the the first available option\n if (ids.length === 1 || !isInteractive()) {\n // This method is cheaper than `resolveIdentitiesAsync` and checking the\n // cached user preference so we should use this as early as possible.\n return Security.resolveCertificateSigningInfoAsync(ids[0]);\n }\n\n // Get identities and sort by the one that the user is most likely to choose.\n const [identities, preferred] = await sortDefaultIdToBeginningAsync(\n await Security.resolveIdentitiesAsync(ids)\n );\n\n // Read the config to interact with the `ios.appleTeamId` property\n const { exp } = getConfig(projectRoot, {\n // We don't need very many fields here, just use the lightest possible read.\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n const configuredTeamId = exp.ios?.appleTeamId;\n\n const configuredIdentity = configuredTeamId\n ? identities.find((identity) => identity.appleTeamId === configuredTeamId)\n : undefined;\n\n const selectedIdentity =\n configuredIdentity ?? (await selectDevelopmentTeamAsync(identities, preferred));\n\n await Promise.all([\n // Store the last used value and suggest it as the first value\n // next time the user has to select a code signing identity.\n setLastDeveloperCodeSigningIdAsync(selectedIdentity.signingCertificateId),\n // Store the last used team id in the app manifest, when no team id has been configured yet\n configuredTeamId || !selectedIdentity.appleTeamId\n ? Promise.resolve()\n : modifyConfigAsync(projectRoot, { ios: { appleTeamId: selectedIdentity.appleTeamId } }),\n ]);\n\n return selectedIdentity;\n}\n\n/** Prompt the user to select a development team, highlighting the preferred value based on the user history. */\nexport async function selectDevelopmentTeamAsync(\n identities: Security.CertificateSigningInfo[],\n preferredId: string | null\n): Promise<Security.CertificateSigningInfo> {\n const index = await selectAsync(\n 'Development team for signing the app',\n identities.map((value, i) => {\n const format =\n value.signingCertificateId === preferredId ? chalk.bold : (message: string) => message;\n return {\n // Formatted like: `650 Industries, Inc. (A1BCDEF234) - Apple Development: Evan Bacon (AA00AABB0A)`\n title: format(\n [value.appleTeamName, `(${value.appleTeamId}) -`, value.codeSigningInfo].join(' ')\n ),\n value: i,\n };\n })\n );\n\n return identities[index];\n}\n"],"names":["sortDefaultIdToBeginningAsync","resolveCertificateSigningIdentityAsync","selectDevelopmentTeamAsync","identities","lastSelected","getLastDeveloperCodeSigningIdAsync","iterations","signingCertificateId","length","push","shift","assertCodeSigningSetup","Log","log","chalk","bold","learnMore","CommandError","projectRoot","ids","exp","isInteractive","Security","resolveCertificateSigningInfoAsync","preferred","resolveIdentitiesAsync","getConfig","skipSDKVersionRequirement","skipPlugins","configuredTeamId","ios","appleTeamId","configuredIdentity","find","identity","undefined","selectedIdentity","Promise","all","setLastDeveloperCodeSigningIdAsync","resolve","modifyConfigAsync","preferredId","index","selectAsync","map","value","i","format","message","title","appleTeamName","codeSigningInfo","join"],"mappings":"AAAA;;;;;;;;;;;IAcsBA,6BAA6B,MAA7BA,6BAA6B;IAoC7BC,sCAAsC,MAAtCA,sCAAsC;IAoDtCC,0BAA0B,MAA1BA,0BAA0B;;;yBAtGH,cAAc;;;;;;;8DACzC,OAAO;;;;;;gEAEC,YAAY;0BACiD,YAAY;2DAC9E,cAAc;wBACN,uBAAuB;6BACtB,4BAA4B;sBAChC,qBAAqB;yBACnB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EACtCzC,UAAU,CAAC0C,GAAG,CAAC,CAACC,KAAK,EAAEC,CAAC,GAAK;QAC3B,MAAMC,MAAM,GACVF,KAAK,CAACvC,oBAAoB,KAAKmC,WAAW,GAAG5B,MAAK,EAAA,QAAA,CAACC,IAAI,GAAG,CAACkC,OAAe,GAAKA,OAAO,AAAC;QACzF,OAAO;YACL,mGAAmG;YACnGC,KAAK,EAAEF,MAAM,CACX;gBAACF,KAAK,CAACK,aAAa;gBAAE,CAAC,CAAC,EAAEL,KAAK,CAACf,WAAW,CAAC,GAAG,CAAC;gBAAEe,KAAK,CAACM,eAAe;aAAC,CAACC,IAAI,CAAC,GAAG,CAAC,CACnF;YACDP,KAAK,EAAEC,CAAC;SACT,CAAC;IACJ,CAAC,CAAC,CACH,AAAC;IAEF,OAAO5C,UAAU,CAACwC,KAAK,CAAC,CAAC;AAC3B,CAAC"}
@@ -635,7 +635,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
635
635
  serializerOutput: "static"
636
636
  };
637
637
  // https://github.com/facebook/metro/blob/2405f2f6c37a1b641cc379b9c733b1eff0c1c2a1/packages/metro/src/lib/parseOptionsFromUrl.js#L55-L87
638
- if (!opts.mainModuleName.startsWith("/")) {
638
+ if (!opts.mainModuleName.startsWith("/") && !_path().default.isAbsolute(opts.mainModuleName)) {
639
639
  opts.mainModuleName = "./" + opts.mainModuleName;
640
640
  }
641
641
  const output = await this.metroLoadModuleContents(opts.mainModuleName, opts, extraOptions);