@r_masseater/msch 0.50.0 → 0.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cargo-inputs.mjs +1 -1
  2. package/dist/changed.mjs +2 -2
  3. package/dist/cli.mjs +871 -566
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +10 -6
  7. package/dist/config.mjs.map +1 -1
  8. package/dist/decision-rules.d.mts +1 -1
  9. package/dist/decision-rules.mjs +1 -1
  10. package/dist/{define-lint-preset-B1Xy1brk.mjs → define-lint-preset-CecEvjVf.mjs} +96 -1
  11. package/dist/define-lint-preset-CecEvjVf.mjs.map +1 -0
  12. package/dist/{dependencies-DbwLA4nT.mjs → dependencies-DCJv7YcW.mjs} +5 -2
  13. package/dist/dependencies-DCJv7YcW.mjs.map +1 -0
  14. package/dist/{index-DL7PSp7j.d.mts → index-B2X8WhBt.d.mts} +41 -2
  15. package/dist/{index-DdJXnW1q.d.mts → index-BZIBqvmt.d.mts} +18 -7
  16. package/dist/lint-rules.mjs +247 -6
  17. package/dist/lint-rules.mjs.map +1 -1
  18. package/dist/lint.d.mts +1 -1
  19. package/dist/lint.mjs +1 -1
  20. package/dist/oxlint.mjs +3 -7
  21. package/dist/oxlint.mjs.map +1 -1
  22. package/dist/{package-BKpgZyaV.mjs → package-LeBO9czg.mjs} +2 -2
  23. package/dist/{package-BKpgZyaV.mjs.map → package-LeBO9czg.mjs.map} +1 -1
  24. package/dist/{problem-D8mlJc3T.mjs → problem-CzOlOb5f.mjs} +10 -2
  25. package/dist/problem-CzOlOb5f.mjs.map +1 -0
  26. package/dist/{project-CR2jzkij.mjs → project-C4uzq7_4.mjs} +2 -2
  27. package/dist/{project-CR2jzkij.mjs.map → project-C4uzq7_4.mjs.map} +1 -1
  28. package/dist/publish.mjs +1 -1
  29. package/dist/publish.mjs.map +1 -1
  30. package/dist/started-once-muJbvD_I.mjs +8 -0
  31. package/dist/started-once-muJbvD_I.mjs.map +1 -0
  32. package/dist/workspace-settings.d.mts +2 -2
  33. package/dist/workspace-settings.mjs +83 -42
  34. package/dist/workspace-settings.mjs.map +1 -1
  35. package/package.json +14 -12
  36. package/skills/msch-checks/SKILL.md +1 -1
  37. package/skills/workspace-settings/SKILL.md +1 -0
  38. package/src/app/vite.d.ts +3 -2
  39. package/dist/define-lint-preset-B1Xy1brk.mjs.map +0 -1
  40. package/dist/dependencies-DbwLA4nT.mjs.map +0 -1
  41. package/dist/problem-D8mlJc3T.mjs.map +0 -1
  42. package/dist/started-once-CkTooI_o.mjs +0 -13
  43. package/dist/started-once-CkTooI_o.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"project-CR2jzkij.mjs","names":["Arr","Fn","Arr","Num","Str","Arr","HIDDEN_PREFIX","Str","Arr","Arr","Str","Arr","Arr","Str","Bool"],"sources":["../src/shared/lib/values.ts","../src/entities/project/model/library.ts","../src/entities/project/model/telemetry.ts","../src/entities/project/model/project.ts","../src/entities/project/model/inputs.ts","../src/shared/lib/pass-records.ts","../src/entities/project/model/implementation.ts"],"sourcesContent":["import { Array as Arr, Function as Fn, Option, pipe } from \"effect\";\n\nimport { IndexKind } from \"./compiler.ts\";\nimport type { Checker, Type } from \"./compiler.ts\";\n\nexport type Value = string | number;\n\nexport interface Vocabulary {\n readonly values: readonly Value[];\n readonly admitsUnnamedValues: boolean;\n}\n\nconst SCHEMA_TYPE_PROPERTIES = [\"Type\", \"_output\"] as const;\n\nconst MINIMUM_SET_SIZE = 2;\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const valueKey = (value: Value): string => `${typeof value}:${String(value)}`;\n\nconst literalValueOf = (type: Type): Option.Option<Value> => {\n if (type.isStringLiteralType() || type.isNumberLiteralType()) {\n return Option.some(type.value);\n }\n return Option.none();\n};\n\nexport const literalValuesOf = (types: readonly Type[]): Option.Option<readonly Value[]> => {\n const values = pipe(\n types,\n Arr.map((member) => literalValueOf(member)),\n Arr.getSomes,\n Arr.dedupeWith((left, right) => valueKey(left) === valueKey(right)),\n );\n if (values.length !== types.length || values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some(values);\n};\n\nexport const literalUnionOf = (type: Type): Option.Option<readonly Value[]> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n return literalValuesOf(type.getTypes());\n};\n\nconst elementTypeOf = (checker: Checker, type: Type): Option.Option<Type> => {\n if (!checker.isArrayLikeType(type)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getIndexTypeOfType(type, IndexKind.Number));\n};\n\nexport const schemaTypeOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Type> =>\n Arr.findFirst(SCHEMA_TYPE_PROPERTIES, (name) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(type, name)),\n ).pipe(Option.map((property) => checker.getTypeOfSymbol(property)));\n\nexport const finiteValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalUnionOf(type).pipe(\n Option.orElse(() => elementTypeOf(checker, type).pipe(Option.flatMap(literalUnionOf))),\n Option.orElse(() => schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf))),\n );\n\nexport const vocabularyOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Vocabulary> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n const optionalIds = new Set([checker.getUndefinedType().id, checker.getNullType().id]);\n const members = pipe(\n type.getTypes(),\n Arr.filter((member) => !optionalIds.has(member.id)),\n );\n const values = Arr.getSomes(\n pipe(\n members,\n Arr.map((member) => literalValueOf(member)),\n ),\n );\n if (values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some({ values, admitsUnnamedValues: values.length !== members.length });\n };\n\nexport const isSubsetOf: {\n (superset: readonly Value[]): (subset: readonly Value[]) => boolean;\n (subset: readonly Value[], superset: readonly Value[]): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (subset: readonly Value[], superset: readonly Value[]): boolean => {\n const held = new Set(\n pipe(\n superset,\n Arr.map((value) => valueKey(value)),\n ),\n );\n return pipe(\n subset,\n Arr.every((value) => held.has(valueKey(value))),\n );\n});\n\nexport const sameValues: {\n (right: readonly Value[]): (left: readonly Value[]) => boolean;\n (left: readonly Value[], right: readonly Value[]): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (left: readonly Value[], right: readonly Value[]): boolean =>\n left.length === right.length && isSubsetOf(left, right),\n);\n\nconst valueText = (value: Value): string => {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n return String(value);\n};\n\nexport const formatValues = (values: readonly Value[]): string =>\n pipe(values, Arr.map(valueText), Arr.join(\" | \"));\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { DependencyEntry } from \"#/entities/package/@x/project.ts\";\nimport {\n InternalSymbolName,\n isModuleDeclaration,\n isVariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n SyntaxKind,\n TypeSymbol,\n Type,\n} from \"#/shared/lib/compiler.ts\";\nimport {\n declarationsOf,\n isGenericDeclaration,\n isTypeDeclaration,\n propertyNamesOf,\n resolvedSymbol,\n} from \"#/shared/lib/syntax.ts\";\nimport { schemaTypeOf, vocabularyOf } from \"#/shared/lib/values.ts\";\nimport type { Vocabulary } from \"#/shared/lib/values.ts\";\n\nexport interface LibraryType {\n readonly specifier: string;\n readonly typeName: string;\n}\n\nexport interface LibraryVocabulary extends LibraryType {\n readonly vocabulary: Vocabulary;\n}\n\nexport interface DeclarationLocation {\n readonly file: string;\n readonly pos: number;\n readonly kind: SyntaxKind;\n}\n\nexport interface LibraryShape extends LibraryType {\n readonly form: \"declared\" | \"schema\";\n readonly declaration: DeclarationLocation;\n readonly propertyNames: readonly string[];\n}\n\nexport interface LibraryIndex {\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly shapes: readonly LibraryShape[];\n}\n\ninterface Walk {\n readonly checker: Checker;\n readonly entry: DependencyEntry;\n}\n\ninterface Visit {\n readonly exported: TypeSymbol;\n readonly qualifier: string;\n readonly ancestors: readonly TypeSymbol[];\n}\n\ninterface Exported {\n readonly symbol: TypeSymbol;\n readonly typeName: string;\n}\n\nconst NAMESPACE_DEPTH_LIMIT = 8;\nconst EMPTY_INDEX: LibraryIndex = { vocabularies: [], shapes: [] };\n\nexport const isObjectType =\n (checker: Checker) =>\n (type: Type): boolean =>\n !type.isUnionType() &&\n !type.isLiteralType() &&\n checker.getApparentType(type).id === type.id &&\n Arr.isReadonlyArrayNonEmpty(checker.getPropertiesOfType(type));\n\nexport const describeLibraryType = (type: LibraryType): string =>\n `${type.typeName} from ${type.specifier}`;\n\nexport const locationOf = (declaration: Node): DeclarationLocation => ({\n file: declaration.getSourceFile().fileName,\n pos: declaration.pos,\n kind: declaration.kind,\n});\n\nexport const declarationKey = (location: DeclarationLocation): string =>\n `${location.file}#${String(location.pos)}#${String(location.kind)}`;\n\ntype ShapeSource = LibraryType & Pick<LibraryShape, \"form\">;\n\nconst shapeOf =\n (checker: Checker) =>\n (source: ShapeSource, declaration: Declaration, type: Type): readonly LibraryShape[] =>\n Arr.filter(\n [\n {\n ...source,\n declaration: locationOf(declaration),\n propertyNames: propertyNamesOf(checker)(type),\n },\n ],\n () => isObjectType(checker)(type),\n );\n\nconst declaredTypeIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isTypeDeclaration);\n if (Option.isNone(declaration) || isGenericDeclaration(declaration.value)) {\n return EMPTY_INDEX;\n }\n const located = { specifier: walk.entry.specifier, typeName: exported.typeName };\n const type = walk.checker.getDeclaredTypeOfSymbol(exported.symbol);\n const vocabularies = vocabularyOf(walk.checker)(type).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n );\n const shapes = shapeOf(walk.checker)({ ...located, form: \"declared\" }, declaration.value, type);\n return { vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n vocabularies: vocabularyOf(walk.checker)(schemaType).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n ),\n shapes: shapeOf(walk.checker)({ ...located, form: \"schema\" }, declaration, schemaType),\n });\n\nconst schemaValueIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isVariableDeclaration);\n if (Option.isNone(declaration)) {\n return EMPTY_INDEX;\n }\n const valueType = walk.checker.getTypeOfSymbolAtLocation(exported.symbol, declaration.value);\n const located = {\n specifier: walk.entry.specifier,\n typeName: `(typeof ${exported.typeName})[\"Type\"]`,\n };\n return Option.match(schemaTypeOf(walk.checker)(valueType), {\n onNone: () => EMPTY_INDEX,\n onSome: (schemaType) => schemaTypeIndex(walk, located)(declaration.value, schemaType),\n });\n};\n\nconst mergeIndexes = (indexes: readonly LibraryIndex[]): LibraryIndex => ({\n vocabularies: pipe(\n indexes,\n Arr.flatMap((index) => index.vocabularies),\n ),\n shapes: pipe(\n indexes,\n Arr.flatMap((index) => index.shapes),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isModuleDeclaration(declaration)),\n );\n\nconst indexUnder = (walk: Walk, visit: Visit): LibraryIndex => {\n const symbol = resolvedSymbol(walk.checker)(visit.exported);\n const named = { symbol, typeName: `${visit.qualifier}${visit.exported.name}` };\n const own = mergeIndexes([declaredTypeIndex(walk, named), schemaValueIndex(walk, named)]);\n if (\n !isNamespace(symbol) ||\n visit.ancestors.length >= NAMESPACE_DEPTH_LIMIT ||\n visit.ancestors.includes(symbol)\n ) {\n return own;\n }\n const nested = pipe(\n walk.checker.getExportsOfModule(symbol),\n Arr.map((member) =>\n indexUnder(walk, {\n exported: member,\n qualifier: `${named.typeName}.`,\n ancestors: [...visit.ancestors, symbol],\n }),\n ),\n );\n return mergeIndexes([own, ...nested]);\n};\n\nconst exportAssignmentOf = (moduleSymbol: TypeSymbol): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(moduleSymbol.getExports().get(InternalSymbolName.ExportEquals));\n\nconst indexOfEntry =\n (checker: Checker) =>\n (entry: DependencyEntry): LibraryIndex => {\n const moduleSymbol = Option.fromUndefinedOr(\n checker.getSymbolOfSourceFile(entry.declarationsPath),\n );\n if (Option.isNone(moduleSymbol)) {\n return EMPTY_INDEX;\n }\n const walk: Walk = { checker, entry };\n const roots = Option.match(exportAssignmentOf(moduleSymbol.value), {\n onNone: () => checker.getExportsOfModule(moduleSymbol.value),\n onSome: (assigned) => [resolvedSymbol(checker)(assigned)],\n });\n return mergeIndexes(\n pipe(\n roots,\n Arr.map((exported) => indexUnder(walk, { exported, qualifier: \"\", ancestors: [] })),\n ),\n );\n };\n\nexport interface CachedIndex {\n readonly index: LibraryIndex;\n readonly cached: boolean;\n}\n\nexport interface LibraryCache {\n readonly indexOf: (entry: DependencyEntry, compute: () => LibraryIndex) => CachedIndex;\n}\n\nexport const libraryCache = (): LibraryCache => {\n const indexes = new Map<string, LibraryIndex>();\n return {\n indexOf: (entry, compute) =>\n Option.match(Option.fromUndefinedOr(indexes.get(entry.declarationsPath)), {\n onSome: (index) => ({ index, cached: true }),\n onNone: () => {\n const index = compute();\n indexes.set(entry.declarationsPath, index);\n return { index, cached: false };\n },\n }),\n };\n};\n\nconst indexEntry =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entry: DependencyEntry): Effect.Effect<LibraryIndex> =>\n Effect.sync(() => cache.indexOf(entry, () => indexOfEntry(checker)(entry))).pipe(\n Effect.tap(({ index, cached }) =>\n Effect.annotateCurrentSpan({\n \"msch.library.cached\": cached,\n \"msch.library.vocabularies\": index.vocabularies.length,\n \"msch.library.shapes\": index.shapes.length,\n }),\n ),\n Effect.map(({ index }) => index),\n Effect.withSpan(\"indexLibraryEntry\", {\n attributes: { \"msch.library.specifier\": entry.specifier },\n }),\n );\n\nexport const libraryIndex =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entries: readonly DependencyEntry[]): Effect.Effect<LibraryIndex> =>\n pipe(\n entries,\n (items) => Effect.forEach(items, indexEntry(cache)(checker), { concurrency: 1 }),\n Effect.map(mergeIndexes),\n Effect.withSpan(\"libraryIndex\"),\n );\n","import { Array as Arr, Effect, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nimport type { API } from \"#/shared/lib/compiler.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RSS_LINE = /^VmRSS:\\s+(?<kib>\\d+) kB$/mu;\nconst BYTES_PER_KIB = 1024;\nconst UNKNOWN_RSS = 0;\n\nconst kibibytesIn = (status: string): Option.Option<string> =>\n Option.fromNullishOr(RSS_LINE.exec(status)).pipe(\n Option.flatMap((match) => Option.fromUndefinedOr(match.groups)),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[\"kib\"])),\n );\n\nconst residentBytesOf = (pid: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* residentBytes() {\n const files = yield* RepositoryFiles;\n const status = yield* files.readFile(`/proc/${pid}/status`);\n return pipe(\n status,\n Option.flatMap(kibibytesIn),\n Option.flatMap(Num.parse),\n Option.map((kib) => kib * BYTES_PER_KIB),\n Option.getOrElse(() => UNKNOWN_RSS),\n );\n });\n\nconst childPids = Effect.gen(function* childPids() {\n const files = yield* RepositoryFiles;\n const pid = String(process.pid);\n const children = yield* files.readFile(`/proc/${pid}/task/${pid}/children`);\n return pipe(\n children,\n Option.map((text) => pipe(Str.trim(text), Str.split(\" \"), Arr.filter(Str.isNonEmpty))),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst annotateMemory = Effect.gen(function* annotateMemory() {\n const own = yield* residentBytesOf(String(process.pid));\n const pids = yield* childPids;\n const children = yield* Effect.forEach(pids, (pid) => residentBytesOf(pid), { concurrency: 1 });\n const { heapUsed } = process.memoryUsage();\n yield* Effect.annotateCurrentSpan({\n \"process.memory.rss\": own,\n \"process.memory.heap_used\": heapUsed,\n \"msch.compiler.memory.rss\": Num.sumAll(children),\n });\n});\n\nexport const annotateResources = (api: API): Effect.Effect<void, never, RepositoryFiles> =>\n Effect.gen(function* annotateCompiler() {\n yield* annotateMemory;\n const { totals } = api.getTimingInfo();\n yield* Effect.annotateCurrentSpan({\n \"msch.compiler.requests\": totals.requestCount,\n \"msch.compiler.round_trip_ms\": totals.roundTripMs,\n \"msch.compiler.server_ms\": totals.serverTimeMs,\n });\n });\n","import { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n dependencyEntries,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { API, getLeadingCommentRanges } from \"#/shared/lib/compiler.ts\";\nimport type { Checker, ParsedCommandLine, Program, SourceFile } from \"#/shared/lib/compiler.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { libraryCache, libraryIndex } from \"./library.ts\";\nimport type { LibraryCache, LibraryIndex } from \"./library.ts\";\nimport { annotateResources } from \"./telemetry.ts\";\n\nexport interface Project {\n readonly packageName: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n readonly program: Program;\n readonly checker: Checker;\n readonly sourceFiles: readonly SourceFile[];\n readonly library: LibraryIndex;\n}\n\nexport type SourceCheck = (checker: Checker) => (sourceFile: SourceFile) => readonly Problem[];\n\ninterface PackageInfo {\n readonly directory: string;\n readonly name: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n}\n\nconst CONFIG_FILE = \"tsconfig.json\";\nconst CONFIG_PATHSPEC = `:(glob)**/${CONFIG_FILE}`;\nconst HIDDEN_PREFIX = \".\";\nconst SKIPPED_DIRECTORIES: ReadonlySet<string> = new Set([NODE_MODULES, \"dist\", \"coverage\"]);\n\nconst isVisible = (file: string): boolean =>\n pipe(\n Str.split(file, \"/\"),\n Arr.every(\n (segment) => !Str.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment),\n ),\n );\n\nexport const listConfigFiles = (\n root: string,\n): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* configFilesUnder() {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);\n const visible = pipe(\n listed,\n Arr.filter(isVisible),\n Arr.map((file) => files.join(root, file)),\n );\n return Arr.sort(visible, Order.String);\n });\n\nexport const parseConfig =\n (api: API) =>\n (configPath: string): Option.Option<ParsedCommandLine> =>\n Option.some(api.parseConfigFile(configPath)).pipe(\n Option.filter((parsed) => Arr.isReadonlyArrayNonEmpty(parsed.fileNames)),\n );\n\nconst nearestPackageDirectory = (\n directory: string,\n root: string,\n): Effect.Effect<string, never, RepositoryFiles> =>\n Effect.gen(function* nearestPackage() {\n const files = yield* RepositoryFiles;\n const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE));\n const parent = files.dirname(directory);\n if (hasManifest || directory === root || parent === directory) {\n return directory;\n }\n return yield* nearestPackageDirectory(parent, root);\n });\n\nexport const packageDirectoryOf =\n (root: string) =>\n (directory: string): Effect.Effect<string, never, RepositoryFiles> =>\n nearestPackageDirectory(directory, root);\n\nconst packageInfoOf = Effect.fn(\"packageInfoOf\")(function* packageInfoOf(\n configPath: string,\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);\n const manifest = yield* readManifest(directory);\n return {\n directory,\n name: manifest.pipe(Option.flatMap((found) => Option.fromUndefinedOr(found.name))),\n workspaceDependencies: manifest.pipe(\n Option.map(workspaceDependencies),\n Option.getOrElse(() => []),\n ),\n } satisfies PackageInfo;\n});\n\nconst NO_CHECK_PRAGMA = /^\\/\\/\\s*@ts-nocheck/u;\nconst FILE_START = 0;\n\nconst skipsTypeChecking = (sourceFile: SourceFile): boolean =>\n pipe(\n getLeadingCommentRanges(sourceFile.text, FILE_START) ?? [],\n Arr.some((range) => NO_CHECK_PRAGMA.test(Str.slice(range.pos, range.end)(sourceFile.text))),\n );\n\nconst buildProject = Effect.fn(\"buildProject\")(function* buildProject(\n { compiler: { api, libraries }, generated }: Workspace,\n parsed: ParsedCommandLine,\n info: PackageInfo,\n) {\n const entries = yield* dependencyEntries(info.directory);\n const program = yield* Effect.sync(() =>\n api.createProgram(\n [\n ...parsed.fileNames,\n ...pipe(\n entries,\n Arr.map((entry) => entry.declarationsPath),\n ),\n ],\n { ...parsed.options, noEmit: true },\n ),\n ).pipe(Effect.withSpan(\"createProgram\"));\n const { checker } = program.getProject();\n const library = yield* libraryIndex(libraries)(checker)(entries);\n const projectFiles: ReadonlySet<string> = new Set(\n pipe(\n parsed.fileNames,\n Arr.filter((fileName) => !generated.includes(fileName)),\n ),\n );\n return {\n packageName: info.name,\n workspaceDependencies: info.workspaceDependencies,\n program,\n checker,\n sourceFiles: pipe(\n program.getSourceFileNames(),\n Arr.filter((fileName) => projectFiles.has(fileName)),\n Arr.flatMap((fileName) =>\n Option.toArray(Option.fromUndefinedOr(program.getSourceFile(fileName))),\n ),\n Arr.filter((sourceFile) => !sourceFile.isDeclarationFile && !skipsTypeChecking(sourceFile)),\n ),\n library,\n } satisfies Project;\n});\n\nexport interface Compiler {\n readonly api: API;\n readonly libraries: LibraryCache;\n}\n\nexport interface Workspace {\n readonly compiler: Compiler;\n readonly root: string;\n readonly generated: readonly string[];\n}\n\nexport const typeScriptCompiler = Effect.acquireRelease(\n Effect.sync((): Compiler => ({\n api: new API({ collectTiming: true }),\n libraries: libraryCache(),\n })),\n ({ api }) =>\n Effect.sync(() => {\n api.close();\n }),\n);\n\nconst loadProject = Effect.fn(\"loadProject\")(function* loadProject(\n workspace: Workspace,\n configPath: string,\n) {\n const { compiler, root } = workspace;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none<Project>();\n }\n const info = yield* packageInfoOf(configPath, root);\n const project = yield* buildProject(workspace, parsed.value, info);\n yield* Effect.annotateCurrentSpan({\n \"msch.project.config\": configPath,\n \"msch.project.program_files\": project.program.getSourceFileNames().length,\n \"msch.project.source_files\": project.sourceFiles.length,\n });\n yield* annotateResources(compiler.api);\n return Option.some(project);\n});\n\nconst releaseProject = (project: Project): Effect.Effect<void> =>\n Effect.sync(() => {\n project.program.dispose();\n });\n\nexport const withProject =\n (workspace: Workspace) =>\n (configPath: string) =>\n <Value, Failure, Requirements>(\n work: (project: Project) => Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<Option.Option<Value>, Failure, Requirements | RepositoryFiles> =>\n Effect.acquireUseRelease(\n loadProject(workspace, configPath),\n (loaded) =>\n Option.match(loaded, {\n onNone: () => Effect.succeedNone,\n onSome: (project) => work(project).pipe(Effect.asSome),\n }),\n (loaded) => Option.match(loaded, { onNone: () => Effect.void, onSome: releaseProject }),\n );\n\nexport const mentions =\n (needle: string) =>\n ({ api }: Compiler) =>\n (configPath: string): Effect.Effect<boolean, never, RepositoryFiles> =>\n Effect.gen(function* mentionsNeedle() {\n const files = yield* RepositoryFiles;\n const fileNames = Option.match(parseConfig(api)(configPath), {\n onNone: (): readonly string[] => [],\n onSome: (parsed): readonly string[] => parsed.fileNames,\n });\n const texts = yield* Effect.forEach(fileNames, (fileName) => files.readFile(fileName), {\n concurrency: 1,\n });\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n","import { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { packageDirectoryOf, parseConfig } from \"./project.ts\";\nimport type { Workspace } from \"./project.ts\";\n\nexport interface ProjectInputs {\n readonly options: string;\n readonly files: readonly string[];\n readonly dependencies: readonly string[];\n}\n\nconst SEPARATOR = \"/\";\nconst SCOPE_PREFIX = \"@\";\nconst HIDDEN_PREFIX = \".\";\n\nconst encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\n\nexport const nearestManifestDirectory = Effect.fn(\"nearestManifestDirectory\")(\n function* nearestManifestDirectory(start: string) {\n const files = yield* RepositoryFiles;\n let directory = start;\n let parent = files.dirname(directory);\n while (parent !== directory && !(yield* files.exists(files.join(directory, MANIFEST_FILE)))) {\n directory = parent;\n parent = files.dirname(directory);\n }\n return directory;\n },\n);\n\nconst dependenciesOf = Effect.fn(\"dependenciesOf\")(function* dependenciesOf(directory: string) {\n const files = yield* RepositoryFiles;\n const manifest = yield* readManifest(directory);\n const names = Option.match(manifest, {\n onNone: (): readonly string[] => [],\n onSome: workspaceDependencies,\n });\n return yield* Effect.forEach(\n names,\n (name) => files.realPath(files.join(directory, NODE_MODULES, name)),\n {\n concurrency: 1,\n },\n );\n});\n\nexport const workspaceClosure = Effect.fn(\"workspaceClosure\")(function* workspaceClosure(\n start: string,\n) {\n const seen = new Set([start]);\n const queue = [start];\n for (const directory of queue) {\n const next = yield* dependenciesOf(directory);\n for (const dependency of next) {\n if (!seen.has(dependency)) {\n seen.add(dependency);\n queue.push(dependency);\n }\n }\n }\n return [...seen];\n});\n\nconst isUnder =\n (prefixes: readonly string[]) =>\n (file: string): boolean =>\n pipe(\n prefixes,\n Arr.some((prefix) => Str.startsWith(prefix)(file)),\n );\n\nconst closureOf = Effect.fn(\"closureOf\")(function* closureOf(root: string, configPath: string) {\n const files = yield* RepositoryFiles;\n const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));\n const directories = yield* workspaceClosure(directory);\n const prefixes = pipe(\n directories,\n Arr.map((found) => `${files.relative(root, found)}${SEPARATOR}`),\n );\n return { directories, prefixes };\n});\n\nconst scopedNames =\n (modules: string) =>\n (name: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* listScope() {\n const files = yield* RepositoryFiles;\n if (!Str.startsWith(SCOPE_PREFIX)(name)) {\n return [name];\n }\n const scoped = yield* files.readDirectory(files.join(modules, name));\n return pipe(\n scoped,\n Arr.map((entry) => `${name}${SEPARATOR}${entry}`),\n );\n });\n\nconst installedNames = Effect.fn(\"installedNames\")(function* installedNames(modules: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.readDirectory(modules);\n const nested = yield* pipe(\n listed,\n Arr.filter((name) => !Str.startsWith(HIDDEN_PREFIX)(name)),\n (items) => Effect.forEach(items, scopedNames(modules), { concurrency: 1 }),\n );\n return Arr.flatten(nested);\n});\n\nexport const installedPackages = Effect.fn(\"installedPackages\")(function* installedPackages(\n root: string,\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const modules = files.join(directory, NODE_MODULES);\n const names = yield* installedNames(modules);\n return yield* Effect.forEach(\n names,\n (name) =>\n files\n .realPath(files.join(modules, name))\n .pipe(Effect.map((found) => files.relative(root, found))),\n { concurrency: 1 },\n );\n});\n\nconst dependencyVersions = Effect.fn(\"dependencyVersions\")(function* dependencyVersions(\n root: string,\n directories: readonly string[],\n) {\n const installed = yield* Effect.forEach(\n Arr.dedupe([root, ...directories]),\n (directory) => installedPackages(root, directory),\n { concurrency: 1 },\n );\n return Arr.sort(Arr.dedupe(Arr.flatten(installed)), Order.String);\n});\n\nexport interface InputScope {\n readonly workspace: Workspace;\n readonly listed: readonly string[];\n}\n\nexport const projectInputs =\n ({ workspace: { compiler, root }, listed }: InputScope) =>\n (configPath: string): Effect.Effect<Option.Option<ProjectInputs>, never, RepositoryFiles> =>\n Effect.gen(function* collectInputs() {\n const files = yield* RepositoryFiles;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none();\n }\n const closure = yield* closureOf(root, configPath);\n const dependencies = yield* dependencyVersions(root, closure.directories);\n const options = yield* encodeOptions(parsed.value.options).pipe(\n Effect.orElseSucceed(() => \"\"),\n );\n const sources = pipe(\n parsed.value.fileNames,\n Arr.map((fileName) => files.relative(root, fileName)),\n );\n const shared = pipe(listed, Arr.filter(isUnder(closure.prefixes)));\n return Option.some({\n options,\n files: Arr.sort(Arr.dedupe([...sources, ...shared]), Order.String),\n dependencies,\n });\n });\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst PASSED = \"\";\nconst UNREADABLE = \"\";\nconst FIELD_SEPARATOR = \"\\0\";\nconst LINE_SEPARATOR = \"\\n\";\n\nexport interface Records {\n readonly directory: string;\n readonly passed: readonly string[];\n}\n\nexport type NamedFile = readonly [name: string, file: string];\n\nexport const contentKey = Effect.fn(\"contentKey\")(function* contentKey(\n salt: readonly string[],\n named: readonly NamedFile[],\n) {\n const files = yield* RepositoryFiles;\n const entries = yield* Effect.forEach(\n named,\n ([name, file]) =>\n files\n .hashFile(file)\n .pipe(\n Effect.map(\n (found) => `${name}${FIELD_SEPARATOR}${Option.getOrElse(found, () => UNREADABLE)}`,\n ),\n ),\n { concurrency: 1 },\n );\n return yield* files.hash(Arr.join([...salt, ...entries], LINE_SEPARATOR));\n});\n\nexport const recordsIn = Effect.fn(\"recordsIn\")(function* recordsIn(directory: string) {\n const files = yield* RepositoryFiles;\n const present = yield* files.readDirectory(directory);\n return { directory, passed: present } satisfies Records;\n});\n\nexport const keepOnly = Effect.fn(\"keepOnly\")(function* keepOnly(\n records: Records,\n keys: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const stale = pipe(\n records.passed,\n Arr.filter((key) => !Arr.contains(keys, key)),\n );\n yield* Effect.forEach(stale, (key) => files.removeFile(files.join(records.directory, key)), {\n concurrency: 1,\n discard: true,\n });\n yield* Effect.forEach(\n keys,\n (key) => files.writeFile(files.join(records.directory, key), PASSED),\n { concurrency: 1, discard: true },\n );\n});\n","import { Array as Arr, Boolean as Bool, Effect, String as Str, pipe } from \"effect\";\n\nimport { contentKey } from \"#/shared/lib/pass-records.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { installedPackages, nearestManifestDirectory } from \"./inputs.ts\";\n\nconst MANIFEST_ENTRY = \"package.json\";\nconst SOURCE_ENTRY = \"src\";\nconst LOWER_LAYERS = [\"entities\", \"shared\"] as const;\nconst PATH_SEPARATOR = \"/\";\nconst NOT_INSTALLED: readonly string[] = [];\n\nconst walked = (directory: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* walkFrom() {\n const files = yield* RepositoryFiles;\n const found = yield* files.walkDirectory(directory);\n return pipe(\n found,\n Arr.map((file) => files.join(directory, file)),\n );\n });\n\nconst sourceFiles = Effect.fn(\"sourceFiles\")(function* sourceFiles(\n root: string,\n moduleDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const source = files.join(root, SOURCE_ENTRY);\n const layers = pipe(\n LOWER_LAYERS,\n Arr.map((layer) => files.join(source, layer)),\n );\n const nested = yield* Effect.forEach([files.dirname(moduleDirectory), ...layers], walked, {\n concurrency: 1,\n });\n return Arr.flatten(nested);\n});\n\nconst bundleParts = Effect.fn(\"bundleParts\")(function* bundleParts(\n root: string,\n moduleDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const bundled = yield* walked(moduleDirectory);\n return { listed: [files.join(root, MANIFEST_ENTRY), ...bundled], installed: NOT_INSTALLED };\n});\n\nconst sourceParts = Effect.fn(\"sourceParts\")(function* sourceParts(\n root: string,\n moduleDirectory: string,\n) {\n const listed = yield* sourceFiles(root, moduleDirectory);\n const installed = yield* installedPackages(root, root);\n return { listed, installed };\n});\n\n/** @internal */\nexport const implementationOf = Effect.fn(\"implementationOf\")(function* implementationOf(\n moduleDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const root = yield* nearestManifestDirectory(moduleDirectory);\n const fromSource = Str.startsWith(`${files.join(root, SOURCE_ENTRY)}${PATH_SEPARATOR}`)(\n moduleDirectory,\n );\n const parts = yield* Bool.match(fromSource, {\n onFalse: () => bundleParts(root, moduleDirectory),\n onTrue: () => sourceParts(root, moduleDirectory),\n });\n return {\n files: pipe(\n Arr.sort(parts.listed, Str.Order),\n Arr.map((file) => [files.relative(root, file), file] as const),\n ),\n installed: parts.installed,\n };\n});\n\nexport const implementationFingerprint = Effect.fn(\"implementationFingerprint\")(\n function* implementationFingerprint(moduleDirectory: string) {\n const implementation = yield* implementationOf(moduleDirectory);\n return yield* contentKey(implementation.installed, implementation.files);\n },\n);\n"],"mappings":";;;;;AAYA,MAAM,yBAAyB,CAAC,QAAQ,SAAS;AAEjD,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB;AAEzB,MAAa,YAAY,UAAyB,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAEjF,MAAM,kBAAkB,SAAqC;CAC3D,IAAI,KAAK,oBAAoB,KAAK,KAAK,oBAAoB,GACzD,OAAO,OAAO,KAAK,KAAK,KAAK;CAE/B,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,mBAAmB,UAA4D;CAC1F,MAAM,SAAS,KACb,OACAA,MAAI,KAAK,WAAW,eAAe,MAAM,CAAC,GAC1CA,MAAI,UACJA,MAAI,YAAY,MAAM,UAAU,SAAS,IAAI,MAAM,SAAS,KAAK,CAAC,CACpE;CACA,IAAI,OAAO,WAAW,MAAM,UAAU,OAAO,SAAS,kBACpD,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,KAAK,MAAM;AAC3B;AAEA,MAAa,kBAAkB,SAAgD;CAC7E,IAAI,CAAC,KAAK,YAAY,GACpB,OAAO,OAAO,KAAK;CAErB,OAAO,gBAAgB,KAAK,SAAS,CAAC;AACxC;AAEA,MAAM,iBAAiB,SAAkB,SAAoC;CAC3E,IAAI,CAAC,QAAQ,gBAAgB,IAAI,GAC/B,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,gBAAgB,QAAQ,mBAAmB,MAAM,UAAU,MAAM,CAAC;AAClF;AAEA,MAAa,gBACV,aACA,SACCA,MAAI,UAAU,yBAAyB,SACrC,OAAO,gBAAgB,QAAQ,kBAAkB,MAAM,IAAI,CA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,OAAO,OAAO,yBAAyB,eAAe;CAC5D,MAAM,aAAaC,SAAI,WAAW,GAAG,MAAM,KAAK,MAAM,YAAY,IAAI,gBAAgB,CAAC,CACrF,eACF;CACA,MAAM,QAAQ,OAAOC,QAAK,MAAM,YAAY;EAC1C,eAAe,YAAY,MAAM,eAAe;EAChD,cAAc,YAAY,MAAM,eAAe;CACjD,CAAC;CACD,OAAO;EACL,OAAO,KACLF,MAAI,KAAK,MAAM,QAAQC,SAAI,KAAK,GAChCD,MAAI,KAAK,SAAS,CAAC,MAAM,SAAS,MAAM,IAAI,GAAG,IAAI,CAAU,CAC/D;EACA,WAAW,MAAM;CACnB;AACF,CAAC;AAED,MAAa,4BAA4B,OAAO,GAAG,2BAA2B,CAAC,CAC7E,UAAU,0BAA0B,iBAAyB;CAC3D,MAAM,iBAAiB,OAAO,iBAAiB,eAAe;CAC9D,OAAO,OAAO,WAAW,eAAe,WAAW,eAAe,KAAK;AACzE,CACF"}
