@rowlabs/ev 0.1.0 → 0.2.2

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 +56 -30
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -6343,9 +6343,21 @@ var init_context = __esm({
6343
6343
  }
6344
6344
  });
6345
6345
 
6346
+ // ../shared/dist/logo.js
6347
+ var LOGO_COLOR_SVG, LOGO_WHITE_SVG;
6348
+ var init_logo = __esm({
6349
+ "../shared/dist/logo.js"() {
6350
+ "use strict";
6351
+ LOGO_COLOR_SVG = `<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><g><g transform="matrix(1.043103,0,0,1.043103,-1969.396552,-1257.862069)"><circle cx="1958" cy="1412" r="58" style="fill:rgb(6,130,180)"/></g><g transform="matrix(1,0,0,1,-1825.5,-1142.5)"><path d="M1949,1340L2048,1340L2011.057,1376.943L1949,1376.943L1949,1340Z" style="fill:rgb(6,130,180)"/></g><g transform="matrix(0.991379,0,0,0.991379,-1546.12069,-1299.827586)"><circle cx="1958" cy="1412" r="58" style="fill:rgb(81,86,103)"/></g><g transform="matrix(0.991379,0,0,0.991379,-1753.12069,-1007.827586)"><circle cx="1958" cy="1412" r="58" style="fill:rgb(81,86,103)"/></g><g transform="matrix(1,0,0,1,-1825.5,-1142.5)"><path d="M2015,1483L2020,1396L2168,1258L2188,1280L2050,1411L2044,1493L2015,1483Z" style="fill:rgb(81,86,103)"/></g><g transform="matrix(1,0,0,1,-1825.5,-1142.5)"><path d="M2217.5,1338.994C2224.201,1338.967 2296,1340.287 2296,1409.245L2296,1438L2267.001,1433C2267.001,1433 2278.218,1369.349 2217.5,1369.001C2156.783,1369.349 2168,1433 2168,1433L2139,1438L2139,1409.245C2139,1340.287 2210.799,1338.967 2217.5,1338.994Z" style="fill:rgb(81,86,103)"/></g><g transform="matrix(1,0,0,1,-1503.5,-1252.5)"><path d="M1896.384,1552.005L1896.384,1552L1896.88,1552.002L1897.384,1552L1897.384,1552.005C1907.262,1552.083 1987.32,1553.318 2003,1573L2003,1675C2003,1675 1986.471,1709.757 1897.384,1721.865L1897.384,1722L1896.88,1721.934L1896.384,1722L1896.384,1721.868C1805.805,1709.761 1789,1675 1789,1675L1789,1573C1804.949,1553.307 1886.416,1552.081 1896.384,1552.005ZM1881.205,1630.637L1881.202,1630.637L1871,1676L1918,1676L1907.945,1631.209C1914.592,1626.939 1919,1619.48 1919,1611C1919,1597.754 1908.246,1587 1895,1587C1881.754,1587 1871,1597.754 1871,1611C1871,1619.113 1875.035,1626.292 1881.205,1630.637Z" style="fill:rgb(6,130,180)"/></g></g></svg>`;
6352
+ LOGO_WHITE_SVG = `<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><g><g transform="matrix(1.043103,0,0,1.043103,-1969.396552,-1257.862069)"><circle cx="1958" cy="1412" r="58" style="fill:white"/></g><g transform="matrix(1,0,0,1,-1825.5,-1142.5)"><path d="M1949,1340L2048,1340L2011.057,1376.943L1949,1376.943L1949,1340Z" style="fill:white"/></g><g transform="matrix(0.991379,0,0,0.991379,-1546.12069,-1299.827586)"><circle cx="1958" cy="1412" r="58" style="fill:white"/></g><g transform="matrix(0.991379,0,0,0.991379,-1753.12069,-1007.827586)"><circle cx="1958" cy="1412" r="58" style="fill:white"/></g><g transform="matrix(1,0,0,1,-1825.5,-1142.5)"><path d="M2015,1483L2020,1396L2168,1258L2188,1280L2050,1411L2044,1493L2015,1483Z" style="fill:white"/></g><g transform="matrix(1,0,0,1,-1825.5,-1142.5)"><path d="M2217.5,1338.994C2224.201,1338.967 2296,1340.287 2296,1409.245L2296,1438L2267.001,1433C2267.001,1433 2278.218,1369.349 2217.5,1369.001C2156.783,1369.349 2168,1433 2168,1433L2139,1438L2139,1409.245C2139,1340.287 2210.799,1338.967 2217.5,1338.994Z" style="fill:white"/></g><g transform="matrix(1,0,0,1,-1503.5,-1252.5)"><path d="M1896.384,1552.005L1896.384,1552L1896.88,1552.002L1897.384,1552L1897.384,1552.005C1907.262,1552.083 1987.32,1553.318 2003,1573L2003,1675C2003,1675 1986.471,1709.757 1897.384,1721.865L1897.384,1722L1896.88,1721.934L1896.384,1722L1896.384,1721.868C1805.805,1709.761 1789,1675 1789,1675L1789,1573C1804.949,1553.307 1886.416,1552.081 1896.384,1552.005ZM1881.205,1630.637L1881.202,1630.637L1871,1676L1918,1676L1907.945,1631.209C1914.592,1626.939 1919,1619.48 1919,1611C1919,1597.754 1908.246,1587 1895,1587C1881.754,1587 1871,1597.754 1871,1611C1871,1619.113 1875.035,1626.292 1881.205,1630.637Z" style="fill:white"/></g></g></svg>`;
6353
+ }
6354
+ });
6355
+
6346
6356
  // ../shared/dist/index.js
