@nx/expo 0.0.0-pr-22179-271588f

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 (194) hide show
  1. package/.eslintrc.json +46 -0
  2. package/LICENSE +22 -0
  3. package/README.md +68 -0
  4. package/docs/build-list-examples.md +71 -0
  5. package/docs/export-examples.md +112 -0
  6. package/docs/prebuild-examples.md +70 -0
  7. package/docs/run-examples.md +91 -0
  8. package/docs/start-examples.md +104 -0
  9. package/executors.json +64 -0
  10. package/generators.json +33 -0
  11. package/index.d.ts +3 -0
  12. package/index.js +9 -0
  13. package/migrations.json +689 -0
  14. package/package.json +57 -0
  15. package/plugin.d.ts +1 -0
  16. package/plugin.js +6 -0
  17. package/plugins/jest/svg-mock.d.ts +0 -0
  18. package/plugins/jest/svg-mock.js +3 -0
  19. package/plugins/metro-resolver.d.ts +1 -0
  20. package/plugins/metro-resolver.js +136 -0
  21. package/plugins/plugin.d.ts +14 -0
  22. package/plugins/plugin.js +150 -0
  23. package/plugins/with-nx-metro.d.ts +8 -0
  24. package/plugins/with-nx-metro.js +31 -0
  25. package/plugins/with-nx-webpack.d.ts +5 -0
  26. package/plugins/with-nx-webpack.js +51 -0
  27. package/project.json +61 -0
  28. package/src/executors/build/build.impl.d.ts +6 -0
  29. package/src/executors/build/build.impl.js +70 -0
  30. package/src/executors/build/schema.d.ts +14 -0
  31. package/src/executors/build/schema.json +83 -0
  32. package/src/executors/build-list/build-fragment.d.ts +54 -0
  33. package/src/executors/build-list/build-list.impl.d.ts +7 -0
  34. package/src/executors/build-list/build-list.impl.js +81 -0
  35. package/src/executors/build-list/schema.d.ts +25 -0
  36. package/src/executors/build-list/schema.json +79 -0
  37. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +9 -0
  38. package/src/executors/ensure-symlink/ensure-symlink.impl.js +13 -0
  39. package/src/executors/ensure-symlink/schema.json +11 -0
  40. package/src/executors/export/export.impl.d.ts +7 -0
  41. package/src/executors/export/export.impl.js +73 -0
  42. package/src/executors/export/schema.d.ts +13 -0
  43. package/src/executors/export/schema.json +49 -0
  44. package/src/executors/install/install.impl.d.ts +7 -0
  45. package/src/executors/install/install.impl.js +63 -0
  46. package/src/executors/install/schema.d.ts +7 -0
  47. package/src/executors/install/schema.json +34 -0
  48. package/src/executors/prebuild/prebuild.impl.d.ts +7 -0
  49. package/src/executors/prebuild/prebuild.impl.js +69 -0
  50. package/src/executors/prebuild/schema.d.ts +7 -0
  51. package/src/executors/prebuild/schema.json +36 -0
  52. package/src/executors/run/run.impl.d.ts +6 -0
  53. package/src/executors/run/run.impl.js +96 -0
  54. package/src/executors/run/schema.d.ts +24 -0
  55. package/src/executors/run/schema.json +65 -0
  56. package/src/executors/serve/lib/is-packager-running.d.ts +1 -0
  57. package/src/executors/serve/lib/is-packager-running.js +15 -0
  58. package/src/executors/serve/schema.d.ts +7 -0
  59. package/src/executors/serve/schema.json +35 -0
  60. package/src/executors/serve/serve.impl.d.ts +11 -0
  61. package/src/executors/serve/serve.impl.js +105 -0
  62. package/src/executors/start/schema.d.ts +22 -0
  63. package/src/executors/start/schema.json +93 -0
  64. package/src/executors/start/start.impl.d.ts +7 -0
  65. package/src/executors/start/start.impl.js +77 -0
  66. package/src/executors/submit/schema.d.ts +12 -0
  67. package/src/executors/submit/schema.json +57 -0
  68. package/src/executors/submit/submit.impl.d.ts +6 -0
  69. package/src/executors/submit/submit.impl.js +70 -0
  70. package/src/executors/sync-deps/schema.d.ts +5 -0
  71. package/src/executors/sync-deps/schema.json +33 -0
  72. package/src/executors/sync-deps/sync-deps.impl.d.ts +9 -0
  73. package/src/executors/sync-deps/sync-deps.impl.js +78 -0
  74. package/src/executors/update/schema.d.ts +15 -0
  75. package/src/executors/update/schema.json +75 -0
  76. package/src/executors/update/update.impl.d.ts +6 -0
  77. package/src/executors/update/update.impl.js +67 -0
  78. package/src/generators/application/application.d.ts +5 -0
  79. package/src/generators/application/application.js +63 -0
  80. package/src/generators/application/files/.babelrc.js.template +6 -0
  81. package/src/generators/application/files/app.json.template +44 -0
  82. package/src/generators/application/files/assets/adaptive-icon.png +0 -0
  83. package/src/generators/application/files/assets/favicon.png +0 -0
  84. package/src/generators/application/files/assets/icon.png +0 -0
  85. package/src/generators/application/files/assets/splash.png +0 -0
  86. package/src/generators/application/files/eas.json.template +25 -0
  87. package/src/generators/application/files/index.js.template +8 -0
  88. package/src/generators/application/files/metro.config.js.template +33 -0
  89. package/src/generators/application/files/package.json.template +18 -0
  90. package/src/generators/application/files/src/app/App.spec.tsx.template +9 -0
  91. package/src/generators/application/files/src/app/App.tsx.template +731 -0
  92. package/src/generators/application/files/test-setup.ts.template +1 -0
  93. package/src/generators/application/files/tsconfig.app.json.template +10 -0
  94. package/src/generators/application/files/tsconfig.json.template +20 -0
  95. package/src/generators/application/files/webpack.config.js.template +57 -0
  96. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  97. package/src/generators/application/lib/add-e2e.js +87 -0
  98. package/src/generators/application/lib/add-eas-scripts.d.ts +2 -0
  99. package/src/generators/application/lib/add-eas-scripts.js +74 -0
  100. package/src/generators/application/lib/add-project.d.ts +3 -0
  101. package/src/generators/application/lib/add-project.js +91 -0
  102. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  103. package/src/generators/application/lib/create-application-files.js +27 -0
  104. package/src/generators/application/lib/normalize-options.d.ts +13 -0
  105. package/src/generators/application/lib/normalize-options.js +42 -0
  106. package/src/generators/application/schema.d.ts +22 -0
  107. package/src/generators/application/schema.json +94 -0
  108. package/src/generators/component/component.d.ts +5 -0
  109. package/src/generators/component/component.js +62 -0
  110. package/src/generators/component/files/__fileName__.spec.tsx.template +11 -0
  111. package/src/generators/component/files/__fileName__.tsx.template +32 -0
  112. package/src/generators/component/lib/add-import.d.ts +3 -0
  113. package/src/generators/component/lib/add-import.js +29 -0
  114. package/src/generators/component/lib/normalize-options.d.ts +10 -0
  115. package/src/generators/component/lib/normalize-options.js +50 -0
  116. package/src/generators/component/schema.d.ts +25 -0
  117. package/src/generators/component/schema.json +90 -0
  118. package/src/generators/init/init.d.ts +6 -0
  119. package/src/generators/init/init.js +74 -0
  120. package/src/generators/init/lib/add-git-ignore-entry.d.ts +2 -0
  121. package/src/generators/init/lib/add-git-ignore-entry.js +17 -0
  122. package/src/generators/init/lib/gitignore-entries.d.ts +1 -0
  123. package/src/generators/init/lib/gitignore-entries.js +19 -0
  124. package/src/generators/init/schema.d.ts +7 -0
  125. package/src/generators/init/schema.json +33 -0
  126. package/src/generators/library/files/lib/.babelrc.js.template +21 -0
  127. package/src/generators/library/files/lib/README.md +7 -0
  128. package/src/generators/library/files/lib/package.json.template +5 -0
  129. package/src/generators/library/files/lib/src/index.ts.template +0 -0
  130. package/src/generators/library/files/lib/test-setup.ts.template +1 -0
  131. package/src/generators/library/files/lib/tsconfig.json.template +16 -0
  132. package/src/generators/library/files/lib/tsconfig.lib.json.template +9 -0
  133. package/src/generators/library/lib/normalize-options.d.ts +11 -0
  134. package/src/generators/library/lib/normalize-options.js +35 -0
  135. package/src/generators/library/library.d.ts +5 -0
  136. package/src/generators/library/library.js +159 -0
  137. package/src/generators/library/schema.d.ts +25 -0
  138. package/src/generators/library/schema.json +104 -0
  139. package/src/migrations/update-15-0-3/add-new-expo-cli-targets.d.ts +9 -0
  140. package/src/migrations/update-15-0-3/add-new-expo-cli-targets.js +61 -0
  141. package/src/migrations/update-15-0-3/change-jest-preset.d.ts +8 -0
  142. package/src/migrations/update-15-0-3/change-jest-preset.js +69 -0
  143. package/src/migrations/update-15-8-3/change-webpack-to-metro.d.ts +8 -0
  144. package/src/migrations/update-15-8-3/change-webpack-to-metro.js +31 -0
  145. package/src/migrations/update-16-0-0/add-jest-expo.d.ts +6 -0
  146. package/src/migrations/update-16-0-0/add-jest-expo.js +27 -0
  147. package/src/migrations/update-16-0-0/remove-deprecated-targets.d.ts +5 -0
  148. package/src/migrations/update-16-0-0/remove-deprecated-targets.js +32 -0
  149. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  150. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  151. package/src/migrations/update-16-1-4/update-eas-scripts.d.ts +5 -0
  152. package/src/migrations/update-16-1-4/update-eas-scripts.js +42 -0
  153. package/src/migrations/update-16-2-2/add-submit-target.d.ts +5 -0
  154. package/src/migrations/update-16-2-2/add-submit-target.js +22 -0
  155. package/src/migrations/update-16-6-0/add-depends-on.d.ts +6 -0
  156. package/src/migrations/update-16-6-0/add-depends-on.js +29 -0
  157. package/src/migrations/update-16-6-0/update-metro-config.d.ts +6 -0
  158. package/src/migrations/update-16-6-0/update-metro-config.js +65 -0
  159. package/src/migrations/update-16-9-0/remove-types-react-native.d.ts +7 -0
  160. package/src/migrations/update-16-9-0/remove-types-react-native.js +13 -0
  161. package/src/migrations/update-16-9-0/update-eas-cli-version.d.ts +2 -0
  162. package/src/migrations/update-16-9-0/update-eas-cli-version.js +17 -0
  163. package/src/migrations/update-18-0-0/change-outputDir-export-target.d.ts +5 -0
  164. package/src/migrations/update-18-0-0/change-outputDir-export-target.js +25 -0
  165. package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
  166. package/src/migrations/update-18-0-0/remove-block-list.js +28 -0
  167. package/src/migrations/update-18-0-0/remove-eas-cli.d.ts +12 -0
  168. package/src/migrations/update-18-0-0/remove-eas-cli.js +18 -0
  169. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
  170. package/src/migrations/update-18-0-0/remove-symlink-target.js +29 -0
  171. package/src/utils/add-jest.d.ts +2 -0
  172. package/src/utils/add-jest.js +47 -0
  173. package/src/utils/add-linting.d.ts +13 -0
  174. package/src/utils/add-linting.js +37 -0
  175. package/src/utils/ensure-dependencies.d.ts +2 -0
  176. package/src/utils/ensure-dependencies.js +24 -0
  177. package/src/utils/ensure-node-modules-symlink.d.ts +9 -0
  178. package/src/utils/ensure-node-modules-symlink.js +28 -0
  179. package/src/utils/find-all-npm-dependencies.d.ts +2 -0
  180. package/src/utils/find-all-npm-dependencies.js +27 -0
  181. package/src/utils/has-expo-plugin.d.ts +2 -0
  182. package/src/utils/has-expo-plugin.js +11 -0
  183. package/src/utils/init-root-babel-config.d.ts +2 -0
  184. package/src/utils/init-root-babel-config.js +13 -0
  185. package/src/utils/pod-install-task.d.ts +16 -0
  186. package/src/utils/pod-install-task.js +66 -0
  187. package/src/utils/resolve-eas.d.ts +1 -0
  188. package/src/utils/resolve-eas.js +36 -0
  189. package/src/utils/versions.d.ts +19 -0
  190. package/src/utils/versions.js +22 -0
  191. package/tsconfig.json +13 -0
  192. package/tsconfig.lib.json +11 -0
  193. package/tsconfig.spec.json +20 -0
  194. package/typings/svg.d.ts +6 -0
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@nx/expo",
3
+ "version": "0.0.0-pr-22179-271588f",
4
+ "private": false,
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
+ "keywords": [
7
+ "Monorepo",
8
+ "Expo",
9
+ "React",
10
+ "Web",
11
+ "Jest",
12
+ "Native",
13
+ "CLI"
14
+ ],
15
+ "homepage": "https://nx.dev",
16
+ "bugs": {
17
+ "url": "https://github.com/nrwl/nx/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/nrwl/nx.git",
22
+ "directory": "packages/expo"
23
+ },
24
+ "license": "MIT",
25
+ "author": "Victor Savkin",
26
+ "main": "./index.js",
27
+ "types": "index.d.ts",
28
+ "dependencies": {
29
+ "@nx/devkit": "0.0.0-pr-22179-271588f",
30
+ "chalk": "^4.1.0",
31
+ "enhanced-resolve": "^5.8.3",
32
+ "fs-extra": "^11.1.0",
33
+ "metro-config": "~0.80.4",
34
+ "metro-resolver": "~0.80.4",
35
+ "node-fetch": "^2.6.7",
36
+ "tslib": "^2.3.0",
37
+ "tsconfig-paths": "^4.1.2",
38
+ "tsconfig-paths-webpack-plugin": "^4.0.0",
39
+ "@nx/jest": "0.0.0-pr-22179-271588f",
40
+ "@nx/js": "0.0.0-pr-22179-271588f",
41
+ "@nx/eslint": "0.0.0-pr-22179-271588f",
42
+ "@nx/react": "0.0.0-pr-22179-271588f",
43
+ "@nx/web": "0.0.0-pr-22179-271588f",
44
+ "@nx/webpack": "0.0.0-pr-22179-271588f",
45
+ "@nrwl/expo": "0.0.0-pr-22179-271588f"
46
+ },
47
+ "executors": "./executors.json",
48
+ "ng-update": {
49
+ "requirements": {},
50
+ "migrations": "./migrations.json"
51
+ },
52
+ "generators": "./generators.json",
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "type": "commonjs"
57
+ }
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes, createDependencies, ExpoPluginOptions, } from './plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,6 @@
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; } });
File without changes
@@ -0,0 +1,3 @@
1
+ // From https://github.com/kristerkari/react-native-svg-transformer#usage-with-jest
2
+ module.exports = 'SvgMock';
3
+ module.exports.ReactComponent = 'SvgMock';
@@ -0,0 +1 @@
1
+ export declare function getResolveRequest(extensions: string[]): (_context: any, realModuleName: string, platform: string | null) => any;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getResolveRequest = void 0;
4
+ const metroResolver = require("metro-resolver");
5
+ const tsconfig_paths_1 = require("tsconfig-paths");
6
+ const chalk = require("chalk");
7
+ const enhanced_resolve_1 = require("enhanced-resolve");
8
+ const path_1 = require("path");
9
+ const fs = require("fs");
10
+ const devkit_1 = require("@nx/devkit");
11
+ /*
12
+ * Use tsconfig to resolve additional workspace libs.
13
+ *
14
+ * This resolve function requires projectRoot to be set to
15
+ * workspace root in order modules and assets to be registered and watched.
16
+ */
17
+ function getResolveRequest(extensions) {
18
+ return function (_context, realModuleName, platform) {
19
+ const debug = process.env.NX_REACT_NATIVE_DEBUG === 'true';
20
+ if (debug)
21
+ console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`));
22
+ const { resolveRequest, ...context } = _context;
23
+ const resolvedPath = resolveRequestFromContext(resolveRequest, _context, realModuleName, platform, debug) ||
24
+ defaultMetroResolver(context, realModuleName, platform, debug) ||
25
+ tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) ||
26
+ pnpmResolver(extensions, context, realModuleName, debug);
27
+ if (resolvedPath) {
28
+ return resolvedPath;
29
+ }
30
+ if (debug) {
31
+ console.log(chalk.red(`[Nx] Unable to resolve with any resolver: ${realModuleName}`));
32
+ }
33
+ throw new Error(`Cannot resolve ${chalk.bold(realModuleName)}`);
34
+ };
35
+ }
36
+ exports.getResolveRequest = getResolveRequest;
37
+ function resolveRequestFromContext(resolveRequest, context, realModuleName, platform, debug) {
38
+ try {
39
+ return resolveRequest(context, realModuleName, platform);
40
+ }
41
+ catch {
42
+ if (debug)
43
+ console.log(chalk.cyan(`[Nx] Unable to resolve with default resolveRequest: ${realModuleName}`));
44
+ }
45
+ }
46
+ /**
47
+ * This function try to resolve path using metro's default resolver
48
+ * @returns path if resolved, else undefined
49
+ */
50
+ function defaultMetroResolver(context, realModuleName, platform, debug) {
51
+ try {
52
+ return metroResolver.resolve(context, realModuleName, platform);
53
+ }
54
+ catch {
55
+ if (debug)
56
+ console.log(chalk.cyan(`[Nx] Unable to resolve with default Metro resolver: ${realModuleName}`));
57
+ }
58
+ }
59
+ /**
60
+ * This resolver try to resolve module for pnpm.
61
+ * @returns path if resolved, else undefined
62
+ * This pnpm resolver is inspired from https://github.com/vjpr/pnpm-react-native-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js
63
+ */
64
+ function pnpmResolver(extensions, context, realModuleName, debug) {
65
+ try {
66
+ const pnpmResolve = getPnpmResolver(extensions);
67
+ const lookupStartPath = (0, path_1.dirname)(context.originModulePath);
68
+ const filePath = pnpmResolve.resolveSync({}, lookupStartPath, realModuleName);
69
+ if (filePath) {
70
+ return { type: 'sourceFile', filePath };
71
+ }
72
+ }
73
+ catch {
74
+ if (debug)
75
+ console.log(chalk.cyan(`[Nx] Unable to resolve with default PNPM resolver: ${realModuleName}`));
76
+ }
77
+ }
78
+ /**
79
+ * This function try to resolve files that are specified in tsconfig's paths
80
+ * @returns path if resolved, else undefined
81
+ */
82
+ function tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) {
83
+ try {
84
+ const tsConfigPathMatcher = getMatcher(debug);
85
+ const match = tsConfigPathMatcher(realModuleName, undefined, undefined, extensions.map((ext) => `.${ext}`));
86
+ return metroResolver.resolve(context, match, platform);
87
+ }
88
+ catch {
89
+ if (debug) {
90
+ console.log(chalk.cyan(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`));
91
+ console.log(chalk.cyan(`[Nx] The following tsconfig paths was used:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
92
+ }
93
+ }
94
+ }
95
+ let matcher;
96
+ let absoluteBaseUrl;
97
+ let paths;
98
+ function getMatcher(debug) {
99
+ if (!matcher) {
100
+ const result = (0, tsconfig_paths_1.loadConfig)();
101
+ if (result.resultType === 'success') {
102
+ absoluteBaseUrl = result.absoluteBaseUrl;
103
+ paths = result.paths;
104
+ if (debug) {
105
+ console.log(chalk.cyan(`[Nx] Located tsconfig at ${chalk.bold(absoluteBaseUrl)}`));
106
+ console.log(chalk.cyan(`[Nx] Found the following paths:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
107
+ }
108
+ matcher = (0, tsconfig_paths_1.createMatchPath)(absoluteBaseUrl, paths);
109
+ }
110
+ else {
111
+ console.log(chalk.cyan(`[Nx] Failed to locate tsconfig}`));
112
+ throw new Error(`Could not load tsconfig for project`);
113
+ }
114
+ }
115
+ return matcher;
116
+ }
117
+ /**
118
+ * This function returns resolver for pnpm.
119
+ * It is inspired form https://github.com/vjpr/pnpm-expo-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js.
120
+ */
121
+ let resolver;
122
+ function getPnpmResolver(extensions) {
123
+ if (!resolver) {
124
+ const fileSystem = new enhanced_resolve_1.CachedInputFileSystem(fs, 4000);
125
+ resolver = enhanced_resolve_1.ResolverFactory.createResolver({
126
+ fileSystem,
127
+ extensions: extensions.map((extension) => '.' + extension),
128
+ useSyncFileSystemCalls: true,
129
+ modules: [(0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'), 'node_modules'],
130
+ conditionNames: ['native', 'browser', 'require', 'default'],
131
+ mainFields: ['react-native', 'browser', 'main'],
132
+ aliasFields: ['browser'],
133
+ });
134
+ }
135
+ return resolver;
136
+ }
@@ -0,0 +1,14 @@
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>;
@@ -0,0 +1,150 @@
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
+ }
@@ -0,0 +1,8 @@
1
+ import type { MetroConfig } from 'metro-config';
2
+ interface WithNxOptions {
3
+ debug?: boolean;
4
+ extensions?: string[];
5
+ watchFolders?: string[];
6
+ }
7
+ export declare function withNxMetro(userConfig: MetroConfig, opts?: WithNxOptions): Promise<import("metro-config").ConfigT>;
8
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withNxMetro = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const metro_config_1 = require("metro-config");
6
+ const fs_extra_1 = require("fs-extra");
7
+ const metro_resolver_1 = require("./metro-resolver");
8
+ async function withNxMetro(userConfig, opts = {}) {
9
+ const extensions = ['', 'ts', 'tsx', 'js', 'jsx', 'json'];
10
+ if (opts.debug)
11
+ process.env.NX_REACT_NATIVE_DEBUG = 'true';
12
+ if (opts.extensions)
13
+ extensions.push(...opts.extensions);
14
+ let watchFolders = (0, fs_extra_1.readdirSync)(devkit_1.workspaceRoot)
15
+ .filter((fileName) => !['dist', 'e2e'].includes(fileName) && !fileName.startsWith('.'))
16
+ .map((fileName) => (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, fileName))
17
+ .filter((filePath) => (0, fs_extra_1.statSync)(filePath).isDirectory());
18
+ if (opts.watchFolders?.length) {
19
+ watchFolders = watchFolders.concat(opts.watchFolders);
20
+ }
21
+ watchFolders = [...new Set(watchFolders)].filter((folder) => (0, fs_extra_1.existsSync)(folder));
22
+ const nxConfig = {
23
+ resolver: {
24
+ resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
25
+ nodeModulesPaths: [(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules')],
26
+ },
27
+ watchFolders,
28
+ };
29
+ return (0, metro_config_1.mergeConfig)(userConfig, nxConfig);
30
+ }
31
+ exports.withNxMetro = withNxMetro;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @deprecated TODO(v19) use bundler: 'metro' instead, will be removed in v19
3
+ * This function add additional rules to expo's webpack config to make expo web working
4
+ */
5
+ export declare function withNxWebpack(config: any): Promise<any>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withNxWebpack = void 0;
4
+ const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
5
+ const path_1 = require("path");
6
+ /**
7
+ * @deprecated TODO(v19) use bundler: 'metro' instead, will be removed in v19
8
+ * This function add additional rules to expo's webpack config to make expo web working
9
+ */
10
+ async function withNxWebpack(config) {
11
+ // add additional rule to load files under libs
12
+ const rules = config.module.rules.find((rule) => Array.isArray(rule.oneOf))?.oneOf;
13
+ if (rules) {
14
+ rules.push({
15
+ test: /\.(mjs|[jt]sx?)$/,
16
+ exclude: /node_modules/,
17
+ use: {
18
+ loader: require.resolve('@nx/webpack/src/utils/web-babel-loader.js'),
19
+ options: {
20
+ presets: [
21
+ [
22
+ '@nx/react/babel',
23
+ {
24
+ runtime: 'automatic',
25
+ },
26
+ ],
27
+ ],
28
+ },
29
+ },
30
+ });
31
+ }
32
+ if (!config.resolve) {
33
+ config.resolve = {};
34
+ }
35
+ if (!config.resolve.plugins) {
36
+ config.resolve.plugins = [];
37
+ }
38
+ const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
39
+ const tsConfigPath = (0, path_1.resolve)(__dirname, 'tsconfig.json');
40
+ config.resolve.plugins.push(new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
41
+ configFile: tsConfigPath,
42
+ extensions,
43
+ }));
44
+ config.resolve.fallback = {
45
+ ...config.resolve.fallback,
46
+ crypto: require.resolve('crypto-browserify'),
47
+ stream: require.resolve('stream-browserify'),
48
+ };
49
+ return config;
50
+ }
51
+ exports.withNxWebpack = withNxWebpack;
package/project.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "expo",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/expo/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "lint": {},
8
+ "test": {},
9
+ "build-base": {
10
+ "executor": "@nx/js:tsc",
11
+ "options": {
12
+ "assets": [
13
+ "packages/expo/*.md",
14
+ {
15
+ "input": "packages/expo",
16
+ "glob": "**/!(*.ts)",
17
+ "output": "/"
18
+ },
19
+ {
20
+ "input": "packages/expo",
21
+ "glob": "**/*.d.ts",
22
+ "output": "/"
23
+ },
24
+ {
25
+ "input": "packages/expo",
26
+ "glob": "**/files/**",
27
+ "output": "/"
28
+ },
29
+ {
30
+ "input": "packages/expo",
31
+ "glob": "**/files/**/.gitkeep",
32
+ "output": "/"
33
+ },
34
+ {
35
+ "input": "packages/expo",
36
+ "glob": "**/files/**/.babelrc.js.template",
37
+ "output": "/"
38
+ },
39
+ {
40
+ "input": "packages/expo",
41
+ "glob": "**/*.json",
42
+ "ignore": ["**/tsconfig*.json", "**/project.json"],
43
+ "output": "/"
44
+ },
45
+ "LICENSE"
46
+ ]
47
+ }
48
+ },
49
+ "build": {
50
+ "executor": "nx:run-commands",
51
+ "outputs": ["{workspaceRoot}/build/packages/expo"],
52
+ "options": {
53
+ "command": "node ./scripts/copy-readme.js expo"
54
+ }
55
+ },
56
+ "add-extra-dependencies": {
57
+ "command": "node ./scripts/add-dependency-to-build.js expo @nrwl/expo"
58
+ }
59
+ },
60
+ "tags": []
61
+ }
@@ -0,0 +1,6 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { ExpoEasBuildOptions } from './schema';
3
+ export interface ReactNativeBuildOutput {
4
+ success: boolean;
5
+ }
6
+ export default function buildExecutor(options: ExpoEasBuildOptions, context: ExecutorContext): AsyncGenerator<ReactNativeBuildOutput>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const path_1 = require("path");
5
+ const child_process_1 = require("child_process");
6
+ const resolve_eas_1 = require("../../utils/resolve-eas");
7
+ let childProcess;
8
+ async function* buildExecutor(options, context) {
9
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
10
+ try {
11
+ await runCliBuild(context.root, projectRoot, options);
12
+ yield { success: true };
13
+ }
14
+ finally {
15
+ if (childProcess) {
16
+ childProcess.kill();
17
+ }
18
+ }
19
+ }
20
+ exports.default = buildExecutor;
21
+ function runCliBuild(workspaceRoot, projectRoot, options) {
22
+ return new Promise((resolve, reject) => {
23
+ childProcess = (0, child_process_1.fork)((0, resolve_eas_1.resolveEas)(workspaceRoot), ['build', ...createBuildOptions(options)], {
24
+ cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
25
+ env: process.env,
26
+ });
27
+ // Ensure the child process is killed when the parent exits
28
+ process.on('exit', () => childProcess.kill());
29
+ process.on('SIGTERM', () => childProcess.kill());
30
+ childProcess.on('error', (err) => {
31
+ reject(err);
32
+ });
33
+ childProcess.on('exit', (code) => {
34
+ if (code === 0) {
35
+ resolve(code);
36
+ }
37
+ else {
38
+ reject(code);
39
+ }
40
+ });
41
+ });
42
+ }
43
+ function createBuildOptions(options) {
44
+ return Object.keys(options).reduce((acc, k) => {
45
+ const v = options[k];
46
+ if (typeof v === 'boolean') {
47
+ if (k === 'interactive') {
48
+ if (v === false) {
49
+ acc.push('--non-interactive'); // when is false, the flag is --non-interactive
50
+ }
51
+ }
52
+ else if (k === 'wait') {
53
+ if (v === false) {
54
+ acc.push('--no-wait'); // when is false, the flag is --no-wait
55
+ }
56
+ else {
57
+ acc.push('--wait');
58
+ }
59
+ }
60
+ else if (v === true) {
61
+ // when true, does not need to pass the value true, just need to pass the flag in kebob case
62
+ acc.push(`--${(0, devkit_1.names)(k).fileName}`);
63
+ }
64
+ }
65
+ else {
66
+ acc.push(`--${(0, devkit_1.names)(k).fileName}`, v);
67
+ }
68
+ return acc;
69
+ }, []);
70
+ }
@@ -0,0 +1,14 @@
1
+ // command to run https://github.com/expo/eas-cli/tree/main#eas-build
2
+ // options from github.com/expo/eas-cli/blob/main/packages/eas-cli/src/commands/build/index.ts
3
+ export interface ExpoEasBuildOptions {
4
+ platform: 'ios' | 'android' | 'all';
5
+ profile?: string;
6
+ interactive: boolean; // default is true
7
+ local: boolean; // default is false
8
+ output?: string;
9
+ wait: boolean; // default is true
10
+ clearCache: boolean; // default is false
11
+ json: boolean; // default is false
12
+ autoSubmit: boolean; // default is false
13
+ autoSubmitWithProfile?: string;
14
+ }