@nx/react-native 20.0.0-beta.5 → 20.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/migrations.json +0 -213
  2. package/package.json +7 -7
  3. package/src/generators/application/application.js +2 -0
  4. package/src/generators/application/lib/add-e2e.js +0 -1
  5. package/src/generators/application/lib/normalize-options.js +2 -3
  6. package/src/generators/application/schema.d.ts +2 -4
  7. package/src/generators/application/schema.json +9 -14
  8. package/src/generators/component/lib/normalize-options.d.ts +1 -0
  9. package/src/generators/component/lib/normalize-options.js +4 -4
  10. package/src/generators/component/schema.d.ts +2 -5
  11. package/src/generators/component/schema.json +10 -15
  12. package/src/generators/init/init.js +2 -0
  13. package/src/generators/library/lib/normalize-options.js +1 -1
  14. package/src/generators/library/library.js +2 -0
  15. package/src/generators/library/schema.d.ts +2 -4
  16. package/src/generators/library/schema.json +8 -13
  17. package/src/utils/testing-generators.js +1 -2
  18. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  19. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  20. package/src/migrations/update-16-1-0/upgrade-storybook-6-5.d.ts +0 -6
  21. package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +0 -21
  22. package/src/migrations/update-16-6-0/add-depends-on.d.ts +0 -6
  23. package/src/migrations/update-16-6-0/add-depends-on.js +0 -63
  24. package/src/migrations/update-16-6-0/update-metro-config.d.ts +0 -6
  25. package/src/migrations/update-16-6-0/update-metro-config.js +0 -63
  26. package/src/migrations/update-16-9-0/remove-types-react-native.d.ts +0 -7
  27. package/src/migrations/update-16-9-0/remove-types-react-native.js +0 -13
package/migrations.json CHANGED
@@ -1,35 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "update-16-0-0-add-nx-packages": {
4
- "cli": "nx",
5
- "version": "16.0.0-beta.1",
6
- "description": "Replace @nrwl/react-native with @nx/react-native",
7
- "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
- },
9
- "update-16-1-0-upgrade-storybook-6-5": {
10
- "cli": "nx",
11
- "version": "16.1.0-beta.0",
12
- "description": "Upgrade @storybook/react-native to 6.5",
13
- "implementation": "./src/migrations/update-16-1-0/upgrade-storybook-6-5"
14
- },
15
- "update-16-6-0-add-dependsOn": {
16
- "cli": "nx",
17
- "version": "16.6.0-beta.0",
18
- "description": "Add dependsOn like ensure-symlink or sync-deps to targets",
19
- "implementation": "./src/migrations/update-16-6-0/add-depends-on"
20
- },
21
- "update-16-6-0-update-metro-config": {
22
- "cli": "nx",
23
- "version": "16.6.0-beta.0",
24
- "description": "Update metro.config.js to use the new metro config format",
25
- "implementation": "./src/migrations/update-16-6-0/update-metro-config"
26
- },
27
- "update-16-9-0-remove-types-react-native": {
28
- "cli": "nx",
29
- "version": "16.9.0-beta.1",
30
- "description": "Remove @types/react-native from package.json",
31
- "implementation": "./src/migrations/update-16-9-0/remove-types-react-native"
32
- },
33
3
  "update-18-0-0-add-web-configuration": {
34
4
  "cli": "nx",
35
5
  "version": "18.0.0-beta.0",
@@ -74,189 +44,6 @@
74
44
  }
75
45
  },
