From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UKyNOcDszWH5BwEAgWs5BA (envelope-from ) for ; Thu, 30 Dec 2021 18:30:40 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id qBstMsDszWG8agEAG6o9tA (envelope-from ) for ; Thu, 30 Dec 2021 18:30:40 +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 5B2FC37F3F for ; Thu, 30 Dec 2021 18:30:40 +0100 (CET) Received: from localhost ([::1]:54492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2zGB-0002XT-6k for larch@yhetil.org; Thu, 30 Dec 2021 12:30:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2zFc-0002Vg-5t for guix-patches@gnu.org; Thu, 30 Dec 2021 12:30:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:42796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2zFa-0000ls-IS for guix-patches@gnu.org; Thu, 30 Dec 2021 12:30:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n2zFa-0001hX-EW for guix-patches@gnu.org; Thu, 30 Dec 2021 12:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#51838] [PATCH v6 05/41] guix: node-build-system: Add 'delete-dependencies' helper function. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Dec 2021 17:30:02 +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 , 51838@debbugs.gnu.org Cc: Timothy Sample , Pierre Langlois , Jelle Licht Received: via spool by 51838-submit@debbugs.gnu.org id=B51838.16408853876478 (code B ref 51838); Thu, 30 Dec 2021 17:30:02 +0000 Received: (at 51838) by debbugs.gnu.org; 30 Dec 2021 17:29:47 +0000 Received: from localhost ([127.0.0.1]:54342 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2zFL-0001gP-Hh for submit@debbugs.gnu.org; Thu, 30 Dec 2021 12:29:47 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42961) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2zFJ-0001g3-4q for 51838@debbugs.gnu.org; Thu, 30 Dec 2021 12:29:45 -0500 Received: by mail-wr1-f68.google.com with SMTP id w20so42716211wra.9 for <51838@debbugs.gnu.org>; Thu, 30 Dec 2021 09:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=C5Kr+2RcZCN+nDpjSOQlUQgiqpbUGyH6EA8N/SRyDjE=; b=YYQmlehRPuzcezGFYwfyIWLaqfr4Q0qR9C/+/4Vmjv0fCuQDa9KZ2A/Elx1+lAuNT4 mWmQoWIIjkMfDOqb+6jXnvShBScM1Ara65EKjXOBOqumRGWYnfhJ/aEzbnvQG97fA6nL 82fpd2mUItUxpwbSoq2N8S+8HmBTfL6yEYucelK2N4OxWTeNoIYGrDivsXryLRcNlGUE 0jmDoIJCsMJ9WOLtgr+4x93DwYLij0k450OHz196R4QUhx0mRlmhfZhf1PBzimsjVTUG h34JG35UGJw4vVC5bYD7zX2KYPE/humN1pJgJL9YftPLZdjfTNQNAiyEVWK/67jl0OWZ qanQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=C5Kr+2RcZCN+nDpjSOQlUQgiqpbUGyH6EA8N/SRyDjE=; b=WVFW+IAlKnZEVV+AGc5RnqT05wYXCfwryltjKIRf22n9Ri7RnxBndMJLENbdByNym7 f5KJuUuK+ftFFUjURxaBs5J/e3PTvkSVewH5STWTwtRzsO7XWi7bBrEXmTsQf8xG6Tsz P8Rk8XdSz/YXV/bGIYam6TJ7GLvrIp+M+Hh2LYiFMMZvtBeAjupnYchU9+6r/234x1/d epmJbv5Nnem9a8eLApkkuSKkZdrZ5nJFc8qohXkcZgtwozV3ePzsJp0CCLgVSFueyC7a R53eUUvfY/joARTFD1v41njH8wzd7oJHzAAn1IBPatzbWFv5/lc4Nl0PYj2vXpBsKcbk cUMQ== X-Gm-Message-State: AOAM532dl38kLXqFF0n+gEnEtjxHpku3UxEZ7jbMbtdGp/7IYBH4SIVu EmhWXZ1F9ROwDBu/canddLY= X-Google-Smtp-Source: ABdhPJxSwg2Gh9FEd3e9/GFBaylmUDa32EaDPZ6y5gJWjzdoivhbeBvh+fFhzw5XZ6Bdo74uP2kF5w== X-Received: by 2002:a05:6000:1548:: with SMTP id 8mr24655133wry.489.1640885379280; Thu, 30 Dec 2021 09:29:39 -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 e13sm27489257wmq.10.2021.12.30.09.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Dec 2021 09:29:38 -0800 (PST) Message-ID: <7d5dd434d7750123fa32cb623df0463d60d3f82f.camel@gmail.com> From: Liliana Marie Prikler Date: Thu, 30 Dec 2021 18:29:37 +0100 In-Reply-To: <20211230073919.30327-6-philip@philipmcgrath.com> References: <082a81964a43ae5f735ad2ca433d0dfe00859c35.camel@gmail.com> <20211230073919.30327-1-philip@philipmcgrath.com> <20211230073919.30327-6-philip@philipmcgrath.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=1640885440; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=C5Kr+2RcZCN+nDpjSOQlUQgiqpbUGyH6EA8N/SRyDjE=; b=LTOeV1er57ByfLbEAgzRasRlBq3MWJQZFjotZgqU5cBOXfo4mRo0xM372m2LZm1EhhywoZ neOEAM3oPMUqdIGPpCphvUl8xLSt1GxgTKtmh1MU08E8vF18Ca05m5VQe/Mj0PsaLYkaw1 muZIbASGLprJW9qxYirBc0eR7yFIUgBLBOFmI8XvIYNu/e+DIzAWpRyOxaDe5WYzCJNVqn ik4TCrVFE2xugd4cU+BfrHpxxpT5a/3/j8eXbBe8vEUBDmGh/YnezEtr2NogAy3k5Va98J UiNq0ZiGCM9qg1gG1zBAE3EeBR/ALAKXc9AFDdK7G6HS5I0vBC05pxIT7ZjdkA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640885440; a=rsa-sha256; cv=none; b=S6jZEWXLJjO0pf95xdwbFUgfeK931j1hZ1LkBZaHOrIRNsz8jNs+xgWojvoe0MNBZkR8K4 hJBCXZWu1RDUC2Eq5VvZrN9inq0WkLv602NPdgjOZFfPMF0HMeFfQOotv7OcSQd/SrgTx/ rtxnDAtPjWWR6lsq7AVQvdoaLkwn/1fcdT+yvhvx6VVK0rp12w/tpD1wB8Q0gNJo2dsjFw 1kthhgK4O31L7TrDu1ze5Rnr9TMEt5wsNSypJK6tGH+7DJKfKmgeBmEbqyKIvW24atNfjT 4g1CRCNizP79Mhp9vTouS0xBvSQMPTBaNNihXq2WWlDl9r4plvAlLYTcCMSsoA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=YYQmlehR; 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.77 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=YYQmlehR; 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: 5B2FC37F3F X-Spam-Score: -2.77 X-Migadu-Scanner: scn0.migadu.com X-TUID: P/7c3kb/+iTq Am Donnerstag, dem 30.12.2021 um 02:38 -0500 schrieb Philip McGrath: > * guix/build/node-build-system.scm (delete-dependencies): New > exported procedure.  Functionally updates a "package.json"-like value > by removing specified npm packages from the "dependencies" and > "devDependencies" objects. > --- >  guix/build/node-build-system.scm | 18 ++++++++++++++++++ >  1 file changed, 18 insertions(+) > > diff --git a/guix/build/node-build-system.scm b/guix/build/node- > build-system.scm > index dc8b6a41c2..9967223b86 100644 > --- a/guix/build/node-build-system.scm > +++ b/guix/build/node-build-system.scm > @@ -27,6 +27,7 @@ (define-module (guix build node-build-system) >    #:use-module (srfi srfi-1) >    #:export (%standard-phases >              with-atomic-json-file-replacement > +            delete-dependencies >              node-build)) >   >  ;; Commentary: > @@ -325,6 +326,23 @@ (define resolve-dependencies >                                 deps)))))) >    #t) >   > +(define (delete-dependencies pkg-meta absent-dependencies) > +  "Functionally update PKG-META, a json object corresponding to a > +'package.json' file, to allow building without the ABSENT- > DEPENDENCIES.  To > +avoid reintroducing the ABSENT-DEPENDENCIES, only use this procedure > after the > +'patch-dependencies' phase." > +  (define delete-fom-jsobject > +    (match-lambda > +      (('@ . alist) > +       (cons '@ (filter (match-lambda > +                          ((k . v) > +                           (not (member k absent-dependencies)))) > +                        alist))))) > +  (jsobject-update* > +   pkg-meta > +   "devDependencies" '(@) delete-fom-jsobject > +   "dependencies" '(@) delete-fom-jsobject)) Given this rather easy definition in terms of our helper functions, I think this procedure can do more. Particularly, I'd argue that we can define it as such: (define* (delete-dependencies dependencies #:key (file "package.json") (json-keys  '("dependencies" "devDependencies")) "Remove DEPENDENCIES from JSON_KEYS in FILE." (with-atomic-json-file-replacement ...)) This would in turn make it easier to delete dependencies from #:phases, eliminating the need to shorten it to #:absent-dependencies. WDYT?