@farthershore/cli 0.3.1 → 0.3.3
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/dist/build-info.d.ts +1 -0
- package/dist/build-info.js +10 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +1 -0
- package/dist/commands/apply.js +15 -1
- package/dist/config.js +2 -1
- package/package.json +1 -1
|
@@ -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
|
@@ -93,6 +93,12 @@ export declare function createClient(opts: {
|
|
|
93
93
|
}>;
|
|
94
94
|
}>;
|
|
95
95
|
managementListProducts: () => Promise<Product[]>;
|
|
96
|
+
whoami: () => Promise<{
|
|
97
|
+
tokenId: string;
|
|
98
|
+
organizationId: string;
|
|
99
|
+
productId: string | null;
|
|
100
|
+
scopes: string[];
|
|
101
|
+
}>;
|
|
96
102
|
isMakerToken: () => boolean;
|
|
97
103
|
};
|
|
98
104
|
export type ApiClient = ReturnType<typeof createClient>;
|
package/dist/client.js
CHANGED
|
@@ -71,6 +71,7 @@ export function createClient(opts) {
|
|
|
71
71
|
// --- Management (maker token) ---
|
|
72
72
|
managementCompile: (productId) => request("POST", `/management/products/${productId}/compile`),
|
|
73
73
|
managementListProducts: () => request("GET", "/management/products"),
|
|
74
|
+
whoami: () => request("GET", "/management/whoami"),
|
|
74
75
|
isMakerToken: () => opts.token.startsWith("mk_"),
|
|
75
76
|
};
|
|
76
77
|
}
|
package/dist/commands/apply.js
CHANGED
|
@@ -55,7 +55,21 @@ export function registerApplyCommand(program, getClient) {
|
|
|
55
55
|
"Pass a product slug, or run inside a product repo to auto-detect from product.yaml.")
|
|
56
56
|
.action(async (productArg) => {
|
|
57
57
|
const client = getClient();
|
|
58
|
-
|
|
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;
|
|
61
|
+
if (client.isMakerToken() && !productArg) {
|
|
62
|
+
try {
|
|
63
|
+
const info = await client.whoami();
|
|
64
|
+
productId = info.productId;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Fall through to slug resolution
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!productId) {
|
|
71
|
+
productId = await resolveProductId(client, productArg);
|
|
72
|
+
}
|
|
59
73
|
if (!productId) {
|
|
60
74
|
const hint = productArg
|
|
61
75
|
? `Product "${productArg}" not found. Check the name and try again.`
|
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:
|
|
16
|
+
apiUrl: BUILD_API_URL,
|
|
16
17
|
defaultFormat: "table",
|
|
17
18
|
};
|
|
18
19
|
export function loadConfig() {
|