UNPKG

@nx/detox

Version:

The Nx Plugin for Detox contains executors and generators for allowing your workspace to use the powerful Detox integration testing capabilities.

58 lines (57 loc) 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = update; const devkit_1 = require("@nx/devkit"); const semver_1 = require("semver"); /** * Remove @config-plugins/detox for Expo 54+ projects. * * The @config-plugins/detox package has been discontinued and is incompatible * with Expo 54. See: https://github.com/expo/config-plugins/pull/290 * * This migration removes the dependency from package.json for projects * using Expo 54 or above. */ async function update(tree) { const rootPackageJsonPath = 'package.json'; if (!tree.exists(rootPackageJsonPath)) { return; } const packageJson = (0, devkit_1.readJson)(tree, rootPackageJsonPath); // Check if @config-plugins/detox is installed const hasConfigPluginsDetox = packageJson.dependencies?.['@config-plugins/detox'] || packageJson.devDependencies?.['@config-plugins/detox']; if (!hasConfigPluginsDetox) { return; } // Check the installed Expo version const expoVersion = packageJson.dependencies?.['expo'] || packageJson.devDependencies?.['expo']; if (!expoVersion) { // No expo installed, this is likely a React Native project, skip return; } const cleanedVersion = (0, semver_1.clean)(expoVersion) ?? (0, semver_1.coerce)(expoVersion)?.version; if (!cleanedVersion) { devkit_1.logger.warn(`Could not parse Expo version "${expoVersion}". Skipping @config-plugins/detox removal.`); return; } const majorVersion = (0, semver_1.major)(cleanedVersion); if (majorVersion < 54) { // Expo 53 or below still supports @config-plugins/detox return; } // Remove @config-plugins/detox from package.json (0, devkit_1.updateJson)(tree, rootPackageJsonPath, (json) => { if (json.dependencies?.['@config-plugins/detox']) { delete json.dependencies['@config-plugins/detox']; } if (json.devDependencies?.['@config-plugins/detox']) { delete json.devDependencies['@config-plugins/detox']; } return json; }); devkit_1.logger.warn(`Removed @config-plugins/detox from package.json.\n` + `The @config-plugins/detox package has been discontinued and is incompatible with Expo 54+.\n` + `For E2E testing with Expo 54+, consider using Maestro: https://docs.expo.dev/build-reference/e2e-tests/`); await (0, devkit_1.formatFiles)(tree); }