@r_masseater/msch 0.54.0 → 0.57.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 (70) hide show
  1. package/README.md +18 -18
  2. package/dist/app-B22Gq0no.mjs +2120 -0
  3. package/dist/app-B22Gq0no.mjs.map +1 -0
  4. package/dist/cargo-inputs.d.mts +1 -1
  5. package/dist/cargo-inputs.mjs +4 -9
  6. package/dist/cargo-inputs.mjs.map +1 -1
  7. package/dist/changed.mjs +90 -19
  8. package/dist/changed.mjs.map +1 -1
  9. package/dist/{check-upstream-exits-DYxWDyHC.mjs → check-upstream-exits-DsBS7bui.mjs} +2 -2
  10. package/dist/check-upstream-exits-DsBS7bui.mjs.map +1 -0
  11. package/dist/cli.mjs +469 -385
  12. package/dist/cli.mjs.map +1 -1
  13. package/dist/config.d.mts +1 -1
  14. package/dist/config.mjs +3 -2
  15. package/dist/config.mjs.map +1 -1
  16. package/dist/credential-broker-D8sFyowJ.mjs +105 -0
  17. package/dist/credential-broker-D8sFyowJ.mjs.map +1 -0
  18. package/dist/decision-rules.d.mts +1 -1
  19. package/dist/decision-rules.mjs +1 -1
  20. package/dist/{define-lint-preset-CWEkZVIC.mjs → define-lint-preset-DeLIlDuA.mjs} +7 -634
  21. package/dist/define-lint-preset-DeLIlDuA.mjs.map +1 -0
  22. package/dist/{dependencies-DCJv7YcW.mjs → dependencies-CbvZost8.mjs} +11 -7
  23. package/dist/dependencies-CbvZost8.mjs.map +1 -0
  24. package/dist/exits.mjs +4 -5
  25. package/dist/exits.mjs.map +1 -1
  26. package/dist/{index-BeH2yfX6.d.mts → index-Cwnhs7VE.d.mts} +4 -51
  27. package/dist/library.d.mts +18 -0
  28. package/dist/library.mjs +28 -0
  29. package/dist/library.mjs.map +1 -0
  30. package/dist/lint-rules.mjs +243 -40
  31. package/dist/lint-rules.mjs.map +1 -1
  32. package/dist/lint.d.mts +2 -2
  33. package/dist/lint.mjs +1 -1
  34. package/dist/locked-inputs-DMSoGCa-.mjs +20 -0
  35. package/dist/locked-inputs-DMSoGCa-.mjs.map +1 -0
  36. package/dist/locked-inputs.d.mts +2 -3
  37. package/dist/locked-inputs.mjs +1 -20
  38. package/dist/oxlint.mjs +29 -14
  39. package/dist/oxlint.mjs.map +1 -1
  40. package/dist/{package-LeBO9czg.mjs → package-DZbqpZfs.mjs} +6 -6
  41. package/dist/package-DZbqpZfs.mjs.map +1 -0
  42. package/dist/{problem-CzOlOb5f.mjs → problem-Q4Zyi4PR.mjs} +10 -6
  43. package/dist/problem-Q4Zyi4PR.mjs.map +1 -0
  44. package/dist/{project-C4uzq7_4.mjs → project-CIY_lNiT.mjs} +36 -14
  45. package/dist/project-CIY_lNiT.mjs.map +1 -0
  46. package/dist/publish.mjs +625 -338
  47. package/dist/publish.mjs.map +1 -1
  48. package/dist/runtime-LT40e_l3.mjs +28 -0
  49. package/dist/runtime-LT40e_l3.mjs.map +1 -0
  50. package/dist/{syntax-3AJkpCcs.mjs → syntax-BNRNY74H.mjs} +13 -4
  51. package/dist/syntax-BNRNY74H.mjs.map +1 -0
  52. package/dist/wake.d.mts +1 -0
  53. package/dist/wake.mjs +25 -0
  54. package/dist/wake.mjs.map +1 -0
  55. package/dist/workspace-settings.mjs +5 -5
  56. package/dist/workspace-settings.mjs.map +1 -1
  57. package/package.json +29 -22
  58. package/skills/{publishing → msch-publishing}/SKILL.md +8 -2
  59. package/skills/{repository-config → msch-repository-config}/SKILL.md +5 -2
  60. package/skills/{workspace-settings → msch-workspace-settings}/SKILL.md +4 -3
  61. package/dist/check-upstream-exits-DYxWDyHC.mjs.map +0 -1
  62. package/dist/define-lint-preset-CWEkZVIC.mjs.map +0 -1
  63. package/dist/dependencies-DCJv7YcW.mjs.map +0 -1
  64. package/dist/locked-inputs.mjs.map +0 -1
  65. package/dist/package-LeBO9czg.mjs.map +0 -1
  66. package/dist/problem-CzOlOb5f.mjs.map +0 -1
  67. package/dist/project-C4uzq7_4.mjs.map +0 -1
  68. package/dist/runtime-DFsdNYI0.mjs +0 -29
  69. package/dist/runtime-DFsdNYI0.mjs.map +0 -1
  70. package/dist/syntax-3AJkpCcs.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"publish.mjs","names":["taggedError","Arr","Str","taggedError","Rec","Arr","MANIFEST_FILE","UNVERSIONED","Str","taggedError","Rec","Str","Arr","MANIFEST_FILE","taggedError","Str","Arr","Rec","Rec","Arr","Str","Rec","Arr","Predicate","Arr","Str","Arr","Rec","Arr","Str","Arr"],"sources":["../../github-workflow/src/shared/api/github.ts","../../github-workflow/src/shared/lib/process.ts","../../github-workflow/src/shared/lib/workflow.ts","../src/features/publish-workspace/model/broker.ts","../src/features/publish-workspace/model/manifest.ts","../src/features/publish-workspace/model/dependencies.ts","../src/features/publish-workspace/model/export-targets.ts","../src/features/publish-workspace/model/platforms.ts","../src/features/publish-workspace/model/widened-ranges.ts","../src/features/publish-workspace/model/npm.ts","../src/features/publish-workspace/model/provenance.ts","../src/features/publish-workspace/model/tags.ts","../src/features/publish-workspace/model/plan.ts","../src/features/publish-workspace/model/release.ts","../bin/msch-publish.ts"],"sourcesContent":["import { Config, Effect, Redacted } from \"effect\";\nimport type { Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpBody, HttpClientError, HttpMethod } from \"effect/http\";\n\nconst API = \"https://api.github.com\";\nconst HEADERS = {\n accept: \"application/vnd.github+json\",\n \"user-agent\": \"masseater.dev\",\n \"x-github-api-version\": \"2022-11-28\",\n};\n\n/** @internal */\nexport type GitHubFailure =\n | Config.ConfigError\n | HttpBody.HttpBodyError\n | HttpClientError.HttpClientError;\n\n/** @internal */\nexport type GitHubRequest<Success> = Effect.Effect<Success, GitHubFailure, HttpClient.HttpClient>;\n\nconst requestTo = Effect.fn(\"requestTo\")(function* requestTo(\n method: HttpMethod.HttpMethod,\n path: string,\n) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const token = yield* Config.Redacted(\"GH_TOKEN\").pipe(\n Config.orElse(() => Config.Redacted(\"GITHUB_TOKEN\")),\n );\n return HttpClientRequest.make(method)(`${API}/repos/${repository}/${path}`).pipe(\n HttpClientRequest.bearerToken(Redacted.value(token)),\n HttpClientRequest.setHeaders(HEADERS),\n );\n});\n\nconst execute = Effect.fn(\"execute\")(function* execute(\n request: HttpClientRequest.HttpClientRequest,\n) {\n const client = yield* HttpClient.HttpClient;\n const response = yield* client.execute(request);\n return yield* HttpClientResponse.filterStatusOk(response);\n});\n\nconst withBody = Effect.fn(\"withBody\")(function* withBody(\n method: HttpMethod.HttpMethod.WithBody,\n path: string,\n body: unknown,\n) {\n const request = yield* requestTo(method, path);\n const filled = yield* HttpClientRequest.bodyJson(request, body);\n return yield* execute(filled);\n});\n\nconst getJsonOf =\n <Codec extends Schema.Constraint>(schema: Codec) =>\n (\n path: string,\n ): Effect.Effect<\n Codec[\"Type\"],\n GitHubFailure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n requestTo(\"GET\", path).pipe(\n Effect.flatMap(execute),\n Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)),\n );\n\nconst postJsonOf =\n <Codec extends Schema.Constraint>(schema: Codec) =>\n ({\n path,\n body,\n }: GitHubWrite): Effect.Effect<\n Codec[\"Type\"],\n GitHubFailure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n withBody(\"POST\", path, body).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));\n\nconst removeAt = (path: string): GitHubRequest<void> =>\n requestTo(\"DELETE\", path).pipe(Effect.flatMap(execute), Effect.asVoid);\n\n/** @internal */\nexport interface GitHubWrite {\n readonly path: string;\n readonly body: unknown;\n}\n\nconst postTo = ({ path, body }: GitHubWrite): GitHubRequest<void> =>\n withBody(\"POST\", path, body).pipe(Effect.asVoid);\n\nconst patchAt = ({ path, body }: GitHubWrite): GitHubRequest<void> =>\n withBody(\"PATCH\", path, body).pipe(Effect.asVoid);\n\n/** @internal */\nexport const getJson = getJsonOf;\n\n/** @internal */\nexport const remove = removeAt;\n\n/** @internal */\nexport const post = postTo;\n\n/** @internal */\nexport const patch = patchAt;\n\n/** @internal */\nexport const postJson = postJsonOf;\n","import { Array as Arr, Effect, Schema, Stream, String as Str } from \"effect\";\nimport type { PlatformError } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nconst SUCCESS = 0;\n\nconst taggedError = Schema.TaggedError;\n\nexport class CommandFailed extends taggedError<CommandFailed, { readonly brand: unique symbol }>()(\n \"CommandFailed\",\n { message: Schema.String },\n) {}\n\nexport interface Command {\n readonly command: string;\n readonly args: readonly string[];\n readonly env?: Readonly<Record<string, string>>;\n readonly cwd?: string;\n}\n\n/** @internal */\nexport type Spawned<Success> = Effect.Effect<\n Success,\n CommandFailed | PlatformError.PlatformError,\n ChildProcessSpawner.ChildProcessSpawner\n>;\n\nconst failed = ({ command, args }: Command): CommandFailed =>\n CommandFailed.make({ message: `${command} ${Arr.join(args, \" \")} failed` });\n\nconst exitCodeOf = Effect.fn(\"exitCodeOf\")(function* exitCodeOf({\n command,\n args,\n env,\n cwd,\n}: Command) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n return yield* spawner.exitCode(\n ChildProcess.make(command, args, {\n cwd,\n env,\n extendEnv: true,\n stdin: \"ignore\",\n stdout: \"inherit\",\n stderr: \"inherit\",\n }),\n );\n});\n\nconst succeedsWith = (command: Command): Spawned<boolean> =>\n exitCodeOf(command).pipe(Effect.map((code) => code === SUCCESS));\n\nconst mustSucceedWith = (command: Command): Spawned<void> =>\n succeedsWith(command).pipe(\n Effect.filterOrFail(\n (passed) => passed,\n () => failed(command),\n ),\n Effect.asVoid,\n );\n\nconst collected = Effect.fn(\"collected\")(function* collected({ command, args, env, cwd }: Command) {\n const handle = yield* ChildProcess.make(command, args, {\n cwd,\n env,\n extendEnv: true,\n stdin: \"ignore\",\n stderr: \"inherit\",\n });\n const [output, code] = yield* Effect.all(\n [handle.stdout.pipe(Stream.decodeText(), Stream.mkString), handle.exitCode],\n { concurrency: \"unbounded\" },\n );\n return { output, code };\n});\n\nconst outputWith = (command: Command): Spawned<string> =>\n collected(command).pipe(\n Effect.scoped,\n Effect.filterOrFail(\n ({ code }) => code === SUCCESS,\n () => failed(command),\n ),\n Effect.map(({ output }) => Str.trim(output)),\n );\n\n/** @internal */\nexport const succeeds = succeedsWith;\n\n/** @internal */\nexport const mustSucceed = mustSucceedWith;\n\nconst finishedWith = (command: Command): Spawned<Readonly<{ output: string; code: number }>> =>\n Effect.scoped(collected(command));\n\n/** @internal */\nexport const outputOf = outputWith;\n\n/** @internal */\nexport const finished = finishedWith;\n","import {\n Array as Arr,\n Config,\n Console,\n Effect,\n FileSystem,\n Record as Rec,\n Schema,\n pipe,\n} from \"effect\";\nimport type { PlatformError } from \"effect\";\n\n/** @internal */\nexport type Appended = Effect.Effect<\n void,\n Config.ConfigError | PlatformError.PlatformError,\n FileSystem.FileSystem\n>;\n\nconst taggedError = Schema.TaggedError;\n\nexport class WorkflowFailed extends taggedError<\n WorkflowFailed,\n { readonly brand: unique symbol }\n>()(\"WorkflowFailed\", { message: Schema.String }) {}\n\nconst appendTo = (variable: string, entries: Readonly<Record<string, string>>): Appended =>\n Effect.gen(function* appended() {\n const path = yield* Config.String(variable);\n const fs = yield* FileSystem.FileSystem;\n const lines = pipe(\n Rec.toEntries(entries),\n Arr.map(([name, value]) => `${name}=${value}\\n`),\n Arr.join(\"\"),\n );\n yield* fs.writeFileString(path, lines, { flag: \"a\" });\n });\n\nconst outputsOf = (outputs: Readonly<Record<string, string>>): Appended =>\n appendTo(\"GITHUB_OUTPUT\", outputs);\n\nconst envOf = (variables: Readonly<Record<string, string>>): Appended =>\n appendTo(\"GITHUB_ENV\", variables);\n\n/** @internal */\nexport const writeOutputs = outputsOf;\n\n/** @internal */\nexport const setEnv = envOf;\n\nexport const warn = (message: string): Effect.Effect<void> => Console.log(`::warning::${message}`);\n\nexport const mask = (value: string): Effect.Effect<void> => Console.log(`::add-mask::${value}`);\n\nexport const fail = Effect.fn(\"fail\")(function* fail(message: string) {\n yield* Console.log(`::error::${message}`);\n return yield* WorkflowFailed.make({ message });\n});\n","import { mask } from \"@masseater.dev/github-workflow\";\nimport { Config, Console, Effect, Option, Redacted, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\n\nconst BROKER = \"https://credentials.masseater.dev/\";\nconst AUDIENCE = \"masseater-dev-credential-broker\";\n\nconst IdToken = Schema.Struct({ value: Schema.String });\nconst Issued = Schema.Record(Schema.String, Schema.Unknown);\n\n/** @internal */\nexport interface Credential {\n readonly kind: string;\n readonly field: string;\n}\n\nconst oidcToken = Effect.fn(\"publish.oidc\")(function* oidcToken(\n requestUrl: string,\n requestToken: Redacted.Redacted,\n) {\n const client = yield* HttpClient.HttpClient;\n const request = HttpClientRequest.get(`${requestUrl}&audience=${AUDIENCE}`).pipe(\n HttpClientRequest.bearerToken(Redacted.value(requestToken)),\n );\n const response = yield* HttpClient.filterStatusOk(client).execute(request);\n const { value } = yield* HttpClientResponse.schemaBodyJson(IdToken)(response);\n yield* mask(value);\n return value;\n});\n\nconst issued = Effect.fn(\"publish.issued\")(function* issued(\n oidc: string,\n { kind, field }: Credential,\n) {\n const client = yield* HttpClient.HttpClient;\n const request = HttpClientRequest.post(`${BROKER}?only=${kind}`).pipe(\n HttpClientRequest.bearerToken(oidc),\n );\n const response = yield* HttpClient.filterStatusOk(client).execute(request);\n const body = yield* HttpClientResponse.schemaBodyJson(Issued)(response);\n const token = Option.filter(\n Option.fromNullishOr(body[field]),\n (value): value is string => typeof value === \"string\" && value !== \"\",\n );\n yield* Effect.forEach(Option.toArray(token), mask, { concurrency: 1, discard: true });\n return token;\n});\n\n/** @internal */\nexport const brokerCredential = Effect.fn(\"publish.brokerCredential\")(function* brokerCredential(\n credential: Credential,\n) {\n const requestUrl = yield* Config.option(Config.String(\"ACTIONS_ID_TOKEN_REQUEST_URL\"));\n const requestToken = yield* Config.option(Config.Redacted(\"ACTIONS_ID_TOKEN_REQUEST_TOKEN\"));\n if (Option.isNone(requestUrl) || Option.isNone(requestToken)) {\n return Option.none<string>();\n }\n return yield* oidcToken(requestUrl.value, requestToken.value).pipe(\n Effect.flatMap((oidc) => issued(oidc, credential)),\n Effect.tapError(() => Console.log(`The credential broker gave no ${credential.field}`)),\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n});\n","import { Effect, FileSystem, Option, Path, Schema, String as Str, pipe } from \"effect\";\n\nconst MANIFEST_FILE = \"package.json\";\nconst SCOPE = /^@[^/]+\\//u;\nconst UNVERSIONED = \"0.0.0\";\nconst ROOT = \".\";\n\nconst Native = Schema.Struct({ binary: Schema.String, targets: Schema.Array(Schema.String) });\n\nconst ManifestSchema = Schema.Struct({\n name: Schema.String,\n version: Schema.String,\n private: Schema.optionalKey(Schema.Boolean),\n dependencies: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n native: Schema.optionalKey(Native),\n \"size-limit\": Schema.optionalKey(Schema.Unknown),\n});\n\n/** @internal */\nexport type Manifest = typeof ManifestSchema.Type;\n\n/** @internal */\nexport const manifestIn = Effect.fn(\"publish.manifest\")(function* manifestIn(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE));\n return yield* Schema.decodeEffect(Schema.fromJsonString(ManifestSchema))(text);\n});\n\n/** @internal */\nexport const releaseName = ({ name }: Pick<Manifest, \"name\">): string =>\n Str.replace(SCOPE, \"\")(name);\n\n/** @internal */\nexport const isRoot = (directory: string): boolean => directory === ROOT;\n\n/** @internal */\nexport interface Tagged extends Pick<Manifest, \"name\" | \"version\"> {\n readonly directory: string;\n}\n\n/** @internal */\nexport const tagOf = ({ directory, name, version }: Tagged): string => {\n if (isRoot(directory)) {\n return `v${version}`;\n }\n return `${releaseName({ name })}-v${version}`;\n};\n\n/** @internal */\nexport const environmentOf = (manifest: Pick<Manifest, \"name\">): string =>\n `${releaseName(manifest)}-release`;\n\n/** @internal */\nexport const isVersioned = ({ version }: Pick<Manifest, \"version\">): boolean =>\n version !== UNVERSIONED;\n\n/** @internal */\nexport const goesToNpm = (manifest: Pick<Manifest, \"private\">): boolean =>\n !pipe(\n Option.fromUndefinedOr(manifest.private),\n Option.getOrElse(() => false),\n );\n","import { succeeds } from \"@masseater.dev/github-workflow\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport { goesToNpm, manifestIn } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\n\nconst WORKSPACE_PROTOCOL = \"workspace:\";\nconst READ_CONCURRENCY = 8;\n\n/** @internal */\nexport interface Published {\n readonly directory: string;\n readonly name: string;\n readonly version: string;\n}\n\n/** @internal */\nexport const onNpm = ({ directory, name, version }: Published): ReturnType<typeof succeeds> =>\n succeeds({ command: \"npm\", args: [\"view\", `${name}@${version}`, \"version\"], cwd: directory });\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class UnpublishedDependencies extends taggedError<\n UnpublishedDependencies,\n { readonly brand: unique symbol }\n>()(\"UnpublishedDependencies\", { message: Schema.String }) {}\n\nconst workspaceDependencies = (manifest: Manifest): readonly string[] =>\n pipe(\n Option.fromUndefinedOr(manifest.dependencies),\n Option.map((dependencies) =>\n pipe(dependencies, Rec.filter(Str.startsWith(WORKSPACE_PROTOCOL)), Rec.keys),\n ),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst failWhenMissing = (\n missing: readonly Published[],\n manifest: Manifest,\n): Effect.Effect<void, UnpublishedDependencies> => {\n if (Arr.isReadonlyArrayEmpty(missing)) {\n return Effect.void;\n }\n const names = pipe(\n missing,\n Arr.map(({ directory, name, version }) => `${name}@${version} (${directory})`),\n Arr.join(\", \"),\n );\n return Effect.fail(\n UnpublishedDependencies.make({\n message: `${manifest.name} depends on versions that are not on npm yet. Publish them first: ${names}`,\n }),\n );\n};\n\n/** @internal */\nexport interface Dependent {\n readonly manifest: Manifest;\n readonly workspaces: readonly string[];\n}\n\n/** @internal */\nexport const requirePublishedDependencies = Effect.fn(\"publish.dependencies\")(\n function* requirePublishedDependencies({ manifest, workspaces }: Dependent) {\n const wanted = workspaceDependencies(manifest);\n const siblings = yield* Effect.forEach(\n workspaces,\n (directory) => manifestIn(directory).pipe(Effect.map((found) => ({ directory, ...found }))),\n { concurrency: READ_CONCURRENCY },\n );\n const internal = pipe(\n siblings,\n Arr.filter((sibling) => Arr.contains(wanted, sibling.name) && goesToNpm(sibling)),\n );\n const missing = yield* Effect.filter(\n internal,\n (sibling) => onNpm(sibling).pipe(Effect.map((published) => !published)),\n { concurrency: READ_CONCURRENCY },\n );\n yield* failWhenMissing(missing, manifest);\n },\n);\n","import {\n Array as Arr,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nconst PATTERN = \"*\";\nconst MANIFEST_FILE = \"package.json\";\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class MissingExportTargets extends taggedError<\n MissingExportTargets,\n { readonly brand: unique symbol }\n>()(\"MissingExportTargets\", { message: Schema.String }) {}\n\nconst AnyExports = Schema.optionalKey(Schema.Unknown);\nconst PublishConfig = Schema.Struct({ exports: AnyExports });\n\nconst PublishedExports = Schema.fromJsonString(\n Schema.Struct({ exports: AnyExports, publishConfig: Schema.optionalKey(PublishConfig) }),\n);\n\ntype PublishedManifest = typeof PublishedExports.Type;\n\nconst singleTarget = (target: string): readonly string[] => {\n if (Str.includes(PATTERN)(target)) {\n return [];\n }\n return [target];\n};\n\n/** @internal */\nexport const exportTargetsOf = (exports: unknown): readonly string[] => {\n if (Predicate.isString(exports)) {\n return singleTarget(exports);\n }\n if (Arr.isArray(exports)) {\n return pipe(\n exports,\n Arr.flatMap((entry) => exportTargetsOf(entry)),\n );\n }\n if (Predicate.isReadonlyObject(exports)) {\n return pipe(\n Rec.values(exports),\n Arr.flatMap((entry) => exportTargetsOf(entry)),\n );\n }\n return [];\n};\n\nconst publishedExportsOf = (manifest: PublishedManifest): unknown =>\n pipe(\n Option.fromUndefinedOr(manifest.publishConfig),\n Option.flatMap((config) => Option.fromUndefinedOr(config.exports)),\n Option.orElse(() => Option.fromUndefinedOr(manifest.exports)),\n Option.getOrUndefined,\n );\n\nconst missingMessage = (missing: readonly string[]): string =>\n `The published exports point to files the build did not write: ${Arr.join(missing, \", \")}`;\n\n/** @internal */\nexport const checkExportTargets = Effect.fn(\"publish.checkExportTargets\")(\n function* checkExportTargets(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const manifest = yield* fileSystem\n .readFileString(path.join(directory, MANIFEST_FILE))\n .pipe(Effect.flatMap(Schema.decodeEffect(PublishedExports)));\n const missing = yield* Effect.filter(exportTargetsOf(publishedExportsOf(manifest)), (target) =>\n Effect.map(fileSystem.exists(path.join(directory, target)), (found) => !found),\n );\n return yield* pipe(\n missing,\n Arr.match({\n onEmpty: () => Effect.void,\n onNonEmpty: (list) =>\n Effect.fail(MissingExportTargets.make({ message: missingMessage(list) })),\n }),\n );\n },\n);\n","import { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nconst RUNNERS = {\n linux: \"ubuntu-latest\",\n windows: \"windows-latest\",\n macos: \"macos-latest\",\n} as const satisfies Readonly<Record<string, string>>;\n\ntype Os = keyof typeof RUNNERS;\n\nconst NODE_PLATFORMS: Readonly<Record<string, Os>> = {\n linux: \"linux\",\n win32: \"windows\",\n darwin: \"macos\",\n};\n\nconst BUILD = \"release:\";\nconst CHECK = \"release:check:\";\nconst LIBC: Readonly<Record<string, string>> = { gnu: \"glibc\", musl: \"musl\" };\nconst CPU_INDEX = 1;\nconst ABI_INDEX = 2;\n\n/** @internal */\nexport interface Runner {\n readonly os: string;\n readonly runner: string;\n}\n\n/** @internal */\nexport interface NativeTarget {\n readonly target: string;\n readonly runner: string;\n}\n\nconst systems = Rec.keys(RUNNERS);\n\nconst runnersFor = (tasks: readonly string[], prefix: string): readonly Runner[] =>\n pipe(\n systems,\n Arr.filter((os) => Arr.contains(tasks, `${prefix}${os}`)),\n Arr.map((os): Runner => ({ os, runner: RUNNERS[os] })),\n );\n\n/** @internal */\nexport const buildsOf = (tasks: readonly string[]): readonly Runner[] => runnersFor(tasks, BUILD);\n\n/** @internal */\nexport const checksOf = (tasks: readonly string[]): readonly Runner[] => runnersFor(tasks, CHECK);\n\n/** @internal */\nexport const nativeTargetsOf = (targets: readonly string[]): readonly NativeTarget[] =>\n pipe(\n targets,\n Arr.flatMap((target) =>\n pipe(\n Arr.head(Str.split(target, \"-\")),\n Option.flatMap((platform) => Rec.get(NODE_PLATFORMS, platform)),\n Option.map((os): NativeTarget => ({ target, runner: RUNNERS[os] })),\n Option.toArray,\n ),\n ),\n );\n\n/** @internal */\nexport interface NativePackage {\n readonly name: string;\n readonly version: string;\n readonly binary: string;\n readonly target: string;\n}\n\nconst libcOf = (parts: readonly string[]): Readonly<Record<string, readonly string[]>> =>\n pipe(\n Arr.get(parts, ABI_INDEX),\n Option.flatMap((abi) => Rec.get(LIBC, abi)),\n Option.match({ onNone: () => ({}), onSome: (libc) => ({ libc: [libc] }) }),\n );\n\n/** @internal */\nexport const nativeFileOf = ({ binary, target }: NativePackage): string =>\n `${binary}.${target}.node`;\n\n/** @internal */\nexport const nativeFields = (native: NativePackage): Readonly<Record<string, unknown>> => {\n const parts = Str.split(native.target, \"-\");\n const file = nativeFileOf(native);\n return {\n name: `${native.name}-${native.target}`,\n version: native.version,\n os: Option.toArray(Arr.head(parts)),\n cpu: Option.toArray(Arr.get(parts, CPU_INDEX)),\n ...libcOf(parts),\n main: file,\n files: [file],\n };\n};\n\n/** @internal */\nexport const nativeReadme = ({ name, target }: NativePackage): string =>\n `# ${name}-${target}\\n\\nThe prebuilt ${target} native addon of [${name}](https://www.npmjs.com/package/${name}). Install ${name} instead; npm picks this package for your platform.\\n`;\n","import { Effect, FileSystem, Path } from \"effect\";\n\nconst HOOK_FILE = \"widen-ranges.mjs\";\n\n/** @internal */\nexport const WIDEN_RANGES = `const EXACT = /^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:-[0-9A-Za-z.-]+)?(?:\\\\+[0-9A-Za-z.-]+)?$/u;\nconst widen = (held) =>\n held === undefined\n ? undefined\n : Object.fromEntries(Object.entries(held).map(([name, specifier]) => [name, EXACT.test(specifier) ? \\`^\\${specifier}\\` : specifier]));\nexport const hooks = {\n beforePacking: (manifest) => ({\n ...manifest,\n dependencies: widen(manifest.dependencies),\n peerDependencies: widen(manifest.peerDependencies),\n }),\n};\n`;\n\n/** @internal */\nexport const widenRangesEnv = Effect.fn(\"publish.widenRanges\")(function* widenRangesEnv(\n directory: string,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const hook = path.join(directory, HOOK_FILE);\n yield* fileSystem.writeFileString(hook, WIDEN_RANGES);\n return { pnpm_config_pnpmfile: hook };\n});\n","import { mustSucceed } from \"@masseater.dev/github-workflow\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record as Rec,\n Schema,\n pipe,\n} from \"effect\";\n\nimport { brokerCredential } from \"./broker.ts\";\nimport { onNpm } from \"./dependencies.ts\";\nimport { checkExportTargets } from \"./export-targets.ts\";\nimport { manifestIn } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { nativeFields, nativeFileOf, nativeReadme } from \"./platforms.ts\";\nimport type { NativePackage } from \"./platforms.ts\";\nimport { widenRangesEnv } from \"./widened-ranges.ts\";\n\nconst TARBALL = \"package.tgz\";\nconst NPM_DIR = \"npm\";\nconst NATIVE_DIR = \"native\";\nconst MANIFEST_FILE = \"package.json\";\nconst KEPT_FIELDS: readonly string[] = [\"license\", \"repository\", \"homepage\", \"bugs\", \"engines\"];\nconst PUBLISH_FLAGS = [\"--provenance\", \"--access\", \"public\"];\n\ntype Env = Readonly<Record<string, string>>;\n\nconst PackageJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));\nconst PlatformManifest = Schema.fromJsonString(\n Schema.Struct({ name: Schema.String, version: Schema.String }),\n);\nconst authEnv = Effect.fn(\"publish.authEnv\")(function* authEnv() {\n const token = yield* brokerCredential({ kind: \"npm\", field: \"npmToken\" });\n return Option.match(token, {\n onNone: (): Env => ({}),\n onSome: (value): Env => ({ NODE_AUTH_TOKEN: value }),\n });\n});\n\nconst verifyPackage = Effect.fn(\"publish.verify\")(function* verifyPackage(\n directory: string,\n manifest: Manifest,\n) {\n const size = pipe(\n Option.fromUndefinedOr(manifest[\"size-limit\"]),\n Option.map(() => \"size\"),\n Option.toArray,\n );\n const tasks = [\"build\", \"test\", ...size];\n yield* Effect.forEach(\n tasks,\n (task) => mustSucceed({ command: \"vp\", args: [\"run\", task], cwd: directory }),\n { concurrency: 1, discard: true },\n );\n yield* checkExportTargets(directory);\n});\n\nconst keptFields = Effect.fn(\"publish.keptFields\")(function* keptFields(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE));\n const raw = yield* Schema.decodeEffect(PackageJson)(text);\n return pipe(\n raw,\n Rec.filter((_value, key) => Arr.contains(KEPT_FIELDS, key)),\n );\n});\n\nconst writeNative = Effect.fn(\"publish.writeNative\")(function* writeNative(\n directory: string,\n native: NativePackage,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const kept = yield* keptFields(directory);\n const target = path.resolve(directory, NPM_DIR, native.target);\n const file = nativeFileOf(native);\n yield* fileSystem.makeDirectory(target, { recursive: true });\n yield* fileSystem.copyFile(path.join(directory, NATIVE_DIR, file), path.join(target, file));\n const text = yield* Schema.encodeEffect(PackageJson)({ ...kept, ...nativeFields(native) });\n yield* Effect.all(\n [\n fileSystem.writeFileString(path.join(target, MANIFEST_FILE), text),\n fileSystem.writeFileString(path.join(target, \"README.md\"), nativeReadme(native)),\n ],\n { concurrency: \"unbounded\" },\n );\n return target;\n});\n\nconst publishNative = Effect.fn(\"publish.publishNative\")(function* publishNative(\n target: string,\n env: Env,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const { name, version } = yield* fileSystem\n .readFileString(path.join(target, MANIFEST_FILE))\n .pipe(Effect.flatMap(Schema.decodeEffect(PlatformManifest)));\n if (yield* onNpm({ directory: target, name, version })) {\n yield* Console.log(`${name}@${version} is already published, skipping`);\n return name;\n }\n yield* mustSucceed({\n command: \"npm\",\n args: [\"publish\", \".\", ...PUBLISH_FLAGS],\n env,\n cwd: target,\n });\n return name;\n});\n\nconst addOptionalDependencies = Effect.fn(\"publish.optionalDependencies\")(\n function* addOptionalDependencies(directory: string, names: readonly string[], version: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(directory, MANIFEST_FILE);\n const manifest = yield* fileSystem\n .readFileString(file)\n .pipe(Effect.flatMap(Schema.decodeEffect(PackageJson)));\n const optionalDependencies = pipe(\n names,\n Arr.map((name): readonly [string, string] => [name, version]),\n Rec.fromEntries,\n );\n const updated = yield* Schema.encodeEffect(PackageJson)({ ...manifest, optionalDependencies });\n yield* fileSystem.writeFileString(file, updated);\n },\n);\n\nconst publishNatives = Effect.fn(\"publish.publishNatives\")(function* publishNatives(\n directory: string,\n manifest: Manifest,\n env: Env,\n) {\n if (Predicate.isUndefined(manifest.native)) {\n return;\n }\n const { binary, targets } = manifest.native;\n const written = yield* Effect.forEach(\n targets,\n (target) =>\n writeNative(directory, { name: manifest.name, version: manifest.version, binary, target }),\n { concurrency: 1 },\n );\n const names = yield* Effect.forEach(written, (target) => publishNative(target, env), {\n concurrency: 1,\n });\n yield* addOptionalDependencies(directory, names, manifest.version);\n});\n\nconst pack = Effect.fn(\"publish.pack\")(function* pack(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const temporary = yield* fileSystem.makeTempDirectoryScoped();\n const tarball = path.join(temporary, TARBALL);\n const env = yield* widenRangesEnv(temporary);\n yield* mustSucceed({\n command: \"vp\",\n args: [\"pm\", \"pack\", \"--out\", tarball],\n env,\n cwd: directory,\n });\n return tarball;\n});\n\n/** @internal */\nexport const publishToNpm = Effect.fn(\"publish.npm\")(function* publishToNpm(directory: string) {\n const manifest = yield* manifestIn(directory);\n if (yield* onNpm({ directory, ...manifest })) {\n return yield* Console.log(`${manifest.name}@${manifest.version} is already published`);\n }\n yield* verifyPackage(directory, manifest);\n const env = yield* authEnv();\n yield* publishNatives(directory, manifest, env);\n const tarball = yield* pack(directory);\n return yield* mustSucceed({\n command: \"npm\",\n args: [\"publish\", tarball, ...PUBLISH_FLAGS],\n env,\n cwd: directory,\n });\n}, Effect.scoped);\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\nimport { Base64 } from \"effect/encoding\";\nimport { HttpClient, HttpClientResponse } from \"effect/http\";\n\nconst ATTESTATIONS = \"https://registry.npmjs.org/-/npm/v1/attestations/\";\nconst SLSA = /slsa\\.dev\\/provenance/u;\n\nconst Digest = Schema.Struct({ gitCommit: Schema.String });\nconst Dependency = Schema.Struct({ digest: Digest });\nconst BuildDefinition = Schema.Struct({ resolvedDependencies: Schema.Array(Dependency) });\nconst Predicate = Schema.Struct({ buildDefinition: BuildDefinition });\nconst Statement = Schema.fromJsonString(Schema.Struct({ predicate: Predicate }));\n\nconst Envelope = Schema.Struct({ payload: Schema.String });\nconst Bundle = Schema.Struct({ dsseEnvelope: Envelope });\nconst Attestation = Schema.Struct({ predicateType: Schema.String, bundle: Bundle });\nconst Attestations = Schema.Struct({ attestations: Schema.Array(Attestation) });\n\n/** @internal */\nexport interface Version {\n readonly name: string;\n readonly version: string;\n}\n\nconst commitOf = (payload: string): Effect.Effect<Option.Option<string>> =>\n pipe(\n Base64.decodeString(payload),\n Effect.fromResult,\n Effect.flatMap(Schema.decodeEffect(Statement)),\n Effect.map(({ predicate }) =>\n pipe(\n Arr.head(predicate.buildDefinition.resolvedDependencies),\n Option.map(({ digest }) => digest.gitCommit),\n ),\n ),\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n\n/** @internal */\nexport const provenanceCommit = Effect.fn(\"publish.provenanceCommit\")(function* provenanceCommit({\n name,\n version,\n}: Version) {\n const client = yield* HttpClient.HttpClient;\n const url = `${ATTESTATIONS}${Str.replace(\"/\", \"%2f\")(name)}@${version}`;\n const found = yield* HttpClient.filterStatusOk(client)\n .get(url)\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(Attestations)),\n Effect.map(({ attestations }) =>\n Arr.findFirst(attestations, ({ predicateType }) => SLSA.test(predicateType)),\n ),\n Effect.orElseSucceed(() => Option.none<(typeof Attestations.Type.attestations)[number]>()),\n );\n if (Option.isNone(found)) {\n return Option.none<string>();\n }\n return yield* commitOf(found.value.bundle.dsseEnvelope.payload);\n});\n","import { mustSucceed, outputOf, succeeds } from \"@masseater.dev/github-workflow\";\nimport { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\nimport semver from \"semver\";\n\nimport { brokerCredential } from \"./broker.ts\";\nimport { goesToNpm, tagOf } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { provenanceCommit } from \"./provenance.ts\";\n\nconst UNVERSIONED = \"0.0.0\";\nconst LOOKUP_CONCURRENCY = 4;\n\nconst Versions = Schema.fromJsonString(Schema.Array(Schema.String));\n\n/** @internal */\nexport interface Workspace {\n readonly directory: string;\n readonly manifest: Manifest;\n}\n\n/** @internal */\nexport interface Revision {\n readonly tag: string;\n readonly sha: string;\n}\n\n/** @internal */\nexport const tagged = Effect.fn(\"publish.tagged\")(function* tagged(tag: string) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n return yield* succeeds({\n command: \"gh\",\n args: [\"api\", `repos/${repository}/git/ref/tags/${tag}`],\n });\n});\n\nconst tokenEnv = brokerCredential({ kind: \"github\", field: \"githubToken\" }).pipe(\n Effect.map(\n Option.match({\n onNone: (): Readonly<Record<string, string>> => ({}),\n onSome: (value): Readonly<Record<string, string>> => ({ GH_TOKEN: value }),\n }),\n ),\n);\n\n/** @internal */\nexport const createTag = Effect.fn(\"publish.createTag\")(function* createTag({\n tag,\n sha,\n}: Revision) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const env = yield* tokenEnv;\n yield* Effect.logInfo(`tagging ${tag} at ${sha}`);\n yield* mustSucceed({\n command: \"gh\",\n env,\n args: [\n \"api\",\n \"-X\",\n \"POST\",\n `repos/${repository}/git/refs`,\n \"-f\",\n `ref=refs/tags/${tag}`,\n \"-f\",\n `sha=${sha}`,\n ],\n });\n});\n\nconst isRelease = (version: string): boolean =>\n version !== UNVERSIONED && semver.valid(version) !== null && semver.prerelease(version) === null;\n\nconst publishedVersions = Effect.fn(\"publish.publishedVersions\")(function* publishedVersions({\n directory,\n manifest,\n}: Workspace) {\n if (!goesToNpm(manifest)) {\n return [];\n }\n const text = yield* outputOf({\n command: \"npm\",\n args: [\"view\", manifest.name, \"versions\", \"--json\"],\n cwd: directory,\n }).pipe(Effect.orElseSucceed(() => \"[]\"));\n const versions = yield* Schema.decodeEffect(Versions)(text).pipe(\n Effect.orElseSucceed((): readonly string[] => []),\n );\n return pipe(\n versions,\n Arr.filter((version) => isRelease(version) && version !== manifest.version),\n );\n});\n\n/** @internal */\nexport const untaggedVersions = Effect.fn(\"publish.untaggedVersions\")(function* untaggedVersions(\n workspace: Workspace,\n) {\n const versions = yield* publishedVersions(workspace);\n return yield* Effect.filter(\n versions,\n (version) =>\n tagged(\n tagOf({ directory: workspace.directory, name: workspace.manifest.name, version }),\n ).pipe(Effect.map((found) => !found)),\n { concurrency: LOOKUP_CONCURRENCY },\n );\n});\n\nconst backfillVersion = Effect.fn(\"publish.backfillVersion\")(function* backfillVersion(\n workspace: Workspace,\n version: string,\n) {\n const { directory, manifest } = workspace;\n const tag = tagOf({ directory, name: manifest.name, version });\n const commit = yield* provenanceCommit({ name: manifest.name, version });\n if (Option.isNone(commit)) {\n yield* Effect.logWarning(`${tag} has no npm provenance, so it stays untagged`);\n return;\n }\n yield* createTag({ tag, sha: commit.value });\n});\n\n/** @internal */\nexport const backfillTags = Effect.fn(\"publish.backfillTags\")(function* backfillTags(\n workspace: Workspace,\n) {\n const versions = yield* untaggedVersions(workspace);\n yield* Effect.forEach(versions, (version) => backfillVersion(workspace, version), {\n concurrency: 1,\n discard: true,\n });\n});\n","import { outputOf, succeeds, writeOutputs } from \"@masseater.dev/github-workflow\";\nimport {\n Array as Arr,\n Config,\n Effect,\n Option,\n Path,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { onNpm, requirePublishedDependencies } from \"./dependencies.ts\";\nimport {\n environmentOf,\n goesToNpm,\n isRoot,\n isVersioned,\n manifestIn,\n releaseName,\n tagOf,\n} from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { buildsOf, checksOf, nativeTargetsOf } from \"./platforms.ts\";\nimport { tagged, untaggedVersions } from \"./tags.ts\";\n\nconst HOOK = \"release:publish\";\nconst NONE = 0;\nconst TRAILING_SLASH = /\\/$/u;\n\nconst Task = Schema.Struct({ package: Schema.String, name: Schema.String });\n\nconst TaskGraph = Schema.fromJsonString(\n Schema.Struct({ workspaceRoot: Schema.String, tasks: Schema.Record(Schema.String, Task) }),\n);\n\nconst Runner = Schema.Struct({ os: Schema.String, runner: Schema.String });\n\nconst NativeTarget = Schema.Struct({ target: Schema.String, runner: Schema.String });\n\nconst PlanSchema = Schema.Struct({\n directory: Schema.String,\n name: Schema.String,\n version: Schema.String,\n tag: Schema.String,\n environment: Schema.String,\n npm: Schema.Boolean,\n native: Schema.Array(NativeTarget),\n builds: Schema.Array(Runner),\n checks: Schema.Array(Runner),\n release: Schema.Boolean,\n tagged: Schema.Boolean,\n hook: Schema.Boolean,\n});\n\n/** @internal */\nexport type Plan = typeof PlanSchema.Type;\n\nconst AssetCount = Schema.fromJsonString(Schema.Finite);\n\nconst graphTasks = outputOf({ command: \"vp\", args: [\"run\", \"--json\"] }).pipe(\n Effect.flatMap(Schema.decodeEffect(TaskGraph)),\n Effect.map(({ tasks }) => Rec.values(tasks)),\n);\n\nconst tasksIn = (tasks: readonly (typeof Task.Type)[], directory: string): readonly string[] =>\n pipe(\n tasks,\n Arr.filter((task) => task.package === directory),\n Arr.map(({ name }) => name),\n );\n\nconst workspacesOf = (tasks: readonly (typeof Task.Type)[]): readonly string[] =>\n pipe(\n tasks,\n Arr.map((task) => task.package),\n Arr.dedupe,\n );\n\nconst allTagged = Effect.fn(\"publish.allTagged\")(function* allTagged(\n directory: string,\n manifest: Manifest,\n) {\n if (!isVersioned(manifest)) {\n return true;\n }\n const current = yield* tagged(tagOf({ directory, ...manifest }));\n const older = yield* untaggedVersions({ directory, manifest });\n return current && Arr.isReadonlyArrayEmpty(older);\n});\n\nconst workspaceOf = (directory: string): Effect.Effect<string, never, Path.Path> =>\n Path.Path.pipe(Effect.map((path) => Str.replace(TRAILING_SLASH, \"\")(path.normalize(directory))));\n\n/** @internal */\nexport const released = Effect.fn(\"publish.released\")(function* released(tag: string) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n return yield* succeeds({ command: \"gh\", args: [\"release\", \"view\", tag, \"--repo\", repository] });\n});\n\n/** @internal */\nexport const releasedWithAssets = Effect.fn(\"publish.releasedWithAssets\")(\n function* releasedWithAssets(tag: string) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const view = [\"release\", \"view\", tag, \"--repo\", repository];\n const exists = yield* released(tag);\n if (!exists) {\n return false;\n }\n const count = yield* outputOf({\n command: \"gh\",\n args: [...view, \"--json\", \"assets\", \"--jq\", \".assets | length\"],\n }).pipe(Effect.flatMap(Schema.decodeEffect(AssetCount)));\n return count > NONE;\n },\n);\n\nconst keepWhen =\n (kept: boolean) =>\n <Item>(items: readonly Item[]): readonly Item[] =>\n pipe(\n items,\n Arr.filter(() => kept),\n );\n\nconst needsNpm = Effect.fn(\"publish.needsNpm\")(function* needsNpm(\n directory: string,\n manifest: Manifest,\n workspaces: readonly string[],\n) {\n if (!goesToNpm(manifest)) {\n return false;\n }\n const published = yield* onNpm({ directory, ...manifest });\n if (published) {\n return false;\n }\n yield* requirePublishedDependencies({ manifest, workspaces });\n return true;\n});\n\nconst needsRelease = Effect.fn(\"publish.needsRelease\")(function* needsRelease(\n directory: string,\n manifest: Manifest,\n builds: readonly unknown[],\n) {\n const tag = tagOf({ directory, ...manifest });\n if (!isVersioned(manifest)) {\n return false;\n }\n if (isRoot(directory)) {\n return !(yield* released(tag));\n }\n if (Arr.isReadonlyArrayEmpty(builds)) {\n return false;\n }\n return !(yield* releasedWithAssets(tag));\n});\n\nconst nativeOf = (manifest: Manifest): readonly (typeof NativeTarget.Type)[] =>\n pipe(\n Option.fromUndefinedOr(manifest.native),\n Option.map(({ targets }) => nativeTargetsOf(targets)),\n Option.getOrElse((): readonly (typeof NativeTarget.Type)[] => []),\n );\n\n/** @internal */\nexport const planOf = Effect.fn(\"publish.plan\")(function* planOf(directory: string) {\n const workspace = yield* workspaceOf(directory);\n const manifest = yield* manifestIn(workspace);\n const graph = yield* graphTasks;\n const tasks = tasksIn(graph, workspace);\n const npm = yield* needsNpm(workspace, manifest, workspacesOf(graph));\n const release = yield* needsRelease(workspace, manifest, buildsOf(tasks));\n const built = keepWhen(release || !isVersioned(manifest));\n const tag = tagOf({ directory: workspace, ...manifest });\n return {\n directory: workspace,\n name: releaseName(manifest),\n version: manifest.version,\n tag,\n tagged: yield* allTagged(workspace, manifest),\n environment: environmentOf(manifest),\n npm,\n native: keepWhen(npm)(nativeOf(manifest)),\n builds: built(buildsOf(tasks)),\n checks: built(checksOf(tasks)),\n release,\n hook: release && Arr.contains(tasks, HOOK),\n } satisfies Plan;\n});\n\n/** @internal */\nexport const writePlan = Effect.fn(\"publish.writePlan\")(function* writePlan(plan: Plan) {\n const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(PlanSchema))(plan);\n yield* Effect.logInfo(encoded);\n yield* writeOutputs({ plan: encoded });\n});\n","import { mustSucceed, succeeds, writeOutputs } from \"@masseater.dev/github-workflow\";\nimport { Array as Arr, Config, Effect, FileSystem, Option, Order, Path, pipe } from \"effect\";\n\nimport { goesToNpm, isRoot, isVersioned, manifestIn, releaseName, tagOf } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { releasedWithAssets } from \"./plan.ts\";\nimport { provenanceCommit } from \"./provenance.ts\";\nimport { backfillTags, createTag, tagged } from \"./tags.ts\";\n\nconst ASSETS = \"release-assets\";\n\nconst revisionOf = Effect.fn(\"publish.revision\")(function* revisionOf(manifest: Manifest) {\n const head = yield* Config.String(\"GITHUB_SHA\");\n if (!goesToNpm(manifest)) {\n return head;\n }\n const published = yield* provenanceCommit(manifest);\n return Option.getOrElse(published, () => head);\n});\n\nconst tagRevision = Effect.fn(\"publish.tag\")(function* tagRevision(\n tag: string,\n manifest: Manifest,\n) {\n if (yield* tagged(tag)) {\n return;\n }\n const sha = yield* revisionOf(manifest);\n yield* createTag({ tag, sha });\n});\n\nconst assetsIn = Effect.fn(\"publish.assets\")(function* assetsIn(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const folder = path.join(directory, ASSETS);\n if (!(yield* fileSystem.exists(folder))) {\n return [];\n }\n const names = yield* fileSystem.readDirectory(folder, { recursive: true });\n const files = yield* Effect.filter(\n pipe(\n names,\n Arr.map((name) => path.join(folder, name)),\n ),\n (file) =>\n fileSystem.stat(file).pipe(\n Effect.map(({ type }) => type === \"File\"),\n Effect.orElseSucceed(() => false),\n ),\n );\n return Arr.sort(files, Order.String);\n});\n\nconst LIBRARY_NOTES = [\"--latest=false\", \"--notes\", \"\"];\nconst ROOT_NOTES = [\"--latest\", \"--generate-notes\"];\n\nconst notesOf = (directory: string): readonly string[] => {\n if (isRoot(directory)) {\n return ROOT_NOTES;\n }\n return LIBRARY_NOTES;\n};\n\ninterface Release {\n readonly directory: string;\n readonly manifest: Manifest;\n}\n\nconst createRelease = Effect.fn(\"publish.createRelease\")(function* createRelease({\n directory,\n manifest,\n}: Release) {\n const tag = tagOf({ directory, ...manifest });\n const notes = notesOf(directory);\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const exists = yield* succeeds({\n command: \"gh\",\n args: [\"release\", \"view\", tag, \"--repo\", repository],\n });\n if (exists) {\n return;\n }\n yield* mustSucceed({\n command: \"gh\",\n args: [\n \"release\",\n \"create\",\n tag,\n \"--repo\",\n repository,\n \"--verify-tag\",\n \"--title\",\n `${releaseName(manifest)} v${manifest.version}`,\n ...notes,\n ],\n });\n});\n\nconst uploadAssets = Effect.fn(\"publish.uploadAssets\")(function* uploadAssets({\n directory,\n manifest,\n}: Release) {\n const tag = tagOf({ directory, ...manifest });\n const files = yield* assetsIn(directory);\n if (Arr.isReadonlyArrayEmpty(files) || (yield* releasedWithAssets(tag))) {\n return;\n }\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n yield* createRelease({ directory, manifest });\n yield* mustSucceed({\n command: \"gh\",\n args: [\"release\", \"upload\", tag, ...files, \"--repo\", repository, \"--clobber\"],\n });\n});\n\n/** @internal */\nexport const publishRelease = Effect.fn(\"publish.release\")(function* publishRelease(\n directory: string,\n) {\n const manifest = yield* manifestIn(directory);\n if (!isVersioned(manifest)) {\n yield* Effect.logInfo(`${manifest.name} has no version to publish`);\n return;\n }\n const tag = tagOf({ directory, ...manifest });\n yield* Effect.andThen(tagRevision(tag, manifest), backfillTags({ directory, manifest }));\n yield* writeOutputs({ tag });\n if (isRoot(directory)) {\n yield* createRelease({ directory, manifest });\n }\n yield* uploadAssets({ directory, manifest });\n});\n","#!/usr/bin/env node\nimport { Effect, Schema, Stdio } from \"effect\";\n\nimport { runCli } from \"#/app/runtime.ts\";\nimport {\n planOf,\n publishRelease,\n publishToNpm,\n writePlan,\n} from \"#/features/publish-workspace/index.ts\";\n\nconst Arguments = Schema.Union([\n Schema.Tuple([Schema.Literal(\"plan\"), Schema.String]),\n Schema.Tuple([Schema.Literal(\"npm\"), Schema.String]),\n Schema.Tuple([Schema.Literal(\"release\"), Schema.String]),\n]);\n\nconst taggedError = Schema.TaggedError;\n\nclass UsageError extends taggedError<UsageError, { readonly brand: unique symbol }>()(\n \"UsageError\",\n { message: Schema.String },\n) {}\n\nconst USAGE = \"usage: msch-publish <plan|npm|release> <workspace directory>\";\n\nconst publish = Effect.gen(function* publish() {\n const stdio = yield* Stdio.Stdio;\n const args = yield* stdio.args;\n const [step, directory] = yield* Schema.decodeUnknownEffect(Arguments)(args).pipe(\n Effect.mapError(() => UsageError.make({ message: USAGE })),\n );\n if (step === \"plan\") {\n return yield* planOf(directory).pipe(Effect.flatMap(writePlan));\n }\n if (step === \"npm\") {\n return yield* publishToNpm(directory);\n }\n return yield* publishRelease(directory);\n});\n\nrunCli(publish);\n"],"mappings":";;;;;;;;AAKA,MAAM,MAAM;AACZ,MAAM,UAAU;CACd,QAAQ;CACR,cAAc;CACd,wBAAwB;AAC1B;AAWA,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,UACjD,QACA,MACA;CACA,MAAM,aAAa,OAAO,OAAO,OAAO,mBAAmB;CAC3D,MAAM,QAAQ,OAAO,OAAO,SAAS,UAAU,CAAC,CAAC,KAC/C,OAAO,aAAa,OAAO,SAAS,cAAc,CAAC,CACrD;CACA,OAAO,kBAAkB,KAAK,MAAM,CAAC,CAAC,GAAG,IAAI,SAAS,WAAW,GAAG,MAAM,CAAC,CAAC,KAC1E,kBAAkB,YAAY,SAAS,MAAM,KAAK,CAAC,GACnD,kBAAkB,WAAW,OAAO,CACtC;AACF,CAAC;AAED,MAAM,UAAU,OAAO,GAAG,SAAS,CAAC,CAAC,UAAU,QAC7C,SACA;CAEA,MAAM,WAAW,QAAO,OADF,WAAW,WAAA,CACF,QAAQ,OAAO;CAC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IAAI,SAAS,OACX,OAAO,OAAO,aAAa,SAAS;CAEtC,OAAO,OAAO,eAAe,SAAS;AACxC,CAAC;AAED,OAAO,OAAO"}
1
+ {"version":3,"file":"publish.mjs","names":["PATTERN","UNVERSIONED","taggedError","Native","PublishConfig","Rec","Arr","Str","Rec","Arr","Str","MANIFEST_FILE","Rec","Arr","Arr","Str","Arr","Rec","MANIFEST_FILE","Versions","Rec","Arr","MANIFEST_FILE","UNVERSIONED","Str","taggedError","Rec","Str","Arr","Predicate","Arr","Str","Arr","Rec","Arr","Str","Arr","MANIFEST_FILE","taggedError","Str","Arr","Rec","Arr","Rec","Arr"],"sources":["../src/features/publish-workspace/model/compat-manifest.ts","../src/features/publish-workspace/model/platforms.ts","../src/features/publish-workspace/model/native-package.ts","../src/features/publish-workspace/model/widened-ranges.ts","../src/features/publish-workspace/model/pack.ts","../src/features/publish-workspace/model/compat-native.ts","../src/features/publish-workspace/model/compat-workspace.ts","../src/features/publish-workspace/model/compat.ts","../src/features/publish-workspace/model/manifest.ts","../src/features/publish-workspace/model/dependencies.ts","../src/features/publish-workspace/model/broker.ts","../src/features/publish-workspace/model/provenance.ts","../src/features/publish-workspace/model/tags.ts","../src/features/publish-workspace/model/plan.ts","../src/features/publish-workspace/model/compat-plan.ts","../src/features/publish-workspace/model/export-targets.ts","../src/features/publish-workspace/model/npm.ts","../src/features/publish-workspace/model/release.ts","../bin/msch-publish.ts"],"sourcesContent":["import {\n Array as Arr,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\nimport semver from \"semver\";\n\nconst PACKAGE_JSON_EXPORT = \"./package.json\";\nconst PATTERN = \"*\";\nconst ROOT_EXPORT = \".\";\nconst UNVERSIONED = \"0.0.0\";\nconst VITE = \"vite\";\n\n/** @internal */\nexport const VITE_PLUS = \"vite-plus\";\nconst TYPES = \"types\";\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class IncompatiblePackage extends taggedError<\n IncompatiblePackage,\n { readonly brand: unique symbol }\n>()(\"IncompatiblePackage\", { message: Schema.String }) {}\n\nconst Declared = Schema.Record(Schema.String, Schema.String);\n\nconst VitePlusManifestJson = Schema.fromJsonString(\n Schema.Struct({ dependencies: Schema.optionalKey(Declared) }),\n);\n\nconst Bin = Schema.Union([Schema.String, Declared]);\n\nconst Native = Schema.Struct({ binary: Schema.String, targets: Schema.Array(Schema.String) });\n\nconst Engines = Schema.Struct({ node: Schema.optionalKey(Schema.String) });\n\nconst PublishConfig = Schema.Struct({\n exports: Schema.optionalKey(Schema.Unknown),\n bin: Schema.optionalKey(Bin),\n});\n\n/** @internal */\nexport const CompatManifestJson = Schema.fromJsonString(\n Schema.Struct({\n name: Schema.String,\n version: Schema.String,\n private: Schema.optionalKey(Schema.Boolean),\n native: Schema.optionalKey(Native),\n exports: Schema.optionalKey(Schema.Unknown),\n bin: Schema.optionalKey(Bin),\n dependencies: Schema.optionalKey(Declared),\n optionalDependencies: Schema.optionalKey(Declared),\n engines: Schema.optionalKey(Engines),\n peerDependencies: Schema.optionalKey(Declared),\n publishConfig: Schema.optionalKey(PublishConfig),\n }),\n);\n\n/** @internal */\nexport type CompatManifest = typeof CompatManifestJson.Type;\n\n/** @internal */\nexport interface CompatCase {\n readonly label: \"floor\" | \"latest\";\n readonly node: string;\n readonly peers: Readonly<Record<string, string>>;\n}\n\n/** @internal */\nexport interface SmokeTargets {\n readonly imports: readonly string[];\n readonly bins: readonly string[];\n}\n\ntype Pair = readonly [string, string];\n\nconst lowestOf = (range: string): Option.Option<string> =>\n pipe(\n Option.fromNullishOr(semver.validRange(range)),\n Option.flatMap(() => Option.fromNullishOr(semver.minVersion(range))),\n Option.map(({ version }) => version),\n );\n\nconst floorOf = (version: string): string => {\n if (semver.prerelease(version) !== null) {\n return version;\n }\n return `~${String(semver.major(version))}.${String(semver.minor(version))}.0`;\n};\n\nconst pinnedPeer = ([name, range]: Pair): readonly Pair[] =>\n Option.match(lowestOf(range), {\n onNone: (): readonly Pair[] => [],\n onSome: (version): readonly Pair[] => {\n if (version === UNVERSIONED) {\n return [[name, range]];\n }\n return [[name, floorOf(version)]];\n },\n });\n\nconst floorPeers = (peers: Readonly<Record<string, string>>): Readonly<Record<string, string>> =>\n pipe(Rec.toEntries(peers), Arr.flatMap(pinnedPeer), Rec.fromEntries);\n\nconst nodeFloorOf = (manifest: CompatManifest): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(manifest.engines),\n Option.flatMap(({ node }) => Option.fromUndefinedOr(node)),\n Option.flatMap(lowestOf),\n );\n\nconst withoutViteOfVitePlus = (\n peers: Readonly<Record<string, string>>,\n): Readonly<Record<string, string>> => {\n if (Rec.has(peers, VITE_PLUS)) {\n return Rec.remove(peers, VITE);\n }\n return peers;\n};\n\n/** @internal */\nexport const viteAliasOf = (vitePlusManifest: string): Option.Option<string> =>\n pipe(\n Schema.decodeOption(VitePlusManifestJson)(vitePlusManifest),\n Option.flatMapNullishOr(({ dependencies }) => dependencies),\n Option.flatMap(Rec.get(VITE)),\n Option.map((spec) => `${VITE}@${spec}`),\n );\n\nconst casesOf = (manifest: CompatManifest, floor: string): readonly CompatCase[] => {\n const declared = withoutViteOfVitePlus(manifest.peerDependencies ?? {});\n return [\n { label: \"floor\", node: floorOf(floor), peers: floorPeers(declared) },\n { label: \"latest\", node: `^${String(semver.major(floor))}`, peers: declared },\n ];\n};\n\n/** @internal */\nexport const compatCasesOf = (manifest: CompatManifest): readonly CompatCase[] =>\n pipe(\n nodeFloorOf(manifest),\n Option.match({\n onNone: (): readonly CompatCase[] => [],\n onSome: (floor): readonly CompatCase[] => casesOf(manifest, floor),\n }),\n );\n\nconst isTypesOnly = (target: Option.Option<unknown>): boolean =>\n Option.match(target, {\n onNone: () => false,\n onSome: (value) =>\n Predicate.isReadonlyObject(value) &&\n pipe(\n Rec.keys(value),\n Arr.every((key) => key === TYPES),\n ),\n });\n\nconst subpathsOf = (exports: unknown): readonly string[] => {\n if (Predicate.isString(exports)) {\n return [ROOT_EXPORT];\n }\n if (Predicate.isReadonlyObject(exports)) {\n const keys = Rec.keys(exports);\n if (pipe(keys, Arr.every(Str.startsWith(ROOT_EXPORT)))) {\n return pipe(\n keys,\n Arr.filter((key) => key !== PACKAGE_JSON_EXPORT && !Str.includes(PATTERN)(key)),\n Arr.filter((key) => !isTypesOnly(Rec.get(exports, key))),\n );\n }\n return [ROOT_EXPORT];\n }\n return [];\n};\n\nconst specifierOf = (name: string, subpath: string): string => {\n if (subpath === ROOT_EXPORT) {\n return name;\n }\n return `${name}${Str.replace(ROOT_EXPORT, \"\")(subpath)}`;\n};\n\nconst binFilesOf = (bin: CompatManifest[\"bin\"]): readonly string[] => {\n if (Predicate.isUndefined(bin)) {\n return [];\n }\n if (Predicate.isString(bin)) {\n return [bin];\n }\n return Rec.values(bin);\n};\n\n/** @internal */\nexport const smokeTargetsOf = (manifest: CompatManifest): SmokeTargets => {\n const published = Option.fromUndefinedOr(manifest.publishConfig);\n const exports = pipe(\n published,\n Option.flatMap(({ exports: own }) => Option.fromUndefinedOr(own)),\n Option.getOrElse(() => manifest.exports),\n );\n const bin = pipe(\n published,\n Option.flatMap(({ bin: own }) => Option.fromUndefinedOr(own)),\n Option.getOrElse(() => manifest.bin),\n );\n return {\n imports: pipe(\n subpathsOf(exports),\n Arr.map((subpath) => specifierOf(manifest.name, subpath)),\n ),\n bins: binFilesOf(bin),\n };\n};\n\n/** @internal */\nexport const compatManifestIn = Effect.fn(\"compat.manifestIn\")(function* compatManifestIn(\n directory: string,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fileSystem.readFileString(path.join(directory, \"package.json\"));\n return yield* Schema.decodeEffect(CompatManifestJson)(text);\n});\n","import { Array as Arr, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nconst RUNNERS = {\n linux: \"ubuntu-latest\",\n windows: \"windows-latest\",\n macos: \"macos-latest\",\n} as const satisfies Readonly<Record<string, string>>;\n\ntype Os = keyof typeof RUNNERS;\n\nconst NODE_PLATFORMS: Readonly<Record<string, Os>> = {\n linux: \"linux\",\n win32: \"windows\",\n darwin: \"macos\",\n};\n\nconst BUILD = \"release:\";\nconst CHECK = \"release:check:\";\nconst LIBC: Readonly<Record<string, string>> = { gnu: \"glibc\", musl: \"musl\" };\nconst CPU_INDEX = 1;\nconst ABI_INDEX = 2;\n\n/** @internal */\nexport interface Runner {\n readonly os: string;\n readonly runner: string;\n}\n\n/** @internal */\nexport interface NativeTarget {\n readonly target: string;\n readonly runner: string;\n}\n\nconst systems = Rec.keys(RUNNERS);\n\nconst runnersFor = (tasks: readonly string[], prefix: string): readonly Runner[] =>\n pipe(\n systems,\n Arr.filter((os) => Arr.contains(tasks, `${prefix}${os}`)),\n Arr.map((os): Runner => ({ os, runner: RUNNERS[os] })),\n );\n\n/** @internal */\nexport const buildsOf = (tasks: readonly string[]): readonly Runner[] => runnersFor(tasks, BUILD);\n\n/** @internal */\nexport const checksOf = (tasks: readonly string[]): readonly Runner[] => runnersFor(tasks, CHECK);\n\n/** @internal */\nexport const nativeTargetsOf = (targets: readonly string[]): readonly NativeTarget[] =>\n pipe(\n targets,\n Arr.flatMap((target) =>\n pipe(\n Arr.head(Str.split(target, \"-\")),\n Option.flatMap((platform) => Rec.get(NODE_PLATFORMS, platform)),\n Option.map((os): NativeTarget => ({ target, runner: RUNNERS[os] })),\n Option.toArray,\n ),\n ),\n );\n\n/** @internal */\nexport interface NativePackage {\n readonly name: string;\n readonly version: string;\n readonly binary: string;\n readonly target: string;\n}\n\nconst libcOf = (parts: readonly string[]): Readonly<Record<string, readonly string[]>> =>\n pipe(\n Arr.get(parts, ABI_INDEX),\n Option.flatMap((abi) => Rec.get(LIBC, abi)),\n Option.match({ onNone: () => ({}), onSome: (libc) => ({ libc: [libc] }) }),\n );\n\n/** @internal */\nexport const nativeFileOf = ({ binary, target }: NativePackage): string =>\n `${binary}.${target}.node`;\n\n/** @internal */\nexport const nativeFields = (native: NativePackage): Readonly<Record<string, unknown>> => {\n const parts = Str.split(native.target, \"-\");\n const file = nativeFileOf(native);\n return {\n name: `${native.name}-${native.target}`,\n version: native.version,\n os: Option.toArray(Arr.head(parts)),\n cpu: Option.toArray(Arr.get(parts, CPU_INDEX)),\n ...libcOf(parts),\n main: file,\n files: [file],\n };\n};\n\n/** @internal */\nexport const nativeReadme = ({ name, target }: NativePackage): string =>\n `# ${name}-${target}\\n\\nThe prebuilt ${target} native addon of [${name}](https://www.npmjs.com/package/${name}). Install ${name} instead; npm picks this package for your platform.\\n`;\n","import { Array as Arr, Effect, FileSystem, Path, Record as Rec, Schema, pipe } from \"effect\";\n\nimport { nativeFields, nativeFileOf, nativeReadme } from \"./platforms.ts\";\nimport type { NativePackage } from \"./platforms.ts\";\n\nconst NPM_DIR = \"npm\";\nconst NATIVE_DIR = \"native\";\nconst MANIFEST_FILE = \"package.json\";\nconst KEPT_FIELDS: readonly string[] = [\"license\", \"repository\", \"homepage\", \"bugs\", \"engines\"];\n\n/** @internal */\nexport const PackageJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));\n\nconst keptFields = Effect.fn(\"publish.keptFields\")(function* keptFields(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE));\n const raw = yield* Schema.decodeEffect(PackageJson)(text);\n return pipe(\n raw,\n Rec.filter((_value, key) => Arr.contains(KEPT_FIELDS, key)),\n );\n});\n\n/** @internal */\nexport const writeNative = Effect.fn(\"publish.writeNative\")(function* writeNative(\n directory: string,\n native: NativePackage,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const kept = yield* keptFields(directory);\n const target = path.resolve(directory, NPM_DIR, native.target);\n const file = nativeFileOf(native);\n yield* fileSystem.makeDirectory(target, { recursive: true });\n yield* fileSystem.copyFile(path.join(directory, NATIVE_DIR, file), path.join(target, file));\n const text = yield* Schema.encodeEffect(PackageJson)({ ...kept, ...nativeFields(native) });\n yield* Effect.all(\n [\n fileSystem.writeFileString(path.join(target, MANIFEST_FILE), text),\n fileSystem.writeFileString(path.join(target, \"README.md\"), nativeReadme(native)),\n ],\n { concurrency: \"unbounded\" },\n );\n return target;\n});\n","import { Effect, FileSystem, Path } from \"effect\";\n\nconst HOOK_FILE = \"widen-ranges.mjs\";\n\n/** @internal */\nexport const WIDEN_RANGES = `const EXACT = /^\\\\d+\\\\.\\\\d+\\\\.\\\\d+(?:-[0-9A-Za-z.-]+)?(?:\\\\+[0-9A-Za-z.-]+)?$/u;\nconst widen = (held) =>\n held === undefined\n ? undefined\n : Object.fromEntries(Object.entries(held).map(([name, specifier]) => [name, EXACT.test(specifier) ? \\`^\\${specifier}\\` : specifier]));\nexport const hooks = {\n beforePacking: (manifest) => ({\n ...manifest,\n dependencies: widen(manifest.dependencies),\n peerDependencies: widen(manifest.peerDependencies),\n }),\n};\n`;\n\n/** @internal */\nexport const widenRangesEnv = Effect.fn(\"publish.widenRanges\")(function* widenRangesEnv(\n directory: string,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const hook = path.join(directory, HOOK_FILE);\n yield* fileSystem.writeFileString(hook, WIDEN_RANGES);\n return { pnpm_config_pnpmfile: hook };\n});\n","import { mustSucceed } from \"@r_masseater/github-workflow\";\nimport { Effect, FileSystem, Path } from \"effect\";\n\nimport { widenRangesEnv } from \"./widened-ranges.ts\";\n\nconst TARBALL = \"package.tgz\";\n\n/** @internal */\nexport const pack = Effect.fn(\"publish.pack\")(function* pack(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const temporary = yield* fileSystem.makeTempDirectoryScoped();\n const tarball = path.join(temporary, TARBALL);\n const env = yield* widenRangesEnv(temporary);\n yield* mustSucceed({\n command: \"vp\",\n args: [\"pm\", \"pack\", \"--out\", tarball],\n env,\n cwd: directory,\n });\n return tarball;\n});\n","import { arch, platform } from \"node:os\";\n\nimport { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\n\nimport type { CompatManifest } from \"./compat-manifest.ts\";\nimport { writeNative } from \"./native-package.ts\";\nimport { pack } from \"./pack.ts\";\n\ntype Entry = readonly [string, string];\n\ninterface Built {\n readonly directory: string;\n readonly manifest: CompatManifest;\n readonly binary: string;\n readonly target: string;\n}\n\nconst HOST_PREFIX = `${platform()}-${arch()}-`;\n\nconst builtOf = (directory: string, manifest: CompatManifest): Option.Option<Built> =>\n pipe(\n Option.fromUndefinedOr(manifest.native),\n Option.flatMap(({ binary, targets }) =>\n pipe(\n targets,\n Arr.findFirst(Str.startsWith(HOST_PREFIX)),\n Option.map((target): Built => ({ directory, manifest, binary, target })),\n ),\n ),\n );\n\nconst packedNative = Effect.fn(\"compat.packedNative\")(function* packedNative({\n directory,\n manifest,\n binary,\n target,\n}: Built) {\n const written = yield* writeNative(directory, {\n name: manifest.name,\n version: manifest.version,\n binary,\n target,\n });\n const tarball = yield* pack(written);\n const entries: readonly Entry[] = [[`${manifest.name}-${target}`, tarball]];\n return entries;\n});\n\n/** @internal */\nexport const nativeTarballs = Effect.fn(\"compat.native\")(function* nativeTarballs(\n directory: string,\n manifest: CompatManifest,\n) {\n const none: readonly Entry[] = [];\n return yield* pipe(\n builtOf(directory, manifest),\n Option.match({ onNone: () => Effect.succeed(none), onSome: packedNative }),\n );\n});\n","import { mustSucceed } from \"@r_masseater/github-workflow\";\nimport {\n Array as Arr,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record as Rec,\n pipe,\n} from \"effect\";\n\nimport { compatManifestIn } from \"./compat-manifest.ts\";\nimport type { CompatManifest } from \"./compat-manifest.ts\";\nimport { nativeTarballs } from \"./compat-native.ts\";\nimport { pack } from \"./pack.ts\";\n\ninterface Workspace {\n readonly directory: string;\n readonly manifest: CompatManifest;\n}\n\n/** @internal */\nexport type Tarballs = Readonly<Record<string, string>>;\n\nconst dependencyNamesOf = (manifest: CompatManifest): readonly string[] =>\n pipe(\n [manifest.dependencies, manifest.peerDependencies, manifest.optionalDependencies],\n Arr.flatMap((declared) => Rec.keys(declared ?? {})),\n );\n\nconst closureOf = (\n known: Readonly<Record<string, Workspace>>,\n names: readonly string[],\n seen: readonly Workspace[],\n): readonly Workspace[] => {\n const [name, ...rest] = names;\n if (Predicate.isUndefined(name)) {\n return seen;\n }\n const found = Rec.get(known, name);\n const reached = pipe(\n seen,\n Arr.some((item) => item.manifest.name === name),\n );\n if (Option.isNone(found) || reached) {\n return closureOf(known, rest, seen);\n }\n const inner = closureOf(known, dependencyNamesOf(found.value.manifest), [...seen, found.value]);\n return closureOf(known, rest, inner);\n};\n\nconst workspacesBeside = Effect.fn(\"compat.workspaces\")(function* workspacesBeside(\n directory: string,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const parent = path.dirname(path.resolve(directory));\n const entries = yield* fileSystem.readDirectory(parent);\n const found = yield* Effect.forEach(\n entries,\n (entry) =>\n compatManifestIn(path.join(parent, entry)).pipe(\n Effect.map((manifest): readonly Workspace[] => [\n { directory: path.join(parent, entry), manifest },\n ]),\n Effect.orElseSucceed((): readonly Workspace[] => []),\n ),\n { concurrency: 1 },\n );\n return pipe(\n Arr.flatten(found),\n Arr.map((workspace): readonly [string, Workspace] => [workspace.manifest.name, workspace]),\n Rec.fromEntries,\n );\n});\n\ntype Entry = readonly [string, string];\n\nconst builtTarball = Effect.fn(\"compat.pack\")(function* builtTarball(directory: string) {\n yield* mustSucceed({ command: \"vp\", args: [\"run\", \"build\"], cwd: directory });\n return yield* pack(directory);\n});\n\nconst tarballsOf = Effect.fn(\"compat.tarballs\")(function* tarballsOf({\n directory,\n manifest,\n}: Workspace) {\n const tarball = yield* builtTarball(directory);\n const natives = yield* nativeTarballs(directory, manifest);\n const own: readonly Entry[] = [[manifest.name, tarball]];\n return [...own, ...natives];\n});\n\n/** @internal */\nexport const workspaceTarballs = Effect.fn(\"compat.local\")(function* workspaceTarballs(\n directory: string,\n manifest: CompatManifest,\n) {\n const known = yield* workspacesBeside(directory);\n const reached = closureOf(known, dependencyNamesOf(manifest), [{ directory, manifest }]);\n const packed = yield* Effect.forEach(reached, tarballsOf, { concurrency: 1 });\n return Rec.fromEntries(Arr.flatten(packed));\n});\n","import { mustSucceed, outputOf } from \"@r_masseater/github-workflow\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Option,\n Path,\n Record as Rec,\n Schema,\n pipe,\n} from \"effect\";\nimport semver from \"semver\";\n\nimport {\n IncompatiblePackage,\n VITE_PLUS,\n compatManifestIn,\n compatCasesOf,\n smokeTargetsOf,\n viteAliasOf,\n} from \"./compat-manifest.ts\";\nimport type { CompatCase, CompatManifest } from \"./compat-manifest.ts\";\nimport { workspaceTarballs } from \"./compat-workspace.ts\";\nimport type { Tarballs } from \"./compat-workspace.ts\";\n\nconst MANIFEST_FILE = \"package.json\";\nconst INSTALL_FLAGS = [\"--no-audit\", \"--no-fund\"];\n\nconst LOAD_FAILURE = String.raw`/ERR_(MODULE_NOT_FOUND|PACKAGE_|INVALID_PACKAGE|UNKNOWN_FILE|UNSUPPORTED_DIR|REQUIRE_ESM)|SyntaxError/u`;\n\nconst IMPORT_ONLY = \"await import(process.argv[1])\";\n\nconst SPAWN_CHECKED = `import { spawnSync } from \"node:child_process\"; const { stderr } = spawnSync(process.execPath, process.argv.slice(1), { encoding: \"utf8\", stdio: [\"ignore\", \"ignore\", \"pipe\"], timeout: 60000 }); if (${LOAD_FAILURE}.test(stderr)) { process.stderr.write(stderr); process.exit(1); }`;\n\nconst Versions = Schema.String.pipe(Schema.Array, Schema.fromJsonString);\nconst ConsumerJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));\n\nconst installedNode = Effect.fn(\"compat.node\")(function* installedNode(\n directory: string,\n range: string,\n) {\n const path = yield* Path.Path;\n const fileSystem = yield* FileSystem.FileSystem;\n yield* fileSystem.makeDirectory(directory, { recursive: true });\n const listed = yield* outputOf({\n command: \"npm\",\n args: [\"view\", \"node\", \"versions\", \"--json\"],\n cwd: directory,\n });\n const versions = yield* Schema.decodeEffect(Versions)(listed);\n const version = yield* Effect.fromOption(\n Option.fromNullishOr(semver.maxSatisfying([...versions], range)),\n ).pipe(\n Effect.mapError(() =>\n IncompatiblePackage.make({ message: `No Node.js release satisfies ${range}` }),\n ),\n );\n yield* mustSucceed({\n command: \"npm\",\n args: [\"install\", ...INSTALL_FLAGS, `node@${version}`],\n cwd: directory,\n });\n return { version, binary: path.join(directory, \"node_modules\", \"node\", \"bin\", \"node\") };\n});\n\ninterface Consumer {\n readonly peers: Readonly<Record<string, string>>;\n readonly tarballs: Tarballs;\n}\n\nconst fileEntries = (tarballs: Tarballs): readonly (readonly [string, string])[] =>\n pipe(\n Rec.toEntries(tarballs),\n Arr.map(([name, file]): readonly [string, string] => [name, `file:${file}`]),\n );\n\nconst siblingOverrides = (tarballs: Tarballs): readonly (readonly [string, string])[] =>\n pipe(\n Rec.keys(tarballs),\n Arr.map((sibling): readonly [string, string] => [sibling, `$${sibling}`]),\n );\n\nconst consumerJson = Effect.fn(\"compat.json\")(function* consumerJson({\n peers,\n tarballs,\n}: Consumer) {\n const dependencies = Rec.fromEntries([...Rec.toEntries(peers), ...fileEntries(tarballs)]);\n return yield* Schema.encodeEffect(ConsumerJson)({\n private: true,\n type: \"module\",\n dependencies,\n overrides: Rec.fromEntries(siblingOverrides(tarballs)),\n });\n});\n\nconst withViteOfVitePlus = Effect.fn(\"compat.vite\")(function* withViteOfVitePlus(\n directory: string,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fileSystem.readFileString(\n path.join(directory, \"node_modules\", VITE_PLUS, MANIFEST_FILE),\n );\n yield* Option.match(viteAliasOf(text), {\n onNone: () => Effect.void,\n onSome: (alias) =>\n mustSucceed({\n command: \"npm\",\n args: [\"install\", \"--ignore-scripts\", \"--force\", ...INSTALL_FLAGS, alias],\n cwd: directory,\n }),\n });\n});\n\nconst installedConsumer = Effect.fn(\"compat.consumer\")(function* installedConsumer(\n root: string,\n consumer: Consumer,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = path.join(root, \"consumer\");\n yield* fileSystem.makeDirectory(directory, { recursive: true });\n const text = yield* consumerJson(consumer);\n yield* fileSystem.writeFileString(path.join(directory, MANIFEST_FILE), text);\n yield* mustSucceed({\n command: \"npm\",\n args: [\"install\", \"--ignore-scripts\", ...INSTALL_FLAGS],\n cwd: directory,\n });\n if (Rec.has(consumer.peers, VITE_PLUS)) {\n yield* withViteOfVitePlus(directory);\n }\n return directory;\n});\n\ninterface Started {\n readonly runtime: string;\n readonly consumer: string;\n readonly args: readonly string[];\n}\n\nconst loadsCleanly = ({ runtime, consumer, args }: Started): ReturnType<typeof mustSucceed> =>\n mustSucceed({\n command: runtime,\n args: [\"--input-type=module\", \"-e\", SPAWN_CHECKED, \"--\", ...args],\n cwd: consumer,\n });\n\nconst smoke = Effect.fn(\"compat.smoke\")(function* smoke(\n manifest: CompatManifest,\n runtime: string,\n consumer: string,\n) {\n const path = yield* Path.Path;\n const { imports, bins } = smokeTargetsOf(manifest);\n const importer = [\"--input-type=module\", \"-e\", IMPORT_ONLY];\n yield* Effect.forEach(\n imports,\n (specifier) => loadsCleanly({ runtime, consumer, args: [...importer, specifier] }),\n { concurrency: 1, discard: true },\n );\n yield* Effect.forEach(\n bins,\n (file) =>\n loadsCleanly({\n runtime,\n consumer,\n args: [path.join(consumer, \"node_modules\", manifest.name, file), \"--help\"],\n }),\n { concurrency: 1, discard: true },\n );\n});\n\ninterface Run {\n readonly manifest: CompatManifest;\n readonly tarballs: Tarballs;\n readonly compat: CompatCase;\n}\n\nconst runCase = Effect.fn(\"compat.case\")(function* runCase({ manifest, tarballs, compat }: Run) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const root = yield* fileSystem.makeTempDirectoryScoped();\n const runtime = yield* installedNode(path.join(root, \"runtime\"), compat.node);\n const consumer = yield* installedConsumer(root, { peers: compat.peers, tarballs });\n const peers = pipe(\n Rec.toEntries(compat.peers),\n Arr.map(([name, range]) => `${name}@${range}`),\n Arr.join(\", \"),\n );\n yield* Console.log(\n `${manifest.name} ${compat.label}: Node.js ${runtime.version}, peers ${peers}`,\n );\n yield* smoke(manifest, runtime.binary, consumer);\n}, Effect.scoped);\n\n/** @internal */\nexport const checkCompat = Effect.fn(\"publish.compat\")(function* checkCompat(directory: string) {\n const manifest = yield* compatManifestIn(directory);\n const cases = compatCasesOf(manifest);\n if (Arr.isReadonlyArrayEmpty(cases)) {\n return yield* IncompatiblePackage.make({\n message: `${manifest.name} declares no engines.node, so there is no supported Node.js range to check`,\n });\n }\n const tarballs = yield* workspaceTarballs(directory, manifest);\n return yield* Effect.forEach(cases, (compat) => runCase({ manifest, tarballs, compat }), {\n concurrency: 1,\n discard: true,\n });\n}, Effect.scoped);\n","import { Effect, FileSystem, Option, Path, Schema, String as Str, pipe } from \"effect\";\n\nconst MANIFEST_FILE = \"package.json\";\nconst SCOPE = /^@[^/]+\\//u;\nconst UNVERSIONED = \"0.0.0\";\nconst ROOT = \".\";\n\nconst Native = Schema.Struct({ binary: Schema.String, targets: Schema.Array(Schema.String) });\n\nconst ManifestSchema = Schema.Struct({\n name: Schema.String,\n version: Schema.String,\n private: Schema.optionalKey(Schema.Boolean),\n dependencies: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n native: Schema.optionalKey(Native),\n \"size-limit\": Schema.optionalKey(Schema.Unknown),\n});\n\n/** @internal */\nexport type Manifest = typeof ManifestSchema.Type;\n\n/** @internal */\nexport const manifestIn = Effect.fn(\"publish.manifest\")(function* manifestIn(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fileSystem.readFileString(path.join(directory, MANIFEST_FILE));\n return yield* Schema.decodeEffect(Schema.fromJsonString(ManifestSchema))(text);\n});\n\n/** @internal */\nexport const releaseName = ({ name }: Pick<Manifest, \"name\">): string =>\n Str.replace(SCOPE, \"\")(name);\n\n/** @internal */\nexport const isRoot = (directory: string): boolean => directory === ROOT;\n\n/** @internal */\nexport interface Tagged extends Pick<Manifest, \"name\" | \"version\"> {\n readonly directory: string;\n}\n\n/** @internal */\nexport const tagOf = ({ directory, name, version }: Tagged): string => {\n if (isRoot(directory)) {\n return `v${version}`;\n }\n return `${releaseName({ name })}-v${version}`;\n};\n\n/** @internal */\nexport const environmentOf = (manifest: Pick<Manifest, \"name\">): string =>\n `${releaseName(manifest)}-release`;\n\n/** @internal */\nexport const isVersioned = ({ version }: Pick<Manifest, \"version\">): boolean =>\n version !== UNVERSIONED;\n\n/** @internal */\nexport const goesToNpm = (manifest: Pick<Manifest, \"private\">): boolean =>\n !pipe(\n Option.fromUndefinedOr(manifest.private),\n Option.getOrElse(() => false),\n );\n","import { succeeds } from \"@r_masseater/github-workflow\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport { goesToNpm, manifestIn } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\n\nconst WORKSPACE_PROTOCOL = \"workspace:\";\nconst READ_CONCURRENCY = 8;\n\n/** @internal */\nexport interface Published {\n readonly directory: string;\n readonly name: string;\n readonly version: string;\n}\n\n/** @internal */\nexport const onNpm = ({ directory, name, version }: Published): ReturnType<typeof succeeds> =>\n succeeds({ command: \"npm\", args: [\"view\", `${name}@${version}`, \"version\"], cwd: directory });\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class UnpublishedDependencies extends taggedError<\n UnpublishedDependencies,\n { readonly brand: unique symbol }\n>()(\"UnpublishedDependencies\", { message: Schema.String }) {}\n\nconst workspaceDependencies = (manifest: Manifest): readonly string[] =>\n pipe(\n Option.fromUndefinedOr(manifest.dependencies),\n Option.map((dependencies) =>\n pipe(dependencies, Rec.filter(Str.startsWith(WORKSPACE_PROTOCOL)), Rec.keys),\n ),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst failWhenMissing = (\n missing: readonly Published[],\n manifest: Manifest,\n): Effect.Effect<void, UnpublishedDependencies> => {\n if (Arr.isReadonlyArrayEmpty(missing)) {\n return Effect.void;\n }\n const names = pipe(\n missing,\n Arr.map(({ directory, name, version }) => `${name}@${version} (${directory})`),\n Arr.join(\", \"),\n );\n return Effect.fail(\n UnpublishedDependencies.make({\n message: `${manifest.name} depends on versions that are not on npm yet. Publish them first: ${names}`,\n }),\n );\n};\n\n/** @internal */\nexport interface Dependent {\n readonly manifest: Manifest;\n readonly workspaces: readonly string[];\n}\n\n/** @internal */\nexport const requirePublishedDependencies = Effect.fn(\"publish.dependencies\")(\n function* requirePublishedDependencies({ manifest, workspaces }: Dependent) {\n const wanted = workspaceDependencies(manifest);\n const siblings = yield* Effect.forEach(\n workspaces,\n (directory) => manifestIn(directory).pipe(Effect.map((found) => ({ directory, ...found }))),\n { concurrency: READ_CONCURRENCY },\n );\n const internal = pipe(\n siblings,\n Arr.filter((sibling) => Arr.contains(wanted, sibling.name) && goesToNpm(sibling)),\n );\n const missing = yield* Effect.filter(\n internal,\n (sibling) => onNpm(sibling).pipe(Effect.map((published) => !published)),\n { concurrency: READ_CONCURRENCY },\n );\n yield* failWhenMissing(missing, manifest);\n },\n);\n","import { mask } from \"@r_masseater/github-workflow\";\nimport { Console, Effect, Option, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\n\nimport { BROKER, actionsOidcToken } from \"#/shared/lib/credential-broker.ts\";\n\nconst Issued = Schema.Record(Schema.String, Schema.Unknown);\n\n/** @internal */\nexport interface Credential {\n readonly kind: string;\n readonly field: string;\n}\n\nconst issued = Effect.fn(\"publish.issued\")(function* issued(\n oidc: string,\n { kind, field }: Credential,\n) {\n const client = yield* HttpClient.HttpClient;\n const request = HttpClientRequest.post(`${BROKER}?only=${kind}`).pipe(\n HttpClientRequest.bearerToken(oidc),\n );\n const response = yield* HttpClient.filterStatusOk(client).execute(request);\n const body = yield* HttpClientResponse.schemaBodyJson(Issued)(response);\n const token = Option.filter(\n Option.fromNullishOr(body[field]),\n (value): value is string => typeof value === \"string\" && value !== \"\",\n );\n yield* Effect.forEach(Option.toArray(token), mask, { concurrency: 1, discard: true });\n return token;\n});\n\n/** @internal */\nexport const brokerCredential = Effect.fn(\"publish.brokerCredential\")(function* brokerCredential(\n credential: Credential,\n) {\n return yield* actionsOidcToken.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.succeedNone,\n onSome: (oidc) => issued(oidc, credential),\n }),\n ),\n Effect.tapError(() => Console.log(`The credential broker gave no ${credential.field}`)),\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n});\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\nimport { Base64 } from \"effect/encoding\";\nimport { HttpClient, HttpClientResponse } from \"effect/http\";\n\nconst ATTESTATIONS = \"https://registry.npmjs.org/-/npm/v1/attestations/\";\nconst SLSA = /slsa\\.dev\\/provenance/u;\n\nconst Digest = Schema.Struct({ gitCommit: Schema.String });\nconst Dependency = Schema.Struct({ digest: Digest });\nconst BuildDefinition = Schema.Struct({ resolvedDependencies: Schema.Array(Dependency) });\nconst Predicate = Schema.Struct({ buildDefinition: BuildDefinition });\nconst Statement = Schema.fromJsonString(Schema.Struct({ predicate: Predicate }));\n\nconst Envelope = Schema.Struct({ payload: Schema.String });\nconst Bundle = Schema.Struct({ dsseEnvelope: Envelope });\nconst Attestation = Schema.Struct({ predicateType: Schema.String, bundle: Bundle });\nconst Attestations = Schema.Struct({ attestations: Schema.Array(Attestation) });\n\n/** @internal */\nexport interface Version {\n readonly name: string;\n readonly version: string;\n}\n\nconst commitOf = (payload: string): Effect.Effect<Option.Option<string>> =>\n pipe(\n Base64.decodeString(payload),\n Effect.fromResult,\n Effect.flatMap(Schema.decodeEffect(Statement)),\n Effect.map(({ predicate }) =>\n pipe(\n Arr.head(predicate.buildDefinition.resolvedDependencies),\n Option.map(({ digest }) => digest.gitCommit),\n ),\n ),\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n\n/** @internal */\nexport const provenanceCommit = Effect.fn(\"publish.provenanceCommit\")(function* provenanceCommit({\n name,\n version,\n}: Version) {\n const client = yield* HttpClient.HttpClient;\n const url = `${ATTESTATIONS}${Str.replace(\"/\", \"%2f\")(name)}@${version}`;\n const found = yield* HttpClient.filterStatusOk(client)\n .get(url)\n .pipe(\n Effect.flatMap(HttpClientResponse.schemaBodyJson(Attestations)),\n Effect.map(({ attestations }) =>\n Arr.findFirst(attestations, ({ predicateType }) => SLSA.test(predicateType)),\n ),\n Effect.orElseSucceed(() => Option.none<(typeof Attestations.Type.attestations)[number]>()),\n );\n if (Option.isNone(found)) {\n return Option.none<string>();\n }\n return yield* commitOf(found.value.bundle.dsseEnvelope.payload);\n});\n","import { mustSucceed, outputOf, succeeds } from \"@r_masseater/github-workflow\";\nimport { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\nimport semver from \"semver\";\n\nimport { brokerCredential } from \"./broker.ts\";\nimport { goesToNpm, tagOf } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { provenanceCommit } from \"./provenance.ts\";\n\nconst UNVERSIONED = \"0.0.0\";\nconst LOOKUP_CONCURRENCY = 4;\n\nconst Versions = Schema.String.pipe(Schema.Array, Schema.fromJsonString);\n\n/** @internal */\nexport interface Workspace {\n readonly directory: string;\n readonly manifest: Manifest;\n}\n\n/** @internal */\nexport interface Revision {\n readonly tag: string;\n readonly sha: string;\n}\n\n/** @internal */\nexport const tagged = Effect.fn(\"publish.tagged\")(function* tagged(tag: string) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n return yield* succeeds({\n command: \"gh\",\n args: [\"api\", `repos/${repository}/git/ref/tags/${tag}`],\n });\n});\n\nconst tokenEnv = brokerCredential({ kind: \"github\", field: \"githubToken\" }).pipe(\n Effect.map(\n Option.match({\n onNone: (): Readonly<Record<string, string>> => ({}),\n onSome: (value): Readonly<Record<string, string>> => ({ GH_TOKEN: value }),\n }),\n ),\n);\n\n/** @internal */\nexport const createTag = Effect.fn(\"publish.createTag\")(function* createTag({\n tag,\n sha,\n}: Revision) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const env = yield* tokenEnv;\n yield* Effect.logInfo(`tagging ${tag} at ${sha}`);\n yield* mustSucceed({\n command: \"gh\",\n env,\n args: [\n \"api\",\n \"-X\",\n \"POST\",\n `repos/${repository}/git/refs`,\n \"-f\",\n `ref=refs/tags/${tag}`,\n \"-f\",\n `sha=${sha}`,\n ],\n });\n});\n\nconst isRelease = (version: string): boolean =>\n version !== UNVERSIONED && semver.valid(version) !== null && semver.prerelease(version) === null;\n\nconst publishedVersions = Effect.fn(\"publish.publishedVersions\")(function* publishedVersions({\n directory,\n manifest,\n}: Workspace) {\n if (!goesToNpm(manifest)) {\n return [];\n }\n const text = yield* outputOf({\n command: \"npm\",\n args: [\"view\", manifest.name, \"versions\", \"--json\"],\n cwd: directory,\n }).pipe(Effect.orElseSucceed(() => \"[]\"));\n const versions = yield* Schema.decodeEffect(Versions)(text).pipe(\n Effect.orElseSucceed((): readonly string[] => []),\n );\n return pipe(\n versions,\n Arr.filter((version) => isRelease(version) && version !== manifest.version),\n );\n});\n\n/** @internal */\nexport const untaggedVersions = Effect.fn(\"publish.untaggedVersions\")(function* untaggedVersions(\n workspace: Workspace,\n) {\n const versions = yield* publishedVersions(workspace);\n return yield* Effect.filter(\n versions,\n (version) =>\n tagged(\n tagOf({ directory: workspace.directory, name: workspace.manifest.name, version }),\n ).pipe(Effect.map((found) => !found)),\n { concurrency: LOOKUP_CONCURRENCY },\n );\n});\n\nconst backfillVersion = Effect.fn(\"publish.backfillVersion\")(function* backfillVersion(\n workspace: Workspace,\n version: string,\n) {\n const { directory, manifest } = workspace;\n const tag = tagOf({ directory, name: manifest.name, version });\n const commit = yield* provenanceCommit({ name: manifest.name, version });\n if (Option.isNone(commit)) {\n yield* Effect.logWarning(`${tag} has no npm provenance, so it stays untagged`);\n return;\n }\n yield* createTag({ tag, sha: commit.value });\n});\n\n/** @internal */\nexport const backfillTags = Effect.fn(\"publish.backfillTags\")(function* backfillTags(\n workspace: Workspace,\n) {\n const versions = yield* untaggedVersions(workspace);\n yield* Effect.forEach(versions, (version) => backfillVersion(workspace, version), {\n concurrency: 1,\n discard: true,\n });\n});\n","import { outputOf, succeeds, writeOutputs } from \"@r_masseater/github-workflow\";\nimport {\n Array as Arr,\n Config,\n Effect,\n Option,\n Path,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { onNpm, requirePublishedDependencies } from \"./dependencies.ts\";\nimport {\n environmentOf,\n goesToNpm,\n isRoot,\n isVersioned,\n manifestIn,\n releaseName,\n tagOf,\n} from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { buildsOf, checksOf, nativeTargetsOf } from \"./platforms.ts\";\nimport { tagged, untaggedVersions } from \"./tags.ts\";\n\nconst HOOK = \"release:publish\";\nconst NONE = 0;\nconst TRAILING_SLASH = /\\/$/u;\n\nconst Task = Schema.Struct({ package: Schema.String, name: Schema.String });\n\nconst TaskGraph = Schema.fromJsonString(\n Schema.Struct({ workspaceRoot: Schema.String, tasks: Schema.Record(Schema.String, Task) }),\n);\n\nconst Runner = Schema.Struct({ os: Schema.String, runner: Schema.String });\n\nconst NativeTarget = Schema.Struct({ target: Schema.String, runner: Schema.String });\n\nconst PlanSchema = Schema.Struct({\n directory: Schema.String,\n name: Schema.String,\n version: Schema.String,\n tag: Schema.String,\n environment: Schema.String,\n npm: Schema.Boolean,\n native: Schema.Array(NativeTarget),\n builds: Schema.Array(Runner),\n checks: Schema.Array(Runner),\n release: Schema.Boolean,\n tagged: Schema.Boolean,\n hook: Schema.Boolean,\n});\n\n/** @internal */\nexport type Plan = typeof PlanSchema.Type;\n\nconst AssetCount = Schema.fromJsonString(Schema.Finite);\n\n/** @internal */\nexport const graphTasks = outputOf({ command: \"vp\", args: [\"run\", \"--json\"] }).pipe(\n Effect.flatMap(Schema.decodeEffect(TaskGraph)),\n Effect.map(({ tasks }) => Rec.values(tasks)),\n);\n\nconst tasksIn = (tasks: readonly (typeof Task.Type)[], directory: string): readonly string[] =>\n pipe(\n tasks,\n Arr.filter((task) => task.package === directory),\n Arr.map(({ name }) => name),\n );\n\n/** @internal */\nexport const workspacesOf = (tasks: readonly (typeof Task.Type)[]): readonly string[] =>\n pipe(\n tasks,\n Arr.map((task) => task.package),\n Arr.dedupe,\n );\n\nconst allTagged = Effect.fn(\"publish.allTagged\")(function* allTagged(\n directory: string,\n manifest: Manifest,\n) {\n if (!isVersioned(manifest)) {\n return true;\n }\n const current = yield* tagged(tagOf({ directory, ...manifest }));\n const older = yield* untaggedVersions({ directory, manifest });\n return current && Arr.isReadonlyArrayEmpty(older);\n});\n\nconst workspaceOf = (directory: string): Effect.Effect<string, never, Path.Path> =>\n Path.Path.pipe(Effect.map((path) => Str.replace(TRAILING_SLASH, \"\")(path.normalize(directory))));\n\n/** @internal */\nexport const released = Effect.fn(\"publish.released\")(function* released(tag: string) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n return yield* succeeds({ command: \"gh\", args: [\"release\", \"view\", tag, \"--repo\", repository] });\n});\n\n/** @internal */\nexport const releasedWithAssets = Effect.fn(\"publish.releasedWithAssets\")(\n function* releasedWithAssets(tag: string) {\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const view = [\"release\", \"view\", tag, \"--repo\", repository];\n const exists = yield* released(tag);\n if (!exists) {\n return false;\n }\n const count = yield* outputOf({\n command: \"gh\",\n args: [...view, \"--json\", \"assets\", \"--jq\", \".assets | length\"],\n }).pipe(Effect.flatMap(Schema.decodeEffect(AssetCount)));\n return count > NONE;\n },\n);\n\nconst keepWhen =\n (kept: boolean) =>\n <Item>(items: readonly Item[]): readonly Item[] =>\n pipe(\n items,\n Arr.filter(() => kept),\n );\n\nconst needsNpm = Effect.fn(\"publish.needsNpm\")(function* needsNpm(\n directory: string,\n manifest: Manifest,\n workspaces: readonly string[],\n) {\n if (!goesToNpm(manifest)) {\n return false;\n }\n const published = yield* onNpm({ directory, ...manifest });\n if (published) {\n return false;\n }\n yield* requirePublishedDependencies({ manifest, workspaces });\n return true;\n});\n\nconst needsRelease = Effect.fn(\"publish.needsRelease\")(function* needsRelease(\n directory: string,\n manifest: Manifest,\n builds: readonly unknown[],\n) {\n const tag = tagOf({ directory, ...manifest });\n if (!isVersioned(manifest)) {\n return false;\n }\n if (isRoot(directory)) {\n return !(yield* released(tag));\n }\n if (Arr.isReadonlyArrayEmpty(builds)) {\n return false;\n }\n return !(yield* releasedWithAssets(tag));\n});\n\nconst nativeOf = (manifest: Manifest): readonly (typeof NativeTarget.Type)[] =>\n pipe(\n Option.fromUndefinedOr(manifest.native),\n Option.map(({ targets }) => nativeTargetsOf(targets)),\n Option.getOrElse((): readonly (typeof NativeTarget.Type)[] => []),\n );\n\n/** @internal */\nexport const planOf = Effect.fn(\"publish.plan\")(function* planOf(directory: string) {\n const workspace = yield* workspaceOf(directory);\n const manifest = yield* manifestIn(workspace);\n const graph = yield* graphTasks;\n const tasks = tasksIn(graph, workspace);\n const npm = yield* needsNpm(workspace, manifest, workspacesOf(graph));\n const release = yield* needsRelease(workspace, manifest, buildsOf(tasks));\n const built = keepWhen(release || !isVersioned(manifest));\n const tag = tagOf({ directory: workspace, ...manifest });\n return {\n directory: workspace,\n name: releaseName(manifest),\n version: manifest.version,\n tag,\n tagged: yield* allTagged(workspace, manifest),\n environment: environmentOf(manifest),\n npm,\n native: keepWhen(npm)(nativeOf(manifest)),\n builds: built(buildsOf(tasks)),\n checks: built(checksOf(tasks)),\n release,\n hook: release && Arr.contains(tasks, HOOK),\n } satisfies Plan;\n});\n\n/** @internal */\nexport const writePlan = Effect.fn(\"publish.writePlan\")(function* writePlan(plan: Plan) {\n const encoded = yield* Schema.encodeEffect(Schema.fromJsonString(PlanSchema))(plan);\n yield* Effect.logInfo(encoded);\n yield* writeOutputs({ plan: encoded });\n});\n","import { writeOutputs } from \"@r_masseater/github-workflow\";\nimport { Array as Arr, Effect, Schema } from \"effect\";\n\nimport { compatCasesOf, compatManifestIn } from \"./compat-manifest.ts\";\nimport { goesToNpm } from \"./manifest.ts\";\nimport { graphTasks, workspacesOf } from \"./plan.ts\";\n\nconst Directories = Schema.String.pipe(Schema.Array, Schema.fromJsonString);\n\nconst isChecked = Effect.fn(\"compat.isChecked\")(function* isChecked(directory: string) {\n const manifest = yield* compatManifestIn(directory);\n return goesToNpm(manifest) && !Arr.isReadonlyArrayEmpty(compatCasesOf(manifest));\n});\n\n/** @internal */\nexport const writeCompatPlan = Effect.fn(\"publish.compatPlan\")(function* writeCompatPlan() {\n const graph = yield* graphTasks;\n const checked = yield* Effect.filter(workspacesOf(graph), isChecked, { concurrency: 1 });\n const encoded = yield* Schema.encodeEffect(Directories)(checked);\n yield* Effect.logInfo(encoded);\n yield* writeOutputs({ directories: encoded });\n});\n","import {\n Array as Arr,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nconst PATTERN = \"*\";\nconst MANIFEST_FILE = \"package.json\";\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class MissingExportTargets extends taggedError<\n MissingExportTargets,\n { readonly brand: unique symbol }\n>()(\"MissingExportTargets\", { message: Schema.String }) {}\n\nconst AnyExports = Schema.optionalKey(Schema.Unknown);\nconst PublishConfig = Schema.Struct({ exports: AnyExports });\n\nconst PublishedExports = Schema.fromJsonString(\n Schema.Struct({ exports: AnyExports, publishConfig: Schema.optionalKey(PublishConfig) }),\n);\n\ntype PublishedManifest = typeof PublishedExports.Type;\n\nconst singleTarget = (target: string): readonly string[] => {\n if (Str.includes(PATTERN)(target)) {\n return [];\n }\n return [target];\n};\n\n/** @internal */\nexport const exportTargetsOf = (exports: unknown): readonly string[] => {\n if (Predicate.isString(exports)) {\n return singleTarget(exports);\n }\n if (Arr.isArray(exports)) {\n return pipe(\n exports,\n Arr.flatMap((entry) => exportTargetsOf(entry)),\n );\n }\n if (Predicate.isReadonlyObject(exports)) {\n return pipe(\n Rec.values(exports),\n Arr.flatMap((entry) => exportTargetsOf(entry)),\n );\n }\n return [];\n};\n\nconst publishedExportsOf = (manifest: PublishedManifest): unknown =>\n pipe(\n Option.fromUndefinedOr(manifest.publishConfig),\n Option.flatMap((config) => Option.fromUndefinedOr(config.exports)),\n Option.orElse(() => Option.fromUndefinedOr(manifest.exports)),\n Option.getOrUndefined,\n );\n\nconst missingMessage = (missing: readonly string[]): string =>\n `The published exports point to files the build did not write: ${Arr.join(missing, \", \")}`;\n\n/** @internal */\nexport const checkExportTargets = Effect.fn(\"publish.checkExportTargets\")(\n function* checkExportTargets(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const manifest = yield* fileSystem\n .readFileString(path.join(directory, MANIFEST_FILE))\n .pipe(Effect.flatMap(Schema.decodeEffect(PublishedExports)));\n const missing = yield* Effect.filter(exportTargetsOf(publishedExportsOf(manifest)), (target) =>\n Effect.map(fileSystem.exists(path.join(directory, target)), (found) => !found),\n );\n return yield* pipe(\n missing,\n Arr.match({\n onEmpty: () => Effect.void,\n onNonEmpty: (list) =>\n Effect.fail(MissingExportTargets.make({ message: missingMessage(list) })),\n }),\n );\n },\n);\n","import { mustSucceed } from \"@r_masseater/github-workflow\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record as Rec,\n Schema,\n pipe,\n} from \"effect\";\n\nimport { brokerCredential } from \"./broker.ts\";\nimport { checkCompat } from \"./compat.ts\";\nimport { onNpm } from \"./dependencies.ts\";\nimport { checkExportTargets } from \"./export-targets.ts\";\nimport { manifestIn } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { PackageJson, writeNative } from \"./native-package.ts\";\nimport { pack } from \"./pack.ts\";\n\nconst MANIFEST_FILE = \"package.json\";\nconst PUBLISH_FLAGS = [\"--provenance\", \"--access\", \"public\"];\n\ntype Env = Readonly<Record<string, string>>;\n\nconst PlatformManifest = Schema.fromJsonString(\n Schema.Struct({ name: Schema.String, version: Schema.String }),\n);\nconst authEnv = Effect.fn(\"publish.authEnv\")(function* authEnv() {\n const token = yield* brokerCredential({ kind: \"npm\", field: \"npmToken\" });\n return Option.match(token, {\n onNone: (): Env => ({}),\n onSome: (value): Env => ({ NODE_AUTH_TOKEN: value }),\n });\n});\n\nconst verifyPackage = Effect.fn(\"publish.verify\")(function* verifyPackage(\n directory: string,\n manifest: Manifest,\n) {\n const size = pipe(\n Option.fromUndefinedOr(manifest[\"size-limit\"]),\n Option.map(() => \"size\"),\n Option.toArray,\n );\n const tasks = [\"build\", \"test\", ...size];\n yield* Effect.forEach(\n tasks,\n (task) => mustSucceed({ command: \"vp\", args: [\"run\", task], cwd: directory }),\n { concurrency: 1, discard: true },\n );\n yield* checkExportTargets(directory);\n yield* checkCompat(directory);\n});\n\nconst publishNative = Effect.fn(\"publish.publishNative\")(function* publishNative(\n target: string,\n env: Env,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const { name, version } = yield* fileSystem\n .readFileString(path.join(target, MANIFEST_FILE))\n .pipe(Effect.flatMap(Schema.decodeEffect(PlatformManifest)));\n if (yield* onNpm({ directory: target, name, version })) {\n yield* Console.log(`${name}@${version} is already published, skipping`);\n return name;\n }\n yield* mustSucceed({\n command: \"npm\",\n args: [\"publish\", \".\", ...PUBLISH_FLAGS],\n env,\n cwd: target,\n });\n return name;\n});\n\nconst addOptionalDependencies = Effect.fn(\"publish.optionalDependencies\")(\n function* addOptionalDependencies(directory: string, names: readonly string[], version: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(directory, MANIFEST_FILE);\n const manifest = yield* fileSystem\n .readFileString(file)\n .pipe(Effect.flatMap(Schema.decodeEffect(PackageJson)));\n const optionalDependencies = pipe(\n names,\n Arr.map((name): readonly [string, string] => [name, version]),\n Rec.fromEntries,\n );\n const updated = yield* Schema.encodeEffect(PackageJson)({ ...manifest, optionalDependencies });\n yield* fileSystem.writeFileString(file, updated);\n },\n);\n\nconst publishNatives = Effect.fn(\"publish.publishNatives\")(function* publishNatives(\n directory: string,\n manifest: Manifest,\n env: Env,\n) {\n if (Predicate.isUndefined(manifest.native)) {\n return;\n }\n const { binary, targets } = manifest.native;\n const written = yield* Effect.forEach(\n targets,\n (target) =>\n writeNative(directory, { name: manifest.name, version: manifest.version, binary, target }),\n { concurrency: 1 },\n );\n const names = yield* Effect.forEach(written, (target) => publishNative(target, env), {\n concurrency: 1,\n });\n yield* addOptionalDependencies(directory, names, manifest.version);\n});\n\n/** @internal */\nexport const publishToNpm = Effect.fn(\"publish.npm\")(function* publishToNpm(directory: string) {\n const manifest = yield* manifestIn(directory);\n if (yield* onNpm({ directory, ...manifest })) {\n return yield* Console.log(`${manifest.name}@${manifest.version} is already published`);\n }\n yield* verifyPackage(directory, manifest);\n const env = yield* authEnv();\n yield* publishNatives(directory, manifest, env);\n const tarball = yield* pack(directory);\n return yield* mustSucceed({\n command: \"npm\",\n args: [\"publish\", tarball, ...PUBLISH_FLAGS],\n env,\n cwd: directory,\n });\n}, Effect.scoped);\n","import { mustSucceed, succeeds, writeOutputs } from \"@r_masseater/github-workflow\";\nimport { Array as Arr, Config, Effect, FileSystem, Option, Order, Path, pipe } from \"effect\";\n\nimport { goesToNpm, isRoot, isVersioned, manifestIn, releaseName, tagOf } from \"./manifest.ts\";\nimport type { Manifest } from \"./manifest.ts\";\nimport { releasedWithAssets } from \"./plan.ts\";\nimport { provenanceCommit } from \"./provenance.ts\";\nimport { backfillTags, createTag, tagged } from \"./tags.ts\";\n\nconst ASSETS = \"release-assets\";\n\nconst revisionOf = Effect.fn(\"publish.revision\")(function* revisionOf(manifest: Manifest) {\n const head = yield* Config.String(\"GITHUB_SHA\");\n if (!goesToNpm(manifest)) {\n return head;\n }\n const published = yield* provenanceCommit(manifest);\n return Option.getOrElse(published, () => head);\n});\n\nconst tagRevision = Effect.fn(\"publish.tag\")(function* tagRevision(\n tag: string,\n manifest: Manifest,\n) {\n if (yield* tagged(tag)) {\n return;\n }\n const sha = yield* revisionOf(manifest);\n yield* createTag({ tag, sha });\n});\n\nconst assetsIn = Effect.fn(\"publish.assets\")(function* assetsIn(directory: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const folder = path.join(directory, ASSETS);\n if (!(yield* fileSystem.exists(folder))) {\n return [];\n }\n const names = yield* fileSystem.readDirectory(folder, { recursive: true });\n const files = yield* Effect.filter(\n pipe(\n names,\n Arr.map((name) => path.join(folder, name)),\n ),\n (file) =>\n fileSystem.stat(file).pipe(\n Effect.map(({ type }) => type === \"File\"),\n Effect.orElseSucceed(() => false),\n ),\n );\n return Arr.sort(files, Order.String);\n});\n\nconst LIBRARY_NOTES = [\"--latest=false\", \"--notes\", \"\"];\nconst ROOT_NOTES = [\"--latest\", \"--generate-notes\"];\n\nconst notesOf = (directory: string): readonly string[] => {\n if (isRoot(directory)) {\n return ROOT_NOTES;\n }\n return LIBRARY_NOTES;\n};\n\ninterface Release {\n readonly directory: string;\n readonly manifest: Manifest;\n}\n\nconst createRelease = Effect.fn(\"publish.createRelease\")(function* createRelease({\n directory,\n manifest,\n}: Release) {\n const tag = tagOf({ directory, ...manifest });\n const notes = notesOf(directory);\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n const exists = yield* succeeds({\n command: \"gh\",\n args: [\"release\", \"view\", tag, \"--repo\", repository],\n });\n if (exists) {\n return;\n }\n yield* mustSucceed({\n command: \"gh\",\n args: [\n \"release\",\n \"create\",\n tag,\n \"--repo\",\n repository,\n \"--verify-tag\",\n \"--title\",\n `${releaseName(manifest)} v${manifest.version}`,\n ...notes,\n ],\n });\n});\n\nconst uploadAssets = Effect.fn(\"publish.uploadAssets\")(function* uploadAssets({\n directory,\n manifest,\n}: Release) {\n const tag = tagOf({ directory, ...manifest });\n const files = yield* assetsIn(directory);\n if (Arr.isReadonlyArrayEmpty(files) || (yield* releasedWithAssets(tag))) {\n return;\n }\n const repository = yield* Config.String(\"GITHUB_REPOSITORY\");\n yield* createRelease({ directory, manifest });\n yield* mustSucceed({\n command: \"gh\",\n args: [\"release\", \"upload\", tag, ...files, \"--repo\", repository, \"--clobber\"],\n });\n});\n\n/** @internal */\nexport const publishRelease = Effect.fn(\"publish.release\")(function* publishRelease(\n directory: string,\n) {\n const manifest = yield* manifestIn(directory);\n if (!isVersioned(manifest)) {\n yield* Effect.logInfo(`${manifest.name} has no version to publish`);\n return;\n }\n const tag = tagOf({ directory, ...manifest });\n yield* Effect.andThen(tagRevision(tag, manifest), backfillTags({ directory, manifest }));\n yield* writeOutputs({ tag });\n if (isRoot(directory)) {\n yield* createRelease({ directory, manifest });\n }\n yield* uploadAssets({ directory, manifest });\n});\n","#!/usr/bin/env node\nimport { Effect, Schema, Stdio } from \"effect\";\n\nimport { runCli } from \"#/app/runtime.ts\";\nimport {\n checkCompat,\n planOf,\n publishRelease,\n publishToNpm,\n writeCompatPlan,\n writePlan,\n} from \"#/features/publish-workspace/index.ts\";\n\nconst Arguments = Schema.Tuple([\n Schema.Literals([\"plan\", \"npm\", \"release\", \"compat\", \"compat-plan\"]),\n Schema.String,\n]);\n\nconst taggedError = Schema.TaggedError;\n\nclass UsageError extends taggedError<UsageError, { readonly brand: unique symbol }>()(\n \"UsageError\",\n { message: Schema.String },\n) {}\n\nconst USAGE = \"usage: msch-publish <plan|npm|release|compat|compat-plan> <workspace directory>\";\n\nconst steps = {\n plan: Effect.fn(\"plan\")(function* plan(directory: string) {\n return yield* planOf(directory).pipe(Effect.flatMap(writePlan));\n }),\n npm: publishToNpm,\n release: publishRelease,\n compat: checkCompat,\n \"compat-plan\": Effect.fn(\"compat-plan\")(function* compatPlan() {\n return yield* writeCompatPlan();\n }),\n};\n\nconst publish = Effect.gen(function* publish() {\n const stdio = yield* Stdio.Stdio;\n const args = yield* stdio.args;\n const [step, directory] = yield* Schema.decodeUnknownEffect(Arguments)(args).pipe(\n Effect.mapError(() => UsageError.make({ message: USAGE })),\n );\n return yield* steps[step](directory);\n});\n\nrunCli(publish);\n"],"mappings":";;;;;;;;;AAcA,MAAM,sBAAsB;AAC5B,MAAMA,YAAU;AAChB,MAAM,cAAc;AACpB,MAAMC,gBAAc;AACpB,MAAM,OAAO;;AAGb,MAAa,YAAY;AACzB,MAAM,QAAQ;AAEd,MAAMC,gBAAc,OAAO;;AAG3B,IAAa,sBAAb,cAAyCA,cAGvC,CAAC,CAAC,uBAAuB,EAAE,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAExD,MAAM,WAAW,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM;AAE3D,MAAM,uBAAuB,OAAO,eAClC,OAAO,OAAO,EAAE,cAAc,OAAO,YAAY,QAAQ,EAAE,CAAC,CAC9D;AAEA,MAAM,MAAM,OAAO,MAAM,CAAC,OAAO,QAAQ,QAAQ,CAAC;AAElD,MAAMC,WAAS,OAAO,OAAO;CAAE,QAAQ,OAAO;CAAQ,SAAS,OAAO,MAAM,OAAO,MAAM;AAAE,CAAC;AAE5F,MAAM,UAAU,OAAO,OAAO,EAAE,MAAM,OAAO,YAAY,OAAO,MAAM,EAAE,CAAC;AAEzE,MAAMC,kBAAgB,OAAO,OAAO;CAClC,SAAS,OAAO,YAAY,OAAO,OAAO;CAC1C,KAAK,OAAO,YAAY,GAAG;AAC7B,CAAC;;AAGD,MAAa,qBAAqB,OAAO,eACvC,OAAO,OAAO;CACZ,MAAM,OAAO;CACb,SAAS,OAAO;CAChB,SAAS,OAAO,YAAY,OAAO,OAAO;CAC1C,QAAQ,OAAO,YAAYD,QAAM;CACjC,SAAS,OAAO,YAAY,OAAO,OAAO;CAC1C,KAAK,OAAO,YAAY,GAAG;CAC3B,cAAc,OAAO,YAAY,QAAQ;CACzC,sBAAsB,OAAO,YAAY,QAAQ;CACjD,SAAS,OAAO,YAAY,OAAO;CAC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3B,IAAM,aAAN,cAAyB,YAA2D,CAAC,CACnF,cACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;AAEH,MAAM,QAAQ;AAEd,MAAM,QAAQ;CACZ,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,UAAU,KAAK,WAAmB;EACxD,OAAO,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,OAAO,QAAQ,SAAS,CAAC;CAChE,CAAC;CACD,KAAK;CACL,SAAS;CACT,QAAQ;CACR,eAAe,OAAO,GAAG,aAAa,CAAC,CAAC,UAAU,aAAa;EAC7D,OAAO,OAAO,gBAAgB;CAChC,CAAC;AACH;AAEA,MAAM,UAAU,OAAO,IAAI,UAAU,UAAU;CAE7C,MAAM,OAAO,QAAO,OADC,MAAM,MAAA,CACD;CAC1B,MAAM,CAAC,MAAM,aAAa,OAAO,OAAO,oBAAoB,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,KAC3E,OAAO,eAAe,WAAW,KAAK,EAAE,SAAS,MAAM,CAAC,CAAC,CAC3D;CACA,OAAO,OAAO,MAAM,KAAK,CAAC,SAAS;AACrC,CAAC;AAED,OAAO,OAAO"}
@@ -0,0 +1,28 @@
1
+ import { r as nodeRepositoryFiles } from "./repository-files-B5sRbxlz.mjs";
2
+ import { Cause, Effect, Option, Schema, Stdio, Stream } from "effect";
3
+ import { runMainWith } from "@r_masseater/node-main";
4
+ // src/app/output.ts
5
+ const taggedError = Schema.TaggedError;
6
+ var ProblemsFound = class extends taggedError()("ProblemsFound", { count: Schema.Finite }) {};
7
+ /** @internal */
8
+ const writeStdout = Effect.fn("writeStdout")(function* writeStdout(text) {
9
+ const stdio = yield* Stdio.Stdio;
10
+ yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);
11
+ });
12
+ // src/app/runtime.ts
13
+ const reportFailure = (cause) => Effect.gen(function* report() {
14
+ const stdio = yield* Stdio.Stdio;
15
+ if (Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)))) return;
16
+ yield* Stream.make(`${Cause.pretty(cause)}\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);
17
+ });
18
+ /** @internal */
19
+ const runCli = (program) => {
20
+ runMainWith({
21
+ serviceName: "msch",
22
+ services: nodeRepositoryFiles,
23
+ onFailure: reportFailure
24
+ })(program);
25
+ };
26
+ export { ProblemsFound as n, writeStdout as r, runCli as t };
27
+
28
+ //# sourceMappingURL=runtime-LT40e_l3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-LT40e_l3.mjs","names":[],"sources":["../src/app/output.ts","../src/app/runtime.ts"],"sourcesContent":["import { Effect, Schema, Stdio, Stream } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class ProblemsFound extends taggedError<ProblemsFound, { readonly brand: unique symbol }>()(\n \"ProblemsFound\",\n {\n count: Schema.Finite,\n },\n) {}\n\n/** @internal */\nexport const writeStdout = Effect.fn(\"writeStdout\")(function* writeStdout(text: string) {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n});\n","import { runMainWith } from \"@r_masseater/node-main\";\nimport { Cause, Effect, Option, Schema, Stdio, Stream } from \"effect\";\nimport type { FileSystem, Path } from \"effect\";\nimport type { HttpClient } from \"effect/http\";\nimport type { ChildProcessSpawner } from \"effect/process\";\n\nimport { nodeRepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport type { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { ProblemsFound } from \"./output.ts\";\n\nconst reportFailure = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const failed = Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)));\n if (failed) {\n return;\n }\n yield* Stream.make(`${Cause.pretty(cause)}\\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const runCli = <Value, Failure>(\n program: Effect.Effect<\n Value,\n Failure,\n | RepositoryFiles\n | Stdio.Stdio\n | FileSystem.FileSystem\n | Path.Path\n | ChildProcessSpawner.ChildProcessSpawner\n | HttpClient.HttpClient\n >,\n): void => {\n runMainWith({\n serviceName: \"msch\",\n services: nodeRepositoryFiles,\n onFailure: reportFailure,\n })(program);\n};\n"],"mappings":";;;;AAEA,MAAM,cAAc,OAAO;AAE3B,IAAa,gBAAb,cAAmC,YAA8D,CAAC,CAChG,iBACA,EACE,OAAO,OAAO,OAChB,CACF,CAAC,CAAC,CAAC;;AAGH,MAAa,cAAc,OAAO,GAAG,aAAa,CAAC,CAAC,UAAU,YAAY,MAAc;CACtF,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,KAAK;AACxE,CAAC;;ACJD,MAAM,iBACJ,UAEA,OAAO,IAAI,UAAU,SAAS;CAC5B,MAAM,QAAQ,OAAO,MAAM;CAE3B,IADe,MAAM,gBAAgB,KAAK,CAAC,CAAC,KAAK,OAAO,OAAO,OAAO,GAAG,aAAa,CAAC,CAC9E,GACP;CAEF,OAAO,OAAO,KAAK,GAAG,MAAM,OAAO,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,KAAK;AAC9F,CAAC;;AAGH,MAAa,UACX,YAUS;CACT,YAAY;EACV,aAAa;EACb,UAAU;EACV,WAAW;CACb,CAAC,CAAC,CAAC,OAAO;AACZ"}
@@ -1,8 +1,8 @@
1
1
  import { t as NODE_MODULES } from "./repository-files-B5sRbxlz.mjs";
2
2
  import { Array, Option, String, pipe } from "effect";
3
3
  import { InternalSymbolName, SyntaxKind, getJSDocTags, getLeadingCommentRanges, getNameOfDeclaration, getTextOfJSDocComment } from "typescript/ast";
4
- import { isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isReturnStatement, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "typescript/ast/is";
5
- import { API, IndexKind, SignatureKind } from "typescript/sync";
4
+ import { isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isLiteralTypeNode, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isPropertySignatureDeclaration, isReturnStatement, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "typescript/ast/is";
5
+ import { API, IndexKind, SignatureKind, SymbolFlags as SymbolFlags$1 } from "typescript/sync";
6
6
  // src/shared/lib/syntax.ts
7
7
  const NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;
8
8
  const uniqueByReference = (items) => Array.dedupeWith(items, (left, right) => left === right);
@@ -28,6 +28,7 @@ const packageOf = (fileName) => {
28
28
  const descendantsOf = (node) => pipe(childrenOf(node), Array.flatMap((child) => Array.prepend(descendantsOf(child), child)));
29
29
  const isExternalFile = (program) => (sourceFile) => !program.isSourceFileDefaultLibrary(sourceFile) && (String.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) || program.isSourceFileFromExternalLibrary(sourceFile));
30
30
  const isExternalDeclaration = (program) => (declaration) => isExternalFile(program)(declaration.getSourceFile());
31
+ const isOutsideDeclaration = (program) => (declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()) || isExternalDeclaration(program)(declaration);
31
32
  const ALIAS_KINDS = /* @__PURE__ */ new Set([
32
33
  SyntaxKind.ImportSpecifier,
33
34
  SyntaxKind.ImportClause,
@@ -61,6 +62,14 @@ const columnOf = (node) => {
61
62
  const contains = (outer) => (inner) => outer.getSourceFile().fileName === inner.getSourceFile().fileName && outer.getStart() <= inner.getStart() && inner.getEnd() <= outer.getEnd();
62
63
  const isInsideAny = (outers) => (node) => pipe(outers, Array.some((outer) => contains(outer)(node)));
63
64
  const isTypeDeclaration = (declaration) => isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration) || isEnumDeclaration(declaration);
65
+ const membersOf = (declaration) => {
66
+ if (isInterfaceDeclaration(declaration) || isClassDeclaration(declaration)) return declaration.members;
67
+ if (isTypeAliasDeclaration(declaration) && isTypeLiteralNode(declaration.type)) return declaration.type.members;
68
+ return [];
69
+ };
70
+ const isTagNamed = (name) => (member) => (isPropertySignatureDeclaration(member) || isPropertyDeclaration(member)) && pipe(Option.fromUndefinedOr(member.type), Option.exists((type) => isLiteralTypeNode(type) && isStringLiteral(type.literal) && type.literal.text === name));
71
+ const declaresAType = (declarations) => pipe(declarations, Array.some((declaration) => isTypeDeclaration(declaration) || isClassDeclaration(declaration)));
72
+ const carriesTag = (name) => (declarations) => pipe(declarations, Array.flatMap(membersOf), Array.some(isTagNamed(name)));
64
73
  const isGenericDeclaration = (declaration) => (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) && Array.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);
65
74
  const propertyNamesOf = (checker) => (type) => pipe(checker.getPropertiesOfType(type), Array.map((property) => property.name));
66
75
  const moduleSpecifierOf = (statement) => {
@@ -68,6 +77,6 @@ const moduleSpecifierOf = (statement) => {
68
77
  return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter((specifier) => isStringLiteral(specifier)), Option.map((specifier) => specifier.text));
69
78
  };
70
79
  const importedModulesOf = (sourceFile) => pipe(sourceFile.statements, Array.map((statement) => moduleSpecifierOf(statement)), Array.getSomes);
71
- export { isSpreadElement as $, isBlock as A, isInterfaceDeclaration as B, getJSDocTags as C, isArrayLiteralExpression as D, getTextOfJSDocComment as E, isExportDeclaration as F, isObjectLiteralExpression as G, isModuleDeclaration as H, isFunctionDeclaration as I, isPropertyAssignment as J, isParenthesizedExpression as K, isFunctionExpression as L, isClassDeclaration as M, isElementAccessExpression as N, isArrowFunction as O, isEnumDeclaration as P, isSourceFile as Q, isIdentifier as R, SyntaxKind as S, getNameOfDeclaration as T, isNewExpression as U, isModuleBlock as V, isNumericLiteral as W, isSatisfiesExpression as X, isReturnStatement as Y, isSignatureDeclaration as Z, uniqueByReference as _, descendantsOf as a, isVariableDeclaration as at, InternalSymbolName as b, isGenericDeclaration as c, lineOf as d, isStringLiteral as et, packageOf as f, symbolAt as g, resolvedSymbol as h, declarationsOf as i, isUnionTypeNode as it, isCallExpression as j, isBinaryExpression as k, isInsideAny as l, referencedSymbols as m, columnOf as n, isTypeLiteralNode as nt, importedModulesOf as o, isVariableDeclarationList as ot, propertyNamesOf as p, isPropertyAccessExpression as q, contains as r, isTypeReferenceNode as rt, isExternalDeclaration as s, isVariableStatement as st, childrenOf as t, isTypeAliasDeclaration as tt, isTypeDeclaration as u, API as v, getLeadingCommentRanges as w, SignatureKind as x, IndexKind as y, isImportDeclaration as z };
80
+ export { isReturnStatement as $, getTextOfJSDocComment as A, isFunctionDeclaration as B, InternalSymbolName as C, getJSDocTags as D, SyntaxKind as E, isCallExpression as F, isModuleBlock as G, isIdentifier as H, isClassDeclaration as I, isNumericLiteral as J, isModuleDeclaration as K, isElementAccessExpression as L, isArrowFunction as M, isBinaryExpression as N, getLeadingCommentRanges as O, isBlock as P, isPropertyAssignment as Q, isEnumDeclaration as R, IndexKind as S, SymbolFlags$1 as T, isImportDeclaration as U, isFunctionExpression as V, isInterfaceDeclaration as W, isParenthesizedExpression as X, isObjectLiteralExpression as Y, isPropertyAccessExpression as Z, referencedSymbols as _, declarationsOf as a, isTypeAliasDeclaration as at, uniqueByReference as b, importedModulesOf as c, isUnionTypeNode as ct, isInsideAny as d, isVariableStatement as dt, isSatisfiesExpression as et, isOutsideDeclaration as f, propertyNamesOf as g, packageOf as h, contains as i, isStringLiteral as it, isArrayLiteralExpression as j, getNameOfDeclaration as k, isExternalDeclaration as l, isVariableDeclaration as lt, lineOf as m, childrenOf as n, isSourceFile as nt, declaresAType as o, isTypeLiteralNode as ot, isTypeDeclaration as p, isNewExpression as q, columnOf as r, isSpreadElement as rt, descendantsOf as s, isTypeReferenceNode as st, carriesTag as t, isSignatureDeclaration as tt, isGenericDeclaration as u, isVariableDeclarationList as ut, resolvedSymbol as v, SignatureKind as w, API as x, symbolAt as y, isExportDeclaration as z };
72
81
 
73
- //# sourceMappingURL=syntax-3AJkpCcs.mjs.map
82
+ //# sourceMappingURL=syntax-BNRNY74H.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-BNRNY74H.mjs","names":["Arr","Str"],"sources":["../src/shared/lib/syntax.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n isClassDeclaration,\n isEnumDeclaration,\n isExportAssignment,\n isExportDeclaration,\n isIdentifier,\n isImportDeclaration,\n isInterfaceDeclaration,\n isLiteralTypeNode,\n isPropertyAccessExpression,\n isPropertyDeclaration,\n isPropertySignatureDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n EnumDeclaration,\n Expression,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n} from \"./compiler.ts\";\nimport { NODE_MODULES } from \"./repository-files.ts\";\n\nconst NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;\n\nexport const POSITION_BASE = 1;\n\nexport const uniqueByReference = <Item>(items: readonly Item[]): readonly Item[] =>\n Arr.dedupeWith(items, (left, right) => left === right);\n\nexport const childrenOf = (node: Node): readonly Node[] => {\n const children: Node[] = [];\n node.forEachChild((child) => {\n children.push(child);\n });\n return children;\n};\n\nconst SCOPE_PREFIX = \"@\";\nconst SCOPED_SEGMENTS = 2;\nconst UNSCOPED_SEGMENTS = 1;\n\nexport const packageOf = (fileName: string): string => {\n const afterModules = pipe(\n fileName,\n Str.lastIndexOf(NODE_MODULES_SEGMENT),\n Option.match({\n onNone: () => fileName,\n onSome: (index) => Str.slice(index + NODE_MODULES_SEGMENT.length)(fileName),\n }),\n );\n const segments = Str.split(\"/\")(afterModules);\n if (Str.startsWith(SCOPE_PREFIX)(afterModules)) {\n return pipe(Arr.take(segments, SCOPED_SEGMENTS), Arr.join(\"/\"));\n }\n return pipe(Arr.take(segments, UNSCOPED_SEGMENTS), Arr.join(\"/\"));\n};\n\nexport const descendantsOf = (node: Node): readonly Node[] =>\n pipe(\n childrenOf(node),\n Arr.flatMap((child) => Arr.prepend(descendantsOf(child), child)),\n );\n\nconst isExternalFile =\n (program: Program) =>\n (sourceFile: SourceFile): boolean =>\n !program.isSourceFileDefaultLibrary(sourceFile) &&\n (Str.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) ||\n program.isSourceFileFromExternalLibrary(sourceFile));\n\nexport const isExternalDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n isExternalFile(program)(declaration.getSourceFile());\n\nexport const isOutsideDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n program.isSourceFileDefaultLibrary(declaration.getSourceFile()) ||\n isExternalDeclaration(program)(declaration);\n\nconst ALIAS_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ImportSpecifier,\n SyntaxKind.ImportClause,\n SyntaxKind.NamespaceImport,\n SyntaxKind.ExportSpecifier,\n SyntaxKind.ImportEqualsDeclaration,\n SyntaxKind.ExportAssignment,\n]);\n\nexport const declarationsOf = (symbol: TypeSymbol): readonly Declaration[] =>\n pipe(\n symbol.declarations,\n Arr.flatMap((handle) => Option.toArray(Option.fromUndefinedOr(handle.resolve()))),\n );\n\nconst isEntityName = (expression: Expression): boolean =>\n isIdentifier(expression) ||\n (isPropertyAccessExpression(expression) && isEntityName(expression.expression));\n\nconst aliasesAnEntity = (declaration: Node): boolean =>\n !isExportAssignment(declaration) || isEntityName(declaration.expression);\n\nconst isAliasDeclaration = (declaration: Node): boolean =>\n ALIAS_KINDS.has(declaration.kind) && aliasesAnEntity(declaration);\n\nexport const resolvedSymbol =\n (checker: Checker) =>\n (symbol: TypeSymbol): TypeSymbol => {\n if (\n !pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isAliasDeclaration(declaration)),\n )\n ) {\n return symbol;\n }\n return checker.getAliasedSymbol(symbol);\n };\n\nexport const symbolAt =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(node)).pipe(\n Option.map(resolvedSymbol(checker)),\n );\n\nexport const referencedSymbols =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] => {\n const identifiers = pipe(\n Arr.prepend(descendantsOf(node), node),\n Arr.filter((candidate) => isIdentifier(candidate)),\n );\n const symbols = pipe(\n checker.getSymbolAtLocation(identifiers),\n Arr.flatMap((symbol) => Option.toArray(Option.fromUndefinedOr(symbol))),\n Arr.map(resolvedSymbol(checker)),\n );\n return uniqueByReference(symbols);\n };\n\nexport const lineOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + POSITION_BASE;\n};\n\nexport const columnOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return (\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).character + POSITION_BASE\n );\n};\n\nexport const contains =\n (outer: Node) =>\n (inner: Node): boolean =>\n outer.getSourceFile().fileName === inner.getSourceFile().fileName &&\n outer.getStart() <= inner.getStart() &&\n inner.getEnd() <= outer.getEnd();\n\nexport const isInsideAny =\n (outers: readonly Node[]) =>\n (node: Node): boolean =>\n pipe(\n outers,\n Arr.some((outer) => contains(outer)(node)),\n );\n\nexport const isTypeDeclaration = (\n declaration: Node,\n): declaration is TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration =>\n isTypeAliasDeclaration(declaration) ||\n isInterfaceDeclaration(declaration) ||\n isEnumDeclaration(declaration);\n\nconst membersOf = (declaration: Node): readonly Node[] => {\n if (isInterfaceDeclaration(declaration) || isClassDeclaration(declaration)) {\n return declaration.members;\n }\n if (isTypeAliasDeclaration(declaration) && isTypeLiteralNode(declaration.type)) {\n return declaration.type.members;\n }\n return [];\n};\n\nconst isTagNamed =\n (name: string) =>\n (member: Node): boolean =>\n (isPropertySignatureDeclaration(member) || isPropertyDeclaration(member)) &&\n pipe(\n Option.fromUndefinedOr(member.type),\n Option.exists(\n (type) =>\n isLiteralTypeNode(type) && isStringLiteral(type.literal) && type.literal.text === name,\n ),\n );\n\nexport const declaresAType = (declarations: readonly Node[]): boolean =>\n pipe(\n declarations,\n Arr.some((declaration) => isTypeDeclaration(declaration) || isClassDeclaration(declaration)),\n );\n\nexport const carriesTag =\n (name: string) =>\n (declarations: readonly Node[]): boolean =>\n pipe(declarations, Arr.flatMap(membersOf), Arr.some(isTagNamed(name)));\n\nexport const isGenericDeclaration = (declaration: Node): boolean =>\n (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) &&\n Arr.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);\n\nexport const propertyNamesOf =\n (checker: Checker) =>\n (type: Type): readonly string[] =>\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => property.name),\n );\n\nconst moduleSpecifierOf = (statement: Node): Option.Option<string> => {\n if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(\n Option.filter((specifier) => isStringLiteral(specifier)),\n Option.map((specifier) => specifier.text),\n );\n};\n\nexport const importedModulesOf = (sourceFile: SourceFile): readonly string[] =>\n pipe(\n sourceFile.statements,\n Arr.map((statement) => moduleSpecifierOf(statement)),\n Arr.getSomes,\n );\n"],"mappings":";;;;;;AAkCA,MAAM,uBAAuB,IAAI,aAAa;AAI9C,MAAa,qBAA2B,UACtCA,MAAI,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAK;AAEvD,MAAa,cAAc,SAAgC;CACzD,MAAM,WAAmB,CAAC;CAC1B,KAAK,cAAc,UAAU;EAC3B,SAAS,KAAK,KAAK;CACrB,CAAC;CACD,OAAO;AACT;AAEA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAE1B,MAAa,aAAa,aAA6B;CACrD,MAAM,eAAe,KACnB,UACAC,OAAI,YAAY,oBAAoB,GACpC,OAAO,MAAM;EACX,cAAc;EACd,SAAS,UAAUA,OAAI,MAAM,QAAQ,qBAAqB,MAAM,CAAC,CAAC,QAAQ;CAC5E,CAAC,CACH;CACA,MAAM,WAAWA,OAAI,MAAM,GAAG,CAAC,CAAC,YAAY;CAC5C,IAAIA,OAAI,WAAW,YAAY,CAAC,CAAC,YAAY,GAC3C,OAAO,KAAKD,MAAI,KAAK,UAAU,eAAe,GAAGA,MAAI,KAAK,GAAG,CAAC;CAEhE,OAAO,KAAKA,MAAI,KAAK,UAAU,iBAAiB,GAAGA,MAAI,KAAK,GAAG,CAAC;AAClE;AAEA,MAAa,iBAAiB,SAC5B,KACE,WAAW,IAAI,GACfA,MAAI,SAAS,UAAUA,MAAI,QAAQ,cAAc,KAAK,GAAG,KAAK,CAAC,CACjE;AAEF,MAAM,kBACH,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mB,WAAW,CAAC,CAC7F;AAEF,MAAa,cACV,UACA,iBACC,KAAK,cAAcA,MAAI,QAAQ,SAAS,GAAGA,MAAI,KAAK,WAAW,IAAI,CAAC,CAAC;AAEzE,MAAa,wBAAwB,iBAClC,uBAAuB,WAAW,KAAK,uBAAuB,WAAW,MAC1EA,MAAI,wBAAwB,YAAY,kBAAkB,CAAC,CAAC;AAE9D,MAAa,mBACV,aACA,SACC,KACE,QAAQ,oBAAoB,IAAI,GAChCA,MAAI,KAAK,aAAa,SAAS,IAAI,CACrC;AAEJ,MAAM,qBAAqB,cAA2C;CACpE,IAAI,CAAC,oBAAoB,SAAS,KAAK,CAAC,oBAAoB,SAAS,GACnE,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,gBAAgB,UAAU,eAAe,CAAC,CAAC,KACvD,OAAO,QAAQ,cAAc,gBAAgB,SAAS,CAAC,GACvD,OAAO,KAAK,cAAc,UAAU,IAAI,CAC1C;AACF;AAEA,MAAa,qBAAqB,eAChC,KACE,WAAW,YACXA,MAAI,KAAK,cAAc,kBAAkB,SAAS,CAAC,GACnDA,MAAI,QACN"}
@@ -0,0 +1 @@
1
+ export {}
package/dist/wake.mjs ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { t as runCli } from "./runtime-LT40e_l3.mjs";
3
+ import { n as actionsOidcToken, t as BROKER } from "./credential-broker-D8sFyowJ.mjs";
4
+ import { Boolean, Console, Effect, Option, Schema } from "effect";
5
+ import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
6
+ // src/features/wake-project/model/wake.ts
7
+ const Woken = Schema.Struct({ woken: Schema.Boolean });
8
+ /** @internal */
9
+ const wakeOnRedMain = Effect.fn("wake.redMain")(function* wakeOnRedMain() {
10
+ const oidc = yield* actionsOidcToken;
11
+ if (Option.isNone(oidc)) return yield* Console.log("Not running in GitHub Actions: nothing to tell the broker");
12
+ const client = yield* HttpClient.HttpClient;
13
+ const request = HttpClientRequest.post(`${BROKER}wake/main-red`).pipe(HttpClientRequest.bearerToken(oidc.value));
14
+ const response = yield* HttpClient.filterStatusOk(client).execute(request);
15
+ const { woken } = yield* HttpClientResponse.schemaBodyJson(Woken)(response);
16
+ return yield* Console.log(Boolean.match(woken, {
17
+ onTrue: () => "Asked the project to fix main",
18
+ onFalse: () => "Asked recently: skipped"
19
+ }));
20
+ });
21
+ // bin/msch-wake.ts
22
+ runCli(wakeOnRedMain());
23
+ export {};
24
+
25
+ //# sourceMappingURL=wake.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wake.mjs","names":["Bool"],"sources":["../src/features/wake-project/model/wake.ts","../bin/msch-wake.ts"],"sourcesContent":["import { Boolean as Bool, Console, Effect, Option, Schema } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\n\nimport { BROKER, actionsOidcToken } from \"#/shared/lib/credential-broker.ts\";\n\nconst Woken = Schema.Struct({ woken: Schema.Boolean });\n\n/** @internal */\nexport const wakeOnRedMain = Effect.fn(\"wake.redMain\")(function* wakeOnRedMain() {\n const oidc = yield* actionsOidcToken;\n if (Option.isNone(oidc)) {\n return yield* Console.log(\"Not running in GitHub Actions: nothing to tell the broker\");\n }\n const client = yield* HttpClient.HttpClient;\n const request = HttpClientRequest.post(`${BROKER}wake/main-red`).pipe(\n HttpClientRequest.bearerToken(oidc.value),\n );\n const response = yield* HttpClient.filterStatusOk(client).execute(request);\n const { woken } = yield* HttpClientResponse.schemaBodyJson(Woken)(response);\n return yield* Console.log(\n Bool.match(woken, {\n onTrue: () => \"Asked the project to fix main\",\n onFalse: () => \"Asked recently: skipped\",\n }),\n );\n});\n","#!/usr/bin/env node\nimport { runCli } from \"#/app/runtime.ts\";\nimport { wakeOnRedMain } from \"#/features/wake-project/index.ts\";\n\nrunCli(wakeOnRedMain());\n"],"mappings":";;;;;;AAKA,MAAM,QAAQ,OAAO,OAAO,EAAE,OAAO,OAAO,QAAQ,CAAC;;AAGrD,MAAa,gBAAgB,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,gBAAgB;CAC/E,MAAM,OAAO,OAAO;CACpB,IAAI,OAAO,OAAO,IAAI,GACpB,OAAO,OAAO,QAAQ,IAAI,2DAA2D;CAEvF,MAAM,SAAS,OAAO,WAAW;CACjC,MAAM,UAAU,kBAAkB,KAAK,GAAG,OAAO,cAAc,CAAC,CAAC,KAC/D,kBAAkB,YAAY,KAAK,KAAK,CAC1C;CACA,MAAM,WAAW,OAAO,WAAW,eAAe,MAAM,CAAC,CAAC,QAAQ,OAAO;CACzE,MAAM,EAAE,UAAU,OAAO,mBAAmB,eAAe,KAAK,CAAC,CAAC,QAAQ;CAC1E,OAAO,OAAO,QAAQ,IACpBA,QAAK,MAAM,OAAO;EAChB,cAAc;EACd,eAAe;CACjB,CAAC,CACH;AACF,CAAC;;ACrBD,OAAO,cAAc,CAAC"}
@@ -1,12 +1,12 @@
1
- import { a as publicEntriesOf, i as EntryManifestJson, n as entriesOf, t as PackEntry } from "./package-LeBO9czg.mjs";
2
- import { A as merged, D as tasksOf, M as settingsInvalid, N as usedFrom, O as testsItself, R as literalOf, S as NO_TASKS, d as deployEntries, g as prefixed, j as programOf, k as literalSettings, m as shadcnUiIn, r as readManifest, s as writeLockedClosures, t as MANIFEST_FILE, v as workspaceDirectories, z as nestedValues } from "./dependencies-DCJv7YcW.mjs";
1
+ import { a as publicEntriesOf, i as EntryManifestJson, n as entriesOf, t as PackEntry } from "./package-DZbqpZfs.mjs";
2
+ import { A as merged, D as tasksOf, M as settingsInvalid, N as usedFrom, O as testsItself, R as literalOf, S as NO_TASKS, d as deployEntries, g as prefixed, j as programOf, k as literalSettings, m as shadcnUiIn, r as readManifest, s as writeLockedClosures, t as MANIFEST_FILE, v as workspaceDirectories, z as nestedValues } from "./dependencies-CbvZost8.mjs";
3
3
  import { r as ignoredDirectories, t as collectIgnoredDirectories } from "./ignored-directories-BTMTNuAx.mjs";
4
4
  import { n as RepositoryFiles, r as nodeRepositoryFiles } from "./repository-files-B5sRbxlz.mjs";
5
5
  import { Array, Effect, Option, Record, Schema, pipe } from "effect";
6
6
  // src/features/build-workspace-settings/model/dependency-allowances.ts
7
7
  const MSCH_DEV_DEPENDENCIES = ["msch", "devDependencies"];
8
8
  const MSCH_DEPENDENCIES = ["msch", "dependencies"];
9
- const Names$1 = Schema.optional(Schema.Array(Schema.String));
9
+ const Names$1 = Schema.String.pipe(Schema.Array, Schema.optional);
10
10
  const DependencySettings = Schema.Struct({
11
11
  use: Names$1,
12
12
  dependencies: Names$1
@@ -94,7 +94,7 @@ const SeverityWithOptions = Schema.mutable(Schema.TupleWithRest(Schema.Tuple([Se
94
94
  const RuleSetting = Schema.Union([Severity, SeverityWithOptions]);
95
95
  const Rules = Schema.Record(Schema.String, RuleSetting);
96
96
  const decodeRules = Schema.decodeUnknownEffect(Rules);
97
- const Names = Schema.optional(Schema.Array(Schema.String));
97
+ const Names = Schema.String.pipe(Schema.Array, Schema.optional);
98
98
  const WorkspaceOverride = Schema.Struct({
99
99
  files: Schema.Array(Schema.String),
100
100
  excludeFiles: Names,
@@ -103,7 +103,7 @@ const WorkspaceOverride = Schema.Struct({
103
103
  });
104
104
  const WorkspaceLintSettings = Schema.Struct({
105
105
  ignorePatterns: Names,
106
- overrides: Schema.optional(Schema.Array(WorkspaceOverride))
106
+ overrides: WorkspaceOverride.pipe(Schema.Array, Schema.optional)
107
107
  });
108
108
  const overrideOf = Effect.fn("overrideOf")(function* overrideOf(source, ruleSets, override) {
109
109
  const { file, directory } = source;