diff options
| author | Maxim Cournoyer <maxim@guixotic.coop> | 2026-08-02 18:18:30 +0900 |
|---|---|---|
| committer | Maxim Cournoyer <maxim@guixotic.coop> | 2026-08-27 10:59:22 +0900 |
| commit | 728408c2b08defad444bfe50856b0f00399f2231 (patch) | |
| tree | 93f41980d384241358f358e64f9d145d2fc6ea58 | |
| parent | b8c45293f72f1bc4694608566ecb15fdc4b1b9ee (diff) | |
build/node: Clean-up deprecation.
(guix build json-utils): should not be deprecating things that are to be
deprecated in (guix build node-build-system). For things now defined in (guix
build json-utils), opt to re-export rather than define a deprecation, as this
would otherwise cause warnings that cannot be resolved (due to the conflicting
definitions).
* guix/build/json-utils.scm: Export with-atomic-json-file-replacement*. Do not
define/export delete-fields, replace-fields and add-fields. Avoid double
definition of with-atomic-json-file-replacement and modify-json.
* guix/build/node-build-system.scm: Streamline imports/re-exports. Do not
deprecate things that were newly added to (guix build json-utils).
* tests/node.scm: Add (guix build json-utils) import.
| -rw-r--r-- | guix/build/json-utils.scm | 20 | ||||
| -rw-r--r-- | guix/build/node-build-system.scm | 44 | ||||
| -rw-r--r-- | tests/node.scm | 1 |
3 files changed, 17 insertions, 48 deletions
diff --git a/guix/build/json-utils.scm b/guix/build/json-utils.scm index 5090daf770e..027f919bdab 100644 --- a/guix/build/json-utils.scm +++ b/guix/build/json-utils.scm | |||
| @@ -35,14 +35,12 @@ | |||
| 35 | #:use-module (srfi srfi-26) | 35 | #:use-module (srfi srfi-26) |
| 36 | #:use-module (srfi srfi-34) | 36 | #:use-module (srfi srfi-34) |
| 37 | #:use-module (srfi srfi-35) | 37 | #:use-module (srfi srfi-35) |
| 38 | #:export (with-atomic-json-file-replacement | 38 | #:export (with-atomic-json-file-replacement ;deprecated |
| 39 | with-atomic-json-file-replacement* | ||
| 39 | modify-json | 40 | modify-json |
| 40 | modify-json-fields | 41 | modify-json-fields |
| 41 | delete-fields | ||
| 42 | delete-json-fields | 42 | delete-json-fields |
| 43 | replace-fields | ||
| 44 | replace-json-fields | 43 | replace-json-fields |
| 45 | add-fields | ||
| 46 | add-json-fields | 44 | add-json-fields |
| 47 | 45 | ||
| 48 | &modify-json-invalid-field-value-error | 46 | &modify-json-invalid-field-value-error |
| @@ -65,13 +63,11 @@ a value to be written as JSON to the replacement FILE." | |||
| 65 | ;; removed in favor of with-atomic-json-file-replacement*'s content eventually. | 63 | ;; removed in favor of with-atomic-json-file-replacement*'s content eventually. |
| 66 | ;; On removal, also remove the (guix deprecation) modules and their closures | 64 | ;; On removal, also remove the (guix deprecation) modules and their closures |
| 67 | ;; from node-build-system imported-modules. | 65 | ;; from node-build-system imported-modules. |
| 68 | (define* (with-atomic-json-file-replacement proc | 66 | (define-deprecated (with-atomic-json-file-replacement proc |
| 69 | #:optional (file "package.json")) | 67 | #:optional (file "package.json")) |
| 68 | with-atomic-json-file-replacement* | ||
| 70 | (with-atomic-json-file-replacement* file proc)) | 69 | (with-atomic-json-file-replacement* file proc)) |
| 71 | 70 | ||
| 72 | (define-deprecated/public-alias with-atomic-json-file-replacement | ||
| 73 | with-atomic-json-file-replacement*) | ||
| 74 | |||
| 75 | ;; This is the function we eventually want to migrate to. | 71 | ;; This is the function we eventually want to migrate to. |
| 76 | (define* (modify-json* file #:rest modifications) | 72 | (define* (modify-json* file #:rest modifications) |
| 77 | "Modify JSON FILE with successive callbacks." | 73 | "Modify JSON FILE with successive callbacks." |
| @@ -205,8 +201,6 @@ invalid field value provided, expected string or list of strings, got ~s~%") | |||
| 205 | (assoc-remove! data key)) | 201 | (assoc-remove! data key)) |
| 206 | #:strict? strict?)) | 202 | #:strict? strict?)) |
| 207 | 203 | ||
| 208 | (define-deprecated/alias delete-fields delete-json-fields) | ||
| 209 | |||
| 210 | (define* (replace-json-fields fields #:key (strict? #t) insert?) | 204 | (define* (replace-json-fields fields #:key (strict? #t) insert?) |
| 211 | "Provides a lambda to supply to modify-json which replaces the value of the | 205 | "Provides a lambda to supply to modify-json which replaces the value of the |
| 212 | supplied field. `fields` is a list of pairs, where the first element is the | 206 | supplied field. `fields` is a list of pairs, where the first element is the |
| @@ -225,14 +219,10 @@ invalid field value provided, expected string or list of strings, got ~s~%") | |||
| 225 | #:insert? insert? | 219 | #:insert? insert? |
| 226 | #:strict? strict?)) | 220 | #:strict? strict?)) |
| 227 | 221 | ||
| 228 | (define-deprecated/alias replace-fields replace-json-fields) | ||
| 229 | |||
| 230 | (define* (add-json-fields fields) | 222 | (define* (add-json-fields fields) |
| 231 | "Like `replace-json-fields', but can insert new fields as well." | 223 | "Like `replace-json-fields', but can insert new fields as well." |
| 232 | (replace-json-fields fields #:insert? #t)) | 224 | (replace-json-fields fields #:insert? #t)) |
| 233 | 225 | ||
| 234 | (define-deprecated/alias add-fields add-json-fields) | ||
| 235 | |||
| 236 | ;;; Local Variables: | 226 | ;;; Local Variables: |
| 237 | ;;; eval: (put 'with-atomic-json-file-replacement 'scheme-indent-function 1) | 227 | ;;; eval: (put 'with-atomic-json-file-replacement 'scheme-indent-function 1) |
| 238 | ;;; eval: (put 'modify-json* 'scheme-indent-function 1) | 228 | ;;; eval: (put 'modify-json* 'scheme-indent-function 1) |
diff --git a/guix/build/node-build-system.scm b/guix/build/node-build-system.scm index 102fc1e0cf1..3767ae68a39 100644 --- a/guix/build/node-build-system.scm +++ b/guix/build/node-build-system.scm | |||
| @@ -25,15 +25,8 @@ | |||
| 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) | ||
| 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) | 28 | #:use-module (guix deprecation) |
| 29 | #:use-module (guix build json-utils) | ||
| 37 | #:use-module (guix build utils) | 30 | #:use-module (guix build utils) |
| 38 | #:use-module (ice-9 format) | 31 | #:use-module (ice-9 format) |
| 39 | #:use-module (ice-9 ftw) | 32 | #:use-module (ice-9 ftw) |
| @@ -49,16 +42,16 @@ | |||
| 49 | delete-dev-dependencies | 42 | delete-dev-dependencies |
| 50 | delete-dev-dependencies/except | 43 | delete-dev-dependencies/except |
| 51 | node-build | 44 | node-build |
| 52 | modify-json | 45 | |
| 46 | ;; The following are deprecated and have been moved to the (guix | ||
| 47 | ;; build json-utils) module. | ||
| 48 | ;; TODO: Remove after 2027/08. | ||
| 53 | delete-fields | 49 | delete-fields |
| 54 | replace-fields | 50 | replace-fields |
| 55 | add-fields) | 51 | add-fields) |
| 56 | #:re-export ((modify-json-fields* . modify-json-fields) | 52 | ;; Also deprecated. |
| 57 | (delete-json-fields* . delete-json-fields) | 53 | #:re-export (with-atomic-json-file-replacement |
| 58 | (replace-json-fields* . replace-json-fields) | 54 | modify-json)) |
| 59 | (add-json-fields* . add-json-fields) | ||
| 60 | (with-atomic-json-file-replacement* | ||
| 61 | . with-atomic-json-file-replacement))) | ||
| 62 | 55 | ||
| 63 | ;;; | 56 | ;;; |
| 64 | ;;; Helpers | 57 | ;;; Helpers |
| @@ -74,33 +67,18 @@ | |||
| 74 | '("devDependencies" | 67 | '("devDependencies" |
| 75 | "peerDependencies")) | 68 | "peerDependencies")) |
| 76 | 69 | ||
| 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 | 70 | (define-deprecated/alias modify-json-fields |
| 84 | (@ (guix build json-utils) modify-json-fields)) | 71 | (@ (guix build json-utils) modify-json-fields)) |
| 85 | 72 | ||
| 86 | (define-deprecated/alias delete-fields | 73 | (define-deprecated/alias delete-fields |
| 87 | (@ (guix build json-utils) delete-json-fields)) | 74 | (@ (guix build json-utils) delete-json-fields)) |
| 88 | 75 | ||
| 89 | (define-deprecated/alias delete-json-fields | ||
| 90 | (@ (guix build json-utils) delete-json-fields)) | ||
| 91 | |||
| 92 | (define-deprecated/alias replace-fields | 76 | (define-deprecated/alias replace-fields |
| 93 | (@ (guix build json-utils) replace-json-fields)) | 77 | (@ (guix build json-utils) replace-json-fields)) |
| 94 | 78 | ||
| 95 | (define-deprecated/alias replace-json-fields | ||
| 96 | (@ (guix build json-utils) replace-json-fields)) | ||
| 97 | |||
| 98 | (define-deprecated/alias add-fields | 79 | (define-deprecated/alias add-fields |
| 99 | (@ (guix build json-utils) add-json-fields)) | 80 | (@ (guix build json-utils) add-json-fields)) |
| 100 | 81 | ||
| 101 | (define-deprecated/alias add-json-fields | ||
| 102 | (@ (guix build json-utils) add-json-fields)) | ||
| 103 | |||
| 104 | (define* (delete-dependencies dependencies-to-remove | 82 | (define* (delete-dependencies dependencies-to-remove |
| 105 | #:key negate? | 83 | #:key negate? |
| 106 | (dependency-keys %dependency-keys)) | 84 | (dependency-keys %dependency-keys)) |
| @@ -142,8 +120,8 @@ dependencies." | |||
| 142 | #:dependency-keys %dev-dependency-keys)) | 120 | #:dependency-keys %dev-dependency-keys)) |
| 143 | 121 | ||
| 144 | (define (delete-dev-dependencies) | 122 | (define (delete-dev-dependencies) |
| 145 | (delete-json-fields* (list "devDependencies" "peerDependencies") | 123 | (delete-json-fields (list "devDependencies" "peerDependencies") |
| 146 | #:strict? #f)) | 124 | #:strict? #f)) |
| 147 | 125 | ||
| 148 | ;;; | 126 | ;;; |
| 149 | ;;; Phases. | 127 | ;;; Phases. |
| @@ -200,7 +178,7 @@ dependencies." | |||
| 200 | (assoc-set! pkg-meta key | 178 | (assoc-set! pkg-meta key |
| 201 | (resolve-dependencies (getter pkg-meta))))) | 179 | (resolve-dependencies (getter pkg-meta))))) |
| 202 | 180 | ||
| 203 | (modify-json* "package.json" | 181 | (modify-json "package.json" |
| 204 | (resolve "devDependencies" | 182 | (resolve "devDependencies" |
| 205 | (lambda (pkg-meta) | 183 | (lambda (pkg-meta) |
| 206 | (or (assoc-ref pkg-meta "devDependencies") '()))) | 184 | (or (assoc-ref pkg-meta "devDependencies") '()))) |
diff --git a/tests/node.scm b/tests/node.scm index 96048cf5cb5..a833bbfe35b 100644 --- a/tests/node.scm +++ b/tests/node.scm | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
| 18 | 18 | ||
| 19 | (use-modules (json) | 19 | (use-modules (json) |
| 20 | (guix build json-utils) | ||
| 20 | (guix build node-build-system) | 21 | (guix build node-build-system) |
| 21 | (guix tests) | 22 | (guix tests) |
| 22 | (srfi srfi-64)) | 23 | (srfi srfi-64)) |
