@nx/react-native 0.0.0-pr-29464-ef5660f → 0.0.0-pr-29720-06f67e5
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 +7 -7
- package/src/generators/application/application.js +5 -6
- package/src/generators/application/files/app/android/gradlew.bat +94 -94
- package/src/generators/application/lib/add-e2e.js +0 -2
- package/src/generators/application/lib/add-project.js +11 -20
- package/src/generators/application/lib/normalize-options.d.ts +1 -2
- package/src/generators/application/lib/normalize-options.js +8 -8
- package/src/generators/application/schema.d.ts +0 -1
- package/src/generators/application/schema.json +0 -4
- package/src/generators/component/component.js +2 -6
- package/src/generators/component/lib/normalize-options.d.ts +0 -1
- package/src/generators/component/lib/normalize-options.js +0 -1
- package/src/generators/component/schema.d.ts +0 -1
- package/src/generators/component/schema.json +0 -6
- package/src/generators/library/files/lib/package.json.template +4 -0
- package/src/generators/library/lib/normalize-options.d.ts +0 -1
- package/src/generators/library/lib/normalize-options.js +5 -3
- package/src/generators/library/library.js +76 -68
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29720-06f67e5",
|
|
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-
|
|
39
|
-
"@nx/jest": "0.0.0-pr-
|
|
40
|
-
"@nx/js": "0.0.0-pr-
|
|
41
|
-
"@nx/eslint": "0.0.0-pr-
|
|
42
|
-
"@nx/react": "0.0.0-pr-
|
|
43
|
-
"@nx/workspace": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-29720-06f67e5",
|
|
39
|
+
"@nx/jest": "0.0.0-pr-29720-06f67e5",
|
|
40
|
+
"@nx/js": "0.0.0-pr-29720-06f67e5",
|
|
41
|
+
"@nx/eslint": "0.0.0-pr-29720-06f67e5",
|
|
42
|
+
"@nx/react": "0.0.0-pr-29720-06f67e5",
|
|
43
|
+
"@nx/workspace": "0.0.0-pr-29720-06f67e5"
|
|
44
44
|
},
|
|
45
45
|
"executors": "./executors.json",
|
|
46
46
|
"ng-update": {
|
|
@@ -22,7 +22,6 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
|
22
22
|
async function reactNativeApplicationGenerator(host, schema) {
|
|
23
23
|
return await reactNativeApplicationGeneratorInternal(host, {
|
|
24
24
|
addPlugin: false,
|
|
25
|
-
useProjectJson: true,
|
|
26
25
|
...schema,
|
|
27
26
|
});
|
|
28
27
|
}
|
|
@@ -44,11 +43,6 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
44
43
|
}
|
|
45
44
|
await (0, create_application_files_1.createApplicationFiles)(host, options);
|
|
46
45
|
(0, add_project_1.addProject)(host, options);
|
|
47
|
-
// If we are using the new TS solution
|
|
48
|
-
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
49
|
-
if (options.isTsSolutionSetup) {
|
|
50
|
-
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
51
|
-
}
|
|
52
46
|
const lintTask = await (0, add_linting_1.addLinting)(host, {
|
|
53
47
|
...options,
|
|
54
48
|
projectRoot: options.appProjectRoot,
|
|
@@ -94,6 +88,11 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
94
88
|
}, options.linter === 'eslint'
|
|
95
89
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
96
90
|
: undefined);
|
|
91
|
+
// If we are using the new TS solution
|
|
92
|
+
// We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
|
|
93
|
+
if (options.useTsSolution) {
|
|
94
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
95
|
+
}
|
|
97
96
|
(0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
98
97
|
if (!options.skipFormat) {
|
|
99
98
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -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
|
|
@@ -14,7 +14,6 @@ async function addE2e(host, options) {
|
|
|
14
14
|
styledModule: null,
|
|
15
15
|
hasStyles: false,
|
|
16
16
|
unitTestRunner: 'none',
|
|
17
|
-
names: (0, devkit_1.names)(options.name),
|
|
18
17
|
});
|
|
19
18
|
case 'playwright':
|
|
20
19
|
return (0, add_e2e_1.addE2e)(host, {
|
|
@@ -24,7 +23,6 @@ async function addE2e(host, options) {
|
|
|
24
23
|
styledModule: null,
|
|
25
24
|
hasStyles: false,
|
|
26
25
|
unitTestRunner: 'none',
|
|
27
|
-
names: (0, devkit_1.names)(options.name),
|
|
28
26
|
});
|
|
29
27
|
case 'detox':
|
|
30
28
|
const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addProject = addProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
5
6
|
function addProject(host, options) {
|
|
6
7
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
7
8
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
@@ -14,32 +15,22 @@ function addProject(host, options) {
|
|
|
14
15
|
targets: hasPlugin ? {} : getTargets(options),
|
|
15
16
|
tags: options.parsedTags,
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
packageJson.nx ??= {};
|
|
28
|
-
packageJson.nx.targets = getTargets(options);
|
|
29
|
-
}
|
|
30
|
-
if (options.parsedTags?.length) {
|
|
31
|
-
packageJson.nx ??= {};
|
|
32
|
-
packageJson.nx.tags = options.parsedTags;
|
|
33
|
-
}
|
|
18
|
+
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
|
|
19
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
20
|
+
name: options.projectName,
|
|
21
|
+
version: '0.0.1',
|
|
22
|
+
private: true,
|
|
23
|
+
nx: {
|
|
24
|
+
targets: hasPlugin ? {} : getTargets(options),
|
|
25
|
+
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
34
28
|
}
|
|
35
29
|
else {
|
|
36
30
|
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
37
31
|
...project,
|
|
38
32
|
});
|
|
39
33
|
}
|
|
40
|
-
if (!options.useProjectJson || options.isTsSolutionSetup) {
|
|
41
|
-
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
|
|
42
|
-
}
|
|
43
34
|
}
|
|
44
35
|
function getTargets(options) {
|
|
45
36
|
const architect = {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from '../schema';
|
|
3
|
-
export interface NormalizedSchema extends
|
|
3
|
+
export interface NormalizedSchema extends Schema {
|
|
4
4
|
className: string;
|
|
5
5
|
fileName: string;
|
|
6
6
|
projectName: string;
|
|
@@ -13,7 +13,6 @@ export interface NormalizedSchema extends Omit<Schema, 'useTsSolution'> {
|
|
|
13
13
|
rootProject: boolean;
|
|
14
14
|
e2eProjectName: string;
|
|
15
15
|
e2eProjectRoot: string;
|
|
16
|
-
importPath: string;
|
|
17
16
|
isTsSolutionSetup: boolean;
|
|
18
17
|
}
|
|
19
18
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -4,9 +4,10 @@ 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
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
|
+
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
7
8
|
async function normalizeOptions(host, options) {
|
|
8
|
-
await (0, project_name_and_root_utils_1.
|
|
9
|
-
const { projectName, names: projectNames, projectRoot: appProjectRoot,
|
|
9
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
10
|
+
const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
10
11
|
name: options.name,
|
|
11
12
|
projectType: 'application',
|
|
12
13
|
directory: options.directory,
|
|
@@ -15,18 +16,17 @@ async function normalizeOptions(host, options) {
|
|
|
15
16
|
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
16
17
|
nxJson.useInferencePlugins !== false;
|
|
17
18
|
options.addPlugin ??= addPluginDefault;
|
|
18
|
-
const { className, fileName } = (0, devkit_1.names)(
|
|
19
|
+
const { className, fileName } = (0, devkit_1.names)(options.name);
|
|
19
20
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
|
|
20
21
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
|
|
21
22
|
const rootProject = appProjectRoot === '.';
|
|
22
|
-
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
23
|
-
const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath;
|
|
24
23
|
const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
25
24
|
const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
26
25
|
const parsedTags = options.tags
|
|
27
26
|
? options.tags.split(',').map((s) => s.trim())
|
|
28
27
|
: [];
|
|
29
28
|
const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
|
|
29
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
30
30
|
return {
|
|
31
31
|
...options,
|
|
32
32
|
name: projectNames.projectSimpleName,
|
|
@@ -34,9 +34,10 @@ async function normalizeOptions(host, options) {
|
|
|
34
34
|
fileName,
|
|
35
35
|
lowerCaseName: className.toLowerCase(),
|
|
36
36
|
displayName: options.displayName || className,
|
|
37
|
-
projectName:
|
|
37
|
+
projectName: isTsSolutionSetup
|
|
38
|
+
? (0, get_import_path_1.getImportPath)(host, appProjectName)
|
|
39
|
+
: appProjectName,
|
|
38
40
|
appProjectRoot,
|
|
39
|
-
importPath,
|
|
40
41
|
iosProjectRoot,
|
|
41
42
|
androidProjectRoot,
|
|
42
43
|
parsedTags,
|
|
@@ -45,6 +46,5 @@ async function normalizeOptions(host, options) {
|
|
|
45
46
|
e2eProjectName,
|
|
46
47
|
e2eProjectRoot,
|
|
47
48
|
isTsSolutionSetup,
|
|
48
|
-
useProjectJson: options.useProjectJson ?? !isTsSolutionSetup,
|
|
49
49
|
};
|
|
50
50
|
}
|
|
@@ -95,10 +95,6 @@
|
|
|
95
95
|
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
96
96
|
"default": "vite",
|
|
97
97
|
"x-priority": "important"
|
|
98
|
-
},
|
|
99
|
-
"useProjectJson": {
|
|
100
|
-
"type": "boolean",
|
|
101
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
102
98
|
}
|
|
103
99
|
},
|
|
104
100
|
"required": ["directory"]
|
|
@@ -11,9 +11,7 @@ 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
|
-
|
|
15
|
-
await (0, devkit_1.formatFiles)(host);
|
|
16
|
-
}
|
|
14
|
+
await (0, devkit_1.formatFiles)(host);
|
|
17
15
|
}
|
|
18
16
|
function createComponentFiles(host, options) {
|
|
19
17
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files', options.fileExtensionType), options.directory, {
|
|
@@ -33,9 +31,7 @@ function addExportsToBarrel(host, options) {
|
|
|
33
31
|
const proj = workspace.get(options.projectName);
|
|
34
32
|
const isApp = (0, ts_solution_setup_1.getProjectType)(host, proj.root, proj.projectType) === 'application';
|
|
35
33
|
if (options.export && !isApp) {
|
|
36
|
-
const indexFilePath = (0, devkit_1.joinPathFragments)(
|
|
37
|
-
? [options.projectSourceRoot]
|
|
38
|
-
: [options.projectRoot, 'src']), options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
|
|
34
|
+
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
|
|
39
35
|
if (!host.exists(indexFilePath)) {
|
|
40
36
|
return;
|
|
41
37
|
}
|
|
@@ -10,6 +10,5 @@ export interface NormalizedSchema extends Omit<Schema, 'js'> {
|
|
|
10
10
|
fileExtension: string;
|
|
11
11
|
fileExtensionType: FileExtensionType;
|
|
12
12
|
projectName: string;
|
|
13
|
-
projectRoot: string;
|
|
14
13
|
}
|
|
15
14
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -59,12 +59,6 @@
|
|
|
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"
|
|
68
62
|
}
|
|
69
63
|
},
|
|
70
64
|
"required": ["path"]
|
|
@@ -4,8 +4,9 @@ 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
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
7
|
+
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
7
8
|
async function normalizeOptions(host, options) {
|
|
8
|
-
await (0, project_name_and_root_utils_1.
|
|
9
|
+
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
|
|
9
10
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
10
11
|
name: options.name,
|
|
11
12
|
projectType: 'library',
|
|
@@ -24,12 +25,13 @@ async function normalizeOptions(host, options) {
|
|
|
24
25
|
...options,
|
|
25
26
|
fileName: projectName,
|
|
26
27
|
routePath: `/${projectNames.projectSimpleName}`,
|
|
27
|
-
name: isUsingTsSolutionConfig
|
|
28
|
+
name: isUsingTsSolutionConfig
|
|
29
|
+
? (0, get_import_path_1.getImportPath)(host, projectName)
|
|
30
|
+
: projectName,
|
|
28
31
|
projectRoot,
|
|
29
32
|
parsedTags,
|
|
30
33
|
importPath,
|
|
31
34
|
isUsingTsSolutionConfig,
|
|
32
|
-
useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
|
|
33
35
|
};
|
|
34
36
|
return normalized;
|
|
35
37
|
}
|
|
@@ -7,20 +7,15 @@ 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
|
|
10
|
+
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
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");
|
|
20
16
|
async function reactNativeLibraryGenerator(host, schema) {
|
|
21
17
|
return await reactNativeLibraryGeneratorInternal(host, {
|
|
22
18
|
addPlugin: false,
|
|
23
|
-
useProjectJson: true,
|
|
24
19
|
...schema,
|
|
25
20
|
});
|
|
26
21
|
}
|
|
@@ -45,9 +40,6 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
45
40
|
if (addProjectTask) {
|
|
46
41
|
tasks.push(addProjectTask);
|
|
47
42
|
}
|
|
48
|
-
if (options.isUsingTsSolutionConfig) {
|
|
49
|
-
await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
50
|
-
}
|
|
51
43
|
const lintTask = await (0, add_linting_1.addLinting)(host, {
|
|
52
44
|
...options,
|
|
53
45
|
projectName: options.name,
|
|
@@ -58,16 +50,9 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
58
50
|
tasks.push(lintTask);
|
|
59
51
|
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin, 'tsconfig.lib.json');
|
|
60
52
|
tasks.push(jestTask);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
|
|
65
|
-
skipTests: options.unitTestRunner === 'none',
|
|
66
|
-
export: true,
|
|
67
|
-
skipFormat: true,
|
|
68
|
-
js: options.js,
|
|
69
|
-
});
|
|
70
|
-
tasks.push(() => componentTask);
|
|
53
|
+
if (options.publishable || options.buildable) {
|
|
54
|
+
updateLibPackageNpmScope(host, options);
|
|
55
|
+
}
|
|
71
56
|
if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
|
|
72
57
|
(0, js_1.addTsConfigPath)(host, options.importPath, [
|
|
73
58
|
(0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
|
|
@@ -80,6 +65,9 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
80
65
|
}, options.linter === 'eslint'
|
|
81
66
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
82
67
|
: undefined);
|
|
68
|
+
if (options.isUsingTsSolutionConfig) {
|
|
69
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
70
|
+
}
|
|
83
71
|
(0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
|
|
84
72
|
if (!options.skipFormat) {
|
|
85
73
|
await (0, devkit_1.formatFiles)(host);
|
|
@@ -101,62 +89,61 @@ async function addProject(host, options) {
|
|
|
101
89
|
tags: options.parsedTags,
|
|
102
90
|
targets: {},
|
|
103
91
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
packageJson = {
|
|
110
|
-
...packageJson,
|
|
92
|
+
const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
|
|
93
|
+
if (options.isUsingTsSolutionConfig) {
|
|
94
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
|
|
95
|
+
name: options.name,
|
|
96
|
+
version: '0.0.1',
|
|
111
97
|
...determineEntryFields(options),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
react: versions_1.reactVersion,
|
|
115
|
-
'react-native': versions_1.reactNativeVersion,
|
|
98
|
+
nx: {
|
|
99
|
+
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
116
100
|
},
|
|
117
|
-
};
|
|
118
|
-
if (options.name !== options.importPath) {
|
|
119
|
-
packageJson.nx = { name: options.name };
|
|
120
|
-
}
|
|
121
|
-
if (options.parsedTags?.length) {
|
|
122
|
-
packageJson.nx ??= {};
|
|
123
|
-
packageJson.nx.tags = options.parsedTags;
|
|
124
|
-
}
|
|
101
|
+
});
|
|
125
102
|
}
|
|
126
103
|
else {
|
|
127
104
|
(0, devkit_1.addProjectConfiguration)(host, options.name, project);
|
|
128
105
|
}
|
|
129
|
-
if (!options.
|
|
130
|
-
|
|
131
|
-
options.publishable ||
|
|
132
|
-
options.buildable) {
|
|
133
|
-
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), packageJson);
|
|
106
|
+
if (!options.publishable && !options.buildable) {
|
|
107
|
+
return () => { };
|
|
134
108
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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;
|
|
160
147
|
}
|
|
161
148
|
function updateTsConfig(tree, options) {
|
|
162
149
|
if (options.isUsingTsSolutionConfig) {
|
|
@@ -182,12 +169,33 @@ function createFiles(host, options) {
|
|
|
182
169
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
183
170
|
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
|
|
184
171
|
});
|
|
172
|
+
if (!options.publishable && !options.buildable) {
|
|
173
|
+
host.delete(`${options.projectRoot}/package.json`);
|
|
174
|
+
}
|
|
185
175
|
if (options.js) {
|
|
186
176
|
(0, devkit_1.toJS)(host);
|
|
187
177
|
}
|
|
188
178
|
updateTsConfig(host, options);
|
|
189
179
|
}
|
|
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
|
+
}
|
|
190
195
|
function determineEntryFields(options) {
|
|
196
|
+
if (options.buildable) {
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
191
199
|
return {
|
|
192
200
|
main: options.js ? './src/index.js' : './src/index.ts',
|
|
193
201
|
types: options.js ? './src/index.js' : './src/index.ts',
|
|
@@ -93,10 +93,6 @@
|
|
|
93
93
|
"type": "boolean",
|
|
94
94
|
"default": false,
|
|
95
95
|
"x-priority": "internal"
|
|
96
|
-
},
|
|
97
|
-
"useProjectJson": {
|
|
98
|
-
"type": "boolean",
|
|
99
|
-
"description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
|
|
100
96
|
}
|
|
101
97
|
},
|
|
102
98
|
"required": ["directory"]
|