Skip to content

Commit

Permalink
Merge pull request #2190 from spryker/redirects-generator
Browse files Browse the repository at this point in the history
Redirects generator v1
  • Loading branch information
andriitserkovnyi committed Sep 20, 2023
2 parents 3b34485 + ea49f6e commit 8544798
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 4 deletions.
35 changes: 35 additions & 0 deletions _scripts/redirects_generator/redirect_from_generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Function to process Markdown files in a folder and its subfolders recursively
process_markdown_files() {
local folder="$1"

for file in "$folder"/*; do
if [ -f "$file" ] && [[ "$file" == *.md ]]; then
# Check if "redirect_from:" exists in the file
if ! grep -q "redirect_from:" "$file"; then
# Add "redirect_from:" after "template:" if it's missing
awk '/template:/ && !p {print $0 RS "redirect_from:"; p=1; next} 1' "$file" > temp && mv temp "$file"

echo "redirect_from added to: $file"
fi
elif [ -d "$file" ]; then
# If it's a directory, recursively process its contents
process_markdown_files "$file"
fi
done
}

# Specify the folder to add `redirect_from` to
folder_path=""

# Check if the folder exists
if [ ! -d "$folder_path" ]; then
echo "Folder does not exist: $folder_path"
exit 1
fi

# Call the function to process Markdown files and subfolders
process_markdown_files "$folder_path"

echo "Script completed."
54 changes: 54 additions & 0 deletions _scripts/redirects_generator/redirects_generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Function to process files in a folder and its subfolders recursively
process_files() {
local folder="$1"
local root_directory="$2"

for file in "$folder"/*; do
if [ -f "$file" ]; then
# Get the absolute file path
file_path=$(realpath "$file")

# Get the relative file path
relative_path=${file_path#$root_directory}

# Add ' - ' at the start of the relative file path
relative_path=" - $relative_path"

# Replace ".md" with ".html" in the relative file path
relative_path="${relative_path%.md}.html"

# Get the content of the original file
original_content=$(cat "$file")

# Prepend the modified relative file path to the content
updated_content="$relative_path"$'\n'"$original_content"

# Overwrite the original file with the updated content
echo "$updated_content" > "$file"

echo "Modified file path added to: $file"
elif [ -d "$file" ]; then
# If it's a directory, recursively process its contents
process_files "$file" "$root_directory"
fi
done
}

# Specify the folder containing the files to add paths to
folder_path=""

# Check if the folder exists
if [ ! -d "$folder_path" ]; then
echo "Folder does not exist: $folder_path"
exit 1
fi

# Specify the root directory to make paths relative to. Must end with `spryker-docs`
root_directory=""

# Call the function to process files and subfolders
process_files "$folder_path" "$root_directory"

echo "Script completed."
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Coding guidelines
description: This document lists coding guidelines that are used at Spryker
last_updated: Jan 27, 2022
template: concept-topic-template
redirect_from:
---

In this section, you can learn about coding guidelines that we use at Spryker. For more details, see the following documents:
Expand Down
1 change: 1 addition & 0 deletions docs/scos/dev/guidelines/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Guidelines
description: Guidelines for developers working on Spryker Commerce OS
template: concept-topic-template
redirect_from:
---

This section contains a collection of useful guidelines for developing on the Spryker Commerce OS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ title: Extension scenarios
description: Supported extension scenarios for event subscribers registration, modules configuration, plugins registration
last_updated: May 2513, 2023
template: concept-topic-template
redirect_from:
---

This section describes the supported extension scenarios for the following entities:

- [Event subscribers registration](/docs/scos/dev/guidelines/keeping-a-project-upgradable/extension-scenarios/event-subscribers-registration.html)
- [Modules configuration](/docs/scos/dev/guidelines/keeping-a-project-upgradable/extension-scenarios/modules-configuration.html)
- [Plugins registration](/docs/scos/dev/guidelines/keeping-a-project-upgradable/extension-scenarios/plugins-registration.html)
- [Plugins registration](/docs/scos/dev/guidelines/keeping-a-project-upgradable/extension-scenarios/plugins-registration.html)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Keeping a project upgradable
description: Guidelines for keeping a project upgradable
last_updated: Mar 24, 2023
template: concept-topic-template
redirect_from:
related:
- title: Plugins registration
link: docs/scos/dev/guidelines/keeping-a-project-upgradable/supported-extension-scenarios/plugins-registration.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Run the evaluator tool
description: Instructions for running the evaluator tool
template: howto-guide-template
redirect_from:
---

This document outlines the process of using the evaluator tool to verify if your project code adheres to Spryker's standards.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Additional logic in dependency provider
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

The *Additional logic in dependency provider* check checks the way plugins are registered in the dependency provider on the project level.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Dead code checker
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

The dead code checker checks for dead code that extends core classes in your project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Minimum allowed shop version
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

The *Minimum allowed shop version* check makes sure that the project uses one of the supported product releases by the [Spryker Code Upgrader](/docs/scu/dev/onboard-to-spryker-code-upgrader/prepare-a-project-for-spryker-code-upgrader.html).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Multidimensional array
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

This check checks that project doesn't use the deeply nested multidimensional arrays in dependency providers, in order to not overload it with complicated logic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Npm checker
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

This checker identifies and reports security vulnerabilities in the npm dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Open-source vulnerabilities checker
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

Open-source vulnerabilities checker is a tool that checks if your PHP application depends on PHP packages with known security vulnerabilities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: PHP version
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

This guide describes how to resolve issues surrounding the allowed and consistent PHP version being used in different project parts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Plugin registration with restrictions
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

Some plugins have dependencies from other plugins and should be used only before or after another plugin. The *Plugin registration with restrictions* check checks that dependencies between the plugins are described according to the specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Single plugin argument
description: Reference information for evaluator tools.
template: howto-guide-template
redirect_from:
---

This check makes sure that the plugins don't require complicated constructor arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Upgradability guidelines
description: Find solutions to Evaluator violations
template: howto-guide-template
redirect_from:
---

The documents in this section will help you resolve the issues related to code evaluation in a way that keeps your code upgradable and up to date with both Spryker's and industry coding standards.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Architecture performance guidelines
description: Learn about the bad and best architecture practices which can affect the performance of applications in the very end servers
last_updated: Nov 26, 2021
template: concept-topic-template
redirect_from:
related:
- title: General performance guidelines
link: docs/scos/dev/guidelines/performance-guidelines/general-performance-guidelines.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: RAM-aware batch processing
description: RAM-aware batch processing increases memory consumption efficiency for long-running operations.
last_updated: May 16, 2022
template: concept-topic-template
redirect_from:
related:
- title: New Relic transactions grouping by queue names
link: docs/scos/dev/guidelines/performance-guidelines/elastic-computing/new-relic-transaction-grouping-by-queue-names.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Storage caching for primary-replica database setups
description: This guideline explains how to setup the Master-Replica database connection.
last_updated: May 16, 2022
template: concept-topic-template
redirect_from:
related:
- title: New Relic transactions grouping by queue names
link: docs/scos/dev/guidelines/performance-guidelines/elastic-computing/new-relic-transaction-grouping-by-queue-names.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
title: Performance guidelines
description: This guidelines explains how to optimize the performance of your website.
template: concept-topic-template
redirect_from:
---

Performance guidelines help you analyze and optimize performance of your website from different perspectives:

- [General performance guidelines](/docs/scos/dev/guidelines/performance-guidelines/general-performance-guidelines.html) for general approaches to optimizing the server-side execution time.
- [Architecture performance guidelines](/docs/scos/dev/guidelines/performance-guidelines/architecture-performance-guidelines.html) to optimize performance in the very end servers.
- [Frontend performance guidelines](/docs/scos/dev/guidelines/performance-guidelines/front-end-performance-guidelines.html) to do the frontend-specific optimization.
- [Frontend performance guidelines](/docs/scos/dev/guidelines/performance-guidelines/front-end-performance-guidelines.html) to do the frontend-specific optimization.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Testing console commands
description: How to test console commands.
last_updated: Jan 12, 2022
template: concept-topic-template
redirect_from:
related:
- title: Available test helpers
link: docs/scos/dev/guidelines/testing-guidelines/available-test-helpers.html
Expand Down Expand Up @@ -90,4 +91,4 @@ public function testMyConsoleCommand(): void
}
```

That's it. You are all set to test the console commands.
That's it. You are all set to test the console commands.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Testing guidelines
description: This section lists documents inside the Testing guidelines section.
last_updated: Apr 26, 2023
template: concept-topic-template
redirect_from:
---

Get comprehensive guidance for effective testing in Spryker projects. Discover a range of topics, including available test helpers, code coverage generation, data builders for creating transfer objects, executing tests, setting up efficient test organization, configuring and using the Codeception test framework, testing best practices and console commands, and more.
Expand All @@ -19,4 +20,4 @@ The *Testing guidelines* section includes the following documents:
* [Testify](/docs/scos/dev/guidelines/testing-guidelines/testify.html)
* [Testing best practices](/docs/scos/dev/guidelines/testing-guidelines/testing-best-practices.html)
* [Testing concepts](/docs/scos/dev/guidelines/testing-guidelines/testing-concepts.html)
* [Testing console commands](/docs/scos/dev/guidelines/testing-guidelines/testing-console-commands.html)
* [Testing console commands](/docs/scos/dev/guidelines/testing-guidelines/testing-console-commands.html)

0 comments on commit 8544798

Please sign in to comment.