rechrome 1.8.2 → 1.9.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/rech.js +21 -18
  3. package/rech.ts +21 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rechrome",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"
package/rech.js CHANGED
@@ -639,16 +639,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
639
639
  const { extId, token } = primary;
640
640
  const profileEmail = profileInfoSel.user_name || profileDir;
641
641
 
642
- // Save RECHROME_URL
643
- const pwdEnvPath = join(process.cwd(), ".env.local");
644
- const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
645
- const homeEnvPath = join(process.env.HOME!, ".env.local");
646
- const saveChoice = (await ask(
647
- `\n[4/4] Save RECHROME_URL to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n\n Choice [1]: `
648
- )).trim();
649
- const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
650
- if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
651
- const existing = await file(globalEnvPath).text().catch(() => "");
642
+ // Build RECHROME_URL and show it before asking where to save
652
643
  const rechUrl = new URL(url);
653
644
  if (!rechUrl.username) rechUrl.username = randomBytes(9).toString("base64url");
654
645
  rechUrl.searchParams.set("extension_id", extId);
@@ -656,14 +647,26 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
656
647
  rechUrl.searchParams.set("profile", profileEmail);
657
648
  if (userDataDir) rechUrl.searchParams.set("user_data_dir", userDataDir);
658
649
  const newLine = `RECHROME_URL=${rechUrl.toString()}`;
659
- const keysToRemove = ["PLAYWRIGHT_MCP_USER_DATA_DIR", "PLAYWRIGHT_MCP_EXTENSION_ID", "PLAYWRIGHT_MCP_EXTENSION_TOKEN", "PLAYWRIGHT_MCP_PROFILE_DIRECTORY"];
660
- let lines = existing.trimEnd().split("\n").filter(l => !keysToRemove.some(k => l.startsWith(`${k}=`)));
661
- const rechIdx = lines.findIndex(l => l.startsWith("RECHROME_URL="));
662
- if (rechIdx >= 0) lines[rechIdx] = newLine;
663
- else lines.push(newLine);
664
- await Bun.write(globalEnvPath, lines.join("\n").trim() + "\n");
665
- console.log(`\nSaved to ${globalEnvPath}`);
666
- console.log(`\n ${newLine}`);
650
+ console.log(`\n[4/4] Your RECHROME_URL:\n\n ${newLine}\n`);
651
+
652
+ const pwdEnvPath = join(process.cwd(), ".env.local");
653
+ const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
654
+ const homeEnvPath = join(process.env.HOME!, ".env.local");
655
+ const saveChoice = (await ask(
656
+ `Save to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n 4. Skip (already copied)\n\n Choice [1]: `
657
+ )).trim();
658
+ if (saveChoice !== "4") {
659
+ const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
660
+ if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
661
+ const existing = await file(globalEnvPath).text().catch(() => "");
662
+ const keysToRemove = ["PLAYWRIGHT_MCP_USER_DATA_DIR", "PLAYWRIGHT_MCP_EXTENSION_ID", "PLAYWRIGHT_MCP_EXTENSION_TOKEN", "PLAYWRIGHT_MCP_PROFILE_DIRECTORY"];
663
+ let lines = existing.trimEnd().split("\n").filter(l => !keysToRemove.some(k => l.startsWith(`${k}=`)));
664
+ const rechIdx = lines.findIndex(l => l.startsWith("RECHROME_URL="));
665
+ if (rechIdx >= 0) lines[rechIdx] = newLine;
666
+ else lines.push(newLine);
667
+ await Bun.write(globalEnvPath, lines.join("\n").trim() + "\n");
668
+ console.log(`\nSaved to ${globalEnvPath}`);
669
+ }
667
670
 
668
671
  // Save primary to token registry
669
672
  await saveTokenEntry(profileEmail, { extensionId: extId, token, profileDir, userDataDir: userDataDir ?? undefined });
package/rech.ts CHANGED
@@ -639,16 +639,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
639
639
  const { extId, token } = primary;
