summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2026-03-31 15:08:32 +0200
committerMaxim Cournoyer <maxim@guixotic.coop>2026-08-27 10:59:21 +0900
commit920a214e90127dae0127f25bb6d269dd5f067d65 (patch)
tree97b028c4fee153f5ae9a59540ab04669c454c851
parent6e521fffa4effd01df6bba3247411936dfcb6208 (diff)
build-system/node: Deprecate and export json procedures.
* guix/build/node-build-system.scm (with-atomic-json-file-replacement) (modify-json, modify-json-fields, delete-json-fields) (replace-json-fields): Import, deprecate, then export them. (delete-dev-dependencies, patch-dependencies): Use procedure variants that are not deprecated yet. Change-Id: I492e6e7f1f2e8972a2d2a1a037eb84270946e82b Signed-off-by: Jelle Licht <jlicht@fsfe.org>
-rw-r--r--guix/build/json-utils.scm2
-rw-r--r--guix/build/node-build-system.scm55
2 files changed, 51 insertions, 6 deletions
diff --git a/guix/build/json-utils.scm b/guix/build/json-utils.scm
index 9d94fd85c4d..5090daf770e 100644
--- a/guix/build/json-utils.scm
+++ b/guix/build/json-utils.scm
@@ -75,7 +75,7 @@ a value to be written as JSON to the replacement FILE."
75;; This is the function we eventually want to migrate to. 75;; This is the function we eventually want to migrate to.
76(define* (modify-json* file #:rest modifications) 76(define* (modify-json* file #:rest modifications)
77 "Modify JSON FILE with successive callbacks." 77 "Modify JSON FILE with successive callbacks."
78 (with-atomic-json-file-replacement file 78 (with-atomic-json-file-replacement* file
79 (apply compose modifications))) 79 (apply compose modifications)))
80 80
81;; Copied and adapted from (guix utils). 81;; Copied and adapted from (guix utils).
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm
index be715cc97b3..d08935eeed4 100644
--- a/guix/build/node-build-system.scm
+++ b/guix/build/node-build-system.scm
@@ -25,7 +25,15 @@
25 25
26(define-module (guix build node-build-system) 26(define-module (guix build node-build-system)
27 #:use-module ((guix build gnu-build-system) #:prefix gnu:) 27 #:use-module ((guix build gnu-build-system) #:prefix gnu:)
28 #:use-module (guix build json-utils) 28 #:use-module ((guix build json-utils)
29 #:select ((modify-json . modify-json*)
30 (modify-json-fields . modify-json-fields*)
31 (delete-json-fields . delete-json-fields*)
32 (replace-json-fields . replace-json-fields*)
33 (add-json-fields . add-json-fields*)
34 (with-atomic-json-file-replacement
35 . with-atomic-json-file-replacement*)))
36 #:use-module (guix deprecation)
29 #:use-module (guix build utils) 37 #:use-module (guix build utils)
30 #:use-module (ice-9 format) 38 #:use-module (ice-9 format)
31 #:use-module (ice-9 ftw) 39 #:use-module (ice-9 ftw)
@@ -40,7 +48,17 @@
40 delete-dependencies/except 48 delete-dependencies/except
41 delete-dev-dependencies 49 delete-dev-dependencies
42 delete-dev-dependencies/except 50 delete-dev-dependencies/except
43 node-build)) 51 node-build
52 modify-json
53 delete-fields
54 replace-fields
55 add-fields)
56 #:re-export ((modify-json-fields* . modify-json-fields)
57 (delete-json-fields* . delete-json-fields)
58 (replace-json-fields* . replace-json-fields)
59 (add-json-fields* . add-json-fields)
60 (with-atomic-json-file-replacement*
61 . with-atomic-json-file-replacement)))
44 62
45;;; 63;;;
46;;; Helpers 64;;; Helpers
@@ -56,6 +74,33 @@
56 '("devDependencies" 74 '("devDependencies"
57 "peerDependencies")) 75 "peerDependencies"))
58 76
77(define-deprecated/alias with-atomic-json-file-replacement
78 (@ (guix build json-utils) with-atomic-json-file-replacement))
79
80(define-deprecated/alias modify-json
81 (@ (guix build json-utils) modify-json))
82
83(define-deprecated/alias modify-json-fields
84 (@ (guix build json-utils) modify-json-fields))
85
86(define-deprecated/alias delete-fields
87 (@ (guix build json-utils) delete-json-fields))
88
89(define-deprecated/alias delete-json-fields
90 (@ (guix build json-utils) delete-json-fields))
91
92(define-deprecated/alias replace-fields
93 (@ (guix build json-utils) replace-json-fields))
94
95(define-deprecated/alias replace-json-fields
96 (@ (guix build json-utils) replace-json-fields))
97
98(define-deprecated/alias add-fields
99 (@ (guix build json-utils) add-json-fields))
100
101(define-deprecated/alias add-json-fields
102 (@ (guix build json-utils) add-json-fields))
103
59(define* (delete-dependencies dependencies-to-remove 104(define* (delete-dependencies dependencies-to-remove
60 #:key negate? 105 #:key negate?
61 (dependency-keys %dependency-keys)) 106 (dependency-keys %dependency-keys))
@@ -96,8 +141,8 @@ dependencies."
96 #:dependency-keys %dev-dependency-keys)) 141 #:dependency-keys %dev-dependency-keys))
97 142
98(define (delete-dev-dependencies) 143(define (delete-dev-dependencies)
99 (delete-json-fields (list "devDependencies" "peerDependencies") 144 (delete-json-fields* (list "devDependencies" "peerDependencies")
100 #:strict? #f)) 145 #:strict? #f))
101 146
102;;; 147;;;
103;;; Phases. 148;;; Phases.
@@ -154,7 +199,7 @@ dependencies."
154 (assoc-set! pkg-meta key 199 (assoc-set! pkg-meta key
155 (resolve-dependencies (getter pkg-meta))))) 200 (resolve-dependencies (getter pkg-meta)))))
156 201
157 (modify-json "package.json" 202 (modify-json* "package.json"
158 (resolve "devDependencies" 203 (resolve "devDependencies"
159 (lambda (pkg-meta) 204 (lambda (pkg-meta)
160 (or (assoc-ref pkg-meta "devDependencies") '()))) 205 (or (assoc-ref pkg-meta "devDependencies") '())))