browser4-cli 0.1.11 → 0.1.12

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [
@@ -181,12 +181,14 @@ if (cargoVersion !== version) {
181
181
 
182
182
  // 4. Update Cargo.lock (only in sync mode)
183
183
  if (!checkOnly && cargoVersion !== version) {
184
+ let lockUpdated = false;
184
185
  try {
185
186
  execSync("cargo update -p browser4-cli --offline", {
186
187
  cwd: cargoDir,
187
188
  stdio: "pipe",
188
189
  });
189
190
  console.log(" Updated Cargo.lock");
191
+ lockUpdated = true;
190
192
  } catch {
191
193
  try {
192
194
  execSync("cargo update -p browser4-cli", {
@@ -194,8 +196,34 @@ if (!checkOnly && cargoVersion !== version) {
194
196
  stdio: "pipe",
195
197
  });
196
198
  console.log(" Updated Cargo.lock");
199
+ lockUpdated = true;
197
200
  } catch (e) {
198
- console.error(` Warning: Could not update Cargo.lock: ${e.message}`);
201
+ console.error(` Warning: Could not update Cargo.lock via cargo: ${e.message}`);
202
+ }
203
+ }
204
+
205
+ // Fallback: edit Cargo.lock directly when cargo update fails (e.g. due to
206
+ // lock file version mismatch between the installed cargo and the lock file).
207
+ if (!lockUpdated) {
208
+ const cargoLockPath = join(cargoDir, "Cargo.lock");
209
+ try {
210
+ let lockContent = readFileSync(cargoLockPath, "utf-8");
211
+ // Match the [[package]] block for browser4-cli and replace its version.
212
+ // Works for both v3 and v4 lock file formats.
213
+ const lockPkgRegex = new RegExp(
214
+ `(\\[\\[package\\]\\][\\r\\n]+\\s*name\\s*=\\s*"browser4-cli"[\\r\\n]+\\s*version\\s*=\\s*)"[^"]*"`,
215
+ "m"
216
+ );
217
+ if (lockPkgRegex.test(lockContent)) {
218
+ lockContent = lockContent.replace(lockPkgRegex, `$1"${version}"`);
219
+ writeFileSync(cargoLockPath, lockContent);
220
+ console.log(` Updated Cargo.lock directly: ${cargoVersion} -> ${version}`);
221
+ lockUpdated = true;
222
+ } else {
223
+ console.error(" Warning: Could not find browser4-cli entry in Cargo.lock");
224
+ }
225
+ } catch (e2) {
226
+ console.error(` Warning: Could not update Cargo.lock directly: ${e2.message}`);
199
227
  }
200
228
  }
201
229
  }