@glash/cli 0.2.20 → 0.2.21

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.
@@ -1,11 +1,47 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { ok, fail, info, color } from '../lib/ui.mjs';
2
+ import { ok, fail, info, warn, color } from '../lib/ui.mjs';
3
+ import { VERSION } from '../lib/version.mjs';
3
4
 
4
5
  export async function update() {
5
- info(color.dim('→ updating @glash/cli to latest...'));
6
- const child = spawnSync('npm', ['install', '-g', '@glash/cli@latest'], { stdio: 'inherit' });
6
+ info(color.dim('→ updating @glash/cli to the latest version...'));
7
+
8
+ // Quiet npm's funding/audit chatter so the only output is our own clean
9
+ // status line. --loglevel=error keeps real failures visible.
10
+ const child = spawnSync(
11
+ 'npm',
12
+ ['install', '-g', '@glash/cli@latest', '--no-fund', '--no-audit', '--loglevel=error'],
13
+ { stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8' },
14
+ );
15
+
7
16
  if (child.status !== 0) {
8
- return fail(`Update failed with exit code ${child.status ?? 'unknown'}. Please run \`npm install -g @glash/cli@latest\` manually.`);
17
+ const stderr = (child.stderr || '').trim();
18
+ if (/EACCES|permission denied|EPERM/i.test(stderr)) {
19
+ warn('npm needs elevated permissions to write the global package directory.');
20
+ return fail('Run `sudo npm install -g @glash/cli@latest`, or set a user-writable npm prefix (`npm config set prefix ~/.npm-global`).');
21
+ }
22
+ if (stderr) info(color.dim(stderr));
23
+ return fail(`Update failed with exit code ${child.status ?? 'unknown'}. Run \`npm install -g @glash/cli@latest\` manually.`);
24
+ }
25
+
26
+ const installed = resolveInstalledVersion();
27
+ if (installed && installed === VERSION) {
28
+ ok(`Already on the latest version (${color.bold(`v${installed}`)}).`);
29
+ } else if (installed) {
30
+ ok(`Updated @glash/cli → ${color.bold(`v${installed}`)}.`);
31
+ } else {
32
+ ok('Updated @glash/cli to the latest version.');
33
+ }
34
+ }
35
+
36
+ function resolveInstalledVersion() {
37
+ try {
38
+ const res = spawnSync('npm', ['ls', '-g', '@glash/cli', '--depth=0', '--json'], {
39
+ stdio: ['ignore', 'pipe', 'ignore'],
40
+ encoding: 'utf8',
41
+ });
42
+ const parsed = JSON.parse(res.stdout || '{}');
43
+ return parsed?.dependencies?.['@glash/cli']?.version || null;
44
+ } catch {
45
+ return null;
9
46
  }
10
- ok('Successfully updated @glash/cli to the latest version.');
11
47
  }
package/lib/version.mjs CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.20';
1
+ export const VERSION = '0.2.21';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glash/cli",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
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",