@nikovirtala/projen-constructs 0.4.1 → 0.5.1
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 +3 -3
- package/README.md +44 -8
- package/docs/api/assets/highlight.css +6 -6
- package/docs/api/functions/applyDefaults.html +2 -2
- package/docs/api/index.html +76 -33
- package/docs/api/interfaces/AwsCdkConstructLibraryProjectOptions.html +27 -27
- package/docs/api/interfaces/AwsCdkTypeScriptAppProjectOptions.html +29 -29
- package/docs/api/interfaces/JsiiProjectOptions.html +26 -26
- package/docs/api/interfaces/LocalStackOptions.html +2 -2
- package/docs/api/interfaces/ProjectGeneratorOptions.html +3 -3
- package/docs/api/interfaces/TypeScriptProjectOptions.html +24 -24
- package/docs/api/interfaces/VitestConfigOptions.html +2 -2
- 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/config.js +23 -6
- package/lib/native-typescript.d.ts +22 -0
- package/lib/native-typescript.js +77 -0
- 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 +1 -1
package/.jsii
CHANGED
|
@@ -4196,7 +4196,7 @@
|
|
|
4196
4196
|
},
|
|
4197
4197
|
"name": "@nikovirtala/projen-constructs",
|
|
4198
4198
|
"readme": {
|
|
4199
|
-
"markdown": "# @nikovirtala/projen-constructs\n\nProjen project types with standard configuration for consistent project setup across all repositories.\n\n## Installation\n\n```bash\npnpm add -D @nikovirtala/projen-constructs projen constructs\n```\n\nRequires pnpm 12 and `projen` >= 0.101.27. `@mrgrain/cdk-esbuild` and `constructs` are peer\ndependencies as well.\n\nTo create a project from scratch:\n\n```bash\npnpm dlx projen new --from @nikovirtala/projen-constructs aws_cdk_construct_library\n```\n\n## Features\n\n- **Standard Configuration**: Opinionated defaults for author, release branch, package manager, Node.js, TypeScript, and tooling\n- **Automatic Project Type Discovery**: Generates the `ProjectType` enum from Projen's JSII manifest (19 project types)\n- **Component System**: Reusable components (Vitest, TypeDoc, Mise, Homebrew, Colima, LocalStack, Lambda bundling)\n- **Code Generation**: `ProjectGenerator` creates project classes with standard configuration\n- **ES Modules**: TypeScript and CDK App projects use ES modules (JSII uses CommonJS)\n- **Code Quality**: Biome for formatting and linting\n- **Testing**: Vitest with coverage\n- **Auto-merge**: Enabled with auto-approve\n- **VSCode**: Recommended extensions and settings\n- **mise**: Node version management\n\n## Standard Configuration\n\n- **Author**: Niko Virtala (niko.virtala@hey.com)\n- **Default Release Branch**: main\n- **Package Manager**: pnpm 12.16.1\n- **Node Version**: 26.13.0\n- **TypeScript**: 6.0.3\n- **CDK Version**: 2.263.0 (for CDK projects)\n- **JSII Version**: ~6.0.3 (for JSII projects)\n\nThe AWS CDK, Node.js and TypeScript versions live in `src/versions.json` and are refreshed by the\n`update-versions` task, which the dependency upgrade workflow runs.\n\n### pnpm\n\npnpm reads its settings from `pnpm-workspace.yaml`, not `.npmrc`, since pnpm 11. Generated projects\nget:\n\n| Setting | Value | Reason |\n| ---------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |\n| `nodeLinker` | `hoisted` | jsii tooling resolves dependencies from a flat `node_modules` |\n| `allowBuilds` | `esbuild: true` | esbuild links its platform binary in a postinstall script, and pnpm 11 fails an install with ignored builds |\n| `verifyDepsBeforeRun` | `false` | projen resolves the task `PATH` with `$(pnpm -c exec ...)`, which otherwise re-enters `pnpm install` and deadlocks |\n| `minimumReleaseAge` | `0` | the pnpm 11 default of 1440 minutes makes pnpm write `minimumReleaseAgeExclude` entries into this generated file |\n\n### TypeScript configuration\n\nProjen renders three configs, and none of them should be edited directly:\n\n- `tsconfig.json` compiles `src` to `lib`. For JSII projects, jsii validates it against its `strict`\n rule set, so it only carries compiler options jsii accepts.\n- `test/tsconfig.json` extends it and is type-check only. This is the config Vitest type checking and\n the editor use, and the one `tsconfigDev` points at.\n- `projenrc/tsconfig.json` covers `.projenrc.ts`.\n\n## Customization\n\nOverride any option by passing it to the constructor:\n\n```typescript\nconst project = new JsiiProject({\n name: \"my-project\",\n repositoryUrl: \"https://github.com/nikovirtala/my-project.git\",\n minNodeVersion: \"26.0.0\",\n author: \"Custom Author\",\n authorAddress: \"custom@example.com\",\n mise: false,\n vitest: false,\n tsconfig: {\n compilerOptions: {\n noUnusedLocals: false,\n },\n },\n biomeOptions: {\n biomeConfig: {\n formatter: {\n lineWidth: 100,\n },\n },\n },\n});\n```\n\nEvery component is exposed as an enable flag (`mise`, `vitest`, ...) plus an options property\n(`miseOptions`, `vitestOptions`, ...).\n\n## Usage\n\n### Projects\n\n#### AWS CDK Construct Library Project\n\n```typescript\nimport { AwsCdkConstructLibraryProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new AwsCdkConstructLibraryProject({\n name: \"my-cdk-construct\",\n repositoryUrl: \"https://github.com/nikovirtala/my-cdk-construct.git\",\n});\n\nproject.synth();\n```\n\n#### AWS CDK TypeScript App Project\n\n```typescript\nimport { AwsCdkTypeScriptAppProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new AwsCdkTypeScriptAppProject({\n name: \"my-cdk-app\",\n repositoryUrl: \"https://github.com/nikovirtala/my-cdk-app.git\",\n});\n\nproject.synth();\n```\n\n#### JSII Project\n\n```typescript\nimport { JsiiProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new JsiiProject({\n name: \"my-jsii-project\",\n repositoryUrl: \"https://github.com/nikovirtala/my-jsii-project.git\",\n});\n\nproject.synth();\n```\n\n#### TypeScript Project\n\n```typescript\nimport { TypeScriptProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new TypeScriptProject({\n name: \"my-typescript-project\",\n repositoryUrl: \"https://github.com/nikovirtala/my-typescript-project.git\",\n});\n\nproject.synth();\n```\n\n### Components\n\nThe package includes reusable components for common development tasks:\n\n#### Vitest\n\n[Vitest](https://vitest.dev) testing framework component.\n\n```typescript\nimport { Vitest } from \"@nikovirtala/projen-constructs\";\n\nnew Vitest(project, {\n vitestVersion: \"^5\",\n config: {\n coverageProvider: CoverageProvider.V8,\n coverageReporters: [CoverageReporter.TEXT, CoverageReporter.LCOV],\n },\n});\n```\n\nType checking runs against the project's development tsconfig (`test/tsconfig.json`) unless\n`config.typecheckTsconfig` says otherwise.\n\nFor Vitest settings that `config` doesn't cover, use `extraTestConfig` (merged into `test`) and\n`extraConfig` (top-level options next to `test`):\n\n```typescript\nnew Vitest(project, {\n extraTestConfig: {\n setupFiles: [\"test/setup.ts\"],\n },\n extraConfig: {\n resolve: { alias: { \"@\": \"/src\" } },\n },\n});\n```\n\n`extraTestConfig` is deep-merged over the generated `test` options: objects merge, and other values\n(including arrays) replace the generated value. Both options are rendered as JSON, so their values\ncan't contain functions or regular expressions, which rules out plugins.\n\n#### TypeDoc\n\n[TypeDoc](https://typedoc.org) documentation generation component.\n\n```typescript\nimport { TypeDoc, EntryPointStrategy } from \"@nikovirtala/projen-constructs\";\n\nnew TypeDoc(project, {\n version: \"^0.28\",\n typeDocConfig: {\n entryPointStrategy: EntryPointStrategy.EXPAND,\n out: \"docs/api\",\n exclude: [\"**/*.test.ts\"],\n },\n});\n```\n\n#### Mise\n\n[Mise](https://mise.jdx.dev) dev tools/runtimes management component.\n\n```typescript\nimport { Mise } from \"@nikovirtala/projen-constructs\";\n\nnew Mise(project, {\n nodeVersion: \"26.13.0\",\n});\n```\n\n#### Homebrew\n\n[Homebrew](https://brew.sh) package management component. Writes a `Brewfile` and adds an\n`install:homebrew` task that bootstraps Homebrew and runs `brew bundle`.\n\n```typescript\nimport { Homebrew } from \"@nikovirtala/projen-constructs\";\n\nconst homebrew = new Homebrew(project, {\n packages: [\"jq\", \"yq\"],\n});\n\nhomebrew.addPackage(\"gh\");\n```\n\nA fully qualified formula (`user/repository/formula`) also adds a `tap` entry. Since Homebrew 6,\nformulae from non-official taps only load when trusted, so they're written with `trusted: true`.\nThat trusts only the formula, not the rest of its tap.\n\n#### Colima\n\n[Colima](https://github.com/abiosoft/colima) container runtime component. Alternative for Docker.\n\n```typescript\nimport { Colima } from \"@nikovirtala/projen-constructs\";\n\nnew Colima(project);\n```\n\n#### LocalStack\n\n[LocalStack](https://www.localstack.cloud) AWS emulation component.\n\n```typescript\nimport { LocalStack } from \"@nikovirtala/projen-constructs\";\n\nnew LocalStack(project, {\n services: [\"s3\", \"lambda\", \"dynamodb\"],\n port: 4566,\n debug: true,\n});\n```\n\n#### LambdaFunctionConstructGenerator\n\nGenerates AWS CDK Lambda Function constructs and bundles their code.\n\n```typescript\nimport { LambdaFunctionConstructGenerator } from \"@nikovirtala/projen-constructs\";\n\nnew LambdaFunctionConstructGenerator(project, {\n sourceDir: \"src/handlers\",\n outputDir: \"src/constructs/lambda\",\n filePattern: \"*.lambda.ts\",\n esbuildOptions: {\n minify: true,\n sourcemap: true,\n },\n});\n```\n\n#### Bundler\n\nLow-level bundling utilities for Lambda functions.\n\n```typescript\nimport {\n Bundler,\n LambdaFunctionCodeBundle,\n} from \"@nikovirtala/projen-constructs\";\n\nconst bundler = new Bundler(project, {\n assetsDir: \"assets\",\n esbuildVersion: \"^0.25\",\n});\n\nnew LambdaFunctionCodeBundle(project, {\n entrypoint: \"src/my-function.lambda.ts\",\n extension: \".lambda.ts\",\n});\n```\n\n#### ProjectGenerator\n\nGenerates TypeScript project classes with standard configuration.\n\n```typescript\nimport { ProjectGenerator, ProjectType } from \"@nikovirtala/projen-constructs\";\n\nnew ProjectGenerator(project, {\n name: \"TypeScriptProject\",\n projectType: ProjectType.TYPE_SCRIPT_PROJECT,\n filePath: \"./src/projects/typescript.generated.ts\",\n components: [\n { componentClass: Mise },\n { componentClass: Vitest }, // Auto-detects VitestOptions from JSII manifest\n ],\n});\n```\n\nFeatures:\n\n- Automatically generates the `ProjectType` enum from Projen's JSII manifest\n- Auto-detects component options types from JSII manifests\n- Strips Projen's `@pjnew` annotation from `packageManager`, which `projen new` would otherwise\n render into a generated `.projenrc.ts` as the package manager that ran the command\n- Validates paths to prevent directory traversal attacks\n- Structured error handling with custom error classes\n\n## Migrating from the standalone packages\n\nThe components used to be published as separate packages. Those packages are deprecated and won't\nget new features or fixes. Every class, interface, enum and function they exported is exported from\n`@nikovirtala/projen-constructs` under the same name, except `AwsCdkApp` (see below).\n\n| Deprecated package | Replacement in `@nikovirtala/projen-constructs` |\n| --- | --- |\n| `@nikovirtala/projen-vitest` | `Vitest`, `VitestOptions`, `VitestConfigOptions`, `Environment`, `Pool`, `CoverageProvider`, `CoverageReporter` |\n| `@nikovirtala/projen-typedoc` | `TypeDoc`, `TypeDocOptions`, `TypeDocConfiguration` and its enums |\n| `@nikovirtala/projen-homebrew` | `Homebrew`, `HomebrewOptions` |\n| `@nikovirtala/projen-colima` | `Colima` |\n| `@nikovirtala/projen-localstack` | `LocalStack`, `LocalStackOptions` |\n| `@nikovirtala/projen-bundle-lambda-function-code` | `Bundler`, `LambdaFunctionCodeBundle`, `LambdaFunctionCodeBundler` and their options |\n| `@nikovirtala/projen-lambda-function-construct-generator` | `LambdaFunctionConstructGenerator`, `LambdaFunctionConstructGeneratorOptions` |\n| `@nikovirtala/projen-aws-cdk-app` | `AwsCdkTypeScriptAppProject`, `AwsCdkTypeScriptAppProjectOptions` |\n\n### Steps\n\n1. In `.projenrc.ts`, replace the old package in `devDeps` with `@nikovirtala/projen-constructs`, and\n change the imports:\n\n ```typescript\n // before\n import { Vitest } from \"@nikovirtala/projen-vitest\";\n // after\n import { Vitest } from \"@nikovirtala/projen-constructs\";\n ```\n\n2. Check the peer dependencies. `@nikovirtala/projen-constructs` needs `projen` ^0.104, `constructs`\n ^10 and `@mrgrain/cdk-esbuild` ^5. The standalone packages accepted older projen versions, so you\n may have to upgrade projen in the same change.\n3. Install the new package, run `npx projen` and review the changes to the generated files.\n\n### Changes to expect\n\nThese are the differences in behaviour or generated files between the standalone packages and this\nlibrary.\n\n**Vitest**\n\n- `vitest.config.ts` imports `defineConfig` from\n `@nikovirtala/projen-constructs/lib/vitest-define-config` instead of\n `@nikovirtala/projen-vitest/lib/bundled-define-config`. Projen rewrites the file, so there's\n nothing to change by hand.\n- The config is rendered as JSON, so its keys are quoted. The settings are the same.\n- `config.typecheckTsconfig` defaults to the project's development tsconfig (`test/tsconfig.json`\n in current projen) instead of `tsconfig.dev.json`.\n- JSII and construct library projects exclude `vitest.config.ts` from the published package.\n- New: `extraTestConfig` and `extraConfig` for Vitest settings that `config` doesn't cover.\n\n**Homebrew and Colima**\n\n- Packages from a tap (`owner/tap/formula`) also add a `tap` line to the `Brewfile`, and the\n `Brewfile` is sorted.\n- The `install:homebrew`, `homebrew:bundle` and `colima` tasks run in bash. `homebrew:bundle` also\n finds a freshly installed `brew` that isn't on the `PATH` yet.\n\n**LocalStack**\n\n- `imageTag` is applied: LocalStack starts with `localstack/localstack:<imageTag>`. It used to be\n ignored.\n\n**Bundler / LambdaFunctionCodeBundler**\n\n- `LambdaFunctionCodeBundler.bundleOptions` applies to every discovered entrypoint. Its `entrypoint`\n used to replace them all.\n\n**LambdaFunctionConstructGenerator**\n\n- The bundle task runs `tsx` with the project's development tsconfig instead of `tsconfig.dev.json`.\n\n**TypeDoc**: no changes.\n\n### From `AwsCdkApp` to `AwsCdkTypeScriptAppProject`\n\n```typescript\n// before\nimport { AwsCdkApp } from \"@nikovirtala/projen-aws-cdk-app\";\nconst project = new AwsCdkApp({ name: \"my-app\", cdkVersion: \"2.221.0\" });\n\n// after\nimport { AwsCdkTypeScriptAppProject } from \"@nikovirtala/projen-constructs\";\nconst project = new AwsCdkTypeScriptAppProject({ name: \"my-app\", cdkVersion: \"2.221.0\" });\n```\n\nBoth are ES module apps run with `tsx`, using pnpm, Biome, Vitest and mise. The differences:\n\n- **`nvm` is removed.** Use mise (on by default), which pins the Node.js version in `mise.toml`.\n- **Homebrew is on by default.** The project gets a `Brewfile`, and `npx projen` runs\n `install:homebrew` (installs Homebrew if `brew` is missing) and `homebrew:bundle`. Set\n `homebrew: false` to turn it off.\n- **cdk.json `app`** is `npx tsx src/main.ts` instead of `tsx --tsconfig tsconfig.json src/main.ts`.\n- **Defaults** come from this library: Node.js, TypeScript, CDK and pnpm versions (pnpm 12 instead\n of 10), Dependabot off, auto-merge on, `auto-approve` and `auto-merge` labels on dependency\n upgrade PRs, and auto-approval of PRs by `nikovirtala`. Any option you set explicitly still wins,\n so set `autoApproveOptions` if you aren't `nikovirtala`.\n- **tsconfig**: `noImplicitOverride` and `allowSyntheticDefaultImports` move from `tsconfig.json`\n to the development tsconfig (`test/tsconfig.json`).\n- **Options removed from the interface**: `eslint`, `jest`, `prettier` (and their options),\n `sampleCode` and `tsJestOptions`.\n- `vitestOptions` takes the `VitestOptions` of this library, and now also `homebrewOptions` and\n `miseOptions`.\n\n## Development\n\nThis project is managed by Projen and generates itself: `.projenrc.ts` defines the project using the\n`JsiiProject` type from `src/`. Configuration changes belong in `.projenrc.ts`, never in the\ngenerated files.\n\n```bash\npnpm projen # synthesize project files\npnpm build # synthesize, compile, test and package\npnpm test # biome, vitest, typedoc\npnpm test:watch # vitest in watch mode\npnpm test:update # update snapshots\npnpm biome # format and lint\npnpm docgen # regenerate API.md from the .jsii manifest\npnpm update-versions # refresh src/versions.json\npnpm upgrade # upgrade dependencies\n```\n\n### Build process\n\n```mermaid\nflowchart TD\n projenrc[\".projenrc.ts\"]\n\n subgraph synthesize[\"default (synthesize)\"]\n direction TB\n synth[\"tsx .projenrc.ts\"]\n generator[\"ProjectGenerator\"]\n generated[\"src/project-type.ts<br/>src/projects/*.generated.ts<br/>src/projects/*-options.generated.ts\"]\n projenfiles[\"package.json, tsconfig.json,<br/>pnpm-workspace.yaml, workflows, ...\"]\n brew[\"install:homebrew<br/>brew bundle\"]\n definecfg[\"bundle-vitest-define-config<br/>esbuild → lib/vitest-define-config.js\"]\n\n synth --> generator --> generated\n synth --> projenfiles\n synth --> brew\n synth --> definecfg\n end\n\n subgraph compile[\"compile\"]\n direction TB\n jsii[\"jsii<br/>validates tsconfig.json against the strict rule set\"]\n lib[\"lib/**\"]\n manifest[\".jsii manifest\"]\n\n jsii --> lib\n jsii --> manifest\n end\n\n subgraph test[\"test\"]\n direction TB\n biome[\"biome check --write\"]\n vitest[\"vitest run<br/>+ type checking\"]\n typedoc[\"typedoc → docs/api\"]\n\n biome --> vitest --> typedoc\n end\n\n subgraph package[\"package\"]\n direction TB\n pacmak[\"jsii-pacmak<br/>--pack-command 'pnpm pack'\"]\n dist[\"dist/js/*.tgz\"]\n\n pacmak --> dist\n end\n\n projenrc --> synthesize\n synthesize --> compile\n compile --> test\n test --> package\n\n manifest -. \"component options FQNs<br/>read on the next synthesis\" .-> generator\n docgen[\"docgen<br/>jsii-docgen → API.md\"]\n manifest --> docgen\n\n classDef artifact fill:#eef,stroke:#88a\n class generated,projenfiles,lib,manifest,dist artifact\n```\n\nThe dashed edge is the part worth knowing about: `ProjectGenerator` reads the committed `.jsii`\nmanifest to resolve component options types, so the manifest produced by `compile` feeds the *next*\nsynthesis. This is why `.jsii` is committed rather than ignored. A component options type that is\nmissing from the manifest is reported as a warning and its options property is left out of the\ngenerated interface, which is expected only while a new component is being introduced: compile once,\nthen synthesize again.\n\n`package` runs `package:js` on CI and `package-all` locally; both end up in `jsii-pacmak`.\n`docgen` is not part of `build` and has to be run explicitly after the manifest changes.\n"
|
|
4199
|
+
"markdown": "# @nikovirtala/projen-constructs\n\nProjen project types with standard configuration for consistent project setup across all repositories.\n\n## Installation\n\n```bash\npnpm add -D @nikovirtala/projen-constructs projen constructs\n```\n\nRequires pnpm 12 and `projen` ^0.104.23. `@mrgrain/cdk-esbuild` and `constructs` are peer\ndependencies as well.\n\nTo create a project from scratch:\n\n```bash\npnpm dlx projen new --from @nikovirtala/projen-constructs aws_cdk_construct_library\n```\n\n## Features\n\n- **Standard Configuration**: Opinionated defaults for author, release branch, package manager, Node.js, TypeScript, and tooling\n- **Automatic Project Type Discovery**: Generates the `ProjectType` enum from Projen's JSII manifest (19 project types)\n- **Component System**: Reusable components (Vitest, TypeDoc, Mise, Homebrew, Colima, LocalStack, Lambda bundling)\n- **Code Generation**: `ProjectGenerator` creates project classes with standard configuration\n- **ES Modules**: TypeScript and CDK App projects use ES modules (JSII uses CommonJS)\n- **Code Quality**: Biome for formatting and linting\n- **Testing**: Vitest with coverage\n- **Auto-merge**: Enabled with auto-approve\n- **VSCode**: Recommended extensions and settings\n- **mise**: Node version management\n\n## Standard Configuration\n\n- **Author**: Niko Virtala (niko.virtala@hey.com)\n- **Default Release Branch**: main\n- **Package Manager**: pnpm 12.16.1\n- **Node Version**: 26.13.0\n- **TypeScript**: 6.0.3\n- **CDK Version**: 2.263.0 (for CDK projects)\n- **JSII Version**: ~6.0.3 (for JSII projects)\n\nThe AWS CDK, Node.js and TypeScript versions live in `src/versions.json` and are refreshed by the\n`update-versions` task, which the dependency upgrade workflow runs.\n\n### pnpm\n\npnpm reads its settings from `pnpm-workspace.yaml`, not `.npmrc`, since pnpm 11. Generated projects\nget:\n\n| Setting | Value | Reason |\n| ---------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------ |\n| `nodeLinker` | `hoisted` | jsii tooling resolves dependencies from a flat `node_modules` |\n| `allowBuilds` | `esbuild: true` | esbuild links its platform binary in a postinstall script, and pnpm 11 fails an install with ignored builds |\n| `verifyDepsBeforeRun` | `false` | projen resolves the task `PATH` with `$(pnpm -c exec ...)`, which otherwise re-enters `pnpm install` and deadlocks |\n| `minimumReleaseAge` | `0` | the pnpm 11 default of 1440 minutes makes pnpm write `minimumReleaseAgeExclude` entries into this generated file |\n\n### TypeScript configuration\n\nProjen renders three configs, and none of them should be edited directly:\n\n- `tsconfig.json` compiles `src` to `lib`. For JSII projects, jsii validates it against its `strict`\n rule set, so it only carries compiler options jsii accepts.\n- `test/tsconfig.json` extends it and is type-check only. This is the config Vitest type checking and\n the editor use, and the one `tsconfigDev` points at.\n- `projenrc/tsconfig.json` covers `.projenrc.ts`.\n\n### Native TypeScript\n\nTypeScript and AWS CDK app projects run TypeScript with Node.js's built-in\n[type stripping](https://nodejs.org/api/typescript.html#type-stripping) instead of `tsx` or\n`ts-node`: the default task is `node .projenrc.ts`, and the cdk.json `app` is `node src/main.ts`.\nTheir `tsconfig.json` sets `erasableSyntaxOnly` and `verbatimModuleSyntax`, so `tsc` reports code\nthat Node.js can't run before Node.js does.\n\nCode in these projects must therefore:\n\n- only use syntax that can be stripped: no `enum`s (use an `as const` object), no namespaces with\n values, and no constructor parameter properties\n- mark type-only imports with `type` (Biome's `useImportType` fixes these)\n- import relative files with their `.ts` extension, and never import a directory\n- use Node.js [subpath imports](https://nodejs.org/api/packages.html#subpath-imports)\n (`#stacks` in `package.json` `imports`) instead of tsconfig `paths`, which Node.js doesn't read\n- import packages without an `exports` map either from the package root or with an explicit file,\n e.g. `projen/lib/component.js` rather than `projen/lib/component`\n\nLambda handlers bundled by esbuild and tests run by Vitest aren't run by Node.js directly, but the\nsame compiler options apply to them.\n\nJSII and AWS CDK construct library projects keep using `tsx`, because jsii compiles to CommonJS, and\ntheir `.projenrc.ts` often imports their own `src`.\n\nWhen you start a new project by hand, make sure `package.json` has `\"type\": \"module\"` before the\nfirst `node .projenrc.ts`: `npm init` writes `\"type\": \"commonjs\"`, which makes Node.js reject the\n`import` statements in `.projenrc.ts`.\n\n## Customization\n\nOverride any option by passing it to the constructor:\n\n```typescript\nimport { JsiiProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new JsiiProject({\n name: \"my-project\",\n repositoryUrl: \"https://github.com/nikovirtala/my-project.git\",\n minNodeVersion: \"26.0.0\",\n author: \"Custom Author\",\n authorAddress: \"custom@example.com\",\n mise: false,\n vitest: false,\n tsconfig: {\n compilerOptions: {\n noUnusedLocals: false,\n },\n },\n biomeOptions: {\n biomeConfig: {\n formatter: {\n lineWidth: 100,\n },\n },\n },\n});\n```\n\nEvery component is exposed as an enable flag (`mise`, `vitest`, ...) plus an options property\n(`miseOptions`, `vitestOptions`, ...).\n\n## Usage\n\n### Projects\n\n#### AWS CDK Construct Library Project\n\n```typescript\nimport { AwsCdkConstructLibraryProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new AwsCdkConstructLibraryProject({\n name: \"my-cdk-construct\",\n repositoryUrl: \"https://github.com/nikovirtala/my-cdk-construct.git\",\n});\n\nproject.synth();\n```\n\n#### AWS CDK TypeScript App Project\n\n```typescript\nimport { AwsCdkTypeScriptAppProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new AwsCdkTypeScriptAppProject({\n name: \"my-cdk-app\",\n repository: \"https://github.com/nikovirtala/my-cdk-app.git\",\n});\n\nproject.synth();\n```\n\n#### JSII Project\n\n```typescript\nimport { JsiiProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new JsiiProject({\n name: \"my-jsii-project\",\n repositoryUrl: \"https://github.com/nikovirtala/my-jsii-project.git\",\n});\n\nproject.synth();\n```\n\n#### TypeScript Project\n\n```typescript\nimport { TypeScriptProject } from \"@nikovirtala/projen-constructs\";\n\nconst project = new TypeScriptProject({\n name: \"my-typescript-project\",\n repository: \"https://github.com/nikovirtala/my-typescript-project.git\",\n});\n\nproject.synth();\n```\n\n### Components\n\nThe package includes reusable components for common development tasks:\n\n#### Vitest\n\n[Vitest](https://vitest.dev) testing framework component.\n\n```typescript\nimport { Vitest, CoverageProvider, CoverageReporter } from \"@nikovirtala/projen-constructs\";\n\nnew Vitest(project, {\n vitestVersion: \"^5\",\n config: {\n coverageProvider: CoverageProvider.V8,\n coverageReporters: [CoverageReporter.TEXT, CoverageReporter.LCOV],\n },\n});\n```\n\nType checking runs against the project's development tsconfig (`test/tsconfig.json`) unless\n`config.typecheckTsconfig` says otherwise.\n\nFor Vitest settings that `config` doesn't cover, use `extraTestConfig` (merged into `test`) and\n`extraConfig` (top-level options next to `test`):\n\n```typescript\nimport { Vitest } from \"@nikovirtala/projen-constructs\";\n\nnew Vitest(project, {\n extraTestConfig: {\n setupFiles: [\"test/setup.ts\"],\n },\n extraConfig: {\n resolve: { alias: { \"@\": \"/src\" } },\n },\n});\n```\n\n`extraTestConfig` is deep-merged over the generated `test` options: objects merge, and other values\n(including arrays) replace the generated value. Both options are rendered as JSON, so their values\ncan't contain functions or regular expressions, which rules out plugins.\n\n#### TypeDoc\n\n[TypeDoc](https://typedoc.org) documentation generation component.\n\n```typescript\nimport { TypeDoc, EntryPointStrategy } from \"@nikovirtala/projen-constructs\";\n\nnew TypeDoc(project, {\n version: \"^0.28\",\n typeDocConfig: {\n entryPointStrategy: EntryPointStrategy.EXPAND,\n out: \"docs/api\",\n exclude: [\"**/*.test.ts\"],\n },\n});\n```\n\n#### Mise\n\n[Mise](https://mise.jdx.dev) dev tools/runtimes management component.\n\n```typescript\nimport { Mise } from \"@nikovirtala/projen-constructs\";\n\nnew Mise(project, {\n nodeVersion: \"26.13.0\",\n});\n```\n\n#### Homebrew\n\n[Homebrew](https://brew.sh) package management component. Writes a `Brewfile` and adds an\n`install:homebrew` task that bootstraps Homebrew and runs `brew bundle`.\n\n```typescript\nimport { Homebrew } from \"@nikovirtala/projen-constructs\";\n\nconst homebrew = new Homebrew(project, {\n packages: [\"jq\", \"yq\"],\n});\n\nhomebrew.addPackage(\"gh\");\n```\n\nA fully qualified formula (`user/repository/formula`) also adds a `tap` entry. Since Homebrew 6,\nformulae from non-official taps only load when trusted, so they're written with `trusted: true`.\nThat trusts only the formula, not the rest of its tap.\n\n#### Colima\n\n[Colima](https://github.com/abiosoft/colima) container runtime component. Alternative for Docker.\n\n```typescript\nimport { Colima } from \"@nikovirtala/projen-constructs\";\n\nnew Colima(project);\n```\n\n#### LocalStack\n\n[LocalStack](https://www.localstack.cloud) AWS emulation component.\n\n```typescript\nimport { LocalStack } from \"@nikovirtala/projen-constructs\";\n\nnew LocalStack(project, {\n services: [\"s3\", \"lambda\", \"dynamodb\"],\n port: 4566,\n debug: true,\n});\n```\n\n#### LambdaFunctionConstructGenerator\n\nGenerates AWS CDK Lambda Function constructs and bundles their code.\n\n```typescript\nimport { LambdaFunctionConstructGenerator } from \"@nikovirtala/projen-constructs\";\n\nnew LambdaFunctionConstructGenerator(project, {\n sourceDir: \"src/handlers\",\n outputDir: \"src/constructs/lambda\",\n filePattern: \"*.lambda.ts\",\n esbuildOptions: {\n minify: true,\n sourcemap: true,\n },\n});\n```\n\n#### Bundler\n\nLow-level bundling utilities for Lambda functions.\n\n```typescript\nimport {\n Bundler,\n LambdaFunctionCodeBundle,\n} from \"@nikovirtala/projen-constructs\";\n\nconst bundler = new Bundler(project, {\n assetsDir: \"assets\",\n esbuildVersion: \"^0.25\",\n});\n\nnew LambdaFunctionCodeBundle(project, {\n entrypoint: \"src/my-function.lambda.ts\",\n extension: \".lambda.ts\",\n});\n```\n\n#### ProjectGenerator\n\nGenerates TypeScript project classes with standard configuration.\n\n```typescript\nimport { ProjectGenerator, ProjectType, Mise, Vitest } from \"@nikovirtala/projen-constructs\";\n\nnew ProjectGenerator(project, {\n name: \"TypeScriptProject\",\n projectType: ProjectType.TYPE_SCRIPT_PROJECT,\n filePath: \"./src/projects/typescript.generated.ts\",\n components: [\n { componentClass: Mise },\n { componentClass: Vitest }, // Auto-detects VitestOptions from JSII manifest\n ],\n});\n```\n\nFeatures:\n\n- Automatically generates the `ProjectType` enum from Projen's JSII manifest\n- Auto-detects component options types from JSII manifests\n- Strips Projen's `@pjnew` annotation from `packageManager`, which `projen new` would otherwise\n render into a generated `.projenrc.ts` as the package manager that ran the command\n- Validates paths to prevent directory traversal attacks\n- Structured error handling with custom error classes\n\n## Migrating from the standalone packages\n\nThe components used to be published as separate packages. Those packages are deprecated and won't\nget new features or fixes. Every class, interface, enum and function they exported is exported from\n`@nikovirtala/projen-constructs` under the same name, except `AwsCdkApp` (see below).\n\n| Deprecated package | Replacement in `@nikovirtala/projen-constructs` |\n| --- | --- |\n| `@nikovirtala/projen-vitest` | `Vitest`, `VitestOptions`, `VitestConfigOptions`, `Environment`, `Pool`, `CoverageProvider`, `CoverageReporter` |\n| `@nikovirtala/projen-typedoc` | `TypeDoc`, `TypeDocOptions`, `TypeDocConfiguration` and its enums |\n| `@nikovirtala/projen-homebrew` | `Homebrew`, `HomebrewOptions` |\n| `@nikovirtala/projen-colima` | `Colima` |\n| `@nikovirtala/projen-localstack` | `LocalStack`, `LocalStackOptions` |\n| `@nikovirtala/projen-bundle-lambda-function-code` | `Bundler`, `LambdaFunctionCodeBundle`, `LambdaFunctionCodeBundler` and their options |\n| `@nikovirtala/projen-lambda-function-construct-generator` | `LambdaFunctionConstructGenerator`, `LambdaFunctionConstructGeneratorOptions` |\n| `@nikovirtala/projen-aws-cdk-app` | `AwsCdkTypeScriptAppProject`, `AwsCdkTypeScriptAppProjectOptions` |\n\n### Steps\n\n1. In `.projenrc.ts`, replace the old package in `devDeps` with `@nikovirtala/projen-constructs`, and\n change the imports:\n\n ```typescript\n // before\n import { Vitest } from \"@nikovirtala/projen-vitest\";\n // after\n import { Vitest } from \"@nikovirtala/projen-constructs\";\n ```\n\n2. Check the peer dependencies. `@nikovirtala/projen-constructs` needs `projen` ^0.104.23, `constructs`\n ^10 and `@mrgrain/cdk-esbuild` ^5. The standalone packages accepted older projen versions, so you\n may have to upgrade projen in the same change.\n3. Install the new package, run `npx projen` and review the changes to the generated files.\n\n### Changes to expect\n\nThese are the differences in behaviour or generated files between the standalone packages and this\nlibrary.\n\n**Vitest**\n\n- `vitest.config.ts` imports `defineConfig` from\n `@nikovirtala/projen-constructs/lib/vitest-define-config` instead of\n `@nikovirtala/projen-vitest/lib/bundled-define-config`. Projen rewrites the file, so there's\n nothing to change by hand.\n- The config is rendered as JSON, so its keys are quoted. The settings are the same.\n- `config.typecheckTsconfig` defaults to the project's development tsconfig (`test/tsconfig.json`\n in current projen) instead of `tsconfig.dev.json`.\n- JSII and construct library projects exclude `vitest.config.ts` from the published package.\n- New: `extraTestConfig` and `extraConfig` for Vitest settings that `config` doesn't cover.\n\n**Homebrew and Colima**\n\n- Packages from a tap (`owner/tap/formula`) also add a `tap` line to the `Brewfile`, and the\n `Brewfile` is sorted.\n- The `install:homebrew`, `homebrew:bundle` and `colima` tasks run in bash. `homebrew:bundle` also\n finds a freshly installed `brew` that isn't on the `PATH` yet.\n\n**LocalStack**\n\n- `imageTag` is applied: LocalStack starts with `localstack/localstack:<imageTag>`. It used to be\n ignored.\n\n**Bundler / LambdaFunctionCodeBundler**\n\n- `LambdaFunctionCodeBundler.bundleOptions` applies to every discovered entrypoint. Its `entrypoint`\n used to replace them all.\n\n**LambdaFunctionConstructGenerator**\n\n- The bundle task runs `tsx` with the project's development tsconfig instead of `tsconfig.dev.json`.\n\n**TypeDoc**: no changes.\n\n### From `AwsCdkApp` to `AwsCdkTypeScriptAppProject`\n\n```typescript\n// before\nimport { AwsCdkApp } from \"@nikovirtala/projen-aws-cdk-app\";\nconst project = new AwsCdkApp({ name: \"my-app\", cdkVersion: \"2.221.0\" });\n\n// after\nimport { AwsCdkTypeScriptAppProject } from \"@nikovirtala/projen-constructs\";\nconst project = new AwsCdkTypeScriptAppProject({ name: \"my-app\", cdkVersion: \"2.221.0\" });\n```\n\nBoth are ES module apps using pnpm, Biome, Vitest and mise. The differences:\n\n- **Native TypeScript**: `.projenrc.ts` and the app run with `node` instead of `tsx`, and the\n tsconfig sets `erasableSyntaxOnly` and `verbatimModuleSyntax` (see [Native TypeScript](#native-typescript)).\n\n- **`nvm` is removed.** Use mise (on by default), which pins the Node.js version in `mise.toml`.\n- **Homebrew is on by default.** The project gets a `Brewfile`, and `npx projen` runs\n `install:homebrew` (installs Homebrew if `brew` is missing) and `homebrew:bundle`. Set\n `homebrew: false` to turn it off.\n- **cdk.json `app`** is `node src/main.ts` instead of `tsx --tsconfig tsconfig.json src/main.ts`.\n- **Defaults** come from this library: Node.js, TypeScript, CDK and pnpm versions (pnpm 12 instead\n of 10), Dependabot off, auto-merge on, `auto-approve` and `auto-merge` labels on dependency\n upgrade PRs, and auto-approval of PRs by `nikovirtala`. Any option you set explicitly still wins,\n so set `autoApproveOptions` if you aren't `nikovirtala`.\n- **tsconfig**: `noImplicitOverride` and `allowSyntheticDefaultImports` move from `tsconfig.json`\n to the development tsconfig (`test/tsconfig.json`).\n- **Options removed from the interface**: `eslint`, `jest`, `prettier` (and their options),\n `sampleCode` and `tsJestOptions`.\n- `vitestOptions` takes the `VitestOptions` of this library, and now also `homebrewOptions` and\n `miseOptions`.\n\n## Development\n\nThis project is managed by Projen and generates itself: `.projenrc.ts` defines the project using the\n`JsiiProject` type from `src/`. Configuration changes belong in `.projenrc.ts`, never in the\ngenerated files.\n\n```bash\npnpm projen # synthesize project files\npnpm build # synthesize, compile, test and package\npnpm test # biome, vitest, typedoc\npnpm test:watch # vitest in watch mode\npnpm test:update # update snapshots\npnpm biome # format and lint\npnpm docgen # regenerate API.md from the .jsii manifest\npnpm update-versions # refresh src/versions.json\npnpm upgrade # upgrade dependencies\n```\n\n### Build process\n\n```mermaid\nflowchart TD\n projenrc[\".projenrc.ts\"]\n\n subgraph synthesize[\"default (synthesize)\"]\n direction TB\n synth[\"tsx .projenrc.ts\"]\n generator[\"ProjectGenerator\"]\n generated[\"src/project-type.ts<br/>src/projects/*.generated.ts<br/>src/projects/*-options.generated.ts\"]\n projenfiles[\"package.json, tsconfig.json,<br/>pnpm-workspace.yaml, workflows, ...\"]\n brew[\"install:homebrew<br/>brew bundle\"]\n definecfg[\"bundle-vitest-define-config<br/>esbuild → lib/vitest-define-config.js\"]\n\n synth --> generator --> generated\n synth --> projenfiles\n synth --> brew\n synth --> definecfg\n end\n\n subgraph compile[\"compile\"]\n direction TB\n jsii[\"jsii<br/>validates tsconfig.json against the strict rule set\"]\n lib[\"lib/**\"]\n manifest[\".jsii manifest\"]\n\n jsii --> lib\n jsii --> manifest\n end\n\n subgraph test[\"test\"]\n direction TB\n biome[\"biome check --write\"]\n vitest[\"vitest run<br/>+ type checking\"]\n typedoc[\"typedoc → docs/api\"]\n\n biome --> vitest --> typedoc\n end\n\n subgraph package[\"package\"]\n direction TB\n pacmak[\"jsii-pacmak<br/>--pack-command 'pnpm pack'\"]\n dist[\"dist/js/*.tgz\"]\n\n pacmak --> dist\n end\n\n projenrc --> synthesize\n synthesize --> compile\n compile --> test\n test --> package\n\n manifest -. \"component options FQNs<br/>read on the next synthesis\" .-> generator\n docgen[\"docgen<br/>jsii-docgen → API.md\"]\n manifest --> docgen\n\n classDef artifact fill:#eef,stroke:#88a\n class generated,projenfiles,lib,manifest,dist artifact\n```\n\nThe dashed edge is the part worth knowing about: `ProjectGenerator` reads the committed `.jsii`\nmanifest to resolve component options types, so the manifest produced by `compile` feeds the *next*\nsynthesis. This is why `.jsii` is committed rather than ignored. A component options type that is\nmissing from the manifest is reported as a warning and its options property is left out of the\ngenerated interface, which is expected only while a new component is being introduced: compile once,\nthen synthesize again.\n\n`package` runs `package:js` on CI and `package-all` locally; both end up in `jsii-pacmak`.\n`docgen` is not part of `build` and has to be run explicitly after the manifest changes.\n"
|
|
4200
4200
|
},
|
|
4201
4201
|
"repository": {
|
|
4202
4202
|
"type": "git",
|
|
@@ -21397,6 +21397,6 @@
|
|
|
21397
21397
|
"symbolId": "src/components/vitest:VitestOptions"
|
|
21398
21398
|
}
|
|
21399
21399
|
},
|
|
21400
|
-
"version": "0.
|
|
21401
|
-
"fingerprint": "
|
|
21400
|
+
"version": "0.5.1",
|
|
21401
|
+
"fingerprint": "lRTyhf+ZhOeupjIiVw+BEiEh09V9s7tiv8V/ZXRJZaQ="
|
|
21402
21402
|
}
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Projen project types with standard configuration for consistent project setup ac
|
|
|
8
8
|
pnpm add -D @nikovirtala/projen-constructs projen constructs
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Requires pnpm 12 and `projen`
|
|
11
|
+
Requires pnpm 12 and `projen` ^0.104.23. `@mrgrain/cdk-esbuild` and `constructs` are peer
|
|
12
12
|
dependencies as well.
|
|
13
13
|
|
|
14
14
|
To create a project from scratch:
|
|
@@ -65,11 +65,42 @@ Projen renders three configs, and none of them should be edited directly:
|
|
|
65
65
|
the editor use, and the one `tsconfigDev` points at.
|
|
66
66
|
- `projenrc/tsconfig.json` covers `.projenrc.ts`.
|
|
67
67
|
|
|
68
|
+
### Native TypeScript
|
|
69
|
+
|
|
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.
|
|
75
|
+
|
|
76
|
+
Code in these projects must therefore:
|
|
77
|
+
|
|
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`
|
|
86
|
+
|
|
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.
|
|
89
|
+
|
|
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`.
|
|
92
|
+
|
|
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`.
|
|
96
|
+
|
|
68
97
|
## Customization
|
|
69
98
|
|
|
70
99
|
Override any option by passing it to the constructor:
|
|
71
100
|
|
|
72
101
|
```typescript
|
|
102
|
+
import { JsiiProject } from "@nikovirtala/projen-constructs";
|
|
103
|
+
|
|
73
104
|
const project = new JsiiProject({
|
|
74
105
|
name: "my-project",
|
|
75
106
|
repositoryUrl: "https://github.com/nikovirtala/my-project.git",
|
|
@@ -120,7 +151,7 @@ import { AwsCdkTypeScriptAppProject } from "@nikovirtala/projen-constructs";
|
|
|
120
151
|
|
|
121
152
|
const project = new AwsCdkTypeScriptAppProject({
|
|
122
153
|
name: "my-cdk-app",
|
|
123
|
-
|
|
154
|
+
repository: "https://github.com/nikovirtala/my-cdk-app.git",
|
|
124
155
|
});
|
|
125
156
|
|
|
126
157
|
project.synth();
|
|
@@ -146,7 +177,7 @@ import { TypeScriptProject } from "@nikovirtala/projen-constructs";
|
|
|
146
177
|
|
|
147
178
|
const project = new TypeScriptProject({
|
|
148
179
|
name: "my-typescript-project",
|
|
149
|
-
|
|
180
|
+
repository: "https://github.com/nikovirtala/my-typescript-project.git",
|
|
150
181
|
});
|
|
151
182
|
|
|
152
183
|
project.synth();
|
|
@@ -161,7 +192,7 @@ The package includes reusable components for common development tasks:
|
|
|
161
192
|
[Vitest](https://vitest.dev) testing framework component.
|
|
162
193
|
|
|
163
194
|
```typescript
|
|
164
|
-
import { Vitest } from "@nikovirtala/projen-constructs";
|
|
195
|
+
import { Vitest, CoverageProvider, CoverageReporter } from "@nikovirtala/projen-constructs";
|
|
165
196
|
|
|
166
197
|
new Vitest(project, {
|
|
167
198
|
vitestVersion: "^5",
|
|
@@ -179,6 +210,8 @@ For Vitest settings that `config` doesn't cover, use `extraTestConfig` (merged i
|
|
|
179
210
|
`extraConfig` (top-level options next to `test`):
|
|
180
211
|
|
|
181
212
|
```typescript
|
|
213
|
+
import { Vitest } from "@nikovirtala/projen-constructs";
|
|
214
|
+
|
|
182
215
|
new Vitest(project, {
|
|
183
216
|
extraTestConfig: {
|
|
184
217
|
setupFiles: ["test/setup.ts"],
|
|
@@ -309,7 +342,7 @@ new LambdaFunctionCodeBundle(project, {
|
|
|
309
342
|
Generates TypeScript project classes with standard configuration.
|
|
310
343
|
|
|
311
344
|
```typescript
|
|
312
|
-
import { ProjectGenerator, ProjectType } from "@nikovirtala/projen-constructs";
|
|
345
|
+
import { ProjectGenerator, ProjectType, Mise, Vitest } from "@nikovirtala/projen-constructs";
|
|
313
346
|
|
|
314
347
|
new ProjectGenerator(project, {
|
|
315
348
|
name: "TypeScriptProject",
|
|
@@ -360,7 +393,7 @@ get new features or fixes. Every class, interface, enum and function they export
|
|
|
360
393
|
import { Vitest } from "@nikovirtala/projen-constructs";
|
|
361
394
|
```
|
|
362
395
|
|
|
363
|
-
2. Check the peer dependencies. `@nikovirtala/projen-constructs` needs `projen` ^0.104, `constructs`
|
|
396
|
+
2. Check the peer dependencies. `@nikovirtala/projen-constructs` needs `projen` ^0.104.23, `constructs`
|
|
364
397
|
^10 and `@mrgrain/cdk-esbuild` ^5. The standalone packages accepted older projen versions, so you
|
|
365
398
|
may have to upgrade projen in the same change.
|
|
366
399
|
3. Install the new package, run `npx projen` and review the changes to the generated files.
|
|
@@ -417,13 +450,16 @@ import { AwsCdkTypeScriptAppProject } from "@nikovirtala/projen-constructs";
|
|
|
417
450
|
const project = new AwsCdkTypeScriptAppProject({ name: "my-app", cdkVersion: "2.221.0" });
|
|
418
451
|
```
|
|
419
452
|
|
|
420
|
-
Both are ES module apps
|
|
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)).
|
|
421
457
|
|
|
422
458
|
- **`nvm` is removed.** Use mise (on by default), which pins the Node.js version in `mise.toml`.
|
|
423
459
|
- **Homebrew is on by default.** The project gets a `Brewfile`, and `npx projen` runs
|
|
424
460
|
`install:homebrew` (installs Homebrew if `brew` is missing) and `homebrew:bundle`. Set
|
|
425
461
|
`homebrew: false` to turn it off.
|
|
426
|
-
- **cdk.json `app`** is `
|
|
462
|
+
- **cdk.json `app`** is `node src/main.ts` instead of `tsx --tsconfig tsconfig.json src/main.ts`.
|
|
427
463
|
- **Defaults** come from this library: Node.js, TypeScript, CDK and pnpm versions (pnpm 12 instead
|
|
428
464
|
of 10), Dependabot off, auto-merge on, `auto-approve` and `auto-merge` labels on dependency
|
|
429
465
|
upgrade PRs, and auto-approval of PRs by `nikovirtala`. Any option you set explicitly still wins,
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
--dark-hl-2: #CE9178;
|
|
8
8
|
--light-hl-3: #0000FF;
|
|
9
9
|
--dark-hl-3: #569CD6;
|
|
10
|
-
--light-hl-4: #
|
|
11
|
-
--dark-hl-4: #
|
|
10
|
+
--light-hl-4: #AF00DB;
|
|
11
|
+
--dark-hl-4: #C586C0;
|
|
12
12
|
--light-hl-5: #001080;
|
|
13
13
|
--dark-hl-5: #9CDCFE;
|
|
14
|
-
--light-hl-6: #
|
|
15
|
-
--dark-hl-6: #
|
|
16
|
-
--light-hl-7: #
|
|
17
|
-
--dark-hl-7: #
|
|
14
|
+
--light-hl-6: #0070C1;
|
|
15
|
+
--dark-hl-6: #4FC1FF;
|
|
16
|
+
--light-hl-7: #098658;
|
|
17
|
+
--dark-hl-7: #B5CEA8;
|
|
18
18
|
--light-hl-8: #008000;
|
|
19
19
|
--dark-hl-8: #6A9955;
|
|
20
20
|
--light-hl-9: #CD3131;
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
<section class="tsd-panel">
|
|
14
14
|
<ul class="tsd-signatures">
|
|
15
15
|
<li class="">
|
|
16
|
-
<div class="tsd-signature tsd-anchor-link" id="applydefaults"><span class="tsd-kind-call-signature">applyDefaults</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">project</span><span class="tsd-signature-symbol">:</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">
|
|
16
|
+
<div class="tsd-signature tsd-anchor-link" id="applydefaults"><span class="tsd-kind-call-signature">applyDefaults</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">project</span><span class="tsd-signature-symbol">:</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">AwsCdkTypeScriptApp</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">TypeScriptProject</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">AwsCdkConstructLibrary</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">JsiiProject</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">components</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Component</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span><a href="#applydefaults" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div>
|
|
17
17
|
<div class="tsd-description">
|
|
18
18
|
<div class="tsd-parameters">
|
|
19
19
|
<h4 class="tsd-parameters-title">Parameters</h4>
|
|
20
20
|
<ul class="tsd-parameter-list">
|
|
21
|
-
<li><span><span class="tsd-kind-parameter">project</span>: <span class="tsd-signature-type">
|
|
21
|
+
<li><span><span class="tsd-kind-parameter">project</span>: <span class="tsd-signature-type">AwsCdkTypeScriptApp</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">TypeScriptProject</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">AwsCdkConstructLibrary</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">JsiiProject</span></span></li>
|
|
22
22
|
<li><span><span class="tsd-kind-parameter">components</span>: <span class="tsd-signature-type">Component</span><span class="tsd-signature-symbol">[]</span></span></li></ul></div>
|
|
23
23
|
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></div></li></ul></section></div>
|
|
24
24
|
<div class="col-sidebar">
|