@nx/expo 0.0.0-pr-22179-271588f
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 +46 -0
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/docs/build-list-examples.md +71 -0
- package/docs/export-examples.md +112 -0
- package/docs/prebuild-examples.md +70 -0
- package/docs/run-examples.md +91 -0
- package/docs/start-examples.md +104 -0
- package/executors.json +64 -0
- package/generators.json +33 -0
- package/index.d.ts +3 -0
- package/index.js +9 -0
- package/migrations.json +689 -0
- package/package.json +57 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/jest/svg-mock.d.ts +0 -0
- package/plugins/jest/svg-mock.js +3 -0
- package/plugins/metro-resolver.d.ts +1 -0
- package/plugins/metro-resolver.js +136 -0
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +150 -0
- package/plugins/with-nx-metro.d.ts +8 -0
- package/plugins/with-nx-metro.js +31 -0
- package/plugins/with-nx-webpack.d.ts +5 -0
- package/plugins/with-nx-webpack.js +51 -0
- package/project.json +61 -0
- package/src/executors/build/build.impl.d.ts +6 -0
- package/src/executors/build/build.impl.js +70 -0
- package/src/executors/build/schema.d.ts +14 -0
- package/src/executors/build/schema.json +83 -0
- package/src/executors/build-list/build-fragment.d.ts +54 -0
- package/src/executors/build-list/build-list.impl.d.ts +7 -0
- package/src/executors/build-list/build-list.impl.js +81 -0
- package/src/executors/build-list/schema.d.ts +25 -0
- package/src/executors/build-list/schema.json +79 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +9 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +13 -0
- package/src/executors/ensure-symlink/schema.json +11 -0
- package/src/executors/export/export.impl.d.ts +7 -0
- package/src/executors/export/export.impl.js +73 -0
- package/src/executors/export/schema.d.ts +13 -0
- package/src/executors/export/schema.json +49 -0
- package/src/executors/install/install.impl.d.ts +7 -0
- package/src/executors/install/install.impl.js +63 -0
- package/src/executors/install/schema.d.ts +7 -0
- package/src/executors/install/schema.json +34 -0
- package/src/executors/prebuild/prebuild.impl.d.ts +7 -0
- package/src/executors/prebuild/prebuild.impl.js +69 -0
- package/src/executors/prebuild/schema.d.ts +7 -0
- package/src/executors/prebuild/schema.json +36 -0
- package/src/executors/run/run.impl.d.ts +6 -0
- package/src/executors/run/run.impl.js +96 -0
- package/src/executors/run/schema.d.ts +24 -0
- package/src/executors/run/schema.json +65 -0
- 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.d.ts +22 -0
- package/src/executors/start/schema.json +93 -0
- package/src/executors/start/start.impl.d.ts +7 -0
- package/src/executors/start/start.impl.js +77 -0
- package/src/executors/submit/schema.d.ts +12 -0
- package/src/executors/submit/schema.json +57 -0
- package/src/executors/submit/submit.impl.d.ts +6 -0
- package/src/executors/submit/submit.impl.js +70 -0
- package/src/executors/sync-deps/schema.d.ts +5 -0
- package/src/executors/sync-deps/schema.json +33 -0
- package/src/executors/sync-deps/sync-deps.impl.d.ts +9 -0
- package/src/executors/sync-deps/sync-deps.impl.js +78 -0
- package/src/executors/update/schema.d.ts +15 -0
- package/src/executors/update/schema.json +75 -0
- package/src/executors/update/update.impl.d.ts +6 -0
- package/src/executors/update/update.impl.js +67 -0
- package/src/generators/application/application.d.ts +5 -0
- package/src/generators/application/application.js +63 -0
- package/src/generators/application/files/.babelrc.js.template +6 -0
- package/src/generators/application/files/app.json.template +44 -0
- package/src/generators/application/files/assets/adaptive-icon.png +0 -0
- package/src/generators/application/files/assets/favicon.png +0 -0
- package/src/generators/application/files/assets/icon.png +0 -0
- package/src/generators/application/files/assets/splash.png +0 -0
- package/src/generators/application/files/eas.json.template +25 -0
- package/src/generators/application/files/index.js.template +8 -0
- package/src/generators/application/files/metro.config.js.template +33 -0
- package/src/generators/application/files/package.json.template +18 -0
- package/src/generators/application/files/src/app/App.spec.tsx.template +9 -0
- package/src/generators/application/files/src/app/App.tsx.template +731 -0
- package/src/generators/application/files/test-setup.ts.template +1 -0
- package/src/generators/application/files/tsconfig.app.json.template +10 -0
- package/src/generators/application/files/tsconfig.json.template +20 -0
- 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 +87 -0
- package/src/generators/application/lib/add-eas-scripts.d.ts +2 -0
- package/src/generators/application/lib/add-eas-scripts.js +74 -0
- package/src/generators/application/lib/add-project.d.ts +3 -0
- package/src/generators/application/lib/add-project.js +91 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.js +27 -0
- package/src/generators/application/lib/normalize-options.d.ts +13 -0
- package/src/generators/application/lib/normalize-options.js +42 -0
- package/src/generators/application/schema.d.ts +22 -0
- package/src/generators/application/schema.json +94 -0
- package/src/generators/component/component.d.ts +5 -0
- package/src/generators/component/component.js +62 -0
- package/src/generators/component/files/__fileName__.spec.tsx.template +11 -0
- package/src/generators/component/files/__fileName__.tsx.template +32 -0
- package/src/generators/component/lib/add-import.d.ts +3 -0
- package/src/generators/component/lib/add-import.js +29 -0
- package/src/generators/component/lib/normalize-options.d.ts +10 -0
- package/src/generators/component/lib/normalize-options.js +50 -0
- package/src/generators/component/schema.d.ts +25 -0
- package/src/generators/component/schema.json +90 -0
- package/src/generators/init/init.d.ts +6 -0
- package/src/generators/init/init.js +74 -0
- package/src/generators/init/lib/add-git-ignore-entry.d.ts +2 -0
- package/src/generators/init/lib/add-git-ignore-entry.js +17 -0
- package/src/generators/init/lib/gitignore-entries.d.ts +1 -0
- package/src/generators/init/lib/gitignore-entries.js +19 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +33 -0
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/files/lib/README.md +7 -0
- package/src/generators/library/files/lib/package.json.template +5 -0
- package/src/generators/library/files/lib/src/index.ts.template +0 -0
- package/src/generators/library/files/lib/test-setup.ts.template +1 -0
- package/src/generators/library/files/lib/tsconfig.json.template +16 -0
- package/src/generators/library/files/lib/tsconfig.lib.json.template +9 -0
- package/src/generators/library/lib/normalize-options.d.ts +11 -0
- package/src/generators/library/lib/normalize-options.js +35 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +159 -0
- package/src/generators/library/schema.d.ts +25 -0
- package/src/generators/library/schema.json +104 -0
- package/src/migrations/update-15-0-3/add-new-expo-cli-targets.d.ts +9 -0
- package/src/migrations/update-15-0-3/add-new-expo-cli-targets.js +61 -0
- package/src/migrations/update-15-0-3/change-jest-preset.d.ts +8 -0
- package/src/migrations/update-15-0-3/change-jest-preset.js +69 -0
- package/src/migrations/update-15-8-3/change-webpack-to-metro.d.ts +8 -0
- package/src/migrations/update-15-8-3/change-webpack-to-metro.js +31 -0
- package/src/migrations/update-16-0-0/add-jest-expo.d.ts +6 -0
- package/src/migrations/update-16-0-0/add-jest-expo.js +27 -0
- package/src/migrations/update-16-0-0/remove-deprecated-targets.d.ts +5 -0
- package/src/migrations/update-16-0-0/remove-deprecated-targets.js +32 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-1-4/update-eas-scripts.d.ts +5 -0
- package/src/migrations/update-16-1-4/update-eas-scripts.js +42 -0
- package/src/migrations/update-16-2-2/add-submit-target.d.ts +5 -0
- package/src/migrations/update-16-2-2/add-submit-target.js +22 -0
- package/src/migrations/update-16-6-0/add-depends-on.d.ts +6 -0
- package/src/migrations/update-16-6-0/add-depends-on.js +29 -0
- package/src/migrations/update-16-6-0/update-metro-config.d.ts +6 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +65 -0
- package/src/migrations/update-16-9-0/remove-types-react-native.d.ts +7 -0
- package/src/migrations/update-16-9-0/remove-types-react-native.js +13 -0
- package/src/migrations/update-16-9-0/update-eas-cli-version.d.ts +2 -0
- package/src/migrations/update-16-9-0/update-eas-cli-version.js +17 -0
- package/src/migrations/update-18-0-0/change-outputDir-export-target.d.ts +5 -0
- 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 +2 -0
- package/src/utils/add-jest.js +47 -0
- package/src/utils/add-linting.d.ts +13 -0
- package/src/utils/add-linting.js +37 -0
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +24 -0
- package/src/utils/ensure-node-modules-symlink.d.ts +9 -0
- package/src/utils/ensure-node-modules-symlink.js +28 -0
- package/src/utils/find-all-npm-dependencies.d.ts +2 -0
- package/src/utils/find-all-npm-dependencies.js +27 -0
- package/src/utils/has-expo-plugin.d.ts +2 -0
- package/src/utils/has-expo-plugin.js +11 -0
- package/src/utils/init-root-babel-config.d.ts +2 -0
- package/src/utils/init-root-babel-config.js +13 -0
- package/src/utils/pod-install-task.d.ts +16 -0
- package/src/utils/pod-install-task.js +66 -0
- package/src/utils/resolve-eas.d.ts +1 -0
- package/src/utils/resolve-eas.js +36 -0
- package/src/utils/versions.d.ts +19 -0
- package/src/utils/versions.js +22 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.spec.json +20 -0
- package/typings/svg.d.ts +6 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prebuildAsync = 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 pod_install_task_1 = require("../../utils/pod-install-task");
|
|
8
|
+
const install_impl_1 = require("../install/install.impl");
|
|
9
|
+
let childProcess;
|
|
10
|
+
async function* prebuildExecutor(options, context) {
|
|
11
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
12
|
+
try {
|
|
13
|
+
await prebuildAsync(context.root, projectRoot, options);
|
|
14
|
+
if (options.install) {
|
|
15
|
+
await (0, install_impl_1.installAsync)(devkit_1.workspaceRoot, {});
|
|
16
|
+
if (options.platform === 'ios') {
|
|
17
|
+
(0, pod_install_task_1.podInstall)((0, path_1.join)(context.root, projectRoot, 'ios'));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
yield {
|
|
21
|
+
success: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
if (childProcess) {
|
|
26
|
+
childProcess.kill();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.default = prebuildExecutor;
|
|
31
|
+
function prebuildAsync(workspaceRoot, projectRoot, options) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), ['prebuild', ...createPrebuildOptions(options), '--no-install'], { cwd: (0, path_1.join)(workspaceRoot, projectRoot), env: process.env });
|
|
34
|
+
// Ensure the child process is killed when the parent exits
|
|
35
|
+
process.on('exit', () => childProcess.kill());
|
|
36
|
+
process.on('SIGTERM', () => childProcess.kill());
|
|
37
|
+
childProcess.on('error', (err) => {
|
|
38
|
+
reject(err);
|
|
39
|
+
});
|
|
40
|
+
childProcess.on('exit', (code) => {
|
|
41
|
+
if (code === 0) {
|
|
42
|
+
resolve(code);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
reject(code);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.prebuildAsync = prebuildAsync;
|
|
51
|
+
const nxOptions = ['install', 'interactive']; // interactive is passed in by e2e tests
|
|
52
|
+
// options from https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/prebuild/index.ts
|
|
53
|
+
function createPrebuildOptions(options) {
|
|
54
|
+
return Object.keys(options).reduce((acc, k) => {
|
|
55
|
+
if (!nxOptions.includes(k)) {
|
|
56
|
+
const v = options[k];
|
|
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
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return acc;
|
|
68
|
+
}, []);
|
|
69
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// options from https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/prebuild/index.ts
|
|
2
|
+
export interface ExpoPrebuildOptions {
|
|
3
|
+
clean?: boolean; // default is false
|
|
4
|
+
install: boolean; // default is true
|
|
5
|
+
platform: 'all' | 'android' | 'ios'; // default is all
|
|
6
|
+
template?: string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cli": "nx",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"outputCapture": "direct-nodejs",
|
|
5
|
+
"$id": "NxExpoPrebuild",
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
|
+
"title": "Expo Prebuild",
|
|
8
|
+
"description": "Create native iOS and Android project files for building natively.",
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"clean": {
|
|
12
|
+
"type": "boolean",
|
|
13
|
+
"description": "Delete the native folders and regenerate them before applying changes",
|
|
14
|
+
"default": false
|
|
15
|
+
},
|
|
16
|
+
"install": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Installing npm packages and CocoaPods.",
|
|
19
|
+
"default": true,
|
|
20
|
+
"x-priority": "internal"
|
|
21
|
+
},
|
|
22
|
+
"platform": {
|
|
23
|
+
"description": "Platforms to sync",
|
|
24
|
+
"default": "all",
|
|
25
|
+
"enum": ["ios", "android", "all"],
|
|
26
|
+
"alias": "p",
|
|
27
|
+
"x-priority": "important"
|
|
28
|
+
},
|
|
29
|
+
"template": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Project template to clone from. File path pointing to a local tar file or a github repo"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"required": ["platform"],
|
|
35
|
+
"examplesFile": "../../../docs/prebuild-examples.md"
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { ExpoRunOptions } from './schema';
|
|
3
|
+
export interface ExpoRunOutput {
|
|
4
|
+
success: boolean;
|
|
5
|
+
}
|
|
6
|
+
export default function runExecutor(options: ExpoRunOptions, context: ExecutorContext): AsyncGenerator<ExpoRunOutput>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
const fs_extra_1 = require("fs-extra");
|
|
8
|
+
const prebuild_impl_1 = require("../prebuild/prebuild.impl");
|
|
9
|
+
const pod_install_task_1 = require("../../utils/pod-install-task");
|
|
10
|
+
const install_impl_1 = require("../install/install.impl");
|
|
11
|
+
let childProcess;
|
|
12
|
+
async function* runExecutor(options, context) {
|
|
13
|
+
if ((0, os_1.platform)() !== 'darwin' && options.platform === 'ios') {
|
|
14
|
+
throw new Error(`The run-ios build requires Mac to run`);
|
|
15
|
+
}
|
|
16
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
17
|
+
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(context.root, projectRoot, options.platform))) {
|
|
18
|
+
await (0, prebuild_impl_1.prebuildAsync)(context.root, projectRoot, {
|
|
19
|
+
install: options.install,
|
|
20
|
+
platform: options.platform,
|
|
21
|
+
clean: options.clean,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (options.install) {
|
|
25
|
+
await (0, install_impl_1.installAsync)(context.root, {});
|
|
26
|
+
if (options.platform === 'ios') {
|
|
27
|
+
(0, pod_install_task_1.podInstall)((0, path_1.join)(context.root, projectRoot, 'ios'));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
await runCliRun(context.root, projectRoot, options);
|
|
32
|
+
yield { success: true };
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
if (childProcess) {
|
|
36
|
+
childProcess.kill();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = runExecutor;
|
|
41
|
+
function runCliRun(workspaceRoot, projectRoot, options) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
childProcess = (0, child_process_1.fork)(require.resolve('@expo/cli/build/bin/cli'), ['run:' + options.platform, ...createRunOptions(options), '--no-install'], // pass in no-install to prevent node_modules install
|
|
44
|
+
{
|
|
45
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
46
|
+
env: process.env,
|
|
47
|
+
});
|
|
48
|
+
// Ensure the child process is killed when the parent exits
|
|
49
|
+
process.on('exit', () => childProcess.kill());
|
|
50
|
+
process.on('SIGTERM', () => childProcess.kill());
|
|
51
|
+
childProcess.on('error', (err) => {
|
|
52
|
+
reject(err);
|
|
53
|
+
});
|
|
54
|
+
childProcess.on('exit', (code) => {
|
|
55
|
+
if (code === 0) {
|
|
56
|
+
resolve(code);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
reject(code);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const nxOptions = ['platform', 'clean'];
|
|
65
|
+
const iOSOptions = ['xcodeConfiguration', 'schema'];
|
|
66
|
+
const androidOptions = ['variant'];
|
|
67
|
+
/*
|
|
68
|
+
* run options:
|
|
69
|
+
* ios: https://github.com/expo/expo/blob/main/packages/@expo/cli/src/run/ios/index.ts
|
|
70
|
+
* android: https://github.com/expo/expo/blob/main/packages/@expo/cli/src/run/android/index.ts
|
|
71
|
+
*/
|
|
72
|
+
function createRunOptions(options) {
|
|
73
|
+
return Object.keys(options).reduce((acc, k) => {
|
|
74
|
+
if (nxOptions.includes(k) ||
|
|
75
|
+
(options.platform === 'ios' && androidOptions.includes(k)) ||
|
|
76
|
+
(options.platform === 'android' && iOSOptions.includes(k))) {
|
|
77
|
+
return acc;
|
|
78
|
+
}
|
|
79
|
+
const v = options[k];
|
|
80
|
+
{
|
|
81
|
+
if (k === 'xcodeConfiguration') {
|
|
82
|
+
acc.push('--configuration', v);
|
|
83
|
+
}
|
|
84
|
+
else if (typeof v === 'boolean') {
|
|
85
|
+
// no need to pass in the flag when it is true, pass the --no-<flag> when it is false. e.g. --no-build-cache, --no-bundler
|
|
86
|
+
if (v === false) {
|
|
87
|
+
acc.push(`--no-${(0, devkit_1.names)(k).fileName}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
acc.push(`--${(0, devkit_1.names)(k).fileName}`, v);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return acc;
|
|
95
|
+
}, []);
|
|
96
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* options from
|
|
3
|
+
* - android: https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/run/android/resolveOptions.ts
|
|
4
|
+
* - ios: https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/run/ios/options/resolveOptions.ts
|
|
5
|
+
*/
|
|
6
|
+
export interface ExpoRunOptions {
|
|
7
|
+
// nx options
|
|
8
|
+
platform: 'ios' | 'android';
|
|
9
|
+
install?: boolean; // default is true
|
|
10
|
+
clean?: boolean; // default is false
|
|
11
|
+
|
|
12
|
+
// ios only
|
|
13
|
+
scheme?: string; // Xcode scheme to build.
|
|
14
|
+
xcodeConfiguration?: XcodeConfiguration; // Xcode configuration to build. Default `Debug`
|
|
15
|
+
|
|
16
|
+
// android only
|
|
17
|
+
variant?: string;
|
|
18
|
+
|
|
19
|
+
// shared between ios and android
|
|
20
|
+
device?: string;
|
|
21
|
+
port: number; // default is 8081
|
|
22
|
+
bundler: boolean; // default is true
|
|
23
|
+
buildCache?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"$id": "NxExpoRun",
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
|
+
"title": "Run iOS or Android application",
|
|
8
|
+
"description": "Run Expo target options.",
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"platform": {
|
|
12
|
+
"description": "Platform to run for (ios, android).",
|
|
13
|
+
"enum": ["ios", "android"],
|
|
14
|
+
"default": "ios",
|
|
15
|
+
"alias": "p"
|
|
16
|
+
},
|
|
17
|
+
"xcodeConfiguration": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "(iOS) Xcode configuration to use. Debug or Release",
|
|
20
|
+
"default": "Debug",
|
|
21
|
+
"x-priority": "important"
|
|
22
|
+
},
|
|
23
|
+
"scheme": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "(iOS) Explicitly set the Xcode scheme to use"
|
|
26
|
+
},
|
|
27
|
+
"variant": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "(Android) Specify your app's build variant (e.g. debug, release).",
|
|
30
|
+
"default": "debug",
|
|
31
|
+
"x-priority": "important"
|
|
32
|
+
},
|
|
33
|
+
"device": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Device name or UDID to build the app on. The value is not required if you have a single device connected.",
|
|
36
|
+
"alias": "d"
|
|
37
|
+
},
|
|
38
|
+
"port": {
|
|
39
|
+
"type": "number",
|
|
40
|
+
"description": "Port to start the Metro bundler on",
|
|
41
|
+
"default": 8081,
|
|
42
|
+
"alias": "p"
|
|
43
|
+
},
|
|
44
|
+
"bundler": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "Whether to skip starting the Metro bundler. True to start it, false to skip it."
|
|
47
|
+
},
|
|
48
|
+
"install": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"description": "Installing npm packages and CocoaPods before building.",
|
|
51
|
+
"default": true
|
|
52
|
+
},
|
|
53
|
+
"buildCache": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"description": "Should use derived data for builds."
|
|
56
|
+
},
|
|
57
|
+
"clean": {
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"description": "Delete the native folders and regenerate them before applying changes",
|
|
60
|
+
"default": false
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"required": ["platform"],
|
|
64
|
+
"examplesFile": "../../../docs/run-examples.md"
|
|
65
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// options from https://github.com/expo/expo/blob/main/packages/%40expo/cli/src/start/resolveOptions.ts
|
|
2
|
+
|
|
3
|
+
export interface ExpoStartOptions {
|
|
4
|
+
forceManifestType: 'classic' | 'expo-updates';
|
|
5
|
+
privateKeyPath?: string;
|
|
6
|
+
port: number;
|
|
7
|
+
dev?: boolean;
|
|
8
|
+
devClient?: boolean;
|
|
9
|
+
minify?: boolean;
|
|
10
|
+
https?: boolean;
|
|
11
|
+
clear?: boolean;
|
|
12
|
+
maxWorkers?: number;
|
|
13
|
+
scheme?: string;
|
|
14
|
+
ios?: boolean;
|
|
15
|
+
android?: boolean;
|
|
16
|
+
web?: boolean;
|
|
17
|
+
host?: 'localhost' | 'lan' | 'tunnel';
|
|
18
|
+
lan?: boolean;
|
|
19
|
+
localhost?: boolean;
|
|
20
|
+
tunnel?: boolean;
|
|
21
|
+
offline?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"$id": "NxExpoStart",
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
|
+
"title": "Packager Server for Expo",
|
|
8
|
+
"description": "Packager Server target options.",
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"forceManifestType": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Override auto detection of manifest type.",
|
|
14
|
+
"enum": ["expo-updates", "classic"]
|
|
15
|
+
},
|
|
16
|
+
"privateKeyPath": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Path to private key for code signing. Default: 'private-key.pem' in the same directory as the certificate specified by the expo-updates configuration in app.json."
|
|
19
|
+
},
|
|
20
|
+
"port": {
|
|
21
|
+
"type": "number",
|
|
22
|
+
"description": "Port to start the native Metro bundler on (does not apply to web or tunnel)",
|
|
23
|
+
"default": 19000,
|
|
24
|
+
"alias": "p"
|
|
25
|
+
},
|
|
26
|
+
"clear": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Clear the Metro bundler cache",
|
|
29
|
+
"alias": "c"
|
|
30
|
+
},
|
|
31
|
+
"maxWorkers": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"description": "Maximum number of tasks to allow Metro to spawn"
|
|
34
|
+
},
|
|
35
|
+
"dev": {
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "Turn development mode on or off"
|
|
38
|
+
},
|
|
39
|
+
"devClient": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "Experimental: Starts the bundler for use with the expo-development-client"
|
|
42
|
+
},
|
|
43
|
+
"minify": {
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"description": "Whether or not to minify code"
|
|
46
|
+
},
|
|
47
|
+
"https": {
|
|
48
|
+
"type": "boolean",
|
|
49
|
+
"description": "To start webpack with https or http protocol"
|
|
50
|
+
},
|
|
51
|
+
"scheme": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "Custom URI protocol to use with a development build"
|
|
54
|
+
},
|
|
55
|
+
"android": {
|
|
56
|
+
"type": "boolean",
|
|
57
|
+
"description": "Opens your app in Expo Go on a connected Android device",
|
|
58
|
+
"alias": "a"
|
|
59
|
+
},
|
|
60
|
+
"ios": {
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"description": "Opens your app in Expo Go in a currently running iOS simulator on your computer",
|
|
63
|
+
"alias": "i"
|
|
64
|
+
},
|
|
65
|
+
"web": {
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"description": " Opens your app in a web browser",
|
|
68
|
+
"alias": "w"
|
|
69
|
+
},
|
|
70
|
+
"host": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "lan (default), tunnel, localhost. Type of host to use. lan uses the local network; tunnel ues any network by tunnel through ngrok; localhost connects to the dev server over localhost.",
|
|
73
|
+
"enum": ["localhost", "lan", "tunnel"]
|
|
74
|
+
},
|
|
75
|
+
"tunnel": {
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"description": "Same as --host tunnel"
|
|
78
|
+
},
|
|
79
|
+
"lan": {
|
|
80
|
+
"type": "boolean",
|
|
81
|
+
"description": "Same as --host lan"
|
|
82
|
+
},
|
|
83
|
+
"localhost": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"description": "Same as --host localhost"
|
|
86
|
+
},
|
|
87
|
+
"offline": {
|
|
88
|
+
"type": "boolean",
|
|
89
|
+
"description": "Allows this command to run while offline"
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"examplesFile": "../../../docs/start-examples.md"
|
|
93
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { ExpoStartOptions } from './schema';
|
|
3
|
+
export interface ExpoStartOutput {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
success: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default function startExecutor(options: ExpoStartOptions, context: ExecutorContext): AsyncGenerator<ExpoStartOutput>;
|