~
~ '
` (O) ~
H '
~ H
` ____hHh____
~ `---------' ~
` | | | '
| | |
| | |
| | |
| | |
| | |
| | |
| | |
_____;~~~~~:____
__' \
/ \ |
| _\\_ | |\
| \\ | | | ___
__ / __ | | | _/ \
/__\ |_____/__\____|_________|__\ /__\___\
This project was bootstrapped with Avalon.
root
├── README.md...........................................................README of your project.
├── docker..............................................................Dockerfiles to execute commands (Use them via scripts).
│ ├── build.Dockerfile................................................Dockerfile used to execute to compile the project using TypeScript.
│ ├── ci.Dockerfile...................................................Dockerfile used for the CI step.
│ ├── format.Dockerfile...............................................Dockerfile used run prettier.
│ ├── install.Dockerfile..............................................Dockerfile used to install the node_modules of the project.
│ ├── release.Dockerfile..............................................Dockerfile used for the CD step.
│ ├── start-development.Dockerfile....................................Dockerfile used to compile to compile the project using TypeScript and watch for changes.
│ ├── test.Dockerfile.................................................Dockerfile used to execute the test runner.
│ └── watch-tests.Dockerfile..........................................Dockerfile used to execute the test runner and watch for changes.
├── library
│ ├── LICENSE.........................................................Software License.
│ ├── jest.config.js..................................................Test runner configuration.
│ ├── package.json....................................................Defines name, version and project dependencies.
│ ├── source..........................................................Actual library source code.
│ │ ├── environment.d.ts............................................Global typings.
│ │ └── index.ts....................................................Source code entrypoint.
│ ├── test............................................................Tests directory.
│ │ └── index.test.ts
│ ├── tsconfig.json...................................................TypeScript compiler configuration.
│ └── tsconfig.production.json........................................TypeScript compiler configuration for release.
├── .avaloncli.json.....................................................Avalon CLI configuration file. Contains metadata about the artifact (Internal).
├── .gitignore..........................................................Filters out unnecesary files from your Git commits.
└── scripts.............................................................Bash scripts used to interact with the codebase. It uses the docker directory files under the hood.
├── build.sh........................................................Script to build the project.
├── ci.sh...........................................................Script to build and test the project during the CI step.
├── format.sh.......................................................Script to format the project.
├── install.sh......................................................Script to install the project.
├── release.sh......................................................Script to release the project during the CD step.
├── start-development.sh............................................Script to start development.
├── test.sh.........................................................Script to tests.
└── watch-tests.sh..................................................Script to watch tests.
Installs the library dependencies (AKA your node_modules):
bash ./scripts/install.sh
alternatively you can run the script using the Avalon CLI:
avalon install
Runs npm commands:
bash ./scripts/npm.sh
alternatively you can run the script using the Avalon CLI:
avalon npm [NPM_ARGUMENTS]
Compiles your source code using the 🧙♂️ TypeScript compiler and re-compiles on changes:
bash ./scripts/start-development.sh
alternatively you can run the script using the Avalon CLI:
avalon develop
Executes the 🃏 Jest test runner:
bash ./scripts/test.sh
alternatively you can run the script using the Avalon CLI:
avalon test
Note: 💡 You can use a custom test file path as well:
bash ./scripts/test.sh tests/some-test.spec.ts
avalon test tests/some-test.spec.ts
Executes the 🃏 Jest test runner and watches for changes:
bash ./scripts/watch-tests
alternatively you can run the script using the Avalon CLI:
avalon watch-tests
Formats your source code using 💅 Prettier:
bash ./scripts/format.sh
alternatively you can run the script using the Avalon CLI:
avalon format
Compiles your source code using the 🧙♂️ TypeScript compiler:
bash ./scripts/build.sh
alternatively you can run the script using the Avalon CLI:
avalon build
Note: 💡 The scripts for CI (ci.sh
) and Release(release.sh
) are meant to be used via GitHub actions.
Git hooks are a mean to fire off custom scripts when certain important actions occur while performing 🌳 Git actions. Git hooks are located in the .git/hooks
where each file represents a different hook.
Avalon sets up two client-side hooks:
pre-commit
: Will format files beforegit commit
.pre-push
:- Will prevent any
git push
action tomaster
/main
/dev
branches. - Will format files before
git push
.
- Will prevent any
CI/CD is a modern software development practice in which incremental changes are made frequently and then the code is delivered quickly. It is a way to provide value to customers efficientlly by using automations to shorten the release cycles.
The CI (Continous Integration) part is about integrating changes into our system in a safe way.
Source code needs to live in a centralized repository where developers will constantly push code.
A dedicated server will know when code is pushed to this repository and will check the source code by building the project and running its tests.
The build server will send the results to the responsible developer when they are ready, closing the loop of feedback.
To perform the CI step in your project, you only need to push code to the repository.
- Changes are pushed to the GitHub repository.
- The CI GitHub action (
.github/workflows/ci.yml
). - The CI GitHub actions executes a
build
step. - The
build
step executes thescripts/ci.sh
script which builds a Docker image using thedocker/ci.Dockerfile
Dockerfile. - When building the Docker image, the project is copied and built inside the Docker image.
- After building the Docker image, the
scripts/ci.sh
script creates a new Docker container using that image. - The new Docker container executes the test runner.
- The test runner finishes running the tests and results are delivered to us via the GitHub UI.
The CD (continous delivery) part is an extension of CI (Continous Integration). It's about automatically deploying all code changes after the build stage.
Software releases are automated however the team can decide the frequency of these releases (Weekly, Biweekly, etc.).
To publish your project to npm, you only need to create a new GitHub release.
The CD GitHub action needs to be provided with an NPM_AUTH_TOKEN
to perform actions in your behalf during the release
step. Access tokens are an alternative to using username and passwords for authenticating in npm when using the CLI.
- Create an npm auth. token (The automation token type is recommended for this).
- Store the the obtained auth. token your GitHub repository's secrets.
-
build:
- A new GitHub release is created.
- The CD GitHub action (
.github/workflows/cd.yml
) is triggered. - The
build
step executes thescripts/ci.sh
script which builds a Docker image using thedocker/ci.Dockerfile
Dockerfile. - When building the Docker image, the project is built inside the Docker image.
- After building the Docker image, the
scripts/ci.sh
script creates a new Docker container using that image. - The new Docker container executes the test runner.
- The test runner finishes running the tests and moves to the
release
step.
-
release:
- The
release
step executes thescripts/release.sh
script (passing theNPM_AUTH_TOKEN
) which builds a Docker image using thedocker/release.Dockerfile
Dockerfile. - When building the Docker image, the source code is copied inside the Docker image.
- After building the Docker image, the
scripts/release.sh
script creates a new Docker container using that image. - The new Docker container executes the instructions needed to publish the artifact to the npm registry.
- The new Docker container finishes publishing the artifact and returns some results to us via the GitHub UI.
- The