Skip to main content

CDK for software projects

Project description

projen

Define and maintain complex project configuration through code.

Documentation · Changelog · Project types · Join the community

Apache 2.0 License Gitpod ready-to-code Build badge Release badge Commit activity


projen synthesizes project configuration files such as package.json, tsconfig.json, .gitignore, GitHub Workflows, eslint, jest, etc from a well-typed definition written in JavaScript.

As opposed to existing templating/scaffolding tools, projen is not a one-off generator. Synthesized files should never be manually edited (in fact, projen enforces that). To modify your project setup, users interact with rich strongly-typed class and execute projen to update their project configuration files.

By defining a custom project type and using projen in multiple repositories, it's possible to update configuration files and CI/CD workflows across dozens (or hundreds!?) of projects.

Check out this talk about projen from its creator.

Getting Started

projen doesn't need to be installed. You will be using npx to run projen which takes care of all required setup steps.

To create a new project, run the following command and follow the instructions:

$ mkdir my-project
$ cd my-project
$ npx projen new PROJECT-TYPE
🤖 Synthesizing project...
...

Project types

Currently supported project types (use npx projen new without a type for a full list):

Built-in: (run npx projen new <type>)

External: (run npx projen new --from <type>)

Use npx projen new PROJECT-TYPE --help to view a list of command line switches that allows you to specify most project options during bootstrapping. For example: npx projen new jsii --author-name "Jerry Berry".

The new command will create a .projenrc.js file which looks like this for jsii projects:

const { JsiiProject } = require('projen');

const project = new JsiiProject({
  authorAddress: "elad.benisrael@gmail.com",
  authorName: "Elad Ben-Israel",
  name: "foobar",
  repository: "https://github.com/eladn/foobar.git",
});

project.synth();

This program instantiates the project type with minimal setup, and then calls synth() to synthesize the project files. By default, the new command will also execute this program, which will result in a fully working project.

Once your project is created, you can configure your project by editing .projenrc.js and re-running npx projen to synthesize again.

The files generated by projen are considered an "implementation detail" and projen protects them from being manually edited (most files are marked read-only, and an "anti tamper" check is configured in the CI build workflow to ensure that files are not updated during build).

For example, to setup PyPI publishing in jsii projects, you can use python option:

const project = new JsiiProject({
  // ...
  python: {
    distName: "mydist",
    module: "my_module",
  }
});

Run:

npx projen

And you'll notice that your package.json file now contains a python section in its jsii config and the GitHub release.yml workflow includes a PyPI publishing step.

We recommend to put this in your shell profile, so you can simply run pj every time you update .projenrc.js:

alias pj='npx projen'

Most projects come with an assortment of tasks that handle various development activities, from compiling to publishing. Tasks can be and composed together, and can be run as local commands or turned into GitHub workflows. You can list all tasks with npx projen --help:

$ npx projen --help
projen [command]

Commands:
  projen new [PROJECT-TYPE-NAME] [OPTIONS]  Creates a new projen project
  projen clobber                            hard resets to HEAD of origin and cleans the local repo
  projen compile                            Only compile
  projen test                               Run tests
  projen build                              Full release build (test+compile)
  projen upgrade                            upgrade dependencies (including projen)
...

The build task is the same task that's executed in your CI builds. It typically compiles, lints, tests and packages your module for distribution.

Shell Completions

If installed as a global package, projen includes rich shell tab-completion support. To enable this in your shell, run:

# Bash
projen completion >> ~/.bashrc

# ZSH
projen completion >> ~/.zshrc

Features

Some examples for features built-in to project types:

  • Fully synthesize package.json
  • Standard npm scripts like compile, build, test, package
  • eslint
  • Jest
  • jsii: compile, package, api compatibility checks, API.md
  • Bump & release scripts with CHANGELOG generation based on conventional commits
  • Automated PR builds
  • Automated releases to npm, maven, NuGet and PyPI
  • Automated dependency upgrades
  • Mergify configuration
  • LICENSE file generation
  • gitignore + npmignore management
  • Node "engines" support with coupling to CI build environment and @types/node
  • Anti-tamper: CI builds will fail if a synthesized file is modified manually

Documentation

For documentation including examples and a full API reference, visit https://projen.io/.

Ecosystem

projen takes a "batteries included" approach and aims to offer dozens of different project types out of the box (we are just getting started). Think projen new react, projen new angular, projen new java-maven, projen new awscdk-typescript, projen new cdk8s-python (nothing in projen is tied to javascript or npm!)...

Adding new project types is as simple as submitting a pull request to this repo and exporting a class that extends projen.Project (or one of its derivatives). Projen automatically discovers project types so your type will immediately be available in projen new.

Projects in external modules

projen is bundled with many project types out of the box, but it can also work with project types and components defined in external jsii modules (the reason we need jsii is because projen uses the jsii metadata to discover project types & options in projen new).

