GNU bug report logs -
#62375
[PATCH 0/1] npm binary importer
Previous Next
Reported by: jlicht <at> fsfe.org
Date: Wed, 22 Mar 2023 11:26:01 UTC
Severity: normal
Tags: moreinfo, patch
Done: Jelle Licht <jlicht <at> fsfe.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hello Jelle!
jlicht <at> fsfe.org skribis:
> From: Jelle Licht <jlicht <at> fsfe.org>
>
> * guix/scripts/import.scm: (importers): Add "npm-binary".
> * guix/import/npm-binary.scm: New file.
> * guix/scripts/import/npm-binary.scm: New file.
> * Makefile.am: Add them.
>
> Co-authored-by: Timothy Sample <samplet <at> ngyro.com>
> Co-authored-by: Lars-Dominik Braun <lars <at> 6xq.net>
Woohoo! I think it’ll be useful to many, even if we know it’s far from
“ideal” by our standards.
We’ll need doc under “Invoking guix import” and tests in
‘tests/npm-binary.scm’, similar to what’s done for the other importers.
The doc should clarify why it’s called that way and what the limitations
are.
For tests, I’d recommend mocking the npmjs.org HTTP servers using
‘with-http-server’ as in ‘tests/cpan.scm’.
Also, please add docstrings to top-level procedures.
> +;; TODO: Support other registries
> +(define *registry* "https://registry.npmjs.org")
> +(define *default-page* "https://www.npmjs.com/package")
The convention currently is more like ‘%registry’.
> +(define (http-error-code arglist)
> + (match arglist
> + (('http-error _ _ _ (code)) code)
> + (_ #f)))
Unused. :-)
> +(define (hash-url url)
> + "Downloads the resource at URL and computes the base32 hash for it."
> + (call-with-temporary-output-file
> + (lambda (temp port)
> + (begin ((@ (guix import utils) url-fetch) url temp)
> + (guix-hash-url temp)))))
Maybe something more like: (port-sha256 (http-fetch …)) ?
> +(define (npm-package->package-sexp npm-package)
> + "Return the `package' s-expression for an NPM-PACKAGE."
> + (define (new-or-existing-inputs resolved-deps)
> + (map package-revision->input resolved-deps))
> +
> + (match npm-package
> + (($ <package-revision> name version home-page dependencies dev-dependencies peer-dependencies license description dist)
Please use ‘match-record’ instead and keep lines below 80 chars. :-)
> + (let* ((name (npm-name->name name))
> + (url (dist-tarball dist))
> + (home-page (if (string? home-page)
> + home-page
> + (string-append *default-page* "/" (uri-encode name))))
> + (synopsis description)
> + (resolved-deps (map (match-lambda (($ <versioned-package> name version)
> + (resolve-package name (string->semver-range version)))) (append dependencies peer-dependencies)))
Likewise.
That’s it! Could you send an updated patch?
Thanks,
Ludo’.
This bug report was last modified 142 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.