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

Support limited JS templates in Brioche.download and other statics #118

Merged
merged 5 commits into from
Aug 30, 2024

Conversation

kylewlacy
Copy link
Member

Part of #70

This PR updates the "project analysis" phase to support a limited form of JS template expressions, which can be used by statics like Brioche.download. Templates can currently only include references to the project export from the root module, or trivial values like nested string literals. This means it's pretty limited, but it does allow for one major quality-of-life improvement: referencing the version number in a download URL. Here's a minimal example (based on the jq package):

import * as std from "std";

export const project = {
  name: "jq",
  version: "1.7.1",
};

const source = Brioche.download(
  `https://github.com/jqlang/jq/releases/download/jq-${project.version}/jq-${project.version}.tar.gz`,
)
  .unarchive("tar", "gzip")
  .peel();

// ...

If the value for project.version gets updated, then the new URL will automatically get downloaded, then the new URL and hash will get recorded in the lockfile! This should make managing updates simpler

@kylewlacy kylewlacy merged commit 42ca499 into main Aug 30, 2024
5 checks passed
@kylewlacy kylewlacy deleted the statics-with-templates branch August 30, 2024 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant