@effected/engine 0.18.2 → 0.19.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 +3 -3
- package/build/ActionRun.js +3 -3
- package/build/ActionRunResult.js +1 -1
- package/build/BuildRun.js +3 -3
- package/build/BuildRunResult.js +1 -1
- package/build/BuildWatch.js +268 -0
- package/build.d.ts +100 -2
- package/build.js +3 -2
- package/package.json +1 -1
- package/schema/AjvInstanceValidator.js +2 -2
- package/schema/AjvValidator.js +2 -2
- package/schema/ConfigLoader.js +3 -3
- package/schema/Report.js +1 -1
- package/schema/RunReport.js +1 -1
- package/schema/Runner.js +4 -4
- package/schema/SchemaRun.js +2 -2
- package/schema/SchemaValidate.js +4 -4
- package/schema/VersionCheck.js +1 -1
package/build/ActionInit.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { NotAPackageError } from "./BuildRun.js";
|
|
2
|
-
import { ErrorText, PathContainment } from "@effected/kit";
|
|
3
|
-
import { Effect, FileSystem, Path, Predicate, Result, Schema } from "effect";
|
|
4
1
|
import { EffectedConfigSchema } from "@effected/bundler";
|
|
5
2
|
import { AtomicFile } from "@effected/files";
|
|
3
|
+
import { ErrorText, PathContainment } from "@effected/kit";
|
|
4
|
+
import { Effect, FileSystem, Path, Predicate, Result, Schema } from "effect";
|
|
5
|
+
import { NotAPackageError } from "./BuildRun.js";
|
|
6
6
|
|
|
7
7
|
// src/build/ActionInit.ts
|
|
8
8
|
/**
|
package/build/ActionRun.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ActionRunResult } from "./ActionRunResult.js";
|
|
2
|
-
import { readPackageName, workspaceRootOf } from "./BuildRun.js";
|
|
3
|
-
import { Effect, Layer, Path, Schema } from "effect";
|
|
4
1
|
import { ActionBuildResult, ActionBuilder, BuildResult, EffectedConfigFile } from "@effected/bundler";
|
|
5
2
|
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
3
|
+
import { Effect, Layer, Path, Schema } from "effect";
|
|
4
|
+
import { ActionRunResult } from "./ActionRunResult.js";
|
|
5
|
+
import { readPackageName, workspaceRootOf } from "./BuildRun.js";
|
|
6
6
|
|
|
7
7
|
// src/build/ActionRun.ts
|
|
8
8
|
/**
|
package/build/ActionRunResult.js
CHANGED
package/build/BuildRun.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { acquireBuildLock, buildLockPath } from "./BuildLock.js";
|
|
2
|
-
import { BuildRunResult } from "./BuildRunResult.js";
|
|
3
|
-
import { DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Predicate, Schema } from "effect";
|
|
4
1
|
import { BuildIssuesSchema, BuildJournal, Bundler, EffectedConfigError, EffectedConfigFile, IssueJournal, flattenIssues, loadPlugins } from "@effected/bundler";
|
|
5
2
|
import { NodeJournalWatcher } from "@effected/jsonl/node";
|
|
6
3
|
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
4
|
+
import { DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Predicate, Schema } from "effect";
|
|
5
|
+
import { acquireBuildLock, buildLockPath } from "./BuildLock.js";
|
|
6
|
+
import { BuildRunResult } from "./BuildRunResult.js";
|
|
7
7
|
|
|
8
8
|
// src/build/BuildRun.ts
|
|
9
9
|
/**
|
package/build/BuildRunResult.js
CHANGED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { EffectedConfigFile } from "@effected/bundler";
|
|
2
|
+
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
3
|
+
import { Deferred, Effect, FiberMap, FileSystem, Layer, Option, Path, PlatformError, Queue, Semaphore, Stream } from "effect";
|
|
4
|
+
import { NotAnActionError } from "./ActionRun.js";
|
|
5
|
+
import { readPackageName, workspaceRootOf } from "./BuildRun.js";
|
|
6
|
+
|
|
7
|
+
// src/build/BuildWatch.ts
|
|
8
|
+
/**
|
|
9
|
+
* What every watched build ignores: package-relative paths a build writes, matched on `/` boundaries.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* An entry covers the path itself, everything under it, and the directories it lives in, so a build creating
|
|
13
|
+
* `.github/actions/local` triggers nothing with its `.github` and `.github/actions` directory events. A path that only
|
|
14
|
+
* shares a prefix (`distribution`), or a file beside an entry (`.github/workflows/ci.yml`), still triggers.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_EXCLUDES = [
|
|
19
|
+
"dist",
|
|
20
|
+
"node_modules",
|
|
21
|
+
".turbo",
|
|
22
|
+
".git",
|
|
23
|
+
".cache",
|
|
24
|
+
"tsdoc.json",
|
|
25
|
+
".actrc",
|
|
26
|
+
".github/workflows/act-test.yml",
|
|
27
|
+
".github/actions/local"
|
|
28
|
+
];
|
|
29
|
+
const CONFIG_NAME = "effected.toml";
|
|
30
|
+
/** Discovery from `cwd`, as `BuildRun` and `ActionRun` provide it to the root search and the config load. */
|
|
31
|
+
const discoveryFrom = (cwd) => WorkspaceDiscovery.layer({ cwd }).pipe(Layer.provide(WorkspaceRoot.layer));
|
|
32
|
+
/**
|
|
33
|
+
* Whether an exclusion covers `path`, on `/` boundaries: `path` is the excluded path, lies under it, or is a directory
|
|
34
|
+
* it lives in. A build creating `.github/actions/local` also creates `.github` and `.github/actions`, and those
|
|
35
|
+
* directory events are the build's own; a file under them that no exclusion names still triggers.
|
|
36
|
+
*/
|
|
37
|
+
const isUnder = (path, prefix) => {
|
|
38
|
+
const trimmed = trimExclusion(prefix);
|
|
39
|
+
return isCovered(path, prefix) || trimmed !== "" && trimmed.startsWith(`${path}/`);
|
|
40
|
+
};
|
|
41
|
+
const trimExclusion = (prefix) => prefix.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
42
|
+
/** Whether `path` is an excluded path or lies under it, on `/` boundaries: a top-level directory never watched. */
|
|
43
|
+
const isCovered = (path, prefix) => {
|
|
44
|
+
const trimmed = trimExclusion(prefix);
|
|
45
|
+
return trimmed !== "" && (path === trimmed || path.startsWith(`${trimmed}/`));
|
|
46
|
+
};
|
|
47
|
+
/** The config as it is now, or `None` when it will not load; a watch's exclusions never fail. */
|
|
48
|
+
const loadConfig = (target) => EffectedConfigFile.load({
|
|
49
|
+
cwd: target.cwd,
|
|
50
|
+
root: target.root
|
|
51
|
+
}).pipe(Effect.provide(discoveryFrom(target.cwd)), Effect.option);
|
|
52
|
+
/**
|
|
53
|
+
* {@link DEFAULT_EXCLUDES} plus each of `paths` that resolves inside the package, package-relative with `/`. Outside
|
|
54
|
+
* the package no watched event can match one, and at the package itself it would exclude everything.
|
|
55
|
+
*/
|
|
56
|
+
const withInside = (path, cwd, paths) => {
|
|
57
|
+
const added = [];
|
|
58
|
+
for (const entry of paths) {
|
|
59
|
+
const relative = path.relative(cwd, path.resolve(cwd, entry)).split(path.sep).join("/");
|
|
60
|
+
if (relative !== "" && relative !== ".." && !relative.startsWith("../") && !path.isAbsolute(relative) && !DEFAULT_EXCLUDES.includes(relative) && !added.includes(relative)) added.push(relative);
|
|
61
|
+
}
|
|
62
|
+
return added.length === 0 ? DEFAULT_EXCLUDES : [...DEFAULT_EXCLUDES, ...added];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Rebuild on change.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
var BuildWatch = class {
|
|
70
|
+
/**
|
|
71
|
+
* Resolves what a watch covers, refusing a directory that cannot be built at all: no `package.json`, a workspace
|
|
72
|
+
* root that cannot be discovered, or, for an action, a config that loads with no `[action]` table. A config that
|
|
73
|
+
* will not load is not refused, because it is an edit the watch must survive.
|
|
74
|
+
*/
|
|
75
|
+
static target = (cwd, kind) => Effect.gen(function* () {
|
|
76
|
+
const resolved = (yield* Path.Path).resolve(cwd);
|
|
77
|
+
yield* readPackageName(resolved);
|
|
78
|
+
const discovery = discoveryFrom(resolved);
|
|
79
|
+
const root = yield* workspaceRootOf(resolved).pipe(Effect.provide(discovery));
|
|
80
|
+
if (kind === "action") {
|
|
81
|
+
const loaded = yield* EffectedConfigFile.load({
|
|
82
|
+
cwd: resolved,
|
|
83
|
+
root
|
|
84
|
+
}).pipe(Effect.provide(discovery), Effect.option);
|
|
85
|
+
if (Option.isSome(loaded) && loaded.value.config.action === void 0) return yield* new NotAnActionError({ cwd: resolved });
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
cwd: resolved,
|
|
89
|
+
root
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* A package's exclusions: {@link DEFAULT_EXCLUDES} plus each `[package.build.meta] localPaths` directory inside the
|
|
94
|
+
* package, package-relative, read from the config as it is now. Every build copies the API model into each one, so
|
|
95
|
+
* without them the watch would rebuild itself. Any config that will not load, or `meta = false`, gives the defaults.
|
|
96
|
+
*/
|
|
97
|
+
static packageExcludes = (target) => Effect.gen(function* () {
|
|
98
|
+
const path = yield* Path.Path;
|
|
99
|
+
const loaded = yield* loadConfig(target);
|
|
100
|
+
const meta = Option.isSome(loaded) ? loaded.value.config.package.build.meta : false;
|
|
101
|
+
return withInside(path, target.cwd, meta === false ? [] : meta.localPaths);
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* An action's exclusions: {@link DEFAULT_EXCLUDES} plus its enabled `persistLocal.path`, package-relative, read
|
|
105
|
+
* from the config as it is now. `persist: false`, the `--no-persist` build that writes nothing there, leaves that
|
|
106
|
+
* path watched. Any config that will not load, or has no `[action]` table, gives the defaults.
|
|
107
|
+
*/
|
|
108
|
+
static actionExcludes = (target, options) => Effect.gen(function* () {
|
|
109
|
+
if (options?.persist === false) return DEFAULT_EXCLUDES;
|
|
110
|
+
const path = yield* Path.Path;
|
|
111
|
+
const loaded = yield* loadConfig(target);
|
|
112
|
+
const persist = Option.isSome(loaded) ? loaded.value.config.action?.persistLocal : void 0;
|
|
113
|
+
if (persist === void 0 || !persist.enabled) return DEFAULT_EXCLUDES;
|
|
114
|
+
return withInside(path, target.cwd, [persist.path]);
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Builds once with `Initial` after every watcher is installed, then once per settled batch of changes, for as long
|
|
118
|
+
* as it runs. Fails with a watcher's `PlatformError`, or when a watcher stops; `build`'s errors propagate.
|
|
119
|
+
*
|
|
120
|
+
* @remarks
|
|
121
|
+
* The package directory is watched non-recursively, and each of its top-level directories that no exclusion covers
|
|
122
|
+
* gets a recursive watch of its own, so an excluded `node_modules`, `.git` or `dist` is never walked. A directory
|
|
123
|
+
* that is only where an exclusion lives, such as `.github`, is watched, and its events are filtered. The set follows
|
|
124
|
+
* the package: a new top-level directory is watched from its first event, a removed one's watch is dropped, and the
|
|
125
|
+
* exclusions are re-read after each batch. `<root>/.config` is watched while it exists, including one created after
|
|
126
|
+
* the watch starts. A watch stopping fails the run, except that a top-level directory's or `<root>/.config`'s watch
|
|
127
|
+
* ending once the directory is gone is that directory going away.
|
|
128
|
+
*/
|
|
129
|
+
static run = (options) => Effect.scoped(Effect.gen(function* () {
|
|
130
|
+
const fs = yield* FileSystem.FileSystem;
|
|
131
|
+
const path = yield* Path.Path;
|
|
132
|
+
const cwd = path.resolve(options.cwd);
|
|
133
|
+
const root = path.resolve(options.root);
|
|
134
|
+
const debounce = options.debounce ?? "100 millis";
|
|
135
|
+
const toRelative = (absolute) => path.relative(cwd, absolute).split(path.sep).join("/");
|
|
136
|
+
const absoluteIn = (dir, eventPath) => path.resolve(dir, eventPath);
|
|
137
|
+
const inPackage = (absolute) => {
|
|
138
|
+
const relative = toRelative(absolute);
|
|
139
|
+
return relative === "" || relative === ".." || relative.startsWith("../") ? void 0 : relative;
|
|
140
|
+
};
|
|
141
|
+
const configDir = path.join(root, ".config");
|
|
142
|
+
/** The root-tier `effected.toml` directly in `dir`, as a batch entry, or nothing. */
|
|
143
|
+
const configIn = (dir) => (absolute) => path.dirname(absolute) === dir && path.basename(absolute) === CONFIG_NAME ? toRelative(absolute) : void 0;
|
|
144
|
+
const fixed = [{
|
|
145
|
+
dir: cwd,
|
|
146
|
+
accept: inPackage,
|
|
147
|
+
topLevel: true
|
|
148
|
+
}];
|
|
149
|
+
const rootTier = root !== cwd && (yield* fs.exists(root));
|
|
150
|
+
if (rootTier) fixed.push({
|
|
151
|
+
dir: root,
|
|
152
|
+
topLevel: false,
|
|
153
|
+
accept: configIn(root)
|
|
154
|
+
});
|
|
155
|
+
const pending = yield* Queue.unbounded();
|
|
156
|
+
const offer = (entry) => entry === void 0 ? Effect.void : Queue.offer(pending, entry);
|
|
157
|
+
const stopped = (dir) => PlatformError.systemError({
|
|
158
|
+
_tag: "Unknown",
|
|
159
|
+
module: "FileSystem",
|
|
160
|
+
method: "watch",
|
|
161
|
+
pathOrDescriptor: dir,
|
|
162
|
+
description: "The watcher stopped."
|
|
163
|
+
});
|
|
164
|
+
const directoryAt = (dir) => Effect.map(Effect.option(fs.stat(dir)), Option.filter((info) => info.type === "Directory"));
|
|
165
|
+
const watchWhilePresent = (dir, recursive, accept) => {
|
|
166
|
+
const ready = Deferred.makeUnsafe();
|
|
167
|
+
return {
|
|
168
|
+
ready,
|
|
169
|
+
watching: Effect.flatMap(directoryAt(dir), (armedOn) => {
|
|
170
|
+
const armedIno = Option.flatMap(armedOn, (info) => info.ino);
|
|
171
|
+
const unlessGone = (error) => Effect.flatMap(directoryAt(dir), (now) => {
|
|
172
|
+
const nowIno = Option.flatMap(now, (info) => info.ino);
|
|
173
|
+
return Option.isSome(now) && (Option.isNone(armedIno) || Option.isNone(nowIno) || armedIno.value === nowIno.value) ? Effect.fail(error) : Effect.void;
|
|
174
|
+
});
|
|
175
|
+
return fs.watch(dir, {
|
|
176
|
+
recursive,
|
|
177
|
+
onReady: () => {
|
|
178
|
+
Deferred.doneUnsafe(ready, Effect.void);
|
|
179
|
+
}
|
|
180
|
+
}).pipe(Stream.runForEach((event) => offer(accept(absoluteIn(dir, event.path)))), Effect.matchEffect({
|
|
181
|
+
onFailure: unlessGone,
|
|
182
|
+
onSuccess: () => unlessGone(stopped(dir))
|
|
183
|
+
}));
|
|
184
|
+
}).pipe(Effect.ensuring(Effect.sync(() => Deferred.doneUnsafe(ready, Effect.void))))
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
const directories = yield* FiberMap.make();
|
|
188
|
+
const arm = (name) => {
|
|
189
|
+
const { ready, watching } = watchWhilePresent(path.join(cwd, name), true, inPackage);
|
|
190
|
+
return Effect.as(FiberMap.run(directories, name, watching, { onlyIfMissing: true }), ready);
|
|
191
|
+
};
|
|
192
|
+
const configWatch = yield* FiberMap.make();
|
|
193
|
+
const configPermit = yield* Semaphore.make(1);
|
|
194
|
+
const claimConfig = Effect.gen(function* () {
|
|
195
|
+
if (!rootTier || (yield* FiberMap.has(configWatch, "config")) || !(yield* fs.exists(configDir))) return Option.none();
|
|
196
|
+
const { ready, watching } = watchWhilePresent(configDir, false, configIn(configDir));
|
|
197
|
+
yield* FiberMap.run(configWatch, "config", watching, { onlyIfMissing: true });
|
|
198
|
+
return Option.some(ready);
|
|
199
|
+
});
|
|
200
|
+
const armConfig = Semaphore.withPermit(configPermit, claimConfig);
|
|
201
|
+
const configEvent = Effect.gen(function* () {
|
|
202
|
+
const armed = yield* Semaphore.withPermit(configPermit, Effect.andThen(FiberMap.remove(configWatch, "config"), claimConfig));
|
|
203
|
+
if (Option.isSome(armed)) yield* Deferred.await(armed.value);
|
|
204
|
+
yield* offer(toRelative(path.join(configDir, CONFIG_NAME)));
|
|
205
|
+
});
|
|
206
|
+
const permit = yield* Semaphore.make(1);
|
|
207
|
+
const reconcile = Semaphore.withPermit(permit, Effect.gen(function* () {
|
|
208
|
+
const excludes = yield* options.exclude;
|
|
209
|
+
const wanted = /* @__PURE__ */ new Set();
|
|
210
|
+
for (const name of yield* fs.readDirectory(cwd)) {
|
|
211
|
+
if (excludes.some((prefix) => isCovered(name, prefix))) continue;
|
|
212
|
+
const info = yield* Effect.option(fs.stat(path.join(cwd, name)));
|
|
213
|
+
if (Option.isSome(info) && info.value.type === "Directory") wanted.add(name);
|
|
214
|
+
}
|
|
215
|
+
for (const [name] of [...directories]) if (!wanted.has(name)) yield* FiberMap.remove(directories, name);
|
|
216
|
+
const armed = [];
|
|
217
|
+
for (const name of wanted) if (!(yield* FiberMap.has(directories, name))) armed.push(yield* arm(name));
|
|
218
|
+
return armed;
|
|
219
|
+
}));
|
|
220
|
+
const fixedReady = fixed.map(() => Deferred.makeUnsafe());
|
|
221
|
+
const watching = Stream.mergeAll(fixed.map((target, index) => fs.watch(target.dir, { onReady: () => {
|
|
222
|
+
Deferred.doneUnsafe(fixedReady[index], Effect.void);
|
|
223
|
+
} }).pipe(Stream.map((event) => ({
|
|
224
|
+
target,
|
|
225
|
+
absolute: absoluteIn(target.dir, event.path)
|
|
226
|
+
})), Stream.concat(Stream.fail(stopped(target.dir))))), { concurrency: "unbounded" }).pipe(Stream.runForEach(({ target, absolute }) => {
|
|
227
|
+
const entry = target.accept(absolute);
|
|
228
|
+
if (target.topLevel) return entry === void 0 ? Effect.void : Effect.andThen(reconcile, offer(entry));
|
|
229
|
+
return absolute === configDir ? configEvent : offer(entry);
|
|
230
|
+
}), Effect.andThen(Effect.never));
|
|
231
|
+
const nextBatch = Effect.gen(function* () {
|
|
232
|
+
const batch = new Set(yield* Queue.takeAll(pending));
|
|
233
|
+
while (true) {
|
|
234
|
+
const more = yield* Effect.timeoutOption(Queue.takeAll(pending), debounce);
|
|
235
|
+
if (Option.isNone(more)) break;
|
|
236
|
+
for (const entry of more.value) batch.add(entry);
|
|
237
|
+
}
|
|
238
|
+
const excludes = yield* options.exclude;
|
|
239
|
+
return [...batch].filter((entry) => !excludes.some((prefix) => isUnder(entry, prefix))).sort();
|
|
240
|
+
});
|
|
241
|
+
const consuming = Effect.gen(function* () {
|
|
242
|
+
const armed = yield* reconcile;
|
|
243
|
+
const config = yield* armConfig;
|
|
244
|
+
yield* Effect.forEach([
|
|
245
|
+
...fixedReady,
|
|
246
|
+
...armed,
|
|
247
|
+
...Option.toArray(config)
|
|
248
|
+
], Deferred.await, { discard: true });
|
|
249
|
+
yield* options.build({ _tag: "Initial" });
|
|
250
|
+
while (true) {
|
|
251
|
+
const paths = yield* nextBatch;
|
|
252
|
+
yield* reconcile;
|
|
253
|
+
if (paths.length > 0) yield* options.build({
|
|
254
|
+
_tag: "Changed",
|
|
255
|
+
paths
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return yield* Effect.raceAllFirst([
|
|
260
|
+
watching,
|
|
261
|
+
consuming,
|
|
262
|
+
Effect.andThen(FiberMap.join(directories), Effect.never),
|
|
263
|
+
Effect.andThen(FiberMap.join(configWatch), Effect.never)
|
|
264
|
+
]);
|
|
265
|
+
}));
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export { BuildWatch, DEFAULT_EXCLUDES };
|
package/build.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
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";
|
|
7
6
|
import { Duration, Effect, FileSystem, Layer, Option, Path, PlatformError, Schema } from "effect";
|
|
7
|
+
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";
|
|
8
8
|
import { AppendError, JournalWatcher } from "@effected/jsonl";
|
|
9
9
|
declare const BuildLockHolder_base: Schema.Class<BuildLockHolder, Schema.Struct<{
|
|
10
10
|
/** The holding process. */
|
|
@@ -504,5 +504,103 @@ export declare class ActionRun {
|
|
|
504
504
|
private constructor();
|
|
505
505
|
static readonly run: (input: ActionRunInput, deps: ActionRunDeps) => Effect.Effect<ActionRunResult, EffectedConfigError | NotAPackageError | NotAnActionError | BundleFailed | CleanError | WriteError | PersistLocalError | ActionYmlPathError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
506
506
|
}
|
|
507
|
-
|
|
507
|
+
/**
|
|
508
|
+
* Why a watched build runs: the first build, or a settled batch of changes.
|
|
509
|
+
*
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
512
|
+
type WatchTrigger = {
|
|
513
|
+
readonly _tag: "Initial";
|
|
514
|
+
} | {
|
|
515
|
+
readonly _tag: "Changed";
|
|
516
|
+
/**
|
|
517
|
+
* The changed paths, de-duplicated and sorted, relative to the package directory with `/` separators; a
|
|
518
|
+
* root-tier `effected.toml` reads as `../…`.
|
|
519
|
+
*/
|
|
520
|
+
readonly paths: ReadonlyArray<string>;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* What every watched build ignores: package-relative paths a build writes, matched on `/` boundaries.
|
|
524
|
+
*
|
|
525
|
+
* @remarks
|
|
526
|
+
* An entry covers the path itself, everything under it, and the directories it lives in, so a build creating
|
|
527
|
+
* `.github/actions/local` triggers nothing with its `.github` and `.github/actions` directory events. A path that only
|
|
528
|
+
* shares a prefix (`distribution`), or a file beside an entry (`.github/workflows/ci.yml`), still triggers.
|
|
529
|
+
*
|
|
530
|
+
* @public
|
|
531
|
+
*/
|
|
532
|
+
export declare const DEFAULT_EXCLUDES: ReadonlyArray<string>;
|
|
533
|
+
/**
|
|
534
|
+
* What {@link BuildWatch.run} watches and what it runs.
|
|
535
|
+
*
|
|
536
|
+
* @public
|
|
537
|
+
*/
|
|
538
|
+
interface BuildWatchOptions<E, R> {
|
|
539
|
+
/** The package directory, absolute. */
|
|
540
|
+
readonly cwd: string;
|
|
541
|
+
/** The workspace root, absolute. */
|
|
542
|
+
readonly root: string;
|
|
543
|
+
/**
|
|
544
|
+
* Package-relative paths to ignore, re-evaluated before each batch is filtered. Each covers itself, what lies under
|
|
545
|
+
* it, and the directories it lives in, as {@link DEFAULT_EXCLUDES} does.
|
|
546
|
+
*/
|
|
547
|
+
readonly exclude: Effect.Effect<ReadonlyArray<string>, never, R>;
|
|
548
|
+
/** How long the watched tree must be quiet before a batch is cut; omitted, 100 milliseconds. */
|
|
549
|
+
readonly debounce?: Duration.Input;
|
|
550
|
+
/** One build; its errors end the watch. */
|
|
551
|
+
readonly build: (trigger: WatchTrigger) => Effect.Effect<void, E, R>;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* The directories a watch covers, resolved once at startup.
|
|
555
|
+
*
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
interface WatchTarget {
|
|
559
|
+
/** The package directory, absolute. */
|
|
560
|
+
readonly cwd: string;
|
|
561
|
+
/** The workspace root, absolute; `cwd` itself when there is no workspace above it. */
|
|
562
|
+
readonly root: string;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Rebuild on change.
|
|
566
|
+
*
|
|
567
|
+
* @public
|
|
568
|
+
*/
|
|
569
|
+
export declare class BuildWatch {
|
|
570
|
+
/**
|
|
571
|
+
* Resolves what a watch covers, refusing a directory that cannot be built at all: no `package.json`, a workspace
|
|
572
|
+
* root that cannot be discovered, or, for an action, a config that loads with no `[action]` table. A config that
|
|
573
|
+
* will not load is not refused, because it is an edit the watch must survive.
|
|
574
|
+
*/
|
|
575
|
+
static readonly target: (cwd: string, kind: "package" | "action") => Effect.Effect<WatchTarget, NotAPackageError | NotAnActionError | EffectedConfigError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
576
|
+
/**
|
|
577
|
+
* A package's exclusions: {@link DEFAULT_EXCLUDES} plus each `[package.build.meta] localPaths` directory inside the
|
|
578
|
+
* package, package-relative, read from the config as it is now. Every build copies the API model into each one, so
|
|
579
|
+
* without them the watch would rebuild itself. Any config that will not load, or `meta = false`, gives the defaults.
|
|
580
|
+
*/
|
|
581
|
+
static readonly packageExcludes: (target: WatchTarget) => Effect.Effect<ReadonlyArray<string>, never, FileSystem.FileSystem | Path.Path>;
|
|
582
|
+
/**
|
|
583
|
+
* An action's exclusions: {@link DEFAULT_EXCLUDES} plus its enabled `persistLocal.path`, package-relative, read
|
|
584
|
+
* from the config as it is now. `persist: false`, the `--no-persist` build that writes nothing there, leaves that
|
|
585
|
+
* path watched. Any config that will not load, or has no `[action]` table, gives the defaults.
|
|
586
|
+
*/
|
|
587
|
+
static readonly actionExcludes: (target: WatchTarget, options?: {
|
|
588
|
+
readonly persist?: boolean;
|
|
589
|
+
}) => Effect.Effect<ReadonlyArray<string>, never, FileSystem.FileSystem | Path.Path>;
|
|
590
|
+
/**
|
|
591
|
+
* Builds once with `Initial` after every watcher is installed, then once per settled batch of changes, for as long
|
|
592
|
+
* as it runs. Fails with a watcher's `PlatformError`, or when a watcher stops; `build`'s errors propagate.
|
|
593
|
+
*
|
|
594
|
+
* @remarks
|
|
595
|
+
* The package directory is watched non-recursively, and each of its top-level directories that no exclusion covers
|
|
596
|
+
* gets a recursive watch of its own, so an excluded `node_modules`, `.git` or `dist` is never walked. A directory
|
|
597
|
+
* that is only where an exclusion lives, such as `.github`, is watched, and its events are filtered. The set follows
|
|
598
|
+
* the package: a new top-level directory is watched from its first event, a removed one's watch is dropped, and the
|
|
599
|
+
* exclusions are re-read after each batch. `<root>/.config` is watched while it exists, including one created after
|
|
600
|
+
* the watch starts. A watch stopping fails the run, except that a top-level directory's or `<root>/.config`'s watch
|
|
601
|
+
* ending once the directory is gone is that directory going away.
|
|
602
|
+
*/
|
|
603
|
+
static readonly run: <E, R>(options: BuildWatchOptions<E, R>) => Effect.Effect<never, E | PlatformError.PlatformError, R | FileSystem.FileSystem | Path.Path>;
|
|
604
|
+
}
|
|
605
|
+
export { ActionBuildResult, type ActionInitDeps, type ActionInitInput, type ActionRunDeps, type ActionRunInput, type ActionScaffoldInput, ActionValidation, type BuildIssues, type BuildLockOptions, type BuildProgress, type BuildReport, BuildResult, type BuildRunDeps, type BuildRunInput, type BuildWatchOptions, type BundleResult, type ValidationIssue, ValidationResult, type WatchTarget, type WatchTrigger, renderCiAnnotations };
|
|
508
606
|
//# sourceMappingURL=build.d.ts.map
|
package/build.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ActionBuildResult, ActionValidation, BuildResult, ValidationResult, renderCiAnnotations } from "@effected/bundler";
|
|
1
2
|
import { ActionInit, ActionInitResult, ActionMetadataInvalidError, ActionMetadataMissingError, ActionScaffold, ActionScaffoldFile, ScaffoldConflict, ScaffoldConflictError, ScaffoldExistsError, ScaffoldWriteError } from "./build/ActionInit.js";
|
|
2
3
|
import { ActionRun, NotAnActionError } from "./build/ActionRun.js";
|
|
3
4
|
import { ActionRunResult } from "./build/ActionRunResult.js";
|
|
4
5
|
import { BuildLockHolder, BuildLockTimeoutError } from "./build/BuildLock.js";
|
|
5
6
|
import { BuildRun, NotAPackageError } from "./build/BuildRun.js";
|
|
6
7
|
import { BuildRunResult } from "./build/BuildRunResult.js";
|
|
7
|
-
import {
|
|
8
|
+
import { BuildWatch, DEFAULT_EXCLUDES } from "./build/BuildWatch.js";
|
|
8
9
|
|
|
9
|
-
export { ActionBuildResult, ActionInit, ActionInitResult, ActionMetadataInvalidError, ActionMetadataMissingError, ActionRun, ActionRunResult, ActionScaffold, ActionScaffoldFile, ActionValidation, BuildLockHolder, BuildLockTimeoutError, BuildResult, BuildRun, BuildRunResult, NotAPackageError, NotAnActionError, ScaffoldConflict, ScaffoldConflictError, ScaffoldExistsError, ScaffoldWriteError, ValidationResult, renderCiAnnotations };
|
|
10
|
+
export { ActionBuildResult, ActionInit, ActionInitResult, ActionMetadataInvalidError, ActionMetadataMissingError, ActionRun, ActionRunResult, ActionScaffold, ActionScaffoldFile, ActionValidation, BuildLockHolder, BuildLockTimeoutError, BuildResult, BuildRun, BuildRunResult, BuildWatch, DEFAULT_EXCLUDES, NotAPackageError, NotAnActionError, ScaffoldConflict, ScaffoldConflictError, ScaffoldExistsError, ScaffoldWriteError, ValidationResult, renderCiAnnotations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { makeAjv } from "./internal/ajv.js";
|
|
2
|
-
import { Effect, Layer } from "effect";
|
|
3
1
|
import { InstanceFinding, InstanceValidator, InstanceValidatorError } from "@effected/schemastore";
|
|
2
|
+
import { Effect, Layer } from "effect";
|
|
3
|
+
import { makeAjv } from "./internal/ajv.js";
|
|
4
4
|
|
|
5
5
|
// src/schema/AjvInstanceValidator.ts
|
|
6
6
|
const findingFromAjvError = (error) => InstanceFinding.make({
|
package/schema/AjvValidator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { makeAjv } from "./internal/ajv.js";
|
|
2
|
-
import { Effect, Layer } from "effect";
|
|
3
1
|
import { SchemaValidator, SchemaValidatorError, ValidationFinding } from "@effected/schemastore";
|
|
2
|
+
import { Effect, Layer } from "effect";
|
|
3
|
+
import { makeAjv } from "./internal/ajv.js";
|
|
4
4
|
|
|
5
5
|
// src/schema/AjvValidator.ts
|
|
6
6
|
const findingFromAjvError = (error) => ValidationFinding.make({
|
package/schema/ConfigLoader.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { causeMessage } from "./internal/causeMessage.js";
|
|
2
|
-
import { flattenSchemaError } from "./internal/decode.js";
|
|
3
1
|
import { createRequire } from "node:module";
|
|
4
2
|
import { PathContainment } from "@effected/kit";
|
|
5
|
-
import { Effect, FileSystem, Path, Predicate, Result, Schema } from "effect";
|
|
6
3
|
import { CatalogEntry, SchemaVersioning, isSchemastoreConfig } from "@effected/schemastore";
|
|
4
|
+
import { Effect, FileSystem, Path, Predicate, Result, Schema } from "effect";
|
|
7
5
|
import { createJiti } from "jiti";
|
|
6
|
+
import { causeMessage } from "./internal/causeMessage.js";
|
|
7
|
+
import { flattenSchemaError } from "./internal/decode.js";
|
|
8
8
|
|
|
9
9
|
// src/schema/ConfigLoader.ts
|
|
10
10
|
/**
|
package/schema/Report.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { RunReport } from "./RunReport.js";
|
|
2
3
|
import { VersionMismatch } from "./VersionCheck.js";
|
|
3
|
-
import { Schema } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/schema/Report.ts
|
|
6
6
|
const findingLine = (finding) => ` ${finding.label} at "${finding.path}": ${finding.message}`;
|
package/schema/RunReport.js
CHANGED
package/schema/Runner.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ConfigLoader } from "./ConfigLoader.js";
|
|
2
|
-
import { decodeJson, flattenSchemaError } from "./internal/decode.js";
|
|
3
|
-
import { CatalogReport, CatalogSliceReport, DocumentDiff, MergedCatalogReport, RunReport, SchemaReport } from "./RunReport.js";
|
|
4
|
-
import { Effect, FileSystem, Option, Order, Path, Predicate, Result, Schema } from "effect";
|
|
5
1
|
import { AtomicFile } from "@effected/files";
|
|
6
2
|
import { CanonicalJson, CatalogEntry, DriftPolicy, SchemaFileWriteError, SchemaPipeline, SchemaVersioning } from "@effected/schemastore";
|
|
7
3
|
import { LineDiff } from "@effected/source";
|
|
4
|
+
import { Effect, FileSystem, Option, Order, Path, Predicate, Result, Schema } from "effect";
|
|
5
|
+
import { ConfigLoader } from "./ConfigLoader.js";
|
|
6
|
+
import { decodeJson, flattenSchemaError } from "./internal/decode.js";
|
|
7
|
+
import { CatalogReport, CatalogSliceReport, DocumentDiff, MergedCatalogReport, RunReport, SchemaReport } from "./RunReport.js";
|
|
8
8
|
|
|
9
9
|
// src/schema/Runner.ts
|
|
10
10
|
/**
|
package/schema/SchemaRun.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { SchemaFile } from "@effected/schemastore";
|
|
2
|
+
import { Effect, Option, Schema } from "effect";
|
|
1
3
|
import { AjvValidator } from "./AjvValidator.js";
|
|
2
4
|
import { ConfigLoader } from "./ConfigLoader.js";
|
|
3
5
|
import { Runner } from "./Runner.js";
|
|
4
6
|
import { RunReport } from "./RunReport.js";
|
|
5
7
|
import { VersionCheck, VersionMismatch, VersionMismatchError } from "./VersionCheck.js";
|
|
6
|
-
import { Effect, Option, Schema } from "effect";
|
|
7
|
-
import { SchemaFile } from "@effected/schemastore";
|
|
8
8
|
|
|
9
9
|
// src/schema/SchemaRun.ts
|
|
10
10
|
/**
|
package/schema/SchemaValidate.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Jsonc } from "@effected/jsonc";
|
|
2
|
+
import { InstanceValidator } from "@effected/schemastore";
|
|
3
|
+
import { LineIndex } from "@effected/source";
|
|
4
|
+
import { Effect, FileSystem, JsonPointer, Option, Path, Predicate, Result, Schema, SchemaTransformation } from "effect";
|
|
1
5
|
import { AjvInstanceValidator } from "./AjvInstanceValidator.js";
|
|
2
6
|
import { ConfigLoader } from "./ConfigLoader.js";
|
|
3
7
|
import { VersionCheck, VersionMismatch, VersionMismatchError } from "./VersionCheck.js";
|
|
4
|
-
import { Effect, FileSystem, JsonPointer, Option, Path, Predicate, Result, Schema, SchemaTransformation } from "effect";
|
|
5
|
-
import { InstanceValidator } from "@effected/schemastore";
|
|
6
|
-
import { LineIndex } from "@effected/source";
|
|
7
|
-
import { Jsonc } from "@effected/jsonc";
|
|
8
8
|
|
|
9
9
|
// src/schema/SchemaValidate.ts
|
|
10
10
|
/**
|