76
46
  "packageJsonUpdates": {
77
- "16.0.0": {
78
- "version": "16.0.0-beta.0",
79
- "packages": {
80
- "@react-native-community/cli": {
81
- "version": "10.2.2",
82
- "alwaysAddToPackageJson": false
83
- },
84
- "react-native": {
85
- "version": "0.71.7",
86
- "alwaysAddToPackageJson": false
87
- },
88
- "@types/react-native": {
89
- "version": "0.71.6",
90
- "alwaysAddToPackageJson": false
91
- },
92
- "@testing-library/react-native": {
93
- "version": "12.0.1",
94
- "alwaysAddToPackageJson": false
95
- },
96
- "react-native-svg": {
97
- "version": "13.9.0",
98
- "alwaysAddToPackageJson": false
99
- }
100
- }
101
- },
102
- "16.0.2": {
103
- "version": "16.0.2-beta.0",
104
- "packages": {
105
- "@react-native-async-storage/async-storage": {
106
- "version": "1.18.1",
107
- "alwaysAddToPackageJson": false
108
- },
109
- "react-native-safe-area-context": {
110
- "version": "4.5.1",
111
- "alwaysAddToPackageJson": false
112
- }
113
- }
114
- },
115
- "16.1.5": {
116
- "version": "16.1.5-beta.0",
117
- "packages": {
118
- "react-native": {
119
- "version": "0.71.8",
120
- "alwaysAddToPackageJson": false
121
- },
122
- "@types/react-native": {
123
- "version": "0.71.7",
124
- "alwaysAddToPackageJson": false
125
- },
126
- "@testing-library/react-native": {
127
- "version": "12.1.2",
128
- "alwaysAddToPackageJson": false
129
- },
130
- "react-native-safe-area-context": {
131
- "version": "4.5.2",
132
- "alwaysAddToPackageJson": false
133
- }
134
- }
135
- },
136
- "16.4.0": {
137
- "version": "16.4.0-beta.5",
138
- "packages": {
139
- "react-native": {
140
- "version": "0.71.10",
141
- "alwaysAddToPackageJson": false
142
- },
143
- "@react-native-async-storage/async-storage": {
144
- "version": "1.18.2",
145
- "alwaysAddToPackageJson": false
146
- },
147
- "react-native-safe-area-context": {
148
- "version": "4.5.3",
149
- "alwaysAddToPackageJson": false
150
- }
151
- }
152
- },
153
- "16.6.0": {
154
- "version": "16.6.0-beta.0",
155
- "packages": {
156
- "react-native": {
157
- "version": "0.72.3",
158
- "alwaysAddToPackageJson": false
159
- },
160
- "@types/react-native": {
161
- "version": "0.72.2",
162
- "alwaysAddToPackageJson": false
163
- },
164
- "metro": {
165
- "version": "0.76.7",
166
- "alwaysAddToPackageJson": false
167
- },
168
- "metro-resolver": {
169
- "version": "0.76.7",
170
- "alwaysAddToPackageJson": false
171
- },
172
- "metro-config": {
173
- "version": "0.76.7",
174
- "alwaysAddToPackageJson": false
175
- },
176
- "metro-react-native-babel-preset": {
177
- "version": "0.76.7",
178
- "alwaysAddToPackageJson": false
179
- },
180
- "metro-babel-register": {
181
- "version": "0.76.7",
182
- "alwaysAddToPackageJson": false
183
- },
184
- "metro-react-native-babel-transformer": {
185
- "version": "0.76.7",
186
- "alwaysAddToPackageJson": false
187
- },
188
- "@react-native/metro-config": {
189
- "version": "^0.72.9",
190
- "alwaysAddToPackageJson": false,
191
- "addToPackageJson": "devDependencies"
192
- },
193
- "@react-native-community/cli": {
194
- "version": "11.3.5",
195
- "alwaysAddToPackageJson": false
196
- },
197
- "@react-native-community/cli-platform-android": {
198
- "version": "11.3.5",
199
- "alwaysAddToPackageJson": false
200
- },
201
- "@react-native-community/cli-platform-ios": {
202
- "version": "11.3.5",
203
- "alwaysAddToPackageJson": false
204
- },
205
- "@babel/runtime": {
206
- "version": "7.22.6",
207
- "alwaysAddToPackageJson": false
208
- },
209
- "@react-native-async-storage/async-storage": {
210
- "version": "1.19.0",
211
- "alwaysAddToPackageJson": false
212
- },
213
- "react-native-safe-area-context": {
214
- "version": "4.7.1",
215
- "alwaysAddToPackageJson": false
216
- }
217
- }
218
- },
219
- "16.9.0": {
220
- "version": "16.9.0-beta.1",
221
- "packages": {
222
- "react-native": {
223
- "version": "0.72.4",
224
- "alwaysAddToPackageJson": false
225
- },
226
- "@react-native/metro-config": {
227
- "version": "^0.72.11",
228
- "alwaysAddToPackageJson": false
229
- },
230
- "@react-native-community/cli": {
231
- "version": "11.3.6",
232
- "alwaysAddToPackageJson": false
233
- },
234
- "@react-native-community/cli-platform-android": {
235
- "version": "11.3.6",
236
- "alwaysAddToPackageJson": false
237
- },
238
- "@react-native-community/cli-platform-ios": {
239
- "version": "11.3.6",
240
- "alwaysAddToPackageJson": false
241
- },
242
- "@testing-library/react-native": {
243
- "version": "~12.3.0",
244
- "alwaysAddToPackageJson": false
245
- },
246
- "@testing-library/jest-native": {
247
- "version": "~5.4.3",
248
- "alwaysAddToPackageJson": false
249
- },
250
- "@react-native-async-storage/async-storage": {
251
- "version": "~1.19.3",
252
- "alwaysAddToPackageJson": false
253
- },
254
- "react-native-safe-area-context": {
255
- "version": "~4.7.2",
256
- "alwaysAddToPackageJson": false
257
- }
258
- }
259
- },
260
47
  "17.1.0": {
261
48
  "version": "17.1.0-beta.1",
262
49
  "packages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "20.0.0-beta.5",
3
+ "version": "20.0.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
6
6
  "keywords": [
@@ -36,12 +36,12 @@
36
36
  "node-fetch": "^2.6.7",
37
37
  "tsconfig-paths": "^4.1.2",
38
38
  "tslib": "^2.3.0",
39
- "@nx/devkit": "20.0.0-beta.5",
40
- "@nx/jest": "20.0.0-beta.5",
41
- "@nx/js": "20.0.0-beta.5",
42
- "@nx/eslint": "20.0.0-beta.5",
43
- "@nx/react": "20.0.0-beta.5",
44
- "@nx/workspace": "20.0.0-beta.5"
39
+ "@nx/devkit": "20.0.0-beta.6",
40
+ "@nx/jest": "20.0.0-beta.6",
41
+ "@nx/js": "20.0.0-beta.6",
42
+ "@nx/eslint": "20.0.0-beta.6",
43
+ "@nx/react": "20.0.0-beta.6",
44
+ "@nx/workspace": "20.0.0-beta.6"
45
45
  },
46
46
  "executors": "./executors.json",
47
47
  "ng-update": {
@@ -5,6 +5,7 @@ exports.reactNativeApplicationGeneratorInternal = reactNativeApplicationGenerato
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
7
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  const add_linting_1 = require("../../utils/add-linting");
9
10
  const add_jest_1 = require("../../utils/add-jest");
10
11
  const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
@@ -24,6 +25,7 @@ async function reactNativeApplicationGenerator(host, schema) {
24
25
  });
25
26
  }
26
27
  async function reactNativeApplicationGeneratorInternal(host, schema) {
28
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react-native', 'application');
27
29
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
28
30
  const tasks = [];
29
31
  const jsInitTask = await (0, js_1.initGenerator)(host, {
@@ -30,7 +30,6 @@ async function addE2e(host, options) {
30
30
  ...options,
31
31
  e2eName: options.e2eProjectName,
32
32
  e2eDirectory: options.e2eProjectRoot,
33
- projectNameAndRootFormat: 'as-provided',
34
33
  appProject: options.projectName,
35
34
  appDisplayName: options.displayName,
36
35
  appName: options.name,
@@ -4,13 +4,12 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
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, {
7
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
8
+ const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
9
  name: options.name,
9
10
  projectType: 'application',
10
11
  directory: options.directory,
11
- projectNameAndRootFormat: options.projectNameAndRootFormat,
12
12
  });
13
- options.projectNameAndRootFormat = projectNameAndRootFormat;
14
13
  const nxJson = (0, devkit_1.readNxJson)(host);
15
14
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
16
15
  nxJson.useInferencePlugins !== false;
@@ -1,13 +1,11 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  export interface Schema {
5
- name: string;
4
+ directory: string;
5
+ name?: string;
6
6
  displayName?: string;
7
7
  style?: string;
8
8
  skipFormat?: boolean;
9
- directory?: string;
10
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
9
  tags?: string;
12
10
  unitTestRunner: 'jest' | 'none'; // default is jest
13
11
  classComponent?: boolean;
@@ -16,29 +16,24 @@
16
16
  ],
17
17
  "type": "object",
18
18
  "properties": {
19
- "name": {
20
- "description": "The name of the application.",
19
+ "directory": {
20
+ "description": "The directory of the new application.",
21
21
  "type": "string",
22
22
  "$default": {
23
23
  "$source": "argv",
24
24
  "index": 0
25
25
  },
26
- "x-prompt": "What name would you like to use for the application?",
27
- "pattern": "^[a-zA-Z][^:]*$"
26
+ "x-prompt": "Which directory do you want to create the application in?"
28
27
  },
29
- "displayName": {
30
- "description": "The display name to show in the application. Defaults to name.",
28
+ "name": {
29
+ "description": "The name of the application.",
30
+ "pattern": "^[a-zA-Z][^:]*$",
31
31
  "type": "string"
32
32
  },
33
- "directory": {
34
- "description": "The directory of the new application.",
33
+ "displayName": {
34
+ "description": "The display name to show in the application. Defaults to name.",
35
35
  "type": "string"
36
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
37
  "skipFormat": {
43
38
  "description": "Skip formatting files",
44
39
  "type": "boolean",
@@ -99,5 +94,5 @@
99
94
  "x-priority": "important"
100
95
  }
101
96
  },
102
- "required": []
97
+ "required": ["directory"]
103
98
  }
@@ -1,6 +1,7 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from '../schema';
3
3
  export interface NormalizedSchema extends Schema {
4
+ directory: string;
4
5
  projectSourceRoot: string;
5
6
  fileName: string;
6
7
  className: string;
@@ -4,13 +4,12 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
6
6
  async function normalizeOptions(host, options) {
7
- assertValidOptions(options);
8
7
  const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
8
+ path: options.path,
9
9
  name: options.name,
10
- directory: options.directory,
11
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
12
10
  fileExtension: 'tsx',
13
11
  });
12
+ assertValidOptions({ name, directory });
14
13
  const project = (0, devkit_1.getProjects)(host).get(projectName);
15
14
  const { className } = (0, devkit_1.names)(name);
16
15
  const { sourceRoot: projectSourceRoot, projectType } = project;
@@ -20,6 +19,7 @@ async function normalizeOptions(host, options) {
20
19
  options.classComponent = options.classComponent ?? false;
21
20
  return {
22
21
  ...options,
22
+ name,
23
23
  directory,
24
24
  className,
25
25
  fileName,
@@ -37,7 +37,7 @@ function assertValidOptions(options) {
37
37
  if (options.directory) {
38
38
  suggestion = `${options.directory}${s}${suggestion}`;
39
39
  }
40
- 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}\`)?`);
40
+ throw new Error(`Found "${s}" in the component name. Did you mean to use the --path option (e.g. \`nx g c ${suggestion}/${name} \`)?`);
41
41
  }
42
42
  });
43
43
  }
@@ -1,14 +1,11 @@
1
- import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
-
3
1
  /**
4
2
  * Same as the @nx/react library schema, except it removes keys: style, routing, globalCss
5
3
  */
6
4
  export interface Schema {
7
- name: string;
5
+ path: string;
6
+ name?: string;
8
7
  skipTests?: boolean;
9
- directory?: string;
10
8
  export?: boolean;
11
9
  classComponent?: boolean;
12
10
  js?: boolean;
13
- nameAndDirectoryFormat?: NameAndDirectoryFormat;
14
11
  }
@@ -7,22 +7,27 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g @nx/react-native:component my-component --directory=mylib/src/lib/my-component",
10
+ "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component ",
11
11
  "description": "Generate a component in the `mylib` library"
12
12
  },
13
13
  {
14
- "command": "nx g @nx/react-native:component my-component --directory=mylib/src/lib/my-component --classComponent",
14
+ "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component --classComponent",
15
15
  "description": "Generate a class component in the `mylib` library"
16
16
  }
17
17
  ],
18
18
  "properties": {
19
- "name": {
19
+ "path": {
20
20
  "type": "string",
21
- "description": "The name of the component.",
21
+ "description": "The path at which to create the component file.",
22
22
  "$default": {
23
23
  "$source": "argv",
24
24
  "index": 0
25
25
  },
26
+ "x-prompt": "What path would you like to use for the component?"
27
+ },
28
+ "name": {
29
+ "type": "string",
30
+ "description": "The name of the component.",
26
31
  "x-prompt": "What name would you like to use for the component?"
27
32
  },
28
33
  "js": {
@@ -35,16 +40,6 @@
35
40
  "description": "When true, does not create `spec.ts` test files for the new component.",
36
41
  "default": false
37
42
  },
38
- "directory": {
39
- "type": "string",
40
- "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.",
41
- "x-priority": "important"
42
- },
43
- "nameAndDirectoryFormat": {
44
- "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`).",
45
- "type": "string",
46
- "enum": ["as-provided", "derived"]
47
- },
48
43
  "export": {
49
44
  "type": "boolean",
50
45
  "description": "When true, the component is exported from the project `index.ts` (if it exists).",
@@ -59,5 +54,5 @@
59
54
  "default": false
60
55
  }
61
56
  },
62
- "required": ["name"]
57
+ "required": ["path"]
63
58
  }
@@ -5,6 +5,7 @@ exports.reactNativeInitGeneratorInternal = reactNativeInitGeneratorInternal;
5
5
  exports.updateDependencies = updateDependencies;
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  const plugin_1 = require("../../../plugins/plugin");
9
10
  const versions_1 = require("../../utils/versions");
10
11
  const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
@@ -15,6 +16,7 @@ function reactNativeInitGenerator(host, schema) {
15
16
  });
16
17
  }
