@r_masseater/msch 0.64.0 → 0.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cargo-inputs.mjs +2 -2
- package/dist/changed.mjs +4 -4
- package/dist/cli.mjs +105 -153
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +8 -3
- package/dist/config.mjs.map +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{define-lint-preset-CVDGUMjV.mjs → define-lint-preset-DpGK82kj.mjs} +6 -4
- package/dist/define-lint-preset-DpGK82kj.mjs.map +1 -0
- package/dist/{dependencies-B6p7x90y.mjs → dependencies-BDQ7XSwU.mjs} +7 -30
- package/dist/dependencies-BDQ7XSwU.mjs.map +1 -0
- package/dist/exits.mjs +13 -30
- package/dist/exits.mjs.map +1 -1
- package/dist/export-subpaths-D6ZLYZGy.mjs +17 -0
- package/dist/export-subpaths-D6ZLYZGy.mjs.map +1 -0
- package/dist/{ignored-directories-BgUqwuc4.mjs → ignored-directories-DurTKTTN.mjs} +2 -2
- package/dist/{ignored-directories-BgUqwuc4.mjs.map → ignored-directories-DurTKTTN.mjs.map} +1 -1
- package/dist/{index-BZIBqvmt.d.mts → index-MUn1dolO.d.mts} +2 -1
- package/dist/lint.mjs +1 -1
- package/dist/lookup-DjQU0W6q.mjs +33 -0
- package/dist/lookup-DjQU0W6q.mjs.map +1 -0
- package/dist/lookup-report-CPR_cj8F.mjs +29 -0
- package/dist/lookup-report-CPR_cj8F.mjs.map +1 -0
- package/dist/oxlint.mjs +2 -2
- package/dist/{pass-records-CFIrQmB5.mjs → pass-records-DdiDtl_g.mjs} +5 -5
- package/dist/pass-records-DdiDtl_g.mjs.map +1 -0
- package/dist/{problem-D2HKNIVq.mjs → problem-glqVxx3h.mjs} +2 -2
- package/dist/{problem-D2HKNIVq.mjs.map → problem-glqVxx3h.mjs.map} +1 -1
- package/dist/publish.mjs +15 -23
- package/dist/publish.mjs.map +1 -1
- package/dist/{published-BIexKvdJ.mjs → published-DnkuW2Tw.mjs} +10 -15
- package/dist/published-DnkuW2Tw.mjs.map +1 -0
- package/dist/refs.d.mts +1 -0
- package/dist/refs.mjs +237 -0
- package/dist/refs.mjs.map +1 -0
- package/dist/{repository-files-B5sRbxlz.mjs → repository-files-mOPItI5o.mjs} +3 -3
- package/dist/repository-files-mOPItI5o.mjs.map +1 -0
- package/dist/{runtime-A2p57njU.mjs → runtime-mDBC8Yey.mjs} +2 -2
- package/dist/{runtime-A2p57njU.mjs.map → runtime-mDBC8Yey.mjs.map} +1 -1
- package/dist/{syntax-C0ddqOHc.mjs → syntax-A3ga4Ksb.mjs} +2 -2
- package/dist/{syntax-C0ddqOHc.mjs.map → syntax-A3ga4Ksb.mjs.map} +1 -1
- package/dist/tree-sitter-BfzHNwTR.mjs +41 -0
- package/dist/tree-sitter-BfzHNwTR.mjs.map +1 -0
- package/dist/{upstream-exits-DitN-yYH.mjs → upstream-exits-Bv2E-QO6.mjs} +13 -29
- package/dist/upstream-exits-Bv2E-QO6.mjs.map +1 -0
- package/dist/wake.mjs +1 -1
- package/dist/workspace-settings.d.mts +1 -1
- package/dist/workspace-settings.mjs +18 -5
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +5 -3
- package/skills/msch-checks/SKILL.md +6 -0
- package/skills/msch-publishing/SKILL.md +2 -0
- package/dist/define-lint-preset-CVDGUMjV.mjs.map +0 -1
- package/dist/dependencies-B6p7x90y.mjs.map +0 -1
- package/dist/pass-records-CFIrQmB5.mjs.map +0 -1
- package/dist/published-BIexKvdJ.mjs.map +0 -1
- package/dist/repository-files-B5sRbxlz.mjs.map +0 -1
- package/dist/upstream-exits-DitN-yYH.mjs.map +0 -1
package/dist/lint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { o as INSTRUMENTATION, m as alchemyOverride, l as allRulesOf, h as cloudflareResourceSyntax, g as commandsOverride, p as decisionPlugin, u as decisionRules, d as decisionTestRules, f as generated, c as lint, t as markdownOf, i as remotionRules, _ as removalPolicyOverride, v as removalPolicySyntax, s as requiredStack, r as structureOf, n as textlintPresets, a as tracedRules } from "./define-lint-preset-
|
|
1
|
+
export { o as INSTRUMENTATION, m as alchemyOverride, l as allRulesOf, h as cloudflareResourceSyntax, g as commandsOverride, p as decisionPlugin, u as decisionRules, d as decisionTestRules, f as generated, c as lint, t as markdownOf, i as remotionRules, _ as removalPolicyOverride, v as removalPolicySyntax, s as requiredStack, r as structureOf, n as textlintPresets, a as tracedRules } from "./define-lint-preset-DpGK82kj.mjs";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Config, Effect, Option } from "effect";
|
|
2
|
+
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
3
|
+
// src/shared/lib/lookup.ts
|
|
4
|
+
const USER_AGENT = "msch (https://github.com/masseater/ecosystems/tree/main/libs/msch)";
|
|
5
|
+
/** @internal */
|
|
6
|
+
const JSON_ACCEPT = "application/json";
|
|
7
|
+
const requestOf = ({ url, token, accept }) => {
|
|
8
|
+
const request = HttpClientRequest.get(url).pipe(HttpClientRequest.setHeader("user-agent", USER_AGENT), HttpClientRequest.setHeader("accept", accept));
|
|
9
|
+
return Option.match(token, {
|
|
10
|
+
onNone: () => request,
|
|
11
|
+
onSome: (value) => HttpClientRequest.bearerToken(value)(request)
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
/** @internal */
|
|
15
|
+
const sent = (lookup) => HttpClient.HttpClient.pipe(Effect.flatMap((client) => client.execute(requestOf(lookup))));
|
|
16
|
+
/** @internal */
|
|
17
|
+
const fetched = (lookup) => sent(lookup).pipe(Effect.flatMap(HttpClientResponse.filterStatusOk));
|
|
18
|
+
/** @internal */
|
|
19
|
+
const jsonLookup = ({ url, token }) => ({
|
|
20
|
+
url,
|
|
21
|
+
token,
|
|
22
|
+
accept: JSON_ACCEPT
|
|
23
|
+
});
|
|
24
|
+
/** @internal */
|
|
25
|
+
const publicLookup = (url) => jsonLookup({
|
|
26
|
+
url,
|
|
27
|
+
token: Option.none()
|
|
28
|
+
});
|
|
29
|
+
/** @internal */
|
|
30
|
+
const githubToken = Config.option(Config.String("GH_TOKEN").pipe(Config.orElse(() => Config.String("GITHUB_TOKEN")))).pipe(Effect.orElseSucceed(() => Option.none()));
|
|
31
|
+
export { sent as a, publicLookup as i, githubToken as n, jsonLookup as r, fetched as t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=lookup-DjQU0W6q.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-DjQU0W6q.mjs","names":[],"sources":["../src/shared/lib/lookup.ts"],"sourcesContent":["import { Config, Effect, Option } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\nimport type { HttpClientError } from \"effect/http\";\n\nconst USER_AGENT = \"msch (https://github.com/masseater/ecosystems/tree/main/libs/msch)\";\n\n/** @internal */\nexport const JSON_ACCEPT = \"application/json\";\n\n/** @internal */\nexport interface Lookup {\n readonly url: string;\n readonly token: Option.Option<string>;\n readonly accept: string;\n}\n\nconst requestOf = ({ url, token, accept }: Lookup): HttpClientRequest.HttpClientRequest => {\n const request = HttpClientRequest.get(url).pipe(\n HttpClientRequest.setHeader(\"user-agent\", USER_AGENT),\n HttpClientRequest.setHeader(\"accept\", accept),\n );\n return Option.match(token, {\n onNone: () => request,\n onSome: (value) => HttpClientRequest.bearerToken(value)(request),\n });\n};\n\n/** @internal */\nexport const sent = (\n lookup: Lookup,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n> => HttpClient.HttpClient.pipe(Effect.flatMap((client) => client.execute(requestOf(lookup))));\n\n/** @internal */\nexport const fetched = (\n lookup: Lookup,\n): Effect.Effect<\n HttpClientResponse.HttpClientResponse,\n HttpClientError.HttpClientError,\n HttpClient.HttpClient\n> => sent(lookup).pipe(Effect.flatMap(HttpClientResponse.filterStatusOk));\n\n/** @internal */\nexport const jsonLookup = ({\n url,\n token,\n}: {\n readonly url: string;\n readonly token: Option.Option<string>;\n}): Lookup => ({\n url,\n token,\n accept: JSON_ACCEPT,\n});\n\n/** @internal */\nexport const publicLookup = (url: string): Lookup => jsonLookup({ url, token: Option.none() });\n\n/** @internal */\nexport const githubToken: Effect.Effect<Option.Option<string>> = Config.option(\n Config.String(\"GH_TOKEN\").pipe(Config.orElse(() => Config.String(\"GITHUB_TOKEN\"))),\n).pipe(Effect.orElseSucceed(() => Option.none<string>()));\n"],"mappings":";;;AAIA,MAAM,aAAa;;AAGnB,MAAa,cAAc;AAS3B,MAAM,aAAa,EAAE,KAAK,OAAO,aAA0D;CACzF,MAAM,UAAU,kBAAkB,IAAI,GAAG,CAAC,CAAC,KACzC,kBAAkB,UAAU,cAAc,UAAU,GACpD,kBAAkB,UAAU,UAAU,MAAM,CAC9C;CACA,OAAO,OAAO,MAAM,OAAO;EACzB,cAAc;EACd,SAAS,UAAU,kBAAkB,YAAY,KAAK,CAAC,CAAC,OAAO;CACjE,CAAC;AACH;;AAGA,MAAa,QACX,WAKG,WAAW,WAAW,KAAK,OAAO,SAAS,WAAW,OAAO,QAAQ,UAAU,MAAM,CAAC,CAAC,CAAC;;AAG7F,MAAa,WACX,WAKG,KAAK,MAAM,CAAC,CAAC,KAAK,OAAO,QAAQ,mBAAmB,cAAc,CAAC;;AAGxE,MAAa,cAAc,EACzB,KACA,aAIa;CACb;CACA;CACA,QAAQ;AACV;;AAGA,MAAa,gBAAgB,QAAwB,WAAW;CAAE;CAAK,OAAO,OAAO,KAAK;AAAE,CAAC;;AAG7F,MAAa,cAAoD,OAAO,OACtE,OAAO,OAAO,UAAU,CAAC,CAAC,KAAK,OAAO,aAAa,OAAO,OAAO,cAAc,CAAC,CAAC,CACnF,CAAC,CAAC,KAAK,OAAO,oBAAoB,OAAO,KAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as JSON_FLAG } from "./cli-contract-D7btWrEu.mjs";
|
|
2
|
+
import { n as RepositoryFiles } from "./repository-files-mOPItI5o.mjs";
|
|
3
|
+
import { n as ProblemsFound, r as writeStdout } from "./runtime-mDBC8Yey.mjs";
|
|
4
|
+
import { Array, Effect, Order, Schema, Stdio, pipe } from "effect";
|
|
5
|
+
// src/app/lookup-report.ts
|
|
6
|
+
const NONE_FOUND = 0;
|
|
7
|
+
const LINE_BREAK = "\n";
|
|
8
|
+
const byPlace = Order.Struct({
|
|
9
|
+
file: Order.String,
|
|
10
|
+
line: Order.Number
|
|
11
|
+
});
|
|
12
|
+
const textOf = (row, describe) => (json, rows) => {
|
|
13
|
+
if (json) return Schema.encodeEffect(row.pipe(Schema.Array, Schema.fromJsonString))(rows);
|
|
14
|
+
return Effect.succeed(pipe(rows, Array.map((found) => `${describe(found)}${LINE_BREAK}`), Array.join("")));
|
|
15
|
+
};
|
|
16
|
+
/** @internal */
|
|
17
|
+
const lookupReport = ({ row, rows, describe }) => Effect.gen(function* report() {
|
|
18
|
+
const stdio = yield* Stdio.Stdio;
|
|
19
|
+
const files = yield* RepositoryFiles;
|
|
20
|
+
const args = yield* stdio.args;
|
|
21
|
+
const found = yield* rows(files.resolve("."));
|
|
22
|
+
const text = yield* textOf(row, describe)(Array.contains(args, JSON_FLAG), Array.sort(found, byPlace));
|
|
23
|
+
yield* writeStdout(text);
|
|
24
|
+
if (found.length > NONE_FOUND) return yield* ProblemsFound.make({ count: found.length });
|
|
25
|
+
return NONE_FOUND;
|
|
26
|
+
});
|
|
27
|
+
export { lookupReport as t };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=lookup-report-CPR_cj8F.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-report-CPR_cj8F.mjs","names":["Arr"],"sources":["../src/app/lookup-report.ts"],"sourcesContent":["import { Array as Arr, Effect, Order, Schema, Stdio, pipe } from \"effect\";\n\nimport { JSON_FLAG } from \"#/shared/lib/cli-contract.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { ProblemsFound, writeStdout } from \"./output.ts\";\n\nconst NONE_FOUND = 0;\nconst LINE_BREAK = \"\\n\";\n\nconst byPlace = Order.Struct({ file: Order.String, line: Order.Number });\n\n/** @internal */\nexport interface Place {\n readonly file: string;\n readonly line: number;\n}\n\n/** @internal */\nexport interface LookupReport<Row extends Place, Failure, Requirements> {\n readonly row: Schema.Codec<Row>;\n readonly rows: (root: string) => Effect.Effect<readonly Row[], Failure, Requirements>;\n readonly describe: (row: Row) => string;\n}\n\nconst textOf =\n <Row extends Place>(row: Schema.Codec<Row>, describe: (row: Row) => string) =>\n (json: boolean, rows: readonly Row[]): Effect.Effect<string, Schema.SchemaError> => {\n if (json) {\n return Schema.encodeEffect(row.pipe(Schema.Array, Schema.fromJsonString))(rows);\n }\n return Effect.succeed(\n pipe(\n rows,\n Arr.map((found) => `${describe(found)}${LINE_BREAK}`),\n Arr.join(\"\"),\n ),\n );\n };\n\n/** @internal */\nexport const lookupReport = <Row extends Place, Failure, Requirements>({\n row,\n rows,\n describe,\n}: LookupReport<Row, Failure, Requirements>): Effect.Effect<\n number,\n Failure | Schema.SchemaError | ProblemsFound,\n Requirements | RepositoryFiles | Stdio.Stdio\n> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const files = yield* RepositoryFiles;\n const args = yield* stdio.args;\n const found = yield* rows(files.resolve(\".\"));\n const text = yield* textOf(row, describe)(\n Arr.contains(args, JSON_FLAG),\n Arr.sort(found, byPlace),\n );\n yield* writeStdout(text);\n if (found.length > NONE_FOUND) {\n return yield* ProblemsFound.make({ count: found.length });\n }\n return NONE_FOUND;\n });\n"],"mappings":";;;;;AAOA,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,UAAU,MAAM,OAAO;CAAE,MAAM,MAAM;CAAQ,MAAM,MAAM;AAAO,CAAC;AAevE,MAAM,UACgB,KAAwB,cAC3C,MAAe,SAAoE;CAClF,IAAI,MACF,OAAO,OAAO,aAAa,IAAI,KAAK,OAAO,OAAO,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI;CAEhF,OAAO,OAAO,QACZ,KACE,MACAA,MAAI,KAAK,UAAU,GAAG,SAAS,KAAK,IAAI,YAAY,GACpDA,MAAI,KAAK,EAAE,CACb,CACF;AACF;;AAGF,MAAa,gBAA0D,EACrE,KACA,MACA,eAMA,OAAO,IAAI,UAAU,SAAS;CAC5B,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,MAAM;CAC1B,MAAM,QAAQ,OAAO,KAAK,MAAM,QAAQ,GAAG,CAAC;CAC5C,MAAM,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CACvCA,MAAI,SAAS,MAAM,SAAS,GAC5BA,MAAI,KAAK,OAAO,OAAO,CACzB;CACA,OAAO,YAAY,IAAI;CACvB,IAAI,MAAM,SAAS,YACjB,OAAO,OAAO,cAAc,KAAK,EAAE,OAAO,MAAM,OAAO,CAAC;CAE1D,OAAO;AACT,CAAC"}
|
package/dist/oxlint.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as describeFinding, t as ProblemList } from "./problem-
|
|
1
|
+
import { n as describeFinding, t as ProblemList } from "./problem-glqVxx3h.mjs";
|
|
2
2
|
import { t as JSON_FLAG } from "./cli-contract-D7btWrEu.mjs";
|
|
3
|
-
import { i as nodeServicesLayer } from "./repository-files-
|
|
3
|
+
import { i as nodeServicesLayer } from "./repository-files-mOPItI5o.mjs";
|
|
4
4
|
import { Array, Effect, Layer, Schema, Stream, pipe } from "effect";
|
|
5
5
|
import { ChildProcess } from "effect/process";
|
|
6
6
|
// src/features/report-problems/model/oxlint-rule.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-
|
|
2
|
-
import { i as workspaceDependencies, n as dependencyEntries, r as readManifest, t as MANIFEST_FILE } from "./dependencies-
|
|
3
|
-
import { C as IndexKind, J as isModuleDeclaration, S as API, a as declarationsOf, dt as isVariableDeclaration, g as propertyNamesOf, k as getLeadingCommentRanges, o as declaresAType, p as isTypeDeclaration, t as carriesTag, u as isGenericDeclaration, v as resolvedSymbol, w as InternalSymbolName } from "./syntax-
|
|
1
|
+
import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-mOPItI5o.mjs";
|
|
2
|
+
import { i as workspaceDependencies, n as dependencyEntries, r as readManifest, t as MANIFEST_FILE } from "./dependencies-BDQ7XSwU.mjs";
|
|
3
|
+
import { C as IndexKind, J as isModuleDeclaration, S as API, a as declarationsOf, dt as isVariableDeclaration, g as propertyNamesOf, k as getLeadingCommentRanges, o as declaresAType, p as isTypeDeclaration, t as carriesTag, u as isGenericDeclaration, v as resolvedSymbol, w as InternalSymbolName } from "./syntax-A3ga4Ksb.mjs";
|
|
4
4
|
import { Array, Effect, Function, Number, Option, Order, Schema, String as String$1, pipe } from "effect";
|
|
5
5
|
// src/shared/lib/values.ts
|
|
6
6
|
const SCHEMA_TYPE_PROPERTIES = ["Type", "_output"];
|
|
@@ -120,7 +120,7 @@ const mergeIndexes = (indexes) => ({
|
|
|
120
120
|
typeNames: pipe(indexes, Array.flatMap((index) => index.typeNames)),
|
|
121
121
|
tagNames: pipe(indexes, Array.flatMap((index) => index.tagNames))
|
|
122
122
|
});
|
|
123
|
-
const isNamespace = (symbol) =>
|
|
123
|
+
const isNamespace = (symbol) => Array.some(declarationsOf(symbol), isModuleDeclaration);
|
|
124
124
|
const typeNameIndex = (visit, symbol) => {
|
|
125
125
|
const declarations = declarationsOf(symbol);
|
|
126
126
|
const typeNames = pipe([visit.exported.name], Array.filter(() => declaresAType(declarations)));
|
|
@@ -433,4 +433,4 @@ const keepOnly = Effect.fn("keepOnly")(function* keepOnly(records, keys) {
|
|
|
433
433
|
});
|
|
434
434
|
export { valueKey as C, schemaTypeOf as S, formatValues as _, nearestManifestDirectory as a, literalValuesOf as b, listConfigFiles as c, withProject as d, declarationKey as f, finiteValuesOf as g, locationOf as h, installedPackages as i, mentions as l, isObjectType as m, keepOnly as n, projectInputs as o, describeLibraryType as p, recordsIn as r, workspaceClosure as s, contentKey as t, typeScriptCompiler as u, isSubsetOf as v, vocabularyOf as w, sameValues as x, literalUnionOf as y };
|
|
435
435
|
|
|
436
|
-
//# sourceMappingURL=pass-records-
|
|
436
|
+
//# sourceMappingURL=pass-records-DdiDtl_g.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pass-records-DdiDtl_g.mjs","names":["Arr","Fn","Arr","Num","Str","Arr","HIDDEN_PREFIX","Str","Arr","Arr","Str","Arr"],"sources":["../src/shared/lib/values.ts","../src/entities/project/model/library.ts","../src/entities/project/model/telemetry.ts","../src/entities/project/model/project.ts","../src/entities/project/model/inputs.ts","../src/shared/lib/pass-records.ts"],"sourcesContent":["import { Array as Arr, Function as Fn, Option, pipe } from \"effect\";\n\nimport { IndexKind } from \"./compiler.ts\";\nimport type { Checker, Type } from \"./compiler.ts\";\n\nexport type Value = string | number;\n\nexport interface Vocabulary {\n readonly values: readonly Value[];\n readonly admitsUnnamedValues: boolean;\n}\n\nconst SCHEMA_TYPE_PROPERTIES = [\"Type\", \"_output\"] as const;\n\nconst MINIMUM_SET_SIZE = 2;\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const valueKey = (value: Value): string => `${typeof value}:${String(value)}`;\n\nconst literalValueOf = (type: Type): Option.Option<Value> => {\n if (type.isStringLiteralType() || type.isNumberLiteralType()) {\n return Option.some(type.value);\n }\n return Option.none();\n};\n\nexport const literalValuesOf = (types: readonly Type[]): Option.Option<readonly Value[]> => {\n const values = pipe(\n types,\n Arr.map((member) => literalValueOf(member)),\n Arr.getSomes,\n Arr.dedupeWith((left, right) => valueKey(left) === valueKey(right)),\n );\n if (values.length !== types.length || values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some(values);\n};\n\nexport const literalUnionOf = (type: Type): Option.Option<readonly Value[]> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n return literalValuesOf(type.getTypes());\n};\n\nconst elementTypeOf = (checker: Checker, type: Type): Option.Option<Type> => {\n if (!checker.isArrayLikeType(type)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getIndexTypeOfType(type, IndexKind.Number));\n};\n\nexport const schemaTypeOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Type> =>\n Arr.findFirst(SCHEMA_TYPE_PROPERTIES, (name) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(type, name)),\n ).pipe(Option.map((property) => checker.getTypeOfSymbol(property)));\n\nexport const finiteValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalUnionOf(type).pipe(\n Option.orElse(() => elementTypeOf(checker, type).pipe(Option.flatMap(literalUnionOf))),\n Option.orElse(() => schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf))),\n );\n\nexport const vocabularyOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Vocabulary> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n const optionalIds = new Set([checker.getUndefinedType().id, checker.getNullType().id]);\n const members = pipe(\n type.getTypes(),\n Arr.filter((member) => !optionalIds.has(member.id)),\n );\n const values = Arr.getSomes(\n pipe(\n members,\n Arr.map((member) => literalValueOf(member)),\n ),\n );\n if (values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some({ values, admitsUnnamedValues: values.length !== members.length });\n };\n\nexport const isSubsetOf: {\n (superset: readonly Value[]): (subset: readonly Value[]) => boolean;\n (subset: readonly Value[], superset: readonly Value[]): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (subset: readonly Value[], superset: readonly Value[]): boolean => {\n const held = new Set(\n pipe(\n superset,\n Arr.map((value) => valueKey(value)),\n ),\n );\n return pipe(\n subset,\n Arr.every((value) => held.has(valueKey(value))),\n );\n});\n\nexport const sameValues: {\n (right: readonly Value[]): (left: readonly Value[]) => boolean;\n (left: readonly Value[], right: readonly Value[]): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (left: readonly Value[], right: readonly Value[]): boolean =>\n left.length === right.length && isSubsetOf(left, right),\n);\n\nconst valueText = (value: Value): string => {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n return String(value);\n};\n\nexport const formatValues = (values: readonly Value[]): string =>\n pipe(values, Arr.map(valueText), Arr.join(\" | \"));\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { DependencyEntry } from \"#/entities/package/@x/project.ts\";\nimport {\n InternalSymbolName,\n isModuleDeclaration,\n isVariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n SyntaxKind,\n TypeSymbol,\n Type,\n} from \"#/shared/lib/compiler.ts\";\nimport {\n declarationsOf,\n isGenericDeclaration,\n isTypeDeclaration,\n carriesTag,\n declaresAType,\n propertyNamesOf,\n resolvedSymbol,\n} from \"#/shared/lib/syntax.ts\";\nimport { schemaTypeOf, vocabularyOf } from \"#/shared/lib/values.ts\";\nimport type { Vocabulary } from \"#/shared/lib/values.ts\";\n\nexport interface LibraryType {\n readonly specifier: string;\n readonly typeName: string;\n}\n\nexport interface LibraryVocabulary extends LibraryType {\n readonly vocabulary: Vocabulary;\n}\n\nexport interface DeclarationLocation {\n readonly file: string;\n readonly pos: number;\n readonly kind: SyntaxKind;\n}\n\nexport interface LibraryShape extends LibraryType {\n readonly form: \"declared\" | \"schema\";\n readonly declaration: DeclarationLocation;\n readonly propertyNames: readonly string[];\n}\n\nexport interface LibraryIndex {\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly shapes: readonly LibraryShape[];\n readonly typeNames: readonly string[];\n readonly tagNames: readonly string[];\n}\n\ninterface Walk {\n readonly checker: Checker;\n readonly entry: DependencyEntry;\n}\n\ninterface Visit {\n readonly exported: TypeSymbol;\n readonly qualifier: string;\n readonly ancestors: readonly TypeSymbol[];\n}\n\ninterface Exported {\n readonly symbol: TypeSymbol;\n readonly typeName: string;\n}\n\nconst NAMESPACE_DEPTH_LIMIT = 8;\nconst EMPTY_INDEX: LibraryIndex = { vocabularies: [], shapes: [], typeNames: [], tagNames: [] };\n\nexport const isObjectType =\n (checker: Checker) =>\n (type: Type): boolean =>\n !type.isUnionType() &&\n !type.isLiteralType() &&\n checker.getApparentType(type).id === type.id &&\n Arr.isReadonlyArrayNonEmpty(checker.getPropertiesOfType(type));\n\nexport const describeLibraryType = (type: LibraryType): string =>\n `${type.typeName} from ${type.specifier}`;\n\nexport const locationOf = (declaration: Node): DeclarationLocation => ({\n file: declaration.getSourceFile().fileName,\n pos: declaration.pos,\n kind: declaration.kind,\n});\n\nexport const declarationKey = (location: DeclarationLocation): string =>\n `${location.file}#${String(location.pos)}#${String(location.kind)}`;\n\ntype ShapeSource = LibraryType & Pick<LibraryShape, \"form\">;\n\nconst shapeOf =\n (checker: Checker) =>\n (source: ShapeSource, declaration: Declaration, type: Type): readonly LibraryShape[] =>\n Arr.filter(\n [\n {\n ...source,\n declaration: locationOf(declaration),\n propertyNames: propertyNamesOf(checker)(type),\n },\n ],\n () => isObjectType(checker)(type),\n );\n\nconst declaredTypeIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isTypeDeclaration);\n if (Option.isNone(declaration) || isGenericDeclaration(declaration.value)) {\n return EMPTY_INDEX;\n }\n const located = { specifier: walk.entry.specifier, typeName: exported.typeName };\n const type = walk.checker.getDeclaredTypeOfSymbol(exported.symbol);\n const vocabularies = vocabularyOf(walk.checker)(type).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n );\n const shapes = shapeOf(walk.checker)({ ...located, form: \"declared\" }, declaration.value, type);\n return { ...EMPTY_INDEX, vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n ...EMPTY_INDEX,\n vocabularies: vocabularyOf(walk.checker)(schemaType).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n ),\n shapes: shapeOf(walk.checker)({ ...located, form: \"schema\" }, declaration, schemaType),\n });\n\nconst schemaValueIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isVariableDeclaration);\n if (Option.isNone(declaration)) {\n return EMPTY_INDEX;\n }\n const valueType = walk.checker.getTypeOfSymbolAtLocation(exported.symbol, declaration.value);\n const located = {\n specifier: walk.entry.specifier,\n typeName: `(typeof ${exported.typeName})[\"Type\"]`,\n };\n return Option.match(schemaTypeOf(walk.checker)(valueType), {\n onNone: () => EMPTY_INDEX,\n onSome: (schemaType) => schemaTypeIndex(walk, located)(declaration.value, schemaType),\n });\n};\n\nconst mergeIndexes = (indexes: readonly LibraryIndex[]): LibraryIndex => ({\n vocabularies: pipe(\n indexes,\n Arr.flatMap((index) => index.vocabularies),\n ),\n shapes: pipe(\n indexes,\n Arr.flatMap((index) => index.shapes),\n ),\n typeNames: pipe(\n indexes,\n Arr.flatMap((index) => index.typeNames),\n ),\n tagNames: pipe(\n indexes,\n Arr.flatMap((index) => index.tagNames),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n Arr.some(declarationsOf(symbol), isModuleDeclaration);\n\nconst typeNameIndex = (visit: Visit, symbol: TypeSymbol): LibraryIndex => {\n const declarations = declarationsOf(symbol);\n const typeNames = pipe(\n [visit.exported.name],\n Arr.filter(() => declaresAType(declarations)),\n );\n const tagNames = pipe(\n typeNames,\n Arr.filter((name) => carriesTag(name)(declarations)),\n );\n return { ...EMPTY_INDEX, typeNames, tagNames };\n};\n\nconst indexUnder = (walk: Walk, visit: Visit): LibraryIndex => {\n const symbol = resolvedSymbol(walk.checker)(visit.exported);\n const named = { symbol, typeName: `${visit.qualifier}${visit.exported.name}` };\n const own = mergeIndexes([\n declaredTypeIndex(walk, named),\n schemaValueIndex(walk, named),\n typeNameIndex(visit, symbol),\n ]);\n if (\n !isNamespace(symbol) ||\n visit.ancestors.length >= NAMESPACE_DEPTH_LIMIT ||\n visit.ancestors.includes(symbol)\n ) {\n return own;\n }\n const nested = pipe(\n walk.checker.getExportsOfModule(symbol),\n Arr.map((member) =>\n indexUnder(walk, {\n exported: member,\n qualifier: `${named.typeName}.`,\n ancestors: [...visit.ancestors, symbol],\n }),\n ),\n );\n return mergeIndexes([own, ...nested]);\n};\n\nconst exportAssignmentOf = (moduleSymbol: TypeSymbol): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(moduleSymbol.getExports().get(InternalSymbolName.ExportEquals));\n\nconst indexOfEntry =\n (checker: Checker) =>\n (entry: DependencyEntry): LibraryIndex => {\n const moduleSymbol = Option.fromUndefinedOr(\n checker.getSymbolOfSourceFile(entry.declarationsPath),\n );\n if (Option.isNone(moduleSymbol)) {\n return EMPTY_INDEX;\n }\n const walk: Walk = { checker, entry };\n const roots = Option.match(exportAssignmentOf(moduleSymbol.value), {\n onNone: () => checker.getExportsOfModule(moduleSymbol.value),\n onSome: (assigned) => [resolvedSymbol(checker)(assigned)],\n });\n return mergeIndexes(\n pipe(\n roots,\n Arr.map((exported) => indexUnder(walk, { exported, qualifier: \"\", ancestors: [] })),\n ),\n );\n };\n\nexport interface CachedIndex {\n readonly index: LibraryIndex;\n readonly cached: boolean;\n}\n\nexport interface LibraryCache {\n readonly indexOf: (entry: DependencyEntry, compute: () => LibraryIndex) => CachedIndex;\n}\n\nexport const libraryCache = (): LibraryCache => {\n const indexes = new Map<string, LibraryIndex>();\n return {\n indexOf: (entry, compute) =>\n Option.match(Option.fromUndefinedOr(indexes.get(entry.declarationsPath)), {\n onSome: (index) => ({ index, cached: true }),\n onNone: () => {\n const index = compute();\n indexes.set(entry.declarationsPath, index);\n return { index, cached: false };\n },\n }),\n };\n};\n\nconst indexEntry =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entry: DependencyEntry): Effect.Effect<LibraryIndex> =>\n Effect.sync(() => cache.indexOf(entry, () => indexOfEntry(checker)(entry))).pipe(\n Effect.tap(({ index, cached }) =>\n Effect.annotateCurrentSpan({\n \"msch.library.cached\": cached,\n \"msch.library.vocabularies\": index.vocabularies.length,\n \"msch.library.shapes\": index.shapes.length,\n }),\n ),\n Effect.map(({ index }) => index),\n Effect.withSpan(\"indexLibraryEntry\", {\n attributes: { \"msch.library.specifier\": entry.specifier },\n }),\n );\n\nexport const libraryIndex =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entries: readonly DependencyEntry[]): Effect.Effect<LibraryIndex> =>\n pipe(\n entries,\n (items) => Effect.forEach(items, indexEntry(cache)(checker), { concurrency: 1 }),\n Effect.map(mergeIndexes),\n Effect.withSpan(\"libraryIndex\"),\n );\n","import { Array as Arr, Effect, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nimport type { API } from \"#/shared/lib/compiler.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RSS_LINE = /^VmRSS:\\s+(?<kib>\\d+) kB$/mu;\nconst BYTES_PER_KIB = 1024;\nconst UNKNOWN_RSS = 0;\n\nconst kibibytesIn = (status: string): Option.Option<string> =>\n Option.fromNullishOr(RSS_LINE.exec(status)).pipe(\n Option.flatMap((match) => Option.fromUndefinedOr(match.groups)),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[\"kib\"])),\n );\n\nconst residentBytesOf = (pid: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* residentBytes() {\n const files = yield* RepositoryFiles;\n const status = yield* files.readFile(`/proc/${pid}/status`);\n return pipe(\n status,\n Option.flatMap(kibibytesIn),\n Option.flatMap(Num.parse),\n Option.map((kib) => kib * BYTES_PER_KIB),\n Option.getOrElse(() => UNKNOWN_RSS),\n );\n });\n\nconst childPids = Effect.gen(function* childPids() {\n const files = yield* RepositoryFiles;\n const pid = String(process.pid);\n const children = yield* files.readFile(`/proc/${pid}/task/${pid}/children`);\n return pipe(\n children,\n Option.map((text) => pipe(Str.trim(text), Str.split(\" \"), Arr.filter(Str.isNonEmpty))),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst annotateMemory = Effect.gen(function* annotateMemory() {\n const own = yield* residentBytesOf(String(process.pid));\n const pids = yield* childPids;\n const children = yield* Effect.forEach(pids, (pid) => residentBytesOf(pid), { concurrency: 1 });\n const { heapUsed } = process.memoryUsage();\n yield* Effect.annotateCurrentSpan({\n \"process.memory.rss\": own,\n \"process.memory.heap_used\": heapUsed,\n \"msch.compiler.memory.rss\": Num.sumAll(children),\n });\n});\n\nexport const annotateResources = (api: API): Effect.Effect<void, never, RepositoryFiles> =>\n Effect.gen(function* annotateCompiler() {\n yield* annotateMemory;\n const { totals } = api.getTimingInfo();\n yield* Effect.annotateCurrentSpan({\n \"msch.compiler.requests\": totals.requestCount,\n \"msch.compiler.round_trip_ms\": totals.roundTripMs,\n \"msch.compiler.server_ms\": totals.serverTimeMs,\n });\n });\n","import { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n dependencyEntries,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { API, getLeadingCommentRanges } from \"#/shared/lib/compiler.ts\";\nimport type { Checker, ParsedCommandLine, Program, SourceFile } from \"#/shared/lib/compiler.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { libraryCache, libraryIndex } from \"./library.ts\";\nimport type { LibraryCache, LibraryIndex } from \"./library.ts\";\nimport { annotateResources } from \"./telemetry.ts\";\n\nexport interface Project {\n readonly packageName: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n readonly program: Program;\n readonly checker: Checker;\n readonly sourceFiles: readonly SourceFile[];\n readonly library: LibraryIndex;\n}\n\nexport type SourceCheck = (checker: Checker) => (sourceFile: SourceFile) => readonly Problem[];\n\ninterface PackageInfo {\n readonly directory: string;\n readonly name: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n}\n\nconst CONFIG_FILE = \"tsconfig.json\";\nconst CONFIG_PATHSPEC = `:(glob)**/${CONFIG_FILE}`;\nconst HIDDEN_PREFIX = \".\";\nconst SKIPPED_DIRECTORIES: ReadonlySet<string> = new Set([NODE_MODULES, \"dist\", \"coverage\"]);\n\nconst isVisible = (file: string): boolean =>\n pipe(\n Str.split(file, \"/\"),\n Arr.every(\n (segment) => !Str.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment),\n ),\n );\n\nexport const listConfigFiles = (\n root: string,\n): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* configFilesUnder() {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);\n const visible = pipe(\n listed,\n Arr.filter(isVisible),\n Arr.map((file) => files.join(root, file)),\n );\n return Arr.sort(visible, Order.String);\n });\n\nexport const parseConfig =\n (api: API) =>\n (configPath: string): Option.Option<ParsedCommandLine> =>\n Option.some(api.parseConfigFile(configPath)).pipe(\n Option.filter((parsed) => Arr.isReadonlyArrayNonEmpty(parsed.fileNames)),\n );\n\nconst nearestPackageDirectory = (\n directory: string,\n root: string,\n): Effect.Effect<string, never, RepositoryFiles> =>\n Effect.gen(function* nearestPackage() {\n const files = yield* RepositoryFiles;\n const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE));\n const parent = files.dirname(directory);\n if (hasManifest || directory === root || parent === directory) {\n return directory;\n }\n return yield* nearestPackageDirectory(parent, root);\n });\n\nexport const packageDirectoryOf =\n (root: string) =>\n (directory: string): Effect.Effect<string, never, RepositoryFiles> =>\n nearestPackageDirectory(directory, root);\n\nconst packageInfoOf = Effect.fn(\"packageInfoOf\")(function* packageInfoOf(\n configPath: string,\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);\n const manifest = yield* readManifest(directory);\n return {\n directory,\n name: manifest.pipe(Option.flatMap((found) => Option.fromUndefinedOr(found.name))),\n workspaceDependencies: manifest.pipe(\n Option.map(workspaceDependencies),\n Option.getOrElse(() => []),\n ),\n } satisfies PackageInfo;\n});\n\nconst NO_CHECK_PRAGMA = /^\\/\\/\\s*@ts-nocheck/u;\nconst FILE_START = 0;\n\nconst skipsTypeChecking = (sourceFile: SourceFile): boolean =>\n pipe(\n getLeadingCommentRanges(sourceFile.text, FILE_START) ?? [],\n Arr.some((range) => NO_CHECK_PRAGMA.test(Str.slice(range.pos, range.end)(sourceFile.text))),\n );\n\nconst buildProject = Effect.fn(\"buildProject\")(function* buildProject(\n { compiler: { api, libraries }, generated }: Workspace,\n parsed: ParsedCommandLine,\n info: PackageInfo,\n) {\n const entries = yield* dependencyEntries(info.directory);\n const program = yield* Effect.sync(() =>\n api.createProgram(\n [\n ...parsed.fileNames,\n ...pipe(\n entries,\n Arr.map((entry) => entry.declarationsPath),\n ),\n ],\n { ...parsed.options, noEmit: true },\n ),\n ).pipe(Effect.withSpan(\"createProgram\"));\n const { checker } = program.getProject();\n const library = yield* libraryIndex(libraries)(checker)(entries);\n const projectFiles: ReadonlySet<string> = new Set(\n pipe(\n parsed.fileNames,\n Arr.filter((fileName) => !generated.includes(fileName)),\n ),\n );\n return {\n packageName: info.name,\n workspaceDependencies: info.workspaceDependencies,\n program,\n checker,\n sourceFiles: pipe(\n program.getSourceFileNames(),\n Arr.filter((fileName) => projectFiles.has(fileName)),\n Arr.flatMap((fileName) =>\n Option.toArray(Option.fromUndefinedOr(program.getSourceFile(fileName))),\n ),\n Arr.filter((sourceFile) => !sourceFile.isDeclarationFile && !skipsTypeChecking(sourceFile)),\n ),\n library,\n } satisfies Project;\n});\n\nexport interface Compiler {\n readonly api: API;\n readonly libraries: LibraryCache;\n}\n\nexport interface Workspace {\n readonly compiler: Compiler;\n readonly root: string;\n readonly generated: readonly string[];\n}\n\nexport const typeScriptCompiler = Effect.acquireRelease(\n Effect.sync((): Compiler => ({\n api: new API({ collectTiming: true }),\n libraries: libraryCache(),\n })),\n ({ api }) =>\n Effect.sync(() => {\n api.close();\n }),\n);\n\nconst loadProject = Effect.fn(\"loadProject\")(function* loadProject(\n workspace: Workspace,\n configPath: string,\n) {\n const { compiler, root } = workspace;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none<Project>();\n }\n const info = yield* packageInfoOf(configPath, root);\n const project = yield* buildProject(workspace, parsed.value, info);\n yield* Effect.annotateCurrentSpan({\n \"msch.project.config\": configPath,\n \"msch.project.program_files\": project.program.getSourceFileNames().length,\n \"msch.project.source_files\": project.sourceFiles.length,\n });\n yield* annotateResources(compiler.api);\n return Option.some(project);\n});\n\nconst releaseProject = (project: Project): Effect.Effect<void> =>\n Effect.sync(() => {\n project.program.dispose();\n });\n\nexport const withProject =\n (workspace: Workspace) =>\n (configPath: string) =>\n <Value, Failure, Requirements>(\n work: (project: Project) => Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<Option.Option<Value>, Failure, Requirements | RepositoryFiles> =>\n Effect.acquireUseRelease(\n loadProject(workspace, configPath),\n (loaded) =>\n Option.match(loaded, {\n onNone: () => Effect.succeedNone,\n onSome: (project) => work(project).pipe(Effect.asSome),\n }),\n (loaded) => Option.match(loaded, { onNone: () => Effect.void, onSome: releaseProject }),\n );\n\nexport const mentions =\n (needle: string) =>\n ({ api }: Compiler) =>\n (configPath: string): Effect.Effect<boolean, never, RepositoryFiles> =>\n Effect.gen(function* mentionsNeedle() {\n const files = yield* RepositoryFiles;\n const fileNames = Option.match(parseConfig(api)(configPath), {\n onNone: (): readonly string[] => [],\n onSome: (parsed): readonly string[] => parsed.fileNames,\n });\n const texts = yield* Effect.forEach(fileNames, (fileName) => files.readFile(fileName), {\n concurrency: 1,\n });\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n","import { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { packageDirectoryOf, parseConfig } from \"./project.ts\";\nimport type { Workspace } from \"./project.ts\";\n\nexport interface ProjectInputs {\n readonly options: string;\n readonly files: readonly string[];\n readonly dependencies: readonly string[];\n}\n\nconst SEPARATOR = \"/\";\nconst SCOPE_PREFIX = \"@\";\nconst HIDDEN_PREFIX = \".\";\n\nconst encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\n\nexport const nearestManifestDirectory = Effect.fn(\"nearestManifestDirectory\")(\n function* nearestManifestDirectory(start: string) {\n const files = yield* RepositoryFiles;\n let directory = start;\n let parent = files.dirname(directory);\n while (parent !== directory && !(yield* files.exists(files.join(directory, MANIFEST_FILE)))) {\n directory = parent;\n parent = files.dirname(directory);\n }\n return directory;\n },\n);\n\nconst dependenciesOf = Effect.fn(\"dependenciesOf\")(function* dependenciesOf(directory: string) {\n const files = yield* RepositoryFiles;\n const manifest = yield* readManifest(directory);\n const names = Option.match(manifest, {\n onNone: (): readonly string[] => [],\n onSome: workspaceDependencies,\n });\n return yield* Effect.forEach(\n names,\n (name) => files.realPath(files.join(directory, NODE_MODULES, name)),\n {\n concurrency: 1,\n },\n );\n});\n\nexport const workspaceClosure = Effect.fn(\"workspaceClosure\")(function* workspaceClosure(\n start: string,\n) {\n const seen = new Set([start]);\n const queue = [start];\n for (const directory of queue) {\n const next = yield* dependenciesOf(directory);\n for (const dependency of next) {\n if (!seen.has(dependency)) {\n seen.add(dependency);\n queue.push(dependency);\n }\n }\n }\n return [...seen];\n});\n\nconst isUnder =\n (prefixes: readonly string[]) =>\n (file: string): boolean =>\n pipe(\n prefixes,\n Arr.some((prefix) => Str.startsWith(prefix)(file)),\n );\n\nconst closureOf = Effect.fn(\"closureOf\")(function* closureOf(root: string, configPath: string) {\n const files = yield* RepositoryFiles;\n const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));\n const directories = yield* workspaceClosure(directory);\n const prefixes = pipe(\n directories,\n Arr.map((found) => `${files.relative(root, found)}${SEPARATOR}`),\n );\n return { directories, prefixes };\n});\n\nconst scopedNames =\n (modules: string) =>\n (name: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* listScope() {\n const files = yield* RepositoryFiles;\n if (!Str.startsWith(SCOPE_PREFIX)(name)) {\n return [name];\n }\n const scoped = yield* files.readDirectory(files.join(modules, name));\n return pipe(\n scoped,\n Arr.map((entry) => `${name}${SEPARATOR}${entry}`),\n );\n });\n\nconst installedNames = Effect.fn(\"installedNames\")(function* installedNames(modules: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.readDirectory(modules);\n const nested = yield* pipe(\n listed,\n Arr.filter((name) => !Str.startsWith(HIDDEN_PREFIX)(name)),\n (items) => Effect.forEach(items, scopedNames(modules), { concurrency: 1 }),\n );\n return Arr.flatten(nested);\n});\n\nexport const installedPackages = Effect.fn(\"installedPackages\")(function* installedPackages(\n root: string,\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const modules = files.join(directory, NODE_MODULES);\n const names = yield* installedNames(modules);\n return yield* Effect.forEach(\n names,\n (name) =>\n files\n .realPath(files.join(modules, name))\n .pipe(Effect.map((found) => files.relative(root, found))),\n { concurrency: 1 },\n );\n});\n\nconst dependencyVersions = Effect.fn(\"dependencyVersions\")(function* dependencyVersions(\n root: string,\n directories: readonly string[],\n) {\n const installed = yield* Effect.forEach(\n Arr.dedupe([root, ...directories]),\n (directory) => installedPackages(root, directory),\n { concurrency: 1 },\n );\n return Arr.sort(Arr.dedupe(Arr.flatten(installed)), Order.String);\n});\n\nexport interface InputScope {\n readonly workspace: Workspace;\n readonly listed: readonly string[];\n}\n\nexport const projectInputs =\n ({ workspace: { compiler, root }, listed }: InputScope) =>\n (configPath: string): Effect.Effect<Option.Option<ProjectInputs>, never, RepositoryFiles> =>\n Effect.gen(function* collectInputs() {\n const files = yield* RepositoryFiles;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none();\n }\n const closure = yield* closureOf(root, configPath);\n const dependencies = yield* dependencyVersions(root, closure.directories);\n const options = yield* encodeOptions(parsed.value.options).pipe(\n Effect.orElseSucceed(() => \"\"),\n );\n const sources = pipe(\n parsed.value.fileNames,\n Arr.map((fileName) => files.relative(root, fileName)),\n );\n const shared = pipe(listed, Arr.filter(isUnder(closure.prefixes)));\n return Option.some({\n options,\n files: Arr.sort(Arr.dedupe([...sources, ...shared]), Order.String),\n dependencies,\n });\n });\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst PASSED = \"\";\nconst UNREADABLE = \"\";\nconst FIELD_SEPARATOR = \"\\0\";\nconst LINE_SEPARATOR = \"\\n\";\n\nexport interface Records {\n readonly directory: string;\n readonly passed: readonly string[];\n}\n\nexport type NamedFile = readonly [name: string, file: string];\n\nexport const contentKey = Effect.fn(\"contentKey\")(function* contentKey(\n salt: readonly string[],\n named: readonly NamedFile[],\n) {\n const files = yield* RepositoryFiles;\n const entries = yield* Effect.forEach(\n named,\n ([name, file]) =>\n files\n .hashFile(file)\n .pipe(\n Effect.map(\n (found) => `${name}${FIELD_SEPARATOR}${Option.getOrElse(found, () => UNREADABLE)}`,\n ),\n ),\n { concurrency: 1 },\n );\n return yield* files.hash(Arr.join([...salt, ...entries], LINE_SEPARATOR));\n});\n\nexport const recordsIn = Effect.fn(\"recordsIn\")(function* recordsIn(directory: string) {\n const files = yield* RepositoryFiles;\n const present = yield* files.readDirectory(directory);\n return { directory, passed: present } satisfies Records;\n});\n\nexport const keepOnly = Effect.fn(\"keepOnly\")(function* keepOnly(\n records: Records,\n keys: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const stale = pipe(\n records.passed,\n Arr.filter((key) => !Arr.contains(keys, key)),\n );\n yield* Effect.forEach(stale, (key) => files.removeFile(files.join(records.directory, key)), {\n concurrency: 1,\n discard: true,\n });\n yield* Effect.forEach(\n keys,\n (key) => files.writeFile(files.join(records.directory, key), PASSED),\n { concurrency: 1, discard: true },\n );\n});\n"],"mappings":";;;;;AAYA,MAAM,yBAAyB,CAAC,QAAQ,SAAS;AAEjD,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB;AAEzB,MAAa,YAAY,UAAyB,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAEjF,MAAM,kBAAkB,SAAqC;CAC3D,IAAI,KAAK,oBAAoB,KAAK,KAAK,oBAAoB,GACzD,OAAO,OAAO,KAAK,KAAK,KAAK;CAE/B,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,mBAAmB,UAA4D;CAC1F,MAAM,SAAS,KACb,OACAA,MAAI,KAAK,WAAW,eAAe,MAAM,CAAC,GAC1CA,MAAI,UACJA,MAAI,YAAY,MAAM,UAAU,SAAS,IAAI,MAAM,SAAS,KAAK,CAAC,CACpE;CACA,IAAI,OAAO,WAAW,MAAM,UAAU,OAAO,SAAS,kBACpD,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,KAAK,MAAM;AAC3B;AAEA,MAAa,kBAAkB,SAAgD;CAC7E,IAAI,CAAC,KAAK,YAAY,GACpB,OAAO,OAAO,KAAK;CAErB,OAAO,gBAAgB,KAAK,SAAS,CAAC;AACxC;AAEA,MAAM,iBAAiB,SAAkB,SAAoC;CAC3E,IAAI,CAAC,QAAQ,gBAAgB,IAAI,GAC/B,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,gBAAgB,QAAQ,mBAAmB,MAAM,UAAU,MAAM,CAAC;AAClF;AAEA,MAAa,gBACV,aACA,SACCA,MAAI,UAAU,yBAAyB,SACrC,OAAO,gBAAgB,QAAQ,kBAAkB,MAAM,IAAI,CAAC,CAC9D,CAAC,CAAC,KAAK,OAAO,KAAK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AG,UAAU,CAAC,CAAC,UAAU,SACtD,SACA,MACA;CACA,MAAM,QAAQ,OAAO;CACrB,MAAM,QAAQ,KACZ,QAAQ,QACRA,MAAI,QAAQ,QAAQ,CAACA,MAAI,SAAS,MAAM,GAAG,CAAC,CAC9C;CACA,OAAO,OAAO,QAAQ,QAAQ,QAAQ,MAAM,WAAW,MAAM,KAAK,QAAQ,WAAW,GAAG,CAAC,GAAG;EAC1F,aAAa;EACb,SAAS;CACX,CAAC;CACD,OAAO,OAAO,QACZ,OACC,QAAQ,MAAM,UAAU,MAAM,KAAK,QAAQ,WAAW,GAAG,GAAG,MAAM,GACnE;EAAE,aAAa;EAAG,SAAS;CAAK,CAClC;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as lineOf, r as columnOf } from "./syntax-
|
|
1
|
+
import { m as lineOf, r as columnOf } from "./syntax-A3ga4Ksb.mjs";
|
|
2
2
|
import { Array, Order, Schema, pipe } from "effect";
|
|
3
3
|
// src/shared/lib/problem.ts
|
|
4
4
|
const RuleNameSchema = Schema.String.check(Schema.isPattern(/^[a-z]+(?:-[a-z]+)*$/u));
|
|
@@ -48,4 +48,4 @@ const describeFinding = (problem) => `[${problem.rule}] ${problem.message}`;
|
|
|
48
48
|
const formatProblem = (relative) => (problem) => `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;
|
|
49
49
|
export { problemAtPosition as a, problemAt as i, describeFinding as n, problemInFile as o, formatProblem as r, sortProblems as s, ProblemList as t };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=problem-
|
|
51
|
+
//# sourceMappingURL=problem-glqVxx3h.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"problem-
|
|
1
|
+
{"version":3,"file":"problem-glqVxx3h.mjs","names":["Arr"],"sources":["../src/shared/lib/problem.ts"],"sourcesContent":["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":";;;AAKA,MAAM,iBAAiB,OAAO,OAAO,MAAM,OAAO,UAAU,uBAAuB,CAAC;AAIpF,MAAM,gBAAgB,OAAO,OAAO;CAClC,MAAM,OAAO;CACb,MAAM,OAAO;CACb,QAAQ,OAAO;CACf,MAAM;CACN,SAAS,OAAO;AAClB,CAAC;AAID,MAAa,cAAc,OAAO,MAAM,aAAa;AAIrD,MAAM,QAAQ;AAOd,MAAa,qBACV,UACA,MAAc,EAAE,MAAM,UAA8B,aAA8B;CACjF;CACA;CACA;CACA;CACA;AACF;AAEF,MAAa,iBACV,UACA,MAAc,YACb,kBAAkB,IAAI,CAAC,CAAC,MAAM;CAAE,MAAM;CAAO,QAAQ;AAAM,GAAG,OAAO;AAOzE,MAAa,aACV,EAAE,MAAM,eACR,UAAyB;CACxB,MAAM,KAAK,cAAc,CAAC,CAAC;CAC3B,MAAM,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,GAC1FA,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"}
|
package/dist/publish.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as runCli } from "./runtime-
|
|
2
|
+
import { t as runCli } from "./runtime-mDBC8Yey.mjs";
|
|
3
|
+
import { n as importSpecifierOf, t as exportEntriesOf } from "./export-subpaths-D6ZLYZGy.mjs";
|
|
3
4
|
import { i as writeOutputs, n as actionsOidcToken, r as mask, t as BROKER } from "./credential-broker-9FMyTp1H.mjs";
|
|
4
|
-
import { Array, Config, Console, Effect, FileSystem, Option, Order, Path, Predicate, Record, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
5
|
+
import { Array, Config, Console, Duration, Effect, FileSystem, Option, Order, Path, Predicate, Record, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
5
6
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
6
7
|
import semver from "semver";
|
|
7
8
|
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
@@ -9,28 +10,31 @@ import { Base64 } from "effect/encoding";
|
|
|
9
10
|
import { arch, platform } from "node:os";
|
|
10
11
|
// ../github-workflow/src/shared/lib/process.ts
|
|
11
12
|
const SUCCESS = 0;
|
|
13
|
+
const FORCE_KILL_AFTER = Duration.seconds(10);
|
|
12
14
|
const taggedError$4 = Schema.TaggedError;
|
|
13
15
|
var CommandFailed = class extends taggedError$4()("CommandFailed", { message: Schema.String }) {};
|
|
14
16
|
const failed = ({ command, args }) => CommandFailed.make({ message: `${command} ${Array.join(args, " ")} failed` });
|
|
15
|
-
const exitCodeOf = Effect.fn("exitCodeOf")(function* exitCodeOf({ command, args, env, cwd }) {
|
|
17
|
+
const exitCodeOf = Effect.fn("exitCodeOf")(function* exitCodeOf({ command, args, env, cwd, forceKillAfter = FORCE_KILL_AFTER }) {
|
|
16
18
|
return yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make(command, args, {
|
|
17
19
|
cwd,
|
|
18
20
|
env,
|
|
19
21
|
extendEnv: true,
|
|
20
22
|
stdin: "ignore",
|
|
21
23
|
stdout: "inherit",
|
|
22
|
-
stderr: "inherit"
|
|
24
|
+
stderr: "inherit",
|
|
25
|
+
forceKillAfter
|
|
23
26
|
}));
|
|
24
27
|
});
|
|
25
28
|
const succeedsWith = (command) => exitCodeOf(command).pipe(Effect.map((code) => code === SUCCESS));
|
|
26
29
|
const mustSucceedWith = (command) => succeedsWith(command).pipe(Effect.filterOrFail((passed) => passed, () => failed(command)), Effect.asVoid);
|
|
27
|
-
const collected = Effect.fn("collected")(function* collected({ command, args, env, cwd }) {
|
|
30
|
+
const collected = Effect.fn("collected")(function* collected({ command, args, env, cwd, forceKillAfter = FORCE_KILL_AFTER }) {
|
|
28
31
|
const handle = yield* ChildProcess.make(command, args, {
|
|
29
32
|
cwd,
|
|
30
33
|
env,
|
|
31
34
|
extendEnv: true,
|
|
32
35
|
stdin: "ignore",
|
|
33
|
-
stderr: "inherit"
|
|
36
|
+
stderr: "inherit",
|
|
37
|
+
forceKillAfter
|
|
34
38
|
});
|
|
35
39
|
const [output, code] = yield* Effect.all([handle.stdout.pipe(Stream.decodeText(), Stream.mkString), handle.exitCode], { concurrency: "unbounded" });
|
|
36
40
|
return {
|
|
@@ -91,7 +95,6 @@ const checkExportTargets = Effect.fn("publish.checkExportTargets")(function* che
|
|
|
91
95
|
// src/features/publish-workspace/model/compat-manifest.ts
|
|
92
96
|
const PACKAGE_JSON_EXPORT = "./package.json";
|
|
93
97
|
const PATTERN = "*";
|
|
94
|
-
const ROOT_EXPORT = ".";
|
|
95
98
|
const UNVERSIONED$2 = "0.0.0";
|
|
96
99
|
const VITE = "vite";
|
|
97
100
|
/** @internal */
|
|
@@ -163,25 +166,14 @@ const compatCasesOf = (manifest) => pipe(nodeFloorOf(manifest), Option.match({
|
|
|
163
166
|
onNone: () => [],
|
|
164
167
|
onSome: (floor) => casesOf(manifest, floor)
|
|
165
168
|
}));
|
|
166
|
-
const isTypesOnly = (target) =>
|
|
167
|
-
|
|
168
|
-
onSome: (value) => Predicate.isReadonlyObject(value) && pipe(Record.keys(value), Array.every((key) => key === TYPES))
|
|
169
|
-
});
|
|
170
|
-
const exportedSubpaths = (exports) => {
|
|
171
|
-
const keys = Record.keys(exports);
|
|
172
|
-
if (!pipe(keys, Array.every(String$1.startsWith(ROOT_EXPORT)))) return [ROOT_EXPORT];
|
|
173
|
-
return pipe(keys, Array.filter((key) => key !== PACKAGE_JSON_EXPORT && !String$1.includes(PATTERN)(key)), Array.filter((key) => !isTypesOnly(Record.get(exports, key))));
|
|
174
|
-
};
|
|
169
|
+
const isTypesOnly = (target) => Predicate.isReadonlyObject(target) && pipe(Record.keys(target), Array.every((key) => key === TYPES));
|
|
170
|
+
const exportedSubpaths = (exports) => pipe(exportEntriesOf(exports), Array.filter(([subpath, target]) => subpath !== PACKAGE_JSON_EXPORT && !String$1.includes(PATTERN)(subpath) && !isTypesOnly(target)), Array.map(([subpath]) => subpath));
|
|
175
171
|
const subpathsOf = foldExports({
|
|
176
|
-
string: () => [
|
|
177
|
-
array: () => [
|
|
172
|
+
string: () => ["."],
|
|
173
|
+
array: () => ["."],
|
|
178
174
|
object: exportedSubpaths,
|
|
179
175
|
other: () => []
|
|
180
176
|
});
|
|
181
|
-
const specifierOf = (name, subpath) => {
|
|
182
|
-
if (subpath === ROOT_EXPORT) return name;
|
|
183
|
-
return `${name}${String$1.replace(ROOT_EXPORT, "")(subpath)}`;
|
|
184
|
-
};
|
|
185
177
|
const binFilesOf = (bin) => {
|
|
186
178
|
if (Predicate.isUndefined(bin)) return [];
|
|
187
179
|
if (Predicate.isString(bin)) return [bin];
|
|
@@ -193,7 +185,7 @@ const smokeTargetsOf = (manifest) => {
|
|
|
193
185
|
const exports = pipe(published, Option.flatMap(({ exports: own }) => Option.fromUndefinedOr(own)), Option.getOrElse(() => manifest.exports));
|
|
194
186
|
const bin = pipe(published, Option.flatMap(({ bin: own }) => Option.fromUndefinedOr(own)), Option.getOrElse(() => manifest.bin));
|
|
195
187
|
return {
|
|
196
|
-
imports: pipe(subpathsOf(exports), Array.map((subpath) =>
|
|
188
|
+
imports: pipe(subpathsOf(exports), Array.map((subpath) => importSpecifierOf(manifest.name, subpath))),
|
|
197
189
|
bins: binFilesOf(bin)
|
|
198
190
|
};
|
|
199
191
|
};
|