@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,32 @@
1
+ <% if (classComponent) { %>
2
+ import { Component } from 'react';
3
+ <% } else { %>
4
+ import React from 'react';
5
+ <% } %>
6
+ import { View, Text } from 'react-native';
7
+
8
+ /* eslint-disable-next-line */
9
+ export interface <%= className %>Props {
10
+ }
11
+
12
+ <% if (classComponent) { %>
13
+ export class <%= className %> extends Component<<%= className %>Props> {
14
+ render() {
15
+ return (
16
+ <View>
17
+ <Text>Welcome to <%= name %>!</Text>
18
+ </View>
19
+ );
20
+ }
21
+ }
22
+ <% } else { %>
23
+ export function <%= className %>(props: <%= className %>Props) {
24
+ return (
25
+ <View>
26
+ <Text>Welcome to <%= name %>!</Text>
27
+ </View>
28
+ );
29
+ }
30
+ <% } %>
31
+
32
+ export default <%= className %>;
@@ -0,0 +1,3 @@
1
+ import * as ts from 'typescript';
2
+ import { StringChange } from '@nx/devkit';
3
+ export declare function addImport(source: ts.SourceFile, statement: string): StringChange[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addImport = void 0;
4
+ const js_1 = require("@nx/js");
5
+ const ts = require("typescript");
6
+ const devkit_1 = require("@nx/devkit");
7
+ function addImport(source, statement) {
8
+ const allImports = (0, js_1.findNodes)(source, ts.SyntaxKind.ImportDeclaration);
9
+ if (allImports.length > 0) {
10
+ const lastImport = allImports[allImports.length - 1];
11
+ return [
12
+ {
13
+ type: devkit_1.ChangeType.Insert,
14
+ index: lastImport.end + 1,
15
+ text: `\n${statement}\n`,
16
+ },
17
+ ];
18
+ }
19
+ else {
20
+ return [
21
+ {
22
+ type: devkit_1.ChangeType.Insert,
23
+ index: 0,
24
+ text: `\n${statement}\n`,
25
+ },
26
+ ];
27
+ }
28
+ }
29
+ exports.addImport = addImport;
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Schema } from '../schema';
3
+ export interface NormalizedSchema extends Schema {
4
+ projectSourceRoot: string;
5
+ fileName: string;
6
+ className: string;
7
+ filePath: string;
8
+ projectName: string;
9
+ }
10
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
6
+ async function normalizeOptions(host, options) {
7
+ assertValidOptions(options);
8
+ const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
9
+ artifactType: 'component',
10
+ callingGenerator: '@nx/expo:component',
11
+ name: options.name,
12
+ directory: options.directory,
13
+ derivedDirectory: options.directory,
14
+ flat: options.flat,
15
+ nameAndDirectoryFormat: options.nameAndDirectoryFormat,
16
+ project: options.project,
17
+ fileExtension: 'tsx',
18
+ pascalCaseFile: options.pascalCaseFiles,
19
+ });
20
+ const project = (0, devkit_1.getProjects)(host).get(projectName);
21
+ const { className } = (0, devkit_1.names)(name);
22
+ const { sourceRoot: projectSourceRoot, projectType } = project;
23
+ if (options.export && projectType === 'application') {
24
+ devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
25
+ }
26
+ options.classComponent = options.classComponent ?? false;
27
+ return {
28
+ ...options,
29
+ directory,
30
+ className,
31
+ fileName,
32
+ filePath,
33
+ projectSourceRoot,
34
+ projectName,
35
+ };
36
+ }
37
+ exports.normalizeOptions = normalizeOptions;
38
+ function assertValidOptions(options) {
39
+ const slashes = ['/', '\\'];
40
+ slashes.forEach((s) => {
41
+ if (options.name.indexOf(s) !== -1) {
42
+ const [name, ...rest] = options.name.split(s).reverse();
43
+ let suggestion = rest.map((x) => x.toLowerCase()).join(s);
44
+ if (options.directory) {
45
+ suggestion = `${options.directory}${s}${suggestion}`;
46
+ }
47
+ throw new Error(`Found "${s}" in the component name. Did you mean to use the --directory option (e.g. \`nx g c ${name} --directory ${suggestion}\`)?`);
48
+ }
49
+ });
50
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Same as the @nx/react library schema, except it removes keys: style, routing, globalCss
3
+ */
4
+ export interface Schema {
5
+ name: string;
6
+ /**
7
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
8
+ */
9
+ project: string;
10
+ directory?: string;
11
+ skipFormat: boolean; // default is false
12
+ skipTests: boolean; // default is false
13
+ /**
14
+ * @deprecated Provide the name in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
15
+ */
16
+ export: boolean; // default is false
17
+ pascalCaseFiles: boolean; // default is false
18
+ classComponent: boolean; // default is false
19
+ js: boolean; // default is false
20
+ /**
21
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
22
+ */
23
+ flat: boolean; // default is false
24
+ nameAndDirectoryFormat?: 'as-provided' | 'derived';
25
+ }
@@ -0,0 +1,90 @@
1
+ {
2
+ "cli": "nx",
3
+ "$id": "NxExpoComponent",
4
+ "$schema": "https://json-schema.org/schema",
5
+ "description": "Create a Expo Component for Nx.",
6
+ "type": "object",
7
+ "examples": [
8
+ {
9
+ "command": "g @nx/expo:component my-component --project=mylib",
10
+ "description": "Generate a component in the mylib library"
11
+ },
12
+ {
13
+ "command": "g @nx/expo:component my-component --project=mylib --classComponent",
14
+ "description": "Generate a class component in the mylib library"
15
+ }
16
+ ],
17
+ "properties": {
18
+ "project": {
19
+ "type": "string",
20
+ "description": "The name of the project.",
21
+ "alias": "p",
22
+ "$default": {
23
+ "$source": "projectName"
24
+ },
25
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
26
+ },
27
+ "name": {
28
+ "type": "string",
29
+ "description": "The name of the component.",
30
+ "$default": {
31
+ "$source": "argv",
32
+ "index": 0
33
+ },
34
+ "x-prompt": "What name would you like to use for the component?"
35
+ },
36
+ "js": {
37
+ "type": "boolean",
38
+ "description": "Generate JavaScript files rather than TypeScript files.",
39
+ "default": false
40
+ },
41
+ "skipFormat": {
42
+ "description": "Skip formatting files.",
43
+ "type": "boolean",
44
+ "default": false,
45
+ "x-priority": "internal"
46
+ },
47
+ "skipTests": {
48
+ "type": "boolean",
49
+ "description": "When true, does not create \"spec.ts\" test files for the new component.",
50
+ "default": false
51
+ },
52
+ "directory": {
53
+ "type": "string",
54
+ "description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
55
+ "x-priority": "important"
56
+ },
57
+ "nameAndDirectoryFormat": {
58
+ "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
59
+ "type": "string",
60
+ "enum": ["as-provided", "derived"]
61
+ },
62
+ "flat": {
63
+ "type": "boolean",
64
+ "description": "Create component at the source root rather than its own directory.",
65
+ "default": false,
66
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
67
+ },
68
+ "export": {
69
+ "type": "boolean",
70
+ "description": "When true, the component is exported from the project index.ts (if it exists).",
71
+ "alias": "e",
72
+ "default": false,
73
+ "x-prompt": "Should this component be exported in the project?"
74
+ },
75
+ "pascalCaseFiles": {
76
+ "type": "boolean",
77
+ "description": "Use pascal case component file name (e.g. App.tsx).",
78
+ "alias": "P",
79
+ "default": false,
80
+ "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
81
+ },
82
+ "classComponent": {
83
+ "type": "boolean",
84
+ "alias": "C",
85
+ "description": "Use class components instead of functional component.",
86
+ "default": false
87
+ }
88
+ },
89
+ "required": ["name"]
90
+ }
@@ -0,0 +1,6 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function expoInitGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function expoInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
5
+ export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
6
+ export default expoInitGenerator;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDependencies = exports.expoInitGeneratorInternal = exports.expoInitGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
6
+ const plugin_1 = require("../../../plugins/plugin");
7
+ const versions_1 = require("../../utils/versions");
8
+ const has_expo_plugin_1 = require("../../utils/has-expo-plugin");
9
+ const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
10
+ function expoInitGenerator(tree, schema) {
11
+ return expoInitGeneratorInternal(tree, { addPlugin: false, ...schema });
12
+ }
13
+ exports.expoInitGenerator = expoInitGenerator;
14
+ async function expoInitGeneratorInternal(host, schema) {
15
+ const nxJson = (0, devkit_1.readNxJson)(host);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ schema.addPlugin ??= addPluginDefault;
19
+ (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
20
+ if (schema.addPlugin) {
21
+ addPlugin(host);
22
+ }
23
+ const tasks = [];
24
+ if (!schema.skipPackageJson) {
25
+ tasks.push(moveDependency(host));
26
+ tasks.push(updateDependencies(host, schema));
27
+ }
28
+ if (schema.updatePackageScripts) {
29
+ await (0, update_package_scripts_1.updatePackageScripts)(host, plugin_1.createNodes);
30
+ }
31
+ if (!schema.skipFormat) {
32
+ await (0, devkit_1.formatFiles)(host);
33
+ }
34
+ return (0, devkit_1.runTasksInSerial)(...tasks);
35
+ }
36
+ exports.expoInitGeneratorInternal = expoInitGeneratorInternal;
37
+ function updateDependencies(host, schema) {
38
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {
39
+ react: versions_1.reactVersion,
40
+ 'react-dom': versions_1.reactDomVersion,
41
+ 'react-native': versions_1.reactNativeVersion,
42
+ expo: versions_1.expoVersion,
43
+ }, {
44
+ '@nx/expo': versions_1.nxVersion,
45
+ '@expo/cli': versions_1.expoCliVersion,
46
+ }, undefined, schema.keepExistingVersions);
47
+ }
48
+ exports.updateDependencies = updateDependencies;
49
+ function moveDependency(host) {
50
+ return (0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react-native'], []);
51
+ }
52
+ function addPlugin(host) {
53
+ const nxJson = (0, devkit_1.readNxJson)(host);
54
+ if ((0, has_expo_plugin_1.hasExpoPlugin)(host)) {
55
+ return;
56
+ }
57
+ nxJson.plugins ??= [];
58
+ nxJson.plugins.push({
59
+ plugin: '@nx/expo/plugin',
60
+ options: {
61
+ startTargetName: 'start',
62
+ serveTargetName: 'serve',
63
+ runIosTargetName: 'run-ios',
64
+ runAndroidTargetName: 'run-android',
65
+ exportTargetName: 'export',
66
+ prebuildTargetName: 'prebuild',
67
+ installTargetName: 'install',
68
+ buildTargetName: 'build',
69
+ submitTargetName: 'submit',
70
+ },
71
+ });
72
+ (0, devkit_1.updateNxJson)(host, nxJson);
73
+ }
74
+ exports.default = expoInitGenerator;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function addGitIgnoreEntry(host: Tree): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGitIgnoreEntry = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const gitignore_entries_1 = require("./gitignore-entries");
6
+ function addGitIgnoreEntry(host) {
7
+ if (!host.exists('.gitignore')) {
8
+ devkit_1.logger.warn(`Couldn't find .gitignore file to update`);
9
+ return;
10
+ }
11
+ let content = host.read('.gitignore')?.toString('utf-8').trimEnd();
12
+ if (!/\.expo\/$/gm.test(content)) {
13
+ content = `${content}\n${gitignore_entries_1.gitIgnoreEntriesForExpo}\n`;
14
+ }
15
+ host.write('.gitignore', content);
16
+ }
17
+ exports.addGitIgnoreEntry = addGitIgnoreEntry;
@@ -0,0 +1 @@
1
+ export declare const gitIgnoreEntriesForExpo = "\n# Expo\nnode_modules/\n.expo/\n.yarn/\ndist/\nnpm-debug.*\n*.jks\n*.p8\n*.p12\n*.key\n*.mobileprovision\n*.orig.*\nweb-build/\ncache/\n";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gitIgnoreEntriesForExpo = void 0;
4
+ exports.gitIgnoreEntriesForExpo = `
5
+ # Expo
6
+ node_modules/
7
+ .expo/
8
+ .yarn/
9
+ dist/
10
+ npm-debug.*
11
+ *.jks
12
+ *.p8
13
+ *.p12
14
+ *.key
15
+ *.mobileprovision
16
+ *.orig.*
17
+ web-build/
18
+ cache/
19
+ `;
@@ -0,0 +1,7 @@
1
+ export interface Schema {
2
+ skipFormat?: boolean;
3
+ skipPackageJson?: boolean; // default is false
4
+ keepExistingVersions?: boolean; // default is false
5
+ updatePackageScripts?: boolean;
6
+ addPlugin?: boolean;
7
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "cli": "nx",
3
+ "$id": "NxExpoInit",
4
+ "$schema": "https://json-schema.org/schema",
5
+ "description": "Add Nx Expo Schematics.",
6
+ "type": "object",
7
+ "properties": {
8
+ "skipFormat": {
9
+ "description": "Skip formatting files",
10
+ "type": "boolean",
11
+ "default": false,
12
+ "x-priority": "internal"
13
+ },
14
+ "skipPackageJson": {
15
+ "type": "boolean",
16
+ "default": false,
17
+ "description": "Do not add dependencies to `package.json`."
18
+ },
19
+ "keepExistingVersions": {
20
+ "type": "boolean",
21
+ "x-priority": "internal",
22
+ "description": "Keep existing dependencies versions",
23
+ "default": false
24
+ },
25
+ "updatePackageScripts": {
26
+ "type": "boolean",
27
+ "x-priority": "internal",
28
+ "description": "Update `package.json` scripts with inferred targets",
29
+ "default": false
30
+ }
31
+ },
32
+ "required": []
33
+ }
@@ -0,0 +1,21 @@
1
+ module.exports = function (api) {
2
+ api.cache(true);
3
+
4
+ return {
5
+ presets: [
6
+ [
7
+ '@nx/react/babel',
8
+ {
9
+ runtime: 'automatic',
10
+ useBuiltIns: 'usage',
11
+ },
12
+ ],
13
+ ],
14
+ plugins: [],
15
+ env: {
16
+ test: {
17
+ presets: ['babel-preset-expo'],
18
+ },
19
+ },
20
+ };
21
+ };
@@ -0,0 +1,7 @@
1
+ # <%= name %>
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test <%= name %>` to execute the unit tests via [Jest](https://jestjs.io).
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "<%= name %>",
3
+ "version": "0.0.1",
4
+ "main": "<%= appMain %>"
5
+ }
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-native/extend-expect';
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "<%= rootTsConfigPath %>",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "allowJs": true,
6
+ "esModuleInterop": true,
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "files": [],
10
+ "include": [],
11
+ "references": [
12
+ {
13
+ "path": "./tsconfig.lib.json"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "<%= offsetFromRoot %>dist/out-tsc",
5
+ "types": ["node"]
6
+ },
7
+ "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "test-setup.ts"],
8
+ "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
9
+ }
@@ -0,0 +1,11 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Schema } from '../schema';
3
+ export interface NormalizedSchema extends Schema {
4
+ name: string;
5
+ fileName: string;
6
+ projectRoot: string;
7
+ routePath: string;
8
+ parsedTags: string[];
9
+ appMain: string;
10
+ }
11
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -0,0 +1,35 @@
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, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
+ name: options.name,
9
+ projectType: 'library',
10
+ directory: options.directory,
11
+ importPath: options.importPath,
12
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
13
+ callingGenerator: '@nx/expo:library',
14
+ });
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 parsedTags = options.tags
20
+ ? options.tags.split(',').map((s) => s.trim())
21
+ : [];
22
+ const appMain = options.js ? 'src/index.js' : 'src/index.ts';
23
+ const normalized = {
24
+ ...options,
25
+ fileName: projectName,
26
+ routePath: `/${projectNames.projectSimpleName}`,
27
+ name: projectName,
28
+ projectRoot,
29
+ parsedTags,
30
+ importPath,
31
+ appMain,
32
+ };
33
+ return normalized;
34
+ }
35
+ exports.normalizeOptions = normalizeOptions;
@@ -0,0 +1,5 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function expoLibraryGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function expoLibraryGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
5
+ export default expoLibraryGenerator;