ngx-git 1.0.3 → 1.0.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.
Files changed (2) hide show
  1. package/cli.js +30 -3
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -10,6 +10,7 @@ const fs = require("fs");
10
10
  const path = require("path");
11
11
  const http = require("http");
12
12
  const os = require("os");
13
+ const zlib = require("zlib");
13
14
 
14
15
  const axios = require("axios");
15
16
 
@@ -18,7 +19,7 @@ console.log = () => {};
18
19
  require("dotenv").config();
19
20
  console.log = _log;
20
21
 
21
- const VERSION = "1.0.3";
22
+ const VERSION = "1.0.5";
22
23
  const CONFIG_PATH = path.join(os.homedir(), ".ngxconfig");
23
24
  const CB_PORT = 9988; // local callback server port for OAuth
24
25
 
@@ -152,6 +153,8 @@ function collectFiles(folderPath) {
152
153
  walk(fullPath, relPath);
153
154
  } else if (entry.isFile()) {
154
155
  const buf = fs.readFileSync(fullPath);
156
+ const compressed = zlib.gzipSync(buf);
157
+
155
158
  // Skip binary files > 50 MB (GitHub limit)
156
159
  if (buf.length > 50 * 1024 * 1024) {
157
160
  console.log(
@@ -161,7 +164,12 @@ function collectFiles(folderPath) {
161
164
  );
162
165
  continue;
163
166
  }
164
- files.push({ path: relPath, content_b64: buf.toString("base64") });
167
+
168
+ files.push({
169
+ path: relPath,
170
+ content_b64: compressed.toString("base64"),
171
+ compressed: true,
172
+ });
165
173
  }
166
174
  }
167
175
  }
@@ -531,6 +539,25 @@ const { flags, rest } = parseArgs(rawArgs || []);
531
539
  console.log(`ngx ${VERSION}`);
532
540
  break;
533
541
 
542
+ case "token":
543
+ if (!rest[0]) fatal("Usage: ngx token <JWT>");
544
+
545
+ try {
546
+ const decoded = JSON.parse(
547
+ Buffer.from(rest[0].split(".")[1], "base64").toString(),
548
+ );
549
+
550
+ const c = cfg();
551
+ c.token = rest[0];
552
+ c.username = decoded.username; // 🔥 fix
553
+ saveCfg(c);
554
+
555
+ ok(`Token saved for ${decoded.username}`);
556
+ } catch {
557
+ fatal("Invalid JWT token");
558
+ }
559
+ break;
560
+
534
561
  case "login":
535
562
  await doLogin();
536
563
  break;
@@ -636,7 +663,7 @@ ${C.cyan("Config:")}
636
663
  ngx -v Show version
637
664
 
638
665
  ${C.grey("Auto-ignored on push:")}
639
- ${C.grey(".env node_modules .git dist build *.key *.pem secrets")}
666
+ ${C.grey(".env node_modules .git build *.key *.pem secrets")}
640
667
  ${C.grey("Add extras in .ngxignore or .gitignore")}
641
668
  `);
642
669
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-git",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "NGX - Minimal GitHub-like server",
5
5
  "main": "server.js",
6
6
  "bin": {