snow-flow-test 9.0.135-test.2 → 9.0.167-test.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.cjs +45 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "9.0.135-test.2",
3
+ "version": "9.0.167-test.10",
4
4
  "name": "snow-flow-test",
5
5
  "description": "Snow-Flow - AI-powered ServiceNow development CLI with 410+ MCP tools",
6
6
  "type": "module",
package/postinstall.cjs CHANGED
@@ -17,6 +17,10 @@ const distDir = path.join(packageDir, 'dist');
17
17
  const mcpDir = path.join(distDir, 'mcp');
18
18
  const mcpIndexPath = path.join(mcpDir, 'enterprise-proxy', 'index.js');
19
19
 
20
+ // Path to bundled binary (for test packages that include binaries directly)
21
+ const bundledBinaryDir = path.join(distDir, `snow-flow-${platform}-${arch}`, 'bin');
22
+ const bundledBinaryPath = path.join(bundledBinaryDir, binaryName);
23
+
20
24
  // Get version from package.json
21
25
  function getVersion() {
22
26
  try {
@@ -72,6 +76,31 @@ function download(url) {
72
76
  });
73
77
  }
74
78
 
79
+ // Try to copy bundled binary from dist folder (for test packages)
80
+ function copyBundledBinary() {
81
+ if (fs.existsSync(bundledBinaryPath)) {
82
+ console.log(`Found bundled binary for ${platform}-${arch}, installing...`);
83
+ try {
84
+ // Ensure bin directory exists
85
+ if (!fs.existsSync(binDir)) {
86
+ fs.mkdirSync(binDir, { recursive: true });
87
+ }
88
+ // Copy binary
89
+ fs.copyFileSync(bundledBinaryPath, binaryPath);
90
+ // Make executable
91
+ if (platform !== 'windows') {
92
+ fs.chmodSync(binaryPath, 0o755);
93
+ }
94
+ console.log('✅ Binary installed from bundled package!');
95
+ return true;
96
+ } catch (err) {
97
+ console.log(`Could not copy bundled binary: ${err.message}`);
98
+ return false;
99
+ }
100
+ }
101
+ return false;
102
+ }
103
+
75
104
  async function downloadBinary() {
76
105
  const version = getVersion();
77
106
  if (!version) {
@@ -170,23 +199,33 @@ async function main() {
170
199
 
171
200
  // Download binary if missing, incompatible, or version mismatch
172
201
  if (!fs.existsSync(binaryPath)) {
173
- console.log('Binary not found, downloading...');
174
- await downloadBinary();
202
+ console.log('Binary not found, checking for bundled binary...');
203
+ // Try bundled binary first (for test packages), then download
204
+ if (!copyBundledBinary()) {
205
+ console.log('No bundled binary found, downloading from GitHub releases...');
206
+ await downloadBinary();
207
+ }
175
208
  } else if (!binaryWorks) {
176
209
  // Binary exists but can't execute (wrong architecture, corrupted, etc.)
177
- console.log('Binary incompatible with this platform, downloading correct version...');
210
+ console.log('Binary incompatible with this platform, getting correct version...');
178
211
  try {
179
212
  fs.unlinkSync(binaryPath);
180
213
  } catch {}
181
- await downloadBinary();
214
+ // Try bundled binary first, then download
215
+ if (!copyBundledBinary()) {
216
+ await downloadBinary();
217
+ }
182
218
  } else if (packageVersion && binaryVersion && packageVersion !== binaryVersion) {
183
219
  console.log(`Version mismatch: binary is ${binaryVersion}, package is ${packageVersion}`);
184
- console.log('Downloading correct version...');
220
+ console.log('Getting correct version...');
185
221
  // Remove old binary first
186
222
  try {
187
223
  fs.unlinkSync(binaryPath);
188
224
  } catch {}
189
- await downloadBinary();
225
+ // Try bundled binary first, then download
226
+ if (!copyBundledBinary()) {
227
+ await downloadBinary();
228
+ }
190
229
  } else {
191
230
  // Make sure it's executable
192
231
  if (platform !== 'windows') {