@nx/expo 20.2.0 → 20.2.2
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 +8 -8
- package/src/generators/application/files/base/tsconfig.app.json.template +11 -1
- package/src/generators/component/component.js +12 -20
- package/src/generators/component/files/js/__fileName__.__ext__ +28 -0
- package/src/generators/component/files/{__fileName__.spec.tsx.template → js/__fileName__.spec.__ext__} +0 -1
- package/src/generators/component/files/{__fileName__.tsx.template → ts/__fileName__.__ext__} +6 -6
- package/src/generators/component/files/ts/__fileName__.spec.__ext__ +10 -0
- package/src/generators/component/lib/normalize-options.d.ts +4 -1
- package/src/generators/component/lib/normalize-options.js +7 -3
- package/src/generators/component/schema.d.ts +9 -5
- package/src/generators/component/schema.json +8 -4
- package/src/generators/library/files/lib/tsconfig.lib.json.template +11 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/expo",
|
|
3
|
-
"version": "20.2.
|
|
3
|
+
"version": "20.2.2",
|
|
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": [
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"main": "./index",
|
|
29
29
|
"types": "index.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nx/devkit": "20.2.
|
|
32
|
-
"@nx/eslint": "20.2.
|
|
33
|
-
"@nx/jest": "20.2.
|
|
34
|
-
"@nx/js": "20.2.
|
|
35
|
-
"@nx/react": "20.2.
|
|
36
|
-
"@nx/web": "20.2.
|
|
37
|
-
"@nx/webpack": "20.2.
|
|
31
|
+
"@nx/devkit": "20.2.2",
|
|
32
|
+
"@nx/eslint": "20.2.2",
|
|
33
|
+
"@nx/jest": "20.2.2",
|
|
34
|
+
"@nx/js": "20.2.2",
|
|
35
|
+
"@nx/react": "20.2.2",
|
|
36
|
+
"@nx/web": "20.2.2",
|
|
37
|
+
"@nx/webpack": "20.2.2",
|
|
38
38
|
"enhanced-resolve": "^5.8.3",
|
|
39
39
|
"metro-config": "~0.80.4",
|
|
40
40
|
"metro-resolver": "~0.80.4",
|
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
"types": ["node"]
|
|
6
6
|
},
|
|
7
7
|
"files": ["<%= offsetFromRoot %>node_modules/@nx/expo/typings/svg.d.ts"],
|
|
8
|
-
"exclude": [
|
|
8
|
+
"exclude": [
|
|
9
|
+
"**/*.test.ts",
|
|
10
|
+
"**/*.spec.ts",
|
|
11
|
+
"**/*.test.tsx",
|
|
12
|
+
"**/*.spec.tsx",
|
|
13
|
+
"**/*.test.js",
|
|
14
|
+
"**/*.spec.js",
|
|
15
|
+
"**/*.test.jsx",
|
|
16
|
+
"**/*.spec.jsx",
|
|
17
|
+
"src/test-setup.ts"
|
|
18
|
+
],
|
|
9
19
|
"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
|
|
10
20
|
}
|
|
@@ -15,35 +15,27 @@ async function expoComponentGenerator(host, schema) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
function createComponentFiles(host, options) {
|
|
18
|
-
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), options.directory, {
|
|
18
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files', options.fileExtensionType), options.directory, {
|
|
19
19
|
...options,
|
|
20
|
-
|
|
20
|
+
ext: options.fileExtension,
|
|
21
21
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (options.skipTests && /.*spec.tsx/.test(c.path)) {
|
|
25
|
-
deleteFile = true;
|
|
26
|
-
}
|
|
27
|
-
if (deleteFile) {
|
|
28
|
-
host.delete(c.path);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (options.js) {
|
|
32
|
-
(0, devkit_1.toJS)(host);
|
|
22
|
+
if (options.skipTests) {
|
|
23
|
+
host.delete((0, devkit_1.joinPathFragments)(options.directory, `${options.fileName}.spec.${options.fileExtension}`));
|
|
33
24
|
}
|
|
34
25
|
}
|
|
35
26
|
function addExportsToBarrel(host, options) {
|
|
36
27
|
const workspace = (0, devkit_1.getProjects)(host);
|
|
37
28
|
const isApp = workspace.get(options.projectName).projectType === 'application';
|
|
38
29
|
if (options.export && !isApp) {
|
|
39
|
-
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
|
|
43
|
-
const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
|
|
44
|
-
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, add_import_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
|
|
45
|
-
host.write(indexFilePath, changes);
|
|
30
|
+
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
|
|
31
|
+
if (!host.exists(indexFilePath)) {
|
|
32
|
+
return;
|
|
46
33
|
}
|
|
34
|
+
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
35
|
+
const indexSourceFile = ts.createSourceFile(indexFilePath, indexSource, ts.ScriptTarget.Latest, true);
|
|
36
|
+
const relativePathFromIndex = getRelativeImportToFile(indexFilePath, options.filePath);
|
|
37
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, add_import_1.addImport)(indexSourceFile, `export * from '${relativePathFromIndex}';`));
|
|
38
|
+
host.write(indexFilePath, changes);
|
|
47
39
|
}
|
|
48
40
|
}
|
|
49
41
|
function getRelativeImportToFile(indexPath, filePath) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<%_ if (classComponent) { _%>
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
<%_ } else { _%>
|
|
4
|
+
import React from 'react';
|
|
5
|
+
<%_ } _%>
|
|
6
|
+
import { View, Text } from 'react-native';
|
|
7
|
+
|
|
8
|
+
<%_ if (classComponent) { _%>
|
|
9
|
+
export class <%= className %> extends Component {
|
|
10
|
+
render() {
|
|
11
|
+
return (
|
|
12
|
+
<View>
|
|
13
|
+
<Text>Welcome to <%= name %>!</Text>
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
<%_ } else { _%>
|
|
19
|
+
export function <%= className %>(props) {
|
|
20
|
+
return (
|
|
21
|
+
<View>
|
|
22
|
+
<Text>Welcome to <%= name %>!</Text>
|
|
23
|
+
</View>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
<%_ } _%>
|
|
27
|
+
|
|
28
|
+
export default <%= className %>;
|
package/src/generators/component/files/{__fileName__.tsx.template → ts/__fileName__.__ext__}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
<% if (classComponent) { %>
|
|
1
|
+
<%_ if (classComponent) { _%>
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
-
<% } else { %>
|
|
3
|
+
<%_ } else { _%>
|
|
4
4
|
import React from 'react';
|
|
5
|
-
<% } %>
|
|
5
|
+
<%_ } _%>
|
|
6
6
|
import { View, Text } from 'react-native';
|
|
7
7
|
|
|
8
8
|
/* eslint-disable-next-line */
|
|
9
9
|
export interface <%= className %>Props {
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
<% if (classComponent) { %>
|
|
12
|
+
<%_ if (classComponent) { _%>
|
|
13
13
|
export class <%= className %> extends Component<<%= className %>Props> {
|
|
14
14
|
render() {
|
|
15
15
|
return (
|
|
@@ -19,7 +19,7 @@ export class <%= className %> extends Component<<%= className %>Props> {
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
<% } else { %>
|
|
22
|
+
<%_ } else { _%>
|
|
23
23
|
export function <%= className %>(props: <%= className %>Props) {
|
|
24
24
|
return (
|
|
25
25
|
<View>
|
|
@@ -27,6 +27,6 @@ export function <%= className %>(props: <%= className %>Props) {
|
|
|
27
27
|
</View>
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
|
-
<% } %>
|
|
30
|
+
<%_ } _%>
|
|
31
31
|
|
|
32
32
|
export default <%= className %>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import <%= className %> from './<%= fileName %>';
|
|
4
|
+
|
|
5
|
+
describe('<%= className %>', () => {
|
|
6
|
+
it('should render successfully', () => {
|
|
7
|
+
const { root } = render(< <%= className %> />);
|
|
8
|
+
expect(root).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { type FileExtensionType } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
3
|
import { Schema } from '../schema';
|
|
3
|
-
export interface NormalizedSchema extends Schema {
|
|
4
|
+
export interface NormalizedSchema extends Omit<Schema, 'js'> {
|
|
4
5
|
directory: string;
|
|
5
6
|
projectSourceRoot: string;
|
|
6
7
|
fileName: string;
|
|
8
|
+
fileExtension: string;
|
|
9
|
+
fileExtensionType: FileExtensionType;
|
|
7
10
|
className: string;
|
|
8
11
|
filePath: string;
|
|
9
12
|
projectName: string;
|
|
@@ -4,13 +4,15 @@ exports.normalizeOptions = normalizeOptions;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
6
|
async function normalizeOptions(host, options) {
|
|
7
|
-
const { artifactName: name, fileName, filePath, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
7
|
+
const { artifactName: name, fileName, fileExtension, fileExtensionType, filePath, directory, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
|
|
8
8
|
name: options.name,
|
|
9
9
|
path: options.path,
|
|
10
|
-
|
|
10
|
+
allowedFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
|
|
11
|
+
fileExtension: options.js ? 'js' : 'tsx',
|
|
12
|
+
js: options.js,
|
|
11
13
|
});
|
|
12
|
-
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
13
14
|
const { className } = (0, devkit_1.names)(name);
|
|
15
|
+
const project = (0, devkit_1.getProjects)(host).get(projectName);
|
|
14
16
|
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
15
17
|
if (options.export && projectType === 'application') {
|
|
16
18
|
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
|
@@ -22,6 +24,8 @@ async function normalizeOptions(host, options) {
|
|
|
22
24
|
directory,
|
|
23
25
|
className,
|
|
24
26
|
fileName,
|
|
27
|
+
fileExtension,
|
|
28
|
+
fileExtensionType,
|
|
25
29
|
filePath,
|
|
26
30
|
projectSourceRoot,
|
|
27
31
|
projectName,
|
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
export interface Schema {
|
|
5
5
|
path: string;
|
|
6
6
|
name?: string;
|
|
7
|
-
skipFormat
|
|
8
|
-
skipTests
|
|
9
|
-
export
|
|
10
|
-
classComponent
|
|
11
|
-
|
|
7
|
+
skipFormat?: boolean;
|
|
8
|
+
skipTests?: boolean;
|
|
9
|
+
export?: boolean;
|
|
10
|
+
classComponent?: boolean;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Provide the full file path including the file extension in the `path` option. This option will be removed in Nx v21.
|
|
14
|
+
*/
|
|
15
|
+
js?: boolean;
|
|
12
16
|
}
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
9
|
"description": "Generate a component with the exported symbol matching the file name. It results in the component `Foo` at `mylib/src/foo.tsx`",
|
|
10
|
-
"command": "nx g @nx/expo:component mylib/src/foo"
|
|
10
|
+
"command": "nx g @nx/expo:component mylib/src/foo.tsx"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"description": "Generate a component with the exported symbol different from the file name. It results in the component `Custom` at `mylib/src/foo.tsx`",
|
|
14
|
-
"command": "nx g @nx/expo:component mylib/src/foo --name=custom"
|
|
14
|
+
"command": "nx g @nx/expo:component mylib/src/foo.tsx --name=custom"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"description": "Generate a component without the providing the file extension. It results in the component `Foo` at `mylib/src/foo.tsx`",
|
|
18
|
+
"command": "nx g @nx/expo:component mylib/src/foo"
|
|
15
19
|
},
|
|
16
20
|
{
|
|
17
21
|
"description": "Generate a class component at `mylib/src/foo.tsx`",
|
|
@@ -21,7 +25,7 @@
|
|
|
21
25
|
"properties": {
|
|
22
26
|
"path": {
|
|
23
27
|
"type": "string",
|
|
24
|
-
"description": "The file path to the component
|
|
28
|
+
"description": "The file path to the component. Relative to the current working directory.",
|
|
25
29
|
"$default": {
|
|
26
30
|
"$source": "argv",
|
|
27
31
|
"index": 0
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
"js": {
|
|
36
40
|
"type": "boolean",
|
|
37
41
|
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
38
|
-
"
|
|
42
|
+
"x-deprecated": "Provide the full file path including the file extension in the `path` option. This option will be removed in Nx v21."
|
|
39
43
|
},
|
|
40
44
|
"skipFormat": {
|
|
41
45
|
"description": "Skip formatting files.",
|
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
5
5
|
"types": ["node"]
|
|
6
6
|
},
|
|
7
|
-
"exclude": [
|
|
7
|
+
"exclude": [
|
|
8
|
+
"**/*.test.ts",
|
|
9
|
+
"**/*.spec.ts",
|
|
10
|
+
"**/*.test.tsx",
|
|
11
|
+
"**/*.spec.tsx",
|
|
12
|
+
"**/*.test.js",
|
|
13
|
+
"**/*.spec.js",
|
|
14
|
+
"**/*.test.jsx",
|
|
15
|
+
"**/*.spec.jsx",
|
|
16
|
+
"src/test-setup.ts"
|
|
17
|
+
],
|
|
8
18
|
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
|
9
19
|
}
|