@nx/react-native 16.8.0-beta.3 → 16.8.0-beta.5
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 +10 -10
- package/plugins/metro-resolver.js +4 -5
- package/plugins/with-nx-metro.js +23 -27
- package/src/executors/build-android/build-android.impl.js +6 -9
- package/src/executors/build-ios/build-ios.impl.js +8 -11
- package/src/executors/bundle/bundle.impl.js +6 -9
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -7
- package/src/executors/pod-install/pod-install.impl.js +5 -8
- package/src/executors/run-android/run-android.impl.js +23 -39
- package/src/executors/run-ios/run-ios.impl.js +25 -41
- package/src/executors/start/lib/is-packager-running.js +9 -12
- package/src/executors/start/start.impl.js +38 -43
- package/src/executors/storybook/storybook.impl.js +17 -20
- package/src/executors/sync-deps/sync-deps.impl.js +32 -37
- package/src/generators/application/application.js +23 -21
- package/src/generators/application/application.spec.ts +41 -38
- package/src/generators/application/lib/add-detox.js +15 -7
- package/src/generators/application/lib/add-project.js +4 -2
- package/src/generators/application/lib/create-application-files.js +6 -1
- package/src/generators/application/lib/nomalize-options.spec.ts +30 -25
- package/src/generators/application/lib/normalize-options.js +30 -23
- package/src/generators/component/component.js +9 -9
- package/src/generators/component/component.spec.ts +14 -22
- package/src/generators/component/lib/normalize-options.js +36 -37
- package/src/generators/component-story/component-story.js +6 -9
- package/src/generators/component-story/component-story.spec.ts +7 -7
- package/src/generators/init/init.js +56 -29
- package/src/generators/init/init.spec.ts +1 -1
- package/src/generators/library/lib/normalize-options.js +21 -18
- package/src/generators/library/library.js +94 -79
- package/src/generators/library/library.spec.ts +47 -57
- package/src/generators/stories/stories-app.spec.ts +20 -37
- package/src/generators/stories/stories-lib.spec.ts +10 -18
- package/src/generators/stories/stories.js +39 -44
- package/src/generators/storybook-configuration/configuration.js +29 -34
- package/src/generators/storybook-configuration/configuration.spec.ts +10 -12
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +1 -1
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +7 -7
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +30 -34
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +1 -1
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +7 -7
- package/src/generators/upgrade-native/upgrade-native.js +13 -16
- package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.js +11 -16
- package/src/migrations/update-12-5-0/update-jest-for-react-native.js +5 -8
- package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.js +12 -15
- package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.js +7 -11
- package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +16 -20
- package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js +23 -28
- package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.js +26 -30
- package/src/migrations/update-14-2-1/rename-blockList-metro-config.js +16 -20
- package/src/migrations/update-14-5-5/add-exclude-sync-deps.js +12 -16
- package/src/migrations/update-14-5-8/change-searchDir-storybook.js +12 -16
- package/src/migrations/update-14-6-0/remove-jest-transform.js +13 -17
- package/src/migrations/update-15-0-0/add-babel-inputs.js +3 -6
- package/src/migrations/update-15-9-1/add-build-ios-target.js +19 -23
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +2 -3
- package/src/migrations/update-16-6-0/add-depends-on.js +29 -33
- package/src/migrations/update-16-6-0/update-metro-config.js +11 -15
- package/src/utils/add-jest.js +19 -22
- package/src/utils/add-linting.js +26 -29
- package/src/utils/chmod-android-gradle-files.js +1 -1
- package/src/utils/find-all-npm-dependencies.js +1 -2
- package/src/utils/symlink-task.js +1 -1
- package/src/utils/testing-generators.js +19 -23
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
/**
|
|
6
5
|
* This migration adds dependsOn to project.json.
|
|
7
6
|
*
|
|
8
7
|
*/
|
|
9
|
-
function update(tree) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
config.targets['bundle-android'].dependsOn = ['ensure-symlink'];
|
|
38
|
-
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
39
|
-
}
|
|
8
|
+
async function update(tree) {
|
|
9
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
10
|
+
for (const [name, config] of projects.entries()) {
|
|
11
|
+
if (config.targets?.['start']?.executor === '@nx/react-native:start') {
|
|
12
|
+
config.targets['start'].dependsOn = [
|
|
13
|
+
'ensure-symlink',
|
|
14
|
+
'sync-deps',
|
|
15
|
+
'pod-install',
|
|
16
|
+
];
|
|
17
|
+
config.targets['run-ios'].dependsOn = [
|
|
18
|
+
'ensure-symlink',
|
|
19
|
+
'sync-deps',
|
|
20
|
+
'pod-install',
|
|
21
|
+
];
|
|
22
|
+
config.targets['bundle-ios'].dependsOn = ['ensure-symlink'];
|
|
23
|
+
config.targets['run-android'].dependsOn = ['ensure-symlink', 'sync-deps'];
|
|
24
|
+
config.targets['build-android'].dependsOn = [
|
|
25
|
+
'ensure-symlink',
|
|
26
|
+
'sync-deps',
|
|
27
|
+
];
|
|
28
|
+
config.targets['build-ios'].dependsOn = [
|
|
29
|
+
'ensure-symlink',
|
|
30
|
+
'sync-deps',
|
|
31
|
+
'pod-install',
|
|
32
|
+
];
|
|
33
|
+
config.targets['pod-install'].dependsOn = ['ensure-symlink', 'sync-deps'];
|
|
34
|
+
config.targets['bundle-android'].dependsOn = ['ensure-symlink'];
|
|
35
|
+
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
40
36
|
}
|
|
41
|
-
}
|
|
37
|
+
}
|
|
42
38
|
}
|
|
43
39
|
exports.default = update;
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
/**
|
|
7
6
|
* This migration updates metro.config.js to export config as a default.
|
|
8
7
|
*
|
|
9
8
|
*/
|
|
10
|
-
function update(tree) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
tree.write((0, path_1.join)(config.root, 'metro-v71.config.js'), oldConfigComment + oldConfig);
|
|
21
|
-
tree.write((0, path_1.join)(config.root, 'metro.config.js'), content);
|
|
22
|
-
}
|
|
9
|
+
async function update(tree) {
|
|
10
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
11
|
+
for (const [_, config] of projects.entries()) {
|
|
12
|
+
if (config.targets?.['start']?.executor === '@nx/react-native:start') {
|
|
13
|
+
if (tree.exists((0, path_1.join)(config.root, 'metro.config.js'))) {
|
|
14
|
+
const oldConfig = tree
|
|
15
|
+
.read((0, path_1.join)(config.root, 'metro.config.js'))
|
|
16
|
+
.toString();
|
|
17
|
+
tree.write((0, path_1.join)(config.root, 'metro-v71.config.js'), oldConfigComment + oldConfig);
|
|
18
|
+
tree.write((0, path_1.join)(config.root, 'metro.config.js'), content);
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
|
-
}
|
|
21
|
+
}
|
|
26
22
|
}
|
|
27
23
|
exports.default = update;
|
|
28
24
|
const oldConfigComment = `/**
|
package/src/utils/add-jest.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addJest = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const jest_1 = require("@nx/jest");
|
|
7
|
-
function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const content = `module.exports = {
|
|
6
|
+
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
|
|
7
|
+
if (unitTestRunner !== 'jest') {
|
|
8
|
+
return () => { };
|
|
9
|
+
}
|
|
10
|
+
const jestTask = await (0, jest_1.configurationGenerator)(host, {
|
|
11
|
+
js,
|
|
12
|
+
project: projectName,
|
|
13
|
+
supportTsx: true,
|
|
14
|
+
skipSerializers: true,
|
|
15
|
+
setupFile: 'none',
|
|
16
|
+
compiler: 'babel',
|
|
17
|
+
skipPackageJson,
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
});
|
|
20
|
+
// overwrite the jest.config.ts file because react native needs to have special transform property
|
|
21
|
+
const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
|
|
22
|
+
const content = `module.exports = {
|
|
25
23
|
displayName: '${projectName}',
|
|
26
24
|
preset: 'react-native',
|
|
27
25
|
resolver: '@nx/jest/plugins/resolver',
|
|
@@ -32,8 +30,7 @@ function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPack
|
|
|
32
30
|
},
|
|
33
31
|
coverageDirectory: '${(0, devkit_1.offsetFromRoot)(appProjectRoot)}coverage/${appProjectRoot}'
|
|
34
32
|
};`;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
33
|
+
host.write(configPath, content);
|
|
34
|
+
return jestTask;
|
|
38
35
|
}
|
|
39
36
|
exports.addJest = addJest;
|
package/src/utils/add-linting.js
CHANGED
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLinting = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const linter_1 = require("@nx/linter");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const lint_1 = require("@nx/react/src/utils/lint");
|
|
8
7
|
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
9
|
-
function addLinting(host, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
skipPackageJson: options.skipPackageJson,
|
|
22
|
-
});
|
|
23
|
-
tasks.push(lintTask);
|
|
24
|
-
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
25
|
-
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
26
|
-
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
|
|
27
|
-
'public',
|
|
28
|
-
'.cache',
|
|
29
|
-
'node_modules',
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
if (!options.skipPackageJson) {
|
|
33
|
-
const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
34
|
-
tasks.push(installTask);
|
|
35
|
-
}
|
|
36
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
8
|
+
async function addLinting(host, options) {
|
|
9
|
+
if (options.linter === linter_1.Linter.None) {
|
|
10
|
+
return () => { };
|
|
11
|
+
}
|
|
12
|
+
const tasks = [];
|
|
13
|
+
const lintTask = await (0, linter_1.lintProjectGenerator)(host, {
|
|
14
|
+
linter: options.linter,
|
|
15
|
+
project: options.projectName,
|
|
16
|
+
tsConfigPaths: options.tsConfigPaths,
|
|
17
|
+
eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
skipPackageJson: options.skipPackageJson,
|
|
37
20
|
});
|
|
21
|
+
tasks.push(lintTask);
|
|
22
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
23
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
24
|
+
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
|
|
25
|
+
'public',
|
|
26
|
+
'.cache',
|
|
27
|
+
'node_modules',
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
if (!options.skipPackageJson) {
|
|
31
|
+
const installTask = await (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
32
|
+
tasks.push(installTask);
|
|
33
|
+
}
|
|
34
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
38
35
|
}
|
|
39
36
|
exports.addLinting = addLinting;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findAllNpmDependencies = void 0;
|
|
4
4
|
function findAllNpmDependencies(graph, projectName, list = [], seen = new Set()) {
|
|
5
|
-
var _a;
|
|
6
5
|
// In case of bad circular dependencies
|
|
7
6
|
if (seen.has(projectName)) {
|
|
8
7
|
return list;
|
|
@@ -19,7 +18,7 @@ function findAllNpmDependencies(graph, projectName, list = [], seen = new Set())
|
|
|
19
18
|
}
|
|
20
19
|
else {
|
|
21
20
|
// it's workspace project, search for it's dependencies
|
|
22
|
-
|
|
21
|
+
graph.dependencies[projectName]?.forEach((dep) => findAllNpmDependencies(graph, dep.target, list, seen));
|
|
23
22
|
}
|
|
24
23
|
return list;
|
|
25
24
|
}
|
|
@@ -10,7 +10,7 @@ function runSymlink(workspaceRoot, projectRoot) {
|
|
|
10
10
|
try {
|
|
11
11
|
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(workspaceRoot, projectRoot);
|
|
12
12
|
}
|
|
13
|
-
catch
|
|
13
|
+
catch {
|
|
14
14
|
throw new Error(`Failed to create symlinks for ${chalk.bold(projectRoot)}`);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createLib = exports.createApp = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const application_1 = require("../generators/application/application");
|
|
7
6
|
const linter_1 = require("@nx/linter");
|
|
8
|
-
function createApp(tree, appName) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
7
|
+
async function createApp(tree, appName) {
|
|
8
|
+
await (0, application_1.default)(tree, {
|
|
9
|
+
linter: linter_1.Linter.EsLint,
|
|
10
|
+
skipFormat: true,
|
|
11
|
+
style: 'css',
|
|
12
|
+
unitTestRunner: 'none',
|
|
13
|
+
name: appName,
|
|
14
|
+
e2eTestRunner: 'none',
|
|
15
|
+
install: false,
|
|
16
|
+
projectNameAndRootFormat: 'as-provided',
|
|
19
17
|
});
|
|
20
18
|
}
|
|
21
19
|
exports.createApp = createApp;
|
|
22
|
-
function createLib(tree, libName) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
targets: {},
|
|
32
|
-
});
|
|
20
|
+
async function createLib(tree, libName) {
|
|
21
|
+
const { fileName } = (0, devkit_1.names)(libName);
|
|
22
|
+
tree.write(`${fileName}/src/index.ts`, `import React from 'react';\n`);
|
|
23
|
+
(0, devkit_1.addProjectConfiguration)(tree, fileName, {
|
|
24
|
+
tags: [],
|
|
25
|
+
root: `${fileName}`,
|
|
26
|
+
projectType: 'library',
|
|
27
|
+
sourceRoot: `${fileName}/src`,
|
|
28
|
+
targets: {},
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
31
|
exports.createLib = createLib;
|