App packaging tip for easier building
-
Wanted to share something I do for my packages; Using a
package.json
to manage various scriptsI use a
package.json
file with different scripts to achieve common Cloudron packaging tasks:- Building and pushing the Docker image
- Installing my application (Production or test)
- Updating my application (Production or test)
- Linting the code related to my package
It also offers a better portability for other potential developers (providing the Cloudron CLI as a dependency, etc.)
Here is an example of one:
{ "name": "io.cloudron.yourapp", "description": "Cloudron Yourapp application", "scripts": { "build": "bash scripts/build.sh", "format": "npx prettier . --write", "lint:shell": "npx shellcheck -x scripts/*.sh", "lint:apply": "npx shellcheck -f diff scripts/*.sh | git apply", "update:prod": "bash scripts/update.sh -l prod", "update:test": "bash scripts/update.sh -l test", "prepare": "husky" }, "devDependencies": { "husky": "^9.0.11", "prettier": "^3.3.1", "cloudron": "^5.5.0", "shellcheck": "^2.2.0" } }
Apart from a
package.json
, I also ship all of my packages repos with files such as.editorconfig
and.prettierrc
to help uniformize my different packages. -
@girish
.editorconfig
for => https://editorconfig.org/ && VSCODE and.prettierrc
for => https://prettier.io/docs/en/configuration.html
Some quality of life files that makes coding and style consistent with editor automation.
They are considered personnel files, since another user fight have different preferences about style and so on.
But in a given shared project sense this can also be a foundation on how the style is meant to be. -
To make it more clear, I have made a template repository with all the files and scripts I usually use for my Cloudron apps.
In the future, we might benefit from adopting such a strategy for the Cloudron CLI
init
script by using these files as a template/starter Cloudron app project. It'd make maintenance easier, more uniform, and make the process less daunting for new app devs.