Starting new projects
development, productivity, tips UpdatedGetting started on a new project can be fun and exciting but there can also be a lot of initial setup and plumbing required which can sometimes be quite tedious. Here are some of the tips, tricks, and templates I use to bootstrap a new project so I can get to the fun stuff sooner.
Version control #
The first step for most projects is to setup version control, my preference is git
.
In my dotfiles I have some git defaults configured to help set things up the way I want, for example, the default branch that's created should be main
instead of master
:
# ~/.gitconfig
[init]
defaultBranch = main
I also have my user name, email, and some other things configured so I don't have to do this manually. Starting a new repo is as simple as:
git init [project-name]
Common files #
Generate a README.md
file for your npm packages with @alangreene/readme
npx @alangreene/readme
It fills out a template with data from your package.json
. Once generated you can edit as needed to suit the project.
Some other things to consider include .gitignore
, CONTRIBUTING.md
, DEVELOPMENT.md
, LICENSE
.
Hat tip to Tierney Cyren for the following:
npx license $(npm get init-license)
npx gitignore node
npx covgen <email> # adds the Contributor Covenant to `CODE_OF_CONDUCT.md`
npm init -y
npx license
accepts some optional args to override its default behaviour:
--name
: defaults to name from git config, or$USER
--email
: defaults to email from git config--projectName
: defaults to folder name
Node.js #
Similar to my git
config, I also have some npm defaults configured to speed things up so I can run:
npm init -y
For a scoped package add --scope=<scope>
, for example:
npm init -y --scope=@alangreene
- TODO: document common starter setup with Prettier, ESLint, Jest, etc.
- TODO: refactor init scripts as
@alangreene/create
for use asnpm init @alangreene
- alternatively, split out sub-types as
@alangreene/create-<name>
for use asnpm init @alangreene/<name>
- NOTE: to pass additional args to the initialiser:
npm init <name> -- <args>
- see https://docs.npmjs.com/cli/v6/commands/npm-init (also
-w
for workspaces innpm@7
, compare toyarn
workspaces)
- alternatively, split out sub-types as
Templates #
GitHub now provides support for creating repositories from templates.
- TODO: cleanup and publish Eleventy + Tailwind template
- TODO: create homelab Docker / Kubernetes template