Skip to main content

@flowwright/plugin-artifacts

The smallest of the seven: two thin wrappers over the core artifact.upload primitive.

npm install --save-dev @flowwright/plugin-artifacts

API

ExportKindSignature
archiveArtifactsstep helper(paths: string | string[]) => Promise<void>
archiveStagestage builder(name, paths, opts?: ArchiveStageOptions) => StageDefinition
ArchiveStageOptionstypeOmit<StageOptions, "run" | "produces">

Example

pipeline.ts
import { pipeline, stage, sh } from "@flowwright/core";
import { archiveStage } from "@flowwright/plugin-artifacts";

export default pipeline({
name: "acme-api",
stages: [
stage("Build", {
id: "build",
run: async () => {
await sh(["npm", "run", "build"]);
},
}),
archiveStage("Archive", ["dist", "coverage/lcov.info"], {
id: "archive",
needs: ["build"],
}),
],
});

What it composes down to

archiveArtifacts(["dist", "coverage/lcov.info"]) loops artifact.upload(path), so the stage's produces becomes ["dist", "coverage/lcov.info"] in argument order.

archiveStage(name, paths, opts) is one line:

stage(name, { ...opts, run: () => archiveArtifacts(paths) });

The non-obvious part: produces is not set from the options — it's recorded by the artifact.upload() calls in the body. That's why ArchiveStageOptions omits it. The hand-written equivalent is either form:

// via the body — what the plugin does
stage("Archive", {
needs: ["build"],
run: async () => {
await artifact.upload("dist");
},
});

// or declaratively, no plugin needed
stage("Archive", { needs: ["build"], produces: ["dist"], run: async () => {} });

Both end up in the same de-duplicated list.

Gotchas

Worth asking whether you need this at all. produces: ["dist"] on the stage that already builds dist says the same thing without a separate stage or a dependency. A dedicated archive stage earns its place when the outputs come from several stages and you want one place that names them.

Local flow run collects nothing. Declaring artifacts records the declaration and shows it in flow explain; the files stay where the build left them. Collection is a server-side feature. See Artifacts, cache and stash.