@glash/cli 0.2.37 → 0.2.39

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.
@@ -711,12 +711,14 @@ function sourceUploadPartSize(value) {
711
711
  }
712
712
 
713
713
  function sourceUploadConcurrency(flags = {}) {
714
- // Default 3: fewer simultaneous part uploads means each connection gets more of
715
- // a constrained uplink and finishes before it can be reset mid-stream. Override
716
- // with --source-concurrency or GLASH_SOURCE_UPLOAD_CONCURRENCY.
717
- const raw = flags['source-concurrency'] ?? process.env.GLASH_SOURCE_UPLOAD_CONCURRENCY ?? '3';
714
+ // Default 4 — parts upload simultaneously and 4 is the measured throughput
715
+ // sweet spot: a single connection can't saturate a typical uplink (~2.5x
716
+ // speedup from parallelism), but past ~4 connections contention makes it
717
+ // slower and unreliable. Override with --source-concurrency or
718
+ // GLASH_SOURCE_UPLOAD_CONCURRENCY (capped at 8).
719
+ const raw = flags['source-concurrency'] ?? process.env.GLASH_SOURCE_UPLOAD_CONCURRENCY ?? '4';
718
720
  const parsed = Number(raw);
719
- if (!Number.isFinite(parsed) || parsed < 1) return 3;
721
+ if (!Number.isFinite(parsed) || parsed < 1) return 4;
720
722
  return Math.max(1, Math.min(8, Math.floor(parsed)));
721
723
  }
722
724
 
@@ -7,6 +7,17 @@ import { prompt, ok, fail, info, warn, color } from '../lib/ui.mjs';
7
7
 
8
8
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
9
9
 
10
+ async function identityPost(path, body, opts) {
11
+ try {
12
+ return await apiPost(`/identity${path}`, body, opts);
13
+ } catch (e) {
14
+ if (e?.status === 404) {
15
+ return apiPost(`/auth${path}`, body, opts);
16
+ }
17
+ throw e;
18
+ }
19
+ }
20
+
10
21
  function openBrowser(url) {
11
22
  try {
12
23
  const opener = platform === 'darwin' ? 'open' : platform === 'win32' ? 'cmd' : 'xdg-open';
@@ -29,7 +40,7 @@ export async function login({ flags }) {
29
40
  async function browserLogin(flags) {
30
41
  let start;
31
42
  try {
32
- start = await apiPost('/auth/cli/device/start', { deviceName: hostname() });
43
+ start = await identityPost('/cli/device/start', { deviceName: hostname() });
33
44
  } catch (e) {
34
45
  // Older backend without device auth — fall back to password login.
35
46
  warn('Browser login is unavailable; falling back to email/password.');
@@ -60,7 +71,7 @@ async function browserLogin(flags) {
60
71
  await sleep(delay);
61
72
  let r;
62
73
  try {
63
- r = await apiPost('/auth/cli/device/poll', { deviceCode });
74
+ r = await identityPost('/cli/device/poll', { deviceCode });
64
75
  } catch (e) {
65
76
  return fail(e.message);
66
77
  }
@@ -84,16 +95,16 @@ async function passwordLogin(flags) {
84
95
  if (!email || !password) return fail('email and password required');
85
96
 
86
97
  try {
87
- let r = await apiPost('/auth/login', { email, password });
98
+ let r = await identityPost('/login', { email, password });
88
99
 
89
100
  // Second factor is always required. Complete the email-OTP challenge.
90
101
  if (!r?.accessToken && r?.secondFactorRequired && !r?.challengeId) {
91
- r = await apiPost('/auth/login', { email, password, secondFactorMethod: 'email_otp' });
102
+ r = await identityPost('/login', { email, password, secondFactorMethod: 'email_otp' });
92
103
  }
93
104
  if (!r?.accessToken && (r?.otpRequired || r?.challengeId)) {
94
105
  const code = flags.otp || (await prompt('Enter the 6-digit code sent to your email: '));
95
106
  if (!code) throw new Error('A verification code is required to sign in.');
96
- r = await apiPost('/auth/login', {
107
+ r = await identityPost('/login', {
97
108
  email,
98
109
  password,
99
110
  emailOtpCode: String(code).trim(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glash/cli",
3
- "version": "0.2.37",
3
+ "version": "0.2.39",
4
4
  "description": "glashDB command-line interface — deploy projects, pull source + env, manage env vars.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://glashdb.com",