From 36a2dfe579d8135162d1915aef292585881670f3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 04:13:05 +0000 Subject: [PATCH 1/6] feat(prettier): update dependency @trivago/prettier-plugin-sort-imports to v5 --- prettier/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prettier/package.json b/prettier/package.json index 9f9fba21..e8cb052c 100644 --- a/prettier/package.json +++ b/prettier/package.json @@ -2,7 +2,7 @@ "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", "tailwindcss": "^3.3.2" From 5670d7855e4304a9d2d107a5870a728ddd6f844c Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 6 Dec 2024 07:18:56 -0500 Subject: [PATCH 2/6] Move to an install script for prettier executables --- prettier/Dockerfile | 8 +++----- prettier/info.yaml | 2 +- prettier/install.sh | 26 ++++++++++++++++++++++++++ prettier/prettier-with-tailwindcss | 10 ---------- 4 files changed, 30 insertions(+), 16 deletions(-) create mode 100755 prettier/install.sh delete mode 100755 prettier/prettier-with-tailwindcss 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..0517c5ef 100644 --- a/prettier/info.yaml +++ b/prettier/info.yaml @@ -2,7 +2,7 @@ enabled: true name: prettier version_cmd: | - prettier --version | sed 's/^/v/; s/$/-2/' + prettier-with-tailwindcss --version | sed 's/^/v/; s/$/-2/' command: - prettier-with-tailwindcss - "--write" diff --git a/prettier/install.sh b/prettier/install.sh new file mode 100755 index 00000000..33502b02 --- /dev/null +++ b/prettier/install.sh @@ -0,0 +1,26 @@ +#!/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-with-tailwindcss </dev/null +trap 'yarn --offline unlink ${plugins[*]} >/dev/null' EXIT +/app/node_modules/.bin/prettier "\$@" +EOM + +chmod +x /usr/local/bin/prettier-with-tailwindcss 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 "$@" From a46b18db0a9d94f2bcbc95555bc96881f75b06b1 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 6 Dec 2024 07:22:54 -0500 Subject: [PATCH 3/6] [prettier] Install svelte dependencies This is now needed by prettier-plugin-sort-import@v5. No idea why. --- prettier/package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prettier/package.json b/prettier/package.json index e8cb052c..139e7621 100644 --- a/prettier/package.json +++ b/prettier/package.json @@ -5,6 +5,8 @@ "@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" } } From 3a99094286d5f8a198fe8fbfda08a630a0f96ca6 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 6 Dec 2024 07:24:59 -0500 Subject: [PATCH 4/6] [prettier] go back to simpler CMD --- prettier/info.yaml | 4 ++-- prettier/install.sh | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/prettier/info.yaml b/prettier/info.yaml index 0517c5ef..004cb74d 100644 --- a/prettier/info.yaml +++ b/prettier/info.yaml @@ -2,9 +2,9 @@ enabled: true name: prettier version_cmd: | - prettier-with-tailwindcss --version | sed 's/^/v/; s/$/-2/' + 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 index 33502b02..553cd4f8 100755 --- a/prettier/install.sh +++ b/prettier/install.sh @@ -23,4 +23,8 @@ trap 'yarn --offline unlink ${plugins[*]} >/dev/null' EXIT /app/node_modules/.bin/prettier "\$@" EOM +# Install at the legacy name we may see as CMD in the wild chmod +x /usr/local/bin/prettier-with-tailwindcss + +# Copy back as the right name +cp /usr/local/bin/prettier{-with-tailwindcss,} From ebcb68ad91ac480e3aba33512938018baf9e148f Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 6 Dec 2024 07:26:47 -0500 Subject: [PATCH 5/6] [prettier] flip the name we install vs the copy --- prettier/install.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/prettier/install.sh b/prettier/install.sh index 553cd4f8..7ba03d7a 100755 --- a/prettier/install.sh +++ b/prettier/install.sh @@ -10,21 +10,14 @@ for plugin in "${plugins[@]}"; do (cd /app/node_modules/"$plugin" && yarn link) done -cat >/usr/local/bin/prettier-with-tailwindcss </usr/local/bin/prettier </dev/null trap 'yarn --offline unlink ${plugins[*]} >/dev/null' EXIT /app/node_modules/.bin/prettier "\$@" EOM -# Install at the legacy name we may see as CMD in the wild -chmod +x /usr/local/bin/prettier-with-tailwindcss +chmod +x /usr/local/bin/prettier -# Copy back as the right name -cp /usr/local/bin/prettier{-with-tailwindcss,} +# Copy as a legacy name we may see as CMD in the wild +cp /usr/local/bin/prettier{,-with-tailwindcss} From edd122f312930e79589d0337cf5b33c2db67b180 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 6 Dec 2024 07:28:44 -0500 Subject: [PATCH 6/6] [prettier] make shim executable more robust --- prettier/install.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prettier/install.sh b/prettier/install.sh index 7ba03d7a..024c4742 100755 --- a/prettier/install.sh +++ b/prettier/install.sh @@ -12,8 +12,15 @@ done cat >/usr/local/bin/prettier </dev/null -trap 'yarn --offline unlink ${plugins[*]} >/dev/null' EXIT +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