@cparra/apex-reflection 2.22.0-dev.20251224082625 → 2.22.0
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/index.d.ts +4 -1
- package/dist/index.js +20 -57
- package/dist/out.d.ts +3 -0
- package/dist/out.js +31506 -0
- package/package.json +3 -15
- package/publish-scripts/postinstall.js +0 -199
package/package.json
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apex-reflection",
|
|
3
|
-
"version": "2.22.0
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Provides tools for reflecting Apex code, the language used in Salesforce development.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"clean": "rimraf dist",
|
|
8
8
|
"build": "npm run clean && tsc",
|
|
9
|
-
"postinstall": "node publish-scripts/postinstall.js",
|
|
10
|
-
"dev:build": "npm run build && npm run dev:build:native:host && npm run dev:chmod:native:host",
|
|
11
|
-
"dev:build:native:host": "node scripts/build-natives.js --host",
|
|
12
|
-
"dev:chmod:native:host": "node scripts/dev-chmod-native-host.js",
|
|
13
|
-
"dev:version:prerelease": "node scripts/dev-bump-version-prerelease.js",
|
|
14
|
-
"dev:publish": "node scripts/dev-publish.js",
|
|
15
9
|
"test": "jest"
|
|
16
10
|
},
|
|
17
11
|
"keywords": [
|
|
@@ -26,7 +20,6 @@
|
|
|
26
20
|
"devDependencies": {
|
|
27
21
|
"@types/jest": "^27.0.2",
|
|
28
22
|
"@types/node": "^16.18.98",
|
|
29
|
-
"@types/shelljs": "^0.10.0",
|
|
30
23
|
"@types/typescript": "^2.0.0",
|
|
31
24
|
"jest": "^27.2.4",
|
|
32
25
|
"rimraf": "^6.0.1",
|
|
@@ -35,11 +28,6 @@
|
|
|
35
28
|
},
|
|
36
29
|
"types": "dist/index.d.ts",
|
|
37
30
|
"files": [
|
|
38
|
-
"dist
|
|
39
|
-
|
|
40
|
-
"publish-scripts/postinstall.js"
|
|
41
|
-
],
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"shelljs": "^0.10.0"
|
|
44
|
-
}
|
|
31
|
+
"dist"
|
|
32
|
+
]
|
|
45
33
|
}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Postinstall script (publishable):
|
|
5
|
-
* - Downloads the correct native binary for the current platform/arch from GitHub Releases
|
|
6
|
-
* - Stores it inside this package at: dist/native/<platform-arch>/<binaryName>
|
|
7
|
-
* - Ensures executable permissions on Unix-like systems
|
|
8
|
-
*
|
|
9
|
-
* Asset naming convention (GitHub Release assets):
|
|
10
|
-
* apex-reflection-<platform>-<arch>[.exe]
|
|
11
|
-
*
|
|
12
|
-
* Where:
|
|
13
|
-
* platform: darwin | linux | windows
|
|
14
|
-
* arch: x64 | arm64 (darwin supports both; linux/windows only x64 in this setup)
|
|
15
|
-
*
|
|
16
|
-
* The GitHub release tag is expected to be:
|
|
17
|
-
* v<version> (version taken from this package's package.json)
|
|
18
|
-
*
|
|
19
|
-
* This keeps the npm package small by downloading only the needed binary at install time.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const https = require("https");
|
|
23
|
-
const fs = require("fs");
|
|
24
|
-
const path = require("path");
|
|
25
|
-
const stream = require("stream");
|
|
26
|
-
const { promisify } = require("util");
|
|
27
|
-
|
|
28
|
-
const pipeline = promisify(stream.pipeline);
|
|
29
|
-
|
|
30
|
-
const REPO_OWNER = "cesarParra";
|
|
31
|
-
const REPO_NAME = "apex-reflection";
|
|
32
|
-
|
|
33
|
-
function main() {
|
|
34
|
-
console.log("[apex-reflection] postinstall: installing native binary...");
|
|
35
|
-
|
|
36
|
-
const pkg = readPackageJson();
|
|
37
|
-
const version = pkg.version;
|
|
38
|
-
if (!version || typeof version !== "string") {
|
|
39
|
-
fail("package.json missing a valid `version` field.");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const target = resolveTarget(process.platform, process.arch);
|
|
43
|
-
const assetName = `apex-reflection-${target.releasePlatform}-${target.releaseArch}${target.exeExt}`;
|
|
44
|
-
const tag = `v${version}`;
|
|
45
|
-
|
|
46
|
-
const downloadUrl = `https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/download/${tag}/${assetName}`;
|
|
47
|
-
|
|
48
|
-
const outDir = path.join(__dirname, "..", "dist", "native", target.folderName);
|
|
49
|
-
const outPath = path.join(outDir, target.binaryFileName);
|
|
50
|
-
|
|
51
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
52
|
-
|
|
53
|
-
return downloadFile(downloadUrl, outPath)
|
|
54
|
-
.then(() => {
|
|
55
|
-
if (process.platform !== "win32") {
|
|
56
|
-
try {
|
|
57
|
-
fs.chmodSync(outPath, 0o755);
|
|
58
|
-
} catch (e) {
|
|
59
|
-
console.warn(
|
|
60
|
-
`[apex-reflection] postinstall: could not chmod +x ${outPath}: ${stringifyErr(e)}`
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
console.log(`[apex-reflection] postinstall: native binary installed at: ${outPath}`);
|
|
66
|
-
})
|
|
67
|
-
.catch((err) => {
|
|
68
|
-
console.error("[apex-reflection] postinstall: failed to install native binary.");
|
|
69
|
-
console.error(`[apex-reflection] postinstall: ${stringifyErr(err)}`);
|
|
70
|
-
console.error("[apex-reflection] postinstall: Verify the release assets here:");
|
|
71
|
-
console.error(`https://github.com/${REPO_OWNER}/${REPO_NAME}/releases/tag/${tag}`);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function readPackageJson() {
|
|
77
|
-
const pkgPath = path.join(__dirname, "..", "package.json");
|
|
78
|
-
const raw = fs.readFileSync(pkgPath, "utf8");
|
|
79
|
-
return JSON.parse(raw);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function resolveTarget(nodePlatform, nodeArch) {
|
|
83
|
-
const platformMap = {
|
|
84
|
-
darwin: "darwin",
|
|
85
|
-
linux: "linux",
|
|
86
|
-
win32: "windows",
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const releasePlatform = platformMap[nodePlatform];
|
|
90
|
-
if (!releasePlatform) {
|
|
91
|
-
throw new Error(`Unsupported platform: ${nodePlatform}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const supportedArch = new Set(["x64", "arm64"]);
|
|
95
|
-
if (!supportedArch.has(nodeArch)) {
|
|
96
|
-
throw new Error(`Unsupported architecture: ${nodeArch}`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Current intended support
|
|
100
|
-
if (releasePlatform === "linux" && nodeArch !== "x64") {
|
|
101
|
-
throw new Error(`Unsupported architecture for linux: ${nodeArch}`);
|
|
102
|
-
}
|
|
103
|
-
if (releasePlatform === "windows" && nodeArch !== "x64") {
|
|
104
|
-
throw new Error(`Unsupported architecture for windows: ${nodeArch}`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const folderName = `${releasePlatform}-${nodeArch}`;
|
|
108
|
-
const exeExt = releasePlatform === "windows" ? ".exe" : "";
|
|
109
|
-
const binaryFileName = `apex-reflection${exeExt}`;
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
releasePlatform,
|
|
113
|
-
releaseArch: nodeArch,
|
|
114
|
-
folderName,
|
|
115
|
-
exeExt,
|
|
116
|
-
binaryFileName,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function downloadFile(url, destPath) {
|
|
121
|
-
return new Promise((resolve, reject) => {
|
|
122
|
-
const tmpPath = `${destPath}.tmp`;
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath);
|
|
126
|
-
} catch (_) {
|
|
127
|
-
// ignore
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const request = https.get(url, (response) => {
|
|
131
|
-
if (response.statusCode === 301 || response.statusCode === 302) {
|
|
132
|
-
const next = response.headers.location;
|
|
133
|
-
response.resume();
|
|
134
|
-
if (!next) return reject(new Error(`Redirect with no location for ${url}`));
|
|
135
|
-
return downloadFile(next, destPath).then(resolve, reject);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (response.statusCode !== 200) {
|
|
139
|
-
response.resume();
|
|
140
|
-
return reject(new Error(`HTTP ${response.statusCode} while downloading ${url}`));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const totalSize = Number(response.headers["content-length"] || 0);
|
|
144
|
-
let downloaded = 0;
|
|
145
|
-
|
|
146
|
-
response.on("data", (chunk) => {
|
|
147
|
-
downloaded += chunk.length;
|
|
148
|
-
if (totalSize > 0) {
|
|
149
|
-
const pct = Math.floor((downloaded / totalSize) * 100);
|
|
150
|
-
process.stdout.write(`\r[apex-reflection] postinstall: downloading... ${pct}%`);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const file = fs.createWriteStream(tmpPath);
|
|
155
|
-
|
|
156
|
-
pipeline(response, file)
|
|
157
|
-
.then(() => {
|
|
158
|
-
process.stdout.write("\n");
|
|
159
|
-
fs.renameSync(tmpPath, destPath);
|
|
160
|
-
resolve();
|
|
161
|
-
})
|
|
162
|
-
.catch((err) => {
|
|
163
|
-
try {
|
|
164
|
-
if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath);
|
|
165
|
-
} catch (_) {
|
|
166
|
-
// ignore
|
|
167
|
-
}
|
|
168
|
-
reject(err);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
request.on("error", (err) => {
|
|
173
|
-
try {
|
|
174
|
-
if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath);
|
|
175
|
-
} catch (_) {
|
|
176
|
-
// ignore
|
|
177
|
-
}
|
|
178
|
-
reject(err);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function stringifyErr(e) {
|
|
184
|
-
if (!e) return "unknown error";
|
|
185
|
-
if (typeof e === "string") return e;
|
|
186
|
-
if (e && e.message) return e.message;
|
|
187
|
-
try {
|
|
188
|
-
return JSON.stringify(e);
|
|
189
|
-
} catch (_) {
|
|
190
|
-
return String(e);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function fail(msg) {
|
|
195
|
-
console.error(`[apex-reflection] postinstall: ${msg}`);
|
|
196
|
-
process.exit(1);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
Promise.resolve(main());
|