@nx/react-native 0.0.0-pr-3-16b3273 → 0.0.0-pr-29464-b66c9d0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "0.0.0-pr-3-16b3273",
3
+ "version": "0.0.0-pr-29464-b66c9d0",
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": [
@@ -35,12 +35,12 @@
35
35
  "picocolors": "^1.1.0",
36
36
  "tsconfig-paths": "^4.1.2",
37
37
  "tslib": "^2.3.0",
38
- "@nx/devkit": "0.0.0-pr-3-16b3273",
39
- "@nx/jest": "0.0.0-pr-3-16b3273",
40
- "@nx/js": "0.0.0-pr-3-16b3273",
41
- "@nx/eslint": "0.0.0-pr-3-16b3273",
42
- "@nx/react": "0.0.0-pr-3-16b3273",
43
- "@nx/workspace": "0.0.0-pr-3-16b3273"
38
+ "@nx/devkit": "0.0.0-pr-29464-b66c9d0",
39
+ "@nx/jest": "0.0.0-pr-29464-b66c9d0",
40
+ "@nx/js": "0.0.0-pr-29464-b66c9d0",
41
+ "@nx/eslint": "0.0.0-pr-29464-b66c9d0",
42
+ "@nx/react": "0.0.0-pr-29464-b66c9d0",
43
+ "@nx/workspace": "0.0.0-pr-29464-b66c9d0"
44
44
  },
45
45
  "executors": "./executors.json",
