@farthershore/cli 0.3.3 → 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.
- package/dist/client.d.ts +12 -0
- package/dist/client.js +2 -0
- package/dist/commands/apply.js +42 -35
- package/package.json +1 -1
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"),
|
package/dist/commands/apply.js
CHANGED
|
@@ -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
|
-
//
|
|
59
|
-
// the token — no
|
|
60
|
-
|
|
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
|
|
64
|
-
|
|
90
|
+
const result = await client.managementCompileSelf();
|
|
91
|
+
handleResult(result);
|
|
92
|
+
return;
|
|
65
93
|
}
|
|
66
|
-
catch {
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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";
|