@nx/expo 17.0.0-beta.6 → 17.0.0-beta.8
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/generators/application/lib/add-detox.js +2 -2
- 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/library/schema.d.ts +1 -1
- package/src/utils/add-linting.d.ts +1 -1
- package/src/utils/add-linting.js +4 -4
package/generators.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"description": "Create a library"
|
|
25
25
|
},
|
|
26
26
|
"component": {
|
|
27
|
-
"factory": "./src/generators/component/component#
|
|
27
|
+
"factory": "./src/generators/component/component#expoComponentGeneratorInternal",
|
|
28
28
|
"schema": "./src/generators/component/schema.json",
|
|
29
29
|
"description": "Create a component",
|
|
30
30
|
"aliases": ["c"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/expo",
|
|
3
|
-
"version": "17.0.0-beta.
|
|
3
|
+
"version": "17.0.0-beta.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"tslib": "^2.3.0",
|
|
35
35
|
"tsconfig-paths": "^4.1.2",
|
|
36
36
|
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
37
|
-
"@nx/detox": "17.0.0-beta.
|
|
38
|
-
"@nx/devkit": "17.0.0-beta.
|
|
39
|
-
"@nx/jest": "17.0.0-beta.
|
|
40
|
-
"@nx/js": "17.0.0-beta.
|
|
41
|
-
"@nx/
|
|
42
|
-
"@nx/react": "17.0.0-beta.
|
|
43
|
-
"@nx/webpack": "17.0.0-beta.
|
|
44
|
-
"@nrwl/expo": "17.0.0-beta.
|
|
37
|
+
"@nx/detox": "17.0.0-beta.8",
|
|
38
|
+
"@nx/devkit": "17.0.0-beta.8",
|
|
39
|
+
"@nx/jest": "17.0.0-beta.8",
|
|
40
|
+
"@nx/js": "17.0.0-beta.8",
|
|
41
|
+
"@nx/eslint": "17.0.0-beta.8",
|
|
42
|
+
"@nx/react": "17.0.0-beta.8",
|
|
43
|
+
"@nx/webpack": "17.0.0-beta.8",
|
|
44
|
+
"@nrwl/expo": "17.0.0-beta.8"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"expo": ">= 49.0.0",
|
|
@@ -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',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from './schema';
|
|
2
2
|
import { Tree } from '@nx/devkit';
|
|
3
3
|
export declare function expoComponentGenerator(host: Tree, schema: Schema): Promise<void>;
|
|
4
|
+
export declare function expoComponentGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
|
|
4
5
|
export default expoComponentGenerator;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expoComponentGenerator = void 0;
|
|
3
|
+
exports.expoComponentGeneratorInternal = exports.expoComponentGenerator = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
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 path_1 = require("path");
|
|
9
9
|
async function expoComponentGenerator(host, schema) {
|
|
10
|
+
return expoComponentGeneratorInternal(host, {
|
|
11
|
+
nameAndDirectoryFormat: 'derived',
|
|
12
|
+
...schema,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.expoComponentGenerator = expoComponentGenerator;
|
|
16
|
+
async function expoComponentGeneratorInternal(host, schema) {
|
|
10
17
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
11
18
|
createComponentFiles(host, options);
|
|
12
19
|
addExportsToBarrel(host, options);
|
|
@@ -14,10 +21,9 @@ async function expoComponentGenerator(host, schema) {
|
|
|
14
21
|
await (0, devkit_1.formatFiles)(host);
|
|
15
22
|
}
|
|
16
23
|
}
|
|
17
|
-
exports.
|
|
24
|
+
exports.expoComponentGeneratorInternal = expoComponentGeneratorInternal;
|
|
18
25
|
function createComponentFiles(host, options) {
|
|
19
|
-
|
|
20
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, {
|
|
26
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.directory, {
|
|
21
27
|
...options,
|
|
22
28
|
tmpl: '',
|
|
23
29
|
});
|
|
@@ -42,9 +48,15 @@ function addExportsToBarrel(host, options) {
|
|
|
42
48
|
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
43
49
|
if (indexSource !== null) {
|
|
44
50
|
const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
|
|
45
|
-
const
|
|
51
|
+
const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
|
|
52
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, add_import_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
|
|
46
53
|
host.write(indexFilePath, changes);
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
}
|
|
57
|
+
function getRelativeImportToFile(indexPath, filePath) {
|
|
58
|
+
const { name, dir } = (0, path_1.parse)(filePath);
|
|
59
|
+
const relativeDirToTarget = (0, path_1.relative)((0, path_1.dirname)(indexPath), dir);
|
|
60
|
+
return `./${(0, devkit_1.joinPathFragments)(relativeDirToTarget, name)}`;
|
|
61
|
+
}
|
|
50
62
|
exports.default = expoComponentGenerator;
|
|
@@ -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/expo: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,13 +3,23 @@
|
|
|
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
|
directory?: string;
|
|
8
11
|
skipFormat: boolean; // default is false
|
|
9
12
|
skipTests: boolean; // default is false
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Provide the name in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
|
|
15
|
+
*/
|
|
10
16
|
export: boolean; // default is false
|
|
11
17
|
pascalCaseFiles: boolean; // default is false
|
|
12
18
|
classComponent: boolean; // default is false
|
|
13
19
|
js: boolean; // default is false
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
|
|
22
|
+
*/
|
|
14
23
|
flat: boolean; // default is false
|
|
24
|
+
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
15
25
|
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"$default": {
|
|
23
23
|
"$source": "projectName"
|
|
24
24
|
},
|
|
25
|
-
"x-
|
|
25
|
+
"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."
|
|
26
26
|
},
|
|
27
27
|
"name": {
|
|
28
28
|
"type": "string",
|
|
@@ -51,13 +51,19 @@
|
|
|
51
51
|
},
|
|
52
52
|
"directory": {
|
|
53
53
|
"type": "string",
|
|
54
|
-
"description": "
|
|
54
|
+
"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.",
|
|
55
55
|
"x-priority": "important"
|
|
56
56
|
},
|
|
57
|
+
"nameAndDirectoryFormat": {
|
|
58
|
+
"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`).",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"enum": ["as-provided", "derived"]
|
|
61
|
+
},
|
|
57
62
|
"flat": {
|
|
58
63
|
"type": "boolean",
|
|
59
64
|
"description": "Create component at the source root rather than its own directory.",
|
|
60
|
-
"default": false
|
|
65
|
+
"default": false,
|
|
66
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18."
|
|
61
67
|
},
|
|
62
68
|
"export": {
|
|
63
69
|
"type": "boolean",
|
|
@@ -70,7 +76,8 @@
|
|
|
70
76
|
"type": "boolean",
|
|
71
77
|
"description": "Use pascal case component file name (e.g. App.tsx).",
|
|
72
78
|
"alias": "P",
|
|
73
|
-
"default": false
|
|
79
|
+
"default": false,
|
|
80
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
|
|
74
81
|
},
|
|
75
82
|
"classComponent": {
|
|
76
83
|
"type": "boolean",
|
|
@@ -79,5 +86,5 @@
|
|
|
79
86
|
"default": false
|
|
80
87
|
}
|
|
81
88
|
},
|
|
82
|
-
"required": ["name"
|
|
89
|
+
"required": ["name"]
|
|
83
90
|
}
|
|
@@ -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
|
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,
|