@nx/expo 17.0.4 → 17.0.6

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.
Files changed (109) hide show
  1. package/.eslintrc.json +0 -3
  2. package/LICENSE +1 -1
  3. package/README.md +4 -9
  4. package/collection.json +0 -0
  5. package/docs/start-examples.md +0 -6
  6. package/executors.json +0 -5
  7. package/generators.json +2 -2
  8. package/migrations.json +6 -114
  9. package/package.json +16 -12
  10. package/plugins/metro-resolver.js +1 -4
  11. package/plugins/with-nx-metro.js +2 -6
  12. package/plugins/with-nx-webpack.d.ts +1 -1
  13. package/plugins/with-nx-webpack.js +4 -8
  14. package/src/executors/build/build.impl.js +1 -2
  15. package/src/executors/build/schema.json +1 -1
  16. package/src/executors/build-list/build-list.impl.js +3 -2
  17. package/src/executors/build-list/schema.json +1 -1
  18. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +0 -4
  19. package/src/executors/ensure-symlink/ensure-symlink.impl.js +0 -4
  20. package/src/executors/ensure-symlink/schema.json +1 -1
  21. package/src/executors/export/export.impl.d.ts +0 -1
  22. package/src/executors/export/export.impl.js +15 -25
  23. package/src/executors/export/schema.d.ts +2 -4
  24. package/src/executors/export/schema.json +13 -14
  25. package/src/executors/install/install.impl.js +2 -0
  26. package/src/executors/install/schema.json +1 -1
  27. package/src/executors/prebuild/prebuild.impl.js +5 -11
  28. package/src/executors/prebuild/schema.json +1 -2
  29. package/src/executors/run/schema.json +1 -1
  30. package/src/executors/start/schema.json +1 -1
  31. package/src/executors/start/start.impl.js +1 -7
  32. package/src/executors/submit/schema.json +1 -1
  33. package/src/executors/submit/submit.impl.js +1 -2
  34. package/src/executors/sync-deps/schema.d.ts +0 -1
  35. package/src/executors/sync-deps/schema.json +1 -6
  36. package/src/executors/sync-deps/sync-deps.impl.d.ts +3 -4
  37. package/src/executors/sync-deps/sync-deps.impl.js +11 -33
  38. package/src/executors/update/schema.json +1 -1
  39. package/src/executors/update/update.impl.js +4 -7
  40. package/src/generators/application/application.js +7 -27
  41. package/src/generators/application/files/app.json.template +0 -2
  42. package/src/generators/application/files/eas.json.template +3 -0
  43. package/src/generators/application/files/metro.config.js.template +5 -1
  44. package/src/generators/application/files/src/app/App.tsx.template +13 -50
  45. package/src/generators/application/lib/add-detox.d.ts +3 -0
  46. package/src/generators/application/lib/add-detox.js +24 -0
  47. package/src/generators/application/lib/add-project.js +22 -20
  48. package/src/generators/application/lib/create-application-files.js +2 -0
  49. package/src/generators/application/lib/normalize-options.d.ts +0 -6
  50. package/src/generators/application/lib/normalize-options.js +1 -33
  51. package/src/generators/application/schema.d.ts +1 -2
  52. package/src/generators/application/schema.json +4 -4
  53. package/src/generators/component/files/__fileName__.tsx.template +1 -1
  54. package/src/generators/component/schema.d.ts +3 -3
  55. package/src/generators/component/schema.json +4 -4
  56. package/src/generators/init/init.d.ts +2 -3
  57. package/src/generators/init/init.js +40 -44
  58. package/src/generators/init/schema.d.ts +3 -3
  59. package/src/generators/init/schema.json +16 -11
  60. package/src/generators/library/files/lib/babel.config.json +17 -0
  61. package/src/generators/library/lib/normalize-options.js +0 -5
  62. package/src/generators/library/library.js +38 -52
  63. package/src/generators/library/schema.d.ts +0 -1
  64. package/src/generators/library/schema.json +2 -2
  65. package/src/migrations/{update-18-0-0/change-outputDir-export-target.d.ts → update-16-1-4/add-detox-app-json.d.ts} +1 -1
  66. package/src/migrations/update-16-1-4/add-detox-app-json.js +29 -0
  67. package/src/migrations/update-16-6-0/update-metro-config.js +5 -1
  68. package/src/migrations/update-16-9-0/remove-types-react-native.js +9 -2
  69. package/src/migrations/update-16-9-0/update-eas-cli-version.js +2 -1
  70. package/src/utils/add-jest.d.ts +1 -1
  71. package/src/utils/add-jest.js +5 -15
  72. package/src/utils/add-linting.d.ts +0 -1
  73. package/src/utils/add-linting.js +1 -1
  74. package/src/utils/find-all-npm-dependencies.js +2 -4
  75. package/src/utils/symlink-task.d.ts +2 -0
  76. package/src/utils/symlink-task.js +18 -0
  77. package/src/utils/versions.d.ts +15 -14
  78. package/src/utils/versions.js +16 -15
  79. package/docs/export-examples.md +0 -112
  80. package/plugin.d.ts +0 -1
  81. package/plugin.js +0 -6
  82. package/plugins/plugin.d.ts +0 -14
  83. package/plugins/plugin.js +0 -150
  84. package/src/executors/serve/lib/is-packager-running.d.ts +0 -1
  85. package/src/executors/serve/lib/is-packager-running.js +0 -15
  86. package/src/executors/serve/schema.d.ts +0 -7
  87. package/src/executors/serve/schema.json +0 -35
  88. package/src/executors/serve/serve.impl.d.ts +0 -11
  89. package/src/executors/serve/serve.impl.js +0 -105
  90. package/src/generators/application/files/webpack.config.js.template +0 -57
  91. package/src/generators/application/lib/add-e2e.d.ts +0 -3
  92. package/src/generators/application/lib/add-e2e.js +0 -86
  93. package/src/generators/library/files/lib/.babelrc.js.template +0 -21
  94. package/src/migrations/update-18-0-0/change-outputDir-export-target.js +0 -25
  95. package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
  96. package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
  97. package/src/migrations/update-18-0-0/remove-eas-cli.d.ts +0 -12
  98. package/src/migrations/update-18-0-0/remove-eas-cli.js +0 -18
  99. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
  100. package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -29
  101. package/src/utils/ensure-dependencies.d.ts +0 -2
  102. package/src/utils/ensure-dependencies.js +0 -24
  103. package/src/utils/has-expo-plugin.d.ts +0 -2
  104. package/src/utils/has-expo-plugin.js +0 -11
  105. package/src/utils/resolve-eas.d.ts +0 -1
  106. package/src/utils/resolve-eas.js +0 -36
  107. /package/src/generators/application/files/{.babelrc.js.template → babel.config.js.template} +0 -0
  108. /package/src/{utils → generators/init/lib}/init-root-babel-config.d.ts +0 -0
  109. /package/src/{utils → generators/init/lib}/init-root-babel-config.js +0 -0
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
+ const versions_1 = require("../../utils/versions");
4
5
  async function update(tree) {
5
6
  const projects = (0, devkit_1.getProjects)(tree);
6
7
  for (const [name, config] of projects.entries()) {
7
8
  if (config.targets?.['start']?.executor === '@nx/expo:start') {
8
9
  (0, devkit_1.updateJson)(tree, `${config.root}/eas.json`, (easJson) => {
9
10
  if (easJson?.cli?.version) {
10
- easJson.cli.version = `>= 5`;
11
+ easJson.cli.version = `>= ${versions_1.easCliVersion.replace('~', '')}`;
11
12
  }
12
13
  return easJson;
13
14
  });
@@ -1,2 +1,2 @@
1
1
  import { Tree } from '@nx/devkit';
2
- export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
2
+ export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJest = void 0;
4
4
  const jest_1 = require("@nx/jest");
5
- async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin) {
5
+ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
6
6
  if (unitTestRunner !== 'jest') {
7
7
  return () => { };
8
8
  }
@@ -15,31 +15,21 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
15
15
  compiler: 'babel',
16
16
  skipPackageJson,
17
17
  skipFormat: true,
18
- addPlugin,
19
18
  });
20
19
  // overwrite the jest.config.ts file because react native needs to have special transform property
21
- // use preset from https://github.com/expo/expo/blob/main/packages/jest-expo/jest-preset.js
22
20
  const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
23
21
  const content = `module.exports = {
24
22
  displayName: '${projectName}',
25
23
  resolver: '@nx/jest/plugins/resolver',
26
24
  preset: 'jest-expo',
25
+ transformIgnorePatterns: [
26
+ 'node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)',
27
+ ],
27
28
  moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
28
29
  setupFilesAfterEnv: ['<rootDir>/test-setup.${js ? 'js' : 'ts'}'],
29
30
  moduleNameMapper: {
30
31
  '\\\\.svg$': '@nx/expo/plugins/jest/svg-mock'
31
- },
32
- transform: {
33
- '\\.[jt]sx?$': [
34
- 'babel-jest',
35
- {
36
- configFile: __dirname + '/.babelrc.js',
37
- },
38
- ],
39
- '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp|ttf|otf|m4v|mov|mp4|mpeg|mpg|webm|aac|aiff|caf|m4a|mp3|wav|html|pdf|obj)$': require.resolve(
40
- 'jest-expo/src/preset/assetFileTransformer.js'
41
- ),
42
- },
32
+ }
43
33
  };`;
44
34
  host.write(configPath, content);
45
35
  return jestTask;
@@ -7,7 +7,6 @@ interface NormalizedSchema {
7
7
  setParserOptionsProject?: boolean;
8
8
  tsConfigPaths: string[];
9
9
  skipPackageJson?: boolean;
10
- addPlugin?: boolean;
11
10
  }
12
11
  export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
13
12
  export {};
@@ -14,9 +14,9 @@ async function addLinting(host, options) {
14
14
  linter: options.linter,
15
15
  project: options.projectName,
16
16
  tsConfigPaths: options.tsConfigPaths,
17
+ eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
17
18
  skipFormat: true,
18
19
  skipPackageJson: options.skipPackageJson,
19
- addPlugin: options.addPlugin,
20
20
  });
