@glash/cli 0.2.4 → 0.2.5

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/bin/glash.mjs CHANGED
@@ -3,7 +3,7 @@ import { argv, exit } from 'node:process';
3
3
  import { parseArgs } from '../lib/args.mjs';
4
4
  import { info, fail, color } from '../lib/ui.mjs';
5
5
 
6
- const VERSION = '0.2.4';
6
+ const VERSION = '0.2.5';
7
7
 
8
8
  const sub = argv[2];
9
9
  const rest = argv.slice(3);
@@ -5,7 +5,8 @@ import { execSync } from 'node:child_process';
5
5
  import { zipDirectory } from '../lib/zip.mjs';
6
6
  import { join, basename } from 'node:path';
7
7
  import { tmpdir } from 'node:os';
8
- import { access, readFile, rm } from 'node:fs/promises';
8
+ import { openAsBlob } from 'node:fs';
9
+ import { access, readFile, rm, stat } from 'node:fs/promises';
9
10
 
10
11
  function currentCommit() {
11
12
  try {
@@ -140,11 +141,11 @@ export async function deploy({ flags }) {
140
141
  const zipPath = join(tmpdir(), `glash-deploy-${Date.now()}.zip`);
141
142
  try {
142
143
  await zipDirectory(process.cwd(), zipPath);
143
- const zipBuffer = await readFile(zipPath);
144
+ const zipStat = await stat(zipPath);
145
+ info(color.dim(`→ source bundle ${(zipStat.size / 1024 / 1024).toFixed(1)} MB`));
144
146
  const formData = new FormData();
145
147
  formData.append('projectId', projectId);
146
- // We wrap the buffer in a Blob so fetch treats it as a file
147
- formData.append('file', new Blob([zipBuffer]), 'project.zip');
148
+ formData.append('file', await openAsBlob(zipPath, { type: 'application/zip' }), 'project.zip');
148
149
 
149
150
  formData.append('commitHash', commitHash || 'local-upload');
150
151
  formData.append('gitBranch', gitBranch || '');
@@ -154,7 +155,7 @@ export async function deploy({ flags }) {
154
155
  await rm(zipPath, { force: true }).catch(() => {});
155
156
  } catch (e) {
156
157
  await rm(zipPath, { force: true }).catch(() => {});
157
- return fail(`Packaging failed: ${e.message}`);
158
+ return fail(`Upload failed: ${e.message}`);
158
159
  }
159
160
  } else {
160
161
  info(color.dim(`→ deploying connected repo for project ${projectId}${commitHash ? ` @ ${commitHash.slice(0, 7)}` : ''} (${target})`));
package/lib/api.mjs CHANGED
@@ -23,11 +23,17 @@ export async function api(method, path, { body, token, query } = {}) {
23
23
  if (qs) url += (url.includes('?') ? '&' : '?') + qs;
24
24
  }
25
25
 
26
- const res = await fetch(url, {
27
- method,
28
- headers,
29
- body: body instanceof FormData ? body : (body === undefined ? undefined : JSON.stringify(body)),
30
- });
26
+ let res;
27
+ try {
28
+ res = await fetch(url, {
29
+ method,
30
+ headers,
31
+ body: body instanceof FormData ? body : (body === undefined ? undefined : JSON.stringify(body)),
32
+ });
33
+ } catch (e) {
34
+ const detail = e?.cause?.message || e?.message || String(e);
35
+ throw new GlashApiError(0, `Network request failed while calling ${method} ${path}: ${detail}`);
36
+ }
31
37
 
32
38
  if (!res.ok) {
33
39
  let message = `HTTP ${res.status}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glash/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
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",