@effected/bundler 0.6.1 → 0.7.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.
Files changed (48) hide show
  1. package/Bundler.js +3 -3
  2. package/BundlerError.js +1 -1
  3. package/action/ActionBuilder.js +101 -23
  4. package/action/ActionBundle.js +15 -11
  5. package/action/ActionCheck.js +71 -0
  6. package/action/ActionErrors.js +68 -2
  7. package/action/ActionValidation.js +7 -4
  8. package/action/PersistLocal.js +111 -83
  9. package/action/PersistTarget.js +119 -0
  10. package/action/tree.js +25 -0
  11. package/catalog/resolve-catalogs.js +1 -1
  12. package/changesets/next-versions.js +2 -2
  13. package/config/ActionConfig.js +16 -9
  14. package/config/BuildConfig.js +1 -1
  15. package/config/EffectedConfigFile.js +3 -3
  16. package/config/plugins.js +2 -2
  17. package/config-validation/ConfigValidator.js +1 -1
  18. package/dts/bundled-siblings.js +2 -2
  19. package/dts/reexport-stub.js +1 -1
  20. package/dts/relative-imports.js +1 -1
  21. package/dts/resolved-tsconfig.js +4 -4
  22. package/exe/build.js +3 -3
  23. package/index.d.ts +229 -22
  24. package/index.js +6 -4
  25. package/internal/native-realpath.js +1 -1
  26. package/journal/BuildJournal.js +2 -2
  27. package/jsx/config.js +1 -1
  28. package/manifest/emit-manifest.js +2 -2
  29. package/manifest/manifest-set.js +1 -1
  30. package/manifest/transform.js +1 -1
  31. package/meta/api-extractor.js +5 -5
  32. package/meta/bundle-source.js +2 -2
  33. package/meta/generate.js +2 -2
  34. package/meta/og-image.js +2 -2
  35. package/meta/og-satori.js +3 -3
  36. package/meta/run-pass.js +1 -1
  37. package/meta/scrub-declaration-maps.js +1 -1
  38. package/meta/tsconfig-resolver.js +2 -2
  39. package/meta/tsdoc-config.js +1 -1
  40. package/package.json +9 -9
  41. package/passes/build-target-groups.js +1 -1
  42. package/passes/bundled-deps.js +1 -1
  43. package/passes/loose-files.js +1 -1
  44. package/passes/strip-maps.js +1 -1
  45. package/passes/sync-public.js +3 -3
  46. package/passes/target-groups.js +2 -2
  47. package/report/collector.js +1 -1
  48. package/report/issues-artifact.js +1 -1
@@ -1,6 +1,9 @@
1
- import { ActionYmlPathError, PersistLocalError } from "./ActionErrors.js";
2
- import { Effect, FileSystem, Path, Result, Schema } from "effect";
1
+ import { AtomicDirectory, AtomicFile } from "@effected/files";
3
2
  import { Yaml } from "@effected/yaml";
3
+ import { Effect, FileSystem, Option, Path, Result, Schema } from "effect";
4
+ import { ActionYmlPathError, PersistLocalError } from "./ActionErrors.js";
5
+ import { within } from "./PersistTarget.js";
6
+ import { sameBytes, walkEntries } from "./tree.js";
4
7
 
5
8
  // src/action/PersistLocal.ts
6
9
  /**
@@ -9,19 +12,22 @@ import { Yaml } from "@effected/yaml";
9
12
  * @public
10
13
  */
11
14
  var PersistLocalResult = class extends Schema.Class("PersistLocalResult")({
12
- /** Files copied because they were new or changed. */
15
+ /** Files written that were new or changed. */
13
16
  filesCopied: Schema.Number,
14
- /** Files left alone because they matched. */
17
+ /** Files that already matched the persisted copy. */
15
18
  filesSkipped: Schema.Number,
16
19
  /** Whether an act template file was generated. */
17
20
  actTemplateGenerated: Schema.Boolean,
21
+ /** Act template files not written because their real path cannot be resolved or is outside the workspace. */
22
+ actTemplateSkipped: Schema.Array(Schema.String),
18
23
  /** The local action directory. */
19
24
  outputPath: Schema.String
20
25
  }) {};
21
26
  const ACTRC_CONTENT = `--container-architecture linux/amd64
22
27
  -W .github/workflows/act-test.yml
23
28
  `;
