create-cdkts
v0.1.2
Published
Command Line utility to bootstrap a TypeScript CDK project
Downloads
38
Readme
create-cdkts
The fastest way to bootstrap a Typescript CDK configuration with modern tooling into an existing project, or a new project! Uses opinionated defaults to give you a modern development environment.
How
Getting Started
Run the following command in your project root to bootstrap a CDK configuration with minimal defaults
npm
npm create cdkts --yesyarn
yarn create cdkts --yespnpm
pnpm create cdkts --yesnpx
npx create-cdkts@latest --yesIncludes modern tools and configuration including:
tsx- TypeScript Execute - Easiest way to run TypeScript in Node.js https://tsx.is/biome- Biome - Rust based formatting tooling https://biomejs.dev/oxlint- OXC Linter - Rust based linter with eslint compatibility https://oxc.rslefthook- Lefthook - Rust based Git hooks manager https://github.com/evilmartians/lefthook
This will install the minimal required dependencies, with a minimal configuration into your existing project. It will
- add your CDK files to the a directory called
cdk/ - add a
tsconfig.jsonto your project root that works with CDK. - create a
cdk.jsonfile in your project root - add a
deployscript to yourpackage.json - Add Vitest as a test runner and a
testscript to run it - Add Biome for formatting and a
formatscript to run it - Add OXC linter (oxlint) for linting and a
lintscript to run it - Add Lefthook for Git hooks management, and install a
pre-commithook withlintandformatcommands
The default configuration will install vitest, oxlint, lefthook, biome and tsx frameworks, but you can optionally only install what you need.
Using Rust based tooling with first class TypeScript support providing performance, compatibility and overall a better developer experience.
Help
You can get the basic create-cdkts options by running
npx create-cdkts --helpThis will output the following
create cdk typescript
=====================================
Usage: npx create-cdkts [options]
If no options are specified the CLI will enter interactive mode and ask
configuration questions.
Basic options:
-c, --config <filename> Use a config file instead of CLI
options
-n, --name <string> CDK project name, will default to
project root directory name
-r, --root <dirname> The root directory of the project you
want to configure CDK for. Defaults
to the current working directory.
-d, --dir <dirname> Directory to write CDK template
files to. Defaults to "./cdk"
-t, --test <vitest|jest|none> Which test framework to include.
Default is none.
-p, --package-manager <npm|yarn|pnpm|auto>
Explicitely specify the package
manager to use when installing
dependencies. Valid options are npm,
yarn, pnpm and auto detect. Defaults
to auto. If unable to detect any, will
use npm.
-ox, --oxlint <Yes|no> Use Oxlint for linting. Default: Yes
-b, --biome <Yes|no> Use Biome for formatting. Default: Yes
-l, --lefthook <Yes|no> Use Lefthook for Git hooks. Default: Yes
-y, --yes Run using all the default settings.
-h, --help Show this help message
Examples:
# scaffold a CDK project in the directory 'new-project' to use ES modules
# with the CDK files placed in ./src/cdk/ directory
npx create-cdkts --root new-project/ --dir src/cdk
Notes:
* If the root directory specified already has a package.json file it will
integrate with the existing project and add config into package.json
* If it detects that there is an existing CDK configuration it will abort
installation. This behaviour can be toggled with the --overide option
* The CLI will attempt to determine which package manager is in use on the
project, if it can't it will default to npm. This behaviour can be
overridden explicitely through to -p option.
Why
Why create a new bootstrap for CDK projects? CDK has it's own bootstrap command, but it's limited.
create-cdkts allows you to integrate CDK into an existing project easily in a more flexible way. This is ideal when wanting to migrate to CDK, or use CDK to deploy the infrastructure for modern web frameworks.
Optional test framework.
Options are vitest, jest or none. If your project is already using a test framework, it won't force one on your. It also adds support for vitest which has better TypeScript support, and is more performant than jest
Package Manager Detection
It can detect which package manager is being used, and install dependencies using your preferred package manager. It has support for npm, yarn and pnpm
Smaller footprint
The default CDK App bootstrap creates multiple files and folders, many of which are unnecessary. create-cdkts has a smaller footprint that makes it easy to add and remove it from an existing project.
What it does
Creates a single directory with default name
cdk/, that you can change, containingcdk.tswhich is your CDK App entry file. This is the entry point into your CDK config will usestack.tsa simple example CDK stack configuration
Adds
cdk.jsonfile to the root of your project, that is configured to use thetsconfig.jsonconfiguration andcdk.tsentry point in your CDK directory. This file usestsxoverts-nodeto invoke CDK.If a
tsconfig.jsonconfiguration exists in your project root folder it will update it to add your CDK directory to theexcludesproperty.Add a script called
deploywith the valuecdk deploy -allto yourpackage.jsonso you can typenpm run deployto trigger a CDK deploy.Install the following base development dependencies using the package manager already in use in the project.
aws-cdk@latest aws-cdk-lib@latest typescript@latest constructs@latest tsx@latestDepending on test framework it will install either
vitest@latestif Vitest is selectedjest@latest ts-jest@latestif Jest is selected- Add a
jest.config.jsonfile to the project root ifjestis selected
Adds the following dependencies by default with the ability to optionally exclude them
@biomejs/biome@latestoxlint@latestlefthook@latest
Update .gitignore and .npmignore in the root of your project to exclude CDK working directories
Roadmap
- [ ] Add interactive install options
