@cparra/apex-reflection 2.22.0-dev.20251224093546 → 2.23.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 +0 -7
- package/dist/index.js +7 -18
- package/package.json +1 -1
- package/publish-scripts/postinstall.js +2 -10
package/README.md
CHANGED
|
@@ -42,13 +42,6 @@ body was not parsed successfully, with a message indicating where the error occu
|
|
|
42
42
|
Even though this library is exposed as a Node.js library, the project's source code is written in Dart. The source can
|
|
43
43
|
be found in the `lib/src` directory.
|
|
44
44
|
|
|
45
|
-
The Dart source code is transpiled to JS by `dart2js` through the default [grinder](https://pub.dev/packages/grinder)
|
|
46
|
-
workflow within `tool/grind.dart`.
|
|
47
|
-
|
|
48
|
-
To generate the JS files first set up `grinder` locally by following that package's instructions through its pub.dev
|
|
49
|
-
listing, and then you can simply run `grind`. That build takes care of combining the output with `preamble/preamble.js`
|
|
50
|
-
to achieve compatibility with Node.js. The resulting file is `js/apex-reflection-node/out.js`.
|
|
51
|
-
|
|
52
45
|
### Tests
|
|
53
46
|
|
|
54
47
|
Both the Dart source code and the JS output must be tested.
|
package/dist/index.js
CHANGED
|
@@ -41,9 +41,9 @@ function resolveNativeBinaryPath() {
|
|
|
41
41
|
}
|
|
42
42
|
throw new Error(`Native binary not found. Expected one of:\n- ${downloadedPath}\n- ${devBuiltPath}\n\nIf you just installed this package, ensure postinstall succeeded.\nIf you're developing locally, run the dev build to create the host binary.`);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function reflectFor(type, declarationBody) {
|
|
45
45
|
const binaryPath = resolveNativeBinaryPath();
|
|
46
|
-
const result = (0, child_process_1.spawnSync)(binaryPath, [
|
|
46
|
+
const result = (0, child_process_1.spawnSync)(binaryPath, [`--type=${type}`], {
|
|
47
47
|
input: declarationBody,
|
|
48
48
|
encoding: "utf8",
|
|
49
49
|
maxBuffer: 1024 * 1024 * 50,
|
|
@@ -58,6 +58,10 @@ function reflect(declarationBody) {
|
|
|
58
58
|
if (!stdout) {
|
|
59
59
|
throw new Error("apex-reflection native binary produced no output on stdout.");
|
|
60
60
|
}
|
|
61
|
+
return stdout;
|
|
62
|
+
}
|
|
63
|
+
function reflect(declarationBody) {
|
|
64
|
+
const stdout = reflectFor("reflectType", declarationBody);
|
|
61
65
|
try {
|
|
62
66
|
return JSON.parse(stdout);
|
|
63
67
|
}
|
|
@@ -67,22 +71,7 @@ function reflect(declarationBody) {
|
|
|
67
71
|
}
|
|
68
72
|
exports.reflect = reflect;
|
|
69
73
|
function reflectTrigger(declarationBody) {
|
|
70
|
-
const
|
|
71
|
-
const result = (0, child_process_1.spawnSync)(binaryPath, ["--type=reflectTrigger"], {
|
|
72
|
-
input: declarationBody,
|
|
73
|
-
encoding: "utf8",
|
|
74
|
-
maxBuffer: 1024 * 1024 * 50,
|
|
75
|
-
});
|
|
76
|
-
if (result.error) {
|
|
77
|
-
throw new Error(`apex-reflection native binary failed to start. error:\n${String(result.error)}`);
|
|
78
|
-
}
|
|
79
|
-
if (result.status !== 0) {
|
|
80
|
-
throw new Error(`apex-reflection native binary failed (code=${result.status}). stderr:\n${result.stderr ?? ""}`);
|
|
81
|
-
}
|
|
82
|
-
const stdout = (result.stdout ?? "").toString().trim();
|
|
83
|
-
if (!stdout) {
|
|
84
|
-
throw new Error("apex-reflection native binary produced no output on stdout.");
|
|
85
|
-
}
|
|
74
|
+
const stdout = reflectFor("reflectTrigger", declarationBody);
|
|
86
75
|
try {
|
|
87
76
|
return JSON.parse(stdout);
|
|
88
77
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Postinstall script
|
|
4
|
+
* Postinstall script.
|
|
5
5
|
* - Downloads the correct native binary for the current platform/arch from GitHub Releases
|
|
6
6
|
* - Stores it inside this package at: dist/native/<platform-arch>/<binaryName>
|
|
7
7
|
* - Ensures executable permissions on Unix-like systems
|
|
@@ -16,10 +16,7 @@
|
|
|
16
16
|
* The GitHub release tag is expected to be:
|
|
17
17
|
* v<version> (version taken from this package's package.json)
|
|
18
18
|
*
|
|
19
|
-
* This keeps the npm package small by downloading only the needed binary at install time.
|
|
20
|
-
*
|
|
21
19
|
* Note:
|
|
22
|
-
* - Some GitHub UI surfaces show a simplified download URL even when the asset name includes the arch.
|
|
23
20
|
* - To make installs resilient (especially for dev releases), we try multiple possible asset names.
|
|
24
21
|
*/
|
|
25
22
|
|
|
@@ -113,7 +110,6 @@ function resolveTarget(nodePlatform, nodeArch) {
|
|
|
113
110
|
throw new Error(`Unsupported architecture: ${nodeArch}`);
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
// Current intended support
|
|
117
113
|
if (releasePlatform === "linux" && nodeArch !== "x64") {
|
|
118
114
|
throw new Error(`Unsupported architecture for linux: ${nodeArch}`);
|
|
119
115
|
}
|
|
@@ -140,8 +136,6 @@ function buildCandidateAssetNames(target) {
|
|
|
140
136
|
const primary = `apex-reflection-${target.releasePlatform}-${target.releaseArch}${target.exeExt}`;
|
|
141
137
|
|
|
142
138
|
// Fallbacks (mainly for dev flows / edge cases):
|
|
143
|
-
// - Some dev releases might end up with an unsuffixed asset name.
|
|
144
|
-
// - Additionally, for non-windows platforms, try without extension explicitly.
|
|
145
139
|
const fallbacks = [];
|
|
146
140
|
|
|
147
141
|
// Unsuffixed name (no arch/platform)
|
|
@@ -155,13 +149,11 @@ function buildCandidateAssetNames(target) {
|
|
|
155
149
|
|
|
156
150
|
// De-dup while preserving order
|
|
157
151
|
const seen = new Set();
|
|
158
|
-
|
|
152
|
+
return [primary, ...fallbacks].filter((name) => {
|
|
159
153
|
if (seen.has(name)) return false;
|
|
160
154
|
seen.add(name);
|
|
161
155
|
return true;
|
|
162
156
|
});
|
|
163
|
-
|
|
164
|
-
return all;
|
|
165
157
|
}
|
|
166
158
|
|
|
167
159
|
function downloadFirstAvailableAsset(tag, assetNames, destPath) {
|