GNU bug report logs - #42338
[PATCH] Add composer build system (PHP)

Previous Next

Package: guix-patches;

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

From: Julien Lepiller <julien <at> lepiller.eu>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 42338 <at> debbugs.gnu.org
Subject: [bug#42338] [PATCH 01/34] guix: import: Add composer importer.
Date: Fri, 18 Sep 2020 00:43:33 +0200
[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.