@iflow-ai/iflow-cli 0.3.22 → 0.3.23-beta.20251121150829

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iflow-ai/iflow-cli",
3
- "version": "0.3.22",
3
+ "version": "0.3.23-beta.20251121150829",
4
4
  "engines": {
5
5
  "node": ">=20.0.0"
6
6
  },
@@ -27,6 +27,7 @@
27
27
  "build:packages": "npm run build --workspaces",
28
28
  "build:sandbox": "node scripts/build_sandbox.js --skip-npm-install-build",
29
29
  "bundle": "npm run generate && node esbuild.config.js && node scripts/copy_bundle_assets.js",
30
+ "postinstall": "node scripts/postinstall-ripgrep.js",
30
31
  "test": "npm run test --workspaces --if-present",
31
32
  "test:ci": "npm run test:ci --workspaces --if-present && npm run test:scripts",
32
33
  "test:scripts": "vitest run --config ./scripts/tests/vitest.config.ts",
@@ -43,7 +44,7 @@
43
44
  "typecheck": "npm run typecheck --workspaces --if-present",
44
45
  "preflight": "npm run clean && npm ci && npm run format && npm run lint:ci && npm run build && npm run typecheck && npm run test:ci",
45
46
  "prepare": "husky",
46
- "prepack": "npm run bundle",
47
+ "prepack": "git lfs pull && npm run bundle",
47
48
  "prepare:package": "node scripts/prepare-package.js",
48
49
  "release:version": "node scripts/version.js",
49
50
  "telemetry": "node scripts/telemetry.js",
@@ -57,6 +58,7 @@
57
58
  "vendors/",
58
59
  "scripts/postinstall-vscode-plugin.js",
59
60
  "scripts/postinstall-idea-plugin.js",
61
+ "scripts/postinstall-ripgrep.js",
60
62
  "README.md",
61
63
  "LICENSE"
62
64
  ],
@@ -0,0 +1,138 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /**
8
+ * Post-install script to remove macOS quarantine attributes from ripgrep binaries.
9
+ * This prevents ENOEXEC errors when spawning the ripgrep process.
10
+ *
11
+ * The quarantine attributes are added by macOS Gatekeeper when files are downloaded
12
+ * from the internet, and can cause spawn() to fail with ENOEXEC intermittently.
13
+ */
14
+
15
+ import { execSync } from 'child_process';
16
+ import { existsSync, readdirSync, statSync, readFileSync } from 'fs';
17
+ import { join, dirname } from 'path';
18
+ import { fileURLToPath } from 'url';
19
+
20
+ const __dirname = dirname(fileURLToPath(import.meta.url));
21
+ const vendorsDir = join(__dirname, '..', 'vendors', 'ripgrep');
22
+
23
+ /**
24
+ * Checks if a file is a Git LFS pointer file
25
+ * @param {string} filePath - Path to the file
26
+ * @returns {boolean} True if the file is a Git LFS pointer
27
+ */
28
+ function isGitLFSPointer(filePath) {
29
+ try {
30
+ const stat = statSync(filePath);
31
+ // Git LFS pointers are small text files (usually < 200 bytes)
32
+ if (stat.size > 500) {
33
+ return false;
34
+ }
35
+
36
+ const content = readFileSync(filePath, 'utf8');
37
+ return content.startsWith('version https://git-lfs.github.com/spec/');
38
+ } catch {
39
+ return false;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Removes problematic extended attributes from a file on macOS
45
+ * This includes quarantine and cache attributes that can cause ENOEXEC
46
+ * Note: com.apple.provenance cannot be removed but doesn't cause issues
47
+ * @param {string} filePath - Path to the file
48
+ */
49
+ function removeQuarantineAttribute(filePath) {
50
+ if (process.platform !== 'darwin') {
51
+ return; // Only needed on macOS
52
+ }
53
+
54
+ const attributesToRemove = [
55
+ 'com.apple.quarantine',
56
+ 'CachedFileMimeType',
57
+ 'CachedFileType',
58
+ 'FileXRayCachedResultInEA',
59
+ ];
60
+
61
+ let removed = false;
62
+ for (const attr of attributesToRemove) {
63
+ try {
64
+ execSync(`xattr -d "${attr}" "${filePath}" 2>/dev/null`, {
65
+ stdio: 'ignore',
66
+ });
67
+ removed = true;
68
+ } catch {
69
+ // Attribute might not exist, continue
70
+ }
71
+ }
72
+
73
+ if (removed) {
74
+ console.log(` ✓ Removed extended attributes from ${filePath}`);
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Recursively finds and processes ripgrep binaries
80
+ * @param {string} dir - Directory to search
81
+ */
82
+ function processRipgrepBinaries(dir) {
83
+ if (!existsSync(dir)) {
84
+ console.log(
85
+ 'Ripgrep vendors directory not found, skipping quarantine removal.',
86
+ );
87
+ return;
88
+ }
89
+
90
+ const entries = readdirSync(dir);
91
+ let hasGitLFSPointers = false;
92
+
93
+ for (const entry of entries) {
94
+ const fullPath = join(dir, entry);
95
+ const stat = statSync(fullPath);
96
+
97
+ if (stat.isDirectory()) {
98
+ // Recurse into subdirectories
99
+ processRipgrepBinaries(fullPath);
100
+ } else if (entry === 'rg' || entry === 'rg.exe') {
101
+ // Check if this is a Git LFS pointer file
102
+ if (isGitLFSPointer(fullPath)) {
103
+ console.error(
104
+ ` ✗ Error: ${fullPath} is a Git LFS pointer file, not a real binary!`,
105
+ );
106
+ console.error(
107
+ ` This will cause ENOEXEC errors when trying to execute ripgrep.`,
108
+ );
109
+ console.error(
110
+ ` Please ensure Git LFS is installed and run: git lfs pull`,
111
+ );
112
+ hasGitLFSPointers = true;
113
+ } else {
114
+ // Found a real ripgrep binary
115
+ removeQuarantineAttribute(fullPath);
116
+ }
117
+ }
118
+ }
119
+
120
+ if (hasGitLFSPointers) {
121
+ console.error(
122
+ '\n⚠️ WARNING: Some ripgrep binaries are Git LFS pointer files.',
123
+ );
124
+ console.error(
125
+ ' The search functionality will not work until these are replaced with real binaries.',
126
+ );
127
+ console.error(' To fix this, run: git lfs install && git lfs pull\n');
128
+ }
129
+ }
130
+
131
+ // Main execution
132
+ if (process.platform === 'darwin') {
133
+ console.log('Removing macOS quarantine attributes from ripgrep binaries...');
134
+ processRipgrepBinaries(vendorsDir);
135
+ console.log('Done!');
136
+ } else {
137
+ console.log('Skipping quarantine removal (not on macOS)');
138
+ }