@farthershore/cli 0.3.2 → 0.3.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.
@@ -0,0 +1 @@
1
+ export declare const BUILD_API_URL = "https://core.farthershore.com";
@@ -0,0 +1,10 @@
1
+ // Build-time constants baked into the CLI binary at publish time.
2
+ //
3
+ // To publish a staging variant:
4
+ // 1. Change BUILD_API_URL below to the staging URL
5
+ // 2. Change the npm package name/tag in package.json
6
+ // 3. Run `npm publish`
7
+ //
8
+ // The CLI uses this as the default API URL — users don't need to set
9
+ // FARTHERSHORE_API_URL or pass --api-url for their target environment.
10
+ export const BUILD_API_URL = "https://core.farthershore.com";
package/dist/client.d.ts CHANGED
@@ -81,6 +81,18 @@ export declare function createClient(opts: {
81
81
  message: string;
82
82
  }>;
83
83
  }>;
84
+ managementCompileSelf: () => Promise<{
85
+ success: boolean;
86
+ productId: string;
87
+ errors?: Array<{
88
+ code?: string;
89
+ message: string;
90
+ }>;
91
+ warnings?: Array<{
92
+ code?: string;
93
+ message: string;
94
+ }>;
95
+ }>;
84
96
  managementCompile: (productId: string) => Promise<{
85
97
  success: boolean;
86
98
  errors?: Array<{
package/dist/client.js CHANGED
@@ -69,6 +69,8 @@ export function createClient(opts) {
69
69
  // --- Compile ---
70
70
  compileProduct: (productId) => request("POST", `/products/${productId}/compile`),
71
71
  // --- Management (maker token) ---
72
+ // Compile the product associated with the token — no product ID needed.
73
+ managementCompileSelf: () => request("POST", "/management/compile"),
72
74
  managementCompile: (productId) => request("POST", `/management/products/${productId}/compile`),
73
75
  managementListProducts: () => request("GET", "/management/products"),
74
76
  whoami: () => request("GET", "/management/whoami"),
@@ -48,6 +48,33 @@ async function resolveProductId(client, arg) {
48
48
  return null;
49
49
  }
50
50
  }
51
+ function handleResult(result) {
52
+ // GitHub Actions annotations
53
+ if (CI) {
54
+ for (const err of result.errors ?? []) {
55
+ console.log(`::error file=product.yaml::${err.code ? `[${err.code}] ` : ""}${err.message}`);
56
+ }
57
+ for (const w of result.warnings ?? []) {
58
+ console.log(`::warning file=product.yaml::${w.code ? `[${w.code}] ` : ""}${w.message}`);
59
+ }
60
+ }
61
+ if (result.success) {
62
+ output.success("Compilation passed");
63
+ if (result.warnings?.length) {
64
+ console.log();
65
+ for (const w of result.warnings) {
66
+ output.warn(`${w.code ? `[${w.code}] ` : ""}${w.message}`);
67
+ }
68
+ }
69
+ }
70
+ else {
71
+ output.error("Compilation failed\n");
72
+ for (const err of result.errors ?? []) {
73
+ console.log(` • ${err.code ? `[${err.code}] ` : ""}${err.message}`);
74
+ }
75
+ process.exitCode = 1;
76
+ }
77
+ }
51
78
  export function registerApplyCommand(program, getClient) {
52
79
  program
53
80
  .command("apply [product]")
@@ -55,21 +82,25 @@ export function registerApplyCommand(program, getClient) {
55
82
  "Pass a product slug, or run inside a product repo to auto-detect from product.yaml.")
56
83
  .action(async (productArg) => {
57
84
  const client = getClient();
58
- // For product-scoped maker tokens, get the productId directly from
59
- // the token — no need to read product.yaml or resolve slugs.
60
- let productId = null;
85
+ // Fast path for CI: product-scoped maker token with no argument.
86
+ // Server auto-resolves product from the token — no product.yaml,
87
+ // no slug lookup, single API call.
61
88
  if (client.isMakerToken() && !productArg) {
62
89
  try {
63
- const info = await client.whoami();
64
- productId = info.productId;
90
+ const result = await client.managementCompileSelf();
91
+ handleResult(result);
92
+ return;
65
93
  }
66
- catch {
67
- // Fall through to slug resolution
94
+ catch (err) {
95
+ const msg = err instanceof Error ? err.message : "Compilation check failed";
96
+ if (CI)
97
+ console.log(`::error::${msg}`);
98
+ output.error(msg);
99
+ process.exitCode = 1;
100
+ return;
68
101
  }
69
102
  }
70
- if (!productId) {
71
- productId = await resolveProductId(client, productArg);
72
- }
103
+ const productId = await resolveProductId(client, productArg);
73
104
  if (!productId) {
74
105
  const hint = productArg
75
106
  ? `Product "${productArg}" not found. Check the name and try again.`
@@ -83,31 +114,7 @@ export function registerApplyCommand(program, getClient) {
83
114
  const result = client.isMakerToken()
84
115
  ? await client.managementCompile(productId)
85
116
  : await client.compileProduct(productId);
86
- // GitHub Actions annotations
87
- if (CI) {
88
- for (const err of result.errors ?? []) {
89
- console.log(`::error file=product.yaml::${err.code ? `[${err.code}] ` : ""}${err.message}`);
90
- }
91
- for (const w of result.warnings ?? []) {
92
- console.log(`::warning file=product.yaml::${w.code ? `[${w.code}] ` : ""}${w.message}`);
93
- }
94
- }
95
- if (result.success) {
96
- output.success("Compilation passed");
97
- if (result.warnings?.length) {
98
- console.log();
99
- for (const w of result.warnings) {
100
- output.warn(`${w.code ? `[${w.code}] ` : ""}${w.message}`);
101
- }
102
- }
103
- }
104
- else {
105
- output.error("Compilation failed\n");
106
- for (const err of result.errors ?? []) {
107
- console.log(` • ${err.code ? `[${err.code}] ` : ""}${err.message}`);
108
- }
109
- process.exitCode = 1;
110
- }
117
+ handleResult(result);
111
118
  }
112
119
  catch (err) {
113
120
  const msg = err instanceof Error ? err.message : "Compilation check failed";
package/dist/config.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { join } from "node:path";
5
+ import { BUILD_API_URL } from "./build-info.js";
5
6
  const CONFIG_DIR = join(homedir(), ".farthershore");
6
7
  const CONFIG_FILE = join(CONFIG_DIR, "config.json");
7
8
  const CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
@@ -12,7 +13,7 @@ function ensureDir(dir) {
12
13
  }
13
14
  // --- Config ---
14
15
  const DEFAULT_CONFIG = {
15
- apiUrl: "https://core.farthershore.com",
16
+ apiUrl: BUILD_API_URL,
16
17
  defaultFormat: "table",
17
18
  };
18
19
  export function loadConfig() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farthershore/cli",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "FartherShore CLI — create and configure API products",
5
5
  "type": "module",
6
6
  "bin": {