24
- const ACT_WORKFLOW_CONTENT = `name: Local Test
29
+ /** The act workflow. The step's path is a quoted scalar (JSON is YAML), so a `#` or `: ` in it is not misread. */
30
+ const actWorkflowContent = (actionPath) => `name: Local Test
25
31
  on:
26
32
  workflow_dispatch:
27
33
 
@@ -30,57 +36,8 @@ jobs:
30
36
  runs-on: ubuntu-latest
31
37
  steps:
32
38
  - uses: actions/checkout@v7
33
- - uses: ./.github/actions/local
39
+ - uses: ${JSON.stringify(`./${actionPath}`)}
34
40
  `;
35
- const sameBytes = (a, b) => a.length === b.length && a.every((byte, index) => byte === b[index]);
36
- /** Copies `from` over `to` unless they already match, and says whether it copied. */
37
- const syncFile = Effect.fnUntraced(function* (from, to) {
38
- const fs = yield* FileSystem.FileSystem;
39
- const path = yield* Path.Path;
40
- if ((yield* fs.exists(to)) && sameBytes(yield* fs.readFile(from), yield* fs.readFile(to))) return false;
41
- yield* fs.makeDirectory(path.dirname(to), { recursive: true });
42
- yield* fs.copyFile(from, to);
43
- return true;
44
- });
45
- /** Every file under `directory`, relative to `base`. */
46
- const walk = (directory, base) => Effect.gen(function* () {
47
- const fs = yield* FileSystem.FileSystem;
48
- const path = yield* Path.Path;
49
- if (!(yield* fs.exists(directory))) return [];
50
- const files = [];
51
- for (const name of yield* fs.readDirectory(directory)) {
52
- const full = path.join(directory, name);
53
- if ((yield* fs.stat(full)).type === "Directory") files.push(...yield* walk(full, base));
54
- else files.push(path.relative(base, full));
55
- }
56
- return files;
57
- });
58
- /** Removes a file and each parent up to `root` that it leaves empty. */
59
- const removeStale = Effect.fnUntraced(function* (file, root) {
60
- const fs = yield* FileSystem.FileSystem;
61
- const path = yield* Path.Path;
62
- yield* fs.remove(file, { force: true });
63
- let parent = path.dirname(file);
64
- while (parent !== root && (yield* fs.exists(parent)) && (yield* fs.readDirectory(parent)).length === 0) {
65
- yield* fs.remove(parent, { recursive: true });
66
- parent = path.dirname(parent);
67
- }
68
- });
69
- /** Makes `to` match `from`: copies what is new or changed, and removes what `from` no longer has. */
70
- const syncDirectory = Effect.fnUntraced(function* (from, to) {
71
- const path = yield* Path.Path;
72
- const sourceFiles = yield* walk(from, from);
73
- let copied = 0;
74
- let skipped = 0;
75
- for (const file of sourceFiles) if (yield* syncFile(path.join(from, file), path.join(to, file))) copied++;
76
- else skipped++;
77
- const sources = new Set(sourceFiles);
78
- for (const file of yield* walk(to, to)) if (!sources.has(file)) yield* removeStale(path.join(to, file), to);
79
- return {
80
- copied,
81
- skipped
82
- };
83
- });
84
41
  /** Fails when a `runs` path in the persisted `action.yml` names no persisted file. */
85
42
  const checkRunsPaths = Effect.fnUntraced(function* (actionYml, outputPath) {
86
43
  const fs = yield* FileSystem.FileSystem;
@@ -105,14 +62,46 @@ const checkRunsPaths = Effect.fnUntraced(function* (actionYml, outputPath) {
105
62
  });
106
63
  }
107
64
  });
