From e1515636b2fd1c64f03c0a0fad6bb505f9ce973e Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 27 Jan 2022 12:18:57 +0100 Subject: [PATCH 01/39] chore: initial commit - remove files --- packages/cli/src/commands/index.ts | 8 - packages/cli/src/commands/install/install.ts | 33 - .../cli/src/commands/install/uninstall.ts | 29 - .../src/commands/link/__tests__/link.test.ts | 262 ----- .../commands/link/__tests__/makeHook.test.ts | 19 - .../cli/src/commands/link/getPlatformName.ts | 8 - packages/cli/src/commands/link/link.ts | 105 -- packages/cli/src/commands/link/linkAll.ts | 59 - packages/cli/src/commands/link/linkAssets.ts | 30 - .../cli/src/commands/link/linkDependency.ts | 67 -- packages/cli/src/commands/link/makeHook.ts | 10 - packages/cli/src/commands/link/pollParams.ts | 18 - .../commands/link/printDeprecationWarning.ts | 12 - packages/cli/src/commands/link/unlink.ts | 178 --- packages/platform-android/src/index.ts | 1 - .../src/link/__fixtures__/patchedBuild.gradle | 31 - .../src/link/__tests__/isInstalled.test.ts | 37 - .../platform-android/src/link/copyAssets.ts | 33 - packages/platform-android/src/link/index.ts | 19 - .../platform-android/src/link/isInstalled.ts | 18 - .../patches/__tests__/applyParams.test.ts | 20 - .../patches/__tests__/makeBuildPatch.test.ts | 71 -- .../patches/__tests__/makeImportPatch.test.ts | 26 - .../__tests__/makePackagePatch.test.ts | 31 - .../__tests__/makeSettingsPatch.test.ts | 102 -- .../__tests__/makeStringsPatch.test.ts | 25 - .../__tests__/normalizeProjectName.test.ts | 19 - .../src/link/patches/applyParams.ts | 25 - .../src/link/patches/applyPatch.ts | 26 - .../src/link/patches/makeBuildPatch.ts | 56 - .../src/link/patches/makeImportPatch.ts | 14 - .../src/link/patches/makePackagePatch.ts | 23 - .../src/link/patches/makeSettingsPatch.ts | 34 - .../src/link/patches/makeStringsPatch.ts | 31 - .../src/link/patches/normalizeProjectName.ts | 11 - .../src/link/patches/revokePatch.ts | 21 - .../src/link/registerNativeModule.ts | 46 - .../platform-android/src/link/unlinkAssets.ts | 37 - .../src/link/unregisterNativeModule.ts | 58 - .../src/link/warnAboutManuallyLinkedLibs.ts | 50 - packages/platform-ios/src/index.ts | 1 - .../src/link-pods/__fixtures__/Info.plist | 0 .../src/link-pods/__fixtures__/PodfileSimple | 8 - .../__fixtures__/PodfileWithFunction | 30 - .../__fixtures__/PodfileWithInvalidKey.lock | 16 - .../link-pods/__fixtures__/PodfileWithMarkers | 34 - .../link-pods/__fixtures__/PodfileWithTarget | 32 - .../__tests__/findLineToAddPod.test.ts | 47 - .../findMarkedLinesInPodfile.test.ts | 35 - .../__tests__/findPodTargetLine.test.ts | 31 - .../getDependenciesFromPodfileLock.test.ts | 22 - .../link-pods/__tests__/isInstalled.test.ts | 45 - .../__tests__/removePodEntry.test.ts | 49 - .../platform-ios/src/link-pods/addPodEntry.ts | 44 - .../src/link-pods/findLineToAddPod.ts | 34 - .../src/link-pods/findMarkedLinesInPodfile.ts | 19 - .../src/link-pods/findPodTargetLine.ts | 23 - .../getDependenciesFromPodfileLock.ts | 30 - .../platform-ios/src/link-pods/isInstalled.ts | 36 - .../platform-ios/src/link-pods/readPodfile.ts | 16 - .../src/link-pods/registerNativeModule.ts | 55 - .../src/link-pods/removePodEntry.ts | 24 - .../platform-ios/src/link-pods/savePodFile.ts | 19 - .../src/link-pods/unregisterNativeModule.ts | 28 - .../src/link/__fixtures__/Info.plist | 12 - .../link/__fixtures__/linearGradient.pbxproj | 258 ----- .../src/link/__fixtures__/project.pbxproj | 1011 ----------------- .../link/__tests__/addFileToProject.test.ts | 33 - .../__tests__/addProjectToLibraries.test.ts | 35 - .../link/__tests__/addSharedLibraries.test.ts | 48 - .../src/link/__tests__/createGroup.test.ts | 54 - .../link/__tests__/getBuildProperty.test.ts | 27 - .../src/link/__tests__/getGroup.test.ts | 46 - .../__tests__/getHeaderSearchPath.test.ts | 106 -- .../link/__tests__/getHeadersInFolder.test.ts | 51 - .../src/link/__tests__/getPlist.test.ts | 29 - .../src/link/__tests__/getPlistPath.test.ts | 27 - .../src/link/__tests__/getTargets.test.ts | 29 - .../link/__tests__/hasLibraryImported.test.ts | 32 - .../src/link/__tests__/isInstalled.test.ts | 39 - .../__tests__/mapHeaderSearchPaths.test.ts | 44 - .../removeProjectFromLibraries.test.ts | 41 - .../removeProjectFromProject.test.ts | 41 - .../__tests__/removeSharedLibrary.test.ts | 40 - .../src/link/__tests__/writePlist.test.ts | 60 - .../platform-ios/src/link/addFileToProject.ts | 22 - .../src/link/addProjectToLibraries.ts | 24 - .../src/link/addSharedLibraries.ts | 27 - .../src/link/addToHeaderSearchPaths.ts | 15 - .../src/link/common/isInstalled.ts | 26 - .../src/link/common/registerNativeModule.ts | 28 - .../src/link/common/unregisterNativeModule.ts | 36 - packages/platform-ios/src/link/copyAssets.ts | 58 - packages/platform-ios/src/link/createGroup.ts | 35 - .../src/link/createGroupWithMessage.ts | 31 - .../platform-ios/src/link/getBuildProperty.ts | 30 - packages/platform-ios/src/link/getGroup.ts | 46 - .../src/link/getHeaderSearchPath.ts | 63 - .../src/link/getHeadersInFolder.ts | 31 - packages/platform-ios/src/link/getPlist.ts | 26 - .../platform-ios/src/link/getPlistPath.ts | 23 - packages/platform-ios/src/link/getTargets.ts | 46 - .../src/link/hasLibraryImported.ts | 22 - packages/platform-ios/src/link/index.ts | 19 - packages/platform-ios/src/link/isInstalled.ts | 43 - .../src/link/mapHeaderSearchPaths.ts | 50 - .../src/link/registerNativeModule.ts | 94 -- .../src/link/removeFromHeaderSearchPaths.ts | 20 - .../removeFromPbxItemContainerProxySection.ts | 25 - .../removeFromPbxReferenceProxySection.ts | 24 - .../src/link/removeFromProjectReferences.ts | 36 - .../src/link/removeFromStaticLibraries.ts | 33 - .../src/link/removeProductGroup.ts | 17 - .../src/link/removeProjectFromLibraries.ts | 22 - .../src/link/removeProjectFromProject.ts | 37 - .../src/link/removeSharedLibraries.ts | 22 - .../platform-ios/src/link/unlinkAssets.ts | 66 -- .../src/link/unregisterNativeModule.ts | 86 -- .../src/link/warnAboutManuallyLinkedLibs.ts | 50 - .../src/link/warnAboutPodInstall.ts | 29 - packages/platform-ios/src/link/writePlist.ts | 37 - 121 files changed, 5743 deletions(-) delete mode 100644 packages/cli/src/commands/install/install.ts delete mode 100644 packages/cli/src/commands/install/uninstall.ts delete mode 100644 packages/cli/src/commands/link/__tests__/link.test.ts delete mode 100644 packages/cli/src/commands/link/__tests__/makeHook.test.ts delete mode 100644 packages/cli/src/commands/link/getPlatformName.ts delete mode 100644 packages/cli/src/commands/link/link.ts delete mode 100644 packages/cli/src/commands/link/linkAll.ts delete mode 100644 packages/cli/src/commands/link/linkAssets.ts delete mode 100644 packages/cli/src/commands/link/linkDependency.ts delete mode 100644 packages/cli/src/commands/link/makeHook.ts delete mode 100644 packages/cli/src/commands/link/pollParams.ts delete mode 100644 packages/cli/src/commands/link/printDeprecationWarning.ts delete mode 100644 packages/cli/src/commands/link/unlink.ts delete mode 100644 packages/platform-android/src/link/__fixtures__/patchedBuild.gradle delete mode 100644 packages/platform-android/src/link/__tests__/isInstalled.test.ts delete mode 100644 packages/platform-android/src/link/copyAssets.ts delete mode 100644 packages/platform-android/src/link/index.ts delete mode 100644 packages/platform-android/src/link/isInstalled.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/applyParams.test.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts delete mode 100644 packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts delete mode 100644 packages/platform-android/src/link/patches/applyParams.ts delete mode 100644 packages/platform-android/src/link/patches/applyPatch.ts delete mode 100644 packages/platform-android/src/link/patches/makeBuildPatch.ts delete mode 100644 packages/platform-android/src/link/patches/makeImportPatch.ts delete mode 100644 packages/platform-android/src/link/patches/makePackagePatch.ts delete mode 100644 packages/platform-android/src/link/patches/makeSettingsPatch.ts delete mode 100644 packages/platform-android/src/link/patches/makeStringsPatch.ts delete mode 100644 packages/platform-android/src/link/patches/normalizeProjectName.ts delete mode 100644 packages/platform-android/src/link/patches/revokePatch.ts delete mode 100644 packages/platform-android/src/link/registerNativeModule.ts delete mode 100644 packages/platform-android/src/link/unlinkAssets.ts delete mode 100644 packages/platform-android/src/link/unregisterNativeModule.ts delete mode 100644 packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts delete mode 100644 packages/platform-ios/src/link-pods/__fixtures__/Info.plist delete mode 100644 packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple delete mode 100644 packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction delete mode 100644 packages/platform-ios/src/link-pods/__fixtures__/PodfileWithInvalidKey.lock delete mode 100644 packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers delete mode 100644 packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget delete mode 100644 packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts delete mode 100644 packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts delete mode 100644 packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts delete mode 100644 packages/platform-ios/src/link-pods/__tests__/getDependenciesFromPodfileLock.test.ts delete mode 100644 packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts delete mode 100644 packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts delete mode 100644 packages/platform-ios/src/link-pods/addPodEntry.ts delete mode 100644 packages/platform-ios/src/link-pods/findLineToAddPod.ts delete mode 100644 packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts delete mode 100644 packages/platform-ios/src/link-pods/findPodTargetLine.ts delete mode 100644 packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts delete mode 100644 packages/platform-ios/src/link-pods/isInstalled.ts delete mode 100644 packages/platform-ios/src/link-pods/readPodfile.ts delete mode 100644 packages/platform-ios/src/link-pods/registerNativeModule.ts delete mode 100644 packages/platform-ios/src/link-pods/removePodEntry.ts delete mode 100644 packages/platform-ios/src/link-pods/savePodFile.ts delete mode 100644 packages/platform-ios/src/link-pods/unregisterNativeModule.ts delete mode 100644 packages/platform-ios/src/link/__fixtures__/Info.plist delete mode 100644 packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj delete mode 100644 packages/platform-ios/src/link/__fixtures__/project.pbxproj delete mode 100644 packages/platform-ios/src/link/__tests__/addFileToProject.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/createGroup.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getGroup.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getPlist.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getPlistPath.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/getTargets.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/isInstalled.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts delete mode 100644 packages/platform-ios/src/link/__tests__/writePlist.test.ts delete mode 100644 packages/platform-ios/src/link/addFileToProject.ts delete mode 100644 packages/platform-ios/src/link/addProjectToLibraries.ts delete mode 100644 packages/platform-ios/src/link/addSharedLibraries.ts delete mode 100644 packages/platform-ios/src/link/addToHeaderSearchPaths.ts delete mode 100644 packages/platform-ios/src/link/common/isInstalled.ts delete mode 100644 packages/platform-ios/src/link/common/registerNativeModule.ts delete mode 100644 packages/platform-ios/src/link/common/unregisterNativeModule.ts delete mode 100644 packages/platform-ios/src/link/copyAssets.ts delete mode 100644 packages/platform-ios/src/link/createGroup.ts delete mode 100644 packages/platform-ios/src/link/createGroupWithMessage.ts delete mode 100644 packages/platform-ios/src/link/getBuildProperty.ts delete mode 100644 packages/platform-ios/src/link/getGroup.ts delete mode 100644 packages/platform-ios/src/link/getHeaderSearchPath.ts delete mode 100644 packages/platform-ios/src/link/getHeadersInFolder.ts delete mode 100644 packages/platform-ios/src/link/getPlist.ts delete mode 100644 packages/platform-ios/src/link/getPlistPath.ts delete mode 100644 packages/platform-ios/src/link/getTargets.ts delete mode 100644 packages/platform-ios/src/link/hasLibraryImported.ts delete mode 100644 packages/platform-ios/src/link/index.ts delete mode 100644 packages/platform-ios/src/link/isInstalled.ts delete mode 100644 packages/platform-ios/src/link/mapHeaderSearchPaths.ts delete mode 100644 packages/platform-ios/src/link/registerNativeModule.ts delete mode 100644 packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts delete mode 100644 packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts delete mode 100644 packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts delete mode 100644 packages/platform-ios/src/link/removeFromProjectReferences.ts delete mode 100644 packages/platform-ios/src/link/removeFromStaticLibraries.ts delete mode 100644 packages/platform-ios/src/link/removeProductGroup.ts delete mode 100644 packages/platform-ios/src/link/removeProjectFromLibraries.ts delete mode 100644 packages/platform-ios/src/link/removeProjectFromProject.ts delete mode 100644 packages/platform-ios/src/link/removeSharedLibraries.ts delete mode 100644 packages/platform-ios/src/link/unlinkAssets.ts delete mode 100644 packages/platform-ios/src/link/unregisterNativeModule.ts delete mode 100644 packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts delete mode 100644 packages/platform-ios/src/link/warnAboutPodInstall.ts delete mode 100644 packages/platform-ios/src/link/writePlist.ts diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index c79db2ff8..3bb098237 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -3,10 +3,6 @@ import {commands as doctorCommands} from '@react-native-community/cli-doctor'; import {commands as configCommands} from '@react-native-community/cli-config'; import {commands as metroCommands} from '@react-native-community/cli-plugin-metro'; import profileHermes from '@react-native-community/cli-hermes'; -import link from './link/link'; -import unlink from './link/unlink'; -import install from './install/install'; -import uninstall from './install/uninstall'; import upgrade from './upgrade/upgrade'; import init from './init'; @@ -14,10 +10,6 @@ export const projectCommands = [ ...metroCommands, ...configCommands, doctorCommands.info, - link, - unlink, - install, - uninstall, upgrade, profileHermes, ] as Command[]; diff --git a/packages/cli/src/commands/install/install.ts b/packages/cli/src/commands/install/install.ts deleted file mode 100644 index b4a830d5d..000000000 --- a/packages/cli/src/commands/install/install.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import {logger} from '@react-native-community/cli-tools'; -import * as PackageManager from '../../tools/packageManager'; -import link from '../link/link'; -import {Config} from '@react-native-community/cli-types'; -import loadConfig from '@react-native-community/cli-config'; - -async function install(args: Array, ctx: Config): Promise { - const name = args[0]; - - logger.info(`Installing "${name}"...`); - await PackageManager.install([name], {root: ctx.root}); - - // Reload configuration to see newly installed dependency - const newConfig = loadConfig(); - - logger.info(`Linking "${name}"...`); - await link.func([name], newConfig, {platforms: undefined}); - - logger.success(`Successfully installed and linked "${name}"`); -} - -export default { - func: install, - description: 'install and link native dependencies', - name: 'install ', -}; diff --git a/packages/cli/src/commands/install/uninstall.ts b/packages/cli/src/commands/install/uninstall.ts deleted file mode 100644 index f5c46bf1b..000000000 --- a/packages/cli/src/commands/install/uninstall.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import {Config} from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; -import * as PackageManager from '../../tools/packageManager'; -import unlink from '../link/unlink'; - -async function uninstall(args: Array, ctx: Config): Promise { - const name = args[0]; - - logger.info(`Unlinking "${name}"...`); - await unlink.func([name], ctx, {}); - - logger.info(`Uninstalling "${name}"...`); - await PackageManager.uninstall([name], {root: ctx.root}); - - logger.success(`Successfully uninstalled and unlinked "${name}"`); -} - -export default { - func: uninstall, - description: 'uninstall and unlink native dependencies', - name: 'uninstall ', -}; diff --git a/packages/cli/src/commands/link/__tests__/link.test.ts b/packages/cli/src/commands/link/__tests__/link.test.ts deleted file mode 100644 index 5c9d5d604..000000000 --- a/packages/cli/src/commands/link/__tests__/link.test.ts +++ /dev/null @@ -1,262 +0,0 @@ -import {func as link} from '../link'; -import loadConfig from '@react-native-community/cli-config'; -import makeHook from '../makeHook'; - -jest.mock('chalk', () => ({ - grey: jest.fn(), - bold: jest.fn(), - dim: {underline: jest.fn()}, -})); -jest.mock('@react-native-community/cli-config'); -jest.mock('../makeHook', () => { - return jest.fn(() => { - return jest.fn(() => Promise.resolve()); - }); -}); - -const baseConfig = loadConfig(); - -const baseDependencyConfig = { - name: 'react-native-gradient', - assets: [], - hooks: {}, - params: [], - platforms: {ios: {}, android: {}}, -}; - -describe('link', () => { - beforeEach(() => { - jest.resetModules(); - }); - - it('should accept a name of a dependency to link', async () => { - const config = { - ...baseConfig, - dependencies: { - get ['react-native-gradient']() { - return baseDependencyConfig; - }, - }, - }; - - const spy = jest.spyOn(config.dependencies, 'react-native-gradient', 'get'); - - await link(['react-native-gradient'], config, {}); - - expect(spy).toHaveBeenCalled(); - }); - - it('should accept the name of a dependency with a scope / tag', async () => { - const config = { - ...baseConfig, - dependencies: { - get ['@scope/something']() { - return baseDependencyConfig; - }, - }, - }; - - const spy = jest.spyOn(config.dependencies, '@scope/something', 'get'); - - await link(['@scope/something@latest'], config, {}); - - expect(spy).toHaveBeenCalled(); - }); - - it('should register native module when android/ios projects are present', async () => { - const prelink = 'node prelink.js'; - const postlink = 'node postlink.js'; - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': { - ...baseDependencyConfig, - hooks: {prelink, postlink}, - }, - }, - }; - - await link(['react-native-blur'], config, {}); - expect(registerNativeModule.mock.calls).toHaveLength(2); - expect((makeHook as jest.Mock).mock.calls).toEqual([[prelink], [postlink]]); - }); - - it('should copy assets only from the specific dependency that we are linking', (done) => { - const dependencyAssets = ['Fonts/Font.ttf']; - const projectAssets = ['Fonts/FontC.ttf']; - - const copyAssets = jest.fn(); - const dependency = { - ...baseDependencyConfig, - assets: dependencyAssets, - }; - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: jest.fn(), - copyAssets, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - android: { - linkConfig: () => ({ - register: jest.fn(), - copyAssets, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': dependency, - }, - assets: projectAssets, - }; - - link(['react-native-blur'], config, {}).then(() => { - expect(copyAssets.mock.calls).toHaveLength(2); - expect(copyAssets.mock.calls[0][0]).toEqual(dependencyAssets); - done(); - }); - }); - - it('should not register modules when they are already installed', (done) => { - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - }, - dependencies: { - 'react-native-blur': baseDependencyConfig, - }, - }; - - link(['react-native-blur'], config, {}).then(() => { - expect(registerNativeModule.mock.calls).toHaveLength(0); - done(); - }); - }); - - it('should register native modules for additional platforms', (done) => { - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - windows: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(true), - }), - }, - windows: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': { - ...baseDependencyConfig, - platforms: { - ...baseDependencyConfig.platforms, - windows: {}, - }, - }, - }, - }; - - link(['react-native-blur'], config, {}).then(() => { - expect(registerNativeModule.mock.calls).toHaveLength(1); - done(); - }); - }); - - it('should link only for specific platforms if --platforms is used', async () => { - const registerNativeModule = jest.fn(); - - const config = { - ...baseConfig, - project: { - ios: {}, - android: {}, - }, - platforms: { - ios: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - android: { - linkConfig: () => ({ - register: registerNativeModule, - isInstalled: jest.fn().mockReturnValue(false), - }), - }, - }, - dependencies: { - 'react-native-blur': baseDependencyConfig, - }, - }; - - await link(['react-native-blur'], config, {platforms: ['android']}); - - expect(registerNativeModule.mock.calls).toHaveLength(1); - }); -}); diff --git a/packages/cli/src/commands/link/__tests__/makeHook.test.ts b/packages/cli/src/commands/link/__tests__/makeHook.test.ts deleted file mode 100644 index 70982f359..000000000 --- a/packages/cli/src/commands/link/__tests__/makeHook.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import makeHook from '../makeHook'; - -afterAll(() => { - jest.restoreAllMocks(); -}); - -describe('makeHook', () => { - it('invokes the command', async () => { - const hook = makeHook('echo'); - const result = await hook(); - expect(result.cmd).toBe('echo'); - }); - - it('invokes the command with multiple arguments', async () => { - const hook = makeHook('node -p "1;"'); - const result = await hook(); - expect(result.cmd).toBe('node -p "1;"'); - }); -}); diff --git a/packages/cli/src/commands/link/getPlatformName.ts b/packages/cli/src/commands/link/getPlatformName.ts deleted file mode 100644 index f926cec61..000000000 --- a/packages/cli/src/commands/link/getPlatformName.ts +++ /dev/null @@ -1,8 +0,0 @@ -const names: {[key: string]: string} = { - ios: 'iOS', - android: 'Android', -}; - -export default function getPlatformName(name: string): string { - return names[name] || name; -} diff --git a/packages/cli/src/commands/link/link.ts b/packages/cli/src/commands/link/link.ts deleted file mode 100644 index e9d43be74..000000000 --- a/packages/cli/src/commands/link/link.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import chalk from 'chalk'; -import {pick} from 'lodash'; -import {logger, CLIError} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import getPlatformName from './getPlatformName'; -import linkDependency from './linkDependency'; -import linkAssets from './linkAssets'; -import linkAll from './linkAll'; -import makeHook from './makeHook'; -import printDeprecationWarning from './printDeprecationWarning'; - -type FlagsType = { - platforms?: Array; - all?: boolean; -}; - -/** - * Updates project and links all dependencies to it. - * - * @param args If optional argument [packageName] is provided, - * only that package is processed. - */ -async function link( - [rawPackageName]: Array, - ctx: Config, - opts: FlagsType, -) { - let platforms = ctx.platforms; - let project = ctx.project; - - if (opts.platforms) { - // @ts-ignore - platforms = pick(platforms, opts.platforms); - logger.debug('Skipping selected platforms'); - } - - logger.debug( - 'Available platforms: ' + - `${Object.keys(platforms).map(getPlatformName).join(', ')}`, - ); - - if (rawPackageName === undefined) { - logger.debug('No package name provided, will link all possible assets.'); - return linkAll(ctx, {linkDeps: opts.all, linkAssets: true}); - } - - printDeprecationWarning('react-native link [packageName]'); - - // Trim the version / tag out of the package name (eg. package@latest) - const packageName = rawPackageName.replace(/^(.+?)(@.+?)$/gi, '$1'); - - if (!Object.keys(ctx.dependencies).includes(packageName)) { - throw new CLIError(` - Unknown dependency. Make sure that the package you are trying to link is - already installed in your "node_modules" and present in your "package.json" dependencies. - `); - } - - const {[packageName]: dependency} = ctx.dependencies; - - logger.debug(`Package to link: ${rawPackageName}`); - - try { - if (dependency.hooks.prelink) { - await makeHook(dependency.hooks.prelink)(); - } - await linkDependency(platforms, project, dependency); - if (dependency.hooks.postlink) { - await makeHook(dependency.hooks.postlink)(); - } - await linkAssets(platforms, project, dependency.assets); - } catch (error) { - throw new CLIError( - `Linking "${chalk.bold(dependency.name)}" failed.`, - error, - ); - } -} - -export const func = link; - -export default { - func: link, - description: 'links assets and optionally native modules', - name: 'link [packageName]', - options: [ - { - name: '--platforms [list]', - description: 'Scope linking to specified platforms', - parse: (val: string) => val.toLowerCase().split(','), - }, - { - name: '--all', - description: 'Link all native modules and assets', - }, - ], -}; diff --git a/packages/cli/src/commands/link/linkAll.ts b/packages/cli/src/commands/link/linkAll.ts deleted file mode 100644 index 5eb3fc57b..000000000 --- a/packages/cli/src/commands/link/linkAll.ts +++ /dev/null @@ -1,59 +0,0 @@ -import {uniqBy} from 'lodash'; -import * as path from 'path'; -import chalk from 'chalk'; -import {CLIError, logger} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import linkAssets from './linkAssets'; -import linkDependency from './linkDependency'; -import makeHook from './makeHook'; -import printDeprecationWarning from './printDeprecationWarning'; - -const dedupeAssets = (assets: Array): Array => - uniqBy(assets, (asset) => path.basename(asset)); - -type Options = { - linkDeps?: boolean; - linkAssets?: boolean; -}; - -async function linkAll(config: Config, options: Options) { - if (options.linkDeps) { - printDeprecationWarning('react-native link --all'); - logger.debug('Linking all dependencies'); - - for (let key in config.dependencies) { - const dependency = config.dependencies[key]; - try { - if (dependency.hooks.prelink) { - await makeHook(dependency.hooks.prelink)(); - } - await linkDependency(config.platforms, config.project, dependency); - if (dependency.hooks.postlink) { - await makeHook(dependency.hooks.postlink)(); - } - } catch (error) { - throw new CLIError( - `Linking "${chalk.bold(dependency.name)}" failed.`, - error, - ); - } - } - } - if (options.linkAssets) { - logger.debug('Linking all assets'); - const projectAssets = config.assets; - const assets = dedupeAssets( - Object.keys(config.dependencies).reduce( - (acc, dependency) => acc.concat(config.dependencies[dependency].assets), - projectAssets, - ), - ); - try { - linkAssets(config.platforms, config.project, assets); - } catch (error) { - throw new CLIError('Linking assets failed.', error); - } - } -} - -export default linkAll; diff --git a/packages/cli/src/commands/link/linkAssets.ts b/packages/cli/src/commands/link/linkAssets.ts deleted file mode 100644 index 927035017..000000000 --- a/packages/cli/src/commands/link/linkAssets.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {isEmpty} from 'lodash'; -import {Config} from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; - -export default function linkAssets( - platforms: Config['platforms'], - project: Config['project'], - assets: Array, -) { - if (isEmpty(assets)) { - return; - } - - Object.keys(platforms || {}).forEach((platform) => { - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - - if (!linkConfig || !linkConfig.copyAssets || !project[platform]) { - return; - } - - logger.info(`Linking assets to ${platform} project`); - - linkConfig.copyAssets(assets, project[platform]); - }); - - logger.success('Assets have been successfully linked to your project'); -} diff --git a/packages/cli/src/commands/link/linkDependency.ts b/packages/cli/src/commands/link/linkDependency.ts deleted file mode 100644 index 906980d5c..000000000 --- a/packages/cli/src/commands/link/linkDependency.ts +++ /dev/null @@ -1,67 +0,0 @@ -import chalk from 'chalk'; -import { - Config, - Dependency, - AndroidDependencyConfig, - AndroidProjectConfig, - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; -import pollParams from './pollParams'; -import getPlatformName from './getPlatformName'; - -export default async function linkDependency( - platforms: Config['platforms'], - project: Config['project'], - dependency: Dependency, -) { - const params = await pollParams(dependency.params); - - Object.keys(platforms || {}).forEach((platform) => { - const projectConfig: AndroidProjectConfig | IOSProjectConfig = - project[platform]; - const dependencyConfig: AndroidDependencyConfig | IOSDependencyConfig = - dependency.platforms[platform]; - - if (!projectConfig || !dependencyConfig) { - return; - } - const {name} = dependency; - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - - if (!linkConfig || !linkConfig.isInstalled || !linkConfig.register) { - return; - } - - const isInstalled = linkConfig.isInstalled( - projectConfig, - name, - dependencyConfig, - ); - - if (isInstalled) { - logger.info( - `${getPlatformName(platform)} module "${chalk.bold( - name, - )}" is already linked`, - ); - return; - } - - logger.info( - `Linking "${chalk.bold(name)}" ${getPlatformName(platform)} dependency`, - ); - - linkConfig.register(name, dependencyConfig, params, projectConfig); - - logger.info( - `${getPlatformName(platform)} module "${chalk.bold( - dependency.name, - )}" has been successfully linked`, - ); - }); -} diff --git a/packages/cli/src/commands/link/makeHook.ts b/packages/cli/src/commands/link/makeHook.ts deleted file mode 100644 index 1cb435965..000000000 --- a/packages/cli/src/commands/link/makeHook.ts +++ /dev/null @@ -1,10 +0,0 @@ -import execa from 'execa'; - -export default function makeHook(command: string) { - return () => { - const args = command.split(' '); - const cmd = args.shift() as string; - - return execa(cmd, args, {stdio: 'inherit'}); - }; -} diff --git a/packages/cli/src/commands/link/pollParams.ts b/packages/cli/src/commands/link/pollParams.ts deleted file mode 100644 index 36c9f86fe..000000000 --- a/packages/cli/src/commands/link/pollParams.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import prompts from 'prompts'; - -export default (questions: any[]) => - new Promise((resolve, reject) => { - if (!questions) { - resolve({}); - return; - } - - prompts(questions).then(resolve, reject); - }); diff --git a/packages/cli/src/commands/link/printDeprecationWarning.ts b/packages/cli/src/commands/link/printDeprecationWarning.ts deleted file mode 100644 index 74e980d2a..000000000 --- a/packages/cli/src/commands/link/printDeprecationWarning.ts +++ /dev/null @@ -1,12 +0,0 @@ -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; - -export default function printDeprecationWarning(command: string) { - logger.warn( - `Calling ${chalk.bold( - command, - )} is deprecated in favor of autolinking. It will be removed in the next major release.\nAutolinking documentation: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); -} diff --git a/packages/cli/src/commands/link/unlink.ts b/packages/cli/src/commands/link/unlink.ts deleted file mode 100644 index bc57816ea..000000000 --- a/packages/cli/src/commands/link/unlink.ts +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import {flatMap, values, difference, pick} from 'lodash'; -import {logger, CLIError} from '@react-native-community/cli-tools'; -import { - Config, - Dependency, - AndroidDependencyConfig, - AndroidProjectConfig, - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import getPlatformName from './getPlatformName'; -import makeHook from './makeHook'; -import printDeprecationWarning from './printDeprecationWarning'; - -type Flags = { - platforms?: Array; -}; - -const unlinkDependency = ( - platforms: Config['platforms'], - project: Config['project'], - dependency: Dependency, - packageName: string, - otherDependencies: Array, -) => { - printDeprecationWarning('react-native unlink [packageName]'); - Object.keys(platforms || {}).forEach((platform) => { - const projectConfig: AndroidProjectConfig | IOSProjectConfig = - project[platform]; - const dependencyConfig: AndroidDependencyConfig | IOSDependencyConfig = - dependency.platforms[platform]; - if (!projectConfig || !dependencyConfig) { - return; - } - - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - - if (!linkConfig || !linkConfig.isInstalled || !linkConfig.unregister) { - return; - } - - const isInstalled = linkConfig.isInstalled( - projectConfig, - packageName, - dependencyConfig, - ); - - if (!isInstalled) { - logger.info( - `${getPlatformName(platform)} module "${packageName}" is not installed`, - ); - return; - } - - logger.info( - `Unlinking "${packageName}" ${getPlatformName(platform)} dependency`, - ); - - linkConfig.unregister( - packageName, - dependencyConfig, - projectConfig, - otherDependencies, - ); - - logger.info( - `${getPlatformName(platform)} module "${ - dependency.name - }" has been successfully unlinked`, - ); - }); -}; - -/** - * Updates project and unlink specific dependency - * - * If optional argument [packageName] is provided, it's the only one - * that's checked - */ -async function unlink(args: Array, ctx: Config, opts: Flags) { - const packageName = args[0]; - let platforms = ctx.platforms; - - if (opts.platforms) { - // @ts-ignore - platforms = pick(platforms, opts.platforms); - logger.debug('Skipping selected platforms'); - } - - logger.debug( - `Available platforms: ${Object.keys(platforms) - .map(getPlatformName) - .join(', ')}`, - ); - - const {[packageName]: dependency, ...otherDependencies} = ctx.dependencies; - - if (!dependency) { - throw new CLIError(` - Failed to unlink "${packageName}". It appears that the project is not linked yet. - `); - } - - const dependencies = values(otherDependencies); - try { - if (dependency.hooks.preunlink) { - await makeHook(dependency.hooks.preunlink)(); - } - unlinkDependency( - platforms, - ctx.project, - dependency, - packageName, - dependencies, - ); - if (dependency.hooks.postunlink) { - await makeHook(dependency.hooks.postunlink)(); - } - } catch (error) { - throw new CLIError( - `Something went wrong while unlinking. Reason ${error.message}`, - error, - ); - } - - // @todo move all these to above try/catch - // @todo it is possible we could be unlinking some project assets in case of duplicate - const assets = difference( - dependency.assets, - flatMap(dependencies, (d) => d.assets), - ); - - if (assets.length === 0) { - return; - } - - Object.keys(platforms || {}).forEach((platform) => { - const projectConfig = ctx.project[platform]; - const linkConfig = - platforms[platform] && - platforms[platform].linkConfig && - platforms[platform].linkConfig(); - if (!linkConfig || !linkConfig.unlinkAssets || !projectConfig) { - return; - } - - logger.info(`Unlinking assets from ${platform} project`); - - linkConfig.unlinkAssets(assets, projectConfig); - }); - - logger.info( - `${packageName} assets has been successfully unlinked from your project`, - ); -} - -export default { - func: unlink, - description: 'unlink native dependency', - name: 'unlink ', - options: [ - { - name: '--platforms [list]', - description: 'Scope unlinking to specified platforms', - parse: (val: string) => val.toLowerCase().split(','), - }, - ], -}; diff --git a/packages/platform-android/src/index.ts b/packages/platform-android/src/index.ts index d03bb9749..e5cebbd00 100644 --- a/packages/platform-android/src/index.ts +++ b/packages/platform-android/src/index.ts @@ -2,7 +2,6 @@ * Android platform files */ -export {default as linkConfig} from './link'; export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; export {getAndroidProject, getPackageName} from './utils/getAndroidProject'; diff --git a/packages/platform-android/src/link/__fixtures__/patchedBuild.gradle b/packages/platform-android/src/link/__fixtures__/patchedBuild.gradle deleted file mode 100644 index fe66858c6..000000000 --- a/packages/platform-android/src/link/__fixtures__/patchedBuild.gradle +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -dependencies { - implementation project(':test-impl') - implementation(project(':test-impl-config')) { - exclude(group: 'org.unwanted', module: 'test10') - } - implementation (project(':test-impl-config-spaces')) { - exclude group: 'com.google.android.gms' - } -// Indentation being off for some entries is a part of the test, because -// Gradle doesn't care about indentation and neither should we -implementationDebug project(':test-impl-debug') -implementationAbc project(':test-impl-abc') - compile project(':test-compile') - compileDebug project(':test-compile-debug') - compileAbc project(':test-compile-abc') - - api project(':test-api') - apiDebug project(':test-api-debug') - apiAbc project(':test-api-abc') - - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.android.support:appcompat-v7:27.1.1" - implementation "com.facebook.react:react-native:+" -} diff --git a/packages/platform-android/src/link/__tests__/isInstalled.test.ts b/packages/platform-android/src/link/__tests__/isInstalled.test.ts deleted file mode 100644 index c783f969e..000000000 --- a/packages/platform-android/src/link/__tests__/isInstalled.test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from '../isInstalled'; - -const path = require('path'); - -const projectConfig = { - buildGradlePath: path.join(__dirname, '../__fixtures__/patchedBuild.gradle'), -}; - -describe('android::isInstalled', () => { - test.each([ - ['test-impl', true], - ['test-impl-config', true], - ['test-impl-config-spaces', true], - ['test-impl-debug', true], - ['test-impl-abc', true], - ['test-compile', true], - ['test-compile-debug', true], - ['test-compile-abc', true], - ['test-api', true], - ['test-api-debug', true], - ['test-api-abc', true], - ['test-not-there-yet', false], - ])( - 'properly detects if %p project is already in build.gradle', - (project: string, isPresent: boolean) => { - expect(isInstalled(projectConfig, project)).toBe(isPresent); - }, - ); -}); diff --git a/packages/platform-android/src/link/copyAssets.ts b/packages/platform-android/src/link/copyAssets.ts deleted file mode 100644 index 91cda1bdf..000000000 --- a/packages/platform-android/src/link/copyAssets.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs-extra'; -import path from 'path'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; - -/** - * Copies each file from an array of assets provided to targetPath directory - * - * For now, the only types of files that are handled are: - * - Fonts (otf, ttf) - copied to targetPath/fonts under original name - */ -export default function copyAssetsAndroid( - files: Array, - project: {assetsPath: string}, -) { - const assets = groupFilesByType(files); - - logger.debug(`Assets path: ${project.assetsPath}`); - (assets.font || []).forEach((asset) => { - const fontsDir = path.join(project.assetsPath, 'fonts'); - logger.debug(`Copying asset ${asset}`); - // @todo: replace with fs.mkdirSync(path, {recursive}) + fs.copyFileSync - // and get rid of fs-extra once we move to Node 10 - fs.copySync(asset, path.join(fontsDir, path.basename(asset))); - }); -} diff --git a/packages/platform-android/src/link/index.ts b/packages/platform-android/src/link/index.ts deleted file mode 100644 index f7a5f21f2..000000000 --- a/packages/platform-android/src/link/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from './isInstalled'; -import register from './registerNativeModule'; -import unregister from './unregisterNativeModule'; -import copyAssets from './copyAssets'; -import unlinkAssets from './unlinkAssets'; - -export function getAndroidLinkConfig() { - return {isInstalled, register, unregister, copyAssets, unlinkAssets}; -} - -export default getAndroidLinkConfig; diff --git a/packages/platform-android/src/link/isInstalled.ts b/packages/platform-android/src/link/isInstalled.ts deleted file mode 100644 index de53851e1..000000000 --- a/packages/platform-android/src/link/isInstalled.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import makeBuildPatch from './patches/makeBuildPatch'; - -export default function isInstalled( - config: {buildGradlePath: string}, - name: string, -) { - const buildGradle = fs.readFileSync(config.buildGradlePath, 'utf8'); - return makeBuildPatch(name).installPattern.test(buildGradle); -} diff --git a/packages/platform-android/src/link/patches/__tests__/applyParams.test.ts b/packages/platform-android/src/link/patches/__tests__/applyParams.test.ts deleted file mode 100644 index 35a26f8cc..000000000 --- a/packages/platform-android/src/link/patches/__tests__/applyParams.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import applyParams from '../applyParams'; - -describe('applyParams', () => { - it('apply params to the string', () => { - expect(applyParams('${foo}', {foo: 'foo'} as any, 'react-native')).toEqual( - 'getResources().getString(R.string.reactNative_foo)', - ); - }); - - it('use null if no params provided', () => { - expect(applyParams('${foo}', {}, 'react-native')).toEqual('null'); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts deleted file mode 100644 index 10e952d02..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeBuildPatch.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeBuildPatch from '../makeBuildPatch'; -import normalizeProjectName from '../normalizeProjectName'; -import path from 'path'; - -const name = 'test'; -const scopedName = '@scoped/test'; -const normalizedScopedName = normalizeProjectName('@scoped/test'); -const buildGradlePath = path.join( - __dirname, - '../../__fixtures__/patchedBuild.gradle', -); - -describe('makeBuildPatch', () => { - it('should build a patch function', () => { - // @ts-ignore - expect(Object.prototype.toString(makeBuildPatch(name))).toBe( - '[object Object]', - ); - }); - - it('should make a correct patch', () => { - const {patch} = makeBuildPatch(name); - expect(patch).toBe(` implementation project(':${name}')\n`); - }); - - it('should make a correct install check pattern', () => { - const {installPattern} = makeBuildPatch(name); - expect(installPattern.toString()).toEqual(expect.stringContaining(name)); - }); - - test.each([ - ['test-impl', " implementation project(':test-impl')\n"], - ['test-compile', " compile project(':test-compile')\n"], - ['test-api', " api project(':test-api')\n"], - [ - 'test-not-there-yet', - " implementation project(':test-not-there-yet')\n", - ], - ])( - 'properly detects the patch string of project %p in build.gradle', - (project, projectPatchString) => { - expect(makeBuildPatch(project, buildGradlePath).patch).toBe( - projectPatchString, - ); - }, - ); -}); - -describe('makeBuildPatchWithScopedPackage', () => { - it('should make a correct patch', () => { - const {patch} = makeBuildPatch(scopedName); - expect(patch).toBe( - ` implementation project(':${normalizedScopedName}')\n`, - ); - }); - - it('should make a correct install check pattern', () => { - const {installPattern} = makeBuildPatch(scopedName); - expect(installPattern.toString()).toEqual( - expect.stringContaining(normalizedScopedName), - ); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts deleted file mode 100644 index 26f6e6f06..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeImportPatch.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeImportPatch from '../makeImportPatch'; - -const packageImportPath = 'import some.example.project'; - -describe('makeImportPatch', () => { - it('should build a patch', () => { - // @ts-ignore - expect(Object.prototype.toString(makeImportPatch(packageImportPath))).toBe( - '[object Object]', - ); - }); - - it('MainActivity contains a correct import patch', () => { - const {patch} = makeImportPatch(packageImportPath); - - expect(patch).toBe(`\n${packageImportPath}`); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts deleted file mode 100644 index d31c35153..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makePackagePatch.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import makePackagePatch from '../makePackagePatch'; -import applyParams from '../applyParams'; - -const packageInstance = "new SomeLibrary(${foo}, ${bar}, 'something')"; -const name = 'some-library'; -const params: any = { - foo: 'foo', - bar: 'bar', -}; - -describe('makePackagePatch@0.20', () => { - it('should build a patch', () => { - const packagePatch = makePackagePatch(packageInstance, params, name); - // @ts-ignore - expect(Object.prototype.toString(packagePatch)).toBe('[object Object]'); - }); - - it('MainActivity contains a correct 0.20 import patch', () => { - const {patch} = makePackagePatch(packageInstance, params, name); - const processedInstance = applyParams(packageInstance, params, name); - - expect(patch).toBe(`,\n ${processedInstance}`); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts deleted file mode 100644 index 4b80cf7ae..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeSettingsPatch.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeSettingsPatch from '../makeSettingsPatch'; - -const projectConfig = { - sourceDir: '/home/project/android/app', - settingsGradlePath: '/home/project/android/settings.gradle', -}; - -describe('makeSettingsPatch with package "test"', () => { - const name = 'test'; - const dependencyConfig = { - sourceDir: `/home/project/node_modules/${name}/android`, - }; - - it('should build a patch function', () => { - expect( - makeSettingsPatch(name, dependencyConfig, projectConfig), - ).toMatchObject({ - pattern: '\n', - patch: expect.any(String), - }); - }); - - it('includes project with correct path', () => { - const {patch} = makeSettingsPatch(name, dependencyConfig, projectConfig); - - expect(patch).toMatchInlineSnapshot(` -"include ':test' -project(':test').projectDir = new File(rootProject.projectDir, '../node_modules/test/android') -" -`); - }); - - // Simulate Windows environment on POSIX filesystem - // TODO: scope this test to Windows-only once we setup CI on Windows - // as changing path to be windows-specific breaks global path mock - // eslint-disable-next-line jest/no-disabled-tests - it.skip('includes project with correct path on Windows', () => { - jest.resetModules(); - jest.doMock('path', () => { - const path = jest.requireActual('path'); - path.dirname = path.win32.dirname; - path.relative = path.win32.relative; - return path; - }); - // eslint-disable-next-line no-shadow - const makeSettingsPatch = require('../makeSettingsPatch').default; - const projectConfigWindows = { - sourceDir: 'C:\\home\\project\\android\\app', - settingsGradlePath: 'C:\\home\\project\\android\\settings.gradle', - }; - const dependencyConfigWindows = { - sourceDir: `C:\\home\\project\\node_modules\\${name}\\android`, - }; - const {patch} = makeSettingsPatch( - name, - dependencyConfigWindows, - projectConfigWindows, - ); - - jest.dontMock('path'); - - expect(patch).toMatchInlineSnapshot(` -"include ':test' -project(':test').projectDir = new File(rootProject.projectDir, '../node_modules/test/android') -" -`); - }); -}); - -describe('makeSettingsPatch with scoped package "@scoped/test"', () => { - const name = '@scoped/test'; - const dependencyConfig = { - sourceDir: `/home/project/node_modules/${name}/android`, - }; - - it('should build a patch function', () => { - expect( - makeSettingsPatch(name, dependencyConfig, projectConfig), - ).toMatchObject({ - pattern: '\n', - patch: expect.any(String), - }); - }); - - it('includes project with correct path', () => { - const {patch} = makeSettingsPatch(name, dependencyConfig, projectConfig); - - expect(patch).toMatchInlineSnapshot(` -"include ':@scoped_test' -project(':@scoped_test').projectDir = new File(rootProject.projectDir, '../node_modules/@scoped/test/android') -" -`); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts b/packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts deleted file mode 100644 index bf5b21652..000000000 --- a/packages/platform-android/src/link/patches/__tests__/makeStringsPatch.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import makeStringsPatch from '../makeStringsPatch'; - -describe('makeStringsPatch', () => { - it('should export a patch with element', () => { - const params: any = { - keyA: 'valueA', - }; - - expect(makeStringsPatch(params, 'module').patch).toContain( - 'valueA', - ); - }); - - it('should export an empty patch if no params given', () => { - expect(makeStringsPatch({}, 'module').patch).toBe(''); - }); -}); diff --git a/packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts b/packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts deleted file mode 100644 index 16d149192..000000000 --- a/packages/platform-android/src/link/patches/__tests__/normalizeProjectName.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import normalizeProjectName from '../normalizeProjectName'; - -const name = 'test'; -const scopedName = '@scoped/test'; - -describe('normalizeProjectName', () => { - it('should replace slashes with underscores', () => { - expect(normalizeProjectName(name)).toBe('test'); - expect(normalizeProjectName(scopedName)).toBe('@scoped_test'); - }); -}); diff --git a/packages/platform-android/src/link/patches/applyParams.ts b/packages/platform-android/src/link/patches/applyParams.ts deleted file mode 100644 index aea97fe3c..000000000 --- a/packages/platform-android/src/link/patches/applyParams.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {camelCase as toCamelCase} from 'lodash'; -import {AndroidProjectParams} from '@react-native-community/cli-types'; - -export default function applyParams( - str: string, - params: AndroidProjectParams, - prefix: string, -) { - return str.replace(/\$\{(\w+)\}/g, (_pattern: string, param: string) => { - const name = `${toCamelCase(prefix)}_${param}`; - - // @ts-ignore - return params[param] - ? `getResources().getString(R.string.${name})` - : 'null'; - }); -} diff --git a/packages/platform-android/src/link/patches/applyPatch.ts b/packages/platform-android/src/link/patches/applyPatch.ts deleted file mode 100644 index 3a4d60876..000000000 --- a/packages/platform-android/src/link/patches/applyPatch.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function applyPatch( - file: string, - patch: {patch: string; pattern: string | RegExp}, -) { - if (file) { - logger.debug(`Patching ${file}`); - } - - fs.writeFileSync( - file, - fs - .readFileSync(file, 'utf8') - .replace(patch.pattern, (match) => `${match}${patch.patch}`), - ); -} diff --git a/packages/platform-android/src/link/patches/makeBuildPatch.ts b/packages/platform-android/src/link/patches/makeBuildPatch.ts deleted file mode 100644 index 74d8392be..000000000 --- a/packages/platform-android/src/link/patches/makeBuildPatch.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import normalizeProjectName from './normalizeProjectName'; - -const depConfigs = ['compile', 'api', 'implementation']; - -export default function makeBuildPatch(name: string, buildGradlePath?: string) { - const normalizedProjectName = normalizeProjectName(name); - const installPattern = new RegExp( - buildDepRegExp(normalizedProjectName, ...depConfigs), - ); - - return { - installPattern, - pattern: /[^ \t]dependencies {(\r\n|\n)/, - patch: makePatchString(normalizedProjectName, buildGradlePath), - }; -} - -function makePatchString( - normalizedProjectName: string, - buildGradlePath?: string, -) { - const defaultPatchString = ` implementation project(':${normalizedProjectName}')\n`; - if (!buildGradlePath) { - return defaultPatchString; - } - - const buildGradle = fs.readFileSync(buildGradlePath, 'utf8'); - - for (const config of depConfigs) { - const depPattern = new RegExp( - buildDepRegExp(normalizedProjectName, config), - ); - if (depPattern.test(buildGradle)) { - return ` ${config} project(':${normalizedProjectName}')\n`; - } - } - - return defaultPatchString; -} - -function buildDepRegExp( - normalizedProjectName: string, - ...configs: Array -) { - const orConfigs = configs.join('|'); - return `(${orConfigs})\\w*\\s*\\(*project\\s*\\(['"]:${normalizedProjectName}['"]\\)`; -} diff --git a/packages/platform-android/src/link/patches/makeImportPatch.ts b/packages/platform-android/src/link/patches/makeImportPatch.ts deleted file mode 100644 index a90d6a47b..000000000 --- a/packages/platform-android/src/link/patches/makeImportPatch.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function makeImportPatch(packageImportPath: string) { - return { - pattern: 'import com.facebook.react.ReactApplication;', - patch: `\n${packageImportPath}`, - }; -} diff --git a/packages/platform-android/src/link/patches/makePackagePatch.ts b/packages/platform-android/src/link/patches/makePackagePatch.ts deleted file mode 100644 index 3e983cab3..000000000 --- a/packages/platform-android/src/link/patches/makePackagePatch.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import applyParams from './applyParams'; -import {AndroidProjectParams} from '@react-native-community/cli-types'; - -export default function makePackagePatch( - packageInstance: string, - params: AndroidProjectParams, - prefix: string, -) { - const processedInstance = applyParams(packageInstance, params, prefix); - - return { - pattern: 'new MainReactPackage()', - patch: `,\n ${processedInstance}`, - }; -} diff --git a/packages/platform-android/src/link/patches/makeSettingsPatch.ts b/packages/platform-android/src/link/patches/makeSettingsPatch.ts deleted file mode 100644 index 6bd81ab4b..000000000 --- a/packages/platform-android/src/link/patches/makeSettingsPatch.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import path from 'path'; -import slash from 'slash'; -import normalizeProjectName from './normalizeProjectName'; - -export default function makeSettingsPatch( - name: string, - androidConfig: {sourceDir: string}, - projectConfig: {settingsGradlePath: string}, -) { - // Gradle expects paths to be posix even on Windows - const projectDir = slash( - path.relative( - path.dirname(projectConfig.settingsGradlePath), - androidConfig.sourceDir, - ), - ); - const normalizedProjectName = normalizeProjectName(name); - - return { - pattern: '\n', - patch: - `include ':${normalizedProjectName}'\n` + - `project(':${normalizedProjectName}').projectDir = ` + - `new File(rootProject.projectDir, '${projectDir}')\n`, - }; -} diff --git a/packages/platform-android/src/link/patches/makeStringsPatch.ts b/packages/platform-android/src/link/patches/makeStringsPatch.ts deleted file mode 100644 index b84488f50..000000000 --- a/packages/platform-android/src/link/patches/makeStringsPatch.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {camelCase as toCamelCase} from 'lodash'; -import {AndroidProjectParams} from '@react-native-community/cli-types'; - -export default function makeStringsPatch( - params: AndroidProjectParams, - prefix: string, -) { - const values = Object.keys(params).map((param) => { - const name = `${toCamelCase(prefix)}_${param}`; - return ( - ' ' + - // @ts-ignore - `${params[param]}` - ); - }); - - const patch = values.length > 0 ? `${values.join('\n')}\n` : ''; - - return { - pattern: '\n', - patch, - }; -} diff --git a/packages/platform-android/src/link/patches/normalizeProjectName.ts b/packages/platform-android/src/link/patches/normalizeProjectName.ts deleted file mode 100644 index e905cc371..000000000 --- a/packages/platform-android/src/link/patches/normalizeProjectName.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function normalizeProjectName(name: string) { - return name.replace(/\//g, '_'); -} diff --git a/packages/platform-android/src/link/patches/revokePatch.ts b/packages/platform-android/src/link/patches/revokePatch.ts deleted file mode 100644 index 474a6287b..000000000 --- a/packages/platform-android/src/link/patches/revokePatch.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function revokePatch(file: string, patch: {patch: string}) { - if (file) { - logger.debug(`Patching ${file}`); - } - - fs.writeFileSync( - file, - fs.readFileSync(file, 'utf8').replace(patch.patch, ''), - ); -} diff --git a/packages/platform-android/src/link/registerNativeModule.ts b/packages/platform-android/src/link/registerNativeModule.ts deleted file mode 100644 index e02a03583..000000000 --- a/packages/platform-android/src/link/registerNativeModule.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import applyPatch from './patches/applyPatch'; -import makeStringsPatch from './patches/makeStringsPatch'; -import makeSettingsPatch from './patches/makeSettingsPatch'; -import makeBuildPatch from './patches/makeBuildPatch'; -import makeImportPatch from './patches/makeImportPatch'; -import makePackagePatch from './patches/makePackagePatch'; -import { - AndroidProjectConfig, - AndroidDependencyConfig, - AndroidProjectParams, -} from '@react-native-community/cli-types'; - -export default function registerNativeAndroidModule( - name: string, - androidConfig: AndroidDependencyConfig, - params: AndroidProjectParams, - projectConfig: AndroidProjectConfig, -) { - const buildPatch = makeBuildPatch(name); - - applyPatch( - projectConfig.settingsGradlePath, - makeSettingsPatch(name, androidConfig, projectConfig), - ); - - applyPatch(projectConfig.buildGradlePath, buildPatch); - applyPatch(projectConfig.stringsPath, makeStringsPatch(params, name)); - - applyPatch( - projectConfig.mainFilePath, - makePackagePatch(androidConfig.packageInstance, params, name), - ); - - applyPatch( - projectConfig.mainFilePath, - makeImportPatch(androidConfig.packageImportPath), - ); -} diff --git a/packages/platform-android/src/link/unlinkAssets.ts b/packages/platform-android/src/link/unlinkAssets.ts deleted file mode 100644 index 3d387dead..000000000 --- a/packages/platform-android/src/link/unlinkAssets.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; - -/** - * Copies each file from an array of assets provided to targetPath directory - * - * For now, the only types of files that are handled are: - * - Fonts (otf, ttf) - copied to targetPath/fonts under original name - */ -export default function unlinkAssetsAndroid( - files: Array, - project: {assetsPath: string}, -) { - const assets = groupFilesByType(files); - - logger.debug(`Assets path: ${project.assetsPath}`); - (assets.font || []).forEach((file) => { - const filePath = path.join( - project.assetsPath, - 'fonts', - path.basename(file), - ); - if (fs.existsSync(filePath)) { - logger.debug(`Removing asset ${filePath}`); - fs.unlinkSync(filePath); - } - }); -} diff --git a/packages/platform-android/src/link/unregisterNativeModule.ts b/packages/platform-android/src/link/unregisterNativeModule.ts deleted file mode 100644 index 457e28aeb..000000000 --- a/packages/platform-android/src/link/unregisterNativeModule.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {camelCase as toCamelCase} from 'lodash'; - -import revokePatch from './patches/revokePatch'; -import makeSettingsPatch from './patches/makeSettingsPatch'; -import makeBuildPatch from './patches/makeBuildPatch'; -import makeStringsPatch from './patches/makeStringsPatch'; -import makeImportPatch from './patches/makeImportPatch'; -import makePackagePatch from './patches/makePackagePatch'; -import { - AndroidProjectConfig, - AndroidDependencyConfig, -} from '@react-native-community/cli-types'; - -export default function unregisterNativeAndroidModule( - name: string, - androidConfig: AndroidDependencyConfig, - projectConfig: AndroidProjectConfig, -) { - const buildPatch = makeBuildPatch(name, projectConfig.buildGradlePath); - const strings = fs.readFileSync(projectConfig.stringsPath, 'utf8'); - const params = {}; - - strings.replace( - /moduleConfig="true" name="(\w+)">(.*) { - // @ts-ignore - params[param.slice(toCamelCase(name).length + 1)] = value; - }, - ); - - revokePatch( - projectConfig.settingsGradlePath, - makeSettingsPatch(name, androidConfig, projectConfig), - ); - - revokePatch(projectConfig.buildGradlePath, buildPatch); - revokePatch(projectConfig.stringsPath, makeStringsPatch(params, name)); - - revokePatch( - projectConfig.mainFilePath, - makePackagePatch(androidConfig.packageInstance, params, name), - ); - - revokePatch( - projectConfig.mainFilePath, - makeImportPatch(androidConfig.packageImportPath), - ); -} diff --git a/packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts b/packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts deleted file mode 100644 index 28badad2d..000000000 --- a/packages/platform-android/src/link/warnAboutManuallyLinkedLibs.ts +++ /dev/null @@ -1,50 +0,0 @@ -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; -import getLinkConfig from './index'; -import {Config} from '@react-native-community/cli-types'; - -// TODO: move to cli-tools once platform-ios and platform-android are migrated -// to TS and unify with iOS implementation -export default function warnAboutManuallyLinkedLibs( - config: Config, - platform: string = 'android', - linkConfig: ReturnType< - Config['platforms']['android']['linkConfig'] - > = getLinkConfig(), -) { - let deps: Array = []; - const projectConfig = config.project[platform]; - - for (let key in config.dependencies) { - const dependency = config.dependencies[key]; - - const dependencyConfig = dependency.platforms[platform]; - if (projectConfig && dependencyConfig) { - const x = linkConfig.isInstalled( - projectConfig, - dependency.name, - dependencyConfig, - ); - deps = deps.concat(x ? dependency.name : []); - } - } - - const installedModules = [...new Set(deps)]; - - if (installedModules.length) { - logger.error( - `React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: \n${installedModules - .map( - (x) => - ` - ${chalk.bold(x)} ${chalk.dim( - `(to unlink run: "react-native unlink ${x}")`, - )}`, - ) - .join( - '\n', - )}\nThis is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.\nRead more about autolinking: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); - } -} diff --git a/packages/platform-ios/src/index.ts b/packages/platform-ios/src/index.ts index 389b3a219..59589860d 100644 --- a/packages/platform-ios/src/index.ts +++ b/packages/platform-ios/src/index.ts @@ -2,6 +2,5 @@ * iOS platform files */ -export {default as linkConfig} from './link'; export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; diff --git a/packages/platform-ios/src/link-pods/__fixtures__/Info.plist b/packages/platform-ios/src/link-pods/__fixtures__/Info.plist deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple b/packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple deleted file mode 100644 index 3e42c2527..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileSimple +++ /dev/null @@ -1,8 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '9.0' - -target 'Testing' do - pod 'TestPod', '~> 3.1' - - # test should point to this line -end diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction deleted file mode 100644 index 13b70fb0a..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithFunction +++ /dev/null @@ -1,30 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '9.0' - -target 'none' do - pod 'React', - :path => "../node_modules/react-native", - :subspecs => [ - "Core", - "ART", - "RCTActionSheet", - "RCTAnimation", - "RCTCameraRoll", - "RCTGeolocation", - "RCTImage", - "RCTNetwork", - "RCTText", - "RCTVibration", - "RCTWebSocket", - "DevSupport", - "BatchedBridge" - ] - - pod 'Yoga', - :path => "../node_modules/react-native/ReactCommon/yoga" - - # test should point to this line - post_install do |installer| - - end -end diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithInvalidKey.lock b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithInvalidKey.lock deleted file mode 100644 index 2f92d2945..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithInvalidKey.lock +++ /dev/null @@ -1,16 +0,0 @@ -PODS: - - MyPackage (1.0.0) - -EXTERNAL SOURCES: - ExternalInterface: - :path: !ruby/object:Pathname - path: "../node_modules/MyOtherPackage/ios" - -SPEC CHECKSUMS: - MyPackage: 77fd5fb102a4a5eedafa2c2b0245ceb7b7c15e45 - MyOtherPackage: a9bb76128853e98a9ef6d12b0c8c91debc9bc475 - - -PODFILE CHECKSUM: a8110dc7c367fc529b8b6a1084258784444d62ec - -COCOAPODS: 1.7.5 diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers deleted file mode 100644 index bf27d3368..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithMarkers +++ /dev/null @@ -1,34 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -# platform :ios, '9.0' - -target 'None' do - # Uncomment the next line if you're using Swift or would like to use dynamic frameworks - # use_frameworks! - # Your 'node_modules' directory is probably in the root of your project, # but if not, adjust the `:path` accordingly - pod 'React', :path => '../node_modules/react-native', :subspecs => [ - 'Core', - 'RCTText', - 'RCTNetwork', - 'BatchedBridge', - 'RCTImage', - 'RCTWebSocket', # needed for debugging - # Add any other subspecs you want to use in your project - ] - - # Add new pods below this line - - # test should point to this line - target 'NoneTests' do - inherit! :search_paths - # Pods for testing - end -end - -target 'Second' do - - target 'NoneUITests' do - inherit! :search_paths - # Add new pods below this line - end - -end \ No newline at end of file diff --git a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget b/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget deleted file mode 100644 index 5887ababe..000000000 --- a/packages/platform-ios/src/link-pods/__fixtures__/PodfileWithTarget +++ /dev/null @@ -1,32 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -# platform :ios, '9.0' - -target 'None' do - # Uncomment the next line if you're using Swift or would like to use dynamic frameworks - # use_frameworks! - # Your 'node_modules' directory is probably in the root of your project, # but if not, adjust the `:path` accordingly - pod 'React', :path => '../node_modules/react-native', :subspecs => [ - 'Core', - 'RCTText', - 'RCTNetwork', - 'BatchedBridge', - 'RCTImage', - 'RCTWebSocket', # needed for debugging - # Add any other subspecs you want to use in your project - ] - - # Explicitly include Yoga if you are using RN >= 0.42.0 - pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga" - - # test should point to this line - target 'NoneTests' do - inherit! :search_paths - # Pods for testing - end - - target 'NoneUITests' do - inherit! :search_paths - # Pods for testing - end - -end \ No newline at end of file diff --git a/packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts b/packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts deleted file mode 100644 index a4e3b6f6a..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/findLineToAddPod.test.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import findLineToAddPod from '../findLineToAddPod'; -import readPodfile from '../readPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); -const LINE_AFTER_TARGET_IN_TEST_PODFILE = 4; - -describe('pods::findLineToAddPod', () => { - it('returns null if file is not Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'Info.plist')); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toBeNull(); - }); - - it('returns correct line number for Simple Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toEqual({line: 7, indentation: 2}); - }); - - it('returns correct line number for Podfile with target', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileWithTarget')); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toEqual({line: 21, indentation: 2}); - }); - - it('returns correct line number for Podfile with function', () => { - const podfile = readPodfile( - path.join(PODFILES_PATH, 'PodfileWithFunction'), - ); - expect( - findLineToAddPod(podfile, LINE_AFTER_TARGET_IN_TEST_PODFILE), - ).toEqual({line: 26, indentation: 2}); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts b/packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts deleted file mode 100644 index 5f2951f83..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/findMarkedLinesInPodfile.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import readPodfile from '../readPodfile'; -import findMarkedLinesInPodfile from '../findMarkedLinesInPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__'); - -describe('pods::findMarkedLinesInPodfile', () => { - it('returns empty array if file is not Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'Info.plist')); - expect(findMarkedLinesInPodfile(podfile)).toEqual([]); - }); - - it('returns empty array for Simple Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect(findMarkedLinesInPodfile(podfile)).toEqual([]); - }); - - it('returns correct line numbers for Podfile with marker', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileWithMarkers')); - const expectedObject = [ - {line: 18, indentation: 2}, - {line: 31, indentation: 4}, - ]; - expect(findMarkedLinesInPodfile(podfile)).toEqual(expectedObject); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts b/packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts deleted file mode 100644 index e8fdd24ce..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/findPodTargetLine.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import findPodTargetLine from '../findPodTargetLine'; -import readPodfile from '../readPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__'); - -describe('pods::findPodTargetLine', () => { - it('returns null if file is not Podfile', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'Info.plist')); - expect(findPodTargetLine(podfile, 'name')).toBeNull(); - }); - - it('returns null if there is not matching project name', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect(findPodTargetLine(podfile, 'invalidName')).toBeNull(); - }); - - it('returns correct line if there is a matching project', () => { - const podfile = readPodfile(path.join(PODFILES_PATH, 'PodfileSimple')); - expect(findPodTargetLine(podfile, 'Testing')).toBe(4); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/getDependenciesFromPodfileLock.test.ts b/packages/platform-ios/src/link-pods/__tests__/getDependenciesFromPodfileLock.test.ts deleted file mode 100644 index c8df696a7..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/getDependenciesFromPodfileLock.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getDependenciesFromPodfileLock from '../getDependenciesFromPodfileLock'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); - -describe('pods::getDependenciesFromPodfileLock', () => { - it('only parses parts of the lock file that are valid yaml', () => { - const podfileDeps = getDependenciesFromPodfileLock( - path.join(PODFILES_PATH, 'PodfileWithInvalidKey.lock'), - ); - expect(podfileDeps).toEqual(['MyPackage', 'MyOtherPackage']); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts b/packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts deleted file mode 100644 index 13621191e..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/isInstalled.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from '../isInstalled'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); - -describe('pods::isInstalled', () => { - it('returns false if pod is missing', () => { - const project = {podfile: path.join(PODFILES_PATH, 'PodfileSimple')}; - const podspecName = {podspecPath: '/path/NotExisting'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(false); - }); - - it('returns true for existing pod with version number', () => { - const project = {podfile: path.join(PODFILES_PATH, 'PodfileSimple')}; - const podspecName = {podspecPath: '/path/TestPod.podspec'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(true); - }); - - it('returns true for existing pod with path', () => { - const project = {podfile: path.join(PODFILES_PATH, 'PodfileWithTarget')}; - const podspecName = {podspecPath: '/path/Yoga.podspec'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(true); - }); - - it('returns true for existing pod with multiline definition', () => { - const project = { - podfile: path.join(PODFILES_PATH, 'PodfileWithFunction'), - }; - const podspecName = {podspecPath: '/path/React.podspec'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(project, podspecName)).toBe(true); - }); -}); diff --git a/packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts b/packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts deleted file mode 100644 index 5e9e25472..000000000 --- a/packages/platform-ios/src/link-pods/__tests__/removePodEntry.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import removePodEntry from '../removePodEntry'; -import readPodfile from '../readPodfile'; - -const path = require('path'); - -const PODFILES_PATH = path.join(__dirname, '../__fixtures__/'); - -describe('pods::removePodEntry', () => { - it('should remove one line from Podfile with TestPod', () => { - const {podfileContent, podLinesCount} = readTestPodFile('PodfileSimple'); - const podFileWithRemoved = removePodEntry(podfileContent, 'TestPod'); - const newLineCount = podFileWithRemoved.split('\n').length; - expect(newLineCount).toBe(podLinesCount - 1); - }); - - it('should remove one line from Podfile with Yoga', () => { - const {podfileContent, podLinesCount} = readTestPodFile( - 'PodfileWithTarget', - ); - const podFileWithRemoved = removePodEntry(podfileContent, 'Yoga'); - const newLineCount = podFileWithRemoved.split('\n').length; - expect(newLineCount).toBe(podLinesCount - 1); - }); - - it('should remove whole reference to React pod from Podfile', () => { - const {podfileContent, podLinesCount} = readTestPodFile( - 'PodfileWithTarget', - ); - const podFileWithRemoved = removePodEntry(podfileContent, 'React'); - const newLineCount = podFileWithRemoved.split('\n').length; - expect(newLineCount).toBe(podLinesCount - 9); - }); -}); - -function readTestPodFile(fileName) { - const podfileLines = readPodfile(path.join(PODFILES_PATH, fileName)); - return { - podfileContent: podfileLines.join('\n'), - podLinesCount: podfileLines.length, - }; -} diff --git a/packages/platform-ios/src/link-pods/addPodEntry.ts b/packages/platform-ios/src/link-pods/addPodEntry.ts deleted file mode 100644 index 2a76cb889..000000000 --- a/packages/platform-ios/src/link-pods/addPodEntry.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {logger} from '@react-native-community/cli-tools'; -import getPodspecName from '../config/getPodspecName'; - -export default function addPodEntry( - podLines: Array, - linesToAddEntry: - | Array<{line: number; indentation: number}> - | {line: number; indentation: number} - | null - | undefined, - podspecPath: string, - nodeModulePath: string, -) { - const podName = getPodspecName(podspecPath); - const newEntry = `pod '${podName}', :path => '../node_modules/${nodeModulePath}'\n`; - - if (!linesToAddEntry) { - return; - } - - if (Array.isArray(linesToAddEntry)) { - linesToAddEntry.map(({line, indentation}, idx) => { - logger.debug(`Adding ${podName} to Pod file"`); - podLines.splice(line + idx, 0, getLineToAdd(newEntry, indentation)); - }); - } else { - const {line, indentation} = linesToAddEntry; - logger.debug(`Adding ${podName} to Pod file"`); - podLines.splice(line, 0, getLineToAdd(newEntry, indentation)); - } -} - -function getLineToAdd(newEntry: string, indentation: number) { - const spaces = Array(indentation + 1).join(' '); - return spaces + newEntry; -} diff --git a/packages/platform-ios/src/link-pods/findLineToAddPod.ts b/packages/platform-ios/src/link-pods/findLineToAddPod.ts deleted file mode 100644 index 8a35d730b..000000000 --- a/packages/platform-ios/src/link-pods/findLineToAddPod.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function findLineToAddPod( - podLines: Array, - firstTargetLine: number, -) { - // match line with new target: target 'project_name' do (most likely target inside podfile main target) - const nextTarget = /target ('|")\w+('|") do/g; - // match line that has only 'end' (if we don't catch new target or function, this would mean this is end of current target) - const endOfCurrentTarget = /^\s*end\s*$/g; - // match function definition, like: post_install do |installer| (some Podfiles have function defined inside main target - const functionDefinition = /^\s*[a-z_]+\s+do(\s+\|[a-z]+\|)?/g; - - for (let i = firstTargetLine; i < podLines.length - 1; i++) { - const matchNextConstruct = - podLines[i].match(nextTarget) || podLines[i].match(functionDefinition); - const matchEnd = podLines[i].match(endOfCurrentTarget); - - if (matchNextConstruct || matchEnd) { - const firstNonSpaceCharacter = podLines[i].search(/\S/); - return { - indentation: firstNonSpaceCharacter + (matchEnd ? 2 : 0), - line: i, - }; - } - } - return null; -} diff --git a/packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts b/packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts deleted file mode 100644 index 1e9551025..000000000 --- a/packages/platform-ios/src/link-pods/findMarkedLinesInPodfile.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export const MARKER_TEXT = '# Add new pods below this line'; - -export default function findMarkedLinesInPodfile(podLines: Array) { - const result = []; - for (let i = 0, len = podLines.length; i < len; i++) { - if (podLines[i].includes(MARKER_TEXT)) { - result.push({line: i + 1, indentation: podLines[i].indexOf('#')}); - } - } - return result; -} diff --git a/packages/platform-ios/src/link-pods/findPodTargetLine.ts b/packages/platform-ios/src/link-pods/findPodTargetLine.ts deleted file mode 100644 index f18e41bba..000000000 --- a/packages/platform-ios/src/link-pods/findPodTargetLine.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function findPodTargetLine( - podLines: Array, - projectName: string, -) { - const targetName = projectName.replace('.xcodeproj', ''); - // match first target definition in file: target 'target_name' do - const targetRegex = new RegExp(`target ('|")${targetName}('|") do`, 'g'); - for (let i = 0, len = podLines.length; i < len; i++) { - const match = podLines[i].match(targetRegex); - if (match) { - return i + 1; - } - } - return null; -} diff --git a/packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts b/packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts deleted file mode 100644 index 6f4cf9c3d..000000000 --- a/packages/platform-ios/src/link-pods/getDependenciesFromPodfileLock.ts +++ /dev/null @@ -1,30 +0,0 @@ -import fs from 'fs'; -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; -import {safeLoad} from 'js-yaml'; - -const CHECKSUM_KEY = 'SPEC CHECKSUMS'; - -export default function getDependenciesFromPodfileLock( - podfileLockPath: string, -) { - logger.debug(`Reading ${podfileLockPath}`); - let fileContent; - try { - fileContent = fs.readFileSync(podfileLockPath, 'utf8'); - } catch (err) { - logger.error( - `Could not find "Podfile.lock" at ${chalk.dim( - podfileLockPath, - )}. Did you run "${chalk.bold('pod install')}" in iOS directory?`, - ); - return []; - } - - // Previous portions of the lock file could be invalid yaml. - // Only parse parts that are valid - const tail = fileContent.split(CHECKSUM_KEY).slice(1); - const checksumTail = CHECKSUM_KEY + tail; - - return Object.keys(safeLoad(checksumTail)[CHECKSUM_KEY] || {}); -} diff --git a/packages/platform-ios/src/link-pods/isInstalled.ts b/packages/platform-ios/src/link-pods/isInstalled.ts deleted file mode 100644 index 6972cd4c7..000000000 --- a/packages/platform-ios/src/link-pods/isInstalled.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import readPodfile from './readPodfile'; -import getPodspecName from '../config/getPodspecName'; -import { - IOSProjectConfig, - IOSDependencyConfig, -} from '@react-native-community/cli-types'; - -export default function isInstalled( - iOSProject: IOSProjectConfig, - dependencyConfig: IOSDependencyConfig, -) { - if (!iOSProject.podfile || !dependencyConfig.podspecPath) { - return false; - } - // match line with pod declaration: pod 'dependencyPodName' (other possible parameters of pod are ignored) - const dependencyRegExp = new RegExp( - `pod\\s+('|")${getPodspecName(dependencyConfig.podspecPath)}('|")`, - 'g', - ); - const podLines = readPodfile(iOSProject.podfile); - for (let i = 0, len = podLines.length; i < len; i++) { - const match = podLines[i].match(dependencyRegExp); - if (match) { - return true; - } - } - return false; -} diff --git a/packages/platform-ios/src/link-pods/readPodfile.ts b/packages/platform-ios/src/link-pods/readPodfile.ts deleted file mode 100644 index cfbccf020..000000000 --- a/packages/platform-ios/src/link-pods/readPodfile.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function readPodfile(podfilePath: string) { - logger.debug(`Reading ${podfilePath}`); - const podContent = fs.readFileSync(podfilePath, 'utf8'); - return podContent.split(/\r?\n/g); -} diff --git a/packages/platform-ios/src/link-pods/registerNativeModule.ts b/packages/platform-ios/src/link-pods/registerNativeModule.ts deleted file mode 100644 index ab8e6b909..000000000 --- a/packages/platform-ios/src/link-pods/registerNativeModule.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import chalk from 'chalk'; -import {CLIError} from '@react-native-community/cli-tools'; -import {IOSProjectConfig} from '@react-native-community/cli-types'; -import readPodfile from './readPodfile'; -import findPodTargetLine from './findPodTargetLine'; -import findLineToAddPod from './findLineToAddPod'; -import findMarkedLinesInPodfile, { - MARKER_TEXT, -} from './findMarkedLinesInPodfile'; -import addPodEntry from './addPodEntry'; -import savePodFile from './savePodFile'; - -export default function registerNativeModulePods( - name: string, - podspecPath: string, - iOSProject: IOSProjectConfig, -) { - const podLines = readPodfile(iOSProject.podfile); - const linesToAddEntry = getLinesToAddEntry(podLines, iOSProject); - addPodEntry(podLines, linesToAddEntry, podspecPath, name); - savePodFile(iOSProject.podfile, podLines); -} - -function getLinesToAddEntry( - podLines: Array, - {projectName}: IOSProjectConfig, -) { - const linesToAddPodWithMarker = findMarkedLinesInPodfile(podLines); - if (linesToAddPodWithMarker.length > 0) { - return linesToAddPodWithMarker; - } - const firstTargetLined = findPodTargetLine(podLines, projectName); - if (firstTargetLined === null) { - throw new CLIError(` - We couldn't find a target to add a CocoaPods dependency. - - Make sure that you have a "${chalk.dim( - `target '${projectName.replace('.xcodeproj', '')}' do`, - )}" line in your Podfile. - - Alternatively, include "${chalk.dim( - MARKER_TEXT, - )}" in a Podfile where we should add - linked dependencies. - `); - } - return findLineToAddPod(podLines, firstTargetLined); -} diff --git a/packages/platform-ios/src/link-pods/removePodEntry.ts b/packages/platform-ios/src/link-pods/removePodEntry.ts deleted file mode 100644 index a9339cf36..000000000 --- a/packages/platform-ios/src/link-pods/removePodEntry.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {logger} from '@react-native-community/cli-tools'; -import getPodspecName from '../config/getPodspecName'; - -export default function removePodEntry( - podfileContent: string, - podspecPath: string, -) { - const podName = getPodspecName(podspecPath); - // this regex should catch line(s) with full pod definition, like: pod 'podname', :path => '../node_modules/podname', :subspecs => ['Sub2', 'Sub1'] - const podRegex = new RegExp( - `\\n( |\\t)*pod\\s+("|')${podName}("|')(,\\s*(:[a-z]+\\s*=>)?\\s*(("|').*?("|')|\\[[\\s\\S]*?\\]))*\\n`, - 'g', - ); - logger.debug(`Removing ${podName} from Pod file`); - return podfileContent.replace(podRegex, '\n'); -} diff --git a/packages/platform-ios/src/link-pods/savePodFile.ts b/packages/platform-ios/src/link-pods/savePodFile.ts deleted file mode 100644 index a26cdf438..000000000 --- a/packages/platform-ios/src/link-pods/savePodFile.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import {logger} from '@react-native-community/cli-tools'; - -export default function savePodFile( - podfilePath: string, - podLines: Array, -) { - const newPodfile = podLines.join('\n'); - logger.debug(`Writing changes to ${podfilePath}`); - fs.writeFileSync(podfilePath, newPodfile); -} diff --git a/packages/platform-ios/src/link-pods/unregisterNativeModule.ts b/packages/platform-ios/src/link-pods/unregisterNativeModule.ts deleted file mode 100644 index 18d0acdde..000000000 --- a/packages/platform-ios/src/link-pods/unregisterNativeModule.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import removePodEntry from './removePodEntry'; -import {logger} from '@react-native-community/cli-tools'; -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; - -/** - * Unregister native module IOS with CocoaPods - */ -export default function unregisterNativeModule( - dependencyConfig: IOSDependencyConfig, - iOSProject: IOSProjectConfig, -) { - const podContent = fs.readFileSync(iOSProject.podfile, 'utf8'); - const removed = removePodEntry(podContent, dependencyConfig.podspecPath); - logger.debug(`Writing changes to ${iOSProject.podfile}`); - fs.writeFileSync(iOSProject.podfile, removed); -} diff --git a/packages/platform-ios/src/link/__fixtures__/Info.plist b/packages/platform-ios/src/link/__fixtures__/Info.plist deleted file mode 100644 index b2e7b96ea..000000000 --- a/packages/platform-ios/src/link/__fixtures__/Info.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - - - diff --git a/packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj b/packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj deleted file mode 100644 index ca87c2e43..000000000 --- a/packages/platform-ios/src/link/__fixtures__/linearGradient.pbxproj +++ /dev/null @@ -1,258 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - BBD49E3F1AC8DEF000610F8E /* BVLinearGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */; }; - BBD49E401AC8DEF000610F8E /* BVLinearGradientManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBVLinearGradient.a; sourceTree = BUILT_PRODUCTS_DIR; }; - BBD49E391AC8DEF000610F8E /* BVLinearGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVLinearGradient.h; sourceTree = ""; }; - BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVLinearGradient.m; sourceTree = ""; }; - BBD49E3B1AC8DEF000610F8E /* BVLinearGradientManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVLinearGradientManager.h; sourceTree = ""; }; - BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVLinearGradientManager.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - BBD49E391AC8DEF000610F8E /* BVLinearGradient.h */, - BBD49E3A1AC8DEF000610F8E /* BVLinearGradient.m */, - BBD49E3B1AC8DEF000610F8E /* BVLinearGradientManager.h */, - BBD49E3C1AC8DEF000610F8E /* BVLinearGradientManager.m */, - 134814211AA4EA7D00B7C361 /* Products */, - ); - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* BVLinearGradient */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "BVLinearGradient" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = BVLinearGradient; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libBVLinearGradient.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "BVLinearGradient" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* BVLinearGradient */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BBD49E3F1AC8DEF000610F8E /* BVLinearGradient.m in Sources */, - BBD49E401AC8DEF000610F8E /* BVLinearGradientManager.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = BVLinearGradient; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../react-native/React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = BVLinearGradient; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "BVLinearGradient" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "BVLinearGradient" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/packages/platform-ios/src/link/__fixtures__/project.pbxproj b/packages/platform-ios/src/link/__fixtures__/project.pbxproj deleted file mode 100644 index 428aa40c9..000000000 --- a/packages/platform-ios/src/link/__fixtures__/project.pbxproj +++ /dev/null @@ -1,1011 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { -/* Begin PBXBuildFile section */ - 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; - 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; - 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; - 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; - 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; - 00E356F31AD99517003FC87E /* BasicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* BasicTests.m */; }; - 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; - 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; - 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; - 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; - 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; - 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; - 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; - 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTActionSheet; - }; - 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTGeolocation; - }; - 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B5115D1A9E6B3D00147676; - remoteInfo = RCTImage; - }; - 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B511DB1A9E6C8500147676; - remoteInfo = RCTNetwork; - }; - 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; - remoteInfo = RCTVibration; - }; - 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 13B07F861A680F5B00A75B9A; - remoteInfo = Basic; - }; - 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTSettings; - }; - 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3C86DF461ADF2C930047B81A; - remoteInfo = RCTWebSocket; - }; - 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = React; - }; - 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A283A1D9B042B00D4039D; - remoteInfo = "RCTImage-tvOS"; - }; - 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28471D9B043800D4039D; - remoteInfo = "RCTLinking-tvOS"; - }; - 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28541D9B044C00D4039D; - remoteInfo = "RCTNetwork-tvOS"; - }; - 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28611D9B046600D4039D; - remoteInfo = "RCTSettings-tvOS"; - }; - 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A287B1D9B048500D4039D; - remoteInfo = "RCTText-tvOS"; - }; - 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28881D9B049200D4039D; - remoteInfo = "RCTWebSocket-tvOS"; - }; - 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28131D9B038B00D4039D; - remoteInfo = "React-tvOS"; - }; - 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3C059A1DE3340900C268FA; - remoteInfo = yoga; - }; - 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3C06751DE3340C00C268FA; - remoteInfo = "yoga-tvOS"; - }; - 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; - remoteInfo = cxxreact; - }; - 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; - remoteInfo = "cxxreact-tvOS"; - }; - 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; - remoteInfo = jschelpers; - }; - 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; - remoteInfo = "jschelpers-tvOS"; - }; - 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTAnimation; - }; - 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 2D2A28201D9B03D100D4039D; - remoteInfo = "RCTAnimation-tvOS"; - }; - 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTLinking; - }; - 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B5119B1A9E6C1200147676; - remoteInfo = RCTText; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; - 00E356EE1AD99517003FC87E /* BasicTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BasicTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 00E356F21AD99517003FC87E /* BasicTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BasicTests.m; sourceTree = ""; }; - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; - 13B07F961A680F5B00A75B9A /* Basic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Basic.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Basic/AppDelegate.h; sourceTree = ""; }; - 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Basic/AppDelegate.m; sourceTree = ""; }; - 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Basic/Images.xcassets; sourceTree = ""; }; - 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Basic/Info.plist; sourceTree = ""; }; - 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Basic/main.m; sourceTree = ""; }; - 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; - 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 00E356EB1AD99517003FC87E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */, - 146834051AC3E58100842450 /* libReact.a in Frameworks */, - 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, - 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, - 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, - 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, - 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, - 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, - 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, - 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, - 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 00C302A81ABCB8CE00DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302B61ABCB90400DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302BC1ABCB91800DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, - 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302D41ABCB9D200DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, - 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302E01ABCB9EE00DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, - ); - name = Products; - sourceTree = ""; - }; - 00E356EF1AD99517003FC87E /* BasicTests */ = { - isa = PBXGroup; - children = ( - 00E356F21AD99517003FC87E /* BasicTests.m */, - 00E356F01AD99517003FC87E /* Supporting Files */, - ); - path = BasicTests; - sourceTree = ""; - }; - 00E356F01AD99517003FC87E /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 00E356F11AD99517003FC87E /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 139105B71AF99BAD00B5F7CC /* Products */ = { - isa = PBXGroup; - children = ( - 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, - 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 139FDEE71B06529A00C62182 /* Products */ = { - isa = PBXGroup; - children = ( - 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, - 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 13B07FAE1A68108700A75B9A /* Basic */ = { - isa = PBXGroup; - children = ( - 008F07F21AC5B25A0029DE68 /* main.jsbundle */, - 13B07FAF1A68108700A75B9A /* AppDelegate.h */, - 13B07FB01A68108700A75B9A /* AppDelegate.m */, - 13B07FB51A68108700A75B9A /* Images.xcassets */, - 13B07FB61A68108700A75B9A /* Info.plist */, - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, - 13B07FB71A68108700A75B9A /* main.m */, - ); - name = Basic; - sourceTree = ""; - }; - 146834001AC3E56700842450 /* Products */ = { - isa = PBXGroup; - children = ( - 146834041AC3E56700842450 /* libReact.a */, - 3DAD3EA31DF850E9000B6D8A /* libReact.a */, - 3DAD3EA51DF850E9000B6D8A /* libyoga.a */, - 3DAD3EA71DF850E9000B6D8A /* libyoga.a */, - 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */, - 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */, - 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */, - 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */, - ); - name = Products; - sourceTree = ""; - }; - 5E91572E1DD0AC6500FF2AA8 /* Products */ = { - isa = PBXGroup; - children = ( - 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */, - 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 78C398B11ACF4ADC00677621 /* Products */ = { - isa = PBXGroup; - children = ( - 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, - 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 832341AE1AAA6A7D00B99B32 /* Libraries */ = { - isa = PBXGroup; - children = ( - 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */, - 146833FF1AC3E56700842450 /* React.xcodeproj */, - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, - ); - name = Libraries; - sourceTree = ""; - }; - 832341B11AAA6A8300B99B32 /* Products */ = { - isa = PBXGroup; - children = ( - 832341B51AAA6A8300B99B32 /* libRCTText.a */, - 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */, - ); - name = Products; - sourceTree = ""; - }; - 83CBB9F61A601CBA00E9B192 = { - isa = PBXGroup; - children = ( - AD9196DA1CABA83E000E8D91 /* NestedGroup */, - 13B07FAE1A68108700A75B9A /* Basic */, - 832341AE1AAA6A7D00B99B32 /* Libraries */, - 00E356EF1AD99517003FC87E /* BasicTests */, - 83CBBA001A601CBA00E9B192 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 83CBBA001A601CBA00E9B192 /* Products */ = { - isa = PBXGroup; - children = ( - 13B07F961A680F5B00A75B9A /* Basic.app */, - 00E356EE1AD99517003FC87E /* BasicTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - AD9196DA1CABA83E000E8D91 /* NestedGroup */ = { - isa = PBXGroup; - children = ( - AD9196DB1CABA844000E8D91 /* Libraries */, - ); - name = NestedGroup; - sourceTree = ""; - }; - AD9196DB1CABA844000E8D91 /* Libraries */ = { - isa = PBXGroup; - children = ( - ); - name = Libraries; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 00E356ED1AD99517003FC87E /* BasicTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "BasicTests" */; - buildPhases = ( - 00E356EA1AD99517003FC87E /* Sources */, - 00E356EB1AD99517003FC87E /* Frameworks */, - 00E356EC1AD99517003FC87E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 00E356F51AD99517003FC87E /* PBXTargetDependency */, - ); - name = BasicTests; - productName = BasicTests; - productReference = 00E356EE1AD99517003FC87E /* BasicTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 13B07F861A680F5B00A75B9A /* Basic */ = { - isa = PBXNativeTarget; - buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Basic" */; - buildPhases = ( - 13B07F871A680F5B00A75B9A /* Sources */, - 13B07F8C1A680F5B00A75B9A /* Frameworks */, - 13B07F8E1A680F5B00A75B9A /* Resources */, - 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Basic; - productName = "Hello World"; - productReference = 13B07F961A680F5B00A75B9A /* Basic.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 83CBB9F71A601CBA00E9B192 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 00E356ED1AD99517003FC87E = { - CreatedOnToolsVersion = 6.2; - TestTargetID = 13B07F861A680F5B00A75B9A; - }; - }; - }; - buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Basic" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 83CBB9F61A601CBA00E9B192; - productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; - ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; - }, - { - ProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */; - ProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; - }, - { - ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; - ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; - }, - { - ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; - ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - }, - { - ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; - ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - }, - { - ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; - ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - }, - { - ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; - ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - }, - { - ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; - ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - }, - { - ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; - ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; - }, - { - ProductGroup = 139FDEE71B06529A00C62182 /* Products */; - ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - }, - { - ProductGroup = 146834001AC3E56700842450 /* Products */; - ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 13B07F861A680F5B00A75B9A /* Basic */, - 00E356ED1AD99517003FC87E /* BasicTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTActionSheet.a; - remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTGeolocation.a; - remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTImage.a; - remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTNetwork.a; - remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTVibration.a; - remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTSettings.a; - remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTWebSocket.a; - remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 146834041AC3E56700842450 /* libReact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReact.a; - remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTImage-tvOS.a"; - remoteRef = 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTLinking-tvOS.a"; - remoteRef = 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTNetwork-tvOS.a"; - remoteRef = 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTSettings-tvOS.a"; - remoteRef = 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTText-tvOS.a"; - remoteRef = 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTWebSocket-tvOS.a"; - remoteRef = 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA31DF850E9000B6D8A /* libReact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReact.a; - remoteRef = 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA51DF850E9000B6D8A /* libyoga.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libyoga.a; - remoteRef = 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA71DF850E9000B6D8A /* libyoga.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libyoga.a; - remoteRef = 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcxxreact.a; - remoteRef = 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libcxxreact.a; - remoteRef = 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libjschelpers.a; - remoteRef = 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libjschelpers.a; - remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTAnimation.a; - remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = "libRCTAnimation-tvOS.a"; - remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTLinking.a; - remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTText.a; - remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXResourcesBuildPhase section */ - 00E356EC1AD99517003FC87E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F8E1A680F5B00A75B9A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, - 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Bundle React Native code and images"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 00E356EA1AD99517003FC87E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 00E356F31AD99517003FC87E /* BasicTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F871A680F5B00A75B9A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, - 13B07FC11A68108700A75B9A /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 13B07F861A680F5B00A75B9A /* Basic */; - targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - 13B07FB21A68108700A75B9A /* Base */, - ); - name = LaunchScreen.xib; - path = Basic; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 00E356F61AD99517003FC87E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = BasicTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - ); - }; - name = Debug; - }; - 00E356F71AD99517003FC87E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - COPY_PHASE_STRIP = NO; - INFOPLIST_FILE = BasicTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic"; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - ); - }; - name = Release; - }; - 13B07F941A680F5B00A75B9A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = 1; - DEAD_CODE_STRIPPING = NO; - INFOPLIST_FILE = Basic/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_NAME = Basic; - VERSIONING_SYSTEM = "apple-generic"; - HEADER_SEARCH_PATHS = "$(inherited)"; - }; - name = Debug; - }; - 13B07F951A680F5B00A75B9A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = 1; - INFOPLIST_FILE = Basic/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = ( - "$(inherited)", - "-ObjC", - "-lc++", - ); - PRODUCT_NAME = Basic; - VERSIONING_SYSTEM = "apple-generic"; - HEADER_SEARCH_PATHS = "$(inherited)"; - }; - name = Release; - }; - 83CBBA201A601CBA00E9B192 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 83CBBA211A601CBA00E9B192 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "BasicTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 00E356F61AD99517003FC87E /* Debug */, - 00E356F71AD99517003FC87E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Basic" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 13B07F941A680F5B00A75B9A /* Debug */, - 13B07F951A680F5B00A75B9A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "Basic" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 83CBBA201A601CBA00E9B192 /* Debug */, - 83CBBA211A601CBA00E9B192 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} diff --git a/packages/platform-ios/src/link/__tests__/addFileToProject.test.ts b/packages/platform-ios/src/link/__tests__/addFileToProject.test.ts deleted file mode 100644 index c429f0918..000000000 --- a/packages/platform-ios/src/link/__tests__/addFileToProject.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addFileToProject from '../addFileToProject'; - -const xcode = require('xcode'); -const path = require('path'); -const _ = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::addFileToProject', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should add file to a project', () => { - const {fileRef} = addFileToProject( - project, - '../__fixtures__/linearGradient.pbxproj', - ); - expect( - _.includes(Object.keys(project.pbxFileReferenceSection()), fileRef), - ).toBeTruthy(); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts b/packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts deleted file mode 100644 index e520f8026..000000000 --- a/packages/platform-ios/src/link/__tests__/addProjectToLibraries.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addProjectToLibraries from '../addProjectToLibraries'; - -const xcode = require('xcode'); -const path = require('path'); -const PbxFile = require('xcode/lib/pbxFile'); -const {last} = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::addProjectToLibraries', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should append file to Libraries group', () => { - const file = new PbxFile('fakePath'); - const libraries = project.pbxGroupByName('Libraries'); - - addProjectToLibraries(libraries, file); - - const child = last(libraries.children); - - expect(child.comment).toBe(file.basename); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts b/packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts deleted file mode 100644 index 49a14d879..000000000 --- a/packages/platform-ios/src/link/__tests__/addSharedLibraries.test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addSharedLibraries from '../addSharedLibraries'; -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::addSharedLibraries', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should automatically create Frameworks group', () => { - expect(getGroup(project, 'Frameworks')).toBeNull(); - addSharedLibraries(project, ['libz.tbd']); - expect(getGroup(project, 'Frameworks')).not.toBeNull(); - }); - - it('should add shared libraries to project', () => { - addSharedLibraries(project, ['libz.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(1); - expect(frameworksGroup.children[0].comment).toEqual('libz.tbd'); - - addSharedLibraries(project, ['MessageUI.framework']); - expect(frameworksGroup.children).toHaveLength(2); - }); - - it('should not add duplicate libraries to project', () => { - addSharedLibraries(project, ['libz.tbd']); - addSharedLibraries(project, ['libz.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(1); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/createGroup.test.ts b/packages/platform-ios/src/link/__tests__/createGroup.test.ts deleted file mode 100644 index fd7ba3bf8..000000000 --- a/packages/platform-ios/src/link/__tests__/createGroup.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import createGroup from '../createGroup'; -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); -const {last} = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::createGroup', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should create a group with given name', () => { - const createdGroup = createGroup(project, 'Resources'); - expect(createdGroup.name).toBe('Resources'); - }); - - it('should attach group to main project group', () => { - const createdGroup = createGroup(project, 'Resources'); - const mainGroup = getGroup(project); - - expect(last(mainGroup.children).comment).toBe(createdGroup.name); - }); - - it('should create a nested group with given path', () => { - const createdGroup = createGroup(project, 'NewGroup/NewNestedGroup'); - const outerGroup = getGroup(project, 'NewGroup'); - - expect(last(outerGroup.children).comment).toBe(createdGroup.name); - }); - - it('should-not create already created groups', () => { - const createdGroup = createGroup(project, 'Libraries/NewNestedGroup'); - const outerGroup = getGroup(project, 'Libraries'); - const mainGroup = getGroup(project); - - expect( - mainGroup.children.filter((group) => group.comment === 'Libraries'), - ).toHaveLength(1); - expect(last(outerGroup.children).comment).toBe(createdGroup.name); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts b/packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts deleted file mode 100644 index 672c31bd6..000000000 --- a/packages/platform-ios/src/link/__tests__/getBuildProperty.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getBuildProperty from '../getBuildProperty'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getBuildProperty', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return build property from main target', () => { - const plistPath = getBuildProperty(project, 'INFOPLIST_FILE'); - expect(plistPath).toEqual('Basic/Info.plist'); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getGroup.test.ts b/packages/platform-ios/src/link/__tests__/getGroup.test.ts deleted file mode 100644 index 9c8f0dd0f..000000000 --- a/packages/platform-ios/src/link/__tests__/getGroup.test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getGroup', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return a top-level group', () => { - const group = getGroup(project, 'Libraries'); - expect(group.children.length > 0).toBeTruthy(); - expect(group.name).toBe('Libraries'); - }); - - it('should return nested group when specified', () => { - const group = getGroup(project, 'NestedGroup/Libraries'); - expect(group.children).toHaveLength(0); // our test nested Libraries is empty - expect(group.name).toBe('Libraries'); - }); - - it('should return null when no group found', () => { - const group = getGroup(project, 'I-Dont-Exist'); - expect(group).toBeNull(); - }); - - it('should return top-level group when name not specified', () => { - const mainGroupId = project.getFirstProject().firstProject.mainGroup; - const mainGroup = project.getPBXGroupByKey(mainGroupId); - const group = getGroup(project); - expect(group).toEqual(mainGroup); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts b/packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts deleted file mode 100644 index c0103da5a..000000000 --- a/packages/platform-ios/src/link/__tests__/getHeaderSearchPath.test.ts +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getHeaderSearchPath from '../getHeaderSearchPath'; -import {posix as path} from 'path'; - -const SRC_DIR = path.join('react-native-project', 'ios'); - -describe('ios::getHeaderSearchPath', () => { - /** - * See https://github.com/Microsoft/react-native-code-push - */ - it('should return correct path when all headers are in root folder', () => { - const files = [ - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'Gradient.h', - ), - path.join('react-native-project', 'node_modules', 'package', 'Manager.h'), - ]; - - const searchPath = getHeaderSearchPath(SRC_DIR, files); - - expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package'].join(path.sep)}"`, - ); - }); - - /** - * See https://github.com/facebook/react-native/tree/master/React - */ - it('should return correct path when headers are in multiple folders', () => { - const files = [ - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderA', - 'Gradient.h', - ), - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderB', - 'Manager.h', - ), - ]; - - const searchPath = getHeaderSearchPath(SRC_DIR, files); - - expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package', 'src'].join( - path.sep, - )}/**"`, - ); - }); - - /** - * This is just to make sure the above two does not collide with each other - */ - it('should return correct path when headers are in root and nested folders', () => { - const files = [ - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderA', - 'Gradient.h', - ), - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'folderB', - 'Manager.h', - ), - path.join( - 'react-native-project', - 'node_modules', - 'package', - 'src', - 'Manager.h', - ), - ]; - - const searchPath = getHeaderSearchPath(SRC_DIR, files); - - expect(searchPath).toBe( - `"${['$(SRCROOT)', '..', 'node_modules', 'package', 'src'].join( - path.sep, - )}/**"`, - ); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts b/packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts deleted file mode 100644 index a97ca7962..000000000 --- a/packages/platform-ios/src/link/__tests__/getHeadersInFolder.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getHeadersInFolder from '../getHeadersInFolder'; - -jest.mock('fs'); -jest.mock('path'); - -const fs = require('fs'); - -const ROOT_DIR = '/'; - -describe('ios::getHeadersInFolder', () => { - it('should return an array of all headers in given folder', () => { - fs.__setMockFilesystem({ - 'FileA.h': '', - 'FileB.h': '', - }); - - const foundHeaders = getHeadersInFolder(ROOT_DIR); - - expect(foundHeaders).toHaveLength(2); - - getHeadersInFolder(process.cwd()).forEach((headerPath) => { - expect(headerPath.includes(process.cwd())).toBe(true); - }); - }); - - it('should ignore all headers in Pods, Examples & node_modules', () => { - fs.__setMockFilesystem({ - 'FileA.h': '', - 'FileB.h': '', - Pods: { - 'FileC.h': '', - }, - Examples: { - 'FileD.h': '', - }, - node_modules: { - 'FileE.h': '', - }, - }); - - expect(getHeadersInFolder(ROOT_DIR)).toHaveLength(2); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getPlist.test.ts b/packages/platform-ios/src/link/__tests__/getPlist.test.ts deleted file mode 100644 index c2ddbaa58..000000000 --- a/packages/platform-ios/src/link/__tests__/getPlist.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getPlist from '../getPlist'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getPlist', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return null when `.plist` file missing', () => { - const plistPath = getPlist(project, process.cwd()); - expect(plistPath).toBeNull(); - }); - - // @todo - Happy scenario -}); diff --git a/packages/platform-ios/src/link/__tests__/getPlistPath.test.ts b/packages/platform-ios/src/link/__tests__/getPlistPath.test.ts deleted file mode 100644 index 8f33048e6..000000000 --- a/packages/platform-ios/src/link/__tests__/getPlistPath.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getPlistPath from '../getPlistPath'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getPlistPath', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return path without Xcode $(SRCROOT)', () => { - const plistPath = getPlistPath(project, '/'); - expect(plistPath).toBe(path.normalize('/Basic/Info.plist')); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/getTargets.test.ts b/packages/platform-ios/src/link/__tests__/getTargets.test.ts deleted file mode 100644 index 547806896..000000000 --- a/packages/platform-ios/src/link/__tests__/getTargets.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getTargets from '../getTargets'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::getTargets', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return an array of project targets', () => { - const targets = getTargets(project); - expect(targets).toHaveLength(2); - expect(targets[0].name).toContain('Basic.app'); - expect(targets[1].name).toContain('BasicTests.xctest'); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts b/packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts deleted file mode 100644 index 6b2b2159d..000000000 --- a/packages/platform-ios/src/link/__tests__/hasLibraryImported.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import hasLibraryImported from '../hasLibraryImported'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::hasLibraryImported', () => { - beforeEach(() => { - project.parseSync(); - }); - - it('should return true if project has been already imported', () => { - const libraries = project.pbxGroupByName('Libraries'); - expect(hasLibraryImported(libraries, 'React.xcodeproj')).toBeTruthy(); - }); - - it('should return false if project is not imported', () => { - const libraries = project.pbxGroupByName('Libraries'); - expect(hasLibraryImported(libraries, 'ACME.xcodeproj')).toBeFalsy(); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/isInstalled.test.ts b/packages/platform-ios/src/link/__tests__/isInstalled.test.ts deleted file mode 100644 index 340aa3f99..000000000 --- a/packages/platform-ios/src/link/__tests__/isInstalled.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from '../isInstalled'; - -const path = require('path'); - -const baseProjectConfig = { - pbxprojPath: path.join(__dirname, '../__fixtures__/project.pbxproj'), - libraryFolder: 'Libraries', -}; - -describe('ios::isInstalled', () => { - it('should return true when .xcodeproj in Libraries', () => { - const dependencyConfig = {projectName: 'React.xcodeproj'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(baseProjectConfig, dependencyConfig)).toBeTruthy(); - }); - - it('should return false when .xcodeproj not in Libraries', () => { - const dependencyConfig = {projectName: 'Missing.xcodeproj'}; - // @ts-ignore FIXME: Improve types - expect(isInstalled(baseProjectConfig, dependencyConfig)).toBeFalsy(); - }); - - it('should return false when `LibraryFolder` is missing', () => { - const dependencyConfig = {projectName: 'React.xcodeproj'}; - const projectConfig = Object.assign({}, baseProjectConfig, { - libraryFolder: 'Missing', - }); - // @ts-ignore FIXME: Improve types - expect(isInstalled(projectConfig, dependencyConfig)).toBeFalsy(); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts b/packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts deleted file mode 100644 index 0ced635c5..000000000 --- a/packages/platform-ios/src/link/__tests__/mapHeaderSearchPaths.test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import mapHeaderSearchPaths from '../mapHeaderSearchPaths'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::mapHeaderSearchPaths', () => { - beforeEach(() => { - project.parseSync(); - }); - - /** - * Based on the fixtures, our assumption is that this function - * has to be executed two times. - */ - it('should be called twice', () => { - const callback = jest.fn(); - mapHeaderSearchPaths(project, callback); - - expect(callback.mock.calls).toHaveLength(2); - }); - - it('calls the function with an array of paths, given a project with one', () => { - const callback = jest.fn(); - mapHeaderSearchPaths(project, callback); - - const paths = callback.mock.calls[0][0]; - - expect(paths instanceof Array).toBe(true); - expect(paths).toHaveLength(1); - expect(paths[0]).toBe('"$(inherited)"'); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts b/packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts deleted file mode 100644 index 3308e83a1..000000000 --- a/packages/platform-ios/src/link/__tests__/removeProjectFromLibraries.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addProjectToLibraries from '../addProjectToLibraries'; -import removeProjectFromLibraries from '../removeProjectFromLibraries'; - -const xcode = require('xcode'); -const PbxFile = require('xcode/lib/pbxFile'); -const path = require('path'); -const {last} = require('lodash'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::removeProjectFromLibraries', () => { - beforeEach(() => { - project.parseSync(); - - addProjectToLibraries( - project.pbxGroupByName('Libraries'), - new PbxFile('fakePath'), - ); - }); - - it('should remove file from Libraries group', () => { - const file = new PbxFile('fakePath'); - const libraries = project.pbxGroupByName('Libraries'); - - removeProjectFromLibraries(libraries, file); - - const child = last(libraries.children); - - expect(child.comment).not.toBe(file.basename); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts b/packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts deleted file mode 100644 index 7ea04df4f..000000000 --- a/packages/platform-ios/src/link/__tests__/removeProjectFromProject.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addFileToProject from '../addFileToProject'; -import removeProjectFromProject from '../removeProjectFromProject'; - -const xcode = require('xcode'); -const pbxFile = require('xcode/lib/pbxFile'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); -const filePath = '../__fixtures__/linearGradient.pbxproj'; - -describe('ios::addFileToProject', () => { - beforeEach(() => { - project.parseSync(); - addFileToProject(project, filePath); - }); - - it('should return removed file', () => { - expect( - removeProjectFromProject(project, filePath) instanceof pbxFile, - ).toBeTruthy(); - }); - - it('should remove file from a project', () => { - const file = removeProjectFromProject(project, filePath); - expect(project.pbxFileReferenceSection()[file.fileRef]).not.toBeDefined(); - }); - - // todo(mike): add in .xcodeproj after Xcode modifications so we can test extra - // removals later. - it.todo('should remove file from PBXContainerProxy'); -}); diff --git a/packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts b/packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts deleted file mode 100644 index f48da6480..000000000 --- a/packages/platform-ios/src/link/__tests__/removeSharedLibrary.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import addSharedLibraries from '../addSharedLibraries'; -import removeSharedLibraries from '../removeSharedLibraries'; -import getGroup from '../getGroup'; - -const xcode = require('xcode'); -const path = require('path'); - -const project = xcode.project( - path.join(__dirname, '../__fixtures__/project.pbxproj'), -); - -describe('ios::removeSharedLibraries', () => { - beforeEach(() => { - project.parseSync(); - addSharedLibraries(project, ['libc++.tbd', 'libz.tbd']); - }); - - it('should remove only the specified shared library', () => { - removeSharedLibraries(project, ['libc++.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(1); - expect(frameworksGroup.children[0].comment).toEqual('libz.tbd'); - }); - - it('should ignore missing shared libraries', () => { - removeSharedLibraries(project, ['libxml2.tbd']); - - const frameworksGroup = getGroup(project, 'Frameworks'); - expect(frameworksGroup.children).toHaveLength(2); - }); -}); diff --git a/packages/platform-ios/src/link/__tests__/writePlist.test.ts b/packages/platform-ios/src/link/__tests__/writePlist.test.ts deleted file mode 100644 index 7393ee39c..000000000 --- a/packages/platform-ios/src/link/__tests__/writePlist.test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getPlistPath from '../getPlistPath'; -import writePlist from '../writePlist'; - -jest.mock('path'); -jest.mock('fs'); -jest.mock('../getPlistPath', () => jest.fn(() => null)); - -const {readFileSync} = jest.requireActual('fs'); -const fs = require('fs'); - -const xcode = require('xcode'); - -const realPath = jest.requireActual('path'); -const projectPath = realPath.join(__dirname, '../__fixtures__/project.pbxproj'); -const infoPlistPath = realPath.join(__dirname, '../__fixtures__/Info.plist'); - -fs.readFileSync = jest.fn(() => readFileSync(projectPath).toString()); - -const {writeFileSync} = fs; -fs.writeFileSync = jest.fn(writeFileSync); - -const project = xcode.project('/Basic/project.pbxproj'); - -const plist = { - CFBundleDevelopmentRegion: 'en', - UISupportedInterfaceOrientations: ['UIInterfaceOrientationPortrait'], -}; - -describe('ios::writePlist', () => { - beforeEach(() => { - project.parseSync(); - fs.writeFileSync.mockReset(); - }); - - it('should write a `.plist` file', () => { - // @ts-ignore - getPlistPath.mockImplementation(() => '/Basic/Info.plist'); - writePlist(project, '/', plist); - const infoPlist = readFileSync(infoPlistPath).toString(); - expect(fs.writeFileSync).toHaveBeenCalledWith( - '/Basic/Info.plist', - infoPlist, - ); - }); - - it('when plistPath is null it should return null', () => { - // @ts-ignore - getPlistPath.mockImplementation(() => null); - expect(writePlist(project, '/', plist)).toBeNull(); - expect(fs.writeFileSync).not.toHaveBeenCalled(); - }); -}); diff --git a/packages/platform-ios/src/link/addFileToProject.ts b/packages/platform-ios/src/link/addFileToProject.ts deleted file mode 100644 index 6d5162c10..000000000 --- a/packages/platform-ios/src/link/addFileToProject.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import PbxFile from 'xcode/lib/pbxFile'; - -/** - * Given xcodeproj and filePath, it creates new file - * from path provided, adds it to the project - * and returns newly created instance of a file - */ -export default function addFileToProject(project: any, filePath: string) { - const file = new PbxFile(filePath); - file.uuid = project.generateUuid(); - file.fileRef = project.generateUuid(); - project.addToPbxFileReferenceSection(file); - return file; -} diff --git a/packages/platform-ios/src/link/addProjectToLibraries.ts b/packages/platform-ios/src/link/addProjectToLibraries.ts deleted file mode 100644 index 8c7af5fd8..000000000 --- a/packages/platform-ios/src/link/addProjectToLibraries.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Given an array of xcodeproj libraries and pbxFile, - * it appends it to that group - * - * Important: That function mutates `libraries` and it's not pure. - * It's mainly due to limitations of `xcode` library. - */ -export default function addProjectToLibraries( - libraries: {children: Array<{value: string; comment: string}>}, - file: {fileRef: string; basename: string}, -) { - return libraries.children.push({ - value: file.fileRef, - comment: file.basename, - }); -} diff --git a/packages/platform-ios/src/link/addSharedLibraries.ts b/packages/platform-ios/src/link/addSharedLibraries.ts deleted file mode 100644 index 652243125..000000000 --- a/packages/platform-ios/src/link/addSharedLibraries.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import createGroupWithMessage from './createGroupWithMessage'; - -export default function addSharedLibraries( - project: any, - libraries: Array, -) { - if (!libraries.length) { - return; - } - - // Create a Frameworks group if necessary. - createGroupWithMessage(project, 'Frameworks'); - - const target = project.getFirstTarget().uuid; - - for (const name of libraries) { - project.addFramework(name, {target}); - } -} diff --git a/packages/platform-ios/src/link/addToHeaderSearchPaths.ts b/packages/platform-ios/src/link/addToHeaderSearchPaths.ts deleted file mode 100644 index e397f4b85..000000000 --- a/packages/platform-ios/src/link/addToHeaderSearchPaths.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import mapHeaderSearchPaths from './mapHeaderSearchPaths'; -import {logger} from '@react-native-community/cli-tools'; - -export default function addToHeaderSearchPaths(project: any, path: string) { - logger.debug(`Adding ${path} to header search paths`); - mapHeaderSearchPaths(project, (searchPaths) => searchPaths.concat(path)); -} diff --git a/packages/platform-ios/src/link/common/isInstalled.ts b/packages/platform-ios/src/link/common/isInstalled.ts deleted file mode 100644 index 9afd3c660..000000000 --- a/packages/platform-ios/src/link/common/isInstalled.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalledIOS from '../isInstalled'; -import isInstalledPods from '../../link-pods/isInstalled'; -import { - IOSProjectConfig, - IOSDependencyConfig, -} from '@react-native-community/cli-types'; - -export default function isInstalled( - projectConfig: IOSProjectConfig, - // FIXME: name is never used - _name: string | undefined, - dependencyConfig: IOSDependencyConfig, -) { - return ( - isInstalledIOS(projectConfig, dependencyConfig) || - isInstalledPods(projectConfig, dependencyConfig) - ); -} diff --git a/packages/platform-ios/src/link/common/registerNativeModule.ts b/packages/platform-ios/src/link/common/registerNativeModule.ts deleted file mode 100644 index 8b2d21b94..000000000 --- a/packages/platform-ios/src/link/common/registerNativeModule.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import registerDependencyIOS from '../registerNativeModule'; -import registerDependencyPods from '../../link-pods/registerNativeModule'; - -export default function registerNativeModule( - name: string, - dependencyConfig: IOSDependencyConfig, - // FIXME: Params is never used - _params: any | undefined, - projectConfig: IOSProjectConfig, -) { - if (projectConfig.podfile && dependencyConfig.podspecPath) { - registerDependencyPods(name, dependencyConfig.podspecPath, projectConfig); - } else { - registerDependencyIOS(dependencyConfig, projectConfig); - } -} diff --git a/packages/platform-ios/src/link/common/unregisterNativeModule.ts b/packages/platform-ios/src/link/common/unregisterNativeModule.ts deleted file mode 100644 index 39b0fcd26..000000000 --- a/packages/platform-ios/src/link/common/unregisterNativeModule.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {compact} from 'lodash'; -import isInstalledIOS from '../isInstalled'; -import isInstalledPods from '../../link-pods/isInstalled'; -import unregisterDependencyIOS from '../unregisterNativeModule'; -import unregisterDependencyPods from '../../link-pods/unregisterNativeModule'; -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; - -export default function unregisterNativeModule( - _name: string, - dependencyConfig: IOSDependencyConfig, - projectConfig: IOSProjectConfig, - // FIXME: Add type signature here - otherDependencies: Array, -) { - const isIosInstalled = isInstalledIOS(projectConfig, dependencyConfig); - const isPodInstalled = isInstalledPods(projectConfig, dependencyConfig); - if (isIosInstalled) { - const iOSDependencies = compact( - otherDependencies.map((d) => d.platforms.ios), - ); - unregisterDependencyIOS(dependencyConfig, projectConfig, iOSDependencies); - } else if (isPodInstalled) { - unregisterDependencyPods(dependencyConfig, projectConfig); - } -} diff --git a/packages/platform-ios/src/link/copyAssets.ts b/packages/platform-ios/src/link/copyAssets.ts deleted file mode 100644 index d965ef4b0..000000000 --- a/packages/platform-ios/src/link/copyAssets.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; -import xcode from 'xcode'; -import createGroupWithMessage from './createGroupWithMessage'; -import getPlist from './getPlist'; -import writePlist from './writePlist'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; -import {IOSProjectConfig} from '@react-native-community/cli-types'; - -/** - * This function works in a similar manner to its Android version, - * except it does not copy fonts but creates Xcode Group references - */ -export default function linkAssetsIOS( - files: Array, - projectConfig: IOSProjectConfig, -) { - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const assets = groupFilesByType(files); - const plist = getPlist(project, projectConfig.sourceDir); - - createGroupWithMessage(project, 'Resources'); - - function addResourceFile(f: Array) { - return (f || []) - .map((asset) => { - logger.debug(`Linking asset ${asset}`); - return project.addResourceFile( - path.relative(projectConfig.sourceDir, asset), - {target: project.getFirstTarget().uuid}, - ); - }) - .filter(Boolean) // xcode returns false if file is already there - .map((file) => file.basename); - } - - addResourceFile(assets.image); - - const fonts = addResourceFile(assets.font); - - // @ts-ignore Type mismatch with the lib - const existingFonts = plist.UIAppFonts || []; - const allFonts = [...existingFonts, ...fonts]; - // @ts-ignore Type mismatch with the lib - plist.UIAppFonts = Array.from(new Set(allFonts)); // use Set to dedupe w/existing - - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); - - writePlist(project, projectConfig.sourceDir, plist); -} diff --git a/packages/platform-ios/src/link/createGroup.ts b/packages/platform-ios/src/link/createGroup.ts deleted file mode 100644 index 422d46921..000000000 --- a/packages/platform-ios/src/link/createGroup.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import getGroup from './getGroup'; - -const hasGroup = ( - pbxGroup: {children: Array<{comment: string}>}, - name: string, -) => pbxGroup.children.find((group) => group.comment === name); - -/** - * Given project and path of the group, it deeply creates a given group - * making all outer groups if necessary - * - * Returns newly created group - */ -export default function createGroup(project: any, path: string) { - return path.split('/').reduce((group, name) => { - if (!hasGroup(group, name)) { - const uuid = project.pbxCreateGroup(name, '""'); - - group.children.push({ - value: uuid, - comment: name, - }); - } - - return project.pbxGroupByName(name); - }, getGroup(project)); -} diff --git a/packages/platform-ios/src/link/createGroupWithMessage.ts b/packages/platform-ios/src/link/createGroupWithMessage.ts deleted file mode 100644 index c569e6783..000000000 --- a/packages/platform-ios/src/link/createGroupWithMessage.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {logger} from '@react-native-community/cli-tools'; -import createGroup from './createGroup'; -import getGroup from './getGroup'; - -/** - * Given project and path of the group, it checks if a group exists at that path, - * and deeply creates a group for that path if its does not already exist. - * - * Returns the existing or newly created group - */ -export default function createGroupWithMessage(project: any, path: string) { - let group = getGroup(project, path); - - if (!group) { - group = createGroup(project, path); - - logger.warn( - `Group '${path}' does not exist in your Xcode project. We have created it automatically for you.`, - ); - } - - return group; -} diff --git a/packages/platform-ios/src/link/getBuildProperty.ts b/packages/platform-ios/src/link/getBuildProperty.ts deleted file mode 100644 index 3eb7e9c6a..000000000 --- a/packages/platform-ios/src/link/getBuildProperty.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Gets build property from the main target build section - * - * It differs from the project.getBuildProperty exposed by xcode in the way that: - * - it only checks for build property in the main target `Debug` section - * - `xcode` library iterates over all build sections and because it misses - * an early return when property is found, it will return undefined/wrong value - * when there's another build section typically after the one you want to access - * without the property defined (e.g. CocoaPods sections appended to project - * miss INFOPLIST_FILE), see: https://github.com/alunny/node-xcode/blob/master/lib/pbxProject.js#L1765 - */ -export default function getBuildProperty(project: any, prop: string) { - const target = project.getFirstTarget().firstTarget; - const config = project.pbxXCConfigurationList()[ - target.buildConfigurationList - ]; - const buildSection = project.pbxXCBuildConfigurationSection()[ - config.buildConfigurations[0].value - ]; - - return buildSection.buildSettings[prop]; -} diff --git a/packages/platform-ios/src/link/getGroup.ts b/packages/platform-ios/src/link/getGroup.ts deleted file mode 100644 index 8b0a27fea..000000000 --- a/packages/platform-ios/src/link/getGroup.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -const getFirstProject = (project: any) => - project.getFirstProject().firstProject; - -const findGroup = ( - groups: {children: Array<{comment: string; value: string}>}, - name: string, -) => groups.children.find((group) => group.comment === name); - -/** - * Returns group from .xcodeproj if one exists, null otherwise - * - * Unlike node-xcode `pbxGroupByName` - it does not return `first-matching` - * group if multiple groups with the same name exist - * - * If path is not provided, it returns top-level group - */ -export default function getGroup(project: any, path?: string) { - const firstProject = getFirstProject(project); - - let groups = project.getPBXGroupByKey(firstProject.mainGroup); - - if (!path) { - return groups; - } - - for (const name of path.split('/')) { - const foundGroup = findGroup(groups, name); - - if (foundGroup) { - groups = project.getPBXGroupByKey(foundGroup.value); - } else { - groups = null; - break; - } - } - - return groups; -} diff --git a/packages/platform-ios/src/link/getHeaderSearchPath.ts b/packages/platform-ios/src/link/getHeaderSearchPath.ts deleted file mode 100644 index 119450e59..000000000 --- a/packages/platform-ios/src/link/getHeaderSearchPath.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import {posix as path} from 'path'; -import {last, union} from 'lodash'; - -/** - * Given an array of directories, it returns the one that contains - * all the other directories in a given array inside it. - * - * Example: - * Given an array of directories: ['/Users/Kureev/a', '/Users/Kureev/b'] - * the returned folder is `/Users/Kureev` - * - * Check `getHeaderSearchPath.spec.js` for more use-cases. - */ -const getOuterDirectory = (directories: Array) => - directories.reduce((topDir, currentDir) => { - const currentFolders = currentDir.split(path.sep); - const topMostFolders = topDir.split(path.sep); - - if ( - currentFolders.length === topMostFolders.length && - last(currentFolders) !== last(topMostFolders) - ) { - return currentFolders.slice(0, -1).join(path.sep); - } - - return currentFolders.length < topMostFolders.length ? currentDir : topDir; - }); - -/** - * Given an array of headers it returns search path so Xcode can resolve - * headers when referenced like below: - * ``` - * #import "CodePush.h" - * ``` - * If all files are located in one directory (directories.length === 1), - * we simply return a relative path to that location. - * - * Otherwise, we loop through them all to find the outer one that contains - * all the headers inside. That location is then returned with /** appended at - * the end so Xcode marks that location as `recursive` and will look inside - * every folder of it to locate correct headers. - */ -export default function getHeaderSearchPath( - sourceDir: string, - headers: Array, -) { - const directories = union(headers.map(path.dirname)); - - return directories.length === 1 - ? `"$(SRCROOT)/${path.relative(sourceDir, directories[0])}"` - : `"$(SRCROOT)/${path.relative( - sourceDir, - getOuterDirectory(directories), - )}/**"`; -} diff --git a/packages/platform-ios/src/link/getHeadersInFolder.ts b/packages/platform-ios/src/link/getHeadersInFolder.ts deleted file mode 100644 index 8e2b8b8a1..000000000 --- a/packages/platform-ios/src/link/getHeadersInFolder.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import glob from 'glob'; -import path from 'path'; - -const GLOB_EXCLUDE_PATTERN = [ - 'node_modules/**', - 'Pods/**', - 'Examples/**', - 'examples/**', -]; - -/** - * Given folder, it returns an array of all header files - * inside it, ignoring node_modules and examples - */ -export default function getHeadersInFolder(folder: string) { - return glob - .sync('**/*.h', { - cwd: folder, - nodir: true, - ignore: GLOB_EXCLUDE_PATTERN, - }) - .map((file) => path.join(folder, file)); -} diff --git a/packages/platform-ios/src/link/getPlist.ts b/packages/platform-ios/src/link/getPlist.ts deleted file mode 100644 index f7bb3c497..000000000 --- a/packages/platform-ios/src/link/getPlist.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import plistParser from 'plist'; -import fs from 'fs'; -import getPlistPath from './getPlistPath'; - -/** - * Returns Info.plist located in the iOS project - * - * Returns `null` if INFOPLIST_FILE is not specified. - */ -export default function getPlist(project: any, sourceDir: string) { - const plistPath = getPlistPath(project, sourceDir); - - if (!plistPath || !fs.existsSync(plistPath)) { - return null; - } - - return plistParser.parse(fs.readFileSync(plistPath, 'utf-8')); -} diff --git a/packages/platform-ios/src/link/getPlistPath.ts b/packages/platform-ios/src/link/getPlistPath.ts deleted file mode 100644 index ce8cafd7d..000000000 --- a/packages/platform-ios/src/link/getPlistPath.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import path from 'path'; -import getBuildProperty from './getBuildProperty'; - -export default function getPlistPath(project: string, sourceDir: string) { - const plistFile = getBuildProperty(project, 'INFOPLIST_FILE'); - - if (!plistFile) { - return null; - } - - return path.join( - sourceDir, - plistFile.replace(/"/g, '').replace('$(SRCROOT)', ''), - ); -} diff --git a/packages/platform-ios/src/link/getTargets.ts b/packages/platform-ios/src/link/getTargets.ts deleted file mode 100644 index 784c3803d..000000000 --- a/packages/platform-ios/src/link/getTargets.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -interface Target { - value: string; -} - -/** - * Given xcodeproj it returns list of targets - */ -export default function getTargets(project: any) { - const { - firstProject: {targets}, - } = project.getFirstProject(); - const nativeTargetSection = project.pbxNativeTargetSection(); - return targets - .filter((target: Target) => nativeTargetSection[target.value] !== undefined) - .map((target: Target) => { - const key = target.value; - const configurationListId = - nativeTargetSection[key].buildConfigurationList; - const configurationList = project.pbxXCConfigurationList()[ - configurationListId - ]; - const buildConfigurationId = - configurationList.buildConfigurations[0].value; - const buildConfiguration = project.pbxXCBuildConfigurationSection()[ - buildConfigurationId - ]; - return { - uuid: key, - target: nativeTargetSection[key], - name: nativeTargetSection[key].productReference_comment, - isTVOS: - (buildConfiguration.buildSettings.SDKROOT && - buildConfiguration.buildSettings.SDKROOT.indexOf('appletv') !== - -1) || - false, - }; - }); -} diff --git a/packages/platform-ios/src/link/hasLibraryImported.ts b/packages/platform-ios/src/link/hasLibraryImported.ts deleted file mode 100644 index b3637a3e0..000000000 --- a/packages/platform-ios/src/link/hasLibraryImported.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Given an array of libraries already imported and packageName that will be - * added, returns true or false depending on whether the library is already linked - * or not - */ -export default function hasLibraryImported( - libraries: {children: Array<{comment: string}>}, - packageName: string, -) { - return ( - libraries.children.filter((library) => library.comment === packageName) - .length > 0 - ); -} diff --git a/packages/platform-ios/src/link/index.ts b/packages/platform-ios/src/link/index.ts deleted file mode 100644 index 4b38b1556..000000000 --- a/packages/platform-ios/src/link/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import isInstalled from './common/isInstalled'; -import register from './common/registerNativeModule'; -import unregister from './common/unregisterNativeModule'; -import copyAssets from './copyAssets'; -import unlinkAssets from './unlinkAssets'; - -export function getIOSLinkConfig() { - return {isInstalled, register, unregister, copyAssets, unlinkAssets}; -} - -export default getIOSLinkConfig; diff --git a/packages/platform-ios/src/link/isInstalled.ts b/packages/platform-ios/src/link/isInstalled.ts deleted file mode 100644 index 3e9ac3812..000000000 --- a/packages/platform-ios/src/link/isInstalled.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import xcode from 'xcode'; -import getGroup from './getGroup'; -import hasLibraryImported from './hasLibraryImported'; -import { - IOSProjectConfig, - IOSDependencyConfig, -} from '@react-native-community/cli-types'; - -const memo = new Map(); - -/** - * Returns true if `xcodeproj` specified by dependencyConfig is present - * in a top level `libraryFolder` - */ -export default function isInstalled( - projectConfig: IOSProjectConfig, - dependencyConfig: IOSDependencyConfig, -) { - let project; - - if (memo.has(projectConfig.pbxprojPath)) { - project = memo.get(projectConfig.pbxprojPath); - } else { - project = xcode.project(projectConfig.pbxprojPath).parseSync(); - memo.set(projectConfig.pbxprojPath, project); - } - - const libraries = getGroup(project, projectConfig.libraryFolder); - - if (!libraries) { - return false; - } - - return hasLibraryImported(libraries, dependencyConfig.projectName); -} diff --git a/packages/platform-ios/src/link/mapHeaderSearchPaths.ts b/packages/platform-ios/src/link/mapHeaderSearchPaths.ts deleted file mode 100644 index 4bdda1ef2..000000000 --- a/packages/platform-ios/src/link/mapHeaderSearchPaths.ts +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Given Xcode project and path, iterate over all build configurations - * and execute func with HEADER_SEARCH_PATHS from current section - * - * We cannot use builtin addToHeaderSearchPaths method since react-native init does not - * use $(TARGET_NAME) for PRODUCT_NAME, but sets it manually so that method will skip - * that target. - * - * To workaround that issue and make it more bullet-proof for different names, - * we iterate over all configurations and look for `lc++` linker flag to detect - * React Native target. - * - * Important: That function mutates `buildSettings` and it's not pure thus you should - * not rely on its return value - */ -const defaultHeaderPaths = ['"$(inherited)"']; - -export default function headerSearchPathIter( - project: any, - func: (searchPaths: Array) => Array, -) { - const config = project.pbxXCBuildConfigurationSection(); - - Object.keys(config) - .filter((ref) => ref.indexOf('_comment') === -1) - .forEach((ref) => { - const {buildSettings} = config[ref]; - const shouldVisitBuildSettings = - (Array.isArray(buildSettings.OTHER_LDFLAGS) - ? buildSettings.OTHER_LDFLAGS - : [] - ).indexOf('"-lc++"') >= 0; - - if (shouldVisitBuildSettings) { - const searchPaths = buildSettings.HEADER_SEARCH_PATHS - ? [].concat(buildSettings.HEADER_SEARCH_PATHS) - : defaultHeaderPaths; - - buildSettings.HEADER_SEARCH_PATHS = func(searchPaths); - } - }); -} diff --git a/packages/platform-ios/src/link/registerNativeModule.ts b/packages/platform-ios/src/link/registerNativeModule.ts deleted file mode 100644 index e86bc56d3..000000000 --- a/packages/platform-ios/src/link/registerNativeModule.ts +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import xcode from 'xcode'; -import fs from 'fs'; -import path from 'path'; -import {isEmpty} from 'lodash'; -import { - IOSDependencyConfig, - IOSProjectConfig, -} from '@react-native-community/cli-types'; -import addToHeaderSearchPaths from './addToHeaderSearchPaths'; -import getHeadersInFolder from './getHeadersInFolder'; -import getHeaderSearchPath from './getHeaderSearchPath'; -import getTargets from './getTargets'; -import createGroupWithMessage from './createGroupWithMessage'; -import addFileToProject from './addFileToProject'; -import addProjectToLibraries from './addProjectToLibraries'; -import addSharedLibraries from './addSharedLibraries'; -import {logger} from '@react-native-community/cli-tools'; - -/** - * Register native module IOS adds given dependency to project by adding - * its xcodeproj to project libraries as well as attaching static library - * to the first target (the main one) - * - * If library is already linked, this action is a no-op. - */ -export default function registerNativeModuleIOS( - dependencyConfig: IOSDependencyConfig, - projectConfig: IOSProjectConfig, -) { - logger.debug(`Reading ${projectConfig.pbxprojPath}`); - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const dependencyProject = xcode - .project(dependencyConfig.pbxprojPath) - .parseSync(); - - const libraries = createGroupWithMessage( - project, - projectConfig.libraryFolder, - ); - const file = addFileToProject( - project, - path.relative(projectConfig.sourceDir, dependencyConfig.projectPath), - ); - - const targets = getTargets(project); - - addProjectToLibraries(libraries, file); - - getTargets(dependencyProject).forEach((product: any) => { - let i; - if (!product.isTVOS) { - for (i = 0; i < targets.length; i++) { - if (!targets[i].isTVOS) { - logger.debug(`Adding ${product.name} to ${targets[i].target.name}`); - project.addStaticLibrary(product.name, { - target: targets[i].uuid, - }); - } - } - } - - if (product.isTVOS) { - for (i = 0; i < targets.length; i++) { - if (targets[i].isTVOS) { - logger.debug(`Adding ${product.name} to ${targets[i].target.name}`); - project.addStaticLibrary(product.name, { - target: targets[i].uuid, - }); - } - } - } - }); - - addSharedLibraries(project, dependencyConfig.sharedLibraries); - - const headers = getHeadersInFolder(dependencyConfig.folder); - if (!isEmpty(headers)) { - addToHeaderSearchPaths( - project, - getHeaderSearchPath(projectConfig.sourceDir, headers), - ); - } - - logger.debug(`Writing changes to ${projectConfig.pbxprojPath}`); - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); -} diff --git a/packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts b/packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts deleted file mode 100644 index 79a946967..000000000 --- a/packages/platform-ios/src/link/removeFromHeaderSearchPaths.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import mapHeaderSearchPaths from './mapHeaderSearchPaths'; -import {logger} from '@react-native-community/cli-tools'; - -/** - * Given Xcode project and absolute path, it makes sure there are no headers referring to it - */ -export default function addToHeaderSearchPaths(project: any, path: string) { - logger.debug(`Removing ${path} from header search paths`); - mapHeaderSearchPaths(project, (searchPaths) => - searchPaths.filter((searchPath) => searchPath !== path), - ); -} diff --git a/packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts b/packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts deleted file mode 100644 index 6ca7e4356..000000000 --- a/packages/platform-ios/src/link/removeFromPbxItemContainerProxySection.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * For all files that are created and referenced from another `.xcodeproj` - - * a new PBXItemContainerProxy is created that contains `containerPortal` value - * which equals to xcodeproj file.uuid from PBXFileReference section. - */ -export default function removeFromPbxItemContainerProxySection( - project: any, - file: any, -) { - const section = project.hash.project.objects.PBXContainerItemProxy; - - for (const key of Object.keys(section)) { - if (section[key].containerPortal === file.uuid) { - delete section[key]; - } - } -} diff --git a/packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts b/packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts deleted file mode 100644 index 214cb98de..000000000 --- a/packages/platform-ios/src/link/removeFromPbxReferenceProxySection.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * Every file added to the project from another project is attached to - * `PBXItemContainerProxy` through `PBXReferenceProxy`. - */ -export default function removeFromPbxReferenceProxySection( - project: any, - file: any, -) { - const section = project.hash.project.objects.PBXReferenceProxy; - - for (const key of Object.keys(section)) { - if (section[key].path === file.basename) { - delete section[key]; - } - } -} diff --git a/packages/platform-ios/src/link/removeFromProjectReferences.ts b/packages/platform-ios/src/link/removeFromProjectReferences.ts deleted file mode 100644 index f2ba588e9..000000000 --- a/packages/platform-ios/src/link/removeFromProjectReferences.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -/** - * For each file (.xcodeproj), there's an entry in `projectReferences` created - * that has two entries - `ProjectRef` - reference to a file.uuid and - * `ProductGroup` - uuid of a Products group. - * - * When projectReference is found - it's deleted and the removed value is returned - * so that ProductGroup in PBXGroup section can be removed as well. - * - * Otherwise returns null - */ -export default function removeFromProjectReferences(project: any, file: any) { - const {firstProject} = project.getFirstProject(); - - const projectRef = firstProject.projectReferences.find( - (item: any) => item.ProjectRef === file.uuid, - ); - - if (!projectRef) { - return null; - } - - firstProject.projectReferences.splice( - firstProject.projectReferences.indexOf(projectRef), - 1, - ); - - return projectRef; -} diff --git a/packages/platform-ios/src/link/removeFromStaticLibraries.ts b/packages/platform-ios/src/link/removeFromStaticLibraries.ts deleted file mode 100644 index 264ec34f2..000000000 --- a/packages/platform-ios/src/link/removeFromStaticLibraries.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import PbxFile from 'xcode/lib/pbxFile'; -import removeFromPbxReferenceProxySection from './removeFromPbxReferenceProxySection'; - -/** - * Removes file from static libraries - * - * Similar to `node-xcode` addStaticLibrary - */ -export default function removeFromStaticLibraries( - project: any, - path: string, - opts: {[key: string]: any}, -) { - const file = new PbxFile(path); - - file.target = opts ? opts.target : undefined; - - project.removeFromPbxFileReferenceSection(file); - project.removeFromPbxBuildFileSection(file); - project.removeFromPbxFrameworksBuildPhase(file); - project.removeFromLibrarySearchPaths(file); - removeFromPbxReferenceProxySection(project, file); - - return file; -} diff --git a/packages/platform-ios/src/link/removeProductGroup.ts b/packages/platform-ios/src/link/removeProductGroup.ts deleted file mode 100644 index 75cfd52e5..000000000 --- a/packages/platform-ios/src/link/removeProductGroup.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function removeProductGroup(project: any, productGroupId: any) { - const section = project.hash.project.objects.PBXGroup; - - for (const key of Object.keys(section)) { - if (key === productGroupId) { - delete section[key]; - } - } -} diff --git a/packages/platform-ios/src/link/removeProjectFromLibraries.ts b/packages/platform-ios/src/link/removeProjectFromLibraries.ts deleted file mode 100644 index b4b2e1760..000000000 --- a/packages/platform-ios/src/link/removeProjectFromLibraries.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/** - * Given an array of xcodeproj libraries and pbxFile, - * it removes it from that group by comparing basenames - * - * Important: That function mutates `libraries` and it's not pure. - * It's mainly due to limitations of `xcode` library. - */ -export default function removeProjectFromLibraries( - libraries: {children: Array<{comment: string}>}, - file: {basename: string}, -) { - libraries.children = libraries.children.filter( - (library) => library.comment !== file.basename, - ); -} diff --git a/packages/platform-ios/src/link/removeProjectFromProject.ts b/packages/platform-ios/src/link/removeProjectFromProject.ts deleted file mode 100644 index a22c311c1..000000000 --- a/packages/platform-ios/src/link/removeProjectFromProject.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import PbxFile from 'xcode/lib/pbxFile'; -import removeFromPbxItemContainerProxySection from './removeFromPbxItemContainerProxySection'; -import removeFromProjectReferences from './removeFromProjectReferences'; -import removeProductGroup from './removeProductGroup'; - -/** - * Given xcodeproj and filePath, it creates new file - * from path provided and removes it. That operation is required since - * underlying method requires PbxFile instance to be passed (it does not - * have to have uuid or fileRef defined since it will do equality check - * by path) - * - * Returns removed file (that one will have UUID) - */ -export default function removeProjectFromProject( - project: any, - filePath: string, -) { - const file = project.removeFromPbxFileReferenceSection(new PbxFile(filePath)); - const projectRef = removeFromProjectReferences(project, file); - - if (projectRef) { - removeProductGroup(project, projectRef.ProductGroup); - } - - removeFromPbxItemContainerProxySection(project, file); - - return file; -} diff --git a/packages/platform-ios/src/link/removeSharedLibraries.ts b/packages/platform-ios/src/link/removeSharedLibraries.ts deleted file mode 100644 index 540f2cf35..000000000 --- a/packages/platform-ios/src/link/removeSharedLibraries.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -export default function removeSharedLibraries( - project: any, - libraries: Array, -) { - if (!libraries.length) { - return; - } - - const target = project.getFirstTarget().uuid; - - for (const name of libraries) { - project.removeFramework(name, {target}); - } -} diff --git a/packages/platform-ios/src/link/unlinkAssets.ts b/packages/platform-ios/src/link/unlinkAssets.ts deleted file mode 100644 index 7f25cd61d..000000000 --- a/packages/platform-ios/src/link/unlinkAssets.ts +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import fs from 'fs'; -import path from 'path'; -import xcode from 'xcode'; -import {difference} from 'lodash'; - -import getPlist from './getPlist'; -import writePlist from './writePlist'; -import {logger, groupFilesByType} from '@react-native-community/cli-tools'; -import {IOSProjectConfig} from '@react-native-community/cli-types'; - -/** - * Unlinks assets from iOS project. Removes references for fonts from `Info.plist` - * fonts provided by application and from `Resources` group - */ -export default function unlinkAssetsIOS( - files: any, - projectConfig: IOSProjectConfig, -) { - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const assets = groupFilesByType(files); - const plist = getPlist(project, projectConfig.sourceDir); - - if (!plist) { - logger.error( - 'Could not locate "Info.plist" file. Check if your project has "INFOPLIST_FILE" set properly', - ); - return; - } - - if (!project.pbxGroupByName('Resources')) { - logger.error( - 'Group "Resources" does not exist in your Xcode project. There is nothing to unlink.', - ); - return; - } - - const removeResourceFiles = (f: Array = []) => - (f || []) - .map((asset) => { - logger.debug(`Unlinking asset ${asset}`); - return project.removeResourceFile( - path.relative(projectConfig.sourceDir, asset), - {target: project.getFirstTarget().uuid}, - ); - }) - .map((file) => file.basename); - - removeResourceFiles(assets.image); - - const fonts = removeResourceFiles(assets.font); - - // @ts-ignore Type mismatch - plist.UIAppFonts = difference(plist.UIAppFonts || [], fonts); - - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); - - writePlist(project, projectConfig.sourceDir, plist); -} diff --git a/packages/platform-ios/src/link/unregisterNativeModule.ts b/packages/platform-ios/src/link/unregisterNativeModule.ts deleted file mode 100644 index 57192354f..000000000 --- a/packages/platform-ios/src/link/unregisterNativeModule.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import xcode from 'xcode'; -import path from 'path'; -import fs from 'fs'; -import {difference, isEmpty} from 'lodash'; - -import getGroup from './getGroup'; -import getTargets from './getTargets'; -import getHeadersInFolder from './getHeadersInFolder'; -import getHeaderSearchPath from './getHeaderSearchPath'; -import removeProjectFromProject from './removeProjectFromProject'; -import removeProjectFromLibraries from './removeProjectFromLibraries'; -import removeFromStaticLibraries from './removeFromStaticLibraries'; -import removeFromHeaderSearchPaths from './removeFromHeaderSearchPaths'; -import removeSharedLibraries from './removeSharedLibraries'; -import {logger} from '@react-native-community/cli-tools'; -import { - IOSDependencyConfig, - IOSProjectConfig, - IOSProjectParams, -} from '@react-native-community/cli-types'; - -/** - * Unregister native module IOS - * - * If library is already unlinked, this action is a no-op. - */ -export default function unregisterNativeModule( - dependencyConfig: IOSDependencyConfig, - projectConfig: IOSProjectConfig, - iOSDependencies: Array, -) { - logger.debug(`Reading ${projectConfig.pbxprojPath}`); - const project = xcode.project(projectConfig.pbxprojPath).parseSync(); - const dependencyProject = xcode - .project(dependencyConfig.pbxprojPath) - .parseSync(); - - const libraries = getGroup(project, projectConfig.libraryFolder); - - const file = removeProjectFromProject( - project, - path.relative(projectConfig.sourceDir, dependencyConfig.projectPath), - ); - - removeProjectFromLibraries(libraries, file); - - getTargets(dependencyProject).forEach((target: any) => { - logger.debug( - `Removing ${target.name} from ${ - project.getFirstTarget().firstTarget.name - }`, - ); - removeFromStaticLibraries(project, target.name, { - target: project.getFirstTarget().uuid, - }); - }); - - const sharedLibraries = difference( - dependencyConfig.sharedLibraries, - iOSDependencies.reduce( - (libs, dependency) => libs.concat(dependency.sharedLibraries), - projectConfig.sharedLibraries, - ), - ); - - removeSharedLibraries(project, sharedLibraries); - - const headers = getHeadersInFolder(dependencyConfig.folder); - if (!isEmpty(headers)) { - removeFromHeaderSearchPaths( - project, - getHeaderSearchPath(projectConfig.sourceDir, headers), - ); - } - - logger.debug(`Writing changes to ${projectConfig.pbxprojPath}`); - fs.writeFileSync(projectConfig.pbxprojPath, project.writeSync()); -} diff --git a/packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts b/packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts deleted file mode 100644 index 9aac5d0d8..000000000 --- a/packages/platform-ios/src/link/warnAboutManuallyLinkedLibs.ts +++ /dev/null @@ -1,50 +0,0 @@ -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import getLinkConfig from './index'; - -// TODO: move to cli-tools once platform-ios and platform-android are migrated -// to TS and unify with Android implementation -export default function warnAboutManuallyLinkedLibs( - config: Config, - platform: string = 'ios', - linkConfig: ReturnType< - Config['platforms']['ios']['linkConfig'] - > = getLinkConfig(), -) { - let deps: Array = []; - const projectConfig = config.project[platform]; - - for (let key in config.dependencies) { - const dependency = config.dependencies[key]; - - const dependencyConfig = dependency.platforms[platform]; - if (projectConfig && dependencyConfig) { - const x = linkConfig.isInstalled( - projectConfig, - dependency.name, - dependencyConfig, - ); - deps = deps.concat(x ? dependency.name : []); - } - } - - const installedModules = [...new Set(deps)]; - - if (installedModules.length) { - logger.error( - `React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: \n${installedModules - .map( - (x) => - ` - ${chalk.bold(x)} ${chalk.dim( - `(to unlink run: "react-native unlink ${x}")`, - )}`, - ) - .join( - '\n', - )}\nThis is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink " and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.\nRead more about autolinking: ${chalk.dim.underline( - 'https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', - )}`, - ); - } -} diff --git a/packages/platform-ios/src/link/warnAboutPodInstall.ts b/packages/platform-ios/src/link/warnAboutPodInstall.ts deleted file mode 100644 index 1f06fc277..000000000 --- a/packages/platform-ios/src/link/warnAboutPodInstall.ts +++ /dev/null @@ -1,29 +0,0 @@ -import path from 'path'; -import chalk from 'chalk'; -import {logger} from '@react-native-community/cli-tools'; -import {Config} from '@react-native-community/cli-types'; -import getDependenciesFromPodfileLock from '../link-pods/getDependenciesFromPodfileLock'; - -export default function warnAboutPodInstall(config: Config) { - const podLockDeps = getDependenciesFromPodfileLock( - `${config.project.ios!.podfile}.lock`, - ); - const podDeps = Object.keys(config.dependencies) - .map((depName) => { - const dependency = config.dependencies[depName].platforms.ios; - return dependency && dependency.podspecPath - ? path.basename(dependency.podspecPath).replace(/\.podspec/, '') - : ''; - }) - .filter(Boolean); - - const missingPods = podDeps.filter((podDep) => !podLockDeps.includes(podDep)); - - if (missingPods.length) { - logger.error( - `Could not find the following native modules: ${missingPods - .map((pod) => chalk.bold(pod)) - .join(', ')}. Did you forget to run "${chalk.bold('pod install')}" ?`, - ); - } -} diff --git a/packages/platform-ios/src/link/writePlist.ts b/packages/platform-ios/src/link/writePlist.ts deleted file mode 100644 index 52b002d55..000000000 --- a/packages/platform-ios/src/link/writePlist.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import plistParser, {PlistValue} from 'plist'; -import fs from 'fs'; -import getPlistPath from './getPlistPath'; - -/** - * Writes to Info.plist located in the iOS project - * - * Returns `null` if INFOPLIST_FILE is not specified or file is non-existent. - */ -export default function writePlist( - project: any, - sourceDir: string, - plist: PlistValue | null, -) { - const plistPath = getPlistPath(project, sourceDir); - - if (!plistPath) { - return null; - } - - // We start with an offset of -1, because Xcode maintains a custom - // indentation of the plist. - // Ref: https://github.com/facebook/react-native/issues/11668 - return fs.writeFileSync( - plistPath, - // @ts-ignore Type mismatch - `${plistParser.build(plist, {indent: '\t', offset: -1})}\n`, - ); -} From 0ae9eea92dba07950ad2c696cc34982c613fa1a1 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 27 Jan 2022 13:33:21 +0100 Subject: [PATCH 02/39] chore: further removal --- docs/configuration.md | 106 ----------- docs/dependencies.md | 83 +------- docs/platforms.md | 179 ++---------------- .../src/__tests__/findAssets-test.ts | 51 ----- packages/cli-config/src/commands/config.ts | 9 +- packages/cli-config/src/findAssets.ts | 28 --- packages/cli-config/src/loadConfig.ts | 7 - packages/cli-config/src/readConfigFromDisk.ts | 3 - packages/cli-config/src/schema.ts | 21 -- packages/cli-types/src/android.ts | 35 ++-- packages/cli-types/src/index.ts | 102 +++------- packages/cli-types/src/ios.ts | 74 +------- packages/platform-android/src/config/index.ts | 47 +---- .../platform-ios/src/config/getPodspecName.ts | 12 -- packages/platform-ios/src/config/index.ts | 45 ++--- 15 files changed, 91 insertions(+), 711 deletions(-) delete mode 100644 packages/cli-config/src/__tests__/findAssets-test.ts delete mode 100644 packages/cli-config/src/findAssets.ts delete mode 100644 packages/platform-ios/src/config/getPodspecName.ts diff --git a/docs/configuration.md b/docs/configuration.md index 8b66e9529..b2d6cd7bf 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2,8 +2,6 @@ React Native CLI has a configuration mechanism that allows changing its behavior and providing additional features. -> Note: Configuring CLI used to be possible via `rn-cli.config.js` (that has been renamed to `metro.config.js`) and never documented `rnpm` entry on the `package.json`. We have provided migration guides where possible. - React Native CLI can be configured by creating a `react-native.config.js` at the root of the project. Depending on the type of a package, the set of valid properties is different. Check the documentation for @@ -14,107 +12,3 @@ Check the documentation for - [plugins](./plugins.md) to learn more about different types of configuration and features available. - -## Migration guide - -`"rnpm"` is deprecated and support for it is removed since v4.x of the CLI. - -> **Important**: Proceed further only if your project uses `"rnpm"` in `package.json`. - -There are different kinds of React Native projects, including apps, libraries and platforms. For each we prepared a brief "before & after" of the configuration shape with legacy `"rnpm"` and current `react-native.config.js`. Please mind that all configuration entries are optional. - -### Apps - -`package.json` entry: - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"], - "plugin": "./path-to-commands.js" - } -} -``` - -becomes `react-native.config.js` - -```js -module.exports = { - project: { - ios: {}, - android: {}, // grouped into "project" - }, - assets: ['./path-to-assets'], // stays the same - commands: require('./path-to-commands.js'), // formerly "plugin", returns an array of commands -}; -``` - -### Libraries - -`package.json` entry: - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"], - "hooks": { - "prelink": "./path-to-a-prelink-hook" - } - } -} -``` - -becomes `react-native.config.js`: - -```js -module.exports = { - // config for a library is scoped under "dependency" key - dependency: { - platforms: { - ios: {}, - android: {}, // projects are grouped into "platforms" - }, - assets: ['./path-to-assets'], // stays the same - // hooks are considered anti-pattern, please avoid them - hooks: { - prelink: './path-to-a-prelink-hook', - }, - }, -}; -``` - -You'll find more details in [dependencies](./dependencies.md) docs. - -### Out-of-tree platforms - -`package.json` entry: - -```json -{ - "rnpm": { - "haste": { - "platforms": ["windows"], - "providesModuleNodeModules": ["react-native-windows"] - }, - "platform": "./local-cli/platform.js" - } -} -``` - -becomes `react-native.config.js` - -```js -module.exports = { - platforms: { - // grouped under "platforms" entry - windows: require('./local-cli/platform.js').windows, - }, - // "haste" is no longer needed -}; -``` - -You'll find more details in [platforms](./platforms.md) docs. diff --git a/docs/dependencies.md b/docs/dependencies.md index aed576ad7..814bddcf1 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -6,7 +6,7 @@ For example, `lodash` is a dependency that doesn't have any native code to link. By default, CLI analyses the folder structure inside the dependency and looks for assets and native files to link. This simple heuristic works in most of the cases. -At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly. A dependency can also define additional settings, such as a script to run after linking, in order to support some advanced use-cases. +At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly. ## How does it work? @@ -17,15 +17,14 @@ module.exports = { dependency: { platforms: { ios: { - project: './Custom.xcodeproj' - } - } - assets: ['./assets'] - } + project: './Custom.xcodeproj', + }, + }, + }, }; ``` -> The above configuration informs CLI of the additional assets to link and about a custom project location. +> The above configuration informs CLI about a custom project location. ## Dependency interface @@ -36,15 +35,9 @@ type DependencyConfigT = { platforms: { [key: string]: any; }; - assets: string[]; - hooks: { - [key: string]: string; - }; }; ``` -> Note: This interface is subject to breaking changes. We may consider renaming some keys to simplify the configuration further. If you are going to use it, be prepared to update before we ship a stable 0.60.0 release. - ### platforms A map of specific settings that can be set per platform. The exact shape is always defined by the package that provides given platform. @@ -79,10 +72,6 @@ Custom path to `.xcodeproj`. Custom path to `.podspec` file to use when auto-linking. Example: `node_modules/react-native-module/ios/module.podspec`. -#### platforms.ios.sharedLibraries - -An array of shared iOS libraries to link with the dependency. E.g. `libc++`. This is mostly a requirement of the native code that a dependency ships with. - #### platforms.ios.scriptPhases An array of iOS script phases to add to the project. Specifying a `path` property with a path relative to the dependency root will load the contents of the file at the path as the script contents. @@ -140,63 +129,3 @@ An array of build variants or flavors which will include the dependency. If the A string that defines which method other than `implementation` do you want to use for autolinking inside `build.gradle` i.e: `'embed project(path: ":$dependencyName", configuration: "default")',` - `"dependencyName` will be replaced by the actual package's name. You can achieve the same result by directly defining this key per `dependency` _(without placeholder)_ and it will have higher priority than this option. - -### assets - -An array of assets folders to glob for files to link. - -### hooks - -A map where key is the name of a hook and value is the path to a file to execute. - -For example, `link` command supports `prelink` and `postlink` hooks to run before and after linking is done. - -These are the only ones supported by CLI at the moment. Depending on the packages used in your project, you may find other hooks supported to. - -> Note: This has nothing to do with React Hooks. - -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -> Note: We read `rnpm` configuration to remain backwards-compatible. Dependency maintainers should update their configuration in the nearest future. - -### Changing the configuration - -Properties were renamed. Look at the following example for the differences. - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"], - "hooks": { - "prelink": "./path-to-a-prelink-hook" - } - } -} -``` - -to a `react-native.config.js` - -```js -module.exports = { - dependency: { - platforms: { - ios: {}, - android: {}, - }, - assets: ['./path-to-assets'], - hooks: { - prelink: './path-to-a-prelink-hook', - }, - }, -}; -``` - -### Asking for params while linking has been removed - -If your library needs it, do not upgrade over to the new config format. - -If you want to ask users for additional settings, consider setting a custom `postlink` hook, just like [`react-native-code-push`](https://github.com/Microsoft/react-native-code-push/blob/master/package.json#L53). diff --git a/docs/platforms.md b/docs/platforms.md index 53f3caddd..89bbd58a5 100644 --- a/docs/platforms.md +++ b/docs/platforms.md @@ -17,12 +17,10 @@ const android = require('@react-native-community/cli-platform-android'); module.exports = { platforms: { ios: { - linkConfig: ios.linkConfig, projectConfig: ios.projectConfig, dependencyConfig: ios.dependencyConfig, }, android: { - linkConfig: android.linkConfig, projectConfig: android.projectConfig, dependencyConfig: android.dependencyConfig, }, @@ -41,20 +39,8 @@ At the end, a map of available platforms is passed to the bundler (Metro) to mak ```ts type PlatformConfig = { npmPackageName?: string; - projectConfig: (string, ProjectParams) => ?ProjectConfig, - dependencyConfig: (string, ProjectParams) => ?DependencyConfig, - linkConfig: () => { - isInstalled: (ProjectConfig, string, DependencyConfig) => boolean, - register: (string, DependencyConfig, Object, ProjectConfig) => void, - unregister: ( - string, - DependencyConfig, - ProjectConfig, - Array, - ) => void, - copyAssets: (string[], ProjectConfig) => void, - unlinkAssets: (string[], ProjectConfig) => void, - }, + projectConfig: (string, ProjectParams) => ?ProjectConfig; + dependencyConfig: (string, ProjectParams) => ?DependencyConfig; }; ``` @@ -66,7 +52,7 @@ If this property is not specified, it is assumed that the code in core `react-na ### projectConfig -Returns a project configuration for a given platform or `null`, when no project found. This is later used inside `linkConfig` to perform linking and unlinking. +Returns a project configuration for a given platform or `null`, when no project found. First argument is a root folder where the project is located. @@ -85,38 +71,17 @@ module.exports = { On Android and iOS, this function returns: ```ts -type ProjectConfigIOST = { +type IOSProjectConfig = { sourceDir: string; - folder: string; - pbxprojPath: string; - podfile: null; - podspecPath: null; - projectPath: string; - projectName: string; - libraryFolder: string; - sharedLibraries: Array; - plist: Array; }; -type ProjectConfigAndroidT = { +type AndroidProjectConfig = { sourceDir: string; - isFlat: boolean; - folder: string; - stringsPath: string; - manifestPath: string; - buildGradlePath: string; - settingsGradlePath: string; - assetsPath: string; - mainFilePath: string; packageName: string; - packageFolder: string; - appName: string; dependencyConfiguration?: string; }; ``` -We suggest performing all side-effects inside this function (such as resolving paths to native files) and making `linkConfig` functions pure, operating on provided data. - ### dependencyConfig Similar to [`projectConfig`](#projectconfig) above, but for a dependency of a project. @@ -136,137 +101,17 @@ module.exports = { On Android and iOS, this function returns: ```ts -type DependencyConfigIOST = ProjectConfigIOST; +type IOSDependencyConfig = { + podspecPath: string; + scriptPhases: Array; + configurations: string[]; +}; -type DependencyConfigAndroidT = { +type AndroidDependencyConfig = { sourceDir: string; - folder: string; packageImportPath: string; packageInstance: string; - manifestPath: string; - packageName: string; dependencyConfiguration?: string; + buildTypes: string[]; }; ``` - -### linkConfig - -Returns an object with utilities that are run by the CLI while linking. - -> Note: The following is deprecated and will stop working in the future. Consider providing a [`autolinking`](./autolinking.md) support. - -#### linkConfig.isInstalled - -Returns true if a library is already linked to a given project. False otherwise. - -#### linkConfig.register - -Performs platform-specific steps in order to link a library. - -#### linkConfig.unregister - -Performs platform-specific steps in order to unlink a library. - -#### linkConfig.copyAssets - -Performs platform-specific steps in order to copy assets of a library to a project. - -#### linkConfig.unlinkAssets - -Performs platform-specific steps in order to unlink assets of a library from a project. - -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -### Changing the configuration for a platform - -A `platform` property would need to be renamed to `platforms`. `haste` is no longer supported - we are able to infer that automatically. - -For example: - -```json -{ - "rnpm": { - "haste": { - "platforms": ["windows"], - "providesModuleNodeModules": ["react-native-windows"] - }, - "platform": "./local-cli/platform.js" - } -} -``` - -to `react-native.config.js` - -```js -module.exports = { - platforms: { - windows: require('./local-cli/platform.js').windows, - }, -}; -``` - -> The above configuration is taken from `react-native-windows` and adds support for `windows` platform. - -### Changing platform configuration for a [`dependency`](./dependencies.md) - -Platform keys are now under `dependency.platforms`. - -For example: - -```json -{ - "rnpm": { - "ios": { - "project": "PathToCustomProject.xcodeproj" - } - } -} -``` - -to `react-native.config.js` - -```js -module.exports = { - dependency: { - platforms: { - ios: { - project: 'PathToCustomProject.xcodeproj', - }, - }, - }, -}; -``` - -> The above is a configuration of a dependency that explicitly sets a path to `.xcodeproj`. - -### Changing platform configuration for a [`project`](./projects.md) - -Platform keys are now under `project.platforms`. - -For example: - -```json -{ - "rnpm": { - "ios": { - "project": "PathToCustomProject.xcodeproj" - } - } -} -``` - -to `react-native.config.js` - -```js -module.exports = { - project: { - ios: { - project: 'PathToCustomProject.xcodeproj', - }, - }, -}; -``` - -> The above is a configuration of a project that explicitly sets its main `.xcodeproj` project. diff --git a/packages/cli-config/src/__tests__/findAssets-test.ts b/packages/cli-config/src/__tests__/findAssets-test.ts deleted file mode 100644 index 7ee1a6904..000000000 --- a/packages/cli-config/src/__tests__/findAssets-test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @emails oncall+javascript_foundation - */ - -import findAssets from '../findAssets'; - -jest.mock('path'); -jest.mock('fs'); - -const fs = require('fs'); - -describe('findAssets', () => { - beforeEach(() => { - fs.__setMockFilesystem({ - testDir: { - fonts: { - 'A.ttf': '', - 'B.ttf': '', - }, - images: { - 'C.jpg': '', - }, - }, - }); - }); - - it('returns an array of all files in given folders', () => { - const assets = findAssets('/testDir', ['fonts', 'images']); - - expect(Array.isArray(assets)).toBeTruthy(); - expect(assets).toHaveLength(3); - }); - - it('prepends assets paths with the folder path', () => { - const assets = findAssets('/testDir', ['fonts', 'images']); - - assets.forEach((assetPath) => { - expect(assetPath).toContain('testDir'); - }); - }); - - it('returns an empty array if given assets are null', () => { - expect(findAssets('/testDir', null)).toHaveLength(0); - }); -}); diff --git a/packages/cli-config/src/commands/config.ts b/packages/cli-config/src/commands/config.ts index 076f3d91c..de12675d4 100644 --- a/packages/cli-config/src/commands/config.ts +++ b/packages/cli-config/src/commands/config.ts @@ -1,13 +1,10 @@ -import {Config, Dependency} from '@react-native-community/cli-types'; +import {Config, DependencyConfig} from '@react-native-community/cli-types'; -function isValidRNDependency(config: Dependency) { +function isValidRNDependency(config: DependencyConfig) { return ( Object.keys(config.platforms).filter((key) => Boolean(config.platforms[key]), - ).length !== 0 || - (config.hooks && Object.keys(config.hooks).length !== 0) || - (config.assets && config.assets.length !== 0) || - (config.params && config.params.length !== 0) + ).length !== 0 ); } diff --git a/packages/cli-config/src/findAssets.ts b/packages/cli-config/src/findAssets.ts deleted file mode 100644 index 8461603a3..000000000 --- a/packages/cli-config/src/findAssets.ts +++ /dev/null @@ -1,28 +0,0 @@ -import glob from 'glob'; -import path from 'path'; - -const findAssetsInFolder = (folder: string): string[] => { - const assets = glob.sync(path.join(folder, '**'), {nodir: true}); - if (process.platform === 'win32') { - return assets.map((asset) => asset.split('/').join('\\')); - } - return assets; -}; - -/** - * Given an array of assets folders, e.g. ['Fonts', 'Images'], - * it globs in them to find all files that can be copied. - * - * It returns an array of absolute paths to files found. - */ -export default function findAssets( - folder: string, - assets: Array, -): Array { - return (assets || []) - .map((asset) => path.join(folder, asset)) - .reduce( - (acc, assetPath) => acc.concat(findAssetsInFolder(assetPath)), - [] as string[], - ); -} diff --git a/packages/cli-config/src/loadConfig.ts b/packages/cli-config/src/loadConfig.ts index 24e5c8887..f988d3942 100644 --- a/packages/cli-config/src/loadConfig.ts +++ b/packages/cli-config/src/loadConfig.ts @@ -15,7 +15,6 @@ import { } from '@react-native-community/cli-tools'; import findDependencies from './findDependencies'; import resolveReactNativePath from './resolveReactNativePath'; -import findAssets from './findAssets'; import { readConfigFromDisk, readDependencyConfigFromDisk, @@ -50,9 +49,6 @@ function getDependencyConfig( }, {} as Config['platforms'], ), - assets: findAssets(root, config.dependency.assets), - hooks: config.dependency.hooks, - params: config.dependency.params, }, userConfig.dependencies[dependencyName] || {}, ) as Dependency; @@ -74,9 +70,6 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config { }, dependencies: userConfig.dependencies, commands: userConfig.commands, - get assets() { - return findAssets(projectRoot, userConfig.assets); - }, healthChecks: [], platforms: userConfig.platforms, get project() { diff --git a/packages/cli-config/src/readConfigFromDisk.ts b/packages/cli-config/src/readConfigFromDisk.ts index 4f651528f..6b0f79358 100644 --- a/packages/cli-config/src/readConfigFromDisk.ts +++ b/packages/cli-config/src/readConfigFromDisk.ts @@ -59,9 +59,6 @@ export function readDependencyConfigFromDisk( const emptyDependencyConfig = { dependency: { platforms: {}, - assets: [], - hooks: {}, - params: [], }, commands: [], platforms: {}, diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index 185a5ba5b..21d80e109 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -81,18 +81,6 @@ export const dependencyConfig = t .default({}), }) .default(), - assets: t.array().items(t.string()).default([]), - hooks: map(t.string(), t.string()).default({}), - params: t - .array() - .items( - t.object({ - name: t.string(), - type: t.string(), - message: t.string(), - }), - ) - .default([]), }) .default(), platforms: map( @@ -146,15 +134,6 @@ export const projectConfig = t }) .allow(null), }), - assets: t.array().items(t.string()), - hooks: map(t.string(), t.string()), - params: t.array().items( - t.object({ - name: t.string(), - type: t.string(), - message: t.string(), - }), - ), }) .allow(null), ).default({}), diff --git a/packages/cli-types/src/android.ts b/packages/cli-types/src/android.ts index cd4f15d36..15934e65a 100644 --- a/packages/cli-types/src/android.ts +++ b/packages/cli-types/src/android.ts @@ -1,30 +1,31 @@ export interface AndroidProjectConfig { sourceDir: string; - isFlat: boolean; - folder: string; - stringsPath: string; - manifestPath: string; - buildGradlePath: string; - settingsGradlePath: string; - assetsPath: string; - mainFilePath: string; packageName: string; - packageFolder: string; - appName: string; dependencyConfiguration?: string; } -export type AndroidProjectParams = Partial; +export type AndroidProjectParams = { + sourceDir?: string; + appName?: string; + manifestPath?: string; + packageName?: string; + dependencyConfiguration?: string; +}; -export interface AndroidDependencyConfig { +export type AndroidDependencyConfig = { sourceDir: string; - folder: string; packageImportPath: string; packageInstance: string; - manifestPath: string; - packageName: string; dependencyConfiguration?: string; buildTypes: string[]; -} +}; -export type AndroidDependencyParams = Partial; +export type AndroidDependencyParams = { + sourceDir?: string; + manifestPath?: string; + packageName?: string; + dependencyConfiguration?: string; + packageImportPath?: string; + packageInstance?: string; + buildTypes?: string[]; +}; diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index ecfa0e8fe..cdfcbd4c6 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -3,7 +3,6 @@ import { IOSProjectParams, IOSDependencyConfig, IOSDependencyParams, - IOSNativeModulesConfig, } from './ios'; import { AndroidProjectConfig, @@ -73,82 +72,48 @@ interface PlatformConfig< dependency: string, params: DependencyParams, ) => DependencyConfig | void; - linkConfig: () => { - isInstalled: ( - projectConfig: ProjectConfig, - packageName: string, - dependencyConfig: DependencyConfig, - ) => boolean; - register: ( - name: string, - dependencyConfig: DependencyConfig, - params: Object, - projectConfig: ProjectConfig, - ) => void; - unregister: ( - name: string, - dependencyConfig: DependencyConfig, - projectConfig: ProjectConfig, - otherDependencies: Array, - ) => void; - copyAssets: (assets: string[], projectConfig: ProjectConfig) => void; - unlinkAssets: (assets: string[], projectConfig: ProjectConfig) => void; - }; } -export interface Dependency { +type AndroidPlatformConfig = PlatformConfig< + AndroidProjectConfig, + AndroidProjectParams, + AndroidDependencyConfig, + AndroidDependencyParams +>; + +type IOSPlatformConfig = PlatformConfig< + IOSProjectConfig, + IOSProjectParams, + IOSDependencyConfig, + IOSDependencyParams +>; + +export type ProjectConfig = { + android?: ReturnType; + ios?: ReturnType; + [key: string]: any; +}; + +export interface DependencyConfig { name: string; root: string; platforms: { - android?: AndroidDependencyConfig | null; - ios?: IOSDependencyConfig | null; + android?: ReturnType; + ios?: ReturnType; [key: string]: any; }; - assets: string[]; - hooks: { - prelink?: string; - postlink?: string; - preunlink?: string; - postunlink?: string; - }; - params: Prompt[]; } -export type ProjectConfig = { - android?: AndroidProjectConfig; - ios?: IOSProjectConfig; - [key: string]: any; -}; - -/** - * @property root - Root where the configuration has been resolved from - * @property reactNativePath - Path to React Native source - * @property project - Object that contains configuration for a project (null, when platform not available) - * @property assets - An array of assets as defined by the user - * @property dependencies - Map of the dependencies that are present in the project - * @property platforms - Map of available platforms (build-ins and dynamically loaded) - * @property commands - An array of commands that are present in 3rd party packages - * @property healthChecks - An array of health check categories to add to doctor command - */ -export interface Config extends IOSNativeModulesConfig { +export interface Config { root: string; reactNativePath: string; project: ProjectConfig; - assets: string[]; - dependencies: {[key: string]: Dependency}; + dependencies: { + [key: string]: DependencyConfig; + }; platforms: { - android: PlatformConfig< - AndroidProjectConfig, - AndroidProjectParams, - AndroidDependencyConfig, - AndroidDependencyParams - >; - ios: PlatformConfig< - IOSProjectConfig, - IOSProjectParams, - IOSDependencyConfig, - IOSDependencyParams - >; + android: AndroidPlatformConfig; + ios: IOSPlatformConfig; [name: string]: PlatformConfig; }; commands: Command[]; @@ -156,11 +121,7 @@ export interface Config extends IOSNativeModulesConfig { healthChecks: []; } -/** - * Shares some structure with Config, except that root is calculated and can't - * be defined - */ - +// @todo double check the following two types for correction export type UserConfig = Omit & { reactNativePath: string | void; // Additional project settings @@ -173,7 +134,7 @@ export type UserConfig = Omit & { export type UserDependencyConfig = { // Additional dependency settings - dependency: Omit; + dependency: Omit; // An array of commands that ship with the dependency commands: Command[]; // An array of extra platforms to load @@ -187,7 +148,6 @@ export { IOSProjectParams, IOSDependencyConfig, IOSDependencyParams, - IOSNativeModulesConfig, }; export { diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index 3cb3183ac..7150a0883 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -1,48 +1,24 @@ /** - * Settings that user can define in the project configuration for iOS. - * Same for dependency - we share the type. - * - * See UserDependencyConfigT and UserConfigT for details + * Types in this document describe the data that is expected by `native_modules.rb`. + * When performing changes, make sure to sync it with the Ruby file. */ + export interface IOSProjectParams { project?: string; - /** - * @deprecated A podspec should always be at the root of a package and - * have the name of the package. This property will be - * removed in a future major version. - * - * @todo Log a warning when this is used. - */ - podspecPath?: string; - sharedLibraries?: string[]; - libraryFolder?: string; - plist: Array; - scriptPhases?: Array; -} - -export interface IOSDependencyParams extends IOSProjectParams { - configurations?: string[]; } -// The following types are used in untyped-parts of the codebase, so I am leaving them -// until we actually need them. export interface IOSProjectConfig { sourceDir: string; - folder: string; - pbxprojPath: string; - podfile: string; - podspecPath: string; - projectPath: string; - projectName: string; - libraryFolder: string; - sharedLibraries: Array; - plist: Array; } -export interface IOSDependencyConfig extends IOSProjectConfig { +export interface IOSDependencyConfig { + podspecPath: string; + scriptPhases: Array; configurations: string[]; } +export type IOSDependencyParams = Partial; + /** * @see https://www.rubydoc.info/gems/cocoapods-core/Pod/Podfile/DSL#script_phase-instance_method * @@ -61,37 +37,3 @@ export type IOSScriptPhase = ({script: string} | {path: string}) & { dependency_file?: string; execution_position?: 'before_compile' | 'after_compile' | 'any'; }; - -/** - * This describes the data that is expected by `native_modules.rb`. It is only - * meant to ensure the `Config` interface follows exactly what is needed, so - * only make changes to this interface (or `IOSScriptPhase`) if the data - * requirements of `native_modules.rb` change. - */ -export interface IOSNativeModulesConfig { - reactNativePath: string; - project: { - ios?: { - sourceDir: string; - }; - }; - dependencies: { - [name: string]: { - root: string; - platforms: { - ios?: null | { - /** - * @deprecated A podspec should always be at the root of a package and - * have the name of the package. This property will be - * removed in a future major version. - * - * @todo Log a warning when this is used. - */ - podspecPath: string; - scriptPhases?: Array; - }; - android?: null | {}; - }; - }; - }; -} diff --git a/packages/platform-android/src/config/index.ts b/packages/platform-android/src/config/index.ts index b6c820229..0e31f6ae1 100644 --- a/packages/platform-android/src/config/index.ts +++ b/packages/platform-android/src/config/index.ts @@ -37,7 +37,7 @@ export function projectConfig( const sourceDir = path.join(root, src); const appName = getAppName(sourceDir, userConfig.appName); - const isFlat = sourceDir.indexOf('app') === -1; + const manifestPath = userConfig.manifestPath ? path.join(sourceDir, userConfig.manifestPath) : findManifest(path.join(sourceDir, appName)); @@ -54,52 +54,10 @@ export function projectConfig( throw new Error(`Package name not found in ${manifestPath}`); } - const packageFolder = - userConfig.packageFolder || packageName.replace(/\./g, path.sep); - - const mainFilePath = path.join( - sourceDir, - userConfig.mainFilePath || - path.join(appName, `src/main/java/${packageFolder}/MainApplication.java`), - ); - - const stringsPath = path.join( - sourceDir, - userConfig.stringsPath || - path.join(appName, '/src/main/res/values/strings.xml'), - ); - - const settingsGradlePath = path.join( - sourceDir, - userConfig.settingsGradlePath || 'settings.gradle', - ); - - const assetsPath = path.join( - sourceDir, - userConfig.assetsPath || path.join(appName, '/src/main/assets'), - ); - - const buildGradlePath = path.join( - sourceDir, - userConfig.buildGradlePath || 'build.gradle', - ); - - const dependencyConfiguration = userConfig.dependencyConfiguration; - return { sourceDir, - isFlat, - folder: root, - stringsPath, - manifestPath, - buildGradlePath, - settingsGradlePath, - assetsPath, - mainFilePath, packageName, - packageFolder, - appName, - dependencyConfiguration, + dependencyConfiguration: userConfig.dependencyConfiguration, }; } @@ -162,7 +120,6 @@ export function dependencyConfig( return { sourceDir, - folder: root, packageImportPath, packageInstance, buildTypes, diff --git a/packages/platform-ios/src/config/getPodspecName.ts b/packages/platform-ios/src/config/getPodspecName.ts deleted file mode 100644 index 923eb5be6..000000000 --- a/packages/platform-ios/src/config/getPodspecName.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import path from 'path'; - -export default function getPodspecName(podspecFile: string) { - return path.basename(podspecFile).replace(/\.podspec$/, ''); -} diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index 21574257c..f2745dd3c 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -15,21 +15,10 @@ import { IOSProjectParams, IOSDependencyParams, } from '@react-native-community/cli-types'; +import {logger} from '@react-native-community/cli-tools'; const memoizedFindProject = memoize(findProject); -/** - * For libraries specified without an extension, add '.tbd' for those that - * start with 'lib' and '.framework' to the rest. - */ -const mapSharedLibaries = (libraries: Array) => - libraries.map((name) => { - if (path.extname(name)) { - return name; - } - return name + (name.indexOf('lib') === 0 ? '.tbd' : '.framework'); - }); - /** * Returns project config by analyzing given folder and applying some user defaults * when constructing final object @@ -57,21 +46,6 @@ export function projectConfig(folder: string, userConfig: IOSProjectParams) { return { sourceDir, - folder, - pbxprojPath: path.join(projectPath, 'project.pbxproj'), - podfile, - podspecPath: - userConfig.podspecPath || - // podspecs are usually placed in the root dir of the library or in the - // iOS project path - findPodspec(folder) || - findPodspec(sourceDir), - projectPath, - projectName: path.basename(projectPath), - libraryFolder: userConfig.libraryFolder || 'Libraries', - sharedLibraries: mapSharedLibaries(userConfig.sharedLibraries || []), - plist: userConfig.plist || [], - scriptPhases: userConfig.scriptPhases || [], }; } @@ -79,12 +53,15 @@ export function dependencyConfig( folder: string, userConfig: IOSDependencyParams, ) { - const configurations = userConfig.configurations || []; - - const baseConfig = projectConfig(folder, userConfig); - if (!baseConfig) { - return null; + if (userConfig.podspecPath) { + logger.warn(` + A podspec should always be at the root of a package and have the name of the package. + This property will be removed in a future major version. + `); } - - return {...baseConfig, configurations}; + return { + podspecPath: userConfig.podspecPath || findPodspec(folder), + configurations: userConfig.configurations || [], + scriptPhases: userConfig.scriptPhases || [], + }; } From 30103d37082bcee04ac4003d5045914837c422ef Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 27 Jan 2022 13:41:03 +0100 Subject: [PATCH 03/39] chore: wip --- docs/dependencies.md | 18 ++++---- docs/projects.md | 64 +++++++-------------------- packages/cli-config/src/loadConfig.ts | 8 ++-- 3 files changed, 28 insertions(+), 62 deletions(-) diff --git a/docs/dependencies.md b/docs/dependencies.md index 814bddcf1..5e936c3a4 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -31,8 +31,10 @@ module.exports = { The following type describes the configuration of a dependency that can be set under `dependency` key inside `react-native.config.js`. ```ts -type DependencyConfigT = { +type DependencyConfig = { platforms: { + android?: AndroidDependencyParams; + ios?: IOSDependencyParams; [key: string]: any; }; }; @@ -47,27 +49,23 @@ In most cases, as a library author, you should not need to define any of these. The following settings are available on iOS and Android: ```ts -type DependencyParamsIOST = { - project?: string; +type IOSDependencyConfig = { podspecPath?: string; - sharedLibraries?: string[]; + scriptPhases?: Array; configurations?: string[]; }; -type DependencyParamsAndroidT = { +type AndroidDependencyParams = { sourceDir?: string; manifestPath?: string; + packageName?: string; + dependencyConfiguration?: string; packageImportPath?: string; packageInstance?: string; buildTypes?: string[]; - dependencyConfiguration?: string; }; ``` -#### platforms.ios.project - -Custom path to `.xcodeproj`. - #### platforms.ios.podspecPath Custom path to `.podspec` file to use when auto-linking. Example: `node_modules/react-native-module/ios/module.podspec`. diff --git a/docs/projects.md b/docs/projects.md index 06f8a5067..8c0f73879 100644 --- a/docs/projects.md +++ b/docs/projects.md @@ -17,7 +17,6 @@ module.exports = { project: './CustomProject.xcodeproj', }, }, - assets: ['./assets'], }; ``` @@ -27,28 +26,27 @@ You can check all available options below. ```ts type ProjectConfigT = { - reactNativePath: ?string, + reactNativePath: ?string; project: { - android?: ProjectParamsAndroidT, - ios?: IOSProjectParams, - [key: string]: any, - }, - assets: string[], - platforms: PlatformT, + android?: ProjectParamsAndroidT; + ios?: IOSProjectParams; + [key: string]: any; + }; + platforms: PlatformT; dependencies: { [key: string]: { - name: string, - root: string, + name: string; + root: string; platforms: { - [key: string]: PlatformSettingsT - }, - assets: string[], + [key: string]: PlatformSettingsT; + }; + assets: string[]; hooks: { - [key: string]: string - } - }, - }, - commands: CommandT[] + [key: string]: string; + }; + }; + }; + commands: CommandT[]; }; ``` @@ -156,33 +154,3 @@ module.exports = { The object provided here is deep merged with the dependency config. Check [`projectConfig`](platforms.md#projectconfig) and [`dependencyConfig`](platforms.md#dependencyConfig) return values for a full list of properties that you can override. > Note: This is an advanced feature and you should not need to use it mos of the time. - -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -### Changing the configuration - -Properties `ios` and `android` were moved under `project`. Take a look at the following example for the differences. - -```json -{ - "rnpm": { - "ios": {}, - "android": {}, - "assets": ["./path-to-assets"] - } -} -``` - -to a `react-native.config.js` - -```js -module.exports = { - project: { - ios: {}, - android: {}, - }, - assets: ['./path-to-assets'], -}; -``` diff --git a/packages/cli-config/src/loadConfig.ts b/packages/cli-config/src/loadConfig.ts index f988d3942..c66fa0b7d 100644 --- a/packages/cli-config/src/loadConfig.ts +++ b/packages/cli-config/src/loadConfig.ts @@ -3,7 +3,7 @@ import chalk from 'chalk'; import { UserDependencyConfig, ProjectConfig, - Dependency, + DependencyConfig, UserConfig, Config, } from '@react-native-community/cli-types'; @@ -29,7 +29,7 @@ function getDependencyConfig( config: UserDependencyConfig, userConfig: UserConfig, isPlatform: boolean, -): Dependency { +): DependencyConfig { return merge( { root, @@ -51,7 +51,7 @@ function getDependencyConfig( ), }, userConfig.dependencies[dependencyName] || {}, - ) as Dependency; + ) as DependencyConfig; } /** @@ -124,7 +124,7 @@ function loadConfig(projectRoot: string = findProjectRoot()): Config { return assign({}, acc, { dependencies: assign({}, acc.dependencies, { - get [dependencyName](): Dependency { + get [dependencyName](): DependencyConfig { return getDependencyConfig( root, dependencyName, From 6c53e48c036f803fad7e4964f19f59f0cd5bc3b0 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Fri, 28 Jan 2022 10:26:10 +0100 Subject: [PATCH 04/39] continue work --- docs/platforms.md | 2 +- .../src/profileHermes/downloadProfile.ts | 7 +--- packages/cli-types/src/android.ts | 1 + packages/cli-types/src/index.ts | 11 +++-- .../src/commands/runAndroid/index.ts | 32 ++++++-------- .../commands/runAndroid/runOnAllDevices.ts | 3 +- .../__tests__/getAndroidProject.test.ts | 1 + .../src/config/__tests__/readManifest.test.ts | 42 ------------------- .../{utils => config}/getAndroidProject.ts | 10 ++--- packages/platform-android/src/config/index.ts | 13 ++---- .../src/config/readManifest.ts | 21 ---------- packages/platform-android/src/index.ts | 2 +- .../platform-ios/src/commands/runIOS/index.ts | 7 +--- 13 files changed, 34 insertions(+), 118 deletions(-) create mode 100644 packages/platform-android/src/config/__tests__/getAndroidProject.test.ts delete mode 100644 packages/platform-android/src/config/__tests__/readManifest.test.ts rename packages/platform-android/src/{utils => config}/getAndroidProject.ts (84%) delete mode 100644 packages/platform-android/src/config/readManifest.ts diff --git a/docs/platforms.md b/docs/platforms.md index 89bbd58a5..8e4f25c26 100644 --- a/docs/platforms.md +++ b/docs/platforms.md @@ -98,7 +98,7 @@ module.exports = { }; ``` -On Android and iOS, this function returns: +On Android and iOS, this function returns a dependency configuration for: ```ts type IOSDependencyConfig = { diff --git a/packages/cli-hermes/src/profileHermes/downloadProfile.ts b/packages/cli-hermes/src/profileHermes/downloadProfile.ts index d28d9515b..2a2ca5e31 100644 --- a/packages/cli-hermes/src/profileHermes/downloadProfile.ts +++ b/packages/cli-hermes/src/profileHermes/downloadProfile.ts @@ -6,10 +6,7 @@ import path from 'path'; import os from 'os'; import transformer from 'hermes-profile-transformer'; import {findSourcemap, generateSourcemap} from './sourcemapUtils'; -import { - getAndroidProject, - getPackageName, -} from '@react-native-community/cli-platform-android'; +import {getAndroidProject} from '@react-native-community/cli-platform-android'; /** * Get the last modified hermes profile * @param packageNameWithSuffix @@ -54,7 +51,7 @@ export async function downloadProfile( try { const androidProject = getAndroidProject(ctx); const packageNameWithSuffix = [ - appId || getPackageName(androidProject), + appId || androidProject.packageName, appIdSuffix, ] .filter(Boolean) diff --git a/packages/cli-types/src/android.ts b/packages/cli-types/src/android.ts index 15934e65a..a74112da6 100644 --- a/packages/cli-types/src/android.ts +++ b/packages/cli-types/src/android.ts @@ -1,5 +1,6 @@ export interface AndroidProjectConfig { sourceDir: string; + appName: string; packageName: string; dependencyConfiguration?: string; } diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index cdfcbd4c6..408cd97c8 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -89,8 +89,8 @@ type IOSPlatformConfig = PlatformConfig< >; export type ProjectConfig = { - android?: ReturnType; - ios?: ReturnType; + android?: Exclude, void>; + ios?: Exclude, void>; [key: string]: any; }; @@ -98,8 +98,11 @@ export interface DependencyConfig { name: string; root: string; platforms: { - android?: ReturnType; - ios?: ReturnType; + android?: Exclude< + ReturnType, + void + >; + ios?: Exclude, void>; [key: string]: any; }; } diff --git a/packages/platform-android/src/commands/runAndroid/index.ts b/packages/platform-android/src/commands/runAndroid/index.ts index 37631a720..1c6918924 100644 --- a/packages/platform-android/src/commands/runAndroid/index.ts +++ b/packages/platform-android/src/commands/runAndroid/index.ts @@ -21,11 +21,9 @@ import { getDefaultUserTerminal, CLIError, } from '@react-native-community/cli-tools'; -import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs'; -import {getAndroidProject, getPackageName} from '../../utils/getAndroidProject'; +import {getAndroidProject} from '../../config/getAndroidProject'; -function displayWarnings(config: Config, args: Flags) { - warnAboutManuallyLinkedLibs(config); +function displayWarnings(args: Flags) { if (args.appFolder) { logger.warn( 'Using deprecated "--appFolder" flag. Use "project.android.appName" in react-native.config.js instead.', @@ -60,7 +58,7 @@ type AndroidProject = NonNullable; * Starts the app on a connected Android emulator or device. */ async function runAndroid(_argv: Array, config: Config, args: Flags) { - displayWarnings(config, args); + displayWarnings(args); const androidProject = getAndroidProject(config); if (args.jetifier) { @@ -112,21 +110,17 @@ function buildAndRun(args: Flags, androidProject: AndroidProject) { process.chdir(androidProject.sourceDir); const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew'; - const {appFolder} = args; - const packageName = getPackageName(androidProject, appFolder); - const adbPath = getAdbPath(); if (args.deviceId) { - return runOnSpecificDevice(args, cmd, packageName, adbPath, androidProject); + return runOnSpecificDevice(args, cmd, adbPath, androidProject); } else { - return runOnAllDevices(args, cmd, packageName, adbPath, androidProject); + return runOnAllDevices(args, cmd, adbPath, androidProject); } } function runOnSpecificDevice( args: Flags, gradlew: 'gradlew.bat' | './gradlew', - packageName: string, adbPath: string, androidProject: AndroidProject, ) { @@ -135,13 +129,7 @@ function runOnSpecificDevice( if (devices.length > 0 && deviceId) { if (devices.indexOf(deviceId) !== -1) { buildApk(gradlew, androidProject.sourceDir); - installAndLaunchOnDevice( - args, - deviceId, - packageName, - adbPath, - androidProject, - ); + installAndLaunchOnDevice(args, deviceId, adbPath, androidProject); } else { logger.error( `Could not find device with the id: "${deviceId}". Please choose one of the following:`, @@ -226,13 +214,17 @@ function getInstallApkName( function installAndLaunchOnDevice( args: Flags, selectedDevice: string, - packageName: string, adbPath: string, androidProject: AndroidProject, ) { tryRunAdbReverse(args.port, selectedDevice); tryInstallAppOnDevice(args, adbPath, selectedDevice, androidProject); - tryLaunchAppOnDevice(selectedDevice, packageName, adbPath, args); + tryLaunchAppOnDevice( + selectedDevice, + androidProject.packageName, + adbPath, + args, + ); } function startServerInNewWindow( diff --git a/packages/platform-android/src/commands/runAndroid/runOnAllDevices.ts b/packages/platform-android/src/commands/runAndroid/runOnAllDevices.ts index 0149269d2..d1a1d2246 100644 --- a/packages/platform-android/src/commands/runAndroid/runOnAllDevices.ts +++ b/packages/platform-android/src/commands/runAndroid/runOnAllDevices.ts @@ -31,7 +31,6 @@ type AndroidProject = NonNullable; async function runOnAllDevices( args: Flags, cmd: string, - packageName: string, adbPath: string, androidProject: AndroidProject, ) { @@ -98,7 +97,7 @@ async function runOnAllDevices( (devices.length > 0 ? devices : [undefined]).forEach( (device: string | void) => { tryRunAdbReverse(args.port, device); - tryLaunchAppOnDevice(device, packageName, adbPath, args); + tryLaunchAppOnDevice(device, androidProject.packageName, adbPath, args); }, ); } diff --git a/packages/platform-android/src/config/__tests__/getAndroidProject.test.ts b/packages/platform-android/src/config/__tests__/getAndroidProject.test.ts new file mode 100644 index 000000000..59bca1f94 --- /dev/null +++ b/packages/platform-android/src/config/__tests__/getAndroidProject.test.ts @@ -0,0 +1 @@ +// @todo diff --git a/packages/platform-android/src/config/__tests__/readManifest.test.ts b/packages/platform-android/src/config/__tests__/readManifest.test.ts deleted file mode 100644 index 231e5844d..000000000 --- a/packages/platform-android/src/config/__tests__/readManifest.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import findManifest from '../findManifest'; -import readManifest from '../readManifest'; -import * as mocks from '../__fixtures__/android'; - -jest.mock('path'); -jest.mock('fs'); - -const fs = require('fs'); - -describe('android::readManifest', () => { - beforeAll(() => { - fs.__setMockFilesystem({ - empty: {}, - nested: { - android: { - app: mocks.valid, - }, - }, - }); - }); - - it('returns manifest content if file exists in the folder', () => { - const manifestPath = findManifest('/nested'); - expect(readManifest(manifestPath)).not.toBeNull(); - expect(typeof readManifest(manifestPath)).toBe('object'); - }); - - it('throws an error if there is no manifest in the folder', () => { - const fakeManifestPath = findManifest('/empty'); - expect(() => { - readManifest(fakeManifestPath); - }).toThrow(); - }); -}); diff --git a/packages/platform-android/src/utils/getAndroidProject.ts b/packages/platform-android/src/config/getAndroidProject.ts similarity index 84% rename from packages/platform-android/src/utils/getAndroidProject.ts rename to packages/platform-android/src/config/getAndroidProject.ts index 5855d8cb6..6711e7e04 100644 --- a/packages/platform-android/src/utils/getAndroidProject.ts +++ b/packages/platform-android/src/config/getAndroidProject.ts @@ -1,4 +1,4 @@ -import {Config, AndroidProjectConfig} from '@react-native-community/cli-types'; +import {Config} from '@react-native-community/cli-types'; import {logger, CLIError} from '@react-native-community/cli-tools'; import fs from 'fs'; import chalk from 'chalk'; @@ -20,18 +20,14 @@ export function getAndroidProject(config: Config) { * Get the package name of the running React Native app * @param config */ -export function getPackageName( - androidProject: AndroidProjectConfig, - appFolder?: string, -) { - const {appName, manifestPath} = androidProject; +export function getPackageName(manifestPath: string) { const androidManifest = fs.readFileSync(manifestPath, 'utf8'); let packageNameMatchArray = androidManifest.match(/package="(.+?)"/); if (!packageNameMatchArray || packageNameMatchArray.length === 0) { throw new CLIError( `Failed to build the app: No package name found. Found errors in ${chalk.underline.dim( - `${appFolder || appName}/src/main/AndroidManifest.xml`, + `${manifestPath}`, )}`, ); } diff --git a/packages/platform-android/src/config/index.ts b/packages/platform-android/src/config/index.ts index 0e31f6ae1..0cf8c2199 100644 --- a/packages/platform-android/src/config/index.ts +++ b/packages/platform-android/src/config/index.ts @@ -11,15 +11,12 @@ import fs from 'fs'; import findAndroidDir from './findAndroidDir'; import findManifest from './findManifest'; import findPackageClassName from './findPackageClassName'; -import readManifest from './readManifest'; import { AndroidProjectParams, AndroidDependencyParams, AndroidProjectConfig, } from '@react-native-community/cli-types'; -import {XmlDocument} from 'xmldoc'; - -const getPackageName = (manifest: XmlDocument) => manifest.attr.package; +import {getPackageName} from './getAndroidProject'; /** * Gets android project config by analyzing given folder and taking some @@ -46,9 +43,7 @@ export function projectConfig( return null; } - const manifest = readManifest(manifestPath); - - const packageName = userConfig.packageName || getPackageName(manifest); + const packageName = userConfig.packageName || getPackageName(manifestPath); if (!packageName) { throw new Error(`Package name not found in ${manifestPath}`); @@ -56,6 +51,7 @@ export function projectConfig( return { sourceDir, + appName, packageName, dependencyConfiguration: userConfig.dependencyConfiguration, }; @@ -97,8 +93,7 @@ export function dependencyConfig( return null; } - const manifest = readManifest(manifestPath); - const packageName = userConfig.packageName || getPackageName(manifest); + const packageName = userConfig.packageName || getPackageName(manifestPath); const packageClassName = findPackageClassName(sourceDir); /** diff --git a/packages/platform-android/src/config/readManifest.ts b/packages/platform-android/src/config/readManifest.ts deleted file mode 100644 index 0e69f21e9..000000000 --- a/packages/platform-android/src/config/readManifest.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import fs from 'fs'; -import xml from 'xmldoc'; -import {CLIError} from '@react-native-community/cli-tools'; - -export default function readManifest(manifestPath: string) { - try { - return new xml.XmlDocument(fs.readFileSync(manifestPath, 'utf8')); - } catch (error) { - throw new CLIError( - `Failed to parse Android Manifest file at ${manifestPath}`, - error, - ); - } -} diff --git a/packages/platform-android/src/index.ts b/packages/platform-android/src/index.ts index e5cebbd00..beb6fa00d 100644 --- a/packages/platform-android/src/index.ts +++ b/packages/platform-android/src/index.ts @@ -4,4 +4,4 @@ export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; -export {getAndroidProject, getPackageName} from './utils/getAndroidProject'; +export {getAndroidProject, getPackageName} from './config/getAndroidProject'; diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index e0b5487f2..0219e0105 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -19,8 +19,6 @@ import findXcodeProject, {ProjectInfo} from './findXcodeProject'; import parseIOSDevicesList from './parseIOSDevicesList'; import parseXctraceIOSDevicesList from './parseXctraceIOSDevicesList'; import findMatchingSimulator from './findMatchingSimulator'; -import warnAboutManuallyLinkedLibs from '../../link/warnAboutManuallyLinkedLibs'; -import warnAboutPodInstall from '../../link/warnAboutPodInstall'; import { logger, CLIError, @@ -43,16 +41,13 @@ type FlagsT = { terminal: string | undefined; }; -function runIOS(_: Array, ctx: Config, args: FlagsT) { +function runIOS(_: Array, _ctx: Config, args: FlagsT) { if (!fs.existsSync(args.projectPath)) { throw new CLIError( 'iOS project folder not found. Are you sure this is a React Native project?', ); } - warnAboutManuallyLinkedLibs(ctx); - warnAboutPodInstall(ctx); - process.chdir(args.projectPath); const xcodeProject = findXcodeProject(fs.readdirSync('.')); From 596d849d30c07ec056c648afe8d17460afd66d8b Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Fri, 28 Jan 2022 10:41:08 +0100 Subject: [PATCH 05/39] chore: fix warnings and errors --- packages/cli-types/src/ios.ts | 4 +- packages/cli/src/commands/upgrade/upgrade.ts | 12 ++- .../src/config/__tests__/findProject.test.ts | 85 ------------------- .../src/config/findPodfilePath.ts | 8 +- .../platform-ios/src/config/findProject.ts | 57 ------------- packages/platform-ios/src/config/index.ts | 24 ++---- packages/platform-ios/src/index.ts | 1 + 7 files changed, 19 insertions(+), 172 deletions(-) delete mode 100644 packages/platform-ios/src/config/__tests__/findProject.test.ts delete mode 100644 packages/platform-ios/src/config/findProject.ts diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index 7150a0883..47c01d530 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -3,9 +3,7 @@ * When performing changes, make sure to sync it with the Ruby file. */ -export interface IOSProjectParams { - project?: string; -} +export interface IOSProjectParams {} export interface IOSProjectConfig { sourceDir: string; diff --git a/packages/cli/src/commands/upgrade/upgrade.ts b/packages/cli/src/commands/upgrade/upgrade.ts index b60fc4d0f..8c68d10b0 100644 --- a/packages/cli/src/commands/upgrade/upgrade.ts +++ b/packages/cli/src/commands/upgrade/upgrade.ts @@ -7,6 +7,7 @@ import {Config} from '@react-native-community/cli-types'; import {logger, CLIError, fetch} from '@react-native-community/cli-tools'; import * as PackageManager from '../../tools/packageManager'; import {installPods} from '@react-native-community/cli-doctor'; +import {findXcodeProject} from '@react-native-community/cli-platform-ios'; type UpgradeError = {message: string; stderr: string}; @@ -111,10 +112,15 @@ const getPatch = async ( return; } if (platform === 'ios') { - patchWithRenamedProjects = patchWithRenamedProjects.replace( - new RegExp('RnDiffApp', 'g'), - config.project[platform]!.projectName.replace('.xcodeproj', ''), + const project = findXcodeProject( + fs.readdirSync(config.project[platform]!.sourceDir), ); + if (project) { + patchWithRenamedProjects = patchWithRenamedProjects.replace( + new RegExp('RnDiffApp', 'g'), + project.name.replace('.xcodeproj', ''), + ); + } } else if (platform === 'android') { patchWithRenamedProjects = patchWithRenamedProjects .replace( diff --git a/packages/platform-ios/src/config/__tests__/findProject.test.ts b/packages/platform-ios/src/config/__tests__/findProject.test.ts deleted file mode 100644 index bdcf9106a..000000000 --- a/packages/platform-ios/src/config/__tests__/findProject.test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import findProject from '../findProject'; -import * as projects from '../__fixtures__/projects'; - -jest.mock('path'); -jest.mock('fs'); - -const fs = require('fs'); - -describe('ios::findProject', () => { - it('returns path to xcodeproj if found', () => { - fs.__setMockFilesystem(projects.flat); - expect(findProject('/')).not.toBeNull(); - }); - - it('returns null if there are no projects', () => { - fs.__setMockFilesystem({testDir: projects}); - expect(findProject('/')).toBeNull(); - }); - - it('ignores node_modules', () => { - fs.__setMockFilesystem({node_modules: projects.flat}); - expect(findProject('/')).toBeNull(); - }); - - it('ignores Pods', () => { - fs.__setMockFilesystem({Pods: projects.flat}); - expect(findProject('/')).toBeNull(); - }); - - it('ignores Pods inside `ios` folder', () => { - fs.__setMockFilesystem({ - ios: { - Pods: projects.flat, - DemoApp: projects.flat.ios, - }, - }); - expect(findProject('/')).toBe('ios/DemoApp/demoProject.xcodeproj'); - }); - - it('ignores xcodeproj from example folders', () => { - fs.__setMockFilesystem({ - examples: projects.flat, - Examples: projects.flat, - example: projects.flat, - KeychainExample: projects.flat, - Zpp: projects.flat, - }); - - expect(findProject('/').toLowerCase()).not.toContain('example'); - }); - - it('ignores xcodeproj from sample folders', () => { - fs.__setMockFilesystem({ - samples: projects.flat, - Samples: projects.flat, - sample: projects.flat, - KeychainSample: projects.flat, - Zpp: projects.flat, - }); - - expect(findProject('/').toLowerCase()).not.toContain('sample'); - }); - - it('ignores xcodeproj from test folders at any level', () => { - fs.__setMockFilesystem({ - test: projects.flat, - IntegrationTests: projects.flat, - tests: projects.flat, - Zpp: { - tests: projects.flat, - src: projects.flat, - }, - }); - - expect(findProject('/').toLowerCase()).not.toContain('test'); - }); -}); diff --git a/packages/platform-ios/src/config/findPodfilePath.ts b/packages/platform-ios/src/config/findPodfilePath.ts index 814b3aabd..685a1883b 100644 --- a/packages/platform-ios/src/config/findPodfilePath.ts +++ b/packages/platform-ios/src/config/findPodfilePath.ts @@ -6,16 +6,10 @@ * */ -import fs from 'fs'; import glob from 'glob'; import path from 'path'; -export default function findPodfilePath(folder: string, projectFolder: string) { - const podFilePath = path.join(projectFolder, '..', 'Podfile'); - if (fs.existsSync(podFilePath)) { - return podFilePath; - } - +export default function findPodfilePath(folder: string) { const podfiles = glob.sync('**/Podfile', { cwd: folder, ignore: 'node_modules/**', diff --git a/packages/platform-ios/src/config/findProject.ts b/packages/platform-ios/src/config/findProject.ts deleted file mode 100644 index fb28c436a..000000000 --- a/packages/platform-ios/src/config/findProject.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ - -import glob from 'glob'; -import path from 'path'; - -/** - * Glob pattern to look for xcodeproj - */ -const GLOB_PATTERN = '**/*.xcodeproj'; - -/** - * Regexp matching all test projects - */ -const TEST_PROJECTS = /test|example|sample/i; - -/** - * Base iOS folder - */ -const IOS_BASE = 'ios'; - -/** - * These folders will be excluded from search to speed it up - */ -const GLOB_EXCLUDE_PATTERN = ['**/@(Pods|node_modules|Carthage)/**']; - -/** - * Finds iOS project by looking for all .xcodeproj files - * in given folder. - * - * Returns first match if files are found or null - * - * Note: `./ios/*.xcodeproj` are returned regardless of the name - */ -export default function findProject(folder: string): string | null { - const projects = glob - .sync(GLOB_PATTERN, { - cwd: folder, - ignore: GLOB_EXCLUDE_PATTERN, - }) - .filter( - (project) => - path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project), - ) - .sort((project) => (path.dirname(project) === IOS_BASE ? -1 : 1)); - - if (projects.length === 0) { - return null; - } - - return projects[0]; -} diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index f2745dd3c..0a3fb1f5c 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -5,10 +5,7 @@ * LICENSE file in the root directory of this source tree. * */ - import path from 'path'; -import {memoize} from 'lodash'; -import findProject from './findProject'; import findPodfilePath from './findPodfilePath'; import findPodspec from './findPodspec'; import { @@ -17,8 +14,6 @@ import { } from '@react-native-community/cli-types'; import {logger} from '@react-native-community/cli-tools'; -const memoizedFindProject = memoize(findProject); - /** * Returns project config by analyzing given folder and applying some user defaults * when constructing final object @@ -27,25 +22,20 @@ export function projectConfig(folder: string, userConfig: IOSProjectParams) { if (!userConfig) { return; } - const project = userConfig.project || memoizedFindProject(folder); + + const podfile = findPodfilePath(folder); /** - * No iOS config found here + * In certain repos, the Xcode project can + * be generated by a tool. The only file that we can assume to exist on disk + * is `Podfile`. */ - if (!project) { + if (!podfile) { return null; } - const projectPath = path.join(folder, project); - const podfile = findPodfilePath(folder, projectPath); - - // This is a temporary fix for #1435. In certain repos, the Xcode project can - // be generated by a tool. The only file that we can assume to exist on disk - // is `Podfile`. - const sourceDir = podfile ? path.dirname(podfile) : path.dirname(projectPath); - return { - sourceDir, + sourceDir: path.dirname(podfile), }; } diff --git a/packages/platform-ios/src/index.ts b/packages/platform-ios/src/index.ts index 59589860d..5cdcca156 100644 --- a/packages/platform-ios/src/index.ts +++ b/packages/platform-ios/src/index.ts @@ -4,3 +4,4 @@ export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; +export {default as findXcodeProject} from './commands/runIOS/findXcodeProject'; From 8a24cd28bdcdc87718d2c638ba43d4e6ec6b5e6a Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 20:43:42 +0100 Subject: [PATCH 06/39] chore: move findXcodeProj to config and upgrade run-ios --- packages/cli-types/src/ios.ts | 4 ++++ packages/cli/src/commands/upgrade/upgrade.ts | 9 +++------ .../__tests__/findXcodeProject.test.ts | 0 .../{commands/runIOS => config}/findXcodeProject.ts | 0 packages/platform-ios/src/config/index.ts | 13 +++++++++++-- packages/platform-ios/src/index.ts | 1 - 6 files changed, 18 insertions(+), 9 deletions(-) rename packages/platform-ios/src/{commands/runIOS => config}/__tests__/findXcodeProject.test.ts (100%) rename packages/platform-ios/src/{commands/runIOS => config}/findXcodeProject.ts (100%) diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index 47c01d530..26c19d65c 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -7,6 +7,10 @@ export interface IOSProjectParams {} export interface IOSProjectConfig { sourceDir: string; + xcodeProject: { + name: string; + isWorkspace: boolean; + } | null; } export interface IOSDependencyConfig { diff --git a/packages/cli/src/commands/upgrade/upgrade.ts b/packages/cli/src/commands/upgrade/upgrade.ts index 8c68d10b0..05fc2a7d7 100644 --- a/packages/cli/src/commands/upgrade/upgrade.ts +++ b/packages/cli/src/commands/upgrade/upgrade.ts @@ -7,7 +7,6 @@ import {Config} from '@react-native-community/cli-types'; import {logger, CLIError, fetch} from '@react-native-community/cli-tools'; import * as PackageManager from '../../tools/packageManager'; import {installPods} from '@react-native-community/cli-doctor'; -import {findXcodeProject} from '@react-native-community/cli-platform-ios'; type UpgradeError = {message: string; stderr: string}; @@ -112,13 +111,11 @@ const getPatch = async ( return; } if (platform === 'ios') { - const project = findXcodeProject( - fs.readdirSync(config.project[platform]!.sourceDir), - ); - if (project) { + const xcodeProject = config.project.ios!.xcodeProject; + if (xcodeProject) { patchWithRenamedProjects = patchWithRenamedProjects.replace( new RegExp('RnDiffApp', 'g'), - project.name.replace('.xcodeproj', ''), + xcodeProject.name.replace('.xcodeproj', ''), ); } } else if (platform === 'android') { diff --git a/packages/platform-ios/src/commands/runIOS/__tests__/findXcodeProject.test.ts b/packages/platform-ios/src/config/__tests__/findXcodeProject.test.ts similarity index 100% rename from packages/platform-ios/src/commands/runIOS/__tests__/findXcodeProject.test.ts rename to packages/platform-ios/src/config/__tests__/findXcodeProject.test.ts diff --git a/packages/platform-ios/src/commands/runIOS/findXcodeProject.ts b/packages/platform-ios/src/config/findXcodeProject.ts similarity index 100% rename from packages/platform-ios/src/commands/runIOS/findXcodeProject.ts rename to packages/platform-ios/src/config/findXcodeProject.ts diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index 0a3fb1f5c..5dfbc56c0 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -6,11 +6,14 @@ * */ import path from 'path'; +import fs from 'fs'; import findPodfilePath from './findPodfilePath'; +import findXcodeProject from './findXcodeProject'; import findPodspec from './findPodspec'; import { IOSProjectParams, IOSDependencyParams, + IOSProjectConfig, } from '@react-native-community/cli-types'; import {logger} from '@react-native-community/cli-tools'; @@ -18,9 +21,12 @@ import {logger} from '@react-native-community/cli-tools'; * Returns project config by analyzing given folder and applying some user defaults * when constructing final object */ -export function projectConfig(folder: string, userConfig: IOSProjectParams) { +export function projectConfig( + folder: string, + userConfig: IOSProjectParams, +): IOSProjectConfig | null { if (!userConfig) { - return; + return null; } const podfile = findPodfilePath(folder); @@ -34,8 +40,11 @@ export function projectConfig(folder: string, userConfig: IOSProjectParams) { return null; } + const xcodeProject = findXcodeProject(fs.readdirSync(folder)); + return { sourceDir: path.dirname(podfile), + xcodeProject, }; } diff --git a/packages/platform-ios/src/index.ts b/packages/platform-ios/src/index.ts index 5cdcca156..59589860d 100644 --- a/packages/platform-ios/src/index.ts +++ b/packages/platform-ios/src/index.ts @@ -4,4 +4,3 @@ export {default as commands} from './commands'; export {projectConfig, dependencyConfig} from './config'; -export {default as findXcodeProject} from './commands/runIOS/findXcodeProject'; From a1fe895678e89cc5aa2a012fe08444fc8e052a5b Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 20:45:03 +0100 Subject: [PATCH 07/39] chore: add todo --- packages/platform-ios/src/config/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index 5dfbc56c0..e544b8d0d 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -40,6 +40,10 @@ export function projectConfig( return null; } + /** + * @todo + * What if there are multiple `xcodeproj` found? Shall we read from a Podfile? + */ const xcodeProject = findXcodeProject(fs.readdirSync(folder)); return { From 2f8baf8a34cad087e5e9cad0a5cb26320cd5cb7f Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 20:46:04 +0100 Subject: [PATCH 08/39] chore: remove example --- .../platform-ios/src/commands/runIOS/index.ts | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index 0219e0105..9991756d0 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -15,7 +15,7 @@ import fs from 'fs'; import path from 'path'; import chalk from 'chalk'; import {Config} from '@react-native-community/cli-types'; -import findXcodeProject, {ProjectInfo} from './findXcodeProject'; +import findXcodeProject, {ProjectInfo} from '../../config/findXcodeProject'; import parseIOSDevicesList from './parseIOSDevicesList'; import parseXctraceIOSDevicesList from './parseXctraceIOSDevicesList'; import findMatchingSimulator from './findMatchingSimulator'; @@ -41,19 +41,20 @@ type FlagsT = { terminal: string | undefined; }; -function runIOS(_: Array, _ctx: Config, args: FlagsT) { - if (!fs.existsSync(args.projectPath)) { +function runIOS(_: Array, ctx: Config, args: FlagsT) { + if (!ctx.project.ios) { throw new CLIError( 'iOS project folder not found. Are you sure this is a React Native project?', ); } - process.chdir(args.projectPath); + const {xcodeProject, sourceDir} = ctx.project.ios; + + process.chdir(sourceDir); - const xcodeProject = findXcodeProject(fs.readdirSync('.')); if (!xcodeProject) { throw new CLIError( - `Could not find Xcode project files in "${args.projectPath}" folder`, + `Could not find Xcode project files in "${sourceDir}" folder`, ); } @@ -570,10 +571,6 @@ export default { desc: 'Run on a different simulator, e.g. iPhone SE (2nd generation)', cmd: 'react-native run-ios --simulator "iPhone SE (2nd generation)"', }, - { - desc: 'Pass a non-standard location of iOS directory', - cmd: 'react-native run-ios --project-path "./app/ios"', - }, { desc: "Run on a connected device, e.g. Max's iPhone", cmd: 'react-native run-ios --device "Max\'s iPhone"', @@ -601,13 +598,6 @@ export default { name: '--scheme ', description: 'Explicitly set Xcode scheme to use', }, - { - name: '--project-path ', - description: - 'Path relative to project root where the Xcode project ' + - '(.xcodeproj) lives.', - default: 'ios', - }, { name: '--device [string]', description: From 510a903c9145d9858aa5fc180482e78c489c0512 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 20:48:57 +0100 Subject: [PATCH 09/39] chore: update source dir and update dependnecy config for ios --- packages/cli-types/src/ios.ts | 5 ++++- packages/platform-ios/src/config/index.ts | 14 +++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index 26c19d65c..a0ec22cfd 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -19,7 +19,10 @@ export interface IOSDependencyConfig { configurations: string[]; } -export type IOSDependencyParams = Partial; +export type IOSDependencyParams = Omit< + Partial, + 'podspecPath' +>; /** * @see https://www.rubydoc.info/gems/cocoapods-core/Pod/Podfile/DSL#script_phase-instance_method diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index e544b8d0d..0c8ade717 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -40,14 +40,16 @@ export function projectConfig( return null; } + const sourceDir = path.dirname(podfile); + /** * @todo * What if there are multiple `xcodeproj` found? Shall we read from a Podfile? */ - const xcodeProject = findXcodeProject(fs.readdirSync(folder)); + const xcodeProject = findXcodeProject(fs.readdirSync(sourceDir)); return { - sourceDir: path.dirname(podfile), + sourceDir, xcodeProject, }; } @@ -56,14 +58,8 @@ export function dependencyConfig( folder: string, userConfig: IOSDependencyParams, ) { - if (userConfig.podspecPath) { - logger.warn(` - A podspec should always be at the root of a package and have the name of the package. - This property will be removed in a future major version. - `); - } return { - podspecPath: userConfig.podspecPath || findPodspec(folder), + podspecPath: findPodspec(folder), configurations: userConfig.configurations || [], scriptPhases: userConfig.scriptPhases || [], }; From 2a433456c63a1148184331d3ac62230606d67e10 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 20:49:12 +0100 Subject: [PATCH 10/39] chore: remove logger --- packages/platform-ios/src/config/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index 0c8ade717..ea178d52e 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -15,7 +15,6 @@ import { IOSDependencyParams, IOSProjectConfig, } from '@react-native-community/cli-types'; -import {logger} from '@react-native-community/cli-tools'; /** * Returns project config by analyzing given folder and applying some user defaults From 410ec1a8df4b6ebdc253db1b6297bb0ee3bd2983 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 20:56:41 +0100 Subject: [PATCH 11/39] chore: fix type issues --- packages/cli-types/src/index.ts | 2 ++ packages/cli-types/src/ios.ts | 10 ++++++---- packages/platform-ios/src/commands/runIOS/index.ts | 12 +++++------- packages/platform-ios/src/config/findXcodeProject.ts | 8 ++------ 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index 408cd97c8..31f3c347e 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -3,6 +3,7 @@ import { IOSProjectParams, IOSDependencyConfig, IOSDependencyParams, + IOSProjectInfo, } from './ios'; import { AndroidProjectConfig, @@ -151,6 +152,7 @@ export { IOSProjectParams, IOSDependencyConfig, IOSDependencyParams, + IOSProjectInfo, }; export { diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index a0ec22cfd..353315fbe 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -5,12 +5,14 @@ export interface IOSProjectParams {} +export type IOSProjectInfo = { + name: string; + isWorkspace: boolean; +}; + export interface IOSProjectConfig { sourceDir: string; - xcodeProject: { - name: string; - isWorkspace: boolean; - } | null; + xcodeProject: IOSProjectInfo | null; } export interface IOSDependencyConfig { diff --git a/packages/platform-ios/src/commands/runIOS/index.ts b/packages/platform-ios/src/commands/runIOS/index.ts index 9991756d0..98272b37d 100644 --- a/packages/platform-ios/src/commands/runIOS/index.ts +++ b/packages/platform-ios/src/commands/runIOS/index.ts @@ -11,11 +11,9 @@ import child_process, { // @ts-ignore SpawnOptionsWithoutStdio, } from 'child_process'; -import fs from 'fs'; import path from 'path'; import chalk from 'chalk'; -import {Config} from '@react-native-community/cli-types'; -import findXcodeProject, {ProjectInfo} from '../../config/findXcodeProject'; +import {Config, IOSProjectInfo} from '@react-native-community/cli-types'; import parseIOSDevicesList from './parseIOSDevicesList'; import parseXctraceIOSDevicesList from './parseXctraceIOSDevicesList'; import findMatchingSimulator from './findMatchingSimulator'; @@ -121,7 +119,7 @@ function runIOS(_: Array, ctx: Config, args: FlagsT) { } async function runOnSimulator( - xcodeProject: ProjectInfo, + xcodeProject: IOSProjectInfo, scheme: string, args: FlagsT, ) { @@ -237,7 +235,7 @@ async function runOnSimulator( async function runOnDevice( selectedDevice: Device, scheme: string, - xcodeProject: ProjectInfo, + xcodeProject: IOSProjectInfo, args: FlagsT, ) { const isIOSDeployInstalled = child_process.spawnSync( @@ -302,7 +300,7 @@ async function runOnDevice( } function buildProject( - xcodeProject: ProjectInfo, + xcodeProject: IOSProjectInfo, udid: string | undefined, scheme: string, args: FlagsT, @@ -417,7 +415,7 @@ function getTargetPaths(buildSettings: string) { } function getBuildPath( - xcodeProject: ProjectInfo, + xcodeProject: IOSProjectInfo, configuration: string, buildOutput: string, scheme: string, diff --git a/packages/platform-ios/src/config/findXcodeProject.ts b/packages/platform-ios/src/config/findXcodeProject.ts index bed01013e..1dedee096 100644 --- a/packages/platform-ios/src/config/findXcodeProject.ts +++ b/packages/platform-ios/src/config/findXcodeProject.ts @@ -7,13 +7,9 @@ */ import path from 'path'; +import {IOSProjectInfo} from '@react-native-community/cli-types'; -export type ProjectInfo = { - name: string; - isWorkspace: boolean; -}; - -function findXcodeProject(files: Array): ProjectInfo | null { +function findXcodeProject(files: Array): IOSProjectInfo | null { const sortedFiles = files.sort(); for (let i = sortedFiles.length - 1; i >= 0; i--) { const fileName = files[i]; From b3e0730c2a7cd73ac643b082f7dbd48bf552da9d Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:07:22 +0100 Subject: [PATCH 12/39] chore: remove tests for missing properties, prefer snapshots instead for broader coverage --- .../config/__tests__/getProjectConfig.test.ts | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/packages/platform-android/src/config/__tests__/getProjectConfig.test.ts b/packages/platform-android/src/config/__tests__/getProjectConfig.test.ts index ab74d77f1..20037a6b5 100644 --- a/packages/platform-android/src/config/__tests__/getProjectConfig.test.ts +++ b/packages/platform-android/src/config/__tests__/getProjectConfig.test.ts @@ -56,12 +56,7 @@ describe('android::getProjectConfig', () => { const folder = '/nested'; const config = getProjectConfig(folder, userConfig); - expect(config).toMatchObject({ - sourceDir: '/nested/android', - appName: 'app', - packageName: 'com.some.example', - manifestPath: '/nested/android/app/src/AndroidManifest.xml', - }); + expect(config).toMatchSnapshot(); }); it('flat structure', () => { @@ -69,12 +64,7 @@ describe('android::getProjectConfig', () => { const folder = '/flat'; const config = getProjectConfig(folder, userConfig); - expect(config).toMatchObject({ - sourceDir: '/flat/android', - appName: '', - packageName: 'com.some.example', - manifestPath: '/flat/android/src/AndroidManifest.xml', - }); + expect(config).toMatchSnapshot(); }); it('multiple', () => { @@ -82,14 +72,9 @@ describe('android::getProjectConfig', () => { manifestPath: 'src/main/AndroidManifest.xml', }; const folder = '/multiple'; - const config = getProjectConfig(folder, userConfig); - expect(config).toMatchObject({ - sourceDir: '/multiple/android', - appName: '', - packageName: 'com.some.example', - manifestPath: '/multiple/android/src/main/AndroidManifest.xml', - }); + + expect(config).toMatchSnapshot(); }); }); @@ -99,14 +84,4 @@ describe('android::getProjectConfig', () => { expect(getProjectConfig(folder, userConfig)).toBeNull(); }); - - it('should correctly resolve mainFilePath', () => { - const userConfig = {}; - const folder = '/nested'; - - const config = getProjectConfig(folder, userConfig); - expect(config.mainFilePath).toEqual( - '/nested/android/app/src/main/java/com/some/example/MainApplication.java', - ); - }); }); From 16996b3e6188c4eb4a1f50b7481cc561943754ba Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:10:41 +0100 Subject: [PATCH 13/39] chore: update snapshots for iOS config (removed properties) --- .../__snapshots__/index-test.ts.snap | 81 ------------------- .../cli-config/src/__tests__/index-test.ts | 12 --- 2 files changed, 93 deletions(-) diff --git a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap index 4b11e87ce..36602ec82 100644 --- a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap +++ b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap @@ -2,27 +2,15 @@ exports[`should apply build types from dependency config 1`] = ` Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { "configurations": Array [ "debug", ], - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": null, - "projectName": "HelloWorld.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "<>/node_modules/react-native-test/ios", }, }, "root": "<>/node_modules/react-native-test", @@ -31,7 +19,6 @@ Object { exports[`should have a valid structure by default 1`] = ` Object { - "assets": Array [], "commands": Array [], "dependencies": Object {}, "healthChecks": Array [], @@ -55,56 +42,15 @@ Array [ ] `; -exports[`should merge project configuration with default values: snapshoting \`react-native-test\` config 1`] = ` -Object { - "assets": Array [ - "foo", - ], - "hooks": Object {}, - "name": "react-native-test", - "params": Array [], - "platforms": Object { - "android": null, - "ios": Object { - "configurations": Array [], - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, - "podspecPath": null, - "projectName": "HelloWorld.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj", - "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "./abc", - }, - }, - "root": "<>/node_modules/react-native-test", -} -`; - exports[`should read a config of a dependency and use it to load other settings 1`] = ` Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { "configurations": Array [], - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/customLocation/customProject.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", - "projectName": "customProject.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/customLocation/customProject.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "<>/node_modules/react-native-test/customLocation", }, }, "root": "<>/node_modules/react-native-test", @@ -114,10 +60,7 @@ Object { exports[`should return dependencies from package.json 1`] = ` Object { "react-native": Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native", - "params": Array [], "platforms": Object { "android": null, "ios": null, @@ -125,25 +68,13 @@ Object { "root": "<>/node_modules/react-native", }, "react-native-test": Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { "configurations": Array [], - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": null, - "projectName": "HelloWorld.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "<>/node_modules/react-native-test/ios", }, }, "root": "<>/node_modules/react-native-test", @@ -157,27 +88,15 @@ exports[`should skip packages that have invalid configuration: logged warning 1` exports[`supports dependencies from user configuration with custom build type 1`] = ` Object { - "assets": Array [], - "hooks": Object {}, "name": "react-native-test", - "params": Array [], "platforms": Object { "android": null, "ios": Object { "configurations": Array [ "custom_build_type", ], - "folder": "<>/node_modules/react-native-test", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": null, - "projectName": "HelloWorld.xcodeproj", - "projectPath": "<>/node_modules/react-native-test/ios/HelloWorld.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "<>/node_modules/react-native-test/ios", }, }, "root": "<>/node_modules/react-native-test", diff --git a/packages/cli-config/src/__tests__/index-test.ts b/packages/cli-config/src/__tests__/index-test.ts index b1100fdaf..a4a9d214b 100644 --- a/packages/cli-config/src/__tests__/index-test.ts +++ b/packages/cli-config/src/__tests__/index-test.ts @@ -260,25 +260,13 @@ module.exports = { const {dependencies} = loadConfig(DIR); expect(removeString(dependencies['local-lib'], DIR)).toMatchInlineSnapshot(` Object { - "assets": Array [], - "hooks": Object {}, "name": "local-lib", - "params": Array [], "platforms": Object { "android": null, "ios": Object { "configurations": Array [], - "folder": "<>/native-libs/local-lib", - "libraryFolder": "Libraries", - "pbxprojPath": "<>/native-libs/local-lib/ios/LocalRNLibrary.xcodeproj/project.pbxproj", - "plist": Array [], - "podfile": null, "podspecPath": "custom-path", - "projectName": "LocalRNLibrary.xcodeproj", - "projectPath": "<>/native-libs/local-lib/ios/LocalRNLibrary.xcodeproj", "scriptPhases": Array [], - "sharedLibraries": Array [], - "sourceDir": "<>/native-libs/local-lib/ios", }, }, "root": "<>/native-libs/local-lib", From a67a5a662d058ebf77af3dd9716a10ef04133073 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:13:34 +0100 Subject: [PATCH 14/39] chore: fix upgrade tests --- .../src/commands/upgrade/__tests__/upgrade-testing-methods.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/upgrade/__tests__/upgrade-testing-methods.ts b/packages/cli/src/commands/upgrade/__tests__/upgrade-testing-methods.ts index 40d45b3fe..324a56596 100644 --- a/packages/cli/src/commands/upgrade/__tests__/upgrade-testing-methods.ts +++ b/packages/cli/src/commands/upgrade/__tests__/upgrade-testing-methods.ts @@ -152,7 +152,7 @@ const fetchesRegularPatchInstallRemoteAppliesPatchInstallsDepsRemovesRemote = as [newVersion], merge(ctx, { project: { - ios: {projectName: 'TestApp.xcodeproj'}, + ios: {xcodeProject: {name: 'TestApp.xcodeproj'}}, android: {packageName: 'com.testapp'}, }, }), @@ -218,7 +218,7 @@ const worksWithNameIosAndNameAndroid = async (newVersion) => { [newVersion], merge(ctx, { project: { - ios: {projectName: 'CustomIos.xcodeproj'}, + ios: {xcodeProject: {name: 'CustomIos.xcodeproj'}}, android: {packageName: 'co.uk.customandroid.app'}, }, }), From 65f4335af40135265606be9fe70753c67438e02b Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:26:37 +0100 Subject: [PATCH 15/39] chore: remove extra tests --- __e2e__/install.test.ts | 38 ----------------------- __e2e__/uninstall.test.ts | 63 --------------------------------------- 2 files changed, 101 deletions(-) delete mode 100644 __e2e__/install.test.ts delete mode 100644 __e2e__/uninstall.test.ts diff --git a/__e2e__/install.test.ts b/__e2e__/install.test.ts deleted file mode 100644 index 1b2c52c88..000000000 --- a/__e2e__/install.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import path from 'path'; -import { - runCLI, - getTempDirectory, - cleanupSync, - writeFiles, -} from '../jest/helpers'; - -const DIR = getTempDirectory('command-install-test'); -const pkg = 'react-native-config'; - -beforeEach(() => { - cleanupSync(DIR); - writeFiles(DIR, { - 'node_modules/react-native/package.json': '{}', - 'package.json': '{}', - }); -}); -afterEach(() => cleanupSync(DIR)); - -test.each(['yarn', 'npm'])('install module with %s', (pm) => { - if (pm === 'yarn') { - writeFiles(DIR, {'yarn.lock': ''}); - } - const {stdout, code} = runCLI(DIR, ['install', pkg]); - - expect(stdout).toContain(`Installing "${pkg}"`); - expect(stdout).toContain(`Linking "${pkg}"`); - // TODO – this behavior is a bug, linking should fail/warn without native deps - // to link. Not a high priority since we're changing how link works - expect(stdout).toContain(`Successfully installed and linked "${pkg}"`); - expect(require(path.join(DIR, 'package.json'))).toMatchObject({ - dependencies: { - [pkg]: expect.any(String), - }, - }); - expect(code).toBe(0); -}); diff --git a/__e2e__/uninstall.test.ts b/__e2e__/uninstall.test.ts deleted file mode 100644 index 56c4be551..000000000 --- a/__e2e__/uninstall.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { - runCLI, - getTempDirectory, - cleanupSync, - writeFiles, -} from '../jest/helpers'; - -const DIR = getTempDirectory('command-uninstall-test'); -const pkg = 'react-native-config'; - -beforeEach(() => { - cleanupSync(DIR); - writeFiles(DIR, { - 'node_modules/react-native/package.json': '{}', - 'node_modules/react-native-config/package.json': '{}', - 'package.json': `{ - "dependencies": { - "react-native-config": "*" - } - }`, - }); -}); -afterEach(() => cleanupSync(DIR)); - -test('uninstall fails when package is not defined', () => { - writeFiles(DIR, { - 'package.json': `{ - "dependencies": {} - }`, - }); - const {stderr, code} = runCLI(DIR, ['uninstall'], { - expectedFailure: true, - }); - - expect(stderr).toContain('missing required argument'); - expect(code).toBe(1); -}); - -test('uninstall fails when package is not installed', () => { - writeFiles(DIR, { - 'package.json': `{ - "dependencies": {} - }`, - }); - const {stderr, code} = runCLI(DIR, ['uninstall', pkg], { - expectedFailure: true, - }); - - expect(stderr).toContain(`Failed to unlink "${pkg}".`); - expect(code).toBe(1); -}); - -test.each(['yarn', 'npm'])('uninstall module with %s', (pm) => { - if (pm === 'yarn') { - writeFiles(DIR, {'yarn.lock': ''}); - } - const {stdout, code} = runCLI(DIR, ['uninstall', pkg]); - - expect(stdout).toContain(`Unlinking "${pkg}"`); - expect(stdout).toContain(`Uninstalling "${pkg}"`); - expect(stdout).toContain(`Successfully uninstalled and unlinked "${pkg}"`); - expect(code).toBe(0); -}); From edf3175540c8bd84b1452fde31d68ff947e9ad27 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:26:46 +0100 Subject: [PATCH 16/39] chore: update config tests --- .../__tests__/__snapshots__/index-test.ts.snap | 16 ++++++++++++++++ packages/cli-config/src/__tests__/index-test.ts | 6 ------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap index 36602ec82..69e9df6ab 100644 --- a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap +++ b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap @@ -42,6 +42,22 @@ Array [ ] `; +exports[`should merge project configuration with default values: snapshoting \`react-native-test\` config 1`] = ` +Object { + "name": "react-native-test", + "platforms": Object { + "android": null, + "ios": Object { + "configurations": Array [], + "podspecPath": null, + "scriptPhases": Array [], + "sourceDir": "./abc", + }, + }, + "root": "<>/node_modules/react-native-test", +} +`; + exports[`should read a config of a dependency and use it to load other settings 1`] = ` Object { "name": "react-native-test", diff --git a/packages/cli-config/src/__tests__/index-test.ts b/packages/cli-config/src/__tests__/index-test.ts index a4a9d214b..76dd2080e 100644 --- a/packages/cli-config/src/__tests__/index-test.ts +++ b/packages/cli-config/src/__tests__/index-test.ts @@ -121,11 +121,6 @@ test('should merge project configuration with default values', () => { writeFiles(DIR, { ...REACT_NATIVE_MOCK, 'node_modules/react-native-test/package.json': '{}', - 'node_modules/react-native-test/react-native.config.js': `module.exports = { - dependency: { - assets: ["foo", "baz"] - } - }`, 'node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj': '', 'package.json': `{ @@ -143,7 +138,6 @@ test('should merge project configuration with default values', () => { sourceDir: "./abc" } }, - assets: ["foo"] } } }`, From 3854ee320f6214f9d5a3422d88bbc9b86172f23c Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:27:05 +0100 Subject: [PATCH 17/39] chore: two tests tbd to support new resolution mechanism --- .../config/__tests__/getProjectConfig.test.ts | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts index cfe0cc9b0..e8af74718 100644 --- a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts +++ b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts @@ -22,29 +22,7 @@ describe('ios::getProjectConfig', () => { fs.__setMockFilesystem({testDir: projects}); }); - it('returns an object with ios project configuration', () => { - const folder = '/testDir/nested'; + it.skip('returns `null` if Podfile was not found', () => {}); - expect(getProjectConfig(folder, userConfig)).not.toBeNull(); - expect(typeof getProjectConfig(folder, userConfig)).toBe('object'); - }); - - it('returns `null` if ios project was not found', () => { - const folder = '/testDir/empty'; - - expect(getProjectConfig(folder, userConfig)).toBeNull(); - }); - - it('returns normalized shared library names', () => { - const projectConfig = getProjectConfig('/testDir/nested', { - sharedLibraries: ['libc++', 'libz.tbd', 'HealthKit', 'HomeKit.framework'], - }); - - expect(projectConfig.sharedLibraries).toEqual([ - 'libc++.tbd', - 'libz.tbd', - 'HealthKit.framework', - 'HomeKit.framework', - ]); - }); + it.skip(`returns an object with ios project configuration`, () => {}); }); From f8a9adef113e4cb8f7f3cd61b768198e08438d90 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 21:54:39 +0100 Subject: [PATCH 18/39] chore: fix ios tests and bring back configurable sourceDir --- packages/cli-types/src/ios.ts | 4 +- .../__tests__/runOnAllDevices.test.ts | 55 ++++++------------- .../getProjectConfig.test.ts.snap | 28 ++++++++++ .../__tests__/getAndroidProject.test.ts | 1 - packages/platform-android/src/config/index.ts | 1 + .../src/config/__fixtures__/projects.ts | 50 +++++++---------- .../config/__tests__/findPodfilePath.test.ts | 10 ++-- .../src/config/__tests__/findPodspec.test.ts | 7 ++- .../config/__tests__/getProjectConfig.test.ts | 8 +-- 9 files changed, 80 insertions(+), 84 deletions(-) create mode 100644 packages/platform-android/src/config/__tests__/__snapshots__/getProjectConfig.test.ts.snap delete mode 100644 packages/platform-android/src/config/__tests__/getAndroidProject.test.ts diff --git a/packages/cli-types/src/ios.ts b/packages/cli-types/src/ios.ts index 353315fbe..990949099 100644 --- a/packages/cli-types/src/ios.ts +++ b/packages/cli-types/src/ios.ts @@ -3,7 +3,9 @@ * When performing changes, make sure to sync it with the Ruby file. */ -export interface IOSProjectParams {} +export interface IOSProjectParams { + sourceDir?: string; +} export type IOSProjectInfo = { name: string; diff --git a/packages/platform-android/src/commands/runAndroid/__tests__/runOnAllDevices.test.ts b/packages/platform-android/src/commands/runAndroid/__tests__/runOnAllDevices.test.ts index 540861c06..d96794aa2 100644 --- a/packages/platform-android/src/commands/runAndroid/__tests__/runOnAllDevices.test.ts +++ b/packages/platform-android/src/commands/runAndroid/__tests__/runOnAllDevices.test.ts @@ -8,13 +8,15 @@ import runOnAllDevices from '../runOnAllDevices'; import execa from 'execa'; +import {Flags} from '..'; +import {AndroidProjectConfig} from '@react-native-community/cli-types'; jest.mock('execa'); jest.mock('../getAdbPath'); jest.mock('../tryLaunchEmulator'); describe('--appFolder', () => { - const args = { + const args: Flags = { root: '/root', appFolder: undefined, appId: '', @@ -27,20 +29,12 @@ describe('--appFolder', () => { port: 8081, terminal: 'iTerm2', jetifier: true, + activeArchOnly: false, }; - const androidProject = { - manifestPath: '/android/app/src/main/AndroidManifest.xml', + const androidProject: AndroidProjectConfig = { appName: 'app', packageName: 'com.test', sourceDir: '/android', - isFlat: false, - folder: '', - stringsPath: '', - buildGradlePath: '', - settingsGradlePath: '', - assetsPath: '', - mainFilePath: '', - packageFolder: '', }; beforeEach(() => { jest.clearAllMocks(); @@ -50,7 +44,6 @@ describe('--appFolder', () => { await runOnAllDevices( {...args, variant: 'debug'}, './gradlew', - 'com.testapp', 'adb', androidProject, ); @@ -60,13 +53,10 @@ describe('--appFolder', () => { }); it('uses appName and default variant', async () => { - await runOnAllDevices( - {...args, variant: 'debug'}, - './gradlew', - 'com.testapp', - 'adb', - {...androidProject, appName: 'someApp'}, - ); + await runOnAllDevices({...args, variant: 'debug'}, './gradlew', 'adb', { + ...androidProject, + appName: 'someApp', + }); expect(((execa as unknown) as jest.Mock).mock.calls[0][1]).toContain( 'someApp:installDebug', @@ -74,13 +64,10 @@ describe('--appFolder', () => { }); it('uses appName and custom variant', async () => { - await runOnAllDevices( - {...args, variant: 'staging'}, - './gradlew', - 'com.testapp', - 'adb', - {...androidProject, appName: 'anotherApp'}, - ); + await runOnAllDevices({...args, variant: 'staging'}, './gradlew', 'adb', { + ...androidProject, + appName: 'anotherApp', + }); expect(((execa as unknown) as jest.Mock).mock.calls[0][1]).toContain( 'anotherApp:installStaging', @@ -91,7 +78,6 @@ describe('--appFolder', () => { await runOnAllDevices( {...args, appFolder: 'someApp', variant: 'debug'}, './gradlew', - 'com.testapp', 'adb', androidProject, ); @@ -105,7 +91,6 @@ describe('--appFolder', () => { await runOnAllDevices( {...args, appFolder: 'anotherApp', variant: 'staging'}, './gradlew', - 'com.testapp', 'adb', androidProject, ); @@ -119,7 +104,6 @@ describe('--appFolder', () => { await runOnAllDevices( {...args, tasks: ['someTask']}, './gradlew', - 'com.testapp', 'adb', androidProject, ); @@ -130,13 +114,10 @@ describe('--appFolder', () => { }); it('uses appName and custom task argument', async () => { - await runOnAllDevices( - {...args, tasks: ['someTask']}, - './gradlew', - 'com.testapp', - 'adb', - {...androidProject, appName: 'anotherApp'}, - ); + await runOnAllDevices({...args, tasks: ['someTask']}, './gradlew', 'adb', { + ...androidProject, + appName: 'anotherApp', + }); expect(((execa as unknown) as jest.Mock).mock.calls[0][1]).toContain( 'anotherApp:someTask', @@ -147,7 +128,6 @@ describe('--appFolder', () => { await runOnAllDevices( {...args, appFolder: 'anotherApp', tasks: ['someTask'], variant: 'debug'}, './gradlew', - 'com.testapp', 'adb', {...androidProject, appName: 'anotherApp'}, ); @@ -161,7 +141,6 @@ describe('--appFolder', () => { await runOnAllDevices( {...args, tasks: ['clean', 'someTask']}, './gradlew', - 'com.testapp', 'adb', androidProject, ); diff --git a/packages/platform-android/src/config/__tests__/__snapshots__/getProjectConfig.test.ts.snap b/packages/platform-android/src/config/__tests__/__snapshots__/getProjectConfig.test.ts.snap new file mode 100644 index 000000000..cbc399249 --- /dev/null +++ b/packages/platform-android/src/config/__tests__/__snapshots__/getProjectConfig.test.ts.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`android::getProjectConfig returns an object with android project configuration for flat structure 1`] = ` +Object { + "appName": "", + "dependencyConfiguration": undefined, + "packageName": "com.some.example", + "sourceDir": "/flat/android", +} +`; + +exports[`android::getProjectConfig returns an object with android project configuration for multiple 1`] = ` +Object { + "appName": "", + "dependencyConfiguration": undefined, + "packageName": "com.some.example", + "sourceDir": "/multiple/android", +} +`; + +exports[`android::getProjectConfig returns an object with android project configuration for nested structure 1`] = ` +Object { + "appName": "app", + "dependencyConfiguration": undefined, + "packageName": "com.some.example", + "sourceDir": "/nested/android", +} +`; diff --git a/packages/platform-android/src/config/__tests__/getAndroidProject.test.ts b/packages/platform-android/src/config/__tests__/getAndroidProject.test.ts deleted file mode 100644 index 59bca1f94..000000000 --- a/packages/platform-android/src/config/__tests__/getAndroidProject.test.ts +++ /dev/null @@ -1 +0,0 @@ -// @todo diff --git a/packages/platform-android/src/config/index.ts b/packages/platform-android/src/config/index.ts index 0cf8c2199..d4cb2e96b 100644 --- a/packages/platform-android/src/config/index.ts +++ b/packages/platform-android/src/config/index.ts @@ -33,6 +33,7 @@ export function projectConfig( } const sourceDir = path.join(root, src); + const appName = getAppName(sourceDir, userConfig.appName); const manifestPath = userConfig.manifestPath diff --git a/packages/platform-ios/src/config/__fixtures__/projects.ts b/packages/platform-ios/src/config/__fixtures__/projects.ts index 1a5af665d..7b10ea09f 100644 --- a/packages/platform-ios/src/config/__fixtures__/projects.ts +++ b/packages/platform-ios/src/config/__fixtures__/projects.ts @@ -3,41 +3,29 @@ const path = jest.requireActual('path'); // @ts-ignore const fs = jest.requireActual('fs'); -const ios = { - 'demoProject.xcodeproj': { - 'project.pbxproj': fs.readFileSync( - path.join(__dirname, './files/project.pbxproj'), - ), - }, +export const projectWithPodfileOnly = { + ios: {}, }; -const iosPod = { - 'demoProject.xcodeproj': { - 'project.pbxproj': fs.readFileSync( - path.join(__dirname, './files/project.pbxproj'), - ), +export const project = { + ios: { + Podfile: 'content', + 'demoProject.xcodeproj': { + 'project.pbxproj': fs.readFileSync( + path.join(__dirname, './files/project.pbxproj'), + ), + }, }, - 'TestPod.podspec': 'empty', -}; - -export const flat = { - ios, -}; - -export const nested = { - ios, }; export const withExamples = { - Examples: flat, - ios, -}; - -export const withPods = { - Podfile: 'content', - ios: iosPod, -}; - -export const withoutPods = { - ios, + ...project, + Examples: { + Podfile: 'content', + 'exampleProject.xcodeproj': { + 'project.pbxproj': fs.readFileSync( + path.join(__dirname, './files/project.pbxproj'), + ), + }, + }, }; diff --git a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts index d8bfe7904..513276260 100644 --- a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts +++ b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts @@ -1,4 +1,6 @@ +import path from 'path'; import findPodfilePath from '../findPodfilePath'; + import * as projects from '../__fixtures__/projects'; jest.mock('path'); @@ -8,12 +10,12 @@ const fs = require('fs'); describe('ios::findPodfilePath', () => { it('returns null if there is no Podfile', () => { - fs.__setMockFilesystem(projects.withoutPods); - expect(findPodfilePath(process.cwd(), '')).toBeNull(); + fs.__setMockFilesystem({}); + expect(findPodfilePath('/')).toBeNull(); }); it('returns Podfile path if it exists', () => { - fs.__setMockFilesystem(projects.withPods); - expect(findPodfilePath(process.cwd(), '/ios')).toContain('Podfile'); + fs.__setMockFilesystem(projects.project); + expect(findPodfilePath('/')).toContain('ios/Podfile'); }); }); diff --git a/packages/platform-ios/src/config/__tests__/findPodspec.test.ts b/packages/platform-ios/src/config/__tests__/findPodspec.test.ts index 42faa57a1..e162ca5e8 100644 --- a/packages/platform-ios/src/config/__tests__/findPodspec.test.ts +++ b/packages/platform-ios/src/config/__tests__/findPodspec.test.ts @@ -7,7 +7,6 @@ */ import findPodspec from '../findPodspec'; -import * as projects from '../__fixtures__/projects'; jest.mock('path'); jest.mock('fs'); @@ -16,12 +15,14 @@ const fs = require('fs'); describe('ios::findPodspec', () => { it('returns null if there is not podspec file', () => { - fs.__setMockFilesystem(projects.flat); + fs.__setMockFilesystem({}); expect(findPodspec('')).toBeNull(); }); it('returns podspec name if only one exists', () => { - fs.__setMockFilesystem(projects.withPods.ios); + fs.__setMockFilesystem({ + 'TestPod.podspec': 'empty', + }); expect(findPodspec('/')).toBe('/TestPod.podspec'); }); diff --git a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts index e8af74718..bc048c661 100644 --- a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts +++ b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts @@ -6,8 +6,6 @@ * */ -import * as projects from '../__fixtures__/projects'; - jest.mock('path'); jest.mock('fs'); @@ -18,11 +16,9 @@ const getProjectConfig = require('../').projectConfig; describe('ios::getProjectConfig', () => { const userConfig = {}; - beforeEach(() => { - fs.__setMockFilesystem({testDir: projects}); - }); - it.skip('returns `null` if Podfile was not found', () => {}); it.skip(`returns an object with ios project configuration`, () => {}); + + it.skip(`returns correct configuration when multiple Podfile are present`, () => {}); }); From 1c9508e62a34ad316919612928e26642379ce171 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 22:16:25 +0100 Subject: [PATCH 19/39] feat: align findPodfilePath with old findProject heuristics --- .../src/config/findPodfilePath.ts | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/packages/platform-ios/src/config/findPodfilePath.ts b/packages/platform-ios/src/config/findPodfilePath.ts index 685a1883b..3a5d909ad 100644 --- a/packages/platform-ios/src/config/findPodfilePath.ts +++ b/packages/platform-ios/src/config/findPodfilePath.ts @@ -9,13 +9,43 @@ import glob from 'glob'; import path from 'path'; -export default function findPodfilePath(folder: string) { - const podfiles = glob.sync('**/Podfile', { - cwd: folder, - ignore: 'node_modules/**', - }); +// Regexp matching all test projects +const TEST_PROJECTS = /test|example|sample/i; + +// Base iOS folder +const IOS_BASE = 'ios'; + +// These folders will be excluded from search to speed it up +const GLOB_EXCLUDE_PATTERN = ['**/@(Pods|node_modules|Carthage)/**']; + +export default function findPodfilePath(cwd: string) { + /** + * First, we're going to look for all Podfiles within the `cwd` + */ + const podfiles = glob + .sync('**/Podfile', { + cwd, + ignore: GLOB_EXCLUDE_PATTERN, + }) + /** + * Then, we will run a simple test to rule out most example projects, + * unless they are located in a `ios` folder + */ + .filter( + (project) => + path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project), + ) + /** + * Podfile from `ios` folder will be picked up as a first one. + */ + .sort((project) => (path.dirname(project) === IOS_BASE ? -1 : 1)); + if (podfiles.length > 0) { - return path.join(folder, podfiles[0]); + /** + * @todo + * Shall we print a warning when multiple `Podfile` were found? + */ + return path.join(cwd, podfiles[0]); } return null; From be963e130d6f7995b49570512f8b53dbf33bc44a Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 22:21:27 +0100 Subject: [PATCH 20/39] chore: fix lint --- .../src/config/__tests__/findPodfilePath.test.ts | 1 - .../src/config/__tests__/getProjectConfig.test.ts | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts index 513276260..79cfbb6cb 100644 --- a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts +++ b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts @@ -1,4 +1,3 @@ -import path from 'path'; import findPodfilePath from '../findPodfilePath'; import * as projects from '../__fixtures__/projects'; diff --git a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts index bc048c661..ca1e99add 100644 --- a/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts +++ b/packages/platform-ios/src/config/__tests__/getProjectConfig.test.ts @@ -9,16 +9,8 @@ jest.mock('path'); jest.mock('fs'); -const fs = require('fs'); - -const getProjectConfig = require('../').projectConfig; - describe('ios::getProjectConfig', () => { - const userConfig = {}; - it.skip('returns `null` if Podfile was not found', () => {}); - - it.skip(`returns an object with ios project configuration`, () => {}); - - it.skip(`returns correct configuration when multiple Podfile are present`, () => {}); + it.skip('returns an object with ios project configuration', () => {}); + it.skip('returns correct configuration when multiple Podfile are present', () => {}); }); From 194ee758d8704ace19155f50eb2b905c65a6ea0d Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 22:31:29 +0100 Subject: [PATCH 21/39] chore: update snapshot --- __e2e__/__snapshots__/config.test.ts.snap | 24 ++++------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/__e2e__/__snapshots__/config.test.ts.snap b/__e2e__/__snapshots__/config.test.ts.snap index 3b19df155..98e235ea8 100644 --- a/__e2e__/__snapshots__/config.test.ts.snap +++ b/__e2e__/__snapshots__/config.test.ts.snap @@ -32,7 +32,6 @@ exports[`shows up current config without unnecessary output 1`] = ` ] } ], - "assets": [], "healthChecks": [], "platforms": { "ios": {}, @@ -41,29 +40,14 @@ exports[`shows up current config without unnecessary output 1`] = ` "project": { "ios": { "sourceDir": "<>/TestProject/ios", - "folder": "<>/TestProject", - "pbxprojPath": "<>/TestProject/ios/TestProject.xcodeproj/project.pbxproj", - "podfile": "<>/TestProject/ios/Podfile", - "podspecPath": null, - "projectPath": "<>/TestProject/ios/TestProject.xcodeproj", - "projectName": "TestProject.xcodeproj", - "libraryFolder": "Libraries", - "sharedLibraries": [], - "plist": [], - "scriptPhases": [] + "xcodeProject": { + "name": "TestProject.xcodeproj", + "isWorkspace": false + } }, "android": { "sourceDir": "<>/TestProject/android", - "isFlat": true, - "folder": "<>/TestProject", - "stringsPath": "<>/TestProject/android/app/src/main/res/values/strings.xml", - "manifestPath": "<>/TestProject/android/app/src/main/AndroidManifest.xml", - "buildGradlePath": "<>/TestProject/android/build.gradle", - "settingsGradlePath": "<>/TestProject/android/settings.gradle", - "assetsPath": "<>/TestProject/android/app/src/main/assets", - "mainFilePath": "<>/TestProject/android/app/src/main/java/com/testproject/MainApplication.java", "packageName": "com.testproject", - "packageFolder": "com/testproject", "appName": "app" } } From 387f9ee5b53ae0b6aedff2e9b60b8d7039ad074b Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 22:38:19 +0100 Subject: [PATCH 22/39] fix: filter invalid deps --- packages/platform-ios/src/config/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index ea178d52e..81e1c17e4 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -28,7 +28,7 @@ export function projectConfig( return null; } - const podfile = findPodfilePath(folder); + const podfile = findPodfilePath(userConfig.sourceDir || folder); /** * In certain repos, the Xcode project can @@ -57,8 +57,14 @@ export function dependencyConfig( folder: string, userConfig: IOSDependencyParams, ) { + const podspecPath = findPodspec(folder); + + if (!podspecPath) { + return null; + } + return { - podspecPath: findPodspec(folder), + podspecPath, configurations: userConfig.configurations || [], scriptPhases: userConfig.scriptPhases || [], }; From 299285f982e4d7682885a0310383099c1d4d695f Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:11:48 +0100 Subject: [PATCH 23/39] chore: update tests --- .../__tests__/__snapshots__/index-test.ts.snap | 13 +++++++------ packages/cli-config/src/__tests__/index-test.ts | 16 ++++++---------- packages/cli-config/src/schema.ts | 1 + 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap index 69e9df6ab..5e6015359 100644 --- a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap +++ b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap @@ -9,7 +9,7 @@ Object { "configurations": Array [ "debug", ], - "podspecPath": null, + "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", "scriptPhases": Array [], }, }, @@ -49,9 +49,10 @@ Object { "android": null, "ios": Object { "configurations": Array [], - "podspecPath": null, - "scriptPhases": Array [], - "sourceDir": "./abc", + "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", + "scriptPhases": Array [ + "./abc", + ], }, }, "root": "<>/node_modules/react-native-test", @@ -89,7 +90,7 @@ Object { "android": null, "ios": Object { "configurations": Array [], - "podspecPath": null, + "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", "scriptPhases": Array [], }, }, @@ -111,7 +112,7 @@ Object { "configurations": Array [ "custom_build_type", ], - "podspecPath": null, + "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", "scriptPhases": Array [], }, }, diff --git a/packages/cli-config/src/__tests__/index-test.ts b/packages/cli-config/src/__tests__/index-test.ts index 76dd2080e..c2c4e7d12 100644 --- a/packages/cli-config/src/__tests__/index-test.ts +++ b/packages/cli-config/src/__tests__/index-test.ts @@ -75,8 +75,7 @@ test('should return dependencies from package.json', () => { writeFiles(DIR, { ...REACT_NATIVE_MOCK, 'node_modules/react-native-test/package.json': '{}', - 'node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj': - '', + 'node_modules/react-native-test/ReactNativeTest.podspec': '', 'package.json': `{ "dependencies": { "react-native": "0.0.1", @@ -121,8 +120,7 @@ test('should merge project configuration with default values', () => { writeFiles(DIR, { ...REACT_NATIVE_MOCK, 'node_modules/react-native-test/package.json': '{}', - 'node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj': - '', + 'node_modules/react-native-test/ReactNativeTest.podspec': '', 'package.json': `{ "dependencies": { "react-native": "0.0.1", @@ -135,7 +133,7 @@ test('should merge project configuration with default values', () => { "react-native-test": { platforms: { ios: { - sourceDir: "./abc" + scriptPhases: ["./abc"] } }, } @@ -225,7 +223,7 @@ test('supports dependencies from user configuration with custom root and propert writeFiles(DIR, { ...REACT_NATIVE_MOCK, - 'native-libs/local-lib/ios/LocalRNLibrary.xcodeproj/project.pbxproj': '', + 'native-libs/local-lib/LocalRNLibrary.podspec': '', 'react-native.config.js': ` const path = require('path'); const root = path.resolve('${escapePathSeparator( @@ -273,8 +271,7 @@ test('should apply build types from dependency config', () => { writeFiles(DIR, { ...REACT_NATIVE_MOCK, 'node_modules/react-native-test/package.json': '{}', - 'node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj': - '', + 'node_modules/react-native-test/ReactNativeTest.podspec': '', 'node_modules/react-native-test/react-native.config.js': `module.exports = { dependency: { platforms: { @@ -313,8 +310,7 @@ test('supports dependencies from user configuration with custom build type', () } }`, 'node_modules/react-native-test/package.json': '{}', - 'node_modules/react-native-test/ios/HelloWorld.xcodeproj/project.pbxproj': - '', + 'node_modules/react-native-test/ReactNativeTest.podspec': '', 'node_modules/react-native-test/react-native.config.js': 'module.exports = {}', 'package.json': `{ diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index 21d80e109..afbbb60cc 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -121,6 +121,7 @@ export const projectConfig = t libraryFolder: t.string(), sharedLibraries: t.array().items(t.string()), configurations: t.array().items(t.string()).default([]), + scriptPhases: t.array().items(t.string()).default([]), }) .allow(null), android: t From d665720ac8f5afaad9744382a2a3ebce66d9d773 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:20:56 +0100 Subject: [PATCH 24/39] chore: add missing properties to Joi schema --- packages/cli-config/src/schema.ts | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index afbbb60cc..1cb6eb98e 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -60,6 +60,7 @@ export const dependencyConfig = t platforms: map(t.string(), t.any()) .keys({ ios: t + // IOSDependencyConfig .object({ project: t.string(), podspecPath: t.string(), @@ -70,9 +71,11 @@ export const dependencyConfig = t }) .default({}), android: t + // AndroidDependencyParams .object({ sourceDir: t.string(), manifestPath: t.string(), + packageName: t.string(), packageImportPath: t.string(), packageInstance: t.string(), dependencyConfiguration: t.string(), @@ -110,24 +113,17 @@ export const projectConfig = t root: t.string(), platforms: map(t.string(), t.any()).keys({ ios: t + // IOSDependencyConfig .object({ - sourceDir: t.string(), - folder: t.string(), - pbxprojPath: t.string(), - podfile: t.string(), podspecPath: t.string(), - projectPath: t.string(), - projectName: t.string(), - libraryFolder: t.string(), - sharedLibraries: t.array().items(t.string()), configurations: t.array().items(t.string()).default([]), scriptPhases: t.array().items(t.string()).default([]), }) .allow(null), android: t + // AndroidDependencyConfig .object({ sourceDir: t.string(), - folder: t.string(), packageImportPath: t.string(), packageInstance: t.string(), dependencyConfiguration: t.string(), @@ -142,24 +138,18 @@ export const projectConfig = t project: map(t.string(), t.any()) .keys({ ios: t + // IOSProjectParams .object({ - project: t.string(), - sharedLibraries: t.array().items(t.string()), - libraryFolder: t.string(), + sourceDir: t.string(), }) .default({}), android: t + // AndroidProjectParams .object({ sourceDir: t.string(), + appName: t.string(), manifestPath: t.string(), packageName: t.string(), - packageFolder: t.string(), - mainFilePath: t.string(), - stringsPath: t.string(), - settingsGradlePath: t.string(), - assetsPath: t.string(), - buildGradlePath: t.string(), - appName: t.string(), dependencyConfiguration: t.string(), }) .default({}), From 020aa16126f5bd1923b62b9509927c16d0591500 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:22:09 +0100 Subject: [PATCH 25/39] chore: another update --- packages/cli-config/src/schema.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index 1cb6eb98e..55d82a3d3 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -60,12 +60,8 @@ export const dependencyConfig = t platforms: map(t.string(), t.any()) .keys({ ios: t - // IOSDependencyConfig + // IOSDependencyParams .object({ - project: t.string(), - podspecPath: t.string(), - sharedLibraries: t.array().items(t.string()), - libraryFolder: t.string(), scriptPhases: t.array().items(t.object()), configurations: t.array().items(t.string()).default([]), }) From 01536908d4d116655dab83c2286a19006919f27b Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:42:27 +0100 Subject: [PATCH 26/39] chore: fix Joi schema --- .../cli-config/src/__tests__/__snapshots__/index-test.ts.snap | 4 +++- packages/cli-config/src/__tests__/index-test.ts | 2 +- packages/cli-config/src/schema.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap index 5e6015359..d70378976 100644 --- a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap +++ b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap @@ -67,7 +67,9 @@ Object { "ios": Object { "configurations": Array [], "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", - "scriptPhases": Array [], + "scriptPhases": Array [ + "./customLocation/custom.sh", + ], }, }, "root": "<>/node_modules/react-native-test", diff --git a/packages/cli-config/src/__tests__/index-test.ts b/packages/cli-config/src/__tests__/index-test.ts index c2c4e7d12..91458dfd1 100644 --- a/packages/cli-config/src/__tests__/index-test.ts +++ b/packages/cli-config/src/__tests__/index-test.ts @@ -97,7 +97,7 @@ test('should read a config of a dependency and use it to load other settings', ( dependency: { platforms: { ios: { - project: "./customLocation/customProject.xcodeproj" + scriptPhases: ["./customLocation/custom.sh"] } } } diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index 55d82a3d3..f46c5c475 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -62,7 +62,7 @@ export const dependencyConfig = t ios: t // IOSDependencyParams .object({ - scriptPhases: t.array().items(t.object()), + scriptPhases: t.array().items(t.string()), configurations: t.array().items(t.string()).default([]), }) .default({}), From f8fd19dd974b3f7aab4e1f215d247a5b175ecc53 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:48:18 +0100 Subject: [PATCH 27/39] chore: update schema --- packages/cli-config/src/schema.ts | 8 ++++++-- packages/cli-types/package.json | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index f46c5c475..b62ea07c6 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -1,3 +1,7 @@ +/** + * This schema is used by `cli-config` to validate the structure. Make sure + * this file stays up to date with `cli-types` package. + */ import t, {SchemaLike} from 'joi'; const map = (key: RegExp | SchemaLike, value: SchemaLike) => @@ -51,7 +55,7 @@ const healthCheck = t.object({ }); /** - * Schema for UserDependencyConfigT + * Schema for UserDependencyConfig */ export const dependencyConfig = t .object({ @@ -98,7 +102,7 @@ export const dependencyConfig = t .default(); /** - * Schema for ProjectConfigT + * Schema for ProjectConfig */ export const projectConfig = t .object({ diff --git a/packages/cli-types/package.json b/packages/cli-types/package.json index a4de42b5e..313ea5933 100644 --- a/packages/cli-types/package.json +++ b/packages/cli-types/package.json @@ -9,6 +9,9 @@ "build", "!*.map" ], + "dependencies": { + "joi": "^17.2.1" + }, "types": "build/index.d.ts", "license": "MIT", "homepage": "https://github.com/react-native-community/cli/tree/master/packages/cli-types", From de1a5d2a20b328d38ca078887bfdb163b5a36970 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:49:25 +0100 Subject: [PATCH 28/39] chore: fix snapshot --- __e2e__/__snapshots__/config.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__e2e__/__snapshots__/config.test.ts.snap b/__e2e__/__snapshots__/config.test.ts.snap index 98e235ea8..f0c98a72f 100644 --- a/__e2e__/__snapshots__/config.test.ts.snap +++ b/__e2e__/__snapshots__/config.test.ts.snap @@ -47,8 +47,8 @@ exports[`shows up current config without unnecessary output 1`] = ` }, "android": { "sourceDir": "<>/TestProject/android", - "packageName": "com.testproject", "appName": "app" + "packageName": "com.testproject", } } } From 2c732a84a89a3cd628a4005b2dc2da95db78358f Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:51:07 +0100 Subject: [PATCH 29/39] chore: note on the future development for this file --- packages/cli-config/src/schema.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index b62ea07c6..e1079bd6f 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -1,6 +1,9 @@ /** * This schema is used by `cli-config` to validate the structure. Make sure * this file stays up to date with `cli-types` package. + * + * In the future, it would be great to generate this file automatically from the + * Typescript types. */ import t, {SchemaLike} from 'joi'; From 60512011e6ee1ba0a549bf439de37b9772c3c80c Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Wed, 2 Feb 2022 23:55:59 +0100 Subject: [PATCH 30/39] chore: update snapshot one more time - nitpick --- __e2e__/__snapshots__/config.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__e2e__/__snapshots__/config.test.ts.snap b/__e2e__/__snapshots__/config.test.ts.snap index f0c98a72f..06c2ae58b 100644 --- a/__e2e__/__snapshots__/config.test.ts.snap +++ b/__e2e__/__snapshots__/config.test.ts.snap @@ -48,7 +48,7 @@ exports[`shows up current config without unnecessary output 1`] = ` "android": { "sourceDir": "<>/TestProject/android", "appName": "app" - "packageName": "com.testproject", + "packageName": "com.testproject" } } } From 361f0c9cdb23499f71593bf65d8cee786b376551 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 3 Feb 2022 00:00:16 +0100 Subject: [PATCH 31/39] one last time --- __e2e__/__snapshots__/config.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__e2e__/__snapshots__/config.test.ts.snap b/__e2e__/__snapshots__/config.test.ts.snap index 06c2ae58b..c63b5c160 100644 --- a/__e2e__/__snapshots__/config.test.ts.snap +++ b/__e2e__/__snapshots__/config.test.ts.snap @@ -47,7 +47,7 @@ exports[`shows up current config without unnecessary output 1`] = ` }, "android": { "sourceDir": "<>/TestProject/android", - "appName": "app" + "appName": "app", "packageName": "com.testproject" } } From 64b4ef797c1c0e3469edf9af6eb0cad60e15eda6 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 3 Feb 2022 19:10:32 +0100 Subject: [PATCH 32/39] feat: print when multiple podfiles are found --- .../__snapshots__/findPodfilePath.test.ts.snap | 9 +++++++++ .../config/__tests__/findPodfilePath.test.ts | 18 +++++++++++++++++- .../platform-ios/src/config/findPodfilePath.ts | 14 ++++++++++---- 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 packages/platform-ios/src/config/__tests__/__snapshots__/findPodfilePath.test.ts.snap diff --git a/packages/platform-ios/src/config/__tests__/__snapshots__/findPodfilePath.test.ts.snap b/packages/platform-ios/src/config/__tests__/__snapshots__/findPodfilePath.test.ts.snap new file mode 100644 index 000000000..52adbf197 --- /dev/null +++ b/packages/platform-ios/src/config/__tests__/__snapshots__/findPodfilePath.test.ts.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ios::findPodfilePath prints a warning when multile Podfiles are found 1`] = ` +Array [ + Array [ + "Multiple Podfiles were found: bar/ios/Podfile,foo/ios/Podfile. Choosing bar/ios/Podfile automatically. If you would like to select a different one, you can configure it via \\"project.ios.sourceDir\\". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md", + ], +] +`; diff --git a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts index 79cfbb6cb..37a366a4c 100644 --- a/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts +++ b/packages/platform-ios/src/config/__tests__/findPodfilePath.test.ts @@ -1,5 +1,5 @@ import findPodfilePath from '../findPodfilePath'; - +import {logger} from '@react-native-community/cli-tools'; import * as projects from '../__fixtures__/projects'; jest.mock('path'); @@ -7,6 +7,10 @@ jest.mock('fs'); const fs = require('fs'); +afterEach(() => { + jest.resetAllMocks(); +}); + describe('ios::findPodfilePath', () => { it('returns null if there is no Podfile', () => { fs.__setMockFilesystem({}); @@ -17,4 +21,16 @@ describe('ios::findPodfilePath', () => { fs.__setMockFilesystem(projects.project); expect(findPodfilePath('/')).toContain('ios/Podfile'); }); + + it('prints a warning when multile Podfiles are found', () => { + const warn = jest.spyOn(logger, 'warn').mockImplementation(); + fs.__setMockFilesystem({ + foo: projects.project, + bar: projects.project, + }); + expect(findPodfilePath('/')).toContain('bar/ios/Podfile'); + expect(warn.mock.calls).toMatchSnapshot(); + }); + + it('igores Podfiles in Example folder', () => {}); }); diff --git a/packages/platform-ios/src/config/findPodfilePath.ts b/packages/platform-ios/src/config/findPodfilePath.ts index 3a5d909ad..be7509fa9 100644 --- a/packages/platform-ios/src/config/findPodfilePath.ts +++ b/packages/platform-ios/src/config/findPodfilePath.ts @@ -6,6 +6,7 @@ * */ +import {inlineString, logger} from '@react-native-community/cli-tools'; import glob from 'glob'; import path from 'path'; @@ -41,10 +42,15 @@ export default function findPodfilePath(cwd: string) { .sort((project) => (path.dirname(project) === IOS_BASE ? -1 : 1)); if (podfiles.length > 0) { - /** - * @todo - * Shall we print a warning when multiple `Podfile` were found? - */ + if (podfiles.length > 1) { + logger.warn( + inlineString(` + Multiple Podfiles were found: ${podfiles}. Choosing ${podfiles[0]} automatically. + If you would like to select a different one, you can configure it via "project.ios.sourceDir". + You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md + `), + ); + } return path.join(cwd, podfiles[0]); } From 00ccd36d16ead849ee109b9e31c797bb494d5cf2 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 3 Feb 2022 19:53:29 +0100 Subject: [PATCH 33/39] update docs --- docs/commands.md | 68 ---------------- docs/dependencies.md | 32 +++----- docs/platforms.md | 7 +- docs/plugins.md | 71 +++-------------- docs/projects.md | 78 ++++++++++--------- .../src/config/findXcodeProject.ts | 35 +++++++++ packages/platform-ios/src/config/index.ts | 9 +-- 7 files changed, 110 insertions(+), 190 deletions(-) diff --git a/docs/commands.md b/docs/commands.md index e36588124..0bfd2335b 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -7,16 +7,12 @@ React Native CLI comes with following commands: - [`doctor`](#doctor) - [`init`](#init) - [`info`](#info) -- [`install`](#install) -- [`link`](#link) - [`log-android`](#log-android) - [`log-ios`](#log-ios) - [`ram-bundle`](#ram-bundle) - [`run-android`](#run-android) - [`run-ios`](#run-ios) - [`start`](#start) -- [`uninstall`](#uninstall) -- [`unlink`](#unlink) - [`upgrade`](#upgrade) - [`profile-hermes`](#profile-hermes) @@ -239,38 +235,6 @@ react-native info Get relevant version info about OS, toolchain and libraries. Useful when sending bug reports. -### `install` - -Usage: - -```sh -react-native install -``` - -Installs single package from npm and then links native dependencies. If `install` detects `yarn.lock` in your project, it will use Yarn as package manager. Otherwise `npm` will be used. - -### `link` - -> Will be replaced by [autolinking](./autolinking.md) soon. - -Usage: - -```sh -react-native link [packageName] -``` - -Links assets and optionally native modules. - -#### Options - -#### `--all` - -Link all native modules and assets. - -#### `--platforms [list]` - -Pass comma-separated list of platforms to scope `link` to. - ### `log-android` Usage: @@ -425,10 +389,6 @@ Explicitly set the scheme configuration to use default: 'Debug'. Explicitly set Xcode scheme to use. -#### `--project-path ` - -Path relative to project root where the Xcode project (.xcodeproj) lives. default: 'ios'. - #### `--device [string]` Explicitly set device to use by name. The value is not required if you have a single device connected. @@ -519,34 +479,6 @@ Path to the CLI configuration file Disables interactive mode -### `uninstall` - -Usage: - -```sh -react-native uninstall -``` - -Unlinks single package native dependencies and then uninstalls it from `package.json`. If `uninstall` detects `yarn.lock` in your project, it will use Yarn as package manager. Otherwise `npm` will be used. - -### `unlink` - -> Will be replaced by [autolinking](./autolinking.md) soon. - -Usage: - -``` -react-native unlink [options] -``` - -Unlink native dependency linked with the `link` command. - -#### Options - -#### `--platforms [list]` - -Scope unlinking to specified platforms - ### `upgrade` Usage: diff --git a/docs/dependencies.md b/docs/dependencies.md index 5e936c3a4..30d574519 100644 --- a/docs/dependencies.md +++ b/docs/dependencies.md @@ -1,14 +1,6 @@ # Dependency -A dependency is a JavaScript package that is listed under dependencies present in the project's `package.json`. It can also contain native, platform-specific files that should be linked. - -For example, `lodash` is a dependency that doesn't have any native code to link. On the other hand, `react-native-vector-icons` is a dependency that contains not only native code, but also font assets that the CLI should link. - -By default, CLI analyses the folder structure inside the dependency and looks for assets and native files to link. This simple heuristic works in most of the cases. - -At the same time, a dependency can explicitly set its configuration in case CLI cannot infer it properly. - -## How does it work? +A dependency is a JavaScript package that is listed under dependencies present in the project's `package.json` and contains native, platform-specific code. A dependency can define the following `react-native.config.js` at the root: @@ -16,16 +8,15 @@ A dependency can define the following `react-native.config.js` at the root: module.exports = { dependency: { platforms: { - ios: { - project: './Custom.xcodeproj', - }, + // iOS specific properties go here + ios: {}, + // Android specific properties go here + android: {}, }, }, }; ``` -> The above configuration informs CLI about a custom project location. - ## Dependency interface The following type describes the configuration of a dependency that can be set under `dependency` key inside `react-native.config.js`. @@ -35,6 +26,8 @@ type DependencyConfig = { platforms: { android?: AndroidDependencyParams; ios?: IOSDependencyParams; + + // There can be additional platforms, such as `windows` present [key: string]: any; }; }; @@ -50,7 +43,6 @@ The following settings are available on iOS and Android: ```ts type IOSDependencyConfig = { - podspecPath?: string; scriptPhases?: Array; configurations?: string[]; }; @@ -66,10 +58,6 @@ type AndroidDependencyParams = { }; ``` -#### platforms.ios.podspecPath - -Custom path to `.podspec` file to use when auto-linking. Example: `node_modules/react-native-module/ios/module.podspec`. - #### platforms.ios.scriptPhases An array of iOS script phases to add to the project. Specifying a `path` property with a path relative to the dependency root will load the contents of the file at the path as the script contents. @@ -109,6 +97,10 @@ A relative path to a folder with Android project (Gradle root project), e.g. `./ Path to a custom `AndroidManifest.xml` +#### platforms.android.packageName + +Custom package name to override one from `AndroidManifest.xml` + #### platforms.android.packageImportPath Custom package import. For example: `import com.acme.AwesomePackage;`. @@ -123,7 +115,7 @@ For settings applicable on other platforms, please consult their respective docu An array of build variants or flavors which will include the dependency. If the array is empty, your dependency will be included in all build types. If you're working on a helper library that should only be included in development, such as a replacement for the React Native development menu, you should set this to `['debug']` to avoid shipping the library in a release build. For more details, see [`build variants`](https://developer.android.com/studio/build/build-variants#dependencies). -### platforms.android.dependencyConfiguration +#### platforms.android.dependencyConfiguration A string that defines which method other than `implementation` do you want to use for autolinking inside `build.gradle` i.e: `'embed project(path: ":$dependencyName", configuration: "default")',` - `"dependencyName` will be replaced by the actual package's name. You can achieve the same result by directly defining this key per `dependency` _(without placeholder)_ and it will have higher priority than this option. diff --git a/docs/platforms.md b/docs/platforms.md index 8e4f25c26..1d187ad37 100644 --- a/docs/platforms.md +++ b/docs/platforms.md @@ -66,17 +66,22 @@ module.exports = { }; ``` -> Note: You may find this useful in order to alter the default behavior of your function. For example, on iOS, we find an `.xcodeproj` by globbing the project files and taking the first match. There's a possibility we pick the wrong one in case the project has multiple `.xcodeproj` files. In order to support this use-case, we have allowed users to define an exact path to an iOS project in order to overwrite our `glob` mechanism. +> Note: You may find this useful in order to alter the default behavior of your function. For example, on iOS, we find a `Podfile` by globbing the project files and taking the first match. There's a possibility we pick the wrong one in case the project has multiple `Podfile` files. In order to support this use-case, we have allowed users to define an iOS directory where the desired `Podfile` is located. On Android and iOS, this function returns: ```ts type IOSProjectConfig = { sourceDir: string; + xcodeProject: { + name: string; + isWorkspace: boolean; + } | null; }; type AndroidProjectConfig = { sourceDir: string; + appName: string; packageName: string; dependencyConfiguration?: string; }; diff --git a/docs/plugins.md b/docs/plugins.md index 2d0d27d53..2f5e103b8 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -33,23 +33,23 @@ At the end, an array of commands concatenated from all plugins is passed on to t ```ts type Command = { - name: string, - description?: string, - func: (argv: Array, config: ConfigT, args: Object) => ?Promise, + name: string; + description?: string; + func: (argv: Array, config: ConfigT, args: Object) => ?Promise; options?: Array<{ - name: string, - description?: string, - parse?: (val: string) => any, + name: string; + description?: string; + parse?: (val: string) => any; default?: | string | boolean | number - | ((config: ConfigT) => string | boolean | number), - }>, + | ((config: ConfigT) => string | boolean | number); + }>; examples?: Array<{ - desc: string, - cmd: string, - }>, + desc: string; + cmd: string; + }>; }; ``` @@ -84,7 +84,7 @@ For example, a `--reset-cache` option will result in a `resetCache: true` or `re Just like with a [command name](#name), your option can require a value (e.g. `--port `) or accept an optional one (e.g. `--host [host]`). In this case, you may find [`default`](#optionsdefault) value useful. > Note: Almost all names are accepted, but **there's an exception** for `--version`, we consider it a reserved word and do not guarantee that it will -work as expected, so avoid using it. (see [this](https://github.com/react-native-community/cli/issues/1300) for further details) +> work as expected, so avoid using it. (see [this](https://github.com/react-native-community/cli/issues/1300) for further details) ##### `options.description` @@ -111,50 +111,3 @@ String that describes this particular usage. ##### `examples.cmd` A command with arguments and options (if applicable) that can be run in order to achieve the desired goal. - - -## Migrating from `rnpm` configuration - -The changes are mostly cosmetic so the migration should be pretty straight-forward. - -### Changing the configuration - -A `plugin` property should be renamed to `commands`. - -For example, the following `rnpm` configuration inside `package.json`: - -```json -{ - "rnpm": { - "plugin": "./path-to-commands.js" - } -} -``` - -should be moved to a `react-native.config.js`: - -```js -module.exports = { - commands: require('./path-to-commands.js'), -}; -``` - -provided that `./path-to-commands.js` returns an array of commands. - -### Renaming command options - -If your command accepts options, rename `command` property of each of them to `name`. - -```diff - module.exports = { - name: 'foo', - func: () => console.log('My work'), - options: [ - { -- command: '--reset-cache, --resetCache', -+ name: '--reset-cache, --resetCache', - description: 'Removes cached files', - } - ] - } -``` diff --git a/docs/projects.md b/docs/projects.md index 8c0f73879..18cec02e5 100644 --- a/docs/projects.md +++ b/docs/projects.md @@ -8,18 +8,20 @@ Projects can provide additional properties to alter the CLI behavior, such as cu A project can define a `react-native.config.js` at the root with custom configuration to be picked up by the CLI. -For example, below configuration informs CLI of the additional assets to link and about a custom project location. +For example, below configuration informs CLI about a source directory with iOS files. ```js module.exports = { project: { ios: { - project: './CustomProject.xcodeproj', + sourceDir: './custom-ios-location', }, }, }; ``` +> Note: You may find this useful in scenarios where multiple `Podfile` files are present and CLI chooses the wrong one. When that happens, CLI will print a warning asking you to verify its selection. + You can check all available options below. ## Project interface @@ -28,25 +30,21 @@ You can check all available options below. type ProjectConfigT = { reactNativePath: ?string; project: { - android?: ProjectParamsAndroidT; + android?: AndroidProjectParams; ios?: IOSProjectParams; + // Any additional platforms would appear here + [key: string]: any; + }; + platforms: { + android: AndroidPlatformConfig; + ios: IOSPlatformConfig; + // Any additional platforms would appear here [key: string]: any; }; - platforms: PlatformT; dependencies: { - [key: string]: { - name: string; - root: string; - platforms: { - [key: string]: PlatformSettingsT; - }; - assets: string[]; - hooks: { - [key: string]: string; - }; - }; + [key: string]: DependencyConfig; }; - commands: CommandT[]; + commands: Command[]; }; ``` @@ -64,33 +62,43 @@ In most cases, as a React Native developer, you should not need to define any of The following settings are available on iOS and Android: ```ts +type IOSProjectParams = { + sourceDir?: string; +}; + type AndroidProjectParams = { sourceDir?: string; + appName?: string; manifestPath?: string; packageName?: string; - packageFolder?: string; - mainFilePath?: string; - stringsPath?: string; - settingsGradlePath?: string; - assetsPath?: string; - buildGradlePath?: string; - appName?: string; // A name of the app in the Android `sourceDir`, equivalent to Gradle project name. By default it's `app`. dependencyConfiguration?: string; }; - -type IOSProjectParams = { - project?: string; - podspecPath?: string; - sharedLibraries?: string[]; - libraryFolder?: string; - plist: Array; - scriptPhases?: Array; -}; ``` -### assets +#### project.ios.sourceDir + +A path to a directory where iOS source files are located. In most cases, you shouldn't need to set it, unless you have +multiple `Podfile` files in your project. + +#### project.android.appName + +A name of the app in the Android `sourceDir`, equivalent to Gradle project name. By default it's `app`. + +#### project.android.sourceDir + +See [`dependency.platforms.android.sourceDir`](dependencies.md#platformsandroidsourcedir) + +#### project.android.manifestPath + +See [`dependency.platforms.android.manifestPath`](dependencies.md#platformsandroidmanifestpath) + +#### project.android.packageName + +See [`dependency.platforms.android.packageName`](dependencies.md#platformsandroidpackagename) + +#### project.android.dependencyConfiguration -An array of folders to check for project assets +See [`dependency.platforms.android.configuration`](dependencies.md#platformsandroiddependencyconfiguration) ### platforms @@ -153,4 +161,4 @@ module.exports = { The object provided here is deep merged with the dependency config. Check [`projectConfig`](platforms.md#projectconfig) and [`dependencyConfig`](platforms.md#dependencyConfig) return values for a full list of properties that you can override. -> Note: This is an advanced feature and you should not need to use it mos of the time. +> Note: This is an advanced feature and you should not need to use it most of the time. diff --git a/packages/platform-ios/src/config/findXcodeProject.ts b/packages/platform-ios/src/config/findXcodeProject.ts index 1dedee096..d82beb2cf 100644 --- a/packages/platform-ios/src/config/findXcodeProject.ts +++ b/packages/platform-ios/src/config/findXcodeProject.ts @@ -11,6 +11,41 @@ import {IOSProjectInfo} from '@react-native-community/cli-types'; function findXcodeProject(files: Array): IOSProjectInfo | null { const sortedFiles = files.sort(); + + const [workspaces, projects] = files.reduce<[string[], string[]]>( + ([w, p], fileName) => { + const ext = path.extname(fileName); + if (ext === '.xcworkspace') { + return [[...w, fileName], p]; + } + if (ext === '.xcodeproj') { + return [w, [...p, fileName]]; + } + return [w, p]; + }, + [[], []], + ); + + if (workspaces.length > 0) { + if (workspaces.length > 1) { + + } + return { + workspaces[0], + isWorkspace: true, + }; + } + + if (projects.length > 0) { + if (projects.length > 1) { + + } + return { + name: projects[0], + isWorkspace: false, + } + } + for (let i = sortedFiles.length - 1; i >= 0; i--) { const fileName = files[i]; const ext = path.extname(fileName); diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index 81e1c17e4..c4c588055 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -31,9 +31,8 @@ export function projectConfig( const podfile = findPodfilePath(userConfig.sourceDir || folder); /** - * In certain repos, the Xcode project can - * be generated by a tool. The only file that we can assume to exist on disk - * is `Podfile`. + * In certain repos, the Xcode project can be generated by a tool. + * The only file that we can assume to exist on disk is `Podfile`. */ if (!podfile) { return null; @@ -41,10 +40,6 @@ export function projectConfig( const sourceDir = path.dirname(podfile); - /** - * @todo - * What if there are multiple `xcodeproj` found? Shall we read from a Podfile? - */ const xcodeProject = findXcodeProject(fs.readdirSync(sourceDir)); return { From 59cb6e0abaff92f5c112d8df9029359bf7d09d94 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Thu, 3 Feb 2022 20:10:32 +0100 Subject: [PATCH 34/39] chore: fix --- .../src/config/findXcodeProject.ts | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/packages/platform-ios/src/config/findXcodeProject.ts b/packages/platform-ios/src/config/findXcodeProject.ts index d82beb2cf..9b2f9737c 100644 --- a/packages/platform-ios/src/config/findXcodeProject.ts +++ b/packages/platform-ios/src/config/findXcodeProject.ts @@ -12,40 +12,6 @@ import {IOSProjectInfo} from '@react-native-community/cli-types'; function findXcodeProject(files: Array): IOSProjectInfo | null { const sortedFiles = files.sort(); - const [workspaces, projects] = files.reduce<[string[], string[]]>( - ([w, p], fileName) => { - const ext = path.extname(fileName); - if (ext === '.xcworkspace') { - return [[...w, fileName], p]; - } - if (ext === '.xcodeproj') { - return [w, [...p, fileName]]; - } - return [w, p]; - }, - [[], []], - ); - - if (workspaces.length > 0) { - if (workspaces.length > 1) { - - } - return { - workspaces[0], - isWorkspace: true, - }; - } - - if (projects.length > 0) { - if (projects.length > 1) { - - } - return { - name: projects[0], - isWorkspace: false, - } - } - for (let i = sortedFiles.length - 1; i >= 0; i--) { const fileName = files[i]; const ext = path.extname(fileName); From 9e70eb362683f8c73c6bed250932b2b9365b0e36 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Fri, 4 Feb 2022 17:32:04 +0100 Subject: [PATCH 35/39] Update autolinking.md --- docs/autolinking.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/autolinking.md b/docs/autolinking.md index 38f95ae9b..0e1103e9f 100644 --- a/docs/autolinking.md +++ b/docs/autolinking.md @@ -15,8 +15,6 @@ yarn react-native run-android That's it. No more editing build config files to use native code. -> Autolinking is a replacement for [react-native link](https://github.com/react-native-community/cli/blob/master/docs/commands.md#link). If you have been using React Native before version 0.60, please `unlink` native dependencies if you have any from a previous install. - ## How does it work Each platform defines its own [`platforms`](./platforms.md) configuration. It instructs the CLI on how to find information about native dependencies. This information is exposed through the [`config`](./commands.md#config) command in a JSON format. It's then used by the scripts run by the platform's build tools. Each script applies the logic to link native dependencies specific to its platform. @@ -28,7 +26,7 @@ The [native_modules.rb](https://github.com/react-native-community/cli/blob/maste 1. Adds dependencies via CocoaPods dev pods (using files from a local path). 1. Adds build phase scripts to the App project’s build phase. (see examples below) -This means that all libraries need to ship a Podspec either in the root of their folder or where the Xcode project is. Podspec references the native code that your library depends on. +This means that all libraries need to ship a Podspec in the root of their folder. Podspec references the native code that your library depends on. The implementation ensures that a library is imported only once. If you need to have a custom `pod` directive then include it above the `use_native_modules!` function. From 48686a9b4da0d8dda68dc22e3b7d95d62cb2c12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 4 Feb 2022 17:45:48 +0100 Subject: [PATCH 36/39] chore: remove xmldoc dep --- packages/platform-android/package.json | 6 ++---- yarn.lock | 14 +------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/packages/platform-android/package.json b/packages/platform-android/package.json index ed5d5a89a..488823ff4 100644 --- a/packages/platform-android/package.json +++ b/packages/platform-android/package.json @@ -15,8 +15,7 @@ "jetifier": "^1.6.2", "lodash": "^4.17.15", "logkitty": "^0.7.1", - "slash": "^3.0.0", - "xmldoc": "^1.1.2" + "slash": "^3.0.0" }, "files": [ "build", @@ -29,8 +28,7 @@ "@types/execa": "^0.9.0", "@types/fs-extra": "^8.1.0", "@types/glob": "^7.1.1", - "@types/lodash": "^4.14.149", - "@types/xmldoc": "^1.1.4" + "@types/lodash": "^4.14.149" }, "homepage": "https://github.com/react-native-community/cli/tree/master/packages/platform-android", "repository": { diff --git a/yarn.lock b/yarn.lock index 279d93dc7..15bfb29b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2562,11 +2562,6 @@ dependencies: "@types/node" "*" -"@types/xmldoc@^1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@types/xmldoc/-/xmldoc-1.1.4.tgz#5867d4e29739719c633bf16413c5a4a4c1c3c802" - integrity sha512-a/ONNCf9itbmzEz1ohx0Fv5TLJzXIPQTapxFu+DlYlDtn9UcAa1OhnrOOMwbU8125hFjrkJKL3qllD7vO5Bivw== - "@types/yargs-parser@*": version "15.0.0" resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d" @@ -10889,7 +10884,7 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -sax@^1.2.1, sax@~1.2.4: +sax@~1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -12692,13 +12687,6 @@ xmlchars@^2.1.1, xmlchars@^2.2.0: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== -xmldoc@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/xmldoc/-/xmldoc-1.1.2.tgz#6666e029fe25470d599cd30e23ff0d1ed50466d7" - integrity sha512-ruPC/fyPNck2BD1dpz0AZZyrEwMOrWTO5lDdIXS91rs3wtm4j+T8Rp2o+zoOYkkAxJTZRPOSnOGei1egoRmKMQ== - dependencies: - sax "^1.2.1" - xmldom@^0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.5.0.tgz#193cb96b84aa3486127ea6272c4596354cb4962e" From 73268924b29a548aa816379677454187a3649e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 4 Feb 2022 17:48:14 +0100 Subject: [PATCH 37/39] chore: remove xcode dep --- .../platform-ios/definitions/xcode/index.d.ts | 5 -- .../definitions/xcode/lib/index.d.ts | 5 -- packages/platform-ios/package.json | 3 +- yarn.lock | 48 +------------------ 4 files changed, 2 insertions(+), 59 deletions(-) delete mode 100644 packages/platform-ios/definitions/xcode/index.d.ts delete mode 100644 packages/platform-ios/definitions/xcode/lib/index.d.ts diff --git a/packages/platform-ios/definitions/xcode/index.d.ts b/packages/platform-ios/definitions/xcode/index.d.ts deleted file mode 100644 index d56c14d09..000000000 --- a/packages/platform-ios/definitions/xcode/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module 'xcode' { - const module: any; - - export default module; -} diff --git a/packages/platform-ios/definitions/xcode/lib/index.d.ts b/packages/platform-ios/definitions/xcode/lib/index.d.ts deleted file mode 100644 index b8f98f04f..000000000 --- a/packages/platform-ios/definitions/xcode/lib/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module 'xcode/lib/pbxFile' { - const module: any; - - export default module; -} diff --git a/packages/platform-ios/package.json b/packages/platform-ios/package.json index ab6190e0c..86f98f098 100644 --- a/packages/platform-ios/package.json +++ b/packages/platform-ios/package.json @@ -14,8 +14,7 @@ "js-yaml": "^3.13.1", "lodash": "^4.17.15", "ora": "^5.4.1", - "plist": "^3.0.2", - "xcode": "^3.0.0" + "plist": "^3.0.2" }, "devDependencies": { "@react-native-community/cli-types": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index 15bfb29b4..c7dd43a6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3269,11 +3269,6 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== -big-integer@^1.6.44: - version "1.6.48" - resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e" - integrity sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w== - binary-extensions@^1.0.0: version "1.13.1" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65" @@ -3310,20 +3305,6 @@ boolbase@^1.0.0, boolbase@~1.0.0: resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= -bplist-creator@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/bplist-creator/-/bplist-creator-0.0.8.tgz#56b2a6e79e9aec3fc33bf831d09347d73794e79c" - integrity sha512-Za9JKzD6fjLC16oX2wsXfc+qBEhJBJB1YPInoAQpMLhDuj5aVOv1baGeIQSq1Fr3OCqzvsoQcSBSwGId/Ja2PA== - dependencies: - stream-buffers "~2.2.0" - -bplist-parser@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.2.0.tgz#43a9d183e5bf9d545200ceac3e712f79ebbe8d0e" - integrity sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw== - dependencies: - big-integer "^1.6.44" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -9741,7 +9722,7 @@ pkginfo@0.x.x: resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff" integrity sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8= -plist@^3.0.1, plist@^3.0.2: +plist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.2.tgz#74bbf011124b90421c22d15779cee60060ba95bc" integrity sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ== @@ -11077,15 +11058,6 @@ signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.6.tgz#24e630c4b0f03fea446a2bd299e62b4a6ca8d0af" integrity sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ== -simple-plist@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.1.1.tgz#54367ca28bc5996a982c325c1c4a4c1a05f4047c" - integrity sha512-pKMCVKvZbZTsqYR6RKgLfBHkh2cV89GXcA/0CVPje3sOiNOnXA8+rp/ciAMZ7JRaUdLzlEM6JFfUn+fS6Nt3hg== - dependencies: - bplist-creator "0.0.8" - bplist-parser "0.2.0" - plist "^3.0.1" - simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" @@ -11404,11 +11376,6 @@ stream-browserify@^2.0.1: inherits "~2.0.1" readable-stream "^2.0.2" -stream-buffers@~2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/stream-buffers/-/stream-buffers-2.2.0.tgz#91d5f5130d1cef96dcfa7f726945188741d09ee4" - integrity sha1-kdX1Ew0c75bc+n9yaUUYh0HQnuQ= - stream-http@^2.7.2: version "2.8.3" resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc" @@ -12299,11 +12266,6 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@^7.0.3: - version "7.0.3" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" - integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== - uuid@^8.3.0: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" @@ -12659,14 +12621,6 @@ ws@^7.2.3: resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.5.tgz#abb1370d4626a5a9cd79d8de404aa18b3465d10d" integrity sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA== -xcode@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/xcode/-/xcode-3.0.1.tgz#3efb62aac641ab2c702458f9a0302696146aa53c" - integrity sha512-kCz5k7J7XbJtjABOvkc5lJmkiDh8VhjVCGNiqdKCscmVpdVUpEAyXv1xmCLkQJ5dsHqx3IPO4XW+NTDhU/fatA== - dependencies: - simple-plist "^1.1.0" - uuid "^7.0.3" - xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" From 794d9b3a314ee8501d782f7912aff2aedc49bfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 4 Feb 2022 17:59:29 +0100 Subject: [PATCH 38/39] chore: return type for dependencyConfig --- .vscode/settings.json | 3 ++- packages/platform-android/src/config/index.ts | 5 +++-- packages/platform-ios/src/config/index.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 230a6715c..dff35f935 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,5 +17,6 @@ "javascriptreact", "typescript", "typescriptreact" - ] + ], + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/packages/platform-android/src/config/index.ts b/packages/platform-android/src/config/index.ts index d4cb2e96b..b4bf86ecb 100644 --- a/packages/platform-android/src/config/index.ts +++ b/packages/platform-android/src/config/index.ts @@ -13,8 +13,9 @@ import findManifest from './findManifest'; import findPackageClassName from './findPackageClassName'; import { AndroidProjectParams, - AndroidDependencyParams, AndroidProjectConfig, + AndroidDependencyParams, + AndroidDependencyConfig, } from '@react-native-community/cli-types'; import {getPackageName} from './getAndroidProject'; @@ -78,7 +79,7 @@ function getAppName(sourceDir: string, userConfigAppName: string | undefined) { export function dependencyConfig( root: string, userConfig: AndroidDependencyParams = {}, -) { +): AndroidDependencyConfig | null { const src = userConfig.sourceDir || findAndroidDir(root); if (!src) { diff --git a/packages/platform-ios/src/config/index.ts b/packages/platform-ios/src/config/index.ts index c4c588055..d5ac6a239 100644 --- a/packages/platform-ios/src/config/index.ts +++ b/packages/platform-ios/src/config/index.ts @@ -14,6 +14,7 @@ import { IOSProjectParams, IOSDependencyParams, IOSProjectConfig, + IOSDependencyConfig, } from '@react-native-community/cli-types'; /** @@ -51,7 +52,7 @@ export function projectConfig( export function dependencyConfig( folder: string, userConfig: IOSDependencyParams, -) { +): IOSDependencyConfig | null { const podspecPath = findPodspec(folder); if (!podspecPath) { From 3e5cb0bc2cc7768d47add0e35dbbf00265374836 Mon Sep 17 00:00:00 2001 From: Mike Grabowski Date: Mon, 7 Feb 2022 12:28:53 +0100 Subject: [PATCH 39/39] Update index.ts --- packages/cli-types/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli-types/src/index.ts b/packages/cli-types/src/index.ts index 31f3c347e..1ca529761 100644 --- a/packages/cli-types/src/index.ts +++ b/packages/cli-types/src/index.ts @@ -125,7 +125,6 @@ export interface Config { healthChecks: []; } -// @todo double check the following two types for correction export type UserConfig = Omit & { reactNativePath: string | void; // Additional project settings