quickjs-zig 1.0.0 → 1.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/package.json +1 -1
- package/postinstall.mjs +31 -10
- package/.gitmodules +0 -3
package/package.json
CHANGED
package/postinstall.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execSync } from 'child_process';
|
|
2
|
-
import { mkdirSync, existsSync, writeFileSync, chmodSync, unlinkSync } from 'fs';
|
|
2
|
+
import { mkdirSync, existsSync, writeFileSync, chmodSync, unlinkSync, renameSync } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import https from 'https';
|
|
@@ -9,6 +9,7 @@ import { fileURLToPath } from 'url';
|
|
|
9
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
const ZIG_VERSION = '0.15.2';
|
|
11
11
|
const BIN_DIR = path.resolve(__dirname, 'bin', 'zig');
|
|
12
|
+
const QUICKJS_DIR = path.resolve(__dirname, 'quickjs');
|
|
12
13
|
|
|
13
14
|
// Mapping for Zig download URLs
|
|
14
15
|
const platformMap = {
|
|
@@ -30,13 +31,16 @@ if (!platform || !arch) {
|
|
|
30
31
|
process.exit(1);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
//
|
|
34
|
+
// Zig download configuration
|
|
34
35
|
const zigTarget = `${arch}-${platform}`;
|
|
35
36
|
const zigFileName = `zig-${zigTarget}-${ZIG_VERSION}.${platform === 'windows' ? 'zip' : 'tar.xz'}`;
|
|
36
37
|
const zigUrl = `https://ziglang.org/download/${ZIG_VERSION}/${zigFileName}`;
|
|
37
|
-
|
|
38
38
|
const ZIG_BIN_PATH = path.join(BIN_DIR, platform === 'windows' ? 'zig.exe' : 'zig');
|
|
39
39
|
|
|
40
|
+
// QuickJS source configuration (using zip for windows, tar.gz for unix)
|
|
41
|
+
const qjsExt = platform === 'windows' ? 'zip' : 'tar.gz';
|
|
42
|
+
const qjsUrl = `https://github.com/bellard/quickjs/archive/refs/heads/master.${qjsExt}`;
|
|
43
|
+
|
|
40
44
|
// --- DOWNLOAD HELPER ---
|
|
41
45
|
const downloadFile = (url, dest) => {
|
|
42
46
|
return new Promise((resolve, reject) => {
|
|
@@ -62,13 +66,30 @@ const downloadFile = (url, dest) => {
|
|
|
62
66
|
async function install() {
|
|
63
67
|
console.log("=== POSTINSTALL: INITIALIZING PROJECT DEPENDENCIES ===");
|
|
64
68
|
|
|
65
|
-
// 1.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
// 1. Download QuickJS source
|
|
70
|
+
if (!existsSync(QUICKJS_DIR)) {
|
|
71
|
+
try {
|
|
72
|
+
console.log(`📥 Downloading QuickJS source (${qjsExt})...`);
|
|
73
|
+
const qjsArchive = path.resolve(__dirname, `qjs.${qjsExt}`);
|
|
74
|
+
await downloadFile(qjsUrl, qjsArchive);
|
|
75
|
+
|
|
76
|
+
if (platform === 'windows') {
|
|
77
|
+
execSync(`powershell -command "Expand-Archive -Path '${qjsArchive}' -DestinationPath '${__dirname}' -Force"`);
|
|
78
|
+
} else {
|
|
79
|
+
execSync(`tar -xzf "${qjsArchive}" -C "${__dirname}"`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const extractedDir = path.resolve(__dirname, 'quickjs-master');
|
|
83
|
+
if (existsSync(extractedDir)) {
|
|
84
|
+
renameSync(extractedDir, QUICKJS_DIR);
|
|
85
|
+
}
|
|
86
|
+
if (existsSync(qjsArchive)) unlinkSync(qjsArchive);
|
|
87
|
+
console.log("✅ QuickJS sources installed.");
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.error(`❌ Failed to install QuickJS: ${err.message}`);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
console.log(`✅ QuickJS source already downloaded.`);
|
|
72
93
|
}
|
|
73
94
|
|
|
74
95
|
// 2. Install Zig Compiler
|
package/.gitmodules
DELETED