mirror of
https://github.com/Mic92/nix-update.git
synced 2024-10-05 14:28:30 +03:00
Merge pull request #217 from Mic92/composer-support
Add support for updating buildComposerProject's vendorHash
This commit is contained in:
commit
36ffca82d2
1
.gitignore
vendored
1
.gitignore
vendored
@ -89,6 +89,7 @@ venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
.direnv
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
|
@ -17,6 +17,7 @@ designed to work with nixpkgs but also other package sets.
|
||||
- update buildRustPackage's cargoHash/cargoSha256 and cargoSetupHook's cargoDeps
|
||||
- update buildGoModule's vendorHash/vendorSha256
|
||||
- update buildNpmPackage's npmDepsHash and npmConfigHook's npmDeps
|
||||
- update buildComposerProject's vendorHash
|
||||
- update fetchYarnDeps offlineCache output hash
|
||||
- update flake outputs (see `--flake`)
|
||||
- build and run the resulting package (see `--build`,
|
||||
|
@ -54,6 +54,7 @@ class Package:
|
||||
cargo_deps: str | None
|
||||
npm_deps: str | None
|
||||
yarn_deps: str | None
|
||||
composer_deps: str | None
|
||||
tests: list[str]
|
||||
has_update_script: bool
|
||||
|
||||
@ -157,6 +158,7 @@ in {{
|
||||
if res.success then res.value.file else false
|
||||
else
|
||||
null;
|
||||
composer_deps = pkg.composerRepository.outputHash or null;
|
||||
npm_deps = pkg.npmDeps.outputHash or null;
|
||||
yarn_deps = pkg.offlineCache.outputHash or null;
|
||||
tests = builtins.attrNames (pkg.passthru.tests or {{}});
|
||||
|
@ -243,6 +243,11 @@ def update_cargo_lock(
|
||||
print(line, end="")
|
||||
|
||||
|
||||
def update_composer_deps_hash(opts: Options, filename: str, current_hash: str) -> None:
|
||||
target_hash = nix_prefetch(opts, "composerRepository")
|
||||
replace_hash(filename, current_hash, target_hash)
|
||||
|
||||
|
||||
def print_hashes(hashes: dict[str, str], indent: str) -> None:
|
||||
if not hashes:
|
||||
return
|
||||
@ -367,6 +372,9 @@ def update(opts: Options) -> Package:
|
||||
):
|
||||
update_cargo_lock(opts, package.filename, package.cargo_lock)
|
||||
|
||||
if package.composer_deps:
|
||||
update_composer_deps_hash(opts, package.filename, package.composer_deps)
|
||||
|
||||
if package.npm_deps:
|
||||
update_npm_deps_hash(opts, package.filename, package.npm_deps)
|
||||
|
||||
|
27
tests/test_composer.py
Normal file
27
tests/test_composer.py
Normal file
@ -0,0 +1,27 @@
|
||||
import subprocess
|
||||
|
||||
import conftest
|
||||
|
||||
from nix_update.options import Options
|
||||
from nix_update.update import update
|
||||
|
||||
|
||||
def test_update(helpers: conftest.Helpers) -> None:
|
||||
with helpers.testpkgs() as path:
|
||||
opts = Options(attribute="composer", import_path=str(path))
|
||||
update(opts)
|
||||
version = subprocess.run(
|
||||
[
|
||||
"nix",
|
||||
"eval",
|
||||
"--raw",
|
||||
"--extra-experimental-features",
|
||||
"nix-command",
|
||||
"-f",
|
||||
path,
|
||||
"composer.version",
|
||||
],
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout.strip()
|
||||
assert tuple(map(int, version.split("."))) >= (0, 11, 1)
|
17
tests/testpkgs/composer.nix
Normal file
17
tests/testpkgs/composer.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{ fetchFromGitHub
|
||||
, php
|
||||
}:
|
||||
|
||||
php.buildComposerProject (finalAttrs: {
|
||||
pname = "castor";
|
||||
version = "0.10.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "jolicode";
|
||||
repo = "castor";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
})
|
@ -4,6 +4,7 @@
|
||||
bitbucket-snapshot = pkgs.callPackage ./bitbucket.nix { isSnapshot = true; };
|
||||
cargoLock.expand = pkgs.callPackage ./cargo-lock-expand { };
|
||||
cargoLock.update = pkgs.callPackage ./cargo-lock-update { };
|
||||
composer = pkgs.callPackage ./composer.nix { };
|
||||
crate = pkgs.callPackage ./crate.nix { };
|
||||
gitea = pkgs.callPackage ./gitea.nix { };
|
||||
github = pkgs.callPackage ./github.nix { };
|
||||
|
Loading…
Reference in New Issue
Block a user