How to add an application to BeeScreens¶
Adding a new application to BeeScreens is a relatively simple process. This guide will walk you through the steps to add a new application to BeeScreens.
You'll use pnpm to add your application to the existing workspace.
Then, you'll add all related commands to Husky to ensure that your application is always in a working state before you push your changes to the remote Git repository.
Finally, you'll set up the GitLab CI/CD pipeline to ensure that your application is always in a working state before merging your changes on the main branch.
Steps¶
Create a new directory for your application¶
Create a new directory in the apps
directory of the BeeScreens Git repository. The name of the directory will be the name of your application.
Create the directories of your application's services¶
If your application has multiple services, create a directory for each service in the directory of your application. The name of the directory will be the name of the service.
For example, if your application has a frontend and a backend, you will have the following structure:
Create or initialize the services' package.json
files¶
For each service, create a package.json
file. You can use the pnpm init
command to initialize the file if you want. Consider following the pnpm - package.json structure documentation to make your own package.json
file.
Name the package with the following convention: @beescreens/<application-name>-<service-name>
.
Your application should have the following structure:
Optional: Create a package for your application¶
If you want, you can create a package for your application. This is useful if you want to share your application with other developers or if you want to release a package to allow the usage of your application on the npm registry.
Your application will be able to use the package as a dependency inside the same workspace.
Create a new directory in the packages
directory of the BeeScreens Git repository. The name of the directory will be the name of your package.
Initialize the package.json
file with the pnpm init
command.
Name the package with the following convention: @beescreens/<application-name>
.
Your package should have the following structure:
Add all directories to the pnpm workspace¶
Add the services to the workspace in the pnpm-workspace.yaml
file.
If you created a package for your application, add it to the workspace as well.
Your pnpm-workspace.yaml
file should look like this:
pnpm-workspace.yaml | |
---|---|
Check if the workspace is valid¶
If you used the pnpm init
command to initialize the package.json
files, a default test
script was added to the scripts
section of the files. You can use this script to check if the workspace is valid with the following command:
In a terminal, execute the following command(s). | |
---|---|
The output of the command should look like this:
Output of the command | |
---|---|
If used with the --parallel
flag, the output of the command should look like this:
Set up the local CI/CD pipeline with Husky¶
Add the commands to test your application to the local CI/CD pipeline with Husky in the .husky/pre-push
file. The did_files_change_in_directory
function allows to run the pnpm commands only if changes were made in the corresponding directory.
.husky/pre-push | |
---|---|
Set up the remote CI/CD pipeline with GitLab CI/CD¶
Add your own GitLab CI/CD configuration file to the .gitlab/ci_cd
directory under the name .gitlab/ci_cd/my-app.yml
. The extends: .test
line extends the definition of the .gitlab/ci_cd/templates/test.yml
template file.
Add your new file to the main .gitlab/ci_cd/main.yml
configuration file.
Commit your changes and push them to the remote repository¶
Commit your changes and push them to the remote repository using the workflow described in the Become a BeeScreens contributor tutorial and the How to contribute to BeeScreens guide.
Check the results¶
On push, Husky should run the local CI pipeline for your application.
On merge request, GitLab CI/CD should run the remote CI pipeline. You can check the results in the GitLab CI/CD pipelines section.
Summary¶
Congrats! You have successfully added your application to the BeeScreens repository.
Locally, pnpm can manage your workspace from anywhere in the repository. pnpm tracks all the available commands and can call any scripts you'd like to run.
Before a push, Husky will run the tests for your application to ensure that your changes do not break the application before sharing your changes to the remote Git repository.
Remotely, on merge request, GitLab CI/CD will run the tests for your application to ensure that your changes do not break the application.
You can have a look at the existing applications to improve your applications and pipelines and start creating an amazing new application!
Related explanations¶
These explanations are related to the current item (in alphabetical order).
Resources and alternatives¶
These resources and alternatives are related to the current item (in alphabetical order).
None at the moment.