Skip to content

Commit 174c2e7

Browse files
authored
refactor(cli): re-organize files (#265)
Hopefully the final big code re-org in the CLI before we move code into the shared package. This move focuses on moving top-level files into `commands` and `cli` respectively, to indicate they will stay within the CLI package. Also removes the `toolkit/error.ts` re-export, which causes many of the import changes. Includes a non-consequential bug fix, to the init command and how it's finding the new `.init-version.json` and `.recommended-feature-flags.json` files. This was incorrect before and would happened to work because `init.ts` was in the same directory as `index.ts`. However because the code is bundled, we need to address the `init-templates` (and the new files) from the project root location. This is already done for the templates themselves, but was missed for `.init-version.json` and `.recommended-feature-flags.json`. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent 4635d02 commit 174c2e7

File tree

108 files changed

+237
-233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+237
-233
lines changed

.projenrc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ const cli = configureProject(
821821
'<rootDir>/lib/user-input.ts',
822822
'<rootDir>/lib/convert-to-user-input.ts',
823823
],
824-
testEnvironment: './test/jest-bufferedconsole.ts',
825-
setupFilesAfterEnv: ['<rootDir>/test/jest-setup-after-env.ts'],
824+
testEnvironment: './test/_helpers/jest-bufferedconsole.ts',
825+
setupFilesAfterEnv: ['<rootDir>/test/_helpers/jest-setup-after-env.ts'],
826826
},
827827
}),
828828

packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ export { guessExecutable } from '../../../../aws-cdk/lib/api/cxapp/exec';
3030

3131
// @todo Should not use! investigate how to replace
3232
export { versionNumber } from '../../../../aws-cdk/lib/cli/version';
33-
export { CliIoHost } from '../../../../aws-cdk/lib/toolkit/cli-io-host';
33+
export { CliIoHost } from '../../../../aws-cdk/lib/cli/io-host';

packages/@aws-cdk/user-input-gen/test/user-input-gen.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ describe('render', () => {
3333
commands: {
3434
deploy: {
3535
description: 'Deploy a stack',
36+
aliases: ['ship-it'],
3637
options: {
3738
all: {
3839
type: 'boolean',
3940
desc: 'Deploy all stacks',
41+
alias: 'A',
4042
default: false,
4143
},
4244
},
@@ -70,6 +72,8 @@ describe('render', () => {
7072
7173
/**
7274
* Deploy a stack
75+
*
76+
* aliases: ship-it
7377
*/
7478
readonly deploy?: DeployOptions;
7579
}
@@ -119,12 +123,16 @@ describe('render', () => {
119123
/**
120124
* Deploy a stack
121125
*
126+
* aliases: ship-it
127+
*
122128
* @struct
123129
*/
124130
export interface DeployOptions {
125131
/**
126132
* Deploy all stacks
127133
*
134+
* aliases: A
135+
*
128136
* @default - false
129137
*/
130138
readonly all?: boolean;

packages/@aws-cdk/user-input-gen/test/yargs-gen.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('render', () => {
7878
commands: {
7979
test: {
8080
description: 'the action under test',
81+
aliases: ['spec'],
8182
options: {
8283
one: {
8384
type: 'boolean',
@@ -104,7 +105,7 @@ describe('render', () => {
104105
return yargs
105106
.env('CDK')
106107
.usage('Usage: cdk -a <cdk-app> COMMAND')
107-
.command('test', 'the action under test', (yargs: Argv) =>
108+
.command(['test', 'spec'], 'the action under test', (yargs: Argv) =>
108109
yargs
109110
.option('one', {
110111
default: undefined,

packages/aws-cdk/jest.config.json

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

packages/aws-cdk/lib/api/aws-auth/awscli-compatible.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { ProxyAgent } from 'proxy-agent';
88
import { makeCachingProvider } from './provider-caching';
99
import type { SdkHttpOptions } from './sdk-provider';
1010
import { readIfPossible } from './util';
11+
import { AuthenticationError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api';
1112
import { debug } from '../../logging';
12-
import { AuthenticationError } from '../../toolkit/error';
1313

1414
const DEFAULT_CONNECTION_TIMEOUT = 10000;
1515
const DEFAULT_TIMEOUT = 300000;

packages/aws-cdk/lib/api/aws-auth/credential-plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { inspect } from 'util';
22
import type { CredentialProviderSource, ForReading, ForWriting, PluginProviderResult, SDKv2CompatibleCredentials, SDKv3CompatibleCredentialProvider, SDKv3CompatibleCredentials } from '@aws-cdk/cli-plugin-contract';
33
import type { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';
44
import { credentialsAboutToExpire, makeCachingProvider } from './provider-caching';
5+
import { AuthenticationError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api';
56
import { debug, warning } from '../../logging';
6-
import { AuthenticationError } from '../../toolkit/error';
77
import { formatErrorMessage } from '../../util';
88
import type { Mode } from '../plugin/mode';
99
import { PluginHost } from '../plugin/plugin';

packages/aws-cdk/lib/api/aws-auth/sdk-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { CredentialPlugins } from './credential-plugins';
1212
import { makeCachingProvider } from './provider-caching';
1313
import { SDK } from './sdk';
1414
import { callTrace, traceMemberMethods } from './tracing';
15+
import { AuthenticationError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api';
1516
import { debug, warning } from '../../logging';
16-
import { AuthenticationError } from '../../toolkit/error';
1717
import { formatErrorMessage } from '../../util';
1818
import { Mode } from '../plugin/mode';
1919

packages/aws-cdk/lib/api/aws-auth/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@ import { cachedAsync } from './cached';
346346
import type { Account } from './sdk-provider';
347347
import { traceMemberMethods } from './tracing';
348348
import { defaultCliUserAgent } from './user-agent';
349+
import { AuthenticationError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api';
349350
import { debug } from '../../logging';
350-
import { AuthenticationError } from '../../toolkit/error';
351351
import { formatErrorMessage } from '../../util';
352352

353353
export interface S3ClientOptions {

packages/aws-cdk/lib/api/bootstrap/bootstrap-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import type * as cxapi from '@aws-cdk/cx-api';
44
import type { BootstrapEnvironmentOptions, BootstrappingParameters } from './bootstrap-props';
55
import { BootstrapStack, bootstrapVersionFromTemplate } from './deploy-bootstrap';
66
import { legacyBootstrapTemplate } from './legacy-template';
7+
import { ToolkitError } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api';
78
import type { IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private';
89
import { warn } from '../../cli/messages';
9-
import { ToolkitError } from '../../toolkit/error';
1010
import { bundledPackageRootDir, loadStructuredFile, serializeStructure } from '../../util';
1111
import type { SDK, SdkProvider } from '../aws-auth';
1212
import type { SuccessfulDeployStackResult } from '../deployments';

0 commit comments

Comments
 (0)