guix_mirror_bot pushed a commit to branch javascript-team
in repository guix.

commit 0592761edf9aa132a232d7ea8442aecd5473a804
Author: Maxim Cournoyer <[email protected]>
AuthorDate: Wed Jun 10 08:34:08 2026 +0900

    build/node: Add `add-fields' procedure, and log modifications.
    
    This is to make it easier to re-add some development dependencies, for
    example, following the blanket removal done by the npm-binary importer.  
This
    is also the reason the removed or modified keys are now added.
    
    * guix/build/node-build-system.scm (delete-fields): Log deleted keys.
    (replace-fields) [#:insert?]: New keyword.  Log modified/added keys.
    (add-fields): New procedure.
---
 guix/build/node-build-system.scm | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index 54853c11fb..501fb630bd 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -38,6 +38,7 @@
             delete-dependencies
             delete-dev-dependencies
             delete-fields
+            add-fields
             modify-json
             modify-json-fields
             node-build
@@ -157,10 +158,12 @@ invalid field value provided, expected string or list of 
strings, got ~s~%"
   (modify-json-fields
    fields
    (lambda (_ data key)
+     (format #t "deleting field ~s, of value: ~y~%"
+             key (assoc-ref data key))
      (assoc-remove! data key))
    #:strict? strict?))
 
-(define* (replace-fields fields #:key (strict? #t))
+(define* (replace-fields fields #:key (strict? #t) insert?)
   "Provides a lambda to supply to modify-json which replaces the value of the
  supplied field. `fields` is a list of pairs, where the first element is the
  field-path and the second element is the value to replace the target with.
@@ -171,10 +174,17 @@ invalid field value provided, expected string or list of 
strings, got ~s~%"
   (modify-json-fields
    fields
    (lambda (field data key)
-     (assoc-set! data key (cdr field)))
+     (let ((value (cdr field)))
+       (format #t "setting field ~s to value ~s%" key value)
+       (assoc-set! data key value)))
    #:field-path-mapper (lambda (field) (car field))
+   #:insert? insert?
    #:strict? strict?))
 
+(define* (add-fields fields)
+  "Like `replace-fields', but can insert new fields as well."
+  (replace-fields fields #:insert? #t))
+
 (define (delete-dev-dependencies)
   (delete-fields (list "devDependencies") #:strict? #f))
 

Reply via email to