@nikovirtala/projen-constructs 0.5.1 → 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.
Files changed (40) 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/README.md +94 -478
  5. package/docs/api/assets/highlight.css +8 -8
  6. package/docs/api/functions/renderBundleName.html +1 -1
  7. package/docs/api/index.html +96 -415
  8. package/docs/api/interfaces/AwsCdkConstructLibraryProjectOptions.html +3 -3
  9. package/docs/api/interfaces/AwsCdkTypeScriptAppProjectOptions.html +3 -3
  10. package/docs/api/interfaces/JsiiProjectOptions.html +3 -3
  11. package/docs/api/interfaces/LocalStackOptions.html +2 -2
  12. package/docs/api/interfaces/ProjectGeneratorOptions.html +1 -1
  13. package/docs/api/interfaces/TypeScriptProjectOptions.html +3 -3
  14. package/docs/api/interfaces/VitestConfigOptions.html +3 -3
  15. package/docs/api/interfaces/VitestOptions.html +2 -2
  16. package/docs/api/media/LICENSE +202 -0
  17. package/docs/api/media/components.md +191 -0
  18. package/docs/api/media/configuration.md +108 -0
  19. package/docs/api/media/development.md +93 -0
  20. package/docs/api/media/index.html +169 -0
  21. package/docs/api/media/migration.md +106 -0
  22. package/docs/api/modules.html +2 -2
  23. package/docs/components.md +191 -0
  24. package/docs/configuration.md +108 -0
  25. package/docs/development.md +93 -0
  26. package/docs/migration.md +106 -0
  27. package/lib/components/bundle-lambda-function-code.js +3 -3
  28. package/lib/components/colima.js +1 -1
  29. package/lib/components/homebrew.js +1 -1
  30. package/lib/components/lambda-function-construct-generator.js +1 -1
  31. package/lib/components/localstack.js +1 -1
  32. package/lib/components/mise.js +1 -1
  33. package/lib/components/typedoc.js +1 -1
  34. package/lib/components/vitest.js +1 -1
  35. package/lib/project-generator.js +1 -1
  36. package/lib/projects/awscdk-construct-library.generated.js +1 -1
  37. package/lib/projects/awscdk-typescript-app.generated.js +1 -1
  38. package/lib/projects/jsii.generated.js +1 -1
  39. package/lib/projects/typescript.generated.js +1 -1
  40. package/package.json +3 -2
package/README.md CHANGED
@@ -1,150 +1,131 @@
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
- ```
10
-
11
- Requires pnpm 12 and `projen` ^0.104.23. `@mrgrain/cdk-esbuild` and `constructs` are peer
12
- dependencies as well.
13
-
14
- To create a project from scratch:
15
-
16
- ```bash
17
- pnpm dlx projen new --from @nikovirtala/projen-constructs aws_cdk_construct_library
18
- ```
11
+ ## Why this exists
19
12
 
20
- ## Features
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.
21
18
 
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
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.
32
21
 
33
- ## Standard Configuration
22
+ ## When not to use this
34
23
 
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)
24
+ Reach for plain projen instead when:
42
25
 
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.
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
45
29
 
46
- ### pnpm
30
+ ## Status and supported versions
47
31
 
48
- pnpm reads its settings from `pnpm-workspace.yaml`, not `.npmrc`, since pnpm 11. Generated projects
49
- get:
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.
50
35
 
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 |
36
+ ## Documentation
57
37
 
58
- ### TypeScript configuration
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 |
59
45
 
60
- Projen renders three configs, and none of them should be edited directly:
46
+ Quick links: [Quick start](#quick-start) · [Usage](#usage) · [Features](#features).
61
47
 
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`.
48
+ ## Quick start
67
49
 
68
- ### Native TypeScript
50
+ Install the library alongside its `projen` and `constructs` peers:
69
51
 
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.
52
+ ```bash
53
+ pnpm add -D @nikovirtala/projen-constructs projen constructs
54
+ ```
75
55
 
