Skip to content

Commit

Permalink
Add more test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Isengo1989 committed Dec 7, 2023
1 parent 029d7fb commit d3f2a39
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 8 deletions.
58 changes: 58 additions & 0 deletions .github/scripts/file-watcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#! /usr/bin/env bash

# Set the path to the snippets folder
WATCHER_PATH=$1
echo 0 > error.txt

# Find all files in the snippets folder
find $WATCHER_PATH -type f -print0 | while IFS= read -r -d '' file; do

# Check if the file contains the string "WATCHER_URL" and is therefore a watcher file
cat "$file" | grep 'WATCHER_URL' >> /dev/null || continue

# Get the JSON from the first line of the file
HEAD=$(cat "$file" | grep 'WATCHER_URL')
JSON=$(sed "s/# //g" <<< "$HEAD")

# Get the values from the JSON
WATCHER_URL=$(echo $JSON | jq -r '.WATCHER_URL')
WATCHER_HASH=$(echo $JSON | jq -r '.WATCHER_HASH')
WATCHER_CONTAINS=$(echo $JSON | jq -r '.WATCHER_CONTAINS')

# Get the hash of the URL
EVAL_HASH="curl -sl $WATCHER_URL | md5sum | cut -d ' ' -f 1"
CALLED_HASH="$(eval $EVAL_HASH)"

# Check if the hashes are equal
if [ "$WATCHER_HASH" == "$CALLED_HASH" ]; then
echo "Both hashes are equal."
else
echo "Hashes are not equal."

FILE_CONTENT=$(curl -sl $WATCHER_URL)

# Check if $WATCHER_CONTAINS contains the string "null" and is therefore empty or not set
if [[ $WATCHER_CONTAINS == "null" ]]; then
echo 1 > error.txt
fi
# Check if $WATCHER_CONTAINS contains the string $WATCHER_CONTAINS and if not call the Slack webhook
if [[ $FILE_CONTENT == *"$WATCHER_CONTAINS"* ]]; then
echo "String found!"
else
echo "String not found! Please check $WATCHER_URL"
echo "Sourcefile: https://github.com/shopware/docs/blob/main/$file"
echo 1 > error.txt
fi
fi
done

ERROR_FOUND=$(cat error.txt)

if [ "$ERROR_FOUND" -eq 1 ]
then
echo "Error found, exiting..."
exit 1
else
echo "$ERROR_FOUND No error found, exiting..."
exit 0
fi
35 changes: 35 additions & 0 deletions .github/workflows/watcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check shopware files for changes
on:
pull_request:
workflow_dispatch:

