>From 54515dbb9e30e3cdf0ac1835c465f157302aefd1 Mon Sep 17 00:00:00 2001 From: swedebugia Date: Sat, 1 Dec 2018 00:15:08 +0100 Subject: [PATCH 2/2] guix: Add blacklisting to recursive importer * guix/import/npm.scm (blacklisted?, npm->guix-package): Remove blacklisted packages from the list passed to the recursive importer. * guix/scripts/import/npm.scm (show-help, %options): Document and improve "recursive" option. * doc/guix.texi (Running guix import): Document the blacklist function. Inspired by ac906cb7bb2ec77821ddec291db4857cc812599d by Ricardo --- doc/guix.texi | 33 ++++++++++++++++++++++++++++++++- guix/import/npm.scm | 16 ++++++++++++---- guix/scripts/import/npm.scm | 10 ++++++++-- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 8f694a20e..ccb3c45f1 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7258,7 +7258,7 @@ guix import npm minimist @end example The importer implements an experimental recursive subsystem, allowing -for a significant of npm packages to be imported. The command below +for a significant number of npm packages to be imported. The command below imports metadata for the @code{optimist} npm package, as well as its dependencies. @@ -7266,6 +7266,37 @@ dependencies. guix import npm -r optimist @end example +The importer currently has does not warn when a cyclic dependency has been +encountered. It will run until the buffer overruns which could take a long +time. You should generally see output every couple of seconds, if not a cyclic +dependency has probably been encountered. These are best avoided by first +packaging an earlier version of one of the packages without the offending +input to avoid the cycle. + address@hidden Note +We have implemented an experimental blacklist functionality, enabled by +default, to help you avoid importing a lot of garbage development +dependencies. You can customize this blacklist by editing address@hidden/import/npm-blacklist.scm} only when running @command{guix import +npm} from a git checkout, see @pxref{Running Guix Before It Is Installed}. + +These packages and every package that begins with these 103 names are +currently blacklisted: (matcha benchmark babel @babel webpack rollup +browserify async ember broccoli nsp uglifyjs2 uglify-js electron statsd vega +grunt-release lineman lerna openlayers openpgp yarnpkg wekan etherpad-lite +meteor keybase docco jsdoc markdown eslint lint markdownlint prettier standard +jscs @ljharb/eslint-config editorconfig-tools jshint xo tick tsml +tsd-check @commitlint safe grunt lerna vows husky nps rimraf colors cli +source-map chai unexpected karma karma-qunit karma-sauce-launcher +karma-browserify coveralls covert nyc qunit mocha yargs sinon code tape +colortape airtap tap tap-spec lab mock nyc proxyquire coffe-script cross-swawn +terst stream-spigot make-generator-function forking-tap bogota faucet gremlins +jest redux-mock-store webdriverio ava enzyme testem protractor testcafe +test262 storybook jasmine volkswagen nightwatch supertest istanbul sizzy +zombie PhantomCSS) +This expands to thousands of packages. address@hidden quotation + @item elpa @cindex elpa Import metadata from an Emacs Lisp Package Archive (ELPA) package diff --git a/guix/import/npm.scm b/guix/import/npm.scm index 2efe81fa9..1d46fd384 100644 --- a/guix/import/npm.scm +++ b/guix/import/npm.scm @@ -350,8 +350,12 @@ a git checkout." ,(guix-hash-url temp-dir))))))))))) (define (blacklisted? name) - "Check if the pair name-version is blacklisted. RETURN #t if yes, else #f." - (member name blacklist)) + "Check if the string name is blacklisted. RETURN #t if yes, else #f." + ;; Split the string to enable ut so blacklist scoped packages like + ;; @babel/core and packages like eslint-popup without having to type in + ;; every single combination. + (if (member (car (string-split name (char-set #\- #\/))) blacklist) + #t #f)) (define (sanitize-npm-version version) "Return version without prefixed ^." @@ -518,8 +522,12 @@ npm list of dependencies DEPENDENCIES." (npm-dependencies (append (extract-npm-dependencies dependencies) - ;; TODO blacklist! - (extract-npm-dependencies dev-dependencies))) + ;; Remove the blacklisted devdeps to avoid big dependency + ;; cycles and all the linters, cli-tools, benchmarking, + ;; etc. JS-devs adds to their development environment. + (remove + blacklisted? + (extract-npm-dependencies dev-dependencies)))) (description (assoc-ref package "description")) (home-page (assoc-ref package "homepage")) (license (extract-license curr)) diff --git a/guix/scripts/import/npm.scm b/guix/scripts/import/npm.scm index 1f4ed777c..c540c3574 100644 --- a/guix/scripts/import/npm.scm +++ b/guix/scripts/import/npm.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 David Thompson +;;; Copyright © 2018 swedebugia ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,7 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-37) + #:use-module (srfi srfi-41) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (guix-import-npm)) @@ -41,7 +43,9 @@ Import and convert the npm package for PACKAGE-NAME.\n")) (display (G_ " -h, --help display this help and exit")) - (display (G_ " + (display (G_ " + -r, --recursive import packages recursively")) + (display (G_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) @@ -88,7 +92,9 @@ `(define-public ,(string->symbol name) ,pkg)) (G_ #f)) - (recursive-import package-name)) + (reverse + (stream->list + (npm-recursive-import package-name)))) ;; Single import (let ((sexp (npm->guix-package package-name))) (unless sexp -- 2.19.1