@jttc/projen-project-types 1.0.0-beta.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cz-config.js +1 -1
- package/.jsii +99 -27
- package/API.md +1568 -9
- package/docs/default-configurations.md +267 -0
- package/docs/index.md +20 -1
- package/docs/project-types/cdk-library.md +413 -0
- package/lib/cdk/cdk-library-project.d.ts +9 -0
- package/lib/cdk/cdk-library-project.js +27 -0
- package/lib/common/common-options.d.ts +25 -0
- package/lib/common/common-options.js +76 -0
- package/lib/index.d.ts +1 -3
- package/lib/index.js +16 -12
- package/mkdocs.yml +4 -0
- package/package.json +10 -4
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# Default Configurations
|
|
2
|
+
|
|
3
|
+
This document describes the default configurations applied to all project types in this package.
|
|
4
|
+
|
|
5
|
+
## Prettier Configuration
|
|
6
|
+
|
|
7
|
+
All projects include Prettier with the following default settings:
|
|
8
|
+
|
|
9
|
+
### Settings Applied
|
|
10
|
+
|
|
11
|
+
```json title=".prettierrc.json" linenums="1"
|
|
12
|
+
{
|
|
13
|
+
"trailingComma": "es5",
|
|
14
|
+
"singleQuote": true,
|
|
15
|
+
"bracketSpacing": true,
|
|
16
|
+
"semi": true
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Rationale
|
|
21
|
+
|
|
22
|
+
- **`trailingComma: "es5"`**: Ensures consistent trailing commas in objects and arrays, making diffs cleaner
|
|
23
|
+
- **`singleQuote: true`**: Uses single quotes for strings, which is common in JavaScript/TypeScript projects
|
|
24
|
+
- **`bracketSpacing: true`**: Adds spaces inside object literal braces `{ foo: bar }`
|
|
25
|
+
- **`semi: true`**: Always includes semicolons for statement termination
|
|
26
|
+
|
|
27
|
+
### Customization
|
|
28
|
+
|
|
29
|
+
You can override these settings by providing custom `prettierOptions`:
|
|
30
|
+
|
|
31
|
+
```typescript title="Custom Prettier Configuration" linenums="1" hl_lines="5 6 7 8"
|
|
32
|
+
const project = new ProjectType({
|
|
33
|
+
// ... other options
|
|
34
|
+
prettierOptions: {
|
|
35
|
+
settings: {
|
|
36
|
+
singleQuote: false,
|
|
37
|
+
semi: false,
|
|
38
|
+
tabWidth: 4,
|
|
39
|
+
printWidth: 120,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Highlighted lines explanation:**
|
|
46
|
+
|
|
47
|
+
- **Line 5**: Use double quotes instead of single quotes
|
|
48
|
+
- **Line 6**: Omit semicolons for cleaner code
|
|
49
|
+
- **Line 7**: Use 4 spaces for indentation instead of 2
|
|
50
|
+
- **Line 8**: Allow longer line length
|
|
51
|
+
|
|
52
|
+
### Disabling Prettier
|
|
53
|
+
|
|
54
|
+
To completely disable Prettier:
|
|
55
|
+
|
|
56
|
+
```typescript title="Disable Prettier" linenums="1" hl_lines="3"
|
|
57
|
+
const project = new ProjectType({
|
|
58
|
+
// ... other options
|
|
59
|
+
prettier: false,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Highlighted line explanation:**
|
|
64
|
+
|
|
65
|
+
- **Line 3**: No `.prettierrc.json` file will be created
|
|
66
|
+
|
|
67
|
+
## VSCode Configuration
|
|
68
|
+
|
|
69
|
+
All projects include VSCode workspace configuration when enabled (default behavior).
|
|
70
|
+
|
|
71
|
+
### Settings Applied
|
|
72
|
+
|
|
73
|
+
```json title=".vscode/settings.json" linenums="1"
|
|
74
|
+
{
|
|
75
|
+
"editor.formatOnSave": true,
|
|
76
|
+
"editor.indentSize": 2,
|
|
77
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
78
|
+
"eslint.nodePath": "./node_modules",
|
|
79
|
+
"eslint.useFlatConfig": false
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Recommended Extensions
|
|
84
|
+
|
|
85
|
+
The following extensions are automatically recommended for all projects:
|
|
86
|
+
|
|
87
|
+
```json title=".vscode/extensions.json" linenums="1"
|
|
88
|
+
{
|
|
89
|
+
"recommendations": [
|
|
90
|
+
"amazonwebservices.aws-toolkit-vscode",
|
|
91
|
+
"DanielThielking.aws-cloudformation-yaml",
|
|
92
|
+
"ms-azuretools.vscode-containers",
|
|
93
|
+
"dbaeumer.vscode-eslint",
|
|
94
|
+
"esbenp.prettier-vscode",
|
|
95
|
+
"mhutchie.git-graph",
|
|
96
|
+
"github.vscode-github-actions",
|
|
97
|
+
"GitHub.vscode-pull-request-github",
|
|
98
|
+
"eamodio.gitlens",
|
|
99
|
+
"spmeesseman.vscode-taskexplorer",
|
|
100
|
+
"wayou.vscode-todo-highlight",
|
|
101
|
+
"vscode-icons-team.vscode-icons",
|
|
102
|
+
"ms-vscode-remote.vscode-remote-extensionpack"
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Development Tools
|
|
108
|
+
- **AWS Toolkit for VS Code** (`amazonwebservices.aws-toolkit-vscode`)
|
|
109
|
+
- **CloudFormation YAML** (`DanielThielking.aws-cloudformation-yaml`)
|
|
110
|
+
- **Docker** (`ms-azuretools.vscode-containers`)
|
|
111
|
+
|
|
112
|
+
#### Code Quality & Formatting
|
|
113
|
+
- **ESLint** (`dbaeumer.vscode-eslint`)
|
|
114
|
+
- **Prettier** (`esbenp.prettier-vscode`)
|
|
115
|
+
|
|
116
|
+
#### Git & Version Control
|
|
117
|
+
- **Git Graph** (`mhutchie.git-graph`)
|
|
118
|
+
- **GitHub Actions** (`github.vscode-github-actions`)
|
|
119
|
+
- **GitHub Pull Requests** (`GitHub.vscode-pull-request-github`)
|
|
120
|
+
- **GitLens** (`eamodio.gitlens`)
|
|
121
|
+
|
|
122
|
+
#### Productivity
|
|
123
|
+
- **Task Explorer** (`spmeesseman.vscode-taskexplorer`)
|
|
124
|
+
- **TODO Highlight** (`wayou.vscode-todo-highlight`)
|
|
125
|
+
- **VSCode Icons** (`vscode-icons-team.vscode-icons`)
|
|
126
|
+
- **Remote Development Extension Pack** (`ms-vscode-remote.vscode-remote-extensionpack`)
|
|
127
|
+
|
|
128
|
+
### Rationale
|
|
129
|
+
|
|
130
|
+
- **Format on save**: Automatically formats code when saving, ensuring consistency
|
|
131
|
+
- **Prettier as default formatter**: Uses the configured prettier settings
|
|
132
|
+
- **ESLint integration**: Provides real-time linting and error detection
|
|
133
|
+
- **AWS-focused extensions**: Optimized for AWS and cloud development workflows
|
|
134
|
+
- **Git workflow tools**: Enhanced git management and collaboration features
|
|
135
|
+
|
|
136
|
+
### Customization
|
|
137
|
+
|
|
138
|
+
You can disable VSCode configuration entirely:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const project = new ProjectType({
|
|
142
|
+
// ... other options
|
|
143
|
+
vscode: false,
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Currently, there's no built-in way to customize individual VSCode settings or extensions, but this may be added in future versions.
|
|
148
|
+
|
|
149
|
+
## Configuration Behavior
|
|
150
|
+
|
|
151
|
+
### Default Behavior (Recommended)
|
|
152
|
+
|
|
153
|
+
When no explicit configuration is provided:
|
|
154
|
+
|
|
155
|
+
```typescript title="Default Configuration" linenums="1"
|
|
156
|
+
const project = new ProjectType({
|
|
157
|
+
name: 'my-project',
|
|
158
|
+
// ... other required options
|
|
159
|
+
// prettier: undefined (defaults to true)
|
|
160
|
+
// vscode: undefined (defaults to true)
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Result**: Both Prettier and VSCode configurations are applied with default settings.
|
|
165
|
+
|
|
166
|
+
### Mixed Configurations
|
|
167
|
+
|
|
168
|
+
You can mix and match configurations:
|
|
169
|
+
|
|
170
|
+
=== "Prettier Only"
|
|
171
|
+
|
|
172
|
+
```typescript linenums="1" title="Prettier Only Configuration" hl_lines="3 4"
|
|
173
|
+
const project = new ProjectType({
|
|
174
|
+
// ... other options
|
|
175
|
+
prettier: true,
|
|
176
|
+
vscode: false,
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Highlighted lines explanation:**
|
|
181
|
+
|
|
182
|
+
- **Line 3**: Enable prettier with default settings
|
|
183
|
+
- **Line 4**: No VSCode configuration files created
|
|
184
|
+
|
|
185
|
+
=== "VSCode Only"
|
|
186
|
+
|
|
187
|
+
```typescript linenums="1" title="VSCode Only Configuration" hl_lines="3 4"
|
|
188
|
+
const project = new ProjectType({
|
|
189
|
+
// ... other options
|
|
190
|
+
prettier: false,
|
|
191
|
+
vscode: true,
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Highlighted lines explanation:**
|
|
196
|
+
|
|
197
|
+
- **Line 3**: No prettier configuration files created
|
|
198
|
+
- **Line 4**: Enable VSCode with default settings
|
|
199
|
+
|
|
200
|
+
=== "Both Disabled"
|
|
201
|
+
|
|
202
|
+
```typescript linenums="1" title="Minimal Configuration" hl_lines="3 4"
|
|
203
|
+
const project = new ProjectType({
|
|
204
|
+
// ... other options
|
|
205
|
+
prettier: false,
|
|
206
|
+
vscode: false,
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Highlighted lines explanation:**
|
|
211
|
+
|
|
212
|
+
- **Line 3**: No prettier files
|
|
213
|
+
- **Line 4**: No VSCode files
|
|
214
|
+
|
|
215
|
+
## Files Created
|
|
216
|
+
|
|
217
|
+
### When Prettier is Enabled
|
|
218
|
+
|
|
219
|
+
- `.prettierrc.json` - Prettier configuration file
|
|
220
|
+
- `.prettierignore` - Files to ignore during formatting (if applicable)
|
|
221
|
+
|
|
222
|
+
### When VSCode is Enabled
|
|
223
|
+
|
|
224
|
+
- `.vscode/settings.json` - Workspace settings
|
|
225
|
+
- `.vscode/extensions.json` - Recommended extensions
|
|
226
|
+
|
|
227
|
+
## Best Practices
|
|
228
|
+
|
|
229
|
+
### 1. Stick with Defaults
|
|
230
|
+
|
|
231
|
+
The default configurations have been carefully chosen for optimal development experience across teams. Unless you have specific requirements, it's recommended to use the defaults.
|
|
232
|
+
|
|
233
|
+
### 2. Team Consistency
|
|
234
|
+
|
|
235
|
+
If you customize configurations, ensure all team members are aware of the changes and update their local environments accordingly.
|
|
236
|
+
|
|
237
|
+
### 3. Document Customizations
|
|
238
|
+
|
|
239
|
+
If you deviate from defaults, document the reasons in your project's README or contributing guidelines.
|
|
240
|
+
|
|
241
|
+
### 4. Extension Installation
|
|
242
|
+
|
|
243
|
+
Encourage team members to install the recommended VSCode extensions for the best development experience.
|
|
244
|
+
|
|
245
|
+
## Future Enhancements
|
|
246
|
+
|
|
247
|
+
Planned improvements to the default configurations:
|
|
248
|
+
|
|
249
|
+
- **ESLint default configuration**: Common ESLint rules for TypeScript projects
|
|
250
|
+
- **Jest configuration**: Default test setup and configuration
|
|
251
|
+
- **GitHub Actions**: Standard CI/CD workflows
|
|
252
|
+
- **Dependabot**: Automated dependency updates
|
|
253
|
+
- **Customizable VSCode settings**: Allow overriding individual settings and extensions
|
|
254
|
+
|
|
255
|
+
## Contributing
|
|
256
|
+
|
|
257
|
+
To propose changes to the default configurations:
|
|
258
|
+
|
|
259
|
+
1. Open an issue describing the proposed change and rationale
|
|
260
|
+
2. Discuss with maintainers and community
|
|
261
|
+
3. Submit a pull request with the changes
|
|
262
|
+
4. Update documentation and tests
|
|
263
|
+
5. Ensure backward compatibility
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
*These configurations are maintained by [Jump to the Cloud](https://jumptothecloud.tech) and are designed to provide productive development environments out of the box.*
|
package/docs/index.md
CHANGED
|
@@ -29,7 +29,26 @@ While projen provides excellent base project types, real-world projects often re
|
|
|
29
29
|
|
|
30
30
|
## Getting Started
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Choose from our available project types:
|
|
33
|
+
|
|
34
|
+
### 🏗️ [CDK Library Project](project-types/cdk-library.md)
|
|
35
|
+
|
|
36
|
+
Create AWS CDK construct libraries with opinionated configurations:
|
|
37
|
+
|
|
38
|
+
- Pre-configured Prettier settings
|
|
39
|
+
- VSCode workspace setup with recommended extensions
|
|
40
|
+
- Best practices for CDK library development
|
|
41
|
+
- Fully customizable while maintaining sensible defaults
|
|
42
|
+
|
|
43
|
+
```bash linenums="1" title="Create new CDK Library project"
|
|
44
|
+
# Create a new CDK Library project
|
|
45
|
+
npx projen new --from @jttc/projen-project-types cdk-library
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
!!! tip "Getting Started"
|
|
49
|
+
After running the command above, follow the interactive prompts to configure your project, then customize further by editing `.projenrc.ts`
|
|
50
|
+
|
|
51
|
+
More project types are planned for future releases!
|
|
33
52
|
|
|
34
53
|
## Contributing
|
|
35
54
|
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
# CDK Library Project
|
|
2
|
+
|
|
3
|
+
The CDK Library Project type provides an opinionated setup for creating AWS CDK construct libraries with best practices and common configurations pre-configured.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This project type extends the standard `AwsCdkConstructLibrary` from projen with additional features:
|
|
8
|
+
|
|
9
|
+
- **Prettier configuration** with sensible defaults
|
|
10
|
+
- **VSCode settings and extensions** for enhanced development experience
|
|
11
|
+
- **Common project structure** and tooling setup
|
|
12
|
+
- **Configurable options** that respect user preferences
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
To create a new CDK Library project, use the projen CLI:
|
|
17
|
+
|
|
18
|
+
```bash linenums="1"
|
|
19
|
+
npx projen new --from @jttc/projen-project-types cdk-library
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This command will create a new project with the CDK Library template and prompt you for the required configuration options such as:
|
|
23
|
+
|
|
24
|
+
- Project name
|
|
25
|
+
- Author information
|
|
26
|
+
- Repository URL
|
|
27
|
+
- CDK version
|
|
28
|
+
- Default branch
|
|
29
|
+
|
|
30
|
+
After the project is created, you can customize it further by editing the `.projenrc.ts` file:
|
|
31
|
+
|
|
32
|
+
```typescript linenums="1" title=".projenrc.ts" hl_lines="4 8 12 13"
|
|
33
|
+
import { CdkLibrary } from '@jttc/projen-project-types';
|
|
34
|
+
|
|
35
|
+
const project = new CdkLibrary({
|
|
36
|
+
name: 'my-awesome-cdk-library',
|
|
37
|
+
author: 'Your Name',
|
|
38
|
+
authorAddress: 'your.email@example.com',
|
|
39
|
+
repositoryUrl: 'https://github.com/yourusername/my-awesome-cdk-library.git',
|
|
40
|
+
cdkVersion: '2.1.0',
|
|
41
|
+
defaultReleaseBranch: 'main',
|
|
42
|
+
|
|
43
|
+
// Add any additional customizations here
|
|
44
|
+
prettier: true,
|
|
45
|
+
vscode: true,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
project.synth();
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Highlighted lines explanation:**
|
|
52
|
+
|
|
53
|
+
- **Line 4**: Choose a descriptive name for your CDK construct library
|
|
54
|
+
- **Line 8**: Pin to a specific CDK version for consistency
|
|
55
|
+
- **Line 12**: Enable prettier formatting (default: true)
|
|
56
|
+
- **Line 13**: Enable VSCode workspace configuration (default: true)
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
### Automatic Prettier Configuration
|
|
61
|
+
|
|
62
|
+
The CDK Library project automatically configures Prettier with opinionated settings. For detailed information about the default prettier configuration used across all project types, see [Default Configurations](../default-configurations.md#prettier-configuration).
|
|
63
|
+
|
|
64
|
+
#### Summary of Default Settings
|
|
65
|
+
|
|
66
|
+
- **Single quotes** for strings
|
|
67
|
+
- **Trailing commas** (ES5 style)
|
|
68
|
+
- **Bracket spacing** enabled
|
|
69
|
+
- **Semicolons** required
|
|
70
|
+
|
|
71
|
+
!!! tip "View Complete Configuration"
|
|
72
|
+
See the [Default Configurations](../default-configurations.md#prettier-configuration) page for the complete prettier setup and customization options.
|
|
73
|
+
|
|
74
|
+
### VSCode Integration
|
|
75
|
+
|
|
76
|
+
When enabled, the project automatically sets up VSCode configuration with settings and recommended extensions optimized for CDK development. For complete details about VSCode configuration, see [Default Configurations](../default-configurations.md#vscode-configuration).
|
|
77
|
+
|
|
78
|
+
#### Key Features
|
|
79
|
+
|
|
80
|
+
- Format on save enabled
|
|
81
|
+
- Prettier as default formatter
|
|
82
|
+
- ESLint integration
|
|
83
|
+
- AWS and Git development extensions
|
|
84
|
+
- Proper indentation and editor settings
|
|
85
|
+
|
|
86
|
+
## Configuration Options
|
|
87
|
+
|
|
88
|
+
### Basic Configuration
|
|
89
|
+
|
|
90
|
+
All standard `AwsCdkConstructLibraryOptions` are supported. Here are the required options:
|
|
91
|
+
|
|
92
|
+
```typescript linenums="1" title="Basic CDK Library Configuration"
|
|
93
|
+
const project = new CdkLibrary({
|
|
94
|
+
// Required options
|
|
95
|
+
name: 'my-cdk-library',
|
|
96
|
+
author: 'Your Name',
|
|
97
|
+
authorAddress: 'your.email@example.com',
|
|
98
|
+
repositoryUrl: 'https://github.com/yourusername/my-cdk-library.git',
|
|
99
|
+
cdkVersion: '2.1.0',
|
|
100
|
+
defaultReleaseBranch: 'main',
|
|
101
|
+
|
|
102
|
+
// Optional configurations (see sections below)
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Prettier Configuration
|
|
107
|
+
|
|
108
|
+
#### Enable/Disable Prettier
|
|
109
|
+
|
|
110
|
+
```typescript linenums="1" title="Disable Prettier" hl_lines="3"
|
|
111
|
+
const project = new CdkLibrary({
|
|
112
|
+
// ... other options
|
|
113
|
+
prettier: false,
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Highlighted line explanation:**
|
|
118
|
+
|
|
119
|
+
- **Line 3**: Disables prettier entirely - no `.prettierrc.json` file will be created
|
|
120
|
+
|
|
121
|
+
#### Custom Prettier Options
|
|
122
|
+
|
|
123
|
+
```typescript linenums="1" title="Custom Prettier Configuration" hl_lines="5 6 7 8 9"
|
|
124
|
+
const project = new CdkLibrary({
|
|
125
|
+
// ... other options
|
|
126
|
+
prettier: true,
|
|
127
|
+
prettierOptions: {
|
|
128
|
+
settings: {
|
|
129
|
+
singleQuote: false,
|
|
130
|
+
semi: false,
|
|
131
|
+
tabWidth: 4,
|
|
132
|
+
trailingComma: 'none',
|
|
133
|
+
printWidth: 120,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Highlighted lines explanation:**
|
|
140
|
+
|
|
141
|
+
- **Line 6**: Use double quotes instead of single quotes
|
|
142
|
+
- **Line 7**: Omit semicolons
|
|
143
|
+
- **Line 8**: Use 4 spaces for indentation instead of 2
|
|
144
|
+
- **Line 9**: No trailing commas
|
|
145
|
+
- **Line 10**: Allow longer lines (120 characters instead of 80)
|
|
146
|
+
|
|
147
|
+
### VSCode Configuration
|
|
148
|
+
|
|
149
|
+
#### Enable/Disable VSCode Setup
|
|
150
|
+
|
|
151
|
+
=== "Default Behavior (Recommended)"
|
|
152
|
+
|
|
153
|
+
```typescript linenums="1" title="VSCode Enabled by Default"
|
|
154
|
+
const project = new CdkLibrary({
|
|
155
|
+
// ... other options
|
|
156
|
+
// vscode: undefined (defaults to enabled)
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
=== "Explicitly Enable"
|
|
161
|
+
|
|
162
|
+
```typescript linenums="1" title="Explicitly Enable VSCode" hl_lines="3"
|
|
163
|
+
const project = new CdkLibrary({
|
|
164
|
+
// ... other options
|
|
165
|
+
vscode: true,
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Highlighted line explanation:**
|
|
170
|
+
|
|
171
|
+
- **Line 3**: Same as default behavior, but explicit
|
|
172
|
+
|
|
173
|
+
=== "Disable VSCode"
|
|
174
|
+
|
|
175
|
+
```typescript linenums="1" title="Disable VSCode Configuration" hl_lines="3"
|
|
176
|
+
const project = new CdkLibrary({
|
|
177
|
+
// ... other options
|
|
178
|
+
vscode: false,
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Highlighted line explanation:**
|
|
183
|
+
|
|
184
|
+
- **Line 3**: No `.vscode/` folder will be created
|
|
185
|
+
|
|
186
|
+
### Behavior Matrix
|
|
187
|
+
|
|
188
|
+
| `prettier` | `vscode` | Prettier Files | VSCode Files | Description |
|
|
189
|
+
|------------|----------|----------------|--------------|-------------|
|
|
190
|
+
| `undefined` | `undefined` | ✅ Created | ✅ Created | Default behavior - both enabled |
|
|
191
|
+
| `true` | `true` | ✅ Created | ✅ Created | Explicitly enabled |
|
|
192
|
+
| `false` | `true` | ❌ Not created | ✅ Created | Only VSCode enabled |
|
|
193
|
+
| `true` | `false` | ✅ Created | ❌ Not created | Only Prettier enabled |
|
|
194
|
+
| `false` | `false` | ❌ Not created | ❌ Not created | Both disabled |
|
|
195
|
+
|
|
196
|
+
## Examples
|
|
197
|
+
|
|
198
|
+
### Minimal Setup
|
|
199
|
+
|
|
200
|
+
Perfect for getting started quickly with all defaults:
|
|
201
|
+
|
|
202
|
+
```typescript linenums="1" title=".projenrc.ts - Minimal Setup"
|
|
203
|
+
import { CdkLibrary } from '@jttc/projen-project-types';
|
|
204
|
+
|
|
205
|
+
const project = new CdkLibrary({
|
|
206
|
+
name: 'simple-cdk-library',
|
|
207
|
+
author: 'John Doe',
|
|
208
|
+
authorAddress: 'john@example.com',
|
|
209
|
+
repositoryUrl: 'https://github.com/johndoe/simple-cdk-library.git',
|
|
210
|
+
cdkVersion: '2.1.0',
|
|
211
|
+
defaultReleaseBranch: 'main',
|
|
212
|
+
// All other options use sensible defaults
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
project.synth();
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Customized Setup
|
|
219
|
+
|
|
220
|
+
Example with custom prettier settings and additional CDK options:
|
|
221
|
+
|
|
222
|
+
```typescript linenums="1" title=".projenrc.ts - Advanced Configuration" hl_lines="11 12 18 19 20"
|
|
223
|
+
import { CdkLibrary } from '@jttc/projen-project-types';
|
|
224
|
+
|
|
225
|
+
const project = new CdkLibrary({
|
|
226
|
+
name: 'advanced-cdk-library',
|
|
227
|
+
author: 'Jane Smith',
|
|
228
|
+
authorAddress: 'jane@company.com',
|
|
229
|
+
repositoryUrl: 'https://github.com/company/advanced-cdk-library.git',
|
|
230
|
+
cdkVersion: '2.1.0',
|
|
231
|
+
defaultReleaseBranch: 'main',
|
|
232
|
+
|
|
233
|
+
// Custom prettier settings
|
|
234
|
+
prettierOptions: {
|
|
235
|
+
settings: {
|
|
236
|
+
printWidth: 120,
|
|
237
|
+
tabWidth: 4,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
// Enable VSCode (explicit)
|
|
242
|
+
vscode: true,
|
|
243
|
+
|
|
244
|
+
// Additional CDK library options
|
|
245
|
+
description: 'An advanced CDK construct library',
|
|
246
|
+
keywords: ['aws', 'cdk', 'constructs'],
|
|
247
|
+
license: 'MIT',
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
project.synth();
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Highlighted lines explanation:**
|
|
254
|
+
|
|
255
|
+
- **Lines 11-16**: Custom prettier settings for longer lines and 4-space indentation
|
|
256
|
+
- **Line 19**: Enable VSCode configuration explicitly
|
|
257
|
+
- **Lines 22-24**: Additional NPM package metadata for discoverability
|
|
258
|
+
|
|
259
|
+
### Development-Only Setup
|
|
260
|
+
|
|
261
|
+
Optimized for local development with minimal tooling:
|
|
262
|
+
|
|
263
|
+
```typescript linenums="1" title=".projenrc.ts - Development Focus" hl_lines="11 12"
|
|
264
|
+
import { CdkLibrary } from '@jttc/projen-project-types';
|
|
265
|
+
|
|
266
|
+
const project = new CdkLibrary({
|
|
267
|
+
name: 'dev-cdk-library',
|
|
268
|
+
author: 'Developer',
|
|
269
|
+
authorAddress: 'dev@localhost.com',
|
|
270
|
+
repositoryUrl: 'https://github.com/dev/dev-cdk-library.git',
|
|
271
|
+
cdkVersion: '2.1.0',
|
|
272
|
+
defaultReleaseBranch: 'main',
|
|
273
|
+
|
|
274
|
+
prettier: false,
|
|
275
|
+
vscode: true,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
project.synth();
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Highlighted lines explanation:**
|
|
282
|
+
|
|
283
|
+
- **Line 11**: Skip prettier for faster development iterations
|
|
284
|
+
- **Line 12**: Keep VSCode config for better developer experience
|
|
285
|
+
|
|
286
|
+
## Project Structure
|
|
287
|
+
|
|
288
|
+
After running `yarn projen` with a CDK Library project, you'll get the following structure:
|
|
289
|
+
|
|
290
|
+
```text title="Generated Project Structure"
|
|
291
|
+
my-cdk-library/
|
|
292
|
+
├── .github/
|
|
293
|
+
│ └── workflows/ # CI/CD workflows
|
|
294
|
+
│ ├── build.yml
|
|
295
|
+
│ ├── release.yml
|
|
296
|
+
│ └── upgrade-main.yml
|
|
297
|
+
├── .vscode/ # VSCode configuration (if enabled)
|
|
298
|
+
│ ├── extensions.json # Recommended extensions
|
|
299
|
+
│ └── settings.json # Editor settings
|
|
300
|
+
├── src/
|
|
301
|
+
│ └── index.ts # Main library entry point
|
|
302
|
+
├── test/
|
|
303
|
+
│ └── *.test.ts # Test files
|
|
304
|
+
├── .eslintrc.json # ESLint configuration
|
|
305
|
+
├── .gitignore # Git ignore rules
|
|
306
|
+
├── .prettierrc.json # Prettier config (if enabled)
|
|
307
|
+
├── .projenrc.ts # Projen configuration
|
|
308
|
+
├── package.json # NPM package configuration
|
|
309
|
+
├── tsconfig.json # TypeScript configuration
|
|
310
|
+
└── README.md # Generated README
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
!!! info "Conditional Files"
|
|
314
|
+
Some files are only created based on your configuration:
|
|
315
|
+
|
|
316
|
+
- `.vscode/` folder: Only when `vscode: true` (default)
|
|
317
|
+
- `.prettierrc.json`: Only when `prettier: true` (default)
|
|
318
|
+
|
|
319
|
+
## Best Practices
|
|
320
|
+
|
|
321
|
+
### 1. Use Consistent Configurations
|
|
322
|
+
|
|
323
|
+
Stick with the default prettier and VSCode configurations unless you have specific requirements. This ensures consistency across your team and projects.
|
|
324
|
+
|
|
325
|
+
### 2. Leverage VSCode Extensions
|
|
326
|
+
|
|
327
|
+
The recommended extensions provide significant productivity improvements for CDK development. Make sure your team installs them.
|
|
328
|
+
|
|
329
|
+
### 3. Customize Thoughtfully
|
|
330
|
+
|
|
331
|
+
While customization is available, consider whether deviating from defaults provides real value. Consistency often trumps personal preferences in team environments.
|
|
332
|
+
|
|
333
|
+
### 4. Version Lock Your CDK Version
|
|
334
|
+
|
|
335
|
+
Always specify a specific CDK version to ensure consistent builds across environments:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
cdkVersion: '2.1.0', // Good - specific version
|
|
339
|
+
// cdkVersion: '^2.0.0', // Avoid - could lead to inconsistencies
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Troubleshooting
|
|
343
|
+
|
|
344
|
+
### Prettier Not Working
|
|
345
|
+
|
|
346
|
+
If prettier isn't formatting your code:
|
|
347
|
+
|
|
348
|
+
1. Ensure the prettier extension is installed in VSCode
|
|
349
|
+
2. Check that `"editor.defaultFormatter": "esbenp.prettier-vscode"` is in your VSCode settings
|
|
350
|
+
3. Verify `.prettierrc.json` exists in your project root
|
|
351
|
+
|
|
352
|
+
### VSCode Extensions Not Recommended
|
|
353
|
+
|
|
354
|
+
If VSCode isn't showing extension recommendations:
|
|
355
|
+
|
|
356
|
+
1. Check that `.vscode/extensions.json` exists
|
|
357
|
+
2. Restart VSCode
|
|
358
|
+
3. Go to Extensions panel and look for the "Recommended" section
|
|
359
|
+
|
|
360
|
+
### Build Errors
|
|
361
|
+
|
|
362
|
+
If you encounter build errors after setup:
|
|
363
|
+
|
|
364
|
+
1. Run `yarn install` to ensure all dependencies are installed
|
|
365
|
+
2. Run `yarn projen` to regenerate configuration files
|
|
366
|
+
3. Check that your CDK version is compatible with your constructs version
|
|
367
|
+
|
|
368
|
+
## Migration Guide
|
|
369
|
+
|
|
370
|
+
### From Standard AwsCdkConstructLibrary
|
|
371
|
+
|
|
372
|
+
To migrate from a standard `AwsCdkConstructLibrary` to `CdkLibrary`:
|
|
373
|
+
|
|
374
|
+
1. Install the package: `npm install @jttc/projen-project-types`
|
|
375
|
+
2. Update your `.projenrc.ts`:
|
|
376
|
+
|
|
377
|
+
```diff
|
|
378
|
+
- import { AwsCdkConstructLibrary } from 'projen/lib/awscdk';
|
|
379
|
+
+ import { CdkLibrary } from '@jttc/projen-project-types';
|
|
380
|
+
|
|
381
|
+
- const project = new AwsCdkConstructLibrary({
|
|
382
|
+
+ const project = new CdkLibrary({
|
|
383
|
+
// ... same options
|
|
384
|
+
});
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
3. Run `yarn projen` to regenerate files
|
|
388
|
+
4. Commit the changes
|
|
389
|
+
|
|
390
|
+
The migration is backward compatible - all existing options will continue to work.
|
|
391
|
+
|
|
392
|
+
## Contributing
|
|
393
|
+
|
|
394
|
+
To contribute improvements to the CDK Library project type:
|
|
395
|
+
|
|
396
|
+
1. Fork the repository
|
|
397
|
+
2. Make your changes
|
|
398
|
+
3. Add tests for new functionality
|
|
399
|
+
4. Update documentation
|
|
400
|
+
5. Submit a pull request
|
|
401
|
+
|
|
402
|
+
## Support
|
|
403
|
+
|
|
404
|
+
If you encounter issues or have questions:
|
|
405
|
+
|
|
406
|
+
- Check this documentation
|
|
407
|
+
- Review existing GitHub issues
|
|
408
|
+
- Create a new issue with detailed information
|
|
409
|
+
- Tag the maintainers for urgent issues
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
*This project type is maintained by [Jump to the Cloud](https://jumptothecloud.tech) team.*
|