Skip to content
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

Convert to WebP & pre-commit hook #12590

Merged
merged 14 commits into from
Apr 17, 2023
Merged

Convert to WebP & pre-commit hook #12590

merged 14 commits into from
Apr 17, 2023

Conversation

tabathadelane
Copy link
Contributor

@tabathadelane tabathadelane commented Apr 12, 2023

  • adds webp-converter package to convert PNG images to WebP
  • adds convertPNGs.mjs script to convert repo PNGs to WebP format
  • script also updates image references in markdown and javascript files
  • adds glob package to grab all png/markdown/js files
    • installed with an alias as glob10 because jest is using glob v7 as a dependency and it was causing major conflicts to install a newer version
  • adds meow package for flag support to run script on staged vs global files
  • adds husky package for pre-commit checks
  • creates pre-commit.mjs script that warns contributors on png image uploads
  • organizes package.json scripts in ascending order
  • adds yarn lint and yarn pre-commit to required checks that must pass before staged files can be committed

Script can be run on staged files with command yarn convert-to-webp
Script can be run globally on entire repo with command yarn convert-to-webp -g

NOTE: The pre-commit.sh scripts have been temporarily disabled until we can coordinate with writers about this change.

NOTE: 😢 Github desktop does not 🙅‍♀️ support bash escape characters to change 🎨ANSI colors, so the pre-commit failure message can only use emojis

replaces #12317

@tabathadelane tabathadelane requested review from a team, sunnyzanchi and clarkmcadoo and removed request for a team April 12, 2023 23:25
@github-actions github-actions bot added the eng issues related to site functionality that requires engineering label Apr 12, 2023
@github-actions
Copy link

Hi @tabathadelane 👋

Thanks for your pull request! Your PR is in a queue, and a writer will take a look soon. We generally publish small edits within one business day, and larger edits within three days.

Gatsby Cloud will automatically generate a preview of your request, and will comment with a link when the preview is ready (usually 20 to 30 minutes).

@tabathadelane tabathadelane marked this pull request as draft April 12, 2023 23:47
@tabathadelane tabathadelane changed the title Clark/add husky Convert to WebP & pre-commit hook Apr 12, 2023
@gatsby-cloud
Copy link

gatsby-cloud bot commented Apr 13, 2023

✅ docs-website-develop deploy preview ready

@tabathadelane tabathadelane marked this pull request as ready for review April 13, 2023 18:51
clarkmcadoo
clarkmcadoo previously approved these changes Apr 14, 2023
tabathadelane and others added 2 commits April 17, 2023 13:24
* check literal `.` in `stagedMDs` regex

* use `continue` instead of `break` to avoid early exit

* update convert-to-webp script to include jpgs

* add error logging to convert-to-webp

* run Prettier
sunnyzanchi
sunnyzanchi previously approved these changes Apr 17, 2023

import { rm, readFile, writeFile } from 'fs/promises';
import { glob } from 'glob10';
// installed with an alias because v10 conflicts with jest dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you move this a line up? comments are usually above the line they refer to

scripts/pre-commit.mjs Outdated Show resolved Hide resolved
@@ -28,6 +28,10 @@ const main = async () => {

console.log(results);
console.log(`Failed file count: ${results.length}`);

if (results.length > 0) {
process.exitCode = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good addition!

@tabathadelane tabathadelane merged commit fe25fe3 into develop Apr 17, 2023
@tabathadelane tabathadelane deleted the clark/add-husky branch April 17, 2023 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
eng issues related to site functionality that requires engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants