- I've actually started using a debugger now which helped a lot in finding this bug
- vscode has a separate JS debug terminal that'll listen to any NodeJS process that you run
- wrote tests, doc and code for this one
- the cli repo is great at keeping documentation near code so it can be updated alongside code changes. it was pretty easy to add support for a different argument type
- should've asked a few questions before the PR to avoid assuming that site ids are uuidv4 when there was a solution that could work without assuming anything about what the backend stores ids as
- fixes 2 issues at once
- single word fix
- flaky tests make life miserable. this PR had tests failing on different OSes but not all of them at once. I don't like these sort of platform bugs
- first pr for which I wrote a test, makes me happy to know that no one will break it unknowingly
- debugging this was just a lot of print statements in a lot of places, I still haven't used a debugger with NodeJS, tried to use it with this one but wasn't able to get it running properly
- this was pretty low effort and turned out to be more of docs issue rather than a feature issue
- codebases get big sometime and you don't even know if a particular feature is supported or not, maintaining updated documentation is very important
- be a bit more patient with what you claim to be true, always double-check, mistakes will forever be out there in the public forum
- there's a
deprecatedtag in JSDoc that can be used to mark things that are outdated - I tried to test my changes for this PR but gave up after some point and had to take things out and manually test them outside the repo (sad day), still not sure if everything is going to work, fortunately there are 3 folks tagged on this PR for review
- edit: so it turns out I broke stuff: netlify/cli#3588
- learning: don't work on features/tests you can't write the tests to or just ask for some help
- sometimes you can avoid using a mock by making a wrapper and only testing the responses from the core function's response instead of checking if the wrapping function throws an error, exits the process etc.
- don't just remove dead code without asking the original author
- don't club changes you find while working on a PR, always create a separate PR for unrelated changes
switch(true)pattern with statements that evaluate to boolean as cases. (Feels like using guards in Haskell)- do not write PRs with excessively large changes as I did in this one, eventually I had to break it up to allow the reviewer to properly test everything since the changes are all across the codebase
- naming is hard, naming branches with limited characters is harder
- sometimes it's not possible to just refactor a codebase to fix a bug the right way and you've to succumb to using a tempfix (which is very permanent)
- the Proxy object in JS (I don't completely get this yet)
- colorless instance in chalk (for logging to files?)
- used the chalk package for styling text
- came across ci-info
- maintainers have other work too (I'm holding the urge to @ people constantly in my PRs)
- decided to read up more about the oclif cli framework that the repo uses
npm linkto use the repo cli directly (through symlinks) instead of doing a global install- edit: I made an typo in this one and fixed it after a few months in #3563, definitely need to be more responsible
- for loops are easier to understand over using confusing recursive approaches or functional array methods (easy to realise but hard to accept as an FP fan)
- used
Promise.all,Promise.allSettled,Promise.any(N.B. Promise.allSetlled doesn't make the async call in order unlike a for loop) - installed and tried out
nvmto debug an issue caused due to Node.js 10 not supporting the?.operator for...of,for...in(knew these but didn't use them due to pref for functional methods)- running tests serially to avoid burning my Mac (also had to force shutdown my Mac for the first time since everything hanged)
- more ava stuff and some useful flags:
fail-fast,verbose,serial - found a eslint plugin to enforce fp rules
- wrote a recursive way to retry (this was rejected since a loop is actually more intuitive)
const retry = async (retriesLeft) => { try { return await asyncCall() } catch (error) { if (retriesLeft === 0) { throw error } return retry(retriesLeft - 1) } } Object.entries(a).map([key, value]) => {})is a pretty neat way to use key-value pairs from an object.
- learnt more about static methods in JS classes (in most cases, separating these methods from classes is better)
- came across the ascii-table package, output data as tables easily on terminal
.------------------------------------. | a | apple | Some longer string | | b | banana | hi | | c | carrot | meow | | e | elephants | | '------------------------------------' - the ava testing library (it even supports snapshots for cli output)
- to avoid losing work while using
git stashset this as a git alias:git add --all && git stash - pattern matching through
*in npm scripts, useful for separation e.g.test:dev:*will run all scripts that start with the wordtest:dev: - came across git lfs (could use these for my figma design files)
- using objects to pass arguments so when one is removed, you don't need to care about the positioning (not sure about using this for other langs but seems good for js due to the spread operator and object property shorthand)
- the pain of flaky tests; can't debug code if it's not wrong