@griffin-app/griffin-cli 1.0.5 → 1.0.6
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/hub/login.js +14 -4
- package/dist/core/plan-diff.d.ts +1 -1
- package/dist/core/plan-diff.js +5 -5
- package/dist/resolve.d.ts +1 -1
- package/dist/resolve.js +6 -1
- package/dist/utils/sdk-error.js +1 -1
- package/package.json +4 -4
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// CLI implementation
|
|
2
2
|
import { createAuthClient } from "better-auth/client";
|
|
3
3
|
import { deviceAuthorizationClient, jwtClient, } from "better-auth/client/plugins";
|
|
4
|
-
import { loadState, saveState } from "../../core/state.js";
|
|
4
|
+
import { getProjectId, loadState, saveState } from "../../core/state.js";
|
|
5
5
|
import { saveHubCredentials } from "../../core/credentials.js";
|
|
6
6
|
import { terminal } from "../../utils/terminal.js";
|
|
7
7
|
import { randomBytes } from "crypto";
|
|
8
|
+
import { createEmptyState } from "../../schemas/state.js";
|
|
8
9
|
const baseURL = "http://localhost:4000/api/auth";
|
|
9
10
|
const hubBaseUrl = "http://localhost:3000";
|
|
10
11
|
//const baseURL = "https://cloud.griffin.app"
|
|
@@ -41,12 +42,17 @@ async function pollForToken(clientId, deviceCode, interval) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
export async function executeLogin() {
|
|
44
|
-
|
|
45
|
-
let clientId
|
|
45
|
+
let state;
|
|
46
|
+
let clientId;
|
|
47
|
+
try {
|
|
48
|
+
state = await loadState();
|
|
49
|
+
clientId = state.hub?.clientId;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
}
|
|
46
53
|
if (!clientId) {
|
|
47
54
|
clientId = randomBytes(16).toString("hex");
|
|
48
55
|
}
|
|
49
|
-
//const clientId = state.hub?.clientId;
|
|
50
56
|
const { data } = await authClient.device.code({
|
|
51
57
|
client_id: clientId,
|
|
52
58
|
});
|
|
@@ -67,6 +73,10 @@ export async function executeLogin() {
|
|
|
67
73
|
terminal.success("Login successful");
|
|
68
74
|
terminal.log(` Token saved to user credentials`);
|
|
69
75
|
}
|
|
76
|
+
if (!state) {
|
|
77
|
+
const projectId = await getProjectId();
|
|
78
|
+
state = createEmptyState(projectId);
|
|
79
|
+
}
|
|
70
80
|
// Save hub config to project state (without token)
|
|
71
81
|
await saveState({
|
|
72
82
|
...state,
|
package/dist/core/plan-diff.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface FieldChange {
|
|
|
13
13
|
export interface NodeChange {
|
|
14
14
|
type: "add" | "remove" | "modify";
|
|
15
15
|
nodeId: string;
|
|
16
|
-
nodeType: "ASSERTION" | "
|
|
16
|
+
nodeType: "ASSERTION" | "HTTP_REQUEST" | "WAIT";
|
|
17
17
|
summary: string;
|
|
18
18
|
fieldChanges: FieldChange[];
|
|
19
19
|
}
|
package/dist/core/plan-diff.js
CHANGED
|
@@ -78,7 +78,7 @@ function compareNodes(localNodes, remoteNodes) {
|
|
|
78
78
|
*/
|
|
79
79
|
function getNodeSummary(node) {
|
|
80
80
|
switch (node.type) {
|
|
81
|
-
case "
|
|
81
|
+
case "HTTP_REQUEST":
|
|
82
82
|
return `${node.method} ${formatValue(node.path)}`;
|
|
83
83
|
case "WAIT":
|
|
84
84
|
return `wait ${node.duration_ms}ms`;
|
|
@@ -116,8 +116,8 @@ function compareNodeFields(local, remote) {
|
|
|
116
116
|
return changes;
|
|
117
117
|
}
|
|
118
118
|
switch (local.type) {
|
|
119
|
-
case NodeType.
|
|
120
|
-
|
|
119
|
+
case NodeType.HTTP_REQUEST:
|
|
120
|
+
compareHttpRequestFields(local, remote, changes);
|
|
121
121
|
break;
|
|
122
122
|
case NodeType.WAIT:
|
|
123
123
|
compareWaitFields(local, remote, changes);
|
|
@@ -129,9 +129,9 @@ function compareNodeFields(local, remote) {
|
|
|
129
129
|
return changes;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* Compare fields specific to
|
|
132
|
+
* Compare fields specific to HttpRequest nodes
|
|
133
133
|
*/
|
|
134
|
-
function
|
|
134
|
+
function compareHttpRequestFields(local, remote, changes) {
|
|
135
135
|
const fields = [
|
|
136
136
|
"method",
|
|
137
137
|
"path",
|
package/dist/resolve.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PlanV1 } from "@griffin-app/griffin-hub-sdk";
|
|
2
|
-
import { PlanDSL } from "@griffin-app/griffin-ts
|
|
2
|
+
import { PlanDSL } from "@griffin-app/griffin-ts";
|
|
3
3
|
export declare function resolvePlan(plan: PlanDSL, projectId: string, envName: string, variables: Record<string, string>): Omit<PlanV1, "id">;
|
package/dist/resolve.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { migrateToLatest, CURRENT_PLAN_VERSION } from "@griffin-app/griffin-ts";
|
|
1
2
|
import { resolveVariablesInPlan } from "./core/variables.js";
|
|
2
3
|
export function resolvePlan(plan, projectId, envName, variables) {
|
|
3
|
-
|
|
4
|
+
// Migrate DSL plan to latest version before resolving
|
|
5
|
+
const migratedPlan = plan.version === CURRENT_PLAN_VERSION
|
|
6
|
+
? plan
|
|
7
|
+
: migrateToLatest(plan);
|
|
8
|
+
const resolvedPlan = resolveVariablesInPlan(migratedPlan, variables);
|
|
4
9
|
return {
|
|
5
10
|
...resolvedPlan,
|
|
6
11
|
project: projectId,
|
package/dist/utils/sdk-error.js
CHANGED
|
@@ -37,7 +37,7 @@ export function handleSDKError(error, context) {
|
|
|
37
37
|
case 404:
|
|
38
38
|
terminal.error(`${contextMsg}Resource not found`);
|
|
39
39
|
if (sdkError.url) {
|
|
40
|
-
terminal.dim(`
|
|
40
|
+
terminal.dim(`URL: ${sdkError.url}`);
|
|
41
41
|
}
|
|
42
42
|
terminal.dim("The requested resource may not exist on the hub.");
|
|
43
43
|
return terminal.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griffin-app/griffin-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "CLI tool for running and managing griffin API tests",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@griffin-app/griffin-
|
|
27
|
-
"@griffin-app/griffin-
|
|
28
|
-
"@griffin-app/griffin-ts": "0.1.
|
|
26
|
+
"@griffin-app/griffin-plan-executor": "0.1.12",
|
|
27
|
+
"@griffin-app/griffin-hub-sdk": "1.0.4",
|
|
28
|
+
"@griffin-app/griffin-ts": "0.1.10",
|
|
29
29
|
"better-auth": "^1.4.17",
|
|
30
30
|
"cli-table3": "^0.6.5",
|
|
31
31
|
"commander": "^12.1.0",
|