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

refactor: remove app boilerplate and improvements to cx protocol #868

Merged
merged 9 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 4 additions & 4 deletions docs/src/apps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ as shown in the following example.

import { App } from '@aws-cdk/cdk'

const app = new App(process.argv); // input: ARGV
const app = new App(); // input: ARGV

// <add stacks here>

process.stdout.write(app.run());
app.run();

An |app-construct| is a collection of |stack| objects, as shown in the following
example.
Expand All @@ -41,7 +41,7 @@ example.
import { App } from '@aws-cdk/cdk'
import { MyStack } from './my-stack'

const app = new App(process.argv);
const app = new App();

const dev = new MyStack(app, { name: 'Dev', region: 'us-west-2', dev: true })
const preProd = new MyStack(app, { name: 'PreProd', region: 'us-west-2', preProd: true })
Expand All @@ -58,7 +58,7 @@ example.
prodStages: prod
});

process.stdout.write(app.run());
app.run();

Use the |toolkit| to list the stacks in this executable,
as shown in the following example.
Expand Down
18 changes: 8 additions & 10 deletions docs/src/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ the |cdk|.
import { MyStack } from './my-stack'
import { DeploymentPipeline } from './my-deployment'

const app = new App(process.argv);
const app = new App();

// Use the default environment
new MyStack(app, { name: 'Dev' });
Expand Down Expand Up @@ -107,9 +107,7 @@ the |cdk|.
prodStages: prod
});

app.exec()
.then(stdout => process.stdout.write(stdout))
.catch(e => { throw e });
app.run();

.. _dynamodb_example:

Expand Down Expand Up @@ -140,11 +138,11 @@ and sort key **Timestamp**.
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

new MyStack(app, 'MyStack');

process.stdout.write(app.run());
app.run();

.. _creating_rds_example:

Expand Down Expand Up @@ -183,11 +181,11 @@ The following example creates the Aurora database **MyAuroraDatabase**.
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

new MyStack(app, 'MyStack');

process.stdout.write(app.run());
app.run();

.. _creating_s3_example:

Expand All @@ -213,8 +211,8 @@ encryption provided by |S3|.
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

new MyStack(app, 'MyStack');

process.stdout.write(app.run());
app.run()
13 changes: 6 additions & 7 deletions docs/src/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class. Let's create our first, empty **App**:
}
}

process.stdout.write(new MyApp(process.argv).run());
new MyApp().run();

.. group-tab:: TypeScript

Expand All @@ -219,7 +219,7 @@ class. Let's create our first, empty **App**:
}
}

process.stdout.write(new MyApp(process.argv).run());
new MyApp().run();

.. group-tab:: Java

Expand Down Expand Up @@ -454,7 +454,7 @@ Define a stack and add it to the app.
}
}

process.stdout.write(new MyApp(process.argv).run());
new MyApp().run();

.. group-tab:: TypeScript

Expand All @@ -472,14 +472,13 @@ Define a stack and add it to the app.
}

class MyApp extends cdk.App {
constructor(argv: string[]) {
super(argv);

constructor() {
super();
new MyStack(this, 'hello-cdk');
}
}

process.stdout.write(new MyApp(process.argv).run());
new MyApp().run();

.. group-tab:: Java

Expand Down
4 changes: 2 additions & 2 deletions docs/src/passing-in-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ Finally, connect the dots in your app.

.. code-block:: ts

const app = new cdk.App(process.argv);
const app = new cdk.App();

const myStack = new HelloCdkStack(app, "HelloCdkStack");

new MyCdkStack(app, "MyCdkStack", {
theBucketRefProps: myStack.myBucketRefProps
});

process.stdout.write(app.run());
app.run();

.. _using_cfn_parameter:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/stacks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ And then, add instances of this class to your app:

.. code-block:: js

const app = new App(process.argv);
const app = new App();

new MyStack(app, 'NorthAmerica', { env: { region: 'us-east-1' } });
new MyStack(app, 'Europe', { env: { region: 'us-west-2' } });
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

public class HelloJavaApp {
public static void main(final String[] args) {
App app = new App(Arrays.asList(args));
App app = new App();

new HelloJavaStack(app, "hello-cdk");

System.out.println(app.run());
app.run();
}
}
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/advanced-usage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class CloudFormationExample extends cdk.Stack {
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

new PolicyExample(app, 'PolicyExample');
new IncludeExample(app, 'IncludeExample');
Expand All @@ -199,4 +199,4 @@ new CloudFormationExample(app, 'CloudFormationExample');
new EnvContextExample(app, 'EnvContextExampleNA', { env: { region: 'us-east-1' }});
new EnvContextExample(app, 'EnvContextExampleEU', { env: { region: 'eu-west-2' }});

process.stdout.write(app.run());
app.run();
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class Consumer extends cdk.Stack {
// first. In the future the toolkit will be able to understand the relationships
// between the stacks and will deploy them in order.

const app = new cdk.App(process.argv);
const app = new cdk.App();

const producer = new Producer(app, 'produce');

new Consumer(app, 'consume', {
userBucketRef: producer.myBucketRef
});

process.stdout.write(app.run());
app.run();
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/chat-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class ChatAppFunction extends lambda.Function {
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

// Add the stack to the app
// (apps can host many stacks, for example, one for each region)
new MyStack(app, 'ChatAppStack', { env: { region: 'us-west-2' } });

process.stdout.write(app.run());
app.run();
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/cloudformation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class CloudFormationExample extends cdk.Stack {
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

new CloudFormationExample(app);

process.stdout.write(app.run());
app.run();
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/custom-resource/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ class FailAfterCreatingStack extends cdk.Stack {
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

new SucceedingStack(app, 'SucceedingStack');
new FailCreationStack(app, 'FailCreationStack');
new FailAfterCreatingStack(app, 'FailAfterCreatingStack');

process.stdout.write(app.run());
app.run();
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/ec2/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"us-east-1e",
"us-east-1f"
],
"ssm:585695036304:us-east-1:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2": "ami-14c5486b"
"ssm:585695036304:us-east-1:/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2": "ami-0ff8a91507f77f867"
}
}
}
4 changes: 2 additions & 2 deletions examples/cdk-examples-typescript/ec2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class CommonInfrastructure extends cdk.Stack {
}
}

const app = new cdk.App(process.argv);
const app = new cdk.App();

const infra = new CommonInfrastructure(app, 'infra');

new AppWithVpc(app, 'app-with-vpc');
new MyApp(app, 'my-app', { infra });

process.stdout.write(app.run());
app.run();
Loading