@effected/engine 0.13.0 → 0.14.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/build/ActionInit.js +461 -0
- package/build/ActionRun.js +74 -0
- package/build/ActionRunResult.js +22 -0
- package/build/BuildRun.js +162 -0
- package/build/BuildRunResult.js +26 -0
- package/build.d.ts +446 -0
- package/build.js +8 -0
- package/package.json +11 -3
- package/schema/Runner.js +1 -1
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { NotAPackageError } from "./BuildRun.js";
|
|
2
|
+
import { ErrorText, PathContainment } from "@effected/kit";
|
|
3
|
+
import { Effect, FileSystem, Path, Predicate, Result, Schema } from "effect";
|
|
4
|
+
import { AtomicFile } from "@effected/files";
|
|
5
|
+
|
|
6
|
+
// src/build/ActionInit.ts
|
|
7
|
+
/**
|
|
8
|
+
* One file of a scaffold: where it goes, relative to the action's directory, and its whole content.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
var ActionScaffoldFile = class extends Schema.Class("ActionScaffoldFile")({
|
|
13
|
+
/** The path, relative to the action's directory, with `/` separators. */
|
|
14
|
+
path: Schema.String,
|
|
15
|
+
/** The complete content. */
|
|
16
|
+
contents: Schema.String
|
|
17
|
+
}) {};
|
|
18
|
+
/**
|
|
19
|
+
* Everything a new action needs that `action init` writes, as data: the files, and the packages its source imports.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
var ActionScaffold = class extends Schema.Class("ActionScaffold")({
|
|
24
|
+
/** The files, in the order they are written. */
|
|
25
|
+
files: Schema.Array(ActionScaffoldFile),
|
|
26
|
+
/** The runtime packages the scaffold's source imports, closed over their required peers. */
|
|
27
|
+
dependencies: Schema.Array(Schema.String),
|
|
28
|
+
/** The packages the scaffold's tooling needs: the `effected` command and the tsconfig preset it extends. */
|
|
29
|
+
devDependencies: Schema.Array(Schema.String)
|
|
30
|
+
}) {};
|
|
31
|
+
/**
|
|
32
|
+
* What one `action init` did.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
var ActionInitResult = class extends Schema.Class("ActionInitResult")({
|
|
37
|
+
/** The action's directory. */
|
|
38
|
+
cwd: Schema.String,
|
|
39
|
+
/** Every file written, relative to `cwd`, in the order written. */
|
|
40
|
+
written: Schema.Array(Schema.String),
|
|
41
|
+
/** The files among `written` that existed and were replaced, which only `force` allows. */
|
|
42
|
+
overwritten: Schema.Array(Schema.String),
|
|
43
|
+
/** Runtime packages the scaffold imports that `package.json` does not declare yet. */
|
|
44
|
+
missingDependencies: Schema.Array(Schema.String),
|
|
45
|
+
/** Tooling packages the scaffold needs that `package.json` does not declare yet. */
|
|
46
|
+
missingDevDependencies: Schema.Array(Schema.String),
|
|
47
|
+
/** Whether `package.json` sets `"type": "module"`, which the entry's top-level `await` needs. */
|
|
48
|
+
typeModule: Schema.Boolean
|
|
49
|
+
}) {};
|
|
50
|
+
/**
|
|
51
|
+
* The files a scaffold would write already exist, and overwriting was not asked for. Nothing was written.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
var ScaffoldExistsError = class extends Schema.TaggedError()("ScaffoldExistsError", {
|
|
56
|
+
/** The action's directory. */
|
|
57
|
+
cwd: Schema.String,
|
|
58
|
+
/** The existing files, relative to `cwd`. */
|
|
59
|
+
files: Schema.Array(Schema.String)
|
|
60
|
+
}) {
|
|
61
|
+
get message() {
|
|
62
|
+
return `${this.cwd} already has ${this.files.join(", ")}: nothing was written, and overwriting needs force`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* One path a scaffold cannot be written over, whatever `force` says.
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
var ScaffoldConflict = class extends Schema.Class("ScaffoldConflict")({
|
|
71
|
+
/** The path, relative to the action's directory. */
|
|
72
|
+
path: Schema.String,
|
|
73
|
+
/**
|
|
74
|
+
* What is there: `symlink` a symbolic link, which is never followed or replaced; `not-a-file` a directory or other
|
|
75
|
+
* non-file where a file goes; `not-a-directory` a file where a directory goes; `unreadable` an entry that could not
|
|
76
|
+
* be inspected; `unwritable` an existing file or directory this process may not write (`.` is the action's directory
|
|
77
|
+
* itself); `escapes` a path that resolves outside the
|
|
78
|
+
* action's directory; `case-variant` an entry whose name differs from the scaffold's only in case.
|
|
79
|
+
*/
|
|
80
|
+
kind: Schema.Literals([
|
|
81
|
+
"symlink",
|
|
82
|
+
"not-a-file",
|
|
83
|
+
"not-a-directory",
|
|
84
|
+
"unreadable",
|
|
85
|
+
"unwritable",
|
|
86
|
+
"escapes",
|
|
87
|
+
"case-variant"
|
|
88
|
+
])
|
|
89
|
+
}) {};
|
|
90
|
+
/**
|
|
91
|
+
* Paths the scaffold would write cannot be written over: a symbolic link, the wrong kind of entry, an entry that could
|
|
92
|
+
* not be inspected, or a path resolving outside the action's directory. Nothing was written, and `force` does not
|
|
93
|
+
* change it.
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
var ScaffoldConflictError = class extends Schema.TaggedError()("ScaffoldConflictError", {
|
|
98
|
+
/** The action's directory. */
|
|
99
|
+
cwd: Schema.String,
|
|
100
|
+
/** Each conflicting path and what is there. */
|
|
101
|
+
conflicts: Schema.Array(ScaffoldConflict)
|
|
102
|
+
}) {
|
|
103
|
+
get message() {
|
|
104
|
+
const listed = this.conflicts.map((conflict) => `${conflict.path} (${conflict.kind})`).join(", ");
|
|
105
|
+
return `${this.cwd} cannot take the scaffold over ${listed}: nothing was written`;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* A scaffold file or directory could not be written after every check passed. The files before it were written.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
var ScaffoldWriteError = class extends Schema.TaggedError()("ScaffoldWriteError", {
|
|
114
|
+
/** The action's directory. */
|
|
115
|
+
cwd: Schema.String,
|
|
116
|
+
/** The path that could not be written, relative to `cwd`. */
|
|
117
|
+
path: Schema.String,
|
|
118
|
+
/** The files written before it, relative to `cwd`, in order. */
|
|
119
|
+
written: Schema.Array(Schema.String),
|
|
120
|
+
/** The underlying filesystem failure, preserved structurally. */
|
|
121
|
+
cause: Schema.Defect()
|
|
122
|
+
}) {
|
|
123
|
+
get message() {
|
|
124
|
+
const before = this.written.length > 0 ? this.written.join(", ") : "nothing";
|
|
125
|
+
const cause = ErrorText.causeMessage(this.cause);
|
|
126
|
+
return `Could not write ${this.path} in ${this.cwd}: ${cause}; already written: ${before}`;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The action's name or description was neither given nor found in `package.json`, or was blank.
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
var ActionMetadataMissingError = class extends Schema.TaggedError()("ActionMetadataMissingError", {
|
|
135
|
+
/** Which `action.yml` field had no value. */
|
|
136
|
+
field: Schema.Literals(["name", "description"]) }) {
|
|
137
|
+
get message() {
|
|
138
|
+
return `The action needs a ${this.field}: pass one, or set "${this.field}" in package.json`;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* The action's name or description holds a control character or a lone surrogate, which `action.yml` cannot carry.
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
var ActionMetadataInvalidError = class extends Schema.TaggedError()("ActionMetadataInvalidError", {
|
|
147
|
+
/** Which `action.yml` field it was. */
|
|
148
|
+
field: Schema.Literals(["name", "description"]),
|
|
149
|
+
/** The first offending character or lone surrogate, as `U+XXXX`. */
|
|
150
|
+
character: Schema.String
|
|
151
|
+
}) {
|
|
152
|
+
get message() {
|
|
153
|
+
return `The action's ${this.field} holds ${this.character}, a control character or lone surrogate: write it on one line, as printable text`;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const DEPENDENCIES = [
|
|
157
|
+
"@effected/github-actions",
|
|
158
|
+
"effect",
|
|
159
|
+
"@effect/platform-node"
|
|
160
|
+
];
|
|
161
|
+
const DEV_DEPENDENCIES = [
|
|
162
|
+
"@effected/plugin",
|
|
163
|
+
"typescript",
|
|
164
|
+
"@types/node"
|
|
165
|
+
];
|
|
166
|
+
const isControl = (code) => code < 32 && code !== 9 || code >= 127 && code <= 159;
|
|
167
|
+
const codePoint = (character) => `U+${(character.codePointAt(0) ?? 0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
168
|
+
const yamlString = (value) => JSON.stringify(value).replace(/[\u007F-\u009F\u2028\u2029]/g, (character) => `\\u${codePoint(character).slice(2)}`);
|
|
169
|
+
const effectedToml = `# \`effected action build\` reads the [action] tables. A key left out takes its default.
|
|
170
|
+
|
|
171
|
+
[action.entries]
|
|
172
|
+
main = "src/main.ts"
|
|
173
|
+
|
|
174
|
+
# Copies each build to .github/actions/local, the target act and CI smoke-test.
|
|
175
|
+
[action.persistLocal]
|
|
176
|
+
enabled = true
|
|
177
|
+
path = ".github/actions/local"
|
|
178
|
+
`;
|
|
179
|
+
const actionYml = (input) => `# The single source of the action's input and output names and their defaults: code mirrors them.
|
|
180
|
+
name: ${yamlString(input.name)}
|
|
181
|
+
description: ${yamlString(input.description)}
|
|
182
|
+
branding:
|
|
183
|
+
icon: package
|
|
184
|
+
color: blue
|
|
185
|
+
runs:
|
|
186
|
+
using: node24
|
|
187
|
+
main: dist/main.js
|
|
188
|
+
`;
|
|
189
|
+
const mainTs = `// The main entry: the program and the guard, nothing else. The guard keeps the program importable by tests, and the
|
|
190
|
+
// build's load check imports this bundle with GITHUB_ACTIONS unset, so it loads without running.
|
|
191
|
+
import { Action } from "@effected/github-actions";
|
|
192
|
+
import { program } from "./program.js";
|
|
193
|
+
|
|
194
|
+
if (process.env.GITHUB_ACTIONS) {
|
|
195
|
+
await Action.run(program);
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
const programTs = `// The program: read the inputs, run the steps in order, fold their results into the outputs, and report. Composition
|
|
199
|
+
// only: when it has steps, their bodies live in src/steps/, and every human-readable string in src/format.ts.
|
|
200
|
+
import { Effect } from "effect";
|
|
201
|
+
|
|
202
|
+
export const program = Effect.logInfo("The action ran.");
|
|
203
|
+
`;
|
|
204
|
+
const tsconfigJson = `{
|
|
205
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
206
|
+
"extends": "@effected/plugin/tsconfig/ecma.json"
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
const blank = (value) => value === void 0 || value.trim() === "";
|
|
210
|
+
const checked = (field, value) => {
|
|
211
|
+
const found = [...value].find((character) => isControl(character.codePointAt(0) ?? 0) || !character.isWellFormed());
|
|
212
|
+
return found === void 0 ? Effect.succeed(value.trim()) : Effect.fail(new ActionMetadataInvalidError({
|
|
213
|
+
field,
|
|
214
|
+
character: codePoint(found)
|
|
215
|
+
}));
|
|
216
|
+
};
|
|
217
|
+
const stringField = (value, key) => {
|
|
218
|
+
const field = value[key];
|
|
219
|
+
return Predicate.isString(field) ? field : void 0;
|
|
220
|
+
};
|
|
221
|
+
const declaredIn = (value, key) => {
|
|
222
|
+
const field = value[key];
|
|
223
|
+
return Predicate.isObject(field) ? Object.keys(field) : [];
|
|
224
|
+
};
|
|
225
|
+
const readManifest = Effect.fnUntraced(function* (cwd) {
|
|
226
|
+
const fs = yield* FileSystem.FileSystem;
|
|
227
|
+
const path = yield* Path.Path;
|
|
228
|
+
const text = yield* fs.readFileString(path.join(cwd, "package.json")).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.fail(new NotAPackageError({
|
|
229
|
+
cwd,
|
|
230
|
+
reason: "it has no package.json"
|
|
231
|
+
}))));
|
|
232
|
+
const parsed = yield* Effect.try({
|
|
233
|
+
try: () => JSON.parse(text),
|
|
234
|
+
catch: () => new NotAPackageError({
|
|
235
|
+
cwd,
|
|
236
|
+
reason: "its package.json is not valid JSON"
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
if (!Predicate.isObject(parsed)) return yield* new NotAPackageError({
|
|
240
|
+
cwd,
|
|
241
|
+
reason: "its package.json is not an object"
|
|
242
|
+
});
|
|
243
|
+
const name = stringField(parsed, "name");
|
|
244
|
+
return {
|
|
245
|
+
name: name === void 0 ? void 0 : name.replace(/^@[^/]+\//, ""),
|
|
246
|
+
description: stringField(parsed, "description"),
|
|
247
|
+
declared: new Set(["dependencies", "devDependencies"].flatMap((key) => declaredIn(parsed, key))),
|
|
248
|
+
typeModule: stringField(parsed, "type") === "module"
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
252
|
+
* Scaffolds a new GitHub Action to the kit's canonical shape.
|
|
253
|
+
*
|
|
254
|
+
* @remarks
|
|
255
|
+
* {@link ActionInit.plan} is pure: it answers the files as data. {@link ActionInit.write} puts a plan on disk, and
|
|
256
|
+
* {@link ActionInit.run} is the front ends' one call, reading defaults from `package.json` first.
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
var ActionInit = class ActionInit {
|
|
261
|
+
constructor() {}
|
|
262
|
+
/**
|
|
263
|
+
* The scaffold for one action: the `[action]` tables of `effected.toml`, `action.yml`, the `main` entry, the program
|
|
264
|
+
* it runs, and a `tsconfig.json` extending the kit's preset.
|
|
265
|
+
*
|
|
266
|
+
* @remarks
|
|
267
|
+
* It has only a `main` phase and requires no token, so it builds and runs as it stands; `pre`, `post` and App
|
|
268
|
+
* authentication are added when the action needs them. The `action.yml` carries branding, because a missing one is a
|
|
269
|
+
* warning, and a warning fails a build under CI.
|
|
270
|
+
*/
|
|
271
|
+
static plan(input) {
|
|
272
|
+
return ActionScaffold.make({
|
|
273
|
+
files: [
|
|
274
|
+
ActionScaffoldFile.make({
|
|
275
|
+
path: "effected.toml",
|
|
276
|
+
contents: effectedToml
|
|
277
|
+
}),
|
|
278
|
+
ActionScaffoldFile.make({
|
|
279
|
+
path: "action.yml",
|
|
280
|
+
contents: actionYml(input)
|
|
281
|
+
}),
|
|
282
|
+
ActionScaffoldFile.make({
|
|
283
|
+
path: "src/main.ts",
|
|
284
|
+
contents: mainTs
|
|
285
|
+
}),
|
|
286
|
+
ActionScaffoldFile.make({
|
|
287
|
+
path: "src/program.ts",
|
|
288
|
+
contents: programTs
|
|
289
|
+
}),
|
|
290
|
+
ActionScaffoldFile.make({
|
|
291
|
+
path: "tsconfig.json",
|
|
292
|
+
contents: tsconfigJson
|
|
293
|
+
})
|
|
294
|
+
],
|
|
295
|
+
dependencies: DEPENDENCIES,
|
|
296
|
+
devDependencies: DEV_DEPENDENCIES
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Writes a scaffold under `cwd`.
|
|
301
|
+
*
|
|
302
|
+
* @remarks
|
|
303
|
+
* Every path is inspected with `lstat` before anything is written, so a refusal writes nothing:
|
|
304
|
+
*
|
|
305
|
+
* - A symbolic link at a file or at a directory the scaffold writes into is a {@link ScaffoldConflictError}, with or
|
|
306
|
+
* without `force`. A link is never followed and never replaced, so no write can leave `cwd` through one.
|
|
307
|
+
* - So is a directory or other non-file where a file goes, a file where a directory goes, an entry that cannot be
|
|
308
|
+
* inspected, and an existing file that cannot be written.
|
|
309
|
+
* - An existing regular file is a {@link ScaffoldExistsError} unless `force`, which replaces it.
|
|
310
|
+
*
|
|
311
|
+
* A name that differs from the scaffold's only in case (`Action.yml`) is a conflict too, and so is an existing directory,
|
|
312
|
+
* the action's own included, that this process may not write into.
|
|
313
|
+
*
|
|
314
|
+
* Then every directory is created and the files are written, each atomically and with a link at its path replaced
|
|
315
|
+
* rather than followed. Just before each write, the directories on its path are inspected again and the target is
|
|
316
|
+
* confirmed to resolve inside `cwd`. That is a point-in-time check: no committed link survives the pass above, but a
|
|
317
|
+
* concurrent local writer could still swap a directory for a link between the check and the write. Past the first
|
|
318
|
+
* check, a failure is {@link ScaffoldWriteError}, naming the path and the files already written.
|
|
319
|
+
*
|
|
320
|
+
* @returns The files written and the ones among them that were replaced.
|
|
321
|
+
*/
|
|
322
|
+
static write = Effect.fn("ActionInit.write")(function* (scaffold, options) {
|
|
323
|
+
const fs = yield* FileSystem.FileSystem;
|
|
324
|
+
const path = yield* Path.Path;
|
|
325
|
+
const root = yield* fs.realPath(path.resolve(options.cwd));
|
|
326
|
+
const at = (relative) => path.join(root, ...relative.split("/"));
|
|
327
|
+
const conflicts = [];
|
|
328
|
+
const conflict = (relative, kind) => conflicts.push(ScaffoldConflict.make({
|
|
329
|
+
path: relative,
|
|
330
|
+
kind
|
|
331
|
+
}));
|
|
332
|
+
/** The entry's type, `undefined` when nothing is there, or `null` when it could not be inspected. */
|
|
333
|
+
const probe = (relative) => Effect.map(Effect.result(fs.lstat(at(relative))), (info) => Result.isSuccess(info) ? info.success.type : info.failure.reason._tag === "NotFound" ? void 0 : null);
|
|
334
|
+
const directories = [...new Set(scaffold.files.flatMap((file) => {
|
|
335
|
+
const segments = file.path.split("/").slice(0, -1);
|
|
336
|
+
return segments.map((_, index) => segments.slice(0, index + 1).join("/"));
|
|
337
|
+
}))].sort((a, b) => a.split("/").length - b.split("/").length);
|
|
338
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
339
|
+
const create = [];
|
|
340
|
+
const under = (paths, relative) => [...paths].some((parent) => relative.startsWith(`${parent}/`));
|
|
341
|
+
const parentOf = (relative) => relative.split("/").slice(0, -1).join("/");
|
|
342
|
+
const basename = (relative) => relative.split("/").at(-1) ?? relative;
|
|
343
|
+
const listings = /* @__PURE__ */ new Map();
|
|
344
|
+
const listing = (relative) => Effect.gen(function* () {
|
|
345
|
+
const cached = listings.get(relative);
|
|
346
|
+
if (cached !== void 0) return cached;
|
|
347
|
+
const read = yield* Effect.result(fs.readDirectory(relative === "" ? root : at(relative)));
|
|
348
|
+
const names = Result.isSuccess(read) ? read.success : null;
|
|
349
|
+
listings.set(relative, names);
|
|
350
|
+
return names;
|
|
351
|
+
});
|
|
352
|
+
const caseVariant = (relative) => Effect.map(listing(parentOf(relative)), (names) => {
|
|
353
|
+
const name = basename(relative);
|
|
354
|
+
return names !== null && !names.includes(name) && names.some((entry) => entry.toLowerCase() === name.toLowerCase());
|
|
355
|
+
});
|
|
356
|
+
const writable = (relative) => Effect.map(Effect.result(fs.access(relative === "" ? root : at(relative), { writable: true })), Result.isSuccess);
|
|
357
|
+
if (!(yield* writable(""))) conflict(".", "unwritable");
|
|
358
|
+
for (const directory of directories) {
|
|
359
|
+
if (under(blocked, directory)) continue;
|
|
360
|
+
if (under(create, directory)) {
|
|
361
|
+
create.push(directory);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (yield* caseVariant(directory)) {
|
|
365
|
+
blocked.add(directory);
|
|
366
|
+
conflict(directory, "case-variant");
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
const type = yield* probe(directory);
|
|
370
|
+
if (type === void 0) create.push(directory);
|
|
371
|
+
else if (type !== "Directory") {
|
|
372
|
+
blocked.add(directory);
|
|
373
|
+
conflict(directory, type === null ? "unreadable" : type === "SymbolicLink" ? "symlink" : "not-a-directory");
|
|
374
|
+
} else if (!(yield* writable(directory))) {
|
|
375
|
+
blocked.add(directory);
|
|
376
|
+
conflict(directory, "unwritable");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const existing = [];
|
|
380
|
+
for (const file of scaffold.files) {
|
|
381
|
+
if (under(blocked, file.path) || under(create, file.path)) continue;
|
|
382
|
+
if (yield* caseVariant(file.path)) {
|
|
383
|
+
conflict(file.path, "case-variant");
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const type = yield* probe(file.path);
|
|
387
|
+
if (type === void 0) continue;
|
|
388
|
+
if (type === "File") {
|
|
389
|
+
const replaceable = yield* Effect.result(fs.access(at(file.path), { writable: true }));
|
|
390
|
+
if (Result.isSuccess(replaceable)) existing.push(file.path);
|
|
391
|
+
else conflict(file.path, "unwritable");
|
|
392
|
+
} else conflict(file.path, type === null ? "unreadable" : type === "SymbolicLink" ? "symlink" : "not-a-file");
|
|
393
|
+
}
|
|
394
|
+
if (conflicts.length > 0) return yield* new ScaffoldConflictError({
|
|
395
|
+
cwd: root,
|
|
396
|
+
conflicts
|
|
397
|
+
});
|
|
398
|
+
if (existing.length > 0 && !options.force) return yield* new ScaffoldExistsError({
|
|
399
|
+
cwd: root,
|
|
400
|
+
files: existing
|
|
401
|
+
});
|
|
402
|
+
const written = [];
|
|
403
|
+
const failed = (relative) => (cause) => new ScaffoldWriteError({
|
|
404
|
+
cwd: root,
|
|
405
|
+
path: relative,
|
|
406
|
+
written: [...written],
|
|
407
|
+
cause
|
|
408
|
+
});
|
|
409
|
+
for (const directory of create) yield* fs.makeDirectory(at(directory)).pipe(Effect.mapError(failed(directory)));
|
|
410
|
+
const confined = (relative) => Effect.gen(function* () {
|
|
411
|
+
const segments = relative.split("/").slice(0, -1);
|
|
412
|
+
for (let index = 1; index <= segments.length; index++) if ((yield* probe(segments.slice(0, index).join("/"))) !== "Directory") return false;
|
|
413
|
+
return yield* PathContainment.isWithin(root, at(relative));
|
|
414
|
+
});
|
|
415
|
+
for (const file of scaffold.files) {
|
|
416
|
+
if (!(yield* confined(file.path))) return yield* failed(file.path)(/* @__PURE__ */ new Error(`${file.path} no longer resolves inside ${root}: a directory on its path changed after the checks`));
|
|
417
|
+
yield* AtomicFile.write(at(file.path), file.contents, { links: "replace" }).pipe(Effect.mapError(failed(file.path)));
|
|
418
|
+
written.push(file.path);
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
written,
|
|
422
|
+
overwritten: existing
|
|
423
|
+
};
|
|
424
|
+
});
|
|
425
|
+
/**
|
|
426
|
+
* Scaffolds the action in `deps.cwd`: reads `package.json` for the name and description not given, plans, and
|
|
427
|
+
* writes.
|
|
428
|
+
*
|
|
429
|
+
* @remarks
|
|
430
|
+
* The error channel holds a run that could not start or finish: a directory with no readable `package.json`, a name or
|
|
431
|
+
* description found nowhere or holding a control character, files that exist without `force`, a path that cannot be
|
|
432
|
+
* written over ({@link ScaffoldConflictError}), and a write that failed. It edits no `package.json`: the result names
|
|
433
|
+
* the packages to add.
|
|
434
|
+
*/
|
|
435
|
+
static run = Effect.fn("ActionInit.run")(function* (input, deps) {
|
|
436
|
+
const cwd = (yield* Path.Path).resolve(deps.cwd);
|
|
437
|
+
const manifest = yield* readManifest(cwd);
|
|
438
|
+
const name = blank(input.name) ? manifest.name : input.name;
|
|
439
|
+
if (blank(name)) return yield* new ActionMetadataMissingError({ field: "name" });
|
|
440
|
+
const description = blank(input.description) ? manifest.description : input.description;
|
|
441
|
+
if (blank(description)) return yield* new ActionMetadataMissingError({ field: "description" });
|
|
442
|
+
const scaffold = ActionInit.plan({
|
|
443
|
+
name: yield* checked("name", name ?? ""),
|
|
444
|
+
description: yield* checked("description", description ?? "")
|
|
445
|
+
});
|
|
446
|
+
const { written, overwritten } = yield* ActionInit.write(scaffold, {
|
|
447
|
+
cwd,
|
|
448
|
+
force: input.force
|
|
449
|
+
});
|
|
450
|
+
return ActionInitResult.make({
|
|
451
|
+
cwd,
|
|
452
|
+
written,
|
|
453
|
+
overwritten,
|
|
454
|
+
missingDependencies: scaffold.dependencies.filter((dependency) => !manifest.declared.has(dependency)),
|
|
455
|
+
missingDevDependencies: scaffold.devDependencies.filter((dependency) => !manifest.declared.has(dependency)),
|
|
456
|
+
typeModule: manifest.typeModule
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
export { ActionInit, ActionInitResult, ActionMetadataInvalidError, ActionMetadataMissingError, ActionScaffold, ActionScaffoldFile, ScaffoldConflict, ScaffoldConflictError, ScaffoldExistsError, ScaffoldWriteError };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ActionRunResult } from "./ActionRunResult.js";
|
|
2
|
+
import { readPackageName, workspaceRootOf } from "./BuildRun.js";
|
|
3
|
+
import { Effect, Layer, Path, Schema } from "effect";
|
|
4
|
+
import { ActionBuildResult, ActionBuilder, BuildResult, EffectedConfigFile } from "@effected/bundler";
|
|
5
|
+
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
6
|
+
|
|
7
|
+
// src/build/ActionRun.ts
|
|
8
|
+
/**
|
|
9
|
+
* The directory asked to build as an action has no `[action]` table in its config, so it is a library.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
var NotAnActionError = class extends Schema.TaggedError()("NotAnActionError", {
|
|
14
|
+
/** The directory. */
|
|
15
|
+
cwd: Schema.String }) {
|
|
16
|
+
get message() {
|
|
17
|
+
return `${this.cwd} is not an action: its effected.toml has no [action] table`;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** The partial result a builder failure stops with. No bundling happened when `build` is absent. */
|
|
21
|
+
const failedResult = (error) => ActionRunResult.make({
|
|
22
|
+
verdict: "failed",
|
|
23
|
+
result: ActionBuildResult.make({
|
|
24
|
+
validation: error.validation,
|
|
25
|
+
build: error.build ?? BuildResult.make({
|
|
26
|
+
success: false,
|
|
27
|
+
entries: [],
|
|
28
|
+
duration: 0
|
|
29
|
+
}),
|
|
30
|
+
persisted: false
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Runs one GitHub Action build.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Validation stopping the build and an entry failing to bundle or load are a `failed` verdict rather than a failure,
|
|
38
|
+
* with what happened so far in the result, so a front end can always render it. The error channel holds a run that could
|
|
39
|
+
* not start or finish: no `package.json`, a config that will not load, no `[action]` table, an entry that is missing
|
|
40
|
+
* with validation off, and a file that cannot be cleaned, written or persisted.
|
|
41
|
+
*
|
|
42
|
+
* It appends to no journal: the build and issue journals record package builds only.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
var ActionRun = class {
|
|
47
|
+
constructor() {}
|
|
48
|
+
static run = Effect.fn("ActionRun.run")(function* (input, deps) {
|
|
49
|
+
const cwd = (yield* Path.Path).resolve(deps.cwd);
|
|
50
|
+
yield* readPackageName(cwd);
|
|
51
|
+
const discovery = WorkspaceDiscovery.layer({ cwd }).pipe(Layer.provide(WorkspaceRoot.layer));
|
|
52
|
+
const root = yield* workspaceRootOf(cwd).pipe(Effect.provide(discovery));
|
|
53
|
+
const { config } = yield* EffectedConfigFile.load({
|
|
54
|
+
cwd,
|
|
55
|
+
root
|
|
56
|
+
}).pipe(Effect.provide(discovery));
|
|
57
|
+
if (config.action === void 0) return yield* new NotAnActionError({ cwd });
|
|
58
|
+
return yield* ActionBuilder.build({
|
|
59
|
+
cwd,
|
|
60
|
+
config: config.action,
|
|
61
|
+
validate: input.validate,
|
|
62
|
+
persist: input.persist,
|
|
63
|
+
ci: deps.ci
|
|
64
|
+
}).pipe(Effect.map((result) => ActionRunResult.make({
|
|
65
|
+
verdict: "ok",
|
|
66
|
+
result
|
|
67
|
+
})), Effect.catchTags({
|
|
68
|
+
ValidationFailed: (error) => Effect.succeed(failedResult(error)),
|
|
69
|
+
BuildFailed: (error) => Effect.succeed(failedResult(error))
|
|
70
|
+
}));
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { ActionRun, NotAnActionError };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { ActionBuildResult } from "@effected/bundler";
|
|
3
|
+
|
|
4
|
+
// src/build/ActionRunResult.ts
|
|
5
|
+
/**
|
|
6
|
+
* One action build's answer: the verdict a front end maps to an exit code or returns as data, and what the build did.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
var ActionRunResult = class extends Schema.Class("ActionRunResult")({
|
|
11
|
+
/** `failed` when validation stopped the build or an entry failed to bundle or load. */
|
|
12
|
+
verdict: Schema.Literals(["ok", "failed"]),
|
|
13
|
+
/**
|
|
14
|
+
* What validation found, how bundling went and whether the build was persisted.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* When validation stops the build before bundling, `build` has no entries and `success: false`.
|
|
18
|
+
*/
|
|
19
|
+
result: ActionBuildResult
|
|
20
|
+
}) {};
|
|
21
|
+
|
|
22
|
+
export { ActionRunResult };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { BuildRunResult } from "./BuildRunResult.js";
|
|
2
|
+
import { DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Predicate, Schema } from "effect";
|
|
3
|
+
import { BuildIssuesSchema, BuildJournal, Bundler, EffectedConfigError, EffectedConfigFile, IssueJournal, flattenIssues, loadPlugins } from "@effected/bundler";
|
|
4
|
+
import { NodeJournalWatcher } from "@effected/jsonl/node";
|
|
5
|
+
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
6
|
+
|
|
7
|
+
// src/build/BuildRun.ts
|
|
8
|
+
/**
|
|
9
|
+
* The directory asked to build has no readable `package.json`.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
var NotAPackageError = class extends Schema.TaggedError()("NotAPackageError", {
|
|
14
|
+
/** The directory. */
|
|
15
|
+
cwd: Schema.String,
|
|
16
|
+
/** What is wrong with its `package.json`. */
|
|
17
|
+
reason: Schema.String
|
|
18
|
+
}) {
|
|
19
|
+
get message() {
|
|
20
|
+
return `${this.cwd} is not a package: ${this.reason}`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/** The name in the directory's `package.json`, or why it is not a package. */
|
|
24
|
+
const readPackageName = Effect.fnUntraced(function* (cwd) {
|
|
25
|
+
const fs = yield* FileSystem.FileSystem;
|
|
26
|
+
const pathService = yield* Path.Path;
|
|
27
|
+
const text = yield* fs.readFileString(pathService.join(cwd, "package.json")).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.fail(new NotAPackageError({
|
|
28
|
+
cwd,
|
|
29
|
+
reason: "it has no package.json"
|
|
30
|
+
}))));
|
|
31
|
+
const manifest = yield* Effect.try({
|
|
32
|
+
try: () => JSON.parse(text),
|
|
33
|
+
catch: () => new NotAPackageError({
|
|
34
|
+
cwd,
|
|
35
|
+
reason: "its package.json is not valid JSON"
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
return Predicate.hasProperty(manifest, "name") && Predicate.isString(manifest.name) ? manifest.name : "unknown";
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* The workspace root above `cwd`, which is `cwd` itself when there is none.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* Discovery wraps a failed read as a `WorkspaceDiscoveryError`. That is the disk's fault rather than the config's, so
|
|
45
|
+
* its `PlatformError` is unwrapped; a workspace file with the wrong content stays a config fault.
|
|
46
|
+
*/
|
|
47
|
+
const workspaceRootOf = (cwd) => WorkspaceDiscovery.use((discovery) => discovery.infoIn(cwd)).pipe(Effect.map((info) => info.root), Effect.catchTags({
|
|
48
|
+
WorkspaceRootNotFoundError: () => Effect.succeed(cwd),
|
|
49
|
+
WorkspaceDiscoveryError: (error) => Effect.fail(error.cause instanceof PlatformError.PlatformError ? error.cause : new EffectedConfigError({
|
|
50
|
+
path: error.path,
|
|
51
|
+
reason: error.message
|
|
52
|
+
})),
|
|
53
|
+
WorkspacePatternError: (error) => Effect.fail(new EffectedConfigError({
|
|
54
|
+
path: cwd,
|
|
55
|
+
reason: error.message
|
|
56
|
+
}))
|
|
57
|
+
}));
|
|
58
|
+
const decodeIssues = Schema.decodeUnknownEffect(Schema.fromJsonString(BuildIssuesSchema));
|
|
59
|
+
/**
|
|
60
|
+
* The build's `issues.json`, or the same document rebuilt from the report when it cannot stand for this build.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* The bundler swallows a failed artifact write, so the file on disk may be a previous build's. One stamped before this
|
|
64
|
+
* build started is therefore never read as its answer, and after a crash neither is a `buildOk: true`. A finished build
|
|
65
|
+
* with no artifact of its own has no gate a reader could trust, so that is a failure too.
|
|
66
|
+
*/
|
|
67
|
+
const readIssues = Effect.fnUntraced(function* (outcome, packageName, startedAt) {
|
|
68
|
+
const artifact = yield* (yield* FileSystem.FileSystem).readFileString(outcome.issuesPath).pipe(Effect.flatMap(decodeIssues), Effect.option);
|
|
69
|
+
if (Option.isSome(artifact) && Date.parse(artifact.value.generatedAt) >= startedAt && (Option.isNone(outcome.crash) || !artifact.value.buildOk)) return artifact.value;
|
|
70
|
+
return {
|
|
71
|
+
...flattenIssues([outcome.report], {
|
|
72
|
+
target: "prod",
|
|
73
|
+
generatedAt: DateTime.formatIso(yield* DateTime.now),
|
|
74
|
+
buildOk: false,
|
|
75
|
+
failure: Option.getOrElse(outcome.crash, () => ({
|
|
76
|
+
name: "BuildRunError",
|
|
77
|
+
message: `the build finished but ${outcome.issuesPath} ${Option.isSome(artifact) ? "is older than this build" : "could not be read"}`
|
|
78
|
+
}))
|
|
79
|
+
}),
|
|
80
|
+
package: packageName
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Runs one package build.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* A build that crashes or records an error is a `failed` verdict rather than a failure, so a front end can always
|
|
88
|
+
* show the report and the journals always get an envelope. The error channel holds a run that could not start or
|
|
89
|
+
* record: no `package.json`, a config or plugin that will not load, a config the bundler rejects before any build
|
|
90
|
+
* work, and a journal that cannot be written.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
var BuildRun = class {
|
|
95
|
+
constructor() {}
|
|
96
|
+
static run = Effect.fn("BuildRun.run")(function* (input, deps) {
|
|
97
|
+
const pathService = yield* Path.Path;
|
|
98
|
+
const cwd = pathService.resolve(deps.cwd);
|
|
99
|
+
const { onProgress } = deps;
|
|
100
|
+
const packageName = yield* readPackageName(cwd);
|
|
101
|
+
const discovery = WorkspaceDiscovery.layer({ cwd }).pipe(Layer.provide(WorkspaceRoot.layer));
|
|
102
|
+
const root = yield* workspaceRootOf(cwd).pipe(Effect.provide(discovery));
|
|
103
|
+
const resolved = yield* EffectedConfigFile.load({
|
|
104
|
+
cwd,
|
|
105
|
+
root
|
|
106
|
+
}).pipe(Effect.provide(discovery));
|
|
107
|
+
const { build, tsdoctor } = resolved.config.package;
|
|
108
|
+
const plugins = yield* loadPlugins({
|
|
109
|
+
cwd,
|
|
110
|
+
modules: build.plugins,
|
|
111
|
+
...deps.importModule !== void 0 ? { importModule: deps.importModule } : {}
|
|
112
|
+
});
|
|
113
|
+
yield* onProgress?.({
|
|
114
|
+
_tag: "Started",
|
|
115
|
+
package: packageName,
|
|
116
|
+
config: resolved
|
|
117
|
+
}) ?? Effect.void;
|
|
118
|
+
const startedAt = DateTime.toEpochMillis(yield* DateTime.now);
|
|
119
|
+
const outcome = yield* Bundler.build({
|
|
120
|
+
cwd,
|
|
121
|
+
config: build,
|
|
122
|
+
tsdoctor,
|
|
123
|
+
noExe: input.noExe,
|
|
124
|
+
verbose: input.verbose,
|
|
125
|
+
plugins,
|
|
126
|
+
ci: deps.ci,
|
|
127
|
+
...deps.seams !== void 0 ? { seams: deps.seams } : {}
|
|
128
|
+
}).pipe(Effect.map((result) => ({
|
|
129
|
+
report: result.report,
|
|
130
|
+
issuesPath: result.issuesPath,
|
|
131
|
+
crash: Option.none()
|
|
132
|
+
})), Effect.catchTag("BundlerError", (error) => Effect.succeed({
|
|
133
|
+
report: error.report,
|
|
134
|
+
issuesPath: pathService.join(cwd, "dist", "prod", "issues.json"),
|
|
135
|
+
crash: Option.some({
|
|
136
|
+
name: error.name,
|
|
137
|
+
message: error.message
|
|
138
|
+
})
|
|
139
|
+
})));
|
|
140
|
+
if (onProgress !== void 0) for (const group of outcome.report.targetGroups) for (const pass of group.passes) yield* onProgress({
|
|
141
|
+
_tag: "PassDone",
|
|
142
|
+
pass: pass.id,
|
|
143
|
+
group: group.id
|
|
144
|
+
});
|
|
145
|
+
const issues = yield* readIssues(outcome, packageName, startedAt);
|
|
146
|
+
const journals = Layer.mergeAll(BuildJournal.layerAt(root), IssueJournal.layerAt(root)).pipe(Layer.provide(deps.journalWatcher ?? NodeJournalWatcher.layer));
|
|
147
|
+
yield* BuildJournal.record(issues, cwd).pipe(Effect.provide(journals));
|
|
148
|
+
yield* onProgress?.({
|
|
149
|
+
_tag: "Done",
|
|
150
|
+
issues
|
|
151
|
+
}) ?? Effect.void;
|
|
152
|
+
return BuildRunResult.make({
|
|
153
|
+
package: packageName,
|
|
154
|
+
verdict: !issues.buildOk || issues.errors.length > 0 ? "failed" : "ok",
|
|
155
|
+
issues,
|
|
156
|
+
report: outcome.report,
|
|
157
|
+
config: { sources: resolved.sources }
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export { BuildRun, NotAPackageError, readPackageName, workspaceRootOf };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { BuildIssuesSchema, BuildReport, ResolvedEffectedConfig } from "@effected/bundler";
|
|
3
|
+
|
|
4
|
+
// src/build/BuildRunResult.ts
|
|
5
|
+
/**
|
|
6
|
+
* One build's answer: the verdict a front end maps to an exit code or returns as data, the `issues.json` it rests
|
|
7
|
+
* on, everything the build recorded, and the config files it read.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
var BuildRunResult = class extends Schema.Class("BuildRunResult")({
|
|
12
|
+
/** The package's name. */
|
|
13
|
+
package: Schema.String,
|
|
14
|
+
/** `failed` when the build did not reach its end or recorded an error. */
|
|
15
|
+
verdict: Schema.Literals(["ok", "failed"]),
|
|
16
|
+
/** The build's `issues.json`. */
|
|
17
|
+
issues: BuildIssuesSchema,
|
|
18
|
+
/** Everything the build recorded. */
|
|
19
|
+
report: BuildReport,
|
|
20
|
+
/** The config the build ran on. */
|
|
21
|
+
config: Schema.Struct({
|
|
22
|
+
/** The file each tier read, absent for a tier that found none. */
|
|
23
|
+
sources: ResolvedEffectedConfig.fields.sources })
|
|
24
|
+
}) {};
|
|
25
|
+
|
|
26
|
+
export { BuildRunResult };
|
package/build.d.ts
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { ActionBuildResult, ActionBuildResult as ActionBuildResult$1, ActionValidation, ActionYmlPathError, BuildIssues, BuildIssues as BuildIssues$1, BuildReport, BuildReport as BuildReport$1, BuildResult, BundleFailed, BundleResult, BundlerSeams, CleanError, ConfigValidationError, EffectedConfigError, PassReport, PersistLocalError, PluginLoadError, ResolvedEffectedConfig, ValidationIssue, ValidationResult, WriteError, renderCiAnnotations } from "@effected/bundler";
|
|
2
|
+
import { Effect, FileSystem, Layer, Path, PlatformError, Schema } from "effect";
|
|
3
|
+
import { AppendError, JournalWatcher } from "@effected/jsonl";
|
|
4
|
+
import "@effected/workspaces";
|
|
5
|
+
declare const BuildRunResult_base: Schema.Class<BuildRunResult, Schema.Struct<{
|
|
6
|
+
/** The package's name. */
|
|
7
|
+
readonly package: Schema.String;
|
|
8
|
+
/** `failed` when the build did not reach its end or recorded an error. */
|
|
9
|
+
readonly verdict: Schema.Literals<readonly ["ok", "failed"]>;
|
|
10
|
+
/** The build's `issues.json`. */
|
|
11
|
+
readonly issues: Schema.Struct<{
|
|
12
|
+
readonly generatedAt: Schema.String;
|
|
13
|
+
readonly package: Schema.String;
|
|
14
|
+
readonly target: Schema.Literals<readonly ["dev", "prod"]>;
|
|
15
|
+
readonly buildOk: Schema.Boolean;
|
|
16
|
+
readonly failure: Schema.optionalKey<Schema.Struct<{
|
|
17
|
+
readonly name: Schema.optionalKey<Schema.String>;
|
|
18
|
+
readonly message: Schema.String;
|
|
19
|
+
}>>;
|
|
20
|
+
readonly warnings: Schema.$Array<Schema.Struct<{
|
|
21
|
+
readonly source: Schema.Literals<readonly ["tsdown", "rolldown", "api-extractor", "meta", "config"]>;
|
|
22
|
+
readonly level: Schema.Literals<readonly ["warn", "error"]>;
|
|
23
|
+
readonly text: Schema.String;
|
|
24
|
+
readonly code: Schema.optionalKey<Schema.String>;
|
|
25
|
+
readonly ciFatal: Schema.optionalKey<Schema.Boolean>;
|
|
26
|
+
readonly file: Schema.optionalKey<Schema.String>;
|
|
27
|
+
readonly line: Schema.optionalKey<Schema.Number>;
|
|
28
|
+
readonly column: Schema.optionalKey<Schema.Number>;
|
|
29
|
+
}>>;
|
|
30
|
+
readonly errors: Schema.$Array<Schema.Struct<{
|
|
31
|
+
readonly source: Schema.Literals<readonly ["tsdown", "rolldown", "api-extractor", "meta", "config"]>;
|
|
32
|
+
readonly level: Schema.Literals<readonly ["warn", "error"]>;
|
|
33
|
+
readonly text: Schema.String;
|
|
34
|
+
readonly code: Schema.optionalKey<Schema.String>;
|
|
35
|
+
readonly ciFatal: Schema.optionalKey<Schema.Boolean>;
|
|
36
|
+
readonly file: Schema.optionalKey<Schema.String>;
|
|
37
|
+
readonly line: Schema.optionalKey<Schema.Number>;
|
|
38
|
+
readonly column: Schema.optionalKey<Schema.Number>;
|
|
39
|
+
}>>;
|
|
40
|
+
readonly suppressed: Schema.$Array<Schema.Struct<{
|
|
41
|
+
readonly source: Schema.Literals<readonly ["tsdown", "rolldown", "api-extractor", "meta", "config"]>;
|
|
42
|
+
readonly level: Schema.Literals<readonly ["warn", "error"]>;
|
|
43
|
+
readonly text: Schema.String;
|
|
44
|
+
readonly code: Schema.optionalKey<Schema.String>;
|
|
45
|
+
readonly ciFatal: Schema.optionalKey<Schema.Boolean>;
|
|
46
|
+
readonly file: Schema.optionalKey<Schema.String>;
|
|
47
|
+
readonly line: Schema.optionalKey<Schema.Number>;
|
|
48
|
+
readonly column: Schema.optionalKey<Schema.Number>;
|
|
49
|
+
}>>;
|
|
50
|
+
}>;
|
|
51
|
+
/** Everything the build recorded. */
|
|
52
|
+
readonly report: typeof BuildReport$1;
|
|
53
|
+
/** The config the build ran on. */
|
|
54
|
+
readonly config: Schema.Struct<{
|
|
55
|
+
/** The file each tier read, absent for a tier that found none. */
|
|
56
|
+
readonly sources: Schema.Struct<{
|
|
57
|
+
readonly root: Schema.optionalKey<Schema.String>;
|
|
58
|
+
readonly package: Schema.optionalKey<Schema.String>;
|
|
59
|
+
}>;
|
|
60
|
+
}>;
|
|
61
|
+
}>, {}>;
|
|
62
|
+
/**
|
|
63
|
+
* One build's answer: the verdict a front end maps to an exit code or returns as data, the `issues.json` it rests
|
|
64
|
+
* on, everything the build recorded, and the config files it read.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare class BuildRunResult extends BuildRunResult_base {}
|
|
69
|
+
declare const NotAPackageError_base: Schema.Class<NotAPackageError, Schema.TaggedStruct<"NotAPackageError", {
|
|
70
|
+
/** The directory. */
|
|
71
|
+
readonly cwd: Schema.String;
|
|
72
|
+
/** What is wrong with its `package.json`. */
|
|
73
|
+
readonly reason: Schema.String;
|
|
74
|
+
}>, import("effect/Cause").YieldableError>;
|
|
75
|
+
/**
|
|
76
|
+
* The directory asked to build has no readable `package.json`.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare class NotAPackageError extends NotAPackageError_base {
|
|
81
|
+
get message(): string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What one build was asked to do, as the flags or tool parameters said it.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
interface BuildRunInput {
|
|
89
|
+
/** Skips the SEA compile. */
|
|
90
|
+
readonly noExe: boolean;
|
|
91
|
+
/** Measures gzip sizes for the report. */
|
|
92
|
+
readonly verbose: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Progress through one build.
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* `PassDone` is read from the report once the bundler returns, so a front end gets them together rather than as
|
|
99
|
+
* each pass ends. A crashed build reports the passes it recorded before the crash.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
type BuildProgress = {
|
|
104
|
+
readonly _tag: "Started";
|
|
105
|
+
readonly package: string;
|
|
106
|
+
readonly config: ResolvedEffectedConfig;
|
|
107
|
+
} | {
|
|
108
|
+
readonly _tag: "PassDone";
|
|
109
|
+
readonly pass: PassReport["id"];
|
|
110
|
+
readonly group: string;
|
|
111
|
+
} | {
|
|
112
|
+
readonly _tag: "Done";
|
|
113
|
+
readonly issues: BuildIssues$1;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* What the process boundary supplies, and the test seams.
|
|
117
|
+
*
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
interface BuildRunDeps {
|
|
121
|
+
/** The package directory; a relative path resolves against the process's. */
|
|
122
|
+
readonly cwd: string;
|
|
123
|
+
/** Whether this build runs under CI. */
|
|
124
|
+
readonly ci: boolean;
|
|
125
|
+
/** The plugin module importer; omitted, `loadPlugins`' `jiti` default. */
|
|
126
|
+
readonly importModule?: (path: string) => Promise<unknown>;
|
|
127
|
+
/** Replaces the bundler's side effects, for tests. */
|
|
128
|
+
readonly seams?: Partial<BundlerSeams>;
|
|
129
|
+
/** The journals' watcher; omitted, `NodeJournalWatcher.layer`. */
|
|
130
|
+
readonly journalWatcher?: Layer.Layer<JournalWatcher>;
|
|
131
|
+
/** Told when the build starts, of each pass and when it is done. */
|
|
132
|
+
readonly onProgress?: (event: BuildProgress) => Effect.Effect<void>;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Runs one package build.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* A build that crashes or records an error is a `failed` verdict rather than a failure, so a front end can always
|
|
139
|
+
* show the report and the journals always get an envelope. The error channel holds a run that could not start or
|
|
140
|
+
* record: no `package.json`, a config or plugin that will not load, a config the bundler rejects before any build
|
|
141
|
+
* work, and a journal that cannot be written.
|
|
142
|
+
*
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
export declare class BuildRun {
|
|
146
|
+
private constructor();
|
|
147
|
+
static readonly run: (input: BuildRunInput, deps: BuildRunDeps) => Effect.Effect<BuildRunResult, EffectedConfigError | PluginLoadError | NotAPackageError | ConfigValidationError | AppendError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
148
|
+
}
|
|
149
|
+
declare const ActionScaffoldFile_base: Schema.Class<ActionScaffoldFile, Schema.Struct<{
|
|
150
|
+
/** The path, relative to the action's directory, with `/` separators. */
|
|
151
|
+
readonly path: Schema.String;
|
|
152
|
+
/** The complete content. */
|
|
153
|
+
readonly contents: Schema.String;
|
|
154
|
+
}>, {}>;
|
|
155
|
+
/**
|
|
156
|
+
* One file of a scaffold: where it goes, relative to the action's directory, and its whole content.
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare class ActionScaffoldFile extends ActionScaffoldFile_base {}
|
|
161
|
+
declare const ActionScaffold_base: Schema.Class<ActionScaffold, Schema.Struct<{
|
|
162
|
+
/** The files, in the order they are written. */
|
|
163
|
+
readonly files: Schema.$Array<typeof ActionScaffoldFile>;
|
|
164
|
+
/** The runtime packages the scaffold's source imports, closed over their required peers. */
|
|
165
|
+
readonly dependencies: Schema.$Array<Schema.String>;
|
|
166
|
+
/** The packages the scaffold's tooling needs: the `effected` command and the tsconfig preset it extends. */
|
|
167
|
+
readonly devDependencies: Schema.$Array<Schema.String>;
|
|
168
|
+
}>, {}>;
|
|
169
|
+
/**
|
|
170
|
+
* Everything a new action needs that `action init` writes, as data: the files, and the packages its source imports.
|
|
171
|
+
*
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
export declare class ActionScaffold extends ActionScaffold_base {}
|
|
175
|
+
declare const ActionInitResult_base: Schema.Class<ActionInitResult, Schema.Struct<{
|
|
176
|
+
/** The action's directory. */
|
|
177
|
+
readonly cwd: Schema.String;
|
|
178
|
+
/** Every file written, relative to `cwd`, in the order written. */
|
|
179
|
+
readonly written: Schema.$Array<Schema.String>;
|
|
180
|
+
/** The files among `written` that existed and were replaced, which only `force` allows. */
|
|
181
|
+
readonly overwritten: Schema.$Array<Schema.String>;
|
|
182
|
+
/** Runtime packages the scaffold imports that `package.json` does not declare yet. */
|
|
183
|
+
readonly missingDependencies: Schema.$Array<Schema.String>;
|
|
184
|
+
/** Tooling packages the scaffold needs that `package.json` does not declare yet. */
|
|
185
|
+
readonly missingDevDependencies: Schema.$Array<Schema.String>;
|
|
186
|
+
/** Whether `package.json` sets `"type": "module"`, which the entry's top-level `await` needs. */
|
|
187
|
+
readonly typeModule: Schema.Boolean;
|
|
188
|
+
}>, {}>;
|
|
189
|
+
/**
|
|
190
|
+
* What one `action init` did.
|
|
191
|
+
*
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare class ActionInitResult extends ActionInitResult_base {}
|
|
195
|
+
declare const ScaffoldExistsError_base: Schema.Class<ScaffoldExistsError, Schema.TaggedStruct<"ScaffoldExistsError", {
|
|
196
|
+
/** The action's directory. */
|
|
197
|
+
readonly cwd: Schema.String;
|
|
198
|
+
/** The existing files, relative to `cwd`. */
|
|
199
|
+
readonly files: Schema.$Array<Schema.String>;
|
|
200
|
+
}>, import("effect/Cause").YieldableError>;
|
|
201
|
+
/**
|
|
202
|
+
* The files a scaffold would write already exist, and overwriting was not asked for. Nothing was written.
|
|
203
|
+
*
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
export declare class ScaffoldExistsError extends ScaffoldExistsError_base {
|
|
207
|
+
get message(): string;
|
|
208
|
+
}
|
|
209
|
+
declare const ScaffoldConflict_base: Schema.Class<ScaffoldConflict, Schema.Struct<{
|
|
210
|
+
/** The path, relative to the action's directory. */
|
|
211
|
+
readonly path: Schema.String;
|
|
212
|
+
/**
|
|
213
|
+
* What is there: `symlink` a symbolic link, which is never followed or replaced; `not-a-file` a directory or other
|
|
214
|
+
* non-file where a file goes; `not-a-directory` a file where a directory goes; `unreadable` an entry that could not
|
|
215
|
+
* be inspected; `unwritable` an existing file or directory this process may not write (`.` is the action's directory
|
|
216
|
+
* itself); `escapes` a path that resolves outside the
|
|
217
|
+
* action's directory; `case-variant` an entry whose name differs from the scaffold's only in case.
|
|
218
|
+
*/
|
|
219
|
+
readonly kind: Schema.Literals<readonly ["symlink", "not-a-file", "not-a-directory", "unreadable", "unwritable", "escapes", "case-variant"]>;
|
|
220
|
+
}>, {}>;
|
|
221
|
+
/**
|
|
222
|
+
* One path a scaffold cannot be written over, whatever `force` says.
|
|
223
|
+
*
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export declare class ScaffoldConflict extends ScaffoldConflict_base {}
|
|
227
|
+
declare const ScaffoldConflictError_base: Schema.Class<ScaffoldConflictError, Schema.TaggedStruct<"ScaffoldConflictError", {
|
|
228
|
+
/** The action's directory. */
|
|
229
|
+
readonly cwd: Schema.String;
|
|
230
|
+
/** Each conflicting path and what is there. */
|
|
231
|
+
readonly conflicts: Schema.$Array<typeof ScaffoldConflict>;
|
|
232
|
+
}>, import("effect/Cause").YieldableError>;
|
|
233
|
+
/**
|
|
234
|
+
* Paths the scaffold would write cannot be written over: a symbolic link, the wrong kind of entry, an entry that could
|
|
235
|
+
* not be inspected, or a path resolving outside the action's directory. Nothing was written, and `force` does not
|
|
236
|
+
* change it.
|
|
237
|
+
*
|
|
238
|
+
* @public
|
|
239
|
+
*/
|
|
240
|
+
export declare class ScaffoldConflictError extends ScaffoldConflictError_base {
|
|
241
|
+
get message(): string;
|
|
242
|
+
}
|
|
243
|
+
declare const ScaffoldWriteError_base: Schema.Class<ScaffoldWriteError, Schema.TaggedStruct<"ScaffoldWriteError", {
|
|
244
|
+
/** The action's directory. */
|
|
245
|
+
readonly cwd: Schema.String;
|
|
246
|
+
/** The path that could not be written, relative to `cwd`. */
|
|
247
|
+
readonly path: Schema.String;
|
|
248
|
+
/** The files written before it, relative to `cwd`, in order. */
|
|
249
|
+
readonly written: Schema.$Array<Schema.String>;
|
|
250
|
+
/** The underlying filesystem failure, preserved structurally. */
|
|
251
|
+
readonly cause: Schema.Defect;
|
|
252
|
+
}>, import("effect/Cause").YieldableError>;
|
|
253
|
+
/**
|
|
254
|
+
* A scaffold file or directory could not be written after every check passed. The files before it were written.
|
|
255
|
+
*
|
|
256
|
+
* @public
|
|
257
|
+
*/
|
|
258
|
+
export declare class ScaffoldWriteError extends ScaffoldWriteError_base {
|
|
259
|
+
get message(): string;
|
|
260
|
+
}
|
|
261
|
+
declare const ActionMetadataMissingError_base: Schema.Class<ActionMetadataMissingError, Schema.TaggedStruct<"ActionMetadataMissingError", {
|
|
262
|
+
/** Which `action.yml` field had no value. */
|
|
263
|
+
readonly field: Schema.Literals<readonly ["name", "description"]>;
|
|
264
|
+
}>, import("effect/Cause").YieldableError>;
|
|
265
|
+
/**
|
|
266
|
+
* The action's name or description was neither given nor found in `package.json`, or was blank.
|
|
267
|
+
*
|
|
268
|
+
* @public
|
|
269
|
+
*/
|
|
270
|
+
export declare class ActionMetadataMissingError extends ActionMetadataMissingError_base {
|
|
271
|
+
get message(): string;
|
|
272
|
+
}
|
|
273
|
+
declare const ActionMetadataInvalidError_base: Schema.Class<ActionMetadataInvalidError, Schema.TaggedStruct<"ActionMetadataInvalidError", {
|
|
274
|
+
/** Which `action.yml` field it was. */
|
|
275
|
+
readonly field: Schema.Literals<readonly ["name", "description"]>;
|
|
276
|
+
/** The first offending character or lone surrogate, as `U+XXXX`. */
|
|
277
|
+
readonly character: Schema.String;
|
|
278
|
+
}>, import("effect/Cause").YieldableError>;
|
|
279
|
+
/**
|
|
280
|
+
* The action's name or description holds a control character or a lone surrogate, which `action.yml` cannot carry.
|
|
281
|
+
*
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
export declare class ActionMetadataInvalidError extends ActionMetadataInvalidError_base {
|
|
285
|
+
get message(): string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* What the scaffold is built from: the two `action.yml` fields no default can supply.
|
|
289
|
+
*
|
|
290
|
+
* @public
|
|
291
|
+
*/
|
|
292
|
+
interface ActionScaffoldInput {
|
|
293
|
+
/** The action's display name. */
|
|
294
|
+
readonly name: string;
|
|
295
|
+
/** What the action does, one line. */
|
|
296
|
+
readonly description: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* What one `action init` was asked to do, as the flags or tool parameters said it. A name or description left out is
|
|
300
|
+
* read from `package.json`.
|
|
301
|
+
*
|
|
302
|
+
* @public
|
|
303
|
+
*/
|
|
304
|
+
interface ActionInitInput {
|
|
305
|
+
readonly name?: string;
|
|
306
|
+
readonly description?: string;
|
|
307
|
+
/** Replace files that already exist. */
|
|
308
|
+
readonly force: boolean;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* What the process boundary supplies for `action init`.
|
|
312
|
+
*
|
|
313
|
+
* @public
|
|
314
|
+
*/
|
|
315
|
+
interface ActionInitDeps {
|
|
316
|
+
/** The action's directory, which must hold a `package.json`. */
|
|
317
|
+
readonly cwd: string;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Scaffolds a new GitHub Action to the kit's canonical shape.
|
|
321
|
+
*
|
|
322
|
+
* @remarks
|
|
323
|
+
* {@link ActionInit.plan} is pure: it answers the files as data. {@link ActionInit.write} puts a plan on disk, and
|
|
324
|
+
* {@link ActionInit.run} is the front ends' one call, reading defaults from `package.json` first.
|
|
325
|
+
*
|
|
326
|
+
* @public
|
|
327
|
+
*/
|
|
328
|
+
export declare class ActionInit {
|
|
329
|
+
private constructor();
|
|
330
|
+
/**
|
|
331
|
+
* The scaffold for one action: the `[action]` tables of `effected.toml`, `action.yml`, the `main` entry, the program
|
|
332
|
+
* it runs, and a `tsconfig.json` extending the kit's preset.
|
|
333
|
+
*
|
|
334
|
+
* @remarks
|
|
335
|
+
* It has only a `main` phase and requires no token, so it builds and runs as it stands; `pre`, `post` and App
|
|
336
|
+
* authentication are added when the action needs them. The `action.yml` carries branding, because a missing one is a
|
|
337
|
+
* warning, and a warning fails a build under CI.
|
|
338
|
+
*/
|
|
339
|
+
static plan(input: ActionScaffoldInput): ActionScaffold;
|
|
340
|
+
/**
|
|
341
|
+
* Writes a scaffold under `cwd`.
|
|
342
|
+
*
|
|
343
|
+
* @remarks
|
|
344
|
+
* Every path is inspected with `lstat` before anything is written, so a refusal writes nothing:
|
|
345
|
+
*
|
|
346
|
+
* - A symbolic link at a file or at a directory the scaffold writes into is a {@link ScaffoldConflictError}, with or
|
|
347
|
+
* without `force`. A link is never followed and never replaced, so no write can leave `cwd` through one.
|
|
348
|
+
* - So is a directory or other non-file where a file goes, a file where a directory goes, an entry that cannot be
|
|
349
|
+
* inspected, and an existing file that cannot be written.
|
|
350
|
+
* - An existing regular file is a {@link ScaffoldExistsError} unless `force`, which replaces it.
|
|
351
|
+
*
|
|
352
|
+
* A name that differs from the scaffold's only in case (`Action.yml`) is a conflict too, and so is an existing directory,
|
|
353
|
+
* the action's own included, that this process may not write into.
|
|
354
|
+
*
|
|
355
|
+
* Then every directory is created and the files are written, each atomically and with a link at its path replaced
|
|
356
|
+
* rather than followed. Just before each write, the directories on its path are inspected again and the target is
|
|
357
|
+
* confirmed to resolve inside `cwd`. That is a point-in-time check: no committed link survives the pass above, but a
|
|
358
|
+
* concurrent local writer could still swap a directory for a link between the check and the write. Past the first
|
|
359
|
+
* check, a failure is {@link ScaffoldWriteError}, naming the path and the files already written.
|
|
360
|
+
*
|
|
361
|
+
* @returns The files written and the ones among them that were replaced.
|
|
362
|
+
*/
|
|
363
|
+
static readonly write: (scaffold: ActionScaffold, options: {
|
|
364
|
+
readonly cwd: string;
|
|
365
|
+
readonly force: boolean;
|
|
366
|
+
}) => Effect.Effect<{
|
|
367
|
+
readonly written: ReadonlyArray<string>;
|
|
368
|
+
readonly overwritten: ReadonlyArray<string>;
|
|
369
|
+
}, ScaffoldExistsError | ScaffoldConflictError | ScaffoldWriteError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
370
|
+
/**
|
|
371
|
+
* Scaffolds the action in `deps.cwd`: reads `package.json` for the name and description not given, plans, and
|
|
372
|
+
* writes.
|
|
373
|
+
*
|
|
374
|
+
* @remarks
|
|
375
|
+
* The error channel holds a run that could not start or finish: a directory with no readable `package.json`, a name or
|
|
376
|
+
* description found nowhere or holding a control character, files that exist without `force`, a path that cannot be
|
|
377
|
+
* written over ({@link ScaffoldConflictError}), and a write that failed. It edits no `package.json`: the result names
|
|
378
|
+
* the packages to add.
|
|
379
|
+
*/
|
|
380
|
+
static readonly run: (input: ActionInitInput, deps: ActionInitDeps) => Effect.Effect<ActionInitResult, NotAPackageError | ActionMetadataMissingError | ActionMetadataInvalidError | ScaffoldExistsError | ScaffoldConflictError | ScaffoldWriteError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
381
|
+
}
|
|
382
|
+
declare const ActionRunResult_base: Schema.Class<ActionRunResult, Schema.Struct<{
|
|
383
|
+
/** `failed` when validation stopped the build or an entry failed to bundle or load. */
|
|
384
|
+
readonly verdict: Schema.Literals<readonly ["ok", "failed"]>;
|
|
385
|
+
/**
|
|
386
|
+
* What validation found, how bundling went and whether the build was persisted.
|
|
387
|
+
*
|
|
388
|
+
* @remarks
|
|
389
|
+
* When validation stops the build before bundling, `build` has no entries and `success: false`.
|
|
390
|
+
*/
|
|
391
|
+
readonly result: typeof ActionBuildResult$1;
|
|
392
|
+
}>, {}>;
|
|
393
|
+
/**
|
|
394
|
+
* One action build's answer: the verdict a front end maps to an exit code or returns as data, and what the build did.
|
|
395
|
+
*
|
|
396
|
+
* @public
|
|
397
|
+
*/
|
|
398
|
+
export declare class ActionRunResult extends ActionRunResult_base {}
|
|
399
|
+
declare const NotAnActionError_base: Schema.Class<NotAnActionError, Schema.TaggedStruct<"NotAnActionError", {
|
|
400
|
+
/** The directory. */
|
|
401
|
+
readonly cwd: Schema.String;
|
|
402
|
+
}>, import("effect/Cause").YieldableError>;
|
|
403
|
+
/**
|
|
404
|
+
* The directory asked to build as an action has no `[action]` table in its config, so it is a library.
|
|
405
|
+
*
|
|
406
|
+
* @public
|
|
407
|
+
*/
|
|
408
|
+
export declare class NotAnActionError extends NotAnActionError_base {
|
|
409
|
+
get message(): string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* What one action build was asked to do, as the flags or tool parameters said it.
|
|
413
|
+
*
|
|
414
|
+
* @public
|
|
415
|
+
*/
|
|
416
|
+
interface ActionRunInput {
|
|
417
|
+
/** Whether to validate before bundling and check bundle sizes after it. */
|
|
418
|
+
readonly validate: boolean;
|
|
419
|
+
/** Whether to copy the build locally. `persistLocal.enabled = false` turns that off too. */
|
|
420
|
+
readonly persist: boolean;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* What the process boundary supplies for an action build: the parts of {@link BuildRunDeps} it uses.
|
|
424
|
+
*
|
|
425
|
+
* @public
|
|
426
|
+
*/
|
|
427
|
+
type ActionRunDeps = Pick<BuildRunDeps, "cwd" | "ci">;
|
|
428
|
+
/**
|
|
429
|
+
* Runs one GitHub Action build.
|
|
430
|
+
*
|
|
431
|
+
* @remarks
|
|
432
|
+
* Validation stopping the build and an entry failing to bundle or load are a `failed` verdict rather than a failure,
|
|
433
|
+
* with what happened so far in the result, so a front end can always render it. The error channel holds a run that could
|
|
434
|
+
* not start or finish: no `package.json`, a config that will not load, no `[action]` table, an entry that is missing
|
|
435
|
+
* with validation off, and a file that cannot be cleaned, written or persisted.
|
|
436
|
+
*
|
|
437
|
+
* It appends to no journal: the build and issue journals record package builds only.
|
|
438
|
+
*
|
|
439
|
+
* @public
|
|
440
|
+
*/
|
|
441
|
+
export declare class ActionRun {
|
|
442
|
+
private constructor();
|
|
443
|
+
static readonly run: (input: ActionRunInput, deps: ActionRunDeps) => Effect.Effect<ActionRunResult, EffectedConfigError | NotAPackageError | NotAnActionError | BundleFailed | CleanError | WriteError | PersistLocalError | ActionYmlPathError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
444
|
+
}
|
|
445
|
+
export { ActionBuildResult, type ActionInitDeps, type ActionInitInput, type ActionRunDeps, type ActionRunInput, type ActionScaffoldInput, ActionValidation, type BuildIssues, type BuildProgress, type BuildReport, BuildResult, type BuildRunDeps, type BuildRunInput, type BundleResult, type ValidationIssue, ValidationResult, renderCiAnnotations };
|
|
446
|
+
//# sourceMappingURL=build.d.ts.map
|
package/build.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionInit, ActionInitResult, ActionMetadataInvalidError, ActionMetadataMissingError, ActionScaffold, ActionScaffoldFile, ScaffoldConflict, ScaffoldConflictError, ScaffoldExistsError, ScaffoldWriteError } from "./build/ActionInit.js";
|
|
2
|
+
import { ActionRun, NotAnActionError } from "./build/ActionRun.js";
|
|
3
|
+
import { ActionRunResult } from "./build/ActionRunResult.js";
|
|
4
|
+
import { BuildRun, NotAPackageError } from "./build/BuildRun.js";
|
|
5
|
+
import { BuildRunResult } from "./build/BuildRunResult.js";
|
|
6
|
+
import { ActionBuildResult, ActionValidation, BuildResult, ValidationResult, renderCiAnnotations } from "@effected/bundler";
|
|
7
|
+
|
|
8
|
+
export { ActionBuildResult, ActionInit, ActionInitResult, ActionMetadataInvalidError, ActionMetadataMissingError, ActionRun, ActionRunResult, ActionScaffold, ActionScaffoldFile, ActionValidation, BuildResult, BuildRun, BuildRunResult, NotAPackageError, NotAnActionError, ScaffoldConflict, ScaffoldConflictError, ScaffoldExistsError, ScaffoldWriteError, ValidationResult, renderCiAnnotations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The effected tool's shared logic, consumed by its CLI and MCP front ends",
|
|
6
6
|
"keywords": [
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"import": "./index.js",
|
|
34
34
|
"default": "./index.js"
|
|
35
35
|
},
|
|
36
|
+
"./build": {
|
|
37
|
+
"types": "./build.d.ts",
|
|
38
|
+
"import": "./build.js",
|
|
39
|
+
"default": "./build.js"
|
|
40
|
+
},
|
|
36
41
|
"./package.json": "./package.json",
|
|
37
42
|
"./schema": {
|
|
38
43
|
"types": "./schema.d.ts",
|
|
@@ -41,11 +46,14 @@
|
|
|
41
46
|
}
|
|
42
47
|
},
|
|
43
48
|
"dependencies": {
|
|
44
|
-
"@effected/
|
|
49
|
+
"@effected/bundler": "0.1.0",
|
|
50
|
+
"@effected/files": "^0.2.0",
|
|
45
51
|
"@effected/jsonc": "^0.24.0",
|
|
52
|
+
"@effected/jsonl": "^0.18.0",
|
|
46
53
|
"@effected/kit": "^0.13.0",
|
|
47
|
-
"@effected/schemastore": "0.
|
|
54
|
+
"@effected/schemastore": "0.31.0",
|
|
48
55
|
"@effected/source": "^0.4.0",
|
|
56
|
+
"@effected/workspaces": "^0.44.0",
|
|
49
57
|
"ajv": "8.20.0",
|
|
50
58
|
"ajv-formats": "3.0.1",
|
|
51
59
|
"effect": "~4.1.2",
|
package/schema/Runner.js
CHANGED
|
@@ -2,8 +2,8 @@ import { ConfigLoader } from "./ConfigLoader.js";
|
|
|
2
2
|
import { decodeJson, flattenSchemaError } from "./internal/decode.js";
|
|
3
3
|
import { CatalogReport, CatalogSliceReport, DocumentDiff, MergedCatalogReport, RunReport, SchemaReport } from "./RunReport.js";
|
|
4
4
|
import { Effect, FileSystem, Option, Order, Path, Predicate, Result, Schema } from "effect";
|
|
5
|
-
import { CanonicalJson, CatalogEntry, DriftPolicy, SchemaFileWriteError, SchemaPipeline, SchemaVersioning } from "@effected/schemastore";
|
|
6
5
|
import { AtomicFile } from "@effected/files";
|
|
6
|
+
import { CanonicalJson, CatalogEntry, DriftPolicy, SchemaFileWriteError, SchemaPipeline, SchemaVersioning } from "@effected/schemastore";
|
|
7
7
|
import { LineDiff } from "@effected/source";
|
|
8
8
|
|
|
9
9
|
// src/schema/Runner.ts
|