checkpoint-cli 1.0.0 → 1.0.1

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 +36 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -29,6 +29,40 @@ function getSupabase() {
29
29
  },
30
30
  });
31
31
  }
32
+ async function ensureAuthenticatedClient() {
33
+ let sb = await getAuthenticatedClient();
34
+ if (sb)
35
+ return sb;
36
+ console.log(chalk_1.default.yellow(' No active login found. Starting browser sign-in...'));
37
+ console.log('');
38
+ try {
39
+ const tokens = await loginWithBrowser();
40
+ (0, config_js_1.saveConfig)({
41
+ access_token: tokens.access_token,
42
+ refresh_token: tokens.refresh_token,
43
+ app_url: (0, config_js_1.getAppUrl)(),
44
+ });
45
+ sb = await getAuthenticatedClient();
46
+ if (sb) {
47
+ const { data } = await sb.auth.getUser();
48
+ if (data.user?.email) {
49
+ console.log(chalk_1.default.green(` ✓ Logged in as ${chalk_1.default.white(data.user.email)}`));
50
+ }
51
+ else {
52
+ console.log(chalk_1.default.green(' ✓ Logged in'));
53
+ }
54
+ console.log('');
55
+ return sb;
56
+ }
57
+ }
58
+ catch (err) {
59
+ console.log(chalk_1.default.red(` ${err.message}`));
60
+ }
61
+ console.log(chalk_1.default.red(' Could not establish an authenticated session.'));
62
+ console.log(` Run ${chalk_1.default.cyan('checkpoint login')} and try again.`);
63
+ console.log('');
64
+ return null;
65
+ }
32
66
  /** Get an authenticated Supabase client, refreshing the token if needed. */
33
67
  async function getAuthenticatedClient() {
34
68
  const config = (0, config_js_1.loadConfig)();
@@ -68,17 +102,6 @@ async function getAuthenticatedClient() {
68
102
  }
69
103
  return sb;
70
104
  }
71
- function requireAuth() {
72
- const config = (0, config_js_1.loadConfig)();
73
- if (!config) {
74
- console.log('');
75
- console.log(chalk_1.default.red(' Not logged in.'));
76
- console.log('');
77
- console.log(` Run ${chalk_1.default.cyan('checkpoint login')} first.`);
78
- console.log('');
79
- process.exit(1);
80
- }
81
- }
82
105
  /* ── Injection Proxy ── */
83
106
  function startInjectionProxy(targetPort) {
84
107
  const scriptBody = (0, tracking_script_minimal_js_1.buildMinimalTrackingScript)().replace(/<\/script/gi, '<\\/script');
@@ -599,7 +622,6 @@ program
599
622
  .option('-n, --name <name>', 'Tunnel name. Reuse a name to resume the same share URL.')
600
623
  .option('--provider <provider>', 'Tunnel provider: cloudflared (default) or ngrok')
601
624
  .action(async (opts) => {
602
- requireAuth();
603
625
  const port = parseInt(opts.port, 10);
604
626
  console.log('');
605
627
  console.log(chalk_1.default.blue.bold(' ⟐ Checkpoint'));
@@ -628,10 +650,8 @@ program
628
650
  process.exit(1);
629
651
  }
630
652
  // Authenticate
631
- const sb = await getAuthenticatedClient();
653
+ const sb = await ensureAuthenticatedClient();
632
654
  if (!sb) {
633
- console.log(chalk_1.default.red(' Session expired. Run `checkpoint login` again.'));
634
- console.log('');
635
655
  process.exit(1);
636
656
  }
637
657
  // Detect provider
@@ -701,14 +721,11 @@ program
701
721
  .option('-n, --name <name>', 'Name for this tunnel', 'My Tunnel')
702
722
  .option('-p, --port <port>', 'Local port for reference', '3000')
703
723
  .action(async (opts) => {
704
- requireAuth();
705
724
  console.log('');
706
725
  console.log(chalk_1.default.blue.bold(' ⟐ Checkpoint'));
707
726
  console.log('');
708
- const sb = await getAuthenticatedClient();
727
+ const sb = await ensureAuthenticatedClient();
709
728
  if (!sb) {
710
- console.log(chalk_1.default.red(' Session expired. Run `checkpoint login` again.'));
711
- console.log('');
712
729
  process.exit(1);
713
730
  }
714
731
  if (!isValidUrl(opts.url)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "checkpoint-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Share your localhost with reviewers — get visual feedback directly on the page",
5
5
  "keywords": [
6
6
  "checkpoint",