teach-la-website icon indicating copy to clipboard operation
teach-la-website copied to clipboard

Image sizing ci

Open nicolasjeong opened this issue 4 years ago • 13 comments

nicolasjeong avatar Apr 21 '21 04:04 nicolasjeong

@nicolasjeong is this PR ready to review? I'm not sure if we've hit all the requested items in the ticket yet!

mattxwang avatar May 02 '21 03:05 mattxwang

Oh my bad, I thought I had to submit a PR after resolving some of the comments from checkImageSize.js before moving on to fixImageSize.js. (Unless I missed something in checkImageSize.js)

nicolasjeong avatar May 02 '21 05:05 nicolasjeong

Oh my bad, I thought I had to submit a PR after resolving some of the comments from checkImageSize.js before moving on to fixImageSize.js. (Unless I missed something in checkImageSize.js)

Sure, in that case I can give a light review, but we shouldn't merge this until we also make a working fixImageSize.js action and resolve the issues with the CI.

mattxwang avatar May 02 '21 06:05 mattxwang

@reginawang99 @ellieyhcheng I'm not sure why the export/require statements are causing everything in checkImageSize.js to run instead of just the getAllFiles function.

vivianha534 avatar May 13 '21 20:05 vivianha534

Kk I can take a look tonight

reginawang3495 avatar May 13 '21 20:05 reginawang3495

Oh I can jump in here if that makes things easier, basically the entire file is being executed on interpretation (afaik how importing works with ESM/node, but I could be wrong)

I would suggest instead to separate concerns:

  • one file should just be a shared library that only exports functions
  • two individual files should just be the main routines (i.e. calling the modules from that file)

Ideally, any file you import shouldn't have any deterministic or side-effect behaviour!

mattxwang avatar May 13 '21 20:05 mattxwang

@mattxwang Oh ok, so if I'm understanding this correctly, if we had functions that we wanted to use in both checkImageSize.js and fixImageSize.js then we should define the function inside of another file like library.js or something and export the functions in there, and require library.js in checkImageSize.js and fixImageSize.js in order to use the exported functions?

vivianha534 avatar May 13 '21 20:05 vivianha534

@mattxwang Oh ok, so if I'm understanding this correctly, if we had functions that we wanted to use in both checkImageSize.js and fixImageSize.js then we should define the function inside of another file like library.js or something and export the functions in there, and require library.js in checkImageSize.js and fixImageSize.js in order to use the exported functions?

Yup! I would also say that this is generally best practice! I would put all relevant library files in your lib.js file or similar.

Also, since we're not supporting Node 10, ESM imports/exports are probably the way to go.

mattxwang avatar May 13 '21 20:05 mattxwang

It seems that one of the check still fails? I'm pretty sure it's because of the non-fixable images that have errors.

nicolasjeong avatar May 22 '21 06:05 nicolasjeong

Just touching back to this, @reginawang99 / @vivianha534 are y'all wrapping up this ticket? Or do you want me to finish it?

mattxwang avatar May 27 '21 20:05 mattxwang

@vivianha534 i think we can just fix that one fixable image, and just push? and we manually fix/ask people with pictures that are too small for updated pics?

(we can probably manually fix the non-square aspect ratios)

reginawang3495 avatar May 27 '21 20:05 reginawang3495

@mattxwang @reginawang99 Oh I was planning on manually fixing all of the images before having Nico merge it. I've already been working on fixing the images, and the last couple should be done by tonight/tomorrow latest.

vivianha534 avatar May 27 '21 23:05 vivianha534

Just curious, what ended up happening with this PR? @vivianha534 @reginawang3495

mattxwang avatar Nov 16 '21 05:11 mattxwang