| 1 | # Contributor: Michał Polański <[email protected]> |
| 2 | maintainer="Achill Gilgenast <[email protected]>" |
| 3 | pkgname=prettier |
| 4 | pkgver=3.8.4 |
| 5 | pkgrel=0 |
| 6 | pkgdesc="Opinionated code formatter" |
| 7 | url="https://prettier.io/" |
| 8 | license="MIT" |
| 9 | # armhf, armv7, x86: fails at "yarn install" with YN0001: │ Error: Couldn't allocate enough memory |
| 10 | # riscv64: crashes at "yarn install" fetch step |
| 11 | arch="noarch !armhf !armv7 !x86 !riscv64" |
| 12 | depends="nodejs" |
| 13 | makedepends="yarn cmd:timeout" |
| 14 | checkdepends="npm" |
| 15 | subpackages="$pkgname-doc" |
| 16 | source="https://github.com/prettier/prettier/archive/$pkgver/prettier-$pkgver.tar.gz |
| 17 | disable-oxc-and-hermes-plugin-tests.patch |
| 18 | " |
| 19 | options="net" # npm |
| 20 | |
| 21 | case $CARCH in |
| 22 | ppc64le | s390x) |
| 23 | # test run fails with: |
| 24 | # ● Validation Error: |
| 25 | # Module <rootDir>/tests/config/format-test-setup.js in the setupFiles option was not found. |
| 26 | # <rootDir> is: /builds/alpine/aports/community/prettier/src/prettier-3.6.2 |
| 27 | options="!check" |
| 28 | ;; |
| 29 | esac |
| 30 | |
| 31 | build() { |
| 32 | yarn install --frozen-lockfile |
| 33 | # since 3.6.0, prettier source includes two plugins: |
| 34 | # @prettier/plugin-hermes and @prettier/plugin-oxc. upstream packages |
| 35 | # them separately - we could too, but they are not loadable at runtime |
| 36 | # anyway because of https://github.com/prettier/prettier/issues/15141 . |
| 37 | # also, plugin-oxc requires a native rust dependency (oxc-parser), |
| 38 | # which prevents it from building on ppc64le and loongarch64. |
| 39 | # so, just disable the plugin builds (and their tests - see patch) |
| 40 | yarn build --package=prettier |
| 41 | } |
| 42 | |
| 43 | check() { |
| 44 | # tests occasionally hang forever; seems to be some process management |
| 45 | # problem in jest. --runInBand and clearing caches beforehand seems to |
| 46 | # help. |
| 47 | yarn test:production --clearCache |
| 48 | # snapshot tests expect outputs to be identical to the test run that |
| 49 | # generated them. since we patch the tests to disable oxc/hermes, that |
| 50 | # doesn't work for us, so we need to use `--updateSnapshot` to avoid |
| 51 | # failures in CI |
| 52 | timeout -f -k 5s 6m yarn test:production --updateSnapshot --runInBand |
| 53 | } |
| 54 | |
| 55 | package() { |
| 56 | local destdir=/usr/lib/node_modules/prettier |
| 57 | |
| 58 | install -d \ |
| 59 | "$pkgdir"/usr/bin \ |
| 60 | "$pkgdir"/$destdir \ |
| 61 | "$pkgdir"/usr/share/licenses/prettier |
| 62 | |
| 63 | cp -r dist/prettier/* "$pkgdir"/$destdir |
| 64 | ln -s $destdir/bin/prettier.cjs "$pkgdir"/usr/bin/prettier |
| 65 | |
| 66 | cd "$pkgdir"/$destdir |
| 67 | rm README.md # more links to various badges than actual content |
| 68 | mv LICENSE "$pkgdir"/usr/share/licenses/prettier/LICENSE |
| 69 | } |
| 70 | |
| 71 | sha512sums=" |
| 72 | 0e32eaaf1d4f9c700655e5a2d7af9f8aee0581a2cc49a265e7d74bda91a7ce4934ca8bdf453bf60bdc63b110387f9d67ed377ea9a92db1b5b4a37b23eac57c07 prettier-3.8.4.tar.gz |
| 73 | c7be8d92b7f7a8e4519c8515c77b0cb80936b708b13a3448d5310602e957533e22d9a6e93e1d1c313f526eefc9974f08906d0de470060d71d533365985a4e7b2 disable-oxc-and-hermes-plugin-tests.patch |
| 74 | " |