extension-examples icon indicating copy to clipboard operation
extension-examples copied to clipboard

Add a script to keep all extensions dependency versions in line

Open izzymiller opened this issue 3 years ago • 13 comments

update.sh can be used to loop through every extension in the repository and update a specified package to a specified version.

Example usage from root of repo"

./update.sh -p @looker/sdk -v 21.0.7

This would update the package (-p) @looker/sdk to version (-v) 21.0.7 across all extensions. I think that last bit is desirable because it makes things uniform, but if that's not the case I can add in some selection criteria.

I thought about making it fast by just editing the text of package.json, but I think it is useful to actually run the yarn add command to make sure the version exists, see if there are errors, etc. (not to mention prep the extensions to actually be tested). It takes ~240s to run across the repo in its current state.

I imagine the flow to do updates will be something like

git clone [email protected]:looker-open-source/extension-examples.git
cd extension-examples
git checkout -b izzy/bump-looker-sdk-2107
./update.sh -p @looker/sdk -v 21.0.7
git add .
git commit -m "bumped @looker/sdk to 21.0.7"
git push

idk how to bash so if this short script in fact raises the dead please let me know.

izzymiller avatar Apr 30 '21 01:04 izzymiller

oh and just a note on the find behavior— It looks for directories that are not node_modules that contain a *.lock file. Felt like a reasonable heuristic for an extension directory, and better than some stackoverflow suggested solutions regarding maxdepth and stuff.

izzymiller avatar Apr 30 '21 01:04 izzymiller

feature request / next up would be to supply an array / dict to do multiple at once!

izzymiller avatar Apr 30 '21 01:04 izzymiller

I was actually thinking of writing something in javascript or typescript. Basically inputs would be some JS config object that mimics directory structure (down to react/typescript/javascript) . Each node would contain dev dependencies and dependences. The script would just run through the file system looking for package.json and entries based upon config.

My bash scripting skills suck so I normally avoid it like the plague. As an interim solution its okay but copying Jax as I suspect his bash skills are a lot better than mine.

bryans99 avatar Apr 30 '21 17:04 bryans99

This is a great first cut. As @bryans99 says, I think using Node for the entire thing would be more sustainable and readable rather than calling a yarn util via the bash script. However, I wonder if something could be readily extracted/applied from release-please for this. @joeldodge79 thoughts?

jkaster avatar Apr 30 '21 17:04 jkaster

Ha you'll never guess what I wrote before I remembered "hmm, I think Bryn said it should be a bash script?" and started figuring out how to bash.

I'll put up another PR with the node TS script that does more or less what you described.

izzymiller avatar Apr 30 '21 17:04 izzymiller

"hmm, I think Bryn said it should be a bash script?"

I hope I didn't say that, but if I did I apologize. Probably my brain not communicating with my mouth :D

bryans99 avatar Apr 30 '21 17:04 bryans99

I think you were just the spacegoat for my second guessing myself!

izzymiller avatar Apr 30 '21 17:04 izzymiller

*scapegoat lol

izzymiller avatar Apr 30 '21 17:04 izzymiller

spacegoat is much better! Gonna start using that with DevRelish.

jkaster avatar Apr 30 '21 18:04 jkaster

Just thinking about approach for a second... The node script I wrote does exactly the same thing as this script, which isn't what @bryans99 described.

I'm not sure I follow why we would want to provide as input a js object that mimics the entire directory structure of the repo. Wouldn't that be sort of equivalent work to just going thru the repo and editing each package.json, one by one? You'd just be doing that editing in one file, but the same number of keys/values would need to be changed.

I quite liked the idea of just providing {"package": x, "version": y} and having that apply to all package.jsons, since it really minimizes the maintenance work required.

I realize we'd have to make sure all extension examples here were kept up to date with the same versions... but that seems like sort of a good housekeeping practice anyway. Am I missing something neat about your suggestion?

izzymiller avatar Apr 30 '21 18:04 izzymiller

Main reason for the input block is that some examples do not need ALL of the packages. For example, typescript not needed javascript. react and extension react sdk not needed by non react examples.

bryans99 avatar Apr 30 '21 18:04 bryans99

Makes sense!

On Fri, Apr 30, 2021 at 11:58 AM Bryn Ryans @.***> wrote:

Main reason for the input block is that some examples do not need ALL of the packages. For example, typescript not needed javascript. react and extension react sdk not needed by non react examples.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/looker-open-source/extension-examples/pull/15#issuecomment-830308957, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIUAGMYK2IHXIHLQ4KOAFILTLL4U3ANCNFSM433BZRGA .

--

• Izzy Miller

• Developer Relations Engineer l Looker

• 415.298.4687 <(415)298-4687>

@.***

izzymiller avatar Apr 30 '21 18:04 izzymiller

For the codegen repo, we update the Looker release version constant by using a regex pattern and replacing it. If this is a package.json tweak, you could just match the target dependencies and replace them with the new version ref.

jkaster avatar Apr 30 '21 20:04 jkaster