@forgehive/forge-cli 0.3.1 → 0.3.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/tasks/task/run.d.ts +8 -2
- package/dist/tasks/task/run.js +21 -15
- package/package.json +10 -8
- package/src/tasks/task/run.ts +21 -17
package/dist/tasks/task/run.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ export declare const run: import("@forgehive/task").TaskInstanceType<(argv: {
|
|
|
16
16
|
}) => Promise<Promise<any>>;
|
|
17
17
|
verifyLogFolder: (logsPath: string) => Promise<boolean>;
|
|
18
18
|
ensureBuildsFolder: () => Promise<string>;
|
|
19
|
-
sendLogToAPI: (profile: Profile, projectName: string, taskName: string, logItem:
|
|
19
|
+
sendLogToAPI: (profile: Profile, projectName: string, taskName: string, logItem: {
|
|
20
|
+
input: unknown;
|
|
21
|
+
metadata?: Record<string, string>;
|
|
22
|
+
}) => Promise<boolean>;
|
|
20
23
|
}>) => Promise<any>, {
|
|
21
24
|
loadConf: (args: {}) => Promise<Promise<ForgeConf>>;
|
|
22
25
|
loadCurrentProfile: (args: {}) => Promise<Promise<Profile>>;
|
|
@@ -31,5 +34,8 @@ export declare const run: import("@forgehive/task").TaskInstanceType<(argv: {
|
|
|
31
34
|
}) => Promise<Promise<any>>;
|
|
32
35
|
verifyLogFolder: (logsPath: string) => Promise<boolean>;
|
|
33
36
|
ensureBuildsFolder: () => Promise<string>;
|
|
34
|
-
sendLogToAPI: (profile: Profile, projectName: string, taskName: string, logItem:
|
|
37
|
+
sendLogToAPI: (profile: Profile, projectName: string, taskName: string, logItem: {
|
|
38
|
+
input: unknown;
|
|
39
|
+
metadata?: Record<string, string>;
|
|
40
|
+
}) => Promise<boolean>;
|
|
35
41
|
}>;
|
package/dist/tasks/task/run.js
CHANGED
|
@@ -11,10 +11,10 @@ exports.run = void 0;
|
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
12
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
13
13
|
const os_1 = __importDefault(require("os"));
|
|
14
|
-
const axios_1 = __importDefault(require("axios"));
|
|
15
14
|
const task_1 = require("@forgehive/task");
|
|
16
15
|
const schema_1 = require("@forgehive/schema");
|
|
17
16
|
const record_tape_1 = require("@forgehive/record-tape");
|
|
17
|
+
const hive_sdk_1 = require("@forgehive/hive-sdk");
|
|
18
18
|
const create_1 = require("../bundle/create");
|
|
19
19
|
const load_1 = require("../bundle/load");
|
|
20
20
|
const load_2 = require("../conf/load");
|
|
@@ -53,25 +53,31 @@ const boundaries = {
|
|
|
53
53
|
},
|
|
54
54
|
sendLogToAPI: async (profile, projectName, taskName, logItem) => {
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
57
|
-
const authToken = `${profile.apiKey}:${profile.apiSecret}`;
|
|
58
|
-
await axios_1.default.post(logsUrl, {
|
|
56
|
+
const config = {
|
|
59
57
|
projectName,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'Content-Type': 'application/json'
|
|
58
|
+
apiKey: profile.apiKey,
|
|
59
|
+
apiSecret: profile.apiSecret,
|
|
60
|
+
host: profile.url,
|
|
61
|
+
metadata: {
|
|
62
|
+
environment: 'cli'
|
|
66
63
|
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
};
|
|
65
|
+
const client = new hive_sdk_1.HiveLogClient(config);
|
|
66
|
+
const result = await client.sendLog(taskName, logItem);
|
|
67
|
+
if (result === 'success') {
|
|
68
|
+
console.log('===============================================');
|
|
69
|
+
console.log('Log sent to API... ', profile.name, profile.url);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
console.error('Failed to send log to API:', profile.url);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
71
76
|
}
|
|
72
77
|
catch (e) {
|
|
78
|
+
console.error('Failed to send log to API:', profile.url);
|
|
73
79
|
const error = e;
|
|
74
|
-
console.error('
|
|
80
|
+
console.error('Error:', error.message);
|
|
75
81
|
return false;
|
|
76
82
|
}
|
|
77
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgehive/forge-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "TypeScript CLI application",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@forgehive/
|
|
14
|
-
"@forgehive/
|
|
13
|
+
"@forgehive/hive-sdk": "^0.0.2",
|
|
14
|
+
"@forgehive/record-tape": "^0.2.2",
|
|
15
|
+
"@forgehive/runner": "^0.2.2",
|
|
15
16
|
"@forgehive/schema": "^0.1.4",
|
|
16
|
-
"@forgehive/task": "^0.2.
|
|
17
|
+
"@forgehive/task": "^0.2.2",
|
|
17
18
|
"esbuild": "^0.25.0",
|
|
18
19
|
"handlebars": "^4.7.8",
|
|
19
20
|
"minimist": "^1.2.8"
|
|
@@ -26,10 +27,11 @@
|
|
|
26
27
|
"esbuild": "^0.25.0",
|
|
27
28
|
"handlebars": "^4.7.8",
|
|
28
29
|
"minimist": "^1.2.8",
|
|
29
|
-
"@forgehive/
|
|
30
|
-
"@forgehive/
|
|
31
|
-
"@forgehive/
|
|
32
|
-
"@forgehive/
|
|
30
|
+
"@forgehive/hive-sdk": "0.0.2",
|
|
31
|
+
"@forgehive/record-tape": "0.2.2",
|
|
32
|
+
"@forgehive/task": "0.2.2",
|
|
33
|
+
"@forgehive/runner": "0.2.2",
|
|
34
|
+
"@forgehive/schema": "0.1.4"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@types/archiver": "^6.0.3",
|
package/src/tasks/task/run.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
import path from 'path'
|
|
7
7
|
import fs from 'fs/promises'
|
|
8
8
|
import os from 'os'
|
|
9
|
-
import axios from 'axios'
|
|
10
9
|
|
|
11
10
|
import { createTask } from '@forgehive/task'
|
|
12
11
|
import { Schema } from '@forgehive/schema'
|
|
13
12
|
import { RecordTape } from '@forgehive/record-tape'
|
|
13
|
+
import { HiveLogClient } from '@forgehive/hive-sdk'
|
|
14
14
|
|
|
15
15
|
import { create as bundleCreate } from '../bundle/create'
|
|
16
16
|
import { load as bundleLoad } from '../bundle/load'
|
|
@@ -51,29 +51,33 @@ const boundaries = {
|
|
|
51
51
|
|
|
52
52
|
return buildsPath
|
|
53
53
|
},
|
|
54
|
-
sendLogToAPI: async (profile: Profile, projectName: string, taskName: string, logItem: unknown): Promise<boolean> => {
|
|
54
|
+
sendLogToAPI: async (profile: Profile, projectName: string, taskName: string, logItem: { input: unknown; metadata?: Record<string, string> }): Promise<boolean> => {
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
57
|
-
const authToken = `${profile.apiKey}:${profile.apiSecret}`
|
|
58
|
-
|
|
59
|
-
await axios.post(logsUrl, {
|
|
56
|
+
const config = {
|
|
60
57
|
projectName,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'Content-Type': 'application/json'
|
|
58
|
+
apiKey: profile.apiKey,
|
|
59
|
+
apiSecret: profile.apiSecret,
|
|
60
|
+
host: profile.url,
|
|
61
|
+
metadata: {
|
|
62
|
+
environment: 'cli'
|
|
67
63
|
}
|
|
68
|
-
}
|
|
64
|
+
}
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
const client = new HiveLogClient(config)
|
|
67
|
+
const result = await client.sendLog(taskName, logItem)
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
if (result === 'success') {
|
|
70
|
+
console.log('===============================================')
|
|
71
|
+
console.log('Log sent to API... ', profile.name, profile.url)
|
|
72
|
+
return true
|
|
73
|
+
} else {
|
|
74
|
+
console.error('Failed to send log to API:', profile.url)
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
74
77
|
} catch (e) {
|
|
78
|
+
console.error('Failed to send log to API:', profile.url)
|
|
75
79
|
const error = e as Error
|
|
76
|
-
console.error('
|
|
80
|
+
console.error('Error:', error.message)
|
|
77
81
|
return false
|
|
78
82
|
}
|
|
79
83
|
}
|