* feat(expo): move expo to main repo * feat(expo): add e2e expo tests and fix expo unit tests * feat(expo): add generated docs * feat(expo): update cz-config to add expo to commit message * feat(expo): add @nrwl/expo to e2e test setup * feat(expo): add expo to preset * feat(expo): add detox tests * feat(expo): update docs * feat(expo): fix e2e tests * feat(expo): upgrade expo to 46.0.10 * fix(expo): correct eas-cli build:info parameters names * fix(expo): add cleanupProject to e2e test
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { ExecutorContext, names } from '@nrwl/devkit';
|
|
import { join } from 'path';
|
|
import { ChildProcess, fork } from 'child_process';
|
|
|
|
import { ensureNodeModulesSymlink } from '../../utils/ensure-node-modules-symlink';
|
|
|
|
import { ExpoBuildStatusOptions } from './schema';
|
|
|
|
export interface ReactNativeBuildOutput {
|
|
success: boolean;
|
|
}
|
|
|
|
let childProcess: ChildProcess;
|
|
|
|
export default async function* buildStatusExecutor(
|
|
options: ExpoBuildStatusOptions,
|
|
context: ExecutorContext
|
|
): AsyncGenerator<ReactNativeBuildOutput> {
|
|
const projectRoot = context.workspace.projects[context.projectName].root;
|
|
ensureNodeModulesSymlink(context.root, projectRoot);
|
|
|
|
try {
|
|
await runCliBuild(context.root, projectRoot, options);
|
|
yield { success: true };
|
|
} finally {
|
|
if (childProcess) {
|
|
childProcess.kill();
|
|
}
|
|
}
|
|
}
|
|
|
|
function runCliBuild(
|
|
workspaceRoot: string,
|
|
projectRoot: string,
|
|
options: ExpoBuildStatusOptions
|
|
) {
|
|
return new Promise((resolve, reject) => {
|
|
childProcess = fork(
|
|
join(workspaceRoot, './node_modules/expo-cli/bin/expo.js'),
|
|
['build:status', ...createRunOptions(options)],
|
|
{ cwd: join(workspaceRoot, projectRoot) }
|
|
);
|
|
|
|
// Ensure the child process is killed when the parent exits
|
|
process.on('exit', () => childProcess.kill());
|
|
process.on('SIGTERM', () => childProcess.kill());
|
|
|
|
childProcess.on('error', (err) => {
|
|
reject(err);
|
|
});
|
|
childProcess.on('exit', (code) => {
|
|
if (code === 0) {
|
|
resolve(code);
|
|
} else {
|
|
reject(code);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function createRunOptions(options) {
|
|
return Object.keys(options).reduce((acc, k) => {
|
|
const v = options[k];
|
|
if (typeof v === 'boolean') {
|
|
if (v === true) {
|
|
// when true, does not need to pass the value true, just need to pass the flag in kebob case
|
|
acc.push(`--${names(k).fileName}`);
|
|
}
|
|
} else {
|
|
acc.push(`--${names(k).fileName}`, v);
|
|
}
|
|
return acc;
|
|
}, []);
|
|
}
|