@r_masseater/msch 0.119.1 → 0.120.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon-tasks.mjs +12 -15
- package/dist/addon-tasks.mjs.map +1 -1
- package/dist/cargo-inputs.mjs +1 -1
- package/dist/cli.mjs +599 -335
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +8 -3
- package/dist/config.mjs +6 -5
- package/dist/config.mjs.map +1 -1
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-D_gAe4V_.mjs → define-lint-preset-CYgaGe8E.mjs} +4 -3
- package/dist/define-lint-preset-CYgaGe8E.mjs.map +1 -0
- package/dist/{dependencies-CgIp-gS1.mjs → dependencies-OrBsaeID.mjs} +2 -2
- package/dist/{dependencies-CgIp-gS1.mjs.map → dependencies-OrBsaeID.mjs.map} +1 -1
- package/dist/{derive-cargo-inputs-IFNMRDnZ.mjs → derive-cargo-inputs-Btc2ojuD.mjs} +3 -3
- package/dist/{derive-cargo-inputs-IFNMRDnZ.mjs.map → derive-cargo-inputs-Btc2ojuD.mjs.map} +1 -1
- package/dist/{ignored-directories-Btth0IHS.mjs → ignored-directories-wh-dhKsl.mjs} +2 -2
- package/dist/{ignored-directories-Btth0IHS.mjs.map → ignored-directories-wh-dhKsl.mjs.map} +1 -1
- package/dist/{index-CJiAUZDt.d.mts → index-B0ahB5vD.d.mts} +4 -11
- package/dist/{index-UROHZT4o.d.mts → index-D6X9EgDG.d.mts} +2 -2
- package/dist/library.mjs +2 -2
- package/dist/lint.d.mts +1 -1
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +2 -2
- package/dist/{problem-DaWjnZyW.mjs → problem-D0e14vkQ.mjs} +2 -2
- package/dist/{problem-DaWjnZyW.mjs.map → problem-D0e14vkQ.mjs.map} +1 -1
- package/dist/{published-BITU3twH.mjs → published-u44g9ha6.mjs} +25 -4
- package/dist/published-u44g9ha6.mjs.map +1 -0
- package/dist/{repository-files-BU_wY36C.mjs → repository-files-C8B7lrka.mjs} +2 -1
- package/dist/repository-files-C8B7lrka.mjs.map +1 -0
- package/dist/{repository-text-DluK673j.mjs → repository-text-BMqkLDDC.mjs} +18 -5
- package/dist/repository-text-BMqkLDDC.mjs.map +1 -0
- package/dist/{workspace-projects-DYfp6Tpn.mjs → workspace-projects-wllEd2HL.mjs} +14 -7
- package/dist/workspace-projects-wllEd2HL.mjs.map +1 -0
- package/dist/workspace-settings.d.mts +1 -1
- package/dist/workspace-settings.mjs +39 -10
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +7 -7
- package/skills/msch-repository-config/SKILL.md +3 -0
- package/dist/define-lint-preset-D_gAe4V_.mjs.map +0 -1
- package/dist/published-BITU3twH.mjs.map +0 -1
- package/dist/repository-files-BU_wY36C.mjs.map +0 -1
- package/dist/repository-text-DluK673j.mjs.map +0 -1
- package/dist/workspace-projects-DYfp6Tpn.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-cargo-inputs-IFNMRDnZ.mjs","names":["Str","Rec","Arr","taggedError","Rec","Arr","Str","Arr","Str","Arr","Str"],"sources":["../src/features/derive-cargo-inputs/model/cargo-metadata.ts","../src/features/derive-cargo-inputs/model/root-manifest.ts","../src/features/derive-cargo-inputs/model/cargo-inputs.ts","../src/features/derive-cargo-inputs/model/derive.ts"],"sourcesContent":["import { toPosix } from \"@masseater.dev/path-kit\";\nimport { Array as Arr, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport { reachable } from \"#/shared/lib/reachable.ts\";\n\nexport const LOCK_FILE = \"Cargo.lock\";\nexport const MANIFEST_FILE = \"Cargo.toml\";\nexport const WORKSPACE_CACHE = \"node_modules/.cache/msch/cargo-workspace.json\";\nconst LAST_SEGMENT = /\\/[^/]*$/u;\n\nconst IgnoredDirectory = Schema.Struct({\n pattern: Schema.String,\n base: Schema.Literal(\"workspace\"),\n});\nconst CargoPackageSchema = Schema.Struct({\n id: Schema.String,\n name: Schema.String,\n manifest_path: Schema.String,\n source: Schema.NullOr(Schema.String),\n});\nconst CargoNode = Schema.Struct({\n id: Schema.String,\n deps: Schema.Array(Schema.Struct({ pkg: Schema.String })),\n});\nexport const CargoMetadataSchema = Schema.Struct({\n packages: Schema.Array(CargoPackageSchema),\n resolve: Schema.Struct({ nodes: Schema.Array(CargoNode) }),\n workspace_members: Schema.Array(Schema.String),\n workspace_root: Schema.String,\n});\nexport const CargoSourceSchema = Schema.Struct({\n metadata: CargoMetadataSchema,\n manifest: Schema.String,\n});\nexport const CargoWorkspaceSchema = Schema.Struct({\n ...CargoSourceSchema.fields,\n ignored: Schema.Array(IgnoredDirectory),\n});\nexport type CargoMetadata = typeof CargoMetadataSchema.Type;\nexport type CargoSource = typeof CargoSourceSchema.Type;\nexport type CargoWorkspace = typeof CargoWorkspaceSchema.Type;\nexport type CargoPackage = typeof CargoPackageSchema.Type;\n\nexport const directoryOf = (file: string): string =>\n pipe(toPosix(file), Str.replace(LAST_SEGMENT, \"\"));\n\nexport const isLocal = (entry: CargoPackage): boolean => entry.source === null;\n\nexport const closureOf =\n (metadata: CargoMetadata) =>\n (roots: readonly string[]): readonly CargoPackage[] => {\n const edges = Rec.fromEntries(\n pipe(\n metadata.resolve.nodes,\n Arr.map(\n (node) =>\n [\n node.id,\n pipe(\n node.deps,\n Arr.map(({ pkg }) => pkg),\n ),\n ] as const,\n ),\n ),\n );\n const ids = new Set(reachable(edges, roots));\n return pipe(\n metadata.packages,\n Arr.filter((entry) => ids.has(entry.id)),\n );\n };\n","import { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\nimport { getStaticTOMLValue, parseTOML } from \"toml-eslint-parser\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { MANIFEST_FILE } from \"./cargo-metadata.ts\";\n\nconst WORKSPACE = \"workspace\";\nconst PROFILE = \"profile\";\nconst PACKAGE = \"package\";\nconst MEMBER_LISTS = new Set([\"members\", \"exclude\", \"default-members\"]);\nconst EVERY_PACKAGE = \"*\";\nconst VERSION_MARK = \"@\";\nconst URL_MARK = \"/\";\n\ntype Table = Readonly<Record<string, unknown>>;\n\nconst taggedError = Schema.TaggedError;\n\nclass ManifestUnreadable extends taggedError<\n ManifestUnreadable,\n { readonly brand: unique symbol }\n>()(\"ManifestUnreadable\", { file: Schema.String }) {}\n\nconst ManifestJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));\nconst decodeManifest = Schema.decodeUnknownOption(ManifestJson);\nconst encodeManifest = Schema.encodeOption(ManifestJson);\nconst encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\nconst decodeTable = Schema.decodeUnknownOption(Schema.Record(Schema.String, Schema.Unknown));\n\nconst mapTable =\n (change: (table: Table) => Table) =>\n (value: unknown): unknown =>\n pipe(\n decodeTable(value),\n Option.map(change),\n Option.getOrElse(() => value),\n );\n\nconst mapField =\n (name: string, change: (value: unknown) => unknown) =>\n (table: Table): Table => {\n if (!Rec.has(table, name)) {\n return table;\n }\n return { ...table, [name]: change(table[name]) };\n };\n\nconst nameOf = (spec: string): string => Arr.headNonEmpty(Str.split(spec, VERSION_MARK));\n\nconst overrides =\n (closure: readonly string[]) =>\n (spec: string): boolean =>\n spec === EVERY_PACKAGE ||\n Str.includes(URL_MARK)(spec) ||\n pipe(closure, Arr.contains(nameOf(spec)));\n\nconst withoutMembers = (workspace: Table): Table =>\n pipe(\n workspace,\n Rec.filter((_value, key) => !MEMBER_LISTS.has(key)),\n );\n\nconst keptOverrides = (closure: readonly string[]): ((packages: unknown) => unknown) => {\n const applies = overrides(closure);\n return mapTable((packages) =>\n pipe(\n packages,\n Rec.filter((_value, spec) => applies(spec)),\n ),\n );\n};\n\nconst profilesFor = (closure: readonly string[]): ((profiles: unknown) => unknown) => {\n const profileFor = mapTable(mapField(PACKAGE, keptOverrides(closure)));\n return mapTable(Rec.map(profileFor));\n};\n\nconst withoutMemberLists = mapField(WORKSPACE, mapTable(withoutMembers));\n\nexport const readManifest = Effect.fn(\"readManifest\")(function* readManifest(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, MANIFEST_FILE);\n const text = yield* files.readFile(file);\n const value = yield* Effect.try({\n try: () =>\n text.pipe(\n Option.getOrElse(() => \"\"),\n parseTOML,\n getStaticTOMLValue,\n ),\n catch: () => ManifestUnreadable.make({ file }),\n });\n return yield* encodeJson(value);\n});\n\nexport const manifestFor =\n (closure: readonly string[]) =>\n (manifest: string): string => {\n const forClosure = mapField(PROFILE, profilesFor(closure));\n return pipe(\n decodeManifest(manifest),\n Option.map(withoutMemberLists),\n Option.map(forClosure),\n Option.flatMap(encodeManifest),\n Option.getOrElse(() => manifest),\n );\n };\n","import { SEPARATOR, isWithin, relativeTo } from \"@masseater.dev/path-kit\";\nimport { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n LOCK_FILE,\n MANIFEST_FILE,\n WORKSPACE_CACHE,\n closureOf,\n directoryOf,\n isLocal,\n} from \"./cargo-metadata.ts\";\nimport type { CargoMetadata, CargoPackage, CargoWorkspace } from \"./cargo-metadata.ts\";\nimport { manifestFor } from \"./root-manifest.ts\";\n\nconst NEGATION = \"!\";\nconst CONTENTS = \"/**\";\nconst ANYWHERE = \"**/\";\nconst CLOSURE_DIRECTORY = \"node_modules/.cache/msch/cargo-inputs\";\nconst CLOSURE_SUFFIX = \".lock\";\nconst ROOT_SLUG = \"root\";\nconst SLUG_SEPARATOR = \"__\";\nconst LINE = \"\\n\";\nconst WORKSPACE_FILES = [\"rust-toolchain.toml\", \".cargo/**\"] as const;\nconst GENERATED = [\"node_modules\", \"dist\"] as const;\n\nexport type CargoInput =\n | { readonly pattern: string; readonly base: \"workspace\" }\n | { readonly auto: true };\n\nexport interface DerivedInputs {\n readonly inputs: readonly CargoInput[];\n readonly closureFile: string;\n readonly closure: string;\n}\n\nexport interface CargoInputRequest {\n readonly workspace: CargoWorkspace;\n readonly directory: string;\n readonly extras: readonly string[];\n}\n\nconst workspaceInput = (pattern: string): CargoInput => ({ pattern, base: \"workspace\" });\n\nexport const DERIVATION_READS: readonly CargoInput[] = pipe(\n [LOCK_FILE, MANIFEST_FILE, WORKSPACE_CACHE, `${CLOSURE_DIRECTORY}${CONTENTS}`],\n Arr.map((file) => workspaceInput(`${NEGATION}${file}`)),\n);\n\nconst withoutContents = Str.replace(CONTENTS, \"\");\n\nconst slugOf = (owner: string): string =>\n Option.match(Option.liftPredicate(owner, Str.isNonEmpty), {\n onNone: () => ROOT_SLUG,\n onSome: Str.replaceAll(SEPARATOR, SLUG_SEPARATOR),\n });\n\nconst ownedRoots = (metadata: CargoMetadata, owner: string): readonly string[] => {\n const relative = relativeTo(metadata.workspace_root);\n const owned = new Set(\n pipe(\n metadata.packages,\n Arr.filter((entry) =>\n pipe(relative(directoryOf(entry.manifest_path)), Option.exists(isWithin(owner))),\n ),\n Arr.map((entry) => entry.id),\n ),\n );\n return pipe(\n metadata.workspace_members,\n Arr.filter((id) => owned.has(id)),\n );\n};\n\nconst scopedExtra =\n (owner: string) =>\n (extra: string): string => {\n if (Str.startsWith(NEGATION)(extra)) {\n return `${NEGATION}${owner}${SEPARATOR}${Str.slice(NEGATION.length)(extra)}`;\n }\n return `${owner}${SEPARATOR}${extra}`;\n };\n\nconst excludedFrom = (\n workspace: CargoWorkspace,\n walked: readonly string[],\n kept: readonly string[],\n): readonly CargoInput[] =>\n pipe(\n workspace.ignored,\n Arr.filter(({ pattern }) => {\n const covered = withoutContents(Str.slice(NEGATION.length)(pattern));\n const applies = pipe(\n walked,\n Arr.some((dir) => isWithin(dir)(covered)),\n );\n return applies && !pipe(kept, Arr.some(isWithin(covered)));\n }),\n );\n\nconst generatedIn = (walked: readonly string[]): readonly string[] =>\n pipe(\n walked,\n Arr.flatMap((dir) =>\n pipe(\n GENERATED,\n Arr.map((name) => `${NEGATION}${dir}${SEPARATOR}${ANYWHERE}${name}${CONTENTS}`),\n ),\n ),\n );\n\nconst externalIds = (closure: readonly CargoPackage[]): readonly string[] =>\n pipe(\n closure,\n Arr.filter((entry) => !isLocal(entry)),\n Arr.map((entry) => entry.id),\n );\n\nconst closureText = (manifest: string, closure: readonly CargoPackage[]): string => {\n const names = pipe(\n closure,\n Arr.map((entry) => entry.name),\n );\n return Arr.join(\n [...Arr.sort(externalIds(closure), Str.Order), manifestFor(names)(manifest)],\n LINE,\n );\n};\n\n/** @internal */\nexport const cargoInputsOf = ({\n workspace,\n directory,\n extras,\n}: CargoInputRequest): DerivedInputs => {\n const { metadata } = workspace;\n const relative = relativeTo(metadata.workspace_root);\n const owner = Option.getOrElse(relative(directory), () => \"\");\n const closure = closureOf(metadata)(ownedRoots(metadata, owner));\n const walked = Arr.sort(\n pipe(\n closure,\n Arr.filter(isLocal),\n Arr.flatMap((entry) => Option.toArray(relative(directoryOf(entry.manifest_path)))),\n ),\n Str.Order,\n );\n const added = pipe(extras, Arr.map(scopedExtra(owner)));\n const kept = pipe(\n added,\n Arr.filter((extra) => !Str.startsWith(NEGATION)(extra)),\n Arr.map(withoutContents),\n );\n const closureFile = `${CLOSURE_DIRECTORY}${SEPARATOR}${slugOf(owner)}${CLOSURE_SUFFIX}`;\n return {\n inputs: [\n ...pipe(\n walked,\n Arr.map((dir) => workspaceInput(`${dir}${CONTENTS}`)),\n ),\n workspaceInput(closureFile),\n ...pipe(WORKSPACE_FILES, Arr.map(workspaceInput)),\n ...excludedFrom(workspace, walked, kept),\n ...pipe(generatedIn(walked), Arr.map(workspaceInput)),\n ...pipe(added, Arr.map(workspaceInput)),\n ],\n closureFile,\n closure: closureText(workspace.manifest, closure),\n };\n};\n","import {\n Array as Arr,\n Console,\n Effect,\n Layer,\n Option,\n Schema,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport { ChildProcess } from \"effect/process\";\n\nimport { collectPlacedIgnoredDirectories } from \"#/shared/lib/ignored-directories.ts\";\nimport {\n RepositoryFiles,\n nodeRepositoryFiles,\n nodeServicesLayer,\n} from \"#/shared/lib/repository-files.ts\";\nimport { startedOnce } from \"#/shared/lib/started-once.ts\";\n\nimport { cargoInputsOf } from \"./cargo-inputs.ts\";\nimport type { CargoInput, DerivedInputs } from \"./cargo-inputs.ts\";\nimport {\n CargoMetadataSchema,\n CargoSourceSchema,\n LOCK_FILE,\n MANIFEST_FILE,\n WORKSPACE_CACHE,\n} from \"./cargo-metadata.ts\";\nimport type { CargoSource, CargoWorkspace } from \"./cargo-metadata.ts\";\nimport { readManifest } from \"./root-manifest.ts\";\n\nconst KEY_SEPARATOR = \"\\u0000\";\nconst SUCCESS = 0;\nconst KEYS = [LOCK_FILE, MANIFEST_FILE] as const;\nconst METADATA_ARGS = [\"metadata\", \"--format-version\", \"1\", \"--offline\", \"--locked\"];\n\nconst CachedSource = Schema.fromJsonString(\n Schema.Struct({\n fingerprint: Schema.String,\n source: CargoSourceSchema,\n }),\n);\nconst decodeMetadata = Schema.decodeUnknownEffect(Schema.fromJsonString(CargoMetadataSchema));\nconst decodeCached = Schema.decodeUnknownOption(CachedSource);\nconst encodeCached = Schema.encodeEffect(CachedSource);\n\nconst taggedError = Schema.TaggedError;\n\nclass MetadataFailed extends taggedError<MetadataFailed, { readonly brand: unique symbol }>()(\n \"MetadataFailed\",\n { output: Schema.String },\n) {}\n\nconst AUTO: readonly CargoInput[] = [{ auto: true }];\nconst nodeLayer = Layer.provideMerge(nodeRepositoryFiles, nodeServicesLayer);\n\nexport interface CargoInputOptions {\n readonly directory: string;\n readonly extras?: readonly string[];\n}\n\nconst fingerprintOf = Effect.fn(\"fingerprintOf\")(function* fingerprintOf(root: string) {\n const files = yield* RepositoryFiles;\n const texts = yield* Effect.forEach(KEYS, (key) => files.readFile(files.join(root, key)), {\n concurrency: \"unbounded\",\n });\n return yield* files.hash(\n pipe(\n texts,\n Arr.map((text) => Option.getOrElse(text, () => \"\")),\n Arr.join(KEY_SEPARATOR),\n ),\n );\n});\n\nconst cachedSource = Effect.fn(\"cachedSource\")(function* cachedSource(root: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(root, WORKSPACE_CACHE));\n const fingerprint = yield* fingerprintOf(root);\n return text.pipe(\n Option.flatMap(decodeCached),\n Option.filter((cached) => cached.fingerprint === fingerprint),\n Option.map((cached) => cached.source),\n );\n});\n\nconst metadataIn = Effect.fn(\"metadataIn\")(function* metadataIn(root: string) {\n const handle = yield* ChildProcess.make(\"cargo\", METADATA_ARGS, {\n cwd: root,\n extendEnv: true,\n stdin: \"ignore\",\n });\n const [output, problem] = yield* Effect.all(\n [\n handle.stdout.pipe(Stream.decodeText(), Stream.mkString),\n handle.stderr.pipe(Stream.decodeText(), Stream.mkString),\n ],\n { concurrency: \"unbounded\" },\n );\n const code = yield* handle.exitCode;\n if (code !== SUCCESS) {\n return yield* MetadataFailed.make({ output: Str.trim(problem) });\n }\n return yield* decodeMetadata(output);\n}, Effect.scoped);\n\nconst readSource = Effect.fn(\"readSource\")(function* readSource(root: string) {\n const files = yield* RepositoryFiles;\n const source: CargoSource = {\n metadata: yield* metadataIn(root),\n manifest: yield* readManifest(root),\n };\n const text = yield* encodeCached({ fingerprint: yield* fingerprintOf(root), source });\n yield* files.writeFile(files.join(root, WORKSPACE_CACHE), text);\n return source;\n});\n\nconst workspaceIn = Effect.fn(\"workspaceIn\")(function* workspaceIn(root: string) {\n const cached = yield* cachedSource(root);\n const source = yield* Option.match(cached, {\n onNone: () => readSource(root),\n onSome: Effect.succeed,\n });\n const workspace: CargoWorkspace = {\n ...source,\n ignored: yield* collectPlacedIgnoredDirectories(root),\n };\n return workspace;\n});\n\nconst warn = (root: string, reason: string): Effect.Effect<void> =>\n Console.error(\n `msch: the cargo workspace in ${root} could not be read, so its cargo tasks track every file they read: ${reason}`,\n );\n\nconst loaded = (\n root: string,\n): Effect.Effect<Option.Option<CargoWorkspace>, never, Layer.Success<typeof nodeLayer>> =>\n workspaceIn(root).pipe(\n Effect.asSome,\n Effect.catchTag(\"MetadataFailed\", ({ output }) => Effect.fail(output)),\n Effect.tapError((cause) => warn(root, String(cause))),\n Effect.orElseSucceed(() => Option.none<CargoWorkspace>()),\n );\n\nconst loadedOnce = startedOnce<Option.Option<CargoWorkspace>>();\n\nconst loadWorkspace = (root: string): Promise<Option.Option<CargoWorkspace>> =>\n loadedOnce(root, () => Effect.runPromise(loaded(root).pipe(Effect.provide(nodeLayer))));\n\nconst lockDirectory = (\n directory: string,\n): Effect.Effect<Option.Option<string>, never, RepositoryFiles> =>\n Effect.gen(function* findLockDirectory() {\n const files = yield* RepositoryFiles;\n if (yield* files.exists(files.join(directory, LOCK_FILE))) {\n return Option.some(directory);\n }\n const parent = files.dirname(directory);\n if (parent === directory) {\n return Option.none<string>();\n }\n return yield* lockDirectory(parent);\n });\n\nconst writeClosure = Effect.fn(\"writeClosure\")(function* writeClosure(\n root: string,\n derived: DerivedInputs,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, derived.closureFile);\n const written = yield* files.readFile(file);\n if (!Option.exists(written, (text) => text === derived.closure)) {\n yield* files.writeFile(file, derived.closure);\n }\n return derived.inputs;\n});\n\nconst inputsIn = Effect.fn(\"inputsIn\")(function* inputsIn(\n root: string,\n directory: string,\n extras: readonly string[],\n) {\n const workspace = yield* Effect.promise(() => loadWorkspace(root));\n return yield* Option.match(workspace, {\n onNone: () => Effect.succeed(AUTO),\n onSome: (found) => writeClosure(root, cargoInputsOf({ workspace: found, directory, extras })),\n });\n});\n\nconst deriveCargoInputs = Effect.fn(\"deriveCargoInputs\")(function* deriveCargoInputs({\n directory,\n extras = [],\n}: CargoInputOptions) {\n const files = yield* RepositoryFiles;\n const absolute = files.resolve(directory);\n const root = yield* lockDirectory(absolute);\n return yield* Option.match(root, {\n onNone: () => Effect.succeed(AUTO),\n onSome: (found) => inputsIn(found, absolute, extras),\n });\n});\n\nexport const cargoInputs = (options: CargoInputOptions): Promise<readonly CargoInput[]> =>\n Effect.runPromise(deriveCargoInputs(options).pipe(Effect.provide(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C,MACA,WACA,QACA;CACA,MAAM,YAAY,OAAO,OAAO,cAAc,cAAc,IAAI,CAAC;CACjE,OAAO,OAAO,OAAO,MAAM,WAAW;EACpC,cAAc,OAAO,QAAQ,IAAI;EACjC,SAAS,UAAU,aAAa,MAAM,cAAc;GAAE,WAAW;GAAO;GAAW;EAAO,CAAC,CAAC;CAC9F,CAAC;AACH,CAAC;AAED,MAAM,oBAAoB,OAAO,GAAG,mBAAmB,CAAC,CAAC,UAAU,kBAAkB,EACnF,WACA,SAAS,CAAC,KACU;CAEpB,MAAM,YAAW,OADI,gBAAA,CACE,QAAQ,SAAS;CACxC,MAAM,OAAO,OAAO,cAAc,QAAQ;CAC1C,OAAO,OAAO,OAAO,MAAM,MAAM;EAC/B,cAAc,OAAO,QAAQ,IAAI;EACjC,SAAS,UAAU,SAAS,OAAO,UAAU,MAAM;CACrD,CAAC;AACH,CAAC;AAED,MAAa,eAAe,YAC1B,OAAO,WAAW,kBAAkB,OAAO,CAAC,CAAC,KAAK,OAAO,QAAQ,SAAS,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"derive-cargo-inputs-Btc2ojuD.mjs","names":["Str","Rec","Arr","taggedError","Rec","Arr","Str","Arr","Str","Arr","Str"],"sources":["../src/features/derive-cargo-inputs/model/cargo-metadata.ts","../src/features/derive-cargo-inputs/model/root-manifest.ts","../src/features/derive-cargo-inputs/model/cargo-inputs.ts","../src/features/derive-cargo-inputs/model/derive.ts"],"sourcesContent":["import { toPosix } from \"@masseater.dev/path-kit\";\nimport { Array as Arr, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport { reachable } from \"#/shared/lib/reachable.ts\";\n\nexport const LOCK_FILE = \"Cargo.lock\";\nexport const MANIFEST_FILE = \"Cargo.toml\";\nexport const WORKSPACE_CACHE = \"node_modules/.cache/msch/cargo-workspace.json\";\nconst LAST_SEGMENT = /\\/[^/]*$/u;\n\nconst IgnoredDirectory = Schema.Struct({\n pattern: Schema.String,\n base: Schema.Literal(\"workspace\"),\n});\nconst CargoPackageSchema = Schema.Struct({\n id: Schema.String,\n name: Schema.String,\n manifest_path: Schema.String,\n source: Schema.NullOr(Schema.String),\n});\nconst CargoNode = Schema.Struct({\n id: Schema.String,\n deps: Schema.Array(Schema.Struct({ pkg: Schema.String })),\n});\nexport const CargoMetadataSchema = Schema.Struct({\n packages: Schema.Array(CargoPackageSchema),\n resolve: Schema.Struct({ nodes: Schema.Array(CargoNode) }),\n workspace_members: Schema.Array(Schema.String),\n workspace_root: Schema.String,\n});\nexport const CargoSourceSchema = Schema.Struct({\n metadata: CargoMetadataSchema,\n manifest: Schema.String,\n});\nexport const CargoWorkspaceSchema = Schema.Struct({\n ...CargoSourceSchema.fields,\n ignored: Schema.Array(IgnoredDirectory),\n});\nexport type CargoMetadata = typeof CargoMetadataSchema.Type;\nexport type CargoSource = typeof CargoSourceSchema.Type;\nexport type CargoWorkspace = typeof CargoWorkspaceSchema.Type;\nexport type CargoPackage = typeof CargoPackageSchema.Type;\n\nexport const directoryOf = (file: string): string =>\n pipe(toPosix(file), Str.replace(LAST_SEGMENT, \"\"));\n\nexport const isLocal = (entry: CargoPackage): boolean => entry.source === null;\n\nexport const closureOf =\n (metadata: CargoMetadata) =>\n (roots: readonly string[]): readonly CargoPackage[] => {\n const edges = Rec.fromEntries(\n pipe(\n metadata.resolve.nodes,\n Arr.map(\n (node) =>\n [\n node.id,\n pipe(\n node.deps,\n Arr.map(({ pkg }) => pkg),\n ),\n ] as const,\n ),\n ),\n );\n const ids = new Set(reachable(edges, roots));\n return pipe(\n metadata.packages,\n Arr.filter((entry) => ids.has(entry.id)),\n );\n };\n","import { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\nimport { getStaticTOMLValue, parseTOML } from \"toml-eslint-parser\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { MANIFEST_FILE } from \"./cargo-metadata.ts\";\n\nconst WORKSPACE = \"workspace\";\nconst PROFILE = \"profile\";\nconst PACKAGE = \"package\";\nconst MEMBER_LISTS = new Set([\"members\", \"exclude\", \"default-members\"]);\nconst EVERY_PACKAGE = \"*\";\nconst VERSION_MARK = \"@\";\nconst URL_MARK = \"/\";\n\ntype Table = Readonly<Record<string, unknown>>;\n\nconst taggedError = Schema.TaggedError;\n\nclass ManifestUnreadable extends taggedError<\n ManifestUnreadable,\n { readonly brand: unique symbol }\n>()(\"ManifestUnreadable\", { file: Schema.String }) {}\n\nconst ManifestJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown));\nconst decodeManifest = Schema.decodeUnknownOption(ManifestJson);\nconst encodeManifest = Schema.encodeOption(ManifestJson);\nconst encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\nconst decodeTable = Schema.decodeUnknownOption(Schema.Record(Schema.String, Schema.Unknown));\n\nconst mapTable =\n (change: (table: Table) => Table) =>\n (value: unknown): unknown =>\n pipe(\n decodeTable(value),\n Option.map(change),\n Option.getOrElse(() => value),\n );\n\nconst mapField =\n (name: string, change: (value: unknown) => unknown) =>\n (table: Table): Table => {\n if (!Rec.has(table, name)) {\n return table;\n }\n return { ...table, [name]: change(table[name]) };\n };\n\nconst nameOf = (spec: string): string => Arr.headNonEmpty(Str.split(spec, VERSION_MARK));\n\nconst overrides =\n (closure: readonly string[]) =>\n (spec: string): boolean =>\n spec === EVERY_PACKAGE ||\n Str.includes(URL_MARK)(spec) ||\n pipe(closure, Arr.contains(nameOf(spec)));\n\nconst withoutMembers = (workspace: Table): Table =>\n pipe(\n workspace,\n Rec.filter((_value, key) => !MEMBER_LISTS.has(key)),\n );\n\nconst keptOverrides = (closure: readonly string[]): ((packages: unknown) => unknown) => {\n const applies = overrides(closure);\n return mapTable((packages) =>\n pipe(\n packages,\n Rec.filter((_value, spec) => applies(spec)),\n ),\n );\n};\n\nconst profilesFor = (closure: readonly string[]): ((profiles: unknown) => unknown) => {\n const profileFor = mapTable(mapField(PACKAGE, keptOverrides(closure)));\n return mapTable(Rec.map(profileFor));\n};\n\nconst withoutMemberLists = mapField(WORKSPACE, mapTable(withoutMembers));\n\nexport const readManifest = Effect.fn(\"readManifest\")(function* readManifest(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, MANIFEST_FILE);\n const text = yield* files.readFile(file);\n const value = yield* Effect.try({\n try: () =>\n text.pipe(\n Option.getOrElse(() => \"\"),\n parseTOML,\n getStaticTOMLValue,\n ),\n catch: () => ManifestUnreadable.make({ file }),\n });\n return yield* encodeJson(value);\n});\n\nexport const manifestFor =\n (closure: readonly string[]) =>\n (manifest: string): string => {\n const forClosure = mapField(PROFILE, profilesFor(closure));\n return pipe(\n decodeManifest(manifest),\n Option.map(withoutMemberLists),\n Option.map(forClosure),\n Option.flatMap(encodeManifest),\n Option.getOrElse(() => manifest),\n );\n };\n","import { SEPARATOR, isWithin, relativeTo } from \"@masseater.dev/path-kit\";\nimport { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n LOCK_FILE,\n MANIFEST_FILE,\n WORKSPACE_CACHE,\n closureOf,\n directoryOf,\n isLocal,\n} from \"./cargo-metadata.ts\";\nimport type { CargoMetadata, CargoPackage, CargoWorkspace } from \"./cargo-metadata.ts\";\nimport { manifestFor } from \"./root-manifest.ts\";\n\nconst NEGATION = \"!\";\nconst CONTENTS = \"/**\";\nconst ANYWHERE = \"**/\";\nconst CLOSURE_DIRECTORY = \"node_modules/.cache/msch/cargo-inputs\";\nconst CLOSURE_SUFFIX = \".lock\";\nconst ROOT_SLUG = \"root\";\nconst SLUG_SEPARATOR = \"__\";\nconst LINE = \"\\n\";\nconst WORKSPACE_FILES = [\"rust-toolchain.toml\", \".cargo/**\"] as const;\nconst GENERATED = [\"node_modules\", \"dist\"] as const;\n\nexport type CargoInput =\n | { readonly pattern: string; readonly base: \"workspace\" }\n | { readonly auto: true };\n\nexport interface DerivedInputs {\n readonly inputs: readonly CargoInput[];\n readonly closureFile: string;\n readonly closure: string;\n}\n\nexport interface CargoInputRequest {\n readonly workspace: CargoWorkspace;\n readonly directory: string;\n readonly extras: readonly string[];\n}\n\nconst workspaceInput = (pattern: string): CargoInput => ({ pattern, base: \"workspace\" });\n\nexport const DERIVATION_READS: readonly CargoInput[] = pipe(\n [LOCK_FILE, MANIFEST_FILE, WORKSPACE_CACHE, `${CLOSURE_DIRECTORY}${CONTENTS}`],\n Arr.map((file) => workspaceInput(`${NEGATION}${file}`)),\n);\n\nconst withoutContents = Str.replace(CONTENTS, \"\");\n\nconst slugOf = (owner: string): string =>\n Option.match(Option.liftPredicate(owner, Str.isNonEmpty), {\n onNone: () => ROOT_SLUG,\n onSome: Str.replaceAll(SEPARATOR, SLUG_SEPARATOR),\n });\n\nconst ownedRoots = (metadata: CargoMetadata, owner: string): readonly string[] => {\n const relative = relativeTo(metadata.workspace_root);\n const owned = new Set(\n pipe(\n metadata.packages,\n Arr.filter((entry) =>\n pipe(relative(directoryOf(entry.manifest_path)), Option.exists(isWithin(owner))),\n ),\n Arr.map((entry) => entry.id),\n ),\n );\n return pipe(\n metadata.workspace_members,\n Arr.filter((id) => owned.has(id)),\n );\n};\n\nconst scopedExtra =\n (owner: string) =>\n (extra: string): string => {\n if (Str.startsWith(NEGATION)(extra)) {\n return `${NEGATION}${owner}${SEPARATOR}${Str.slice(NEGATION.length)(extra)}`;\n }\n return `${owner}${SEPARATOR}${extra}`;\n };\n\nconst excludedFrom = (\n workspace: CargoWorkspace,\n walked: readonly string[],\n kept: readonly string[],\n): readonly CargoInput[] =>\n pipe(\n workspace.ignored,\n Arr.filter(({ pattern }) => {\n const covered = withoutContents(Str.slice(NEGATION.length)(pattern));\n const applies = pipe(\n walked,\n Arr.some((dir) => isWithin(dir)(covered)),\n );\n return applies && !pipe(kept, Arr.some(isWithin(covered)));\n }),\n );\n\nconst generatedIn = (walked: readonly string[]): readonly string[] =>\n pipe(\n walked,\n Arr.flatMap((dir) =>\n pipe(\n GENERATED,\n Arr.map((name) => `${NEGATION}${dir}${SEPARATOR}${ANYWHERE}${name}${CONTENTS}`),\n ),\n ),\n );\n\nconst externalIds = (closure: readonly CargoPackage[]): readonly string[] =>\n pipe(\n closure,\n Arr.filter((entry) => !isLocal(entry)),\n Arr.map((entry) => entry.id),\n );\n\nconst closureText = (manifest: string, closure: readonly CargoPackage[]): string => {\n const names = pipe(\n closure,\n Arr.map((entry) => entry.name),\n );\n return Arr.join(\n [...Arr.sort(externalIds(closure), Str.Order), manifestFor(names)(manifest)],\n LINE,\n );\n};\n\n/** @internal */\nexport const cargoInputsOf = ({\n workspace,\n directory,\n extras,\n}: CargoInputRequest): DerivedInputs => {\n const { metadata } = workspace;\n const relative = relativeTo(metadata.workspace_root);\n const owner = Option.getOrElse(relative(directory), () => \"\");\n const closure = closureOf(metadata)(ownedRoots(metadata, owner));\n const walked = Arr.sort(\n pipe(\n closure,\n Arr.filter(isLocal),\n Arr.flatMap((entry) => Option.toArray(relative(directoryOf(entry.manifest_path)))),\n ),\n Str.Order,\n );\n const added = pipe(extras, Arr.map(scopedExtra(owner)));\n const kept = pipe(\n added,\n Arr.filter((extra) => !Str.startsWith(NEGATION)(extra)),\n Arr.map(withoutContents),\n );\n const closureFile = `${CLOSURE_DIRECTORY}${SEPARATOR}${slugOf(owner)}${CLOSURE_SUFFIX}`;\n return {\n inputs: [\n ...pipe(\n walked,\n Arr.map((dir) => workspaceInput(`${dir}${CONTENTS}`)),\n ),\n workspaceInput(closureFile),\n ...pipe(WORKSPACE_FILES, Arr.map(workspaceInput)),\n ...excludedFrom(workspace, walked, kept),\n ...pipe(generatedIn(walked), Arr.map(workspaceInput)),\n ...pipe(added, Arr.map(workspaceInput)),\n ],\n closureFile,\n closure: closureText(workspace.manifest, closure),\n };\n};\n","import {\n Array as Arr,\n Console,\n Effect,\n Layer,\n Option,\n Schema,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport { ChildProcess } from \"effect/process\";\n\nimport { collectPlacedIgnoredDirectories } from \"#/shared/lib/ignored-directories.ts\";\nimport {\n RepositoryFiles,\n nodeRepositoryFiles,\n nodeServicesLayer,\n} from \"#/shared/lib/repository-files.ts\";\nimport { startedOnce } from \"#/shared/lib/started-once.ts\";\n\nimport { cargoInputsOf } from \"./cargo-inputs.ts\";\nimport type { CargoInput, DerivedInputs } from \"./cargo-inputs.ts\";\nimport {\n CargoMetadataSchema,\n CargoSourceSchema,\n LOCK_FILE,\n MANIFEST_FILE,\n WORKSPACE_CACHE,\n} from \"./cargo-metadata.ts\";\nimport type { CargoSource, CargoWorkspace } from \"./cargo-metadata.ts\";\nimport { readManifest } from \"./root-manifest.ts\";\n\nconst KEY_SEPARATOR = \"\\u0000\";\nconst SUCCESS = 0;\nconst KEYS = [LOCK_FILE, MANIFEST_FILE] as const;\nconst METADATA_ARGS = [\"metadata\", \"--format-version\", \"1\", \"--offline\", \"--locked\"];\n\nconst CachedSource = Schema.fromJsonString(\n Schema.Struct({\n fingerprint: Schema.String,\n source: CargoSourceSchema,\n }),\n);\nconst decodeMetadata = Schema.decodeUnknownEffect(Schema.fromJsonString(CargoMetadataSchema));\nconst decodeCached = Schema.decodeUnknownOption(CachedSource);\nconst encodeCached = Schema.encodeEffect(CachedSource);\n\nconst taggedError = Schema.TaggedError;\n\nclass MetadataFailed extends taggedError<MetadataFailed, { readonly brand: unique symbol }>()(\n \"MetadataFailed\",\n { output: Schema.String },\n) {}\n\nconst AUTO: readonly CargoInput[] = [{ auto: true }];\nconst nodeLayer = Layer.provideMerge(nodeRepositoryFiles, nodeServicesLayer);\n\nexport interface CargoInputOptions {\n readonly directory: string;\n readonly extras?: readonly string[];\n}\n\nconst fingerprintOf = Effect.fn(\"fingerprintOf\")(function* fingerprintOf(root: string) {\n const files = yield* RepositoryFiles;\n const texts = yield* Effect.forEach(KEYS, (key) => files.readFile(files.join(root, key)), {\n concurrency: \"unbounded\",\n });\n return yield* files.hash(\n pipe(\n texts,\n Arr.map((text) => Option.getOrElse(text, () => \"\")),\n Arr.join(KEY_SEPARATOR),\n ),\n );\n});\n\nconst cachedSource = Effect.fn(\"cachedSource\")(function* cachedSource(root: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(root, WORKSPACE_CACHE));\n const fingerprint = yield* fingerprintOf(root);\n return text.pipe(\n Option.flatMap(decodeCached),\n Option.filter((cached) => cached.fingerprint === fingerprint),\n Option.map((cached) => cached.source),\n );\n});\n\nconst metadataIn = Effect.fn(\"metadataIn\")(function* metadataIn(root: string) {\n const handle = yield* ChildProcess.make(\"cargo\", METADATA_ARGS, {\n cwd: root,\n extendEnv: true,\n stdin: \"ignore\",\n });\n const [output, problem] = yield* Effect.all(\n [\n handle.stdout.pipe(Stream.decodeText(), Stream.mkString),\n handle.stderr.pipe(Stream.decodeText(), Stream.mkString),\n ],\n { concurrency: \"unbounded\" },\n );\n const code = yield* handle.exitCode;\n if (code !== SUCCESS) {\n return yield* MetadataFailed.make({ output: Str.trim(problem) });\n }\n return yield* decodeMetadata(output);\n}, Effect.scoped);\n\nconst readSource = Effect.fn(\"readSource\")(function* readSource(root: string) {\n const files = yield* RepositoryFiles;\n const source: CargoSource = {\n metadata: yield* metadataIn(root),\n manifest: yield* readManifest(root),\n };\n const text = yield* encodeCached({ fingerprint: yield* fingerprintOf(root), source });\n yield* files.writeFile(files.join(root, WORKSPACE_CACHE), text);\n return source;\n});\n\nconst workspaceIn = Effect.fn(\"workspaceIn\")(function* workspaceIn(root: string) {\n const cached = yield* cachedSource(root);\n const source = yield* Option.match(cached, {\n onNone: () => readSource(root),\n onSome: Effect.succeed,\n });\n const workspace: CargoWorkspace = {\n ...source,\n ignored: yield* collectPlacedIgnoredDirectories(root),\n };\n return workspace;\n});\n\nconst warn = (root: string, reason: string): Effect.Effect<void> =>\n Console.error(\n `msch: the cargo workspace in ${root} could not be read, so its cargo tasks track every file they read: ${reason}`,\n );\n\nconst loaded = (\n root: string,\n): Effect.Effect<Option.Option<CargoWorkspace>, never, Layer.Success<typeof nodeLayer>> =>\n workspaceIn(root).pipe(\n Effect.asSome,\n Effect.catchTag(\"MetadataFailed\", ({ output }) => Effect.fail(output)),\n Effect.tapError((cause) => warn(root, String(cause))),\n Effect.orElseSucceed(() => Option.none<CargoWorkspace>()),\n );\n\nconst loadedOnce = startedOnce<Option.Option<CargoWorkspace>>();\n\nconst loadWorkspace = (root: string): Promise<Option.Option<CargoWorkspace>> =>\n loadedOnce(root, () => Effect.runPromise(loaded(root).pipe(Effect.provide(nodeLayer))));\n\nconst lockDirectory = (\n directory: string,\n): Effect.Effect<Option.Option<string>, never, RepositoryFiles> =>\n Effect.gen(function* findLockDirectory() {\n const files = yield* RepositoryFiles;\n if (yield* files.exists(files.join(directory, LOCK_FILE))) {\n return Option.some(directory);\n }\n const parent = files.dirname(directory);\n if (parent === directory) {\n return Option.none<string>();\n }\n return yield* lockDirectory(parent);\n });\n\nconst writeClosure = Effect.fn(\"writeClosure\")(function* writeClosure(\n root: string,\n derived: DerivedInputs,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, derived.closureFile);\n const written = yield* files.readFile(file);\n if (!Option.exists(written, (text) => text === derived.closure)) {\n yield* files.writeFile(file, derived.closure);\n }\n return derived.inputs;\n});\n\nconst inputsIn = Effect.fn(\"inputsIn\")(function* inputsIn(\n root: string,\n directory: string,\n extras: readonly string[],\n) {\n const workspace = yield* Effect.promise(() => loadWorkspace(root));\n return yield* Option.match(workspace, {\n onNone: () => Effect.succeed(AUTO),\n onSome: (found) => writeClosure(root, cargoInputsOf({ workspace: found, directory, extras })),\n });\n});\n\nconst deriveCargoInputs = Effect.fn(\"deriveCargoInputs\")(function* deriveCargoInputs({\n directory,\n extras = [],\n}: CargoInputOptions) {\n const files = yield* RepositoryFiles;\n const absolute = files.resolve(directory);\n const root = yield* lockDirectory(absolute);\n return yield* Option.match(root, {\n onNone: () => Effect.succeed(AUTO),\n onSome: (found) => inputsIn(found, absolute, extras),\n });\n});\n\nexport const cargoInputs = (options: CargoInputOptions): Promise<readonly CargoInput[]> =>\n Effect.runPromise(deriveCargoInputs(options).pip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UAAU,SAC/C,MACA,WACA,QACA;CACA,MAAM,YAAY,OAAO,OAAO,cAAc,cAAc,IAAI,CAAC;CACjE,OAAO,OAAO,OAAO,MAAM,WAAW;EACpC,cAAc,OAAO,QAAQ,IAAI;EACjC,SAAS,UAAU,aAAa,MAAM,cAAc;GAAE,WAAW;GAAO;GAAW;EAAO,CAAC,CAAC;CAC9F,CAAC;AACH,CAAC;AAED,MAAM,oBAAoB,OAAO,GAAG,mBAAmB,CAAC,CAAC,UAAU,kBAAkB,EACnF,WACA,SAAS,CAAC,KACU;CAEpB,MAAM,YAAW,OADI,gBAAA,CACE,QAAQ,SAAS;CACxC,MAAM,OAAO,OAAO,cAAc,QAAQ;CAC1C,OAAO,OAAO,OAAO,MAAM,MAAM;EAC/B,cAAc,OAAO,QAAQ,IAAI;EACjC,SAAS,UAAU,SAAS,OAAO,UAAU,MAAM;CACrD,CAAC;AACH,CAAC;AAED,MAAa,eAAe,YAC1B,OAAO,WAAW,kBAAkB,OAAO,CAAC,CAAC,KAAK,OAAO,QAAQ,SAAS,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as nodeRepositoryFiles, r as RepositoryFiles } from "./repository-files-
|
|
1
|
+
import { i as nodeRepositoryFiles, r as RepositoryFiles } from "./repository-files-C8B7lrka.mjs";
|
|
2
2
|
import { Array, Effect, Function, HashSet, Option, String, pipe } from "effect";
|
|
3
3
|
// src/shared/lib/reachable.ts
|
|
4
4
|
const DATA_FIRST_ARITY = 2;
|
|
@@ -91,4 +91,4 @@ const collectPlacedIgnoredDirectories = Effect.fn("collectPlacedIgnoredDirectori
|
|
|
91
91
|
const ignoredDirectories = (root) => Effect.runPromise(collectIgnoredDirectories(root).pipe(Effect.provide(nodeRepositoryFiles)));
|
|
92
92
|
export { reachable as i, collectPlacedIgnoredDirectories as n, ignoredDirectories as r, collectIgnoredDirectories as t };
|
|
93
93
|
|
|
94
|
-
//# sourceMappingURL=ignored-directories-
|
|
94
|
+
//# sourceMappingURL=ignored-directories-wh-dhKsl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ignored-directories-Btth0IHS.mjs","names":["Arr","Fn","Str","Arr"],"sources":["../src/shared/lib/reachable.ts","../src/shared/lib/ignored-directories.ts"],"sourcesContent":["import { Array as Arr, Function as Fn, HashSet, pipe } from \"effect\";\n\nexport type Edges = Readonly<Record<string, readonly string[]>>;\n\nconst DATA_FIRST_ARITY = 2;\n\nconst visit = (\n edges: Edges,\n seen: HashSet.HashSet<string>,\n frontier: readonly string[],\n): HashSet.HashSet<string> => {\n const fresh = HashSet.difference(HashSet.fromIterable(frontier), seen);\n if (HashSet.isEmpty(fresh)) {\n return seen;\n }\n const next = pipe(\n Arr.fromIterable(fresh),\n Arr.flatMap((id) => edges[id] ?? []),\n );\n return visit(edges, HashSet.union(seen, fresh), next);\n};\n\nexport const reachable: {\n (roots: readonly string[]): (edges: Edges) => readonly string[];\n (edges: Edges, roots: readonly string[]): readonly string[];\n} = Fn.dual(DATA_FIRST_ARITY, (edges: Edges, roots: readonly string[]): readonly string[] =>\n Arr.fromIterable(visit(edges, HashSet.empty(), roots)),\n);\n","import { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\n\nimport { RepositoryFiles, nodeRepositoryFiles } from \"./repository-files.ts\";\n\nconst IGNORE_FILES = \":(glob)**/.gitignore\";\nconst SEPARATOR = \"/\";\nconst NEGATION = \"!\";\nconst CONTENTS = \"/**\";\nconst ROOT = \".\";\nconst ANYWHERE = \"**/\";\nconst READ_CONCURRENCY = 16;\nconst DIRECTORY_ENTRY = /^(?<anchor>\\/?)(?<name>[^!#/].*)\\/$/u;\nconst TOOL_DIRECTORIES = [\"**/node_modules/.vite*\"];\nconst WILDCARD = /[*?[]/u;\n\nexport interface IgnoredDirectory {\n readonly pattern: string;\n readonly base: \"workspace\";\n}\n\nconst scopedName = (anchor: string, name: string): string => {\n if (anchor === SEPARATOR || Str.includes(SEPARATOR)(name)) {\n return name;\n }\n return `${ANYWHERE}${name}`;\n};\n\nconst inDirectory =\n (directory: string) =>\n (glob: string): string => {\n if (directory === ROOT) {\n return glob;\n }\n return `${directory}${SEPARATOR}${glob}`;\n };\n\nconst globOf =\n (directory: string) =>\n (line: string): Option.Option<string> => {\n const found = DIRECTORY_ENTRY.exec(Str.trim(line));\n return pipe(\n Option.fromNullishOr(found),\n Option.flatMap(({ groups }) => Option.fromNullishOr(groups)),\n Option.flatMap(({ anchor, name }) =>\n Option.map(Option.fromNullishOr(name), (entry) => scopedName(anchor ?? \"\", entry)),\n ),\n Option.map(inDirectory(directory)),\n );\n };\n\nconst contentsOf = (glob: string): string => `:(glob)${glob}${CONTENTS}`;\n\nconst keptGlob = Effect.fn(\"keptGlob\")(function* keptGlob(root: string, glob: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.trackedFiles(root, [contentsOf(glob)]);\n return Option.some(glob).pipe(Option.filter(() => Arr.isReadonlyArrayEmpty(listed)));\n});\n\nconst keptGlobs = Effect.fn(\"keptGlobs\")(function* keptGlobs(\n root: string,\n candidates: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.trackedFiles(root, pipe(candidates, Arr.map(contentsOf)));\n if (Arr.isReadonlyArrayEmpty(listed)) {\n return candidates;\n }\n const kept = yield* Effect.forEach(candidates, (glob) => keptGlob(root, glob), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(kept);\n});\n\nconst globsIn = Effect.fn(\"globsIn\")(function* globsIn(root: string, file: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(root, file));\n const toGlob = globOf(files.dirname(file));\n return pipe(\n Option.getOrElse(text, () => \"\"),\n Str.split(\"\\n\"),\n Arr.map(toGlob),\n Arr.getSomes,\n );\n});\n\nconst ignoredGlobs = Effect.fn(\"ignoredGlobs\")(function* ignoredGlobs(root: string) {\n const files = yield* RepositoryFiles;\n const ignoreFiles = yield* files.trackedFiles(root, [IGNORE_FILES]);\n const globs = yield* Effect.forEach(ignoreFiles, (file) => globsIn(root, file), {\n concurrency: 1,\n });\n const kept = yield* keptGlobs(root, Arr.dedupe(Arr.flatten(globs)));\n return Arr.dedupe([...kept, ...TOOL_DIRECTORIES]);\n});\n\nconst exclusionsOf = (globs: readonly string[]): readonly IgnoredDirectory[] =>\n pipe(\n globs,\n Arr.flatMap((glob): readonly IgnoredDirectory[] => [\n { pattern: `${NEGATION}${glob}`, base: \"workspace\" },\n { pattern: `${NEGATION}${glob}${CONTENTS}`, base: \"workspace\" },\n ]),\n );\n\ninterface Placement {\n readonly parent: readonly string[];\n readonly name: string;\n}\n\nconst placementOf = (glob: string): Option.Option<Placement> =>\n pipe(\n Option.liftPredicate(glob, Str.startsWith(ANYWHERE)),\n Option.map((found) => Str.split(SEPARATOR)(Str.slice(ANYWHERE.length)(found))),\n Option.map((segments) => ({\n parent: Arr.initNonEmpty(segments),\n name: Arr.lastNonEmpty(segments),\n })),\n Option.filter(\n ({ parent }) =>\n Arr.isReadonlyArrayNonEmpty(parent) &&\n !pipe(\n parent,\n Arr.some((segment) => WILDCARD.test(segment)),\n ),\n ),\n );\n\nconst placesOf =\n (parent: readonly string[]) =>\n (file: string): readonly string[] => {\n const segments = Str.split(SEPARATOR)(file);\n return pipe(\n Arr.makeBy(segments.length - parent.length, (start) => start),\n Arr.filter((start) =>\n pipe(\n parent,\n Arr.every((segment, offset) => segments[start + offset] === segment),\n ),\n ),\n Arr.map((start) => Arr.join(Arr.take(segments, start + parent.length), SEPARATOR)),\n );\n };\n\nconst placedGlobs = Effect.fn(\"placedGlobs\")(function* placedGlobs(\n root: string,\n globs: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const parents = pipe(\n globs,\n Arr.flatMap((glob) => Option.toArray(placementOf(glob))),\n Arr.map(({ parent }) => contentsOf(`${ANYWHERE}${Arr.join(parent, SEPARATOR)}`)),\n );\n const listed = yield* files.trackedFiles(root, Arr.dedupe(parents));\n return pipe(\n globs,\n Arr.flatMap((glob) =>\n Option.match(placementOf(glob), {\n onNone: () => Arr.filter([glob], (kept) => !Str.startsWith(ANYWHERE)(kept)),\n onSome: ({ parent, name }) =>\n pipe(\n listed,\n Arr.flatMap(placesOf(parent)),\n Arr.dedupe,\n Arr.map((place) => `${place}${SEPARATOR}${name}`),\n ),\n }),\n ),\n );\n});\n\nexport const collectIgnoredDirectories = Effect.fn(\"collectIgnoredDirectories\")(\n function* collectIgnoredDirectories(root: string) {\n const globs = yield* ignoredGlobs(root);\n return exclusionsOf(globs);\n },\n);\n\nexport const collectPlacedIgnoredDirectories = Effect.fn(\"collectPlacedIgnoredDirectories\")(\n function* collectPlacedIgnoredDirectories(root: string) {\n const globs = yield* ignoredGlobs(root);\n const placed = yield* placedGlobs(root, globs);\n return exclusionsOf(placed);\n },\n);\n\nexport const ignoredDirectories = (root: string): Promise<readonly IgnoredDirectory[]> =>\n Effect.runPromise(collectIgnoredDirectories(root).pipe(Effect.provide(nodeRepositoryFiles)));\n"],"mappings":";;;AAIA,MAAM,mBAAmB;AAEzB,MAAM,SACJ,OACA,MACA,aAC4B;CAC5B,MAAM,QAAQ,QAAQ,WAAW,QAAQ,aAAa,QAAQ,GAAG,IAAI;CACrE,IAAI,QAAQ,QAAQ,KAAK,GACvB,OAAO;CAET,MAAM,OAAO,KACXA,MAAI,aAAa,KAAK,GACtBA,MAAI,SAAS,OAAO,MAAM,OAAO,CAAC,CAAC,CACrC;CACA,OAAO,MAAM,OAAO,QAAQ,MAAM,MAAM,KAAK,GAAG,IAAI;AACtD;AAEA,MAAa,YAGTC,SAAG,KAAK,mBAAmB,OAAc,UAC3CD,MAAI,aAAa,MAAM,OAAO,QAAQ,MAAM,GAAG,KAAK,CAAC,CACvD;;ACvBA,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,WAAW;AACjB,MAAM,WAAW;AACjB,MAAM,OAAO;AACb,MAAM,WAAW;AACjB,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB,CA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OAAO,aAAa,IAAI;CACtC,OAAO,aAAa,KAAK;AAC3B,CACF;AAEA,MAAa,kCAAkC,OAAO,GAAG,iCAAiC,CAAC,CACzF,UAAU,gCAAgC,MAAc;CACtD,MAAM,QAAQ,OAAO,aAAa,IAAI;CACtC,MAAM,SAAS,OAAO,YAAY,MAAM,KAAK;CAC7C,OAAO,aAAa,MAAM;AAC5B,CACF;AAEA,MAAa,sBAAsB,SACjC,OAAO,WAAW,0BAA0B,IAAI,CAAC,CAAC,KAAK,OAAO,QAAQ,mBAAmB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"ignored-directories-wh-dhKsl.mjs","names":["Arr","Fn","Str","Arr"],"sources":["../src/shared/lib/reachable.ts","../src/shared/lib/ignored-directories.ts"],"sourcesContent":["import { Array as Arr, Function as Fn, HashSet, pipe } from \"effect\";\n\nexport type Edges = Readonly<Record<string, readonly string[]>>;\n\nconst DATA_FIRST_ARITY = 2;\n\nconst visit = (\n edges: Edges,\n seen: HashSet.HashSet<string>,\n frontier: readonly string[],\n): HashSet.HashSet<string> => {\n const fresh = HashSet.difference(HashSet.fromIterable(frontier), seen);\n if (HashSet.isEmpty(fresh)) {\n return seen;\n }\n const next = pipe(\n Arr.fromIterable(fresh),\n Arr.flatMap((id) => edges[id] ?? []),\n );\n return visit(edges, HashSet.union(seen, fresh), next);\n};\n\nexport const reachable: {\n (roots: readonly string[]): (edges: Edges) => readonly string[];\n (edges: Edges, roots: readonly string[]): readonly string[];\n} = Fn.dual(DATA_FIRST_ARITY, (edges: Edges, roots: readonly string[]): readonly string[] =>\n Arr.fromIterable(visit(edges, HashSet.empty(), roots)),\n);\n","import { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\n\nimport { RepositoryFiles, nodeRepositoryFiles } from \"./repository-files.ts\";\n\nconst IGNORE_FILES = \":(glob)**/.gitignore\";\nconst SEPARATOR = \"/\";\nconst NEGATION = \"!\";\nconst CONTENTS = \"/**\";\nconst ROOT = \".\";\nconst ANYWHERE = \"**/\";\nconst READ_CONCURRENCY = 16;\nconst DIRECTORY_ENTRY = /^(?<anchor>\\/?)(?<name>[^!#/].*)\\/$/u;\nconst TOOL_DIRECTORIES = [\"**/node_modules/.vite*\"];\nconst WILDCARD = /[*?[]/u;\n\nexport interface IgnoredDirectory {\n readonly pattern: string;\n readonly base: \"workspace\";\n}\n\nconst scopedName = (anchor: string, name: string): string => {\n if (anchor === SEPARATOR || Str.includes(SEPARATOR)(name)) {\n return name;\n }\n return `${ANYWHERE}${name}`;\n};\n\nconst inDirectory =\n (directory: string) =>\n (glob: string): string => {\n if (directory === ROOT) {\n return glob;\n }\n return `${directory}${SEPARATOR}${glob}`;\n };\n\nconst globOf =\n (directory: string) =>\n (line: string): Option.Option<string> => {\n const found = DIRECTORY_ENTRY.exec(Str.trim(line));\n return pipe(\n Option.fromNullishOr(found),\n Option.flatMap(({ groups }) => Option.fromNullishOr(groups)),\n Option.flatMap(({ anchor, name }) =>\n Option.map(Option.fromNullishOr(name), (entry) => scopedName(anchor ?? \"\", entry)),\n ),\n Option.map(inDirectory(directory)),\n );\n };\n\nconst contentsOf = (glob: string): string => `:(glob)${glob}${CONTENTS}`;\n\nconst keptGlob = Effect.fn(\"keptGlob\")(function* keptGlob(root: string, glob: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.trackedFiles(root, [contentsOf(glob)]);\n return Option.some(glob).pipe(Option.filter(() => Arr.isReadonlyArrayEmpty(listed)));\n});\n\nconst keptGlobs = Effect.fn(\"keptGlobs\")(function* keptGlobs(\n root: string,\n candidates: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.trackedFiles(root, pipe(candidates, Arr.map(contentsOf)));\n if (Arr.isReadonlyArrayEmpty(listed)) {\n return candidates;\n }\n const kept = yield* Effect.forEach(candidates, (glob) => keptGlob(root, glob), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(kept);\n});\n\nconst globsIn = Effect.fn(\"globsIn\")(function* globsIn(root: string, file: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(root, file));\n const toGlob = globOf(files.dirname(file));\n return pipe(\n Option.getOrElse(text, () => \"\"),\n Str.split(\"\\n\"),\n Arr.map(toGlob),\n Arr.getSomes,\n );\n});\n\nconst ignoredGlobs = Effect.fn(\"ignoredGlobs\")(function* ignoredGlobs(root: string) {\n const files = yield* RepositoryFiles;\n const ignoreFiles = yield* files.trackedFiles(root, [IGNORE_FILES]);\n const globs = yield* Effect.forEach(ignoreFiles, (file) => globsIn(root, file), {\n concurrency: 1,\n });\n const kept = yield* keptGlobs(root, Arr.dedupe(Arr.flatten(globs)));\n return Arr.dedupe([...kept, ...TOOL_DIRECTORIES]);\n});\n\nconst exclusionsOf = (globs: readonly string[]): readonly IgnoredDirectory[] =>\n pipe(\n globs,\n Arr.flatMap((glob): readonly IgnoredDirectory[] => [\n { pattern: `${NEGATION}${glob}`, base: \"workspace\" },\n { pattern: `${NEGATION}${glob}${CONTENTS}`, base: \"workspace\" },\n ]),\n );\n\ninterface Placement {\n readonly parent: readonly string[];\n readonly name: string;\n}\n\nconst placementOf = (glob: string): Option.Option<Placement> =>\n pipe(\n Option.liftPredicate(glob, Str.startsWith(ANYWHERE)),\n Option.map((found) => Str.split(SEPARATOR)(Str.slice(ANYWHERE.length)(found))),\n Option.map((segments) => ({\n parent: Arr.initNonEmpty(segments),\n name: Arr.lastNonEmpty(segments),\n })),\n Option.filter(\n ({ parent }) =>\n Arr.isReadonlyArrayNonEmpty(parent) &&\n !pipe(\n parent,\n Arr.some((segment) => WILDCARD.test(segment)),\n ),\n ),\n );\n\nconst placesOf =\n (parent: readonly string[]) =>\n (file: string): readonly string[] => {\n const segments = Str.split(SEPARATOR)(file);\n return pipe(\n Arr.makeBy(segments.length - parent.length, (start) => start),\n Arr.filter((start) =>\n pipe(\n parent,\n Arr.every((segment, offset) => segments[start + offset] === segment),\n ),\n ),\n Arr.map((start) => Arr.join(Arr.take(segments, start + parent.length), SEPARATOR)),\n );\n };\n\nconst placedGlobs = Effect.fn(\"placedGlobs\")(function* placedGlobs(\n root: string,\n globs: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const parents = pipe(\n globs,\n Arr.flatMap((glob) => Option.toArray(placementOf(glob))),\n Arr.map(({ parent }) => contentsOf(`${ANYWHERE}${Arr.join(parent, SEPARATOR)}`)),\n );\n const listed = yield* files.trackedFiles(root, Arr.dedupe(parents));\n return pipe(\n globs,\n Arr.flatMap((glob) =>\n Option.match(placementOf(glob), {\n onNone: () => Arr.filter([glob], (kept) => !Str.startsWith(ANYWHERE)(kept)),\n onSome: ({ parent, name }) =>\n pipe(\n listed,\n Arr.flatMap(placesOf(parent)),\n Arr.dedupe,\n Arr.map((place) => `${place}${SEPARATOR}${name}`),\n ),\n }),\n ),\n );\n});\n\nexport const collectIgnoredDirectories = Effect.fn(\"collectIgnoredDirectories\")(\n function* collectIgnoredDirectories(root: string) {\n const globs = yield* ignoredGlobs(root);\n return exclusionsOf(globs);\n },\n);\n\nexport const collectPlacedIgnoredDirectories = Effect.fn(\"collectPlacedIgnoredDirectories\")(\n function* collectPlacedIgnoredDirectories(root: string) {\n const globs = yield* ignoredGlobs(root);\n const placed = yield* placedGlobs(root, globs);\n return exclusionsOf(placed);\n },\n);\n\nexport const ignoredDirectories = (root: string): Promise<readonly IgnoredDirectory[]> =>\n Effect.runPromise(collectIgnoredDirectories(root).pipe(Effect.provide(nodeRepositoryFiles)));\n"],"mappings":";;;AAIA,MAAM,mBAAmB;AAEzB,MAAM,SACJ,OACA,MACA,aAC4B;CAC5B,MAAM,QAAQ,QAAQ,WAAW,QAAQ,aAAa,QAAQ,GAAG,IAAI;CACrE,IAAI,QAAQ,QAAQ,KAAK,GACvB,OAAO;CAET,MAAM,OAAO,KACXA,MAAI,aAAa,KAAK,GACtBA,MAAI,SAAS,OAAO,MAAM,OAAO,CAAC,CAAC,CACrC;CACA,OAAO,MAAM,OAAO,QAAQ,MAAM,MAAM,KAAK,GAAG,IAAI;AAC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AAC,CAAC,IAAI,CAAC;EAC1E,SAAS,EAAE,QAAQ,WACjB,KACE,QACAC,MAAI,QAAQ,SAAS,MAAM,CAAC,GAC5BA,MAAI,QACJA,MAAI,KAAK,UAAU,GAAG,QAAQ,YAAY,MAAM,CAClD;CACJ,CAAC,CACH,CACF;AACF,CAAC;AAED,MAAa,4BAA4B,OAAO,GAAG,2BAA2B,CAAC,CAC7E,UAAU,0BAA0B,MAAc;CAChD,MAAM,QAAQ,OAAO,aAAa,IAAI;CACtC,OAAO,aAAa,KAAK;AAC3B,CACF;AAEA,MAAa,kCAAkC,OAAO,GAAG,iCAAiC,CAAC,CACzF,UAAU,gCAAgC,MAAc;CACtD,MAAM,QAAQ,OAAO,aAAa,IAAI;CACtC,MAAM,SAAS,OAAO,YAAY,MAAM,KAAK;CAC7C,OAAO,aAAa,MAAM;AAC5B,CACF;AAEA,MAAa,sBAAsB,SACjC,OAAO,WAAW,0BAA0B,IAAI,CAAC,CAAC,KAAK,OAAO,QAAQ,mBAAmB,CAAC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect
|
|
|
2
2
|
import { ChildProcessSpawner } from "effect/process";
|
|
3
3
|
import "@r_masseater/masseater-utils/kestrion/pnpm";
|
|
4
4
|
import "@r_masseater/masseater-utils/kestrion";
|
|
5
|
+
import { UserConfig } from "vite-plus";
|
|
5
6
|
import { OxlintOverride } from "vite-plus/lint";
|
|
6
7
|
interface WorkspaceTasks {
|
|
7
8
|
readonly verify: readonly string[];
|
|
@@ -19,15 +20,7 @@ interface DependencyAllowance {
|
|
|
19
20
|
readonly dependencies: readonly string[];
|
|
20
21
|
}
|
|
21
22
|
type DependencyAllowances = Readonly<Record<string, DependencyAllowance>>;
|
|
22
|
-
|
|
23
|
-
readonly extends: string | false;
|
|
24
|
-
readonly root: string;
|
|
25
|
-
readonly test: {
|
|
26
|
-
readonly name: string;
|
|
27
|
-
readonly isolate: false;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
type TestProject = string | SharedTestProject;
|
|
23
|
+
type VitestProject = NonNullable<NonNullable<UserConfig["test"]>["projects"]>[number];
|
|
31
24
|
type RuleSet = Readonly<Record<string, unknown>>;
|
|
32
25
|
type RuleSets = Readonly<Record<string, RuleSet>>;
|
|
33
26
|
interface WorkspaceLint {
|
|
@@ -41,7 +34,7 @@ interface WorkspaceSettings {
|
|
|
41
34
|
readonly lint: WorkspaceLint;
|
|
42
35
|
readonly members: readonly string[];
|
|
43
36
|
readonly ignoredDirectories: readonly IgnoredDirectory[];
|
|
44
|
-
readonly testProjects: readonly
|
|
37
|
+
readonly testProjects: readonly VitestProject[];
|
|
45
38
|
readonly tasks: WorkspaceTasks;
|
|
46
39
|
readonly devDependencies: DependencyAllowances;
|
|
47
40
|
readonly dependencies: DependencyAllowances;
|
|
@@ -55,4 +48,4 @@ interface SettingsOptions {
|
|
|
55
48
|
}
|
|
56
49
|
declare const workspaceSettings: (options: SettingsOptions) => Promise<WorkspaceSettings>;
|
|
57
50
|
export { WorkspaceSettings as a, DependencySets as c, WorkspaceTasks as d, WorkspaceLint as i, IgnoredDirectory as l, RuleSets as n, workspaceSettings as o, SettingsOptions as r, DependencyAllowance as s, RuleSet as t, ignoredDirectories as u };
|
|
58
|
-
//# sourceMappingURL=index-
|
|
51
|
+
//# sourceMappingURL=index-B0ahB5vD.d.mts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ToolSections } from "@r_masseater/vite-plus-adopt";
|
|
2
1
|
import { Option } from "effect";
|
|
3
2
|
import markdown from "@textlint/textlint-plugin-markdown";
|
|
4
3
|
import { RecommendedOptions } from "@r_masseater/y8/presets";
|
|
5
4
|
import { Y8Config } from "@r_masseater/y8";
|
|
6
5
|
import { WismConfig } from "@r_masseater/wism";
|
|
6
|
+
import { ToolSections } from "@r_masseater/vite-plus-adopt";
|
|
7
7
|
import { TextlintPluginOptions } from "@textlint/types";
|
|
8
8
|
declare const allRulesOf: ({ prefix, rules }: Readonly<{
|
|
9
9
|
prefix: string;
|
|
@@ -316,4 +316,4 @@ interface MarkdownOptions {
|
|
|
316
316
|
}
|
|
317
317
|
declare const markdownOf: ({ indexSkill, docs }: MarkdownOptions) => Y8Config;
|
|
318
318
|
export { allRulesOf as C, lint$2 as S, decisionTestRules as T, requiredStack as _, _default as a, commandsOverride as b, textlintPresets as c, VideoSayOptions as d, VideoSeriesOptions as f, INSTRUMENTATION as g, tracedRules as h, markdownOf as i, structureOf as l, remotionRules as m, MARKDOWN_RULES as n, zennMarkdown as o, videoRules as p, MarkdownOptions as r, textlintFilters as s, MARKDOWN_IGNORES as t, VideoRulesOptions as u, exempt as v, decisionRules as w, removalPolicyOverride as x, alchemyOverride as y };
|
|
319
|
-
//# sourceMappingURL=index-
|
|
319
|
+
//# sourceMappingURL=index-D6X9EgDG.d.mts.map
|
package/dist/library.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as readManifest } from "./dependencies-
|
|
2
|
-
import { i as nodeRepositoryFiles, r as RepositoryFiles } from "./repository-files-
|
|
1
|
+
import { r as readManifest } from "./dependencies-OrBsaeID.mjs";
|
|
2
|
+
import { i as nodeRepositoryFiles, r as RepositoryFiles } from "./repository-files-C8B7lrka.mjs";
|
|
3
3
|
import { Array, Effect, Match, Option, Predicate, Record, String, pipe } from "effect";
|
|
4
4
|
import { ROOT_SUBPATH, SUBPATH_PREFIX, binEntriesOf, exportEntriesOf } from "@r_masseater/masseater-utils/kestrion";
|
|
5
5
|
// src/features/define-library/model/entries.ts
|
package/dist/lint.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as allRulesOf, S as lint, T as decisionTestRules, _ as requiredStack, a as _default, b as commandsOverride, c as textlintPresets, d as VideoSayOptions, f as VideoSeriesOptions, g as INSTRUMENTATION, h as tracedRules, i as markdownOf, l as structureOf, m as remotionRules, n as MARKDOWN_RULES, o as zennMarkdown, p as videoRules, r as MarkdownOptions, s as textlintFilters, t as MARKDOWN_IGNORES, u as VideoRulesOptions, v as exempt, w as decisionRules, x as removalPolicyOverride, y as alchemyOverride } from "./index-
|
|
1
|
+
import { C as allRulesOf, S as lint, T as decisionTestRules, _ as requiredStack, a as _default, b as commandsOverride, c as textlintPresets, d as VideoSayOptions, f as VideoSeriesOptions, g as INSTRUMENTATION, h as tracedRules, i as markdownOf, l as structureOf, m as remotionRules, n as MARKDOWN_RULES, o as zennMarkdown, p as videoRules, r as MarkdownOptions, s as textlintFilters, t as MARKDOWN_IGNORES, u as VideoRulesOptions, v as exempt, w as decisionRules, x as removalPolicyOverride, y as alchemyOverride } from "./index-D6X9EgDG.mjs";
|
|
2
2
|
export { INSTRUMENTATION, MARKDOWN_IGNORES, MARKDOWN_RULES, type MarkdownOptions, type VideoRulesOptions, type VideoSayOptions, type VideoSeriesOptions, alchemyOverride, allRulesOf, commandsOverride, _default as decisionPlugin, decisionRules, decisionTestRules, exempt, lint, markdownOf, remotionRules, removalPolicyOverride, requiredStack, structureOf, textlintFilters, textlintPresets, tracedRules, videoRules, zennMarkdown };
|
package/dist/lint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as INSTRUMENTATION, t as MARKDOWN_IGNORES, n as MARKDOWN_RULES, v as alchemyOverride, m as allRulesOf, y as commandsOverride, _ as decisionPlugin, h as decisionRules, g as decisionTestRules, x as exempt, p as lint, r as markdownOf, l as remotionRules, b as removalPolicyOverride, f as requiredStack, s as structureOf, a as textlintFilters, o as textlintPresets, u as tracedRules, c as videoRules, i as zennMarkdown } from "./define-lint-preset-
|
|
1
|
+
export { d as INSTRUMENTATION, t as MARKDOWN_IGNORES, n as MARKDOWN_RULES, v as alchemyOverride, m as allRulesOf, y as commandsOverride, _ as decisionPlugin, h as decisionRules, g as decisionTestRules, x as exempt, p as lint, r as markdownOf, l as remotionRules, b as removalPolicyOverride, f as requiredStack, s as structureOf, a as textlintFilters, o as textlintPresets, u as tracedRules, c as videoRules, i as zennMarkdown } from "./define-lint-preset-CYgaGe8E.mjs";
|
package/dist/oxlint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as describeFinding, t as ProblemList } from "./problem-
|
|
2
|
-
import { a as nodeServicesLayer } from "./repository-files-
|
|
1
|
+
import { n as describeFinding, t as ProblemList } from "./problem-D0e14vkQ.mjs";
|
|
2
|
+
import { a as nodeServicesLayer } from "./repository-files-C8B7lrka.mjs";
|
|
3
3
|
import { Array, Effect, Layer, Schema, Stream, pipe } from "effect";
|
|
4
4
|
import { ChildProcess } from "effect/process";
|
|
5
5
|
// src/features/report-problems/model/oxlint-rule.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as NODE_MODULES } from "./repository-files-
|
|
1
|
+
import { n as NODE_MODULES } from "./repository-files-C8B7lrka.mjs";
|
|
2
2
|
import { Array, Option, Order, Schema, String as String$1, pipe } from "effect";
|
|
3
3
|
import { InternalSymbolName, SyntaxKind, getJSDocTags, getLeadingCommentRanges, getNameOfDeclaration, getTextOfJSDocComment } from "tsrs/ast";
|
|
4
4
|
import { isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isExpressionStatement, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isLiteralTypeNode, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isPropertySignatureDeclaration, isReturnStatement, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "tsrs/ast/is";
|
|
@@ -127,4 +127,4 @@ const describeFinding = (problem) => `[${problem.rule}] ${problem.message}`;
|
|
|
127
127
|
const formatProblem = (relative) => (problem) => `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;
|
|
128
128
|
export { isIdentifier as $, uniqueByReference as A, getTextOfJSDocComment as B, moduleSpecifierOf as C, resolvedSymbol as D, referencedSymbols as E, SymbolFlags$1 as F, isCallExpression as G, isArrowFunction as H, SyntaxKind as I, isEnumDeclaration as J, isClassDeclaration as K, getJSDocTags as L, IndexKind as M, InternalSymbolName as N, symbolAt as O, SignatureKind as P, isFunctionExpression as Q, getLeadingCommentRanges as R, moduleSpecifierLiteralOf as S, isVariableStatement as St, propertyNamesOf as T, isBinaryExpression as U, isArrayLiteralExpression as V, isBlock as W, isExpressionStatement as X, isExportDeclaration as Y, isFunctionDeclaration as Z, isGenericDeclaration as _, isTypeLiteralNode as _t, problemAtPosition as a, isNumericLiteral as at, isTypeDeclaration as b, isVariableDeclaration as bt, carriesTag as c, isPropertyAccessExpression as ct, contains as d, isSatisfiesExpression as dt, isImportDeclaration as et, declarationsOf as f, isSignatureDeclaration as ft, isExternalDeclaration as g, isTypeAliasDeclaration as gt, importedModulesOf as h, isStringLiteral as ht, problemAt as i, isNewExpression as it, API as j, symbolAtLocation as k, childrenOf as l, isPropertyAssignment as lt, descendantsOf as m, isSpreadElement as mt, describeFinding as n, isModuleBlock as nt, problemInFile as o, isObjectLiteralExpression as ot, declaresAType as p, isSourceFile as pt, isElementAccessExpression as q, formatProblem as r, isModuleDeclaration as rt, sortProblems as s, isParenthesizedExpression as st, ProblemList as t, isInterfaceDeclaration as tt, columnOf as u, isReturnStatement as ut, isInsideAny as v, isTypeReferenceNode as vt, packageOf as w, lineOf as x, isVariableDeclarationList as xt, isOutsideDeclaration as y, isUnionTypeNode as yt, getNameOfDeclaration as z };
|
|
129
129
|
|
|
130
|
-
//# sourceMappingURL=problem-
|
|
130
|
+
//# sourceMappingURL=problem-D0e14vkQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"problem-DaWjnZyW.mjs","names":["Arr","Str","Arr"],"sources":["../src/shared/lib/syntax.ts","../src/shared/lib/problem.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n isClassDeclaration,\n isEnumDeclaration,\n isExportAssignment,\n isExportDeclaration,\n isIdentifier,\n isImportDeclaration,\n isInterfaceDeclaration,\n isLiteralTypeNode,\n isPropertyAccessExpression,\n isPropertyDeclaration,\n isPropertySignatureDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n EnumDeclaration,\n Expression,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n StringLiteral,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n} from \"./compiler.ts\";\nimport { NODE_MODULES } from \"./repository-files.ts\";\n\nconst NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;\n\nexport const POSITION_BASE = 1;\n\nexport const uniqueByReference = <Item>(items: readonly Item[]): readonly Item[] =>\n Arr.dedupeWith(items, (left, right) => left === right);\n\nexport const childrenOf = (node: Node): readonly Node[] => {\n const children: Node[] = [];\n node.forEachChild((child) => {\n children.push(child);\n });\n return children;\n};\n\nconst SCOPE_PREFIX = \"@\";\nconst SCOPED_SEGMENTS = 2;\nconst UNSCOPED_SEGMENTS = 1;\n\nexport const packageOf = (fileName: string): string => {\n const afterModules = pipe(\n fileName,\n Str.lastIndexOf(NODE_MODULES_SEGMENT),\n Option.match({\n onNone: () => fileName,\n onSome: (index) => Str.slice(index + NODE_MODULES_SEGMENT.length)(fileName),\n }),\n );\n const segments = Str.split(\"/\")(afterModules);\n if (Str.startsWith(SCOPE_PREFIX)(afterModules)) {\n return pipe(Arr.take(segments, SCOPED_SEGMENTS), Arr.join(\"/\"));\n }\n return pipe(Arr.take(segments, UNSCOPED_SEGMENTS), Arr.join(\"/\"));\n};\n\nexport const descendantsOf = (node: Node): readonly Node[] =>\n pipe(\n childrenOf(node),\n Arr.flatMap((child) => Arr.prepend(descendantsOf(child), child)),\n );\n\nconst isExternalFile =\n (program: Program) =>\n (sourceFile: SourceFile): boolean =>\n !program.isSourceFileDefaultLibrary(sourceFile) &&\n (Str.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) ||\n program.isSourceFileFromExternalLibrary(sourceFile));\n\nexport const isExternalDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n isExternalFile(program)(declaration.getSourceFile());\n\nexport const isOutsideDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n program.isSourceFileDefaultLibrary(declaration.getSourceFile()) ||\n isExternalDeclaration(program)(declaration);\n\nconst ALIAS_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ImportSpecifier,\n SyntaxKind.ImportClause,\n SyntaxKind.NamespaceImport,\n SyntaxKind.ExportSpecifier,\n SyntaxKind.ImportEqualsDeclaration,\n SyntaxKind.ExportAssignment,\n]);\n\nexport const declarationsOf = (symbol: TypeSymbol): readonly Declaration[] =>\n pipe(\n symbol.declarations,\n Arr.flatMap((handle) => Option.toArray(Option.fromUndefinedOr(handle.resolve()))),\n );\n\nconst isEntityName = (expression: Expression): boolean =>\n isIdentifier(expression) ||\n (isPropertyAccessExpression(expression) && isEntityName(expression.expression));\n\nconst aliasesAnEntity = (declaration: Node): boolean =>\n !isExportAssignment(declaration) || isEntityName(declaration.expression);\n\nconst isAliasDeclaration = (declaration: Node): boolean =>\n ALIAS_KINDS.has(declaration.kind) && aliasesAnEntity(declaration);\n\nexport const resolvedSymbol =\n (checker: Checker) =>\n (symbol: TypeSymbol): TypeSymbol => {\n if (\n !pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isAliasDeclaration(declaration)),\n )\n ) {\n return symbol;\n }\n return checker.getAliasedSymbol(symbol);\n };\n\nexport const symbolAtLocation =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(node));\n\nexport const symbolAt =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n symbolAtLocation(checker)(node).pipe(Option.map(resolvedSymbol(checker)));\n\nexport const referencedSymbols =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] => {\n const identifiers = pipe(\n Arr.prepend(descendantsOf(node), node),\n Arr.filter((candidate) => isIdentifier(candidate)),\n );\n const symbols = pipe(\n checker.getSymbolAtLocation(identifiers),\n Arr.flatMap((symbol) => Option.toArray(Option.fromUndefinedOr(symbol))),\n Arr.map(resolvedSymbol(checker)),\n );\n return uniqueByReference(symbols);\n };\n\nexport const lineOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + POSITION_BASE;\n};\n\nexport const columnOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return (\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).character + POSITION_BASE\n );\n};\n\nexport const contains =\n (outer: Node) =>\n (inner: Node): boolean =>\n outer.getSourceFile().fileName === inner.getSourceFile().fileName &&\n outer.getStart() <= inner.getStart() &&\n inner.getEnd() <= outer.getEnd();\n\nexport const isInsideAny =\n (outers: readonly Node[]) =>\n (node: Node): boolean =>\n pipe(\n outers,\n Arr.some((outer) => contains(outer)(node)),\n );\n\nexport const isTypeDeclaration = (\n declaration: Node,\n): declaration is TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration =>\n isTypeAliasDeclaration(declaration) ||\n isInterfaceDeclaration(declaration) ||\n isEnumDeclaration(declaration);\n\nconst membersOf = (declaration: Node): readonly Node[] => {\n if (isInterfaceDeclaration(declaration) || isClassDeclaration(declaration)) {\n return declaration.members;\n }\n if (isTypeAliasDeclaration(declaration) && isTypeLiteralNode(declaration.type)) {\n return declaration.type.members;\n }\n return [];\n};\n\nconst isTagNamed =\n (name: string) =>\n (member: Node): boolean =>\n (isPropertySignatureDeclaration(member) || isPropertyDeclaration(member)) &&\n pipe(\n Option.fromUndefinedOr(member.type),\n Option.exists(\n (type) =>\n isLiteralTypeNode(type) && isStringLiteral(type.literal) && type.literal.text === name,\n ),\n );\n\nexport const declaresAType = (declarations: readonly Node[]): boolean =>\n pipe(\n declarations,\n Arr.some((declaration) => isTypeDeclaration(declaration) || isClassDeclaration(declaration)),\n );\n\nexport const carriesTag =\n (name: string) =>\n (declarations: readonly Node[]): boolean =>\n pipe(declarations, Arr.flatMap(membersOf), Arr.some(isTagNamed(name)));\n\nexport const isGenericDeclaration = (declaration: Node): boolean =>\n (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) &&\n Arr.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);\n\nexport const propertyNamesOf =\n (checker: Checker) =>\n (type: Type): readonly string[] =>\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => property.name),\n );\n\nexport const moduleSpecifierLiteralOf = (statement: Node): Option.Option<StringLiteral> => {\n if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter(isStringLiteral));\n};\n\nexport const moduleSpecifierOf = (statement: Node): Option.Option<string> =>\n Option.map(moduleSpecifierLiteralOf(statement), (specifier) => specifier.text);\n\nexport const importedModulesOf = (sourceFile: SourceFile): readonly string[] =>\n pipe(\n sourceFile.statements,\n Arr.map((statement) => moduleSpecifierOf(statement)),\n Arr.getSomes,\n );\n","import { Array as Arr, Order, Schema, pipe } from \"effect\";\n\nimport type { Node } from \"./compiler.ts\";\nimport { columnOf, lineOf } from \"./syntax.ts\";\n\nconst RuleNameSchema = Schema.String.check(Schema.isPattern(/^[a-z]+(?:-[a-z]+)*$/u));\n\nexport type RuleName = typeof RuleNameSchema.Type;\n\nconst ProblemSchema = Schema.Struct({\n file: Schema.String,\n line: Schema.Int,\n column: Schema.Int,\n rule: RuleNameSchema,\n message: Schema.String,\n});\n\nexport type Problem = typeof ProblemSchema.Type;\n\nexport const ProblemList = Schema.Array(ProblemSchema);\n\nexport const CANDIDATE_LIMIT = 3;\n\nconst FIRST = 1;\n\nexport interface Position {\n readonly line: number;\n readonly column: number;\n}\n\nexport const problemAtPosition =\n (rule: RuleName) =>\n (file: string, { line, column }: Readonly<Position>, message: string): Problem => ({\n file,\n line,\n column,\n rule,\n message,\n });\n\nexport const problemInFile =\n (rule: RuleName) =>\n (file: string, message: string): Problem =>\n problemAtPosition(rule)(file, { line: FIRST, column: FIRST }, message);\n\nexport interface Finding {\n readonly rule: RuleName;\n readonly message: string;\n}\n\nexport const problemAt =\n ({ rule, message }: Finding) =>\n (node: Node): Problem => ({\n file: node.getSourceFile().fileName,\n line: lineOf(node),\n column: columnOf(node),\n rule,\n message,\n });\n\nconst problemOrder: Order.Order<Problem> = Order.combineAll([\n Order.mapInput(Order.String, (problem: Problem) => problem.file),\n Order.mapInput(Order.Number, (problem: Problem) => problem.line),\n Order.mapInput(Order.Number, (problem: Problem) => problem.column),\n Order.mapInput(Order.String, (problem: Problem) => problem.rule),\n Order.mapInput(Order.String, (problem: Problem) => problem.message),\n]);\n\nconst problemKey = (problem: Problem): string =>\n pipe(\n [problem.file, String(problem.line), String(problem.column), problem.rule, problem.message],\n Arr.join(\"\\0\"),\n );\n\nexport const sortProblems = (problems: readonly Problem[]): readonly Problem[] =>\n Arr.sort(\n Arr.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)),\n problemOrder,\n );\n\nexport const describeFinding = (problem: Problem): string => `[${problem.rule}] ${problem.message}`;\n\nexport const formatProblem =\n (relative: (file: string) => string) =>\n (problem: Problem): string =>\n `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;\n"],"mappings":";;;;;;AAmCA,MAAM,uBAAuB,IAAI,aAAa;AAI9C,MAAa,qBAA2B,UACtCA,MAAI,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAK;AAEvD,MAAa,cAAc,SAAgC;CACzD,MAAM,WAAmB,CAAC;CAC1B,KAAK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O,QAAQ,MAAM;CAAG,QAAQ;CAAM,QAAQ;AAAO,GAC1FE,MAAI,KAAK,IAAI,CACf;AAEF,MAAa,gBAAgB,aAC3BA,MAAI,KACFA,MAAI,WAAW,WAAW,MAAM,UAAU,WAAW,IAAI,MAAM,WAAW,KAAK,CAAC,GAChF,YACF;AAEF,MAAa,mBAAmB,YAA6B,IAAI,QAAQ,KAAK,IAAI,QAAQ;AAE1F,MAAa,iBACV,cACA,YACC,GAAG,SAAS,QAAQ,IAAI,EAAE,GAAG,OAAO,QAAQ,IAAI,EAAE,GAAG,OAAO,QAAQ,MAAM,EAAE,GAAG,gBAAgB,OAAO"}
|
|
1
|
+
{"version":3,"file":"problem-D0e14vkQ.mjs","names":["Arr","Str","Arr"],"sources":["../src/shared/lib/syntax.ts","../src/shared/lib/problem.ts"],"sourcesContent":["import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n isClassDeclaration,\n isEnumDeclaration,\n isExportAssignment,\n isExportDeclaration,\n isIdentifier,\n isImportDeclaration,\n isInterfaceDeclaration,\n isLiteralTypeNode,\n isPropertyAccessExpression,\n isPropertyDeclaration,\n isPropertySignatureDeclaration,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n EnumDeclaration,\n Expression,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n StringLiteral,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n} from \"./compiler.ts\";\nimport { NODE_MODULES } from \"./repository-files.ts\";\n\nconst NODE_MODULES_SEGMENT = `/${NODE_MODULES}/`;\n\nexport const POSITION_BASE = 1;\n\nexport const uniqueByReference = <Item>(items: readonly Item[]): readonly Item[] =>\n Arr.dedupeWith(items, (left, right) => left === right);\n\nexport const childrenOf = (node: Node): readonly Node[] => {\n const children: Node[] = [];\n node.forEachChild((child) => {\n children.push(child);\n });\n return children;\n};\n\nconst SCOPE_PREFIX = \"@\";\nconst SCOPED_SEGMENTS = 2;\nconst UNSCOPED_SEGMENTS = 1;\n\nexport const packageOf = (fileName: string): string => {\n const afterModules = pipe(\n fileName,\n Str.lastIndexOf(NODE_MODULES_SEGMENT),\n Option.match({\n onNone: () => fileName,\n onSome: (index) => Str.slice(index + NODE_MODULES_SEGMENT.length)(fileName),\n }),\n );\n const segments = Str.split(\"/\")(afterModules);\n if (Str.startsWith(SCOPE_PREFIX)(afterModules)) {\n return pipe(Arr.take(segments, SCOPED_SEGMENTS), Arr.join(\"/\"));\n }\n return pipe(Arr.take(segments, UNSCOPED_SEGMENTS), Arr.join(\"/\"));\n};\n\nexport const descendantsOf = (node: Node): readonly Node[] =>\n pipe(\n childrenOf(node),\n Arr.flatMap((child) => Arr.prepend(descendantsOf(child), child)),\n );\n\nconst isExternalFile =\n (program: Program) =>\n (sourceFile: SourceFile): boolean =>\n !program.isSourceFileDefaultLibrary(sourceFile) &&\n (Str.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) ||\n program.isSourceFileFromExternalLibrary(sourceFile));\n\nexport const isExternalDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n isExternalFile(program)(declaration.getSourceFile());\n\nexport const isOutsideDeclaration =\n (program: Program) =>\n (declaration: Node): boolean =>\n program.isSourceFileDefaultLibrary(declaration.getSourceFile()) ||\n isExternalDeclaration(program)(declaration);\n\nconst ALIAS_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ImportSpecifier,\n SyntaxKind.ImportClause,\n SyntaxKind.NamespaceImport,\n SyntaxKind.ExportSpecifier,\n SyntaxKind.ImportEqualsDeclaration,\n SyntaxKind.ExportAssignment,\n]);\n\nexport const declarationsOf = (symbol: TypeSymbol): readonly Declaration[] =>\n pipe(\n symbol.declarations,\n Arr.flatMap((handle) => Option.toArray(Option.fromUndefinedOr(handle.resolve()))),\n );\n\nconst isEntityName = (expression: Expression): boolean =>\n isIdentifier(expression) ||\n (isPropertyAccessExpression(expression) && isEntityName(expression.expression));\n\nconst aliasesAnEntity = (declaration: Node): boolean =>\n !isExportAssignment(declaration) || isEntityName(declaration.expression);\n\nconst isAliasDeclaration = (declaration: Node): boolean =>\n ALIAS_KINDS.has(declaration.kind) && aliasesAnEntity(declaration);\n\nexport const resolvedSymbol =\n (checker: Checker) =>\n (symbol: TypeSymbol): TypeSymbol => {\n if (\n !pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isAliasDeclaration(declaration)),\n )\n ) {\n return symbol;\n }\n return checker.getAliasedSymbol(symbol);\n };\n\nexport const symbolAtLocation =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(node));\n\nexport const symbolAt =\n (checker: Checker) =>\n (node: Node): Option.Option<TypeSymbol> =>\n symbolAtLocation(checker)(node).pipe(Option.map(resolvedSymbol(checker)));\n\nexport const referencedSymbols =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] => {\n const identifiers = pipe(\n Arr.prepend(descendantsOf(node), node),\n Arr.filter((candidate) => isIdentifier(candidate)),\n );\n const symbols = pipe(\n checker.getSymbolAtLocation(identifiers),\n Arr.flatMap((symbol) => Option.toArray(Option.fromUndefinedOr(symbol))),\n Arr.map(resolvedSymbol(checker)),\n );\n return uniqueByReference(symbols);\n };\n\nexport const lineOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + POSITION_BASE;\n};\n\nexport const columnOf = (node: Node): number => {\n const sourceFile = node.getSourceFile();\n return (\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).character + POSITION_BASE\n );\n};\n\nexport const contains =\n (outer: Node) =>\n (inner: Node): boolean =>\n outer.getSourceFile().fileName === inner.getSourceFile().fileName &&\n outer.getStart() <= inner.getStart() &&\n inner.getEnd() <= outer.getEnd();\n\nexport const isInsideAny =\n (outers: readonly Node[]) =>\n (node: Node): boolean =>\n pipe(\n outers,\n Arr.some((outer) => contains(outer)(node)),\n );\n\nexport const isTypeDeclaration = (\n declaration: Node,\n): declaration is TypeAliasDeclaration | InterfaceDeclaration | EnumDeclaration =>\n isTypeAliasDeclaration(declaration) ||\n isInterfaceDeclaration(declaration) ||\n isEnumDeclaration(declaration);\n\nconst membersOf = (declaration: Node): readonly Node[] => {\n if (isInterfaceDeclaration(declaration) || isClassDeclaration(declaration)) {\n return declaration.members;\n }\n if (isTypeAliasDeclaration(declaration) && isTypeLiteralNode(declaration.type)) {\n return declaration.type.members;\n }\n return [];\n};\n\nconst isTagNamed =\n (name: string) =>\n (member: Node): boolean =>\n (isPropertySignatureDeclaration(member) || isPropertyDeclaration(member)) &&\n pipe(\n Option.fromUndefinedOr(member.type),\n Option.exists(\n (type) =>\n isLiteralTypeNode(type) && isStringLiteral(type.literal) && type.literal.text === name,\n ),\n );\n\nexport const declaresAType = (declarations: readonly Node[]): boolean =>\n pipe(\n declarations,\n Arr.some((declaration) => isTypeDeclaration(declaration) || isClassDeclaration(declaration)),\n );\n\nexport const carriesTag =\n (name: string) =>\n (declarations: readonly Node[]): boolean =>\n pipe(declarations, Arr.flatMap(membersOf), Arr.some(isTagNamed(name)));\n\nexport const isGenericDeclaration = (declaration: Node): boolean =>\n (isTypeAliasDeclaration(declaration) || isInterfaceDeclaration(declaration)) &&\n Arr.isReadonlyArrayNonEmpty(declaration.typeParameters ?? []);\n\nexport const propertyNamesOf =\n (checker: Checker) =>\n (type: Type): readonly string[] =>\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => property.name),\n );\n\nexport const moduleSpecifierLiteralOf = (statement: Node): Option.Option<StringLiteral> => {\n if (!isImportDeclaration(statement) && !isExportDeclaration(statement)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter(isStringLiteral));\n};\n\nexport const moduleSpecifierOf = (statement: Node): Option.Option<string> =>\n Option.map(moduleSpecifierLiteralOf(statement), (specifier) => specifier.text);\n\nexport const importedModulesOf = (sourceFile: SourceFile): readonly string[] =>\n pipe(\n sourceFile.statements,\n Arr.map((statement) => moduleSpecifierOf(statement)),\n Arr.getSomes,\n );\n","import { Array as Arr, Order, Schema, pipe } from \"effect\";\n\nimport type { Node } from \"./compiler.ts\";\nimport { columnOf, lineOf } from \"./syntax.ts\";\n\nconst RuleNameSchema = Schema.String.check(Schema.isPattern(/^[a-z]+(?:-[a-z]+)*$/u));\n\nexport type RuleName = typeof RuleNameSchema.Type;\n\nconst ProblemSchema = Schema.Struct({\n file: Schema.String,\n line: Schema.Int,\n column: Schema.Int,\n rule: RuleNameSchema,\n message: Schema.String,\n});\n\nexport type Problem = typeof ProblemSchema.Type;\n\nexport const ProblemList = Schema.Array(ProblemSchema);\n\nexport const CANDIDATE_LIMIT = 3;\n\nconst FIRST = 1;\n\nexport interface Position {\n readonly line: number;\n readonly column: number;\n}\n\nexport const problemAtPosition =\n (rule: RuleName) =>\n (file: string, { line, column }: Readonly<Position>, message: string): Problem => ({\n file,\n line,\n column,\n rule,\n message,\n });\n\nexport const problemInFile =\n (rule: RuleName) =>\n (file: string, message: string): Problem =>\n problemAtPosition(rule)(file, { line: FIRST, column: FIRST }, message);\n\nexport interface Finding {\n readonly rule: RuleName;\n readonly message: string;\n}\n\nexport const problemAt =\n ({ rule, message }: Finding) =>\n (node: Node): Problem => ({\n file: node.getSourceFile().fileName,\n line: lineOf(node),\n column: columnOf(node),\n rule,\n message,\n });\n\nconst problemOrder: Order.Order<Problem> = Order.combineAll([\n Order.mapInput(Order.String, (problem: Problem) => problem.file),\n Order.mapInput(Order.Number, (problem: Problem) => problem.line),\n Order.mapInput(Order.Number, (problem: Problem) => problem.column),\n Order.mapInput(Order.String, (problem: Problem) => problem.rule),\n Order.mapInput(Order.String, (problem: Problem) => problem.message),\n]);\n\nconst problemKey = (problem: Problem): string =>\n pipe(\n [problem.file, String(problem.line), String(problem.column), problem.rule, problem.message],\n Arr.join(\"\\0\"),\n );\n\nexport const sortProblems = (problems: readonly Problem[]): readonly Problem[] =>\n Arr.sort(\n Arr.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)),\n problemOrder,\n );\n\nexport const describeFinding = (problem: Problem): string => `[${problem.rule}] ${problem.message}`;\n\nexport const formatProblem =\n (relative: (file: string) => string) =>\n (problem: Problem): string =>\n `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;\n"],"mappings":";;;;;;AAmCA,MAAM,uBAAuB,IAAI,aAAa;AAI9C,MAAa,qBAA2B,UACtCA,MAAI,WAAW,QAAQ,MAAM,UAAU,SAAS,KAAK;AAEvD,MAAa,cAAc,SAAgC;CACzD,MAAM,WAAmB,CAAC;CAC1B,KAAK,cAAc,UAAU;EAC3B,SAAS,KAAK,KAAK;CACrB,CAAC;CACD,OAAO;AACT;AAEA,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAE1B,MAAa,aAAa,aAA6B;CACrD,MAAM,eAAe,KACnB,UACAC,SAAI,YAAY,oBAAoB,GACpC,OAAO,MAAM;EACX,cAAc;EACd,SAAS,UAAUA,SAAI,MAAM,QAAQ,qBAAqB,MAAM,CAAC,CAAC,QAAQ;CAC5E,CAAC,CACH;CACA,MAAM,WAAWA,SAAI,MAAM,GAAG,CAAC,CAAC,YAAY;CAC5C,IAAIA,SAAI,WAAW,YAAY,CAAC,CAAC,YAAY,GAC3C,OAAO,KAAKD,MAAI,KAAK,UAAU,eAAe,GAAGA,MAAI,KAAK,GAAG,CAAC;CAEhE,OAAO,KAAKA,MAAI,KAAK,UAAU,iBAAiB,GAAGA,MAAI,KAAK,GAAG,CAAC;AAClE;AAEA,MAAa,iBAAiB,SAC5B,KACE,WAAW,IAAI,GACfA,MAAI,SAAS,UAAUA,MAAI,QAAQ,cAAc,KAAK,GAAG,KAAK,CAAC,CACjE;AAEF,MAAM,kBACH,aACA,eACC,CAAC,QAAQ,2BAA2B,UAAU,MAC7CC,SAAI,SAAS,oBAAoB,CAAC,CAAC,W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,OAAO,IAAI;CACjB,QAAQ,SAAS,IAAI;CACrB;CACA;AACF;AAEF,MAAM,eAAqC,MAAM,WAAW;CAC1D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,IAAI;CAC/D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,IAAI;CAC/D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,MAAM;CACjE,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,IAAI;CAC/D,MAAM,SAAS,MAAM,SAAS,YAAqB,QAAQ,OAAO;AACpE,CAAC;AAED,MAAM,cAAc,YAClB,KACE;CAAC,QAAQ;CAAM,OAAO,QAAQ,IAAI;CAAG,OAAO,QAAQ,MAAM;CAAG,QAAQ;CAAM,QAAQ;AAAO,GAC1FE,MAAI,KAAK,IAAI,CACf;AAEF,MAAa,gBAAgB,aAC3BA,MAAI,KACFA,MAAI,WAAW,WAAW,MAAM,UAAU,WAAW,IAAI,MAAM,WAAW,KAAK,CAAC,GAChF,YACF;AAEF,MAAa,mBAAmB,YAA6B,IAAI,QAAQ,KAAK,IAAI,QAAQ;AAE1F,MAAa,iBACV,cACA,YACC,GAAG,SAAS,QAAQ,IAAI,EAAE,GAAG,OAAO,QAAQ,IAAI,EAAE,GAAG,OAAO,QAAQ,MAAM,EAAE,GAAG,gBAAgB,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as RepositoryFiles, s as groupOf } from "./repository-files-
|
|
2
|
-
import { C as
|
|
1
|
+
import { r as RepositoryFiles, s as groupOf } from "./repository-files-C8B7lrka.mjs";
|
|
2
|
+
import { C as childrenOf, O as stringsIn, S as KeySchema, w as keyName } from "./workspace-projects-wllEd2HL.mjs";
|
|
3
3
|
import { Array, Effect, Option, Predicate, Record, Schema, String, pipe } from "effect";
|
|
4
4
|
import { readWantedLockfile } from "@r_masseater/masseater-utils/kestrion/pnpm";
|
|
5
5
|
import { PACKAGE_JSON_FILE, binEntriesOf, exportEntriesOf, targetsIn } from "@r_masseater/masseater-utils/kestrion";
|
|
@@ -138,6 +138,27 @@ const splitFrontmatter = (source) => pipe(Option.fromNullishOr(FRONTMATTER.exec(
|
|
|
138
138
|
const INDEX_ROLE = "index";
|
|
139
139
|
/** @internal */
|
|
140
140
|
const isIndexSkill = ({ fields }) => Predicate.isObject(fields["metadata"]) && Predicate.hasProperty(fields["metadata"], "role") && fields["metadata"].role === INDEX_ROLE;
|
|
141
|
+
// src/entities/workspace/model/mod-directories.ts
|
|
142
|
+
const HOOKS_FILE = "hooks/hooks.json";
|
|
143
|
+
const Modules = Schema.String.pipe(Schema.Array, Schema.optional);
|
|
144
|
+
const HooksFile = Schema.fromJsonString(Schema.Struct({ modules: Modules }));
|
|
145
|
+
const decodeHooks = Schema.decodeUnknownOption(HooksFile);
|
|
146
|
+
const PARENT = 1;
|
|
147
|
+
const directoryOf = (module) => {
|
|
148
|
+
const parts = pipe(String.split(`hooks/${module}`, "/"), Array.filter((part) => part !== "" && part !== "."));
|
|
149
|
+
return `${Array.join(Array.dropRight(parts, PARENT), "/")}/`;
|
|
150
|
+
};
|
|
151
|
+
/** @internal */
|
|
152
|
+
const modDirectoriesOf = (hooks) => pipe(decodeHooks(hooks), Option.flatMap(({ modules }) => Option.fromNullishOr(modules)), Option.getOrElse(() => []), Array.map(directoryOf), Array.dedupe);
|
|
153
|
+
/** @internal */
|
|
154
|
+
const modDirectories = Effect.fn("modDirectories")(function* modDirectories(directory) {
|
|
155
|
+
const files = yield* RepositoryFiles;
|
|
156
|
+
const hooks = yield* files.readFile(files.join(directory, HOOKS_FILE));
|
|
157
|
+
return Option.match(hooks, {
|
|
158
|
+
onNone: () => [],
|
|
159
|
+
onSome: modDirectoriesOf
|
|
160
|
+
});
|
|
161
|
+
});
|
|
141
162
|
// src/entities/package/model/public-entries.ts
|
|
142
163
|
const SOURCE = /\.[cm]?tsx?$/u;
|
|
143
164
|
const BUILT = /\.(?:d\.)?[cm]?[jt]s$/u;
|
|
@@ -274,6 +295,6 @@ const publishedWorkspaces = Effect.fn("publishedWorkspaces")(function* published
|
|
|
274
295
|
...budgetOf(budget)
|
|
275
296
|
})), Option.toArray)));
|
|
276
297
|
});
|
|
277
|
-
export {
|
|
298
|
+
export { shadcnUiIn as _, workspaceConfigs as a, publicEntriesOf as c, FRONTMATTER as d, splitFrontmatter as f, deployEntries as g, bundledEntries as h, publishedWorkspaces as i, modDirectories as l, workspaceLinks as m, entriesOf as n, entryNameOf as o, linkedPaths as p, packedWorkspaces as r, isBinEntry as s, PackEntry as t, isIndexSkill as u, shadcnUiOf as v, prefixed as y };
|
|
278
299
|
|
|
279
|
-
//# sourceMappingURL=published-
|
|
300
|
+
//# sourceMappingURL=published-u44g9ha6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"published-u44g9ha6.mjs","names":["SEPARATOR","Str","Str","Rec","Arr","READ_CONCURRENCY","Arr","Arr","Rec","Str","parse","Str","Str","Arr","Str","Arr","Arr","Str","Rec"],"sources":["../src/entities/workspace/model/workspace-patterns.ts","../src/entities/workspace/model/shadcn-ui.ts","../src/entities/workspace/model/deploy-entries.ts","../src/entities/workspace/model/locked-links.ts","../src/shared/lib/frontmatter.ts","../src/shared/lib/index-skill.ts","../src/entities/workspace/model/mod-directories.ts","../src/entities/package/model/public-entries.ts","../src/entities/package/model/published.ts"],"sourcesContent":["import { String as Str } from \"effect\";\n\nconst SEPARATOR = \"/\";\nconst NEGATION = \"!\";\nconst RELATIVE = \"./\";\n\nexport const withoutRelative = (target: string): string => {\n if (Str.startsWith(RELATIVE)(target)) {\n return Str.slice(RELATIVE.length)(target);\n }\n return target;\n};\n\nexport const prefixed =\n (directory: string) =>\n (pattern: string): string => {\n if (Str.startsWith(NEGATION)(pattern)) {\n return `${NEGATION}${directory}${SEPARATOR}${Str.slice(NEGATION.length)(pattern)}`;\n }\n return `${directory}${SEPARATOR}${withoutRelative(pattern)}`;\n };\n","import { PACKAGE_JSON_FILE } from \"@r_masseater/masseater-utils/kestrion\";\nimport { decodePackageJson } from \"@r_masseater/masseater-utils/kestrion/npm\";\nimport { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { prefixed, withoutRelative } from \"./workspace-patterns.ts\";\n\nconst SHADCN_FILE = \"components.json\";\nconst WILDCARD = \"*\";\nconst EVERYTHING = \"/**\";\n\nconst ShadcnConfig = Schema.Struct({ aliases: Schema.Struct({ ui: Schema.String }) });\nconst decodeImports = Schema.decodeUnknownOption(Schema.Record(Schema.String, Schema.String));\nconst decodeShadcnConfig = Schema.decodeUnknownOption(Schema.fromJsonString(ShadcnConfig));\n\nconst withoutWildcard = Str.replace(WILDCARD, \"\");\n\nconst importTarget =\n (alias: string) =>\n ([key, target]: readonly [string, string]): Option.Option<string> => {\n if (!Str.endsWith(WILDCARD)(key)) {\n return Option.some(target).pipe(Option.filter(() => key === alias));\n }\n const prefix = withoutWildcard(key);\n if (!Str.startsWith(prefix)(alias)) {\n return Option.none();\n }\n return Option.some(`${withoutWildcard(target)}${Str.slice(prefix.length)(alias)}`);\n };\n\nconst resolvedAlias = (\n imports: Readonly<Record<string, string>>,\n alias: string,\n): Option.Option<string> =>\n pipe(Rec.toEntries(imports), Arr.findFirst(importTarget(alias)), Option.map(withoutRelative));\n\nexport type ShadcnUi = Readonly<{\n file: string;\n alias: string;\n target: Option.Option<string>;\n}>;\n\nexport const shadcnUiOf = Effect.fn(\"shadcnUiOf\")(function* shadcnUiOf(\n root: string,\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, directory, SHADCN_FILE);\n const configText = yield* files.readFile(file);\n const manifestText = yield* files.readFile(files.join(root, directory, PACKAGE_JSON_FILE));\n const imports = pipe(\n manifestText,\n Option.flatMap(decodePackageJson),\n Option.flatMap((manifest) => decodeImports(manifest.imports)),\n );\n return pipe(\n configText,\n Option.flatMap(decodeShadcnConfig),\n Option.map(({ aliases }): ShadcnUi => ({\n file,\n alias: aliases.ui,\n target: pipe(\n imports,\n Option.flatMap((map) => resolvedAlias(map, aliases.ui)),\n ),\n })),\n );\n});\n\nexport const shadcnUiIn = Effect.fn(\"shadcnUiIn\")(function* shadcnUiIn(\n root: string,\n directory: string,\n) {\n const found = yield* shadcnUiOf(root, directory);\n return pipe(\n found,\n Option.map(\n ({ alias, target }) =>\n `${prefixed(directory)(Option.getOrElse(target, () => alias))}${EVERYTHING}`,\n ),\n );\n});\n","import { Array as Arr, Effect, Option, Predicate, Schema, pipe } from \"effect\";\nimport { parse } from \"vite-plus\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { KeySchema, childrenOf, keyName, stringsIn } from \"./config-literal.ts\";\n\nconst MAIN_KEY = \"main\";\nconst FRAMEWORK_SITES = \"Website\";\nconst READ_CONCURRENCY = 16;\nconst SCRIPT = /\\.[cm]?tsx?$/u;\nconst SKIPPED = /\\.test\\.|\\.d\\.[cm]?ts$/u;\nconst ALCHEMY_IMPORT = /from\\s+[\"'](?:alchemy|@alchemy\\.run)(?:\\/[^\"']*)?[\"']/u;\nconst MAIN_PROPERTY = /\\bmain\\s*:/u;\nconst decodeKey = Schema.decodeUnknownOption(KeySchema);\nconst SiteNamespace = Schema.Struct({\n type: Schema.Literal(\"Identifier\"),\n name: Schema.Literal(FRAMEWORK_SITES),\n});\nconst SiteResource = Schema.Struct({\n type: Schema.Literal(\"MemberExpression\"),\n object: SiteNamespace,\n});\nconst FrameworkSite = Schema.Struct({\n type: Schema.Literal(\"CallExpression\"),\n callee: SiteResource,\n});\nconst decodeFrameworkSite = Schema.decodeUnknownOption(FrameworkSite);\n\nconst isMainProperty = (node: Readonly<Record<string, unknown>>): boolean =>\n node[\"type\"] === \"Property\" &&\n pipe(\n decodeKey(node[\"key\"]),\n Option.exists((key) => keyName(key) === MAIN_KEY),\n );\n\ntype Skip = (node: unknown) => boolean;\n\nconst skipNothing: Skip = () => false;\n\nconst isFrameworkSite: Skip = (node) => Option.isSome(decodeFrameworkSite(node));\n\nconst mainTargetsIn = (skip: Skip): ((node: unknown) => readonly string[]) => {\n const visit = (node: unknown): readonly string[] => {\n if (skip(node)) {\n return [];\n }\n if (Predicate.isReadonlyObject(node) && isMainProperty(node)) {\n return pipe(\n stringsIn(node[\"value\"]),\n Arr.head,\n Option.map(({ text }) => text),\n Option.toArray,\n );\n }\n return pipe(childrenOf(node), Arr.flatMap(visit));\n };\n return visit;\n};\n\ninterface Declaring {\n readonly root: string;\n readonly file: string;\n readonly skip: Skip;\n}\n\nconst declaredIn = Effect.fn(\"declaredIn\")(function* declaredIn({ root, file, skip }: Declaring) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(root, file));\n if (Option.isNone(text) || !ALCHEMY_IMPORT.test(text.value) || !MAIN_PROPERTY.test(text.value)) {\n return [];\n }\n const parsed = yield* Effect.promise(() => parse(file, text.value, { lang: \"ts\" }));\n return pipe(\n mainTargetsIn(skip)(parsed.program),\n Arr.map((target) => files.join(files.dirname(file), target)),\n );\n});\n\nconst entriesOutside = Effect.fn(\"entriesOutside\")(function* entriesOutside(\n root: string,\n skip: Skip,\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.listedFiles(root);\n const declaring = pipe(\n listed,\n Arr.filter((file) => SCRIPT.test(file) && !SKIPPED.test(file)),\n );\n const found = yield* Effect.forEach(declaring, (file) => declaredIn({ root, file, skip }), {\n concurrency: READ_CONCURRENCY,\n });\n return pipe(\n Arr.flatten(found),\n Arr.filter((file) => Arr.contains(listed, file)),\n Arr.dedupe,\n );\n});\n\nexport const deployEntries = Effect.fn(\"deployEntries\")(function* deployEntries(root: string) {\n return yield* entriesOutside(root, skipNothing);\n});\n\nexport const bundledEntries = Effect.fn(\"bundledEntries\")(function* bundledEntries(root: string) {\n return yield* entriesOutside(root, isFrameworkSite);\n});\n","import { readWantedLockfile } from \"@r_masseater/masseater-utils/kestrion/pnpm\";\nimport type { ResolvedDependencies } from \"@r_masseater/masseater-utils/kestrion/pnpm\";\nimport { Array as Arr, Effect, Option, Record as Rec, String as Str, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst LINK = \"link:\";\n\nexport interface WorkspaceLink {\n readonly from: string;\n readonly to: string;\n}\n\nexport const linkedPaths = (\n sections: readonly (ResolvedDependencies | undefined)[],\n): readonly string[] =>\n pipe(\n sections,\n Arr.flatMap((resolved) => Rec.values(resolved ?? {})),\n Arr.filter(Str.startsWith(LINK)),\n Arr.map((reference) => Str.slice(LINK.length)(reference)),\n );\n\n/** @internal */\nexport const workspaceLinks = Effect.fn(\"workspaceLinks\")(function* workspaceLinks(root: string) {\n const files = yield* RepositoryFiles;\n const lockfile = yield* readWantedLockfile(root);\n const linksOf = (id: string, paths: readonly string[]): readonly WorkspaceLink[] => {\n const from = files.relative(root, files.join(root, id));\n return pipe(\n paths,\n Arr.map((path): WorkspaceLink => ({\n from,\n to: files.relative(root, files.join(root, id, path)),\n })),\n );\n };\n return pipe(\n lockfile,\n Option.map(({ importers }) =>\n pipe(\n Rec.toEntries(importers),\n Arr.flatMap(([id, project]) =>\n linksOf(\n id,\n linkedPaths([\n project.dependencies,\n project.devDependencies,\n project.optionalDependencies,\n ]),\n ),\n ),\n ),\n ),\n Option.getOrElse((): readonly WorkspaceLink[] => []),\n );\n});\n","import { groupOf } from \"@masseater.dev/lint-host/collections\";\nimport { Option, Schema, String as Str, pipe } from \"effect\";\nimport { parse } from \"yaml\";\n\nexport const FRONTMATTER = /^---\\n(?<yaml>[\\s\\S]*?)\\n---\\n/u;\n\nconst START = 0;\nconst Fields = Schema.Record(Schema.String, Schema.Unknown);\nconst decodeFields = Schema.decodeUnknownOption(Fields);\n\nexport interface Frontmatter {\n readonly fields: typeof Fields.Type;\n readonly body: string;\n}\n\nexport const splitFrontmatter = (source: string): Option.Option<Frontmatter> =>\n pipe(\n Option.fromNullishOr(FRONTMATTER.exec(source)),\n Option.flatMap((found) =>\n pipe(\n groupOf(\"yaml\")(found),\n Option.flatMap(Option.liftThrowable((yaml: string): unknown => parse(yaml))),\n Option.flatMap(decodeFields),\n Option.map((fields): Frontmatter => ({\n fields,\n body: Str.slice(found[START].length)(source),\n })),\n ),\n ),\n );\n","import { Predicate } from \"effect\";\n\nimport type { Frontmatter } from \"./frontmatter.ts\";\n\nconst INDEX_ROLE = \"index\";\n\n/** @internal */\nexport const isIndexSkill = ({ fields }: Frontmatter): boolean =>\n Predicate.isObject(fields[\"metadata\"]) &&\n Predicate.hasProperty(fields[\"metadata\"], \"role\") &&\n fields[\"metadata\"].role === INDEX_ROLE;\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst HOOKS_FILE = \"hooks/hooks.json\";\nconst Modules = Schema.String.pipe(Schema.Array, Schema.optional);\nconst HooksFile = Schema.fromJsonString(Schema.Struct({ modules: Modules }));\nconst decodeHooks = Schema.decodeUnknownOption(HooksFile);\nconst PARENT = 1;\n\nconst directoryOf = (module: string): string => {\n const parts = pipe(\n Str.split(`hooks/${module}`, \"/\"),\n Arr.filter((part) => part !== \"\" && part !== \".\"),\n );\n return `${Arr.join(Arr.dropRight(parts, PARENT), \"/\")}/`;\n};\n\n/** @internal */\nexport const modDirectoriesOf = (hooks: string): readonly string[] =>\n pipe(\n decodeHooks(hooks),\n Option.flatMap(({ modules }) => Option.fromNullishOr(modules)),\n Option.getOrElse((): readonly string[] => []),\n Arr.map(directoryOf),\n Arr.dedupe,\n );\n\n/** @internal */\nexport const modDirectories = Effect.fn(\"modDirectories\")(function* modDirectories(\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const hooks = yield* files.readFile(files.join(directory, HOOKS_FILE));\n return Option.match(hooks, { onNone: (): readonly string[] => [], onSome: modDirectoriesOf });\n});\n","import { binEntriesOf, exportEntriesOf, targetsIn } from \"@r_masseater/masseater-utils/kestrion\";\nimport type { PackageJson } from \"@r_masseater/masseater-utils/kestrion\";\nimport { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport type { PackEntrySource } from \"./published.ts\";\n\nconst SOURCE = /\\.[cm]?tsx?$/u;\nconst BUILT = /\\.(?:d\\.)?[cm]?[jt]s$/u;\nconst OUT_DIRECTORY = /^(?:\\.\\/)?[^/]+\\//u;\nconst DECLARATION = \".d.\";\nconst BIN_LABEL = \"bin\";\n\nexport interface PublicEntry {\n readonly label: string;\n readonly source: string;\n}\n\nexport type EntryManifest = Pick<PackageJson, \"name\" | \"exports\" | \"bin\">;\n\nexport interface EntryLookup {\n readonly manifest: EntryManifest;\n readonly join: (target: string) => string;\n readonly packEntries: readonly PackEntrySource[];\n}\n\nexport const isBinEntry = ({ label }: PublicEntry): boolean =>\n Str.startsWith(`${BIN_LABEL} `)(label);\n\nconst binsOf = (manifest: EntryManifest): readonly (readonly [string, unknown])[] =>\n pipe(\n binEntriesOf(manifest),\n Arr.map(([name, target]) => [`${BIN_LABEL} ${name}`, target] as const),\n );\n\nexport const entryNameOf = (target: string): string =>\n pipe(target, Str.replace(OUT_DIRECTORY, \"\"), Str.replace(BUILT, \"\"));\n\nconst sourceOf =\n ({ join, packEntries }: EntryLookup) =>\n (target: string): Option.Option<string> => {\n if (SOURCE.test(target) && !Str.includes(DECLARATION)(target)) {\n return Option.some(join(target));\n }\n const name = entryNameOf(target);\n return pipe(\n packEntries,\n Arr.findFirst((entry) => entry.name === name),\n Option.map((entry) => entry.source),\n );\n };\n\nexport const publicEntriesOf = (lookup: EntryLookup): readonly PublicEntry[] =>\n pipe(\n [...exportEntriesOf(lookup.manifest.exports), ...binsOf(lookup.manifest)],\n Arr.flatMap(([label, held]) =>\n pipe(\n targetsIn(held),\n Arr.map(sourceOf(lookup)),\n Arr.getSomes,\n Arr.map((source) => ({ label, source })),\n ),\n ),\n Arr.dedupeWith((left, right) => left.label === right.label && left.source === right.source),\n );\n","import { PACKAGE_JSON_FILE } from \"@r_masseater/masseater-utils/kestrion\";\nimport { decodePackageJson } from \"@r_masseater/masseater-utils/kestrion/npm\";\nimport {\n Array as Arr,\n Effect,\n Option,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst CONFIG_FILE = \"vite.config.ts\";\nconst SEPARATOR = \"/\";\nconst READ_CONCURRENCY = 16;\nconst SOURCE_EXTENSION = /\\.[cm]?tsx?$/u;\nconst BYTE = 1;\nconst KILOBYTE = 1000;\nconst MEGABYTE = 1_000_000;\nconst UNIT_BYTES = [\n [\"B\", BYTE],\n [\"kB\", KILOBYTE],\n [\"MB\", MEGABYTE],\n] as const;\n\nconst SizeText = Schema.TemplateLiteralParser([\n Schema.Finite,\n \" \",\n Schema.Literals([\"B\", \"kB\", \"MB\"]),\n]);\nexport const PackEntry = Schema.Union([\n Schema.String,\n Schema.Array(Schema.String),\n Schema.Record(Schema.String, Schema.String),\n]);\nconst BundledPattern = Schema.Union([Schema.String, Schema.instanceOf(RegExp)]);\nconst AlwaysBundle = Schema.Union([BundledPattern, Schema.Array(BundledPattern)]);\nconst PackDeps = Schema.Struct({ alwaysBundle: Schema.optional(AlwaysBundle) });\nconst PackSettings = Schema.Struct({\n entry: Schema.optional(PackEntry),\n deps: Schema.optional(PackDeps),\n});\nconst PackList = Schema.Union([PackSettings, Schema.Array(PackSettings)]);\nconst isEntryList = Schema.is(Schema.Array(Schema.String));\nconst PackConfig = Schema.Struct({ pack: Schema.optional(PackList) });\nconst BudgetConfig = Schema.Struct({\n msch: Schema.Struct({ publish: Schema.Struct({ installSize: SizeText }) }),\n});\n\nconst taggedError = Schema.TaggedError;\n\nclass WorkspaceConfigUnreadable extends taggedError<\n WorkspaceConfigUnreadable,\n { readonly brand: unique symbol }\n>()(\"WorkspaceConfigUnreadable\", { file: Schema.String }) {}\n\nexport interface PackEntrySource {\n readonly name: string;\n readonly source: string;\n}\n\nexport interface PackedWorkspace {\n readonly directory: string;\n readonly configFile: string;\n readonly packEntries: readonly PackEntrySource[];\n readonly alwaysBundle: readonly (string | RegExp)[];\n}\n\nexport interface PublishedWorkspace extends PackedWorkspace {\n readonly installSize: string;\n readonly installBudget: number;\n}\n\nconst bytesPer = (unit: string): number =>\n pipe(\n UNIT_BYTES,\n Arr.findFirst(([name]) => name === unit),\n Option.map(([, bytes]) => bytes),\n Option.getOrElse(() => Number.NaN),\n );\n\nconst nameOf = (source: string): string =>\n pipe(\n Str.split(source, SEPARATOR),\n Arr.last,\n Option.getOrElse(() => source),\n Str.replace(SOURCE_EXTENSION, \"\"),\n );\n\nexport const entriesOf = (entry: typeof PackEntry.Type): readonly PackEntrySource[] => {\n if (Predicate.isString(entry)) {\n return [{ name: nameOf(entry), source: entry }];\n }\n if (isEntryList(entry)) {\n return pipe(\n entry,\n Arr.map((source) => ({ name: nameOf(source), source })),\n );\n }\n return pipe(\n Rec.toEntries(entry),\n Arr.map(([name, source]) => ({ name, source })),\n );\n};\n\nconst packSettingsOf = (pack: typeof PackConfig.Type.pack): readonly (typeof PackSettings.Type)[] =>\n pipe(\n Option.fromUndefinedOr(pack),\n Option.map(Arr.ensure),\n Option.getOrElse((): readonly (typeof PackSettings.Type)[] => []),\n );\n\nconst packEntriesOf = (pack: typeof PackConfig.Type.pack): readonly PackEntrySource[] =>\n pipe(\n packSettingsOf(pack),\n Arr.flatMap((setting) =>\n pipe(\n Option.fromUndefinedOr(setting.entry),\n Option.match({ onNone: () => [], onSome: entriesOf }),\n ),\n ),\n );\n\nconst alwaysBundleOf = (pack: typeof PackConfig.Type.pack): readonly (string | RegExp)[] =>\n pipe(\n packSettingsOf(pack),\n Arr.flatMap((setting) =>\n pipe(\n Option.fromUndefinedOr(setting.deps),\n Option.flatMap((deps) => Option.fromUndefinedOr(deps.alwaysBundle)),\n Option.map(Arr.ensure),\n Option.getOrElse((): readonly (string | RegExp)[] => []),\n ),\n ),\n Arr.dedupe,\n );\n\nconst settingsIn = Effect.fn(\"settingsIn\")(function* settingsIn(file: string) {\n const config = yield* Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: () => WorkspaceConfigUnreadable.make({ file }),\n }).pipe(Effect.option);\n return config;\n});\n\nconst isPublicPackage = Effect.fn(\"isPublicPackage\")(function* isPublicPackage(directory: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(directory, PACKAGE_JSON_FILE));\n return pipe(\n text,\n Option.flatMap(decodePackageJson),\n Option.exists((manifest) => manifest.private !== true),\n );\n});\n\nconst packedWorkspaceOf =\n (directory: string, configFile: string, join: (source: string) => string) =>\n ({ pack }: typeof PackConfig.Type): PackedWorkspace => ({\n directory,\n configFile,\n packEntries: pipe(\n packEntriesOf(pack),\n Arr.map((entry) => ({ name: entry.name, source: join(entry.source) })),\n ),\n alwaysBundle: alwaysBundleOf(pack),\n });\n\nconst budgetOf = ({\n msch,\n}: typeof BudgetConfig.Type): Pick<PublishedWorkspace, \"installSize\" | \"installBudget\"> => {\n const [amount, , unit] = msch.publish.installSize;\n return { installSize: `${amount} ${unit}`, installBudget: amount * bytesPer(unit) };\n};\n\nconst packedIn = Effect.fn(\"packedIn\")(function* packedIn(root: string, configName: string) {\n const files = yield* RepositoryFiles;\n const configFile = files.join(root, configName);\n const directory = files.dirname(configFile);\n const isPublic = yield* isPublicPackage(directory);\n if (!isPublic) {\n return Option.none<readonly [PackedWorkspace, unknown]>();\n }\n const config = yield* settingsIn(configFile);\n return pipe(\n config,\n Option.flatMap((found) =>\n pipe(\n Schema.decodeUnknownOption(PackConfig)(found),\n Option.map(\n packedWorkspaceOf(directory, configFile, (source) => files.join(directory, source)),\n ),\n Option.map((workspace) => [workspace, found] as const),\n ),\n ),\n );\n});\n\n/** @internal */\nexport const workspaceConfigs = Effect.fn(\"workspaceConfigs\")(function* workspaceConfigs(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n return pipe(\n names,\n Arr.filter((name) => files.basename(name) === CONFIG_FILE && Str.includes(SEPARATOR)(name)),\n );\n});\n\nconst packedPairs = Effect.fn(\"packedPairs\")(function* packedPairs(root: string) {\n const configs = yield* workspaceConfigs(root);\n const found = yield* Effect.forEach(configs, (name) => packedIn(root, name), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n\n/** @internal */\nexport const packedWorkspaces = Effect.fn(\"packedWorkspaces\")(function* packedWorkspaces(\n root: string,\n) {\n const pairs = yield* packedPairs(root);\n return pipe(\n pairs,\n Arr.map(([workspace]) => workspace),\n );\n});\n\n/** @internal */\nexport const publishedWorkspaces = Effect.fn(\"publishedWorkspaces\")(function* publishedWorkspaces(\n root: string,\n) {\n const pairs = yield* packedPairs(root);\n return pipe(\n pairs,\n Arr.flatMap(([workspace, config]) =>\n pipe(\n Schema.decodeUnknownOption(BudgetConfig)(config),\n Option.map((budget): PublishedWorkspace => ({ ...workspace, ...budgetOf(budget) })),\n Option.toArray,\n ),\n ),\n );\n});\n"],"mappings":";;;;;;;;;AAEA,MAAMA,cAAY;AAClB,MAAM,WAAW;AACjB,MAAM,WAAW;AAEjB,MAAa,mBAAmB,WAA2B;CACzD,IAAIC,OAAI,WAAW,QAAQ,CAAC,CAAC,MAAM,GACjC,OAAOA,OAAI,MAAM,CAAe,CAAC,CAAC,MAAM;CAE1C,OAAO;AACT;AAEA,MAAa,YACV,eACA,YAA4B;CAC3B,IAAIA,OAAI,WAAW,QAAQ,CAAC,CAAC,OAAO,GAClC,OAAO,GAAG,WAAW,YAAYD,cAAYC,OAAI,MAAM,CAAe,CAAC,CAAC,OAAO;CAEjF,OAAO,GAAG,YAAYD,cAAY,gBAAgB,OAAO;AAC3D;;ACZF,MAAM,cAAc;AACpB,MAAM,WAAW;AACjB,MAAM,aAAa;AAEnB,MAAM,eAAe,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,EAAE,IAAI,OAAO,OAAO,CAAC,EAAE,CAAC;AACpF,MAAM,gBAAgB,OAA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,YAAY,IAAI;CAC3C,OAAO,KACL,OACAA,MAAI,QAAQ,SAAS,MAAM,SAAS,IAAI,MAAM,eAAeC,OAAI,SAAS,SAAS,CAAC,CAAC,IAAI,CAAC,CAC5F;AACF,CAAC;AAED,MAAM,cAAc,OAAO,GAAG,aAAa,CAAC,CAAC,UAAU,YAAY,MAAc;CAC/E,MAAM,UAAU,OAAO,iBAAiB,IAAI;CAC5C,MAAM,QAAQ,OAAO,OAAO,QAAQ,UAAU,SAAS,SAAS,MAAM,IAAI,GAAG,EAC3E,aAAa,iBACf,CAAC;CACD,OAAOD,MAAI,SAAS,KAAK;AAC3B,CAAC;;AAGD,MAAa,mBAAmB,OAAO,GAAG,kBAAkB,CAAC,CAAC,UAAU,iBACtE,MACA;CACA,MAAM,QAAQ,OAAO,YAAY,IAAI;CACrC,OAAO,KACL,OACAA,MAAI,KAAK,CAAC,eAAe,SAAS,CACpC;AACF,CAAC;;AAGD,MAAa,sBAAsB,OAAO,GAAG,qBAAqB,CAAC,CAAC,UAAU,oBAC5E,MACA;CACA,MAAM,QAAQ,OAAO,YAAY,IAAI;CACrC,OAAO,KACL,OACAA,MAAI,SAAS,CAAC,WAAW,YACvB,KACE,OAAO,oBAAoB,YAAY,CAAC,CAAC,MAAM,GAC/C,OAAO,KAAK,YAAgC;EAAE,GAAG;EAAW,GAAG,SAAS,MAAM;CAAE,EAAE,GAClF,OAAO,OACT,CACF,CACF;AACF,CAAC"}
|
|
@@ -163,6 +163,7 @@ const nodeRepositoryFiles = Layer.effect(RepositoryFiles, Effect.gen(function* n
|
|
|
163
163
|
...gitHistory(gitText),
|
|
164
164
|
readLink: (file) => fs.readLink(file).pipe(Effect.option),
|
|
165
165
|
readFile: (file) => fs.readFileString(file).pipe(Effect.option),
|
|
166
|
+
readBytes: (file) => fs.readFile(file).pipe(Effect.option),
|
|
166
167
|
exists: (file) => fs.exists(file).pipe(Effect.orElseSucceed(() => false)),
|
|
167
168
|
realPath: (file) => fs.realPath(file).pipe(Effect.orElseSucceed(() => file)),
|
|
168
169
|
readDirectory: (directory) => fs.readDirectory(directory).pipe(Effect.orElseSucceed(() => [])),
|
|
@@ -178,4 +179,4 @@ const nodeRepositoryFiles = Layer.effect(RepositoryFiles, Effect.gen(function* n
|
|
|
178
179
|
})).pipe(Layer.provide(nodeServicesLayer), Layer.provide(Digest.layerWebCrypto));
|
|
179
180
|
export { nodeServicesLayer as a, nodeRepositoryFiles as i, NODE_MODULES as n, TOOL_NAME as o, RepositoryFiles as r, groupOf as s, MSCH_CACHE as t };
|
|
180
181
|
|
|
181
|
-
//# sourceMappingURL=repository-files-
|
|
182
|
+
//# sourceMappingURL=repository-files-C8B7lrka.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-files-C8B7lrka.mjs","names":["Str","Str","Arr"],"sources":["../../lint-host/src/shared/lib/collections.ts","../src/shared/lib/tool-name.ts","../src/shared/lib/repository-files.ts"],"sourcesContent":["import { Array as Arr, Option, Order, Record as Rec, String as Str, pipe } from \"effect\";\n\nconst byKey = Order.mapInput(Str.Order, ([key]: readonly [string, unknown]) => key);\n\nexport const sortedRecord = <Value>(\n entries: readonly (readonly [string, Value])[],\n): Readonly<Record<string, Value>> => Rec.fromEntries(Arr.sort(entries, byKey));\n\nconst NEXT = 1;\n\nexport interface Grouped<Head, Item> {\n readonly head: Head;\n readonly items: readonly Item[];\n}\n\nexport const groupedUnder =\n <Item, Head>(asHead: (item: Item) => Option.Option<Head>) =>\n (closes: (head: Head, item: Item) => boolean) =>\n (items: readonly Item[]): readonly Grouped<Head, Item>[] =>\n pipe(\n items,\n Arr.flatMap((item, index) =>\n pipe(\n asHead(item),\n Option.map((head): Grouped<Head, Item> => ({\n head,\n items: pipe(\n items,\n Arr.drop(index + NEXT),\n Arr.takeWhile((next) => !closes(head, next)),\n ),\n })),\n Option.toArray,\n ),\n ),\n );\n\nexport const ancestorsBy =\n <Node>(parentOf: (node: Node) => Option.Option<Node>) =>\n (node: Node): readonly Node[] =>\n Arr.unfold(parentOf(node), (current) =>\n pipe(\n current,\n Option.map((found) => [found, parentOf(found)] as const),\n ),\n );\n\nexport const groupOf =\n (name: string) =>\n (found: RegExpMatchArray | null): Option.Option<string> =>\n pipe(\n Option.fromNullishOr(found),\n Option.flatMap((match) => Option.fromNullishOr(match.groups)),\n Option.flatMap((groups) => Option.fromNullishOr(groups[name])),\n );\n","export const TOOL_NAME = \"msch\";\n","import {\n NodeChildProcessSpawner,\n NodeFileSystem,\n NodePath,\n NodeStdio,\n} from \"@effect/platform-node-shared\";\nimport { groupOf } from \"@masseater.dev/lint-host/collections\";\nimport { CACHE_DIRECTORY_NAME } from \"@r_masseater/masseater-utils/plugin-kit\";\nimport {\n Array as Arr,\n Context,\n Effect,\n FileSystem,\n Layer,\n Option,\n Path,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport { Digest } from \"effect/crypto\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { TOOL_NAME } from \"#/shared/lib/tool-name.ts\";\n\n/** @internal */\nexport const nodeServicesLayer = Layer.provideMerge(\n NodeChildProcessSpawner.layer,\n Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeStdio.layer),\n);\n\nconst MISSING_SIZE = 0;\nconst MILLISECONDS = 1000;\nconst GENERATED_PATHSPEC = \":(attr:linguist-generated)\";\nconst OWNED_PATHSPECS = [\":(exclude,attr:linguist-vendored)\", \":(exclude,attr:linguist-generated)\"];\nexport const NODE_MODULES = \"node_modules\";\n\n/** @internal */\nexport const MSCH_CACHE = [NODE_MODULES, CACHE_DIRECTORY_NAME, TOOL_NAME] as const;\nconst LISTED_ARGS = [\"--cached\", \"--others\", \"--exclude-standard\", `--exclude=${NODE_MODULES}/`];\nconst IGNORED_ARGS = [\"--others\", \"--ignored\", \"--exclude-standard\"];\nconst TRACKED_ARGS = [\"--cached\"];\nconst STAGED_ARGS = [\"--stage\"];\nconst HISTORY_ARGS = [\n \"log\",\n \"--max-count=300\",\n \"--no-merges\",\n \"--format=%n%h %as %s\",\n \"--name-only\",\n];\nconst LINK_ENTRY = /^120000 \\S+ \\d+\\t(?<name>.+)$/u;\n\nexport class RepositoryFiles extends Context.Service<\n RepositoryFiles,\n {\n readonly readFile: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly readBytes: (file: string) => Effect.Effect<Option.Option<Uint8Array>>;\n readonly exists: (file: string) => Effect.Effect<boolean>;\n readonly realPath: (file: string) => Effect.Effect<string>;\n readonly readDirectory: (directory: string) => Effect.Effect<readonly string[]>;\n readonly walkDirectory: (directory: string) => Effect.Effect<readonly string[]>;\n readonly writeFile: (file: string, text: string) => Effect.Effect<void>;\n readonly removeFile: (file: string) => Effect.Effect<void>;\n readonly hash: (text: string) => Effect.Effect<string>;\n readonly hashFile: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly generatedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly listedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly ownedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly linkedFiles: (root: string) => Effect.Effect<readonly string[]>;\n readonly readLink: (file: string) => Effect.Effect<Option.Option<string>>;\n readonly mergeBase: (root: string, revision: string) => Effect.Effect<Option.Option<string>>;\n readonly originUrl: (root: string) => Effect.Effect<Option.Option<string>>;\n readonly history: (root: string) => Effect.Effect<string>;\n readonly changedFiles: (root: string, revision: string) => Effect.Effect<readonly string[]>;\n readonly commitMessages: (root: string, revision: string) => Effect.Effect<readonly string[]>;\n readonly readAtRevision: (\n root: string,\n revision: string,\n name: string,\n ) => Effect.Effect<Option.Option<string>>;\n readonly committedAt: (root: string, name: string) => Effect.Effect<Option.Option<number>>;\n readonly matchingFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly trackedFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly ignoredPaths: (\n root: string,\n paths: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly ignoredFiles: (\n root: string,\n pathspecs: readonly string[],\n ) => Effect.Effect<readonly string[]>;\n readonly isDirectory: (file: string) => Effect.Effect<Option.Option<boolean>>;\n readonly fileSize: (file: string) => Effect.Effect<number>;\n readonly join: (...segments: readonly string[]) => string;\n readonly resolve: (...segments: readonly string[]) => string;\n readonly relative: (from: string, to: string) => string;\n readonly dirname: (file: string) => string;\n readonly basename: (file: string) => string;\n }\n>()(\"@r_masseater/msch/shared/lib/repository-files/RepositoryFiles\") {}\n\nconst SUCCESS = 0;\n\ntype GitText = (root: string, args: readonly string[]) => Effect.Effect<Option.Option<string>>;\n\nconst gitTextService = Effect.gen(function* gitTextService() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const gitText: GitText = (root, args) =>\n Effect.gen(function* readText() {\n const handle = yield* ChildProcess.make(\"git\", args, { cwd: root, stdin: \"ignore\" });\n const text = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n const code = yield* handle.exitCode;\n return Option.liftPredicate(text, () => code === SUCCESS);\n }).pipe(\n Effect.scoped,\n Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n return gitText;\n});\n\ntype GitPaths = (\n root: string,\n args: readonly string[],\n separator: string,\n) => Effect.Effect<readonly string[]>;\n\nconst gitPathsService = Effect.gen(function* gitPathsService() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const gitPaths: GitPaths = (root, args, separator) =>\n Effect.gen(function* listPaths() {\n const handle = yield* ChildProcess.make(\"git\", args, {\n cwd: root,\n stdin: \"ignore\",\n });\n const listed = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n return pipe(Str.split(listed, separator), Arr.filter(Str.isNonEmpty));\n }).pipe(\n Effect.scoped,\n Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),\n Effect.orElseSucceed((): readonly string[] => []),\n );\n return gitPaths;\n});\n\nconst linkName = (entry: string): readonly string[] =>\n Option.toArray(groupOf(\"name\")(LINK_ENTRY.exec(entry)));\n\ntype CacheOperations = Pick<\n typeof RepositoryFiles.Service,\n \"walkDirectory\" | \"writeFile\" | \"removeFile\" | \"hash\" | \"hashFile\"\n>;\n\nconst encoder = new TextEncoder();\n\nconst cacheOperations = (\n fs: FileSystem.FileSystem,\n path: Path.Path,\n digest: Digest.Digest[\"Service\"],\n): CacheOperations => ({\n walkDirectory: (directory) =>\n fs\n .readDirectory(directory, { recursive: true })\n .pipe(Effect.orElseSucceed((): readonly string[] => [])),\n writeFile: (file, text) =>\n fs\n .makeDirectory(path.dirname(file), { recursive: true })\n .pipe(Effect.andThen(fs.writeFileString(file, text)), Effect.ignore),\n removeFile: (file) => fs.remove(file, { force: true }).pipe(Effect.ignore),\n hash: (text) => digest.digestHex(Digest.sha256, encoder.encode(text)),\n hashFile: (file) =>\n fs.readFile(file).pipe(\n Effect.flatMap((bytes) => digest.digestHex(Digest.sha256, bytes)),\n Effect.option,\n ),\n});\n\nconst gitFiles =\n (gitPaths: GitPaths) =>\n (root: string, args: readonly string[]): Effect.Effect<readonly string[]> =>\n gitPaths(root, [\"ls-files\", \"-z\", ...args], \"\\0\");\n\nconst gitHistory = (\n gitText: GitText,\n): Pick<RepositoryFiles[\"Service\"], \"commitMessages\" | \"committedAt\"> => ({\n commitMessages: (root, revision) =>\n gitText(root, [\"log\", `${revision}..HEAD`, \"--format=%B%x00\"]).pipe(\n Effect.map(\n Option.match({\n onNone: (): readonly string[] => [],\n onSome: (text) => Str.split(text, \"\\0\"),\n }),\n ),\n ),\n committedAt: (root, name) =>\n gitText(root, [\"log\", \"-1\", \"--format=%ct\", \"HEAD\", \"--\", name]).pipe(\n Effect.map(Option.map(Str.trim)),\n Effect.map(Option.filter(Str.isNonEmpty)),\n Effect.map(Option.map((seconds) => Number(seconds) * MILLISECONDS)),\n ),\n});\n\nconst gitOperations = (\n gitPaths: GitPaths,\n gitText: GitText,\n): Pick<\n RepositoryFiles[\"Service\"],\n | \"changedFiles\"\n | \"ignoredFiles\"\n | \"ignoredPaths\"\n | \"linkedFiles\"\n | \"listedFiles\"\n | \"matchingFiles\"\n | \"mergeBase\"\n | \"originUrl\"\n | \"history\"\n | \"ownedFiles\"\n | \"readAtRevision\"\n | \"trackedFiles\"\n> => {\n const files = gitFiles(gitPaths);\n return {\n listedFiles: (root) => files(root, LISTED_ARGS),\n ownedFiles: (root) => files(root, [...LISTED_ARGS, \"--\", ...OWNED_PATHSPECS]),\n linkedFiles: (root) => files(root, STAGED_ARGS).pipe(Effect.map(Arr.flatMap(linkName))),\n mergeBase: (root, revision) =>\n gitText(root, [\"merge-base\", \"HEAD\", revision]).pipe(\n Effect.map(Option.map(Str.trim)),\n Effect.map(Option.filter(Str.isNonEmpty)),\n ),\n originUrl: (root) =>\n gitText(root, [\"config\", \"--get\", \"remote.origin.url\"]).pipe(\n Effect.map(Option.map(Str.trim)),\n Effect.map(Option.filter(Str.isNonEmpty)),\n ),\n history: (root) => gitText(root, HISTORY_ARGS).pipe(Effect.map(Option.getOrElse(() => \"\"))),\n changedFiles: (root, revision) =>\n gitPaths(root, [\"diff\", \"--name-only\", \"--no-renames\", \"-z\", revision], \"\\0\"),\n readAtRevision: (root, revision, name) => gitText(root, [\"show\", `${revision}:${name}`]),\n matchingFiles: (root, pathspecs) => files(root, [...LISTED_ARGS, \"--\", ...pathspecs]),\n trackedFiles: (root, pathspecs) => files(root, [...TRACKED_ARGS, \"--\", ...pathspecs]),\n ignoredFiles: (root, pathspecs) => files(root, [...IGNORED_ARGS, \"--\", ...pathspecs]),\n ignoredPaths: (root, paths) => gitPaths(root, [\"check-ignore\", \"--\", ...paths], \"\\n\"),\n };\n};\n\nexport const nodeRepositoryFiles = Layer.effect(\n RepositoryFiles,\n Effect.gen(function* nodeRepositoryFiles() {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const digest = yield* Digest.Digest;\n const gitPaths = yield* gitPathsService;\n const gitText = yield* gitTextService;\n return RepositoryFiles.of({\n generatedFiles: (root) =>\n gitFiles(gitPaths)(root, [\"--\", GENERATED_PATHSPEC]).pipe(\n Effect.map(Arr.map((file) => path.join(root, file))),\n ),\n ...gitOperations(gitPaths, gitText),\n ...gitHistory(gitText),\n readLink: (file) => fs.readLink(file).pipe(Effect.option),\n readFile: (file) => fs.readFileString(file).pipe(Effect.option),\n readBytes: (file) => fs.readFile(file).pipe(Effect.option),\n exists: (file) => fs.exists(file).pipe(Effect.orElseSucceed(() => false)),\n realPath: (file) => fs.realPath(file).pipe(Effect.orElseSucceed(() => file)),\n readDirectory: (directory) =>\n fs.readDirectory(directory).pipe(Effect.orElseSucceed((): readonly string[] => [])),\n ...cacheOperations(fs, path, digest),\n isDirectory: (file) =>\n fs.stat(file).pipe(\n Effect.map((info) => info.type === \"Directory\"),\n Effect.option,\n ),\n fileSize: (file) =>\n fs.stat(file).pipe(\n Effect.map((info) => Number(info.size)),\n Effect.orElseSucceed(() => MISSING_SIZE),\n ),\n join: (...segments) => path.join(...segments),\n resolve: (...segments) => path.resolve(...segments),\n relative: (from, to) => path.relative(from, to),\n dirname: (file) => path.dirname(file),\n basename: (file) => path.basename(file),\n });\n }),\n).pipe(Layer.provide(nodeServicesLayer), Layer.provide(Digest.layerWebCrypto));\n"],"mappings":";;;;;AAEc,MAAM,SAASA,OAAI,QAAQ,CAAC,SAAqC,GAAG;AA6ClF,MAAa,WACV,UACA,UACC,KACE,OAAO,cAAc,KAAK,GAC1B,OAAO,SAAS,UAAU,OAAO,cAAc,MAAM,MAAM,CAAC,GAC5D,OAAO,SAAS,WAAW,OAAO,cAAc,OAAO,KAAK,CAAC,CAC/D;;ACtDJ,MAAa,YAAY;;;AC0BzB,MAAa,oBAAoB,MAAM,aACrC,wBAAwB,OACxB,MAAM,SAAS,eAAe,OAAO,SAAS,OAAO,UAAU,KAAK,CACtE;AAEA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB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