1
+ {"version":3,"file":"project-C4uzq7_4.mjs","names":["Arr","Fn","Arr","Num","Str","Arr","HIDDEN_PREFIX","Str","Arr","Arr","Str","Arr","Arr","Str","Bool"],"sources":["../src/shared/lib/values.ts","../src/entities/project/model/library.ts","../src/entities/project/model/telemetry.ts","../src/entities/project/model/project.ts","../src/entities/project/model/inputs.ts","../src/shared/lib/pass-records.ts","../src/entities/project/model/implementation.ts"],"sourcesContent":["import { Array as Arr, Function as Fn, Option, pipe } from \"effect\";\n\nimport { IndexKind } from \"./compiler.ts\";\nimport type { Checker, Type } from \"./compiler.ts\";\n\nexport type Value = string | number;\n\nexport interface Vocabulary {\n readonly values: readonly Value[];\n readonly admitsUnnamedValues: boolean;\n}\n\nconst SCHEMA_TYPE_PROPERTIES = [\"Type\", \"_output\"] as const;\n\nconst MINIMUM_SET_SIZE = 2;\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const valueKey = (value: Value): string => `${typeof value}:${String(value)}`;\n\nconst literalValueOf = (type: Type): Option.Option<Value> => {\n if (type.isStringLiteralType() || type.isNumberLiteralType()) {\n return Option.some(type.value);\n }\n return Option.none();\n};\n\nexport const literalValuesOf = (types: readonly Type[]): Option.Option<readonly Value[]> => {\n const values = pipe(\n types,\n Arr.map((member) => literalValueOf(member)),\n Arr.getSomes,\n Arr.dedupeWith((left, right) => valueKey(left) === valueKey(right)),\n );\n if (values.length !== types.length || values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some(values);\n};\n\nexport const literalUnionOf = (type: Type): Option.Option<readonly Value[]> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n return literalValuesOf(type.getTypes());\n};\n\nconst elementTypeOf = (checker: Checker, type: Type): Option.Option<Type> => {\n if (!checker.isArrayLikeType(type)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getIndexTypeOfType(type, IndexKind.Number));\n};\n\nexport const schemaTypeOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Type> =>\n Arr.findFirst(SCHEMA_TYPE_PROPERTIES, (name) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(type, name)),\n ).pipe(Option.map((property) => checker.getTypeOfSymbol(property)));\n\nexport const finiteValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalUnionOf(type).pipe(\n Option.orElse(() => elementTypeOf(checker, type).pipe(Option.flatMap(literalUnionOf))),\n Option.orElse(() => schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf))),\n );\n\nexport const vocabularyOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Vocabulary> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n const optionalIds = new Set([checker.getUndefinedType().id, checker.getNullType().id]);\n const members = pipe(\n type.getTypes(),\n Arr.filter((member) => !optionalIds.has(member.id)),\n );\n const values = Arr.getSomes(\n pipe(\n members,\n Arr.map((member) => literalValueOf(member)),\n ),\n );\n if (values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some({ values, admitsUnnamedValues: values.length !== members.length });\n };\n\nexport const isSubsetOf: {\n (superset: readonly Value[]): (subset: readonly Value[]) => boolean;\n (subset: readonly Value[], superset: readonly Value[]): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (subset: readonly Value[], superset: readonly Value[]): boolean => {\n const held = new Set(\n pipe(\n superset,\n Arr.map((value) => valueKey(value)),\n ),\n );\n return pipe(\n subset,\n Arr.every((value) => held.has(valueKey(value))),\n );\n});\n\nexport const sameValues: {\n (right: readonly Value[]): (left: readonly Value[]) => boolean;\n (left: readonly Value[], right: readonly Value[]): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (left: readonly Value[], right: readonly Value[]): boolean =>\n left.length === right.length && isSubsetOf(left, right),\n);\n\nconst valueText = (value: Value): string => {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n return String(value);\n};\n\nexport const formatValues = (values: readonly Value[]): string =>\n pipe(values, Arr.map(valueText), Arr.join(\" | \"));\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { DependencyEntry } from \"#/entities/package/@x/project.ts\";\nimport {\n InternalSymbolName,\n isModuleDeclaration,\n isVariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n SyntaxKind,\n TypeSymbol,\n Type,\n} from \"#/shared/lib/compiler.ts\";\nimport {\n declarationsOf,\n isGenericDeclaration,\n isTypeDeclaration,\n propertyNamesOf,\n resolvedSymbol,\n} from \"#/shared/lib/syntax.ts\";\nimport { schemaTypeOf, vocabularyOf } from \"#/shared/lib/values.ts\";\nimport type { Vocabulary } from \"#/shared/lib/values.ts\";\n\nexport interface LibraryType {\n readonly specifier: string;\n readonly typeName: string;\n}\n\nexport interface LibraryVocabulary extends LibraryType {\n readonly vocabulary: Vocabulary;\n}\n\nexport interface DeclarationLocation {\n readonly file: string;\n readonly pos: number;\n readonly kind: SyntaxKind;\n}\n\nexport interface LibraryShape extends LibraryType {\n readonly form: \"declared\" | \"schema\";\n readonly declaration: DeclarationLocation;\n readonly propertyNames: readonly string[];\n}\n\nexport interface LibraryIndex {\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly shapes: readonly LibraryShape[];\n}\n\ninterface Walk {\n readonly checker: Checker;\n readonly entry: DependencyEntry;\n}\n\ninterface Visit {\n readonly exported: TypeSymbol;\n readonly qualifier: string;\n readonly ancestors: readonly TypeSymbol[];\n}\n\ninterface Exported {\n readonly symbol: TypeSymbol;\n readonly typeName: string;\n}\n\nconst NAMESPACE_DEPTH_LIMIT = 8;\nconst EMPTY_INDEX: LibraryIndex = { vocabularies: [], shapes: [] };\n\nexport const isObjectType =\n (checker: Checker) =>\n (type: Type): boolean =>\n !type.isUnionType() &&\n !type.isLiteralType() &&\n checker.getApparentType(type).id === type.id &&\n Arr.isReadonlyArrayNonEmpty(checker.getPropertiesOfType(type));\n\nexport const describeLibraryType = (type: LibraryType): string =>\n `${type.typeName} from ${type.specifier}`;\n\nexport const locationOf = (declaration: Node): DeclarationLocation => ({\n file: declaration.getSourceFile().fileName,\n pos: declaration.pos,\n kind: declaration.kind,\n});\n\nexport const declarationKey = (location: DeclarationLocation): string =>\n `${location.file}#${String(location.pos)}#${String(location.kind)}`;\n\ntype ShapeSource = LibraryType & Pick<LibraryShape, \"form\">;\n\nconst shapeOf =\n (checker: Checker) =>\n (source: ShapeSource, declaration: Declaration, type: Type): readonly LibraryShape[] =>\n Arr.filter(\n [\n {\n ...source,\n declaration: locationOf(declaration),\n propertyNames: propertyNamesOf(checker)(type),\n },\n ],\n () => isObjectType(checker)(type),\n );\n\nconst declaredTypeIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isTypeDeclaration);\n if (Option.isNone(declaration) || isGenericDeclaration(declaration.value)) {\n return EMPTY_INDEX;\n }\n const located = { specifier: walk.entry.specifier, typeName: exported.typeName };\n const type = walk.checker.getDeclaredTypeOfSymbol(exported.symbol);\n const vocabularies = vocabularyOf(walk.checker)(type).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n );\n const shapes = shapeOf(walk.checker)({ ...located, form: \"declared\" }, declaration.value, type);\n return { vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n vocabularies: vocabularyOf(walk.checker)(schemaType).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n ),\n shapes: shapeOf(walk.checker)({ ...located, form: \"schema\" }, declaration, schemaType),\n });\n\nconst schemaValueIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isVariableDeclaration);\n if (Option.isNone(declaration)) {\n return EMPTY_INDEX;\n }\n const valueType = walk.checker.getTypeOfSymbolAtLocation(exported.symbol, declaration.value);\n const located = {\n specifier: walk.entry.specifier,\n typeName: `(typeof ${exported.typeName})[\"Type\"]`,\n };\n return Option.match(schemaTypeOf(walk.checker)(valueType), {\n onNone: () => EMPTY_INDEX,\n onSome: (schemaType) => schemaTypeIndex(walk, located)(declaration.value, schemaType),\n });\n};\n\nconst mergeIndexes = (indexes: readonly LibraryIndex[]): LibraryIndex => ({\n vocabularies: pipe(\n indexes,\n Arr.flatMap((index) => index.vocabularies),\n ),\n shapes: pipe(\n indexes,\n Arr.flatMap((index) => index.shapes),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isModuleDeclaration(declaration)),\n );\n\nconst indexUnder = (walk: Walk, visit: Visit): LibraryIndex => {\n const symbol = resolvedSymbol(walk.checker)(visit.exported);\n const named = { symbol, typeName: `${visit.qualifier}${visit.exported.name}` };\n const own = mergeIndexes([declaredTypeIndex(walk, named), schemaValueIndex(walk, named)]);\n if (\n !isNamespace(symbol) ||\n visit.ancestors.length >= NAMESPACE_DEPTH_LIMIT ||\n visit.ancestors.includes(symbol)\n ) {\n return own;\n }\n const nested = pipe(\n walk.checker.getExportsOfModule(symbol),\n Arr.map((member) =>\n indexUnder(walk, {\n exported: member,\n qualifier: `${named.typeName}.`,\n ancestors: [...visit.ancestors, symbol],\n }),\n ),\n );\n return mergeIndexes([own, ...nested]);\n};\n\nconst exportAssignmentOf = (moduleSymbol: TypeSymbol): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(moduleSymbol.getExports().get(InternalSymbolName.ExportEquals));\n\nconst indexOfEntry =\n (checker: Checker) =>\n (entry: DependencyEntry): LibraryIndex => {\n const moduleSymbol = Option.fromUndefinedOr(\n checker.getSymbolOfSourceFile(entry.declarationsPath),\n );\n if (Option.isNone(moduleSymbol)) {\n return EMPTY_INDEX;\n }\n const walk: Walk = { checker, entry };\n const roots = Option.match(exportAssignmentOf(moduleSymbol.value), {\n onNone: () => checker.getExportsOfModule(moduleSymbol.value),\n onSome: (assigned) => [resolvedSymbol(checker)(assigned)],\n });\n return mergeIndexes(\n pipe(\n roots,\n Arr.map((exported) => indexUnder(walk, { exported, qualifier: \"\", ancestors: [] })),\n ),\n );\n };\n\nexport interface CachedIndex {\n readonly index: LibraryIndex;\n readonly cached: boolean;\n}\n\nexport interface LibraryCache {\n readonly indexOf: (entry: DependencyEntry, compute: () => LibraryIndex) => CachedIndex;\n}\n\nexport const libraryCache = (): LibraryCache => {\n const indexes = new Map<string, LibraryIndex>();\n return {\n indexOf: (entry, compute) =>\n Option.match(Option.fromUndefinedOr(indexes.get(entry.declarationsPath)), {\n onSome: (index) => ({ index, cached: true }),\n onNone: () => {\n const index = compute();\n indexes.set(entry.declarationsPath, index);\n return { index, cached: false };\n },\n }),\n };\n};\n\nconst indexEntry =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entry: DependencyEntry): Effect.Effect<LibraryIndex> =>\n Effect.sync(() => cache.indexOf(entry, () => indexOfEntry(checker)(entry))).pipe(\n Effect.tap(({ index, cached }) =>\n Effect.annotateCurrentSpan({\n \"msch.library.cached\": cached,\n \"msch.library.vocabularies\": index.vocabularies.length,\n \"msch.library.shapes\": index.shapes.length,\n }),\n ),\n Effect.map(({ index }) => index),\n Effect.withSpan(\"indexLibraryEntry\", {\n attributes: { \"msch.library.specifier\": entry.specifier },\n }),\n );\n\nexport const libraryIndex =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entries: readonly DependencyEntry[]): Effect.Effect<LibraryIndex> =>\n pipe(\n entries,\n (items) => Effect.forEach(items, indexEntry(cache)(checker), { concurrency: 1 }),\n Effect.map(mergeIndexes),\n Effect.withSpan(\"libraryIndex\"),\n );\n","import { Array as Arr, Effect, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nimport type { API } from \"#/shared/lib/compiler.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RSS_LINE = /^VmRSS:\\s+(?<kib>\\d+) kB$/mu;\nconst BYTES_PER_KIB = 1024;\nconst UNKNOWN_RSS = 0;\n\nconst kibibytesIn = (status: string): Option.Option<string> =>\n Option.fromNullishOr(RSS_LINE.exec(status)).pipe(\n Option.flatMap((match) => Option.fromUndefinedOr(match.groups)),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[\"kib\"])),\n );\n\nconst residentBytesOf = (pid: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* residentBytes() {\n const files = yield* RepositoryFiles;\n const status = yield* files.readFile(`/proc/${pid}/status`);\n return pipe(\n status,\n Option.flatMap(kibibytesIn),\n Option.flatMap(Num.parse),\n Option.map((kib) => kib * BYTES_PER_KIB),\n Option.getOrElse(() => UNKNOWN_RSS),\n );\n });\n\nconst childPids = Effect.gen(function* childPids() {\n const files = yield* RepositoryFiles;\n const pid = String(process.pid);\n const children = yield* files.readFile(`/proc/${pid}/task/${pid}/children`);\n return pipe(\n children,\n Option.map((text) => pipe(Str.trim(text), Str.split(\" \"), Arr.filter(Str.isNonEmpty))),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst annotateMemory = Effect.gen(function* annotateMemory() {\n const own = yield* residentBytesOf(String(process.pid));\n const pids = yield* childPids;\n const children = yield* Effect.forEach(pids, (pid) => residentBytesOf(pid), { concurrency: 1 });\n const { heapUsed } = process.memoryUsage();\n yield* Effect.annotateCurrentSpan({\n \"process.memory.rss\": own,\n \"process.memory.heap_used\": heapUsed,\n \"msch.compiler.memory.rss\": Num.sumAll(children),\n });\n});\n\nexport const annotateResources = (api: API): Effect.Effect<void, never, RepositoryFiles> =>\n Effect.gen(function* annotateCompiler() {\n yield* annotateMemory;\n const { totals } = api.getTimingInfo();\n yield* Effect.annotateCurrentSpan({\n \"msch.compiler.requests\": totals.requestCount,\n \"msch.compiler.round_trip_ms\": totals.roundTripMs,\n \"msch.compiler.server_ms\": totals.serverTimeMs,\n });\n });\n","import { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n dependencyEntries,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { API, getLeadingCommentRanges } from \"#/shared/lib/compiler.ts\";\nimport type { Checker, ParsedCommandLine, Program, SourceFile } from \"#/shared/lib/compiler.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { libraryCache, libraryIndex } from \"./library.ts\";\nimport type { LibraryCache, LibraryIndex } from \"./library.ts\";\nimport { annotateResources } from \"./telemetry.ts\";\n\nexport interface Project {\n readonly packageName: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n readonly program: Program;\n readonly checker: Checker;\n readonly sourceFiles: readonly SourceFile[];\n readonly library: LibraryIndex;\n}\n\nexport type SourceCheck = (checker: Checker) => (sourceFile: SourceFile) => readonly Problem[];\n\ninterface PackageInfo {\n readonly directory: string;\n readonly name: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n}\n\nconst CONFIG_FILE = \"tsconfig.json\";\nconst CONFIG_PATHSPEC = `:(glob)**/${CONFIG_FILE}`;\nconst HIDDEN_PREFIX = \".\";\nconst SKIPPED_DIRECTORIES: ReadonlySet<string> = new Set([NODE_MODULES, \"dist\", \"coverage\"]);\n\nconst isVisible = (file: string): boolean =>\n pipe(\n Str.split(file, \"/\"),\n Arr.every(\n (segment) => !Str.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment),\n ),\n );\n\nexport const listConfigFiles = (\n root: string,\n): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* configFilesUnder() {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);\n const visible = pipe(\n listed,\n Arr.filter(isVisible),\n Arr.map((file) => files.join(root, file)),\n );\n return Arr.sort(visible, Order.String);\n });\n\nexport const parseConfig =\n (api: API) =>\n (configPath: string): Option.Option<ParsedCommandLine> =>\n Option.some(api.parseConfigFile(configPath)).pipe(\n Option.filter((parsed) => Arr.isReadonlyArrayNonEmpty(parsed.fileNames)),\n );\n\nconst nearestPackageDirectory = (\n directory: string,\n root: string,\n): Effect.Effect<string, never, RepositoryFiles> =>\n Effect.gen(function* nearestPackage() {\n const files = yield* RepositoryFiles;\n const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE));\n const parent = files.dirname(directory);\n if (hasManifest || directory === root || parent === directory) {\n return directory;\n }\n return yield* nearestPackageDirectory(parent, root);\n });\n\nexport const packageDirectoryOf =\n (root: string) =>\n (directory: string): Effect.Effect<string, never, RepositoryFiles> =>\n nearestPackageDirectory(directory, root);\n\nconst packageInfoOf = Effect.fn(\"packageInfoOf\")(function* packageInfoOf(\n configPath: string,\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);\n const manifest = yield* readManifest(directory);\n return {\n directory,\n name: manifest.pipe(Option.flatMap((found) => Option.fromUndefinedOr(found.name))),\n workspaceDependencies: manifest.pipe(\n Option.map(workspaceDependencies),\n Option.getOrElse(() => []),\n ),\n } satisfies PackageInfo;\n});\n\nconst NO_CHECK_PRAGMA = /^\\/\\/\\s*@ts-nocheck/u;\nconst FILE_START = 0;\n\nconst skipsTypeChecking = (sourceFile: SourceFile): boolean =>\n pipe(\n getLeadingCommentRanges(sourceFile.text, FILE_START) ?? [],\n Arr.some((range) => NO_CHECK_PRAGMA.test(Str.slice(range.pos, range.end)(sourceFile.text))),\n );\n\nconst buildProject = Effect.fn(\"buildProject\")(function* buildProject(\n { compiler: { api, libraries }, generated }: Workspace,\n parsed: ParsedCommandLine,\n info: PackageInfo,\n) {\n const entries = yield* dependencyEntries(info.directory);\n const program = yield* Effect.sync(() =>\n api.createProgram(\n [\n ...parsed.fileNames,\n ...pipe(\n entries,\n Arr.map((entry) => entry.declarationsPath),\n ),\n ],\n { ...parsed.options, noEmit: true },\n ),\n ).pipe(Effect.withSpan(\"createProgram\"));\n const { checker } = program.getProject();\n const library = yield* libraryIndex(libraries)(checker)(entries);\n const projectFiles: ReadonlySet<string> = new Set(\n pipe(\n parsed.fileNames,\n Arr.filter((fileName) => !generated.includes(fileName)),\n ),\n );\n return {\n packageName: info.name,\n workspaceDependencies: info.workspaceDependencies,\n program,\n checker,\n sourceFiles: pipe(\n program.getSourceFileNames(),\n Arr.filter((fileName) => projectFiles.has(fileName)),\n Arr.flatMap((fileName) =>\n Option.toArray(Option.fromUndefinedOr(program.getSourceFile(fileName))),\n ),\n Arr.filter((sourceFile) => !sourceFile.isDeclarationFile && !skipsTypeChecking(sourceFile)),\n ),\n library,\n } satisfies Project;\n});\n\nexport interface Compiler {\n readonly api: API;\n readonly libraries: LibraryCache;\n}\n\nexport interface Workspace {\n readonly compiler: Compiler;\n readonly root: string;\n readonly generated: readonly string[];\n}\n\nexport const typeScriptCompiler = Effect.acquireRelease(\n Effect.sync((): Compiler => ({\n api: new API({ collectTiming: true }),\n libraries: libraryCache(),\n })),\n ({ api }) =>\n Effect.sync(() => {\n api.close();\n }),\n);\n\nconst loadProject = Effect.fn(\"loadProject\")(function* loadProject(\n workspace: Workspace,\n configPath: string,\n) {\n const { compiler, root } = workspace;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none<Project>();\n }\n const info = yield* packageInfoOf(configPath, root);\n const project = yield* buildProject(workspace, parsed.value, info);\n yield* Effect.annotateCurrentSpan({\n \"msch.project.config\": configPath,\n \"msch.project.program_files\": project.program.getSourceFileNames().length,\n \"msch.project.source_files\": project.sourceFiles.length,\n });\n yield* annotateResources(compiler.api);\n return Option.some(project);\n});\n\nconst releaseProject = (project: Project): Effect.Effect<void> =>\n Effect.sync(() => {\n project.program.dispose();\n });\n\nexport const withProject =\n (workspace: Workspace) =>\n (configPath: string) =>\n <Value, Failure, Requirements>(\n work: (project: Project) => Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<Option.Option<Value>, Failure, Requirements | RepositoryFiles> =>\n Effect.acquireUseRelease(\n loadProject(workspace, configPath),\n (loaded) =>\n Option.match(loaded, {\n onNone: () => Effect.succeedNone,\n onSome: (project) => work(project).pipe(Effect.asSome),\n }),\n (loaded) => Option.match(loaded, { onNone: () => Effect.void, onSome: releaseProject }),\n );\n\nexport const mentions =\n (needle: string) =>\n ({ api }: Compiler) =>\n (configPath: string): Effect.Effect<boolean, never, RepositoryFiles> =>\n Effect.gen(function* mentionsNeedle() {\n const files = yield* RepositoryFiles;\n const fileNames = Option.match(parseConfig(api)(configPath), {\n onNone: (): readonly string[] => [],\n onSome: (parsed): readonly string[] => parsed.fileNames,\n });\n const texts = yield* Effect.forEach(fileNames, (fileName) => files.readFile(fileName), {\n concurrency: 1,\n });\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n","import { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { packageDirectoryOf, parseConfig } from \"./project.ts\";\nimport type { Workspace } from \"./project.ts\";\n\nexport interface ProjectInputs {\n readonly options: string;\n readonly files: readonly string[];\n readonly dependencies: readonly string[];\n}\n\nconst SEPARATOR = \"/\";\nconst SCOPE_PREFIX = \"@\";\nconst HIDDEN_PREFIX = \".\";\n\nconst encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\n\nexport const nearestManifestDirectory = Effect.fn(\"nearestManifestDirectory\")(\n function* nearestManifestDirectory(start: string) {\n const files = yield* RepositoryFiles;\n let directory = start;\n let parent = files.dirname(directory);\n while (parent !== directory && !(yield* files.exists(files.join(directory, MANIFEST_FILE)))) {\n directory = parent;\n parent = files.dirname(directory);\n }\n return directory;\n },\n);\n\nconst dependenciesOf = Effect.fn(\"dependenciesOf\")(function* dependenciesOf(directory: string) {\n const files = yield* RepositoryFiles;\n const manifest = yield* readManifest(directory);\n const names = Option.match(manifest, {\n onNone: (): readonly string[] => [],\n onSome: workspaceDependencies,\n });\n return yield* Effect.forEach(\n names,\n (name) => files.realPath(files.join(directory, NODE_MODULES, name)),\n {\n concurrency: 1,\n },\n );\n});\n\nexport const workspaceClosure = Effect.fn(\"workspaceClosure\")(function* workspaceClosure(\n start: string,\n) {\n const seen = new Set([start]);\n const queue = [start];\n for (const directory of queue) {\n const next = yield* dependenciesOf(directory);\n for (const dependency of next) {\n if (!seen.has(dependency)) {\n seen.add(dependency);\n queue.push(dependency);\n }\n }\n }\n return [...seen];\n});\n\nconst isUnder =\n (prefixes: readonly string[]) =>\n (file: string): boolean =>\n pipe(\n prefixes,\n Arr.some((prefix) => Str.startsWith(prefix)(file)),\n );\n\nconst closureOf = Effect.fn(\"closureOf\")(function* closureOf(root: string, configPath: string) {\n const files = yield* RepositoryFiles;\n const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));\n const directories = yield* workspaceClosure(directory);\n const prefixes = pipe(\n directories,\n Arr.map((found) => `${files.relative(root, found)}${SEPARATOR}`),\n );\n return { directories, prefixes };\n});\n\nconst scopedNames =\n (modules: string) =>\n (name: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* listScope() {\n const files = yield* RepositoryFiles;\n if (!Str.startsWith(SCOPE_PREFIX)(name)) {\n return [name];\n }\n const scoped = yield* files.readDirectory(files.join(modules, name));\n return pipe(\n scoped,\n Arr.map((entry) => `${name}${SEPARATOR}${entry}`),\n );\n });\n\nconst installedNames = Effect.fn(\"installedNames\")(function* installedNames(modules: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.readDirectory(modules);\n const nested = yield* pipe(\n listed,\n Arr.filter((name) => !Str.startsWith(HIDDEN_PREFIX)(name)),\n (items) => Effect.forEach(items, scopedNames(modules), { concurrency: 1 }),\n );\n return Arr.flatten(nested);\n});\n\nexport const installedPackages = Effect.fn(\"installedPackages\")(function* installedPackages(\n root: string,\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const modules = files.join(directory, NODE_MODULES);\n const names = yield* installedNames(modules);\n return yield* Effect.forEach(\n names,\n (name) =>\n files\n .realPath(files.join(modules, name))\n .pipe(Effect.map((found) => files.relative(root, found))),\n { concurrency: 1 },\n );\n});\n\nconst dependencyVersions = Effect.fn(\"dependencyVersions\")(function* dependencyVersions(\n root: string,\n directories: readonly string[],\n) {\n const installed = yield* Effect.forEach(\n Arr.dedupe([root, ...directories]),\n (directory) => installedPackages(root, directory),\n { concurrency: 1 },\n );\n return Arr.sort(Arr.dedupe(Arr.flatten(installed)), Order.String);\n});\n\nexport interface InputScope {\n readonly workspace: Workspace;\n readonly listed: readonly string[];\n}\n\nexport const projectInputs =\n ({ workspace: { compiler, root }, listed }: InputScope) =>\n (configPath: string): Effect.Effect<Option.Option<ProjectInputs>, never, RepositoryFiles> =>\n Effect.gen(function* collectInputs() {\n const files = yield* RepositoryFiles;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none();\n }\n const closure = yield* closureOf(root, configPath);\n const dependencies = yield* dependencyVersions(root, closure.directories);\n const options = yield* encodeOptions(parsed.value.options).pipe(\n Effect.orElseSucceed(() => \"\"),\n );\n const sources = pipe(\n parsed.value.fileNames,\n Arr.map((fileName) => files.relative(root, fileName)),\n );\n const shared = pipe(listed, Arr.filter(isUnder(closure.prefixes)));\n return Option.some({\n options,\n files: Arr.sort(Arr.dedupe([...sources, ...shared]), Order.String),\n dependencies,\n });\n });\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst PASSED = \"\";\nconst UNREADABLE = \"\";\nconst FIELD_SEPARATOR = \"\\0\";\nconst LINE_SEPARATOR = \"\\n\";\n\nexport interface Records {\n readonly directory: string;\n readonly passed: readonly string[];\n}\n\nexport type NamedFile = readonly [name: string, file: string];\n\nexport const contentKey = Effect.fn(\"contentKey\")(function* contentKey(\n salt: readonly string[],\n named: readonly NamedFile[],\n) {\n const files = yield* RepositoryFiles;\n const entries = yield* Effect.forEach(\n named,\n ([name, file]) =>\n files\n .hashFile(file)\n .pipe(\n Effect.map(\n (found) => `${name}${FIELD_SEPARATOR}${Option.getOrElse(found, () => UNREADABLE)}`,\n ),\n ),\n { concurrency: 1 },\n );\n return yield* files.hash(Arr.join([...salt, ...entries], LINE_SEPARATOR));\n});\n\nexport const recordsIn = Effect.fn(\"recordsIn\")(function* recordsIn(directory: string) {\n const files = yield* RepositoryFiles;\n const present = yield* files.readDirectory(directory);\n return { directory, passed: present } satisfies Records;\n});\n\nexport const keepOnly = Effect.fn(\"keepOnly\")(function* keepOnly(\n records: Records,\n keys: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const stale = pipe(\n records.passed,\n Arr.filter((key) => !Arr.contains(keys, key)),\n );\n yield* Effect.forEach(stale, (key) => files.removeFile(files.join(records.directory, key)), {\n concurrency: 1,\n discard: true,\n });\n yield* Effect.forEach(\n keys,\n (key) => files.writeFile(files.join(records.directory, key), PASSED),\n { concurrency: 1, discard: true },\n );\n});\n","import { Array as Arr, Boolean as Bool, Effect, String as Str, pipe } from \"effect\";\n\nimport { contentKey } from \"#/shared/lib/pass-records.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { installedPackages, nearestManifestDirectory } from \"./inputs.ts\";\n\nconst MANIFEST_ENTRY = \"package.json\";\nconst SOURCE_ENTRY = \"src\";\nconst LOWER_LAYERS = [\"entities\", \"shared\"] as const;\nconst PATH_SEPARATOR = \"/\";\nconst NOT_INSTALLED: readonly string[] = [];\n\nconst walked = (directory: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* walkFrom() {\n const files = yield* RepositoryFiles;\n const found = yield* files.walkDirectory(directory);\n return pipe(\n found,\n Arr.map((file) => files.join(directory, file)),\n );\n });\n\nconst sourceFiles = Effect.fn(\"sourceFiles\")(function* sourceFiles(\n root: string,\n moduleDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const source = files.join(root, SOURCE_ENTRY);\n const layers = pipe(\n LOWER_LAYERS,\n Arr.map((layer) => files.join(source, layer)),\n );\n const nested = yield* Effect.forEach([files.dirname(moduleDirectory), ...layers], walked, {\n concurrency: 1,\n });\n return Arr.flatten(nested);\n});\n\nconst bundleParts = Effect.fn(\"bundleParts\")(function* bundleParts(\n root: string,\n moduleDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const bundled = yield* walked(moduleDirectory);\n return { listed: [files.join(root, MANIFEST_ENTRY), ...bundled], installed: NOT_INSTALLED };\n});\n\nconst sourceParts = Effect.fn(\"sourceParts\")(function* sourceParts(\n root: string,\n moduleDirectory: string,\n) {\n const listed = yield* sourceFiles(root, moduleDirectory);\n const installed = yield* installedPackages(root, root);\n return { listed, installed };\n});\n\n/** @internal */\nexport const implementationOf = Effect.fn(\"implementationOf\")(function* implementationOf(\n moduleDirectory: string,\n) {\n const files = yield* RepositoryFiles;\n const root = yield* nearestManifestDirectory(moduleDirectory);\n const fromSource = Str.startsWith(`${files.join(root, SOURCE_ENTRY)}${PATH_SEPARATOR}`)(\n moduleDirectory,\n );\n const parts = yield* Bool.match(fromSource, {\n onFalse: () => bundleParts(root, moduleDirectory),\n onTrue: () => sourceParts(root, moduleDirectory),\n });\n return {\n files: pipe(\n Arr.sort(parts.listed, Str.Order),\n Arr.map((file) => [files.relative(root, file), file] as const),\n ),\n installed: parts.installed,\n };\n});\n\nexport const implementationFingerprint = Effect.fn(\"implementationFingerprint\")(\n function* implementationFingerprint(moduleDirectory: string) {\n const implementation = yield* implementationOf(moduleDirectory);\n return yield* contentKey(implementation.installed, implementation.files);\n },\n);\n"],"mappings":";;;;;AAYA,MAAM,yBAAyB,CAAC,QAAQ,SAAS;AAEjD,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB;AAEzB,MAAa,YAAY,UAAyB,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAEjF,MAAM,kBAAkB,SAAqC;CAC3D,IAAI,KAAK,oBAAoB,KAAK,KAAK,oBAAoB,GACzD,OAAO,OAAO,KAAK,KAAK,KAAK;CAE/B,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,mBAAmB,UAA4D;CAC1F,MAAM,SAAS,KACb,OACAA,MAAI,KAAK,WAAW,eAAe,MAAM,CAAC,GAC1CA,MAAI,UACJA,MAAI,YAAY,MAAM,UAAU,SAAS,IAAI,MAAM,SAAS,KAAK,CAAC,CACpE;CACA,IAAI,OAAO,WAAW,MAAM,UAAU,OAAO,SAAS,kBACpD,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,KAAK,MAAM;AAC3B;AAEA,MAAa,kBAAkB,SAAgD;CAC7E,IAAI,CAAC,KAAK,YAAY,GACpB,OAAO,OAAO,KAAK;CAErB,OAAO,gBAAgB,KAAK,SAAS,CAAC;AACxC;AAEA,MAAM,iBAAiB,SAAkB,SAAoC;CAC3E,IAAI,CAAC,QAAQ,gBAAgB,IAAI,GAC/B,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,gBAAgB,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AkB,MAAM,IAAI;CAC1B;AAC7B,CAAC;;AAGD,MAAa,mBAAmB,OAAO,GAAG,kBAAkB,CAAC,CAAC,UAAU,iBACtE,iBACA;CACA,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,yBAAyB,eAAe;CAC5D,MAAM,aAAaC,SAAI,WAAW,GAAG,MAAM,KAAK,MAAM,YAAY,IAAI,gBAAgB,CAAC,CACrF,eACF;CACA,MAAM,QAAQ,OAAOC,QAAK,MAAM,YAAY;EAC1C,eAAe,YAAY,MAAM,eAAe;EAChD,cAAc,YAAY,MAAM,eAAe;CACjD,CAAC;CACD,OAAO;EACL,OAAO,KACLF,MAAI,KAAK,MAAM,QAAQC,SAAI,KAAK,GAChCD,MAAI,KAAK,SAAS,CAAC,MAAM,SAAS,MAAM,IAAI,GAAG,IAAI,CAAU,CAC/D;EACA,WAAW,MAAM;CACnB;AACF,CAAC;AAED,MAAa,4BAA4B,OAAO,GAAG,2BAA2B,CAAC,CAC7E,UAAU,0BAA0B,iBAAyB;CAC3D,MAAM,iBAAiB,OAAO,iBAAiB,eAAe;CAC9D,OAAO,OAAO,WAAW,eAAe,WAAW,eAAe,KAAK;AACzE,CACF"}
package/dist/publish.mjs CHANGED
@@ -405,8 +405,8 @@ const publishToNpm = Effect.fn("publish.npm")(function* publishToNpm(directory)
405
405
  directory,
406
406
  ...manifest
407
407
  })) return yield* Console.log(`${manifest.name}@${manifest.version} is already published`);
