Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add forceStdOut and remove quiet as options for assetPublishing #32824

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 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
6 changes: 3 additions & 3 deletions packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { inspect } from 'util';
import { inspect, format } from 'util';
import type { CredentialProviderSource, ForReading, ForWriting, PluginProviderResult, SDKv2CompatibleCredentials, SDKv3CompatibleCredentialProvider, SDKv3CompatibleCredentials } from '@aws-cdk/cli-plugin-contract';
import type { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';
import { credentialsAboutToExpire, makeCachingProvider } from './provider-caching';
import { debug, warning } from '../../logging';
import { debug, warning, info } from '../../logging';
import { AuthenticationError } from '../../toolkit/error';
import { Mode } from '../plugin/mode';
import { PluginHost } from '../plugin/plugin';
Expand Down Expand Up @@ -151,7 +151,7 @@ function v3ProviderFromV2Credentials(x: SDKv2CompatibleCredentials): AwsCredenti
function refreshFromPluginProvider(current: AwsCredentialIdentity, producer: () => Promise<PluginProviderResult>): AwsCredentialIdentityProvider {
return async () => {
// eslint-disable-next-line no-console
console.error(current, Date.now());
info(format(current), Date.now());
if (credentialsAboutToExpire(current)) {
const newCreds = await producer();
if (!isV3Credentials(newCreds)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as cxapi from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import { minimatch } from 'minimatch';
import * as semver from 'semver';
import { error, print, warning } from '../../logging';
import { ToolkitError } from '../../toolkit/error';
import { flatten } from '../../util';
import * as chalk from '../../util/cdk-chalk';

export enum DefaultSelection {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/deploy-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
UpdateStackCommandInput,
Tag,
} from '@aws-sdk/client-cloudformation';
import * as chalk from 'chalk';
import * as uuid from 'uuid';
import type { SDK, SdkProvider, ICloudFormationClient } from './aws-auth';
import type { EnvironmentResources } from './environment-resources';
Expand All @@ -32,6 +31,7 @@ import { type TemplateBodyParameter, makeBodyParameter } from './util/template-b
import { AssetManifestBuilder } from '../util/asset-manifest-builder';
import { determineAllowCrossAccountAssetPublishing } from './util/checks';
import { publishAssets } from '../util/asset-publishing';
import * as chalk from '../util/cdk-chalk';
import { StringWithoutPlaceholders } from './util/placeholders';

export type DeployStackResult =
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { randomUUID } from 'crypto';
import * as cxapi from '@aws-cdk/cx-api';
import * as cdk_assets from 'cdk-assets';
import { AssetManifest, IManifestEntry } from 'cdk-assets';
import * as chalk from 'chalk';
import * as chalk from '../util/cdk-chalk';
import type { SdkProvider } from './aws-auth/sdk-provider';
import { type DeploymentMethod, deployStack, DeployStackResult, destroyStack } from './deploy-stack';
import { type EnvironmentResources } from './environment-resources';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as cxapi from '@aws-cdk/cx-api';
import { ImageIdentifier } from '@aws-sdk/client-ecr';
import { Tag } from '@aws-sdk/client-s3';
import * as chalk from 'chalk';
import * as promptly from 'promptly';
import { debug, print } from '../../logging';
import * as chalk from '../../util/cdk-chalk';
import { IECRClient, IS3Client, SDK, SdkProvider } from '../aws-auth';
import { DEFAULT_TOOLKIT_STACK_NAME, ToolkitInfo } from '../toolkit-info';
import { ProgressPrinter } from './progress-printer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as chalk from 'chalk';
import { GcAsset as GCAsset } from './garbage-collector';
import { print } from '../../logging';
import * as chalk from '../../util/cdk-chalk';

export class ProgressPrinter {
private totalAssets: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/hotswap-deployments.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as cfn_diff from '@aws-cdk/cloudformation-diff';
import * as cxapi from '@aws-cdk/cx-api';
import { WaiterResult } from '@smithy/util-waiter';
import * as chalk from 'chalk';
import type { SDK, SdkProvider } from './aws-auth';
import type { SuccessfulDeployStackResult } from './deploy-stack';
import { EvaluateCloudFormationTemplate } from './evaluate-cloudformation-template';
import { print } from '../logging';
import * as chalk from '../util/cdk-chalk';
import { isHotswappableAppSyncChange } from './hotswap/appsync-mapping-templates';
import { isHotswappableCodeBuildProjectChange } from './hotswap/code-build-projects';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/logs/logs-monitor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as util from 'util';
import * as cxapi from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import { print, error } from '../../logging';
import { flatten } from '../../util/arrays';
import * as chalk from '../../util/cdk-chalk';
import type { SDK } from '../aws-auth';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/plugin/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { inspect } from 'util';
import type { CredentialProviderSource, IPluginHost, Plugin } from '@aws-cdk/cli-plugin-contract';
import * as chalk from 'chalk';

import { type ContextProviderPlugin, isContextProviderPlugin } from './context-provider-plugin';
import { error } from '../../logging';
import { ToolkitError } from '../../toolkit/error';
import * as chalk from '../../util/cdk-chalk';

export let TESTING = false;

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/toolkit-info.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cxapi from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import type { SDK } from './aws-auth';
import { debug } from '../logging';
import * as chalk from '../util/cdk-chalk';
import {
BOOTSTRAP_VARIANT_PARAMETER,
BOOTSTRAP_VERSION_OUTPUT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as util from 'util';
import { ArtifactMetadataEntryType, type MetadataEntry } from '@aws-cdk/cloud-assembly-schema';
import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import { ResourceEvent, StackEventPoller } from './stack-event-poller';
import { error, LogLevel, setLogLevel } from '../../../logging';
import { error, setIoMessageThreshold, info } from '../../../logging';
import { IoMessageLevel } from '../../../toolkit/cli-io-host';
import * as chalk from '../../../util/cdk-chalk';
import type { ICloudFormationClient } from '../../aws-auth';
import { RewritableBlock } from '../display';

Expand Down Expand Up @@ -48,7 +49,7 @@ export interface WithDefaultPrinterProps {
*
* @default - Use value from logging.logLevel
*/
readonly logLevel?: LogLevel;
readonly logLevel?: IoMessageLevel;

/**
* Whether to display all stack events or to display only the events for the
Expand Down Expand Up @@ -102,7 +103,7 @@ export class StackActivityMonitor {
};

const isWindows = process.platform === 'win32';
const verbose = options.logLevel ?? LogLevel.INFO;
const verbose = options.logLevel ?? 'info';
// On some CI systems (such as CircleCI) output still reports as a TTY so we also
// need an individual check for whether we're running on CI.
// see: https://discuss.circleci.com/t/circleci-terminal-is-a-tty-but-term-is-not-set/9965
Expand Down Expand Up @@ -514,7 +515,7 @@ export class HistoryActivityPrinter extends ActivityPrinterBase {
public stop() {
// Print failures at the end
if (this.failures.length > 0) {
this.stream.write('\nFailed resources:\n');
info('\nFailed resources:');
for (const failure of this.failures) {
// Root stack failures are not interesting
if (failure.isStackEvent) {
Expand Down Expand Up @@ -548,9 +549,9 @@ export class HistoryActivityPrinter extends ActivityPrinterBase {

const logicalId = resourceName !== event.LogicalResourceId ? `(${event.LogicalResourceId}) ` : '';

this.stream.write(
info(
util.format(
'%s | %s%s | %s | %s | %s %s%s%s\n',
'%s | %s%s | %s | %s | %s %s%s%s',
event.StackName,
progress !== false ? `${this.progress()} | ` : '',
new Date(event.Timestamp!).toLocaleTimeString(),
Expand Down Expand Up @@ -591,9 +592,9 @@ export class HistoryActivityPrinter extends ActivityPrinterBase {
}

if (Object.keys(this.resourcesInProgress).length > 0) {
this.stream.write(
info(
util.format(
'%s Currently in progress: %s\n',
'%s Currently in progress: %s',
this.progress(),
chalk.bold(Object.keys(this.resourcesInProgress).join(', ')),
),
Expand Down Expand Up @@ -626,7 +627,7 @@ export class CurrentActivityPrinter extends ActivityPrinterBase {
*/
public readonly updateSleep: number = 2_000;

private oldLogLevel: LogLevel = LogLevel.INFO;
private oldLogThreshold: IoMessageLevel = 'info';
private block = new RewritableBlock(this.stream);

constructor(props: PrinterProps) {
Expand Down Expand Up @@ -674,11 +675,11 @@ export class CurrentActivityPrinter extends ActivityPrinterBase {
public start() {
// Need to prevent the waiter from printing 'stack not stable' every 5 seconds, it messes
// with the output calculations.
setLogLevel(LogLevel.INFO);
setIoMessageThreshold('info');
}

public stop() {
setLogLevel(this.oldLogLevel);
setIoMessageThreshold(this.oldLogThreshold);

// Print failures at the end
const lines = new Array<string>();
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/util/template-body-parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as path from 'path';
import { type CloudFormationStackArtifact, type Environment, EnvironmentPlaceholders } from '@aws-cdk/cx-api';
import { HeadObjectCommand, S3Client } from '@aws-sdk/client-s3';
import { getEndpointFromInstructions } from '@smithy/middleware-endpoint';
import * as chalk from 'chalk';
import * as fs from 'fs-extra';
import { debug, error } from '../../logging';
import { toYAML } from '../../serialize';
import { AssetManifestBuilder } from '../../util/asset-manifest-builder';
import * as chalk from '../../util/cdk-chalk';
import { contentHash } from '../../util/content-hash';
import { EnvironmentResources } from '../environment-resources';

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import * as path from 'path';
import * as cxschema from '@aws-cdk/cloud-assembly-schema';
import * as cxapi from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import { EnvironmentResources } from './api/environment-resources';
import { ToolkitInfo } from './api/toolkit-info';
import { debug } from './logging';
import { ToolkitError } from './toolkit/error';
import { AssetManifestBuilder } from './util/asset-manifest-builder';
import * as chalk from './util/cdk-chalk';

/**
* Take the metadata assets from the given stack and add them to the given asset manifest
Expand Down
22 changes: 11 additions & 11 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as path from 'path';
import { format } from 'util';
import * as cxapi from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import * as chokidar from 'chokidar';
import * as fs from 'fs-extra';
import * as promptly from 'promptly';
Expand Down Expand Up @@ -50,6 +49,7 @@ import { deserializeStructure, serializeStructure } from './serialize';
import { Configuration, PROJECT_CONFIG } from './settings';
import { ToolkitError } from './toolkit/error';
import { numberFromBool, partition } from './util';
import * as chalk from './util/cdk-chalk';
import { validateSnsTopicArn } from './util/validate-notification-arn';
import { Concurrency, WorkGraph } from './util/work-graph';
import { WorkGraphBuilder } from './util/work-graph-builder';
Expand Down Expand Up @@ -274,11 +274,11 @@ export class CdkToolkit {
options.ignoreNoStacks,
);
const elapsedSynthTime = new Date().getTime() - startSynthTime;
print('\n✨ Synthesis time: %ss\n', formatTime(elapsedSynthTime));
print(`\n✨ Synthesis time: ${formatTime(elapsedSynthTime)}s\n`);

if (stackCollection.stackCount === 0) {
// eslint-disable-next-line no-console
console.error('This app contains no stacks');
error('This app contains no stacks');
return;
}

Expand Down Expand Up @@ -387,7 +387,7 @@ export class CdkToolkit {
}

const stackIndex = stacks.indexOf(stack) + 1;
print('%s: deploying... [%s/%s]', chalk.bold(stack.displayName), stackIndex, stackCollection.stackCount);
print(`${chalk.bold(stack.displayName)}: deploying... [${stackIndex}/${stackCollection.stackCount}]`);
const startDeployTime = new Date().getTime();

let tags = options.tags;
Expand Down Expand Up @@ -491,7 +491,7 @@ export class CdkToolkit {

success('\n' + message, stack.displayName);
elapsedDeployTime = new Date().getTime() - startDeployTime;
print('\n✨ Deployment time: %ss\n', formatTime(elapsedDeployTime));
print(`\n✨ Deployment time: ${formatTime(elapsedDeployTime)}s\n`);

if (Object.keys(deployResult.outputs).length > 0) {
print('Outputs:');
Expand All @@ -501,7 +501,7 @@ export class CdkToolkit {

for (const name of Object.keys(deployResult.outputs).sort()) {
const value = deployResult.outputs[name];
print('%s.%s = %s', chalk.cyan(stack.id), chalk.cyan(name), chalk.underline(chalk.cyan(value)));
print(`${chalk.cyan(stack.id)}.${chalk.cyan(name)} = ${chalk.underline(chalk.cyan(value))}`);
}

print('Stack ARN:');
Expand Down Expand Up @@ -533,7 +533,7 @@ export class CdkToolkit {
});
}
}
print('\n✨ Total time: %ss\n', formatTime(elapsedSynthTime + elapsedDeployTime));
print(`\n✨ Total time: ${formatTime(elapsedSynthTime + elapsedDeployTime)}s\n`);
};

const assetBuildTime = options.assetBuildTime ?? AssetBuildTime.ALL_BEFORE_DEPLOY;
Expand Down Expand Up @@ -575,11 +575,11 @@ export class CdkToolkit {
const startSynthTime = new Date().getTime();
const stackCollection = await this.selectStacksForDeploy(options.selector, true);
const elapsedSynthTime = new Date().getTime() - startSynthTime;
print('\n✨ Synthesis time: %ss\n', formatTime(elapsedSynthTime));
print(`\n✨ Synthesis time: ${formatTime(elapsedSynthTime)}s\n`);

if (stackCollection.stackCount === 0) {
// eslint-disable-next-line no-console
console.error('No stacks selected');
error('No stacks selected');
return;
}

Expand All @@ -601,9 +601,9 @@ export class CdkToolkit {
anyRollbackable = true;
}
const elapsedRollbackTime = new Date().getTime() - startRollbackTime;
print('\n✨ Rollback time: %ss\n', formatTime(elapsedRollbackTime));
print(`\n✨ Rollback time: ${formatTime(elapsedRollbackTime).toString()}s\n`);
} catch (e: any) {
error('\n ❌ %s failed: %s', chalk.bold(stack.displayName), e.message);
error(`\n ❌ ${chalk.bold(stack.displayName)} failed: ${e.message}`);
throw new ToolkitError('Rollback failed (use --force to orphan failing resources)');
}
}
Expand Down
Loading
Loading