6347
6357
  var dist_exports = {};
6348
6358
  __export(dist_exports, {
6359
+ LOGO_COLOR_SVG: () => LOGO_COLOR_SVG,
6360
+ LOGO_WHITE_SVG: () => LOGO_WHITE_SVG,
6349
6361
  decryptSecret: () => decryptSecret,
6350
6362
  diffEnvs: () => diffEnvs,
6351
6363
  encryptSecret: () => encryptSecret,
@@ -6370,6 +6382,7 @@ var init_dist = __esm({
6370
6382
  init_env_parser();
6371
6383
  init_diff();
6372
6384
  init_context();
6385
+ init_logo();
6373
6386
  }
6374
6387
  });
6375
6388
 
@@ -6405,7 +6418,7 @@ async function loadAuth() {
6405
6418
  return JSON.parse(content);
6406
6419
  }
6407
6420
  function getApiUrl() {
6408
- return process.env.EV_API_URL ?? "https://api.ev.dev";
6421
+ return process.env.EV_API_URL ?? "https://api.git-env.com";
6409
6422
  }
6410
6423
  function findProjectRoot(startDir) {
6411
6424
  let dir = startDir;
@@ -6716,17 +6729,14 @@ import http from "http";
6716
6729
  import open from "open";
6717
6730
  import chalk from "chalk";
6718
6731
  import ora from "ora";
6719
- var GITHUB_CLIENT_ID = process.env.EV_GITHUB_CLIENT_ID ?? "";
6720
6732
  var loginCommand = new Command("login").description("Authenticate with ev via GitHub OAuth").action(async () => {
6721
- const spinner = ora("Waiting for GitHub authentication...").start();
6733
+ const spinner = ora("Waiting for authentication...").start();
6722
6734
  try {
6723
- const code = await startOAuthFlow();
6724
- spinner.text = "Exchanging code for token...";
6725
- const tempClient = await createApiClient();
6726
- const authResponse = await tempClient.githubAuth(code);
6735
+ const result = await startAuthFlow();
6736
+ spinner.text = "Saving credentials...";
6727
6737
  await saveAuth({
6728
- token: authResponse.token,
6729
- userId: authResponse.user.id,
6738
+ token: result.token,
6739
+ userId: result.userId,
6730
6740
  apiUrl: getApiUrl()
6731
6741
  });
6732
6742
  let keypair = await loadKeypair();
@@ -6735,45 +6745,61 @@ var loginCommand = new Command("login").description("Authenticate with ev via Gi
6735
6745
  keypair = generateKeypair();
6736
6746
  await saveKeypair(keypair);
6737
6747
  }
6738
- if (!authResponse.user.publicKey) {
6739
- const client = await createApiClient();
6748
+ const client = await createApiClient();
6749
+ try {
6740
6750
  await client.updatePublicKey(keypair.publicKey);
6751
+ } catch {
6741
6752
  }
6742
- spinner.succeed(
6743
- chalk.green(`Logged in as ${authResponse.user.name} (${authResponse.user.email})`)
6744
- );
6753
+ spinner.succeed(chalk.green(`Logged in as ${result.name} (${result.email})`));
6745
6754
  } catch (err) {
6746
6755
  spinner.fail(chalk.red(`Login failed: ${err.message}`));
6747
6756
  process.exit(1);
6748
6757
  }
6749
6758
  });
6750
- function startOAuthFlow() {
6759
+ function startAuthFlow() {
6760
+ const appUrl = process.env.EV_APP_URL ?? "https://app.git-env.com";
6751
6761
  return new Promise((resolve, reject) => {
6752
6762
  const server = http.createServer((req, res) => {
6753
- const url = new URL(req.url ?? "/", `http://localhost`);
6754
- const code = url.searchParams.get("code");
6755
- if (code) {
6756
- res.writeHead(200, { "Content-Type": "text/html" });
6757
- res.end("<html><body><h1>Success! You can close this tab.</h1></body></html>");
6758
- server.close();
6759
- resolve(code);
6763
+ const url = new URL(req.url ?? "/", "http://localhost");
6764
+ if (url.pathname === "/callback") {
6765
+ const token = url.searchParams.get("token");
6766
+ const userId = url.searchParams.get("userId");
6767
+ const name = url.searchParams.get("name");
6768
+ const email = url.searchParams.get("email");
6769
+ if (token && userId && name && email) {
6770
+ res.writeHead(200, { "Content-Type": "text/html" });
6771
+ res.end(
6772
+ '<html><body style="background:#07080a;color:#e5e7eb;font-family:system-ui;display:flex;align-items:center;justify-content:center;height:100vh;margin:0"><div style="text-align:center"><h1 style="font-size:1.5rem;font-weight:600">Logged in to ev</h1><p style="color:#9ca3af;margin-top:0.5rem">You can close this tab.</p></div></body></html>'
6773
+ );
6774
+ server.close();
6775
+ resolve({ token, userId, name, email });
6776
+ } else {
6777
+ res.writeHead(400, { "Content-Type": "text/html" });
6778
+ res.end(
6779
+ '<html><body style="background:#07080a;color:#e5e7eb;font-family:system-ui;display:flex;align-items:center;justify-content:center;height:100vh;margin:0"><div style="text-align:center"><h1 style="font-size:1.5rem;color:#f87171">Authentication failed</h1><p style="color:#9ca3af;margin-top:0.5rem">Missing credentials. Try `ev login` again.</p></div></body></html>'
6780
+ );
6781
+ server.close();
6782
+ reject(new Error("Authentication failed \u2014 missing credentials in callback"));
6783
+ }
6760
6784
  } else {
6761
- res.writeHead(400);
6762
- res.end("Missing code parameter");
6785
+ res.writeHead(404);
6786
+ res.end("Not found");
6763
6787
  }
6764
6788
  });
6765
- server.listen(9876, () => {
6766
- const redirectUri = `http://localhost:9876`;
6767
- const authUrl = `https://github.com/login/oauth/authorize?client_id=${GITHUB_CLIENT_ID}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=user:email`;
6789
+ server.listen(0, () => {
6790
+ const port = server.address().port;
6791
+ const authUrl = `${appUrl}/cli/auth?port=${port}`;
6768
6792
  open(authUrl).catch(() => {
6769
- console.log(chalk.yellow(`Open this URL in your browser:
6770
- ${authUrl}`));
6793
+ console.log(chalk.yellow(`
6794
+ Open this URL in your browser:
6795
+ ${authUrl}
6796
+ `));
6771
6797
  });
6772
6798
  });
6773
6799
  server.on("error", reject);
6774
6800
  setTimeout(() => {
6775
6801
  server.close();
6776
- reject(new Error("Authentication timed out"));
6802
+ reject(new Error("Authentication timed out after 2 minutes"));
6777
6803
  }, 12e4);
6778
6804
  });
6779
6805
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowlabs/ev",
3
- "version": "0.1.0",
3
+ "version": "0.2.2",
4
4
  "description": "Git for env vars — sync environment variables across teams securely",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,7 +37,6 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "dependencies": {
40
- "@ev/shared": "workspace:*",
41
40
  "chalk": "^5.4.0",
42
41
  "commander": "^13.1.0",
43
42
  "open": "^10.1.0",
@@ -45,6 +44,7 @@
45
44
  "yaml": "^2.7.0"
46
45
  },
47
46
  "devDependencies": {
47
+ "@ev/shared": "workspace:*",
48
48
  "@types/node": "^22.0.0",
49
49
  "tsup": "^8.5.1",
50
50
  "tsx": "^4.19.0",