egisl 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/cli.js +1 -0
- package/llrt.d.ts +5 -0
- package/llrt.js +1 -0
- package/package.json +1 -0
- package/quickjs.d.ts +5 -0
- package/quickjs.js +1 -0
- package/utils.d.ts +34 -0
- package/utils.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Modern JS engine installer (WIP).
|
|
2
|
+
```sh
|
|
3
|
+
# create config file at ./egist.json if not exists, else install all engines in config file
|
|
4
|
+
egist init
|
|
5
|
+
|
|
6
|
+
# latest v8
|
|
7
|
+
egisl add v8
|
|
8
|
+
|
|
9
|
+
# llrt v0.8.1-beta
|
|
10
|
+
egisl add llrt@v0.8.1-beta
|
|
11
|
+
|
|
12
|
+
# quickjs 2026-06-04 build for x64 arch
|
|
13
|
+
egisl add quickjs@2026-06-04_x64
|
|
14
|
+
|
|
15
|
+
# llrt v0.8.1-beta for x64 linux
|
|
16
|
+
egisl add llrt@v0.8.1-beta_x64_linux
|
|
17
|
+
|
|
18
|
+
# add multiple engines
|
|
19
|
+
egisl add v8 quickjs llrt jsc hermes spidermonkey xs
|
|
20
|
+
|
|
21
|
+
# remove engines, similar arguments to egist add
|
|
22
|
+
egisl remove ...
|
|
23
|
+
|
|
24
|
+
# alias binaries, similar arguments to egist add
|
|
25
|
+
egist use ...
|
|
26
|
+
```
|
package/cli.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/llrt.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Arch, type Installer, type OS } from "./utils.ts";
|
|
2
|
+
import { type Unzipped } from "fflate/node";
|
|
3
|
+
export declare const getLink: (releaseTag: string, arch: Arch, os: OS) => string;
|
|
4
|
+
export declare const getBinary: (zipLink: string) => Promise<Unzipped[string]>;
|
|
5
|
+
export declare const install: Installer;
|
package/llrt.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDir,formatBytes,saveBinary,unsupportedTarget}from"./utils.js";import{unzipSync}from"fflate/node";export const getLink=(releaseTag,arch,os)=>{"x64"===arch||"arm64"===arch||unsupportedTarget(arch,os,"llrt supports linux-x64, linux-arm64, mac-x64, mac-arm64, win-x64, win-arm64");"mac"===os?os="darwin":"win"===os&&(os="windows");return`https://github.com/awslabs/llrt/releases/download/${releaseTag}/llrt-${os}-${arch}.zip`};export const getBinary=async zipLink=>Object.values(unzipSync(await (await fetch(zipLink)).bytes()))[0];export const install=async(id,dest,version,arch,os)=>{let logGroup="[llrt@"+id+"]";dest=await createDir(logGroup,dest,"llrt");let link=getLink(version,arch,os);console.info(logGroup,"fetching",link);let binary=await getBinary(link);console.log(logGroup,"binary size:",formatBytes(binary.byteLength));let llrt=await saveBinary(logGroup,os,dest,id,binary);console.info(logGroup,"done :>");return{llrt}};
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"egisl","version":"0.0.1","description":"Modern JS engine installer","keywords":[],"homepage":"","bin":"cli.js","license":"MIT","repository":"js-benchmark-all/engine-installer","type":"module","dependencies":{"fflate":"^0.8.3"},"exports":{"./*":"./*.js"}}
|
package/quickjs.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Arch, type Installer, type OS } from "./utils.ts";
|
|
2
|
+
import { type Unzipped } from "fflate/node";
|
|
3
|
+
export declare const getLink: (releaseDate: string, arch: Arch, os: OS) => string;
|
|
4
|
+
export declare const getBinary: (zipLink: string) => Promise<Unzipped[string]>;
|
|
5
|
+
export declare const install: Installer;
|
package/quickjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDir,formatBytes,saveBinary,unsupportedTarget}from"./utils.js";import{unzipSync}from"fflate/node";let additionalMsg="quickjs supports linux-x64, linux-x86, win-x64, win-x86";export const getLink=(releaseDate,arch,os)=>{"linux"===os||"win"===os||unsupportedTarget(arch,os,additionalMsg);"x64"===arch?arch="x86_64":"x86"===arch?arch="i686":unsupportedTarget(arch,os,additionalMsg);return`https://bellard.org/quickjs/binary_releases/quickjs-${os}-${arch}-${releaseDate}.zip`};export const getBinary=async zipLink=>unzipSync(await (await fetch(zipLink)).bytes()).qjs;export const install=async(id,dest,version,arch,os)=>{let logGroup="[quickjs@"+id+"]";dest=await createDir(logGroup,dest,"quickjs");let link=getLink(version,arch,os);console.info(logGroup,"fetching",link);let binary=await getBinary(link);console.log(logGroup,"binary size:",formatBytes(binary.byteLength));let qjs=await saveBinary(logGroup,os,dest,id,binary);console.info(logGroup,"done :>");return{qjs}};
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
export interface Config {
|
|
3
|
+
/**
|
|
4
|
+
* Default OS.
|
|
5
|
+
*/
|
|
6
|
+
os?: OS;
|
|
7
|
+
/**
|
|
8
|
+
* Default arch.
|
|
9
|
+
*/
|
|
10
|
+
arch?: Arch;
|
|
11
|
+
/**
|
|
12
|
+
* Directory path to install engines, relative to this config file.
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `.egist`.
|
|
15
|
+
*/
|
|
16
|
+
dir: string;
|
|
17
|
+
/**
|
|
18
|
+
* Installed engine binaries.
|
|
19
|
+
*/
|
|
20
|
+
engines: Record<string, Record<string, string>>;
|
|
21
|
+
}
|
|
22
|
+
declare const ARCH: readonly ["x64", "x86", "arm64", "arm"];
|
|
23
|
+
export type Arch = typeof ARCH[number];
|
|
24
|
+
declare const OS: readonly ["linux", "win", "mac"];
|
|
25
|
+
export type OS = typeof OS[number];
|
|
26
|
+
export type Installer = (id: string, dest: string, version: string, arch: Arch, os: OS) => Promise<Record<string, string>>;
|
|
27
|
+
export declare const formatBytes: (size: number) => string;
|
|
28
|
+
export declare const unsupportedTarget: (arch: Arch, os: OS, additionalMsg: string) => never;
|
|
29
|
+
export declare const createDir: (logGroup: string, dest: string, id: string) => Promise<string>;
|
|
30
|
+
export declare const saveBinary: (logGroup: string, os: OS, dest: string, id: string, binary: Parameters<typeof writeFile>[1]) => Promise<string>;
|
|
31
|
+
export declare const useBinary: (logGroup: string, os: OS, dest: string, id: string, binPath: string) => Promise<string>;
|
|
32
|
+
export declare const assertOS: (v: string) => OS;
|
|
33
|
+
export declare const assertArch: (v: string) => Arch;
|
|
34
|
+
export {};
|
package/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdir,writeFile}from"node:fs/promises";import{join,relative}from"node:path";let ARCH=["x64","x86","arm64","arm"],OS=["linux","win","mac"];export const formatBytes=size=>{let unit="b";if(size>=1e6){size/=1e6;unit="mb"}else if(size>=1e3){size/=1e3;unit="kb"}return Math.round(100*size)/100+unit};export const unsupportedTarget=(arch,os,additionalMsg)=>{throw new Error(`installer does not support ${os}-${arch} (${additionalMsg})`)};export const createDir=async(logGroup,dest,id)=>{dest=join(dest,id);console.info(logGroup,"creating",relative(".",dest));await mkdir(dest,{recursive:!0});return dest};export const saveBinary=async(logGroup,os,dest,id,binary)=>{dest=join(dest,"win"===os?id+".exe":id);console.info(logGroup,"saving to",relative(".",dest));await writeFile(dest,binary);return dest};export const useBinary=async(logGroup,os,dest,id,binPath)=>{if("win"===os){dest=join(dest,id+".cmd");console.info(logGroup,"saving script to",relative(".",dest));await writeFile(dest,`@echo off\n"${binPath}" %*`)}else{dest=join(dest,id);console.info(logGroup,"saving script to",relative(".",dest));await writeFile(dest,`#!/usr/bin/env bash\n"${binPath}" "$@"`)}return dest};export const assertOS=v=>{if(OS.includes(v))return v;throw new Error(`expected: ${OS.join(", ")}. recieved: ${v}.`)};export const assertArch=v=>{if(ARCH.includes(v))return v;throw new Error(`expected: ${ARCH.join(", ")}. recieved: ${v}.`)};
|