Say we have a module in npm called projen-vuejs which includes a single project type for vue.js:

$ npx projen new --from projen-vuejs

If the referenced module includes multiple project types, the type is required. Switches can also be used to specify initial values based on the project type APIs. You can also use any package syntax supported by yarn add like projen-vuejs@1.2.3, file:/path/to/local/folder, git@github.com/awesome/projen-vuejs#1.2.3, etc.

$ npx projen new --from projen-vuejs@^2 vuejs-ts --description "my awesome vue project"

Under the hood, projen new will install the projen-vuejs module from npm (version 2.0.0 and above), discover the project types in it and bootstrap the vuejs-ts project type. It will assign the value "my awesome vue project" to the description field. If you examine your .projenrc.js file, you'll see that projen-vuejs is defined as a dev dependency:

const { VueJsProject } = require('projen-vuejs');

const project = new VueJsProject({
  name: 'my-vuejs-sample',
  description: "my awesome vue project",
  // ...
  devDeps: [
    'projen-vuejs'
  ]
});

project.synth();

Roadmap

See Vision.

FAQ

Do I have to write my configuration in JavaScript?

Not at all! JavaScript is the default, but it's also possible to write it in Java, TypeScript, or even JSON. Python support is also planned. This is made possible by the jsii library which allows us to write APIs once and generate libraries in several languages. You can choose a different language by passing the --projenrc-ts, --projenrc-java, or --projenrc-json flags when running projen new.

Note: using a .projenrc.json file to specify configuration only allows accessing a subset of the entire API - the options which are passed to the constructor of each project type.

How does projen work with my IDE?

projen has an unofficial VS Code extension. Check it out!

Community

The projen community can be found within the #projen channel in the cdk.dev community Slack workspace.

Virtual Meetup

  • Thursday June 30, 2022
  • 1-2pm America/New_York (EDT)
  • CFP a Google Form
  • CFP Closes Saturday April 30, 2022
  • Hosted on Zoom

Contributions

Contributions of all kinds are welcome! Check out our contributor's guide and our code of conduct.

For a quick start, check out a development environment:

$ git clone git@github.com:projen/projen
$ cd projen
$ yarn
$ yarn watch # compile in the background

Thanks goes to these wonderful people (emoji key):

All Contributors

 Aatman
Aatman

💻
Adam Elmore
Adam Elmore

💻
Adrian Dimech
Adrian Dimech

💻
Adrian Mace
Adrian Mace

💻
Alexander Forsyth
Alexander Forsyth

💻
Alexander Steppke
Alexander Steppke

💻
Amani Kilumanga
Amani Kilumanga

💻
Amin Fazl
Amin Fazl

💻
Amir Szekely
Amir Szekely

💻
Andrew Hammond
Andrew Hammond

💻
Ansgar Mertens
Ansgar Mertens

💻
Arun Donti
Arun Donti

💻
Ash
Ash

💻
Balagopal Kanattil
Balagopal Kanattil

💻
Bart Callant
Bart Callant

💻
Bilal Quadri
Bilal Quadri

💻
Boris Petersen
Boris Petersen

💻
Brandon Miller
Brandon Miller

💻
Brian Leonard
Brian Leonard

💻
Calvin Combs
Calvin Combs

💻
Campion Fellin
Campion Fellin

💻
Chris Gatt
Chris Gatt

💻
Christopher Rybicki
Christopher Rybicki

💻
Cory Hall
Cory Hall

💻
Cristian Pallarés
Cristian Pallarés

💻
Daniel Schmidt
Daniel Schmidt

💻
Danny Steenman
Danny Steenman

💻
Eduardo Rodrigues
Eduardo Rodrigues

💻
Elad Ben-Israel
Elad Ben-Israel

💻
Eli Polonsky
Eli Polonsky

💻
Eugene Cheung
Eugene Cheung

💻
Grady Barrett
Grady Barrett

💻
Greg Herlein
Greg Herlein

💻
Hasan
Hasan

💻
Hassan Azhar
Hassan Azhar

💻
Hassan Mahmud
Hassan Mahmud

💻
Hassan Mahmud
Hassan Mahmud

💻
Heiko Rothe
Heiko Rothe

💻
Henri Yandell
Henri Yandell

💻
Henry Sachs
Henry Sachs

💻
Hoseung
Hoseung

💻
Ikko Ashimine
Ikko Ashimine

💻
Jack Stevenson
Jack Stevenson

💻
Jacob
Jacob

💻
Jake Pearson
Jake Pearson

💻
Jan Brauer
Jan Brauer

💻
Jeff Malins
Jeff Malins

💻
Jeremy Jonas
Jeremy Jonas

💻
JoLo
JoLo

💻
Jonathan Goldwasser
Jonathan Goldwasser

