@nx/react-native 16.8.0-beta.4 → 16.8.0-beta.6
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,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCliStorybook = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
|
|
@@ -9,25 +8,23 @@ const chalk = require("chalk");
|
|
|
9
8
|
const glob_1 = require("glob");
|
|
10
9
|
const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
11
10
|
const fs_extra_1 = require("fs-extra");
|
|
12
|
-
function reactNativeStorybookExecutor(options, context) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
yield yield tslib_1.__await({ success: true });
|
|
30
|
-
});
|
|
11
|
+
async function* reactNativeStorybookExecutor(options, context) {
|
|
12
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
13
|
+
devkit_1.logger.info(`${chalk.bold.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).`);
|
|
14
|
+
// add storybook addons to app's package.json
|
|
15
|
+
const packageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
|
|
16
|
+
if ((0, fileutils_1.fileExists)(packageJsonPath))
|
|
17
|
+
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(context.projectName, projectRoot, context.root, context.projectGraph, [
|
|
18
|
+
`@storybook/react-native`,
|
|
19
|
+
'@storybook/addon-ondevice-actions',
|
|
20
|
+
'@storybook/addon-ondevice-backgrounds',
|
|
21
|
+
'@storybook/addon-ondevice-controls',
|
|
22
|
+
'@storybook/addon-ondevice-notes',
|
|
23
|
+
'@react-native-async-storage/async-storage',
|
|
24
|
+
'react-native-safe-area-context',
|
|
25
|
+
]));
|
|
26
|
+
runCliStorybook(context.root, options);
|
|
27
|
+
yield { success: true };
|
|
31
28
|
}
|
|
32
29
|
exports.default = reactNativeStorybookExecutor;
|
|
33
30
|
function runCliStorybook(workspaceRoot, options) {
|
|
@@ -1,52 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.displayNewlyAddedDepsMessage = exports.syncDeps = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const path_1 = require("path");
|
|
6
5
|
const chalk = require("chalk");
|
|
7
6
|
const devkit_1 = require("@nx/devkit");
|
|
8
7
|
const find_all_npm_dependencies_1 = require("../../utils/find-all-npm-dependencies");
|
|
9
|
-
function syncDepsExecutor(options, context) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
yield yield tslib_1.__await({ success: true });
|
|
18
|
-
});
|
|
8
|
+
async function* syncDepsExecutor(options, context) {
|
|
9
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
10
|
+
displayNewlyAddedDepsMessage(context.projectName, await syncDeps(context.projectName, projectRoot, context.root, context.projectGraph, typeof options.include === 'string'
|
|
11
|
+
? options.include.split(',')
|
|
12
|
+
: options.include, typeof options.exclude === 'string'
|
|
13
|
+
? options.exclude.split(',')
|
|
14
|
+
: options.exclude));
|
|
15
|
+
yield { success: true };
|
|
19
16
|
}
|
|
20
17
|
exports.default = syncDepsExecutor;
|
|
21
|
-
function syncDeps(projectName, projectRoot, workspaceRoot, projectGraph, include = [], exclude = []) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
async function syncDeps(projectName, projectRoot, workspaceRoot, projectGraph, include = [], exclude = []) {
|
|
19
|
+
let npmDeps = (0, find_all_npm_dependencies_1.findAllNpmDependencies)(projectGraph, projectName);
|
|
20
|
+
const packageJsonPath = (0, path_1.join)(workspaceRoot, projectRoot, 'package.json');
|
|
21
|
+
const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
22
|
+
const newDeps = [];
|
|
23
|
+
let updated = false;
|
|
24
|
+
if (!packageJson.dependencies) {
|
|
25
|
+
packageJson.dependencies = {};
|
|
26
|
+
updated = true;
|
|
27
|
+
}
|
|
28
|
+
if (include && include.length) {
|
|
29
|
+
npmDeps.push(...include);
|
|
30
|
+
}
|
|
31
|
+
if (exclude && exclude.length) {
|
|
32
|
+
npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
|
|
33
|
+
}
|
|
34
|
+
npmDeps.forEach((dep) => {
|
|
35
|
+
if (!packageJson.dependencies[dep]) {
|
|
36
|
+
packageJson.dependencies[dep] = '*';
|
|
37
|
+
newDeps.push(dep);
|
|
30
38
|
updated = true;
|
|
31
39
|
}
|
|
32
|
-
if (include && include.length) {
|
|
33
|
-
npmDeps.push(...include);
|
|
34
|
-
}
|
|
35
|
-
if (exclude && exclude.length) {
|
|
36
|
-
npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
|
|
37
|
-
}
|
|
38
|
-
npmDeps.forEach((dep) => {
|
|
39
|
-
if (!packageJson.dependencies[dep]) {
|
|
40
|
-
packageJson.dependencies[dep] = '*';
|
|
41
|
-
newDeps.push(dep);
|
|
42
|
-
updated = true;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
if (updated) {
|
|
46
|
-
(0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
47
|
-
}
|
|
48
|
-
return newDeps;
|
|
49
40
|
});
|
|
41
|
+
if (updated) {
|
|
42
|
+
(0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
43
|
+
}
|
|
44
|
+
return newDeps;
|
|
50
45
|
}
|
|
51
46
|
exports.syncDeps = syncDeps;
|
|
52
47
|
function displayNewlyAddedDepsMessage(projectName, deps) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactNativeApplicationSchematic = exports.reactNativeApplicationGeneratorInternal = exports.reactNativeApplicationGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const symlink_task_1 = require("../../utils/symlink-task");
|
|
7
6
|
const add_linting_1 = require("../../utils/add-linting");
|
|
@@ -12,30 +11,33 @@ const init_1 = require("../init/init");
|
|
|
12
11
|
const add_project_1 = require("./lib/add-project");
|
|
13
12
|
const create_application_files_1 = require("./lib/create-application-files");
|
|
14
13
|
const add_detox_1 = require("./lib/add-detox");
|
|
15
|
-
function reactNativeApplicationGenerator(host, schema) {
|
|
16
|
-
return
|
|
17
|
-
|
|
14
|
+
async function reactNativeApplicationGenerator(host, schema) {
|
|
15
|
+
return await reactNativeApplicationGeneratorInternal(host, {
|
|
16
|
+
projectNameAndRootFormat: 'derived',
|
|
17
|
+
...schema,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
exports.reactNativeApplicationGenerator = reactNativeApplicationGenerator;
|
|
21
|
-
function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
|
|
33
|
-
const chmodTaskGradlew = (0, chmod_android_gradle_files_1.chmodAndroidGradlewFilesTask)((0, devkit_1.joinPathFragments)(host.root, options.androidProjectRoot));
|
|
34
|
-
if (!options.skipFormat) {
|
|
35
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
36
|
-
}
|
|
37
|
-
return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask, chmodTaskGradlew);
|
|
21
|
+
async function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
22
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
23
|
+
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
24
|
+
(0, add_project_1.addProject)(host, options);
|
|
25
|
+
const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
|
|
26
|
+
const lintTask = await (0, add_linting_1.addLinting)(host, {
|
|
27
|
+
...options,
|
|
28
|
+
projectRoot: options.appProjectRoot,
|
|
29
|
+
tsConfigPaths: [
|
|
30
|
+
(0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
31
|
+
],
|
|
38
32
|
});
|
|
33
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
|
|
34
|
+
const detoxTask = await (0, add_detox_1.addDetox)(host, options);
|
|
35
|
+
const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
|
|
36
|
+
const chmodTaskGradlew = (0, chmod_android_gradle_files_1.chmodAndroidGradlewFilesTask)((0, devkit_1.joinPathFragments)(host.root, options.androidProjectRoot));
|
|
37
|
+
if (!options.skipFormat) {
|
|
38
|
+
await (0, devkit_1.formatFiles)(host);
|
|
39
|
+
}
|
|
40
|
+
return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask, chmodTaskGradlew);
|
|
39
41
|
}
|
|
40
42
|
exports.reactNativeApplicationGeneratorInternal = reactNativeApplicationGeneratorInternal;
|
|
41
43
|
exports.default = reactNativeApplicationGenerator;
|
|
@@ -12,7 +12,7 @@ describe('app', () => {
|
|
|
12
12
|
let appTree: Tree;
|
|
13
13
|
|
|
14
14
|
beforeEach(() => {
|
|
15
|
-
appTree = createTreeWithEmptyWorkspace(
|
|
15
|
+
appTree = createTreeWithEmptyWorkspace();
|
|
16
16
|
appTree.write('.gitignore', '');
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -23,10 +23,11 @@ describe('app', () => {
|
|
|
23
23
|
linter: Linter.EsLint,
|
|
24
24
|
e2eTestRunner: 'none',
|
|
25
25
|
install: false,
|
|
26
|
+
projectNameAndRootFormat: 'as-provided',
|
|
26
27
|
});
|
|
27
28
|
const projects = getProjects(appTree);
|
|
28
29
|
|
|
29
|
-
expect(projects.get('my-app').root).toEqual('
|
|
30
|
+
expect(projects.get('my-app').root).toEqual('my-app');
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
it('should update nx.json', async () => {
|
|
@@ -37,6 +38,7 @@ describe('app', () => {
|
|
|
37
38
|
linter: Linter.EsLint,
|
|
38
39
|
e2eTestRunner: 'none',
|
|
39
40
|
install: false,
|
|
41
|
+
projectNameAndRootFormat: 'as-provided',
|
|
40
42
|
});
|
|
41
43
|
|
|
42
44
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-app');
|
|
@@ -52,15 +54,16 @@ describe('app', () => {
|
|
|
52
54
|
linter: Linter.EsLint,
|
|
53
55
|
e2eTestRunner: 'none',
|
|
54
56
|
install: false,
|
|
57
|
+
projectNameAndRootFormat: 'as-provided',
|
|
55
58
|
});
|
|
56
|
-
expect(appTree.exists('
|
|
57
|
-
expect(appTree.exists('
|
|
59
|
+
expect(appTree.exists('my-app/src/app/App.tsx')).toBeTruthy();
|
|
60
|
+
expect(appTree.exists('my-app/src/main.tsx')).toBeTruthy();
|
|
58
61
|
|
|
59
|
-
const tsconfig = readJson(appTree, '
|
|
60
|
-
expect(tsconfig.extends).toEqual('
|
|
62
|
+
const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
|
|
63
|
+
expect(tsconfig.extends).toEqual('../tsconfig.base.json');
|
|
61
64
|
|
|
62
|
-
expect(appTree.exists('
|
|
63
|
-
expect(appTree.read('
|
|
65
|
+
expect(appTree.exists('my-app/.eslintrc.json')).toBe(true);
|
|
66
|
+
expect(appTree.read('my-app/jest.config.ts', 'utf-8'))
|
|
64
67
|
.toMatchInlineSnapshot(`
|
|
65
68
|
"module.exports = {
|
|
66
69
|
displayName: 'my-app',
|
|
@@ -71,7 +74,7 @@ describe('app', () => {
|
|
|
71
74
|
moduleNameMapper: {
|
|
72
75
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
|
73
76
|
},
|
|
74
|
-
coverageDirectory: '
|
|
77
|
+
coverageDirectory: '../coverage/my-app',
|
|
75
78
|
};
|
|
76
79
|
"
|
|
77
80
|
`);
|
|
@@ -84,6 +87,7 @@ describe('app', () => {
|
|
|
84
87
|
linter: Linter.EsLint,
|
|
85
88
|
e2eTestRunner: 'none',
|
|
86
89
|
install: false,
|
|
90
|
+
projectNameAndRootFormat: 'as-provided',
|
|
87
91
|
});
|
|
88
92
|
const targets = readProjectConfiguration(appTree, 'my-app').targets;
|
|
89
93
|
expect(targets.test).toBeDefined();
|
|
@@ -98,10 +102,11 @@ describe('app', () => {
|
|
|
98
102
|
linter: Linter.EsLint,
|
|
99
103
|
e2eTestRunner: 'none',
|
|
100
104
|
install: false,
|
|
105
|
+
projectNameAndRootFormat: 'as-provided',
|
|
101
106
|
});
|
|
102
107
|
|
|
103
|
-
const tsconfig = readJson(appTree, '
|
|
104
|
-
expect(tsconfig.extends).toEqual('
|
|
108
|
+
const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
|
|
109
|
+
expect(tsconfig.extends).toEqual('../tsconfig.json');
|
|
105
110
|
});
|
|
106
111
|
|
|
107
112
|
describe('detox', () => {
|
|
@@ -112,18 +117,14 @@ describe('app', () => {
|
|
|
112
117
|
linter: Linter.EsLint,
|
|
113
118
|
e2eTestRunner: 'detox',
|
|
114
119
|
install: false,
|
|
120
|
+
projectNameAndRootFormat: 'as-provided',
|
|
115
121
|
});
|
|
116
122
|
|
|
117
123
|
const projects = getProjects(appTree);
|
|
118
|
-
expect(projects.get('my-
|
|
119
|
-
|
|
120
|
-
expect(
|
|
121
|
-
|
|
122
|
-
).toBeTruthy();
|
|
123
|
-
const detoxrc = appTree.read(
|
|
124
|
-
'apps/my-dir/my-app-e2e/.detoxrc.json',
|
|
125
|
-
'utf-8'
|
|
126
|
-
);
|
|
124
|
+
expect(projects.get('my-app').root).toEqual('my-dir');
|
|
125
|
+
|
|
126
|
+
expect(appTree.exists('my-dir-e2e/.detoxrc.json')).toBeTruthy();
|
|
127
|
+
const detoxrc = appTree.read('my-dir-e2e/.detoxrc.json', 'utf-8');
|
|
127
128
|
// Strip trailing commas
|
|
128
129
|
const detoxrcJson = JSON.parse(
|
|
129
130
|
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
|
@@ -131,30 +132,30 @@ describe('app', () => {
|
|
|
131
132
|
expect(detoxrcJson.apps).toEqual({
|
|
132
133
|
'android.debug': {
|
|
133
134
|
binaryPath:
|
|
134
|
-
'
|
|
135
|
+
'../my-dir/android/app/build/outputs/apk/debug/app-debug.apk',
|
|
135
136
|
build:
|
|
136
|
-
'cd
|
|
137
|
+
'cd ../my-dir/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
|
137
138
|
type: 'android.apk',
|
|
138
139
|
},
|
|
139
140
|
'android.release': {
|
|
140
141
|
binaryPath:
|
|
141
|
-
'
|
|
142
|
+
'../my-dir/android/app/build/outputs/apk/release/app-release.apk',
|
|
142
143
|
build:
|
|
143
|
-
'cd
|
|
144
|
+
'cd ../my-dir/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
|
144
145
|
type: 'android.apk',
|
|
145
146
|
},
|
|
146
147
|
'ios.debug': {
|
|
147
148
|
binaryPath:
|
|
148
|
-
'
|
|
149
|
+
'../my-dir/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
|
149
150
|
build:
|
|
150
|
-
"cd
|
|
151
|
+
"cd ../my-dir/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
151
152
|
type: 'ios.app',
|
|
152
153
|
},
|
|
153
154
|
'ios.release': {
|
|
154
155
|
binaryPath:
|
|
155
|
-
'
|
|
156
|
+
'../my-dir/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
|
156
157
|
build:
|
|
157
|
-
"cd
|
|
158
|
+
"cd ../my-dir/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
158
159
|
type: 'ios.app',
|
|
159
160
|
},
|
|
160
161
|
});
|
|
@@ -166,12 +167,13 @@ describe('app', () => {
|
|
|
166
167
|
linter: Linter.EsLint,
|
|
167
168
|
e2eTestRunner: 'detox',
|
|
168
169
|
install: false,
|
|
170
|
+
projectNameAndRootFormat: 'as-provided',
|
|
169
171
|
});
|
|
170
172
|
|
|
171
173
|
const projects = getProjects(appTree);
|
|
172
|
-
expect(projects.get('my-app').root).toEqual('
|
|
174
|
+
expect(projects.get('my-app').root).toEqual('my-app');
|
|
173
175
|
|
|
174
|
-
const detoxrc = appTree.read('
|
|
176
|
+
const detoxrc = appTree.read('my-app-e2e/.detoxrc.json', 'utf-8');
|
|
175
177
|
// Strip trailing commas
|
|
176
178
|
const detoxrcJson = JSON.parse(
|
|
177
179
|
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
|
@@ -179,30 +181,30 @@ describe('app', () => {
|
|
|
179
181
|
expect(detoxrcJson.apps).toEqual({
|
|
180
182
|
'android.debug': {
|
|
181
183
|
binaryPath:
|
|
182
|
-
'
|
|
184
|
+
'../my-app/android/app/build/outputs/apk/debug/app-debug.apk',
|
|
183
185
|
build:
|
|
184
|
-
'cd
|
|
186
|
+
'cd ../my-app/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
|
185
187
|
type: 'android.apk',
|
|
186
188
|
},
|
|
187
189
|
'android.release': {
|
|
188
190
|
binaryPath:
|
|
189
|
-
'
|
|
191
|
+
'../my-app/android/app/build/outputs/apk/release/app-release.apk',
|
|
190
192
|
build:
|
|
191
|
-
'cd
|
|
193
|
+
'cd ../my-app/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
|
192
194
|
type: 'android.apk',
|
|
193
195
|
},
|
|
194
196
|
'ios.debug': {
|
|
195
197
|
binaryPath:
|
|
196
|
-
'
|
|
198
|
+
'../my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
|
197
199
|
build:
|
|
198
|
-
"cd
|
|
200
|
+
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
199
201
|
type: 'ios.app',
|
|
200
202
|
},
|
|
201
203
|
'ios.release': {
|
|
202
204
|
binaryPath:
|
|
203
|
-
'
|
|
205
|
+
'../my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
|
204
206
|
build:
|
|
205
|
-
"cd
|
|
207
|
+
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
206
208
|
type: 'ios.app',
|
|
207
209
|
},
|
|
208
210
|
});
|
|
@@ -220,6 +222,7 @@ describe('app', () => {
|
|
|
220
222
|
e2eTestRunner: 'none',
|
|
221
223
|
install: false,
|
|
222
224
|
skipPackageJson: true,
|
|
225
|
+
projectNameAndRootFormat: 'as-provided',
|
|
223
226
|
});
|
|
224
227
|
|
|
225
228
|
expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addDetox = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const detox_1 = require("@nx/detox");
|
|
6
5
|
const linter_1 = require("@nx/linter");
|
|
7
|
-
function addDetox(host, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
async function addDetox(host, options) {
|
|
7
|
+
if (options?.e2eTestRunner !== 'detox') {
|
|
8
|
+
return () => { };
|
|
9
|
+
}
|
|
10
|
+
return (0, detox_1.detoxApplicationGenerator)(host, {
|
|
11
|
+
...options,
|
|
12
|
+
linter: linter_1.Linter.EsLint,
|
|
13
|
+
e2eName: `${options.projectName}-e2e`,
|
|
14
|
+
e2eDirectory: `${options.appProjectRoot}-e2e`,
|
|
15
|
+
projectNameAndRootFormat: 'as-provided',
|
|
16
|
+
appProject: options.projectName,
|
|
17
|
+
appDisplayName: options.displayName,
|
|
18
|
+
appName: options.name,
|
|
19
|
+
framework: 'react-native',
|
|
20
|
+
skipFormat: true,
|
|
13
21
|
});
|
|
14
22
|
}
|
|
15
23
|
exports.addDetox = addDetox;
|
|
@@ -7,10 +7,12 @@ function addProject(host, options) {
|
|
|
7
7
|
root: options.appProjectRoot,
|
|
8
8
|
sourceRoot: `${options.appProjectRoot}/src`,
|
|
9
9
|
projectType: 'application',
|
|
10
|
-
targets:
|
|
10
|
+
targets: { ...getTargets(options) },
|
|
11
11
|
tags: options.parsedTags,
|
|
12
12
|
};
|
|
13
|
-
(0, devkit_1.addProjectConfiguration)(host, options.projectName,
|
|
13
|
+
(0, devkit_1.addProjectConfiguration)(host, options.projectName, {
|
|
14
|
+
...project,
|
|
15
|
+
});
|
|
14
16
|
}
|
|
15
17
|
exports.addProject = addProject;
|
|
16
18
|
function getTargets(options) {
|
|
@@ -5,7 +5,12 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
function createApplicationFiles(host, options) {
|
|
8
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), options.appProjectRoot,
|
|
8
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), options.appProjectRoot, {
|
|
9
|
+
...options,
|
|
10
|
+
entryFileIos: 'src/main',
|
|
11
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
12
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot),
|
|
13
|
+
});
|
|
9
14
|
if (options.unitTestRunner === 'none') {
|
|
10
15
|
host.delete((0, path_1.join)(options.appProjectRoot, `/src/app/App.spec.tsx`));
|
|
11
16
|
}
|
|
@@ -8,7 +8,7 @@ describe('Normalize Options', () => {
|
|
|
8
8
|
let appTree: Tree;
|
|
9
9
|
|
|
10
10
|
beforeEach(() => {
|
|
11
|
-
appTree = createTreeWithEmptyWorkspace(
|
|
11
|
+
appTree = createTreeWithEmptyWorkspace();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('should normalize options with name in kebab case', async () => {
|
|
@@ -17,19 +17,20 @@ describe('Normalize Options', () => {
|
|
|
17
17
|
linter: Linter.EsLint,
|
|
18
18
|
e2eTestRunner: 'none',
|
|
19
19
|
install: false,
|
|
20
|
+
projectNameAndRootFormat: 'as-provided',
|
|
20
21
|
};
|
|
21
22
|
const options = await normalizeOptions(appTree, schema);
|
|
22
23
|
expect(options).toEqual({
|
|
23
|
-
androidProjectRoot: '
|
|
24
|
-
appProjectRoot: '
|
|
24
|
+
androidProjectRoot: 'my-app/android',
|
|
25
|
+
appProjectRoot: 'my-app',
|
|
25
26
|
className: 'MyApp',
|
|
26
27
|
displayName: 'MyApp',
|
|
27
|
-
iosProjectRoot: '
|
|
28
|
+
iosProjectRoot: 'my-app/ios',
|
|
28
29
|
lowerCaseName: 'myapp',
|
|
29
30
|
name: 'my-app',
|
|
30
31
|
parsedTags: [],
|
|
31
32
|
projectName: 'my-app',
|
|
32
|
-
projectNameAndRootFormat: '
|
|
33
|
+
projectNameAndRootFormat: 'as-provided',
|
|
33
34
|
linter: Linter.EsLint,
|
|
34
35
|
entryFile: 'src/main.tsx',
|
|
35
36
|
e2eTestRunner: 'none',
|
|
@@ -43,19 +44,20 @@ describe('Normalize Options', () => {
|
|
|
43
44
|
name: 'myApp',
|
|
44
45
|
e2eTestRunner: 'none',
|
|
45
46
|
install: false,
|
|
47
|
+
projectNameAndRootFormat: 'as-provided',
|
|
46
48
|
};
|
|
47
49
|
const options = await normalizeOptions(appTree, schema);
|
|
48
50
|
expect(options).toEqual({
|
|
49
|
-
androidProjectRoot: '
|
|
50
|
-
appProjectRoot: '
|
|
51
|
+
androidProjectRoot: 'my-app/android',
|
|
52
|
+
appProjectRoot: 'my-app',
|
|
51
53
|
className: 'MyApp',
|
|
52
54
|
displayName: 'MyApp',
|
|
53
|
-
iosProjectRoot: '
|
|
55
|
+
iosProjectRoot: 'my-app/ios',
|
|
54
56
|
lowerCaseName: 'myapp',
|
|
55
57
|
name: 'my-app',
|
|
56
58
|
parsedTags: [],
|
|
57
59
|
projectName: 'my-app',
|
|
58
|
-
projectNameAndRootFormat: '
|
|
60
|
+
projectNameAndRootFormat: 'as-provided',
|
|
59
61
|
entryFile: 'src/main.tsx',
|
|
60
62
|
e2eTestRunner: 'none',
|
|
61
63
|
unitTestRunner: 'jest',
|
|
@@ -66,23 +68,24 @@ describe('Normalize Options', () => {
|
|
|
66
68
|
it('should normalize options with directory', async () => {
|
|
67
69
|
const schema: Schema = {
|
|
68
70
|
name: 'my-app',
|
|
69
|
-
directory: 'directory',
|
|
71
|
+
directory: 'directory/my-app',
|
|
70
72
|
e2eTestRunner: 'none',
|
|
71
73
|
install: false,
|
|
74
|
+
projectNameAndRootFormat: 'as-provided',
|
|
72
75
|
};
|
|
73
76
|
const options = await normalizeOptions(appTree, schema);
|
|
74
77
|
expect(options).toEqual({
|
|
75
|
-
androidProjectRoot: '
|
|
76
|
-
appProjectRoot: '
|
|
78
|
+
androidProjectRoot: 'directory/my-app/android',
|
|
79
|
+
appProjectRoot: 'directory/my-app',
|
|
77
80
|
className: 'MyApp',
|
|
78
81
|
displayName: 'MyApp',
|
|
79
|
-
iosProjectRoot: '
|
|
82
|
+
iosProjectRoot: 'directory/my-app/ios',
|
|
80
83
|
lowerCaseName: 'myapp',
|
|
81
84
|
name: 'my-app',
|
|
82
|
-
directory: 'directory',
|
|
85
|
+
directory: 'directory/my-app',
|
|
83
86
|
parsedTags: [],
|
|
84
|
-
projectName: '
|
|
85
|
-
projectNameAndRootFormat: '
|
|
87
|
+
projectName: 'my-app',
|
|
88
|
+
projectNameAndRootFormat: 'as-provided',
|
|
86
89
|
entryFile: 'src/main.tsx',
|
|
87
90
|
e2eTestRunner: 'none',
|
|
88
91
|
unitTestRunner: 'jest',
|
|
@@ -95,19 +98,20 @@ describe('Normalize Options', () => {
|
|
|
95
98
|
name: 'directory/my-app',
|
|
96
99
|
e2eTestRunner: 'none',
|
|
97
100
|
install: false,
|
|
101
|
+
projectNameAndRootFormat: 'as-provided',
|
|
98
102
|
};
|
|
99
103
|
const options = await normalizeOptions(appTree, schema);
|
|
100
104
|
expect(options).toEqual({
|
|
101
|
-
androidProjectRoot: '
|
|
102
|
-
appProjectRoot: '
|
|
105
|
+
androidProjectRoot: 'directory/my-app/android',
|
|
106
|
+
appProjectRoot: 'directory/my-app',
|
|
103
107
|
className: 'DirectoryMyApp',
|
|
104
108
|
displayName: 'DirectoryMyApp',
|
|
105
|
-
iosProjectRoot: '
|
|
109
|
+
iosProjectRoot: 'directory/my-app/ios',
|
|
106
110
|
lowerCaseName: 'directorymyapp',
|
|
107
111
|
name: 'directory/my-app',
|
|
108
112
|
parsedTags: [],
|
|
109
|
-
projectName: 'directory
|
|
110
|
-
projectNameAndRootFormat: '
|
|
113
|
+
projectName: 'directory/my-app',
|
|
114
|
+
projectNameAndRootFormat: 'as-provided',
|
|
111
115
|
entryFile: 'src/main.tsx',
|
|
112
116
|
e2eTestRunner: 'none',
|
|
113
117
|
unitTestRunner: 'jest',
|
|
@@ -121,19 +125,20 @@ describe('Normalize Options', () => {
|
|
|
121
125
|
displayName: 'My App',
|
|
122
126
|
e2eTestRunner: 'none',
|
|
123
127
|
install: false,
|
|
128
|
+
projectNameAndRootFormat: 'as-provided',
|
|
124
129
|
};
|
|
125
130
|
const options = await normalizeOptions(appTree, schema);
|
|
126
131
|
expect(options).toEqual({
|
|
127
|
-
androidProjectRoot: '
|
|
128
|
-
appProjectRoot: '
|
|
132
|
+
androidProjectRoot: 'my-app/android',
|
|
133
|
+
appProjectRoot: 'my-app',
|
|
129
134
|
className: 'MyApp',
|
|
130
135
|
displayName: 'My App',
|
|
131
|
-
iosProjectRoot: '
|
|
136
|
+
iosProjectRoot: 'my-app/ios',
|
|
132
137
|
lowerCaseName: 'myapp',
|
|
133
138
|
name: 'my-app',
|
|
134
139
|
parsedTags: [],
|
|
135
140
|
projectName: 'my-app',
|
|
136
|
-
projectNameAndRootFormat: '
|
|
141
|
+
projectNameAndRootFormat: 'as-provided',
|
|
137
142
|
entryFile: 'src/main.tsx',
|
|
138
143
|
e2eTestRunner: 'none',
|
|
139
144
|
unitTestRunner: 'jest',
|