@podge/cli 0.2.0-beta.7 → 0.2.0-beta.9

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.
@@ -30,7 +30,7 @@ function registerApiKeyCommands(program) {
30
30
  .action(async (opts) => {
31
31
  try {
32
32
  const ws = requireWorkspace(opts);
33
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/api-keys`);
33
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/api-keys`);
34
34
  if (opts.json) {
35
35
  (0, output_1.printJson)(data);
36
36
  }
@@ -69,7 +69,7 @@ function registerApiKeyCommands(program) {
69
69
  if (opts.environment) {
70
70
  body.environmentKey = opts.environment;
71
71
  }
72
- const { data } = await (0, client_1.getClient)().post(`/api/v1/workspace/${ws}/api-keys`, body);
72
+ const { data } = await (0, client_1.getClient)().post(`/v1/workspace/${ws}/api-keys`, body);
73
73
  if (opts.json) {
74
74
  (0, output_1.printJson)(data);
75
75
  }
@@ -92,7 +92,7 @@ function registerApiKeyCommands(program) {
92
92
  .action(async (keyId, opts) => {
93
93
  try {
94
94
  const ws = requireWorkspace(opts);
95
- await (0, client_1.getClient)().delete(`/api/v1/workspace/${ws}/api-keys/${keyId}`);
95
+ await (0, client_1.getClient)().delete(`/v1/workspace/${ws}/api-keys/${keyId}`);
96
96
  (0, output_1.printSuccess)(`API key ${keyId} revoked`);
97
97
  }
98
98
  catch (err) {
@@ -79,6 +79,12 @@ function registerAuthCommands(program) {
79
79
  const result = await tokenPromise;
80
80
  (0, config_1.saveCredentials)({ token: result.token, apiUrl: (0, config_1.getApiUrl)() });
81
81
  (0, output_1.printSuccess)("Authenticated successfully. Credentials saved to ~/.podge/credentials.json");
82
+ console.log("");
83
+ (0, output_1.printInfo)("Get started:");
84
+ console.log(` ${chalk_1.default.bold("podge ws list")} List your workspaces`);
85
+ console.log(` ${chalk_1.default.bold("podge config set")} Set default workspace & environment`);
86
+ console.log(` ${chalk_1.default.bold("podge --help")} Show all commands`);
87
+ console.log("");
82
88
  }
83
89
  catch (err) {
84
90
  console.error(chalk_1.default.red(err instanceof Error ? err.message : "Authentication failed."));
@@ -32,7 +32,7 @@ function registerCollectionCommands(program) {
32
32
  .action(async (opts) => {
33
33
  try {
34
34
  const { ws, env } = requireContext(opts);
35
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/environment/${env}/collections`);
35
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/environment/${env}/collections`);
36
36
  if (opts.json) {
37
37
  (0, output_1.printJson)(data);
38
38
  }
@@ -49,6 +49,29 @@ function registerCollectionCommands(program) {
49
49
  (0, client_1.handleError)(err);
50
50
  }
51
51
  });
52
+ col
53
+ .command("create")
54
+ .description("Create a collection")
55
+ .requiredOption("--name <name>", "Collection name")
56
+ .requiredOption("--key <key>", "Collection key")
57
+ .option("-w, --workspace <key>", "Workspace key")
58
+ .option("-e, --environment <key>", "Environment key")
59
+ .option("--json", "Output as JSON")
60
+ .action(async (opts) => {
61
+ try {
62
+ const { ws, env } = requireContext(opts);
63
+ const { data } = await (0, client_1.getClient)().post(`/v1/workspace/${ws}/environment/${env}/collections`, { name: opts.name, key: opts.key });
64
+ if (opts.json) {
65
+ (0, output_1.printJson)(data);
66
+ }
67
+ else {
68
+ (0, output_1.printSuccess)(`Collection "${opts.name}" created (key: ${opts.key})`);
69
+ }
70
+ }
71
+ catch (err) {
72
+ (0, client_1.handleError)(err);
73
+ }
74
+ });
52
75
  col
53
76
  .command("get <key>")
54
77
  .description("Get collection details")
@@ -58,7 +81,7 @@ function registerCollectionCommands(program) {
58
81
  .action(async (key, opts) => {
59
82
  try {
60
83
  const { ws, env } = requireContext(opts);
61
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/environment/${env}/collection/${key}`);
84
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/environment/${env}/collection/${key}`);
62
85
  if (opts.json) {
63
86
  (0, output_1.printJson)(data);
64
87
  }
@@ -79,7 +102,7 @@ function registerCollectionCommands(program) {
79
102
  .action(async (key, opts) => {
80
103
  try {
81
104
  const { ws, env } = requireContext(opts);
82
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/environment/${env}/collection/${key}/schema`);
105
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/environment/${env}/collection/${key}/schema`);
83
106
  (0, output_1.printJson)(data);
84
107
  }
85
108
  catch (err) {
@@ -29,7 +29,7 @@ function registerEnvironmentCommands(program) {
29
29
  .action(async (opts) => {
30
30
  try {
31
31
  const ws = requireWorkspace(opts);
32
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/environments`);
32
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/environments`);
33
33
  if (opts.json) {
34
34
  (0, output_1.printJson)(data);
35
35
  }
@@ -46,6 +46,28 @@ function registerEnvironmentCommands(program) {
46
46
  (0, client_1.handleError)(err);
47
47
  }
48
48
  });
49
+ env
50
+ .command("create")
51
+ .description("Create an environment")
52
+ .requiredOption("--name <name>", "Environment name")
53
+ .requiredOption("--key <key>", "Environment key")
54
+ .option("-w, --workspace <key>", "Workspace key")
55
+ .option("--json", "Output as JSON")
56
+ .action(async (opts) => {
57
+ try {
58
+ const ws = requireWorkspace(opts);
59
+ const { data } = await (0, client_1.getClient)().post(`/v1/workspace/${ws}/environments`, { name: opts.name, key: opts.key });
60
+ if (opts.json) {
61
+ (0, output_1.printJson)(data);
62
+ }
63
+ else {
64
+ (0, output_1.printSuccess)(`Environment "${opts.name}" created (key: ${opts.key})`);
65
+ }
66
+ }
67
+ catch (err) {
68
+ (0, client_1.handleError)(err);
69
+ }
70
+ });
49
71
  env
50
72
  .command("get <key>")
51
73
  .description("Get environment details")
@@ -54,7 +76,7 @@ function registerEnvironmentCommands(program) {
54
76
  .action(async (key, opts) => {
55
77
  try {
56
78
  const ws = requireWorkspace(opts);
57
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/environment/${key}`);
79
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/environment/${key}`);
58
80
  if (opts.json) {
59
81
  (0, output_1.printJson)(data);
60
82
  }
@@ -68,7 +68,7 @@ function registerItemCommands(program) {
68
68
  console.error(chalk_1.default.red("Provide --file or --data"));
69
69
  process.exit(1);
70
70
  }
71
- const url = `/api/v1/workspace/${ws}/environment/${env}/collection/${col}/item${opts.dryRun ? "?dryRun=true" : ""}`;
71
+ const url = `/v1/workspace/${ws}/environment/${env}/collection/${col}/item${opts.dryRun ? "?dryRun=true" : ""}`;
72
72
  const { data } = await (0, client_1.getClient)().post(url, body);
73
73
  if (opts.dryRun) {
74
74
  (0, output_1.printSuccess)("Dry run successful");
@@ -91,7 +91,7 @@ function registerItemCommands(program) {
91
91
  .action(async (documentId, opts) => {
92
92
  try {
93
93
  const { ws, env, col } = requireFullContext(opts);
94
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${ws}/environment/${env}/collection/${col}/document/${documentId}`);
94
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${ws}/environment/${env}/collection/${col}/document/${documentId}`);
95
95
  (0, output_1.printJson)(data);
96
96
  }
97
97
  catch (err) {
@@ -110,7 +110,7 @@ function registerItemCommands(program) {
110
110
  const { ws, env, col } = requireFullContext(opts);
111
111
  const body = JSON.parse(fs.readFileSync(opts.file, "utf-8"));
112
112
  const items = Array.isArray(body) ? body : body.items || [body];
113
- const url = `/api/v1/workspace/${ws}/environment/${env}/collection/${col}/items`;
113
+ const url = `/v1/workspace/${ws}/environment/${env}/collection/${col}/items`;
114
114
  const { data } = await (0, client_1.getClient)().post(url, { items });
115
115
  (0, output_1.printSuccess)(`Batch import submitted (${items.length} items)`);
116
116
  (0, output_1.printJson)(data);
@@ -128,7 +128,7 @@ function registerItemCommands(program) {
128
128
  .action(async (documentId, opts) => {
129
129
  try {
130
130
  const { ws, env, col } = requireFullContext(opts);
131
- const { data } = await (0, client_1.getClient)().delete(`/api/v1/workspace/${ws}/environment/${env}/collection/${col}/document/${documentId}`);
131
+ const { data } = await (0, client_1.getClient)().delete(`/v1/workspace/${ws}/environment/${env}/collection/${col}/document/${documentId}`);
132
132
  (0, output_1.printSuccess)(`Document ${documentId} deleted`);
133
133
  (0, output_1.printJson)(data);
134
134
  }
@@ -158,7 +158,7 @@ function registerItemCommands(program) {
158
158
  console.error(chalk_1.default.red("Provide --file or --data"));
159
159
  process.exit(1);
160
160
  }
161
- const { data } = await (0, client_1.getClient)().patch(`/api/v1/workspace/${ws}/environment/${env}/collection/${col}/document/${documentId}`, body);
161
+ const { data } = await (0, client_1.getClient)().patch(`/v1/workspace/${ws}/environment/${env}/collection/${col}/document/${documentId}`, body);
162
162
  (0, output_1.printSuccess)(`Document ${documentId} update submitted`);
163
163
  (0, output_1.printJson)(data);
164
164
  }
@@ -36,7 +36,7 @@ function registerSearchCommands(program) {
36
36
  if (opts.mode) {
37
37
  body.options = { mode: opts.mode };
38
38
  }
39
- const { data } = await (0, client_1.getClient)().post(`/api/v1/workspace/${ws}/environment/${env}/collection/${col}/search`, body, { headers });
39
+ const { data } = await (0, client_1.getClient)().post(`/v1/workspace/${ws}/environment/${env}/collection/${col}/search`, body, { headers });
40
40
  if (opts.json) {
41
41
  (0, output_1.printJson)(data);
42
42
  }
@@ -13,7 +13,7 @@ function registerWorkspaceCommands(program) {
13
13
  .option("--json", "Output as JSON")
14
14
  .action(async (opts) => {
15
15
  try {
16
- const { data } = await (0, client_1.getClient)().get("/api/v1/workspaces");
16
+ const { data } = await (0, client_1.getClient)().get("/v1/workspaces");
17
17
  if (opts.json) {
18
18
  (0, output_1.printJson)(data);
19
19
  }
@@ -35,7 +35,7 @@ function registerWorkspaceCommands(program) {
35
35
  .option("--json", "Output as JSON")
36
36
  .action(async (key, opts) => {
37
37
  try {
38
- const { data } = await (0, client_1.getClient)().get(`/api/v1/workspace/${key}`);
38
+ const { data } = await (0, client_1.getClient)().get(`/v1/workspace/${key}`);
39
39
  if (opts.json) {
40
40
  (0, output_1.printJson)(data);
41
41
  }
package/dist/index.js CHANGED
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  const commander_1 = require("commander");
5
8
  const fs_1 = require("fs");
6
9
  const path_1 = require("path");
10
+ const chalk_1 = __importDefault(require("chalk"));
7
11
  const auth_1 = require("./commands/auth");
8
12
  const config_1 = require("./commands/config");
9
13
  const workspaces_1 = require("./commands/workspaces");
@@ -14,6 +18,26 @@ const search_1 = require("./commands/search");
14
18
  const apikeys_1 = require("./commands/apikeys");
15
19
  const debug_1 = require("./commands/debug");
16
20
  const pkg = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, "..", "package.json"), "utf-8"));
21
+ const accent = chalk_1.default.hex("#C2C836");
22
+ const dim = chalk_1.default.dim;
23
+ function showBanner() {
24
+ console.log("");
25
+ console.log(accent(" ____ _ "));
26
+ console.log(accent(" | _ \\ ___ __| | __ _ ___ "));
27
+ console.log(accent(" | |_) |/ _ \\ / _` |/ _` |/ _ \\"));
28
+ console.log(accent(" | __/| (_) | (_| | (_| | __/"));
29
+ console.log(accent(" |_| \\___/ \\__,_|\\__, |\\___|"));
30
+ console.log(accent(" |___/ "));
31
+ console.log(dim(` v${pkg.version}`));
32
+ console.log("");
33
+ }
34
+ // Show banner when run with no args, top-level --help, or auth commands
35
+ const args = process.argv.slice(2);
36
+ const isTopLevelHelp = args.length === 0 ||
37
+ (args.length === 1 && (args[0] === "--help" || args[0] === "-h"));
38
+ if (isTopLevelHelp || args[0] === "auth") {
39
+ showBanner();
40
+ }
17
41
  const program = new commander_1.Command();
18
42
  program
19
43
  .name("podge")
@@ -26,6 +26,74 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.startAuthServer = void 0;
27
27
  const http = __importStar(require("http"));
28
28
  const url = __importStar(require("url"));
29
+ function authPage(title, message, success) {
30
+ const accent = success ? "#C2C836" : "#ef4444";
31
+ return `<!DOCTYPE html>
32
+ <html lang="en">
33
+ <head>
34
+ <meta charset="utf-8" />
35
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
36
+ <title>Podge CLI — ${title}</title>
37
+ <style>
38
+ * { margin: 0; padding: 0; box-sizing: border-box; }
39
+ body {
40
+ font-family: Inter, system-ui, -apple-system, sans-serif;
41
+ background: #161820;
42
+ color: #E8E9ED;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ min-height: 100vh;
47
+ }
48
+ .card {
49
+ background: #1D1F28;
50
+ border: 1px solid #2a2c38;
51
+ border-radius: 12px;
52
+ padding: 48px;
53
+ max-width: 440px;
54
+ text-align: center;
55
+ }
56
+ .icon {
57
+ width: 56px;
58
+ height: 56px;
59
+ border-radius: 50%;
60
+ background: ${accent}20;
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ margin: 0 auto 24px;
65
+ font-size: 28px;
66
+ }
67
+ h2 {
68
+ color: ${accent};
69
+ font-size: 20px;
70
+ font-weight: 600;
71
+ margin-bottom: 12px;
72
+ }
73
+ p {
74
+ color: #8b8d97;
75
+ font-size: 14px;
76
+ line-height: 1.5;
77
+ }
78
+ code {
79
+ font-family: "JetBrains Mono", ui-monospace, monospace;
80
+ background: #161820;
81
+ padding: 2px 8px;
82
+ border-radius: 4px;
83
+ font-size: 13px;
84
+ color: #C2C836;
85
+ }
86
+ </style>
87
+ </head>
88
+ <body>
89
+ <div class="card">
90
+ <div class="icon">${success ? "&#10003;" : "&#10007;"}</div>
91
+ <h2>${title}</h2>
92
+ <p>${message}</p>
93
+ </div>
94
+ </body>
95
+ </html>`;
96
+ }
29
97
  function startAuthServer(expectedState, timeoutMs = 120000) {
30
98
  return new Promise((resolve, reject) => {
31
99
  let settled = false;
@@ -63,7 +131,7 @@ function startAuthServer(expectedState, timeoutMs = 120000) {
63
131
  // Always respond with HTML
64
132
  res.writeHead(200, { "Content-Type": "text/html" });
65
133
  if (error) {
66
- res.end("<html><body><h2>Authentication failed</h2><p>You can close this tab.</p></body></html>");
134
+ res.end(authPage("Authentication failed", "Something went wrong. You can close this tab and try again.", false));
67
135
  clearTimeout(timer);
68
136
  settled = true;
69
137
  server.close();
@@ -71,7 +139,7 @@ function startAuthServer(expectedState, timeoutMs = 120000) {
71
139
  return;
72
140
  }
73
141
  if (state !== expectedState) {
74
- res.end("<html><body><h2>Authentication failed</h2><p>Invalid state parameter.</p></body></html>");
142
+ res.end(authPage("Authentication failed", "Invalid state parameter. You can close this tab and try again.", false));
75
143
  clearTimeout(timer);
76
144
  settled = true;
77
145
  server.close();
@@ -79,14 +147,14 @@ function startAuthServer(expectedState, timeoutMs = 120000) {
79
147
  return;
80
148
  }
81
149
  if (!token) {
82
- res.end("<html><body><h2>Authentication failed</h2><p>No token received.</p></body></html>");
150
+ res.end(authPage("Authentication failed", "No token was received. You can close this tab and try again.", false));
83
151
  clearTimeout(timer);
84
152
  settled = true;
85
153
  server.close();
86
154
  rejToken(new Error("No token received from the browser."));
87
155
  return;
88
156
  }
89
- res.end("<html><body><h2>Authentication successful!</h2><p>You can close this tab and return to the terminal.</p></body></html>");
157
+ res.end(authPage("Authentication successful!", "You can close this tab and return to your terminal. Run <code>podge --help</code> to get started.", true));
90
158
  clearTimeout(timer);
91
159
  settled = true;
92
160
  server.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podge/cli",
3
- "version": "0.2.0-beta.7",
3
+ "version": "0.2.0-beta.9",
4
4
  "description": "CLI for Podge — manage workspaces, collections, and search",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",