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

feat(esbuild): Script to update esbuild to the latest available version #2492

Merged

Conversation

JesseTatasciore
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla
Copy link

google-cla bot commented Feb 27, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Feb 27, 2021
console.log('""" Generated code; do not edit\nUpdate by running yarn update-esbuild-versions\n\nHelper macro for fetching esbuild versions for internal tests and examples in rules_nodejs\n"""\n');
console.log('load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")\n')

const latestVersion = JSON.parse(await getUrlAsString('https://registry.npmjs.org/esbuild/latest')).version;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps move the JSON.parse into the getUrlAsString method and refactor it to be called fetch? It's the only placed its used, so doing the parse outside seems like it's implying in other places it's needed as a string.

};

async function main() {
console.log('""" Generated code; do not edit\nUpdate by running yarn update-esbuild-versions\n\nHelper macro for fetching esbuild versions for internal tests and examples in rules_nodejs\n"""\n');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps preference, I like to add all the strings to an array, then join that array a output the result, rather than making multiple calls to console.log, eg:

const content = [];

content.push(''"""Generated code; do not edit');
...
content.join('\n');

console.log(` "https://registry.npmjs.org/${PLATFORMS[platform]}/-/${PLATFORMS[platform]}-%s.tgz" % version,`);
console.log(' ],');
console.log(' strip_prefix = "package",');
console.log(' build_file_content = """exports_files(["bin/esbuild"])""",');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check the original file, the Windows build_file_content is slightly different (see the Buildkite output too)

@bduffany
Copy link
Contributor

Just noticed this after sending out #2494 -- I think this script should also update the _README.md so that if the version is upgraded for the purpose of taking advantage of new esbuild features, then the docs don't point people to old versions of esbuild which don't support the new features.

@mattem
Copy link
Collaborator

mattem commented Mar 1, 2021

This should also update the repo in the examples folder too https://github.com/bazelbuild/rules_nodejs/blob/stable/examples/esbuild/WORKSPACE#L28

@alexeagle
Copy link
Collaborator

@JesseTatasciore ping us if you need help to get this green

@@ -25,12 +25,12 @@ http_archive(
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.2.2/rules_nodejs-3.2.2.tar.gz"],
)

_ESBUILD_VERSION = "0.8.48"
_ESBUILD_VERSION = "0.9.6"
Copy link
Collaborator

Choose a reason for hiding this comment

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

As there are breaking changes in this version, I don't think we should bump to it. This diff is about adding the update script (change one thing at a time :) )

replaceFileContent('packages/esbuild/_README.md', fileReplacements);
}

main();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this always update to latest, or is there a way to force it to a version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to allow for a version to be specified when running the script. Can be run as:
node ./scripts/update-esbuild-versions.js 0.8.57

@mattem mattem marked this pull request as ready for review April 6, 2021 21:20
@mattem mattem merged commit 472ed62 into bazel-contrib:stable Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants