Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type ActionLessRequest<T, U> = Omit<IoRequest<T, U>, 'action'>;
* Wraps a client provided IoHost and provides additional features & services to toolkit internal classes.
*/
export interface IoHelper extends IIoHost {
action: ToolkitAction;
notify<T>(msg: ActionLessMessage<T>): Promise<void>;
requestResponse<T, U>(msg: ActionLessRequest<T, U>): Promise<U>;
}
Expand All @@ -23,7 +22,6 @@ export interface IoHelper extends IIoHost {
*/
export function asIoHelper(ioHost: IIoHost, action: ToolkitAction): IoHelper {
return {
action,
notify: async <T>(msg: Omit<IoMessage<T>, 'action'>) => {
await ioHost.notify({
...msg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export class ContextAwareCloudAssembly implements ICloudAssemblySource {
private canLookup: boolean;
private context: Context;
private contextFile: string;
private ioHost: IoHelper;
private ioHelper: IoHelper;

constructor(private readonly source: ICloudAssemblySource, private readonly props: ContextAwareCloudAssemblyProps) {
this.canLookup = props.lookups ?? true;
this.context = props.context;
this.contextFile = props.contextFile ?? PROJECT_CONTEXT; // @todo new feature not needed right now
this.ioHost = props.services.ioHost;
this.ioHelper = props.services.ioHelper;
}

/**
Expand Down Expand Up @@ -77,22 +77,22 @@ export class ContextAwareCloudAssembly implements ICloudAssemblySource {

let tryLookup = true;
if (previouslyMissingKeys && equalSets(missingKeysSet, previouslyMissingKeys)) {
await this.ioHost.notify(IO.CDK_ASSEMBLY_I0240.msg('Not making progress trying to resolve environmental context. Giving up.', { missingKeys }));
await this.ioHelper.notify(IO.CDK_ASSEMBLY_I0240.msg('Not making progress trying to resolve environmental context. Giving up.', { missingKeys }));
tryLookup = false;
}

previouslyMissingKeys = missingKeysSet;

if (tryLookup) {
await this.ioHost.notify(IO.CDK_ASSEMBLY_I0241.msg('Some context information is missing. Fetching...', { missingKeys }));
await this.ioHelper.notify(IO.CDK_ASSEMBLY_I0241.msg('Some context information is missing. Fetching...', { missingKeys }));
await contextproviders.provideContextValues(
assembly.manifest.missing,
this.context,
this.props.services.sdkProvider,
);

// Cache the new context to disk
await this.ioHost.notify(IO.CDK_ASSEMBLY_I0042.msg(`Writing updated context to ${this.contextFile}...`, {
await this.ioHelper.notify(IO.CDK_ASSEMBLY_I0042.msg(`Writing updated context to ${this.contextFile}...`, {
contextFile: this.contextFile,
context: this.context.all,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function determineOutputDirectory(outdir?: string) {
* @param context The context key/value bash.
*/
export async function prepareDefaultEnvironment(services: ToolkitServices, props: { outdir?: string } = {}): Promise<Env> {
const logFn = (msg: string, ...args: any) => services.ioHost.notify(IO.CDK_ASSEMBLY_I0010.msg(format(msg, ...args)));
const logFn = (msg: string, ...args: any) => services.ioHelper.notify(IO.CDK_ASSEMBLY_I0010.msg(format(msg, ...args)));
const env = await oldPrepare(services.sdkProvider, logFn);

if (props.outdir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export abstract class CloudAssemblySourceBuilder {
return assembly;
}

return assemblyFromDirectory(assembly.directory, services.ioHost, props.loadAssemblyOptions);
return assemblyFromDirectory(assembly.directory, services.ioHelper, props.loadAssemblyOptions);
},
},
contextAssemblyProps,
Expand All @@ -89,8 +89,8 @@ export abstract class CloudAssemblySourceBuilder {
{
produce: async () => {
// @todo build
await services.ioHost.notify(IO.CDK_ASSEMBLY_I0150.msg('--app points to a cloud assembly, so we bypass synth'));
return assemblyFromDirectory(directory, services.ioHost, props.loadAssemblyOptions);
await services.ioHelper.notify(IO.CDK_ASSEMBLY_I0150.msg('--app points to a cloud assembly, so we bypass synth'));
return assemblyFromDirectory(directory, services.ioHelper, props.loadAssemblyOptions);
},
},
contextAssemblyProps,
Expand Down Expand Up @@ -139,17 +139,17 @@ export abstract class CloudAssemblySourceBuilder {
eventPublisher: async (type, line) => {
switch (type) {
case 'data_stdout':
await services.ioHost.notify(IO.CDK_ASSEMBLY_I1001.msg(line));
await services.ioHelper.notify(IO.CDK_ASSEMBLY_I1001.msg(line));
break;
case 'data_stderr':
await services.ioHost.notify(IO.CDK_ASSEMBLY_E1002.msg(line));
await services.ioHelper.notify(IO.CDK_ASSEMBLY_E1002.msg(line));
break;
}
},
extraEnv: envWithContext,
cwd: props.workingDirectory,
});
return assemblyFromDirectory(outdir, services.ioHost, props.loadAssemblyOptions);
return assemblyFromDirectory(outdir, services.ioHelper, props.loadAssemblyOptions);
});
} finally {
await lock?.release();
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/toolkit-lib/lib/toolkit/private/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { IoHelper } from '../../api/shared-private';
*/
export interface ToolkitServices {
sdkProvider: SdkProvider;
ioHost: IoHelper;
ioHelper: IoHelper;
}

/**
Expand Down
Loading
Loading