@maayn/veld 0.1.5 → 0.1.7
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 +4 -5
- package/bin/veld.js +35 -8
- package/binaries/darwin-amd64/veld +0 -0
- package/binaries/darwin-arm64/veld +0 -0
- package/binaries/linux-amd64/veld +0 -0
- package/binaries/linux-arm64/veld +0 -0
- package/binaries/windows-amd64/veld.exe +0 -0
- package/package.json +2 -5
- package/install.js +0 -185
package/README.md
CHANGED
|
@@ -26,17 +26,16 @@ veld openapi # Export OpenAPI 3.0 spec
|
|
|
26
26
|
|
|
27
27
|
## How it works
|
|
28
28
|
|
|
29
|
-
This npm package
|
|
30
|
-
|
|
31
|
-
from [GitHub Releases](https://github.com/Adhamzineldin/Veld/releases).
|
|
29
|
+
This npm package includes pre-built binaries for all supported platforms.
|
|
30
|
+
The wrapper script automatically selects the correct binary for your platform.
|
|
32
31
|
|
|
33
32
|
**Supported platforms:**
|
|
34
33
|
- Linux (x64, arm64)
|
|
35
34
|
- macOS (x64, Apple Silicon)
|
|
36
35
|
- Windows (x64)
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
The package version matches the binary version, so `npm install @maayn/veld@0.2.0`
|
|
38
|
+
installs exactly version 0.2.0. No runtime downloads needed - works offline!
|
|
40
39
|
|
|
41
40
|
## Alternative installation
|
|
42
41
|
|
package/bin/veld.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Veld CLI — npm wrapper
|
|
5
5
|
*
|
|
6
|
-
* This
|
|
7
|
-
*
|
|
8
|
-
* forwarded as-is.
|
|
6
|
+
* This wrapper uses the bundled binary for the current platform.
|
|
7
|
+
* Binaries are included in the package for all supported platforms.
|
|
9
8
|
*/
|
|
10
9
|
|
|
11
10
|
"use strict";
|
|
@@ -15,15 +14,43 @@ const path = require("path");
|
|
|
15
14
|
const fs = require("fs");
|
|
16
15
|
const os = require("os");
|
|
17
16
|
|
|
17
|
+
function getPlatformKey() {
|
|
18
|
+
const platform = os.platform();
|
|
19
|
+
const arch = os.arch();
|
|
20
|
+
|
|
21
|
+
const platformMap = {
|
|
22
|
+
linux: "linux",
|
|
23
|
+
darwin: "darwin",
|
|
24
|
+
win32: "windows",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const archMap = {
|
|
28
|
+
x64: "amd64",
|
|
29
|
+
arm64: "arm64",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const p = platformMap[platform];
|
|
33
|
+
const a = archMap[arch];
|
|
34
|
+
|
|
35
|
+
if (!p || !a) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `${p}-${a}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
18
42
|
function getBinaryName() {
|
|
19
43
|
return os.platform() === "win32" ? "veld.exe" : "veld";
|
|
20
44
|
}
|
|
21
45
|
|
|
22
46
|
function getBinaryPath() {
|
|
23
|
-
//
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
|
|
47
|
+
// Use bundled binary for this platform
|
|
48
|
+
const platformKey = getPlatformKey();
|
|
49
|
+
if (platformKey) {
|
|
50
|
+
const bundledBin = path.join(__dirname, "..", "binaries", platformKey, getBinaryName());
|
|
51
|
+
if (fs.existsSync(bundledBin)) {
|
|
52
|
+
return bundledBin;
|
|
53
|
+
}
|
|
27
54
|
}
|
|
28
55
|
|
|
29
56
|
// Fallback: check if veld is on PATH
|
|
@@ -46,7 +73,7 @@ try {
|
|
|
46
73
|
process.exit(err.status);
|
|
47
74
|
}
|
|
48
75
|
console.error("Error: Could not run veld binary.");
|
|
49
|
-
console.error("Try reinstalling: npm install veld");
|
|
76
|
+
console.error("Try reinstalling: npm install @maayn/veld");
|
|
50
77
|
console.error("");
|
|
51
78
|
console.error("Or install manually:");
|
|
52
79
|
console.error(" go install github.com/Adhamzineldin/Veld/cmd/veld@latest");
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maayn/veld",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Contract-first, multi-stack API code generator. Write .veld contracts once, generate typed frontend SDKs and backend service interfaces.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veld",
|
|
@@ -23,15 +23,12 @@
|
|
|
23
23
|
"bin": {
|
|
24
24
|
"veld": "./bin/veld.js"
|
|
25
25
|
},
|
|
26
|
-
"scripts": {
|
|
27
|
-
"postinstall": "node install.js"
|
|
28
|
-
},
|
|
29
26
|
"engines": {
|
|
30
27
|
"node": ">=16"
|
|
31
28
|
},
|
|
32
29
|
"files": [
|
|
33
30
|
"bin/",
|
|
34
|
-
"
|
|
31
|
+
"binaries/",
|
|
35
32
|
"README.md",
|
|
36
33
|
"LICENSE"
|
|
37
34
|
]
|
package/install.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Veld CLI — postinstall script
|
|
3
|
-
*
|
|
4
|
-
* Downloads the correct pre-built Veld binary for the current platform
|
|
5
|
-
* from GitHub Releases. Falls back to `go install` if the download fails.
|
|
6
|
-
*
|
|
7
|
-
* Supported platforms:
|
|
8
|
-
* - linux-amd64, linux-arm64
|
|
9
|
-
* - darwin-amd64, darwin-arm64
|
|
10
|
-
* - windows-amd64
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
"use strict";
|
|
14
|
-
|
|
15
|
-
const https = require("https");
|
|
16
|
-
const http = require("http");
|
|
17
|
-
const fs = require("fs");
|
|
18
|
-
const path = require("path");
|
|
19
|
-
const os = require("os");
|
|
20
|
-
const { execSync } = require("child_process");
|
|
21
|
-
const zlib = require("zlib");
|
|
22
|
-
|
|
23
|
-
const VERSION = "0.1.0";
|
|
24
|
-
const GITHUB_REPO = "Adhamzineldin/Veld";
|
|
25
|
-
const BASE_URL = `https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}`;
|
|
26
|
-
|
|
27
|
-
function getPlatformKey() {
|
|
28
|
-
const platform = os.platform();
|
|
29
|
-
const arch = os.arch();
|
|
30
|
-
|
|
31
|
-
const platformMap = {
|
|
32
|
-
linux: "linux",
|
|
33
|
-
darwin: "darwin",
|
|
34
|
-
win32: "windows",
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const archMap = {
|
|
38
|
-
x64: "amd64",
|
|
39
|
-
arm64: "arm64",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const p = platformMap[platform];
|
|
43
|
-
const a = archMap[arch];
|
|
44
|
-
|
|
45
|
-
if (!p || !a) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return `${p}-${a}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getBinaryName() {
|
|
53
|
-
return os.platform() === "win32" ? "veld.exe" : "veld";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getDownloadUrl(platformKey) {
|
|
57
|
-
const ext = os.platform() === "win32" ? ".zip" : ".tar.gz";
|
|
58
|
-
return `${BASE_URL}/veld-${platformKey}${ext}`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function download(url) {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
const get = url.startsWith("https") ? https.get : http.get;
|
|
64
|
-
get(url, (res) => {
|
|
65
|
-
// Follow redirects (GitHub sends 302)
|
|
66
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
67
|
-
return download(res.headers.location).then(resolve).catch(reject);
|
|
68
|
-
}
|
|
69
|
-
if (res.statusCode !== 200) {
|
|
70
|
-
reject(new Error(`HTTP ${res.statusCode} downloading ${url}`));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const chunks = [];
|
|
74
|
-
res.on("data", (chunk) => chunks.push(chunk));
|
|
75
|
-
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
76
|
-
res.on("error", reject);
|
|
77
|
-
}).on("error", reject);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function extractTarGz(buffer, destDir) {
|
|
82
|
-
// Write to temp file and use tar
|
|
83
|
-
const tmpFile = path.join(os.tmpdir(), `veld-${Date.now()}.tar.gz`);
|
|
84
|
-
fs.writeFileSync(tmpFile, buffer);
|
|
85
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
86
|
-
try {
|
|
87
|
-
execSync(`tar -xzf "${tmpFile}" -C "${destDir}"`, { stdio: "pipe" });
|
|
88
|
-
} finally {
|
|
89
|
-
fs.unlinkSync(tmpFile);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function extractZip(buffer, destDir) {
|
|
94
|
-
// Write to temp file and use PowerShell / unzip
|
|
95
|
-
const tmpFile = path.join(os.tmpdir(), `veld-${Date.now()}.zip`);
|
|
96
|
-
fs.writeFileSync(tmpFile, buffer);
|
|
97
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
98
|
-
try {
|
|
99
|
-
if (os.platform() === "win32") {
|
|
100
|
-
execSync(
|
|
101
|
-
`powershell -Command "Expand-Archive -Force -Path '${tmpFile}' -DestinationPath '${destDir}'"`,
|
|
102
|
-
{ stdio: "pipe" }
|
|
103
|
-
);
|
|
104
|
-
} else {
|
|
105
|
-
execSync(`unzip -o "${tmpFile}" -d "${destDir}"`, { stdio: "pipe" });
|
|
106
|
-
}
|
|
107
|
-
} finally {
|
|
108
|
-
fs.unlinkSync(tmpFile);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function tryGoInstall() {
|
|
113
|
-
console.log("Attempting fallback: go install github.com/Adhamzineldin/Veld/cmd/veld@latest");
|
|
114
|
-
try {
|
|
115
|
-
execSync("go install github.com/Adhamzineldin/Veld/cmd/veld@latest", {
|
|
116
|
-
stdio: "inherit",
|
|
117
|
-
});
|
|
118
|
-
console.log("✓ Installed veld via go install");
|
|
119
|
-
return true;
|
|
120
|
-
} catch {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async function main() {
|
|
126
|
-
const platformKey = getPlatformKey();
|
|
127
|
-
|
|
128
|
-
if (!platformKey) {
|
|
129
|
-
console.warn(
|
|
130
|
-
`Warning: Unsupported platform ${os.platform()}-${os.arch()}.`
|
|
131
|
-
);
|
|
132
|
-
console.warn("Attempting go install fallback...");
|
|
133
|
-
if (await tryGoInstall()) return;
|
|
134
|
-
console.warn("Install veld manually: go install github.com/Adhamzineldin/Veld/cmd/veld@latest");
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const url = getDownloadUrl(platformKey);
|
|
139
|
-
const destDir = path.join(__dirname, "bin-platform");
|
|
140
|
-
const binaryName = getBinaryName();
|
|
141
|
-
const binaryPath = path.join(destDir, binaryName);
|
|
142
|
-
|
|
143
|
-
// Skip if already downloaded
|
|
144
|
-
if (fs.existsSync(binaryPath)) {
|
|
145
|
-
console.log(`✓ veld binary already exists at ${binaryPath}`);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
console.log(`Downloading veld ${VERSION} for ${platformKey}...`);
|
|
150
|
-
console.log(` ${url}`);
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
const buffer = await download(url);
|
|
154
|
-
|
|
155
|
-
if (os.platform() === "win32") {
|
|
156
|
-
await extractZip(buffer, destDir);
|
|
157
|
-
} else {
|
|
158
|
-
await extractTarGz(buffer, destDir);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Make binary executable on Unix
|
|
162
|
-
if (os.platform() !== "win32") {
|
|
163
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (fs.existsSync(binaryPath)) {
|
|
167
|
-
console.log(`✓ veld ${VERSION} installed successfully`);
|
|
168
|
-
} else {
|
|
169
|
-
throw new Error("Binary not found after extraction");
|
|
170
|
-
}
|
|
171
|
-
} catch (err) {
|
|
172
|
-
console.warn(`Warning: Could not download pre-built binary: ${err.message}`);
|
|
173
|
-
console.warn("");
|
|
174
|
-
|
|
175
|
-
if (await tryGoInstall()) return;
|
|
176
|
-
|
|
177
|
-
console.warn("Install veld manually:");
|
|
178
|
-
console.warn(" go install github.com/Adhamzineldin/Veld/cmd/veld@latest");
|
|
179
|
-
console.warn("");
|
|
180
|
-
console.warn("Or download from: https://github.com/Adhamzineldin/Veld/releases");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
main();
|
|
185
|
-
|