💻
Joost van der Waal
Joost van der Waal

💻
Jordan Sinko
Jordan Sinko

💻
Joseph Egan
Joseph Egan

💻
Josh Kellendonk
Josh Kellendonk

💻
Juho Saarinen
Juho Saarinen

💻
Julian Michel
Julian Michel

💻
Kaizen Conroy
Kaizen Conroy

💻
Kenneth Winner
Kenneth Winner

💻
Kraig Amador
Kraig Amador

💻
Kunal Dabir
Kunal Dabir

💻
Lex Felix
Lex Felix

💻
Manuel
Manuel

💻
Marcio Cruz de Almeida
Marcio Cruz de Almeida

💻
Mark McCulloh
Mark McCulloh

💻
Mark McCulloh
Mark McCulloh

💻
Mark Nielsen
Mark Nielsen

💻
Marnix Dessing
Marnix Dessing

💻
Martin Muller
Martin Muller

💻
Masashi Tomooka
Masashi Tomooka

💻
Matt Gucci
Matt Gucci

💻
Matt Martz
Matt Martz

💻
Matteo Sessa
Matteo Sessa

💻
Matthew Bonig
Matthew Bonig

💻
Matthew Gamble
Matthew Gamble

💻
Max Körlinge
Max Körlinge

💻
Mayur Mahrotri
Mayur Mahrotri

💻
Mike
Mike

💻
Mitchell Valine
Mitchell Valine

💻
Momo Kornher
Momo Kornher

💻
Neil Kuan
Neil Kuan

💻
Nick Lynch
Nick Lynch

💻
Nicolas Byl
Nicolas Byl

💻
Nikhil Zadoo
Nikhil Zadoo

💻
Niraj Palecha
Niraj Palecha

💻
Pahud Hsieh
Pahud Hsieh

💻
Patrick
Patrick

💻
Patrick Florek
Patrick Florek

💻
Philip M. Gollucci
Philip M. Gollucci

💻
Philipp Garbe
Philipp Garbe

💻
Rafal Wilinski
Rafal Wilinski

💻
Rico Huijbers
Rico Huijbers

💻
Rodrigo Farias Rezino
Rodrigo Farias Rezino

💻
Roger Chi
Roger Chi

💻
Romain Marcadier
Romain Marcadier

💻
Ryan Sonshine
Ryan Sonshine

💻
Samuel Tschiedel
Samuel Tschiedel

💻
Saud Khanzada
Saud Khanzada

💻
Sebastian Korfmann
Sebastian Korfmann

💻
Shawn MacIntyre
Shawn MacIntyre

💻
Suhas Gaddam
Suhas Gaddam

💻
Thomas Klinger
Thomas Klinger

💻
Thorsten Hoeger
Thorsten Hoeger

💻
Tiara
Tiara

💻
Tobias
Tobias

💻
Tom Howard
Tom Howard

💻
Tom Keller
Tom Keller

💻
Tomasz Łakomy
Tomasz Łakomy

💻
Travis Martensen
Travis Martensen

💻
Will Dady
Will Dady

💻
Yigong Liu
Yigong Liu

💻
Yohta Kimura
Yohta Kimura

💻
andrestone
andrestone

💻
codeLeeek
codeLeeek

💻
flyingImer
flyingImer

💻
huaxk
huaxk

💻
john-tipper
john-tipper

💻
karlderkaefer
karlderkaefer

💻
lmarsden
lmarsden

💻
michaeltimbs
michaeltimbs

💻
orlandronen1
orlandronen1

💻
pvbouwel
pvbouwel

💻

License

Distributed under the Apache-2.0 license.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

projen-0.71.160.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

projen-0.71.160-py3-none-any.whl (3.7 MB view details)

Uploaded Python 3

File details

Details for the file projen-0.71.160.tar.gz.

File metadata

  • Download URL: projen-0.71.160.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for projen-0.71.160.tar.gz
Algorithm Hash digest
SHA256 1faaf9155c93549e1b6ac35bb707d1f77d7ffa8cbd0591d2b0a78a55a885a51c
MD5 9d7e21f82dc3764ea2d8546812ef3535
BLAKE2b-256 e178381a82f7e35ead52b5fa7bb57fb4c3a5d051a73c44a04688355fbc8e311d

See more details on using hashes here.

File details

Details for the file projen-0.71.160-py3-none-any.whl.

File metadata

  • Download URL: projen-0.71.160-py3-none-any.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for projen-0.71.160-py3-none-any.whl
Algorithm Hash digest
SHA256 95529e32b029baf0fc9c35732a7c467462198004f2388c673413ccb0142baec4
MD5 de007433fb00cff6d16ca42ec0c011ff
BLAKE2b-256 d3681d7f1b0b1b84f7c6440ec2dc854028d4c1fe24af7efe4e3462676e33659b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page