21
21
  tasks.push(lintTask);
22
22
  if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
@@ -8,13 +8,11 @@ function findAllNpmDependencies(graph, projectName, list = [], seen = new Set())
8
8
  }
9
9
  seen.add(projectName);
10
10
  const node = graph.externalNodes[projectName];
11
- // Don't want to include '@nx/react-native' and '@nx/expo' because React Native
11
+ // Don't want to include '@nx/react-native' because React Native
12
12
  // autolink will warn that the package has no podspec file for iOS.
13
13
  if (node) {
14
14
  if (node.name !== `npm:@nx/react-native` &&
15
- node.name !== `npm:@nrwl/react-native` &&
16
- node.name !== `npm:@nx/expo` &&
17
- node.name !== `npm:@nrwl/expo`) {
15
+ node.name !== `npm:@nrwl/react-native`) {
18
16
  list.push(node.data.packageName);
19
17
  }
20
18
  }
@@ -0,0 +1,2 @@
1
+ import { GeneratorCallback } from '@nx/devkit';
2
+ export declare function runSymlink(workspaceRoot: string, projectRoot: string): GeneratorCallback;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runSymlink = void 0;
4
+ const ensure_node_modules_symlink_1 = require("./ensure-node-modules-symlink");
5
+ const chalk = require("chalk");
6
+ const devkit_1 = require("@nx/devkit");
7
+ function runSymlink(workspaceRoot, projectRoot) {
8
+ return () => {
9
+ devkit_1.logger.info(`creating symlinks for ${chalk.bold(projectRoot)}`);
10
+ try {
11
+ (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(workspaceRoot, projectRoot);
12
+ }
13
+ catch {
14
+ throw new Error(`Failed to create symlinks for ${chalk.bold(projectRoot)}`);
15
+ }
16
+ };
17
+ }
18
+ exports.runSymlink = runSymlink;
@@ -1,19 +1,20 @@
1
1
  export declare const nxVersion: any;
2
- export declare const expoVersion = "~50.0.3";
3
- export declare const expoSplashScreenVersion = "~0.26.1";
4
- export declare const expoStatusBarVersion = "~1.11.1";
5
- export declare const expoCliVersion = "~0.16.5";
6
- export declare const babelPresetExpoVersion = "~10.0.0";
2
+ export declare const expoVersion = "49.0.10";
3
+ export declare const expoMetroConfigVersion = "~0.10.7";
4
+ export declare const expoSplashScreenVersion = "~0.20.5";
5
+ export declare const expoStatusBarVersion = "~1.6.0";
6
+ export declare const expoCliVersion = "~0.10.12";
7
+ export declare const easCliVersion = "~5.2.0";
8
+ export declare const babelPresetExpoVersion = "~9.5.2";
7
9
  export declare const reactVersion = "18.2.0";
8
10
  export declare const reactDomVersion = "18.2.0";
9
11
  export declare const reactTestRendererVersion = "18.2.0";
10
- export declare const typesReactVersion = "~18.2.45";
11
- export declare const reactNativeVersion = "0.73.2";
12
- export declare const reactNativeWebVersion = "~0.19.9";
13
- export declare const expoMetroConfigVersion = "~0.17.3";
14
- export declare const expoMetroRuntimeVersion = "~3.1.1";
15
- export declare const reactNativeSvgTransformerVersion = "1.2.0";
16
- export declare const reactNativeSvgVersion = "14.1.0";
17
- export declare const testingLibraryReactNativeVersion = "~12.4.2";
12
+ export declare const typesReactVersion = "18.0.28";
13
+ export declare const reactNativeVersion = "0.72.4";
14
+ export declare const reactNativeWebVersion = "~0.19.8";
15
+ export declare const reactNativeSvgTransformerVersion = "1.0.0";
16
+ export declare const reactNativeSvgVersion = "13.9.0";
17
+ export declare const metroVersion = "0.76.7";
18
+ export declare const testingLibraryReactNativeVersion = "~12.3.0";
18
19
  export declare const testingLibraryJestNativeVersion = "~5.4.3";
19
- export declare const jestExpoVersion = "~50.0.1";
20
+ export declare const jestExpoVersion = "~49.0.0";
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jestExpoVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.expoMetroRuntimeVersion = exports.expoMetroConfigVersion = exports.reactNativeWebVersion = exports.reactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.babelPresetExpoVersion = exports.expoCliVersion = exports.expoStatusBarVersion = exports.expoSplashScreenVersion = exports.expoVersion = exports.nxVersion = void 0;
3
+ exports.jestExpoVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.metroVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.reactNativeWebVersion = exports.reactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.babelPresetExpoVersion = exports.easCliVersion = exports.expoCliVersion = exports.expoStatusBarVersion = exports.expoSplashScreenVersion = exports.expoMetroConfigVersion = exports.expoVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
- exports.expoVersion = '~50.0.3';
6
- exports.expoSplashScreenVersion = '~0.26.1';
7
- exports.expoStatusBarVersion = '~1.11.1';
8
- exports.expoCliVersion = '~0.16.5'; // @expo/cli
9
- exports.babelPresetExpoVersion = '~10.0.0';
5
+ exports.expoVersion = '49.0.10';
6
+ exports.expoMetroConfigVersion = '~0.10.7';
7
+ exports.expoSplashScreenVersion = '~0.20.5';
8
+ exports.expoStatusBarVersion = '~1.6.0';
9
+ exports.expoCliVersion = '~0.10.12'; // @expo/cli
10
+ exports.easCliVersion = '~5.2.0';
11
+ exports.babelPresetExpoVersion = '~9.5.2';
10
12
  exports.reactVersion = '18.2.0';
11
13
  exports.reactDomVersion = '18.2.0';
12
14
  exports.reactTestRendererVersion = '18.2.0';
13
- exports.typesReactVersion = '~18.2.45';
14
- exports.reactNativeVersion = '0.73.2';
15
- exports.reactNativeWebVersion = '~0.19.9';
16
- exports.expoMetroConfigVersion = '~0.17.3';
17
- exports.expoMetroRuntimeVersion = '~3.1.1';
18
- exports.reactNativeSvgTransformerVersion = '1.2.0';
19
- exports.reactNativeSvgVersion = '14.1.0';
20
- exports.testingLibraryReactNativeVersion = '~12.4.2';
15
+ exports.typesReactVersion = '18.0.28';
16
+ exports.reactNativeVersion = '0.72.4';
17
+ exports.reactNativeWebVersion = '~0.19.8';
18
+ exports.reactNativeSvgTransformerVersion = '1.0.0';
19
+ exports.reactNativeSvgVersion = '13.9.0';
20
+ exports.metroVersion = '0.76.7';
21
+ exports.testingLibraryReactNativeVersion = '~12.3.0';
21
22
  exports.testingLibraryJestNativeVersion = '~5.4.3';
22
- exports.jestExpoVersion = '~50.0.1';
23
+ exports.jestExpoVersion = '~49.0.0';
@@ -1,112 +0,0 @@
1
- `project.json`:
2
-
3
- ```json
4
- {
5
- "name": "mobile",
6
- //...
7
- "targets": {
8
- //...
9
- "export": {
10
- "executor": "@nx/expo:export",
11
- "options": {
12
- "outputs": ["{options.outputDir}"],
13
- "platform": "all",
14
- "outputDir": "dist/apps/mobile"
15
- },
16
- "dependsOn": ["sync-deps"]
17
- }
18
- //...
19
- }
20
- }
21
- ```
22
-
23
- ```shell
24
- nx run mobile:export
25
- ```
26
-
27
- ## Examples
28
-
29
- {% tabs %}
30
- {% tab label="Specify outputDir" %}
31
- The `outputDir` option allows you to specify the output directory of your bundle:
32
-
33
- ```json
34
- "export": {
35
- "executor": "@nx/expo:export",
36
- "outputs": ["{options.outputDir}"],
37
- "options": {
38
- "platform": "all",
39
- "bundler": "metro",
40
- "outputDir": "dist/apps/mobile"
41
- },
42
- "dependsOn": ["sync-deps"]
43
- },
44
- ```
45
-
46
- or run command: `nx run mobile:export --outputDir=dist/apps/mobile`.
47
-
48
- {% /tab %}
49
- {% tab label="Specify the platform" %}
50
- The `platform` option allows you to specify the platform to compile with metro bundler: "ios", "android", "all", and "web".
51
-
52
- For example, to bundle for web:
53
-
54
- ```json
55
- "export": {
56
- "executor": "@nx/expo:export",
57
- "outputs": ["{options.outputDir}"],
58
- "options": {
59
- "platform": "web",
60
- "bundler": "metro",
61
- "outputDir": "dist/apps/dogs"
62
- },
63
- "dependsOn": ["sync-deps"]
64
- },
65
- ```
66
-
67
- or run command `nx export mobile --platform=web`.
68
-
69
- {% /tab %}
70
- {% tab label="Bundle for development" %}
71
-
72
- The `dev` option allows you to bundle for development environments.
73
-
74
- ```json
75
- "export": {
76
- "executor": "@nx/expo:export",
77
- "outputs": ["{options.outputDir}"],
78
- "options": {
79
- "platform": "web",
80
- "bundler": "metro",
81
- "outputDir": "dist/apps/dogs",
82
- "dev": true
83
- },
84
- "dependsOn": ["sync-deps"]
85
- },
86
- ```
87
-
88
- or run command `nx export mobile --dev`.
89
-
90
- {% /tab %}
91
- {% tab label="Clear bundle cache" %}
92
-
93
- The `clear` option allows you to clear bundle cache.
94
-
95
- ```json
96
- "export": {
97
- "executor": "@nx/expo:export",
98
- "outputs": ["{options.outputDir}"],
99
- "options": {
100
- "platform": "web",
101
- "bundler": "metro",
102
- "outputDir": "dist/apps/dogs",
103
- "clear": true
104
- },
105
- "dependsOn": ["sync-deps"]
106
- },
107
- ```
108
-
109
- or run command `nx export mobile --clear`.
110
-
111
- {% /tab %}
112
- {% /tabs %}
package/plugin.d.ts DELETED
@@ -1 +0,0 @@
1
- export { createNodes, createDependencies, ExpoPluginOptions, } from './plugins/plugin';
package/plugin.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDependencies = exports.createNodes = void 0;
4
- var plugin_1 = require("./plugins/plugin");
5
- Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
- Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
@@ -1,14 +0,0 @@
1
- import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
- export interface ExpoPluginOptions {
3
- startTargetName?: string;
4
- serveTargetName?: string;
5
- runIosTargetName?: string;
6
- runAndroidTargetName?: string;
7
- exportTargetName?: string;
8
- prebuildTargetName?: string;
9
- installTargetName?: string;
10
- buildTargetName?: string;
11
- submitTargetName?: string;
12
- }
13
- export declare const createDependencies: CreateDependencies;
14
- export declare const createNodes: CreateNodes<ExpoPluginOptions>;
package/plugins/plugin.js DELETED
@@ -1,150 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = exports.createDependencies = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const js_1 = require("@nx/js");
7
- const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
- const fs_1 = require("fs");
9
- const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
- const cache_directory_1 = require("nx/src/utils/cache-directory");
11
- const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'expo.hash');
12
- const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
13
- const calculatedTargets = {};
14
- function readTargetsCache() {
15
- return (0, devkit_1.readJsonFile)(cachePath);
16
- }
17
- function writeTargetsToCache(targets) {
18
- (0, devkit_1.writeJsonFile)(cachePath, targets);
19
- }
20
- const createDependencies = () => {
21
- writeTargetsToCache(calculatedTargets);
22
- return [];
23
- };
24
- exports.createDependencies = createDependencies;
25
- exports.createNodes = [
26
- '**/app.{json,config.js}',
27
- (configFilePath, options, context) => {
28
- options = normalizeOptions(options);
29
- const projectRoot = (0, path_1.dirname)(configFilePath);
30
- // Do not create a project if package.json or project.json or metro.config.js isn't there.
31
- const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
32
- if (!siblingFiles.includes('package.json') ||
33
- !siblingFiles.includes('metro.config.js')) {
34
- return {};
35
- }
36
- const appConfig = getAppConfig(configFilePath, context);
37
- // if appConfig.expo is not defined
38
- if (!appConfig.expo) {
39
- return {};
40
- }
41
- const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
42
- (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
43
- ]);
44
- const targets = targetsCache[hash]
45
- ? targetsCache[hash]
46
- : buildExpoTargets(projectRoot, options, context);
47
- calculatedTargets[hash] = targets;
48
- return {
49
- projects: {
50
- [projectRoot]: {
51
- targets,
52
- },
53
- },
54
- };
55
- },
56
- ];
57
- function buildExpoTargets(projectRoot, options, context) {
58
- const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
59
- const targets = {
60
- [options.startTargetName]: {
61
- command: `expo start`,
62
- options: { cwd: projectRoot },
63
- },
64
- [options.serveTargetName]: {
65
- command: `expo start --web`,
66
- options: { cwd: projectRoot },
67
- },
68
- [options.runIosTargetName]: {
69
- command: `expo run:ios`,
70
- options: { cwd: projectRoot },
71
- },
72
- [options.runAndroidTargetName]: {
73
- command: `expo run:android`,
74
- options: { cwd: projectRoot },
75
- },
76
- [options.exportTargetName]: {
77
- command: `expo export`,
78
- options: { cwd: projectRoot },
79
- cache: true,
80
- dependsOn: [`^${options.exportTargetName}`],
81
- inputs: getInputs(namedInputs),
82
- outputs: [getOutputs(projectRoot, 'dist')],
83
- },
84
- [options.installTargetName]: {
85
- command: `expo install`,
86
- options: { cwd: devkit_1.workspaceRoot }, // install at workspace root
87
- },
88
- [options.prebuildTargetName]: {
89
- executor: `@nx/expo:prebuild`,
90
- },
91
- [options.buildTargetName]: {
92
- command: `eas build`,
93
- options: { cwd: projectRoot },
94
- },
95
- [options.submitTargetName]: {
96
- command: `eas submit`,
97
- options: { cwd: projectRoot },
98
- },
99
- };
100
- return targets;
101
- }
102
- function getAppConfig(configFilePath, context) {
103
- const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
104
- let module = load(resolvedPath);
105
- return module.default ?? module;
106
- }
107
- function getInputs(namedInputs) {
108
- return [
109
- ...('production' in namedInputs
110
- ? ['default', '^production']
111
- : ['default', '^default']),
112
- {
113
- externalDependencies: ['expo'],
114
- },
115
- ];
116
- }
117
- function getOutputs(projectRoot, dir) {
118
- if (projectRoot === '.') {
119
- return `{projectRoot}/${dir}`;
120
- }
121
- else {
122
- return `{workspaceRoot}/${projectRoot}/${dir}`;
123
- }
124
- }
125
- /**
126
- * Load the module after ensuring that the require cache is cleared.
127
- */
128
- function load(path) {
129
- // Clear cache if the path is in the cache
130
- if (require.cache[path]) {
131
- for (const k of Object.keys(require.cache)) {
132
- delete require.cache[k];
133
- }
134
- }
135
- // Then require
136
- return require(path);
137
- }
138
- function normalizeOptions(options) {
139
- options ??= {};
140
- options.startTargetName ??= 'start';
141
- options.serveTargetName ??= 'serve';
142
- options.runIosTargetName ??= 'run-ios';
143
- options.runAndroidTargetName ??= 'run-android';
144
- options.exportTargetName ??= 'export';
145
- options.prebuildTargetName ??= 'prebuild';
146
- options.installTargetName ??= 'install';
147
- options.buildTargetName ??= 'build';
148
- options.submitTargetName ??= 'submit';
149
- return options;
150
- }
@@ -1 +0,0 @@
1
- export declare function isPackagerRunning(packagerPort: number): Promise<'running' | 'not_running' | 'unrecognized'>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPackagerRunning = void 0;
4
- const node_fetch_1 = require("node-fetch");
5
- async function isPackagerRunning(packagerPort) {
6
- try {
7
- const resp = await (0, node_fetch_1.default)(`http://localhost:${packagerPort}/status`);
8
- const data = await resp.text();
9
- return data === 'packager-status:running' ? 'running' : 'unrecognized';
10
- }
11
- catch {
12
- return 'not_running';
13
- }
14
- }
15
- exports.isPackagerRunning = isPackagerRunning;
@@ -1,7 +0,0 @@
1
- export interface ExpoServeExecutorSchema {
2
- port: number;
3
- dev?: boolean;
4
- minify?: boolean;
5
- https?: boolean;
6
- clear?: boolean;
7
- }
@@ -1,35 +0,0 @@
1
- {
2
- "version": 2,
3
- "outputCapture": "direct-nodejs",
4
- "cli": "nx",
5
- "$id": "NxExpoServe",
6
- "$schema": "http://json-schema.org/schema",
7
- "title": "Serve web app for Expo",
8
- "description": "Packager Server target options.",
9
- "type": "object",
10
- "properties": {
11
- "port": {
12
- "type": "number",
13
- "description": "Port to start the native Metro bundler on (does not apply to web or tunnel)",
14
- "default": 4200,
15
- "alias": "p"
16
- },
17
- "clear": {
18
- "type": "boolean",
19
- "description": "Clear the Metro bundler cache",
20
- "alias": "c"
21
- },
22
- "maxWorkers": {
23
- "type": "number",
24
- "description": "Maximum number of tasks to allow Metro to spawn"
25
- },
26
- "dev": {
27
- "type": "boolean",
28
- "description": "Turn development mode on or off"
29
- },
30
- "minify": {
31
- "type": "boolean",
32
- "description": "Whether or not to minify code"
33
- }
34
- }
35
- }
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import { ExecutorContext } from '@nx/devkit';
3
- import { ChildProcess } from 'child_process';
4
- import { ExpoServeExecutorSchema } from './schema';
5
- export interface ExpoServeOutput {
6
- port?: number;
7
- baseUrl?: string;
8
- success: boolean;
9
- }
10
- export default function serveExecutor(options: ExpoServeExecutorSchema, context: ExecutorContext): AsyncGenerator<ExpoServeOutput>;
11
- export declare function runCliServe(workspaceRoot: string, projectRoot: string, options: ExpoServeExecutorSchema): Promise<ChildProcess>;