76
- Code in these projects must therefore:
56
+ Create a `.projenrc.ts` that defines an AWS CDK construct library and synthesizes it:
77
57
 
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`
58
+ ```typescript
59
+ import { AwsCdkConstructLibraryProject } from "@nikovirtala/projen-constructs";
86
60
 
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.
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
+ });
89
68
 
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`.
69
+ project.synth();
70
+ ```
92
71
 
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`.
72
+ Then run synthesis:
96
73
 
97
- ## Customization
74
+ ```bash
75
+ pnpm dlx projen
76
+ ```
98
77
 
99
- Override any option by passing it to the constructor:
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.
100
83
 
101
- ```typescript
102
- import { JsiiProject } from "@nikovirtala/projen-constructs";
84
+ To start a project from scratch without writing `.projenrc.ts` yourself:
103
85
 
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
- });
86
+ ```bash
87
+ pnpm dlx projen new --from @nikovirtala/projen-constructs aws_cdk_construct_library
125
88
  ```
126
89
 
127
- Every component is exposed as an enable flag (`mise`, `vitest`, ...) plus an options property
128
- (`miseOptions`, `vitestOptions`, ...).
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
129
105
 
130
106
  ## Usage
131
107
 
132
- ### Projects
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.
133
111
 
134
- #### AWS CDK Construct Library Project
112
+ ### AWS CDK construct library project
135
113
 
136
114
  ```typescript
137
115
  import { AwsCdkConstructLibraryProject } from "@nikovirtala/projen-constructs";
138
116
 
139
117
  const project = new AwsCdkConstructLibraryProject({
140
118
  name: "my-cdk-construct",
119
+ author: "Your Name",
120
+ authorAddress: "you@example.com",
141
121
  repositoryUrl: "https://github.com/nikovirtala/my-cdk-construct.git",
122
+ cdkVersion: "2.275.0",
142
123
  });
143
124
 
144
125
  project.synth();
145
126
  ```
146
127
 
147
- #### AWS CDK TypeScript App Project
128
+ ### AWS CDK TypeScript app project
148
129
 
149
130
  ```typescript
150
131
  import { AwsCdkTypeScriptAppProject } from "@nikovirtala/projen-constructs";
@@ -152,25 +133,28 @@ import { AwsCdkTypeScriptAppProject } from "@nikovirtala/projen-constructs";
152
133
  const project = new AwsCdkTypeScriptAppProject({
153
134
  name: "my-cdk-app",
154
135
  repository: "https://github.com/nikovirtala/my-cdk-app.git",
136
+ cdkVersion: "2.275.0",
155
137
  });
156
138
 
157
139
  project.synth();
158
140
  ```
159
141
 
160
- #### JSII Project
142
+ ### JSII project
161
143
 
162
144
  ```typescript
163
145
  import { JsiiProject } from "@nikovirtala/projen-constructs";
164
146
 
165
147
  const project = new JsiiProject({
166
148
  name: "my-jsii-project",
149
+ author: "Your Name",
150
+ authorAddress: "you@example.com",
167
151
  repositoryUrl: "https://github.com/nikovirtala/my-jsii-project.git",
168
152
  });
169
153
 
170
154
  project.synth();
171
155
  ```
172
156
 
173
- #### TypeScript Project
157
+ ### TypeScript project
174
158
 
175
159
  ```typescript
176
160
  import { TypeScriptProject } from "@nikovirtala/projen-constructs";
@@ -183,379 +167,11 @@ const project = new TypeScriptProject({
183
167
  project.synth();
184
168
  ```
185
169
 
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
- ```
272
-
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
- ```
170
+ ## Contributing
357
171
 
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
- ```
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.
552
174
 
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.
175
+ ## License
559
176
 
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.
177
+ Apache-2.0. See [LICENSE](./LICENSE).
@@ -13,14 +13,14 @@
13
13
  --dark-hl-5: #9CDCFE;
14
14
  --light-hl-6: #0070C1;
15
15
  --dark-hl-6: #4FC1FF;
16
- --light-hl-7: #098658;
17
- --dark-hl-7: #B5CEA8;
18
- --light-hl-8: #008000;
19
- --dark-hl-8: #6A9955;
20
- --light-hl-9: #CD3131;
21
- --dark-hl-9: #F44747;
22
- --light-hl-10: #000000;
23
- --dark-hl-10: #C8C8C8;
16
+ --light-hl-7: #CD3131;
17
+ --dark-hl-7: #F44747;
18
+ --light-hl-8: #098658;
19
+ --dark-hl-8: #B5CEA8;
20
+ --light-hl-9: #000000;
21
+ --dark-hl-9: #C8C8C8;
22
+ --light-hl-10: #008000;
23
+ --dark-hl-10: #6A9955;
24
24
  --light-code-background: #FFFFFF;
25
25
  --dark-code-background: #1E1E1E;
26
26
  }