Commit | Line | Data |
---|---|---|
a3d3b7a4 AI |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net> | |
4112ff7e | 3 | ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net> |
99863166 | 4 | ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
cb5b5149 | 5 | ;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il> |
11b43f99 | 6 | ;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr> |
a3d3b7a4 AI |
7 | ;;; |
8 | ;;; This file is part of GNU Guix. | |
9 | ;;; | |
10 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
11 | ;;; under the terms of the GNU General Public License as published by | |
12 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
13 | ;;; your option) any later version. | |
14 | ;;; | |
15 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
16 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;;; GNU General Public License for more details. | |
19 | ;;; | |
20 | ;;; You should have received a copy of the GNU General Public License | |
21 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
22 | ||
23 | (define-module (gnu packages javascript) | |
24 | #:use-module ((guix licenses) #:prefix license:) | |
25 | #:use-module (gnu packages) | |
26 | #:use-module (gnu packages base) | |
27 | #:use-module (gnu packages compression) | |
a3d3b7a4 | 28 | #:use-module (gnu packages lisp) |
88f06fd0 | 29 | #:use-module (gnu packages lisp-xyz) |
99863166 | 30 | #:use-module (gnu packages readline) |
a3d3b7a4 AI |
31 | #:use-module (guix packages) |
32 | #:use-module (guix download) | |
68ffb6c5 | 33 | #:use-module (guix git-download) |
89ba894e | 34 | #:use-module (guix build-system gnu) |
68ffb6c5 RW |
35 | #:use-module (guix build-system trivial) |
36 | #:use-module (guix build-system minify)) | |
a3d3b7a4 | 37 | |
649c438c LC |
38 | (define-public font-mathjax |
39 | (package | |
40 | (name "font-mathjax") | |
d6a7268b | 41 | (version "2.7.2") |
649c438c LC |
42 | (source |
43 | (origin | |
44 | (method url-fetch) | |
45 | (uri (string-append | |
46 | "https://github.com/mathjax/MathJax/archive/" | |
47 | version ".tar.gz")) | |
48 | (file-name (string-append name "-" version ".tar.gz")) | |
49 | (sha256 | |
50 | (base32 | |
d6a7268b | 51 | "1r72di4pg4i6pfhcskkxqmf1158m81ki6a7lbw6nz4zh7xw23hy4")))) |
649c438c LC |
52 | (build-system trivial-build-system) |
53 | (arguments | |
54 | `(#:modules ((guix build utils)) | |
55 | #:builder | |
56 | (begin | |
57 | (use-modules (guix build utils) | |
58 | (ice-9 match)) | |
59 | (set-path-environment-variable | |
60 | "PATH" '("bin") (map (match-lambda | |
61 | ((_ . input) | |
62 | input)) | |
63 | %build-inputs)) | |
64 | (let ((install-directory (string-append %output "/share/fonts/mathjax"))) | |
65 | (mkdir-p install-directory) | |
e3cfef22 MW |
66 | (invoke "tar" "-C" install-directory "-xvf" |
67 | (assoc-ref %build-inputs "source") | |
68 | ,(string-append "MathJax-" version "/fonts") | |
69 | "--strip" "2"))))) | |
649c438c LC |
70 | (native-inputs |
71 | `(("gzip" ,gzip) | |
72 | ("tar" ,tar))) | |
73 | (home-page "https://www.mathjax.org/") | |
74 | (synopsis "Fonts for MathJax") | |
75 | (description "This package contains the fonts required for MathJax.") | |
76 | (license license:asl2.0))) | |
77 | ||
a3d3b7a4 AI |
78 | (define-public js-mathjax |
79 | (package | |
80 | (inherit font-mathjax) | |
81 | (name "js-mathjax") | |
82 | (arguments | |
83 | `(#:modules ((guix build utils)) | |
84 | #:builder | |
85 | (begin | |
86 | (use-modules (guix build utils) | |
87 | (ice-9 match) | |
88 | (ice-9 popen) | |
89 | (ice-9 regex)) | |
90 | (set-path-environment-variable | |
91 | "PATH" '("bin") (map (match-lambda | |
92 | ((_ . input) | |
93 | input)) | |
94 | %build-inputs)) | |
95 | (set-path-environment-variable | |
96 | "GUIX_LOCPATH" '("lib/locale") | |
97 | (list (assoc-ref %build-inputs "glibc-utf8-locales"))) | |
98 | (setenv "LANG" "en_US.UTF-8") | |
99 | (let ((install-directory (string-append %output "/share/javascript/mathjax"))) | |
e3cfef22 MW |
100 | (invoke "tar" "xvf" (assoc-ref %build-inputs "source") |
101 | ,(string-append "MathJax-" (package-version font-mathjax) | |
102 | "/unpacked") | |
103 | "--strip" "2") | |
a3d3b7a4 AI |
104 | (mkdir-p install-directory) |
105 | (symlink (string-append (assoc-ref %build-inputs "font-mathjax") | |
106 | "/share/fonts/mathjax") | |
107 | (string-append install-directory "/fonts")) | |
108 | ||
109 | (for-each | |
110 | (lambda (file) | |
111 | (let ((installed (string-append install-directory | |
112 | ;; remove prefix "." | |
113 | (string-drop file 1)))) | |
114 | (format #t "~a -> ~a~%" file installed) | |
115 | (cond | |
116 | ((string-match "\\.js$" file) | |
117 | (mkdir-p (dirname installed)) | |
118 | (let ((minified (open-pipe* OPEN_READ "uglify-js" file))) | |
119 | (call-with-output-file installed | |
120 | (lambda (port) | |
9da2dd90 LC |
121 | (dump-port minified port))) |
122 | ||
123 | (let ((exit (close-pipe minified))) | |
124 | (unless (zero? exit) | |
125 | (error "dear, uglify-js failed" exit))))) | |
a3d3b7a4 AI |
126 | (else |
127 | (install-file file (dirname installed)))))) | |
e3cfef22 MW |
128 | (find-files ".")) |
129 | ||
130 | #t)))) | |
a3d3b7a4 AI |
131 | (native-inputs |
132 | `(("font-mathjax" ,font-mathjax) | |
133 | ("glibc-utf8-locales" ,glibc-utf8-locales) | |
134 | ("uglify-js" ,uglify-js) | |
135 | ,@(package-native-inputs font-mathjax))) | |
136 | (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath") | |
137 | (description "MathJax is a JavaScript display engine for LaTeX, MathML, | |
138 | and AsciiMath notation that works in all modern browsers. It requires no | |
139 | plugins or software to be installed on the browser. So the page author can | |
140 | write web documents that include mathematics and be confident that readers will | |
141 | be able to view it naturally and easily."))) | |
b37b48f8 RW |
142 | |
143 | (define-public js-respond | |
144 | (package | |
145 | (name "js-respond") | |
146 | (version "1.4.2") | |
147 | (source (origin | |
97f6004c EF |
148 | (method git-fetch) |
149 | (uri (git-reference | |
150 | (url "https://github.com/scottjehl/Respond") | |
151 | (commit version))) | |
152 | (file-name (git-file-name name version)) | |
b37b48f8 RW |
153 | (sha256 |
154 | (base32 | |
97f6004c | 155 | "00xid731rirc7sdy1gc8qal3v9g0agr2qx15hm4x97l1lcbylyn2")))) |
367d0833 | 156 | (build-system minify-build-system) |
b37b48f8 | 157 | (arguments |
367d0833 EF |
158 | `(#:javascript-files '("src/matchmedia.addListener.js" |
159 | "src/matchmedia.polyfill.js" | |
160 | "src/respond.js"))) | |
b37b48f8 | 161 | (home-page "https://github.com/scottjehl/Respond") |
b37b48f8 RW |
162 | (synopsis "Polyfill for min/max-width CSS3 Media Queries") |
163 | (description "The goal of this script is to provide a fast and lightweight | |
164 | script to enable responsive web designs in browsers that don't support CSS3 | |
165 | Media Queries.") | |
166 | (license license:expat))) | |
ed69963b RW |
167 | |
168 | (define-public js-html5shiv | |
169 | (package | |
170 | (name "js-html5shiv") | |
171 | (version "3.7.3") | |
172 | (source (origin | |
8a35e58a EF |
173 | (method git-fetch) |
174 | (uri (git-reference | |
175 | (url "https://github.com/aFarkas/html5shiv") | |
176 | (commit version))) | |
177 | (file-name (git-file-name name version)) | |
ed69963b RW |
178 | (sha256 |
179 | (base32 | |
8a35e58a | 180 | "0y1c5nyq0brl9fjdihhax33vks4s1ij9iv113879sg3zflmgqpd0")))) |
ed69963b RW |
181 | (build-system minify-build-system) |
182 | (home-page "https://github.com/aFarkas/html5shiv") | |
183 | (synopsis "Enable HTML5 sectioning elements in legacy browsers") | |
184 | (description "The HTML5 Shiv enables use of HTML5 sectioning elements in | |
185 | legacy Internet Explorer and provides basic HTML5 styling for Internet | |
186 | Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.") | |
187 | ;; From the file "MIT and GPL2 licenses.md": | |
188 | ;; | |
189 | ;; This software is licensed under a dual license system (MIT or GPL | |
190 | ;; version 2). This means you are free to choose with which of both | |
191 | ;; licenses (MIT or GPL version 2) you want to use this library. | |
192 | (license (list license:expat license:gpl2)))) | |
68ffb6c5 RW |
193 | |
194 | (define-public js-json2 | |
195 | (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd") | |
196 | (revision "1")) | |
197 | (package | |
198 | (name "js-json2") | |
199 | (version (string-append "2016-10-28." revision "-" (string-take commit 7))) | |
200 | (source (origin | |
201 | (method git-fetch) | |
202 | (uri (git-reference | |
203 | (url "https://github.com/douglascrockford/JSON-js.git") | |
204 | (commit commit))) | |
205 | (file-name (string-append name "-" version "-checkout")) | |
206 | (sha256 | |
207 | (base32 | |
208 | "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v")))) | |
209 | (build-system minify-build-system) | |
210 | (arguments | |
211 | `(#:javascript-files '("json2.js" | |
212 | "json_parse.js" | |
213 | "json_parse_state.js" | |
214 | "cycle.js"))) | |
215 | (home-page "https://github.com/douglascrockford/JSON-js") | |
216 | (synopsis "JSON encoders and decoders") | |
217 | (description "The files in this collection implement JSON | |
218 | encoders/decoders in JavaScript. | |
219 | ||
220 | @code{json2.js}: This file creates a JSON property in the global object, if | |
221 | there isn't already one, setting its value to an object containing a stringify | |
222 | method and a parse method. The @code{parse} method uses the @code{eval} | |
223 | method to do the parsing, guarding it with several regular expressions to | |
224 | defend against accidental code execution hazards. On current browsers, this | |
225 | file does nothing, preferring the built-in JSON object. | |
226 | ||
227 | @code{json_parse.js}: This file contains an alternative JSON @code{parse} | |
228 | function that uses recursive descent instead of @code{eval}. | |
229 | ||
230 | @code{json_parse_state.js}: This files contains an alternative JSON | |
231 | @code{parse} function that uses a state machine instead of @code{eval}. | |
232 | ||
233 | @code{cycle.js}: This file contains two functions, @code{JSON.decycle} and | |
234 | @code{JSON.retrocycle}, which make it possible to encode cyclical structures | |
235 | and DAGs in JSON, and to then recover them. This is a capability that is not | |
236 | provided by ES5. @code{JSONPath} is used to represent the links.") | |
237 | (license license:public-domain)))) | |
3f48403a RW |
238 | |
239 | (define-public js-strftime | |
240 | (package | |
241 | (name "js-strftime") | |
242 | (version "0.10.0") | |
243 | (source (origin | |
16df2914 EF |
244 | (method git-fetch) |
245 | (uri (git-reference | |
246 | (url"https://github.com/samsonjs/strftime") | |
247 | (commit (string-append "v" version)))) | |
248 | (file-name (git-file-name name version)) | |
3f48403a RW |
249 | (sha256 |
250 | (base32 | |
16df2914 | 251 | "131nmlivazwxyba25kh9lda99749fq4xsyin6lzfalaaydviby4p")))) |
3f48403a RW |
252 | (build-system minify-build-system) |
253 | (arguments | |
254 | `(#:javascript-files '("strftime.js"))) | |
255 | (home-page "https://github.com/samsonjs/strftime") | |
256 | (synopsis "Implementation of strftime to JavaScript") | |
257 | (description "This is an implementation of the @code{strftime} procedure | |
258 | for JavaScript. It works in (at least) node.js and browsers. It supports | |
259 | localization and timezones. Most standard specifiers from C are supported as | |
260 | well as some other extensions from Ruby.") | |
261 | (license license:expat))) | |
a6bbb2a0 RW |
262 | |
263 | (define-public js-highlight | |
264 | (package | |
265 | (name "js-highlight") | |
266 | (version "9.12.0") | |
267 | (source (origin | |
778f4430 EF |
268 | (method git-fetch) |
269 | (uri (git-reference | |
270 | (url "https://github.com/isagalaev/highlight.js") | |
271 | (commit version))) | |
272 | (file-name (git-file-name name version)) | |
a6bbb2a0 RW |
273 | (sha256 |
274 | (base32 | |
778f4430 | 275 | "12qz22qjpd6svj58pwgcwg2x2rzhihfdrxg6lgj39nfpaln6dris")))) |
a6bbb2a0 RW |
276 | (build-system minify-build-system) |
277 | (arguments | |
278 | `(#:javascript-files '("src/highlight.js"))) | |
279 | (home-page "https://github.com/isagalaev/highlight.js") | |
280 | (synopsis "Syntax highlighting for JavaScript") | |
281 | (description "Highlight.js is a syntax highlighter written in JavaScript. | |
282 | It works in the browser as well as on the server. It works with pretty much | |
283 | any markup, doesn’t depend on any framework and has automatic language | |
284 | detection.") | |
285 | (license license:bsd-3))) | |
c4abc94d RW |
286 | |
287 | (define-public js-datatables | |
288 | (package | |
289 | (name "js-datatables") | |
0920b41c | 290 | (version "1.10.19") |
c4abc94d RW |
291 | (source (origin |
292 | (method url-fetch) | |
293 | (uri (string-append "https://datatables.net/releases/DataTables-" | |
294 | version ".zip")) | |
295 | (sha256 | |
296 | (base32 | |
0920b41c | 297 | "0cff8a1g7pjwbjdqq0yzqd963ar7pfi4splmm6rwdzganr77rkhb")))) |
c4abc94d RW |
298 | (build-system minify-build-system) |
299 | (arguments | |
300 | `(#:javascript-files '("media/js/dataTables.bootstrap.js" | |
301 | "media/js/jquery.dataTables.js"))) | |
302 | (native-inputs | |
303 | `(("unzip" ,unzip))) | |
304 | (home-page "https://datatables.net") | |
305 | (synopsis "DataTables plug-in for jQuery") | |
306 | (description "DataTables is a table enhancing plug-in for the jQuery | |
307 | Javascript library, adding sorting, paging and filtering abilities to plain | |
308 | HTML tables with minimal effort.") | |
309 | (license license:expat))) | |
4f65067b | 310 | |
4112ff7e RW |
311 | (define-public js-requirejs |
312 | (package | |
313 | (name "js-requirejs") | |
314 | (version "2.3.6") | |
315 | (source (origin | |
316 | (method git-fetch) | |
317 | (uri (git-reference | |
318 | (url "https://github.com/requirejs/requirejs.git") | |
319 | (commit version))) | |
320 | (file-name (git-file-name name version)) | |
321 | (sha256 | |
322 | (base32 | |
323 | "0cvd5y2mb3h6yil3niqn3gjqrzixdsxcz4rvc2f0hg4kzp5y0w86")))) | |
324 | (build-system minify-build-system) | |
325 | (arguments `(#:javascript-files '("require.js"))) | |
326 | (home-page "https://github.com/requirejs/requirejs/") | |
327 | (synopsis "File and module loader for JavaScript") | |
328 | (description "RequireJS loads plain JavaScript files as well as more | |
329 | defined modules. It is optimized for in-browser use, including in a Web | |
330 | Worker, but it can be used in other JavaScript environments.") | |
331 | (license license:expat))) | |
332 | ||
4f65067b RW |
333 | (define-public js-selectize |
334 | (package | |
335 | (name "js-selectize") | |
3500cb58 | 336 | (version "0.12.6") |
4f65067b | 337 | (source (origin |
41514478 EF |
338 | (method git-fetch) |
339 | (uri (git-reference | |
340 | (url "https://github.com/selectize/selectize.js") | |
341 | (commit (string-append "v" version)))) | |
342 | (file-name (git-file-name name version)) | |
4f65067b RW |
343 | (sha256 |
344 | (base32 | |
3500cb58 | 345 | "15gichl8wi6yxag2ps723nxrgyan15976dzsnvw9h9py8sbyyzjn")))) |
4f65067b RW |
346 | (build-system minify-build-system) |
347 | (arguments `(#:javascript-files '("src/selectize.js"))) | |
348 | (home-page "http://selectize.github.io/selectize.js/") | |
349 | (synopsis "Hybrid widget between a textbox and <select> box") | |
350 | (description "Selectize is the hybrid of a textbox and @code{<select>} | |
351 | box. It's jQuery based and it has autocomplete and native-feeling keyboard | |
352 | navigation; it is useful for tagging, contact lists, etc.") | |
353 | (license license:asl2.0))) | |
0b0aa76f RW |
354 | |
355 | (define-public js-es5-shim | |
356 | (package | |
357 | (name "js-es5-shim") | |
9cf60dec | 358 | (version "4.5.13") |
0b0aa76f | 359 | (source (origin |
2209a447 EF |
360 | (method git-fetch) |
361 | (uri (git-reference | |
362 | (url "https://github.com/es-shims/es5-shim") | |
363 | (commit (string-append "v" version)))) | |
364 | (file-name (git-file-name name version)) | |
0b0aa76f RW |
365 | (sha256 |
366 | (base32 | |
9cf60dec | 367 | "142w384fbyllq4yggv173g82lw3wix4jqcg6hkhx1ymq89vvnpmh")))) |
0b0aa76f RW |
368 | (build-system minify-build-system) |
369 | (arguments `(#:javascript-files | |
370 | '("es5-sham.js" | |
371 | "es5-shim.js"))) | |
372 | (home-page "https://github.com/es-shims/es5-shim") | |
373 | (synopsis "ECMAScript 5 compatibility shims for legacy JavaScript engines") | |
374 | (description "@code{es5-shim.js} patches a JavaScript context to contain | |
375 | all ECMAScript 5 methods that can be faithfully emulated with a legacy | |
376 | JavaScript engine. @code{es5-sham.js} patches other ES5 methods as closely as | |
377 | possible. Many of these shams are intended only to allow code to be written | |
378 | to ES5 without causing run-time errors in older engines. In many cases, this | |
379 | means that these shams cause many ES5 methods to silently fail.") | |
380 | (license license:expat))) | |
89ba894e | 381 | |
11b43f99 NG |
382 | (define-public js-filesaver |
383 | (package | |
384 | (name "js-filesaver") | |
385 | (version "1.3.8") | |
386 | (source (origin | |
e452c69a EF |
387 | (method git-fetch) |
388 | (uri (git-reference | |
389 | (url "https://github.com/eligrey/FileSaver.js") | |
390 | (commit version))) | |
391 | (file-name (git-file-name name version)) | |
11b43f99 NG |
392 | (sha256 |
393 | (base32 | |
e452c69a | 394 | "0gvqk0hnr8fig0n4da7vj7q6z31bcyv52916xz3rbmdj3pgpiv1d")))) |
11b43f99 NG |
395 | (build-system minify-build-system) |
396 | (arguments | |
397 | `(#:phases | |
398 | (modify-phases %standard-phases | |
399 | (add-after 'unpack 'fix-uglification | |
400 | ;; Remove "export" keyword which prevents the file from being | |
401 | ;; uglified by uglify-js. Moreover, that keyword is not present in | |
402 | ;; the minified version of the library some projects are using, | |
403 | ;; e.g., | |
404 | ;; <https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/FileSaver.min.js> | |
405 | (lambda _ | |
406 | (substitute* "src/FileSaver.js" | |
407 | (("export ") "")) | |
408 | #t))))) | |
409 | (home-page | |
410 | "https://eligrey.com/blog/saving-generated-files-on-the-client-side/") | |
411 | (synopsis "HTML5 saveAs() FileSaver implementation") | |
412 | (description "@file{FileSaver.js} implements the @code{saveAs()} | |
413 | FileSaver interface in browsers that do not natively support it. | |
414 | ||
415 | @file{FileSaver.js} is the solution to saving files on the | |
416 | client-side, and is perfect for webapps that need to generate files, | |
417 | or for saving sensitive information that shouldn't be sent to an | |
418 | external server.") | |
419 | (license license:expat))) | |
420 | ||
89ba894e EF |
421 | (define-public mujs |
422 | (package | |
423 | (name "mujs") | |
cb5b5149 | 424 | (version "1.0.6") |
89ba894e | 425 | (source (origin |
cb5b5149 EF |
426 | (method url-fetch) |
427 | (uri (string-append "https://mujs.com/downloads/mujs-" | |
428 | version ".tar.xz")) | |
89ba894e EF |
429 | (sha256 |
430 | (base32 | |
cb5b5149 | 431 | "1q9w2dcspfp580pzx7sw7x9gbn8j0ak6dvj75wd1ml3f3q3i43df")))) |
89ba894e EF |
432 | (build-system gnu-build-system) |
433 | (arguments | |
f8ddf719 EF |
434 | '(#:phases |
435 | (modify-phases %standard-phases | |
436 | (delete 'configure) ; no configure | |
437 | (add-after 'install 'install-shared-library | |
cb5b5149 EF |
438 | (lambda* (#:key (make-flags '()) #:allow-other-keys) |
439 | (apply invoke "make" "install-shared" make-flags)))) | |
89ba894e EF |
440 | #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out")) |
441 | (string-append "CC=gcc")) | |
99863166 TGR |
442 | #:tests? #f)) ; no tests |
443 | (inputs | |
444 | `(("readline" ,readline))) | |
cb5b5149 | 445 | (home-page "https://mujs.com/") |
89ba894e EF |
446 | (synopsis "JavaScript interpreter written in C") |
447 | (description "MuJS is a lightweight Javascript interpreter designed for | |
448 | embedding in other software to extend them with scripting capabilities. MuJS | |
449 | was designed with a focus on small size, correctness, and simplicity. It is | |
450 | written in portable C and implements ECMAScript as specified by ECMA-262. The | |
451 | interface for binding with native code is designed to be as simple as possible | |
452 | to use, and is very similar to Lua. There is no need to interact with byzantine | |
453 | C++ template mechanisms, or worry about marking and unmarking garbage collection | |
454 | roots, or wrestle with obscure build systems.") | |
455 | (license license:isc))) | |
88f06fd0 PN |
456 | |
457 | (define-public uglify-js | |
458 | (package | |
459 | (inherit sbcl-cl-uglify-js) | |
460 | (name "uglify-js") | |
461 | (build-system trivial-build-system) | |
462 | (arguments | |
463 | `(#:modules ((guix build utils)) | |
464 | #:builder | |
465 | (let* ((bin (string-append (assoc-ref %outputs "out") "/bin/")) | |
466 | (script (string-append bin "uglify-js"))) | |
467 | (use-modules (guix build utils)) | |
468 | (mkdir-p bin) | |
469 | (with-output-to-file script | |
470 | (lambda _ | |
471 | (format #t "#!~a/bin/sbcl --script | |
472 | (require :asdf) | |
473 | (push (truename \"~a/lib/sbcl\") asdf:*central-registry*)" | |
474 | (assoc-ref %build-inputs "sbcl") | |
475 | (assoc-ref %build-inputs "sbcl-cl-uglify-js")) | |
476 | ;; FIXME: cannot use progn here because otherwise it fails to | |
477 | ;; find cl-uglify-js. | |
478 | (for-each | |
479 | write | |
480 | '(;; Quiet, please! | |
481 | (let ((*standard-output* (make-broadcast-stream)) | |
482 | (*error-output* (make-broadcast-stream))) | |
483 | (asdf:load-system :cl-uglify-js)) | |
484 | (let ((file (cadr *posix-argv*))) | |
485 | (if file | |
486 | (format t "~a" | |
487 | (cl-uglify-js:ast-gen-code | |
488 | (cl-uglify-js:ast-mangle | |
489 | (cl-uglify-js:ast-squeeze | |
490 | (with-open-file (in file) | |
491 | (parse-js:parse-js in)))) | |
492 | :beautify nil)) | |
493 | (progn | |
494 | (format *error-output* | |
495 | "Please provide a JavaScript file.~%") | |
496 | (sb-ext:exit :code 1)))))))) | |
497 | (chmod script #o755) | |
498 | #t))) | |
499 | (inputs | |
500 | `(("sbcl" ,sbcl) | |
501 | ("sbcl-cl-uglify-js" ,sbcl-cl-uglify-js))) | |
502 | (synopsis "JavaScript compressor"))) |