From patchwork Thu Dec 30 07:38:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liliana Marie Prikler X-Patchwork-Id: 36012 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6649927BBEA; Thu, 6 Jan 2022 18:26:08 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2A78827BBE9 for ; Thu, 6 Jan 2022 18:26:08 +0000 (GMT) Received: from localhost ([::1]:41140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5XSh-0006wP-98 for patchwork@mira.cbaines.net; Thu, 06 Jan 2022 13:26:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5XRl-0006PT-Ig for guix-patches@gnu.org; Thu, 06 Jan 2022 13:25:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5XRh-0000hG-6D for guix-patches@gnu.org; Thu, 06 Jan 2022 13:25:09 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n5XRh-0004yF-2K for guix-patches@gnu.org; Thu, 06 Jan 2022 13:25:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v8 05/41] guix: node-build-system: Add 'delete-dependencies' helper function. References: <20211114124151.36743-1-philip@philipmcgrath.com> In-Reply-To: <20211114124151.36743-1-philip@philipmcgrath.com> Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 06 Jan 2022 18:25:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51838 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Philip McGrath Cc: 51838@debbugs.gnu.org, Timothy Sample , Pierre Langlois , Jelle Licht , Leo Famulari Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.164149347618865 (code B ref 51838); Thu, 06 Jan 2022 18:25:04 +0000 Received: (at 51838) by debbugs.gnu.org; 6 Jan 2022 18:24:36 +0000 Received: from localhost ([127.0.0.1]:42165 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5XRC-0004tz-S8 for submit@debbugs.gnu.org; Thu, 06 Jan 2022 13:24:35 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:47054) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5XR4-0004rg-3W for 51838@debbugs.gnu.org; Thu, 06 Jan 2022 13:24:26 -0500 Received: by mail-wr1-f66.google.com with SMTP id i22so6446564wrb.13 for <51838@debbugs.gnu.org>; Thu, 06 Jan 2022 10:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:subject:to:cc:content-transfer-encoding:message-id :mime-version; bh=2LIgfx6F5oul3G/TSYbHe6O/EsfD/x022Q59UbO1Kdc=; b=n+oZVHwUu/Qe8cR+x0EpXE/HyXAQ3xCC4gNqT1uD7C7zu7qxMuwvj9gfZkb6MtGEln Z3PS7ZfR68kCpAH0sQASpFEeqDfZuW13IFfRR4WilzQo3RcHEm2q11OfKykDZaFZqADV diYonnP7FHJz3byOUAGMA8jHrQGs/JAb6KMkbRhCTdcAJpQep55YNDe3ltctyUGPhFX0 +B2aZQ2MKKr7f4PCGN3g5qb+hfXzS9PWlwzziVmzfUFYVxu7v2AG04N9GGdLh/iMORf/ BFej2s3IyjRrWJRX1w9KoCAyY+KQgM11thYh0i5fyaEoOtjmLtuhlRd9fSsd8pUEmxwL Ir6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:subject:to:cc :content-transfer-encoding:message-id:mime-version; bh=2LIgfx6F5oul3G/TSYbHe6O/EsfD/x022Q59UbO1Kdc=; b=aGiAt6qs9eR29dXmVySwpcNlh2TsGfkF0S6S+0rKFYGuOGflZDx58fvj+P9OgDSkpF hyGCXcmkTqIc6o0MK9E5TEB5ktAYCu8kVb8/wWUnNLi/wa/laZyxC0xLJOXz7JCNFQYL pEJDsz+vM7MdZgujzWs201SaCJ5EfC4qhiDvKnZdMrFrKSa3tJ9XOyytUfwybgGHZWZo fhVPczcS/QX6o4co4xMskxRUa841lKpWcpFqsmRTXZwEivi22l0B/pmMTmL3tgF0UTdh xXtsGwUiTxXOZJasXYCbwiEReQPwmJ3osGU9kIGDYElNYWKSv/ZL6uOCbI7cu8Sf3gHe gHfw== X-Gm-Message-State: AOAM531xece3PZ8d4MZD5sHtqz9+TniwCUfBFj5UTKe5TraQ/TwOgVmm 54EzK0lr6BDycyykfx0IJnHdkD68WYIGWw== X-Google-Smtp-Source: ABdhPJyoZz38x8YKMYLYGZ+cjaEvHRAn0QnprP6rX6WluQuWEmm3fRULABnRyrEAffuEXbviRL6NAw== X-Received: by 2002:a05:6000:2c8:: with SMTP id o8mr51659751wry.84.1641493460577; Thu, 06 Jan 2022 10:24:20 -0800 (PST) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id b17sm2693311wrq.91.2022.01.06.10.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 10:24:20 -0800 (PST) From: Liliana Marie Prikler Date: Thu, 30 Dec 2021 02:38:43 -0500 Message-ID: <9ae866e3078c04f1716b665b7e2de114fe666514.camel@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Many node packages currently skip the configure phase, because they lack both dependencies and a convenient way to build without all of them, e.g. for the purposes of bootstrapping. This patch adds a big hammer to flatten these nails. * guix/build/node-build-system.scm (delete-dependencies): New variable. Signed-off-by: Liliana Marie Prikler --- guix/build/node-build-system.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm index 49b3db34ad..75bded73af 100644 --- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm @@ -25,11 +25,13 @@ (define-module (guix build node-build-system) #:use-module (guix build utils) #:use-module (guix build json) #:use-module (ice-9 ftw) + #:use-module (ice-9 regex) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-71) #:export (%standard-phases with-atomic-json-file-replacement + delete-dependencies node-build)) (define (with-atomic-json-file-replacement file proc) @@ -184,6 +186,30 @@ (define resolve-dependencies (@))))) #t) +(define (delete-dependencies unwanted) + "Rewrite package.json to remove UNWANTED dependencies. Unwanted dependencies +can be specified as regular expressions to exclude a range of related +dependencies, e.g. \"tap\" excludes all dependencies including \"tap\" in their +name, but \"^tap$\" explicitly excludes \"tap\"." + (define delete-from-jsobject + (match-lambda + (('@ . alist) + (cons '@ (filter (match-lambda + ((k . v) + (not (any + (lambda (pattern) + (string-match pattern k)) + unwanted)))) + alist))))) + + (with-atomic-json-file-replacement "package.json" + (lambda (pkg-meta) + (jsobject-update* + pkg-meta + `("peerDependencies" ,delete-from-jsobject (@)) + `("devDependencies" ,delete-from-jsobject (@)) + `("dependencies" ,delete-from-jsobject (@)))))) + (define* (delete-lockfiles #:key inputs #:allow-other-keys) "Delete 'package-lock.json', 'yarn.lock', and 'npm-shrinkwrap.json', if they exist."