@r_masseater/vite-plus-adopt 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -69
- package/dist/attempt-B93fjWiJ.mjs.map +1 -1
- package/dist/attw.mjs.map +1 -1
- package/dist/cli.mjs +45 -17
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-BdAPwzCc.mjs → config-BR_LIdmG.mjs} +3 -1
- package/dist/config-BR_LIdmG.mjs.map +1 -0
- package/dist/fsd.d.mts +3 -3
- package/dist/fsd.mjs +2 -1
- package/dist/fsd.mjs.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +1 -1
- package/dist/{install-C-6lZ_z7.mjs → install-D6kuA6Oe.mjs} +7 -2
- package/dist/install-D6kuA6Oe.mjs.map +1 -0
- package/dist/json-D-rhjlSM.mjs.map +1 -1
- package/dist/postinstall.mjs +1 -1
- package/dist/{types-LygeEwCK.d.mts → types-D-w4yqEn.d.mts} +2 -1
- package/package.json +11 -11
- package/dist/config-BdAPwzCc.mjs.map +0 -1
- package/dist/install-C-6lZ_z7.mjs.map +0 -1
|
@@ -5,6 +5,7 @@ import { TextlintRcConfig } from "@textlint/config-loader";
|
|
|
5
5
|
import { UserConfig } from "@commitlint/types";
|
|
6
6
|
import { Configuration, Rule } from "markdownlint";
|
|
7
7
|
declare const DEPENDENCY_FIELDS: readonly ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
|
|
8
|
+
/** @internal */
|
|
8
9
|
type DependencyField = (typeof DEPENDENCY_FIELDS)[number];
|
|
9
10
|
interface CommitlintConfig extends Readonly<UserConfig> {}
|
|
10
11
|
type SteigerConfig = readonly ReturnType<typeof defineConfig>[number][];
|
|
@@ -76,4 +77,4 @@ declare module "vite" {
|
|
|
76
77
|
interface UserConfig extends ToolSections {}
|
|
77
78
|
}
|
|
78
79
|
export { FallowConfig as a, SteigerSection as c, DependencyRules as i, TextlintConfig as l, BetterleaksRule as n, MarkdownlintConfig as o, CommitlintConfig as r, SteigerConfig as s, BetterleaksConfig as t, ToolSections as u };
|
|
79
|
-
//# sourceMappingURL=types-
|
|
80
|
+
//# sourceMappingURL=types-D-w4yqEn.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/vite-plus-adopt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Adopt Betterleaks, actionlint, zizmor, commitlint, textlint, Steiger and dependency checks into Vite+ through the settings in vite.config.ts, and ship the Feature-Sliced Design Steiger plugin and @arethetypeswrong/core for TypeScript 7.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actionlint",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@commitlint/lint": "21.2.4",
|
|
62
62
|
"@commitlint/load": "21.2.4",
|
|
63
63
|
"@commitlint/types": "21.2.3",
|
|
64
|
-
"@effect/platform-node-shared": "4.1.
|
|
64
|
+
"@effect/platform-node-shared": "4.1.4",
|
|
65
65
|
"@loaderkit/resolve": "1.0.6",
|
|
66
66
|
"@textlint/config-loader": "15.8.0",
|
|
67
67
|
"@textlint/kernel": "15.8.0",
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"fastest-levenshtein": "^1.0.16",
|
|
70
70
|
"fflate": "^0.8.3",
|
|
71
71
|
"markdownlint": "0.42.1",
|
|
72
|
-
"minimatch": "11.0.
|
|
72
|
+
"minimatch": "11.0.8",
|
|
73
73
|
"pluralize": "8.0.0",
|
|
74
74
|
"semver": "7.8.6",
|
|
75
75
|
"smol-toml": "1.9.1",
|
|
76
|
-
"steiger": "0.
|
|
76
|
+
"steiger": "0.10.0",
|
|
77
77
|
"textlint": "15.8.0",
|
|
78
78
|
"tsconfck": "3.1.6",
|
|
79
79
|
"validate-npm-package-name": "8.0.0",
|
|
@@ -81,18 +81,18 @@
|
|
|
81
81
|
"yaml": "2.9.1"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@effect/platform-node": "4.1.
|
|
85
|
-
"@effect/vitest": "4.1.
|
|
84
|
+
"@effect/platform-node": "4.1.4",
|
|
85
|
+
"@effect/vitest": "4.1.4",
|
|
86
86
|
"@feature-sliced/filesystem": "3.1.1",
|
|
87
87
|
"@feature-sliced/steiger-plugin": "0.8.2",
|
|
88
88
|
"@size-limit/file": "14.3.0",
|
|
89
89
|
"@types/node": "26.6.6",
|
|
90
90
|
"@types/semver": "7.8.0",
|
|
91
|
-
"effect": "4.1.
|
|
91
|
+
"effect": "4.1.4",
|
|
92
92
|
"size-limit": "14.3.0",
|
|
93
93
|
"typescript": "7.1.0-beta",
|
|
94
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@1.
|
|
95
|
-
"vite-plus": "1.
|
|
94
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.6.0",
|
|
95
|
+
"vite-plus": "1.6.0"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"effect": "^4.1.2",
|
|
@@ -108,12 +108,12 @@
|
|
|
108
108
|
"!dist/fsd.mjs",
|
|
109
109
|
"!dist/attw.mjs"
|
|
110
110
|
],
|
|
111
|
-
"limit": "
|
|
111
|
+
"limit": "11045 B"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"name": "fsd",
|
|
115
115
|
"path": "dist/fsd.mjs",
|
|
116
|
-
"limit": "
|
|
116
|
+
"limit": "9412 B"
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"name": "attw",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-BdAPwzCc.mjs","names":["Arr","Fn"],"sources":["../src/config.ts"],"sourcesContent":["import { Effect, FileSystem, Function as Fn, Option, Path, Array as Arr, pipe } from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { attempt } from \"./attempt.ts\";\nimport { configMissing } from \"./errors.ts\";\nimport type { VpToolsError } from \"./errors.ts\";\nimport type { ToolSection, ToolSections } from \"./types.ts\";\n\ntype FileServices = FileSystem.FileSystem | Path.Path;\n\nconst CONFIG_FILES = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\", \"vite.config.mjs\"];\n\nconst findConfigFile = (root: string): Effect.Effect<string, VpToolsError, FileServices> =>\n Effect.gen(function* find() {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const existing = yield* pipe(\n CONFIG_FILES,\n Arr.map((name) => path.join(root, name)),\n Effect.filter((file) => fs.exists(file).pipe(Effect.orElseSucceed(() => false))),\n );\n return yield* Effect.fromOption(Arr.head(existing)).pipe(\n Effect.mapError(() => configMissing(`No vite.config file in ${root}`)),\n );\n });\n\nconst loadViteConfig = (root: string): Effect.Effect<ToolSections, VpToolsError, FileServices> =>\n findConfigFile(root).pipe(\n Effect.flatMap((file) => attempt(\"vite.config\")(() => resolveConfigFromFile(file))),\n );\n\nconst requireSection =\n <Key extends ToolSection>(key: Key) =>\n (config: ToolSections): Effect.Effect<NonNullable<ToolSections[Key]>, VpToolsError> =>\n Effect.fromOption(Option.fromNullishOr(config[key])).pipe(\n Effect.mapError(() => configMissing(`vite.config has no \"${key}\" section`)),\n );\n\nconst DATA_FIRST_ARITY = 2;\n\nconst loadSection: {\n <Key extends ToolSection>(\n key: Key,\n ): (root: string) => Effect.Effect<NonNullable<ToolSections[Key]>, VpToolsError, FileServices>;\n <Key extends ToolSection>(\n root: string,\n key: Key,\n ): Effect.Effect<NonNullable<ToolSections[Key]>, VpToolsError, FileServices>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Key extends ToolSection>(\n root: string,\n key: Key,\n ): Effect.Effect<NonNullable<ToolSections[Key]>, VpToolsError, FileServices> =>\n loadViteConfig(root).pipe(Effect.flatMap(requireSection(key))),\n);\n\n/** @internal */\nexport { loadSection, loadViteConfig };\n/** @internal */\nexport type { FileServices };\n"],"mappings":";;;;AAUA,MAAM,eAAe;CAAC;CAAkB;CAAmB;CAAkB;AAAiB;AAE9F,MAAM,kBAAkB,SACtB,OAAO,IAAI,UAAU,OAAO;CAC1B,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,WAAW,OAAO,KACtB,cACAA,MAAI,KAAK,SAAS,KAAK,KAAK,MAAM,IAAI,CAAC,GACvC,OAAO,QAAQ,SAAS,GAAG,OAAO,IAAI,CAAC,CAAC,KAAK,OAAO,oBAAoB,KAAK,CAAC,CAAC,CACjF;CACA,OAAO,OAAO,OAAO,WAAWA,MAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAClD,OAAO,eAAe,cAAc,0BAA0B,MAAM,CAAC,CACvE;AACF,CAAC;AAEH,MAAM,kBAAkB,SACtB,eAAe,IAAI,CAAC,CAAC,KACnB,OAAO,SAAS,SAAS,QAAQ,aAAa,CAAC,OAAO,sBAAsB,IAAI,CAAC,CAAC,CACpF;AAEF,MAAM,kBACsB,SACzB,WACC,OAAO,WAAW,OAAO,cAAc,OAAO,IAAI,CAAC,CAAC,CAAC,KACnD,OAAO,eAAe,cAAc,uBAAuB,IAAI,UAAU,CAAC,CAC5E;AAIJ,MAAM,cAQFC,SAAG,KACL,IAEE,MACA,QAEA,eAAe,IAAI,CAAC,CAAC,KAAK,OAAO,QAAQ,eAAe,GAAG,CAAC,CAAC,CACjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install-C-6lZ_z7.mjs","names":["Fn","Str","Arr","encodeHex","Rec"],"sources":["../src/node-services.ts","../src/output.ts","../src/run-cli.ts","../src/binaries.ts","../src/vendor.ts","../src/install.ts"],"sourcesContent":["import {\n NodeChildProcessSpawner,\n NodeFileSystem,\n NodePath,\n NodeStdio,\n} from \"@effect/platform-node-shared\";\nimport { Layer } from \"effect\";\n\nconst nodeServicesLayer = Layer.provideMerge(\n NodeChildProcessSpawner.layer,\n Layer.mergeAll(NodeFileSystem.layer, NodePath.layer, NodeStdio.layer),\n);\n\n/** @internal */\nexport { nodeServicesLayer };\n","import { Effect, Stdio, Stream, Function as Fn } from \"effect\";\n\nimport { checksFailed } from \"./errors.ts\";\nimport type { VpToolsError } from \"./errors.ts\";\nimport type { Report } from \"./report.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\ntype Sink = \"stdout\" | \"stderr\";\n\nconst writeTo: {\n (text: string): (sink: Sink) => Effect.Effect<void, never, Stdio.Stdio>;\n (sink: Sink, text: string): Effect.Effect<void, never, Stdio.Stdio>;\n} = Fn.dual(DATA_FIRST_ARITY, (sink: Sink, text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* write() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio[sink]()), Effect.orDie);\n }),\n);\n\nconst finish = (report: Report): Effect.Effect<void, VpToolsError, Stdio.Stdio> => {\n if (!report.valid) {\n return Effect.fail(checksFailed(report.output));\n }\n if (report.output === \"\") {\n return Effect.void;\n }\n return writeTo(\"stdout\", `${report.output}\\n`);\n};\n\n/** @internal */\nexport { finish, writeTo };\n/** @internal */\nexport type { Sink };\n","import { runMain } from \"@effect/platform-node-shared/NodeRuntime\";\nimport { Cause, Effect, Layer, Option, Schema, pipe } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport type { CommandServices } from \"./command.ts\";\nimport { VpToolsError } from \"./errors.ts\";\nimport { nodeServicesLayer } from \"./node-services.ts\";\nimport { writeTo } from \"./output.ts\";\n\nconst reportFailure = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> => {\n const message = pipe(\n Cause.findErrorOption(cause),\n Option.filter(Schema.is(VpToolsError)),\n Option.match({\n onNone: () => Cause.pretty(cause),\n onSome: (error) => error.message,\n }),\n );\n return writeTo(\"stderr\", `${message}\\n`);\n};\n\nconst runCli = <Failure>(program: Effect.Effect<void, Failure, CommandServices>): void => {\n const reported = program.pipe(Effect.tapCause(reportFailure));\n const main = Layer.build(nodeServicesLayer).pipe(\n Effect.flatMap((services) => Effect.provideContext(reported, services)),\n Effect.scoped,\n );\n runMain(main, { disableErrorReporting: true });\n};\n\n/** @internal */\nexport { runCli };\n","import { String as Str } from \"effect\";\n\ntype Platform = \"darwin-arm64\" | \"darwin-x64\" | \"linux-arm64\" | \"linux-x64\" | \"win32-x64\";\n\ntype Archive = \"tar.gz\" | \"zip\";\n\ninterface BinaryAsset {\n readonly url: string;\n readonly sha256: string;\n readonly archive: Archive;\n}\n\ninterface Binary {\n readonly name: string;\n readonly version: string;\n readonly assets: Readonly<Record<Platform, BinaryAsset>>;\n}\n\nconst archiveOf = (file: string): Archive => {\n if (Str.endsWith(\".zip\")(file)) {\n return \"zip\";\n }\n return \"tar.gz\";\n};\n\nconst releaseAsset =\n (release: string) =>\n (file: string, sha256: string): BinaryAsset => ({\n url: `${release}/${file}`,\n sha256,\n archive: archiveOf(file),\n });\n\nconst betterleaksAsset = releaseAsset(\n \"https://github.com/betterleaks/betterleaks/releases/download/v2.0.0-rc.7\",\n);\n\nconst BETTERLEAKS: Binary = {\n name: \"betterleaks\",\n version: \"2.0.0-rc.7\",\n assets: {\n \"darwin-arm64\": betterleaksAsset(\n \"betterleaks_2.0.0-rc.7_darwin_arm64.tar.gz\",\n \"d5052b4789752e3d9995c0b71a5b531aea747455ba4f8d1534c90b41e03f906c\",\n ),\n \"darwin-x64\": betterleaksAsset(\n \"betterleaks_2.0.0-rc.7_darwin_x64.tar.gz\",\n \"b3be0c6b4b91036a6d8b98e47642470a5a872d4bff08b8ee34348e9baf1e3434\",\n ),\n \"linux-arm64\": betterleaksAsset(\n \"betterleaks_2.0.0-rc.7_linux_arm64.tar.gz\",\n \"32fcd5a77d7c3c2d97cc615c5d70344d0c62b5a36f38568ce8ec72e62783acad\",\n ),\n \"linux-x64\": betterleaksAsset(\n \"betterleaks_2.0.0-rc.7_linux_x64.tar.gz\",\n \"230ef42dc3a0ee35e5148b7b4e9280224a412ef100cd4e74d3d6681d94e6ccb8\",\n ),\n \"win32-x64\": betterleaksAsset(\n \"betterleaks_2.0.0-rc.7_windows_x64.zip\",\n \"36db668ba12b55537a11cc45cd61565ab7f4f23ce606e0827206f49048a5183e\",\n ),\n },\n};\n\nconst actionlintAsset = releaseAsset(\n \"https://github.com/rhysd/actionlint/releases/download/v1.7.12\",\n);\n\nconst ACTIONLINT: Binary = {\n name: \"actionlint\",\n version: \"1.7.12\",\n assets: {\n \"darwin-arm64\": actionlintAsset(\n \"actionlint_1.7.12_darwin_arm64.tar.gz\",\n \"aba9ced2dee8d27fecca3dc7feb1a7f9a52caefa1eb46f3271ea66b6e0e6953f\",\n ),\n \"darwin-x64\": actionlintAsset(\n \"actionlint_1.7.12_darwin_amd64.tar.gz\",\n \"5b44c3bc2255115c9b69e30efc0fecdf498fdb63c5d58e17084fd5f16324c644\",\n ),\n \"linux-arm64\": actionlintAsset(\n \"actionlint_1.7.12_linux_arm64.tar.gz\",\n \"325e971b6ba9bfa504672e29be93c24981eeb1c07576d730e9f7c8805afff0c6\",\n ),\n \"linux-x64\": actionlintAsset(\n \"actionlint_1.7.12_linux_amd64.tar.gz\",\n \"8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8\",\n ),\n \"win32-x64\": actionlintAsset(\n \"actionlint_1.7.12_windows_amd64.zip\",\n \"6e7241b51e6817ea6a047693d8e6fed13b31819c9a0dd6c5a726e1592d22f6e9\",\n ),\n },\n};\n\nconst zizmorAsset = releaseAsset(\"https://github.com/zizmorcore/zizmor/releases/download/v1.32.0\");\n\nconst ZIZMOR: Binary = {\n name: \"zizmor\",\n version: \"1.32.0\",\n assets: {\n \"darwin-arm64\": zizmorAsset(\n \"zizmor-aarch64-apple-darwin.tar.gz\",\n \"6efed18c4539a663fd3c851a2be9533fd8456c4e646d9416206da059154a0d3c\",\n ),\n \"darwin-x64\": zizmorAsset(\n \"zizmor-x86_64-apple-darwin.tar.gz\",\n \"6983143c719ada6845a69cc4dd2bacc215f971662fecd8bbd2678388e5ce5969\",\n ),\n \"linux-arm64\": zizmorAsset(\n \"zizmor-aarch64-unknown-linux-gnu.tar.gz\",\n \"cb152b207f815116d7fa1c1ee4614f61578803351395052908095e79adfd9fd0\",\n ),\n \"linux-x64\": zizmorAsset(\n \"zizmor-x86_64-unknown-linux-gnu.tar.gz\",\n \"bb110cc765eca9cd7efb2e284a956be5974c60027b0970f16397d86208a9957b\",\n ),\n \"win32-x64\": zizmorAsset(\n \"zizmor-x86_64-pc-windows-msvc.zip\",\n \"d284a16e09d9df4ce2c000357e7b59bd531be093bea5718a1ce225b449b59d49\",\n ),\n },\n};\n\nconst PLATFORMS: readonly Platform[] = [\n \"darwin-arm64\",\n \"darwin-x64\",\n \"linux-arm64\",\n \"linux-x64\",\n \"win32-x64\",\n];\n\nexport { ACTIONLINT, BETTERLEAKS, PLATFORMS, ZIZMOR };\nexport type { Archive, Binary, BinaryAsset, Platform };\n","import { Context } from \"effect\";\n\nconst VendorDirectory = Context.Reference<string>(\"vite-plus-adopt/VendorDirectory\", {\n defaultValue: () => `${import.meta.dirname}/../vendor`,\n});\n\nexport { VendorDirectory };\n","import { untar } from \"@andrewbranch/untar.js\";\nimport { Array as Arr, Effect, FileSystem, Path, pipe, Record as Rec } from \"effect\";\nimport type { Option, PlatformError } from \"effect\";\nimport { encode as encodeHex } from \"effect/encoding/Hex\";\nimport { HttpClient } from \"effect/http\";\nimport { unzip } from \"fflate\";\n\nimport { attempt } from \"./attempt.ts\";\nimport { PLATFORMS } from \"./binaries.ts\";\nimport type { Binary, BinaryAsset, Platform } from \"./binaries.ts\";\nimport { configMissing, toolFailed } from \"./errors.ts\";\nimport type { VpToolsError } from \"./errors.ts\";\nimport { VendorDirectory } from \"./vendor.ts\";\n\ntype Entries = ReadonlyMap<string, Uint8Array>;\n\ninterface Download {\n readonly binary: Binary;\n readonly platform: Platform;\n readonly data: Uint8Array;\n}\n\ntype InstallServices = FileSystem.FileSystem | Path.Path;\n\ntype InstallError = VpToolsError | PlatformError.PlatformError;\n\nconst EXECUTABLE = 0o755;\n\nconst NOT_INSTALLED =\n \"was not installed. Allow the postinstall of @r_masseater/vite-plus-adopt in allowBuilds of pnpm-workspace.yaml and run vp install.\";\n\nconst currentPlatform = (): Option.Option<Platform> =>\n Arr.findFirst(PLATFORMS, (platform) => platform === `${process.platform}-${process.arch}`);\n\nconst executableName = (binary: Binary, platform: Platform): string => {\n if (platform === \"win32-x64\") {\n return `${binary.name}.exe`;\n }\n return binary.name;\n};\n\nconst assetOf = ({ binary, platform }: Download): BinaryAsset => binary.assets[platform];\n\nconst download = (\n binary: Binary,\n asset: BinaryAsset,\n): Effect.Effect<Uint8Array, VpToolsError, HttpClient.HttpClient> =>\n Effect.gen(function* fetchAsset() {\n const httpClient = yield* HttpClient.HttpClient;\n const client = HttpClient.filterStatusOk(httpClient);\n const response = yield* client.get(asset.url);\n const body = yield* response.arrayBuffer;\n return new Uint8Array(body);\n }).pipe(Effect.mapError(toolFailed(binary.name)));\n\nconst verify = (fetched: Download): Effect.Effect<Download, VpToolsError> => {\n const asset = assetOf(fetched);\n const failed = toolFailed(fetched.binary.name);\n const data = new Uint8Array(fetched.data);\n return attempt(fetched.binary.name)(() => crypto.subtle.digest(\"SHA-256\", data)).pipe(\n Effect.map((digest) => encodeHex(new Uint8Array(digest))),\n Effect.filterOrFail(\n (digest) => digest === asset.sha256,\n (digest) => failed(`${asset.url} has SHA-256 ${digest}, expected ${asset.sha256}`),\n ),\n Effect.as(fetched),\n );\n};\n\nconst gunzipped = (data: Uint8Array): Effect.Effect<ArrayBuffer, VpToolsError> => {\n const compressed = new Blob([new Uint8Array(data)]).stream();\n return attempt(\"gunzip\")(() =>\n new Response(compressed.pipeThrough(new DecompressionStream(\"gzip\"))).arrayBuffer(),\n );\n};\n\nconst tarEntries = (data: Uint8Array): Effect.Effect<Entries, VpToolsError> =>\n gunzipped(data).pipe(\n Effect.map(untar),\n Effect.map(\n (files) =>\n new Map(\n pipe(\n files,\n Arr.map((file) => [file.name, file.fileData] as const),\n ),\n ),\n ),\n );\n\nconst zipEntries = (data: Uint8Array): Effect.Effect<Entries, VpToolsError> =>\n Effect.callback<Entries, VpToolsError>((resume) => {\n unzip(data, (failure, files) => {\n if (failure === null) {\n const entries: Entries = new Map(Rec.toEntries(files));\n resume(Effect.succeed(entries));\n return;\n }\n resume(Effect.fail(toolFailed(\"unzip\")(failure)));\n });\n });\n\nconst entriesOf = (\n asset: BinaryAsset,\n): ((data: Uint8Array) => Effect.Effect<Entries, VpToolsError>) => {\n if (asset.archive === \"zip\") {\n return zipEntries;\n }\n return tarEntries;\n};\n\nconst extract = (fetched: Download): Effect.Effect<Uint8Array, VpToolsError> => {\n const asset = assetOf(fetched);\n const executable = executableName(fetched.binary, fetched.platform);\n return entriesOf(asset)(fetched.data).pipe(\n Effect.flatMap((files) => Effect.fromNullishOr(files.get(executable))),\n Effect.mapError(() => toolFailed(fetched.binary.name)(`${asset.url} has no ${executable}`)),\n );\n};\n\nconst binaryPath = (binary: Binary, platform: Platform): Effect.Effect<string, never, Path.Path> =>\n Effect.gen(function* vendoredPath() {\n const path = yield* Path.Path;\n const vendor = yield* VendorDirectory;\n return path.join(vendor, binary.name, binary.version, executableName(binary, platform));\n });\n\nconst place = (\n fetched: Download,\n bytes: Uint8Array,\n): Effect.Effect<void, PlatformError.PlatformError, InstallServices> =>\n Effect.gen(function* write() {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = yield* binaryPath(fetched.binary, fetched.platform);\n yield* fs.makeDirectory(path.dirname(file), { recursive: true });\n yield* Effect.scoped(\n Effect.gen(function* stage() {\n const staging = yield* fs.makeTempDirectoryScoped({\n directory: path.dirname(file),\n prefix: \".partial-\",\n });\n const partial = path.join(staging, path.basename(file));\n yield* fs.writeFile(partial, bytes);\n yield* fs.chmod(partial, EXECUTABLE);\n yield* fs.rename(partial, file);\n }),\n );\n });\n\nconst unpack = (fetched: Download): Effect.Effect<void, InstallError, InstallServices> =>\n verify(fetched).pipe(\n Effect.flatMap(extract),\n Effect.flatMap((bytes) => place(fetched, bytes)),\n );\n\nconst platformOf = (binary: Binary): Effect.Effect<Platform, VpToolsError> =>\n pipe(\n currentPlatform(),\n Effect.fromOption,\n Effect.mapError(() =>\n toolFailed(binary.name)(`no release for ${process.platform}-${process.arch}`),\n ),\n );\n\nconst isPlaced = (\n binary: Binary,\n platform: Platform,\n): Effect.Effect<boolean, PlatformError.PlatformError, InstallServices> =>\n Effect.gen(function* placed() {\n const fs = yield* FileSystem.FileSystem;\n const file = yield* binaryPath(binary, platform);\n return yield* fs.exists(file);\n });\n\nconst installBinary = (\n binary: Binary,\n): Effect.Effect<\n void,\n VpToolsError | PlatformError.PlatformError,\n FileSystem.FileSystem | HttpClient.HttpClient | Path.Path\n> =>\n Effect.gen(function* install() {\n const platform = yield* platformOf(binary);\n if (yield* isPlaced(binary, platform)) {\n return;\n }\n const data = yield* download(binary, binary.assets[platform]);\n yield* unpack({ binary, platform, data });\n });\n\nconst locateBinary = (\n binary: Binary,\n): Effect.Effect<\n string,\n VpToolsError | PlatformError.PlatformError,\n FileSystem.FileSystem | Path.Path\n> =>\n Effect.gen(function* locate() {\n const platform = yield* platformOf(binary);\n if (!(yield* isPlaced(binary, platform))) {\n return yield* configMissing(`${binary.name} ${binary.version} ${NOT_INSTALLED}`);\n }\n return yield* binaryPath(binary, platform);\n });\n\n/** @internal */\nexport { installBinary, locateBinary };\n"],"mappings":";;;;;;;;;AAQA,MAAM,oBAAoB,MAAM,aAC9B,wBAAwB,OACxB,MAAM,SAAS,eAAe,OAAO,SAAS,OAAO,UAAU,KAAK,CACtE;;ACDA,MAAM,UAGFA,SAAG,KAAK,IAAmB,MAAY,SACzC,OAAO,IAAI,UAAU,QAAQ;CAC3B,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,KAAK,CAAC,CAAC,GAAG,OAAO,KAAK;AAC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