Skip to content

Commit

Permalink
feat(prettier): update dependency @trivago/prettier-plugin-sort-impor…
Browse files Browse the repository at this point in the history
…ts to v5 (#848)

* feat(prettier): update dependency @trivago/prettier-plugin-sort-imports to v5

* Move to an install script for prettier executables

* [prettier] Install svelte dependencies

This is now needed by prettier-plugin-sort-import@v5. No idea why.

* [prettier] go back to simpler CMD

* [prettier] flip the name we install vs the copy

* [prettier] make shim executable more robust

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: patrick brisbin <[email protected]>
  • Loading branch information
renovate[bot] and pbrisbin authored Dec 6, 2024
1 parent f253930 commit 61bfc9c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
8 changes: 3 additions & 5 deletions prettier/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ RUN mkdir -p /app
WORKDIR /app
COPY package.json .
RUN yarn install && yarn cache clean
RUN cd node_modules/tailwindcss && yarn link
RUN cd node_modules/@trivago/prettier-plugin-sort-imports && yarn link
ENV PATH=/app/node_modules/.bin:$PATH
COPY prettier-with-tailwindcss /usr/local/bin/prettier-with-tailwindcss
COPY install.sh /tmp
RUN /tmp/install.sh
RUN mkdir -p /code
WORKDIR /code
ENTRYPOINT []
CMD ["prettier-with-tailwindcss", "--help"]
CMD ["prettier", "--help"]
2 changes: 1 addition & 1 deletion prettier/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: prettier
version_cmd: |
prettier --version | sed 's/^/v/; s/$/-2/'
command:
- prettier-with-tailwindcss
- prettier
- "--write"
include:
- "**/*.js"
Expand Down
30 changes: 30 additions & 0 deletions prettier/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail

plugins=(
tailwindcss
@trivago/prettier-plugin-sort-imports
)

for plugin in "${plugins[@]}"; do
(cd /app/node_modules/"$plugin" && yarn link)
done

cat >/usr/local/bin/prettier <<EOM
#!/usr/bin/env bash
if ! yarn --offline link ${plugins[*]} >/dev/null; then
echo "Failed to link yarn modules" >&2
echo "Please report this as an issue" >&2
echo "https://github.com/restyled-io/restylers/issues" >&2
exit 1
fi
trap 'yarn --offline unlink ${plugins[*]} >/dev/null || true' EXIT
/app/node_modules/.bin/prettier "\$@"
EOM

chmod +x /usr/local/bin/prettier

# Copy as a legacy name we may see as CMD in the wild
cp /usr/local/bin/prettier{,-with-tailwindcss}
4 changes: 3 additions & 1 deletion prettier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"name": "@restyled/restyler-prettier",
"version": "0.0.0",
"dependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@trivago/prettier-plugin-sort-imports": "^5.0.0",
"prettier": "3.4.2",
"prettier-plugin-tailwindcss": "^0.6.0",
"prettier-plugin-svelte": "^3.3.2",
"svelte": "^5.0.0",
"tailwindcss": "^3.3.2"
}
}
10 changes: 0 additions & 10 deletions prettier/prettier-with-tailwindcss

This file was deleted.

0 comments on commit 61bfc9c

Please sign in to comment.