create-duffel-app
Work in progress!
TODO:
A scaffolding script to bootstrap a fullstack duffel app
The script will guide you through setting up a minimal fullstack application with Duffel API. At the end of the script, you will have:
- A ready-to-go client and server that can talk to each other locally
- A Duffel API SDK installed and configured with the provided access token
- A code example demonstrating how to make a simple flight search using the Duffel API SDK
Boilerplate source:
Getting started
Get the right NodeJS version
If you use nvm
, run nvm use
. If you use asdf
, run asdf install
.
Install Yarn
Like all Duffel front-ends, this project uses yarn
. If you don't already have it, nstall it globally with npm install --global yarn
.
Start developing
yarn dev
This will start a typescript watcher that will regenerate index.js
. The scaffold can be run by running node index.js
or by linking the package with yarn, just like the following section.
Testing the generated app
Scaffold the sample app by running
yarn build && yarn link
chmod +x .yarn/bin/create-duffel-app
yarn create duffel-app
This will create an app with two folders: client
and server
. Then to run the server:
yarn start:dev
chmod +x ./bin/setup.sh && ./bin/setup.sh
flask run
After this, the server will be running at http://localhost:3001.
Then to run the client, open a separate terminal and run
yarn start
Committing to the repository
To be able to publish the correct version to npm, this project is currently following Angular conventional commit message guidelines which is based on conventional commits. This commit message guideline allows the semantic-release GitHub action to be triggered.
CommitLint to the rescue
Before creating a commit you should run a husky hook which will check if the commit structure is valid or not. If you don't want to create the commit manually, you can use yarn commit
which will use commitzen
to help you out creating the message.
Client CI
Every time a commit is merged to main, a GitHub Action is run to analyse the commit messages with semantic-release
and automatically update the current version to be deployed by following semantic versioning. When the deployment is complete, the action updates the package version, using Duffel's machine user (@duffel-bot
) as the author, and this change will be automatically approved by the GitHub Action via the [autoapprove
workflow] (../.github/workflows/autoapprove.yml).
Continuous Integration
- Developer opens pull request to main
- Pull request is merged
- GitHub Actions are triggered and the commits are analysed
- if there's a breaking change, bump the major version
- if there's a feature commit, bump the minor version
- if there's a fix, bump the patch version
- Deploy the new version
a. Publish to npm
b. Create and push a git tag
c. Publish a GitHub release with the relevant commits and descriptions
- After the release is published then a pull request is automatically created and approved via a GitHub Action to bump the package version