@nx/react-native 18.1.0-beta.0 → 18.1.0-beta.10
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 +2 -1
- package/package.json +9 -8
- package/plugin.d.ts +1 -1
- package/plugin.js +2 -1
- package/src/executors/build-android/build-android.impl.js +1 -1
- package/src/executors/build-android/build-android.impl.ts +1 -1
- package/src/executors/run-android/run-android.impl.js +1 -1
- package/src/executors/run-android/run-android.impl.ts +1 -1
- package/src/executors/storybook/storybook.impl.js +1 -1
- package/src/executors/storybook/storybook.impl.ts +2 -0
- package/src/executors/sync-deps/schema.d.ts +1 -0
- package/src/executors/sync-deps/schema.json +5 -0
- package/src/executors/sync-deps/sync-deps.impl.d.ts +2 -2
- package/src/executors/sync-deps/sync-deps.impl.js +10 -5
- package/src/executors/sync-deps/sync-deps.impl.ts +17 -4
- package/src/generators/application/application.js +2 -3
- package/src/generators/application/files/app/src/app/App.tsx.template +1 -1
- package/src/generators/application/lib/normalize-options.js +4 -1
- package/src/generators/init/init.js +4 -1
- package/src/generators/library/lib/normalize-options.js +5 -1
- package/src/generators/storybook-configuration/configuration.js +4 -1
- package/src/utils/chmod-android-gradle-files.js +6 -2
- package/src/utils/find-all-npm-dependencies.d.ts +2 -0
- package/src/utils/find-all-npm-dependencies.js +27 -0
- package/src/utils/find-all-npm-dependencies.spec.ts +103 -0
package/.eslintrc.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "18.1.0-beta.
|
|
3
|
+
"version": "18.1.0-beta.10",
|
|
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": [
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"main": "./index.js",
|
|
26
26
|
"types": "index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"ajv": "^8.12.0",
|
|
28
29
|
"chalk": "^4.1.0",
|
|
29
30
|
"enhanced-resolve": "^5.8.3",
|
|
30
31
|
"fs-extra": "^11.1.0",
|
|
@@ -35,13 +36,13 @@
|
|
|
35
36
|
"node-fetch": "^2.6.7",
|
|
36
37
|
"tsconfig-paths": "^4.1.2",
|
|
37
38
|
"tslib": "^2.3.0",
|
|
38
|
-
"@nx/devkit": "18.1.0-beta.
|
|
39
|
-
"@nx/jest": "18.1.0-beta.
|
|
40
|
-
"@nx/js": "18.1.0-beta.
|
|
41
|
-
"@nx/eslint": "18.1.0-beta.
|
|
42
|
-
"@nx/react": "18.1.0-beta.
|
|
43
|
-
"@nx/workspace": "18.1.0-beta.
|
|
44
|
-
"@nrwl/react-native": "18.1.0-beta.
|
|
39
|
+
"@nx/devkit": "18.1.0-beta.10",
|
|
40
|
+
"@nx/jest": "18.1.0-beta.10",
|
|
41
|
+
"@nx/js": "18.1.0-beta.10",
|
|
42
|
+
"@nx/eslint": "18.1.0-beta.10",
|
|
43
|
+
"@nx/react": "18.1.0-beta.10",
|
|
44
|
+
"@nx/workspace": "18.1.0-beta.10",
|
|
45
|
+
"@nrwl/react-native": "18.1.0-beta.10"
|
|
45
46
|
},
|
|
46
47
|
"executors": "./executors.json",
|
|
47
48
|
"ng-update": {
|
package/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createNodes, ReactNativePluginOptions } from './plugins/plugin';
|
|
1
|
+
export { createNodes, createDependencies, ReactNativePluginOptions, } from './plugins/plugin';
|
package/plugin.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = void 0;
|
|
3
|
+
exports.createDependencies = exports.createNodes = void 0;
|
|
4
4
|
var plugin_1 = require("./plugins/plugin");
|
|
5
5
|
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
+
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
|
|
@@ -6,7 +6,7 @@ const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-f
|
|
|
6
6
|
const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
7
7
|
async function* buildAndroidExecutor(options, context) {
|
|
8
8
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
9
|
-
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
|
|
9
|
+
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(context.root, projectRoot, 'android'));
|
|
10
10
|
await runCliBuild(context.root, projectRoot, options);
|
|
11
11
|
yield { success: true };
|
|
12
12
|
}
|
|
@@ -15,7 +15,7 @@ export default async function* buildAndroidExecutor(
|
|
|
15
15
|
): AsyncGenerator<ReactNativeBuildOutput> {
|
|
16
16
|
const projectRoot =
|
|
17
17
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
18
|
-
chmodAndroidGradlewFiles(join(projectRoot, 'android'));
|
|
18
|
+
chmodAndroidGradlewFiles(join(context.root, projectRoot, 'android'));
|
|
19
19
|
|
|
20
20
|
await runCliBuild(context.root, projectRoot, options);
|
|
21
21
|
yield { success: true };
|
|
@@ -8,7 +8,7 @@ const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
|
8
8
|
let childProcess;
|
|
9
9
|
async function* runAndroidExecutor(options, context) {
|
|
10
10
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
11
|
-
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
|
|
11
|
+
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(context.root, projectRoot, 'android'));
|
|
12
12
|
const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
|
|
13
13
|
if (options.mode !== 'Release') {
|
|
14
14
|
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
@@ -19,7 +19,7 @@ export default async function* runAndroidExecutor(
|
|
|
19
19
|
): AsyncGenerator<ReactNativeRunAndroidOutput> {
|
|
20
20
|
const projectRoot =
|
|
21
21
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
22
|
-
chmodAndroidGradlewFiles(join(projectRoot, 'android'));
|
|
22
|
+
chmodAndroidGradlewFiles(join(context.root, projectRoot, 'android'));
|
|
23
23
|
|
|
24
24
|
const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
|
|
25
25
|
|
|
@@ -21,7 +21,7 @@ async function* reactNativeStorybookExecutor(options, context) {
|
|
|
21
21
|
const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
|
|
22
22
|
const projectPackageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
23
23
|
if ((0, fileutils_1.fileExists)(packageJsonPath))
|
|
24
|
-
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(projectPackageJson, packageJsonPath, workspacePackageJson, [
|
|
24
|
+
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(context.projectName, projectPackageJson, packageJsonPath, workspacePackageJson, context.projectGraph, [
|
|
25
25
|
`@storybook/react-native`,
|
|
26
26
|
'@storybook/addon-ondevice-actions',
|
|
27
27
|
'@storybook/addon-ondevice-backgrounds',
|
|
@@ -41,9 +41,11 @@ export default async function* reactNativeStorybookExecutor(
|
|
|
41
41
|
displayNewlyAddedDepsMessage(
|
|
42
42
|
context.projectName,
|
|
43
43
|
await syncDeps(
|
|
44
|
+
context.projectName,
|
|
44
45
|
projectPackageJson,
|
|
45
46
|
packageJsonPath,
|
|
46
47
|
workspacePackageJson,
|
|
48
|
+
context.projectGraph,
|
|
47
49
|
[
|
|
48
50
|
`@storybook/react-native`,
|
|
49
51
|
'@storybook/addon-ondevice-actions',
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"default": [],
|
|
25
25
|
"description": "An array of npm packages to exclude."
|
|
26
|
+
},
|
|
27
|
+
"all": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "Copy all dependencies and devDependencies from the workspace root package.json.",
|
|
30
|
+
"default": false
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
1
|
+
import { ExecutorContext, ProjectGraph } from '@nx/devkit';
|
|
2
2
|
import { ReactNativeSyncDepsOptions } from './schema';
|
|
3
3
|
import { PackageJson } from 'nx/src/utils/package-json';
|
|
4
4
|
export interface ReactNativeSyncDepsOutput {
|
|
5
5
|
success: boolean;
|
|
6
6
|
}
|
|
7
7
|
export default function syncDepsExecutor(options: ReactNativeSyncDepsOptions, context: ExecutorContext): AsyncGenerator<ReactNativeSyncDepsOutput>;
|
|
8
|
-
export declare function syncDeps(projectPackageJson: PackageJson, projectPackageJsonPath: string, workspacePackageJson: PackageJson, include?: string[], exclude?: string[]): Promise<string[]>;
|
|
8
|
+
export declare function syncDeps(projectName: string, projectPackageJson: PackageJson, projectPackageJsonPath: string, workspacePackageJson: PackageJson, projectGraph?: ProjectGraph, include?: string[], exclude?: string[], all?: boolean): Promise<string[]>;
|
|
9
9
|
export declare function displayNewlyAddedDepsMessage(projectName: string, deps: string[]): void;
|
|
@@ -4,23 +4,28 @@ exports.displayNewlyAddedDepsMessage = exports.syncDeps = void 0;
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const find_all_npm_dependencies_1 = require("../../utils/find-all-npm-dependencies");
|
|
7
8
|
async function* syncDepsExecutor(options, context) {
|
|
8
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
9
10
|
const workspacePackageJsonPath = (0, path_1.join)(context.root, 'package.json');
|
|
10
11
|
const projectPackageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
|
|
11
12
|
const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
|
|
12
13
|
const projectPackageJson = (0, devkit_1.readJsonFile)(projectPackageJsonPath);
|
|
13
|
-
displayNewlyAddedDepsMessage(context.projectName, await syncDeps(projectPackageJson, projectPackageJsonPath, workspacePackageJson, typeof options.include === 'string'
|
|
14
|
+
displayNewlyAddedDepsMessage(context.projectName, await syncDeps(context.projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, context.projectGraph, typeof options.include === 'string'
|
|
14
15
|
? options.include.split(',')
|
|
15
16
|
: options.include, typeof options.exclude === 'string'
|
|
16
17
|
? options.exclude.split(',')
|
|
17
|
-
: options.exclude));
|
|
18
|
+
: options.exclude, options.all));
|
|
18
19
|
yield { success: true };
|
|
19
20
|
}
|
|
20
21
|
exports.default = syncDepsExecutor;
|
|
21
|
-
async function syncDeps(projectPackageJson, projectPackageJsonPath, workspacePackageJson, include = [], exclude = []) {
|
|
22
|
-
let npmDeps =
|
|
23
|
-
|
|
22
|
+
async function syncDeps(projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, projectGraph = (0, devkit_1.readCachedProjectGraph)(), include = [], exclude = [], all = false) {
|
|
23
|
+
let npmDeps = all
|
|
24
|
+
? Object.keys(workspacePackageJson.dependencies || {})
|
|
25
|
+
: (0, find_all_npm_dependencies_1.findAllNpmDependencies)(projectGraph, projectName);
|
|
26
|
+
let npmDevdeps = all
|
|
27
|
+
? Object.keys(workspacePackageJson.devDependencies || {})
|
|
28
|
+
: [];
|
|
24
29
|
const newDeps = [];
|
|
25
30
|
let updated = false;
|
|
26
31
|
if (!projectPackageJson.dependencies) {
|
|
@@ -2,12 +2,15 @@ import { join } from 'path';
|
|
|
2
2
|
import * as chalk from 'chalk';
|
|
3
3
|
import {
|
|
4
4
|
ExecutorContext,
|
|
5
|
+
ProjectGraph,
|
|
5
6
|
logger,
|
|
7
|
+
readCachedProjectGraph,
|
|
6
8
|
readJsonFile,
|
|
7
9
|
writeJsonFile,
|
|
8
10
|
} from '@nx/devkit';
|
|
9
11
|
|
|
10
12
|
import { ReactNativeSyncDepsOptions } from './schema';
|
|
13
|
+
import { findAllNpmDependencies } from '../../utils/find-all-npm-dependencies';
|
|
11
14
|
import { PackageJson } from 'nx/src/utils/package-json';
|
|
12
15
|
|
|
13
16
|
export interface ReactNativeSyncDepsOutput {
|
|
@@ -33,15 +36,18 @@ export default async function* syncDepsExecutor(
|
|
|
33
36
|
displayNewlyAddedDepsMessage(
|
|
34
37
|
context.projectName,
|
|
35
38
|
await syncDeps(
|
|
39
|
+
context.projectName,
|
|
36
40
|
projectPackageJson,
|
|
37
41
|
projectPackageJsonPath,
|
|
38
42
|
workspacePackageJson,
|
|
43
|
+
context.projectGraph,
|
|
39
44
|
typeof options.include === 'string'
|
|
40
45
|
? options.include.split(',')
|
|
41
46
|
: options.include,
|
|
42
47
|
typeof options.exclude === 'string'
|
|
43
48
|
? options.exclude.split(',')
|
|
44
|
-
: options.exclude
|
|
49
|
+
: options.exclude,
|
|
50
|
+
options.all
|
|
45
51
|
)
|
|
46
52
|
);
|
|
47
53
|
|
|
@@ -49,14 +55,21 @@ export default async function* syncDepsExecutor(
|
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
export async function syncDeps(
|
|
58
|
+
projectName: string,
|
|
52
59
|
projectPackageJson: PackageJson,
|
|
53
60
|
projectPackageJsonPath: string,
|
|
54
61
|
workspacePackageJson: PackageJson,
|
|
62
|
+
projectGraph: ProjectGraph = readCachedProjectGraph(),
|
|
55
63
|
include: string[] = [],
|
|
56
|
-
exclude: string[] = []
|
|
64
|
+
exclude: string[] = [],
|
|
65
|
+
all: boolean = false
|
|
57
66
|
): Promise<string[]> {
|
|
58
|
-
let npmDeps =
|
|
59
|
-
|
|
67
|
+
let npmDeps = all
|
|
68
|
+
? Object.keys(workspacePackageJson.dependencies || {})
|
|
69
|
+
: findAllNpmDependencies(projectGraph, projectName);
|
|
70
|
+
let npmDevdeps = all
|
|
71
|
+
? Object.keys(workspacePackageJson.devDependencies || {})
|
|
72
|
+
: [];
|
|
60
73
|
|
|
61
74
|
const newDeps = [];
|
|
62
75
|
let updated = false;
|
|
@@ -61,11 +61,10 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
|
61
61
|
tasks.push(chmodTaskGradlewTask);
|
|
62
62
|
const podInstallTask = (0, pod_install_task_1.runPodInstall)((0, devkit_1.joinPathFragments)(host.root, options.iosProjectRoot));
|
|
63
63
|
if (options.install) {
|
|
64
|
-
const workspacePackageJsonPath = (0, devkit_1.joinPathFragments)('package.json');
|
|
65
64
|
const projectPackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
|
|
66
|
-
const workspacePackageJson = (0, devkit_1.readJson)(host,
|
|
65
|
+
const workspacePackageJson = (0, devkit_1.readJson)(host, 'package.json');
|
|
67
66
|
const projectPackageJson = (0, devkit_1.readJson)(host, projectPackageJsonPath);
|
|
68
|
-
await (0, sync_deps_impl_1.syncDeps)(projectPackageJson, projectPackageJsonPath, workspacePackageJson);
|
|
67
|
+
await (0, sync_deps_impl_1.syncDeps)(options.name, projectPackageJson, projectPackageJsonPath, workspacePackageJson);
|
|
69
68
|
tasks.push(podInstallTask);
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
@@ -387,7 +387,7 @@ export const App = () => {
|
|
|
387
387
|
</View>
|
|
388
388
|
</View>
|
|
389
389
|
<View style={styles.codeBlock}>
|
|
390
|
-
<Text style={[styles.monospace]}>nx connect
|
|
390
|
+
<Text style={[styles.monospace]}>nx connect</Text>
|
|
391
391
|
</View>
|
|
392
392
|
</View>
|
|
393
393
|
</TouchableOpacity>
|
|
@@ -12,7 +12,10 @@ async function normalizeOptions(host, options) {
|
|
|
12
12
|
callingGenerator: '@nx/react-native:application',
|
|
13
13
|
});
|
|
14
14
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
|
-
|
|
15
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
+
nxJson.useInferencePlugins !== false;
|
|
18
|
+
options.addPlugin ??= addPluginDefault;
|
|
16
19
|
const { className, fileName } = (0, devkit_1.names)(options.name);
|
|
17
20
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
|
|
18
21
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
|
|
@@ -15,7 +15,10 @@ function reactNativeInitGenerator(host, schema) {
|
|
|
15
15
|
exports.reactNativeInitGenerator = reactNativeInitGenerator;
|
|
16
16
|
async function reactNativeInitGeneratorInternal(host, schema) {
|
|
17
17
|
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
|
|
18
|
-
|
|
18
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
19
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
20
|
+
nxJson.useInferencePlugins !== false;
|
|
21
|
+
schema.addPlugin ??= addPluginDefault;
|
|
19
22
|
if (schema.addPlugin) {
|
|
20
23
|
addPlugin(host);
|
|
21
24
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
5
6
|
async function normalizeOptions(host, options) {
|
|
6
7
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
@@ -11,7 +12,10 @@ async function normalizeOptions(host, options) {
|
|
|
11
12
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
13
|
callingGenerator: '@nx/react-native:library',
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
+
nxJson.useInferencePlugins !== false;
|
|
18
|
+
options.addPlugin ??= addPluginDefault;
|
|
15
19
|
const parsedTags = options.tags
|
|
16
20
|
? options.tags.split(',').map((s) => s.trim())
|
|
17
21
|
: [];
|
|
@@ -16,7 +16,10 @@ exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
|
|
|
16
16
|
*/
|
|
17
17
|
async function storybookConfigurationGeneratorInternal(host, schema) {
|
|
18
18
|
devkit_1.logger.warn(`Please run 'nx run @nx/react:storybook-configuration ${schema.project}' instead.`);
|
|
19
|
-
|
|
19
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
20
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
21
|
+
nxJson.useInferencePlugins !== false;
|
|
22
|
+
schema.addPlugin ??= addPluginDefault;
|
|
20
23
|
return (0, react_1.storybookConfigurationGenerator)(host, schema);
|
|
21
24
|
}
|
|
22
25
|
exports.storybookConfigurationGeneratorInternal = storybookConfigurationGeneratorInternal;
|
|
@@ -5,8 +5,12 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
function chmodAndroidGradlewFiles(androidFolder) {
|
|
8
|
-
(0, fs_1.
|
|
9
|
-
|
|
8
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(androidFolder, 'gradlew'))) {
|
|
9
|
+
(0, fs_1.chmodSync)((0, path_1.join)(androidFolder, 'gradlew'), 0o775);
|
|
10
|
+
}
|
|
11
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(androidFolder, 'gradlew.bat'))) {
|
|
12
|
+
(0, fs_1.chmodSync)((0, path_1.join)(androidFolder, 'gradlew.bat'), 0o775);
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
exports.chmodAndroidGradlewFiles = chmodAndroidGradlewFiles;
|
|
12
16
|
function chmodAndroidGradlewFilesTask(androidFolder) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findAllNpmDependencies = void 0;
|
|
4
|
+
function findAllNpmDependencies(graph, projectName, list = [], seen = new Set()) {
|
|
5
|
+
// In case of bad circular dependencies
|
|
6
|
+
if (seen.has(projectName)) {
|
|
7
|
+
return list;
|
|
8
|
+
}
|
|
9
|
+
seen.add(projectName);
|
|
10
|
+
const node = graph.externalNodes[projectName];
|
|
11
|
+
// Don't want to include '@nx/react-native' and '@nx/expo' because React Native
|
|
12
|
+
// autolink will warn that the package has no podspec file for iOS.
|
|
13
|
+
if (node) {
|
|
14
|
+
if (node.name !== `npm:@nx/react-native` &&
|
|
15
|
+
node.name !== `npm:@nrwl/react-native` &&
|
|
16
|
+
node.name !== `npm:@nx/expo` &&
|
|
17
|
+
node.name !== `npm:@nrwl/expo`) {
|
|
18
|
+
list.push(node.data.packageName);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
// it's workspace project, search for it's dependencies
|
|
23
|
+
graph.dependencies[projectName]?.forEach((dep) => findAllNpmDependencies(graph, dep.target, list, seen));
|
|
24
|
+
}
|
|
25
|
+
return list;
|
|
26
|
+
}
|
|
27
|
+
exports.findAllNpmDependencies = findAllNpmDependencies;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { findAllNpmDependencies } from './find-all-npm-dependencies';
|
|
2
|
+
import { DependencyType, ProjectGraph } from '@nx/devkit';
|
|
3
|
+
|
|
4
|
+
test('findAllNpmDependencies', () => {
|
|
5
|
+
const graph: ProjectGraph = {
|
|
6
|
+
nodes: {
|
|
7
|
+
myapp: {
|
|
8
|
+
type: 'app',
|
|
9
|
+
name: 'myapp',
|
|
10
|
+
data: { files: [] },
|
|
11
|
+
},
|
|
12
|
+
lib1: {
|
|
13
|
+
type: 'lib',
|
|
14
|
+
name: 'lib1',
|
|
15
|
+
data: { files: [] },
|
|
16
|
+
},
|
|
17
|
+
lib2: {
|
|
18
|
+
type: 'lib',
|
|
19
|
+
name: 'lib2',
|
|
20
|
+
data: { files: [] },
|
|
21
|
+
},
|
|
22
|
+
lib3: {
|
|
23
|
+
type: 'lib',
|
|
24
|
+
name: 'lib3',
|
|
25
|
+
data: { files: [] },
|
|
26
|
+
},
|
|
27
|
+
} as any,
|
|
28
|
+
externalNodes: {
|
|
29
|
+
'npm:react-native-image-picker': {
|
|
30
|
+
type: 'npm',
|
|
31
|
+
name: 'npm:react-native-image-picker',
|
|
32
|
+
data: {
|
|
33
|
+
version: '1',
|
|
34
|
+
packageName: 'react-native-image-picker',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
'npm:react-native-dialog': {
|
|
38
|
+
type: 'npm',
|
|
39
|
+
name: 'npm:react-native-dialog',
|
|
40
|
+
data: {
|
|
41
|
+
version: '1',
|
|
42
|
+
packageName: 'react-native-dialog',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
'npm:react-native-snackbar': {
|
|
46
|
+
type: 'npm',
|
|
47
|
+
name: 'npm:react-native-snackbar',
|
|
48
|
+
data: {
|
|
49
|
+
version: '1',
|
|
50
|
+
packageName: 'react-native-snackbar',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
'npm:@nx/react-native': {
|
|
54
|
+
type: 'npm',
|
|
55
|
+
name: 'npm:@nx/react-native',
|
|
56
|
+
data: {
|
|
57
|
+
version: '1',
|
|
58
|
+
packageName: '@nx/react-native',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
dependencies: {
|
|
63
|
+
myapp: [
|
|
64
|
+
{ type: DependencyType.static, source: 'myapp', target: 'lib1' },
|
|
65
|
+
{ type: DependencyType.static, source: 'myapp', target: 'lib2' },
|
|
66
|
+
{
|
|
67
|
+
type: DependencyType.static,
|
|
68
|
+
source: 'myapp',
|
|
69
|
+
target: 'npm:react-native-image-picker',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: DependencyType.static,
|
|
73
|
+
source: 'myapp',
|
|
74
|
+
target: 'npm:@nx/react-native',
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
lib1: [
|
|
78
|
+
{ type: DependencyType.static, source: 'lib1', target: 'lib2' },
|
|
79
|
+
{
|
|
80
|
+
type: DependencyType.static,
|
|
81
|
+
source: 'lib3',
|
|
82
|
+
target: 'npm:react-native-snackbar',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
lib2: [{ type: DependencyType.static, source: 'lib2', target: 'lib3' }],
|
|
86
|
+
lib3: [
|
|
87
|
+
{
|
|
88
|
+
type: DependencyType.static,
|
|
89
|
+
source: 'lib3',
|
|
90
|
+
target: 'npm:react-native-dialog',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const result = findAllNpmDependencies(graph, 'myapp');
|
|
97
|
+
|
|
98
|
+
expect(result).toEqual([
|
|
99
|
+
'react-native-dialog',
|
|
100
|
+
'react-native-snackbar',
|
|
101
|
+
'react-native-image-picker',
|
|
102
|
+
]);
|
|
103
|
+
});
|