@nx/expo 18.0.0-beta.0 → 18.0.0-beta.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/.eslintrc.json +3 -0
- package/docs/export-examples.md +112 -0
- package/docs/start-examples.md +6 -0
- package/executors.json +5 -0
- package/generators.json +2 -2
- package/migrations.json +85 -6
- package/package.json +12 -16
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.js +10 -7
- package/plugins/with-nx-metro.js +6 -2
- package/plugins/with-nx-webpack.d.ts +1 -1
- package/plugins/with-nx-webpack.js +8 -4
- package/src/executors/build/build.impl.js +2 -1
- package/src/executors/build/schema.json +1 -1
- package/src/executors/build-list/build-list.impl.js +2 -3
- package/src/executors/build-list/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/export/export.impl.d.ts +1 -0
- package/src/executors/export/export.impl.js +25 -15
- package/src/executors/export/schema.d.ts +4 -2
- package/src/executors/export/schema.json +14 -13
- package/src/executors/install/install.impl.js +0 -2
- package/src/executors/install/schema.json +1 -1
- package/src/executors/prebuild/prebuild.impl.js +11 -5
- package/src/executors/prebuild/schema.json +2 -1
- package/src/executors/run/schema.json +1 -1
- package/src/executors/serve/lib/is-packager-running.d.ts +1 -0
- package/src/executors/serve/lib/is-packager-running.js +15 -0
- package/src/executors/serve/schema.d.ts +7 -0
- package/src/executors/serve/schema.json +35 -0
- package/src/executors/serve/serve.impl.d.ts +11 -0
- package/src/executors/serve/serve.impl.js +103 -0
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +7 -1
- package/src/executors/submit/schema.json +1 -1
- package/src/executors/submit/submit.impl.js +2 -1
- package/src/executors/sync-deps/schema.json +1 -1
- package/src/executors/sync-deps/sync-deps.impl.d.ts +4 -4
- package/src/executors/sync-deps/sync-deps.impl.js +20 -5
- package/src/executors/update/schema.json +1 -1
- package/src/executors/update/update.impl.js +3 -4
- package/src/generators/application/application.js +9 -7
- package/src/generators/application/files/app.json.template +2 -0
- package/src/generators/application/files/eas.json.template +0 -3
- package/src/generators/application/files/metro.config.js.template +0 -4
- package/src/generators/application/files/src/app/App.tsx.template +29 -2
- package/src/generators/application/files/webpack.config.js.template +57 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +85 -0
- package/src/generators/application/lib/add-project.js +12 -21
- package/src/generators/application/lib/create-application-files.js +0 -2
- package/src/generators/application/lib/normalize-options.d.ts +3 -0
- package/src/generators/application/lib/normalize-options.js +8 -1
- package/src/generators/application/schema.d.ts +2 -1
- package/src/generators/application/schema.json +4 -4
- 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 -1
- package/src/generators/init/init.js +9 -5
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +1 -1
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +1 -0
- package/src/generators/library/library.js +6 -1
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +2 -2
- package/src/migrations/update-16-6-0/update-metro-config.js +0 -4
- package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
- package/src/migrations/update-16-9-0/update-eas-cli-version.js +1 -2
- package/src/migrations/{update-16-1-4/add-detox-app-json.d.ts → update-18-0-0/change-outputDir-export-target.d.ts} +1 -1
- package/src/migrations/update-18-0-0/change-outputDir-export-target.js +25 -0
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-block-list.js +26 -0
- package/src/migrations/update-18-0-0/remove-eas-cli.d.ts +12 -0
- package/src/migrations/update-18-0-0/remove-eas-cli.js +18 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.js +29 -0
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +15 -5
- package/src/utils/add-linting.d.ts +1 -0
- package/src/utils/add-linting.js +1 -0
- package/src/utils/ensure-dependencies.js +1 -2
- package/src/utils/resolve-eas.d.ts +1 -0
- package/src/utils/resolve-eas.js +36 -0
- package/src/utils/versions.d.ts +13 -14
- package/src/utils/versions.js +14 -15
- package/src/generators/application/lib/add-detox.d.ts +0 -3
- package/src/generators/application/lib/add-detox.js +0 -24
- package/src/generators/library/files/lib/babel.config.json +0 -17
- package/src/migrations/update-16-1-4/add-detox-app-json.js +0 -29
- package/src/utils/find-all-npm-dependencies.d.ts +0 -2
- package/src/utils/find-all-npm-dependencies.js +0 -25
- package/src/utils/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
- /package/src/generators/application/files/{babel.config.js.template → .babelrc.js.template} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
|
|
2
|
+
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
|
|
3
|
+
const { resolve } = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use bundler: 'metro' instead
|
|
7
|
+
*/
|
|
8
|
+
module.exports = async function (env, argv) {
|
|
9
|
+
const config = await createExpoWebpackConfigAsync(env, argv);
|
|
10
|
+
|
|
11
|
+
// Customize the config before returning it.
|
|
12
|
+
// add additional rule to load files under libs
|
|
13
|
+
const rules = config.module.rules.find((rule) =>
|
|
14
|
+
Array.isArray(rule.oneOf)
|
|
15
|
+
)?.oneOf;
|
|
16
|
+
if (rules) {
|
|
17
|
+
rules.push({
|
|
18
|
+
test: /\.(mjs|[jt]sx?)$/,
|
|
19
|
+
exclude: /node_modules/,
|
|
20
|
+
use: {
|
|
21
|
+
loader: require.resolve('@nx/webpack/src/utils/web-babel-loader.js'),
|
|
22
|
+
options: {
|
|
23
|
+
presets: [
|
|
24
|
+
[
|
|
25
|
+
'@nx/react/babel',
|
|
26
|
+
{
|
|
27
|
+
runtime: 'automatic',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!config.resolve) {
|
|
37
|
+
config.resolve = {};
|
|
38
|
+
}
|
|
39
|
+
if (!config.resolve.plugins) {
|
|
40
|
+
config.resolve.plugins = [];
|
|
41
|
+
}
|
|
42
|
+
const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
|
|
43
|
+
const tsConfigPath = resolve(__dirname, 'tsconfig.json');
|
|
44
|
+
config.resolve.plugins.push(
|
|
45
|
+
new TsconfigPathsPlugin({
|
|
46
|
+
configFile: tsConfigPath,
|
|
47
|
+
extensions,
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
config.resolve.fallback = {
|
|
51
|
+
...config.resolve.fallback,
|
|
52
|
+
crypto: require.resolve('crypto-browserify'),
|
|
53
|
+
stream: require.resolve('stream-browserify'),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return config;
|
|
57
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addE2e = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const web_1 = require("@nx/web");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
|
|
8
|
+
async function addE2e(tree, options) {
|
|
9
|
+
switch (options.e2eTestRunner) {
|
|
10
|
+
case 'cypress': {
|
|
11
|
+
const hasNxExportPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(tree);
|
|
12
|
+
if (!hasNxExportPlugin) {
|
|
13
|
+
(0, web_1.webStaticServeGenerator)(tree, {
|
|
14
|
+
buildTarget: `${options.projectName}:export`,
|
|
15
|
+
targetName: 'serve-static',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
19
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
20
|
+
projectType: 'application',
|
|
21
|
+
root: options.e2eProjectRoot,
|
|
22
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
23
|
+
targets: {},
|
|
24
|
+
implicitDependencies: [options.projectName],
|
|
25
|
+
tags: [],
|
|
26
|
+
});
|
|
27
|
+
return await configurationGenerator(tree, {
|
|
28
|
+
...options,
|
|
29
|
+
project: options.e2eProjectName,
|
|
30
|
+
directory: 'src',
|
|
31
|
+
// the name and root are already normalized, instruct the generator to use them as is
|
|
32
|
+
bundler: 'none',
|
|
33
|
+
skipFormat: true,
|
|
34
|
+
devServerTarget: `${options.projectName}:serve`,
|
|
35
|
+
port: 4200,
|
|
36
|
+
baseUrl: 'http://localhost:4200',
|
|
37
|
+
ciWebServerCommand: hasNxExportPlugin
|
|
38
|
+
? `nx run ${options.projectName}:serve-static`
|
|
39
|
+
: undefined,
|
|
40
|
+
jsx: true,
|
|
41
|
+
rootProject: options.rootProject,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
case 'playwright': {
|
|
45
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
46
|
+
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
|
47
|
+
projectType: 'application',
|
|
48
|
+
root: options.e2eProjectRoot,
|
|
49
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
50
|
+
targets: {},
|
|
51
|
+
implicitDependencies: [options.projectName],
|
|
52
|
+
});
|
|
53
|
+
return configurationGenerator(tree, {
|
|
54
|
+
project: options.e2eProjectName,
|
|
55
|
+
skipFormat: true,
|
|
56
|
+
skipPackageJson: options.skipPackageJson,
|
|
57
|
+
directory: 'src',
|
|
58
|
+
js: false,
|
|
59
|
+
linter: options.linter,
|
|
60
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
61
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
|
|
62
|
+
webServerAddress: 'http://localhost:4200',
|
|
63
|
+
rootProject: options.rootProject,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
case 'detox':
|
|
67
|
+
const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
|
|
68
|
+
return detoxApplicationGenerator(tree, {
|
|
69
|
+
...options,
|
|
70
|
+
e2eName: options.e2eProjectName,
|
|
71
|
+
e2eDirectory: options.e2eProjectRoot,
|
|
72
|
+
projectNameAndRootFormat: 'as-provided',
|
|
73
|
+
appProject: options.projectName,
|
|
74
|
+
appDisplayName: options.displayName,
|
|
75
|
+
appName: options.name,
|
|
76
|
+
framework: 'expo',
|
|
77
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
78
|
+
skipFormat: true,
|
|
79
|
+
});
|
|
80
|
+
case 'none':
|
|
81
|
+
default:
|
|
82
|
+
return () => { };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.addE2e = addE2e;
|
|
@@ -24,33 +24,33 @@ function getTargets(options) {
|
|
|
24
24
|
const architect = {};
|
|
25
25
|
architect.start = {
|
|
26
26
|
executor: '@nx/expo:start',
|
|
27
|
-
dependsOn: ['
|
|
28
|
-
options: {
|
|
29
|
-
port: 8081,
|
|
30
|
-
},
|
|
27
|
+
dependsOn: ['sync-deps'],
|
|
28
|
+
options: {},
|
|
31
29
|
};
|
|
32
30
|
architect.serve = {
|
|
33
|
-
executor: 'nx:
|
|
31
|
+
executor: '@nx/expo:serve',
|
|
32
|
+
dependsOn: ['sync-deps'],
|
|
34
33
|
options: {
|
|
35
|
-
|
|
34
|
+
port: 4200,
|
|
36
35
|
},
|
|
37
36
|
};
|
|
38
37
|
architect['run-ios'] = {
|
|
39
38
|
executor: '@nx/expo:run',
|
|
40
|
-
dependsOn: ['
|
|
39
|
+
dependsOn: ['sync-deps'],
|
|
41
40
|
options: {
|
|
42
41
|
platform: 'ios',
|
|
43
42
|
},
|
|
44
43
|
};
|
|
45
44
|
architect['run-android'] = {
|
|
46
45
|
executor: '@nx/expo:run',
|
|
47
|
-
dependsOn: ['
|
|
46
|
+
dependsOn: ['sync-deps'],
|
|
48
47
|
options: {
|
|
49
48
|
platform: 'android',
|
|
50
49
|
},
|
|
51
50
|
};
|
|
52
51
|
architect['build'] = {
|
|
53
52
|
executor: '@nx/expo:build',
|
|
53
|
+
dependsOn: ['sync-deps'],
|
|
54
54
|
options: {},
|
|
55
55
|
};
|
|
56
56
|
architect['submit'] = {
|
|
@@ -65,13 +65,9 @@ function getTargets(options) {
|
|
|
65
65
|
executor: '@nx/expo:sync-deps',
|
|
66
66
|
options: {},
|
|
67
67
|
};
|
|
68
|
-
architect['ensure-symlink'] = {
|
|
69
|
-
executor: '@nx/expo:ensure-symlink',
|
|
70
|
-
options: {},
|
|
71
|
-
};
|
|
72
68
|
architect['prebuild'] = {
|
|
73
69
|
executor: '@nx/expo:prebuild',
|
|
74
|
-
dependsOn: ['
|
|
70
|
+
dependsOn: ['sync-deps'],
|
|
75
71
|
options: {},
|
|
76
72
|
};
|
|
77
73
|
architect['install'] = {
|
|
@@ -84,16 +80,11 @@ function getTargets(options) {
|
|
|
84
80
|
};
|
|
85
81
|
architect['export'] = {
|
|
86
82
|
executor: '@nx/expo:export',
|
|
87
|
-
dependsOn: ['
|
|
83
|
+
dependsOn: ['sync-deps'],
|
|
84
|
+
outputs: ['{options.outputDir}'],
|
|
88
85
|
options: {
|
|
89
86
|
platform: 'all',
|
|
90
|
-
outputDir:
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
architect['export-web'] = {
|
|
94
|
-
executor: '@nx/expo:export',
|
|
95
|
-
options: {
|
|
96
|
-
bundler: 'metro',
|
|
87
|
+
outputDir: `dist/${options.appProjectRoot}`,
|
|
97
88
|
},
|
|
98
89
|
};
|
|
99
90
|
return architect;
|
|
@@ -3,7 +3,6 @@ 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");
|
|
7
6
|
function createApplicationFiles(host, options) {
|
|
8
7
|
const packageManagerLockFile = {
|
|
9
8
|
npm: 'package-lock.json',
|
|
@@ -17,7 +16,6 @@ function createApplicationFiles(host, options) {
|
|
|
17
16
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
18
17
|
packageManager,
|
|
19
18
|
packageLockFile,
|
|
20
|
-
easCliVersion: versions_1.easCliVersion,
|
|
21
19
|
});
|
|
22
20
|
if (options.unitTestRunner === 'none') {
|
|
23
21
|
host.delete((0, path_1.join)(options.appProjectRoot, `App.spec.tsx`));
|
|
@@ -6,5 +6,8 @@ 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;
|
|
9
12
|
}
|
|
10
13
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -12,14 +12,18 @@ async function normalizeOptions(host, options) {
|
|
|
12
12
|
callingGenerator: '@nx/expo:application',
|
|
13
13
|
});
|
|
14
14
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
15
16
|
const { className } = (0, devkit_1.names)(options.name);
|
|
16
17
|
const parsedTags = options.tags
|
|
17
18
|
? options.tags.split(',').map((s) => s.trim())
|
|
18
19
|
: [];
|
|
20
|
+
const rootProject = appProjectRoot === '.';
|
|
21
|
+
const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
22
|
+
const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
19
23
|
return {
|
|
20
24
|
...options,
|
|
21
25
|
unitTestRunner: options.unitTestRunner || 'jest',
|
|
22
|
-
e2eTestRunner: options.e2eTestRunner
|
|
26
|
+
e2eTestRunner: options.e2eTestRunner,
|
|
23
27
|
name: projectNames.projectSimpleName,
|
|
24
28
|
className,
|
|
25
29
|
lowerCaseName: className.toLowerCase(),
|
|
@@ -27,6 +31,9 @@ async function normalizeOptions(host, options) {
|
|
|
27
31
|
projectName: appProjectName,
|
|
28
32
|
appProjectRoot,
|
|
29
33
|
parsedTags,
|
|
34
|
+
rootProject,
|
|
35
|
+
e2eProjectName,
|
|
36
|
+
e2eProjectRoot,
|
|
30
37
|
};
|
|
31
38
|
}
|
|
32
39
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -15,7 +15,8 @@ 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: 'detox' | 'none'; // default is
|
|
18
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none'; // default is cypress
|
|
19
19
|
standaloneConfig?: boolean;
|
|
20
20
|
skipPackageJson?: boolean; // default is false
|
|
21
|
+
addPlugin?: boolean;
|
|
21
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxExpoApplication",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://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", "none"],
|
|
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": ["detox", "none"],
|
|
79
|
-
"default": "
|
|
78
|
+
"enum": ["cypress", "playwright", "detox", "none"],
|
|
79
|
+
"default": "cypress"
|
|
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 v19.
|
|
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 v19.
|
|
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 v19.
|
|
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": "https://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 v19."
|
|
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 v19."
|
|
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 v19."
|
|
81
81
|
},
|
|
82
82
|
"classComponent": {
|
|
83
83
|
"type": "boolean",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
-
export declare function expoInitGenerator(
|
|
3
|
+
export declare function expoInitGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function expoInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
|
|
5
6
|
export default expoInitGenerator;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDependencies = exports.expoInitGenerator = void 0;
|
|
3
|
+
exports.updateDependencies = exports.expoInitGeneratorInternal = exports.expoInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
6
|
const plugin_1 = require("../../../plugins/plugin");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
8
|
const has_expo_plugin_1 = require("../../utils/has-expo-plugin");
|
|
9
9
|
const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
10
|
-
|
|
10
|
+
function expoInitGenerator(tree, schema) {
|
|
11
|
+
return expoInitGeneratorInternal(tree, { addPlugin: false, ...schema });
|
|
12
|
+
}
|
|
13
|
+
exports.expoInitGenerator = expoInitGenerator;
|
|
14
|
+
async function expoInitGeneratorInternal(host, schema) {
|
|
15
|
+
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
11
16
|
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
|
|
12
|
-
if (
|
|
17
|
+
if (schema.addPlugin) {
|
|
13
18
|
addPlugin(host);
|
|
14
19
|
}
|
|
15
20
|
const tasks = [];
|
|
@@ -25,7 +30,7 @@ async function expoInitGenerator(host, schema) {
|
|
|
25
30
|
}
|
|
26
31
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
27
32
|
}
|
|
28
|
-
exports.
|
|
33
|
+
exports.expoInitGeneratorInternal = expoInitGeneratorInternal;
|
|
29
34
|
function updateDependencies(host, schema) {
|
|
30
35
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
31
36
|
react: versions_1.reactVersion,
|
|
@@ -35,7 +40,6 @@ function updateDependencies(host, schema) {
|
|
|
35
40
|
}, {
|
|
36
41
|
'@nx/expo': versions_1.nxVersion,
|
|
37
42
|
'@expo/cli': versions_1.expoCliVersion,
|
|
38
|
-
'eas-cli': versions_1.easCliVersion,
|
|
39
43
|
}, undefined, schema.keepExistingVersions);
|
|
40
44
|
}
|
|
41
45
|
exports.updateDependencies = updateDependencies;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
presets: [
|
|
6
|
+
[
|
|
7
|
+
'@nx/react/babel',
|
|
8
|
+
{
|
|
9
|
+
runtime: 'automatic',
|
|
10
|
+
useBuiltIns: 'usage',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
],
|
|
14
|
+
plugins: [],
|
|
15
|
+
env: {
|
|
16
|
+
test: {
|
|
17
|
+
presets: ['babel-preset-expo'],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -11,6 +11,7 @@ async function normalizeOptions(host, options) {
|
|
|
11
11
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
12
|
callingGenerator: '@nx/expo:library',
|
|
13
13
|
});
|
|
14
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
14
15
|
const parsedTags = options.tags
|
|
15
16
|
? options.tags.split(',').map((s) => s.trim())
|
|
16
17
|
: [];
|
|
@@ -11,8 +11,10 @@ const normalize_options_1 = require("./lib/normalize-options");
|
|
|
11
11
|
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
12
12
|
const init_root_babel_config_1 = require("../../utils/init-root-babel-config");
|
|
13
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");
|
|
14
15
|
async function expoLibraryGenerator(host, schema) {
|
|
15
16
|
return await expoLibraryGeneratorInternal(host, {
|
|
17
|
+
addPlugin: false,
|
|
16
18
|
projectNameAndRootFormat: 'derived',
|
|
17
19
|
...schema,
|
|
18
20
|
});
|
|
@@ -48,7 +50,7 @@ async function expoLibraryGeneratorInternal(host, schema) {
|
|
|
48
50
|
],
|
|
49
51
|
});
|
|
50
52
|
tasks.push(lintTask);
|
|
51
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson);
|
|
53
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
|
|
52
54
|
tasks.push(jestTask);
|
|
53
55
|
if (options.publishable || options.buildable) {
|
|
54
56
|
updateLibPackageNpmScope(host, options);
|
|
@@ -61,6 +63,9 @@ async function expoLibraryGeneratorInternal(host, schema) {
|
|
|
61
63
|
if (!options.skipFormat) {
|
|
62
64
|
await (0, devkit_1.formatFiles)(host);
|
|
63
65
|
}
|
|
66
|
+
tasks.push(() => {
|
|
67
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
68
|
+
});
|
|
64
69
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
65
70
|
}
|
|
66
71
|
exports.expoLibraryGeneratorInternal = expoLibraryGeneratorInternal;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxExpoLibrary",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://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", "none"],
|
|
38
38
|
"default": "eslint"
|
|
39
39
|
},
|
|
40
40
|
"unitTestRunner": {
|
|
@@ -32,7 +32,6 @@ 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');
|
|
36
35
|
|
|
37
36
|
const defaultConfig = getDefaultConfig(__dirname);
|
|
38
37
|
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
@@ -50,9 +49,6 @@ const customConfig = {
|
|
|
50
49
|
resolver: {
|
|
51
50
|
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
52
51
|
sourceExts: [...sourceExts, 'svg'],
|
|
53
|
-
blockList: exclusionList([/^(?!.*node_modules).*\\/dist\\/.*/]),
|
|
54
|
-
unstable_enableSymlinks: true,
|
|
55
|
-
unstable_enablePackageExports: true,
|
|
56
52
|
},
|
|
57
53
|
};
|
|
58
54
|
|
|
@@ -7,14 +7,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
async function update(tree) {
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
});
|
|
10
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['@types/react-native']);
|
|
11
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
12
|
}
|
|
20
13
|
exports.default = update;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const versions_1 = require("../../utils/versions");
|
|
5
4
|
async function update(tree) {
|
|
6
5
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
6
|
for (const [name, config] of projects.entries()) {
|
|
8
7
|
if (config.targets?.['start']?.executor === '@nx/expo:start') {
|
|
9
8
|
(0, devkit_1.updateJson)(tree, `${config.root}/eas.json`, (easJson) => {
|
|
10
9
|
if (easJson?.cli?.version) {
|
|
11
|
-
easJson.cli.version = `>=
|
|
10
|
+
easJson.cli.version = `>= 5`;
|
|
12
11
|
}
|
|
13
12
|
return easJson;
|
|
14
13
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
/**
|
|
5
|
+
* Remove the offset from the outputDir of the export target
|
|
6
|
+
*/
|
|
7
|
+
async function update(tree) {
|
|
8
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
|
+
for (const [projectName, config] of projects.entries()) {
|
|
10
|
+
if (config.targets?.['export']?.executor === '@nx/expo:export') {
|
|
11
|
+
const target = config.targets['export'];
|
|
12
|
+
if (target.options?.outputDir) {
|
|
13
|
+
const offset = (0, devkit_1.offsetFromRoot)(config.root);
|
|
14
|
+
target.options.outputDir = target.options.outputDir.replace(offset, '');
|
|
15
|
+
target.outputs = ['{options.outputDir}'];
|
|
16
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (config.targets?.['export-web']?.executor === '@nx/expo:export') {
|
|
20
|
+
delete config.targets['export-web'];
|
|
21
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = update;
|