408
- const env = yield* authEnv();
409
408
  yield* verifyPackage(directory, manifest);
409
+ const env = yield* authEnv();
410
410
  yield* publishNatives(directory, manifest, env);
411
411
  const tarball = yield* pack(directory);
412
412
  return yield* mustSucceed({
@@ -1 +1 @@
1
- {"version":3,"file":"publish.mjs","names":["taggedError","Arr","Str","taggedError","Rec","Arr","MANIFEST_FILE","UNVERSIONED","Str","taggedError","Rec","Str","Arr","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/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\ntype Failure = Config.ConfigError | HttpBody.HttpBodyError | HttpClientError.HttpClientError;\n\ntype Sent<Success> = Effect.Effect<Success, Failure, 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 Failure | 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 }: Write): Effect.Effect<\n Codec[\"Type\"],\n Failure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n withBody(\"POST\", path, body).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));\n\nconst removeAt = (path: string): Sent<void> =>\n requestTo(\"DELETE\", path).pipe(Effect.flatMap(execute), Effect.asVoid);\n\ninterface Write {\n readonly path: string;\n readonly body: unknown;\n}\n\nconst postTo = ({ path, body }: Write): Sent<void> =>\n withBody(\"POST\", path, body).pipe(Effect.asVoid);\n\nconst patchAt = ({ path, body }: Write): Sent<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\ntype 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\ntype 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 { 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 { 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});\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 const env = yield* authEnv();\n yield* verifyPackage(directory, manifest);\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;AAMA,MAAM,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,UACjD,QACA,MACA;CACA,MAAM,aAAa,O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AO,OAAO,eAAe,SAAS;AACxC,CAAC;AAED,OAAO,OAAO"}
1
+ {"version":3,"file":"publish.mjs","names":["taggedError","Arr","Str","taggedError","Rec","Arr","MANIFEST_FILE","UNVERSIONED","Str","taggedError","Rec","Str","Arr","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/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\ntype Failure = Config.ConfigError | HttpBody.HttpBodyError | HttpClientError.HttpClientError;\n\ntype Sent<Success> = Effect.Effect<Success, Failure, 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 Failure | 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 }: Write): Effect.Effect<\n Codec[\"Type\"],\n Failure | Schema.SchemaError,\n HttpClient.HttpClient | Codec[\"DecodingServices\"]\n > =>\n withBody(\"POST\", path, body).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)));\n\nconst removeAt = (path: string): Sent<void> =>\n requestTo(\"DELETE\", path).pipe(Effect.flatMap(execute), Effect.asVoid);\n\ninterface Write {\n readonly path: string;\n readonly body: unknown;\n}\n\nconst postTo = ({ path, body }: Write): Sent<void> =>\n withBody(\"POST\", path, body).pipe(Effect.asVoid);\n\nconst patchAt = ({ path, body }: Write): Sent<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\ntype 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\ntype 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 { 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 { 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});\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* publ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AAC,IAAI,CAAC,CAAC,KAC3E,OAAO,eAAe,WAAW,KAAK,EAAE,SAAS,MAAM,CAAC,CAAC,CAC3D;CACA,IAAI,SAAS,QACX,OAAO,OAAO,OAAO,SAAS,CAAC,CAAC,KAAK,OAAO,QAAQ,SAAS,CAAC;CAEhE,IAAI,SAAS,OACX,OAAO,OAAO,aAAa,SAAS;CAEtC,OAAO,OAAO,eAAe,SAAS;AACxC,CAAC;AAED,OAAO,OAAO"}
@@ -0,0 +1,8 @@
1
+ // src/shared/lib/started-once.ts
2
+ const startedOnce = () => {
3
+ const started = /* @__PURE__ */ new Map();
4
+ return (key, start) => started.getOrInsertComputed(key, () => start());
5
+ };
6
+ export { startedOnce as t };
7
+
8
+ //# sourceMappingURL=started-once-muJbvD_I.mjs.map