46
46
  "ng-update": {
@@ -1,94 +1,94 @@
1
- @rem
2
- @rem Copyright 2015 the original author or authors.
3
- @rem
4
- @rem Licensed under the Apache License, Version 2.0 (the "License");
5
- @rem you may not use this file except in compliance with the License.
6
- @rem You may obtain a copy of the License at
7
- @rem
8
- @rem https://www.apache.org/licenses/LICENSE-2.0
9
- @rem
10
- @rem Unless required by applicable law or agreed to in writing, software
11
- @rem distributed under the License is distributed on an "AS IS" BASIS,
12
- @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- @rem See the License for the specific language governing permissions and
14
- @rem limitations under the License.
15
- @rem
16
- @rem SPDX-License-Identifier: Apache-2.0
17
- @rem
18
-
19
- @if "%DEBUG%"=="" @echo off
20
- @rem ##########################################################################
21
- @rem
22
- @rem Gradle startup script for Windows
23
- @rem
24
- @rem ##########################################################################
25
-
26
- @rem Set local scope for the variables with windows NT shell
27
- if "%OS%"=="Windows_NT" setlocal
28
-
29
- set DIRNAME=%~dp0
30
- if "%DIRNAME%"=="" set DIRNAME=.
31
- @rem This is normally unused
32
- set APP_BASE_NAME=%~n0
33
- set APP_HOME=%DIRNAME%
34
-
35
- @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
- for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
-
38
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
- set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
-
41
- @rem Find java.exe
42
- if defined JAVA_HOME goto findJavaFromJavaHome
43
-
44
- set JAVA_EXE=java.exe
45
- %JAVA_EXE% -version >NUL 2>&1
46
- if %ERRORLEVEL% equ 0 goto execute
47
-
48
- echo. 1>&2
49
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
- echo. 1>&2
51
- echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
- echo location of your Java installation. 1>&2
53
-
54
- goto fail
55
-
56
- :findJavaFromJavaHome
57
- set JAVA_HOME=%JAVA_HOME:"=%
58
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
-
60
- if exist "%JAVA_EXE%" goto execute
61
-
62
- echo. 1>&2
63
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
- echo. 1>&2
65
- echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
- echo location of your Java installation. 1>&2
67
-
68
- goto fail
69
-
70
- :execute
71
- @rem Setup the command line
72
-
73
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74
-
75
-
76
- @rem Execute Gradle
77
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78
-
79
- :end
80
- @rem End local scope for the variables with windows NT shell
81
- if %ERRORLEVEL% equ 0 goto mainEnd
82
-
83
- :fail
84
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85
- rem the _cmd.exe /c_ return code!
86
- set EXIT_CODE=%ERRORLEVEL%
87
- if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
- if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
- exit /b %EXIT_CODE%
90
-
91
- :mainEnd
92
- if "%OS%"=="Windows_NT" endlocal
93
-
94
- :omega
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
18
+
19
+ @if "%DEBUG%"=="" @echo off
20
+ @rem ##########################################################################
21
+ @rem
22
+ @rem Gradle startup script for Windows
23
+ @rem
24
+ @rem ##########################################################################
25
+
26
+ @rem Set local scope for the variables with windows NT shell
27
+ if "%OS%"=="Windows_NT" setlocal
28
+
29
+ set DIRNAME=%~dp0
30
+ if "%DIRNAME%"=="" set DIRNAME=.
31
+ @rem This is normally unused
32
+ set APP_BASE_NAME=%~n0
33
+ set APP_HOME=%DIRNAME%
34
+
35
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
+
38
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
+
41
+ @rem Find java.exe
42
+ if defined JAVA_HOME goto findJavaFromJavaHome
43
+
44
+ set JAVA_EXE=java.exe
45
+ %JAVA_EXE% -version >NUL 2>&1
46
+ if %ERRORLEVEL% equ 0 goto execute
47
+
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
53
+
54
+ goto fail
55
+
56
+ :findJavaFromJavaHome
57
+ set JAVA_HOME=%JAVA_HOME:"=%
58
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
+
60
+ if exist "%JAVA_EXE%" goto execute
61
+
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
67
+
68
+ goto fail
69
+
70
+ :execute
71
+ @rem Setup the command line
72
+
73
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74
+
75
+
76
+ @rem Execute Gradle
77
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78
+
79
+ :end
80
+ @rem End local scope for the variables with windows NT shell
81
+ if %ERRORLEVEL% equ 0 goto mainEnd
82
+
83
+ :fail
84
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85
+ rem the _cmd.exe /c_ return code!
86
+ set EXIT_CODE=%ERRORLEVEL%
87
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
+ exit /b %EXIT_CODE%
90
+
91
+ :mainEnd
92
+ if "%OS%"=="Windows_NT" endlocal
93
+
94
+ :omega
@@ -11,7 +11,9 @@ async function reactNativeComponentGenerator(host, schema) {
11
11
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
12
12
  createComponentFiles(host, options);
13
13
  addExportsToBarrel(host, options);
14
- await (0, devkit_1.formatFiles)(host);
14
+ if (!options.skipFormat) {
15
+ await (0, devkit_1.formatFiles)(host);
16
+ }
15
17
  }
16
18
  function createComponentFiles(host, options) {
17
19
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files', options.fileExtensionType), options.directory, {
@@ -31,7 +33,9 @@ function addExportsToBarrel(host, options) {
31
33
  const proj = workspace.get(options.projectName);
32
34
  const isApp = (0, ts_solution_setup_1.getProjectType)(host, proj.root, proj.projectType) === 'application';
33
35
  if (options.export && !isApp) {
34
- const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
36
+ const indexFilePath = (0, devkit_1.joinPathFragments)(...(options.projectSourceRoot
37
+ ? [options.projectSourceRoot]
38
+ : [options.projectRoot, 'src']), options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
35
39
  if (!host.exists(indexFilePath)) {
36
40
  return;
37
41
  }
@@ -10,5 +10,6 @@ export interface NormalizedSchema extends Omit<Schema, 'js'> {
10
10
  fileExtension: string;
11
11
  fileExtensionType: FileExtensionType;
12
12
  projectName: string;
13
+ projectRoot: string;
13
14
  }
14
15
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -31,5 +31,6 @@ async function normalizeOptions(host, options) {
31
31
  fileExtensionType,
32
32
  projectSourceRoot,
33
33
  projectName,
34
+ projectRoot: root,
34
35
  };
35
36
  }
@@ -7,6 +7,7 @@ export interface Schema {
7
7
  skipTests?: boolean;
8
8
  export?: boolean;
9
9
  classComponent?: boolean;
10
+ skipFormat?: boolean;
10
11
 
11
12
  /**
12
13
  * @deprecated Provide the full file path including the file extension in the `path` option. This option will be removed in Nx v21.
@@ -59,6 +59,12 @@
59
59
  "alias": "C",
60
60
  "description": "Use class components instead of functional component.",
61
61
  "default": false
62
+ },
63
+ "skipFormat": {
64
+ "description": "Skip formatting files.",
65
+ "type": "boolean",
66
+ "default": false,
67
+ "x-priority": "internal"
62
68
  }
63
69
  },
64
70
  "required": ["path"]
@@ -26,7 +26,7 @@ async function normalizeOptions(host, options) {
26
26
  fileName: projectName,
27
27
  routePath: `/${projectNames.projectSimpleName}`,
28
28
  name: isUsingTsSolutionConfig
29
- ? (0, get_import_path_1.getImportPath)(host, projectName)
29
+ ? options.importPath ?? (0, get_import_path_1.getImportPath)(host, projectName)
30
30
  : projectName,
31
31
  projectRoot,
32
32
  parsedTags,
@@ -7,12 +7,16 @@ const js_1 = require("@nx/js");
7
7
  const init_1 = require("../init/init");
8
8
  const add_linting_1 = require("../../utils/add-linting");
9
9
  const add_jest_1 = require("../../utils/add-jest");
10
- const versions_1 = require("../../utils/versions");
10
+ const component_1 = require("../component/component");
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
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
15
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
16
+ const add_rollup_build_target_1 = require("@nx/react/src/generators/library/lib/add-rollup-build-target");
17
+ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
18
+ const path_1 = require("path");
19
+ const versions_1 = require("../../utils/versions");
16
20
  async function reactNativeLibraryGenerator(host, schema) {
17
21
  return await reactNativeLibraryGeneratorInternal(host, {
18
22
  addPlugin: false,
@@ -50,9 +54,16 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
50
54
  tasks.push(lintTask);
51
55
  const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin, 'tsconfig.lib.json');
52
56
  tasks.push(jestTask);
53
- if (options.publishable || options.buildable) {
54
- updateLibPackageNpmScope(host, options);
55
- }
57
+ const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
58
+ const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
59
+ const componentTask = await (0, component_1.default)(host, {
60
+ path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
61
+ skipTests: options.unitTestRunner === 'none',
62
+ export: true,
63
+ skipFormat: true,
64
+ js: options.js,
65
+ });
66
+ tasks.push(() => componentTask);
56
67
  if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
57
68
  (0, js_1.addTsConfigPath)(host, options.importPath, [
58
69
  (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
@@ -89,7 +100,6 @@ async function addProject(host, options) {
89
100
  tags: options.parsedTags,
90
101
  targets: {},
91
102
  };
92
- const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
93
103
  if (options.isUsingTsSolutionConfig) {
94
104
  (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
95
105
  name: options.name,
@@ -98,52 +108,41 @@ async function addProject(host, options) {
98
108
  nx: {
99
109
  tags: options.parsedTags?.length ? options.parsedTags : undefined,
100
110
  },
111
+ files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
112
+ peerDependencies: {
113
+ react: versions_1.reactVersion,
114
+ 'react-native': versions_1.reactNativeVersion,
115
+ },
101
116
  });
102
117
  }
103
118
  else {
104
119
  (0, devkit_1.addProjectConfiguration)(host, options.name, project);
105
120
  }
106
- if (!options.publishable && !options.buildable) {
107
- return () => { };
121
+ if (options.publishable || options.buildable) {
122
+ const external = new Set([
123
+ 'react/jsx-runtime',
124
+ 'react-native',
125
+ 'react',
126
+ 'react-dom',
127
+ ]);
128
+ const rollupTask = await (0, add_rollup_build_target_1.addRollupBuildTarget)(host, {
129
+ ...options,
130
+ format: ['cjs', 'esm'],
131
+ style: 'none',
132
+ js: options.js,
133
+ skipFormat: true,
134
+ }, external);
135
+ (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
136
+ json.peerDependencies = {
137
+ ...json.peerDependencies,
138
+ react: versions_1.reactVersion,
139
+ 'react-native': versions_1.reactNativeVersion,
140
+ };
141
+ return json;
142
+ });
143
+ return rollupTask;
108
144
  }
109
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
110
- const rollupConfigTask = await configurationGenerator(host, {
111
- ...options,
112
- project: options.name,
113
- skipFormat: true,
114
- });
115
- (0, devkit_1.updateJson)(host, packageJsonPath, (json) => {
116
- if (json.type === 'module') {
117
- // The @nx/rollup:configuration generator can set the type to 'module' which would
118
- // potentially break this library.
119
- delete json.type;
120
- }
121
- return json;
122
- });
123
- const external = ['react/jsx-runtime', 'react-native', 'react', 'react-dom'];
124
- project.targets.build = {
125
- executor: '@nx/rollup:rollup',
126
- outputs: ['{options.outputPath}'],
127
- options: {
128
- outputPath: options.isUsingTsSolutionConfig
129
- ? `${options.projectRoot}/dist`
130
- : `dist/${options.projectRoot}`,
131
- tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
132
- project: `${options.projectRoot}/package.json`,
133
- entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
134
- external,
135
- rollupConfig: `@nx/react/plugins/bundle-rollup`,
136
- assets: [
137
- {
138
- glob: `${options.projectRoot}/README.md`,
139
- input: '.',
140
- output: '.',
141
- },
142
- ],
143
- },
144
- };
145
- (0, devkit_1.updateProjectConfiguration)(host, options.name, project);
146
- return rollupConfigTask;
145
+ return () => { };
147
146
  }
148
147
  function updateTsConfig(tree, options) {
149
148
  if (options.isUsingTsSolutionConfig) {
@@ -169,33 +168,12 @@ function createFiles(host, options) {
169
168
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
170
169
  rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
171
170
  });
172
- if (!options.publishable && !options.buildable) {
173
- host.delete(`${options.projectRoot}/package.json`);
174
- }
175
171
  if (options.js) {
176
172
  (0, devkit_1.toJS)(host);
177
173
  }
178
174
  updateTsConfig(host, options);
179
175
  }
180
- function updateLibPackageNpmScope(host, options) {
181
- return (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
182
- json.name = options.importPath;
183
- json.peerDependencies = {
184
- react: versions_1.reactVersion,
185
- 'react-native': versions_1.reactNativeVersion,
186
- };
187
- return json;
188
- });
189
- }
190
- function maybeJs(options, path) {
191
- return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
192
- ? path.replace(/\.tsx?$/, '.js')
193
- : path;
194
- }
195
176
  function determineEntryFields(options) {
196
- if (options.buildable) {
197
- return {};
198
- }
199
177
  return {
200
178
  main: options.js ? './src/index.js' : './src/index.ts',
201
179
  types: options.js ? './src/index.js' : './src/index.ts',
@@ -1,4 +0,0 @@
1
- {
2
- "name": "<%= name %>",
3
- "version": "0.0.1"
4
- }