Skip to content

Commit

Permalink
fix(init-templates): numerous fixes and additions to the sample-app i…
Browse files Browse the repository at this point in the history
…nit templates (aws#5119)

* fix: update init templates for csharp and java

* remove extra space

* switch to positive assertion

* revisions to sample-app inits

* further improve init template alignment

* fixup fsharp templates

* remove .ionide directory

* add fix for aws#5130

Fixes aws#5130

* comment out Roslyn analyzers dependency

* complete integration tests up

* fixup python test

* update java main method signature to use String[] args

* adding final in main method for consistency with rest of java template

* update READMEs for java init templates

* update READMEs for C# and F# init templates

* update app READMEs for JavaScript, TypeScript, Python

* update sample-app READMEs for all supported languages

* updating description of sample-apps for all languages in README

* updating README for lib
  • Loading branch information
NGL321 authored and mergify[bot] committed Nov 21, 2019
1 parent bbd7637 commit 02c3b05
Show file tree
Hide file tree
Showing 65 changed files with 872 additions and 252 deletions.
10 changes: 9 additions & 1 deletion packages/aws-cdk/lib/init-templates/app/csharp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Useful commands
# Welcome to your CDK C# project!

This is a blank project for C# development with CDK.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to compile and execute your project.

## Useful commands

* `dotnet build src` compile this app
* `cdk deploy` deploy this stack to your default AWS account/region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<ItemGroup>
<!-- CDK Construct Library dependencies -->
<PackageReference Include="Amazon.CDK" Version="%cdk-version%-devpreview" />
<PackageReference Include="Amazon.CDK.AWS.IAM" Version="%cdk-version%-devpreview" />
<PackageReference Include="Amazon.CDK.AWS.SNS" Version="%cdk-version%-devpreview" />
<PackageReference Include="Amazon.CDK.AWS.SNS.Subscriptions" Version="%cdk-version%-devpreview" />
<PackageReference Include="Amazon.CDK.AWS.SQS" Version="%cdk-version%-devpreview" />

<!-- jsii Roslyn analyzers (un-comment to obtain compile-time checks for missing required props
<PackageReference Include="Amazon.Jsii.Analyzers" Version="*" PrivateAssets="all" />
-->
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace %name.PascalCased%
{
public class %name.PascalCased%Stack : Stack
{
public %name.PascalCased%Stack(Construct scope, string id, IStackProps props) : base(scope, id, props)
public %name.PascalCased%Stack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
// The code that defines your stack goes here
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Potential Code Quality Issues", "RECS0026:Possible unassigned object created by 'new'", Justification = "Constructs add themselves to the scope in which they are created")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Program
static void Main(string[] args)
{
var app = new App();
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack", new StackProps());
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack");
app.Synth();
}
}
Expand Down
12 changes: 5 additions & 7 deletions packages/aws-cdk/lib/init-templates/app/fsharp/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
## Welcome to your CDK F# project!

# CDK HelloWorld
This is a blank project for F# development with CDK.

Welcome to your CDK .NET project!
The `cdk.json` file tells the CDK Toolkit how to execute your app.

You should explore the contents of this template. It demonstrates a CDK app with two instances of
a stack (`HelloStack`) which also uses a user-defined construct (`HelloConstruct`).
It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to compile and execute your project.

The `cdk.json` file tells the CDK Toolkit how to execute your app. It uses the `dotnet` CLI to do this.

# Useful commands
## Useful commands

* `dotnet build src` compile this app
* `cdk ls` list all stacks in the app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import * as path from 'path';
import { InvokeHook } from '../../../init';

export const invoke: InvokeHook = async (targetDirectory: string) => {
const slnPath = path.join(targetDirectory, "src", "HelloCdk.sln");
const fsprojPath = path.join(targetDirectory, "src", "HelloCdk", "HelloCdk.fsproj");
const slnPath = path.join(targetDirectory, "src", "%name.PascalCased%.sln");
const fsprojPath = path.join(targetDirectory, "src", "%name.PascalCased%", "%name.PascalCased%.fsproj");

const child = child_process.spawn('dotnet', [ 'sln', slnPath, 'add', fsprojPath ], {
// Need this for Windows where we want .cmd and .bat to be found as well.
Expand All @@ -26,7 +26,7 @@ export const invoke: InvokeHook = async (targetDirectory: string) => {
if (code === 0) {
resolve(Buffer.concat(stdout).toString('utf-8'));
} else {
reject(new Error(`Could not add project HelloCdk.fsproj to solution HelloCdk.sln. Error code: ${code}`));
reject(new Error(`Could not add project %name.PascalCased%.fsproj to solution %name.PascalCased%.sln. Error code: ${code}`));
}
});
});
Expand Down
4 changes: 0 additions & 4 deletions packages/aws-cdk/lib/init-templates/app/fsharp/cdk.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"app": "dotnet run -p src/%name.PascalCased%/%name.PascalCased%.fsproj"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="%name.PascalCased%Stack.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<!-- CDK Construct Library dependencies -->
<PackageReference Include="Amazon.CDK" Version="%cdk-version%-devpreview" />

<!-- jsii Roslyn analyzers (un-comment to obtain compile-time checks for missing required props
<PackageReference Include="Amazon.Jsii.Analyzers" Version="*" PrivateAssets="all" />
-->
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace %name.PascalCased%

open Amazon.CDK

type %name.PascalCased%Stack(scope, id, props) as this =
inherit Stack(scope, id, props)

// The code that defines your stack goes here
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
open Amazon.CDK
open %name.PascalCased%

[<EntryPoint>]
let main _ =
let app = App(null)

%name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps()) |> ignore

app.Synth() |> ignore
0

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 5 additions & 9 deletions packages/aws-cdk/lib/init-templates/app/java/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Welcome to your CDK Java project!

Welcome to your CDK Java project!
This is a blank project for Java development with CDK.

It is a Maven-based project, so you can open this directory with any Maven-compatible Java IDE,
and you should be able to build and run tests from your IDE.
The `cdk.json` file tells the CDK Toolkit how to execute your app.

You should explore the contents of this template. It demonstrates a CDK app with two instances of
a stack (`HelloStack`) which also uses a user-defined construct (`HelloConstruct`).
It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests.

The `cdk.json` file tells the CDK Toolkit how to execute your app. This example relies on maven
to do that.

# Useful commands
## Useful commands

* `mvn package` compile and run tests
* `cdk ls` list all stacks in the app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Arrays;

public class %name.PascalCased%App {
public static void main(final String argv[]) {
public static void main(final String[] args) {
App app = new App();

new %name.PascalCased%Stack(app, "%name.PascalCased%Stack");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.myorg;

import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.Construct;
import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.StackProps;

public class %name.PascalCased%Stack extends Stack {
public %name.PascalCased%Stack(final Construct scope, final String id) {
super(scope, id, null);
this(scope, id, null);
}

public %name.PascalCased%Stack(final Construct scope, final String id, final StackProps props) {
super(scope, id, props);

// The code that defines your stack goes here
}
Expand Down
8 changes: 7 additions & 1 deletion packages/aws-cdk/lib/init-templates/app/javascript/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Useful commands
# Welcome to your CDK JavaScript project!

This is a blank project for JavaScript development with CDK.

The `cdk.json` file tells the CDK Toolkit how to execute your app. The build step is not required when using JavaScript.

## Useful commands

* `npm run test` perform the jest unit tests
* `cdk deploy` deploy this stack to your default AWS account/region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ To add additional dependencies, for example other CDK libraries, just add
them to your `setup.py` file and rerun the `pip install -r requirements.txt`
command.

# Useful commands
## Useful commands

* `cdk ls` list all stacks in the app
* `cdk synth` emits the synthesized CloudFormation template
Expand Down
8 changes: 7 additions & 1 deletion packages/aws-cdk/lib/init-templates/app/typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Useful commands
# Welcome to your CDK TypeScript project!

This is a blank project for TypeScript development with CDK.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

## Useful commands

* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
Expand Down
5 changes: 0 additions & 5 deletions packages/aws-cdk/lib/init-templates/lib/typescript/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Welcome to your CDK TypeScript Construct Library project!

You should explore the contents of this project. It demonstrates a CDK Construct Library that includes a construct (`%name.PascalCased%`)
which contains an Amazon SNS topic that is subscribed to an Amazon SQS queue.

The construct defines an interface (`%name.PascalCased%Props`) to configure the visibility timeout of the queue.

## Useful commands

* `npm run build` compile typescript to js
* `npm run watch` watch for changes and compile
* `npm run test` perform the jest unit tests
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Welcome to your CDK C# project!

# CDK Sample App
You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`%name.PascalCased%Stack`)
which contains an Amazon SNS topic that is subscribed to an Amazon SQS queue.

Welcome to your CDK .NET project!
The `cdk.json` file tells the CDK Toolkit how to execute your app.

You should explore the contents of this template. It demonstrates a CDK app with two instances of
a stack (`%name.PascalCased%Stack`) which also uses a user-defined construct (`%name.PascalCased%Construct`).
It uses the [.NET Core CLI](https://docs.microsoft.com/dotnet/articles/core/) to compile and execute your project.

The `cdk.json` file tells the CDK Toolkit how to execute your app. It uses the `dotnet` CLI to do this.

# Useful commands
## Useful commands

* `dotnet build src` compile this app
* `cdk ls` list all stacks in the app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<PackageReference Include="Amazon.CDK.AWS.SNS" Version="%cdk-version%-devpreview" />
<PackageReference Include="Amazon.CDK.AWS.SNS.Subscriptions" Version="%cdk-version%-devpreview" />
<PackageReference Include="Amazon.CDK.AWS.SQS" Version="%cdk-version%-devpreview" />

<!-- jsii Roslyn analyzers (un-comment to obtain compile-time checks for missing required props
<PackageReference Include="Amazon.Jsii.Analyzers" Version="*" PrivateAssets="all" />
-->
</ItemGroup>

</Project>

This file was deleted.

Loading

0 comments on commit 02c3b05

Please sign in to comment.