From 492a081410dcb7fa23bc369d2984760a0d3e2d6e Mon Sep 17 00:00:00 2001 From: Phoenix Date: Fri, 3 Nov 2023 15:43:21 -0400 Subject: [PATCH] [autolinking] Add ios.includeTestSpecsLocally. Adds includeTestSpecsLocally option to ExpoModuleConfig for ios. Any module with this config will have the podspec.test_specs included via autolinking when the module path does not include node_modules. This allows module authors to link tests within their own projects, but avoid linking tests for consumers of their published library. --- .../build/ExpoModuleConfig.d.ts | 4 ++++ .../build/ExpoModuleConfig.js | 6 ++++++ .../build/ExpoModuleConfig.js.map | 2 +- .../expo-modules-autolinking/build/platforms/ios.js | 1 + .../build/platforms/ios.js.map | 2 +- packages/expo-modules-autolinking/build/types.d.ts | 10 ++++++++++ packages/expo-modules-autolinking/build/types.js.map | 2 +- .../scripts/ios/autolinking_manager.rb | 12 +++++++++++- .../expo-modules-autolinking/scripts/ios/package.rb | 4 ++++ .../expo-modules-autolinking/src/ExpoModuleConfig.ts | 7 +++++++ .../src/platforms/__tests__/ios-test.ts | 2 ++ .../expo-modules-autolinking/src/platforms/ios.ts | 1 + packages/expo-modules-autolinking/src/types.ts | 11 +++++++++++ 13 files changed, 60 insertions(+), 4 deletions(-) diff --git a/packages/expo-modules-autolinking/build/ExpoModuleConfig.d.ts b/packages/expo-modules-autolinking/build/ExpoModuleConfig.d.ts index 95460b6904627..4a3664e17f488 100644 --- a/packages/expo-modules-autolinking/build/ExpoModuleConfig.d.ts +++ b/packages/expo-modules-autolinking/build/ExpoModuleConfig.d.ts @@ -33,6 +33,10 @@ export declare class ExpoModuleConfig { * Returns whether this module will be added only to the debug configuration */ iosDebugOnly(): boolean; + /** + * Returns whether the podspec test_specs should be included when this project is local. + */ + iosIncludeTestSpecsLocally(): boolean; /** * Returns a list of names of Kotlin native modules classes to put to the generated package provider file. */ diff --git a/packages/expo-modules-autolinking/build/ExpoModuleConfig.js b/packages/expo-modules-autolinking/build/ExpoModuleConfig.js index f9e31929b8d9e..ceaf6ac96a309 100644 --- a/packages/expo-modules-autolinking/build/ExpoModuleConfig.js +++ b/packages/expo-modules-autolinking/build/ExpoModuleConfig.js @@ -59,6 +59,12 @@ class ExpoModuleConfig { iosDebugOnly() { return this.rawConfig.ios?.debugOnly ?? false; } + /** + * Returns whether the podspec test_specs should be included when this project is local. + */ + iosIncludeTestSpecsLocally() { + return this.rawConfig.ios?.includeTestSpecsLocally ?? false; + } /** * Returns a list of names of Kotlin native modules classes to put to the generated package provider file. */ diff --git a/packages/expo-modules-autolinking/build/ExpoModuleConfig.js.map b/packages/expo-modules-autolinking/build/ExpoModuleConfig.js.map index b5538a2f13e2d..3fcc7d957d16f 100644 --- a/packages/expo-modules-autolinking/build/ExpoModuleConfig.js.map +++ b/packages/expo-modules-autolinking/build/ExpoModuleConfig.js.map @@ -1 +1 @@ -{"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAa,gBAAgB;IACN;IAArB,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,UAAU;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAErC,4DAA4D;QAC5D,OAAO,SAAS,EAAE,OAAO,IAAI,SAAS,EAAE,iBAAiB,IAAI,EAAE,CAAC;IAClE,CAAC;IAED;;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CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { AndroidGradlePluginDescriptor, RawExpoModuleConfig, SupportedPlatform } from './types';\n\nfunction arrayize(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModules() {\n const iosConfig = this.rawConfig.ios;\n\n // `modulesClassNames` is a legacy name for the same config.\n return iosConfig?.modules ?? iosConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n iosReactDelegateHandlers(): string[] {\n return this.rawConfig.ios?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n iosPodspecPaths(): string[] {\n return arrayize(this.rawConfig.ios?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n iosSwiftModuleNames(): string[] {\n return arrayize(this.rawConfig.ios?.swiftModuleName);\n }\n\n /**\n * Returns whether this module will be added only to the debug configuration\n */\n iosDebugOnly(): boolean {\n return this.rawConfig.ios?.debugOnly ?? false;\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModules() {\n const androidConfig = this.rawConfig.android;\n\n // `modulesClassNames` is a legacy name for the same config.\n return androidConfig?.modules ?? androidConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns build.gradle file paths defined by the module author.\n */\n androidGradlePaths(): string[] {\n return arrayize(this.rawConfig.android?.gradlePath ?? []);\n }\n\n /**\n * Returns gradle plugins descriptors defined by the module author.\n */\n androidGradlePlugins(): AndroidGradlePluginDescriptor[] {\n return arrayize(this.rawConfig.android?.gradlePlugins ?? []);\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/**\n * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class.\n */\nexport function requireAndResolveExpoModuleConfig(path: string): ExpoModuleConfig {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n return new ExpoModuleConfig(require(path) as RawExpoModuleConfig);\n}\n"]} \ No newline at end of file +{"version":3,"file":"ExpoModuleConfig.js","sourceRoot":"","sources":["../src/ExpoModuleConfig.ts"],"names":[],"mappings":";;;AAEA,SAAS,QAAQ,CAAI,KAA0B;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAa,gBAAgB;IACN;IAArB,YAAqB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEvD;;OAEG;IACH,gBAAgB,CAAC,QAA2B;QAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,UAAU;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAErC,4DAA4D;QAC5D,OAAO,SAAS,EAAE,OAAO,IAAI,SAAS,EAAE,iBAAiB,IAAI,EAAE,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,yBAAyB;QACvB,OAAO,IAAI,CA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,4DAA4D;IAC5D,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAwB,CAAC,CAAC;AACpE,CAAC;AAJD,8EAIC","sourcesContent":["import { AndroidGradlePluginDescriptor, RawExpoModuleConfig, SupportedPlatform } from './types';\n\nfunction arrayize(value: T[] | T | undefined): T[] {\n if (Array.isArray(value)) {\n return value;\n }\n return value != null ? [value] : [];\n}\n\n/**\n * A class that wraps the raw config (`expo-module.json` or `unimodule.json`).\n */\nexport class ExpoModuleConfig {\n constructor(readonly rawConfig: RawExpoModuleConfig) {}\n\n /**\n * Whether the module supports given platform.\n */\n supportsPlatform(platform: SupportedPlatform): boolean {\n return this.rawConfig.platforms?.includes(platform) ?? false;\n }\n\n /**\n * Returns a list of names of Swift native modules classes to put to the generated modules provider file.\n */\n iosModules() {\n const iosConfig = this.rawConfig.ios;\n\n // `modulesClassNames` is a legacy name for the same config.\n return iosConfig?.modules ?? iosConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that receives AppDelegate life-cycle events.\n */\n iosAppDelegateSubscribers(): string[] {\n return this.rawConfig.ios?.appDelegateSubscribers ?? [];\n }\n\n /**\n * Returns a list of names of Swift classes that implement `ExpoReactDelegateHandler`.\n */\n iosReactDelegateHandlers(): string[] {\n return this.rawConfig.ios?.reactDelegateHandlers ?? [];\n }\n\n /**\n * Returns podspec paths defined by the module author.\n */\n iosPodspecPaths(): string[] {\n return arrayize(this.rawConfig.ios?.podspecPath);\n }\n\n /**\n * Returns the product module names, if defined by the module author.\n */\n iosSwiftModuleNames(): string[] {\n return arrayize(this.rawConfig.ios?.swiftModuleName);\n }\n\n /**\n * Returns whether this module will be added only to the debug configuration\n */\n iosDebugOnly(): boolean {\n return this.rawConfig.ios?.debugOnly ?? false;\n }\n\n /**\n * Returns whether the podspec test_specs should be included when this project is local.\n */\n iosIncludeTestSpecsLocally(): boolean {\n return this.rawConfig.ios?.includeTestSpecsLocally ?? false;\n }\n\n /**\n * Returns a list of names of Kotlin native modules classes to put to the generated package provider file.\n */\n androidModules() {\n const androidConfig = this.rawConfig.android;\n\n // `modulesClassNames` is a legacy name for the same config.\n return androidConfig?.modules ?? androidConfig?.modulesClassNames ?? [];\n }\n\n /**\n * Returns build.gradle file paths defined by the module author.\n */\n androidGradlePaths(): string[] {\n return arrayize(this.rawConfig.android?.gradlePath ?? []);\n }\n\n /**\n * Returns gradle plugins descriptors defined by the module author.\n */\n androidGradlePlugins(): AndroidGradlePluginDescriptor[] {\n return arrayize(this.rawConfig.android?.gradlePlugins ?? []);\n }\n\n /**\n * Returns serializable raw config.\n */\n toJSON(): RawExpoModuleConfig {\n return this.rawConfig;\n }\n}\n\n/**\n * Reads the config at given path and returns the config wrapped by `ExpoModuleConfig` class.\n */\nexport function requireAndResolveExpoModuleConfig(path: string): ExpoModuleConfig {\n // TODO: Validate the raw config against a schema.\n // TODO: Support for `*.js` files, not only static `*.json`.\n return new ExpoModuleConfig(require(path) as RawExpoModuleConfig);\n}\n"]} \ No newline at end of file diff --git a/packages/expo-modules-autolinking/build/platforms/ios.js b/packages/expo-modules-autolinking/build/platforms/ios.js index 56b70a710bec6..1f837e04e05b6 100644 --- a/packages/expo-modules-autolinking/build/platforms/ios.js +++ b/packages/expo-modules-autolinking/build/platforms/ios.js @@ -49,6 +49,7 @@ async function resolveModuleAsync(packageName, revision, options) { appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [], reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [], debugOnly: revision.config?.iosDebugOnly() ?? false, + includeTestSpecsLocally: revision.config?.iosIncludeTestSpecsLocally() ?? false, }; } exports.resolveModuleAsync = resolveModuleAsync; diff --git a/packages/expo-modules-autolinking/build/platforms/ios.js.map b/packages/expo-modules-autolinking/build/platforms/ios.js.map index 49f9ee411470a..b326266ebbea0 100644 --- a/packages/expo-modules-autolinking/build/platforms/ios.js.map +++ b/packages/expo-modules-autolinking/build/platforms/ios.js.map @@ -1 +1 @@ -{"version":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,CAAC,CAAC;SACjF;KACF;IACD,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC3E,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC;AATD,8EASC;AAED,SAAS,6BAA6B,CACpC,gBAAwB,EACxB,UAAkB,EAClB,eAA8B,IAAI;IAElC,IAAI,YAAY,EAAE;QAChB,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,MAAM,CAAC,MAAM,CACvE,gBAAgB,CACjB,GAAG,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;KAC9D;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AAC7D,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport {\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\n\nconst indent = ' ';\n\nasync function findPodspecFiles(revision: PackageRevision): Promise {\n const configPodspecPaths = revision.config?.iosPodspecPaths();\n if (configPodspecPaths && configPodspecPaths.length) {\n return configPodspecPaths;\n }\n\n const podspecFiles = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n return podspecFiles;\n}\n\nexport function getSwiftModuleNames(\n pods: ModuleIosPodspecInfo[],\n swiftModuleNames: string[] | undefined\n): string[] {\n if (swiftModuleNames && swiftModuleNames.length) {\n return swiftModuleNames;\n }\n // by default, non-alphanumeric characters in the pod name are replaced by _ in the module name\n return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));\n}\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise {\n const podspecFiles = await findPodspecFiles(revision);\n if (!podspecFiles.length) {\n return null;\n }\n\n const pods = podspecFiles.map((podspecFile) => ({\n podName: path.basename(podspecFile, path.extname(podspecFile)),\n podspecDir: path.dirname(path.join(revision.path, podspecFile)),\n }));\n\n const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.iosSwiftModuleNames());\n\n return {\n packageName,\n pods,\n swiftModuleNames,\n flags: options.flags,\n modules: revision.config?.iosModules() ?? [],\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [],\n reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [],\n debugOnly: revision.config?.iosDebugOnly() ?? false,\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string\n): Promise {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptorIos[],\n className: string\n): Promise {\n const iosModules = modules.filter(\n (module) =>\n module.modules.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n\n const modulesToImport = iosModules.filter((module) => !module.debugOnly);\n const debugOnlyModules = iosModules.filter((module) => module.debugOnly);\n\n const swiftModules = ([] as string[])\n .concat(...modulesToImport.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const debugOnlySwiftModules = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const modulesClassNames = ([] as string[])\n .concat(...modulesToImport.map((module) => module.modules))\n .filter(Boolean);\n\n const debugOnlyModulesClassNames = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.modules))\n .filter(Boolean);\n\n const appDelegateSubscribers = ([] as string[]).concat(\n ...modulesToImport.map((module) => module.appDelegateSubscribers)\n );\n\n const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(\n ...debugOnlyModules.map((module) => module.appDelegateSubscribers)\n );\n\n const reactDelegateHandlerModules = modulesToImport.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${generateCommonImportList(swiftModules)}\n${generateDebugOnlyImportList(debugOnlySwiftModules)}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}\n }\n}\n`;\n}\n\nfunction generateCommonImportList(swiftModules: string[]): string {\n return swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n');\n}\n\nfunction generateDebugOnlyImportList(swiftModules: string[]): string {\n if (!swiftModules.length) {\n return '';\n }\n\n return (\n wrapInDebugConfigurationCheck(\n 0,\n swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n')\n ) + '\\n'\n );\n}\n\nfunction generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {\n const commonClassNames = formatArrayOfClassNames(classNames);\n if (debugOnlyClassName.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,\n `return ${commonClassNames}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonClassNames}`;\n }\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction generateReactDelegateHandlers(\n module: ModuleDescriptorIos[],\n debugOnlyModules: ModuleDescriptorIos[]\n): string {\n const commonModules = formatArrayOfReactDelegateHandler(module);\n if (debugOnlyModules.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,\n `return ${commonModules}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonModules}`;\n }\n}\n\n/**\n * Formats an array of modules to Swift's array containing ReactDelegateHandlers\n */\nexport function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]): string {\n const values: string[] = [];\n for (const module of modules) {\n for (const handler of module.reactDelegateHandlers) {\n values.push(`(packageName: \"${module.packageName}\", handler: ${handler}.self)`);\n }\n }\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction wrapInDebugConfigurationCheck(\n indentationLevel: number,\n debugBlock: string,\n releaseBlock: string | null = null\n) {\n if (releaseBlock) {\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#else\\n${indent.repeat(\n indentationLevel\n )}${releaseBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n }\n\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n}\n"]} \ No newline at end of file +{"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/platforms/ios.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,wDAA0B;AAC1B,gDAAwB;AASxB,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,KAAK,UAAU,gBAAgB,CAAC,QAAyB;IACvD,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC9D,IAAI,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,EAAE;QACnD,OAAO,kBAAkB,CAAC;KAC3B;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAI,EAAC,aAAa,EAAE;QAC7C,GAAG,EAAE,QAAQ,CAAC,IAAI;QAClB,MAAM,EAAE,CAAC,oBAAoB,CAAC;KAC/B,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,mBAAmB,CACjC,IAA4B,EAC5B,gBAAsC;IAEtC,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC/C,OAAO,gBAAgB,CAAC;KACzB;IACD,+FAA+F;IAC/F,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC;AATD,kDASC;AAED;;GAEG;AACI,KAAK,UAAU,kBAAkB,CACtC,WAAmB,EACnB,QAAyB,EACzB,OAAsB;IAEtB,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CA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Aa,EAAE,CAAC;IAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,WAAW,eAAe,OAAO,QAAQ,CAAC,CAAC;SACjF;KACF;IACD,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;EAC3E,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AACtB,CAAC;AATD,8EASC;AAED,SAAS,6BAA6B,CACpC,gBAAwB,EACxB,UAAkB,EAClB,eAA8B,IAAI;IAElC,IAAI,YAAY,EAAE;QAChB,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,MAAM,CAAC,MAAM,CACvE,gBAAgB,CACjB,GAAG,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;KAC9D;IAED,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,iCAAiC,MAAM,CAAC,MAAM,CACrF,gBAAgB,CACjB,GAAG,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC;AAC7D,CAAC","sourcesContent":["import glob from 'fast-glob';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport {\n ModuleDescriptorIos,\n ModuleIosPodspecInfo,\n PackageRevision,\n SearchOptions,\n} from '../types';\n\nconst indent = ' ';\n\nasync function findPodspecFiles(revision: PackageRevision): Promise {\n const configPodspecPaths = revision.config?.iosPodspecPaths();\n if (configPodspecPaths && configPodspecPaths.length) {\n return configPodspecPaths;\n }\n\n const podspecFiles = await glob('*/*.podspec', {\n cwd: revision.path,\n ignore: ['**/node_modules/**'],\n });\n\n return podspecFiles;\n}\n\nexport function getSwiftModuleNames(\n pods: ModuleIosPodspecInfo[],\n swiftModuleNames: string[] | undefined\n): string[] {\n if (swiftModuleNames && swiftModuleNames.length) {\n return swiftModuleNames;\n }\n // by default, non-alphanumeric characters in the pod name are replaced by _ in the module name\n return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));\n}\n\n/**\n * Resolves module search result with additional details required for iOS platform.\n */\nexport async function resolveModuleAsync(\n packageName: string,\n revision: PackageRevision,\n options: SearchOptions\n): Promise {\n const podspecFiles = await findPodspecFiles(revision);\n if (!podspecFiles.length) {\n return null;\n }\n\n const pods = podspecFiles.map((podspecFile) => ({\n podName: path.basename(podspecFile, path.extname(podspecFile)),\n podspecDir: path.dirname(path.join(revision.path, podspecFile)),\n }));\n\n const swiftModuleNames = getSwiftModuleNames(pods, revision.config?.iosSwiftModuleNames());\n\n return {\n packageName,\n pods,\n swiftModuleNames,\n flags: options.flags,\n modules: revision.config?.iosModules() ?? [],\n appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [],\n reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [],\n debugOnly: revision.config?.iosDebugOnly() ?? false,\n includeTestSpecsLocally: revision.config?.iosIncludeTestSpecsLocally() ?? false,\n };\n}\n\n/**\n * Generates Swift file that contains all autolinked Swift packages.\n */\nexport async function generatePackageListAsync(\n modules: ModuleDescriptorIos[],\n targetPath: string\n): Promise {\n const className = path.basename(targetPath, path.extname(targetPath));\n const generatedFileContent = await generatePackageListFileContentAsync(modules, className);\n\n await fs.outputFile(targetPath, generatedFileContent);\n}\n\n/**\n * Generates the string to put into the generated package list.\n */\nasync function generatePackageListFileContentAsync(\n modules: ModuleDescriptorIos[],\n className: string\n): Promise {\n const iosModules = modules.filter(\n (module) =>\n module.modules.length ||\n module.appDelegateSubscribers.length ||\n module.reactDelegateHandlers.length\n );\n\n const modulesToImport = iosModules.filter((module) => !module.debugOnly);\n const debugOnlyModules = iosModules.filter((module) => module.debugOnly);\n\n const swiftModules = ([] as string[])\n .concat(...modulesToImport.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const debugOnlySwiftModules = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.swiftModuleNames))\n .filter(Boolean);\n\n const modulesClassNames = ([] as string[])\n .concat(...modulesToImport.map((module) => module.modules))\n .filter(Boolean);\n\n const debugOnlyModulesClassNames = ([] as string[])\n .concat(...debugOnlyModules.map((module) => module.modules))\n .filter(Boolean);\n\n const appDelegateSubscribers = ([] as string[]).concat(\n ...modulesToImport.map((module) => module.appDelegateSubscribers)\n );\n\n const debugOnlyAppDelegateSubscribers = ([] as string[]).concat(\n ...debugOnlyModules.map((module) => module.appDelegateSubscribers)\n );\n\n const reactDelegateHandlerModules = modulesToImport.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n const debugOnlyReactDelegateHandlerModules = debugOnlyModules.filter(\n (module) => !!module.reactDelegateHandlers.length\n );\n\n return `/**\n * Automatically generated by expo-modules-autolinking.\n *\n * This autogenerated class provides a list of classes of native Expo modules,\n * but only these that are written in Swift and use the new API for creating Expo modules.\n */\n\nimport ExpoModulesCore\n${generateCommonImportList(swiftModules)}\n${generateDebugOnlyImportList(debugOnlySwiftModules)}\n@objc(${className})\npublic class ${className}: ModulesProvider {\n public override func getModuleClasses() -> [AnyModule.Type] {\n${generateModuleClasses(modulesClassNames, debugOnlyModulesClassNames)}\n }\n\n public override func getAppDelegateSubscribers() -> [ExpoAppDelegateSubscriber.Type] {\n${generateModuleClasses(appDelegateSubscribers, debugOnlyAppDelegateSubscribers)}\n }\n\n public override func getReactDelegateHandlers() -> [ExpoReactDelegateHandlerTupleType] {\n${generateReactDelegateHandlers(reactDelegateHandlerModules, debugOnlyReactDelegateHandlerModules)}\n }\n}\n`;\n}\n\nfunction generateCommonImportList(swiftModules: string[]): string {\n return swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n');\n}\n\nfunction generateDebugOnlyImportList(swiftModules: string[]): string {\n if (!swiftModules.length) {\n return '';\n }\n\n return (\n wrapInDebugConfigurationCheck(\n 0,\n swiftModules.map((moduleName) => `import ${moduleName}`).join('\\n')\n ) + '\\n'\n );\n}\n\nfunction generateModuleClasses(classNames: string[], debugOnlyClassName: string[]): string {\n const commonClassNames = formatArrayOfClassNames(classNames);\n if (debugOnlyClassName.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfClassNames(classNames.concat(debugOnlyClassName))}`,\n `return ${commonClassNames}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonClassNames}`;\n }\n}\n\n/**\n * Formats an array of class names to Swift's array containing these classes.\n */\nfunction formatArrayOfClassNames(classNames: string[]): string {\n return `[${classNames.map((className) => `\\n${indent.repeat(3)}${className}.self`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction generateReactDelegateHandlers(\n module: ModuleDescriptorIos[],\n debugOnlyModules: ModuleDescriptorIos[]\n): string {\n const commonModules = formatArrayOfReactDelegateHandler(module);\n if (debugOnlyModules.length > 0) {\n return wrapInDebugConfigurationCheck(\n 2,\n `return ${formatArrayOfReactDelegateHandler(module.concat(debugOnlyModules))}`,\n `return ${commonModules}`\n );\n } else {\n return `${indent.repeat(2)}return ${commonModules}`;\n }\n}\n\n/**\n * Formats an array of modules to Swift's array containing ReactDelegateHandlers\n */\nexport function formatArrayOfReactDelegateHandler(modules: ModuleDescriptorIos[]): string {\n const values: string[] = [];\n for (const module of modules) {\n for (const handler of module.reactDelegateHandlers) {\n values.push(`(packageName: \"${module.packageName}\", handler: ${handler}.self)`);\n }\n }\n return `[${values.map((value) => `\\n${indent.repeat(3)}${value}`).join(',')}\n${indent.repeat(2)}]`;\n}\n\nfunction wrapInDebugConfigurationCheck(\n indentationLevel: number,\n debugBlock: string,\n releaseBlock: string | null = null\n) {\n if (releaseBlock) {\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#else\\n${indent.repeat(\n indentationLevel\n )}${releaseBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n }\n\n return `${indent.repeat(indentationLevel)}#if EXPO_CONFIGURATION_DEBUG\\n${indent.repeat(\n indentationLevel\n )}${debugBlock}\\n${indent.repeat(indentationLevel)}#endif`;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-modules-autolinking/build/types.d.ts b/packages/expo-modules-autolinking/build/types.d.ts index 734175d796de9..d5583ed81998d 100644 --- a/packages/expo-modules-autolinking/build/types.d.ts +++ b/packages/expo-modules-autolinking/build/types.d.ts @@ -64,6 +64,7 @@ export interface ModuleDescriptorIos { appDelegateSubscribers: string[]; reactDelegateHandlers: string[]; debugOnly: boolean; + includeTestSpecsLocally: boolean; } export interface ModuleDescriptorDevTools { packageName: string; @@ -129,6 +130,15 @@ export interface RawExpoModuleConfig { * Defaults to false. */ debugOnly?: boolean; + /** + * Whether the podspec test_specs should included when this project is local. + * Local is defined as 'outside of node_modules', so this option + * has no effect on modules included via package.json, but will affect + * modules in custom search directories. (e.g. local modules in ./modules/) + * + * Defaults to false. + */ + includeTestSpecsLocally?: boolean; }; /** * Android-specific config. diff --git a/packages/expo-modules-autolinking/build/types.js.map b/packages/expo-modules-autolinking/build/types.js.map index db4a9becd0849..cb3ed9126348a 100644 --- a/packages/expo-modules-autolinking/build/types.js.map +++ b/packages/expo-modules-autolinking/build/types.js.map @@ -1 +1 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ExpoModuleConfig } from './ExpoModuleConfig';\n\nexport type SupportedPlatform = 'ios' | 'android' | 'web' | 'devtools';\n\nexport interface SearchOptions {\n // Available in the CLI\n searchPaths: string[];\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n platform: SupportedPlatform;\n silent?: boolean;\n nativeModulesDir?: string | null;\n projectRoot: string;\n /**\n * Filter the search results to only include the project dependencies.\n * In a monorepo, you may like to set this to false and link all modules from the monorepo.\n * @default true\n */\n onlyProjectDeps?: boolean;\n\n // Scratched from project's config\n flags?: Record;\n}\n\nexport interface ResolveOptions extends SearchOptions {\n json?: boolean;\n}\n\nexport interface GenerateOptions extends ResolveOptions {\n target: string;\n namespace?: string;\n empty?: boolean;\n}\n\nexport interface PatchReactImportsOptions {\n podsRoot: string;\n dryRun: boolean;\n}\n\nexport type PackageRevision = {\n path: string;\n version: string;\n config?: ExpoModuleConfig;\n duplicates?: PackageRevision[];\n};\n\nexport type SearchResults = {\n [moduleName: string]: PackageRevision;\n};\n\nexport interface ModuleAndroidProjectInfo {\n name: string;\n sourceDir: string;\n}\n\nexport interface ModuleAndroidPluginInfo {\n id: string;\n sourceDir: string;\n}\n\nexport interface ModuleDescriptorAndroid {\n packageName: string;\n projects: ModuleAndroidProjectInfo[];\n plugins?: ModuleAndroidPluginInfo[];\n modules: string[];\n}\n\nexport interface ModuleIosPodspecInfo {\n podName: string;\n podspecDir: string;\n}\nexport interface ModuleDescriptorIos {\n packageName: string;\n pods: ModuleIosPodspecInfo[];\n flags: Record | undefined;\n swiftModuleNames: string[];\n modules: string[];\n appDelegateSubscribers: string[];\n reactDelegateHandlers: string[];\n debugOnly: boolean;\n}\n\nexport interface ModuleDescriptorDevTools {\n packageName: string;\n packageRoot: string;\n webpageRoot: string;\n}\n\nexport type ModuleDescriptor =\n | ModuleDescriptorAndroid\n | ModuleDescriptorIos\n | ModuleDescriptorDevTools;\n\nexport interface AndroidGradlePluginDescriptor {\n /**\n * Gradle plugin ID\n */\n id: string;\n\n /**\n * Artifact group\n */\n group: string;\n\n /**\n * Relative path to the gradle plugin directory\n */\n sourceDir: string;\n}\n\n/**\n * Represents a raw config from `expo-module.json`.\n */\nexport interface RawExpoModuleConfig {\n /**\n * An array of supported platforms.\n */\n platforms?: SupportedPlatform[];\n\n /**\n * iOS-specific config.\n */\n ios?: {\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n */\n modules?: string[];\n\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n * @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.\n */\n modulesClassNames?: string[];\n\n /**\n * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.\n */\n appDelegateSubscribers?: string[];\n\n /**\n * Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.\n */\n reactDelegateHandlers?: string[];\n\n /**\n * Podspec relative path.\n * To have multiple podspecs, string array type is also supported.\n */\n podspecPath?: string | string[];\n\n /**\n * Swift product module name. If empty, the pod name is used for Swift imports.\n * To have multiple modules, string array is also supported.\n */\n swiftModuleName?: string | string[];\n\n /**\n * Whether this module will be added only to the debug configuration.\n * Defaults to false.\n */\n debugOnly?: boolean;\n };\n\n /**\n * Android-specific config.\n */\n android?: {\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n */\n modules?: string[];\n\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n * @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.\n */\n modulesClassNames?: string[];\n\n /**\n * build.gradle relative path.\n * To have multiple build.gradle projects, string array type is also supported.\n */\n gradlePath?: string | string[];\n\n /**\n * Gradle plugins.\n */\n gradlePlugins?: AndroidGradlePluginDescriptor[];\n };\n\n /**\n * DevTools-specific config.\n */\n devtools?: {\n /**\n * The webpage root directory for Expo CLI DevTools to serve the web resources.\n */\n webpageRoot: string;\n };\n}\n"]} \ No newline at end of file +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ExpoModuleConfig } from './ExpoModuleConfig';\n\nexport type SupportedPlatform = 'ios' | 'android' | 'web' | 'devtools';\n\nexport interface SearchOptions {\n // Available in the CLI\n searchPaths: string[];\n ignorePaths?: string[] | null;\n exclude?: string[] | null;\n platform: SupportedPlatform;\n silent?: boolean;\n nativeModulesDir?: string | null;\n projectRoot: string;\n /**\n * Filter the search results to only include the project dependencies.\n * In a monorepo, you may like to set this to false and link all modules from the monorepo.\n * @default true\n */\n onlyProjectDeps?: boolean;\n\n // Scratched from project's config\n flags?: Record;\n}\n\nexport interface ResolveOptions extends SearchOptions {\n json?: boolean;\n}\n\nexport interface GenerateOptions extends ResolveOptions {\n target: string;\n namespace?: string;\n empty?: boolean;\n}\n\nexport interface PatchReactImportsOptions {\n podsRoot: string;\n dryRun: boolean;\n}\n\nexport type PackageRevision = {\n path: string;\n version: string;\n config?: ExpoModuleConfig;\n duplicates?: PackageRevision[];\n};\n\nexport type SearchResults = {\n [moduleName: string]: PackageRevision;\n};\n\nexport interface ModuleAndroidProjectInfo {\n name: string;\n sourceDir: string;\n}\n\nexport interface ModuleAndroidPluginInfo {\n id: string;\n sourceDir: string;\n}\n\nexport interface ModuleDescriptorAndroid {\n packageName: string;\n projects: ModuleAndroidProjectInfo[];\n plugins?: ModuleAndroidPluginInfo[];\n modules: string[];\n}\n\nexport interface ModuleIosPodspecInfo {\n podName: string;\n podspecDir: string;\n}\nexport interface ModuleDescriptorIos {\n packageName: string;\n pods: ModuleIosPodspecInfo[];\n flags: Record | undefined;\n swiftModuleNames: string[];\n modules: string[];\n appDelegateSubscribers: string[];\n reactDelegateHandlers: string[];\n debugOnly: boolean;\n includeTestSpecsLocally: boolean;\n}\n\nexport interface ModuleDescriptorDevTools {\n packageName: string;\n packageRoot: string;\n webpageRoot: string;\n}\n\nexport type ModuleDescriptor =\n | ModuleDescriptorAndroid\n | ModuleDescriptorIos\n | ModuleDescriptorDevTools;\n\nexport interface AndroidGradlePluginDescriptor {\n /**\n * Gradle plugin ID\n */\n id: string;\n\n /**\n * Artifact group\n */\n group: string;\n\n /**\n * Relative path to the gradle plugin directory\n */\n sourceDir: string;\n}\n\n/**\n * Represents a raw config from `expo-module.json`.\n */\nexport interface RawExpoModuleConfig {\n /**\n * An array of supported platforms.\n */\n platforms?: SupportedPlatform[];\n\n /**\n * iOS-specific config.\n */\n ios?: {\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n */\n modules?: string[];\n\n /**\n * Names of Swift native modules classes to put to the generated modules provider file.\n * @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.\n */\n modulesClassNames?: string[];\n\n /**\n * Names of Swift classes that hooks into `ExpoAppDelegate` to receive AppDelegate life-cycle events.\n */\n appDelegateSubscribers?: string[];\n\n /**\n * Names of Swift classes that implement `ExpoReactDelegateHandler` to hook React instance creation.\n */\n reactDelegateHandlers?: string[];\n\n /**\n * Podspec relative path.\n * To have multiple podspecs, string array type is also supported.\n */\n podspecPath?: string | string[];\n\n /**\n * Swift product module name. If empty, the pod name is used for Swift imports.\n * To have multiple modules, string array is also supported.\n */\n swiftModuleName?: string | string[];\n\n /**\n * Whether this module will be added only to the debug configuration.\n * Defaults to false.\n */\n debugOnly?: boolean;\n\n /**\n * Whether the podspec test_specs should included when this project is local.\n * Local is defined as 'outside of node_modules', so this option\n * has no effect on modules included via package.json, but will affect\n * modules in custom search directories. (e.g. local modules in ./modules/)\n *\n * Defaults to false.\n */\n includeTestSpecsLocally?: boolean;\n };\n\n /**\n * Android-specific config.\n */\n android?: {\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n */\n modules?: string[];\n\n /**\n * Full names (package + class name) of Kotlin native modules classes to put to the generated package provider file.\n * @deprecated Deprecated in favor of `modules`. Might be removed in the future releases.\n */\n modulesClassNames?: string[];\n\n /**\n * build.gradle relative path.\n * To have multiple build.gradle projects, string array type is also supported.\n */\n gradlePath?: string | string[];\n\n /**\n * Gradle plugins.\n */\n gradlePlugins?: AndroidGradlePluginDescriptor[];\n };\n\n /**\n * DevTools-specific config.\n */\n devtools?: {\n /**\n * The webpage root directory for Expo CLI DevTools to serve the web resources.\n */\n webpageRoot: string;\n };\n}\n"]} \ No newline at end of file diff --git a/packages/expo-modules-autolinking/scripts/ios/autolinking_manager.rb b/packages/expo-modules-autolinking/scripts/ios/autolinking_manager.rb index cfd75c8bda7d5..8c5fa1bae60ee 100644 --- a/packages/expo-modules-autolinking/scripts/ios/autolinking_manager.rb +++ b/packages/expo-modules-autolinking/scripts/ios/autolinking_manager.rb @@ -59,7 +59,7 @@ class AutolinkingManager :configuration => package.debugOnly ? ['Debug'] : [] # An empty array means all configurations }.merge(global_flags, package.flags) - if tests_only || include_tests + if tests_only || include_tests || include_tests_when_local(podspec_dir_path, package) podspec = podspec || get_podspec_for_pod(pod) test_specs_names = podspec.test_specs.map { |test_spec| test_spec.name.delete_prefix(podspec.name + "/") @@ -218,5 +218,15 @@ class AutolinkingManager } end + private def include_tests_when_local(path, package) + if path.include? 'node_modules' + return false + end + if package.includeTestSpecsLocally + return true + end + return false + end + end # class AutolinkingManager end # module Expo diff --git a/packages/expo-modules-autolinking/scripts/ios/package.rb b/packages/expo-modules-autolinking/scripts/ios/package.rb index 7dbe3f643e96b..e34cb6b8ab43c 100644 --- a/packages/expo-modules-autolinking/scripts/ios/package.rb +++ b/packages/expo-modules-autolinking/scripts/ios/package.rb @@ -35,6 +35,9 @@ class Package # Whether this module should only be added to the debug configuration. attr_reader :debugOnly + + # Whether the podspec test_specs should be included when this project is local. + attr_reader :includeTestSpecsLocally def initialize(json) @name = json['packageName'] @@ -43,6 +46,7 @@ def initialize(json) @flags = json.fetch('flags', {}) @modules = json.fetch('modules', []) @debugOnly = json['debugOnly'] + @includeTestSpecsLocally = json['includeTestSpecsLocally'] end def has_swift_modules_to_link? diff --git a/packages/expo-modules-autolinking/src/ExpoModuleConfig.ts b/packages/expo-modules-autolinking/src/ExpoModuleConfig.ts index 31ff4b371710d..47ea867ea7ff9 100644 --- a/packages/expo-modules-autolinking/src/ExpoModuleConfig.ts +++ b/packages/expo-modules-autolinking/src/ExpoModuleConfig.ts @@ -65,6 +65,13 @@ export class ExpoModuleConfig { return this.rawConfig.ios?.debugOnly ?? false; } + /** + * Returns whether the podspec test_specs should be included when this project is local. + */ + iosIncludeTestSpecsLocally(): boolean { + return this.rawConfig.ios?.includeTestSpecsLocally ?? false; + } + /** * Returns a list of names of Kotlin native modules classes to put to the generated package provider file. */ diff --git a/packages/expo-modules-autolinking/src/platforms/__tests__/ios-test.ts b/packages/expo-modules-autolinking/src/platforms/__tests__/ios-test.ts index f00f270b87d5d..864e09abfffc7 100644 --- a/packages/expo-modules-autolinking/src/platforms/__tests__/ios-test.ts +++ b/packages/expo-modules-autolinking/src/platforms/__tests__/ios-test.ts @@ -124,6 +124,7 @@ describe(resolveModuleAsync, () => { appDelegateSubscribers: [], reactDelegateHandlers: [], debugOnly: false, + includeTestSpecsLocally: false, }); }); @@ -162,6 +163,7 @@ describe(resolveModuleAsync, () => { appDelegateSubscribers: [], reactDelegateHandlers: [], debugOnly: false, + includeTestSpecsLocally: false, }); }); }); diff --git a/packages/expo-modules-autolinking/src/platforms/ios.ts b/packages/expo-modules-autolinking/src/platforms/ios.ts index dc70ec3876314..1b04b1081a943 100644 --- a/packages/expo-modules-autolinking/src/platforms/ios.ts +++ b/packages/expo-modules-autolinking/src/platforms/ios.ts @@ -65,6 +65,7 @@ export async function resolveModuleAsync( appDelegateSubscribers: revision.config?.iosAppDelegateSubscribers() ?? [], reactDelegateHandlers: revision.config?.iosReactDelegateHandlers() ?? [], debugOnly: revision.config?.iosDebugOnly() ?? false, + includeTestSpecsLocally: revision.config?.iosIncludeTestSpecsLocally() ?? false, }; } diff --git a/packages/expo-modules-autolinking/src/types.ts b/packages/expo-modules-autolinking/src/types.ts index 8c931fca2eaf1..4edb06731c227 100644 --- a/packages/expo-modules-autolinking/src/types.ts +++ b/packages/expo-modules-autolinking/src/types.ts @@ -78,6 +78,7 @@ export interface ModuleDescriptorIos { appDelegateSubscribers: string[]; reactDelegateHandlers: string[]; debugOnly: boolean; + includeTestSpecsLocally: boolean; } export interface ModuleDescriptorDevTools { @@ -159,6 +160,16 @@ export interface RawExpoModuleConfig { * Defaults to false. */ debugOnly?: boolean; + + /** + * Whether the podspec test_specs should included when this project is local. + * Local is defined as 'outside of node_modules', so this option + * has no effect on modules included via package.json, but will affect + * modules in custom search directories. (e.g. local modules in ./modules/) + * + * Defaults to false. + */ + includeTestSpecsLocally?: boolean; }; /**