@forgehive/forge-cli 0.3.0 → 0.3.1
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.js +7 -13
- package/package.json +7 -7
- package/src/tasks/task/run.ts +7 -14
package/dist/tasks/task/run.js
CHANGED
|
@@ -122,23 +122,17 @@ exports.run = (0, task_1.createTask)({
|
|
|
122
122
|
throw new Error(`Handler "${taskDescriptor.handler}" not found in bundle`);
|
|
123
123
|
}
|
|
124
124
|
// Setup record tape
|
|
125
|
-
|
|
125
|
+
const tape = new record_tape_1.RecordTape({
|
|
126
126
|
path: logsPath
|
|
127
127
|
});
|
|
128
128
|
// load record tape
|
|
129
129
|
try {
|
|
130
130
|
await tape.load();
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (log.length > maxLogLength) {
|
|
137
|
-
const newTape = new record_tape_1.RecordTape({
|
|
138
|
-
path: logsPath,
|
|
139
|
-
log: log.slice(-maxLogLength)
|
|
140
|
-
});
|
|
141
|
-
tape = newTape;
|
|
131
|
+
// Maintain a maximum log length by removing old records
|
|
132
|
+
const maxLogLength = 10;
|
|
133
|
+
// Remove records from the beginning until we're within the limit
|
|
134
|
+
while (tape.getLength() >= maxLogLength) {
|
|
135
|
+
tape.shift();
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
catch (_error) {
|
|
@@ -146,7 +140,7 @@ exports.run = (0, task_1.createTask)({
|
|
|
146
140
|
}
|
|
147
141
|
// Run the task with provided arguments
|
|
148
142
|
const [result, error, record] = await task.safeRun(args);
|
|
149
|
-
const logItem = tape.push(
|
|
143
|
+
const logItem = tape.push(record, {
|
|
150
144
|
environment: 'cli'
|
|
151
145
|
});
|
|
152
146
|
await tape.save();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgehive/forge-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "TypeScript CLI application",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@forgehive/record-tape": "^0.2.
|
|
14
|
-
"@forgehive/runner": "^0.2.
|
|
13
|
+
"@forgehive/record-tape": "^0.2.1",
|
|
14
|
+
"@forgehive/runner": "^0.2.1",
|
|
15
15
|
"@forgehive/schema": "^0.1.4",
|
|
16
|
-
"@forgehive/task": "^0.2.
|
|
16
|
+
"@forgehive/task": "^0.2.1",
|
|
17
17
|
"esbuild": "^0.25.0",
|
|
18
18
|
"handlebars": "^4.7.8",
|
|
19
19
|
"minimist": "^1.2.8"
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"esbuild": "^0.25.0",
|
|
27
27
|
"handlebars": "^4.7.8",
|
|
28
28
|
"minimist": "^1.2.8",
|
|
29
|
-
"@forgehive/record-tape": "0.2.0",
|
|
30
|
-
"@forgehive/task": "0.2.0",
|
|
31
29
|
"@forgehive/schema": "0.1.4",
|
|
32
|
-
"@forgehive/runner": "0.2.
|
|
30
|
+
"@forgehive/runner": "0.2.1",
|
|
31
|
+
"@forgehive/record-tape": "0.2.1",
|
|
32
|
+
"@forgehive/task": "0.2.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/archiver": "^6.0.3",
|
package/src/tasks/task/run.ts
CHANGED
|
@@ -141,7 +141,7 @@ export const run = createTask({
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// Setup record tape
|
|
144
|
-
|
|
144
|
+
const tape = new RecordTape({
|
|
145
145
|
path: logsPath
|
|
146
146
|
})
|
|
147
147
|
|
|
@@ -149,19 +149,12 @@ export const run = createTask({
|
|
|
149
149
|
try {
|
|
150
150
|
await tape.load()
|
|
151
151
|
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
// For now, we'll just keep the implementation simple
|
|
155
|
-
const maxLogLength = 9
|
|
156
|
-
const log = tape.getLog()
|
|
152
|
+
// Maintain a maximum log length by removing old records
|
|
153
|
+
const maxLogLength = 10
|
|
157
154
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
log: log.slice(-maxLogLength)
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
tape = newTape
|
|
155
|
+
// Remove records from the beginning until we're within the limit
|
|
156
|
+
while (tape.getLength() >= maxLogLength) {
|
|
157
|
+
tape.shift()
|
|
165
158
|
}
|
|
166
159
|
} catch (_error) {
|
|
167
160
|
// if the tape is not found, create a new one on saving
|
|
@@ -169,7 +162,7 @@ export const run = createTask({
|
|
|
169
162
|
|
|
170
163
|
// Run the task with provided arguments
|
|
171
164
|
const [result, error, record] = await task.safeRun(args)
|
|
172
|
-
const logItem = tape.push(
|
|
165
|
+
const logItem = tape.push(record, {
|
|
173
166
|
environment: 'cli'
|
|
174
167
|
})
|
|
175
168
|
await tape.save()
|