Skip to content

Commit 9c39e7f

Browse files
committed
refactor(cli): make the cli use more shared code
1 parent 8c5ec76 commit 9c39e7f

File tree

17 files changed

+70
-160
lines changed

17 files changed

+70
-160
lines changed

.projenrc.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ tmpToolkitHelpers.eslint?.addRules({
725725
'@typescript-eslint/consistent-type-imports': 'error',
726726
});
727727

728+
tmpToolkitHelpers.gitignore.addPatterns('test/**/*.map');
729+
728730
//////////////////////////////////////////////////////////////////////
729731

730732
let CLI_SDK_VERSION: '2' | '3' = ('3' as any);

packages/@aws-cdk/tmp-toolkit-helpers/.gitignore

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/action-aware.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type ActionLessRequest<T, U> = Omit<IoRequest<T, U>, 'action'>;
1111
* Helper type for IoHosts that are action aware
1212
*/
1313
export interface ActionAwareIoHost extends IIoHost {
14+
action: ToolkitAction;
1415
notify<T>(msg: ActionLessMessage<T>): Promise<void>;
1516
requestResponse<T, U>(msg: ActionLessRequest<T, U>): Promise<U>;
1617
}
@@ -21,6 +22,7 @@ export interface ActionAwareIoHost extends IIoHost {
2122
*/
2223
export function withAction(ioHost: IIoHost, action: ToolkitAction): ActionAwareIoHost {
2324
return {
25+
action,
2426
notify: async <T>(msg: Omit<IoMessage<T>, 'action'>) => {
2527
await ioHost.notify({
2628
...msg,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './action-aware';
2+
export * from './level-priority';
23
export * from './message-maker';
34
export * from './types';

packages/@aws-cdk/toolkit-lib/lib/api/io/private/level-priority.ts renamed to packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/level-priority.ts

File renamed without changes.

packages/@aws-cdk/toolkit-lib/test/api/io/io-message.test.ts renamed to packages/@aws-cdk/tmp-toolkit-helpers/test/api/io/io-message.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isMessageRelevantForLevel } from '../../../lib/api/io/private/level-priority';
1+
import { isMessageRelevantForLevel } from '../../../src/api/io/private/level-priority';
22

33
describe('IoMessageLevel', () => {
44
test.each`

packages/@aws-cdk/toolkit-lib/test/_helpers/test-io-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IIoHost, IoMessage, IoMessageLevel, IoRequest } from '../../lib';
22
import { RequireApproval } from '../../lib';
3-
import { isMessageRelevantForLevel } from '../../lib/api/io/private/level-priority';
3+
import { isMessageRelevantForLevel } from '../../lib/api/shared-private';
44

55
/**
66
* A test implementation of IIoHost that does nothing but can by spied on.

packages/@aws-cdk/toolkit-lib/test/api/io/io-message.test.d.ts.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/aws-cdk/lib/api/deployments/asset-publishing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from 'cdk-assets';
1515
import type { SDK } from '..';
1616
import { formatMessage } from '../../cli/messages';
17-
import { IIoHost, IoMessageLevel, IoMessaging, ToolkitAction } from '../../toolkit/cli-io-host';
17+
import { IIoHost, IoMessageLevel, IoMessaging } from '../../toolkit/cli-io-host';
1818
import { ToolkitError } from '../../toolkit/error';
1919
import type { SdkProvider } from '../aws-auth';
2020
import { Mode } from '../plugin';
@@ -184,7 +184,7 @@ export const EVENT_TO_LEVEL: Record<EventType, IoMessageLevel | false> = {
184184

185185
export abstract class BasePublishProgressListener implements IPublishProgressListener {
186186
protected readonly ioHost: IIoHost;
187-
protected readonly action: ToolkitAction;
187+
protected readonly action: IoMessaging['action'];
188188

189189
constructor({ ioHost, action }: IoMessaging) {
190190
this.ioHost = ioHost;

packages/aws-cdk/lib/api/deployments/deploy-stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { ChangeSetDeploymentMethod, DeploymentMethod } from './deployment-method
2929
import { DeployStackResult, SuccessfulDeployStackResult } from './deployment-result';
3030
import { tryHotswapDeployment } from './hotswap-deployments';
3131
import { debug, info, warn } from '../../cli/messages';
32-
import { IIoHost, IoMessaging, ToolkitAction } from '../../toolkit/cli-io-host';
32+
import { IIoHost, IoMessaging } from '../../toolkit/cli-io-host';
3333
import { ToolkitError } from '../../toolkit/error';
3434
import { formatErrorMessage } from '../../util';
3535
import type { SDK, SdkProvider, ICloudFormationClient } from '../aws-auth';
@@ -368,7 +368,7 @@ class FullCloudFormationDeployment {
368368
private readonly stackParams: ParameterValues,
369369
private readonly bodyParameter: TemplateBodyParameter,
370370
private readonly ioHost: IIoHost,
371-
private readonly action: ToolkitAction,
371+
private readonly action: IoMessaging['action'],
372372
) {
373373
this.cfn = options.sdk.cloudFormation();
374374
this.stackName = options.deployName ?? stackArtifact.stackName;

0 commit comments

Comments
 (0)