17
18
  async function reactNativeInitGeneratorInternal(host, schema) {
19
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react-native', 'init');
18
20
  (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
19
21
  const nxJson = (0, devkit_1.readNxJson)(host);
20
22
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -4,12 +4,12 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  async function normalizeOptions(host, options) {
7
+ await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
7
8
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
9
  name: options.name,
9
10
  projectType: 'library',
10
11
  directory: options.directory,
11
12
  importPath: options.importPath,
12
- projectNameAndRootFormat: options.projectNameAndRootFormat,
13
13
  });
14
14
  const nxJson = (0, devkit_1.readNxJson)(host);
15
15
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -11,6 +11,7 @@ const versions_1 = require("../../utils/versions");
11
11
  const normalize_options_1 = require("./lib/normalize-options");
12
12
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
13
13
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
14
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
14
15
  async function reactNativeLibraryGenerator(host, schema) {
15
16
  return await reactNativeLibraryGeneratorInternal(host, {
16
17
  addPlugin: false,
@@ -18,6 +19,7 @@ async function reactNativeLibraryGenerator(host, schema) {
18
19
  });
19
20
  }
20
21
  async function reactNativeLibraryGeneratorInternal(host, schema) {
22
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react-native', 'library');
21
23
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
22
24
  if (options.publishable === true && !schema.importPath) {
23
25
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
@@ -1,13 +1,11 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  /**
5
4
  * Same as the @nx/react library schema, except it removes keys: style, component, routing, appProject
6
5
  */
7
6
  export interface Schema {
8
- name: string;
9
- directory?: string;
10
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
7
+ directory: string;
8
+ name?: string;
11
9
  skipTsConfig: boolean;
12
10
  skipFormat: boolean;
13
11
  tags?: string;
@@ -12,27 +12,22 @@
12
12
  }
13
13
  ],
14
14
  "properties": {
15
- "name": {
15
+ "directory": {
16
16
  "type": "string",
17
- "description": "Library name.",
17
+ "description": "A directory where the lib is placed.",
18
+ "alias": "dir",
18
19
  "$default": {
19
20
  "$source": "argv",
20
21
  "index": 0
21
22
  },
22
- "x-prompt": "What name would you like to use for the library?",
23
- "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
23
+ "x-prompt": "Which directory do you want to create the library in?"
24
24
  },
25
- "directory": {
25
+ "name": {
26
26
  "type": "string",
27
- "description": "A directory where the lib is placed.",
28
- "alias": "dir",
27
+ "description": "Library name.",
28
+ "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
29
29
  "x-priority": "important"
30
30
  },
31
- "projectNameAndRootFormat": {
32
- "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`).",
33
- "type": "string",
34
- "enum": ["as-provided", "derived"]
35
- },
36
31
  "linter": {
37
32
  "description": "The tool to use for running lint checks.",
38
33
  "type": "string",
@@ -97,5 +92,5 @@
97
92
  "x-priority": "internal"
98
93
  }
99
94
  },
100
- "required": ["name"]
95
+ "required": ["directory"]
101
96
  }
@@ -11,10 +11,9 @@ async function createApp(tree, appName) {
11
11
  skipFormat: true,
12
12
  style: 'css',
13
13
  unitTestRunner: 'none',
14
- name: appName,
14
+ directory: appName,
15
15
  e2eTestRunner: 'none',
16
16
  install: false,
17
- projectNameAndRootFormat: 'as-provided',
18
17
  bundler: 'webpack',
19
18
  });
20
19
  }
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function replacePackage(tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replacePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- async function replacePackage(tree) {
7
- await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react-native', '@nx/react-native');
8
- await (0, devkit_1.formatFiles)(tree);
9
- }
@@ -1,6 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * This migration is to upgrade storybook to 6.5.
4
- * - remove react-native-storybook-loader
5
- */
6
- export default function update(tree: Tree): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- /**
6
- * This migration is to upgrade storybook to 6.5.
7
- * - remove react-native-storybook-loader
8
- */
9
- function update(tree) {
10
- if (tree.exists('package.json')) {
11
- (0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
12
- if (packageJson.dependencies?.['react-native-storybook-loader']) {
13
- delete packageJson.dependencies['react-native-storybook-loader'];
14
- }
15
- if (packageJson.devDependencies?.['react-native-storybook-loader']) {
16
- delete packageJson.devDependencies['react-native-storybook-loader'];
17
- }
18
- return packageJson;
19
- });
20
- }
21
- }
@@ -1,6 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * This migration adds dependsOn to project.json.
4
- *
5
- */
6
- export default function update(tree: Tree): Promise<void>;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- /**
6
- * This migration adds dependsOn to project.json.
7
- *
8
- */
9
- async function update(tree) {
10
- const projects = (0, devkit_1.getProjects)(tree);
11
- for (const [name, config] of projects.entries()) {
12
- if (config.targets?.['start']?.executor === '@nx/react-native:start') {
13
- config.targets['start'].dependsOn = [
14
- 'ensure-symlink',
15
- 'sync-deps',
16
- 'pod-install',
17
- ];
18
- if (config.targets?.['run-ios']?.executor === '@nx/react-native:run-ios') {
19
- config.targets['run-ios'].dependsOn = [
20
- 'ensure-symlink',
21
- 'sync-deps',
22
- 'pod-install',
23
- ];
24
- }
25
- if (config.targets?.['bundle-ios']?.executor === '@nx/react-native:bundle') {
26
- config.targets['bundle-ios'].dependsOn = ['ensure-symlink'];
27
- }
28
- if (config.targets?.['run-android']?.executor ===
29
- '@nx/react-native:run-android') {
30
- config.targets['run-android'].dependsOn ??= [
31
- 'ensure-symlink',
32
- 'sync-deps',
33
- ];
34
- }
35
- if (config.targets?.['build-android']?.executor ===
36
- '@nx/react-native:build-android') {
37
- config.targets['build-android'].dependsOn = [
38
- 'ensure-symlink',
39
- 'sync-deps',
40
- ];
41
- }
42
- if (config.targets?.['build-ios']?.executor === '@nx/react-native:build-ios') {
43
- config.targets['build-ios'].dependsOn ??= [
44
- 'ensure-symlink',
45
- 'sync-deps',
46
- 'pod-install',
47
- ];
48
- }
49
- if (config.targets?.['pod-instal']?.executor ===
50
- '@nx/react-native:pod-install') {
51
- config.targets['pod-install'].dependsOn ??= [
52
- 'ensure-symlink',
53
- 'sync-deps',
54
- ];
55
- }
56
- if (config.targets?.['bundle-android']?.executor ===
57
- '@nx/react-native:bundle') {
58
- config.targets['bundle-android'].dependsOn ??= ['ensure-symlink'];
59
- }
60
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
61
- }
62
- }
63
- }
@@ -1,6 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * This migration updates metro.config.js to export config as a default.
4
- *
5
- */
6
- export default function update(tree: Tree): Promise<void>;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- /**
7
- * This migration updates metro.config.js to export config as a default.
8
- *
9
- */
10
- async function update(tree) {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- for (const [_, config] of projects.entries()) {
13
- if (config.targets?.['start']?.executor === '@nx/react-native:start') {
14
- if (tree.exists((0, path_1.join)(config.root, 'metro.config.js'))) {
15
- const oldConfig = tree
16
- .read((0, path_1.join)(config.root, 'metro.config.js'))
17
- .toString();
18
- tree.write((0, path_1.join)(config.root, 'metro-v71.config.js'), oldConfigComment + oldConfig);
19
- tree.write((0, path_1.join)(config.root, 'metro.config.js'), content);
20
- }
21
- }
22
- }
23
- }
24
- const oldConfigComment = `/**
25
- * Old custom configuration for React Native v0.71.
26
- * From @react-native/metro-config 0.72.1, it is no longer necessary to use a config function to access the complete default config.
27
- * Please port your custom configuration to metro.config.js.
28
- * Please see https://reactnative.dev/docs/metro to learn about configuration.
29
- */
30
- `;
31
- const content = `
32
- const { withNxMetro } = require('@nx/react-native');
33
- const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
34
-
35
- const defaultConfig = getDefaultConfig(__dirname);
36
- const { assetExts, sourceExts } = defaultConfig.resolver;
37
-
38
- /**
39
- * Metro configuration
40
- * https://facebook.github.io/metro/docs/configuration
41
- *
42
- * @type {import('metro-config').MetroConfig}
43
- */
44
- const customConfig = {
45
- transformer: {
46
- babelTransformerPath: require.resolve('react-native-svg-transformer'),
47
- },
48
- resolver: {
49
- assetExts: assetExts.filter((ext) => ext !== 'svg'),
50
- sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
51
- },
52
- };
53
-
54
- module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
55
- // Change this to true to see debugging info.
56
- // Useful if you have issues resolving modules
57
- debug: false,
58
- // all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
59
- extensions: [],
60
- // Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
61
- watchFolders: [],
62
- });
63
- `;
@@ -1,7 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * Remove @types/react-native package since it is no longer required. It would be a part of react native package.
4
- * @param tree
5
- * @returns
6
- */
7
- export default function update(tree: Tree): Promise<void>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- /**
6
- * Remove @types/react-native package since it is no longer required. It would be a part of react native package.
7
- * @param tree
8
- * @returns
9
- */
10
- async function update(tree) {
11
- (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['@types/react-native']);
12
- await (0, devkit_1.formatFiles)(tree);
13
- }