@sylphx/cli 0.1.3 → 0.1.4

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/dist/index.js +95 -38
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27,6 +27,52 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  var import_chalk17 = __toESM(require("chalk"));
28
28
  var import_commander16 = require("commander");
29
29
 
30
+ // package.json
31
+ var package_default = {
32
+ name: "@sylphx/cli",
33
+ version: "0.1.4",
34
+ description: "Sylphx Platform CLI \u2014 deploy, manage logs, env vars, and more",
35
+ type: "commonjs",
36
+ bin: {
37
+ sylphx: "./dist/index.js"
38
+ },
39
+ scripts: {
40
+ build: "tsup src/index.ts --format cjs --dts",
41
+ dev: "tsx src/index.ts",
42
+ typecheck: "tsc --noEmit",
43
+ test: "vitest run",
44
+ "test:watch": "vitest",
45
+ "test:coverage": "vitest run --coverage",
46
+ clean: "rm -rf dist",
47
+ prepublishOnly: "tsup src/index.ts --format cjs --dts"
48
+ },
49
+ files: [
50
+ "dist",
51
+ "README.md"
52
+ ],
53
+ publishConfig: {
54
+ access: "public",
55
+ registry: "https://registry.npmjs.org/"
56
+ },
57
+ dependencies: {
58
+ chalk: "^5.3.0",
59
+ commander: "^12.1.0",
60
+ conf: "^13.0.0",
61
+ eventsource: "^2.0.2",
62
+ open: "^10.1.0",
63
+ ora: "^8.1.0"
64
+ },
65
+ devDependencies: {
66
+ "@types/eventsource": "^1.1.15",
67
+ "@types/node": "^22.0.0",
68
+ "@vitest/coverage-v8": "^3.2.0",
69
+ tsup: "^8.3.0",
70
+ tsx: "^4.19.0",
71
+ typescript: "^5.9.3",
72
+ vitest: "^3.2.0"
73
+ }
74
+ };
75
+
30
76
  // src/commands/db.ts
31
77
  var import_node_readline = __toESM(require("readline"));
32
78
  var import_chalk = __toESM(require("chalk"));
@@ -201,29 +247,38 @@ var api = {
201
247
  query: { envType }
202
248
  });
203
249
  },
204
- /** List domains for a project environment
205
- * NOTE: Endpoint needs backend verification; follows RESTful convention.
250
+ /** Resolve environment ID from project ID + envType.
251
+ * The domains API requires an envId (not projectId).
206
252
  */
253
+ async resolveEnvId(projectId, envType) {
254
+ const project = await request("GET", `/projects/${projectId}`);
255
+ const env = project.environments.find((e) => e.envType === envType || e.name === envType);
256
+ if (!env) throw new ApiError(404, `No environment '${envType}' found for project`);
257
+ return env.id;
258
+ },
259
+ /** List domains for a project environment */
207
260
  async listDomains(projectId, envType) {
208
- return request("GET", `/projects/${projectId}/domains`, {
209
- query: { envType }
210
- });
261
+ const envId = await this.resolveEnvId(projectId, envType);
262
+ const res = await request(
263
+ "GET",
264
+ `/domains/projects/${envId}/domains`
265
+ );
266
+ return Array.isArray(res) ? res : res.domains ?? [];
211
267
  },
