@forgehive/forge-cli 0.2.7 → 0.2.9
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/taskAdapter.d.ts +34 -0
- package/dist/taskAdapter.js +85 -0
- package/dist/tasks/task/run.js +5 -11
- package/package.json +5 -5
- package/src/tasks/task/run.ts +5 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TaskInstanceType, BaseFunction, Boundaries, ExecutionRecord, ReplayConfig } from '@forgehive/task';
|
|
2
|
+
import { SchemaDescription } from '@forgehive/schema';
|
|
3
|
+
/**
|
|
4
|
+
* TaskAdapter wraps a TaskInstanceType to make it compatible with Runner
|
|
5
|
+
* by handling boundary type issues
|
|
6
|
+
*/
|
|
7
|
+
export declare class TaskAdapter<F extends BaseFunction, B extends Boundaries> {
|
|
8
|
+
private task;
|
|
9
|
+
constructor(task: TaskInstanceType<F, B>);
|
|
10
|
+
get version(): string;
|
|
11
|
+
getDescription(): string | undefined;
|
|
12
|
+
describe(): SchemaDescription;
|
|
13
|
+
run(argv?: Parameters<F>[0]): Promise<ReturnType<F>>;
|
|
14
|
+
safeReplay(executionLog: ExecutionRecord<any, any, any>, config: ReplayConfig<any>): Promise<[ReturnType<F> | null, Error | null, ExecutionRecord<Parameters<F>[0], ReturnType<F>, B>]>;
|
|
15
|
+
getMode(): import("@forgehive/task").Mode;
|
|
16
|
+
setMode(mode: string): void;
|
|
17
|
+
validate(argv?: any): any;
|
|
18
|
+
isValid(argv?: any): boolean;
|
|
19
|
+
addListener(fn: any): void;
|
|
20
|
+
removeListener(): void;
|
|
21
|
+
emit(data: any): void;
|
|
22
|
+
asBoundary(): (args: Parameters<F>[0]) => Promise<ReturnType<F>>;
|
|
23
|
+
getBoundaries(): import("@forgehive/task").WrappedBoundaries<B>;
|
|
24
|
+
setBoundariesData(data: any): void;
|
|
25
|
+
getBondariesData(): Record<string, unknown>;
|
|
26
|
+
mockBoundary(name: any, mockFn: any): any;
|
|
27
|
+
resetMock(name: any): any;
|
|
28
|
+
resetMocks(): void;
|
|
29
|
+
safeRun(argv?: Parameters<F>[0]): Promise<[ReturnType<F> | null, Error | null, ExecutionRecord<Parameters<F>[0], ReturnType<F>, B>]>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Helper function to adapt a task instance for Runner compatibility
|
|
33
|
+
*/
|
|
34
|
+
export declare function adaptTask<F extends BaseFunction, B extends Boundaries>(task: TaskInstanceType<F, B>): TaskInstanceType;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskAdapter = void 0;
|
|
4
|
+
exports.adaptTask = adaptTask;
|
|
5
|
+
/**
|
|
6
|
+
* TaskAdapter wraps a TaskInstanceType to make it compatible with Runner
|
|
7
|
+
* by handling boundary type issues
|
|
8
|
+
*/
|
|
9
|
+
class TaskAdapter {
|
|
10
|
+
constructor(task) {
|
|
11
|
+
this.task = task;
|
|
12
|
+
}
|
|
13
|
+
// Forward all required methods to the underlying task
|
|
14
|
+
get version() {
|
|
15
|
+
return this.task.version;
|
|
16
|
+
}
|
|
17
|
+
getDescription() {
|
|
18
|
+
return this.task.getDescription();
|
|
19
|
+
}
|
|
20
|
+
describe() {
|
|
21
|
+
return this.task.describe();
|
|
22
|
+
}
|
|
23
|
+
async run(argv) {
|
|
24
|
+
return this.task.run(argv);
|
|
25
|
+
}
|
|
26
|
+
// This is the problematic method with boundary type incompatibilities
|
|
27
|
+
// Our implementation uses type assertions to make it compatible
|
|
28
|
+
async safeReplay(executionLog, config) {
|
|
29
|
+
// Type assertion to bridge the boundary type gap
|
|
30
|
+
return this.task.safeReplay(executionLog, config);
|
|
31
|
+
}
|
|
32
|
+
// Forward other methods as needed
|
|
33
|
+
getMode() {
|
|
34
|
+
return this.task.getMode();
|
|
35
|
+
}
|
|
36
|
+
setMode(mode) {
|
|
37
|
+
return this.task.setMode(mode);
|
|
38
|
+
}
|
|
39
|
+
validate(argv) {
|
|
40
|
+
return this.task.validate(argv);
|
|
41
|
+
}
|
|
42
|
+
isValid(argv) {
|
|
43
|
+
return this.task.isValid(argv);
|
|
44
|
+
}
|
|
45
|
+
addListener(fn) {
|
|
46
|
+
return this.task.addListener(fn);
|
|
47
|
+
}
|
|
48
|
+
removeListener() {
|
|
49
|
+
return this.task.removeListener();
|
|
50
|
+
}
|
|
51
|
+
emit(data) {
|
|
52
|
+
return this.task.emit(data);
|
|
53
|
+
}
|
|
54
|
+
asBoundary() {
|
|
55
|
+
return this.task.asBoundary();
|
|
56
|
+
}
|
|
57
|
+
getBoundaries() {
|
|
58
|
+
return this.task.getBoundaries();
|
|
59
|
+
}
|
|
60
|
+
setBoundariesData(data) {
|
|
61
|
+
return this.task.setBoundariesData(data);
|
|
62
|
+
}
|
|
63
|
+
getBondariesData() {
|
|
64
|
+
return this.task.getBondariesData();
|
|
65
|
+
}
|
|
66
|
+
mockBoundary(name, mockFn) {
|
|
67
|
+
return this.task.mockBoundary(name, mockFn);
|
|
68
|
+
}
|
|
69
|
+
resetMock(name) {
|
|
70
|
+
return this.task.resetMock(name);
|
|
71
|
+
}
|
|
72
|
+
resetMocks() {
|
|
73
|
+
return this.task.resetMocks();
|
|
74
|
+
}
|
|
75
|
+
async safeRun(argv) {
|
|
76
|
+
return this.task.safeRun(argv);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.TaskAdapter = TaskAdapter;
|
|
80
|
+
/**
|
|
81
|
+
* Helper function to adapt a task instance for Runner compatibility
|
|
82
|
+
*/
|
|
83
|
+
function adaptTask(task) {
|
|
84
|
+
return new TaskAdapter(task);
|
|
85
|
+
}
|
package/dist/tasks/task/run.js
CHANGED
|
@@ -140,21 +140,15 @@ exports.run = (0, task_1.createTask)(schema, boundaries, async function ({ descr
|
|
|
140
140
|
catch (_error) {
|
|
141
141
|
// if the tape is not found, create a new one on saving
|
|
142
142
|
}
|
|
143
|
-
tape.recordFrom(descriptorName, task);
|
|
144
143
|
// Run the task with provided arguments
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
error = e;
|
|
151
|
-
}
|
|
144
|
+
const [result, error, record] = await task.safeRun(args);
|
|
145
|
+
const logItem = tape.push(descriptorName, record, {
|
|
146
|
+
environment: 'cli'
|
|
147
|
+
});
|
|
152
148
|
await tape.save();
|
|
153
|
-
const logItems = tape.getLog();
|
|
154
|
-
const lastLogItem = logItems[logItems.length - 1];
|
|
155
149
|
if (profile) {
|
|
156
150
|
try {
|
|
157
|
-
await sendLogToAPI(profile, projectName, descriptorName,
|
|
151
|
+
await sendLogToAPI(profile, projectName, descriptorName, logItem);
|
|
158
152
|
}
|
|
159
153
|
catch (e) {
|
|
160
154
|
console.error('Failed to send log to API:', e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgehive/forge-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "TypeScript CLI application",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@forgehive/record-tape": "^0.1.
|
|
13
|
+
"@forgehive/record-tape": "^0.1.1",
|
|
14
14
|
"@forgehive/runner": "^0.1.7",
|
|
15
15
|
"@forgehive/schema": "^0.1.4",
|
|
16
16
|
"@forgehive/task": "^0.1.7",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"esbuild": "^0.25.0",
|
|
26
26
|
"handlebars": "^4.7.8",
|
|
27
27
|
"minimist": "^1.2.8",
|
|
28
|
+
"@forgehive/runner": "0.1.8",
|
|
29
|
+
"@forgehive/record-tape": "0.1.2",
|
|
28
30
|
"@forgehive/schema": "0.1.4",
|
|
29
|
-
"@forgehive/
|
|
30
|
-
"@forgehive/runner": "0.1.7",
|
|
31
|
-
"@forgehive/task": "0.1.7"
|
|
31
|
+
"@forgehive/task": "0.1.8"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^29.5.3",
|
package/src/tasks/task/run.ts
CHANGED
|
@@ -166,23 +166,16 @@ export const run = createTask(
|
|
|
166
166
|
// if the tape is not found, create a new one on saving
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
tape.recordFrom(descriptorName, task)
|
|
170
|
-
|
|
171
169
|
// Run the task with provided arguments
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
error = e as Error
|
|
177
|
-
}
|
|
178
|
-
|
|
170
|
+
const [result, error, record] = await task.safeRun(args)
|
|
171
|
+
const logItem = tape.push(descriptorName, record, {
|
|
172
|
+
environment: 'cli'
|
|
173
|
+
})
|
|
179
174
|
await tape.save()
|
|
180
|
-
const logItems = tape.getLog()
|
|
181
|
-
const lastLogItem = logItems[logItems.length - 1]
|
|
182
175
|
|
|
183
176
|
if (profile) {
|
|
184
177
|
try {
|
|
185
|
-
await sendLogToAPI(profile, projectName, descriptorName,
|
|
178
|
+
await sendLogToAPI(profile, projectName, descriptorName, logItem)
|
|
186
179
|
} catch (e) {
|
|
187
180
|
console.error('Failed to send log to API:', e)
|
|
188
181
|
}
|