[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/42: guix: node-build-system: Add 'delete-dependencies' helper functio
From: |
guix-commits |
Subject: |
05/42: guix: node-build-system: Add 'delete-dependencies' helper function. |
Date: |
Sat, 8 Jan 2022 20:09:20 -0500 (EST) |
lilyp pushed a commit to branch master
in repository guix.
commit a62e6e3220e8c7e577b1e682bc1b88273a67de3a
Author: Philip McGrath <philip@philipmcgrath.com>
AuthorDate: Sat Jan 8 03:41:53 2022 -0500
guix: node-build-system: Add 'delete-dependencies' helper function.
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 <liliana.prikler@gmail.com>
---
guix/build/node-build-system.scm | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index a1556ce4b8..bee3792e93 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -25,11 +25,13 @@
#: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)
@@ -187,6 +189,27 @@ found in one of the OBJECTS."
(@)))))
#t)
+(define (delete-dependencies absent)
+ "Rewrite 'package.json' to allow the build to proceed without packages
+listed in ABSENT, a list of strings naming npm packages.
+
+To prevent the deleted dependencies from being reintroduced, use this function
+only after the 'patch-dependencies' phase."
+ (define delete-from-jsobject
+ (match-lambda
+ (('@ . alist)
+ (cons '@ (filter (match-lambda
+ ((k . _)
+ (not (member k absent))))
+ alist)))))
+
+ (with-atomic-json-file-replacement "package.json"
+ (lambda (pkg-meta)
+ (jsobject-update*
+ pkg-meta
+ `("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."
- branch master updated (3e47387805 -> 9d613c36de), guix-commits, 2022/01/08
- 02/42: guix: node-build-system: Add implicit libuv input., guix-commits, 2022/01/08
- 05/42: guix: node-build-system: Add 'delete-dependencies' helper function.,
guix-commits <=
- 08/42: gnu: node-binary-search-bootstrap: Use 'delete-dependencies'., guix-commits, 2022/01/08
- 09/42: gnu: node-debug-bootstrap: Use 'delete-dependencies'., guix-commits, 2022/01/08
- 10/42: gnu: node-llparse-builder-bootstrap: Use 'delete-dependencies'., guix-commits, 2022/01/08
- 13/42: gnu: node-semver: Use 'delete-dependencies'., guix-commits, 2022/01/08
- 14/42: gnu: node-wrappy: Use 'delete-dependencies'., guix-commits, 2022/01/08
- 01/42: guix: node-build-system: Add delete-lockfiles phase., guix-commits, 2022/01/08
- 11/42: gnu: node-llparse-frontend-bootstrap: Use 'delete-dependencies'., guix-commits, 2022/01/08
- 24/42: gnu: Add node-addon-api., guix-commits, 2022/01/08
- 28/42: gnu: Add node-segfault-handler., guix-commits, 2022/01/08
- 26/42: gnu: Add node-file-uri-to-path., guix-commits, 2022/01/08