@nx/expo 17.0.5 → 17.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +0 -3
- package/LICENSE +1 -1
- package/README.md +4 -9
- package/collection.json +0 -0
- package/docs/start-examples.md +0 -6
- package/executors.json +0 -5
- package/generators.json +2 -2
- package/migrations.json +6 -114
- package/package.json +16 -12
- package/plugins/metro-resolver.js +1 -4
- package/plugins/with-nx-metro.js +2 -6
- package/plugins/with-nx-webpack.d.ts +1 -1
- package/plugins/with-nx-webpack.js +4 -8
- package/src/executors/build/build.impl.js +1 -2
- package/src/executors/build/schema.json +1 -1
- package/src/executors/build-list/build-list.impl.js +3 -2
- package/src/executors/build-list/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +0 -4
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/export/export.impl.d.ts +0 -1
- package/src/executors/export/export.impl.js +15 -25
- package/src/executors/export/schema.d.ts +2 -4
- package/src/executors/export/schema.json +13 -14
- package/src/executors/install/install.impl.js +2 -0
- package/src/executors/install/schema.json +1 -1
- package/src/executors/prebuild/prebuild.impl.js +5 -11
- package/src/executors/prebuild/schema.json +1 -2
- package/src/executors/run/schema.json +1 -1
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +1 -7
- package/src/executors/submit/schema.json +1 -1
- package/src/executors/submit/submit.impl.js +1 -2
- package/src/executors/sync-deps/schema.d.ts +0 -1
- package/src/executors/sync-deps/schema.json +1 -6
- package/src/executors/sync-deps/sync-deps.impl.d.ts +3 -4
- package/src/executors/sync-deps/sync-deps.impl.js +11 -33
- package/src/executors/update/schema.json +1 -1
- package/src/executors/update/update.impl.js +4 -7
- package/src/generators/application/application.js +7 -27
- package/src/generators/application/files/app.json.template +0 -2
- package/src/generators/application/files/eas.json.template +3 -0
- package/src/generators/application/files/metro.config.js.template +5 -1
- package/src/generators/application/files/src/app/App.tsx.template +13 -50
- package/src/generators/application/lib/add-detox.d.ts +3 -0
- package/src/generators/application/lib/add-detox.js +24 -0
- package/src/generators/application/lib/add-project.js +22 -20
- package/src/generators/application/lib/create-application-files.js +2 -0
- package/src/generators/application/lib/normalize-options.d.ts +0 -6
- package/src/generators/application/lib/normalize-options.js +1 -33
- package/src/generators/application/schema.d.ts +1 -2
- package/src/generators/application/schema.json +4 -4
- package/src/generators/component/files/__fileName__.tsx.template +1 -1
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +4 -4
- package/src/generators/init/init.d.ts +2 -3
- package/src/generators/init/init.js +40 -44
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +16 -11
- package/src/generators/library/files/lib/babel.config.json +17 -0
- package/src/generators/library/lib/normalize-options.js +0 -5
- package/src/generators/library/library.js +38 -52
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +2 -2
- package/src/migrations/{update-18-0-0/change-outputDir-export-target.d.ts → update-16-1-4/add-detox-app-json.d.ts} +1 -1
- package/src/migrations/update-16-1-4/add-detox-app-json.js +29 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +5 -1
- package/src/migrations/update-16-9-0/remove-types-react-native.js +9 -2
- package/src/migrations/update-16-9-0/update-eas-cli-version.js +2 -1
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +5 -15
- package/src/utils/add-linting.d.ts +0 -1
- package/src/utils/add-linting.js +1 -1
- package/src/utils/find-all-npm-dependencies.js +2 -4
- package/src/utils/symlink-task.d.ts +2 -0
- package/src/utils/symlink-task.js +18 -0
- package/src/utils/versions.d.ts +15 -14
- package/src/utils/versions.js +16 -15
- package/docs/export-examples.md +0 -112
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -6
- package/plugins/plugin.d.ts +0 -14
- package/plugins/plugin.js +0 -150
- package/src/executors/serve/lib/is-packager-running.d.ts +0 -1
- package/src/executors/serve/lib/is-packager-running.js +0 -15
- package/src/executors/serve/schema.d.ts +0 -7
- package/src/executors/serve/schema.json +0 -35
- package/src/executors/serve/serve.impl.d.ts +0 -11
- package/src/executors/serve/serve.impl.js +0 -105
- package/src/generators/application/files/webpack.config.js.template +0 -57
- package/src/generators/application/lib/add-e2e.d.ts +0 -3
- package/src/generators/application/lib/add-e2e.js +0 -86
- package/src/generators/library/files/lib/.babelrc.js.template +0 -21
- package/src/migrations/update-18-0-0/change-outputDir-export-target.js +0 -25
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
- package/src/migrations/update-18-0-0/remove-eas-cli.d.ts +0 -12
- package/src/migrations/update-18-0-0/remove-eas-cli.js +0 -18
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -29
- package/src/utils/ensure-dependencies.d.ts +0 -2
- package/src/utils/ensure-dependencies.js +0 -24
- package/src/utils/has-expo-plugin.d.ts +0 -2
- package/src/utils/has-expo-plugin.js +0 -11
- package/src/utils/resolve-eas.d.ts +0 -1
- package/src/utils/resolve-eas.js +0 -36
- /package/src/generators/application/files/{.babelrc.js.template → babel.config.js.template} +0 -0
- /package/src/{utils → generators/init/lib}/init-root-babel-config.d.ts +0 -0
- /package/src/{utils → generators/init/lib}/init-root-babel-config.js +0 -0
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createApplicationFiles = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
7
|
function createApplicationFiles(host, options) {
|
|
7
8
|
const packageManagerLockFile = {
|
|
8
9
|
npm: 'package-lock.json',
|
|
@@ -16,6 +17,7 @@ function createApplicationFiles(host, options) {
|
|
|
16
17
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
17
18
|
packageManager,
|
|
18
19
|
packageLockFile,
|
|
20
|
+
easCliVersion: versions_1.easCliVersion,
|
|
19
21
|
});
|
|
20
22
|
if (options.unitTestRunner === 'none') {
|
|
21
23
|
host.delete((0, path_1.join)(options.appProjectRoot, `App.spec.tsx`));
|
|
@@ -6,11 +6,5 @@ export interface NormalizedSchema extends Schema {
|
|
|
6
6
|
appProjectRoot: string;
|
|
7
7
|
lowerCaseName: string;
|
|
8
8
|
parsedTags: string[];
|
|
9
|
-
rootProject: boolean;
|
|
10
|
-
e2eProjectName: string;
|
|
11
|
-
e2eProjectRoot: string;
|
|
12
|
-
e2eWebServerAddress: string;
|
|
13
|
-
e2eWebServerTarget: string;
|
|
14
|
-
e2ePort: number;
|
|
15
9
|
}
|
|
16
10
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -12,40 +12,14 @@ async function normalizeOptions(host, options) {
|
|
|
12
12
|
callingGenerator: '@nx/expo:application',
|
|
13
13
|
});
|
|
14
14
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
-
nxJson.useInferencePlugins !== false;
|
|
18
|
-
options.addPlugin ??= addPluginDefault;
|
|
19
15
|
const { className } = (0, devkit_1.names)(options.name);
|
|
20
16
|
const parsedTags = options.tags
|
|
21
17
|
? options.tags.split(',').map((s) => s.trim())
|
|
22
18
|
: [];
|
|
23
|
-
const rootProject = appProjectRoot === '.';
|
|
24
|
-
let e2eWebServerTarget = 'serve';
|
|
25
|
-
if (options.addPlugin) {
|
|
26
|
-
if (nxJson.plugins) {
|
|
27
|
-
for (const plugin of nxJson.plugins) {
|
|
28
|
-
if (typeof plugin === 'object' &&
|
|
29
|
-
plugin.plugin === '@nx/expo/plugin' &&
|
|
30
|
-
plugin.options.serveTargetName) {
|
|
31
|
-
e2eWebServerTarget = plugin.options
|
|
32
|
-
.serveTargetName;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
let e2ePort = options.addPlugin ? 8081 : 4200;
|
|
38
|
-
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
39
|
-
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
|
|
40
|
-
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options.port;
|
|
41
|
-
}
|
|
42
|
-
const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
43
|
-
const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
44
|
-
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
45
19
|
return {
|
|
46
20
|
...options,
|
|
47
21
|
unitTestRunner: options.unitTestRunner || 'jest',
|
|
48
|
-
e2eTestRunner: options.e2eTestRunner,
|
|
22
|
+
e2eTestRunner: options.e2eTestRunner || 'detox',
|
|
49
23
|
name: projectNames.projectSimpleName,
|
|
50
24
|
className,
|
|
51
25
|
lowerCaseName: className.toLowerCase(),
|
|
@@ -53,12 +27,6 @@ async function normalizeOptions(host, options) {
|
|
|
53
27
|
projectName: appProjectName,
|
|
54
28
|
appProjectRoot,
|
|
55
29
|
parsedTags,
|
|
56
|
-
rootProject,
|
|
57
|
-
e2eProjectName,
|
|
58
|
-
e2eProjectRoot,
|
|
59
|
-
e2eWebServerAddress,
|
|
60
|
-
e2eWebServerTarget,
|
|
61
|
-
e2ePort,
|
|
62
30
|
};
|
|
63
31
|
}
|
|
64
32
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -15,8 +15,7 @@ export interface Schema {
|
|
|
15
15
|
js: boolean; // default is false
|
|
16
16
|
linter: Linter; // default is eslint
|
|
17
17
|
setParserOptionsProject?: boolean; // default is false
|
|
18
|
-
e2eTestRunner: '
|
|
18
|
+
e2eTestRunner: 'detox' | 'none'; // default is detox
|
|
19
19
|
standaloneConfig?: boolean;
|
|
20
20
|
skipPackageJson?: boolean; // default is false
|
|
21
|
-
addPlugin?: boolean;
|
|
22
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxExpoApplication",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "http://json-schema.org/schema",
|
|
5
5
|
"description": "Create an Expo Application for Nx.",
|
|
6
6
|
"examples": [
|
|
7
7
|
{
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"linter": {
|
|
49
49
|
"description": "The tool to use for running lint checks.",
|
|
50
50
|
"type": "string",
|
|
51
|
-
"enum": ["eslint"
|
|
51
|
+
"enum": ["eslint"],
|
|
52
52
|
"default": "eslint"
|
|
53
53
|
},
|
|
54
54
|
"unitTestRunner": {
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"e2eTestRunner": {
|
|
76
76
|
"description": "Adds the specified e2e test runner",
|
|
77
77
|
"type": "string",
|
|
78
|
-
"enum": ["
|
|
79
|
-
"default": "
|
|
78
|
+
"enum": ["detox", "none"],
|
|
79
|
+
"default": "detox"
|
|
80
80
|
},
|
|
81
81
|
"standaloneConfig": {
|
|
82
82
|
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
@@ -4,21 +4,21 @@
|
|
|
4
4
|
export interface Schema {
|
|
5
5
|
name: string;
|
|
6
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
|
|
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
8
|
*/
|
|
9
9
|
project: string;
|
|
10
10
|
directory?: string;
|
|
11
11
|
skipFormat: boolean; // default is false
|
|
12
12
|
skipTests: boolean; // default is false
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the name in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
14
|
+
* @deprecated Provide the name in pascal-case and use the `as-provided` format. This option will be removed in Nx v18.
|
|
15
15
|
*/
|
|
16
16
|
export: boolean; // default is false
|
|
17
17
|
pascalCaseFiles: boolean; // default is false
|
|
18
18
|
classComponent: boolean; // default is false
|
|
19
19
|
js: boolean; // default is false
|
|
20
20
|
/**
|
|
21
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
21
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18.
|
|
22
22
|
*/
|
|
23
23
|
flat: boolean; // default is false
|
|
24
24
|
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxExpoComponent",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "http://json-schema.org/schema",
|
|
5
5
|
"description": "Create a Expo Component for Nx.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"examples": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"$default": {
|
|
23
23
|
"$source": "projectName"
|
|
24
24
|
},
|
|
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
|
|
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",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"type": "boolean",
|
|
64
64
|
"description": "Create component at the source root rather than its own directory.",
|
|
65
65
|
"default": false,
|
|
66
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
66
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v18."
|
|
67
67
|
},
|
|
68
68
|
"export": {
|
|
69
69
|
"type": "boolean",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"description": "Use pascal case component file name (e.g. App.tsx).",
|
|
78
78
|
"alias": "P",
|
|
79
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
|
|
80
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v18."
|
|
81
81
|
},
|
|
82
82
|
"classComponent": {
|
|
83
83
|
"type": "boolean",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
-
export declare function expoInitGenerator(
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
|
|
3
|
+
export declare function expoInitGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function updateDependencies(host: Tree): GeneratorCallback;
|
|
6
5
|
export default expoInitGenerator;
|
|
@@ -1,74 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDependencies = exports.
|
|
3
|
+
exports.updateDependencies = exports.expoInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
|
-
const plugin_1 = require("../../../plugins/plugin");
|
|
7
5
|
const versions_1 = require("../../utils/versions");
|
|
8
|
-
const
|
|
6
|
+
const jest_1 = require("@nx/jest");
|
|
7
|
+
const detox_1 = require("@nx/detox");
|
|
8
|
+
const js_1 = require("@nx/js");
|
|
9
9
|
const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
exports.expoInitGenerator = expoInitGenerator;
|
|
14
|
-
async function expoInitGeneratorInternal(host, schema) {
|
|
15
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
-
nxJson.useInferencePlugins !== false;
|
|
18
|
-
schema.addPlugin ??= addPluginDefault;
|
|
10
|
+
const init_root_babel_config_1 = require("./lib/init-root-babel-config");
|
|
11
|
+
async function expoInitGenerator(host, schema) {
|
|
19
12
|
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
|
|
20
|
-
|
|
21
|
-
addPlugin(host);
|
|
22
|
-
}
|
|
13
|
+
(0, init_root_babel_config_1.initRootBabelConfig)(host);
|
|
23
14
|
const tasks = [];
|
|
15
|
+
tasks.push(await (0, js_1.initGenerator)(host, {
|
|
16
|
+
...schema,
|
|
17
|
+
skipFormat: true,
|
|
18
|
+
}));
|
|
24
19
|
if (!schema.skipPackageJson) {
|
|
25
20
|
tasks.push(moveDependency(host));
|
|
26
|
-
tasks.push(updateDependencies(host
|
|
21
|
+
tasks.push(updateDependencies(host));
|
|
27
22
|
}
|
|
28
|
-
if (schema.
|
|
29
|
-
await (0,
|
|
23
|
+
if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
|
|
24
|
+
const jestTask = await (0, jest_1.jestInitGenerator)(host, schema);
|
|
25
|
+
tasks.push(jestTask);
|
|
26
|
+
}
|
|
27
|
+
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
|
|
28
|
+
const detoxTask = await (0, detox_1.detoxInitGenerator)(host, {
|
|
29
|
+
...schema,
|
|
30
|
+
skipFormat: true,
|
|
31
|
+
});
|
|
32
|
+
tasks.push(detoxTask);
|
|
30
33
|
}
|
|
31
34
|
if (!schema.skipFormat) {
|
|
32
35
|
await (0, devkit_1.formatFiles)(host);
|
|
33
36
|
}
|
|
34
37
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
35
38
|
}
|
|
36
|
-
exports.
|
|
37
|
-
function updateDependencies(host
|
|
39
|
+
exports.expoInitGenerator = expoInitGenerator;
|
|
40
|
+
function updateDependencies(host) {
|
|
38
41
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
39
42
|
react: versions_1.reactVersion,
|
|
40
43
|
'react-dom': versions_1.reactDomVersion,
|
|
41
44
|
'react-native': versions_1.reactNativeVersion,
|
|
42
45
|
expo: versions_1.expoVersion,
|
|
46
|
+
'expo-splash-screen': versions_1.expoSplashScreenVersion,
|
|
47
|
+
'expo-status-bar': versions_1.expoStatusBarVersion,
|
|
48
|
+
'react-native-web': versions_1.reactNativeWebVersion,
|
|
49
|
+
'@expo/metro-config': versions_1.expoMetroConfigVersion,
|
|
50
|
+
'react-native-svg-transformer': versions_1.reactNativeSvgTransformerVersion,
|
|
51
|
+
'react-native-svg': versions_1.reactNativeSvgVersion,
|
|
43
52
|
}, {
|
|
44
53
|
'@nx/expo': versions_1.nxVersion,
|
|
54
|
+
'@types/react': versions_1.typesReactVersion,
|
|
55
|
+
metro: versions_1.metroVersion,
|
|
56
|
+
'metro-resolver': versions_1.metroVersion,
|
|
57
|
+
'react-test-renderer': versions_1.reactTestRendererVersion,
|
|
58
|
+
'@testing-library/react-native': versions_1.testingLibraryReactNativeVersion,
|
|
59
|
+
'@testing-library/jest-native': versions_1.testingLibraryJestNativeVersion,
|
|
60
|
+
'jest-expo': versions_1.jestExpoVersion,
|
|
45
61
|
'@expo/cli': versions_1.expoCliVersion,
|
|
46
|
-
|
|
62
|
+
'eas-cli': versions_1.easCliVersion,
|
|
63
|
+
'babel-preset-expo': versions_1.babelPresetExpoVersion,
|
|
64
|
+
});
|
|
47
65
|
}
|
|
48
66
|
exports.updateDependencies = updateDependencies;
|
|
49
67
|
function moveDependency(host) {
|
|
50
68
|
return (0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react-native'], []);
|
|
51
69
|
}
|
|
52
|
-
function addPlugin(host) {
|
|
53
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
54
|
-
if ((0, has_expo_plugin_1.hasExpoPlugin)(host)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
nxJson.plugins ??= [];
|
|
58
|
-
nxJson.plugins.push({
|
|
59
|
-
plugin: '@nx/expo/plugin',
|
|
60
|
-
options: {
|
|
61
|
-
startTargetName: 'start',
|
|
62
|
-
serveTargetName: 'serve',
|
|
63
|
-
runIosTargetName: 'run-ios',
|
|
64
|
-
runAndroidTargetName: 'run-android',
|
|
65
|
-
exportTargetName: 'export',
|
|
66
|
-
prebuildTargetName: 'prebuild',
|
|
67
|
-
installTargetName: 'install',
|
|
68
|
-
buildTargetName: 'build',
|
|
69
|
-
submitTargetName: 'submit',
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
73
|
-
}
|
|
74
70
|
exports.default = expoInitGenerator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface Schema {
|
|
2
|
+
unitTestRunner?: 'jest' | 'none';
|
|
2
3
|
skipFormat?: boolean;
|
|
4
|
+
e2eTestRunner?: 'detox' | 'none';
|
|
3
5
|
skipPackageJson?: boolean; // default is false
|
|
4
|
-
|
|
5
|
-
updatePackageScripts?: boolean;
|
|
6
|
-
addPlugin?: boolean;
|
|
6
|
+
js?: boolean;
|
|
7
7
|
}
|
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxExpoInit",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "http://json-schema.org/schema",
|
|
5
5
|
"description": "Add Nx Expo Schematics.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
|
+
"unitTestRunner": {
|
|
9
|
+
"description": "Adds the specified unit test runner",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"enum": ["jest", "none"],
|
|
12
|
+
"default": "jest"
|
|
13
|
+
},
|
|
8
14
|
"skipFormat": {
|
|
9
15
|
"description": "Skip formatting files",
|
|
10
16
|
"type": "boolean",
|
|
11
17
|
"default": false,
|
|
12
18
|
"x-priority": "internal"
|
|
13
19
|
},
|
|
20
|
+
"e2eTestRunner": {
|
|
21
|
+
"description": "Adds the specified e2e test runner",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"enum": ["detox", "none"],
|
|
24
|
+
"default": "detox"
|
|
25
|
+
},
|
|
14
26
|
"skipPackageJson": {
|
|
15
27
|
"type": "boolean",
|
|
16
28
|
"default": false,
|
|
17
29
|
"description": "Do not add dependencies to `package.json`."
|
|
18
30
|
},
|
|
19
|
-
"
|
|
31
|
+
"js": {
|
|
20
32
|
"type": "boolean",
|
|
21
|
-
"
|
|
22
|
-
"description": "
|
|
23
|
-
"default": false
|
|
24
|
-
},
|
|
25
|
-
"updatePackageScripts": {
|
|
26
|
-
"type": "boolean",
|
|
27
|
-
"x-priority": "internal",
|
|
28
|
-
"description": "Update `package.json` scripts with inferred targets",
|
|
29
|
-
"default": false
|
|
33
|
+
"default": false,
|
|
34
|
+
"description": "Use JavaScript instead of TypeScript"
|
|
30
35
|
}
|
|
31
36
|
},
|
|
32
37
|
"required": []
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
5
|
async function normalizeOptions(host, options) {
|
|
7
6
|
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
@@ -12,10 +11,6 @@ async function normalizeOptions(host, options) {
|
|
|
12
11
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
13
12
|
callingGenerator: '@nx/expo:library',
|
|
14
13
|
});
|
|
15
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
-
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
-
nxJson.useInferencePlugins !== false;
|
|
18
|
-
options.addPlugin ??= addPluginDefault;
|
|
19
14
|
const parsedTags = options.tags
|
|
20
15
|
? options.tags.split(',').map((s) => s.trim())
|
|
21
16
|
: [];
|
|
@@ -8,13 +8,8 @@ const add_linting_1 = require("../../utils/add-linting");
|
|
|
8
8
|
const add_jest_1 = require("../../utils/add-jest");
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
11
|
-
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
12
|
-
const init_root_babel_config_1 = require("../../utils/init-root-babel-config");
|
|
13
|
-
const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
|
|
14
|
-
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
15
11
|
async function expoLibraryGenerator(host, schema) {
|
|
16
12
|
return await expoLibraryGeneratorInternal(host, {
|
|
17
|
-
addPlugin: false,
|
|
18
13
|
projectNameAndRootFormat: 'derived',
|
|
19
14
|
...schema,
|
|
20
15
|
});
|
|
@@ -26,17 +21,12 @@ async function expoLibraryGeneratorInternal(host, schema) {
|
|
|
26
21
|
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)`);
|
|
27
22
|
}
|
|
28
23
|
const tasks = [];
|
|
29
|
-
const
|
|
30
|
-
...
|
|
24
|
+
const initTask = await (0, init_1.default)(host, {
|
|
25
|
+
...options,
|
|
31
26
|
skipFormat: true,
|
|
27
|
+
e2eTestRunner: 'none',
|
|
32
28
|
});
|
|
33
|
-
tasks.push(jsInitTask);
|
|
34
|
-
const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
|
|
35
29
|
tasks.push(initTask);
|
|
36
|
-
if (!options.skipPackageJson) {
|
|
37
|
-
tasks.push((0, ensure_dependencies_1.ensureDependencies)(host));
|
|
38
|
-
}
|
|
39
|
-
(0, init_root_babel_config_1.initRootBabelConfig)(host);
|
|
40
30
|
const addProjectTask = await addProject(host, options);
|
|
41
31
|
if (addProjectTask) {
|
|
42
32
|
tasks.push(addProjectTask);
|
|
@@ -50,7 +40,7 @@ async function expoLibraryGeneratorInternal(host, schema) {
|
|
|
50
40
|
],
|
|
51
41
|
});
|
|
52
42
|
tasks.push(lintTask);
|
|
53
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson
|
|
43
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson);
|
|
54
44
|
tasks.push(jestTask);
|
|
55
45
|
if (options.publishable || options.buildable) {
|
|
56
46
|
updateLibPackageNpmScope(host, options);
|
|
@@ -63,53 +53,49 @@ async function expoLibraryGeneratorInternal(host, schema) {
|
|
|
63
53
|
if (!options.skipFormat) {
|
|
64
54
|
await (0, devkit_1.formatFiles)(host);
|
|
65
55
|
}
|
|
66
|
-
tasks.push(() => {
|
|
67
|
-
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
68
|
-
});
|
|
69
56
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
70
57
|
}
|
|
71
58
|
exports.expoLibraryGeneratorInternal = expoLibraryGeneratorInternal;
|
|
72
59
|
async function addProject(host, options) {
|
|
73
|
-
const
|
|
60
|
+
const targets = {};
|
|
61
|
+
let task;
|
|
62
|
+
if (options.publishable || options.buildable) {
|
|
63
|
+
const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
64
|
+
const external = [
|
|
65
|
+
'react/jsx-runtime',
|
|
66
|
+
'react-native',
|
|
67
|
+
'react',
|
|
68
|
+
'react-dom',
|
|
69
|
+
];
|
|
70
|
+
targets.build = {
|
|
71
|
+
executor: '@nx/rollup:rollup',
|
|
72
|
+
outputs: ['{options.outputPath}'],
|
|
73
|
+
options: {
|
|
74
|
+
outputPath: `dist/${options.projectRoot}`,
|
|
75
|
+
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
76
|
+
project: `${options.projectRoot}/package.json`,
|
|
77
|
+
entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
|
|
78
|
+
external,
|
|
79
|
+
rollupConfig: `@nx/react/plugins/bundle-rollup`,
|
|
80
|
+
assets: [
|
|
81
|
+
{
|
|
82
|
+
glob: `${options.projectRoot}/README.md`,
|
|
83
|
+
input: '.',
|
|
84
|
+
output: '.',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
task = await rollupInitGenerator(host, { ...options, skipFormat: true });
|
|
90
|
+
}
|
|
91
|
+
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
74
92
|
root: options.projectRoot,
|
|
75
93
|
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
76
94
|
projectType: 'library',
|
|
77
95
|
tags: options.parsedTags,
|
|
78
|
-
targets
|
|
79
|
-
};
|
|
80
|
-
(0, devkit_1.addProjectConfiguration)(host, options.name, project);
|
|
81
|
-
if (!options.publishable && !options.buildable) {
|
|
82
|
-
return () => { };
|
|
83
|
-
}
|
|
84
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
85
|
-
const rollupConfigTask = await configurationGenerator(host, {
|
|
86
|
-
...options,
|
|
87
|
-
project: options.name,
|
|
88
|
-
skipFormat: true,
|
|
96
|
+
targets,
|
|
89
97
|
});
|
|
90
|
-
|
|
91
|
-
(0, add_build_target_defaults_1.addBuildTargetDefaults)(host, '@nx/rollup:rollup');
|
|
92
|
-
project.targets.build = {
|
|
93
|
-
executor: '@nx/rollup:rollup',
|
|
94
|
-
outputs: ['{options.outputPath}'],
|
|
95
|
-
options: {
|
|
96
|
-
outputPath: `dist/${options.projectRoot}`,
|
|
97
|
-
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
98
|
-
project: `${options.projectRoot}/package.json`,
|
|
99
|
-
entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
|
|
100
|
-
external,
|
|
101
|
-
rollupConfig: `@nx/react/plugins/bundle-rollup`,
|
|
102
|
-
assets: [
|
|
103
|
-
{
|
|
104
|
-
glob: `${options.projectRoot}/README.md`,
|
|
105
|
-
input: '.',
|
|
106
|
-
output: '.',
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.name, project);
|
|
112
|
-
return rollupConfigTask;
|
|
98
|
+
return task;
|
|
113
99
|
}
|
|
114
100
|
function updateTsConfig(tree, options) {
|
|
115
101
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxExpoLibrary",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "http://json-schema.org/schema",
|
|
5
5
|
"description": "Create a Expo Library for Nx.",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"examples": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"linter": {
|
|
35
35
|
"description": "The tool to use for running lint checks.",
|
|
36
36
|
"type": "string",
|
|
37
|
-
"enum": ["eslint"
|
|
37
|
+
"enum": ["eslint"],
|
|
38
38
|
"default": "eslint"
|
|
39
39
|
},
|
|
40
40
|
"unitTestRunner": {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
/**
|
|
5
|
+
* Add detox plugin to app.json for expo
|
|
6
|
+
*/
|
|
7
|
+
async function update(tree) {
|
|
8
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
|
+
projects.forEach((config) => {
|
|
10
|
+
if (config.targets?.['start']?.executor === '@nrwl/expo:start' ||
|
|
11
|
+
config.targets?.['start']?.executor === '@nx/expo:start') {
|
|
12
|
+
(0, devkit_1.updateJson)(tree, `${config.root}/app.json`, (json) => {
|
|
13
|
+
if (!json.expo.plugins) {
|
|
14
|
+
json.expo.plugins = [];
|
|
15
|
+
}
|
|
16
|
+
json.expo.plugins.push([
|
|
17
|
+
'@config-plugins/detox',
|
|
18
|
+
{
|
|
19
|
+
skipProguard: false,
|
|
20
|
+
subdomains: ['10.0.2.2', 'localhost'],
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
23
|
+
return json;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
29
|
+
exports.default = update;
|
|
@@ -32,6 +32,7 @@ const content = `
|
|
|
32
32
|
const { withNxMetro } = require('@nx/expo');
|
|
33
33
|
const { getDefaultConfig } = require('@expo/metro-config');
|
|
34
34
|
const { mergeConfig } = require('metro-config');
|
|
35
|
+
const exclusionList = require('metro-config/src/defaults/exclusionList');
|
|
35
36
|
|
|
36
37
|
const defaultConfig = getDefaultConfig(__dirname);
|
|
37
38
|
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
@@ -48,7 +49,10 @@ const customConfig = {
|
|
|
48
49
|
},
|
|
49
50
|
resolver: {
|
|
50
51
|
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
51
|
-
sourceExts: [...sourceExts, '
|
|
52
|
+
sourceExts: [...sourceExts, 'svg'],
|
|
53
|
+
blockList: exclusionList([/^(?!.*node_modules).*\\/dist\\/.*/]),
|
|
54
|
+
unstable_enableSymlinks: true,
|
|
55
|
+
unstable_enablePackageExports: true,
|
|
52
56
|
},
|
|
53
57
|
};
|
|
54
58
|
|
|
@@ -7,7 +7,14 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
async function update(tree) {
|
|
10
|
-
(0, devkit_1.
|
|
11
|
-
|
|
10
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
11
|
+
if (!packageJson.devDependencies['@types/react-native'] ||
|
|
12
|
+
!packageJson.dependencies['react-native']) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
16
|
+
delete packageJson.devDependencies['@types/react-native'];
|
|
17
|
+
return packageJson;
|
|
18
|
+
});
|
|
12
19
|
}
|
|
13
20
|
exports.default = update;
|