From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +HThEDc012HpIwAAgWs5BA (envelope-from ) for ; Thu, 06 Jan 2022 19:25:59 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yCOICTc012FhMQAAG6o9tA (envelope-from ) for ; Thu, 06 Jan 2022 19:25:59 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E18D82FF50 for ; Thu, 6 Jan 2022 19:25:58 +0100 (CET) Received: from localhost ([::1]:41140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5XSX-0006wP-Vg for larch@yhetil.org; Thu, 06 Jan 2022 13:25:58 -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 Content-Transfer-Encoding: 7bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1641493558; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2LIgfx6F5oul3G/TSYbHe6O/EsfD/x022Q59UbO1Kdc=; b=EmPVjxGnZjmIpNZCMvwG3q/3bZx8EIHXn90Xmy972YL3g7MrwSFTool24VyGYcYVQojiuh pVA+bQQPyd9SwSZKPog9/1GG4QuQaS4Ole2NdYt0x32YBB3a76HSKs5K1OIoVHT4zvIGuV xC4z4iT1ZXsSyzUxKlKkm3ajtO+nODvKtXgXa9QgxjDgjPGmSOoONquiW4Ewc7IpMydrcC nR0xb3NUXdI/auEBn3SH6WhC/07MoZmNAWDv5c3C1bKB9e1IUjWy3wrRAJMrrNINLlGL9X VytD5uDNd837lIWTIftmI2dlYwmP1ngKpFZVRhPnrRLf0RihjgwKWNUBro/FEg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641493558; a=rsa-sha256; cv=none; b=Ru0IXuZpVXL6/chepPnmLI7+wuTgucCx0LcbPjc3GS8YWDxKhWuFYEwo0IZYe5VBV+cIua FJZMn0DzJgjpTCAJJUJnbi7HaN5jXsNyAKs5P8Xcm4MSUVua6ERnpartTX3Y4owI5cVkyk mc3pDrw37xhN5u7MZ4AidMTztMiRXxR+DYqW/cxlYFHiPnvnHb/tzXH6eBs48hQBc3amUR mCQFKnMsciNl4+tC0FHIyfa08FPhRvQ9r/3APyLTokryOFuL9SY8SvJchyrfLLLJQXGNDl a7gyVbD5G/o5XW73Tr3vCHDjNWphRAQAoG8CPTzhegxVJJ4DLkRNrI4A4vN5ew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=n+oZVHwU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.80 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=n+oZVHwU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E18D82FF50 X-Spam-Score: -2.80 X-Migadu-Scanner: scn0.migadu.com X-TUID: pmW+qRHyFo6l 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." -- 2.34.0