@effected/engine 0.19.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/ActionInit.js +24 -6
- package/build/ActionRun.js +11 -3
- package/build/BuildWatch.js +17 -6
- package/build.d.ts +14 -2
- package/package.json +4 -4
package/build/ActionInit.js
CHANGED
|
@@ -167,18 +167,26 @@ const DEV_DEPENDENCIES = [
|
|
|
167
167
|
const isControl = (code) => code < 32 && code !== 9 || code >= 127 && code <= 159;
|
|
168
168
|
const codePoint = (character) => `U+${(character.codePointAt(0) ?? 0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
169
169
|
const yamlString = (value) => JSON.stringify(value).replace(/[\u007F-\u009F\u2028\u2029]/g, (character) => `\\u${codePoint(character).slice(2)}`);
|
|
170
|
-
const
|
|
170
|
+
const tomlHead = `${EffectedConfigSchema.directive}
|
|
171
171
|
|
|
172
172
|
# \`effected action build\` reads the [action] tables. A key left out takes its default.
|
|
173
173
|
|
|
174
174
|
[action.entries]
|
|
175
175
|
main = "src/main.ts"
|
|
176
|
-
|
|
176
|
+
`;
|
|
177
|
+
const effectedToml = `${tomlHead}
|
|
177
178
|
# Copies each build to .github/actions/local, the target act and CI smoke-test.
|
|
178
179
|
[action.persistLocal]
|
|
179
180
|
enabled = true
|
|
180
181
|
path = ".github/actions/local"
|
|
181
182
|
`;
|
|
183
|
+
const localEffectedToml = `${tomlHead}
|
|
184
|
+
# Persists each build to .github/actions/<package directory name> at the workspace root and keeps no package dist.
|
|
185
|
+
[action.persistLocal]
|
|
186
|
+
base = "workspace"
|
|
187
|
+
dist = false
|
|
188
|
+
`;
|
|
189
|
+
const localGitignore = "dist/\n.action-staging/\n";
|
|
182
190
|
const actionYml = (input) => `# The single source of the action's input and output names and their defaults: code mirrors them.
|
|
183
191
|
name: ${yamlString(input.name)}
|
|
184
192
|
description: ${yamlString(input.description)}
|
|
@@ -276,7 +284,7 @@ var ActionInit = class ActionInit {
|
|
|
276
284
|
files: [
|
|
277
285
|
ActionScaffoldFile.make({
|
|
278
286
|
path: "effected.toml",
|
|
279
|
-
contents: effectedToml
|
|
287
|
+
contents: input.local === true ? localEffectedToml : effectedToml
|
|
280
288
|
}),
|
|
281
289
|
ActionScaffoldFile.make({
|
|
282
290
|
path: "action.yml",
|
|
@@ -293,7 +301,11 @@ var ActionInit = class ActionInit {
|
|
|
293
301
|
ActionScaffoldFile.make({
|
|
294
302
|
path: "tsconfig.json",
|
|
295
303
|
contents: tsconfigJson
|
|
296
|
-
})
|
|
304
|
+
}),
|
|
305
|
+
...input.local === true && input.gitignore !== false ? [ActionScaffoldFile.make({
|
|
306
|
+
path: ".gitignore",
|
|
307
|
+
contents: localGitignore
|
|
308
|
+
})] : []
|
|
297
309
|
],
|
|
298
310
|
dependencies: DEPENDENCIES,
|
|
299
311
|
devDependencies: DEV_DEPENDENCIES
|
|
@@ -436,15 +448,21 @@ var ActionInit = class ActionInit {
|
|
|
436
448
|
* the packages to add.
|
|
437
449
|
*/
|
|
438
450
|
static run = Effect.fn("ActionInit.run")(function* (input, deps) {
|
|
439
|
-
const
|
|
451
|
+
const path = yield* Path.Path;
|
|
452
|
+
const cwd = path.resolve(deps.cwd);
|
|
440
453
|
const manifest = yield* readManifest(cwd);
|
|
441
454
|
const name = blank(input.name) ? manifest.name : input.name;
|
|
442
455
|
if (blank(name)) return yield* new ActionMetadataMissingError({ field: "name" });
|
|
443
456
|
const description = blank(input.description) ? manifest.description : input.description;
|
|
444
457
|
if (blank(description)) return yield* new ActionMetadataMissingError({ field: "description" });
|
|
458
|
+
const fs = yield* FileSystem.FileSystem;
|
|
459
|
+
const local = input.local === true;
|
|
460
|
+
const hasGitignore = local ? yield* fs.exists(path.join(cwd, ".gitignore")) : false;
|
|
445
461
|
const scaffold = ActionInit.plan({
|
|
446
462
|
name: yield* checked("name", name ?? ""),
|
|
447
|
-
description: yield* checked("description", description ?? "")
|
|
463
|
+
description: yield* checked("description", description ?? ""),
|
|
464
|
+
local,
|
|
465
|
+
gitignore: !hasGitignore
|
|
448
466
|
});
|
|
449
467
|
const { written, overwritten } = yield* ActionInit.write(scaffold, {
|
|
450
468
|
cwd,
|
package/build/ActionRun.js
CHANGED
|
@@ -27,7 +27,8 @@ const failedResult = (error) => ActionRunResult.make({
|
|
|
27
27
|
entries: [],
|
|
28
28
|
duration: 0
|
|
29
29
|
}),
|
|
30
|
-
persisted: false
|
|
30
|
+
persisted: false,
|
|
31
|
+
...error._tag === "CheckFailed" ? { drift: error.drift } : {}
|
|
31
32
|
})
|
|
32
33
|
});
|
|
33
34
|
/**
|
|
@@ -39,6 +40,10 @@ const failedResult = (error) => ActionRunResult.make({
|
|
|
39
40
|
* not start or finish: no `package.json`, a config that will not load, no `[action]` table, an entry that is missing
|
|
40
41
|
* with validation off, and a file that cannot be cleaned, written or persisted.
|
|
41
42
|
*
|
|
43
|
+
* With `check`, it writes nothing and a check that finds drift is the verdict `failed` with `result.drift`; the error
|
|
44
|
+
* channel adds `CheckUnavailable` (nothing persisted to compare), `NoOutput` (`dist = false` with persisting off) and
|
|
45
|
+
* `PersistPathError` (a persist path the bundler refuses).
|
|
46
|
+
*
|
|
42
47
|
* It appends to no journal: the build and issue journals record package builds only.
|
|
43
48
|
*
|
|
44
49
|
* @public
|
|
@@ -57,16 +62,19 @@ var ActionRun = class {
|
|
|
57
62
|
if (config.action === void 0) return yield* new NotAnActionError({ cwd });
|
|
58
63
|
return yield* ActionBuilder.build({
|
|
59
64
|
cwd,
|
|
65
|
+
root,
|
|
60
66
|
config: config.action,
|
|
61
67
|
validate: input.validate,
|
|
62
68
|
persist: input.persist,
|
|
63
|
-
ci: deps.ci
|
|
69
|
+
ci: deps.ci,
|
|
70
|
+
check: input.check
|
|
64
71
|
}).pipe(Effect.map((result) => ActionRunResult.make({
|
|
65
72
|
verdict: "ok",
|
|
66
73
|
result
|
|
67
74
|
})), Effect.catchTags({
|
|
68
75
|
ValidationFailed: (error) => Effect.succeed(failedResult(error)),
|
|
69
|
-
BuildFailed: (error) => Effect.succeed(failedResult(error))
|
|
76
|
+
BuildFailed: (error) => Effect.succeed(failedResult(error)),
|
|
77
|
+
CheckFailed: (error) => Effect.succeed(failedResult(error))
|
|
70
78
|
}));
|
|
71
79
|
});
|
|
72
80
|
};
|
package/build/BuildWatch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EffectedConfigFile } from "@effected/bundler";
|
|
1
|
+
import { EffectedConfigFile, PersistTarget } from "@effected/bundler";
|
|
2
2
|
import { WorkspaceDiscovery, WorkspaceRoot } from "@effected/workspaces";
|
|
3
3
|
import { Deferred, Effect, FiberMap, FileSystem, Layer, Option, Path, PlatformError, Queue, Semaphore, Stream } from "effect";
|
|
4
4
|
import { NotAnActionError } from "./ActionRun.js";
|
|
@@ -24,7 +24,8 @@ const DEFAULT_EXCLUDES = [
|
|
|
24
24
|
"tsdoc.json",
|
|
25
25
|
".actrc",
|
|
26
26
|
".github/workflows/act-test.yml",
|
|
27
|
-
".github/actions/local"
|
|
27
|
+
".github/actions/local",
|
|
28
|
+
".action-staging"
|
|
28
29
|
];
|
|
29
30
|
const CONFIG_NAME = "effected.toml";
|
|
30
31
|
/** Discovery from `cwd`, as `BuildRun` and `ActionRun` provide it to the root search and the config load. */
|
|
@@ -38,6 +39,11 @@ const isUnder = (path, prefix) => {
|
|
|
38
39
|
const trimmed = trimExclusion(prefix);
|
|
39
40
|
return isCovered(path, prefix) || trimmed !== "" && trimmed.startsWith(`${path}/`);
|
|
40
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* An `@effected/files` `AtomicFile` temp, `.effected-<base36>.tmp`, which an action persist leaves for a moment beside
|
|
44
|
+
* `.actrc` and `act-test.yml` before renaming it into place. Never a source, so never a trigger.
|
|
45
|
+
*/
|
|
46
|
+
const ATOMIC_TEMP = /(^|\/)\.effected-[0-9a-z]+\.tmp$/;
|
|
41
47
|
const trimExclusion = (prefix) => prefix.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
42
48
|
/** Whether `path` is an excluded path or lies under it, on `/` boundaries: a top-level directory never watched. */
|
|
43
49
|
const isCovered = (path, prefix) => {
|
|
@@ -109,9 +115,14 @@ var BuildWatch = class {
|
|
|
109
115
|
if (options?.persist === false) return DEFAULT_EXCLUDES;
|
|
110
116
|
const path = yield* Path.Path;
|
|
111
117
|
const loaded = yield* loadConfig(target);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
if (Option.isNone(loaded) || loaded.value.config.action === void 0) return DEFAULT_EXCLUDES;
|
|
119
|
+
const resolved = yield* PersistTarget.resolve(loaded.value.config.action, {
|
|
120
|
+
cwd: target.cwd,
|
|
121
|
+
root: target.root
|
|
122
|
+
}).pipe(Effect.option);
|
|
123
|
+
if (Option.isNone(resolved) || !resolved.value.enabled) return DEFAULT_EXCLUDES;
|
|
124
|
+
const realCwd = yield* (yield* FileSystem.FileSystem).realPath(target.cwd).pipe(Effect.orElseSucceed(() => target.cwd));
|
|
125
|
+
return withInside(path, realCwd, [resolved.value.outputPath]);
|
|
115
126
|
});
|
|
116
127
|
/**
|
|
117
128
|
* Builds once with `Initial` after every watcher is installed, then once per settled batch of changes, for as long
|
|
@@ -236,7 +247,7 @@ var BuildWatch = class {
|
|
|
236
247
|
for (const entry of more.value) batch.add(entry);
|
|
237
248
|
}
|
|
238
249
|
const excludes = yield* options.exclude;
|
|
239
|
-
return [...batch].filter((entry) => !excludes.some((prefix) => isUnder(entry, prefix))).sort();
|
|
250
|
+
return [...batch].filter((entry) => !ATOMIC_TEMP.test(entry) && !excludes.some((prefix) => isUnder(entry, prefix))).sort();
|
|
240
251
|
});
|
|
241
252
|
const consuming = Effect.gen(function* () {
|
|
242
253
|
const armed = yield* reconcile;
|
package/build.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
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";
|
|
7
|
+
import { ActionBuildResult, ActionBuildResult as ActionBuildResult$1, ActionValidation, ActionYmlPathError, BuildIssues, BuildIssues as BuildIssues$1, BuildReport, BuildReport as BuildReport$1, BuildResult, BundleFailed, BundleResult, BundlerSeams, CheckUnavailable, CleanError, ConfigValidationError, EffectedConfigError, NoOutput, PassReport, PersistLocalError, PersistPathError, 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. */
|
|
@@ -356,6 +356,10 @@ interface ActionScaffoldInput {
|
|
|
356
356
|
readonly name: string;
|
|
357
357
|
/** What the action does, one line. */
|
|
358
358
|
readonly description: string;
|
|
359
|
+
/** Persist to the workspace root's `.github/actions/<name>` and keep no package `dist`. Omitted, false. */
|
|
360
|
+
readonly local?: boolean;
|
|
361
|
+
/** With `local`, whether to scaffold a `.gitignore` for `dist/` and `.action-staging/`. Omitted, true. */
|
|
362
|
+
readonly gitignore?: boolean;
|
|
359
363
|
}
|
|
360
364
|
/**
|
|
361
365
|
* What one `action init` was asked to do, as the flags or tool parameters said it. A name or description left out is
|
|
@@ -368,6 +372,8 @@ interface ActionInitInput {
|
|
|
368
372
|
readonly description?: string;
|
|
369
373
|
/** Replace files that already exist. */
|
|
370
374
|
readonly force: boolean;
|
|
375
|
+
/** Scaffold the local-only shape: persist to the workspace root and keep no package `dist`. Omitted, false. */
|
|
376
|
+
readonly local?: boolean;
|
|
371
377
|
}
|
|
372
378
|
/**
|
|
373
379
|
* What the process boundary supplies for `action init`.
|
|
@@ -480,6 +486,8 @@ interface ActionRunInput {
|
|
|
480
486
|
readonly validate: boolean;
|
|
481
487
|
/** Whether to copy the build locally. `persistLocal.enabled = false` turns that off too. */
|
|
482
488
|
readonly persist: boolean;
|
|
489
|
+
/** Whether to compare the build with the committed one instead of persisting it. */
|
|
490
|
+
readonly check: boolean;
|
|
483
491
|
}
|
|
484
492
|
/**
|
|
485
493
|
* What the process boundary supplies for an action build: the parts of {@link BuildRunDeps} it uses.
|
|
@@ -496,13 +504,17 @@ type ActionRunDeps = Pick<BuildRunDeps, "cwd" | "ci">;
|
|
|
496
504
|
* not start or finish: no `package.json`, a config that will not load, no `[action]` table, an entry that is missing
|
|
497
505
|
* with validation off, and a file that cannot be cleaned, written or persisted.
|
|
498
506
|
*
|
|
507
|
+
* With `check`, it writes nothing and a check that finds drift is the verdict `failed` with `result.drift`; the error
|
|
508
|
+
* channel adds `CheckUnavailable` (nothing persisted to compare), `NoOutput` (`dist = false` with persisting off) and
|
|
509
|
+
* `PersistPathError` (a persist path the bundler refuses).
|
|
510
|
+
*
|
|
499
511
|
* It appends to no journal: the build and issue journals record package builds only.
|
|
500
512
|
*
|
|
501
513
|
* @public
|
|
502
514
|
*/
|
|
503
515
|
export declare class ActionRun {
|
|
504
516
|
private constructor();
|
|
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>;
|
|
517
|
+
static readonly run: (input: ActionRunInput, deps: ActionRunDeps) => Effect.Effect<ActionRunResult, EffectedConfigError | NotAPackageError | NotAnActionError | BundleFailed | CleanError | WriteError | PersistLocalError | PersistPathError | CheckUnavailable | NoOutput | ActionYmlPathError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
506
518
|
}
|
|
507
519
|
/**
|
|
508
520
|
* Why a watched build runs: the first build, or a settled batch of changes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The effected tool's shared logic, consumed by its CLI and MCP front ends",
|
|
6
6
|
"keywords": [
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@effected/bundler": "0.
|
|
49
|
+
"@effected/bundler": "0.7.1",
|
|
50
50
|
"@effected/files": "0.3.0",
|
|
51
51
|
"@effected/jsonc": "0.25.0",
|
|
52
52
|
"@effected/jsonl": "0.19.0",
|
|
53
53
|
"@effected/kit": "0.14.0",
|
|
54
54
|
"@effected/schemastore": "0.33.1",
|
|
55
55
|
"@effected/source": "0.5.0",
|
|
56
|
-
"@effected/workspaces": "0.
|
|
56
|
+
"@effected/workspaces": "0.49.0",
|
|
57
57
|
"ajv": "8.20.0",
|
|
58
58
|
"ajv-formats": "3.0.1",
|
|
59
|
-
"effect": "4.1.
|
|
59
|
+
"effect": "4.1.5",
|
|
60
60
|
"jiti": "~2.7.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|