@nx/expo 17.3.0-beta.3 → 17.3.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/expo",
3
- "version": "17.3.0-beta.3",
3
+ "version": "17.3.0-beta.5",
4
4
  "private": false,
5
5
  "description": "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.",
6
6
  "keywords": [
@@ -34,14 +34,14 @@
34
34
  "tslib": "^2.3.0",
35
35
  "tsconfig-paths": "^4.1.2",
36
36
  "tsconfig-paths-webpack-plugin": "^4.0.0",
37
- "@nx/detox": "17.3.0-beta.3",
38
- "@nx/devkit": "17.3.0-beta.3",
39
- "@nx/jest": "17.3.0-beta.3",
40
- "@nx/js": "17.3.0-beta.3",
41
- "@nx/eslint": "17.3.0-beta.3",
42
- "@nx/react": "17.3.0-beta.3",
43
- "@nx/webpack": "17.3.0-beta.3",
44
- "@nrwl/expo": "17.3.0-beta.3"
37
+ "@nx/detox": "17.3.0-beta.5",
38
+ "@nx/devkit": "17.3.0-beta.5",
39
+ "@nx/jest": "17.3.0-beta.5",
40
+ "@nx/js": "17.3.0-beta.5",
41
+ "@nx/eslint": "17.3.0-beta.5",
42
+ "@nx/react": "17.3.0-beta.5",
43
+ "@nx/webpack": "17.3.0-beta.5",
44
+ "@nrwl/expo": "17.3.0-beta.5"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "expo": ">= 49.0.0",
@@ -1,6 +1,7 @@
1
1
  import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
2
  export interface ExpoPluginOptions {
3
3
  startTargetName?: string;
4
+ serveTargetName?: string;
4
5
  runIosTargetName?: string;
5
6
  runAndroidTargetName?: string;
6
7
  exportTargetName?: string;
package/plugins/plugin.js CHANGED
@@ -30,7 +30,6 @@ exports.createNodes = [
30
30
  // Do not create a project if package.json or project.json or metro.config.js isn't there.
31
31
  const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
32
32
  if (!siblingFiles.includes('package.json') ||
33
- !siblingFiles.includes('project.json') ||
34
33
  !siblingFiles.includes('metro.config.js')) {
35
34
  return {};
36
35
  }
@@ -59,16 +58,17 @@ function buildExpoTargets(projectRoot, options, context) {
59
58
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
60
59
  const targets = {
61
60
  [options.startTargetName]: {
62
- command: `expo start`,
61
+ executor: `@nx/expo:start`,
62
+ },
63
+ [options.serveTargetName]: {
64
+ command: `expo start --web`,
63
65
  options: { cwd: projectRoot },
64
66
  },
65
67
  [options.runIosTargetName]: {
66
- command: `expo run:ios`,
67
- options: { cwd: projectRoot },
68
+ executor: `@nx/expo:run-ios`,
68
69
  },
69
70
  [options.runAndroidTargetName]: {
70
- command: `expo run:android`,
71
- options: { cwd: projectRoot },
71
+ executor: `@nx/expo:run-android`,
72
72
  },
73
73
  [options.exportTargetName]: {
74
74
  command: `expo export`,
@@ -91,18 +91,15 @@ function buildExpoTargets(projectRoot, options, context) {
91
91
  options: { cwd: devkit_1.workspaceRoot }, // install at workspace root
92
92
  },
93
93
  [options.prebuildTargetName]: {
94
- command: `expo prebuild`,
95
- options: { cwd: projectRoot },
94
+ executor: `@nx/expo:prebuild`,
96
95
  },
97
96
  [options.buildTargetName]: {
98
- command: `eas build`,
99
- options: { cwd: projectRoot },
97
+ executor: `@nx/expo:build`,
100
98
  dependsOn: [`^${options.buildTargetName}`],
101
99
  inputs: getInputs(namedInputs),
102
100
  },
103
101
  [options.submitTargetName]: {
104
- command: `eas submit`,
105
- options: { cwd: projectRoot },
102
+ executor: `@nx/expo:submit`,
106
103
  dependsOn: [`^${options.submitTargetName}`],
107
104
  inputs: getInputs(namedInputs),
108
105
  },
@@ -148,6 +145,7 @@ function load(path) {
148
145
  function normalizeOptions(options) {
149
146
  options ??= {};
150
147
  options.startTargetName ??= 'start';
148
+ options.serveTargetName ??= 'serve';
151
149
  options.runIosTargetName ??= 'run-ios';
152
150
  options.runAndroidTargetName ??= 'run-android';
153
151
  options.exportTargetName ??= 'export';
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expoApplicationGeneratorInternal = exports.expoApplicationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
5
6
  const symlink_task_1 = require("../../utils/symlink-task");
6
7
  const add_linting_1 = require("../../utils/add-linting");
7
8
  const add_jest_1 = require("../../utils/add-jest");
@@ -11,6 +12,8 @@ const add_project_1 = require("./lib/add-project");
11
12
  const create_application_files_1 = require("./lib/create-application-files");
12
13
  const add_eas_scripts_1 = require("./lib/add-eas-scripts");
13
14
  const add_detox_1 = require("./lib/add-detox");
15
+ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
16
+ const init_root_babel_config_1 = require("../../utils/init-root-babel-config");
14
17
  async function expoApplicationGenerator(host, schema) {
15
18
  return await expoApplicationGeneratorInternal(host, {
16
19
  projectNameAndRootFormat: 'derived',
@@ -20,7 +23,18 @@ async function expoApplicationGenerator(host, schema) {
20
23
  exports.expoApplicationGenerator = expoApplicationGenerator;
21
24
  async function expoApplicationGeneratorInternal(host, schema) {
22
25
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
26
+ const tasks = [];
27
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
28
+ ...schema,
29
+ skipFormat: true,
30
+ });
31
+ tasks.push(jsInitTask);
23
32
  const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
33
+ tasks.push(initTask);
34
+ if (!options.skipPackageJson) {
35
+ tasks.push((0, ensure_dependencies_1.ensureDependencies)(host));
36
+ }
37
+ (0, init_root_babel_config_1.initRootBabelConfig)(host);
24
38
  (0, create_application_files_1.createApplicationFiles)(host, options);
25
39
  (0, add_project_1.addProject)(host, options);
26
40
  const lintTask = await (0, add_linting_1.addLinting)(host, {
@@ -30,14 +44,18 @@ async function expoApplicationGeneratorInternal(host, schema) {
30
44
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
31
45
  ],
32
46
  });
47
+ tasks.push(lintTask);
33
48
  const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
49
+ tasks.push(jestTask);
34
50
  const detoxTask = await (0, add_detox_1.addDetox)(host, options);
51
+ tasks.push(detoxTask);
35
52
  const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
53
+ tasks.push(symlinkTask);
36
54
  (0, add_eas_scripts_1.addEasScripts)(host);
37
55
  if (!options.skipFormat) {
38
56
  await (0, devkit_1.formatFiles)(host);
39
57
  }
40
- return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask);
58
+ return (0, devkit_1.runTasksInSerial)(...tasks);
41
59
  }
42
60
  exports.expoApplicationGeneratorInternal = expoApplicationGeneratorInternal;
43
61
  exports.default = expoApplicationGenerator;
@@ -2,11 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
5
6
  function addProject(host, options) {
6
7
  const nxJson = (0, devkit_1.readNxJson)(host);
7
- const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
8
- ? p === '@nx/expo/plugin'
9
- : p.plugin === '@nx/expo/plugin');
8
+ const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(host);
10
9
  const projectConfiguration = {
11
10
  root: options.appProjectRoot,
12
11
  sourceRoot: `${options.appProjectRoot}/src`,
@@ -3,37 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateDependencies = exports.expoInitGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../utils/versions");
6
- const jest_1 = require("@nx/jest");
7
- const detox_1 = require("@nx/detox");
8
- const js_1 = require("@nx/js");
6
+ const has_expo_plugin_1 = require("../../utils/has-expo-plugin");
9
7
  const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
10
- const init_root_babel_config_1 = require("./lib/init-root-babel-config");
11
8
  async function expoInitGenerator(host, schema) {
12
9
  (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
13
- (0, init_root_babel_config_1.initRootBabelConfig)(host);
10
+ if (process.env.NX_PCV3 === 'true') {
11
+ addPlugin(host);
12
+ }
14
13
  const tasks = [];
15
- tasks.push(await (0, js_1.initGenerator)(host, {
16
- ...schema,
17
- skipFormat: true,
18
- }));
19
14
  if (!schema.skipPackageJson) {
20
15
  tasks.push(moveDependency(host));
21
16
  tasks.push(updateDependencies(host));
22
17
  }
23
- if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
24
- const jestTask = await (0, jest_1.jestInitGenerator)(host, schema);
25
- tasks.push(jestTask);
26
- }
27
- if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
28
- const detoxTask = await (0, detox_1.detoxInitGenerator)(host, {
29
- ...schema,
30
- skipFormat: true,
31
- });
32
- tasks.push(detoxTask);
33
- }
34
- if (process.env.NX_PCV3 === 'true') {
35
- addPlugin(host);
36
- }
37
18
  if (!schema.skipFormat) {
38
19
  await (0, devkit_1.formatFiles)(host);
39
20
  }
@@ -46,24 +27,10 @@ function updateDependencies(host) {
46
27
  'react-dom': versions_1.reactDomVersion,
47
28
  'react-native': versions_1.reactNativeVersion,
48
29
  expo: versions_1.expoVersion,
49
- 'expo-splash-screen': versions_1.expoSplashScreenVersion,
50
- 'expo-status-bar': versions_1.expoStatusBarVersion,
51
- 'react-native-web': versions_1.reactNativeWebVersion,
52
- '@expo/metro-config': versions_1.expoMetroConfigVersion,
53
- 'react-native-svg-transformer': versions_1.reactNativeSvgTransformerVersion,
54
- 'react-native-svg': versions_1.reactNativeSvgVersion,
55
30
  }, {
56
31
  '@nx/expo': versions_1.nxVersion,
57
- '@types/react': versions_1.typesReactVersion,
58
- metro: versions_1.metroVersion,
59
- 'metro-resolver': versions_1.metroVersion,
60
- 'react-test-renderer': versions_1.reactTestRendererVersion,
61
- '@testing-library/react-native': versions_1.testingLibraryReactNativeVersion,
62
- '@testing-library/jest-native': versions_1.testingLibraryJestNativeVersion,
63
- 'jest-expo': versions_1.jestExpoVersion,
64
32
  '@expo/cli': versions_1.expoCliVersion,
65
33
  'eas-cli': versions_1.easCliVersion,
66
- 'babel-preset-expo': versions_1.babelPresetExpoVersion,
67
34
  });
68
35
  }
69
36
  exports.updateDependencies = updateDependencies;
@@ -72,14 +39,10 @@ function moveDependency(host) {
72
39
  }
73
40
  function addPlugin(host) {
74
41
  const nxJson = (0, devkit_1.readNxJson)(host);
75
- nxJson.plugins ??= [];
76
- for (const plugin of nxJson.plugins) {
77
- if (typeof plugin === 'string'
78
- ? plugin === '@nx/expo/plugin'
79
- : plugin.plugin === '@nx/expo/plugin') {
80
- return;
81
- }
42
+ if ((0, has_expo_plugin_1.hasExpoPlugin)(host)) {
43
+ return;
82
44
  }
45
+ nxJson.plugins ??= [];
83
46
  nxJson.plugins.push({
84
47
  plugin: '@nx/expo/plugin',
85
48
  options: {
@@ -1,7 +1,4 @@
1
1
  export interface Schema {
2
- unitTestRunner?: 'jest' | 'none';
3
2
  skipFormat?: boolean;
4
- e2eTestRunner?: 'detox' | 'none';
5
3
  skipPackageJson?: boolean; // default is false
6
- js?: boolean;
7
4
  }
@@ -5,33 +5,16 @@
5
5
  "description": "Add Nx Expo Schematics.",
6
6
  "type": "object",
7
7
  "properties": {
8
- "unitTestRunner": {
9
- "description": "Adds the specified unit test runner",
10
- "type": "string",
11
- "enum": ["jest", "none"],
12
- "default": "jest"
13
- },
14
8
  "skipFormat": {
15
9
  "description": "Skip formatting files",
16
10
  "type": "boolean",
17
11
  "default": false,
18
12
  "x-priority": "internal"
19
13
  },
20
- "e2eTestRunner": {
21
- "description": "Adds the specified e2e test runner",
22
- "type": "string",
23
- "enum": ["detox", "none"],
24
- "default": "detox"
25
- },
26
14
  "skipPackageJson": {
27
15
  "type": "boolean",
28
16
  "default": false,
29
17
  "description": "Do not add dependencies to `package.json`."
30
- },
31
- "js": {
32
- "type": "boolean",
33
- "default": false,
34
- "description": "Use JavaScript instead of TypeScript"
35
18
  }
36
19
  },
37
20
  "required": []
@@ -8,6 +8,8 @@ const add_linting_1 = require("../../utils/add-linting");
8
8
  const add_jest_1 = require("../../utils/add-jest");
9
9
  const versions_1 = require("../../utils/versions");
10
10
  const normalize_options_1 = require("./lib/normalize-options");
11
+ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
12
+ const init_root_babel_config_1 = require("../../utils/init-root-babel-config");
11
13
  async function expoLibraryGenerator(host, schema) {
12
14
  return await expoLibraryGeneratorInternal(host, {
13
15
  projectNameAndRootFormat: 'derived',
@@ -21,12 +23,17 @@ async function expoLibraryGeneratorInternal(host, schema) {
21
23
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
22
24
  }
23
25
  const tasks = [];
24
- const initTask = await (0, init_1.default)(host, {
25
- ...options,
26
+ const jsInitTask = await (0, js_1.initGenerator)(host, {
27
+ ...schema,
26
28
  skipFormat: true,
27
- e2eTestRunner: 'none',
28
29
  });
30
+ tasks.push(jsInitTask);
31
+ const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
29
32
  tasks.push(initTask);
33
+ if (!options.skipPackageJson) {
34
+ tasks.push((0, ensure_dependencies_1.ensureDependencies)(host));
35
+ }
36
+ (0, init_root_babel_config_1.initRootBabelConfig)(host);
30
37
  const addProjectTask = await addProject(host, options);
31
38
  if (addProjectTask) {
32
39
  tasks.push(addProjectTask);
@@ -57,45 +64,45 @@ async function expoLibraryGeneratorInternal(host, schema) {
57
64
  }
58
65
  exports.expoLibraryGeneratorInternal = expoLibraryGeneratorInternal;
59
66
  async function addProject(host, options) {
60
- const targets = {};
61
- let task;
62
- if (options.publishable || options.buildable) {
63
- const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
64
- const external = [
65
- 'react/jsx-runtime',
66
- 'react-native',
67
- 'react',
68
- 'react-dom',
69
- ];
70
- targets.build = {
71
- executor: '@nx/rollup:rollup',
72
- outputs: ['{options.outputPath}'],
73
- options: {
74
- outputPath: `dist/${options.projectRoot}`,
75
- tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
76
- project: `${options.projectRoot}/package.json`,
77
- entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
78
- external,
79
- rollupConfig: `@nx/react/plugins/bundle-rollup`,
80
- assets: [
81
- {
82
- glob: `${options.projectRoot}/README.md`,
83
- input: '.',
84
- output: '.',
85
- },
86
- ],
87
- },
88
- };
89
- task = await rollupInitGenerator(host, { ...options, skipFormat: true });
90
- }
91
- (0, devkit_1.addProjectConfiguration)(host, options.name, {
67
+ const project = {
92
68
  root: options.projectRoot,
93
69
  sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
94
70
  projectType: 'library',
95
71
  tags: options.parsedTags,
96
- targets,
72
+ targets: {},
73
+ };
74
+ (0, devkit_1.addProjectConfiguration)(host, options.name, project);
75
+ if (!options.publishable && !options.buildable) {
76
+ return () => { };
77
+ }
78
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
79
+ const rollupConfigTask = await configurationGenerator(host, {
80
+ ...options,
81
+ project: options.name,
82
+ skipFormat: true,
97
83
  });
98
- return task;
84
+ const external = ['react/jsx-runtime', 'react-native', 'react', 'react-dom'];
85
+ project.targets.build = {
86
+ executor: '@nx/rollup:rollup',
87
+ outputs: ['{options.outputPath}'],
88
+ options: {
89
+ outputPath: `dist/${options.projectRoot}`,
90
+ tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
91
+ project: `${options.projectRoot}/package.json`,
92
+ entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
93
+ external,
94
+ rollupConfig: `@nx/react/plugins/bundle-rollup`,
95
+ assets: [
96
+ {
97
+ glob: `${options.projectRoot}/README.md`,
98
+ input: '.',
99
+ output: '.',
100
+ },
101
+ ],
102
+ },
103
+ };
104
+ (0, devkit_1.updateProjectConfiguration)(host, options.name, project);
105
+ return rollupConfigTask;
99
106
  }
100
107
  function updateTsConfig(tree, options) {
101
108
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
@@ -0,0 +1,2 @@
1
+ import { type GeneratorCallback, type Tree } from '@nx/devkit';
2
+ export declare function ensureDependencies(host: Tree): GeneratorCallback;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("./versions");
6
+ function ensureDependencies(host) {
7
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {
8
+ 'expo-splash-screen': versions_1.expoSplashScreenVersion,
9
+ 'expo-status-bar': versions_1.expoStatusBarVersion,
10
+ 'react-native-web': versions_1.reactNativeWebVersion,
11
+ '@expo/metro-config': versions_1.expoMetroConfigVersion,
12
+ 'react-native-svg-transformer': versions_1.reactNativeSvgTransformerVersion,
13
+ 'react-native-svg': versions_1.reactNativeSvgVersion,
14
+ }, {
15
+ '@types/react': versions_1.typesReactVersion,
16
+ metro: versions_1.metroVersion,
17
+ 'metro-resolver': versions_1.metroVersion,
18
+ 'react-test-renderer': versions_1.reactTestRendererVersion,
19
+ '@testing-library/react-native': versions_1.testingLibraryReactNativeVersion,
20
+ '@testing-library/jest-native': versions_1.testingLibraryJestNativeVersion,
21
+ 'jest-expo': versions_1.jestExpoVersion,
22
+ 'babel-preset-expo': versions_1.babelPresetExpoVersion,
23
+ });
24
+ }
25
+ exports.ensureDependencies = ensureDependencies;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function hasExpoPlugin(tree: Tree): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasExpoPlugin = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function hasExpoPlugin(tree) {
6
+ const nxJson = (0, devkit_1.readNxJson)(tree);
7
+ return !!nxJson.plugins?.some((p) => typeof p === 'string'
8
+ ? p === '@nx/expo/plugin'
9
+ : p.plugin === '@nx/expo/plugin');
10
+ }
11
+ exports.hasExpoPlugin = hasExpoPlugin;