jobs:
check-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
./.github/scripts/file-watcher.sh
id: watcher
continue-on-error: true
- name: Send custom JSON data to Slack workflow
if: steps.watcher.outcome != 'success'
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Text: GitHub Action build result: ${{ job.status }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":ladybug: Failed file watcher with status '${{ steps.watcher.outcome }}': Please check ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
2 changes: 2 additions & 0 deletions guides/hosting/infrastructure/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ shopware:
sitemap:
url: "{url-to-your-sitemap-files}"
# The Adapter Configuration

# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f"}
```

If you want to regulate the uploaded file types, then you could add the keys `allowed_extensions`for the public filesystem or `private_local_download_strategy` for the private filesystem.
Expand Down
1 change: 1 addition & 0 deletions guides/hosting/infrastructure/message-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ If you have configured the cli-worker, you should turn off the admin worker in t
shopware:
admin_worker:
enable_admin_worker: false
# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f","WATCHER_CONTAINS":"enable_admin_worker"}
```

::: warning
Expand Down
1 change: 1 addition & 0 deletions guides/hosting/infrastructure/reverse-http-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nav:
title: Reverse HTTP Cache
position: 40

# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Storefront/Resources/config/packages/storefront.yaml","WATCHER_HASH":"77c7d65c6c87a91d2971e770dae10bd2"}
---

# Reverse HTTP Cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nav:
title: Search Criteria
position: 10

# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/store-api-reference/37fb4382af17d88cc50dfbe549752339dec01837/docs/concepts/search-queries.md","WATCHER_HASH":"5a95741bd3bf9d4b900f27a90e87f77b"}
---

# Search Criteria
Expand Down
3 changes: 2 additions & 1 deletion guides/plugins/apps/shipping-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
nav:
title: Shipping methods
position: 25


# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/App/Manifest/Xml/ShippingMethod/ShippingMethod.php","WATCHER_HASH":"cafda2eb40608199c21a229e46d5a32e"}
---

# Shipping methods
Expand Down
10 changes: 5 additions & 5 deletions guides/plugins/themes/add-icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ nav:

## Overview

In this guide you will learn how to use the icon renderer component as well as adding custom icons.
In this guide, you will learn how to use the icon renderer component as well as adding custom icons.

::: info
Even if this is originally a plugin guide, everything will work perfectly in a theme as well. Actually, a theme even is a kind of plugin. So don't get confused by us talking about plugins here.
:::

## Prerequisites

In order to follow this guide easily, you first need to have a functioning plugin installed. Head over to our [Plugin base guide](../plugins/plugin-base-guide) to create a plugin, if you don't know how it's done yet. Also knowing and understanding SCSS will be quite mandatory to fully understand what's going on here. Furthermore, it might be helpful to read the guide on how to [handle own assets](../plugins/storefront/add-custom-assets) in your plugin before you start with this one.
To follow this guide easily, you first need to have a functioning plugin installed. Head over to our [Plugin base guide](../plugins/plugin-base-guide) to create a plugin, if you don't know how it's done yet. Also, knowing and understanding SCSS will be quite mandatory to fully understand what's going on here. Furthermore, it might be helpful to read the guide on how to [handle own assets](../plugins/storefront/add-custom-assets) in your plugin before you start with this one.

## Adding icon

In order to add any icons to the Storefront, you use our `sw_icon` twig action. This way, an icon of choice is displayed in the Storefront.
To add any icons to the Storefront, you use our `sw_icon` twig action. This way, an icon of choice is displayed in the Storefront.

Needless to say, the first step is saving your image somewhere in your plugin where Shopware can find it. The default path for icons is the following:

Expand All @@ -30,7 +30,7 @@ Needless to say, the first step is saving your image somewhere in your plugin wh
`
```

You can also provide "solid" icons or any other custom pack names which can be configured later with the `pack` parameter. You can do that by creating a folder with the pack name:
You can also provide "solid" icons or any other custom pack names that can be configured later with the `pack` parameter. You can do that by creating a folder with the pack name:

```text
<YourPlugin>/src/Resources/app/storefront/dist/assets/icon/<pack-name>
Expand Down Expand Up @@ -89,7 +89,7 @@ A simple but fully functional example could look like below:
Icons or other custom assets are not included in the theme inheritance.
:::

Inside your theme, you cannot put an icon in a directory corresponding the core folder structure and expect the core one to be automatically overwritten by it, as you're used to with themes in general.
Inside your theme, you cannot put an icon in a directory corresponding to the core folder structure and expect the core one to be automatically overwritten by it, as you're used to with themes in general.

## Load icons from custom locations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A theme is a special type of Plugin or App, aimed at easily changing the visual

There are basically several ways to change the appearance of the Storefront. You can have "regular" plugins or apps which main purpose is to add new functions and change the behavior of the shop. These plugins / apps might also contain SCSS/CSS and JavaScript to be able to embed their new features into the Storefront.

Technically a theme is also a plugin / app but it will be visible in the theme manger once its activated and can be assigned to a specific sales channel, while plugins / apps are activated globally. To distinguish a theme from a "regular" plugin / app you need to implement the Interface `Shopware\Storefront\Framework\ThemeInterface`. A theme can inherit also from other themes, overwrite the default configuration \(colors, fonts, media\) and add new configuration options.
Technically, a theme is also a plugin / app but it will be visible in the theme manger once its activated and can be assigned to a specific sales channel, while plugins / apps are activated globally. To distinguish a theme from a "regular" plugin / app you need to implement the Interface `Shopware\Storefront\Framework\ThemeInterface`. A theme can inherit also from other themes, overwrite the default configuration \(colors, fonts, media\) and add new configuration options.

Check failure on line 14 in guides/plugins/themes/differences-plugins-and-apps-vs-themes.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] guides/plugins/themes/differences-plugins-and-apps-vs-themes.md#L14

Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE[1]) Suggestions: `, but` URL: https://languagetool.org/insights/post/grammar-what-are-compound-sentences/ Rule: https://community.languagetool.org/rule/show/COMMA_COMPOUND_SENTENCE?lang=en-US&subId=1 Category: PUNCTUATION
Raw output
guides/plugins/themes/differences-plugins-and-apps-vs-themes.md:14:43: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE[1])
 Suggestions: `, but`
 URL: https://languagetool.org/insights/post/grammar-what-are-compound-sentences/ 
 Rule: https://community.languagetool.org/rule/show/COMMA_COMPOUND_SENTENCE?lang=en-US&subId=1
 Category: PUNCTUATION

You do not need to write any PHP code in a theme. If you need PHP code you should choose a plugin instead. Another important distinction to themes is this: Themes are specific for a sales channel and have to be assigned to them to take effect, the other way around plugins and apps have a global effect on the Shopware installation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav:
title: Script hooks reference
position: 50

# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Webhook/Hookable/HookableEventCollector.php","WATCHER_HASH":"c8d1e5be8efb3ab8e06e434be1330489"}
---

<!--- auto generated by `bin/console docs:generate-scripts-reference` in the shopware project, don't edit this file manually -->
Expand Down
1 change: 1 addition & 0 deletions snippets/config/html_sanitizer.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f","WATCHER_CONTAINS":"html_sanitizer"}
shopware:
html_sanitizer:
sets:
Expand Down
1 change: 1 addition & 0 deletions snippets/config/html_sanitizer_disabled.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
shopware:
html_sanitizer:
enabled: false
# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f","WATCHER_CONTAINS":"html_sanitizer"}
1 change: 1 addition & 0 deletions snippets/config/stock_disabled.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f","WATCHER_CONTAINS":"enable_stock_management"}
# <project root>/config/packages/shopware.yaml
shopware:
stock:
Expand Down
1 change: 1 addition & 0 deletions snippets/guide/app_database_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ You can also use SQLite by setting the `DATABASE_URL` to `sqlite:///%kernel.proj
After choosing your database engine, you need to require two extra composer packages.

```shell
# {"WATCHER_URL":"https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/Framework/Resources/config/packages/shopware.yaml","WATCHER_HASH":"183f85ba8f15e8e7d0006b70be20940f","WATCHER_CONTAINS":"html_sanitizer"}
composer req symfony/maker-bundle migrations
```

Expand Down

0 comments on commit d3f2a39

Please sign in to comment.