@nx/react-native 20.4.0-beta.0 → 20.4.0-beta.2
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/.eslintrc.json +4 -0
- package/package.json +8 -8
- package/plugins/metro-resolver.js +11 -11
- package/src/executors/storybook/storybook.impl.js +3 -3
- package/src/executors/sync-deps/sync-deps.impl.js +4 -4
- package/src/generators/application/application.js +5 -2
- package/src/generators/application/lib/add-project.js +1 -5
- package/src/generators/application/lib/normalize-options.js +6 -2
- package/src/generators/component/component.js +3 -1
- package/src/generators/component/lib/normalize-options.js +4 -2
- package/src/generators/library/lib/normalize-options.js +6 -2
- package/src/generators/library/library.js +5 -7
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +2 -1
- package/src/utils/pod-install-task.js +4 -4
package/.eslintrc.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "20.4.0-beta.
|
|
3
|
+
"version": "20.4.0-beta.2",
|
|
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": [
|
|
@@ -27,21 +27,21 @@
|
|
|
27
27
|
"types": "index.d.ts",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"ajv": "^8.12.0",
|
|
30
|
-
"chalk": "^4.1.0",
|
|
31
30
|
"enhanced-resolve": "^5.8.3",
|
|
32
31
|
"glob": "7.1.4",
|
|
33
32
|
"ignore": "^5.0.4",
|
|
34
33
|
"metro-config": "~0.80.4",
|
|
35
34
|
"metro-resolver": "~0.80.4",
|
|
36
35
|
"node-fetch": "^2.6.7",
|
|
36
|
+
"picocolors": "^1.1.0",
|
|
37
37
|
"tsconfig-paths": "^4.1.2",
|
|
38
38
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/devkit": "20.4.0-beta.
|
|
40
|
-
"@nx/jest": "20.4.0-beta.
|
|
41
|
-
"@nx/js": "20.4.0-beta.
|
|
42
|
-
"@nx/eslint": "20.4.0-beta.
|
|
43
|
-
"@nx/react": "20.4.0-beta.
|
|
44
|
-
"@nx/workspace": "20.4.0-beta.
|
|
39
|
+
"@nx/devkit": "20.4.0-beta.2",
|
|
40
|
+
"@nx/jest": "20.4.0-beta.2",
|
|
41
|
+
"@nx/js": "20.4.0-beta.2",
|
|
42
|
+
"@nx/eslint": "20.4.0-beta.2",
|
|
43
|
+
"@nx/react": "20.4.0-beta.2",
|
|
44
|
+
"@nx/workspace": "20.4.0-beta.2"
|
|
45
45
|
},
|
|
46
46
|
"executors": "./executors.json",
|
|
47
47
|
"ng-update": {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getResolveRequest = getResolveRequest;
|
|
4
4
|
const metroResolver = require("metro-resolver");
|
|
5
5
|
const tsconfig_paths_1 = require("tsconfig-paths");
|
|
6
|
-
const
|
|
6
|
+
const pc = require("picocolors");
|
|
7
7
|
const enhanced_resolve_1 = require("enhanced-resolve");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const fs = require("fs");
|
|
@@ -26,9 +26,9 @@ function getResolveRequest(extensions, exportsConditionNames = [], mainFields =
|
|
|
26
26
|
return resolvedPath;
|
|
27
27
|
}
|
|
28
28
|
if (debug) {
|
|
29
|
-
console.log(
|
|
29
|
+
console.log(pc.red(`[Nx] Unable to resolve with any resolver: ${realModuleName}`));
|
|
30
30
|
}
|
|
31
|
-
throw new Error(`Cannot resolve ${
|
|
31
|
+
throw new Error(`Cannot resolve ${pc.bold(realModuleName)}`);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
function resolveRequestFromContext(resolveRequest, context, realModuleName, platform, debug) {
|
|
@@ -37,7 +37,7 @@ function resolveRequestFromContext(resolveRequest, context, realModuleName, plat
|
|
|
37
37
|
}
|
|
38
38
|
catch {
|
|
39
39
|
if (debug)
|
|
40
|
-
console.log(
|
|
40
|
+
console.log(pc.cyan(`[Nx] Unable to resolve with default resolveRequest: ${realModuleName}`));
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
@@ -50,7 +50,7 @@ function defaultMetroResolver(context, realModuleName, platform, debug) {
|
|
|
50
50
|
}
|
|
51
51
|
catch {
|
|
52
52
|
if (debug)
|
|
53
|
-
console.log(
|
|
53
|
+
console.log(pc.cyan(`[Nx] Unable to resolve with default Metro resolver: ${realModuleName}`));
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -69,7 +69,7 @@ function pnpmResolver(extensions, context, realModuleName, debug, exportsConditi
|
|
|
69
69
|
}
|
|
70
70
|
catch {
|
|
71
71
|
if (debug)
|
|
72
|
-
console.log(
|
|
72
|
+
console.log(pc.cyan(`[Nx] Unable to resolve with default PNPM resolver: ${realModuleName}`));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -84,8 +84,8 @@ function tsconfigPathsResolver(context, extensions, realModuleName, platform, de
|
|
|
84
84
|
}
|
|
85
85
|
catch {
|
|
86
86
|
if (debug) {
|
|
87
|
-
console.log(
|
|
88
|
-
console.log(
|
|
87
|
+
console.log(pc.cyan(`[Nx] Failed to resolve ${pc.bold(realModuleName)}`));
|
|
88
|
+
console.log(pc.cyan(`[Nx] The following tsconfig paths was used:\n:${pc.bold(JSON.stringify(paths, null, 2))}`));
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -99,13 +99,13 @@ function getMatcher(debug) {
|
|
|
99
99
|
absoluteBaseUrl = result.absoluteBaseUrl;
|
|
100
100
|
paths = result.paths;
|
|
101
101
|
if (debug) {
|
|
102
|
-
console.log(
|
|
103
|
-
console.log(
|
|
102
|
+
console.log(pc.cyan(`[Nx] Located tsconfig at ${pc.bold(absoluteBaseUrl)}`));
|
|
103
|
+
console.log(pc.cyan(`[Nx] Found the following paths:\n:${pc.bold(JSON.stringify(paths, null, 2))}`));
|
|
104
104
|
}
|
|
105
105
|
matcher = (0, tsconfig_paths_1.createMatchPath)(absoluteBaseUrl, paths);
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
108
|
-
console.log(
|
|
108
|
+
console.log(pc.cyan(`[Nx] Failed to locate tsconfig}`));
|
|
109
109
|
throw new Error(`Could not load tsconfig for project`);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -6,7 +6,7 @@ const node_fs_1 = require("node:fs");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
|
|
9
|
-
const
|
|
9
|
+
const pc = require("picocolors");
|
|
10
10
|
const glob_1 = require("glob");
|
|
11
11
|
const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
12
12
|
/**
|
|
@@ -16,7 +16,7 @@ const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
|
16
16
|
async function* reactNativeStorybookExecutor(options, context) {
|
|
17
17
|
const { syncDeps: isSyncDepsEnabled = true } = options;
|
|
18
18
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
19
|
-
devkit_1.logger.info(`${
|
|
19
|
+
devkit_1.logger.info(`${pc.bold(pc.cyan('info'))} To see your Storybook stories on the device, you should start your mobile app for the <platform> of your choice (typically ios or android).`);
|
|
20
20
|
// add storybook addons to app's package.json
|
|
21
21
|
const packageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
|
|
22
22
|
const workspacePackageJsonPath = (0, path_1.join)(context.root, 'package.json');
|
|
@@ -44,7 +44,7 @@ function runCliStorybook(workspaceRoot, options) {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
if (storiesFiles.length === 0) {
|
|
47
|
-
devkit_1.logger.warn(`${
|
|
47
|
+
devkit_1.logger.warn(`${pc.bold(pc.yellow('warn'))} No stories found.`);
|
|
48
48
|
}
|
|
49
49
|
const newContents = `// Auto-generated file created by nx
|
|
50
50
|
// DO NOT EDIT.
|
|
@@ -4,7 +4,7 @@ exports.default = syncDepsExecutor;
|
|
|
4
4
|
exports.syncDeps = syncDeps;
|
|
5
5
|
exports.displayNewlyAddedDepsMessage = displayNewlyAddedDepsMessage;
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const
|
|
7
|
+
const pc = require("picocolors");
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
9
|
const find_all_npm_dependencies_1 = require("../../utils/find-all-npm-dependencies");
|
|
10
10
|
async function* syncDepsExecutor(options, context) {
|
|
@@ -68,10 +68,10 @@ async function syncDeps(projectName, projectPackageJson, projectPackageJsonPath,
|
|
|
68
68
|
}
|
|
69
69
|
function displayNewlyAddedDepsMessage(projectName, deps) {
|
|
70
70
|
if (deps.length > 0) {
|
|
71
|
-
devkit_1.logger.info(`${
|
|
72
|
-
${deps.map((d) =>
|
|
71
|
+
devkit_1.logger.info(`${pc.bold(pc.cyan('info'))} Added entries to 'package.json' for '${projectName}' (for autolink):
|
|
72
|
+
${deps.map((d) => pc.bold(pc.cyan(`"${d}": "*"`))).join('\n ')}`);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
|
-
devkit_1.logger.info(`${
|
|
75
|
+
devkit_1.logger.info(`${pc.bold(pc.cyan('info'))} Dependencies for '${projectName}' are up to date! No changes made.`);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -18,6 +18,7 @@ const add_e2e_1 = require("./lib/add-e2e");
|
|
|
18
18
|
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
19
19
|
const sync_deps_impl_1 = require("../../executors/sync-deps/sync-deps.impl");
|
|
20
20
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
21
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
21
22
|
async function reactNativeApplicationGenerator(host, schema) {
|
|
22
23
|
return await reactNativeApplicationGeneratorInternal(host, {
|
|
23
24
|
addPlugin: false,
|
|
@@ -31,6 +32,7 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
31
32
|
skipFormat: true,
|
|
32
33
|
addTsPlugin: schema.useTsSolution,
|
|
33
34
|
formatter: schema.formatter,
|
|
35
|
+
platform: 'web',
|
|
34
36
|
});
|
|
35
37
|
tasks.push(jsInitTask);
|
|
36
38
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
@@ -49,11 +51,11 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
49
51
|
],
|
|
50
52
|
});
|
|
51
53
|
tasks.push(lintTask);
|
|
52
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin);
|
|
54
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin, 'tsconfig.app.json');
|
|
53
55
|
tasks.push(jestTask);
|
|
54
56
|
const webTask = await (0, web_configuration_1.webConfigurationGenerator)(host, {
|
|
55
57
|
...options,
|
|
56
|
-
project: options.
|
|
58
|
+
project: options.projectName,
|
|
57
59
|
skipFormat: true,
|
|
58
60
|
});
|
|
59
61
|
tasks.push(webTask);
|
|
@@ -91,6 +93,7 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
91
93
|
if (options.useTsSolution) {
|
|
92
94
|
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
|
|
93
95
|
}
|
|
96
|
+
(0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
|
|
94
97
|
if (!options.skipFormat) {
|
|
95
98
|
await (0, devkit_1.formatFiles)(host);
|
|
96
99
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addProject = addProject;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
|
-
const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
|
|
7
6
|
function addProject(host, options) {
|
|
8
7
|
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
9
8
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
@@ -18,13 +17,10 @@ function addProject(host, options) {
|
|
|
18
17
|
};
|
|
19
18
|
if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
|
|
20
19
|
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
|
|
21
|
-
name:
|
|
20
|
+
name: options.projectName,
|
|
22
21
|
version: '0.0.1',
|
|
23
22
|
private: true,
|
|
24
23
|
nx: {
|
|
25
|
-
name: options.name,
|
|
26
|
-
projectType: 'application',
|
|
27
|
-
sourceRoot: `${options.appProjectRoot}/src`,
|
|
28
24
|
targets: hasPlugin ? {} : getTargets(options),
|
|
29
25
|
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
30
26
|
},
|
|
@@ -4,6 +4,7 @@ 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
9
|
await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
|
|
9
10
|
const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
@@ -25,6 +26,7 @@ async function normalizeOptions(host, options) {
|
|
|
25
26
|
? options.tags.split(',').map((s) => s.trim())
|
|
26
27
|
: [];
|
|
27
28
|
const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
|
|
29
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
28
30
|
return {
|
|
29
31
|
...options,
|
|
30
32
|
name: projectNames.projectSimpleName,
|
|
@@ -32,7 +34,9 @@ async function normalizeOptions(host, options) {
|
|
|
32
34
|
fileName,
|
|
33
35
|
lowerCaseName: className.toLowerCase(),
|
|
34
36
|
displayName: options.displayName || className,
|
|
35
|
-
projectName:
|
|
37
|
+
projectName: isTsSolutionSetup
|
|
38
|
+
? (0, get_import_path_1.getImportPath)(host, appProjectName)
|
|
39
|
+
: appProjectName,
|
|
36
40
|
appProjectRoot,
|
|
37
41
|
iosProjectRoot,
|
|
38
42
|
androidProjectRoot,
|
|
@@ -41,6 +45,6 @@ async function normalizeOptions(host, options) {
|
|
|
41
45
|
rootProject,
|
|
42
46
|
e2eProjectName,
|
|
43
47
|
e2eProjectRoot,
|
|
44
|
-
isTsSolutionSetup
|
|
48
|
+
isTsSolutionSetup,
|
|
45
49
|
};
|
|
46
50
|
}
|
|
@@ -6,6 +6,7 @@ const normalize_options_1 = require("./lib/normalize-options");
|
|
|
6
6
|
const add_import_1 = require("./lib/add-import");
|
|
7
7
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
9
10
|
async function reactNativeComponentGenerator(host, schema) {
|
|
10
11
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
11
12
|
createComponentFiles(host, options);
|
|
@@ -27,7 +28,8 @@ function addExportsToBarrel(host, options) {
|
|
|
27
28
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
28
29
|
}
|
|
29
30
|
const workspace = (0, devkit_1.getProjects)(host);
|
|
30
|
-
const
|
|
31
|
+
const proj = workspace.get(options.projectName);
|
|
32
|
+
const isApp = (0, ts_solution_setup_1.getProjectType)(host, proj.root, proj.projectType) === 'application';
|
|
31
33
|
if (options.export && !isApp) {
|
|
32
34
|
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
|
|
33
35
|
if (!host.exists(indexFilePath)) {
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
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
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
6
7
|
async function normalizeOptions(host, options) {
|
|
7
8
|
const { artifactName: name, directory, fileName, filePath, fileExtension, fileExtensionType, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
8
9
|
path: options.path,
|
|
@@ -13,8 +14,9 @@ async function normalizeOptions(host, options) {
|
|
|
13
14
|
});
|
|
14
15
|
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
15
16
|
const { className } = (0, devkit_1.names)(name);
|
|
16
|
-
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
17
|
-
if (options.export &&
|
|
17
|
+
const { root, sourceRoot: projectSourceRoot, projectType } = project;
|
|
18
|
+
if (options.export &&
|
|
19
|
+
(0, ts_solution_setup_1.getProjectType)(host, root, projectType) === 'application') {
|
|
18
20
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
|
19
21
|
}
|
|
20
22
|
options.classComponent = options.classComponent ?? false;
|
|
@@ -4,6 +4,7 @@ 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
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, {
|
|
@@ -19,15 +20,18 @@ async function normalizeOptions(host, options) {
|
|
|
19
20
|
const parsedTags = options.tags
|
|
20
21
|
? options.tags.split(',').map((s) => s.trim())
|
|
21
22
|
: [];
|
|
23
|
+
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
|
|
22
24
|
const normalized = {
|
|
23
25
|
...options,
|
|
24
26
|
fileName: projectName,
|
|
25
27
|
routePath: `/${projectNames.projectSimpleName}`,
|
|
26
|
-
name:
|
|
28
|
+
name: isUsingTsSolutionConfig
|
|
29
|
+
? (0, get_import_path_1.getImportPath)(host, projectName)
|
|
30
|
+
: projectName,
|
|
27
31
|
projectRoot,
|
|
28
32
|
parsedTags,
|
|
29
33
|
importPath,
|
|
30
|
-
isUsingTsSolutionConfig
|
|
34
|
+
isUsingTsSolutionConfig,
|
|
31
35
|
};
|
|
32
36
|
return normalized;
|
|
33
37
|
}
|
|
@@ -12,7 +12,7 @@ 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
|
-
const
|
|
15
|
+
const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
|
|
16
16
|
async function reactNativeLibraryGenerator(host, schema) {
|
|
17
17
|
return await reactNativeLibraryGeneratorInternal(host, {
|
|
18
18
|
addPlugin: false,
|
|
@@ -48,7 +48,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
48
48
|
],
|
|
49
49
|
});
|
|
50
50
|
tasks.push(lintTask);
|
|
51
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
|
|
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');
|
|
52
52
|
tasks.push(jestTask);
|
|
53
53
|
if (options.publishable || options.buildable) {
|
|
54
54
|
updateLibPackageNpmScope(host, options);
|
|
@@ -68,6 +68,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
68
68
|
if (options.isUsingTsSolutionConfig) {
|
|
69
69
|
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
70
70
|
}
|
|
71
|
+
(0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
|
|
71
72
|
if (!options.skipFormat) {
|
|
72
73
|
await (0, devkit_1.formatFiles)(host);
|
|
73
74
|
}
|
|
@@ -90,14 +91,11 @@ async function addProject(host, options) {
|
|
|
90
91
|
};
|
|
91
92
|
const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
|
|
92
93
|
if (options.isUsingTsSolutionConfig) {
|
|
93
|
-
(0, devkit_1.writeJson)(host,
|
|
94
|
-
name:
|
|
94
|
+
(0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
|
|
95
|
+
name: options.name,
|
|
95
96
|
version: '0.0.1',
|
|
96
97
|
...determineEntryFields(options),
|
|
97
98
|
nx: {
|
|
98
|
-
name: options.name,
|
|
99
|
-
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
100
|
-
projectType: 'library',
|
|
101
99
|
tags: options.parsedTags?.length ? options.parsedTags : undefined,
|
|
102
100
|
},
|
|
103
101
|
});
|
package/src/utils/add-jest.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
2
|
+
export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean, runtimeTsconfigFileName: string): Promise<import("@nx/devkit").GeneratorCallback>;
|
package/src/utils/add-jest.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addJest = addJest;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const jest_1 = require("@nx/jest");
|
|
6
|
-
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin) {
|
|
6
|
+
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin, runtimeTsconfigFileName) {
|
|
7
7
|
if (unitTestRunner !== 'jest') {
|
|
8
8
|
return () => { };
|
|
9
9
|
}
|
|
@@ -17,6 +17,7 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
|
|
|
17
17
|
skipPackageJson,
|
|
18
18
|
skipFormat: true,
|
|
19
19
|
addPlugin,
|
|
20
|
+
runtimeTsconfigFileName,
|
|
20
21
|
});
|
|
21
22
|
// overwrite the jest.config.ts file because react native needs to have special transform property
|
|
22
23
|
const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
|
|
@@ -6,17 +6,17 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const os_1 = require("os");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
const
|
|
9
|
+
const pc = require("picocolors");
|
|
10
10
|
const devkit_1 = require("@nx/devkit");
|
|
11
11
|
const podInstallErrorMessage = `
|
|
12
|
-
Running ${
|
|
12
|
+
Running ${pc.bold('pod install')} failed, see above.
|
|
13
13
|
Do you have CocoaPods (https://cocoapods.org/) installed?
|
|
14
14
|
|
|
15
15
|
Check that your XCode path is correct:
|
|
16
|
-
${
|
|
16
|
+
${pc.bold('sudo xcode-select --print-path')}
|
|
17
17
|
|
|
18
18
|
If the path is wrong, switch the path: (your path may be different)
|
|
19
|
-
${
|
|
19
|
+
${pc.bold('sudo xcode-select --switch /Applications/Xcode.app')}
|
|
20
20
|
`;
|
|
21
21
|
/**
|
|
22
22
|
* Run pod install on ios directory
|