GithubHelp home page GithubHelp logo

isabella232 / jsvu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlechromelabs/jsvu

0.0 0.0 0.0 184 KB

JavaScript (engine) Version Updater

Home Page: https://mths.be/jsvu

License: Apache License 2.0

JavaScript 100.00%

jsvu's Introduction

jsvu Build status

jsvu is the JavaScript (engine) Version Updater.

jsvu makes it easy to install recent versions of various JavaScript engines without having to compile them from source.

Installation

Note: jsvu requires Node.js v10+. (jsvu follows the latest active LTS version of Node.)

Install the jsvu CLI:

npm install jsvu -g

Modify your dotfiles (e.g. ~/.bashrc) to add ~/.jsvu to your PATH:

export PATH="${HOME}/.jsvu:${PATH}"

Then, run jsvu:

jsvu

On first run, jsvu prompts you for your operating system and architecture, and the list of JavaScript engines you wish to manage through jsvu. It then downloads and installs the latest version of each of the engines you selected.

To update the installed JavaScript engines later on, just run jsvu again.

Supported engines per OS

JavaScript engine Binary name mac64 win32 win64 linux32 linux64
Chakra chakra or ch
GraalJS graaljs
Hermes hermes & hermes-repl
JavaScriptCore javascriptcore or jsc * *
QuickJS quickjs
SpiderMonkey spidermonkey or sm
V8 v8
V8 debug v8-debug
XS xs (32) (32)

* JavaScriptCore requires external dependencies to run on Windows:

  • On 32-bit Windows, install iTunes.
  • On 64-bit Windows, download the latest WinCairoRequirements and add its bin64 directory to your PATH.

Integration with eshost-cli

eshost-cli makes it easy to run and compare code in all JavaScript engines that jsvu installs.

First, install eshost-cli:

npm install -g eshost-cli

Then, either automatically configure jsvu-installed hosts:

eshost --configure-jsvu

…or tell eshost-cli where jsvu installs each JavaScript engine following the instructions below.

Linux/Mac

eshost --add 'Chakra' ch ~/.jsvu/chakra
eshost --add 'GraalJS' graaljs ~/.jsvu/graaljs
eshost --add 'JavaScriptCore' jsc ~/.jsvu/javascriptcore
eshost --add 'QuickJS' qjs ~/.jsvu/quickjs
eshost --add 'SpiderMonkey' jsshell ~/.jsvu/spidermonkey
eshost --add 'V8 --harmony' d8 ~/.jsvu/v8 --args '--harmony'
eshost --add 'V8' d8 ~/.jsvu/v8
eshost --add 'XS' xs ~/.jsvu/xs

Windows

eshost --add "Chakra" ch "%USERPROFILE%\.jsvu\chakra.cmd"
eshost --add "GraalJS" graaljs "%USERPROFILE%\.jsvu\graaljs.cmd"
eshost --add "JavaScriptCore" jsc "%USERPROFILE%\.jsvu\javascriptcore.cmd"
eshost --add "SpiderMonkey" jsshell "%USERPROFILE%\.jsvu\spidermonkey.cmd"
eshost --add "V8 --harmony" d8 "%USERPROFILE%\.jsvu\v8.cmd" --args "--harmony"
eshost --add "V8" d8 "%USERPROFILE%\.jsvu\v8.cmd"
eshost --add "XS" xs "%USERPROFILE%\.jsvu\xs.cmd"

That’s it! You can now run code snippets in all those engines with a single command:

eshost -e 'new RegExp("\n").toString()' # https://crbug.com/v8/1982

eshost -e '(function maxCallStackSize() { try { return 1 + maxCallStackSize(); } catch (_) { return 1; }}())'

eshost -e 'Date.parse("1 Octopus 2018")'

Integration with non-interactive environments

On your personal devices, the only command you’ll ever need is jsvu as described above. There are no command-line flags to remember. 👋🏻

However, there are use cases for running jsvu within non-interactive environments (e.g. as part of continuous integration), where it’s desirable to bypass the initial jsvu prompt asking to confirm your operating system, architecture, and the list of JavaScript engines to install. Here’s how to do that:

jsvu --os=linux64 --engines=all
# Equivalent to:
jsvu --os=linux64 --engines=chakra,graaljs,hermes,javascriptcore,quickjs,spidermonkey,v8,xs

If the operating system and architecture are not known in advance, the --os=default flag attempts to guess the correct value from the running environment. This might not be right for example if running a 32-bit Node.js process on a 64-bit machine.

Note that --engines=all does not install the v8-debug binaries.

Installing specific versions

jsvu also supports installing specific versions alongside the main engine binaries (which it keeps up to date). Here’s an example:

Binaries installed using this method are named ${BINARY}-${VERSION}, so that the above example installs a binary named v8-7.2.502. This way, there’s never any conflict with the main v8 binary, which jsvu can keep up to date.

This feature works for all the supported engines:

jsvu [email protected]
jsvu [email protected]
jsvu [email protected]
jsvu javascriptcore@242640
jsvu quickjs@2019-08-18
jsvu [email protected]
jsvu [email protected]
jsvu [email protected]
jsvu [email protected]

If you pass in an invalid version number, or if the JavaScript engine creators don’t provide a precompiled binary for that specific version, jsvu shows an error.

As a shorthand, for v8 and v8-debug builds, jsvu can even figure out the last known good revision within a milestone. To install the latest available V8 v7.2.x for example, run:

jsvu [email protected]
# jsvu figures out that this means v7.2.502, and then installs that version.

Security considerations

jsvu avoids the need for sudo privileges by installing everything in ~/.jsvu rather than, say, /usr/bin.

jsvu downloads files over HTTPS, and only uses URLs that are controlled by the creators of the JavaScript engine or, in the case of JavaScriptCore on Linux, the port maintainers.

Author

Mathias Bynens (@mathias)

jsvu's People

Contributors

mathiasbynens avatar fraxken avatar kfarnung avatar paulirish avatar rkirsling avatar thlorenz avatar dcodeio avatar disjukr avatar lpadier avatar marionebl avatar mhofman avatar refack avatar gibson042 avatar dulinriley avatar chicoxyzzy avatar sergiyivan avatar vitallium avatar patrick-soquet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.