108
- /** Writes `content` at `file` unless the file exists, and says whether it wrote. */
109
- const writeIfAbsent = Effect.fnUntraced(function* (file, content) {
65
+ /** The entry's own type, without following a link; `None` when nothing is there. */
66
+ const entryType = (file) => Effect.gen(function* () {
67
+ return yield* (yield* FileSystem.FileSystem).lstat(file).pipe(Effect.map((info) => Option.some(info.type)), Effect.catchTag("PlatformError", (error) => error.reason._tag === "NotFound" ? Effect.succeed(Option.none()) : Effect.fail(error)));
68
+ });
69
+ /**
70
+ * Where `file` really lands: its deepest existing ancestor realpathed, with the missing tail put back, as
71
+ * `PersistTarget.resolve` does for the output path. `None` when that ancestor cannot be realpathed (a dangling link).
72
+ */
73
+ const realDestination = Effect.fnUntraced(function* (file) {
74
+ const fs = yield* FileSystem.FileSystem;
75
+ const path = yield* Path.Path;
76
+ let existing = path.dirname(file);
77
+ const tail = [path.basename(file)];
78
+ while (existing !== path.dirname(existing) && Option.isNone(yield* entryType(existing))) {
79
+ tail.unshift(path.basename(existing));
80
+ existing = path.dirname(existing);
81
+ }
82
+ const real = yield* Effect.option(fs.realPath(existing));
83
+ return Option.map(real, (directory) => path.join(directory, ...tail));
84
+ });
85
+ /**
86
+ * Writes `content` at `file` when nothing is there, never through a link. Any entry at `file`, a dangling link
87
+ * included, is present and not ours. A `file` whose real path leaves `root` is not written.
88
+ */
89
+ const writeTemplate = Effect.fnUntraced(function* (file, content, root) {
110
90
  const fs = yield* FileSystem.FileSystem;
111
91
  const path = yield* Path.Path;
112
- if (yield* fs.exists(file)) return false;
113
- yield* fs.makeDirectory(path.dirname(file), { recursive: true });
114
- yield* fs.writeFileString(file, content);
115
- return true;
92
+ const destination = yield* realDestination(file);
93
+ if (Option.isNone(destination) || !within(path, root, destination.value)) return "outside";
94
+ if (Option.isSome(yield* entryType(destination.value))) return "present";
95
+ yield* fs.makeDirectory(path.dirname(destination.value), { recursive: true });
96
+ yield* AtomicFile.write(destination.value, content, { links: "replace" });
97
+ return "written";
98
+ });
99
+ /** The regular files of a persisted `dist`, by relative path; a link, or a `dist` that is one, is never read through. */
100
+ const persistedFiles = Effect.fnUntraced(function* (dist) {
101
+ const types = yield* entryType(dist);
102
+ if (Option.isNone(types) || types.value !== "Directory") return /* @__PURE__ */ new Set();
103
+ const entries = yield* walkEntries(dist, dist);
104
+ return new Set(entries.filter((entry) => !entry.symlink).map((entry) => entry.path));
116
105
  });
117
106
  /**
118
107
  * Copies an action's build to a local action directory, for testing with nektos/act.
@@ -122,24 +111,34 @@ const writeIfAbsent = Effect.fnUntraced(function* (file, content) {
122
111
  var PersistLocal = class {
123
112
  constructor() {}
124
113
  /**
125
- * Makes `persistLocal.path` hold the action's `action.yml` and `dist/`, and generates the act template.
114
+ * Makes the resolved output directory hold the action's `action.yml` and `dist/`, and generates the act template.
126
115
  *
127
116
  * @remarks
128
- * It writes nothing when `persistLocal.enabled` is false. Files that match are left alone, and files the source no
129
- * longer has are removed. A `.actrc` and `.github/workflows/act-test.yml` that already exist are kept. A `runs` path
130
- * in `action.yml` that names no persisted file fails {@link ActionYmlPathError}.
117
+ * It writes nothing when the target is not enabled. `dist/` is persisted first, so a failed dist write never leaves
118
+ * a new `action.yml` beside the old `dist/`. It is replaced whole with `AtomicDirectory.write`, from `distDir`: the
119
+ * package's own `dist/`, or the staging directory when the package keeps none. A reader sees the old tree, the new
120
+ * one, or briefly none, never a partial one; a failure between its two renames leaves `dist` absent until the next
121
+ * persist restores it. A failed removal of the old tree after the new one is live only logs a warning. `action.yml`
122
+ * is then written with `AtomicFile.write`. A symlink at either path is replaced, never followed. Everything else in the persisted
123
+ * directory, a committed README for one, is left alone. `filesCopied` and `filesSkipped` count the files that were
124
+ * new or changed and those that already matched. The act template is rooted at `target.actRoot`, and its step uses
125
+ * the persisted directory relative to it. A `.actrc` or `.github/workflows/act-test.yml` is written only when nothing
126
+ * is at its path, a dangling link included, and only when its real path (its deepest existing ancestor realpathed)
127
+ * stays inside the workspace; one that would leave it is skipped with a warning and listed in `actTemplateSkipped`.
128
+ * A `runs` path in `action.yml` that names no persisted file fails {@link ActionYmlPathError}.
131
129
  *
132
- * @param options - `cwd` is the action's directory.
130
+ * @param target - Where to persist, from {@link PersistTarget.resolve}.
131
+ * @param options - `cwd` is the action's directory and `distDir` is where its bundles are.
133
132
  */
134
- static persist = Effect.fn("PersistLocal.persist")(function* (config, options) {
133
+ static persist = Effect.fn("PersistLocal.persist")(function* (target, options) {
135
134
  const fs = yield* FileSystem.FileSystem;
136
135
  const path = yield* Path.Path;
137
- const { enabled, actTemplate } = config.persistLocal;
138
- const outputPath = path.resolve(options.cwd, config.persistLocal.path);
136
+ const { enabled, actTemplate, outputPath } = target;
139
137
  if (!enabled) return PersistLocalResult.make({
140
138
  filesCopied: 0,
141
139
  filesSkipped: 0,
142
140
  actTemplateGenerated: false,
141
+ actTemplateSkipped: [],
143
142
  outputPath
144
143
  });
145
144
  const failingAt = (at) => Effect.mapError((cause) => new PersistLocalError({
@@ -149,35 +148,64 @@ var PersistLocal = class {
149
148
  yield* fs.makeDirectory(outputPath, { recursive: true }).pipe(failingAt(outputPath));
150
149
  let filesCopied = 0;
151
150
  let filesSkipped = 0;
152
- const actionYml = path.resolve(options.cwd, "action.yml");
153
- const persistedActionYml = path.resolve(outputPath, "action.yml");
154
- if (yield* fs.exists(actionYml).pipe(failingAt(actionYml))) {
155
- if (yield* syncFile(actionYml, persistedActionYml).pipe(failingAt(actionYml))) filesCopied++;
156
- else filesSkipped++;
157
- } else yield* fs.remove(persistedActionYml, { force: true }).pipe(failingAt(persistedActionYml));
158
- const dist = path.resolve(options.cwd, "dist");
151
+ const dist = options.distDir;
159
152
  if (yield* Effect.gen(function* () {
160
153
  return (yield* fs.exists(dist)) && (yield* fs.stat(dist)).type === "Directory";
161
154
  }).pipe(failingAt(dist))) {
162
- const synced = yield* syncDirectory(dist, path.resolve(outputPath, "dist")).pipe(failingAt(dist));
163
- filesCopied += synced.copied;
164
- filesSkipped += synced.skipped;
155
+ const persistedDist = path.resolve(outputPath, "dist");
156
+ const files = yield* Effect.gen(function* () {
157
+ const before = yield* persistedFiles(persistedDist);
158
+ const read = [];
159
+ for (const entry of yield* walkEntries(dist, dist)) {
160
+ const bytes = yield* fs.readFile(path.join(dist, entry.path));
161
+ if (before.has(entry.path) && sameBytes(bytes, yield* fs.readFile(path.join(persistedDist, entry.path)))) filesSkipped++;
162
+ else filesCopied++;
163
+ read.push([entry.path, bytes]);
164
+ }
165
+ return read;
166
+ }).pipe(failingAt(dist));
167
+ yield* AtomicDirectory.write(persistedDist, files).pipe(Effect.catchTag("AtomicDirectoryError", (cause) => cause.operation === "cleanup" ? Effect.logWarning(`Persisted ${persistedDist}, but could not remove the old tree: ${cause.message}`) : Effect.fail(new PersistLocalError({
168
+ path: persistedDist,
169
+ cause
170
+ }))));
165
171
  }
172
+ const actionYml = path.resolve(options.cwd, "action.yml");
173
+ const persistedActionYml = path.resolve(outputPath, "action.yml");
174
+ if (yield* fs.exists(actionYml).pipe(failingAt(actionYml))) {
175
+ if (yield* Effect.gen(function* () {
176
+ const types = yield* entryType(persistedActionYml);
177
+ if (Option.isNone(types) || types.value !== "File") return false;
178
+ return sameBytes(yield* fs.readFile(actionYml), yield* fs.readFile(persistedActionYml));
179
+ }).pipe(failingAt(actionYml))) filesSkipped++;
180
+ else {
181
+ const content = yield* fs.readFile(actionYml).pipe(failingAt(actionYml));
182
+ yield* AtomicFile.write(persistedActionYml, content, { links: "replace" }).pipe(failingAt(actionYml));
183
+ filesCopied++;
184
+ }
185
+ } else yield* fs.remove(persistedActionYml, { force: true }).pipe(failingAt(persistedActionYml));
166
186
  yield* checkRunsPaths(persistedActionYml, outputPath).pipe(Effect.catchTag("PlatformError", (cause) => Effect.fail(new PersistLocalError({
167
187
  path: persistedActionYml,
168
188
  cause
169
189
  }))));
170
190
  let actTemplateGenerated = false;
191
+ const actTemplateSkipped = [];
171
192
  if (actTemplate) {
172
- const actrc = path.resolve(options.cwd, ".actrc");
173
- const workflow = path.resolve(options.cwd, ".github/workflows/act-test.yml");
174
- if (yield* writeIfAbsent(actrc, ACTRC_CONTENT).pipe(failingAt(actrc))) actTemplateGenerated = true;
175
- if (yield* writeIfAbsent(workflow, ACT_WORKFLOW_CONTENT).pipe(failingAt(workflow))) actTemplateGenerated = true;
193
+ const actionPath = path.relative(target.actRoot, outputPath).split(path.sep).join("/");
194
+ const templates = [[path.resolve(target.actRoot, ".actrc"), ACTRC_CONTENT], [path.resolve(target.actRoot, ".github/workflows/act-test.yml"), actWorkflowContent(actionPath)]];
195
+ for (const [file, content] of templates) {
196
+ const outcome = yield* writeTemplate(file, content, target.root).pipe(failingAt(file));
197
+ if (outcome === "written") actTemplateGenerated = true;
198
+ if (outcome === "outside") {
199
+ actTemplateSkipped.push(file);
200
+ yield* Effect.logWarning(`Skipped the act template ${file}: it cannot be resolved or is outside the workspace`);
201
+ }
202
+ }
176
203
  }
177
204
  return PersistLocalResult.make({
178
205
  filesCopied,
179
206
  filesSkipped,
180
207
  actTemplateGenerated,
208
+ actTemplateSkipped,
181
209
  outputPath
182
210
  });
183
211
  });
@@ -0,0 +1,119 @@
1
+ import { Effect, FileSystem, Option, Path, Schema } from "effect";
2
+ import { PersistPathError } from "./ActionErrors.js";
3
+
4
+ // src/action/PersistTarget.ts
5
+ /**
6
+ * Where an action's build is persisted, with every path absolute.
7
+ *
8
+ * @public
9
+ */
10
+ var ResolvedPersist = class extends Schema.Class("ResolvedPersist")({
11
+ /** Whether the build is persisted at all. */
12
+ enabled: Schema.Boolean,
13
+ /** What the persist path was relative to. */
14
+ base: Schema.Literals(["package", "workspace"]),
15
+ /** The persisted action directory. */
16
+ outputPath: Schema.String,
17
+ /** Whether the package's own `dist/` is kept. */
18
+ keepDist: Schema.Boolean,
19
+ /** The scratch directory a build stages into. */
20
+ stagingDir: Schema.String,
21
+ /** Whether the act boilerplate is generated. */
22
+ actTemplate: Schema.Boolean,
23
+ /** The directory the act boilerplate is rooted at: the package under `"package"`, the workspace under `"workspace"`. */
24
+ actRoot: Schema.String,
25
+ /** The real workspace root, which every file a persist writes must stay inside. */
26
+ root: Schema.String
27
+ }) {};
28
+ const STAGING = ".action-staging";
29
+ /**
30
+ * Whether `child` is `parent` or lies below it, by the platform's own rules: `resolveWithin` refuses a relative path
31
+ * that climbs out with `..` and its separator, and an absolute one such as another drive's.
32
+ *
33
+ * @internal
34
+ */
35
+ const within = (path, parent, child) => Option.isSome(path.resolveWithin(parent, path.relative(parent, child)));
36
+ /**
37
+ * Resolves `[action.persistLocal]` against a package and its workspace root.
38
+ *
39
+ * @public
40
+ */
41
+ var PersistTarget = class {
42
+ /** The staging directory's name, under the package. */
43
+ static STAGING = STAGING;
44
+ /**
45
+ * Resolves the persist target, realpathing `cwd` and `root` as `ActionBundle.build` does, and the output path's
46
+ * deepest existing ancestor, so the returned `outputPath` is the real directory a persist writes to.
47
+ *
48
+ * @remarks
49
+ * Fails with `PersistPathError` when the path leaves the workspace, when a workspace-based path lands inside the
50
+ * package, when a package-based path lands in its `dist` or its staging directory, when it is, or contains, the
51
+ * package (which includes the workspace root), when it is or lies inside another package (any directory below the
52
+ * root holding a `package.json`), or when `dist = false` leaves nothing persisted.
53
+ *
54
+ * @param config - The action's config.
55
+ * @param options - The package directory and the workspace root.
56
+ */
57
+ static resolve = (config, options) => Effect.gen(function* () {
58
+ const fs = yield* FileSystem.FileSystem;
59
+ const path = yield* Path.Path;
60
+ const { enabled, base, dist } = config.persistLocal;
61
+ if (!dist && !enabled) return yield* new PersistPathError({
62
+ path: config.persistLocal.path ?? "",
63
+ reason: "dist-without-persist"
64
+ });
65
+ const real = (requested) => {
66
+ const resolved = path.resolve(requested);
67
+ return fs.realPath(resolved).pipe(Effect.orElseSucceed(() => resolved));
68
+ };
69
+ const cwd = yield* real(options.cwd);
70
+ const root = yield* real(options.root);
71
+ const fallback = base === "package" ? ".github/actions/local" : `.github/actions/${path.basename(cwd)}`;
72
+ const configured = config.persistLocal.path ?? fallback;
73
+ let existing = path.resolve(base === "package" ? cwd : root, configured);
74
+ const tail = [];
75
+ while (existing !== path.dirname(existing) && !(yield* fs.exists(existing).pipe(Effect.orElseSucceed(() => false)))) {
76
+ tail.unshift(path.basename(existing));
77
+ existing = path.dirname(existing);
78
+ }
79
+ const outputPath = path.join(yield* real(existing), ...tail);
80
+ if (!within(path, root, outputPath)) return yield* new PersistPathError({
81
+ path: outputPath,
82
+ reason: "outside-workspace"
83
+ });
84
+ if (base === "workspace" && within(path, cwd, outputPath)) return yield* new PersistPathError({
85
+ path: outputPath,
86
+ reason: "inside-package"
87
+ });
88
+ if (base === "package") {
89
+ for (const owned of ["dist", STAGING]) if (within(path, path.join(cwd, owned), outputPath)) return yield* new PersistPathError({
90
+ path: outputPath,
91
+ reason: "inside-package"
92
+ });
93
+ }
94
+ if (within(path, outputPath, cwd)) return yield* new PersistPathError({
95
+ path: outputPath,
96
+ reason: "contains-package"
97
+ });
98
+ for (let dir = outputPath; dir !== root && dir !== path.dirname(dir); dir = path.dirname(dir)) {
99
+ if (dir === cwd) break;
100
+ if (yield* fs.exists(path.join(dir, "package.json")).pipe(Effect.orElseSucceed(() => false))) return yield* new PersistPathError({
101
+ path: outputPath,
102
+ reason: "inside-other-package",
103
+ packageDir: dir
104
+ });
105
+ }
106
+ return ResolvedPersist.make({
107
+ enabled,
108
+ base,
109
+ outputPath,
110
+ keepDist: dist,
111
+ stagingDir: path.join(cwd, STAGING),
112
+ actTemplate: config.persistLocal.actTemplate ?? base === "package",
113
+ actRoot: base === "package" ? cwd : root,
114
+ root
115
+ });
116
+ });
117
+ };
118
+
119
+ export { PersistTarget, ResolvedPersist, within };
package/action/tree.js ADDED
@@ -0,0 +1,25 @@
1
+ import { Effect, FileSystem, Path } from "effect";
2
+
3
+ // src/action/tree.ts
4
+ const sameBytes = (a, b) => a.length === b.length && a.every((byte, index) => byte === b[index]);
5
+ /** Every file and symlink under `directory`, relative to `base`. Links are never followed, so the walk stays inside. */
6
+ const walkEntries = (directory, base) => Effect.gen(function* () {
7
+ const fs = yield* FileSystem.FileSystem;
8
+ const path = yield* Path.Path;
9
+ if (!(yield* fs.exists(directory))) return [];
10
+ const entries = [];
11
+ for (const name of yield* fs.readDirectory(directory)) {
12
+ const full = path.join(directory, name);
13
+ const { type } = yield* fs.lstat(full);
14
+ if (type === "Directory") entries.push(...yield* walkEntries(full, base));
15
+ else entries.push({
16
+ path: path.relative(base, full),
17
+ symlink: type === "SymbolicLink"
18
+ });
19
+ }
20
+ return entries;
21
+ });
22
+ /** Every file under `directory`, relative to `base`. A symlink counts as one file and is never followed. */
23
+ const walk = (directory, base) => Effect.map(walkEntries(directory, base), (entries) => entries.map((entry) => entry.path));
24
+
25
+ export { sameBytes, walk, walkEntries };
@@ -1,6 +1,6 @@
1
- import { Effect } from "effect";
2
1
  import { Manifest } from "@effected/npm";
3
2
  import { Workspaces } from "@effected/workspaces";
3
+ import { Effect } from "effect";
4
4
 
5
5
  // src/catalog/resolve-catalogs.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { Effect } from "effect";
2
- import { WorkspaceDiscovery, Workspaces } from "@effected/workspaces";
3
1
  import { ReleasePlan } from "@effected/changesets";
2
+ import { WorkspaceDiscovery, Workspaces } from "@effected/workspaces";
3
+ import { Effect } from "effect";
4
4
 
5
5
  // src/changesets/next-versions.ts
6
6
  /**
@@ -148,16 +148,23 @@ var ActionPersistLocalOptions = class extends Schema.Class("ActionPersistLocalOp
148
148
  description: "Whether to copy the build output locally.",
149
149
  default: true
150
150
  }).pipe(Schema.withDecodingDefaultKey(Effect.succeed(true))),
151
- /** The local action directory, relative to the package. */
152
- path: Schema.String.annotate({
153
- description: "The local action directory, relative to the package.",
154
- default: ".github/actions/local"
155
- }).pipe(Schema.withDecodingDefaultKey(Effect.succeed(".github/actions/local"))),
156
- /** Whether to generate the act boilerplate, `.actrc` and `act-test.yml`, when those files do not exist. */
157
- actTemplate: Schema.Boolean.annotate({
158
- description: "Whether to generate the act boilerplate, .actrc and act-test.yml, when those files do not exist.",
151
+ /**
152
+ * Where the persisted action lives: relative to the package under `base = "package"`, to the workspace root under
153
+ * `base = "workspace"`.
154
+ */
155
+ base: Schema.Literals(["package", "workspace"]).annotate({
156
+ description: "What the persist path is relative to: \"package\" (the package directory) or \"workspace\" (the workspace root).",
157
+ default: "package"
158
+ }).pipe(Schema.withDecodingDefaultKey(Effect.succeed("package"))),
159
+ /** The persisted action directory. Absent, `.github/actions/local` under the package or `.github/actions/<name>` under the workspace. */
160
+ path: Schema.optionalKey(Schema.String.annotate({ description: "The persisted action directory. Absent: .github/actions/local under the package base, .github/actions/<package directory name> under the workspace base." })),
161
+ /** Whether the build also stays in the package's own `dist/`. */
162
+ dist: Schema.Boolean.annotate({
163
+ description: "Whether the build also stays in the package's own dist/. false needs persistLocal.enabled.",
159
164
  default: true
160
- }).pipe(Schema.withDecodingDefaultKey(Effect.succeed(true)))
165
+ }).pipe(Schema.withDecodingDefaultKey(Effect.succeed(true))),
166
+ /** Whether to generate the act boilerplate, `.actrc` and `act-test.yml`, when those files do not exist. */
167
+ actTemplate: Schema.optionalKey(Schema.Boolean.annotate({ description: "Whether to generate the act boilerplate, .actrc and act-test.yml, when those files do not exist. Absent: true under the package base, false under the workspace base." }))
161
168
  }).annotate({
162
169
  title: "Local action copy",
163
170
  description: "The local copy of the action's build for testing with nektos/act, the [action.persistLocal] table."
@@ -1,5 +1,5 @@
1
- import { ActionConfig } from "./ActionConfig.js";
2
1
  import { Effect, Schema } from "effect";
2
+ import { ActionConfig } from "./ActionConfig.js";
3
3
 
4
4
  // src/config/BuildConfig.ts
5
5
  /**
@@ -1,9 +1,9 @@
1
+ import { TomlCodec } from "@effected/config-file/toml";
2
+ import { WorkspaceDiscovery } from "@effected/workspaces";
3
+ import { Effect, FileSystem, Path, Predicate, Schema, SchemaIssue } from "effect";
1
4
  import { causeMessage } from "../internal/causeMessage.js";
2
5
  import { EffectedConfig, PackageConfig } from "./BuildConfig.js";
3
6
  import { merge } from "./merge.js";
4
- import { Effect, FileSystem, Path, Predicate, Schema, SchemaIssue } from "effect";
5
- import { WorkspaceDiscovery } from "@effected/workspaces";
6
- import { TomlCodec } from "@effected/config-file/toml";
7
7
 
8
8
  // src/config/EffectedConfigFile.ts
9
9
  /** Root tier candidates, first found wins. */
package/config/plugins.js CHANGED
@@ -1,7 +1,7 @@
1
- import { causeMessage } from "../internal/causeMessage.js";
2
- import { Effect, Predicate, Schema } from "effect";
3
1
  import { resolve } from "node:path";
2
+ import { Effect, Predicate, Schema } from "effect";
4
3
  import { createJiti } from "jiti";
4
+ import { causeMessage } from "../internal/causeMessage.js";
5
5
 
6
6
  // src/config/plugins.ts
7
7
  /**
@@ -1,8 +1,8 @@
1
+ import { Context, Effect, FileSystem, Layer } from "effect";
1
2
  import { ConfigValidationError } from "../errors.js";
2
3
  import { normalizeExeOptions } from "../exe/config.js";
3
4
  import { normalizeLooseFiles } from "../passes/loose-files.js";
4
5
  import { resolveTargets } from "../targets/resolve-targets.js";
5
- import { Context, Effect, FileSystem, Layer } from "effect";
6
6
 
7
7
  // src/config-validation/ConfigValidator.ts
8
8
  const VALID_SYNTAX_KINDS = /* @__PURE__ */ new Set([
@@ -1,7 +1,7 @@
1
+ import { WorkspaceRoot } from "@effected/workspaces";
2
+ import { Effect, FileSystem, Path } from "effect";
1
3
  import { ConfigValidationError } from "../errors.js";
2
4
  import { existsLikeNode } from "../internal/exists.js";
3
- import { Effect, FileSystem, Path } from "effect";
4
- import { WorkspaceRoot } from "@effected/workspaces";
5
5
 
6
6
  // src/dts/bundled-siblings.ts
7
7
  /** The package a `bundledPackages` entry belongs to: an entry may name a subpath, since tsdown matches them exactly. */
@@ -1,5 +1,5 @@
1
- import { withParsedSource } from "./parse.js";
2
1
  import { ModifierFlags, isBindingElement, isClassDeclaration, isEnumDeclaration, isExportDeclaration, isFunctionDeclaration, isIdentifier, isInterfaceDeclaration, isModuleDeclaration, isNamedExports, isNamespaceExport, isTypeAliasDeclaration, isVariableStatement } from "typescript/ast";
2
+ import { withParsedSource } from "./parse.js";
3
3
 
4
4
  // src/dts/reexport-stub.ts
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { withParsedSource } from "./parse.js";
2
1
  import { isExportDeclaration, isExternalModuleReference, isImportDeclaration, isImportEqualsDeclaration, isImportTypeNode, isLiteralTypeNode, isStringLiteral } from "typescript/ast";
2
+ import { withParsedSource } from "./parse.js";
3
3
 
4
4
  // src/dts/relative-imports.ts
5
5
  const isRelative = (s) => s.startsWith("./") || s.startsWith("../");
@@ -1,10 +1,10 @@
1
- import { existsLikeNode } from "../internal/exists.js";
2
- import { nativeRealPath } from "../internal/native-realpath.js";
3
- import { Effect, FileSystem, Path, Result } from "effect";
4
- import { tmpdir } from "node:os";
5
1
  import { createHash } from "node:crypto";
2
+ import { tmpdir } from "node:os";
6
3
  import { GlobPattern, GlobPatternOptions } from "@effected/glob";
7
4
  import { TsconfigLoader } from "@effected/tsconfig-json";
5
+ import { Effect, FileSystem, Path, Result } from "effect";
6
+ import { existsLikeNode } from "../internal/exists.js";
7
+ import { nativeRealPath } from "../internal/native-realpath.js";
8
8
 
9
9
  // src/dts/resolved-tsconfig.ts
10
10
  /**
package/exe/build.js CHANGED
@@ -1,9 +1,9 @@
1
- import { buildMetricsPlugin } from "../report/metrics-plugin.js";
2
- import { createTimer } from "../report/timer.js";
3
- import { createTsdownLogger } from "../report/tsdown-logger.js";
4
1
  import { mkdtempSync, rmSync } from "node:fs";
5
2
  import { tmpdir } from "node:os";
6
3
  import { join } from "node:path";
4
+ import { buildMetricsPlugin } from "../report/metrics-plugin.js";
5
+ import { createTimer } from "../report/timer.js";
6
+ import { createTsdownLogger } from "../report/tsdown-logger.js";
7
7
 
8
8
  // src/exe/build.ts
9
9
  /**