GNU bug report logs -
#42338
[PATCH] Add composer build system (PHP)
Previous Next
Reported by: Julien Lepiller <julien <at> lepiller.eu>
Date: Sun, 12 Jul 2020 22:22:02 UTC
Severity: normal
Tags: patch
Done: Steve George <steve <at> futurile.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Le Mon, 07 Sep 2020 16:06:13 +0200,
Ludovic Courtès <ludo <at> gnu.org> a écrit :
> Hi Julien,
>
> There’s a lot of interesting work in here! I’m not familiar with PHP;
> I’ll just make a bird’s eye review.
>
> Julien Lepiller <julien <at> lepiller.eu> skribis:
>
> > * guix/import/composer.scm: New file.
> > * guix/scripts/import/composer.scm: New file.
> > * Makefile.am: Add them.
> > * guix/scripts/import.scm: Add composer importer.
>
> Please add tests and a mention in “Invoking guix import” in the
> manual.
>
> For tests, a strategy that I think works well is that used in
> tests/cpan.scm, where we spawn an HTTP server to mock the real one.
>
> > +(define* (composer-fetch name #:optional version)
> > + "Return an alist representation of the Composer metadata for the
> > package NAME, +or #f on failure."
> > + (let ((package (json-fetch
> > + (string-append "https://repo.packagist.org/p/"
> > name ".json"))))
> > + (if package
> > + (let* ((packages (assoc-ref package "packages"))
> > + (package (assoc-ref packages name))
> > + (versions (filter
> > + (lambda (version)
> > + (and (not (string-contains version
> > "dev"))
> > + (not (string-contains version
> > "beta"))))
> > + (map car package)))
> > + (versions (map
> > + (lambda (version)
> > + (cons (fix-version version) version))
> > + versions))
> > + (version (or (if (null? version) #f version)
> > + (latest-version (map car versions)))))
> > + (assoc-ref package (assoc-ref versions version)))
> > + #f)))
>
> I recommend using ‘define-json-mapping’ instead of browsing alists:
> it’s less error-prone, hides the JSON details away, and leads to more
> readable code. The pypi, crates, cpan importers use it.
>
> Thanks!
>
> Ludo’.
Thanks, here's a new version
[0001-guix-import-Add-composer-importer.patch (text/x-patch, attachment)]
This bug report was last modified 271 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.