Skip to content

EDU-13262: Mapping errors from Contentful scripts #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mariana-caetano
Copy link

@mariana-caetano mariana-caetano commented Apr 11, 2025

This PR updates the following (key changes):

  1. index.js exports

    • Exported the following functions for independent execution:
      • deleteMarkdownFiles
      • getEntries
      • replaceQuotes
      • fixCallouts
      • updateAllImages
  2. Improved error logging

    • Enhanced the logScriptStatus function to log script execution statuses (success or failure) with detailed error messages in the script-errors.md file. This file will be created once you run the first script.
  3. File deletion logic

    • Updated the deleteMarkdownFiles function to recursively delete all files and folders in the docs directory while logging any errors encountered.
  4. Dynamic markdown file creation

    • The createMarkdownFile function generates .md files for various content types based on their locale and metadata.

How to Test Locally

Follow these steps to test the changes locally:

1 Clone this repository
2. Checkout to the branch EDU-13262-mapping-scripts.
3. Open a terminal and make sure you are in the following directory: help-center-content/index.js.
4. Now run individual functions to test each one:
- Step 1: Delete markdown files:
bash node -e "require('./index').deleteMarkdownFiles('./docs')"

  • Step 2: Get entries from Contentful:
    node -e "require('./index').getEntries()"
  • Step 3: Replace quotes:
    node -e "require('./index').replaceQuotes()"
  • Step 4: Fix callouts:
    node -e "require('./index').fixCallouts()"
  • Step 5:Update all images:
    node -e "require('./index').updateAllImages()"
  1. Check the script-errors.md file for any logged errors during execution.

PS.:

  • The errors logged in script-errors.md may not be entirely accurate. For example, the image below shows an error during the deletion of markdown files, but all files in the docs folder were still deleted despite the errors. Maybe the script retried deletion after the files were already removed?

Screenshot_480

@mariana-caetano mariana-caetano self-assigned this Apr 11, 2025
@mariana-caetano mariana-caetano marked this pull request as ready for review April 11, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant