@effected/bundler 0.1.0 → 0.2.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/Bundler.js +126 -78
- package/README.md +3 -3
- package/action/ActionBundle.js +89 -78
- package/action/import-check.js +2 -2
- package/config/BuildConfig.js +26 -15
- package/config/EffectedConfigFile.js +12 -1
- package/config-validation/ConfigValidator.js +20 -14
- package/dts/resolved-tsconfig.js +1 -1
- package/errors.js +3 -3
- package/exe/build.js +1 -1
- package/index.d.ts +180 -480
- package/index.js +6 -7
- package/journal/BuildJournal.js +13 -14
- package/jsx/config.js +13 -20
- package/manifest/built-condition.js +120 -0
- package/manifest/emit-manifest.js +7 -2
- package/manifest/export-patterns.js +14 -16
- package/manifest/manifest-set.js +101 -0
- package/manifest/transform.js +1 -0
- package/meta/api-extractor.js +1 -1
- package/meta/{tsdoctor-config.js → bundle-config.js} +4 -4
- package/meta/{tsdoctor-manifest.js → bundle-manifest.js} +5 -5
- package/meta/{tsdoctor-source.js → bundle-source.js} +27 -15
- package/meta/config.js +1 -1
- package/meta/generate.js +19 -16
- package/meta/og-image.js +1 -1
- package/meta/og-satori.js +2 -2
- package/meta/run-pass.js +18 -11
- package/meta/tsdoc-config.js +1 -1
- package/package.json +6 -5
- package/passes/build-target-groups.js +1 -0
- package/passes/strip-maps.js +16 -15
- package/report/issues-artifact.js +10 -16
- package/report/schema.js +1 -1
- package/targets/binding.js +10 -9
- package/meta/BundleManifest.js +0 -208
- package/meta/ManifestSource.js +0 -37
package/meta/config.js
CHANGED
package/meta/generate.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BundleManifestEmitError } from "../errors.js";
|
|
2
2
|
import { runApiExtractor } from "./api-extractor.js";
|
|
3
|
-
import {
|
|
3
|
+
import { composeBundleManifest, ogImageInfoOf } from "./bundle-manifest.js";
|
|
4
|
+
import { RETIRED_MANIFEST_FILENAME } from "./bundle-source.js";
|
|
4
5
|
import { mergeApiModels } from "./merge-models.js";
|
|
5
6
|
import { resolveOgCacheSalt, writeGeneratedOgImage } from "./og-image.js";
|
|
6
7
|
import { scrubDeclarationMapsUnder } from "./scrub-declaration-maps.js";
|
|
7
8
|
import { resolvePortableTsconfig } from "./tsconfig-resolver.js";
|
|
8
9
|
import { writeTsdocConfig } from "./tsdoc-config.js";
|
|
9
|
-
import {
|
|
10
|
+
import { BUNDLE_MANIFEST_FILENAME, encodeBundleManifest } from "@effected/manifest";
|
|
10
11
|
import { Effect } from "effect";
|
|
11
12
|
import { copyFileSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
12
13
|
import { join, resolve } from "node:path";
|
|
@@ -167,27 +168,28 @@ async function generateMeta(options) {
|
|
|
167
168
|
const bundleTsconfig = join(outMetaDir, "tsconfig.json");
|
|
168
169
|
const portableTsconfig = resolvePortableTsconfig(cwd, tsconfigPath);
|
|
169
170
|
writeFileSync(bundleTsconfig, `${JSON.stringify(portableTsconfig, null, 2)}\n`, "utf-8");
|
|
170
|
-
rmSync(join(outMetaDir,
|
|
171
|
+
rmSync(join(outMetaDir, BUNDLE_MANIFEST_FILENAME), { force: true });
|
|
172
|
+
rmSync(join(outMetaDir, RETIRED_MANIFEST_FILENAME), { force: true });
|
|
171
173
|
rmSync(join(outMetaDir, "og"), {
|
|
172
174
|
recursive: true,
|
|
173
175
|
force: true
|
|
174
176
|
});
|
|
175
177
|
let manifestPath;
|
|
176
178
|
let generatedImageRelative;
|
|
177
|
-
if (options.
|
|
179
|
+
if (options.bundle !== void 0) {
|
|
178
180
|
const composeInput = {
|
|
179
|
-
config: options.
|
|
180
|
-
leaf: options.
|
|
181
|
-
project: options.
|
|
181
|
+
config: options.bundle.config,
|
|
182
|
+
leaf: options.bundle.leaf,
|
|
183
|
+
project: options.bundle.project,
|
|
182
184
|
packageName,
|
|
183
185
|
isPrivate: finalPkg.private === true,
|
|
184
|
-
targets: options.
|
|
186
|
+
targets: options.bundle.targets,
|
|
185
187
|
generatedImage: void 0,
|
|
186
188
|
repository: manifestRepositoryOf(finalPkg.repository)
|
|
187
189
|
};
|
|
188
|
-
const generate = options.
|
|
190
|
+
const generate = options.bundle.config?.openGraph?.generate;
|
|
189
191
|
if (generate !== void 0) {
|
|
190
|
-
const cacheSalt = resolveOgCacheSalt(generate, options.
|
|
192
|
+
const cacheSalt = resolveOgCacheSalt(generate, options.bundle.config?.openGraph?.cacheSalt);
|
|
191
193
|
const generated = await writeGeneratedOgImage({
|
|
192
194
|
generate,
|
|
193
195
|
info: ogImageInfoOf({
|
|
@@ -204,14 +206,14 @@ async function generateMeta(options) {
|
|
|
204
206
|
composeInput.generatedImage = generated;
|
|
205
207
|
generatedImageRelative = generated.path;
|
|
206
208
|
}
|
|
207
|
-
const manifest =
|
|
209
|
+
const manifest = composeBundleManifest(composeInput);
|
|
208
210
|
if (manifest !== void 0) {
|
|
209
|
-
const path = join(outMetaDir,
|
|
211
|
+
const path = join(outMetaDir, BUNDLE_MANIFEST_FILENAME);
|
|
210
212
|
try {
|
|
211
213
|
const encoded = await Effect.runPromise(encodeBundleManifest(manifest));
|
|
212
214
|
writeFileSync(path, `${JSON.stringify(encoded, null, 2)}\n`, "utf-8");
|
|
213
215
|
} catch (cause) {
|
|
214
|
-
throw new
|
|
216
|
+
throw new BundleManifestEmitError({
|
|
215
217
|
packageName,
|
|
216
218
|
path,
|
|
217
219
|
cause
|
|
@@ -226,8 +228,9 @@ async function generateMeta(options) {
|
|
|
226
228
|
copyFileSync(apiJsonPath, join(dest, apiJsonFilename));
|
|
227
229
|
copyFileSync(bundlePackageJson, join(dest, "package.json"));
|
|
228
230
|
copyFileSync(bundleTsconfig, join(dest, "tsconfig.json"));
|
|
229
|
-
if (manifestPath !== void 0) copyFileSync(manifestPath, join(dest,
|
|
230
|
-
else rmSync(join(dest,
|
|
231
|
+
if (manifestPath !== void 0) copyFileSync(manifestPath, join(dest, BUNDLE_MANIFEST_FILENAME));
|
|
232
|
+
else rmSync(join(dest, BUNDLE_MANIFEST_FILENAME), { force: true });
|
|
233
|
+
rmSync(join(dest, RETIRED_MANIFEST_FILENAME), { force: true });
|
|
231
234
|
rmSync(join(dest, "og"), {
|
|
232
235
|
recursive: true,
|
|
233
236
|
force: true
|
package/meta/og-image.js
CHANGED
|
@@ -20,7 +20,7 @@ var OgGenerateError = class extends Data.TaggedError("OgGenerateError") {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* The renderer an `[package.
|
|
23
|
+
* The renderer an `[package.bundle.openGraph] generate` name selects.
|
|
24
24
|
*
|
|
25
25
|
* @remarks
|
|
26
26
|
* Nothing renders here, but a build asking for an image fails now rather than after its passes when a peer is absent.
|
package/meta/og-satori.js
CHANGED
|
@@ -90,7 +90,7 @@ function card(info, colors) {
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
* Build-time Open Graph image renderers for `[package.
|
|
93
|
+
* Build-time Open Graph image renderers for `[package.bundle.openGraph] generate`.
|
|
94
94
|
*
|
|
95
95
|
* @remarks
|
|
96
96
|
* `satori()` returns the default card: project name, package name and version, tagline,
|
|
@@ -111,7 +111,7 @@ const ogImage = { satori(options = {}) {
|
|
|
111
111
|
};
|
|
112
112
|
const cacheSalt = JSON.stringify({
|
|
113
113
|
renderer: "@effected/bundler/og#satori",
|
|
114
|
-
version: "0.
|
|
114
|
+
version: "0.2.0",
|
|
115
115
|
satori: peerVersion("satori"),
|
|
116
116
|
resvg: peerVersion("@resvg/resvg-js"),
|
|
117
117
|
colors
|
package/meta/run-pass.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { resolveNextVersions } from "../changesets/next-versions.js";
|
|
2
2
|
import { deriveExportPaths } from "../entries/export-paths.js";
|
|
3
3
|
import { createEntryName } from "../entries/extract.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BundleManifestEmitError } from "../errors.js";
|
|
5
5
|
import { declarationsDirFor } from "../passes/target-groups.js";
|
|
6
|
+
import { BundleManifestSourceError, loadBundleManifestSources } from "./bundle-source.js";
|
|
6
7
|
import { normalizeMetaOptions } from "./config.js";
|
|
7
8
|
import { generateMeta } from "./generate.js";
|
|
8
9
|
import { OgGenerateError } from "./og-image.js";
|
|
9
10
|
import { rewriteMetaVersions } from "./optimistic.js";
|
|
10
|
-
import { TsdoctorSourceError, loadTsdoctorSources } from "./tsdoctor-source.js";
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
|
|
13
13
|
// src/meta/run-pass.ts
|
|
@@ -31,15 +31,15 @@ async function runMetaPass(o) {
|
|
|
31
31
|
const resolveNext = o.resolveNextVersions ?? resolveNextVersions;
|
|
32
32
|
const nextVersions = norm.optimistic ? await resolveNext(o.cwd) : void 0;
|
|
33
33
|
const manifestTransform = nextVersions ? (m) => rewriteMetaVersions(m, nextVersions.versions, o.packageName) : void 0;
|
|
34
|
-
const loadSources = o.
|
|
34
|
+
const loadSources = o.loadBundleManifestSources ?? loadBundleManifestSources;
|
|
35
35
|
let sources;
|
|
36
36
|
try {
|
|
37
37
|
sources = await loadSources(o.cwd);
|
|
38
38
|
} catch (err) {
|
|
39
|
-
if (err instanceof
|
|
39
|
+
if (err instanceof BundleManifestSourceError) for (const g of o.groups) o.collector.recordError(g.id, {
|
|
40
40
|
source: "meta",
|
|
41
41
|
level: "error",
|
|
42
|
-
code: "
|
|
42
|
+
code: "bundle-manifest-source-invalid",
|
|
43
43
|
text: err.message,
|
|
44
44
|
file: err.path
|
|
45
45
|
});
|
|
@@ -48,8 +48,15 @@ async function runMetaPass(o) {
|
|
|
48
48
|
if (sources.discoveryFailure !== void 0) for (const g of o.groups) o.collector.recordWarning(g.id, {
|
|
49
49
|
source: "meta",
|
|
50
50
|
level: "warn",
|
|
51
|
-
code: "
|
|
52
|
-
text: `Workspace discovery failed, so
|
|
51
|
+
code: "bundle-manifest-workspace-discovery-failed",
|
|
52
|
+
text: `Workspace discovery failed, so bundle.json has no project tier: ${sources.discoveryFailure}`
|
|
53
|
+
});
|
|
54
|
+
for (const path of sources.retiredSources ?? []) for (const g of o.groups) o.collector.recordWarning(g.id, {
|
|
55
|
+
source: "meta",
|
|
56
|
+
level: "warn",
|
|
57
|
+
code: "bundle-manifest-retired-source",
|
|
58
|
+
text: `${path} is no longer read; rename it to bundle.json`,
|
|
59
|
+
file: path
|
|
53
60
|
});
|
|
54
61
|
for (const g of o.groups) {
|
|
55
62
|
const targets = (o.targets ?? []).filter((t) => t.group === g.id).map((t) => ({
|
|
@@ -70,8 +77,8 @@ async function runMetaPass(o) {
|
|
|
70
77
|
tsdoc: norm.tsdoc,
|
|
71
78
|
...manifestTransform !== void 0 ? { manifestTransform } : {},
|
|
72
79
|
ci: o.ci,
|
|
73
|
-
|
|
74
|
-
config: norm.
|
|
80
|
+
bundle: {
|
|
81
|
+
config: norm.bundle,
|
|
75
82
|
leaf: sources.leaf,
|
|
76
83
|
project: sources.project,
|
|
77
84
|
targets
|
|
@@ -86,10 +93,10 @@ async function runMetaPass(o) {
|
|
|
86
93
|
code: "og-generate-failed",
|
|
87
94
|
text: err.message
|
|
88
95
|
});
|
|
89
|
-
else if (err instanceof
|
|
96
|
+
else if (err instanceof BundleManifestEmitError) o.collector.recordError(g.id, {
|
|
90
97
|
source: "meta",
|
|
91
98
|
level: "error",
|
|
92
|
-
code: "
|
|
99
|
+
code: "bundle-manifest-emit-failed",
|
|
93
100
|
text: err.message,
|
|
94
101
|
file: err.path
|
|
95
102
|
});
|
package/meta/tsdoc-config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
1
2
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { join } from "node:path";
|
|
3
|
-
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
import { StandardTags } from "@microsoft/tsdoc";
|
|
5
5
|
|
|
6
6
|
// src/meta/tsdoc-config.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The kit's build pipeline: effected.toml config, tsdown JS and declaration passes, API Extractor meta, SEA, GitHub Action bundles and build journals.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@effect/platform-node": "~4.1.2",
|
|
42
|
-
"@effected/changesets": "0.
|
|
42
|
+
"@effected/changesets": "0.2.0",
|
|
43
43
|
"@effected/config-file": "^0.26.0",
|
|
44
44
|
"@effected/env": "^0.11.0",
|
|
45
45
|
"@effected/files": "^0.2.0",
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
"@effected/images": "^0.9.0",
|
|
48
48
|
"@effected/jsonc": "^0.24.0",
|
|
49
49
|
"@effected/jsonl": "^0.18.0",
|
|
50
|
-
"@effected/
|
|
51
|
-
"@effected/
|
|
50
|
+
"@effected/manifest": "^0.1.0",
|
|
51
|
+
"@effected/npm": "^0.32.0",
|
|
52
|
+
"@effected/package-json": "^0.31.1",
|
|
52
53
|
"@effected/semver": "^0.22.0",
|
|
53
54
|
"@effected/toml": "^0.19.1",
|
|
54
55
|
"@effected/tsconfig-json": "^0.20.2",
|
|
55
56
|
"@effected/walker": "^0.26.0",
|
|
56
|
-
"@effected/workspaces": "^0.44.
|
|
57
|
+
"@effected/workspaces": "^0.44.1",
|
|
57
58
|
"@effected/yaml": "^0.29.0",
|
|
58
59
|
"@jridgewell/sourcemap-codec": "^1.6.0",
|
|
59
60
|
"@microsoft/api-extractor": "^7.60.1",
|
|
@@ -138,6 +138,7 @@ async function buildTargetGroups(options) {
|
|
|
138
138
|
targetGroup,
|
|
139
139
|
devManifest: options.devManifest,
|
|
140
140
|
drop: options.drop,
|
|
141
|
+
...options.set !== void 0 ? { set: options.set } : {},
|
|
141
142
|
sourceDir: options.cwd,
|
|
142
143
|
dual: options.dualExports ?? js.format.includes("cjs"),
|
|
143
144
|
emitDts: options.emitDts !== false,
|
package/passes/strip-maps.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { Result } from "effect";
|
|
2
|
-
import { rmSync } from "node:fs";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
1
|
+
import { Effect, FileSystem, Path, Result } from "effect";
|
|
4
2
|
import { GlobPattern, GlobPatternOptions } from "@effected/glob";
|
|
5
|
-
import {
|
|
6
|
-
import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
|
|
3
|
+
import { descend } from "@effected/walker";
|
|
7
4
|
|
|
8
5
|
// src/passes/strip-maps.ts
|
|
9
6
|
/** `.d.ts.map` / `.d.cts.map` at any depth, dot-directories included. */
|
|
@@ -23,17 +20,21 @@ const STRIPPABLE_MAPS = Result.getOrThrow(GlobPattern.compileResult("**/*.d.{ts,
|
|
|
23
20
|
* vendored tree — only the package's own emitted declarations carry maps worth stripping.
|
|
24
21
|
* @public
|
|
25
22
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const removeDeclarationMaps = Effect.fnUntraced(function* (pkgDir) {
|
|
24
|
+
const fs = yield* FileSystem.FileSystem;
|
|
25
|
+
const path = yield* Path.Path;
|
|
26
|
+
const root = path.resolve(pkgDir);
|
|
27
|
+
const maps = yield* descend(STRIPPABLE_MAPS, {
|
|
28
|
+
cwd: root,
|
|
29
29
|
prune: ["node_modules"],
|
|
30
|
-
onUnreadable: "skip"
|
|
31
|
-
...nodeWalkerSyncOps
|
|
32
|
-
})).map((rel) => {
|
|
33
|
-
const full = join(pkgDir, rel);
|
|
34
|
-
rmSync(full, { force: true });
|
|
35
|
-
return full;
|
|
30
|
+
onUnreadable: "skip"
|
|
36
31
|
});
|
|
37
|
-
|
|
32
|
+
const removed = [];
|
|
33
|
+
for (const rel of maps) {
|
|
34
|
+
yield* fs.remove(path.join(root, rel), { force: true });
|
|
35
|
+
removed.push(path.join(pkgDir, rel));
|
|
36
|
+
}
|
|
37
|
+
return removed;
|
|
38
|
+
});
|
|
38
39
|
|
|
39
40
|
export { removeDeclarationMaps };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { DiagnosticEntry } from "./schema.js";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
2
|
+
import { Clock, Effect, FileSystem, Path, Schema } from "effect";
|
|
5
3
|
|
|
6
4
|
// src/report/issues-artifact.ts
|
|
7
5
|
/**
|
|
@@ -131,25 +129,21 @@ function serializeIssues(issues) {
|
|
|
131
129
|
*
|
|
132
130
|
* @public
|
|
133
131
|
*/
|
|
134
|
-
|
|
135
|
-
const
|
|
132
|
+
const writeIssuesArtifact = Effect.fnUntraced(function* (opts) {
|
|
133
|
+
const fs = yield* FileSystem.FileSystem;
|
|
134
|
+
const path = yield* Path.Path;
|
|
135
|
+
const generatedAt = opts.now !== void 0 ? opts.now() : new Date(yield* Clock.currentTimeMillis);
|
|
136
136
|
const issues = flattenIssues(opts.reports, {
|
|
137
137
|
target: opts.target,
|
|
138
|
-
generatedAt:
|
|
138
|
+
generatedAt: generatedAt.toISOString(),
|
|
139
139
|
buildOk: opts.buildOk,
|
|
140
140
|
failure: opts.failure
|
|
141
141
|
});
|
|
142
|
-
const outPath = join(opts.cwd, "dist", opts.target, "issues.json");
|
|
143
|
-
|
|
142
|
+
const outPath = path.join(opts.cwd, "dist", opts.target, "issues.json");
|
|
143
|
+
yield* fs.makeDirectory(path.dirname(outPath), { recursive: true });
|
|
144
144
|
const tmpPath = `${outPath}.${process.pid}.tmp`;
|
|
145
|
-
|
|
146
|
-
writeFileSync(tmpPath, serializeIssues(issues), "utf8");
|
|
147
|
-
renameSync(tmpPath, outPath);
|
|
148
|
-
} catch (err) {
|
|
149
|
-
rmSync(tmpPath, { force: true });
|
|
150
|
-
throw err;
|
|
151
|
-
}
|
|
145
|
+
yield* fs.writeFileString(tmpPath, serializeIssues(issues)).pipe(Effect.andThen(fs.rename(tmpPath, outPath)), Effect.onError(() => fs.remove(tmpPath, { force: true }).pipe(Effect.ignore)));
|
|
152
146
|
return outPath;
|
|
153
|
-
}
|
|
147
|
+
});
|
|
154
148
|
|
|
155
149
|
export { BuildIssuesSchema, PlainDiagnosticSchema, flattenIssues, serializeIssues, writeIssuesArtifact };
|
package/report/schema.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Schema } from "effect";
|
|
|
5
5
|
var ReportTimings = class extends Schema.Class("ReportTimings")({ totalMs: Schema.Number }) {};
|
|
6
6
|
/**
|
|
7
7
|
* A captured warning or error, from tsdown's logger, rolldown's onLog, API Extractor, the meta
|
|
8
|
-
* pass's own sidecar work (`
|
|
8
|
+
* pass's own sidecar work (`bundle.json` sources, Open Graph generation), or an advisory finding
|
|
9
9
|
* about the build config itself (`config`, e.g. a `publishConfig.targets` set no final release reaches).
|
|
10
10
|
*
|
|
11
11
|
* @public
|
package/targets/binding.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { join } from "node:path";
|
|
1
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
3
2
|
|
|
4
3
|
// src/targets/binding.ts
|
|
5
4
|
/**
|
|
@@ -7,12 +6,14 @@ import { join } from "node:path";
|
|
|
7
6
|
*
|
|
8
7
|
* @public
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
9
|
+
const writeTargetsBinding = Effect.fnUntraced(function* (cwd, resolution) {
|
|
10
|
+
const fs = yield* FileSystem.FileSystem;
|
|
11
|
+
const path = yield* Path.Path;
|
|
12
|
+
const dir = path.join(cwd, "dist", "prod");
|
|
13
|
+
yield* fs.makeDirectory(dir, { recursive: true });
|
|
14
|
+
const file = path.join(dir, "targets.json");
|
|
15
|
+
yield* fs.writeFileString(file, `${JSON.stringify(resolution, null, " ")}\n`);
|
|
16
|
+
return file;
|
|
17
|
+
});
|
|
17
18
|
|
|
18
19
|
export { writeTargetsBinding };
|
package/meta/BundleManifest.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
// src/meta/BundleManifest.ts
|
|
4
|
-
/**
|
|
5
|
-
* The registry protocol families this reader knows how to do more than link
|
|
6
|
-
* to. `"npm"` means an npm-compatible registry — install commands and tarball
|
|
7
|
-
* fetching work against any instance of it — and `"jsr"` the jsr protocol.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* The manifest's `type` field is deliberately NOT constrained to these
|
|
11
|
-
* values: unknown future types must degrade to link-only rendering, not
|
|
12
|
-
* reject the manifest. Use {@link isKnownRegistryType} to branch.
|
|
13
|
-
*
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
const KNOWN_REGISTRY_TYPES = ["npm", "jsr"];
|
|
17
|
-
/**
|
|
18
|
-
* Whether a registry `type` value is a protocol family this reader
|
|
19
|
-
* recognizes. `false` means the registry entry should degrade to link-only
|
|
20
|
-
* rendering — it is never a validation failure.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
function isKnownRegistryType(type) {
|
|
25
|
-
return KNOWN_REGISTRY_TYPES.includes(type);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* One registry the documented package is published to.
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* `type` is the PROTOCOL FAMILY (`"npm"` covers every npm-compatible
|
|
32
|
-
* registry), `name` the human instance label, `url` the package's page on
|
|
33
|
-
* that instance. Unknown `type` values decode successfully and degrade to
|
|
34
|
-
* link-only rendering (see {@link isKnownRegistryType}).
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
const RegistryRef = Schema.Struct({
|
|
39
|
-
/** The protocol family, e.g. `"npm"` or `"jsr"`. Unknown values are accepted. */
|
|
40
|
-
type: Schema.String,
|
|
41
|
-
/** The human instance label, e.g. `"npm"` or `"Savvy Web Registry"`. */
|
|
42
|
-
name: Schema.String,
|
|
43
|
-
/** The package's URL on that registry instance. */
|
|
44
|
-
url: Schema.String
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* One Open Graph image declared by the manifest.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* Exactly ONE of `path` (a bundle-relative asset the consuming platform
|
|
51
|
-
* publishes and resolves to a URL) or `url` (an absolute external URL used
|
|
52
|
-
* verbatim) must be present — the schema enforces the XOR. `type` is a MIME
|
|
53
|
-
* type, inferred from the file extension by the resolver when omitted; `alt`
|
|
54
|
-
* has a documented inference chain (tagline → description →
|
|
55
|
-
* `"<name> API documentation"`).
|
|
56
|
-
*
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
const OpenGraphImage = Schema.Struct({
|
|
60
|
-
/** Bundle-relative asset path. Mutually exclusive with `url`. */
|
|
61
|
-
path: Schema.optionalKey(Schema.String),
|
|
62
|
-
/** Absolute external URL, used verbatim. Mutually exclusive with `path`. */
|
|
63
|
-
url: Schema.optionalKey(Schema.String),
|
|
64
|
-
/** MIME type; inferred from the extension when omitted. */
|
|
65
|
-
type: Schema.optionalKey(Schema.String),
|
|
66
|
-
/** Pixel width; 1200×630 (1.91:1) is the cross-platform safe default. */
|
|
67
|
-
width: Schema.optionalKey(Schema.Int),
|
|
68
|
-
/** Pixel height. */
|
|
69
|
-
height: Schema.optionalKey(Schema.Int),
|
|
70
|
-
/** Alt text; inferred (tagline → description → fallback) when omitted. */
|
|
71
|
-
alt: Schema.optionalKey(Schema.String)
|
|
72
|
-
}).check(Schema.makeFilter((image) => image.path === void 0 !== (image.url === void 0) ? void 0 : "exactly one of \"path\" or \"url\" must be present", { title: "openGraph image source" }));
|
|
73
|
-
/**
|
|
74
|
-
* The manifest's Open Graph block: the asset-ish pieces only — most OG tags
|
|
75
|
-
* are page-level and derive at render time in the consuming platform.
|
|
76
|
-
*
|
|
77
|
-
* @remarks
|
|
78
|
-
* Multiple images follow OG array semantics: the first declared wins, extras
|
|
79
|
-
* are alternates (e.g. a portrait 1000×1500 variant).
|
|
80
|
-
*
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
const OpenGraphConfig = Schema.Struct({
|
|
84
|
-
/** Declared images, first-wins per OG array semantics. */
|
|
85
|
-
images: Schema.optionalKey(Schema.Array(OpenGraphImage)),
|
|
86
|
-
/** Embed accent color (e.g. Discord), a CSS color string. */
|
|
87
|
-
themeColor: Schema.optionalKey(Schema.String)
|
|
88
|
-
});
|
|
89
|
-
/**
|
|
90
|
-
* A pointer to the bundle's SBOM, computed by the bundler at publish and
|
|
91
|
-
* served as a downloadable static asset.
|
|
92
|
-
*
|
|
93
|
-
* @public
|
|
94
|
-
*/
|
|
95
|
-
const SbomRef = Schema.Struct({
|
|
96
|
-
/** Bundle-relative path to the SBOM file. */
|
|
97
|
-
path: Schema.String,
|
|
98
|
-
/** SBOM format label, e.g. `"spdx-json"`. Unknown values are accepted. */
|
|
99
|
-
format: Schema.optionalKey(Schema.String)
|
|
100
|
-
});
|
|
101
|
-
/**
|
|
102
|
-
* The inherited project tier, flattened into the emitted manifest by the
|
|
103
|
-
* bundler (a fetched bundle has no parent directory to walk). Kept nested —
|
|
104
|
-
* structurally distinguishable from the leaf fields — because provenance is
|
|
105
|
-
* load-bearing for override detection.
|
|
106
|
-
*
|
|
107
|
-
* @public
|
|
108
|
-
*/
|
|
109
|
-
const ProjectIdentity = Schema.Struct({
|
|
110
|
-
/** The project display name, e.g. `"Effected"` over leaf `@effected/store`. */
|
|
111
|
-
name: Schema.optionalKey(Schema.String),
|
|
112
|
-
/** The project tagline. */
|
|
113
|
-
tagline: Schema.optionalKey(Schema.String)
|
|
114
|
-
});
|
|
115
|
-
/**
|
|
116
|
-
* The versioned `tsdoctor.json` sidecar manifest — bundle layer 3.
|
|
117
|
-
*
|
|
118
|
-
* @remarks
|
|
119
|
-
* `spec` is the only required field; every other field enriches. Unknown
|
|
120
|
-
* top-level fields are ignored on decode (additive fields are minor spec
|
|
121
|
-
* revisions) and unknown enum-ish values (registry `type`, sbom `format`)
|
|
122
|
-
* degrade gracefully instead of rejecting — an old reader must be able to
|
|
123
|
-
* consume a new bundle.
|
|
124
|
-
*
|
|
125
|
-
* @public
|
|
126
|
-
*/
|
|
127
|
-
const BundleManifest = Schema.Struct({
|
|
128
|
-
/** The integer spec version. This reader understands spec 1. */
|
|
129
|
-
spec: Schema.Literal(1),
|
|
130
|
-
/** Human display name (the npm name is dry; this one is SEO-friendly). */
|
|
131
|
-
name: Schema.optionalKey(Schema.String),
|
|
132
|
-
/** Short tagline. */
|
|
133
|
-
tagline: Schema.optionalKey(Schema.String),
|
|
134
|
-
/** Long description; overrides the package.json description when present. */
|
|
135
|
-
description: Schema.optionalKey(Schema.String),
|
|
136
|
-
/** The inherited project tier, flattened in at emit time. */
|
|
137
|
-
project: Schema.optionalKey(ProjectIdentity),
|
|
138
|
-
/** Open Graph assets. */
|
|
139
|
-
openGraph: Schema.optionalKey(OpenGraphConfig),
|
|
140
|
-
/** SBOM pointer. */
|
|
141
|
-
sbom: Schema.optionalKey(SbomRef),
|
|
142
|
-
/** Registries the package is published to. */
|
|
143
|
-
registries: Schema.optionalKey(Schema.Array(RegistryRef))
|
|
144
|
-
});
|
|
145
|
-
/**
|
|
146
|
-
* Raised when a present `tsdoctor.json` cannot be parsed or does not satisfy
|
|
147
|
-
* the {@link (BundleManifest:variable)} schema.
|
|
148
|
-
*
|
|
149
|
-
* @remarks
|
|
150
|
-
* Absence of the manifest is NEVER this error — layers enrich, never gate,
|
|
151
|
-
* so a missing sidecar is the normal case and reads as `Option.none()`.
|
|
152
|
-
*
|
|
153
|
-
* @public
|
|
154
|
-
*/
|
|
155
|
-
var BundleManifestError = class extends Schema.TaggedError()("BundleManifestError", {
|
|
156
|
-
/** The manifest file path, when the failure is tied to a file on disk. */
|
|
157
|
-
path: Schema.optionalKey(Schema.String),
|
|
158
|
-
/** The underlying failure (JSON syntax or schema decode), preserved structurally. */
|
|
159
|
-
cause: Schema.Defect()
|
|
160
|
-
}) {
|
|
161
|
-
get message() {
|
|
162
|
-
return `Invalid tsdoctor.json manifest${this.path !== void 0 ? ` at ${this.path}` : ""}`;
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Decode an unknown value into a {@link (BundleManifest:type)}.
|
|
167
|
-
*
|
|
168
|
-
* @remarks
|
|
169
|
-
* The typed boundary for manifest input that has already been parsed from
|
|
170
|
-
* JSON (plugin options, fetched payloads). File-based reading lives in
|
|
171
|
-
* `readBundle`, which routes through this after parsing.
|
|
172
|
-
*
|
|
173
|
-
* @public
|
|
174
|
-
*/
|
|
175
|
-
function decodeBundleManifest(input, path) {
|
|
176
|
-
return Schema.decodeUnknownEffect(BundleManifest)(input).pipe(Effect.mapError((cause) => new BundleManifestError({
|
|
177
|
-
...path !== void 0 ? { path } : {},
|
|
178
|
-
cause
|
|
179
|
-
})));
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* The manifest spec version this package reads and writes.
|
|
183
|
-
*
|
|
184
|
-
* @public
|
|
185
|
-
*/
|
|
186
|
-
const MANIFEST_SPEC = 1;
|
|
187
|
-
/**
|
|
188
|
-
* The sidecar manifest's file name inside a bundle folder.
|
|
189
|
-
*
|
|
190
|
-
* @public
|
|
191
|
-
*/
|
|
192
|
-
const TSDOCTOR_MANIFEST_FILENAME = "tsdoctor.json";
|
|
193
|
-
/**
|
|
194
|
-
* Encode a {@link (BundleManifest:type)} into the JSON-ready value a writer
|
|
195
|
-
* serializes as `tsdoctor.json`.
|
|
196
|
-
*
|
|
197
|
-
* @remarks
|
|
198
|
-
* The writer's boundary. Going through the schema rather than
|
|
199
|
-
* `JSON.stringify` means an emitted file is by construction what
|
|
200
|
-
* {@link decodeBundleManifest} accepts.
|
|
201
|
-
*
|
|
202
|
-
* @public
|
|
203
|
-
*/
|
|
204
|
-
function encodeBundleManifest(manifest) {
|
|
205
|
-
return Schema.encodeEffect(BundleManifest)(manifest).pipe(Effect.mapError((cause) => new BundleManifestError({ cause })));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export { BundleManifest, BundleManifestError, KNOWN_REGISTRY_TYPES, MANIFEST_SPEC, OpenGraphConfig, OpenGraphImage, ProjectIdentity, RegistryRef, SbomRef, TSDOCTOR_MANIFEST_FILENAME, decodeBundleManifest, encodeBundleManifest, isKnownRegistryType };
|
package/meta/ManifestSource.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { BundleManifest, BundleManifestError } from "./BundleManifest.js";
|
|
2
|
-
import { Effect, Schema } from "effect";
|
|
3
|
-
|
|
4
|
-
// src/meta/ManifestSource.ts
|
|
5
|
-
/**
|
|
6
|
-
* The shape an author checks in as a `tsdoctor.json` SOURCE file, at a
|
|
7
|
-
* package root (the leaf tier) or a workspace root (the project tier).
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* `BundleManifest` minus `spec` and `project`: a source file never declares
|
|
11
|
-
* its own spec version, and it never declares its inherited tier — the
|
|
12
|
-
* bundler supplies both when it flattens the hierarchy at emit time. Decoded
|
|
13
|
-
* only by writers; readers never see this shape.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
const ManifestSource = Schema.Struct({
|
|
18
|
-
name: BundleManifest.fields.name,
|
|
19
|
-
tagline: BundleManifest.fields.tagline,
|
|
20
|
-
description: BundleManifest.fields.description,
|
|
21
|
-
openGraph: BundleManifest.fields.openGraph,
|
|
22
|
-
sbom: BundleManifest.fields.sbom,
|
|
23
|
-
registries: BundleManifest.fields.registries
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* Decode an unknown value into a {@link (ManifestSource:type)}.
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
function decodeManifestSource(input, path) {
|
|
31
|
-
return Schema.decodeUnknownEffect(ManifestSource)(input).pipe(Effect.mapError((cause) => new BundleManifestError({
|
|
32
|
-
...path !== void 0 ? { path } : {},
|
|
33
|
-
cause
|
|
34
|
-
})));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { ManifestSource, decodeManifestSource };
|