Run apex parsing server in docker to speed up apex formatting with prettier.
docker run -it -p 2117:2117 ziemniakoss/prettier-apex-server:latest
And after that whenever you run prettier, add these flags:
--apex-standalone-parser built-in
Make sure that you have these dependencies and scripts in package.json
"devDependencies": {
"prettier": "^2.8.1",
"prettier-plugin-apex": "^1.12.0",
"wait-on": "^6.0.1"
},
"scripts": {
"preprettier-check": "wait-on http://127.0.0.1:2117/api/ast/",
"prettier-check": "prettier --apex-standalone-parser built-in --list-different ."
}
After that, add prettier apex server definition to bitbucket-pipelines.yml
image: atlassian/default-image:3
definitions:
services:
prettier-apex:
image: ziemniakoss/prettier-apex-server:latest # or your selected version
pipelines:
default:
- step:
name: "Validate with prettier"
services:
- docker
- prettier-apex
caches:
- docker
script:
- npm ci
- npm run prettier-check
Just like in bitbucket, this can be implemented using service containers