Skip to content

Commit

Permalink
support for updating yarn FOD hash
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-re-ka committed Oct 8, 2021
1 parent 5258281 commit 611438d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nix_update/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Package:
mod_sha256: Optional[str]
vendor_sha256: Optional[str]
cargo_sha256: Optional[str]
yarn_sha256: Optional[str]
tests: List[str]

raw_version_position: InitVar[Optional[Dict[str, Any]]]
Expand Down Expand Up @@ -70,6 +71,7 @@ def eval_expression(import_path: str, attr: str) -> str:
mod_sha256 = pkg.modSha256 or null;
vendor_sha256 = pkg.vendorSha256 or null;
cargo_sha256 = pkg.cargoHash or pkg.cargoSha256 or null;
yarn_sha256 = (pkg.offlineCache or {{}}).outputHash or null;
tests = builtins.attrNames (pkg.passthru.tests or {{}});
}})"""

Expand Down
9 changes: 9 additions & 0 deletions nix_update/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def update_cargo_sha256_hash(opts: Options, filename: str, current_hash: str) ->
replace_hash(filename, current_hash, target_hash)


def update_yarn_sha256_hash(opts: Options, filename: str, current_hash: str) -> None:
expr = f"{{ sha256 }}: (import {opts.import_path} {disable_check_meta(opts)}).{opts.attribute}.offlineCache.overrideAttrs (_: {{ inherit sha256; }})"
target_hash = nix_prefetch([expr])
replace_hash(filename, current_hash, target_hash)


def update_version(
package: Package, version: str, preference: VersionPreference, version_regex: str
) -> bool:
Expand Down Expand Up @@ -160,4 +166,7 @@ def update(opts: Options) -> Package:
if package.cargo_sha256:
update_cargo_sha256_hash(opts, package.filename, package.cargo_sha256)

if package.yarn_sha256:
update_yarn_sha256_hash(opts, package.filename, package.yarn_sha256)

return package

0 comments on commit 611438d

Please sign in to comment.