@farthershore/cli 0.3.5 → 0.3.7
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/README.md +30 -4
- package/dist/client.d.ts +17 -29
- package/dist/commands/validate.d.ts +26 -0
- package/dist/config.d.ts +0 -3
- package/dist/index.js +1237 -46
- package/dist/output.d.ts +1 -4
- package/dist/remediation.d.ts +6 -0
- package/dist/types.d.ts +36 -11
- package/package.json +14 -5
- package/dist/auth.js +0 -17
- package/dist/build-info.js +0 -10
- package/dist/client.js +0 -36
- package/dist/commands/apply.js +0 -127
- package/dist/commands/init.js +0 -41
- package/dist/commands/login.js +0 -95
- package/dist/commands/validate.js +0 -190
- package/dist/config.js +0 -76
- package/dist/output.js +0 -47
- package/dist/types.js +0 -9
package/README.md
CHANGED
|
@@ -45,8 +45,7 @@ Options:
|
|
|
45
45
|
|
|
46
46
|
- `--base-url <url>` — Backend API base URL
|
|
47
47
|
- `--description <text>` — Product description
|
|
48
|
-
- `--display-name <name>` — Display name for the portal
|
|
49
|
-
- `--billing <strategy>` — `subscription` (default), `usage_based`, or `hybrid`
|
|
48
|
+
- `--display-name <name>` — Display name for the product portal
|
|
50
49
|
|
|
51
50
|
The created repo contains:
|
|
52
51
|
|
|
@@ -57,7 +56,7 @@ The created repo contains:
|
|
|
57
56
|
|
|
58
57
|
### `farthershore validate [file]`
|
|
59
58
|
|
|
60
|
-
Validate a local `product.yaml` file without making any API calls. Checks structure, required fields, and
|
|
59
|
+
Validate a local `product.yaml` file without making any API calls. Checks structure, required fields, and launch constraints for env-scoped plans and meters.
|
|
61
60
|
|
|
62
61
|
```bash
|
|
63
62
|
# Validate product.yaml in current directory
|
|
@@ -69,7 +68,7 @@ farthershore validate path/to/product.yaml
|
|
|
69
68
|
|
|
70
69
|
### `farthershore apply [product]`
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
Validate the current repo's `product.yaml` first when applying that repo's product, then run the server-side compiler against the pushed branch state for the product. Unpushed local edits are not part of the remote compile. Returns compilation errors and warnings. Exits with code 1 on failure — suitable for CI checks before merging.
|
|
73
72
|
|
|
74
73
|
```bash
|
|
75
74
|
# Inside a product repo (auto-detects from product.yaml)
|
|
@@ -137,3 +136,30 @@ git add -A && git commit -m "Configure product" && git push
|
|
|
137
136
|
| ---------------------- | ------------------------------------------------------- |
|
|
138
137
|
| `FARTHERSHORE_TOKEN` | API token (overrides stored credentials) |
|
|
139
138
|
| `FARTHERSHORE_API_URL` | API base URL (default: `https://core.farthershore.com`) |
|
|
139
|
+
|
|
140
|
+
## Errors and exit codes
|
|
141
|
+
|
|
142
|
+
The CLI exits `0` on success and `1` on any failure (including
|
|
143
|
+
`commander`-level argument errors). When the API returns a 4XX/5XX, the
|
|
144
|
+
CLI prints the canonical error code in brackets and a one-line
|
|
145
|
+
remediation hint when one is registered:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
Error [STRIPE_NOT_CONFIGURED]: connect Stripe before running billing operations
|
|
149
|
+
Hint: Stripe isn't connected on this product. Connect it in the dashboard before running billing operations.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The bracketed code is stable across releases — quote it in support
|
|
153
|
+
threads.
|
|
154
|
+
|
|
155
|
+
`farthershore whoami --format json` emits a stable JSON shape suitable
|
|
156
|
+
for CI scripts. On the not-authenticated path it emits
|
|
157
|
+
`{ "authenticated": false }` with exit code `1`.
|
|
158
|
+
|
|
159
|
+
## CI / agent usage
|
|
160
|
+
|
|
161
|
+
The CLI is non-interactive whenever a token is available via the
|
|
162
|
+
`--token` flag or `FARTHERSHORE_TOKEN` env var — `set-key` only prompts
|
|
163
|
+
when stdin is a TTY and no token argument was passed, so it's safe to
|
|
164
|
+
script. `validate` and `apply` emit GitHub Actions-formatted annotations
|
|
165
|
+
when run under `CI` / `GITHUB_ACTIONS`.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Product, InitProductResponse } from "./types.js";
|
|
1
|
+
import type { Product, InitProductResponse, CompileDiagnostic } from "./types.js";
|
|
2
2
|
export declare function createClient(opts: {
|
|
3
3
|
apiUrl: string;
|
|
4
4
|
token: string;
|
|
@@ -28,41 +28,29 @@ export declare function createClient(opts: {
|
|
|
28
28
|
baseUrl?: string;
|
|
29
29
|
description?: string;
|
|
30
30
|
displayName?: string;
|
|
31
|
-
billingStrategy?: string;
|
|
32
31
|
}) => Promise<InitProductResponse>;
|
|
33
|
-
compileProduct: (productId: string
|
|
32
|
+
compileProduct: (productId: string, opts?: {
|
|
33
|
+
branch?: string;
|
|
34
|
+
}) => Promise<{
|
|
34
35
|
success: boolean;
|
|
35
|
-
errors?:
|
|
36
|
-
|
|
37
|
-
message: string;
|
|
38
|
-
}>;
|
|
39
|
-
warnings?: Array<{
|
|
40
|
-
code?: string;
|
|
41
|
-
message: string;
|
|
42
|
-
}>;
|
|
36
|
+
errors?: CompileDiagnostic[];
|
|
37
|
+
warnings?: CompileDiagnostic[];
|
|
43
38
|
}>;
|
|
44
|
-
managementCompileSelf: (
|
|
39
|
+
managementCompileSelf: (opts?: {
|
|
40
|
+
branch?: string;
|
|
41
|
+
}) => Promise<{
|
|
45
42
|
success: boolean;
|
|
46
43
|
productId: string;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}>;
|
|
51
|
-
warnings?: Array<{
|
|
52
|
-
code?: string;
|
|
53
|
-
message: string;
|
|
54
|
-
}>;
|
|
44
|
+
branch?: string | null;
|
|
45
|
+
errors?: CompileDiagnostic[];
|
|
46
|
+
warnings?: CompileDiagnostic[];
|
|
55
47
|
}>;
|
|
56
|
-
managementCompile: (productId: string
|
|
48
|
+
managementCompile: (productId: string, opts?: {
|
|
49
|
+
branch?: string;
|
|
50
|
+
}) => Promise<{
|
|
57
51
|
success: boolean;
|
|
58
|
-
errors?:
|
|
59
|
-
|
|
60
|
-
message: string;
|
|
61
|
-
}>;
|
|
62
|
-
warnings?: Array<{
|
|
63
|
-
code?: string;
|
|
64
|
-
message: string;
|
|
65
|
-
}>;
|
|
52
|
+
errors?: CompileDiagnostic[];
|
|
53
|
+
warnings?: CompileDiagnostic[];
|
|
66
54
|
}>;
|
|
67
55
|
managementListProducts: () => Promise<Product[]>;
|
|
68
56
|
isMakerToken: () => boolean;
|
|
@@ -1,2 +1,28 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* Validate a parsed YAML object against the canonical Zod schema.
|
|
4
|
+
*
|
|
5
|
+
* Errors are returned in the same `Plan "key": message` shape the previous
|
|
6
|
+
* hand-rolled checks produced, so existing CI output stays grep-friendly.
|
|
7
|
+
* Warnings cover product-quality nudges (no free plan, missing display name)
|
|
8
|
+
* that don't fail the schema parse but are worth flagging.
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateProductYaml(spec: unknown): {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
errors: string[];
|
|
13
|
+
warnings: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Read + parse a product.yaml file. Returns either the parsed spec or
|
|
17
|
+
* a structured error result. Extracted from the validate command so
|
|
18
|
+
* the action handler stays under the cognitive-complexity threshold.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadProductYaml(filePath: string): {
|
|
21
|
+
ok: true;
|
|
22
|
+
spec: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
reason: "missing" | "parse";
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
2
28
|
export declare function registerValidateCommand(program: Command): void;
|
package/dist/config.d.ts
CHANGED
|
@@ -4,6 +4,3 @@ export declare function saveConfig(config: Partial<CliConfig>): void;
|
|
|
4
4
|
export declare function loadCredentials(): Credentials | null;
|
|
5
5
|
export declare function saveCredentials(creds: Credentials): void;
|
|
6
6
|
export declare function clearCredentials(): void;
|
|
7
|
-
export declare function getConfigPath(productSlug: string): string;
|
|
8
|
-
export declare function writeConfigFile(productSlug: string, content: string): string;
|
|
9
|
-
export declare function readConfigFile(productSlug: string): string | null;
|