@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
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-native/extend-expect';
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "<%= offsetFromRoot %>dist/out-tsc",
5
+ "types": ["node"]
6
+ },
7
+ "files": ["<%= offsetFromRoot %>node_modules/@nx/expo/typings/svg.d.ts"],
8
+ "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.spec.tsx", "test-setup.ts"],
9
+ "include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
10
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "allowSyntheticDefaultImports": true,
5
+ "jsx": "react-native",
6
+ "lib": ["dom", "esnext"],
7
+ "moduleResolution": "node",
8
+ "skipLibCheck": true,
9
+ "resolveJsonModule": true,
10
+ "strict": true,
11
+ "declaration": true
12
+ },
13
+ "files": [],
14
+ "include": [],
15
+ "references": [
16
+ {
17
+ "path": "./tsconfig.app.json"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,57 @@
1
+ const createExpoWebpackConfigAsync = require('@expo/webpack-config');
2
+ const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
3
+ const { resolve } = require('path');
4
+
5
+ /**
6
+ * @deprecated use bundler: 'metro' instead
7
+ */
8
+ module.exports = async function (env, argv) {
9
+ const config = await createExpoWebpackConfigAsync(env, argv);
10
+
11
+ // Customize the config before returning it.
12
+ // add additional rule to load files under libs
13
+ const rules = config.module.rules.find((rule) =>
14
+ Array.isArray(rule.oneOf)
15
+ )?.oneOf;
16
+ if (rules) {
17
+ rules.push({
18
+ test: /\.(mjs|[jt]sx?)$/,
19
+ exclude: /node_modules/,
20
+ use: {
21
+ loader: require.resolve('@nx/webpack/src/utils/web-babel-loader.js'),
22
+ options: {
23
+ presets: [
24
+ [
25
+ '@nx/react/babel',
26
+ {
27
+ runtime: 'automatic',
28
+ },
29
+ ],
30
+ ],
31
+ },
32
+ },
33
+ });
34
+ }
35
+
36
+ if (!config.resolve) {
37
+ config.resolve = {};
38
+ }
39
+ if (!config.resolve.plugins) {
40
+ config.resolve.plugins = [];
41
+ }
42
+ const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
43
+ const tsConfigPath = resolve(__dirname, 'tsconfig.json');
44
+ config.resolve.plugins.push(
45
+ new TsconfigPathsPlugin({
46
+ configFile: tsConfigPath,
47
+ extensions,
48
+ })
49
+ );
50
+ config.resolve.fallback = {
51
+ ...config.resolve.fallback,
52
+ crypto: require.resolve('crypto-browserify'),
53
+ stream: require.resolve('stream-browserify'),
54
+ };
55
+
56
+ return config;
57
+ };
@@ -0,0 +1,3 @@
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addE2e(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addE2e = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const web_1 = require("@nx/web");
6
+ const versions_1 = require("../../../utils/versions");
7
+ const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
8
+ async function addE2e(tree, options) {
9
+ const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(tree);
10
+ const port = hasPlugin ? 8081 : 4200;
11
+ switch (options.e2eTestRunner) {
12
+ case 'cypress': {
13
+ const hasNxExpoPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(tree);
14
+ if (!hasNxExpoPlugin) {
15
+ (0, web_1.webStaticServeGenerator)(tree, {
16
+ buildTarget: `${options.projectName}:export`,
17
+ targetName: 'serve-static',
18
+ });
19
+ }
20
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
21
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
22
+ projectType: 'application',
23
+ root: options.e2eProjectRoot,
24
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
25
+ targets: {},
26
+ implicitDependencies: [options.projectName],
27
+ tags: [],
28
+ });
29
+ return await configurationGenerator(tree, {
30
+ ...options,
31
+ project: options.e2eProjectName,
32
+ directory: 'src',
33
+ // the name and root are already normalized, instruct the generator to use them as is
34
+ bundler: 'none',
35
+ skipFormat: true,
36
+ devServerTarget: `${options.projectName}:serve`,
37
+ port,
38
+ baseUrl: `http://localhost:${port}`,
39
+ ciWebServerCommand: hasNxExpoPlugin
40
+ ? `nx run ${options.projectName}:serve-static`
41
+ : undefined,
42
+ jsx: true,
43
+ rootProject: options.rootProject,
44
+ });
45
+ }
46
+ case 'playwright': {
47
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
48
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
49
+ projectType: 'application',
50
+ root: options.e2eProjectRoot,
51
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
52
+ targets: {},
53
+ implicitDependencies: [options.projectName],
54
+ });
55
+ return configurationGenerator(tree, {
56
+ project: options.e2eProjectName,
57
+ skipFormat: true,
58
+ skipPackageJson: options.skipPackageJson,
59
+ directory: 'src',
60
+ js: false,
61
+ linter: options.linter,
62
+ setParserOptionsProject: options.setParserOptionsProject,
63
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
64
+ webServerAddress: `http://localhost:${port}`,
65
+ rootProject: options.rootProject,
66
+ });
67
+ }
68
+ case 'detox':
69
+ const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
70
+ return detoxApplicationGenerator(tree, {
71
+ ...options,
72
+ e2eName: options.e2eProjectName,
73
+ e2eDirectory: options.e2eProjectRoot,
74
+ projectNameAndRootFormat: 'as-provided',
75
+ appProject: options.projectName,
76
+ appDisplayName: options.displayName,
77
+ appName: options.name,
78
+ framework: 'expo',
79
+ setParserOptionsProject: options.setParserOptionsProject,
80
+ skipFormat: true,
81
+ });
82
+ case 'none':
83
+ default:
84
+ return () => { };
85
+ }
86
+ }
87
+ exports.addE2e = addE2e;
@@ -0,0 +1,2 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ export declare function addEasScripts(tree: Tree): void;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addEasScripts = void 0;
4
+ const preInstallScript = `
5
+ /*
6
+ * This script is used to patch the '@nx/expo' package to work with EAS Build.
7
+ * It is run as the eas-build-pre-install script in the 'package.json' of expo app.
8
+ * It is executed as 'node tools/scripts/eas-build-pre-install.mjs <workspace root> <project root>'
9
+ * It will copy the dependencies and devDependencies from the workspace package.json to project's package.json.
10
+ * This is needed because EAS Build does the install in project's directory and not workspace's directory.
11
+ */
12
+ import { readFileSync, writeFileSync } from 'fs';
13
+ import { join } from 'path';
14
+
15
+ const [workspaceRoot, projectRoot] = process.argv.slice(2);
16
+ if (!workspaceRoot) {
17
+ throw new Error('Missing workspace root');
18
+ }
19
+ if (!projectRoot) {
20
+ throw new Error('Missing project root');
21
+ }
22
+ try {
23
+ const workspacePackage = JSON.parse(
24
+ readFileSync(join(workspaceRoot, 'package.json')).toString()
25
+ );
26
+ const projectPackage = JSON.parse(
27
+ readFileSync(join(projectRoot, 'package.json')).toString()
28
+ );
29
+ projectPackage.dependencies = workspacePackage.dependencies;
30
+ projectPackage.devDependencies = workspacePackage.devDependencies;
31
+ writeFileSync(
32
+ join(projectRoot, 'package.json'),
33
+ JSON.stringify(projectPackage, null, 2)
34
+ );
35
+ } catch (e) {
36
+ console.error('Error reading package.json file', e);
37
+ }
38
+ `;
39
+ const postInstallScript = `
40
+ /**
41
+ * This script is used to patch the '@nx/expo' package to work with EAS Build.
42
+ * It is run as a eas-build-post-install script in the 'package.json' of expo app.
43
+ * It is executed as 'node tools/scripts/eas-build-post-install.mjs <workspace root> <project root>'
44
+ * It will create a symlink from the project's node_modules to the workspace's node_modules.
45
+ */
46
+
47
+ import { symlink, existsSync } from 'fs';
48
+ import { join } from 'path';
49
+
50
+ const [workspaceRoot, projectRoot] = process.argv.slice(2);
51
+
52
+ if (existsSync(join(workspaceRoot, 'node_modules'))) {
53
+ console.log('Symlink already exists');
54
+ process.exit(0);
55
+ }
56
+
57
+ symlink(join(projectRoot, 'node_modules'), join(workspaceRoot, 'node_modules'), 'dir', (err) => {
58
+ if (err) console.log(err);
59
+ else {
60
+ console.log('Symlink created');
61
+ }
62
+ });
63
+ `;
64
+ function addEasScripts(tree) {
65
+ const preInstallScriptPath = 'tools/scripts/eas-build-pre-install.mjs';
66
+ const postInstallScriptPath = 'tools/scripts/eas-build-post-install.mjs';
67
+ if (!tree.exists(preInstallScriptPath)) {
68
+ tree.write(preInstallScriptPath, preInstallScript);
69
+ }
70
+ if (!tree.exists(postInstallScriptPath)) {
71
+ tree.write(postInstallScriptPath, postInstallScript);
72
+ }
73
+ }
74
+ exports.addEasScripts = addEasScripts;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function addProject(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
6
+ const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
7
+ function addProject(host, options) {
8
+ const nxJson = (0, devkit_1.readNxJson)(host);
9
+ const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(host);
10
+ if (!hasPlugin) {
11
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(host, '@nx/expo:build');
12
+ }
13
+ const projectConfiguration = {
14
+ root: options.appProjectRoot,
15
+ sourceRoot: `${options.appProjectRoot}/src`,
16
+ projectType: 'application',
17
+ targets: hasPlugin ? {} : getTargets(options),
18
+ tags: options.parsedTags,
19
+ };
20
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, projectConfiguration, options.standaloneConfig);
21
+ }
22
+ exports.addProject = addProject;
23
+ function getTargets(options) {
24
+ const architect = {};
25
+ architect.start = {
26
+ executor: '@nx/expo:start',
27
+ dependsOn: ['sync-deps'],
28
+ options: {},
29
+ };
30
+ architect.serve = {
31
+ executor: '@nx/expo:serve',
32
+ dependsOn: ['sync-deps'],
33
+ options: {
34
+ port: 4200,
35
+ },
36
+ };
37
+ architect['run-ios'] = {
38
+ executor: '@nx/expo:run',
39
+ dependsOn: ['sync-deps'],
40
+ options: {
41
+ platform: 'ios',
42
+ },
43
+ };
44
+ architect['run-android'] = {
45
+ executor: '@nx/expo:run',
46
+ dependsOn: ['sync-deps'],
47
+ options: {
48
+ platform: 'android',
49
+ },
50
+ };
51
+ architect['build'] = {
52
+ executor: '@nx/expo:build',
53
+ dependsOn: ['sync-deps'],
54
+ options: {},
55
+ };
56
+ architect['submit'] = {
57
+ executor: '@nx/expo:submit',
58
+ options: {},
59
+ };
60
+ architect['build-list'] = {
61
+ executor: '@nx/expo:build-list',
62
+ options: {},
63
+ };
64
+ architect['sync-deps'] = {
65
+ executor: '@nx/expo:sync-deps',
66
+ options: {},
67
+ };
68
+ architect['prebuild'] = {
69
+ executor: '@nx/expo:prebuild',
70
+ dependsOn: ['sync-deps'],
71
+ options: {},
72
+ };
73
+ architect['install'] = {
74
+ executor: '@nx/expo:install',
75
+ options: {},
76
+ };
77
+ architect['update'] = {
78
+ executor: '@nx/expo:update',
79
+ options: {},
80
+ };
81
+ architect['export'] = {
82
+ executor: '@nx/expo:export',
83
+ dependsOn: ['sync-deps'],
84
+ outputs: ['{options.outputDir}'],
85
+ options: {
86
+ platform: 'all',
87
+ outputDir: `dist/${options.appProjectRoot}`,
88
+ },
89
+ };
90
+ return architect;
91
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from './normalize-options';
3
+ export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createApplicationFiles = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ function createApplicationFiles(host, options) {
7
+ const packageManagerLockFile = {
8
+ npm: 'package-lock.json',
9
+ yarn: 'yarn.lock',
10
+ pnpm: 'pnpm-lock.yaml',
11
+ };
12
+ const packageManager = (0, devkit_1.detectPackageManager)(host.root);
13
+ const packageLockFile = packageManagerLockFile[packageManager];
14
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files'), options.appProjectRoot, {
15
+ ...options,
16
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
17
+ packageManager,
18
+ packageLockFile,
19
+ });
20
+ if (options.unitTestRunner === 'none') {
21
+ host.delete((0, path_1.join)(options.appProjectRoot, `App.spec.tsx`));
22
+ }
23
+ if (options.js) {
24
+ (0, devkit_1.toJS)(host);
25
+ }
26
+ }
27
+ exports.createApplicationFiles = createApplicationFiles;
@@ -0,0 +1,13 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Schema } from '../schema';
3
+ export interface NormalizedSchema extends Schema {
4
+ className: string;
5
+ projectName: string;
6
+ appProjectRoot: string;
7
+ lowerCaseName: string;
8
+ parsedTags: string[];
9
+ rootProject: boolean;
10
+ e2eProjectName: string;
11
+ e2eProjectRoot: string;
12
+ }
13
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ async function normalizeOptions(host, options) {
7
+ const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
+ name: options.name,
9
+ projectType: 'application',
10
+ directory: options.directory,
11
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
12
+ callingGenerator: '@nx/expo:application',
13
+ });
14
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
15
+ const nxJson = (0, devkit_1.readNxJson)(host);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ options.addPlugin ??= addPluginDefault;
19
+ const { className } = (0, devkit_1.names)(options.name);
20
+ const parsedTags = options.tags
21
+ ? options.tags.split(',').map((s) => s.trim())
22
+ : [];
23
+ const rootProject = appProjectRoot === '.';
24
+ const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
25
+ const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
26
+ return {
27
+ ...options,
28
+ unitTestRunner: options.unitTestRunner || 'jest',
29
+ e2eTestRunner: options.e2eTestRunner,
30
+ name: projectNames.projectSimpleName,
31
+ className,
32
+ lowerCaseName: className.toLowerCase(),
33
+ displayName: options.displayName || className,
34
+ projectName: appProjectName,
35
+ appProjectRoot,
36
+ parsedTags,
37
+ rootProject,
38
+ e2eProjectName,
39
+ e2eProjectRoot,
40
+ };
41
+ }
42
+ exports.normalizeOptions = normalizeOptions;
@@ -0,0 +1,22 @@
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/eslint';
3
+
4
+ export interface Schema {
5
+ name: string;
6
+ displayName?: string;
7
+ style?: string;
8
+ skipFormat: boolean; // default is false
9
+ directory?: string;
10
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
+ tags?: string;
12
+ unitTestRunner: 'jest' | 'none'; // default is jest
13
+ pascalCaseFiles?: boolean;
14
+ classComponent?: boolean;
15
+ js: boolean; // default is false
16
+ linter: Linter; // default is eslint
17
+ setParserOptionsProject?: boolean; // default is false
18
+ e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none'; // default is cypress
19
+ standaloneConfig?: boolean;
20
+ skipPackageJson?: boolean; // default is false
21
+ addPlugin?: boolean;
22
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "cli": "nx",
3
+ "$id": "NxExpoApplication",
4
+ "$schema": "https://json-schema.org/schema",
5
+ "description": "Create an Expo Application for Nx.",
6
+ "examples": [
7
+ {
8
+ "command": "g @nx/expo:app myapp --directory=nested",
9
+ "description": "Generate apps/nested/myapp"
10
+ },
11
+ {
12
+ "command": "g @nx/expo:app myapp --classComponent",
13
+ "description": "Use class components instead of functional components"
14
+ }
15
+ ],
16
+ "type": "object",
17
+ "properties": {
18
+ "name": {
19
+ "description": "The name of the application.",
20
+ "type": "string",
21
+ "$default": {
22
+ "$source": "argv",
23
+ "index": 0
24
+ },
25
+ "x-prompt": "What name would you like to use for the application?",
26
+ "pattern": "^[a-zA-Z][^:]*$"
27
+ },
28
+ "displayName": {
29
+ "description": "The display name to show in the application. Defaults to name.",
30
+ "type": "string"
31
+ },
32
+ "directory": {
33
+ "description": "The directory of the new application.",
34
+ "type": "string",
35
+ "x-priority": "important"
36
+ },
37
+ "projectNameAndRootFormat": {
38
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
39
+ "type": "string",
40
+ "enum": ["as-provided", "derived"]
41
+ },
42
+ "skipFormat": {
43
+ "description": "Skip formatting files",
44
+ "type": "boolean",
45
+ "default": false,
46
+ "x-priority": "internal"
47
+ },
48
+ "linter": {
49
+ "description": "The tool to use for running lint checks.",
50
+ "type": "string",
51
+ "enum": ["eslint", "none"],
52
+ "default": "eslint"
53
+ },
54
+ "unitTestRunner": {
55
+ "type": "string",
56
+ "enum": ["jest", "none"],
57
+ "description": "Test runner to use for unit tests",
58
+ "default": "jest"
59
+ },
60
+ "tags": {
61
+ "type": "string",
62
+ "description": "Add tags to the application (used for linting)",
63
+ "alias": "t"
64
+ },
65
+ "js": {
66
+ "type": "boolean",
67
+ "description": "Generate JavaScript files rather than TypeScript files",
68
+ "default": false
69
+ },
70
+ "setParserOptionsProject": {
71
+ "type": "boolean",
72
+ "description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
73
+ "default": false
74
+ },
75
+ "e2eTestRunner": {
76
+ "description": "Adds the specified e2e test runner",
77
+ "type": "string",
78
+ "enum": ["cypress", "playwright", "detox", "none"],
79
+ "default": "cypress"
80
+ },
81
+ "standaloneConfig": {
82
+ "description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
83
+ "type": "boolean",
84
+ "default": true,
85
+ "x-deprecated": "Nx only supports standaloneConfig"
86
+ },
87
+ "skipPackageJson": {
88
+ "type": "boolean",
89
+ "description": "Do not add dependencies to `package.json`.",
90
+ "default": false
91
+ }
92
+ },
93
+ "required": ["name"]
94
+ }
@@ -0,0 +1,5 @@
1
+ import { Schema } from './schema';
2
+ import { Tree } from '@nx/devkit';
3
+ export declare function expoComponentGenerator(host: Tree, schema: Schema): Promise<void>;
4
+ export declare function expoComponentGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
5
+ export default expoComponentGenerator;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expoComponentGeneratorInternal = exports.expoComponentGenerator = void 0;
4
+ const ts = require("typescript");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const normalize_options_1 = require("./lib/normalize-options");
7
+ const add_import_1 = require("./lib/add-import");
8
+ const path_1 = require("path");
9
+ async function expoComponentGenerator(host, schema) {
10
+ return expoComponentGeneratorInternal(host, {
11
+ nameAndDirectoryFormat: 'derived',
12
+ ...schema,
13
+ });
14
+ }
15
+ exports.expoComponentGenerator = expoComponentGenerator;
16
+ async function expoComponentGeneratorInternal(host, schema) {
17
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
18
+ createComponentFiles(host, options);
19
+ addExportsToBarrel(host, options);
20
+ if (options.skipFormat) {
21
+ await (0, devkit_1.formatFiles)(host);
22
+ }
23
+ }
24
+ exports.expoComponentGeneratorInternal = expoComponentGeneratorInternal;
25
+ function createComponentFiles(host, options) {
26
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.directory, {
27
+ ...options,
28
+ tmpl: '',
29
+ });
30
+ for (const c of host.listChanges()) {
31
+ let deleteFile = false;
32
+ if (options.skipTests && /.*spec.tsx/.test(c.path)) {
33
+ deleteFile = true;
34
+ }
35
+ if (deleteFile) {
36
+ host.delete(c.path);
37
+ }
38
+ }
39
+ if (options.js) {
40
+ (0, devkit_1.toJS)(host);
41
+ }
42
+ }
43
+ function addExportsToBarrel(host, options) {
44
+ const workspace = (0, devkit_1.getProjects)(host);
45
+ const isApp = workspace.get(options.projectName).projectType === 'application';
46
+ if (options.export && !isApp) {
47
+ const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
48
+ const indexSource = host.read(indexFilePath, 'utf-8');
49
+ if (indexSource !== null) {
50
+ const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
51
+ const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
52
+ const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, add_import_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
53
+ host.write(indexFilePath, changes);
54
+ }
55
+ }
56
+ }
57
+ function getRelativeImportToFile(indexPath, filePath) {
58
+ const { name, dir } = (0, path_1.parse)(filePath);
59
+ const relativeDirToTarget = (0, path_1.relative)((0, path_1.dirname)(indexPath), dir);
60
+ return `./${(0, devkit_1.joinPathFragments)(relativeDirToTarget, name)}`;
61
+ }
62
+ exports.default = expoComponentGenerator;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react-native';
3
+
4
+ import <%= className %> from './<%= fileName %>';
5
+
6
+ describe('<%= className %>', () => {
7
+ it('should render successfully', () => {
8
+ const { root } = render(< <%= className %> />);
9
+ expect(root).toBeTruthy();
10
+ });
11
+ });