nx/packages/expo/src/executors/build-list/build-list.impl.ts
Emily Xiong a411e85e42
Feature/move expo (#11712)
* 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
2022-09-16 11:56:28 -04:00

54 lines
1.6 KiB
TypeScript

import { ExecutorContext, logger, names } from '@nrwl/devkit';
import { join } from 'path';
import { execSync } from 'child_process';
import { ensureNodeModulesSymlink } from '../../utils/ensure-node-modules-symlink';
import { ExpoEasBuildListOptions } from './schema';
export interface ReactNativeBuildListOutput {
success: boolean;
}
export default async function* buildListExecutor(
options: ExpoEasBuildListOptions,
context: ExecutorContext
): AsyncGenerator<ReactNativeBuildListOutput> {
const projectRoot = context.workspace.projects[context.projectName].root;
ensureNodeModulesSymlink(context.root, projectRoot);
logger.info(runCliBuildList(context.root, projectRoot, options));
yield { success: true };
}
export function runCliBuildList(
workspaceRoot: string,
projectRoot: string,
options: ExpoEasBuildListOptions
): string {
return execSync(
`./node_modules/eas-cli/bin/run build:list ${createBuildListOptions(
options
).join(' ')}`,
{ cwd: join(workspaceRoot, projectRoot) }
).toString();
}
const nxOptions = ['output'];
function createBuildListOptions(options: ExpoEasBuildListOptions): string[] {
return Object.keys(options).reduce((acc, k) => {
const v = options[k];
if (!nxOptions.includes(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 camel case
acc.push(`--${names(k).propertyName}`);
}
} else {
acc.push(`--${names(k).propertyName}`, v);
}
}
return acc;
}, []);
}