/
executor.ts
29 lines (26 loc) · 960 Bytes
/
executor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import 'reflect-metadata';
import type { ExecutorContext } from '@nx/devkit';
import Container from 'typedi';
import { EXECUTOR_CONTEXT } from '../common/constants';
import { PromoteExecutorSchema } from './schema';
import { HerokuPromoteService } from './services/heroku-promote.service';
import { PROMOTE_EXECUTOR_SCHEMA } from './services/tokens';
export default async function runExecutor(
options: PromoteExecutorSchema,
context: ExecutorContext
) {
options.debug ??= context.isVerbose;
Container.set(PROMOTE_EXECUTOR_SCHEMA, options);
Container.set(EXECUTOR_CONTEXT, context);
const herokuPromoteService = Container.get(HerokuPromoteService);
try {
await herokuPromoteService.run();
herokuPromoteService.logger.info('Promotion successful.');
return { success: true };
} catch (error) {
herokuPromoteService.logger.error(error);
return { success: false };
} finally {
await herokuPromoteService.close();
}
}