@farthershore/cli 0.1.0

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 (44) hide show
  1. package/README.md +83 -0
  2. package/dist/auth.d.ts +1 -0
  3. package/dist/auth.js +18 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/client.d.ts +74 -0
  6. package/dist/client.js +71 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/commands/billing.d.ts +3 -0
  9. package/dist/commands/billing.js +32 -0
  10. package/dist/commands/billing.js.map +1 -0
  11. package/dist/commands/init.d.ts +3 -0
  12. package/dist/commands/init.js +42 -0
  13. package/dist/commands/init.js.map +1 -0
  14. package/dist/commands/login.d.ts +2 -0
  15. package/dist/commands/login.js +82 -0
  16. package/dist/commands/login.js.map +1 -0
  17. package/dist/commands/plans.d.ts +3 -0
  18. package/dist/commands/plans.js +205 -0
  19. package/dist/commands/plans.js.map +1 -0
  20. package/dist/commands/products.d.ts +3 -0
  21. package/dist/commands/products.js +77 -0
  22. package/dist/commands/products.js.map +1 -0
  23. package/dist/commands/team.d.ts +3 -0
  24. package/dist/commands/team.js +47 -0
  25. package/dist/commands/team.js.map +1 -0
  26. package/dist/commands/tokens.d.ts +3 -0
  27. package/dist/commands/tokens.js +31 -0
  28. package/dist/commands/tokens.js.map +1 -0
  29. package/dist/commands/usage.d.ts +3 -0
  30. package/dist/commands/usage.js +24 -0
  31. package/dist/commands/usage.js.map +1 -0
  32. package/dist/config.d.ts +9 -0
  33. package/dist/config.js +74 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +58 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/output.d.ts +11 -0
  39. package/dist/output.js +48 -0
  40. package/dist/output.js.map +1 -0
  41. package/dist/types.d.ts +86 -0
  42. package/dist/types.js +10 -0
  43. package/dist/types.js.map +1 -0
  44. package/package.json +53 -0
