@nx/expo 17.0.2 → 17.0.4
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/LICENSE +1 -1
- package/README.md +9 -4
- 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 +114 -6
- package/package.json +12 -16
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +150 -0
- 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 +105 -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.d.ts +1 -0
- package/src/executors/sync-deps/schema.json +6 -1
- package/src/executors/sync-deps/sync-deps.impl.d.ts +4 -3
- package/src/executors/sync-deps/sync-deps.impl.js +33 -11
- package/src/executors/update/schema.json +1 -1
- package/src/executors/update/update.impl.js +7 -4
- package/src/generators/application/application.js +27 -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 +1 -5
- package/src/generators/application/files/src/app/App.tsx.template +50 -13
- 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 +86 -0
- package/src/generators/application/lib/add-project.js +20 -22
- package/src/generators/application/lib/create-application-files.js +0 -2
- package/src/generators/application/lib/normalize-options.d.ts +6 -0
- package/src/generators/application/lib/normalize-options.js +33 -1
- package/src/generators/application/schema.d.ts +2 -1
- 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 +3 -2
- package/src/generators/init/init.js +44 -40
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +11 -16
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +5 -0
- package/src/generators/library/library.js +52 -38
- 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 +1 -5
- 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 +28 -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 -1
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +24 -0
- package/src/utils/find-all-npm-dependencies.js +4 -2
- package/src/utils/has-expo-plugin.d.ts +2 -0
- package/src/utils/has-expo-plugin.js +11 -0
- package/src/utils/resolve-eas.d.ts +1 -0
- package/src/utils/resolve-eas.js +36 -0
- package/src/utils/versions.d.ts +14 -15
- package/src/utils/versions.js +15 -16
- package/collection.json +0 -0
- 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/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
- /package/src/{generators/init/lib → utils}/init-root-babel-config.d.ts +0 -0
- /package/src/{generators/init/lib → utils}/init-root-babel-config.js +0 -0
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
const resolve_eas_1 = require("../../utils/resolve-eas");
|
|
6
7
|
let childProcess;
|
|
7
8
|
async function* buildExecutor(options, context) {
|
|
8
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
@@ -19,7 +20,7 @@ async function* buildExecutor(options, context) {
|
|
|
19
20
|
exports.default = buildExecutor;
|
|
20
21
|
function runCliBuild(workspaceRoot, projectRoot, options) {
|
|
21
22
|
return new Promise((resolve, reject) => {
|
|
22
|
-
childProcess = (0, child_process_1.fork)(
|
|
23
|
+
childProcess = (0, child_process_1.fork)((0, resolve_eas_1.resolveEas)(workspaceRoot), ['build', ...createBuildOptions(options)], {
|
|
23
24
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
24
25
|
env: process.env,
|
|
25
26
|
});
|
|
@@ -4,11 +4,10 @@ exports.runCliBuildList = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
7
|
-
const
|
|
7
|
+
const resolve_eas_1 = require("../../utils/resolve-eas");
|
|
8
8
|
let childProcess;
|
|
9
9
|
async function* buildListExecutor(options, context) {
|
|
10
10
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
11
|
-
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
12
11
|
try {
|
|
13
12
|
if (options.json) {
|
|
14
13
|
// when json is true, interactive has to be false
|
|
@@ -26,7 +25,7 @@ async function* buildListExecutor(options, context) {
|
|
|
26
25
|
exports.default = buildListExecutor;
|
|
27
26
|
function runCliBuildList(workspaceRoot, projectRoot, options) {
|
|
28
27
|
return new Promise((resolve, reject) => {
|
|
29
|
-
childProcess = (0, child_process_1.fork)(
|
|
28
|
+
childProcess = (0, child_process_1.fork)((0, resolve_eas_1.resolveEas)(workspaceRoot), ['build:list', ...createBuildListOptions(options)], {
|
|
30
29
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
31
30
|
env: process.env,
|
|
32
31
|
stdio: ['inherit', 'pipe', 'inherit', 'ipc'], // only stream stdout on child process
|
|
@@ -2,4 +2,8 @@ import { ExecutorContext } from '@nx/devkit';
|
|
|
2
2
|
export interface ExpoEnsureSymlinkOutput {
|
|
3
3
|
success: boolean;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
7
|
+
* @deprecated It is no longer needed for react native 73.
|
|
8
|
+
*/
|
|
5
9
|
export default function ensureSymlinkExecutor(_: any, context: ExecutorContext): AsyncGenerator<ExpoEnsureSymlinkOutput>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
4
|
+
/**
|
|
5
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
6
|
+
* @deprecated It is no longer needed for react native 73.
|
|
7
|
+
*/
|
|
4
8
|
async function* ensureSymlinkExecutor(_, context) {
|
|
5
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
6
10
|
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxExpoEnsureSymlink",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Ensure Symlink for Expo",
|
|
8
8
|
"description": "Ensure workspace node_modules is symlink under app's node_modules folder.",
|
|
9
9
|
"type": "object",
|
|
@@ -4,3 +4,4 @@ export interface ExpoExportOutput {
|
|
|
4
4
|
success: boolean;
|
|
5
5
|
}
|
|
6
6
|
export default function exportExecutor(options: ExportExecutorSchema, context: ExecutorContext): AsyncGenerator<ExpoExportOutput>;
|
|
7
|
+
export declare function createExportOptions(options: ExportExecutorSchema, projectRoot: string): any[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createExportOptions = void 0;
|
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
|
4
5
|
const child_process_1 = require("child_process");
|
|
5
6
|
const path_1 = require("path");
|
|
@@ -21,11 +22,7 @@ async function* exportExecutor(options, context) {
|
|
|
21
22
|
exports.default = exportExecutor;
|
|
22
23
|
function exportAsync(workspaceRoot, projectRoot, options) {
|
|
23
24
|
return new Promise((resolve, reject) => {
|
|
24
|
-
childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), [
|
|
25
|
-
`export${options.bundler === 'webpack' ? ':web' : ''}`,
|
|
26
|
-
'.',
|
|
27
|
-
...createExportOptions(options),
|
|
28
|
-
], { cwd: (0, path_1.resolve)(workspaceRoot, projectRoot), env: process.env });
|
|
25
|
+
childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), [`export`, ...createExportOptions(options, projectRoot)], { cwd: (0, path_1.resolve)(workspaceRoot, projectRoot), env: process.env });
|
|
29
26
|
// Ensure the child process is killed when the parent exits
|
|
30
27
|
process.on('exit', () => childProcess.kill());
|
|
31
28
|
process.on('SIGTERM', () => childProcess.kill());
|
|
@@ -42,22 +39,35 @@ function exportAsync(workspaceRoot, projectRoot, options) {
|
|
|
42
39
|
});
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
|
-
const nxOptions = ['bundler'];
|
|
42
|
+
const nxOptions = ['bundler', 'interactive']; // interactive is passed in by e2e tests
|
|
46
43
|
// options from https://github.com/expo/expo/blob/main/packages/@expo/cli/src/export/index.ts
|
|
47
|
-
function createExportOptions(options) {
|
|
44
|
+
function createExportOptions(options, projectRoot) {
|
|
48
45
|
return Object.keys(options).reduce((acc, k) => {
|
|
49
46
|
if (!nxOptions.includes(k)) {
|
|
50
47
|
const v = options[k];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
acc.push(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
switch (k) {
|
|
49
|
+
case 'outputDir':
|
|
50
|
+
const path = (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(projectRoot), v); // need to add offset for the outputDir
|
|
51
|
+
acc.push('--output-dir', path);
|
|
52
|
+
break;
|
|
53
|
+
case 'minify':
|
|
54
|
+
if (v === false) {
|
|
55
|
+
acc.push('--no-minify'); // cli only accpets --no-minify
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
if (typeof v === 'boolean') {
|
|
60
|
+
if (v === true) {
|
|
61
|
+
// when true, does not need to pass the value true, just need to pass the flag in kebob case
|
|
62
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`, v);
|
|
67
|
+
}
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
return acc;
|
|
62
71
|
}, []);
|
|
63
72
|
}
|
|
73
|
+
exports.createExportOptions = createExportOptions;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// options form https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/export/resolveOptions.ts
|
|
2
|
+
// https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/export/index.ts
|
|
3
|
+
|
|
2
4
|
export interface ExportExecutorSchema {
|
|
3
5
|
platform?: 'ios' | 'android' | 'all' | 'web'; // default is 'all'
|
|
4
6
|
outputDir?: string;
|
|
5
7
|
clear?: boolean;
|
|
6
8
|
dev?: boolean;
|
|
9
|
+
minify?: boolean;
|
|
7
10
|
maxWorkers?: number;
|
|
8
11
|
dumpAssetmap?: boolean;
|
|
9
|
-
|
|
10
|
-
bundler: 'metro' | 'webpack';
|
|
12
|
+
sourcemap?: boolean;
|
|
11
13
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"version": 2,
|
|
4
4
|
"outputCapture": "direct-nodejs",
|
|
5
5
|
"$id": "NxExpoExport",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Expo Export",
|
|
8
8
|
"description": "Export the JavaScript and assets for your app using Metro/webpack bundler.",
|
|
9
9
|
"type": "object",
|
|
@@ -11,38 +11,39 @@
|
|
|
11
11
|
"platform": {
|
|
12
12
|
"description": "Choose the platform to compile for",
|
|
13
13
|
"enum": ["ios", "android", "all", "web"],
|
|
14
|
+
"default": "all",
|
|
14
15
|
"alias": "p",
|
|
15
16
|
"x-priority": "important"
|
|
16
17
|
},
|
|
17
18
|
"dev": {
|
|
18
19
|
"type": "boolean",
|
|
19
|
-
"description": "
|
|
20
|
+
"description": "Configure static files for developing locally using a non-https server"
|
|
20
21
|
},
|
|
21
22
|
"clear": {
|
|
22
23
|
"type": "boolean",
|
|
23
24
|
"description": "Clear the bundler cache before exporting"
|
|
24
25
|
},
|
|
26
|
+
"minify": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Minify source"
|
|
29
|
+
},
|
|
25
30
|
"outputDir": {
|
|
26
31
|
"type": "string",
|
|
27
|
-
"description": "
|
|
32
|
+
"description": "Relative to workspace root, the directory to export the static files to. Default: dist"
|
|
28
33
|
},
|
|
29
34
|
"maxWorkers": {
|
|
30
35
|
"type": "number",
|
|
31
|
-
"description": "
|
|
36
|
+
"description": "When bundler is metro, the maximum number of tasks to allow the bundler to spawn"
|
|
32
37
|
},
|
|
33
38
|
"dumpAssetmap": {
|
|
34
39
|
"type": "boolean",
|
|
35
|
-
"description": "
|
|
40
|
+
"description": "When bundler is metro, whether to dump the asset map for further processing"
|
|
36
41
|
},
|
|
37
|
-
"
|
|
42
|
+
"sourceMaps": {
|
|
38
43
|
"type": "boolean",
|
|
39
|
-
"description": "
|
|
40
|
-
},
|
|
41
|
-
"bundler": {
|
|
42
|
-
"enum": ["metro", "webpack"],
|
|
43
|
-
"description": "Choose the bundler to compile for",
|
|
44
|
-
"default": "metro"
|
|
44
|
+
"description": "When bundler is metro, whether to emit JavaScript source maps"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
"required": []
|
|
47
|
+
"required": ["platform"],
|
|
48
|
+
"examplesFile": "../../../docs/export-examples.md"
|
|
48
49
|
}
|
|
@@ -3,13 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.installAsync = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
-
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
7
6
|
let childProcess;
|
|
8
7
|
async function* installExecutor(options, context) {
|
|
9
8
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
10
9
|
try {
|
|
11
10
|
await installAsync(context.root, options);
|
|
12
|
-
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
13
11
|
yield {
|
|
14
12
|
success: true,
|
|
15
13
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"version": 2,
|
|
4
4
|
"outputCapture": "direct-nodejs",
|
|
5
5
|
"$id": "NxExpoInstall",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Expo Install",
|
|
8
8
|
"description": "Install a module or other package to a project.",
|
|
9
9
|
"type": "object",
|
|
@@ -4,17 +4,15 @@ exports.prebuildAsync = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
8
7
|
const pod_install_task_1 = require("../../utils/pod-install-task");
|
|
9
8
|
const install_impl_1 = require("../install/install.impl");
|
|
10
9
|
let childProcess;
|
|
11
10
|
async function* prebuildExecutor(options, context) {
|
|
12
11
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
13
|
-
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
14
12
|
try {
|
|
15
13
|
await prebuildAsync(context.root, projectRoot, options);
|
|
16
14
|
if (options.install) {
|
|
17
|
-
await (0, install_impl_1.installAsync)(
|
|
15
|
+
await (0, install_impl_1.installAsync)(devkit_1.workspaceRoot, {});
|
|
18
16
|
if (options.platform === 'ios') {
|
|
19
17
|
(0, pod_install_task_1.podInstall)((0, path_1.join)(context.root, projectRoot, 'ios'));
|
|
20
18
|
}
|
|
@@ -50,13 +48,21 @@ function prebuildAsync(workspaceRoot, projectRoot, options) {
|
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
50
|
exports.prebuildAsync = prebuildAsync;
|
|
53
|
-
const nxOptions = ['install', 'interactive'];
|
|
51
|
+
const nxOptions = ['install', 'interactive']; // interactive is passed in by e2e tests
|
|
54
52
|
// options from https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/prebuild/index.ts
|
|
55
53
|
function createPrebuildOptions(options) {
|
|
56
54
|
return Object.keys(options).reduce((acc, k) => {
|
|
57
55
|
if (!nxOptions.includes(k)) {
|
|
58
56
|
const v = options[k];
|
|
59
|
-
|
|
57
|
+
if (typeof v === 'boolean') {
|
|
58
|
+
if (v === true) {
|
|
59
|
+
// when true, does not need to pass the value true, just need to pass the flag in kebob case
|
|
60
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`, v);
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
return acc;
|
|
62
68
|
}, []);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"version": 2,
|
|
4
4
|
"outputCapture": "direct-nodejs",
|
|
5
5
|
"$id": "NxExpoPrebuild",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Expo Prebuild",
|
|
8
8
|
"description": "Create native iOS and Android project files for building natively.",
|
|
9
9
|
"type": "object",
|
|
@@ -31,5 +31,6 @@
|
|
|
31
31
|
"description": "Project template to clone from. File path pointing to a local tar file or a github repo"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
+
"required": ["platform"],
|
|
34
35
|
"examplesFile": "../../../docs/prebuild-examples.md"
|
|
35
36
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxExpoRun",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Run iOS or Android application",
|
|
8
8
|
"description": "Run Expo target options.",
|
|
9
9
|
"type": "object",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isPackagerRunning(packagerPort: number): Promise<'running' | 'not_running' | 'unrecognized'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPackagerRunning = void 0;
|
|
4
|
+
const node_fetch_1 = require("node-fetch");
|
|
5
|
+
async function isPackagerRunning(packagerPort) {
|
|
6
|
+
try {
|
|
7
|
+
const resp = await (0, node_fetch_1.default)(`http://localhost:${packagerPort}/status`);
|
|
8
|
+
const data = await resp.text();
|
|
9
|
+
return data === 'packager-status:running' ? 'running' : 'unrecognized';
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return 'not_running';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.isPackagerRunning = isPackagerRunning;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"$id": "NxExpoServe",
|
|
6
|
+
"$schema": "http://json-schema.org/schema",
|
|
7
|
+
"title": "Serve web app for Expo",
|
|
8
|
+
"description": "Packager Server target options.",
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"port": {
|
|
12
|
+
"type": "number",
|
|
13
|
+
"description": "Port to start the native Metro bundler on (does not apply to web or tunnel)",
|
|
14
|
+
"default": 4200,
|
|
15
|
+
"alias": "p"
|
|
16
|
+
},
|
|
17
|
+
"clear": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Clear the Metro bundler cache",
|
|
20
|
+
"alias": "c"
|
|
21
|
+
},
|
|
22
|
+
"maxWorkers": {
|
|
23
|
+
"type": "number",
|
|
24
|
+
"description": "Maximum number of tasks to allow Metro to spawn"
|
|
25
|
+
},
|
|
26
|
+
"dev": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Turn development mode on or off"
|
|
29
|
+
},
|
|
30
|
+
"minify": {
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"description": "Whether or not to minify code"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
3
|
+
import { ChildProcess } from 'child_process';
|
|
4
|
+
import { ExpoServeExecutorSchema } from './schema';
|
|
5
|
+
export interface ExpoServeOutput {
|
|
6
|
+
port?: number;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
success: boolean;
|
|
9
|
+
}
|
|
10
|
+
export default function serveExecutor(options: ExpoServeExecutorSchema, context: ExecutorContext): AsyncGenerator<ExpoServeOutput>;
|
|
11
|
+
export declare function runCliServe(workspaceRoot: string, projectRoot: string, options: ExpoServeExecutorSchema): Promise<ChildProcess>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCliServe = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const is_packager_running_1 = require("./lib/is-packager-running");
|
|
8
|
+
async function* serveExecutor(options, context) {
|
|
9
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
10
|
+
const serveProcess = await runCliServe(context.root, projectRoot, options);
|
|
11
|
+
yield {
|
|
12
|
+
port: options.port,
|
|
13
|
+
baseUrl: `http://localhost:${options.port}`,
|
|
14
|
+
success: true,
|
|
15
|
+
};
|
|
16
|
+
if (!serveProcess) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
await new Promise((resolve) => {
|
|
20
|
+
const processExitListener = (signal) => () => {
|
|
21
|
+
serveProcess.kill(signal);
|
|
22
|
+
resolve();
|
|
23
|
+
process.exit();
|
|
24
|
+
};
|
|
25
|
+
process.once('exit', (signal) => serveProcess.kill(signal));
|
|
26
|
+
process.once('SIGTERM', processExitListener);
|
|
27
|
+
process.once('SIGINT', processExitListener);
|
|
28
|
+
process.once('SIGQUIT', processExitListener);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
exports.default = serveExecutor;
|
|
32
|
+
async function runCliServe(workspaceRoot, projectRoot, options) {
|
|
33
|
+
const result = await (0, is_packager_running_1.isPackagerRunning)(options.port);
|
|
34
|
+
if (result === 'running') {
|
|
35
|
+
devkit_1.logger.info(`JS server already running on port ${options.port}.`);
|
|
36
|
+
}
|
|
37
|
+
else if (result === 'unrecognized') {
|
|
38
|
+
devkit_1.logger.warn('JS server not recognized.');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// result === 'not_running'
|
|
42
|
+
devkit_1.logger.info('Starting JS server...');
|
|
43
|
+
try {
|
|
44
|
+
return await serveAsync(workspaceRoot, projectRoot, options);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
devkit_1.logger.error(`Failed to serve the packager server. Error details: ${error.message}`);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.runCliServe = runCliServe;
|
|
53
|
+
function serveAsync(workspaceRoot, projectRoot, options) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), ['start', '--web', ...createServeOptions(options)], {
|
|
56
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
57
|
+
env: process.env,
|
|
58
|
+
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
|
59
|
+
});
|
|
60
|
+
childProcess.stdout.on('data', (data) => {
|
|
61
|
+
process.stdout.write(data);
|
|
62
|
+
if (data
|
|
63
|
+
.toString()
|
|
64
|
+
.includes('Bundling complete' || data.toString().includes('Bundled'))) {
|
|
65
|
+
resolve(childProcess);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
childProcess.stderr.on('data', (data) => {
|
|
69
|
+
process.stderr.write(data);
|
|
70
|
+
});
|
|
71
|
+
childProcess.on('error', (err) => {
|
|
72
|
+
reject(err);
|
|
73
|
+
});
|
|
74
|
+
childProcess.on('exit', (code) => {
|
|
75
|
+
if (code === 0) {
|
|
76
|
+
resolve(childProcess);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
reject(code);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function createServeOptions(options) {
|
|
85
|
+
return Object.keys(options).reduce((acc, k) => {
|
|
86
|
+
const v = options[k];
|
|
87
|
+
if (k === 'dev') {
|
|
88
|
+
if (v === false) {
|
|
89
|
+
acc.push(`--no-dev`); // only no-dev flag is supported
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (typeof v === 'boolean') {
|
|
94
|
+
if (v === true) {
|
|
95
|
+
// when true, does not need to pass the value true, just need to pass the flag in kebob case
|
|
96
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`, v);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return acc;
|
|
104
|
+
}, []);
|
|
105
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxExpoStart",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Packager Server for Expo",
|
|
8
8
|
"description": "Packager Server target options.",
|
|
9
9
|
"type": "object",
|
|
@@ -25,7 +25,13 @@ async function* startExecutor(options, context) {
|
|
|
25
25
|
exports.default = startExecutor;
|
|
26
26
|
function startAsync(workspaceRoot, projectRoot, options) {
|
|
27
27
|
return new Promise((resolve, reject) => {
|
|
28
|
-
childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), ['start', ...createStartOptions(options)], {
|
|
28
|
+
childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), ['start', ...createStartOptions(options)], {
|
|
29
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
30
|
+
env: {
|
|
31
|
+
RCT_METRO_PORT: options.port.toString(),
|
|
32
|
+
...process.env,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
29
35
|
// Ensure the child process is killed when the parent exits
|
|
30
36
|
process.on('exit', () => childProcess.kill());
|
|
31
37
|
process.on('SIGTERM', () => childProcess.kill());
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
|
+
const resolve_eas_1 = require("../../utils/resolve-eas");
|
|
6
7
|
let childProcess;
|
|
7
8
|
async function* submitExecutor(options, context) {
|
|
8
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
@@ -19,7 +20,7 @@ async function* submitExecutor(options, context) {
|
|
|
19
20
|
exports.default = submitExecutor;
|
|
20
21
|
function runCliSubmit(workspaceRoot, projectRoot, options) {
|
|
21
22
|
return new Promise((resolve, reject) => {
|
|
22
|
-
childProcess = (0, child_process_1.fork)(
|
|
23
|
+
childProcess = (0, child_process_1.fork)((0, resolve_eas_1.resolveEas)(workspaceRoot), ['submit', ...createSubmitOptions(options)], {
|
|
23
24
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
24
25
|
env: process.env,
|
|
25
26
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxExpoSyncDeps",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Sync Deps for Expo",
|
|
8
8
|
"description": "Updates package.json with project dependencies.",
|
|
9
9
|
"type": "object",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"default": [],
|
|
25
25
|
"description": "An array of npm packages to exclude."
|
|
26
|
+
},
|
|
27
|
+
"all": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "Copy all dependencies and devDependencies from the workspace root package.json.",
|
|
30
|
+
"default": false
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ExecutorContext, ProjectGraph } from '@nx/devkit';
|
|
2
2
|
import { ExpoSyncDepsOptions } from './schema';
|
|
3
|
-
|
|
3
|
+
import { PackageJson } from 'nx/src/utils/package-json';
|
|
4
|
+
export interface ReactNativeSyncDepsOutput {
|
|
4
5
|
success: boolean;
|
|
5
6
|
}
|
|
6
|
-
export default function syncDepsExecutor(options: ExpoSyncDepsOptions, context: ExecutorContext): AsyncGenerator<
|
|
7
|
-
export declare function syncDeps(projectName: string,
|
|
7
|
+
export default function syncDepsExecutor(options: ExpoSyncDepsOptions, context: ExecutorContext): AsyncGenerator<ReactNativeSyncDepsOutput>;
|
|
8
|
+
export declare function syncDeps(projectName: string, projectPackageJson: PackageJson, projectPackageJsonPath: string, workspacePackageJson: PackageJson, projectGraph?: ProjectGraph, include?: string[], exclude?: string[], all?: boolean): Promise<string[]>;
|
|
8
9
|
export declare function displayNewlyAddedDepsMessage(projectName: string, deps: string[]): void;
|