@nx/react-native 16.8.0-beta.1 → 16.8.0-beta.3
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 +2 -2
- package/package.json +10 -10
- package/src/generators/application/application.d.ts +1 -0
- package/src/generators/application/application.js +9 -3
- package/src/generators/application/lib/add-detox.js +1 -1
- package/src/generators/application/lib/add-project.js +1 -1
- package/src/generators/application/lib/nomalize-options.spec.ts +15 -10
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +24 -27
- package/src/generators/application/schema.d.ts +3 -1
- package/src/generators/application/schema.json +7 -1
- package/src/generators/component/component.js +2 -1
- package/src/generators/library/lib/normalize-options.d.ts +1 -2
- package/src/generators/library/lib/normalize-options.js +19 -19
- package/src/generators/library/library.d.ts +1 -0
- package/src/generators/library/library.js +10 -5
- package/src/generators/library/schema.d.ts +3 -1
- package/src/generators/library/schema.json +6 -1
- package/src/utils/add-linting.js +6 -7
package/generators.json
CHANGED
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"hidden": true
|
|
63
63
|
},
|
|
64
64
|
"application": {
|
|
65
|
-
"factory": "./src/generators/application/application#
|
|
65
|
+
"factory": "./src/generators/application/application#reactNativeApplicationGeneratorInternal",
|
|
66
66
|
"schema": "./src/generators/application/schema.json",
|
|
67
67
|
"aliases": ["app"],
|
|
68
68
|
"x-type": "application",
|
|
69
69
|
"description": "Create a React Native application."
|
|
70
70
|
},
|
|
71
71
|
"library": {
|
|
72
|
-
"factory": "./src/generators/library/library#
|
|
72
|
+
"factory": "./src/generators/library/library#reactNativeLibraryGeneratorInternal",
|
|
73
73
|
"schema": "./src/generators/library/schema.json",
|
|
74
74
|
"aliases": ["lib"],
|
|
75
75
|
"x-type": "library",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "16.8.0-beta.
|
|
3
|
+
"version": "16.8.0-beta.3",
|
|
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,14 +25,14 @@
|
|
|
25
25
|
"main": "./index.js",
|
|
26
26
|
"types": "index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@nrwl/react-native": "16.8.0-beta.
|
|
29
|
-
"@nx/detox": "16.8.0-beta.
|
|
30
|
-
"@nx/devkit": "16.8.0-beta.
|
|
31
|
-
"@nx/jest": "16.8.0-beta.
|
|
32
|
-
"@nx/js": "16.8.0-beta.
|
|
33
|
-
"@nx/linter": "16.8.0-beta.
|
|
34
|
-
"@nx/react": "16.8.0-beta.
|
|
35
|
-
"@nx/workspace": "16.8.0-beta.
|
|
28
|
+
"@nrwl/react-native": "16.8.0-beta.3",
|
|
29
|
+
"@nx/detox": "16.8.0-beta.3",
|
|
30
|
+
"@nx/devkit": "16.8.0-beta.3",
|
|
31
|
+
"@nx/jest": "16.8.0-beta.3",
|
|
32
|
+
"@nx/js": "16.8.0-beta.3",
|
|
33
|
+
"@nx/linter": "16.8.0-beta.3",
|
|
34
|
+
"@nx/react": "16.8.0-beta.3",
|
|
35
|
+
"@nx/workspace": "16.8.0-beta.3",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
37
|
"enhanced-resolve": "^5.8.3",
|
|
38
38
|
"fs-extra": "^11.1.0",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"type": "commonjs",
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "dcd48165a485bc8db57a1fb02b96a0772de3b7e9"
|
|
62
62
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function reactNativeApplicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function reactNativeApplicationGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default reactNativeApplicationGenerator;
|
|
5
6
|
export declare const reactNativeApplicationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reactNativeApplicationSchematic = exports.reactNativeApplicationGenerator = void 0;
|
|
3
|
+
exports.reactNativeApplicationSchematic = exports.reactNativeApplicationGeneratorInternal = exports.reactNativeApplicationGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const symlink_task_1 = require("../../utils/symlink-task");
|
|
@@ -14,7 +14,13 @@ const create_application_files_1 = require("./lib/create-application-files");
|
|
|
14
14
|
const add_detox_1 = require("./lib/add-detox");
|
|
15
15
|
function reactNativeApplicationGenerator(host, schema) {
|
|
16
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
|
|
17
|
+
return yield reactNativeApplicationGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.reactNativeApplicationGenerator = reactNativeApplicationGenerator;
|
|
21
|
+
function reactNativeApplicationGeneratorInternal(host, schema) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
18
24
|
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
19
25
|
(0, add_project_1.addProject)(host, options);
|
|
20
26
|
const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
|
|
@@ -31,6 +37,6 @@ function reactNativeApplicationGenerator(host, schema) {
|
|
|
31
37
|
return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask, chmodTaskGradlew);
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
|
-
exports.
|
|
40
|
+
exports.reactNativeApplicationGeneratorInternal = reactNativeApplicationGeneratorInternal;
|
|
35
41
|
exports.default = reactNativeApplicationGenerator;
|
|
36
42
|
exports.reactNativeApplicationSchematic = (0, devkit_1.convertNxGenerator)(reactNativeApplicationGenerator);
|
|
@@ -9,7 +9,7 @@ function addDetox(host, options) {
|
|
|
9
9
|
if ((options === null || options === void 0 ? void 0 : options.e2eTestRunner) !== 'detox') {
|
|
10
10
|
return () => { };
|
|
11
11
|
}
|
|
12
|
-
return (0, detox_1.detoxApplicationGenerator)(host, Object.assign(Object.assign({}, options), { linter: linter_1.Linter.EsLint, e2eName: `${options.
|
|
12
|
+
return (0, detox_1.detoxApplicationGenerator)(host, Object.assign(Object.assign({}, options), { linter: linter_1.Linter.EsLint, e2eName: `${options.projectName}-e2e`, e2eDirectory: `${options.appProjectRoot}-e2e`, projectNameAndRootFormat: 'as-provided', appProject: options.projectName, appDisplayName: options.displayName, appName: options.name, framework: 'react-native', skipFormat: true }));
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
exports.addDetox = addDetox;
|
|
@@ -11,14 +11,14 @@ describe('Normalize Options', () => {
|
|
|
11
11
|
appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
it('should normalize options with name in kebab case', () => {
|
|
14
|
+
it('should normalize options with name in kebab case', async () => {
|
|
15
15
|
const schema: Schema = {
|
|
16
16
|
name: 'my-app',
|
|
17
17
|
linter: Linter.EsLint,
|
|
18
18
|
e2eTestRunner: 'none',
|
|
19
19
|
install: false,
|
|
20
20
|
};
|
|
21
|
-
const options = normalizeOptions(appTree, schema);
|
|
21
|
+
const options = await normalizeOptions(appTree, schema);
|
|
22
22
|
expect(options).toEqual({
|
|
23
23
|
androidProjectRoot: 'apps/my-app/android',
|
|
24
24
|
appProjectRoot: 'apps/my-app',
|
|
@@ -29,6 +29,7 @@ describe('Normalize Options', () => {
|
|
|
29
29
|
name: 'my-app',
|
|
30
30
|
parsedTags: [],
|
|
31
31
|
projectName: 'my-app',
|
|
32
|
+
projectNameAndRootFormat: 'derived',
|
|
32
33
|
linter: Linter.EsLint,
|
|
33
34
|
entryFile: 'src/main.tsx',
|
|
34
35
|
e2eTestRunner: 'none',
|
|
@@ -37,13 +38,13 @@ describe('Normalize Options', () => {
|
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
it('should normalize options with name in camel case', () => {
|
|
41
|
+
it('should normalize options with name in camel case', async () => {
|
|
41
42
|
const schema: Schema = {
|
|
42
43
|
name: 'myApp',
|
|
43
44
|
e2eTestRunner: 'none',
|
|
44
45
|
install: false,
|
|
45
46
|
};
|
|
46
|
-
const options = normalizeOptions(appTree, schema);
|
|
47
|
+
const options = await normalizeOptions(appTree, schema);
|
|
47
48
|
expect(options).toEqual({
|
|
48
49
|
androidProjectRoot: 'apps/my-app/android',
|
|
49
50
|
appProjectRoot: 'apps/my-app',
|
|
@@ -54,6 +55,7 @@ describe('Normalize Options', () => {
|
|
|
54
55
|
name: 'my-app',
|
|
55
56
|
parsedTags: [],
|
|
56
57
|
projectName: 'my-app',
|
|
58
|
+
projectNameAndRootFormat: 'derived',
|
|
57
59
|
entryFile: 'src/main.tsx',
|
|
58
60
|
e2eTestRunner: 'none',
|
|
59
61
|
unitTestRunner: 'jest',
|
|
@@ -61,14 +63,14 @@ describe('Normalize Options', () => {
|
|
|
61
63
|
});
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
it('should normalize options with directory', () => {
|
|
66
|
+
it('should normalize options with directory', async () => {
|
|
65
67
|
const schema: Schema = {
|
|
66
68
|
name: 'my-app',
|
|
67
69
|
directory: 'directory',
|
|
68
70
|
e2eTestRunner: 'none',
|
|
69
71
|
install: false,
|
|
70
72
|
};
|
|
71
|
-
const options = normalizeOptions(appTree, schema);
|
|
73
|
+
const options = await normalizeOptions(appTree, schema);
|
|
72
74
|
expect(options).toEqual({
|
|
73
75
|
androidProjectRoot: 'apps/directory/my-app/android',
|
|
74
76
|
appProjectRoot: 'apps/directory/my-app',
|
|
@@ -80,6 +82,7 @@ describe('Normalize Options', () => {
|
|
|
80
82
|
directory: 'directory',
|
|
81
83
|
parsedTags: [],
|
|
82
84
|
projectName: 'directory-my-app',
|
|
85
|
+
projectNameAndRootFormat: 'derived',
|
|
83
86
|
entryFile: 'src/main.tsx',
|
|
84
87
|
e2eTestRunner: 'none',
|
|
85
88
|
unitTestRunner: 'jest',
|
|
@@ -87,13 +90,13 @@ describe('Normalize Options', () => {
|
|
|
87
90
|
});
|
|
88
91
|
});
|
|
89
92
|
|
|
90
|
-
it('should normalize options that has directory in its name', () => {
|
|
93
|
+
it('should normalize options that has directory in its name', async () => {
|
|
91
94
|
const schema: Schema = {
|
|
92
95
|
name: 'directory/my-app',
|
|
93
96
|
e2eTestRunner: 'none',
|
|
94
97
|
install: false,
|
|
95
98
|
};
|
|
96
|
-
const options = normalizeOptions(appTree, schema);
|
|
99
|
+
const options = await normalizeOptions(appTree, schema);
|
|
97
100
|
expect(options).toEqual({
|
|
98
101
|
androidProjectRoot: 'apps/directory/my-app/android',
|
|
99
102
|
appProjectRoot: 'apps/directory/my-app',
|
|
@@ -104,6 +107,7 @@ describe('Normalize Options', () => {
|
|
|
104
107
|
name: 'directory/my-app',
|
|
105
108
|
parsedTags: [],
|
|
106
109
|
projectName: 'directory-my-app',
|
|
110
|
+
projectNameAndRootFormat: 'derived',
|
|
107
111
|
entryFile: 'src/main.tsx',
|
|
108
112
|
e2eTestRunner: 'none',
|
|
109
113
|
unitTestRunner: 'jest',
|
|
@@ -111,14 +115,14 @@ describe('Normalize Options', () => {
|
|
|
111
115
|
});
|
|
112
116
|
});
|
|
113
117
|
|
|
114
|
-
it('should normalize options with display name', () => {
|
|
118
|
+
it('should normalize options with display name', async () => {
|
|
115
119
|
const schema: Schema = {
|
|
116
120
|
name: 'my-app',
|
|
117
121
|
displayName: 'My App',
|
|
118
122
|
e2eTestRunner: 'none',
|
|
119
123
|
install: false,
|
|
120
124
|
};
|
|
121
|
-
const options = normalizeOptions(appTree, schema);
|
|
125
|
+
const options = await normalizeOptions(appTree, schema);
|
|
122
126
|
expect(options).toEqual({
|
|
123
127
|
androidProjectRoot: 'apps/my-app/android',
|
|
124
128
|
appProjectRoot: 'apps/my-app',
|
|
@@ -129,6 +133,7 @@ describe('Normalize Options', () => {
|
|
|
129
133
|
name: 'my-app',
|
|
130
134
|
parsedTags: [],
|
|
131
135
|
projectName: 'my-app',
|
|
136
|
+
projectNameAndRootFormat: 'derived',
|
|
132
137
|
entryFile: 'src/main.tsx',
|
|
133
138
|
e2eTestRunner: 'none',
|
|
134
139
|
unitTestRunner: 'jest',
|
|
@@ -10,4 +10,4 @@ export interface NormalizedSchema extends Schema {
|
|
|
10
10
|
parsedTags: string[];
|
|
11
11
|
entryFile: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function normalizeOptions(host: Tree, options: Schema): NormalizedSchema
|
|
13
|
+
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
5
7
|
function normalizeOptions(host, options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return Object.assign(Object.assign({}, options), { unitTestRunner: options.unitTestRunner || 'jest', e2eTestRunner: options.e2eTestRunner || 'detox', name: fileName, className, lowerCaseName: className.toLowerCase(), displayName: options.displayName || className, projectName: appProjectName, appProjectRoot,
|
|
29
|
-
iosProjectRoot,
|
|
30
|
-
androidProjectRoot,
|
|
31
|
-
parsedTags,
|
|
32
|
-
entryFile });
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
10
|
+
name: options.name,
|
|
11
|
+
projectType: 'application',
|
|
12
|
+
directory: options.directory,
|
|
13
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
|
+
callingGenerator: '@nx/react-native:application',
|
|
15
|
+
});
|
|
16
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
17
|
+
const { className } = (0, devkit_1.names)(options.name);
|
|
18
|
+
const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
|
|
19
|
+
const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
|
|
20
|
+
const parsedTags = options.tags
|
|
21
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
22
|
+
: [];
|
|
23
|
+
const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
|
|
24
|
+
return Object.assign(Object.assign({}, options), { unitTestRunner: options.unitTestRunner || 'jest', e2eTestRunner: options.e2eTestRunner || 'detox', name: projectNames.projectSimpleName, className, lowerCaseName: className.toLowerCase(), displayName: options.displayName || className, projectName: appProjectName, appProjectRoot,
|
|
25
|
+
iosProjectRoot,
|
|
26
|
+
androidProjectRoot,
|
|
27
|
+
parsedTags,
|
|
28
|
+
entryFile });
|
|
29
|
+
});
|
|
33
30
|
}
|
|
34
31
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/linter';
|
|
2
3
|
|
|
3
4
|
export interface Schema {
|
|
4
5
|
name: string;
|
|
@@ -6,6 +7,7 @@ export interface Schema {
|
|
|
6
7
|
style?: string;
|
|
7
8
|
skipFormat?: boolean;
|
|
8
9
|
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
9
11
|
tags?: string;
|
|
10
12
|
unitTestRunner?: 'jest' | 'none';
|
|
11
13
|
pascalCaseFiles?: boolean;
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"$source": "argv",
|
|
24
24
|
"index": 0
|
|
25
25
|
},
|
|
26
|
-
"x-prompt": "What name would you like to use for the application?"
|
|
26
|
+
"x-prompt": "What name would you like to use for the application?",
|
|
27
|
+
"pattern": "^[a-zA-Z][^:]*$"
|
|
27
28
|
},
|
|
28
29
|
"displayName": {
|
|
29
30
|
"description": "The display name to show in the application. Defaults to name.",
|
|
@@ -33,6 +34,11 @@
|
|
|
33
34
|
"description": "The directory of the new application.",
|
|
34
35
|
"type": "string"
|
|
35
36
|
},
|
|
37
|
+
"projectNameAndRootFormat": {
|
|
38
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"enum": ["as-provided", "derived"]
|
|
41
|
+
},
|
|
36
42
|
"skipFormat": {
|
|
37
43
|
"description": "Skip formatting files",
|
|
38
44
|
"type": "boolean",
|
|
@@ -6,6 +6,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
6
6
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
7
7
|
const add_import_1 = require("./lib/add-import");
|
|
8
8
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
9
|
+
const path_1 = require("path");
|
|
9
10
|
function reactNativeComponentGenerator(host, schema) {
|
|
10
11
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
12
|
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
@@ -17,7 +18,7 @@ function reactNativeComponentGenerator(host, schema) {
|
|
|
17
18
|
exports.reactNativeComponentGenerator = reactNativeComponentGenerator;
|
|
18
19
|
function createComponentFiles(host, options) {
|
|
19
20
|
const componentDir = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.directory);
|
|
20
|
-
(0, devkit_1.generateFiles)(host, (0,
|
|
21
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, Object.assign(Object.assign({}, options), { tmpl: '' }));
|
|
21
22
|
for (const c of host.listChanges()) {
|
|
22
23
|
let deleteFile = false;
|
|
23
24
|
if (options.skipTests && /.*spec.tsx/.test(c.path)) {
|
|
@@ -5,9 +5,8 @@ export interface NormalizedSchema extends Schema {
|
|
|
5
5
|
fileName: string;
|
|
6
6
|
projectRoot: string;
|
|
7
7
|
routePath: string;
|
|
8
|
-
projectDirectory: string;
|
|
9
8
|
parsedTags: string[];
|
|
10
9
|
appMain?: string;
|
|
11
10
|
appSourceRoot?: string;
|
|
12
11
|
}
|
|
13
|
-
export declare function normalizeOptions(host: Tree, options: Schema): NormalizedSchema
|
|
12
|
+
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
function normalizeOptions(host, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const { projectName, names: projectNames, projectRoot, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
9
|
+
name: options.name,
|
|
10
|
+
projectType: 'library',
|
|
11
|
+
directory: options.directory,
|
|
12
|
+
importPath: options.importPath,
|
|
13
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
14
|
+
callingGenerator: '@nx/react-native:library',
|
|
15
|
+
});
|
|
16
|
+
const parsedTags = options.tags
|
|
17
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
18
|
+
: [];
|
|
19
|
+
const normalized = Object.assign(Object.assign({}, options), { fileName: projectName, routePath: `/${projectNames.projectSimpleName}`, name: projectName, projectRoot,
|
|
20
|
+
parsedTags,
|
|
21
|
+
importPath });
|
|
22
|
+
return normalized;
|
|
23
|
+
});
|
|
24
24
|
}
|
|
25
25
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function reactNativeLibraryGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function reactNativeLibraryGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export default reactNativeLibraryGenerator;
|
|
5
6
|
export declare const reactNativeLibrarySchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reactNativeLibrarySchematic = exports.reactNativeLibraryGenerator = void 0;
|
|
3
|
+
exports.reactNativeLibrarySchematic = exports.reactNativeLibraryGeneratorInternal = exports.reactNativeLibraryGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const js_1 = require("@nx/js");
|
|
@@ -11,7 +11,13 @@ const versions_1 = require("../../utils/versions");
|
|
|
11
11
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
12
12
|
function reactNativeLibraryGenerator(host, schema) {
|
|
13
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
|
|
14
|
+
return yield reactNativeLibraryGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.reactNativeLibraryGenerator = reactNativeLibraryGenerator;
|
|
18
|
+
function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
15
21
|
if (options.publishable === true && !schema.importPath) {
|
|
16
22
|
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
17
23
|
}
|
|
@@ -43,14 +49,13 @@ function reactNativeLibraryGenerator(host, schema) {
|
|
|
43
49
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
|
-
exports.
|
|
52
|
+
exports.reactNativeLibraryGeneratorInternal = reactNativeLibraryGeneratorInternal;
|
|
47
53
|
function addProject(host, options) {
|
|
48
54
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
55
|
const targets = {};
|
|
50
56
|
let task;
|
|
51
57
|
if (options.publishable || options.buildable) {
|
|
52
58
|
const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
53
|
-
const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
|
|
54
59
|
const external = [
|
|
55
60
|
'react/jsx-runtime',
|
|
56
61
|
'react-native',
|
|
@@ -61,7 +66,7 @@ function addProject(host, options) {
|
|
|
61
66
|
executor: '@nx/rollup:rollup',
|
|
62
67
|
outputs: ['{options.outputPath}'],
|
|
63
68
|
options: {
|
|
64
|
-
outputPath: `dist/${
|
|
69
|
+
outputPath: `dist/${options.projectRoot}`,
|
|
65
70
|
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
66
71
|
project: `${options.projectRoot}/package.json`,
|
|
67
72
|
entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/linter';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Same as the @nx/react library schema, except it removes keys: style, component, routing, appProject
|
|
@@ -6,6 +7,7 @@ import { Linter } from '@nx/linter';
|
|
|
6
7
|
export interface Schema {
|
|
7
8
|
name: string;
|
|
8
9
|
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
9
11
|
skipTsConfig: boolean;
|
|
10
12
|
skipFormat: boolean;
|
|
11
13
|
tags?: string;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"index": 0
|
|
21
21
|
},
|
|
22
22
|
"x-prompt": "What name would you like to use for the library?",
|
|
23
|
-
"pattern": "
|
|
23
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
|
|
24
24
|
},
|
|
25
25
|
"directory": {
|
|
26
26
|
"type": "string",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"alias": "dir",
|
|
29
29
|
"x-priority": "important"
|
|
30
30
|
},
|
|
31
|
+
"projectNameAndRootFormat": {
|
|
32
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["as-provided", "derived"]
|
|
35
|
+
},
|
|
31
36
|
"linter": {
|
|
32
37
|
"description": "The tool to use for running lint checks.",
|
|
33
38
|
"type": "string",
|
package/src/utils/add-linting.js
CHANGED
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const linter_1 = require("@nx/linter");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const lint_1 = require("@nx/react/src/utils/lint");
|
|
8
|
+
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
8
9
|
function addLinting(host, options) {
|
|
9
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
11
|
if (options.linter === linter_1.Linter.None) {
|
|
@@ -20,16 +21,14 @@ function addLinting(host, options) {
|
|
|
20
21
|
skipPackageJson: options.skipPackageJson,
|
|
21
22
|
});
|
|
22
23
|
tasks.push(lintTask);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
...json.ignorePatterns,
|
|
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
27
|
'public',
|
|
28
28
|
'.cache',
|
|
29
29
|
'node_modules',
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
});
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
33
32
|
if (!options.skipPackageJson) {
|
|
34
33
|
const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
35
34
|
tasks.push(installTask);
|