package/dist/output.js ADDED
@@ -0,0 +1,48 @@
1
+ // Output formatting: tables, JSON, colors
2
+ import chalk from "chalk";
3
+ export function table(headers, rows) {
4
+ const widths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)));
5
+ const header = headers.map((h, i) => h.padEnd(widths[i])).join(" ");
6
+ const separator = widths.map((w) => "─".repeat(w)).join("──");
7
+ const body = rows
8
+ .map((row) => row.map((cell, i) => (cell ?? "").padEnd(widths[i])).join(" "))
9
+ .join("\n");
10
+ return `${chalk.bold(header)}\n${chalk.dim(separator)}\n${body}`;
11
+ }
12
+ export function json(data) {
13
+ return JSON.stringify(data, null, 2);
14
+ }
15
+ export function success(msg) {
16
+ console.log(chalk.green(`✓ ${msg}`));
17
+ }
18
+ export function error(msg) {
19
+ console.error(chalk.red(`✗ ${msg}`));
20
+ }
21
+ export function warn(msg) {
22
+ console.warn(chalk.yellow(`⚠ ${msg}`));
23
+ }
24
+ export function info(msg) {
25
+ console.log(chalk.dim(msg));
26
+ }
27
+ export function heading(msg) {
28
+ console.log(chalk.bold(msg));
29
+ }
30
+ export function formatPrice(cents) {
31
+ return `$${(cents / 100).toFixed(2)}`;
32
+ }
33
+ export function formatDate(iso) {
34
+ return new Date(iso).toLocaleDateString("en-US", {
35
+ year: "numeric",
36
+ month: "short",
37
+ day: "numeric",
38
+ });
39
+ }
40
+ export function isTTY() {
41
+ return process.stdout.isTTY === true;
42
+ }
43
+ export function outputFormat(flagFormat) {
44
+ if (flagFormat === "json" || flagFormat === "yaml" || flagFormat === "table")
45
+ return flagFormat;
46
+ return isTTY() ? "table" : "json";
47
+ }
48
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,KAAK,CAAC,OAAiB,EAAE,IAAgB;IACvD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,C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pC,CAAC"}
@@ -0,0 +1,86 @@
1
+ export type Product = {
2
+ id: string;
3
+ name: string;
4
+ displayName?: string | null;
5
+ description: string | null;
6
+ baseUrl: string;
7
+ status: "DRAFT" | "ACTIVE";
8
+ runtimeHostname?: string | null;
9
+ portalHostname?: string | null;
10
+ createdAt: string;
11
+ plans: Plan[];
12
+ };
13
+ export type Plan = {
14
+ id: string;
15
+ key: string;
16
+ name: string;
17
+ description: string | null;
18
+ type: string;
19
+ monthlyPriceCents: number;
20
+ isActive: boolean;
21
+ selfServeEnabled: boolean;
22
+ };
23
+ export type ApplyResponse = {
24
+ valid: boolean;
25
+ errors: Array<{
26
+ line?: number;
27
+ message: string;
28
+ }>;
29
+ warnings: Array<{
30
+ message: string;
31
+ }>;
32
+ changes: Array<{
33
+ action: "create" | "update" | "deactivate";
34
+ key: string;
35
+ name: string;
36
+ details: string;
37
+ }>;
38
+ applied: boolean;
39
+ results?: Array<{
40
+ action: string;
41
+ key: string;
42
+ id: string;
43
+ }>;
44
+ };
45
+ export type MakerToken = {
46
+ id: string;
47
+ label: string;
48
+ lastFour: string;
49
+ productId: string | null;
50
+ permissions: string[];
51
+ createdAt: string;
52
+ };
53
+ export type OrgMember = {
54
+ userId: string;
55
+ role: string;
56
+ user?: {
57
+ email?: string;
58
+ name?: string;
59
+ };
60
+ };
61
+ export type CliConfig = {
62
+ apiUrl: string;
63
+ activeOrg?: string;
64
+ defaultFormat?: "table" | "json" | "yaml";
65
+ };
66
+ export type Credentials = {
67
+ token: string;
68
+ orgId?: string;
69
+ userId?: string;
70
+ };
71
+ export type InitProductResponse = {
72
+ product: Product;
73
+ repo: {
74
+ fullName: string;
75
+ htmlUrl: string;
76
+ cloneUrl: string;
77
+ } | null;
78
+ agent: {
79
+ instructions: string;
80
+ agentsMdUrl: string | null;
81
+ };
82
+ };
83
+ export declare class CliError extends Error {
84
+ status?: number | undefined;
85
+ constructor(message: string, status?: number | undefined);
86
+ }
package/dist/types.js ADDED
@@ -0,0 +1,10 @@
1
+ // Shared types for the FartherShore CLI
2
+ export class CliError extends Error {
3
+ status;
4
+ constructor(message, status) {
5
+ super(message);
6
+ this.status = status;
7
+ this.name = "CliError";
8
+ }
9
+ }
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAgFxC,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGxB;IAFT,YACE,OAAe,EACR,MAAe;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,WAAM,GAAN,MAAM,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@farthershore/cli",
3
+ "version": "0.1.0",
4
+ "description": "FartherShore CLI — manage API products, plans, and billing from the terminal",
5
+ "type": "module",
6
+ "bin": {
7
+ "farthershore": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "engines": {
13
+ "node": ">=20"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/farther-shore/farthershore.git"
21
+ },
22
+ "scripts": {
23
+ "dev": "tsx src/index.ts",
24
+ "build": "tsc",
25
+ "prepublishOnly": "npm run build",
26
+ "test": "vitest run",
27
+ "lint": "prettier --check \"src/**/*.ts\"",
28
+ "typecheck": "tsc --noEmit"
29
+ },
30
+ "keywords": [
31
+ "farthershore",
32
+ "api",
33
+ "cli",
34
+ "billing",
35
+ "api-gateway",
36
+ "api-monetization"
37
+ ],
38
+ "author": "Farther Shore",
39
+ "license": "MIT",
40
+ "dependencies": {
41
+ "chalk": "^5.4.1",
42
+ "commander": "^13.1.0",
43
+ "js-yaml": "^4.1.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/js-yaml": "^4.0.9",
47
+ "@types/node": "^22.19.17",
48
+ "prettier": "^3.8.1",
49
+ "tsx": "^4.21.0",
50
+ "typescript": "^6.0.2",
51
+ "vitest": "^3.2.4"
52
+ }
53
+ }