640
640
  const profileEmail = profileInfoSel.user_name || profileDir;
641
641
 
642
- // Save RECHROME_URL
643
- const pwdEnvPath = join(process.cwd(), ".env.local");
644
- const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
645
- const homeEnvPath = join(process.env.HOME!, ".env.local");
646
- const saveChoice = (await ask(
647
- `\n[4/4] Save RECHROME_URL to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n\n Choice [1]: `
648
- )).trim();
649
- const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
650
- if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
651
- const existing = await file(globalEnvPath).text().catch(() => "");
642
+ // Build RECHROME_URL and show it before asking where to save
652
643
  const rechUrl = new URL(url);
653
644
  if (!rechUrl.username) rechUrl.username = randomBytes(9).toString("base64url");
654
645
  rechUrl.searchParams.set("extension_id", extId);
@@ -656,14 +647,26 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
656
647
  rechUrl.searchParams.set("profile", profileEmail);
657
648
  if (userDataDir) rechUrl.searchParams.set("user_data_dir", userDataDir);
658
649
  const newLine = `RECHROME_URL=${rechUrl.toString()}`;
659
- const keysToRemove = ["PLAYWRIGHT_MCP_USER_DATA_DIR", "PLAYWRIGHT_MCP_EXTENSION_ID", "PLAYWRIGHT_MCP_EXTENSION_TOKEN", "PLAYWRIGHT_MCP_PROFILE_DIRECTORY"];
660
- let lines = existing.trimEnd().split("\n").filter(l => !keysToRemove.some(k => l.startsWith(`${k}=`)));
661
- const rechIdx = lines.findIndex(l => l.startsWith("RECHROME_URL="));
662
- if (rechIdx >= 0) lines[rechIdx] = newLine;
663
- else lines.push(newLine);
664
- await Bun.write(globalEnvPath, lines.join("\n").trim() + "\n");
665
- console.log(`\nSaved to ${globalEnvPath}`);
666
- console.log(`\n ${newLine}`);
650
+ console.log(`\n[4/4] Your RECHROME_URL:\n\n ${newLine}\n`);
651
+
652
+ const pwdEnvPath = join(process.cwd(), ".env.local");
653
+ const pwdRechPath = join(process.cwd(), ".rechrome", ".env.local");
654
+ const homeEnvPath = join(process.env.HOME!, ".env.local");
655
+ const saveChoice = (await ask(
656
+ `Save to:\n 1. ${pwdEnvPath} (current dir) [default]\n 2. ${pwdRechPath} (current dir, rechrome-only)\n 3. ${homeEnvPath} (user home)\n 4. Skip (already copied)\n\n Choice [1]: `
657
+ )).trim();
658
+ if (saveChoice !== "4") {
659
+ const globalEnvPath = saveChoice === "3" ? homeEnvPath : saveChoice === "2" ? pwdRechPath : pwdEnvPath;
660
+ if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
661
+ const existing = await file(globalEnvPath).text().catch(() => "");
662
+ const keysToRemove = ["PLAYWRIGHT_MCP_USER_DATA_DIR", "PLAYWRIGHT_MCP_EXTENSION_ID", "PLAYWRIGHT_MCP_EXTENSION_TOKEN", "PLAYWRIGHT_MCP_PROFILE_DIRECTORY"];
663
+ let lines = existing.trimEnd().split("\n").filter(l => !keysToRemove.some(k => l.startsWith(`${k}=`)));
664
+ const rechIdx = lines.findIndex(l => l.startsWith("RECHROME_URL="));
665
+ if (rechIdx >= 0) lines[rechIdx] = newLine;
666
+ else lines.push(newLine);
667
+ await Bun.write(globalEnvPath, lines.join("\n").trim() + "\n");
668
+ console.log(`\nSaved to ${globalEnvPath}`);
669
+ }
667
670
 
668
671
  // Save primary to token registry
669
672
  await saveTokenEntry(profileEmail, { extensionId: extId, token, profileDir, userDataDir: userDataDir ?? undefined });