@kitsi/action 0.2.0 → 0.3.0
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/index.js +43 -69
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -126757,6 +126757,16 @@ var writeFiles = async (basePath, files) => {
|
|
|
126757
126757
|
await writeFile(destination, contents);
|
|
126758
126758
|
}));
|
|
126759
126759
|
};
|
|
126760
|
+
var copyFiles = async (sourceBase, destinationBase) => {
|
|
126761
|
+
const files = await walk(sourceBase);
|
|
126762
|
+
const fileMap = {};
|
|
126763
|
+
await Promise.all(files.map(async (file) => {
|
|
126764
|
+
const relativePath = relative(sourceBase, file);
|
|
126765
|
+
fileMap[relativePath] = await readFile3(file);
|
|
126766
|
+
}));
|
|
126767
|
+
await mkdir2(destinationBase, { recursive: true });
|
|
126768
|
+
await writeFiles(destinationBase, fileMap);
|
|
126769
|
+
};
|
|
126760
126770
|
|
|
126761
126771
|
// ../core/src/engine/cache/serialize.ts
|
|
126762
126772
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -127960,8 +127970,7 @@ class AnnotateHandler {
|
|
|
127960
127970
|
|
|
127961
127971
|
// ../core/src/engine/handlers/artifact-download-handler.ts
|
|
127962
127972
|
import { existsSync as existsSync2 } from "node:fs";
|
|
127963
|
-
import {
|
|
127964
|
-
import { join as join5, relative as relative3 } from "node:path";
|
|
127973
|
+
import { join as join5 } from "node:path";
|
|
127965
127974
|
class ArtifactDownloadHandler {
|
|
127966
127975
|
kind = "artifact-download";
|
|
127967
127976
|
async execute(op, context, _state) {
|
|
@@ -127971,15 +127980,8 @@ class ArtifactDownloadHandler {
|
|
|
127971
127980
|
if (!existsSync2(sourceBase)) {
|
|
127972
127981
|
throw OpErrors.artifact(`Artifact "${op.name}" not found at ${sourceBase}`).build();
|
|
127973
127982
|
}
|
|
127974
|
-
const files = await walk(sourceBase);
|
|
127975
|
-
const fileMap = {};
|
|
127976
|
-
await Promise.all(files.map(async (file) => {
|
|
127977
|
-
const relativePath = relative3(sourceBase, file);
|
|
127978
|
-
fileMap[relativePath] = await readFile6(file);
|
|
127979
|
-
}));
|
|
127980
127983
|
const destinationBase = join5(context.workspace, op.destination);
|
|
127981
|
-
await
|
|
127982
|
-
await writeFiles(destinationBase, fileMap);
|
|
127984
|
+
await copyFiles(sourceBase, destinationBase);
|
|
127983
127985
|
context.reporter?.emit("artifact_download_end", {
|
|
127984
127986
|
artifact: op.name,
|
|
127985
127987
|
status: "success"
|
|
@@ -128030,7 +128032,7 @@ class BindServiceHandler {
|
|
|
128030
128032
|
|
|
128031
128033
|
// ../core/src/engine/handlers/cache-mount-handler.ts
|
|
128032
128034
|
import { existsSync as existsSync3 } from "node:fs";
|
|
128033
|
-
import { mkdir as
|
|
128035
|
+
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
128034
128036
|
import { join as join7 } from "node:path";
|
|
128035
128037
|
|
|
128036
128038
|
class CacheMountHandler {
|
|
@@ -128042,7 +128044,7 @@ class CacheMountHandler {
|
|
|
128042
128044
|
cache: op.cache.name,
|
|
128043
128045
|
path: mountPath
|
|
128044
128046
|
});
|
|
128045
|
-
await
|
|
128047
|
+
await mkdir4(mountPath, { recursive: true });
|
|
128046
128048
|
}
|
|
128047
128049
|
}
|
|
128048
128050
|
|
|
@@ -128078,7 +128080,7 @@ class EnvHandler {
|
|
|
128078
128080
|
}
|
|
128079
128081
|
|
|
128080
128082
|
// ../core/src/engine/handlers/http-handler.ts
|
|
128081
|
-
import { readFile as
|
|
128083
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
128082
128084
|
import { isAbsolute, resolve } from "node:path";
|
|
128083
128085
|
class HttpHandler {
|
|
128084
128086
|
kind = "http";
|
|
@@ -128096,7 +128098,7 @@ class HttpHandler {
|
|
|
128096
128098
|
let body;
|
|
128097
128099
|
if (op.bodyPath) {
|
|
128098
128100
|
const resolved = isAbsolute(op.bodyPath) ? op.bodyPath : resolve(context.workspace, op.bodyPath);
|
|
128099
|
-
body = await
|
|
128101
|
+
body = await readFile6(resolved);
|
|
128100
128102
|
} else if (op.body) {
|
|
128101
128103
|
body = this.renderTemplate(op.body, context);
|
|
128102
128104
|
}
|
|
@@ -128824,41 +128826,11 @@ class PlanRunner {
|
|
|
128824
128826
|
state.artifactUploads.push({ op, step: step2.name });
|
|
128825
128827
|
return;
|
|
128826
128828
|
}
|
|
128827
|
-
|
|
128828
|
-
this.reporter?.emit("op_start", { task: task2.config.name, step: step2.name, op: op.kind });
|
|
128829
|
-
try {
|
|
128830
|
-
const context = {
|
|
128831
|
-
workspace: this.workspace,
|
|
128832
|
-
env: env2,
|
|
128833
|
-
logger: this.logger,
|
|
128834
|
-
resolver: this.resolver,
|
|
128835
|
-
reporter: this.reporter,
|
|
128836
|
-
signal: this.signal,
|
|
128837
|
-
task: task2.config.name,
|
|
128838
|
-
step: step2.name
|
|
128839
|
-
};
|
|
128829
|
+
return this.runOpWithLifecycle(task2.config.name, step2.name, op.kind, env2, async (context) => {
|
|
128840
128830
|
const executeBaseOp = (opToRun) => this.opHandlers.execute(opToRun, context, state);
|
|
128841
128831
|
const cacheResult = await this.cache.tryExecuteOp(op, task2, context, state, executeBaseOp, this.executeOp.bind(this));
|
|
128842
|
-
|
|
128843
|
-
|
|
128844
|
-
task: task2.config.name,
|
|
128845
|
-
step: step2.name,
|
|
128846
|
-
op: op.kind,
|
|
128847
|
-
status: "success",
|
|
128848
|
-
duration: (Date.now() - opStart) / 1000
|
|
128849
|
-
});
|
|
128850
|
-
return result;
|
|
128851
|
-
} catch (error2) {
|
|
128852
|
-
this.reporter?.emit("op_end", {
|
|
128853
|
-
task: task2.config.name,
|
|
128854
|
-
step: step2.name,
|
|
128855
|
-
op: op.kind,
|
|
128856
|
-
status: "failed",
|
|
128857
|
-
duration: (Date.now() - opStart) / 1000,
|
|
128858
|
-
error: error2 instanceof Error ? error2.message : String(error2)
|
|
128859
|
-
});
|
|
128860
|
-
throw error2;
|
|
128861
|
-
}
|
|
128832
|
+
return cacheResult?.handled ? cacheResult.value : await executeBaseOp(op);
|
|
128833
|
+
});
|
|
128862
128834
|
}
|
|
128863
128835
|
async flushArtifactUploads(task2, env2, state, status) {
|
|
128864
128836
|
if (state.artifactUploads.length === 0)
|
|
@@ -128883,36 +128855,38 @@ class PlanRunner {
|
|
|
128883
128855
|
return when === "always" || status === "success";
|
|
128884
128856
|
}
|
|
128885
128857
|
async executeArtifactUpload(task2, env2, state, entry) {
|
|
128858
|
+
await this.runOpWithLifecycle(task2.config.name, entry.step, entry.op.kind, env2, (context) => this.opHandlers.execute(entry.op, context, state));
|
|
128859
|
+
}
|
|
128860
|
+
createExecutionContext(taskName, stepName, env2) {
|
|
128861
|
+
return {
|
|
128862
|
+
workspace: this.workspace,
|
|
128863
|
+
env: env2,
|
|
128864
|
+
logger: this.logger,
|
|
128865
|
+
resolver: this.resolver,
|
|
128866
|
+
reporter: this.reporter,
|
|
128867
|
+
signal: this.signal,
|
|
128868
|
+
task: taskName,
|
|
128869
|
+
step: stepName
|
|
128870
|
+
};
|
|
128871
|
+
}
|
|
128872
|
+
async runOpWithLifecycle(taskName, stepName, opKind, env2, execute) {
|
|
128886
128873
|
const opStart = Date.now();
|
|
128887
|
-
this.reporter?.emit("op_start", {
|
|
128888
|
-
task: task2.config.name,
|
|
128889
|
-
step: entry.step,
|
|
128890
|
-
op: entry.op.kind
|
|
128891
|
-
});
|
|
128874
|
+
this.reporter?.emit("op_start", { task: taskName, step: stepName, op: opKind });
|
|
128892
128875
|
try {
|
|
128893
|
-
const
|
|
128894
|
-
workspace: this.workspace,
|
|
128895
|
-
env: env2,
|
|
128896
|
-
logger: this.logger,
|
|
128897
|
-
resolver: this.resolver,
|
|
128898
|
-
reporter: this.reporter,
|
|
128899
|
-
signal: this.signal,
|
|
128900
|
-
task: task2.config.name,
|
|
128901
|
-
step: entry.step
|
|
128902
|
-
};
|
|
128903
|
-
await this.opHandlers.execute(entry.op, context, state);
|
|
128876
|
+
const result = await execute(this.createExecutionContext(taskName, stepName, env2));
|
|
128904
128877
|
this.reporter?.emit("op_end", {
|
|
128905
|
-
task:
|
|
128906
|
-
step:
|
|
128907
|
-
op:
|
|
128878
|
+
task: taskName,
|
|
128879
|
+
step: stepName,
|
|
128880
|
+
op: opKind,
|
|
128908
128881
|
status: "success",
|
|
128909
128882
|
duration: (Date.now() - opStart) / 1000
|
|
128910
128883
|
});
|
|
128884
|
+
return result;
|
|
128911
128885
|
} catch (error2) {
|
|
128912
128886
|
this.reporter?.emit("op_end", {
|
|
128913
|
-
task:
|
|
128914
|
-
step:
|
|
128915
|
-
op:
|
|
128887
|
+
task: taskName,
|
|
128888
|
+
step: stepName,
|
|
128889
|
+
op: opKind,
|
|
128916
128890
|
status: "failed",
|
|
128917
128891
|
duration: (Date.now() - opStart) / 1000,
|
|
128918
128892
|
error: error2 instanceof Error ? error2.message : String(error2)
|