warpo 2.1.0 → 2.2.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/dist/lib.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export interface Option {
2
+ env: NodeJS.Dict<string>;
3
+ argv: string[];
4
+ }
5
+ export declare function main(options: Option): Promise<number>;
package/dist/lib.js ADDED
@@ -0,0 +1,45 @@
1
+ import * as os from "node:os";
2
+ import { execSync, spawn } from "node:child_process";
3
+ import { existsSync, readFileSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ const dirname = import.meta.dirname;
6
+ function download_url(version) {
7
+ const arch = os.arch();
8
+ const platform = os.platform();
9
+ if ((platform === "linux" && arch === "x64") || (platform === "darwin" && arch === "arm64")) {
10
+ return `https://github.com/wasm-ecosystem/warpo/releases/download/${version}/warpo-${version}-${platform}-${arch}.tar.gz`;
11
+ }
12
+ console.log(`there is no precompiled binary for ${version} + ${platform} + ${arch}, please compile from source.`);
13
+ process.exit(1);
14
+ }
15
+ function get_binary() {
16
+ if (process.env["WARPO_BINARY_PATH"]) {
17
+ return process.env["WARPO_BINARY_PATH"];
18
+ }
19
+ if (process.env["WARPO_FORCE_DOWNLOAD"] !== "1" && existsSync(join(dirname, "warpo"))) {
20
+ return join(dirname, "warpo", "warpo_asc");
21
+ }
22
+ const version = process.env["WARPO_DOWNLOAD_VERSION"] ||
23
+ JSON.parse(readFileSync(join(dirname, "..", "package.json"), "utf8")).version;
24
+ const url = download_url(version);
25
+ console.log(`downloading warpo from ${url}`);
26
+ execSync(`curl -L ${url} | tar xz -C ${dirname}`, { stdio: "inherit" });
27
+ return join(dirname, "warpo", "warpo_asc");
28
+ }
29
+ export async function main(options) {
30
+ const binary = get_binary();
31
+ const ps = spawn(binary, options.argv, { stdio: "inherit", env: options.env });
32
+ return new Promise((resolve, reject) => {
33
+ function shutdown() {
34
+ ps.kill("SIGTERM");
35
+ reject();
36
+ }
37
+ process.on("SIGINT", shutdown);
38
+ process.on("SIGTERM", shutdown);
39
+ ps.on("close", (e) => {
40
+ process.removeListener("SIGINT", shutdown);
41
+ process.removeListener("SIGTERM", shutdown);
42
+ resolve(e);
43
+ });
44
+ });
45
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/warpo.js CHANGED
@@ -1,38 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import * as os from "node:os";
3
- import { execSync, spawn } from "node:child_process";
4
- import { existsSync, readFileSync } from "node:fs";
5
- import { join } from "node:path";
6
- var dirname = import.meta.dirname;
7
- function download_url(version) {
8
- var arch = os.arch();
9
- var platform = os.platform();
10
- if ((platform === "linux" && arch === "x64") || (platform === "darwin" && arch === "arm64")) {
11
- return "https://github.com/wasm-ecosystem/warpo/releases/download/".concat(version, "/warpo-").concat(version, "-").concat(platform, "-").concat(arch, ".tar.gz");
12
- }
13
- console.log("there is no precompiled binary for ".concat(version, " + ").concat(platform, " + ").concat(arch, ", please compile from source."));
14
- process.exit(1);
15
- }
16
- function get_binary() {
17
- if (process.env["WARPO_BINARY_PATH"]) {
18
- return process.env["WARPO_BINARY_PATH"];
19
- }
20
- if (process.env["WARPO_FORCE_DOWNLOAD"] !== "1" && existsSync(join(dirname, "warpo"))) {
21
- return join(dirname, "warpo", "warpo_asc");
22
- }
23
- var version = process.env["WARPO_DOWNLOAD_VERSION"] ||
24
- JSON.parse(readFileSync(join(dirname, "..", "package.json"), "utf8")).version;
25
- var url = download_url(version);
26
- console.log("downloading warpo from ".concat(url));
27
- execSync("curl -L ".concat(url, " | tar xz -C ").concat(dirname), { stdio: "inherit" });
28
- return join(dirname, "warpo", "warpo_asc");
29
- }
30
- var binary = get_binary();
31
- var ps = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
32
- function shutdown() {
33
- ps.kill("SIGTERM");
34
- process.exit();
35
- }
36
- process.on("SIGINT", shutdown);
37
- process.on("SIGTERM", shutdown);
38
- ps.on("close", function (e) { return process.exit(e); });
2
+ import { main } from "./lib.js";
3
+ import { argv, env } from "node:process";
4
+ process.exit(await main({ argv: argv.slice(2), env: env }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warpo",
3
- "version": "2.1.0",
3
+ "version": "2.2.1",
4
4
  "description": "next generation AssemblyScript compiler with optimizations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  "build:ts": "tsc -p tools/scripts/tsconfig.json",
11
11
  "build:cpp": "cmake -S . -B build && cmake --build build --parallel",
12
12
  "build": "npm run build:ts && npm run build:cpp",
13
- "test:ut": "cd build && ctest --output-on-failure",
13
+ "test:as:ut": "as-test",
14
+ "test:cpp:ut": "cd build && ctest --output-on-failure",
14
15
  "test:as:snapshot": "cross-env-shell ./build/tests/frontend/warpo_frontend_test",
15
16
  "test:opt:snapshot": "node tests/snapshot_diff/index.mjs",
16
17
  "test:bootstrap:debug": "./tests/bootstrap/debug.sh",
@@ -18,7 +19,7 @@
18
19
  "test:debug_symbol": "cross-env-shell ./build/tests/DebugSymbol/TestDebugSymbol",
19
20
  "test:debug_symbol:update": "cross-env-shell build/tests/DebugSymbol/TestDebugSymbol --update-fixtures",
20
21
  "test:driver": "node tests/driver/index.mjs",
21
- "test": "npm run test:ut && npm run test:as:snapshot && npm run test:opt:snapshot && npm run test:driver && npm run test:debug_symbol && npm run test:bootstrap:debug && npm run test:bootstrap:release",
22
+ "test": "npm run test:as:ut && npm run test:cpp:ut && npm run test:as:snapshot && npm run test:opt:snapshot && npm run test:driver && npm run test:debug_symbol && npm run test:bootstrap:debug && npm run test:bootstrap:release",
22
23
  "docs:dev": "vitepress dev docs",
23
24
  "docs:build": "vitepress build docs",
24
25
  "prettier": "prettier --check .",
@@ -44,8 +45,9 @@
44
45
  "devDependencies": {
45
46
  "@assemblyscript/loader": "^0.28.9",
46
47
  "@types/node": "^22.15.21",
47
- "assemblyscript": "^0.28.4",
48
+ "assemblyscript": "^0.28.9",
48
49
  "assemblyscript-prettier": "^3.0.1",
50
+ "assemblyscript-unittest-framework": "^2.0.1",
49
51
  "chalk": "^5.6.2",
50
52
  "cross-env": "^10.1.0",
51
53
  "cspell": "^9.3.0",
@@ -4,6 +4,7 @@
4
4
  "target": "esnext",
5
5
  "module": "commonjs",
6
6
  "noLib": true,
7
+ "resolveJsonModule": true,
7
8
  "allowJs": false,
8
9
  "typeRoots": ["types"],
9
10
  "types": ["warpo"],