Subject: [bug#55965] [PATCH 8/9] gnu: Add node-crx3.

From: Marius Bakke <[email-masked]>
Date: Thu, 23 Jun 2022 23:17:46 +0200

Nicolas Graves via Guix-patches via <[email-masked]> skriver:

> * gnu/packages/node-xyz.scm (node-crx3): New variable.
> ---
>  gnu/packages/node-xyz.scm | 40 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>
> diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
> index 8ec014eee8..79594856f1 100644
> --- a/gnu/packages/node-xyz.scm
> +++ b/gnu/packages/node-xyz.scm
> @@ -109,6 +109,46 @@ (define-public node-color-name
>       "This package provides a JSON list with color names and their values.")
>      (license license:expat)))
>  
> +(define-public node-crx3
> +  (package
> +    (name "node-crx3")
> +    (version "1.1.3")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/ahwayakchih/crx3")
> +             (commit (string-append "v" version))))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32
> +         "1snqyw8c3s9p2clhqh1172z0rs1was36sfxkk6acgpar32c2rwzw"))))
> +    (build-system node-build-system)
> +    (arguments
> +     '(#:phases
> +       (modify-phases %standard-phases
> +         (delete 'check)
> +         (add-after 'unpack 'replace-mri-by-minimist
> +           (lambda _
> +             (substitute* "package.json"
> +               (("\"mri\": \"\\^1.1.6\",") "\"minimist\": \"^1.2.6\","))

Dots should also be escaped, otherwise they match any character.
Personally I prefer to have the replacement on a second line for
readability but no strong opinion.

> +             (substitute* "lib/configuration.js"
> +               (("mri") "minimist"))
> +             #t))
> +         (replace 'configure
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (invoke (string-append (assoc-ref inputs "node") "/bin/npm")
> +                     "--offline" "--ignore-scripts" "install" "--production")
> +             #t)))))
> +    (inputs (list node-minimist node-pbf node-yazl))
> +    (home-page "https://github.com/ahwayakchih/crx3")
> +    (synopsis "Create web extension files for Chromium and all other browsers
> +supporting the file format and API")

Perhaps 'Create CRXv3 browser extensions with JavaScript'?

Also, can you add your copyright at the top of the file?