diff --git a/prettier/Dockerfile b/prettier/Dockerfile index 44e17ea2..6e0136ef 100644 --- a/prettier/Dockerfile +++ b/prettier/Dockerfile @@ -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"] diff --git a/prettier/info.yaml b/prettier/info.yaml index 6d098b3b..004cb74d 100644 --- a/prettier/info.yaml +++ b/prettier/info.yaml @@ -4,7 +4,7 @@ name: prettier version_cmd: | prettier --version | sed 's/^/v/; s/$/-2/' command: - - prettier-with-tailwindcss + - prettier - "--write" include: - "**/*.js" diff --git a/prettier/install.sh b/prettier/install.sh new file mode 100755 index 00000000..024c4742 --- /dev/null +++ b/prettier/install.sh @@ -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 </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} diff --git a/prettier/package.json b/prettier/package.json index 9f9fba21..139e7621 100644 --- a/prettier/package.json +++ b/prettier/package.json @@ -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" } } diff --git a/prettier/prettier-with-tailwindcss b/prettier/prettier-with-tailwindcss deleted file mode 100755 index 882ab861..00000000 --- a/prettier/prettier-with-tailwindcss +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -# -# NB. this executable handles link/unlink of all plugins, not just tailwind, but -# we're keeping it named as is to avoid errors for users who may be using -# command in their .restyled.yaml -# -### -yarn link tailwindcss @trivago/prettier-plugin-sort-imports -trap 'yarn unlink tailwindcss @trivago/prettier-plugin-sort-imports' EXIT -prettier "$@"