@nikovirtala/projen-constructs 0.5.1 → 0.5.3

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