incremnt 0.3.0 → 0.5.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.
package/src/lib.js CHANGED
@@ -262,12 +262,17 @@ export async function runCli(argv, stdout, stderr) {
262
262
  }
263
263
 
264
264
  stderr.write('Signing in...\n');
265
- const opened = await maybeOpenBrowser(verificationUrl);
265
+ const headless = isHeadlessLoginEnvironment(options);
266
+ const opened = headless ? false : await maybeOpenBrowser(verificationUrl);
266
267
  if (opened) {
267
268
  stderr.write('Opened your browser to sign in.\n');
268
269
  } else {
269
- stderr.write(`Open this URL to sign in: ${verificationUrl}\n`);
270
+ stderr.write(`Open this URL on any device to sign in: ${verificationUrl}\n`);
271
+ if (headless) {
272
+ stderr.write('Browser launch is disabled in SSH/headless environments. Pass --no-browser explicitly or set INCREMNT_DISABLE_BROWSER=1 to silence this.\n');
273
+ }
270
274
  }
275
+ stderr.write(`If asked, your verification code is: ${challenge.userCode}\n`);
271
276
  if (providers.length > 1) {
272
277
  stderr.write(`Continue with one of: ${providers.join(', ')}.\n`);
273
278
  } else if (providers.length === 0) {
@@ -404,6 +409,13 @@ function resolveLoginBaseUrl(options, sessionState) {
404
409
  return DEFAULT_BASE_URL;
405
410
  }
406
411
 
412
+ function isHeadlessLoginEnvironment(options) {
413
+ if (options['no-browser']) return true;
414
+ if (process.env.INCREMNT_DISABLE_BROWSER === '1') return true;
415
+ if (process.env.SSH_CONNECTION || process.env.SSH_TTY || process.env.SSH_CLIENT) return true;
416
+ return false;
417
+ }
418
+
407
419
  async function maybeOpenBrowser(url) {
408
420
  if (process.env.INCREMNT_DISABLE_BROWSER === '1') {
409
421
  return false;
package/src/local.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
- import os from 'node:os';
3
2
  import path from 'node:path';
3
+ import { userHomeDir } from './state.js';
4
4
 
5
5
  export async function readSnapshot(inputPath) {
6
6
  const raw = await fs.readFile(inputPath, 'utf8');
@@ -8,7 +8,7 @@ export async function readSnapshot(inputPath) {
8
8
  }
9
9
 
10
10
  async function mostRecentDownloadSnapshot() {
11
- const downloadsDir = path.join(os.homedir(), 'Downloads');
11
+ const downloadsDir = path.join(userHomeDir(), 'Downloads');
12
12
 
13
13
  try {
14
14
  const entries = await fs.readdir(downloadsDir, { withFileTypes: true });
@@ -42,7 +42,7 @@ export async function resolveSnapshotSource(explicitPath) {
42
42
  process.env.INCREMNT_SNAPSHOT ? { path: process.env.INCREMNT_SNAPSHOT, source: 'env:INCREMNT_SNAPSHOT' } : null,
43
43
  process.env.ONEMORE_SNAPSHOT ? { path: process.env.ONEMORE_SNAPSHOT, source: 'env:ONEMORE_SNAPSHOT' } : null,
44
44
  { path: path.join(process.cwd(), 'onemore-developer-snapshot.onemore.json'), source: 'cwd' },
45
- { path: path.join(os.homedir(), 'Library', 'Application Support', 'OneMore', 'onemore-developer-snapshot.onemore.json'), source: 'app-support' },
45
+ { path: path.join(userHomeDir(), 'Library', 'Application Support', 'OneMore', 'onemore-developer-snapshot.onemore.json'), source: 'app-support' },
46
46
  downloadSnapshot ? { path: downloadSnapshot, source: 'downloads' } : null
47
47
  ].filter(Boolean);
48
48