212
- /** Add a domain for a project environment
213
- * NOTE: Endpoint needs backend verification; follows RESTful convention.
214
- */
268
+ /** Add a domain for a project environment */
215
269
  async addDomain(projectId, domain, envType) {
216
- return request("POST", `/projects/${projectId}/domains`, {
217
- body: { domain, envType }
270
+ const envId = await this.resolveEnvId(projectId, envType);
271
+ return request("POST", `/domains/projects/${envId}/domains`, {
272
+ body: { domain }
218
273
  });
219
274
  },
220
- /** Remove a domain from a project environment
221
- * NOTE: Endpoint needs backend verification; follows RESTful convention.
222
- */
275
+ /** Remove a domain from a project environment */
223
276
  async removeDomain(projectId, domain, envType) {
224
- return request("DELETE", `/projects/${projectId}/domains/${encodeURIComponent(domain)}`, {
225
- query: { envType }
226
- });
277
+ const envId = await this.resolveEnvId(projectId, envType);
278
+ return request(
279
+ "DELETE",
280
+ `/domains/projects/${envId}/domains/${encodeURIComponent(domain)}`
281
+ );
227
282
  },
228
283
  /** Get current user and orgs */
229
284
  async whoami() {
@@ -231,7 +286,8 @@ var api = {
231
286
  },
232
287
  /** List projects (org is scoped to token) */
233
288
  async listProjects() {
234
- return request("GET", "/projects");
289
+ const res = await request("GET", "/projects");
290
+ return Array.isArray(res) ? res : res.data ?? [];
235
291
  },
236
292
  /** Create a new project */
237
293
  async createProject(data) {
@@ -245,25 +301,32 @@ var api = {
245
301
  async listApps(_orgId) {
246
302
  return this.listProjects();
247
303
  },
248
- /** List all databases */
304
+ /** List all databases (via unified Resources API) */
249
305
  async listDatabases() {
250
- return request("GET", "/databases");
306
+ const res = await request(
307
+ "GET",
308
+ "/resources",
309
+ {
310
+ query: { kind: "database" }
311
+ }
312
+ );
313
+ return Array.isArray(res) ? res : res.data ?? [];
251
314
  },
252
- /** Provision a new database */
315
+ /** Provision a new database (via unified Resources API) */
253
316
  async createDatabase(data) {
254
- return request("POST", "/databases", { body: data });
317
+ return request("POST", "/resources", { body: { ...data, kind: "database" } });
255
318
  },
256
- /** Get database details (includes connectionString) */
319
+ /** Get database details (via unified Resources API) */
257
320
  async getDatabase(id) {
258
- return request("GET", `/databases/${encodeURIComponent(id)}`);
321
+ return request("GET", `/resources/${encodeURIComponent(id)}`);
259
322
  },
260
- /** Delete a database */
323
+ /** Delete a database (via unified Resources API) */
261
324
  async deleteDatabase(id) {
262
- return request("DELETE", `/databases/${encodeURIComponent(id)}`);
325
+ return request("DELETE", `/resources/${encodeURIComponent(id)}`);
263
326
  },
264
- /** Branch a database for staging/preview */
327
+ /** Branch a database for staging/preview (via unified Resources API) */
265
328
  async branchDatabase(id, data) {
266
- return request("POST", `/databases/${encodeURIComponent(id)}/branch`, { body: data });
329
+ return request("POST", `/resources/${encodeURIComponent(id)}/branch`, { body: data });
267
330
  },
268
331
  /** Batch-set env vars for a project environment */
269
332
  async setEnvVars(projectId, vars, envType) {
@@ -503,20 +566,13 @@ function streamLogs(url, token, opts = {}) {
503
566
  return new Promise((resolve) => {
504
567
  const EventSource = require("eventsource");
505
568
  const headers = {
506
- "User-Agent": "sylphx-cli/0.1.0"
569
+ "User-Agent": "sylphx-cli/0.1.0",
570
+ Accept: "text/event-stream"
507
571
  };
508
572
  if (token) {
509
573
  headers.Authorization = `Bearer ${token}`;
510
574
  }
511
- const es = new EventSource(url, {
512
- fetch: (input, init) => fetch(input, {
513
- ...init,
514
- headers: {
515
- ...typeof init?.headers === "object" ? init.headers : {},
516
- ...headers
517
- }
518
- })
519
- });
575
+ const es = new EventSource(url, { headers });
520
576
  let succeeded = false;
521
577
  let timeout;
522
578
  const finish = (success) => {
@@ -1639,8 +1695,9 @@ var whoamiCommand = new import_commander15.Command("whoami").description("Show c
1639
1695
  });
1640
1696
 
1641
1697
  // src/index.ts
1698
+ var { version } = package_default;
1642
1699
  var program = new import_commander16.Command();
1643
- program.name("sylphx").description(`${import_chalk17.default.bold("Sylphx Platform CLI")} \u2014 deploy and manage your applications`).version("0.1.0", "-v, --version", "Print version").helpOption("-h, --help", "Show help").addHelpText(
1700
+ program.name("sylphx").description(`${import_chalk17.default.bold("Sylphx Platform CLI")} \u2014 deploy and manage your applications`).version(version, "-v, --version", "Print version").helpOption("-h, --help", "Show help").addHelpText(
1644
1701
  "after",
1645
1702
  `
1646
1703
  ${import_chalk17.default.bold("Examples:")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphx/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Sylphx Platform CLI — deploy, manage logs, env vars, and more",
5
5
  "type": "commonjs",
6
6
  "bin": {