@nikovirtala/projen-constructs 0.5.0 → 0.5.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/.jsii +4 -4
- package/.kiro/steering/product.md +7 -5
- package/.kiro/steering/tech.md +7 -5
- package/README.md +96 -476
- package/docs/api/assets/highlight.css +12 -12
- package/docs/api/functions/renderBundleName.html +1 -1
- package/docs/api/index.html +96 -415
- package/docs/api/interfaces/AwsCdkConstructLibraryProjectOptions.html +29 -29
- package/docs/api/interfaces/AwsCdkTypeScriptAppProjectOptions.html +31 -31
- package/docs/api/interfaces/JsiiProjectOptions.html +28 -28
- package/docs/api/interfaces/LocalStackOptions.html +2 -2
- package/docs/api/interfaces/ProjectGeneratorOptions.html +3 -3
- package/docs/api/interfaces/TypeScriptProjectOptions.html +26 -26
- package/docs/api/interfaces/VitestConfigOptions.html +3 -3
- package/docs/api/interfaces/VitestOptions.html +2 -2
- package/docs/api/media/LICENSE +202 -0
- package/docs/api/media/components.md +191 -0
- package/docs/api/media/configuration.md +108 -0
- package/docs/api/media/development.md +93 -0
- package/docs/api/media/index.html +169 -0
- package/docs/api/media/migration.md +106 -0
- package/docs/api/modules.html +2 -2
- package/docs/components.md +191 -0
- package/docs/configuration.md +108 -0
- package/docs/development.md +93 -0
- package/docs/migration.md +106 -0
- package/lib/components/bundle-lambda-function-code.js +3 -3
- package/lib/components/colima.js +1 -1
- package/lib/components/homebrew.js +1 -1
- package/lib/components/lambda-function-construct-generator.js +1 -1
- package/lib/components/localstack.js +1 -1
- package/lib/components/mise.js +1 -1
- package/lib/components/typedoc.js +1 -1
- package/lib/components/vitest.js +1 -1
- package/lib/project-generator.js +1 -1
- package/lib/projects/awscdk-construct-library.generated.js +1 -1
- package/lib/projects/awscdk-typescript-app.generated.js +1 -1
- package/lib/projects/jsii.generated.js +1 -1
- package/lib/projects/typescript.generated.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,557 +1,177 @@
|
|
|
1
1
|
# @nikovirtala/projen-constructs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Opinionated projen project types that scaffold TypeScript, JSII and AWS CDK repositories with one shared config.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@nikovirtala/projen-constructs)
|
|
6
|
+
[](https://github.com/nikovirtala/projen-constructs/actions/workflows/build.yml)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
[](https://projen.io)
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
pnpm add -D @nikovirtala/projen-constructs projen constructs
|
|
9
|
-
```
|
|
11
|
+
## Why this exists
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
Projen gives you code-first project configuration, but wiring up a consistent setup across many
|
|
14
|
+
TypeScript, JSII and AWS CDK repositories still means repeating the same choices. This library
|
|
15
|
+
packages those choices into ready-made project types and reusable components, so every repository
|
|
16
|
+
you generate shares the same package manager, Node.js and TypeScript versions, testing, linting and
|
|
17
|
+
release tooling.
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
It is for anyone in the projen and AWS CDK community who maintains more than one repository and wants
|
|
20
|
+
them to behave the same way without hand-copying configuration between them.
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
pnpm dlx projen new --from @nikovirtala/projen-constructs aws_cdk_construct_library
|
|
18
|
-
```
|
|
22
|
+
## When not to use this
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
Reach for plain projen instead when:
|
|
21
25
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- **Code Generation**: `ProjectGenerator` creates project classes with standard configuration
|
|
26
|
-
- **ES Modules**: TypeScript and CDK App projects use ES modules (JSII uses CommonJS)
|
|
27
|
-
- **Code Quality**: Biome for formatting and linting
|
|
28
|
-
- **Testing**: Vitest with coverage
|
|
29
|
-
- **Auto-merge**: Enabled with auto-approve
|
|
30
|
-
- **VSCode**: Recommended extensions and settings
|
|
31
|
-
- **mise**: Node version management
|
|
26
|
+
- you want unopinionated projen defaults and prefer to make each tooling choice yourself
|
|
27
|
+
- your setup is not pnpm-based or cannot run Node.js 26
|
|
28
|
+
- you build in languages beyond TypeScript, JSII and AWS CDK
|
|
32
29
|
|
|
33
|
-
##
|
|
30
|
+
## Status and supported versions
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- **Node Version**: 26.13.0
|
|
39
|
-
- **TypeScript**: 6.0.3
|
|
40
|
-
- **CDK Version**: 2.263.0 (for CDK projects)
|
|
41
|
-
- **JSII Version**: ~6.0.3 (for JSII projects)
|
|
32
|
+
Stability: **stable**. This library requires `projen` ^0.104.23, pnpm 12, and Node.js >= 26.13.0.
|
|
33
|
+
These values are maintained in `src/versions.json` and the project configuration; the numbers quoted
|
|
34
|
+
across this documentation track those sources.
|
|
42
35
|
|
|
43
|
-
|
|
44
|
-
`update-versions` task, which the dependency upgrade workflow runs.
|
|
36
|
+
## Documentation
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
| `nodeLinker` | `hoisted` | jsii tooling resolves dependencies from a flat `node_modules` |
|
|
54
|
-
| `allowBuilds` | `esbuild: true` | esbuild links its platform binary in a postinstall script, and pnpm 11 fails an install with ignored builds |
|
|
55
|
-
| `verifyDepsBeforeRun` | `false` | projen resolves the task `PATH` with `$(pnpm -c exec ...)`, which otherwise re-enters `pnpm install` and deadlocks |
|
|
56
|
-
| `minimumReleaseAge` | `0` | the pnpm 11 default of 1440 minutes makes pnpm write `minimumReleaseAgeExclude` entries into this generated file |
|
|
38
|
+
| Guide | What it covers |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| [Configuration](./docs/configuration.md) | Standard defaults, pnpm settings, the TypeScript configs, native TypeScript, and how to customize any option |
|
|
41
|
+
| [Components](./docs/components.md) | Reference for every component: Vitest, TypeDoc, Mise, Homebrew, Colima, LocalStack, LambdaFunctionConstructGenerator, Bundler, and ProjectGenerator |
|
|
42
|
+
| [Migration](./docs/migration.md) | Moving from the deprecated standalone packages, including the name mapping and behaviour changes |
|
|
43
|
+
| [Development](./docs/development.md) | Development commands and the build process diagram |
|
|
44
|
+
| [API reference](./docs/api/index.html) | Generated TypeDoc API documentation |
|
|
57
45
|
|
|
58
|
-
|
|
46
|
+
Quick links: [Quick start](#quick-start) · [Usage](#usage) · [Features](#features).
|
|
59
47
|
|
|
60
|
-
|
|
48
|
+
## Quick start
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
rule set, so it only carries compiler options jsii accepts.
|
|
64
|
-
- `test/tsconfig.json` extends it and is type-check only. This is the config Vitest type checking and
|
|
65
|
-
the editor use, and the one `tsconfigDev` points at.
|
|
66
|
-
- `projenrc/tsconfig.json` covers `.projenrc.ts`.
|
|
50
|
+
Install the library alongside its `projen` and `constructs` peers:
|
|
67
51
|
|
|
68
|
-
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add -D @nikovirtala/projen-constructs projen constructs
|
|
54
|
+
```
|
|
69
55
|
|
|
70
|
-
|
|
71
|
-
[type stripping](https://nodejs.org/api/typescript.html#type-stripping) instead of `tsx` or
|
|
72
|
-
`ts-node`: the default task is `node .projenrc.ts`, and the cdk.json `app` is `node src/main.ts`.
|
|
73
|
-
Their `tsconfig.json` sets `erasableSyntaxOnly` and `verbatimModuleSyntax`, so `tsc` reports code
|
|
74
|
-
that Node.js can't run before Node.js does.
|
|
56
|
+
Create a `.projenrc.ts` that defines an AWS CDK construct library and synthesizes it:
|
|
75
57
|
|
|
76
|
-
|
|
58
|
+
```typescript
|
|
59
|
+
import { AwsCdkConstructLibraryProject } from "@nikovirtala/projen-constructs";
|
|
77
60
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
e.g. `projen/lib/component.js` rather than `projen/lib/component`
|
|
61
|
+
const project = new AwsCdkConstructLibraryProject({
|
|
62
|
+
name: "my-cdk-construct",
|
|
63
|
+
author: "Your Name",
|
|
64
|
+
authorAddress: "you@example.com",
|
|
65
|
+
repositoryUrl: "https://github.com/your-org/my-cdk-construct.git",
|
|
66
|
+
cdkVersion: "2.275.0",
|
|
67
|
+
});
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
project.synth();
|
|
70
|
+
```
|
|
89
71
|
|
|
90
|
-
|
|
91
|
-
their `.projenrc.ts` often imports their own `src`.
|
|
72
|
+
Then run synthesis:
|
|
92
73
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
74
|
+
```bash
|
|
75
|
+
pnpm dlx projen
|
|
76
|
+
```
|
|
96
77
|
|
|
97
|
-
|
|
78
|
+
**Expected output**: projen reads `.projenrc.ts` and writes the generated project files into the
|
|
79
|
+
working directory: `package.json`, `tsconfig.json`, `pnpm-workspace.yaml`, the GitHub Actions
|
|
80
|
+
workflows, the Vitest and Biome configuration, `mise.toml`, and the source and test scaffolding for
|
|
81
|
+
your construct library. Re-running the command after you edit `.projenrc.ts` updates those files in
|
|
82
|
+
place.
|
|
98
83
|
|
|
99
|
-
|
|
84
|
+
To start a project from scratch without writing `.projenrc.ts` yourself:
|
|
100
85
|
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
name: "my-project",
|
|
104
|
-
repositoryUrl: "https://github.com/nikovirtala/my-project.git",
|
|
105
|
-
minNodeVersion: "26.0.0",
|
|
106
|
-
author: "Custom Author",
|
|
107
|
-
authorAddress: "custom@example.com",
|
|
108
|
-
mise: false,
|
|
109
|
-
vitest: false,
|
|
110
|
-
tsconfig: {
|
|
111
|
-
compilerOptions: {
|
|
112
|
-
noUnusedLocals: false,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
biomeOptions: {
|
|
116
|
-
biomeConfig: {
|
|
117
|
-
formatter: {
|
|
118
|
-
lineWidth: 100,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
});
|
|
86
|
+
```bash
|
|
87
|
+
pnpm dlx projen new --from @nikovirtala/projen-constructs aws_cdk_construct_library
|
|
123
88
|
```
|
|
124
89
|
|
|
125
|
-
|
|
126
|
-
|
|
90
|
+
## Features
|
|
91
|
+
|
|
92
|
+
- **Standard configuration**: opinionated defaults for author, release branch, package manager,
|
|
93
|
+
Node.js, TypeScript, and tooling
|
|
94
|
+
- **Automatic project type discovery**: generates the `ProjectType` enum from projen's JSII manifest
|
|
95
|
+
(<!-- generated:project-type-count-start -->21<!-- generated:project-type-count-end --> project types)
|
|
96
|
+
- **Component system**: reusable components (Vitest, TypeDoc, Mise, Homebrew, Colima, LocalStack,
|
|
97
|
+
Lambda bundling)
|
|
98
|
+
- **Code generation**: `ProjectGenerator` creates project classes with standard configuration
|
|
99
|
+
- **ES modules**: TypeScript and CDK app projects use ES modules (JSII uses CommonJS)
|
|
100
|
+
- **Code quality**: Biome for formatting and linting
|
|
101
|
+
- **Testing**: Vitest with coverage
|
|
102
|
+
- **Auto-merge**: enabled with auto-approve
|
|
103
|
+
- **VSCode**: recommended extensions and settings
|
|
104
|
+
- **mise**: Node version management
|
|
127
105
|
|
|
128
106
|
## Usage
|
|
129
107
|
|
|
130
|
-
|
|
108
|
+
Each project type applies the standard configuration and the shared components. See
|
|
109
|
+
[Configuration](./docs/configuration.md) for the defaults and how to override them, and
|
|
110
|
+
[Components](./docs/components.md) for the component reference.
|
|
131
111
|
|
|
132
|
-
|
|
112
|
+
### AWS CDK construct library project
|
|
133
113
|
|
|
134
114
|
```typescript
|
|
135
115
|
import { AwsCdkConstructLibraryProject } from "@nikovirtala/projen-constructs";
|
|
136
116
|
|
|
137
117
|
const project = new AwsCdkConstructLibraryProject({
|
|
138
118
|
name: "my-cdk-construct",
|
|
119
|
+
author: "Your Name",
|
|
120
|
+
authorAddress: "you@example.com",
|
|
139
121
|
repositoryUrl: "https://github.com/nikovirtala/my-cdk-construct.git",
|
|
122
|
+
cdkVersion: "2.275.0",
|
|
140
123
|
});
|
|
141
124
|
|
|
142
125
|
project.synth();
|
|
143
126
|
```
|
|
144
127
|
|
|
145
|
-
|
|
128
|
+
### AWS CDK TypeScript app project
|
|
146
129
|
|
|
147
130
|
```typescript
|
|
148
131
|
import { AwsCdkTypeScriptAppProject } from "@nikovirtala/projen-constructs";
|
|
149
132
|
|
|
150
133
|
const project = new AwsCdkTypeScriptAppProject({
|
|
151
134
|
name: "my-cdk-app",
|
|
152
|
-
|
|
135
|
+
repository: "https://github.com/nikovirtala/my-cdk-app.git",
|
|
136
|
+
cdkVersion: "2.275.0",
|
|
153
137
|
});
|
|
154
138
|
|
|
155
139
|
project.synth();
|
|
156
140
|
```
|
|
157
141
|
|
|
158
|
-
|
|
142
|
+
### JSII project
|
|
159
143
|
|
|
160
144
|
```typescript
|
|
161
145
|
import { JsiiProject } from "@nikovirtala/projen-constructs";
|
|
162
146
|
|
|
163
147
|
const project = new JsiiProject({
|
|
164
148
|
name: "my-jsii-project",
|
|
149
|
+
author: "Your Name",
|
|
150
|
+
authorAddress: "you@example.com",
|
|
165
151
|
repositoryUrl: "https://github.com/nikovirtala/my-jsii-project.git",
|
|
166
152
|
});
|
|
167
153
|
|
|
168
154
|
project.synth();
|
|
169
155
|
```
|
|
170
156
|
|
|
171
|
-
|
|
157
|
+
### TypeScript project
|
|
172
158
|
|
|
173
159
|
```typescript
|
|
174
160
|
import { TypeScriptProject } from "@nikovirtala/projen-constructs";
|
|
175
161
|
|
|
176
162
|
const project = new TypeScriptProject({
|
|
177
163
|
name: "my-typescript-project",
|
|
178
|
-
|
|
164
|
+
repository: "https://github.com/nikovirtala/my-typescript-project.git",
|
|
179
165
|
});
|
|
180
166
|
|
|
181
167
|
project.synth();
|
|
182
168
|
```
|
|
183
169
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
The package includes reusable components for common development tasks:
|
|
187
|
-
|
|
188
|
-
#### Vitest
|
|
189
|
-
|
|
190
|
-
[Vitest](https://vitest.dev) testing framework component.
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
import { Vitest } from "@nikovirtala/projen-constructs";
|
|
194
|
-
|
|
195
|
-
new Vitest(project, {
|
|
196
|
-
vitestVersion: "^5",
|
|
197
|
-
config: {
|
|
198
|
-
coverageProvider: CoverageProvider.V8,
|
|
199
|
-
coverageReporters: [CoverageReporter.TEXT, CoverageReporter.LCOV],
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Type checking runs against the project's development tsconfig (`test/tsconfig.json`) unless
|
|
205
|
-
`config.typecheckTsconfig` says otherwise.
|
|
206
|
-
|
|
207
|
-
For Vitest settings that `config` doesn't cover, use `extraTestConfig` (merged into `test`) and
|
|
208
|
-
`extraConfig` (top-level options next to `test`):
|
|
209
|
-
|
|
210
|
-
```typescript
|
|
211
|
-
new Vitest(project, {
|
|
212
|
-
extraTestConfig: {
|
|
213
|
-
setupFiles: ["test/setup.ts"],
|
|
214
|
-
},
|
|
215
|
-
extraConfig: {
|
|
216
|
-
resolve: { alias: { "@": "/src" } },
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
`extraTestConfig` is deep-merged over the generated `test` options: objects merge, and other values
|
|
222
|
-
(including arrays) replace the generated value. Both options are rendered as JSON, so their values
|
|
223
|
-
can't contain functions or regular expressions, which rules out plugins.
|
|
224
|
-
|
|
225
|
-
#### TypeDoc
|
|
226
|
-
|
|
227
|
-
[TypeDoc](https://typedoc.org) documentation generation component.
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
import { TypeDoc, EntryPointStrategy } from "@nikovirtala/projen-constructs";
|
|
231
|
-
|
|
232
|
-
new TypeDoc(project, {
|
|
233
|
-
version: "^0.28",
|
|
234
|
-
typeDocConfig: {
|
|
235
|
-
entryPointStrategy: EntryPointStrategy.EXPAND,
|
|
236
|
-
out: "docs/api",
|
|
237
|
-
exclude: ["**/*.test.ts"],
|
|
238
|
-
},
|
|
239
|
-
});
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
#### Mise
|
|
243
|
-
|
|
244
|
-
[Mise](https://mise.jdx.dev) dev tools/runtimes management component.
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
import { Mise } from "@nikovirtala/projen-constructs";
|
|
248
|
-
|
|
249
|
-
new Mise(project, {
|
|
250
|
-
nodeVersion: "26.13.0",
|
|
251
|
-
});
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
#### Homebrew
|
|
255
|
-
|
|
256
|
-
[Homebrew](https://brew.sh) package management component. Writes a `Brewfile` and adds an
|
|
257
|
-
`install:homebrew` task that bootstraps Homebrew and runs `brew bundle`.
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
import { Homebrew } from "@nikovirtala/projen-constructs";
|
|
261
|
-
|
|
262
|
-
const homebrew = new Homebrew(project, {
|
|
263
|
-
packages: ["jq", "yq"],
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
homebrew.addPackage("gh");
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
A fully qualified formula (`user/repository/formula`) also adds a `tap` entry. Since Homebrew 6,
|
|
270
|
-
formulae from non-official taps only load when trusted, so they're written with `trusted: true`.
|
|
271
|
-
That trusts only the formula, not the rest of its tap.
|
|
272
|
-
|
|
273
|
-
#### Colima
|
|
274
|
-
|
|
275
|
-
[Colima](https://github.com/abiosoft/colima) container runtime component. Alternative for Docker.
|
|
276
|
-
|
|
277
|
-
```typescript
|
|
278
|
-
import { Colima } from "@nikovirtala/projen-constructs";
|
|
279
|
-
|
|
280
|
-
new Colima(project);
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
#### LocalStack
|
|
284
|
-
|
|
285
|
-
[LocalStack](https://www.localstack.cloud) AWS emulation component.
|
|
286
|
-
|
|
287
|
-
```typescript
|
|
288
|
-
import { LocalStack } from "@nikovirtala/projen-constructs";
|
|
289
|
-
|
|
290
|
-
new LocalStack(project, {
|
|
291
|
-
services: ["s3", "lambda", "dynamodb"],
|
|
292
|
-
port: 4566,
|
|
293
|
-
debug: true,
|
|
294
|
-
});
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
#### LambdaFunctionConstructGenerator
|
|
298
|
-
|
|
299
|
-
Generates AWS CDK Lambda Function constructs and bundles their code.
|
|
300
|
-
|
|
301
|
-
```typescript
|
|
302
|
-
import { LambdaFunctionConstructGenerator } from "@nikovirtala/projen-constructs";
|
|
303
|
-
|
|
304
|
-
new LambdaFunctionConstructGenerator(project, {
|
|
305
|
-
sourceDir: "src/handlers",
|
|
306
|
-
outputDir: "src/constructs/lambda",
|
|
307
|
-
filePattern: "*.lambda.ts",
|
|
308
|
-
esbuildOptions: {
|
|
309
|
-
minify: true,
|
|
310
|
-
sourcemap: true,
|
|
311
|
-
},
|
|
312
|
-
});
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
#### Bundler
|
|
316
|
-
|
|
317
|
-
Low-level bundling utilities for Lambda functions.
|
|
318
|
-
|
|
319
|
-
```typescript
|
|
320
|
-
import {
|
|
321
|
-
Bundler,
|
|
322
|
-
LambdaFunctionCodeBundle,
|
|
323
|
-
} from "@nikovirtala/projen-constructs";
|
|
324
|
-
|
|
325
|
-
const bundler = new Bundler(project, {
|
|
326
|
-
assetsDir: "assets",
|
|
327
|
-
esbuildVersion: "^0.25",
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
new LambdaFunctionCodeBundle(project, {
|
|
331
|
-
entrypoint: "src/my-function.lambda.ts",
|
|
332
|
-
extension: ".lambda.ts",
|
|
333
|
-
});
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
#### ProjectGenerator
|
|
337
|
-
|
|
338
|
-
Generates TypeScript project classes with standard configuration.
|
|
339
|
-
|
|
340
|
-
```typescript
|
|
341
|
-
import { ProjectGenerator, ProjectType } from "@nikovirtala/projen-constructs";
|
|
342
|
-
|
|
343
|
-
new ProjectGenerator(project, {
|
|
344
|
-
name: "TypeScriptProject",
|
|
345
|
-
projectType: ProjectType.TYPE_SCRIPT_PROJECT,
|
|
346
|
-
filePath: "./src/projects/typescript.generated.ts",
|
|
347
|
-
components: [
|
|
348
|
-
{ componentClass: Mise },
|
|
349
|
-
{ componentClass: Vitest }, // Auto-detects VitestOptions from JSII manifest
|
|
350
|
-
],
|
|
351
|
-
});
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
Features:
|
|
355
|
-
|
|
356
|
-
- Automatically generates the `ProjectType` enum from Projen's JSII manifest
|
|
357
|
-
- Auto-detects component options types from JSII manifests
|
|
358
|
-
- Strips Projen's `@pjnew` annotation from `packageManager`, which `projen new` would otherwise
|
|
359
|
-
render into a generated `.projenrc.ts` as the package manager that ran the command
|
|
360
|
-
- Validates paths to prevent directory traversal attacks
|
|
361
|
-
- Structured error handling with custom error classes
|
|
362
|
-
|
|
363
|
-
## Migrating from the standalone packages
|
|
364
|
-
|
|
365
|
-
The components used to be published as separate packages. Those packages are deprecated and won't
|
|
366
|
-
get new features or fixes. Every class, interface, enum and function they exported is exported from
|
|
367
|
-
`@nikovirtala/projen-constructs` under the same name, except `AwsCdkApp` (see below).
|
|
368
|
-
|
|
369
|
-
| Deprecated package | Replacement in `@nikovirtala/projen-constructs` |
|
|
370
|
-
| --- | --- |
|
|
371
|
-
| `@nikovirtala/projen-vitest` | `Vitest`, `VitestOptions`, `VitestConfigOptions`, `Environment`, `Pool`, `CoverageProvider`, `CoverageReporter` |
|
|
372
|
-
| `@nikovirtala/projen-typedoc` | `TypeDoc`, `TypeDocOptions`, `TypeDocConfiguration` and its enums |
|
|
373
|
-
| `@nikovirtala/projen-homebrew` | `Homebrew`, `HomebrewOptions` |
|
|
374
|
-
| `@nikovirtala/projen-colima` | `Colima` |
|
|
375
|
-
| `@nikovirtala/projen-localstack` | `LocalStack`, `LocalStackOptions` |
|
|
376
|
-
| `@nikovirtala/projen-bundle-lambda-function-code` | `Bundler`, `LambdaFunctionCodeBundle`, `LambdaFunctionCodeBundler` and their options |
|
|
377
|
-
| `@nikovirtala/projen-lambda-function-construct-generator` | `LambdaFunctionConstructGenerator`, `LambdaFunctionConstructGeneratorOptions` |
|
|
378
|
-
| `@nikovirtala/projen-aws-cdk-app` | `AwsCdkTypeScriptAppProject`, `AwsCdkTypeScriptAppProjectOptions` |
|
|
379
|
-
|
|
380
|
-
### Steps
|
|
381
|
-
|
|
382
|
-
1. In `.projenrc.ts`, replace the old package in `devDeps` with `@nikovirtala/projen-constructs`, and
|
|
383
|
-
change the imports:
|
|
384
|
-
|
|
385
|
-
```typescript
|
|
386
|
-
// before
|
|
387
|
-
import { Vitest } from "@nikovirtala/projen-vitest";
|
|
388
|
-
// after
|
|
389
|
-
import { Vitest } from "@nikovirtala/projen-constructs";
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
2. Check the peer dependencies. `@nikovirtala/projen-constructs` needs `projen` ^0.104, `constructs`
|
|
393
|
-
^10 and `@mrgrain/cdk-esbuild` ^5. The standalone packages accepted older projen versions, so you
|
|
394
|
-
may have to upgrade projen in the same change.
|
|
395
|
-
3. Install the new package, run `npx projen` and review the changes to the generated files.
|
|
396
|
-
|
|
397
|
-
### Changes to expect
|
|
398
|
-
|
|
399
|
-
These are the differences in behaviour or generated files between the standalone packages and this
|
|
400
|
-
library.
|
|
401
|
-
|
|
402
|
-
**Vitest**
|
|
403
|
-
|
|
404
|
-
- `vitest.config.ts` imports `defineConfig` from
|
|
405
|
-
`@nikovirtala/projen-constructs/lib/vitest-define-config` instead of
|
|
406
|
-
`@nikovirtala/projen-vitest/lib/bundled-define-config`. Projen rewrites the file, so there's
|
|
407
|
-
nothing to change by hand.
|
|
408
|
-
- The config is rendered as JSON, so its keys are quoted. The settings are the same.
|
|
409
|
-
- `config.typecheckTsconfig` defaults to the project's development tsconfig (`test/tsconfig.json`
|
|
410
|
-
in current projen) instead of `tsconfig.dev.json`.
|
|
411
|
-
- JSII and construct library projects exclude `vitest.config.ts` from the published package.
|
|
412
|
-
- New: `extraTestConfig` and `extraConfig` for Vitest settings that `config` doesn't cover.
|
|
413
|
-
|
|
414
|
-
**Homebrew and Colima**
|
|
415
|
-
|
|
416
|
-
- Packages from a tap (`owner/tap/formula`) also add a `tap` line to the `Brewfile`, and the
|
|
417
|
-
`Brewfile` is sorted.
|
|
418
|
-
- The `install:homebrew`, `homebrew:bundle` and `colima` tasks run in bash. `homebrew:bundle` also
|
|
419
|
-
finds a freshly installed `brew` that isn't on the `PATH` yet.
|
|
420
|
-
|
|
421
|
-
**LocalStack**
|
|
422
|
-
|
|
423
|
-
- `imageTag` is applied: LocalStack starts with `localstack/localstack:<imageTag>`. It used to be
|
|
424
|
-
ignored.
|
|
425
|
-
|
|
426
|
-
**Bundler / LambdaFunctionCodeBundler**
|
|
427
|
-
|
|
428
|
-
- `LambdaFunctionCodeBundler.bundleOptions` applies to every discovered entrypoint. Its `entrypoint`
|
|
429
|
-
used to replace them all.
|
|
430
|
-
|
|
431
|
-
**LambdaFunctionConstructGenerator**
|
|
432
|
-
|
|
433
|
-
- The bundle task runs `tsx` with the project's development tsconfig instead of `tsconfig.dev.json`.
|
|
434
|
-
|
|
435
|
-
**TypeDoc**: no changes.
|
|
436
|
-
|
|
437
|
-
### From `AwsCdkApp` to `AwsCdkTypeScriptAppProject`
|
|
438
|
-
|
|
439
|
-
```typescript
|
|
440
|
-
// before
|
|
441
|
-
import { AwsCdkApp } from "@nikovirtala/projen-aws-cdk-app";
|
|
442
|
-
const project = new AwsCdkApp({ name: "my-app", cdkVersion: "2.221.0" });
|
|
443
|
-
|
|
444
|
-
// after
|
|
445
|
-
import { AwsCdkTypeScriptAppProject } from "@nikovirtala/projen-constructs";
|
|
446
|
-
const project = new AwsCdkTypeScriptAppProject({ name: "my-app", cdkVersion: "2.221.0" });
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
Both are ES module apps using pnpm, Biome, Vitest and mise. The differences:
|
|
450
|
-
|
|
451
|
-
- **Native TypeScript**: `.projenrc.ts` and the app run with `node` instead of `tsx`, and the
|
|
452
|
-
tsconfig sets `erasableSyntaxOnly` and `verbatimModuleSyntax` (see [Native TypeScript](#native-typescript)).
|
|
453
|
-
|
|
454
|
-
- **`nvm` is removed.** Use mise (on by default), which pins the Node.js version in `mise.toml`.
|
|
455
|
-
- **Homebrew is on by default.** The project gets a `Brewfile`, and `npx projen` runs
|
|
456
|
-
`install:homebrew` (installs Homebrew if `brew` is missing) and `homebrew:bundle`. Set
|
|
457
|
-
`homebrew: false` to turn it off.
|
|
458
|
-
- **cdk.json `app`** is `node src/main.ts` instead of `tsx --tsconfig tsconfig.json src/main.ts`.
|
|
459
|
-
- **Defaults** come from this library: Node.js, TypeScript, CDK and pnpm versions (pnpm 12 instead
|
|
460
|
-
of 10), Dependabot off, auto-merge on, `auto-approve` and `auto-merge` labels on dependency
|
|
461
|
-
upgrade PRs, and auto-approval of PRs by `nikovirtala`. Any option you set explicitly still wins,
|
|
462
|
-
so set `autoApproveOptions` if you aren't `nikovirtala`.
|
|
463
|
-
- **tsconfig**: `noImplicitOverride` and `allowSyntheticDefaultImports` move from `tsconfig.json`
|
|
464
|
-
to the development tsconfig (`test/tsconfig.json`).
|
|
465
|
-
- **Options removed from the interface**: `eslint`, `jest`, `prettier` (and their options),
|
|
466
|
-
`sampleCode` and `tsJestOptions`.
|
|
467
|
-
- `vitestOptions` takes the `VitestOptions` of this library, and now also `homebrewOptions` and
|
|
468
|
-
`miseOptions`.
|
|
469
|
-
|
|
470
|
-
## Development
|
|
471
|
-
|
|
472
|
-
This project is managed by Projen and generates itself: `.projenrc.ts` defines the project using the
|
|
473
|
-
`JsiiProject` type from `src/`. Configuration changes belong in `.projenrc.ts`, never in the
|
|
474
|
-
generated files.
|
|
170
|
+
## Contributing
|
|
475
171
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
pnpm build # synthesize, compile, test and package
|
|
479
|
-
pnpm test # biome, vitest, typedoc
|
|
480
|
-
pnpm test:watch # vitest in watch mode
|
|
481
|
-
pnpm test:update # update snapshots
|
|
482
|
-
pnpm biome # format and lint
|
|
483
|
-
pnpm docgen # regenerate API.md from the .jsii manifest
|
|
484
|
-
pnpm update-versions # refresh src/versions.json
|
|
485
|
-
pnpm upgrade # upgrade dependencies
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
### Build process
|
|
489
|
-
|
|
490
|
-
```mermaid
|
|
491
|
-
flowchart TD
|
|
492
|
-
projenrc[".projenrc.ts"]
|
|
493
|
-
|
|
494
|
-
subgraph synthesize["default (synthesize)"]
|
|
495
|
-
direction TB
|
|
496
|
-
synth["tsx .projenrc.ts"]
|
|
497
|
-
generator["ProjectGenerator"]
|
|
498
|
-
generated["src/project-type.ts<br/>src/projects/*.generated.ts<br/>src/projects/*-options.generated.ts"]
|
|
499
|
-
projenfiles["package.json, tsconfig.json,<br/>pnpm-workspace.yaml, workflows, ..."]
|
|
500
|
-
brew["install:homebrew<br/>brew bundle"]
|
|
501
|
-
definecfg["bundle-vitest-define-config<br/>esbuild → lib/vitest-define-config.js"]
|
|
502
|
-
|
|
503
|
-
synth --> generator --> generated
|
|
504
|
-
synth --> projenfiles
|
|
505
|
-
synth --> brew
|
|
506
|
-
synth --> definecfg
|
|
507
|
-
end
|
|
508
|
-
|
|
509
|
-
subgraph compile["compile"]
|
|
510
|
-
direction TB
|
|
511
|
-
jsii["jsii<br/>validates tsconfig.json against the strict rule set"]
|
|
512
|
-
lib["lib/**"]
|
|
513
|
-
manifest[".jsii manifest"]
|
|
514
|
-
|
|
515
|
-
jsii --> lib
|
|
516
|
-
jsii --> manifest
|
|
517
|
-
end
|
|
518
|
-
|
|
519
|
-
subgraph test["test"]
|
|
520
|
-
direction TB
|
|
521
|
-
biome["biome check --write"]
|
|
522
|
-
vitest["vitest run<br/>+ type checking"]
|
|
523
|
-
typedoc["typedoc → docs/api"]
|
|
524
|
-
|
|
525
|
-
biome --> vitest --> typedoc
|
|
526
|
-
end
|
|
527
|
-
|
|
528
|
-
subgraph package["package"]
|
|
529
|
-
direction TB
|
|
530
|
-
pacmak["jsii-pacmak<br/>--pack-command 'pnpm pack'"]
|
|
531
|
-
dist["dist/js/*.tgz"]
|
|
532
|
-
|
|
533
|
-
pacmak --> dist
|
|
534
|
-
end
|
|
535
|
-
|
|
536
|
-
projenrc --> synthesize
|
|
537
|
-
synthesize --> compile
|
|
538
|
-
compile --> test
|
|
539
|
-
test --> package
|
|
540
|
-
|
|
541
|
-
manifest -. "component options FQNs<br/>read on the next synthesis" .-> generator
|
|
542
|
-
docgen["docgen<br/>jsii-docgen → API.md"]
|
|
543
|
-
manifest --> docgen
|
|
544
|
-
|
|
545
|
-
classDef artifact fill:#eef,stroke:#88a
|
|
546
|
-
class generated,projenfiles,lib,manifest,dist artifact
|
|
547
|
-
```
|
|
172
|
+
See [Development](./docs/development.md) for the commands and the build process. Configuration
|
|
173
|
+
changes belong in `.projenrc.ts`, never in the generated files.
|
|
548
174
|
|
|
549
|
-
|
|
550
|
-
manifest to resolve component options types, so the manifest produced by `compile` feeds the *next*
|
|
551
|
-
synthesis. This is why `.jsii` is committed rather than ignored. A component options type that is
|
|
552
|
-
missing from the manifest is reported as a warning and its options property is left out of the
|
|
553
|
-
generated interface, which is expected only while a new component is being introduced: compile once,
|
|
554
|
-
then synthesize again.
|
|
175
|
+
## License
|
|
555
176
|
|
|
556
|
-
|
|
557
|
-
`docgen` is not part of `build` and has to be run explicitly after the manifest changes.
|
|
177
|
+
Apache-2.0. See [LICENSE](./LICENSE).
|