tthr 0.0.46 → 0.0.47

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/dist/index.js +33 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1763,6 +1763,8 @@ async function devCommand(options) {
1763
1763
  import chalk4 from "chalk";
1764
1764
  import ora4 from "ora";
1765
1765
  import os from "os";
1766
+ import { exec } from "child_process";
1767
+ import readline from "readline";
1766
1768
  var isDev3 = process.env.NODE_ENV === "development" || process.env.TETHER_DEV === "true";
1767
1769
  var API_URL3 = isDev3 ? "http://localhost:3001/api/v1" : "https://tether-api.strands.gg/api/v1";
1768
1770
  var AUTH_URL = isDev3 ? "http://localhost:3000/cli" : "https://tthr.io/cli";
@@ -1779,11 +1781,14 @@ async function loginCommand() {
1779
1781
  const deviceCode = await requestDeviceCode();
1780
1782
  spinner.stop();
1781
1783
  const authUrl = `${AUTH_URL}/${deviceCode.userCode}`;
1782
- console.log(chalk4.dim("Open this URL in your browser to authenticate:\n"));
1784
+ console.log(chalk4.dim("Authenticate in your browser:\n"));
1783
1785
  console.log(chalk4.cyan.bold(` ${authUrl}
1784
1786
  `));
1785
1787
  console.log(chalk4.dim(`Your code: ${chalk4.white.bold(deviceCode.userCode)}
1786
1788
  `));
1789
+ await waitForEnter(chalk4.dim("Press Enter to open in browser..."));
1790
+ openBrowser(authUrl);
1791
+ console.log();
1787
1792
  const credentials = await pollForApproval(deviceCode.deviceCode, deviceCode.interval, deviceCode.expiresIn);
1788
1793
  await saveCredentials(credentials);
1789
1794
  console.log(chalk4.green("\u2713") + ` Logged in as ${chalk4.cyan(credentials.email)}`);
@@ -1915,6 +1920,33 @@ async function pollForApproval(deviceCode, interval, expiresIn) {
1915
1920
  function sleep(ms) {
1916
1921
  return new Promise((resolve) => setTimeout(resolve, ms));
1917
1922
  }
1923
+ function openBrowser(url) {
1924
+ const platform = process.platform;
1925
+ let command;
1926
+ if (platform === "darwin") {
1927
+ command = `open "${url}"`;
1928
+ } else if (platform === "win32") {
1929
+ command = `start "" "${url}"`;
1930
+ } else {
1931
+ command = `xdg-open "${url}"`;
1932
+ }
1933
+ exec(command, (error) => {
1934
+ if (error) {
1935
+ }
1936
+ });
1937
+ }
1938
+ function waitForEnter(prompt) {
1939
+ return new Promise((resolve) => {
1940
+ const rl = readline.createInterface({
1941
+ input: process.stdin,
1942
+ output: process.stdout
1943
+ });
1944
+ rl.question(prompt, () => {
1945
+ rl.close();
1946
+ resolve();
1947
+ });
1948
+ });
1949
+ }
1918
1950
 
1919
1951
  // src/commands/update.ts
1920
1952
  import chalk5 from "chalk";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tthr",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "description": "Tether CLI - project scaffolding and deployment",
5
5
  "type": "module",
6
6
  "bin": {