@yahoo/uds-create-config 5.41.8 → 5.42.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.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `settings.build.include` leaves the build settings, and `settings.build.exclude` joins them.
3
+ *
4
+ * A system now ships every source file under its `inputDir` by default, so the list of files to ship
5
+ * that no component imports has nothing left to name: each one it could name ships without it.
6
+ * `exclude` keeps a file out instead. `up` drops a stored `include`, and `upPatch` drops it from a
7
+ * stored draft patch, a patch that wrote nothing else going with it. Nothing reads the field any
8
+ * more, so its value has nowhere to land; the files it named still ship, as every file under
9
+ * `inputDir` does.
10
+ *
11
+ * A `uds.config.ts` that still writes `include` is refused when it is evaluated, by the build
12
+ * settings' own schema, with a message saying to delete it.
13
+ */
14
+ import type { RawWireConfig, SchemaMigration } from '../framework/schema-version';
15
+ export declare const BUILD_EXCLUDE_VERSION = 20261019165323;
16
+ export declare function dropBuildInclude(json: RawWireConfig): RawWireConfig;
17
+ export declare const buildExcludeMigration: SchemaMigration;
@@ -0,0 +1,81 @@
1
+ import { isPlainObject } from "../framework/utils/field-path.js";
2
+ import { z } from "zod";
3
+ //#region src/migrations/20261019165323_build_exclude.ts
4
+ /**
5
+ * `settings.build.include` leaves the build settings, and `settings.build.exclude` joins them.
6
+ *
7
+ * A system now ships every source file under its `inputDir` by default, so the list of files to ship
8
+ * that no component imports has nothing left to name: each one it could name ships without it.
9
+ * `exclude` keeps a file out instead. `up` drops a stored `include`, and `upPatch` drops it from a
10
+ * stored draft patch, a patch that wrote nothing else going with it. Nothing reads the field any
11
+ * more, so its value has nowhere to land; the files it named still ship, as every file under
12
+ * `inputDir` does.
13
+ *
14
+ * A `uds.config.ts` that still writes `include` is refused when it is evaluated, by the build
15
+ * settings' own schema, with a message saying to delete it.
16
+ */
17
+ const BUILD_EXCLUDE_VERSION = 20261019165323;
18
+ /** A record with `key` taken out, or the record itself when it has none. */
19
+ function without(record, key) {
20
+ if (!(key in record)) return record;
21
+ const { [key]: _dropped, ...rest } = record;
22
+ return rest;
23
+ }
24
+ /** The settings body with `build.include` taken out, or the body itself when it has none. */
25
+ function settingsWithoutInclude(settings) {
26
+ if (!isPlainObject(settings.build) || !("include" in settings.build)) return settings;
27
+ return {
28
+ ...settings,
29
+ build: without(settings.build, "include")
30
+ };
31
+ }
32
+ function dropBuildInclude(json) {
33
+ const items = json.items;
34
+ if (!isPlainObject(items) || !isPlainObject(items.settings)) return json;
35
+ const item = items.settings.settings;
36
+ if (!isPlainObject(item)) return json;
37
+ const next = settingsWithoutInclude(item);
38
+ if (next === item) return json;
39
+ return {
40
+ ...json,
41
+ items: {
42
+ ...items,
43
+ settings: {
44
+ ...items.settings,
45
+ settings: next
46
+ }
47
+ }
48
+ };
49
+ }
50
+ /** The envelope this reads, loose, asserting only the item it edits. */
51
+ const before = z.looseObject({ items: z.looseObject({ settings: z.record(z.string(), z.unknown()).optional() }).optional() });
52
+ /** What it produces: no stored `build.include`. */
53
+ const after = before.refine((json) => {
54
+ const item = json.items?.settings?.settings;
55
+ return !(isPlainObject(item) && isPlainObject(item.build) && "include" in item.build);
56
+ }, { message: "no stored `settings.build.include`" });
57
+ /**
58
+ * A settings patch writes `include` three ways: in a body (`create`, `replace`, or `update` with a
59
+ * `build` record), as a field path (`update` with `build.include`), or as a member of the `build`
60
+ * section (`sub-*` with `field: 'build'`). Each loses it, and a patch left writing nothing is dropped.
61
+ */
62
+ function patchWithoutInclude(patch) {
63
+ if (patch.kind !== "settings" || !("data" in patch)) return patch;
64
+ if (!isPlainObject(patch.data)) return patch;
65
+ const data = "field" in patch ? patch.field === "build" ? without(patch.data, "include") : patch.data : without(settingsWithoutInclude(patch.data), "build.include");
66
+ if (data === patch.data) return patch;
67
+ if ((Object.keys(data).length === 0 || Object.keys(data).length === 1 && isPlainObject(data.build) && Object.keys(data.build).length === 0) && patch.operation !== "create") return null;
68
+ return {
69
+ ...patch,
70
+ data
71
+ };
72
+ }
73
+ const buildExcludeMigration = {
74
+ version: BUILD_EXCLUDE_VERSION,
75
+ up: dropBuildInclude,
76
+ upPatch: patchWithoutInclude,
77
+ fromSchema: before,
78
+ toSchema: after
79
+ };
80
+ //#endregion
81
+ export { BUILD_EXCLUDE_VERSION, buildExcludeMigration };