-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Command now accepts `--type=[lib|app]` and `--language=...` - Template types are documented using an info.json file (description, ...) - Language support is enabled juts by adding new files. - Supports (very) minimal templating: + `%name%` gets replaced with the snake_case version of the current directory's basename + `%name.CamelCase%` gets replaced with the capitalized CamelCase version of the current directory's basename + Replaces happen in files with names ending in `.template.extension` and in filenames Fixes #23
- Loading branch information
1 parent
0a7f169
commit e3a7d51
Showing
16 changed files
with
394 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"description": "Template for a CDK Application", | ||
"aliases": ["application"] | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/aws-cdk-toolkit/lib/init-templates/app/typescript/.template.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.js | ||
*.d.ts | ||
node_modules |
2 changes: 2 additions & 0 deletions
2
packages/aws-cdk-toolkit/lib/init-templates/app/typescript/.template.npmignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.ts | ||
!*.d.ts |
24 changes: 24 additions & 0 deletions
24
packages/aws-cdk-toolkit/lib/init-templates/app/typescript/bin/%name%.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env node | ||
import { App, Stack, StackProps } from 'aws-cdk'; | ||
import { Topic } from 'aws-cdk-sns'; | ||
import { Queue } from 'aws-cdk-sqs'; | ||
|
||
class %name.PascalCased%Stack extends Stack { | ||
constructor(parent: App, name: string, props?: StackProps) { | ||
super(parent, name, props); | ||
|
||
const queue = new Queue(this, '%name.PascalCased%Queue', { | ||
visibilityTimeoutSec: 300 | ||
}); | ||
|
||
const topic = new Topic(this, '%name.PascalCased%Topic'); | ||
|
||
topic.subscribeQueue(queue); | ||
} | ||
} | ||
|
||
const app = new App(process.argv); | ||
|
||
new %name.PascalCased%Stack(app, '%name.PascalCased%Stack'); | ||
|
||
process.stdout.write(app.run()); |
27 changes: 27 additions & 0 deletions
27
packages/aws-cdk-toolkit/lib/init-templates/app/typescript/package.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "%name%", | ||
"version": "%cdk-version%", | ||
"description": "A CDK Application", | ||
"private": "true", | ||
"main": "bin/index.js", | ||
"types": "bin/index.d.ts", | ||
"bin": { | ||
"%name%": "bin/%name%.js" | ||
}, | ||
"scripts": { | ||
"prepare": "tslint -p . && tsc && chmod a+x bin/%name%.js", | ||
"watch": "tsc -w", | ||
"lint": "tslint -p . --force" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.9.4", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.8.3" | ||
}, | ||
"dependencies": { | ||
"aws-cdk": "^%cdk-version%", | ||
"aws-cdk-resources": "^%cdk-version%", | ||
"aws-cdk-sns": "^%cdk-version%", | ||
"aws-cdk-sqs": "^%cdk-version%" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/aws-cdk-toolkit/lib/init-templates/app/typescript/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"target":"ES2018", | ||
"module": "commonjs", | ||
"lib": ["es2016", "es2017.object", "es2017.string"], | ||
"declaration": true, | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"experimentalDecorators": true, | ||
"strictPropertyInitialization":false | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"description": "Template for a CDK Construct Library", | ||
"aliases": "library" | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/aws-cdk-toolkit/lib/init-templates/lib/typescript/.template.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.js | ||
*.d.ts | ||
node_modules |
2 changes: 2 additions & 0 deletions
2
packages/aws-cdk-toolkit/lib/init-templates/lib/typescript/.template.npmignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.ts | ||
!*.d.ts |
32 changes: 32 additions & 0 deletions
32
packages/aws-cdk-toolkit/lib/init-templates/lib/typescript/lib/index.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Construct } from 'aws-cdk'; | ||
import { sqs } from 'aws-cdk-resources'; | ||
import { Topic } from 'aws-cdk-sns'; | ||
import { Queue } from 'aws-cdk-sqs'; | ||
|
||
export interface %name.PascalCased%Props { | ||
/** | ||
* The visibility timeout to be configured on the SQS Queue, in seconds. | ||
* | ||
* @default 300 | ||
*/ | ||
visibilityTimeout?: number; | ||
} | ||
|
||
export class %name.PascalCased% extends Construct { | ||
/** @returns the ARN of the SQS queue */ | ||
public readonly queueArn: sqs.QueueArn; | ||
|
||
constructor(parent: Construct, name: string, props: %name.PascalCased%Props = {}) { | ||
super(parent, name); | ||
|
||
const queue = new Queue(this, '%name.PascalCased%Queue', { | ||
visibilityTimeoutSec: props.visibilityTimeout || 300 | ||
}); | ||
|
||
const topic = new Topic(this, '%name.PascalCased%Topic'); | ||
|
||
topic.subscribeQueue(queue); | ||
|
||
this.queueArn = queue.queueArn; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/aws-cdk-toolkit/lib/init-templates/lib/typescript/package.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "%name%", | ||
"version": "%cdk-version%", | ||
"description": "A CDK Construct Library", | ||
"private": true, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"jsii": { | ||
"outdir": "dist", | ||
"names": { | ||
"java": "com.acme.cdk.%name.camelCased%", | ||
"dotnet": "Acme.Cdk.%name.PascalCased%" | ||
} | ||
}, | ||
"scripts": { | ||
"prepare": "jsii && tslint -p .", | ||
"watch": "jsii -w", | ||
"lint": "tsc && tslint -p .", | ||
"test": "nodeunit test/test.*.js" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^8.9.4", | ||
"jsii": "^0.4.0", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.8.3" | ||
}, | ||
"dependencies": { | ||
"aws-cdk": "^%cdk-version%", | ||
"aws-cdk-resources": "^%cdk-version%", | ||
"aws-cdk-sns": "^%cdk-version%", | ||
"aws-cdk-sqs": "^%cdk-version%" | ||
} | ||
} |
Oops, something went wrong.