@nx/react-native 17.0.0-beta.6 → 17.0.0-rc.0
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/generators.json +1 -1
- package/package.json +9 -9
- package/src/executors/build-android/build-android.impl.js +1 -7
- package/src/executors/build-android/build-android.impl.ts +1 -7
- package/src/executors/build-ios/build-ios.impl.js +3 -2
- package/src/executors/build-ios/build-ios.impl.ts +3 -6
- package/src/executors/run-android/run-android.impl.js +5 -3
- package/src/executors/run-android/run-android.impl.ts +5 -7
- package/src/executors/run-android/schema.json +0 -11
- package/src/executors/run-ios/run-ios.impl.js +3 -3
- package/src/executors/run-ios/run-ios.impl.ts +3 -7
- package/src/executors/run-ios/schema.json +0 -17
- package/src/generators/application/application.spec.ts +10 -10
- package/src/generators/application/files/app/metro.config.js.template +1 -1
- package/src/generators/application/lib/add-detox.js +2 -2
- package/src/generators/application/lib/{nomalize-options.spec.ts → normalize-options.spec.ts} +6 -6
- package/src/generators/application/schema.d.ts +1 -1
- package/src/generators/component/component.d.ts +1 -0
- package/src/generators/component/component.js +17 -5
- package/src/generators/component/lib/normalize-options.d.ts +1 -0
- package/src/generators/component/lib/normalize-options.js +17 -24
- package/src/generators/component/schema.d.ts +10 -0
- package/src/generators/component/schema.json +12 -5
- package/src/generators/component-story/component-story.spec.ts +14 -14
- package/src/generators/library/library.spec.ts +32 -17
- package/src/generators/library/schema.d.ts +1 -1
- package/src/generators/stories/stories-app.spec.ts +1 -1
- package/src/generators/stories/stories-lib.spec.ts +1 -1
- package/src/generators/storybook-configuration/configuration.spec.ts +1 -1
- package/src/generators/storybook-configuration/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/utils/add-linting.d.ts +1 -1
- package/src/utils/add-linting.js +4 -4
- package/src/utils/add-linting.spec.ts +2 -2
- package/src/utils/testing-generators.js +2 -2
package/generators.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"description": "Create a React Native library."
|
|
25
25
|
},
|
|
26
26
|
"component": {
|
|
27
|
-
"factory": "./src/generators/component/component#
|
|
27
|
+
"factory": "./src/generators/component/component#reactNativeComponentGeneratorInternal",
|
|
28
28
|
"schema": "./src/generators/component/schema.json",
|
|
29
29
|
"description": "Create a React Native component.",
|
|
30
30
|
"aliases": ["c"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "17.0.0-
|
|
3
|
+
"version": "17.0.0-rc.0",
|
|
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": [
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"node-fetch": "^2.6.7",
|
|
37
37
|
"tsconfig-paths": "^4.1.2",
|
|
38
38
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/detox": "17.0.0-
|
|
40
|
-
"@nx/devkit": "17.0.0-
|
|
41
|
-
"@nx/jest": "17.0.0-
|
|
42
|
-
"@nx/js": "17.0.0-
|
|
43
|
-
"@nx/
|
|
44
|
-
"@nx/react": "17.0.0-
|
|
45
|
-
"@nx/workspace": "17.0.0-
|
|
46
|
-
"@nrwl/react-native": "17.0.0-
|
|
39
|
+
"@nx/detox": "17.0.0-rc.0",
|
|
40
|
+
"@nx/devkit": "17.0.0-rc.0",
|
|
41
|
+
"@nx/jest": "17.0.0-rc.0",
|
|
42
|
+
"@nx/js": "17.0.0-rc.0",
|
|
43
|
+
"@nx/eslint": "17.0.0-rc.0",
|
|
44
|
+
"@nx/react": "17.0.0-rc.0",
|
|
45
|
+
"@nx/workspace": "17.0.0-rc.0",
|
|
46
|
+
"@nrwl/react-native": "17.0.0-rc.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react-native": ">= 0.72.0 < 0.73.0"
|
|
@@ -46,13 +46,7 @@ function runCliBuild(workspaceRoot, projectRoot, options) {
|
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
const nxOptions = ['sync', 'packager'];
|
|
50
49
|
const startOptions = ['port', 'resetCache'];
|
|
51
|
-
const deprecatedOptions = ['apk', 'debug', 'gradleTask'];
|
|
52
50
|
function createBuildAndroidOptions(options) {
|
|
53
|
-
return (0, get_cli_options_1.getCliOptions)(options,
|
|
54
|
-
...nxOptions,
|
|
55
|
-
...startOptions,
|
|
56
|
-
...deprecatedOptions,
|
|
57
|
-
]);
|
|
51
|
+
return (0, get_cli_options_1.getCliOptions)(options, startOptions);
|
|
58
52
|
}
|
|
@@ -66,14 +66,8 @@ function runCliBuild(
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const nxOptions = ['sync', 'packager'];
|
|
70
69
|
const startOptions = ['port', 'resetCache'];
|
|
71
|
-
const deprecatedOptions = ['apk', 'debug', 'gradleTask'];
|
|
72
70
|
|
|
73
71
|
function createBuildAndroidOptions(options: ReactNativeBuildAndroidOptions) {
|
|
74
|
-
return getCliOptions<ReactNativeBuildAndroidOptions>(options,
|
|
75
|
-
...nxOptions,
|
|
76
|
-
...startOptions,
|
|
77
|
-
...deprecatedOptions,
|
|
78
|
-
]);
|
|
72
|
+
return getCliOptions<ReactNativeBuildAndroidOptions>(options, startOptions);
|
|
79
73
|
}
|
|
@@ -47,8 +47,9 @@ function runCliBuildIOS(workspaceRoot, projectRoot, options) {
|
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
const nxOptions = ['sync', 'install', 'packager'];
|
|
51
50
|
const startOptions = ['port', 'resetCache'];
|
|
52
51
|
function createBuildIOSOptions(options) {
|
|
53
|
-
return (0, get_cli_options_1.getCliOptions)(options,
|
|
52
|
+
return (0, get_cli_options_1.getCliOptions)(options, startOptions, [
|
|
53
|
+
'buildFolder',
|
|
54
|
+
]);
|
|
54
55
|
}
|
|
@@ -68,13 +68,10 @@ function runCliBuildIOS(
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
const nxOptions = ['sync', 'install', 'packager'];
|
|
72
71
|
const startOptions = ['port', 'resetCache'];
|
|
73
72
|
|
|
74
73
|
function createBuildIOSOptions(options: ReactNativeBuildIosOptions) {
|
|
75
|
-
return getCliOptions<ReactNativeBuildIosOptions>(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
['buildFolder']
|
|
79
|
-
);
|
|
74
|
+
return getCliOptions<ReactNativeBuildIosOptions>(options, startOptions, [
|
|
75
|
+
'buildFolder',
|
|
76
|
+
]);
|
|
80
77
|
}
|
|
@@ -68,9 +68,11 @@ function runCliRunAndroid(workspaceRoot, projectRoot, options) {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
const nxOptions = ['sync', 'packager'];
|
|
72
71
|
const startOptions = ['port', 'resetCache'];
|
|
73
|
-
const deprecatedOptions = ['variant', 'jetifier'];
|
|
74
72
|
function createRunAndroidOptions(options) {
|
|
75
|
-
return (0, get_cli_options_1.getCliOptions)(options,
|
|
73
|
+
return (0, get_cli_options_1.getCliOptions)(options, startOptions, [
|
|
74
|
+
'appId',
|
|
75
|
+
'appIdSuffix',
|
|
76
|
+
'deviceId',
|
|
77
|
+
]);
|
|
76
78
|
}
|
|
@@ -92,14 +92,12 @@ function runCliRunAndroid(
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const nxOptions = ['sync', 'packager'];
|
|
96
95
|
const startOptions = ['port', 'resetCache'];
|
|
97
|
-
const deprecatedOptions = ['variant', 'jetifier'];
|
|
98
96
|
|
|
99
97
|
function createRunAndroidOptions(options: ReactNativeRunAndroidOptions) {
|
|
100
|
-
return getCliOptions<ReactNativeRunAndroidOptions>(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
);
|
|
98
|
+
return getCliOptions<ReactNativeRunAndroidOptions>(options, startOptions, [
|
|
99
|
+
'appId',
|
|
100
|
+
'appIdSuffix',
|
|
101
|
+
'deviceId',
|
|
102
|
+
]);
|
|
105
103
|
}
|
|
@@ -54,11 +54,6 @@
|
|
|
54
54
|
"examples": ["debug", "release"],
|
|
55
55
|
"x-priority": "important"
|
|
56
56
|
},
|
|
57
|
-
"packager": {
|
|
58
|
-
"type": "boolean",
|
|
59
|
-
"description": "Launch packager while building",
|
|
60
|
-
"default": true
|
|
61
|
-
},
|
|
62
57
|
"port": {
|
|
63
58
|
"type": "number",
|
|
64
59
|
"description": "The port where the packager server is listening on.",
|
|
@@ -95,12 +90,6 @@
|
|
|
95
90
|
"type": "boolean",
|
|
96
91
|
"description": "Explicitly select build type and flavour to use before running a build"
|
|
97
92
|
},
|
|
98
|
-
"sync": {
|
|
99
|
-
"type": "boolean",
|
|
100
|
-
"description": "Syncs npm dependencies to `package.json` (for React Native autolink).",
|
|
101
|
-
"x-deprecated": "Add sync-deps to dependsOn for this target in project.json instead",
|
|
102
|
-
"default": true
|
|
103
|
-
},
|
|
104
93
|
"resetCache": {
|
|
105
94
|
"type": "boolean",
|
|
106
95
|
"description": "Resets metro cache.",
|
|
@@ -69,9 +69,9 @@ function runCliRunIOS(workspaceRoot, projectRoot, options) {
|
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
const nxOptions = ['sync', 'install', 'packager'];
|
|
73
72
|
const startOptions = ['port', 'resetCache'];
|
|
74
|
-
const deprecatedOptions = ['xcodeConfiguration'];
|
|
75
73
|
function createRunIOSOptions(options) {
|
|
76
|
-
return (0, get_cli_options_1.getCliOptions)(options,
|
|
74
|
+
return (0, get_cli_options_1.getCliOptions)(options, startOptions, [
|
|
75
|
+
'buildFolder',
|
|
76
|
+
]);
|
|
77
77
|
}
|
|
@@ -92,14 +92,10 @@ function runCliRunIOS(
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const nxOptions = ['sync', 'install', 'packager'];
|
|
96
95
|
const startOptions = ['port', 'resetCache'];
|
|
97
|
-
const deprecatedOptions = ['xcodeConfiguration'];
|
|
98
96
|
|
|
99
97
|
function createRunIOSOptions(options: ReactNativeRunIosOptions) {
|
|
100
|
-
return getCliOptions<ReactNativeRunIosOptions>(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
['buildFolder']
|
|
104
|
-
);
|
|
98
|
+
return getCliOptions<ReactNativeRunIosOptions>(options, startOptions, [
|
|
99
|
+
'buildFolder',
|
|
100
|
+
]);
|
|
105
101
|
}
|
|
@@ -82,28 +82,11 @@
|
|
|
82
82
|
],
|
|
83
83
|
"description": "Custom params that will be passed to xcodebuild command."
|
|
84
84
|
},
|
|
85
|
-
"install": {
|
|
86
|
-
"type": "boolean",
|
|
87
|
-
"description": "Runs `pod install` for native modules before building iOS app.",
|
|
88
|
-
"default": true,
|
|
89
|
-
"x-deprecated": "Add `pod-install` to dependsOn for this target in project.json instead."
|
|
90
|
-
},
|
|
91
|
-
"sync": {
|
|
92
|
-
"type": "boolean",
|
|
93
|
-
"description": "Syncs npm dependencies to `package.json` (for React Native autolink).",
|
|
94
|
-
"x-deprecated": "Add `sync-deps` to dependsOn for this target in project.json instead.",
|
|
95
|
-
"default": true
|
|
96
|
-
},
|
|
97
85
|
"resetCache": {
|
|
98
86
|
"type": "boolean",
|
|
99
87
|
"description": "Resets metro cache.",
|
|
100
88
|
"default": false
|
|
101
89
|
},
|
|
102
|
-
"packager": {
|
|
103
|
-
"type": "boolean",
|
|
104
|
-
"description": "Launch packager while building",
|
|
105
|
-
"default": true
|
|
106
|
-
},
|
|
107
90
|
"binaryPath": {
|
|
108
91
|
"type": "string",
|
|
109
92
|
"description": "Path relative to project root where pre-built .app binary lives."
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
readProjectConfiguration,
|
|
6
6
|
} from '@nx/devkit';
|
|
7
7
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
8
|
-
import { Linter } from '@nx/
|
|
8
|
+
import { Linter } from '@nx/eslint';
|
|
9
9
|
import { reactNativeApplicationGenerator } from './application';
|
|
10
10
|
|
|
11
11
|
describe('app', () => {
|
|
@@ -18,7 +18,7 @@ describe('app', () => {
|
|
|
18
18
|
|
|
19
19
|
it('should update configuration', async () => {
|
|
20
20
|
await reactNativeApplicationGenerator(appTree, {
|
|
21
|
-
name: '
|
|
21
|
+
name: 'my-app',
|
|
22
22
|
displayName: 'myApp',
|
|
23
23
|
linter: Linter.EsLint,
|
|
24
24
|
e2eTestRunner: 'none',
|
|
@@ -32,7 +32,7 @@ describe('app', () => {
|
|
|
32
32
|
|
|
33
33
|
it('should update nx.json', async () => {
|
|
34
34
|
await reactNativeApplicationGenerator(appTree, {
|
|
35
|
-
name: '
|
|
35
|
+
name: 'my-app',
|
|
36
36
|
displayName: 'myApp',
|
|
37
37
|
tags: 'one,two',
|
|
38
38
|
linter: Linter.EsLint,
|
|
@@ -49,7 +49,7 @@ describe('app', () => {
|
|
|
49
49
|
|
|
50
50
|
it('should generate files', async () => {
|
|
51
51
|
await reactNativeApplicationGenerator(appTree, {
|
|
52
|
-
name: '
|
|
52
|
+
name: 'my-app',
|
|
53
53
|
displayName: 'myApp',
|
|
54
54
|
linter: Linter.EsLint,
|
|
55
55
|
e2eTestRunner: 'none',
|
|
@@ -82,7 +82,7 @@ describe('app', () => {
|
|
|
82
82
|
|
|
83
83
|
it('should generate targets', async () => {
|
|
84
84
|
await reactNativeApplicationGenerator(appTree, {
|
|
85
|
-
name: '
|
|
85
|
+
name: 'my-app',
|
|
86
86
|
displayName: 'myApp',
|
|
87
87
|
linter: Linter.EsLint,
|
|
88
88
|
e2eTestRunner: 'none',
|
|
@@ -97,7 +97,7 @@ describe('app', () => {
|
|
|
97
97
|
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
98
98
|
|
|
99
99
|
await reactNativeApplicationGenerator(appTree, {
|
|
100
|
-
name: '
|
|
100
|
+
name: 'my-app',
|
|
101
101
|
displayName: 'myApp',
|
|
102
102
|
linter: Linter.EsLint,
|
|
103
103
|
e2eTestRunner: 'none',
|
|
@@ -112,8 +112,8 @@ describe('app', () => {
|
|
|
112
112
|
describe('detox', () => {
|
|
113
113
|
it('should create e2e app with directory', async () => {
|
|
114
114
|
await reactNativeApplicationGenerator(appTree, {
|
|
115
|
-
name: '
|
|
116
|
-
directory: '
|
|
115
|
+
name: 'my-app',
|
|
116
|
+
directory: 'my-dir',
|
|
117
117
|
linter: Linter.EsLint,
|
|
118
118
|
e2eTestRunner: 'detox',
|
|
119
119
|
install: false,
|
|
@@ -163,7 +163,7 @@ describe('app', () => {
|
|
|
163
163
|
|
|
164
164
|
it('should create e2e app without directory', async () => {
|
|
165
165
|
await reactNativeApplicationGenerator(appTree, {
|
|
166
|
-
name: '
|
|
166
|
+
name: 'my-app',
|
|
167
167
|
linter: Linter.EsLint,
|
|
168
168
|
e2eTestRunner: 'detox',
|
|
169
169
|
install: false,
|
|
@@ -216,7 +216,7 @@ describe('app', () => {
|
|
|
216
216
|
const packageJsonBefore = readJson(appTree, 'package.json');
|
|
217
217
|
|
|
218
218
|
await reactNativeApplicationGenerator(appTree, {
|
|
219
|
-
name: '
|
|
219
|
+
name: 'my-app',
|
|
220
220
|
displayName: 'myApp',
|
|
221
221
|
linter: Linter.EsLint,
|
|
222
222
|
e2eTestRunner: 'none',
|
|
@@ -19,7 +19,7 @@ const customConfig = {
|
|
|
19
19
|
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
20
20
|
sourceExts: [...sourceExts, 'svg'],
|
|
21
21
|
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
|
|
22
|
-
unstable_enableSymlinks: true,
|
|
22
|
+
// unstable_enableSymlinks: true,
|
|
23
23
|
// unstable_enablePackageExports: true,
|
|
24
24
|
},
|
|
25
25
|
};
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addDetox = void 0;
|
|
4
4
|
const detox_1 = require("@nx/detox");
|
|
5
|
-
const
|
|
5
|
+
const eslint_1 = require("@nx/eslint");
|
|
6
6
|
async function addDetox(host, options) {
|
|
7
7
|
if (options?.e2eTestRunner !== 'detox') {
|
|
8
8
|
return () => { };
|
|
9
9
|
}
|
|
10
10
|
return (0, detox_1.detoxApplicationGenerator)(host, {
|
|
11
11
|
...options,
|
|
12
|
-
linter:
|
|
12
|
+
linter: eslint_1.Linter.EsLint,
|
|
13
13
|
e2eName: `${options.projectName}-e2e`,
|
|
14
14
|
e2eDirectory: `${options.appProjectRoot}-e2e`,
|
|
15
15
|
projectNameAndRootFormat: 'as-provided',
|
package/src/generators/application/lib/{nomalize-options.spec.ts → normalize-options.spec.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import { Linter } from '@nx/
|
|
3
|
+
import { Linter } from '@nx/eslint';
|
|
4
4
|
import { Schema } from '../schema';
|
|
5
5
|
import { normalizeOptions } from './normalize-options';
|
|
6
6
|
|
|
@@ -48,15 +48,15 @@ describe('Normalize Options', () => {
|
|
|
48
48
|
};
|
|
49
49
|
const options = await normalizeOptions(appTree, schema);
|
|
50
50
|
expect(options).toEqual({
|
|
51
|
-
androidProjectRoot: '
|
|
52
|
-
appProjectRoot: '
|
|
51
|
+
androidProjectRoot: 'myApp/android',
|
|
52
|
+
appProjectRoot: 'myApp',
|
|
53
53
|
className: 'MyApp',
|
|
54
54
|
displayName: 'MyApp',
|
|
55
|
-
iosProjectRoot: '
|
|
55
|
+
iosProjectRoot: 'myApp/ios',
|
|
56
56
|
lowerCaseName: 'myapp',
|
|
57
|
-
name: '
|
|
57
|
+
name: 'myApp',
|
|
58
58
|
parsedTags: [],
|
|
59
|
-
projectName: '
|
|
59
|
+
projectName: 'myApp',
|
|
60
60
|
projectNameAndRootFormat: 'as-provided',
|
|
61
61
|
entryFile: 'src/main.tsx',
|
|
62
62
|
e2eTestRunner: 'none',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from './schema';
|
|
2
2
|
import { Tree } from '@nx/devkit';
|
|
3
3
|
export declare function reactNativeComponentGenerator(host: Tree, schema: Schema): Promise<void>;
|
|
4
|
+
export declare function reactNativeComponentGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
|
|
4
5
|
export default reactNativeComponentGenerator;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reactNativeComponentGenerator = void 0;
|
|
3
|
+
exports.reactNativeComponentGeneratorInternal = exports.reactNativeComponentGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
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
9
|
async function reactNativeComponentGenerator(host, schema) {
|
|
10
|
+
return reactNativeComponentGeneratorInternal(host, {
|
|
11
|
+
nameAndDirectoryFormat: 'derived',
|
|
12
|
+
...schema,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.reactNativeComponentGenerator = reactNativeComponentGenerator;
|
|
16
|
+
async function reactNativeComponentGeneratorInternal(host, schema) {
|
|
10
17
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
11
18
|
createComponentFiles(host, options);
|
|
12
19
|
addExportsToBarrel(host, options);
|
|
13
20
|
await (0, devkit_1.formatFiles)(host);
|
|
14
21
|
}
|
|
15
|
-
exports.
|
|
22
|
+
exports.reactNativeComponentGeneratorInternal = reactNativeComponentGeneratorInternal;
|
|
16
23
|
function createComponentFiles(host, options) {
|
|
17
|
-
|
|
18
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, {
|
|
24
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.directory, {
|
|
19
25
|
...options,
|
|
20
26
|
tmpl: '',
|
|
21
27
|
});
|
|
@@ -44,9 +50,15 @@ function addExportsToBarrel(host, options) {
|
|
|
44
50
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
45
51
|
if (indexSource !== null) {
|
|
46
52
|
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
47
|
-
const
|
|
53
|
+
const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
|
|
54
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, add_import_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
|
|
48
55
|
host.write(indexFilePath, changes);
|
|
49
56
|
}
|
|
50
57
|
}
|
|
51
58
|
}
|
|
59
|
+
function getRelativeImportToFile(indexPath, filePath) {
|
|
60
|
+
const { name, dir } = (0, path_1.parse)(filePath);
|
|
61
|
+
const relativeDirToTarget = (0, path_1.relative)((0, path_1.dirname)(indexPath), dir);
|
|
62
|
+
return `./${(0, devkit_1.joinPathFragments)(relativeDirToTarget, name)}`;
|
|
63
|
+
}
|
|
52
64
|
exports.default = reactNativeComponentGenerator;
|
|
@@ -2,17 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
6
|
async function normalizeOptions(host, options) {
|
|
6
7
|
assertValidOptions(options);
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
9
|
+
artifactType: 'component',
|
|
10
|
+
callingGenerator: '@nx/react-native:component',
|
|
11
|
+
name: options.name,
|
|
12
|
+
directory: options.directory,
|
|
13
|
+
derivedDirectory: options.directory,
|
|
14
|
+
flat: options.flat,
|
|
15
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
16
|
+
project: options.project,
|
|
17
|
+
fileExtension: 'tsx',
|
|
18
|
+
pascalCaseFile: options.pascalCaseFiles,
|
|
19
|
+
});
|
|
20
|
+
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
21
|
+
const { className } = (0, devkit_1.names)(name);
|
|
14
22
|
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
15
|
-
const directory = await getDirectory(host, options);
|
|
16
23
|
if (options.export && projectType === 'application') {
|
|
17
24
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
|
18
25
|
}
|
|
@@ -21,26 +28,12 @@ async function normalizeOptions(host, options) {
|
|
|
21
28
|
...options,
|
|
22
29
|
directory,
|
|
23
30
|
className,
|
|
24
|
-
fileName
|
|
31
|
+
fileName,
|
|
32
|
+
filePath,
|
|
25
33
|
projectSourceRoot,
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
36
|
exports.normalizeOptions = normalizeOptions;
|
|
29
|
-
async function getDirectory(host, options) {
|
|
30
|
-
const fileName = (0, devkit_1.names)(options.name).fileName;
|
|
31
|
-
const workspace = (0, devkit_1.getProjects)(host);
|
|
32
|
-
let baseDir;
|
|
33
|
-
if (options.directory) {
|
|
34
|
-
baseDir = options.directory;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
baseDir =
|
|
38
|
-
workspace.get(options.project).projectType === 'application'
|
|
39
|
-
? 'app'
|
|
40
|
-
: 'lib';
|
|
41
|
-
}
|
|
42
|
-
return options.flat ? baseDir : (0, devkit_1.joinPathFragments)(baseDir, fileName);
|
|
43
|
-
}
|
|
44
37
|
function assertValidOptions(options) {
|
|
45
38
|
const slashes = ['/', '\\'];
|
|
46
39
|
slashes.forEach((s) => {
|
|
@@ -3,12 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface Schema {
|
|
5
5
|
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
8
|
+
*/
|
|
6
9
|
project: string;
|
|
7
10
|
skipTests?: boolean;
|
|
8
11
|
directory?: string;
|
|
9
12
|
export?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
|
|
15
|
+
*/
|
|
10
16
|
pascalCaseFiles?: boolean;
|
|
11
17
|
classComponent?: boolean;
|
|
12
18
|
js?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
|
|
21
|
+
*/
|
|
13
22
|
flat?: boolean;
|
|
23
|
+
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
14
24
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"$default": {
|
|
24
24
|
"$source": "projectName"
|
|
25
25
|
},
|
|
26
|
-
"x-
|
|
26
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v18."
|
|
27
27
|
},
|
|
28
28
|
"name": {
|
|
29
29
|
"type": "string",
|
|
@@ -46,13 +46,19 @@
|
|
|
46
46
|
},
|
|
47
47
|
"directory": {
|
|
48
48
|
"type": "string",
|
|
49
|
-
"description": "
|
|
49
|
+
"description": "The directory at which to create the component file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.",
|
|
50
50
|
"x-priority": "important"
|
|
51
51
|
},
|
|
52
|
+
"nameAndDirectoryFormat": {
|
|
53
|
+
"description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
|
|
54
|
+
"type": "string",
|
|
55
|
+
"enum": ["as-provided", "derived"]
|
|
56
|
+
},
|
|
52
57
|
"flat": {
|
|
53
58
|
"type": "boolean",
|
|
54
59
|
"description": "Create component at the source root rather than its own directory.",
|
|
55
|
-
"default": false
|
|
60
|
+
"default": false,
|
|
61
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18."
|
|
56
62
|
},
|
|
57
63
|
"export": {
|
|
58
64
|
"type": "boolean",
|
|
@@ -65,7 +71,8 @@
|
|
|
65
71
|
"type": "boolean",
|
|
66
72
|
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
67
73
|
"alias": "P",
|
|
68
|
-
"default": false
|
|
74
|
+
"default": false,
|
|
75
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
|
|
69
76
|
},
|
|
70
77
|
"classComponent": {
|
|
71
78
|
"type": "boolean",
|
|
@@ -74,5 +81,5 @@
|
|
|
74
81
|
"default": false
|
|
75
82
|
}
|
|
76
83
|
},
|
|
77
|
-
"required": ["name"
|
|
84
|
+
"required": ["name"]
|
|
78
85
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getProjects, Tree, updateProjectConfiguration } from '@nx/devkit';
|
|
2
2
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
3
|
import componentStoryGenerator from './component-story';
|
|
4
|
-
import { Linter } from '@nx/
|
|
4
|
+
import { Linter } from '@nx/eslint';
|
|
5
5
|
|
|
6
6
|
import { formatFile } from '../../utils/format-file';
|
|
7
7
|
import libraryGenerator from '../library/library';
|
|
@@ -75,9 +75,9 @@ describe('react-native:component-story', () => {
|
|
|
75
75
|
appTree.write(
|
|
76
76
|
'test-ui-lib/src/lib/test-ui-libplain.jsx',
|
|
77
77
|
`import React from 'react';
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
import './test.scss';
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
export const Test = () => {
|
|
82
82
|
return (
|
|
83
83
|
<div>
|
|
@@ -85,8 +85,8 @@ describe('react-native:component-story', () => {
|
|
|
85
85
|
</div>
|
|
86
86
|
);
|
|
87
87
|
};
|
|
88
|
-
|
|
89
|
-
export default Test;
|
|
88
|
+
|
|
89
|
+
export default Test;
|
|
90
90
|
`
|
|
91
91
|
);
|
|
92
92
|
|
|
@@ -117,7 +117,7 @@ describe('react-native:component-story', () => {
|
|
|
117
117
|
`import React from 'react';
|
|
118
118
|
|
|
119
119
|
import { View, Text } from 'react-native';
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
export function Test() {
|
|
122
122
|
return (
|
|
123
123
|
<View>
|
|
@@ -125,8 +125,8 @@ describe('react-native:component-story', () => {
|
|
|
125
125
|
</View>
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
export default Test;
|
|
128
|
+
|
|
129
|
+
export default Test;
|
|
130
130
|
`
|
|
131
131
|
);
|
|
132
132
|
await componentStoryGenerator(appTree, {
|
|
@@ -178,14 +178,14 @@ describe('react-native:component-story', () => {
|
|
|
178
178
|
`import React from 'react';
|
|
179
179
|
|
|
180
180
|
export type ButtonStyle = 'default' | 'primary' | 'warning';
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
export interface TestProps {
|
|
183
183
|
name: string;
|
|
184
184
|
displayAge: boolean;
|
|
185
185
|
someAction: (e: unknown) => void;
|
|
186
186
|
style: ButtonStyle;
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
|
|
189
189
|
export const Test = (props: TestProps) => {
|
|
190
190
|
return (
|
|
191
191
|
<div>
|
|
@@ -194,8 +194,8 @@ describe('react-native:component-story', () => {
|
|
|
194
194
|
</div>
|
|
195
195
|
);
|
|
196
196
|
};
|
|
197
|
-
|
|
198
|
-
export default Test;
|
|
197
|
+
|
|
198
|
+
export default Test;
|
|
199
199
|
`
|
|
200
200
|
);
|
|
201
201
|
|
|
@@ -337,12 +337,12 @@ describe('react-native:component-story', () => {
|
|
|
337
337
|
appTree.write(
|
|
338
338
|
cmpPath,
|
|
339
339
|
`import React from 'react';
|
|
340
|
-
|
|
340
|
+
|
|
341
341
|
export interface TestProps {
|
|
342
342
|
name: string;
|
|
343
343
|
displayAge: boolean;
|
|
344
344
|
}
|
|
345
|
-
|
|
345
|
+
|
|
346
346
|
${config.src}
|
|
347
347
|
`
|
|
348
348
|
);
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
} from '@nx/devkit';
|
|
7
7
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
8
8
|
import libraryGenerator from './library';
|
|
9
|
-
import { Linter } from '@nx/
|
|
9
|
+
import { Linter } from '@nx/eslint';
|
|
10
10
|
import { Schema } from './schema';
|
|
11
11
|
|
|
12
12
|
describe('lib', () => {
|
|
13
13
|
let appTree: Tree;
|
|
14
14
|
|
|
15
15
|
const defaultSchema: Schema = {
|
|
16
|
-
name: '
|
|
16
|
+
name: 'my-lib',
|
|
17
17
|
linter: Linter.EsLint,
|
|
18
18
|
skipFormat: false,
|
|
19
19
|
skipTsConfig: false,
|
|
@@ -34,7 +34,7 @@ describe('lib', () => {
|
|
|
34
34
|
expect(projectConfiguration.root).toEqual('my-lib');
|
|
35
35
|
expect(projectConfiguration.targets.build).toBeUndefined();
|
|
36
36
|
expect(projectConfiguration.targets.lint).toEqual({
|
|
37
|
-
executor: '@nx/
|
|
37
|
+
executor: '@nx/eslint:lint',
|
|
38
38
|
outputs: ['{options.outputFile}'],
|
|
39
39
|
options: {
|
|
40
40
|
lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'],
|
|
@@ -124,7 +124,7 @@ describe('lib', () => {
|
|
|
124
124
|
it('should update nx.json', async () => {
|
|
125
125
|
await libraryGenerator(appTree, {
|
|
126
126
|
...defaultSchema,
|
|
127
|
-
directory: '
|
|
127
|
+
directory: 'my-dir',
|
|
128
128
|
tags: 'one',
|
|
129
129
|
});
|
|
130
130
|
|
|
@@ -135,8 +135,8 @@ describe('lib', () => {
|
|
|
135
135
|
|
|
136
136
|
await libraryGenerator(appTree, {
|
|
137
137
|
...defaultSchema,
|
|
138
|
-
name: '
|
|
139
|
-
directory: '
|
|
138
|
+
name: 'my-lib2',
|
|
139
|
+
directory: 'my-dir2',
|
|
140
140
|
tags: 'one,two',
|
|
141
141
|
});
|
|
142
142
|
|
|
@@ -150,12 +150,15 @@ describe('lib', () => {
|
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
it('should update project.json', async () => {
|
|
153
|
-
await libraryGenerator(appTree, {
|
|
153
|
+
await libraryGenerator(appTree, {
|
|
154
|
+
...defaultSchema,
|
|
155
|
+
directory: 'my-dir',
|
|
156
|
+
});
|
|
154
157
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
155
158
|
|
|
156
159
|
expect(projectConfiguration.root).toEqual('my-dir');
|
|
157
160
|
expect(projectConfiguration.targets.lint).toEqual({
|
|
158
|
-
executor: '@nx/
|
|
161
|
+
executor: '@nx/eslint:lint',
|
|
159
162
|
outputs: ['{options.outputFile}'],
|
|
160
163
|
options: {
|
|
161
164
|
lintFilePatterns: ['my-dir/**/*.{ts,tsx,js,jsx}'],
|
|
@@ -164,7 +167,10 @@ describe('lib', () => {
|
|
|
164
167
|
});
|
|
165
168
|
|
|
166
169
|
it('should update root tsconfig.base.json', async () => {
|
|
167
|
-
await libraryGenerator(appTree, {
|
|
170
|
+
await libraryGenerator(appTree, {
|
|
171
|
+
...defaultSchema,
|
|
172
|
+
directory: 'my-dir',
|
|
173
|
+
});
|
|
168
174
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
169
175
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
170
176
|
'my-dir/src/index.ts',
|
|
@@ -177,7 +183,10 @@ describe('lib', () => {
|
|
|
177
183
|
it('should update root tsconfig.json when no tsconfig.base.json', async () => {
|
|
178
184
|
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
179
185
|
|
|
180
|
-
await libraryGenerator(appTree, {
|
|
186
|
+
await libraryGenerator(appTree, {
|
|
187
|
+
...defaultSchema,
|
|
188
|
+
directory: 'my-dir',
|
|
189
|
+
});
|
|
181
190
|
|
|
182
191
|
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
183
192
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
@@ -189,7 +198,10 @@ describe('lib', () => {
|
|
|
189
198
|
});
|
|
190
199
|
|
|
191
200
|
it('should create a local tsconfig.json', async () => {
|
|
192
|
-
await libraryGenerator(appTree, {
|
|
201
|
+
await libraryGenerator(appTree, {
|
|
202
|
+
...defaultSchema,
|
|
203
|
+
directory: 'my-dir',
|
|
204
|
+
});
|
|
193
205
|
|
|
194
206
|
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
195
207
|
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
@@ -206,7 +218,10 @@ describe('lib', () => {
|
|
|
206
218
|
it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
|
|
207
219
|
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
208
220
|
|
|
209
|
-
await libraryGenerator(appTree, {
|
|
221
|
+
await libraryGenerator(appTree, {
|
|
222
|
+
...defaultSchema,
|
|
223
|
+
directory: 'my-dir',
|
|
224
|
+
});
|
|
210
225
|
|
|
211
226
|
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
212
227
|
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
@@ -225,7 +240,7 @@ describe('lib', () => {
|
|
|
225
240
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
226
241
|
expect(projectConfiguration.targets.test).toBeUndefined();
|
|
227
242
|
expect(projectConfiguration.targets.lint).toMatchObject({
|
|
228
|
-
executor: '@nx/
|
|
243
|
+
executor: '@nx/eslint:lint',
|
|
229
244
|
options: {
|
|
230
245
|
lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'],
|
|
231
246
|
},
|
|
@@ -343,7 +358,7 @@ describe('lib', () => {
|
|
|
343
358
|
try {
|
|
344
359
|
await libraryGenerator(appTree, {
|
|
345
360
|
...defaultSchema,
|
|
346
|
-
directory: '
|
|
361
|
+
directory: 'my-dir',
|
|
347
362
|
publishable: true,
|
|
348
363
|
});
|
|
349
364
|
} catch (e) {
|
|
@@ -382,7 +397,7 @@ describe('lib', () => {
|
|
|
382
397
|
await libraryGenerator(appTree, {
|
|
383
398
|
...defaultSchema,
|
|
384
399
|
publishable: true,
|
|
385
|
-
directory: '
|
|
400
|
+
directory: 'my-dir',
|
|
386
401
|
importPath: '@myorg/lib',
|
|
387
402
|
});
|
|
388
403
|
const packageJson = readJson(appTree, 'my-dir/package.json');
|
|
@@ -397,7 +412,7 @@ describe('lib', () => {
|
|
|
397
412
|
it('should fail if the same importPath has already been used', async () => {
|
|
398
413
|
await libraryGenerator(appTree, {
|
|
399
414
|
...defaultSchema,
|
|
400
|
-
name: '
|
|
415
|
+
name: 'my-lib1',
|
|
401
416
|
publishable: true,
|
|
402
417
|
importPath: '@myorg/lib',
|
|
403
418
|
});
|
|
@@ -405,7 +420,7 @@ describe('lib', () => {
|
|
|
405
420
|
try {
|
|
406
421
|
await libraryGenerator(appTree, {
|
|
407
422
|
...defaultSchema,
|
|
408
|
-
name: '
|
|
423
|
+
name: 'my-lib2',
|
|
409
424
|
publishable: true,
|
|
410
425
|
importPath: '@myorg/lib',
|
|
411
426
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
-
import type { Linter } from '@nx/
|
|
2
|
+
import type { Linter } from '@nx/eslint';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Same as the @nx/react library schema, except it removes keys: style, component, routing, appProject
|
|
@@ -2,7 +2,7 @@ import { Tree } from '@nx/devkit';
|
|
|
2
2
|
import storiesGenerator from './stories';
|
|
3
3
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
4
4
|
import applicationGenerator from '../application/application';
|
|
5
|
-
import { Linter } from '@nx/
|
|
5
|
+
import { Linter } from '@nx/eslint';
|
|
6
6
|
import { reactNativeComponentGenerator } from '../component/component';
|
|
7
7
|
|
|
8
8
|
describe('react:stories for applications', () => {
|
|
@@ -2,7 +2,7 @@ import { Tree } from '@nx/devkit';
|
|
|
2
2
|
import storiesGenerator from './stories';
|
|
3
3
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
4
4
|
import applicationGenerator from '../application/application';
|
|
5
|
-
import { Linter } from '@nx/
|
|
5
|
+
import { Linter } from '@nx/eslint';
|
|
6
6
|
import libraryGenerator from '../library/library';
|
|
7
7
|
import reactNativeComponentGenerator from '../component/component';
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import { Linter } from '@nx/
|
|
3
|
+
import { Linter } from '@nx/eslint';
|
|
4
4
|
import { logger } from '@nx/devkit';
|
|
5
5
|
|
|
6
6
|
import libraryGenerator from '../library/library';
|
package/src/utils/add-linting.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLinting = void 0;
|
|
4
|
-
const
|
|
4
|
+
const eslint_1 = require("@nx/eslint");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const lint_1 = require("@nx/react/src/utils/lint");
|
|
7
|
-
const eslint_file_1 = require("@nx/
|
|
7
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
8
8
|
async function addLinting(host, options) {
|
|
9
|
-
if (options.linter ===
|
|
9
|
+
if (options.linter === eslint_1.Linter.None) {
|
|
10
10
|
return () => { };
|
|
11
11
|
}
|
|
12
12
|
const tasks = [];
|
|
13
|
-
const lintTask = await (0,
|
|
13
|
+
const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
|
|
14
14
|
linter: options.linter,
|
|
15
15
|
project: options.projectName,
|
|
16
16
|
tsConfigPaths: options.tsConfigPaths,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import { Linter } from '@nx/
|
|
3
|
+
import { Linter } from '@nx/eslint';
|
|
4
4
|
import { libraryGenerator } from '@nx/js';
|
|
5
5
|
import { addLinting } from './add-linting';
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ describe('Add Linting', () => {
|
|
|
25
25
|
const project = readProjectConfiguration(tree, 'my-lib');
|
|
26
26
|
|
|
27
27
|
expect(project.targets.lint).toBeDefined();
|
|
28
|
-
expect(project.targets.lint.executor).toEqual('@nx/
|
|
28
|
+
expect(project.targets.lint.executor).toEqual('@nx/eslint:lint');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it('should not add lint target when "none" is passed', async () => {
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createLib = exports.createApp = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const application_1 = require("../generators/application/application");
|
|
6
|
-
const
|
|
6
|
+
const eslint_1 = require("@nx/eslint");
|
|
7
7
|
async function createApp(tree, appName) {
|
|
8
8
|
await (0, application_1.default)(tree, {
|
|
9
|
-
linter:
|
|
9
|
+
linter: eslint_1.Linter.EsLint,
|
|
10
10
|
skipFormat: true,
|
|
11
11
|
style: 'css',
|
|
12
12
|
unitTestRunner: 'none',
|