feat: #98 added option to allow for other plugins

This commit is contained in:
2025-05-08 13:20:52 +02:00
parent b73c2bf29c
commit e2704493af
2 changed files with 15 additions and 8 deletions

View File

@@ -70,6 +70,10 @@ inputs:
description: Which identity is used for git name/email when committing changes. Needs to be one of "actions" or "author". description: Which identity is used for git name/email when committing changes. Needs to be one of "actions" or "author".
required: false required: false
default: "actions" default: "actions"
allow_other_plugins:
description: Allow other plugins to be installed. By default, we are checking if the plugins are actually prettier plugins.
required: false
default: false
runs: runs:
using: "composite" using: "composite"
@@ -97,6 +101,7 @@ runs:
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_CLEAN_NODE_FOLDER: ${{ inputs.clean_node_folder }} INPUT_CLEAN_NODE_FOLDER: ${{ inputs.clean_node_folder }}
INPUT_GIT_IDENTITY: ${{ inputs.git_identity }} INPUT_GIT_IDENTITY: ${{ inputs.git_identity }}
INPUT_ALLOW_OTHER_PLUGINS: ${{ inputs.allow_other_plugins }}
branding: branding:
icon: "award" icon: "award"

View File

@@ -49,14 +49,16 @@ npm install --silent prettier@$INPUT_PRETTIER_VERSION
# Install plugins # Install plugins
if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then
for plugin in $INPUT_PRETTIER_PLUGINS; do if [ "$INPUT_ALLOW_OTHER_PLUGINS" != "true" ]; then
echo "Checking plugin: $plugin" for plugin in $INPUT_PRETTIER_PLUGINS; do
# check regex against @prettier/xyz echo "Checking plugin: $plugin"
if ! echo "$plugin" | grep -Eq '(@prettier\/plugin-|(@[a-z\-]+\/)?prettier-plugin-){1}([a-z\-]+)'; then # check regex against @prettier/xyz
echo "$plugin does not seem to be a valid @prettier/plugin-x plugin. Exiting." if ! echo "$plugin" | grep -Eq '(@prettier\/plugin-|(@[a-z\-]+\/)?prettier-plugin-){1}([a-z\-]+)'; then
exit 1 echo "$plugin does not seem to be a valid @prettier/plugin-x plugin. Exiting."
fi exit 1
done fi
done
fi
npm install --silent $INPUT_PRETTIER_PLUGINS npm install --silent $INPUT_PRETTIER_PLUGINS
fi fi
) )