@simonfestl/husky-cli 1.6.1 → 1.6.2
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/commands/worker.js +10 -8
- package/package.json +1 -1
package/dist/commands/worker.js
CHANGED
|
@@ -11,9 +11,10 @@ workerCommand
|
|
|
11
11
|
.action(async (options) => {
|
|
12
12
|
const config = getConfig();
|
|
13
13
|
const identity = getWorkerIdentity();
|
|
14
|
-
// Fetch role from API
|
|
15
|
-
let role = "unknown";
|
|
16
|
-
let permissions = [];
|
|
14
|
+
// Fetch role from API, fallback to cached config
|
|
15
|
+
let role = config.role || "unknown";
|
|
16
|
+
let permissions = config.permissions || [];
|
|
17
|
+
let roleSource = "cached";
|
|
17
18
|
if (config.apiUrl && config.apiKey) {
|
|
18
19
|
try {
|
|
19
20
|
const res = await fetch(`${config.apiUrl}/api/auth/whoami`, {
|
|
@@ -21,16 +22,17 @@ workerCommand
|
|
|
21
22
|
});
|
|
22
23
|
if (res.ok) {
|
|
23
24
|
const data = await res.json();
|
|
24
|
-
role = data.role ||
|
|
25
|
-
permissions = data.permissions ||
|
|
25
|
+
role = data.role || role;
|
|
26
|
+
permissions = data.permissions || permissions;
|
|
27
|
+
roleSource = "api";
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
catch {
|
|
29
|
-
//
|
|
31
|
+
// Fallback to cached role from config
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
if (options.json) {
|
|
33
|
-
console.log(JSON.stringify({ ...identity, role, permissions }, null, 2));
|
|
35
|
+
console.log(JSON.stringify({ ...identity, role, permissions, roleSource }, null, 2));
|
|
34
36
|
}
|
|
35
37
|
else {
|
|
36
38
|
console.log("\n Worker Identity");
|
|
@@ -42,7 +44,7 @@ workerCommand
|
|
|
42
44
|
console.log(` Platform: ${identity.platform}`);
|
|
43
45
|
console.log(` Version: ${identity.agentVersion}`);
|
|
44
46
|
console.log(" " + "─".repeat(40));
|
|
45
|
-
console.log(` Role: ${role}`);
|
|
47
|
+
console.log(` Role: ${role}${roleSource === "cached" ? " (cached)" : ""}`);
|
|
46
48
|
if (permissions.length > 0) {
|
|
47
49
|
console.log(` Perms: ${permissions.join(", ")}`);
|
|
48
50
|
}
|