UNPKG

@nx/expo

Version:

The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.

117 lines (116 loc) 3.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addProject = addProject; const internal_1 = require("@nx/devkit/internal"); const devkit_1 = require("@nx/devkit"); const has_expo_plugin_1 = require("../../../utils/has-expo-plugin"); const deprecation_1 = require("../../../utils/deprecation"); function addProject(host, options) { const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(host); if (!hasPlugin) { (0, deprecation_1.warnExpoExecutorGenerating)(); (0, internal_1.addBuildTargetDefaults)(host, '@nx/expo:build'); } const projectConfiguration = { root: options.appProjectRoot, sourceRoot: `${options.appProjectRoot}/src`, projectType: 'application', targets: hasPlugin ? {} : getTargets(options), tags: options.parsedTags, }; const templatedPackageJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json')); const packageJson = { ...templatedPackageJson, name: options.importPath, version: '0.0.1', private: true, }; if (!options.useProjectJson) { if (options.importPath !== options.projectName) { packageJson.nx = { name: options.projectName }; } if (!hasPlugin) { packageJson.nx ??= {}; packageJson.nx.targets = getTargets(options); } if (options.parsedTags?.length) { packageJson.nx ??= {}; packageJson.nx.tags = options.parsedTags; } } else { (0, devkit_1.addProjectConfiguration)(host, options.projectName, projectConfiguration); } if (!options.useProjectJson || options.isTsSolutionSetup) { (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson); } } function getTargets(options) { const architect = {}; architect.start = { executor: '@nx/expo:start', dependsOn: ['sync-deps'], options: {}, }; architect.serve = { executor: '@nx/expo:serve', dependsOn: ['sync-deps'], options: { port: 4200, }, }; architect['run-ios'] = { executor: '@nx/expo:run', dependsOn: ['sync-deps'], options: { platform: 'ios', }, }; architect['run-android'] = { executor: '@nx/expo:run', dependsOn: ['sync-deps'], options: { platform: 'android', }, }; architect['build'] = { executor: '@nx/expo:build', dependsOn: ['sync-deps'], options: {}, }; architect['submit'] = { executor: '@nx/expo:submit', options: {}, }; architect['build-list'] = { executor: '@nx/expo:build-list', options: {}, }; architect['sync-deps'] = { executor: '@nx/expo:sync-deps', options: {}, }; architect['prebuild'] = { executor: '@nx/expo:prebuild', dependsOn: ['sync-deps'], options: {}, }; architect['install'] = { executor: '@nx/expo:install', options: {}, }; architect['update'] = { executor: '@nx/expo:update', options: {}, }; architect['export'] = { executor: '@nx/expo:export', dependsOn: ['sync-deps'], outputs: ['{options.outputDir}'], options: { platform: 'all', outputDir: `${options.appProjectRoot}/dist`, }, }; return architect; }