From 9a3f3717def2675f659cf6988e3c6e6a19f20f6d Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Sat, 14 Dec 2024 06:18:40 +0000 Subject: [PATCH] feat(lib): address type related FIXMEs --- .lune/exec.luau | 16 ++++++---------- toolchainlib/src/compression.luau | 18 ++++++++---------- toolchainlib/src/github.luau | 1 - toolchainlib/src/init.luau | 1 - toolchainlib/src/platform/toolchain.luau | 3 +-- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.lune/exec.luau b/.lune/exec.luau index f9b1c41..d87f8f6 100644 --- a/.lune/exec.luau +++ b/.lune/exec.luau @@ -21,10 +21,9 @@ export type IoStrategyMapping = { stderr: Option, } --- FIXME: remove unknown usage local DEFAULT_STDIO_STRATEGY: IoStrategyMapping = { - stdout = Option.Some("pipe" :: StdioStrategy) :: Option, - stderr = Option.Some("pipe" :: StdioStrategy) :: Option, + stdout = Option.Some("pipe" :: StdioStrategy), + stderr = Option.Some("pipe" :: StdioStrategy), } function CommandBuilder.new(program: string) return setmetatable( @@ -70,11 +69,10 @@ function CommandBuilder.withStdioStrategy( self: CommandBuilder, strategy: StdioStrategy | IoStrategyMapping ): CommandBuilder - -- FIXME: remove unknown usage self.stdioStrategy = Option.Some(if typeof(strategy) == "string" then { - stdout = Option.Some(strategy) :: Option, - stderr = Option.Some(strategy) :: Option, + stdout = Option.Some(strategy), + stderr = Option.Some(strategy), } else strategy) :: Option return self @@ -104,10 +102,8 @@ function CommandBuilder.exec(self: CommandBuilder): process.SpawnResult ) local child = process.spawn(self.program, self.args, { shell = if process.os == "windows" then "cmd.exe" else "bash", - stdio = self - .stdioStrategy - -- FIXME: remove unknown usage - :orOpt(Option.Some(DEFAULT_STDIO_STRATEGY) :: Option) + stdio = self.stdioStrategy + :orOpt(Option.Some(DEFAULT_STDIO_STRATEGY)) :map(function(mappings: IoStrategyMapping) local translatedMappings: process.SpawnOptionsStdio = {} for field, value in mappings do diff --git a/toolchainlib/src/compression.luau b/toolchainlib/src/compression.luau index 6e01ee0..6d4ffd6 100644 --- a/toolchainlib/src/compression.luau +++ b/toolchainlib/src/compression.luau @@ -19,16 +19,16 @@ local function detectFormat(fileName: string): Option revTable(fileNameParts) if fileNameParts[1] == "zip" then - return Option.Some("Zip" :: CompressionFormat) :: Option + return Option.Some("Zip" :: CompressionFormat) end if fileNameParts[2] == "tar" then if fileNameParts[1] == "gz" then - return Option.Some("TarGz" :: CompressionFormat) :: Option + return Option.Some("TarGz" :: CompressionFormat) end if fileNameParts[1] == "xz" then - return Option.Some("TarXz" :: CompressionFormat) :: Option + return Option.Some("TarXz" :: CompressionFormat) end end @@ -38,16 +38,15 @@ end -- TODO: Use a type function to make all CompressionFormat lowercase local decompress: { [CompressionFormat]: (compressed: buffer) -> Result } = { Zip = function(compressed: buffer) - -- FIXME: remove any usage return (Option.from(dirs.cacheDir()):map(function(cacheDir) local progCacheDir = cacheDir:join("pesde-bin") if not pathfs.isDir(progCacheDir) then pathfs.writeDir(progCacheDir) end - return progCacheDir :: pathfs.AsPath - end) :: Option):match({ - Some = function(dir) + return progCacheDir :: pathfs.Path + end)):match({ + Some = function(dir: pathfs.Path) -- Generate a unique file name and write the contents to the temporary file local tmpFile = dir:join(`{serde.hash("blake3", compressed)}.zip`) local tmpFilePath = tmpFile:toString() @@ -65,19 +64,18 @@ local decompress: { [CompressionFormat]: (compressed: buffer) -> Result, + ), stderr = Option.Some( if process.env.PESDE_LOG == "debug" then "forward" else "pipe" :: CommandBuilder.StdioStrategy - ) :: Option, + ), } :: CommandBuilder.IoStrategyMapping) :intoChildProcess() diff --git a/toolchainlib/src/github.luau b/toolchainlib/src/github.luau index a956f2a..0278ef7 100644 --- a/toolchainlib/src/github.luau +++ b/toolchainlib/src/github.luau @@ -69,7 +69,6 @@ function Github.new(repo: string, config: Option) ) end --- FIXME: Remove unknown usage here function Github.queueTransactions(self: Github, operations: { GithubOperation }): { Result } local queue: { (retries: number) -> Result } = table.create(#operations) diff --git a/toolchainlib/src/init.luau b/toolchainlib/src/init.luau index 6148d82..00b36fc 100644 --- a/toolchainlib/src/init.luau +++ b/toolchainlib/src/init.luau @@ -190,7 +190,6 @@ function installTool(tool: ToolId, installPath: pathfs.Path): number for _, asset in assets do local desc = PlatformDescriptor.fromString(asset.name) local descWithArch = desc:map(function(inner: PlatformDescriptor.PlatformDescriptor) - -- FIXME: unknown usage return inner end) diff --git a/toolchainlib/src/platform/toolchain.luau b/toolchainlib/src/platform/toolchain.luau index 78f8c6b..4bf07c5 100644 --- a/toolchainlib/src/platform/toolchain.luau +++ b/toolchainlib/src/platform/toolchain.luau @@ -8,8 +8,7 @@ return { detect = function(str: string): Option for _, toolchain: Toolchain in TOOLCHAINS do if string.find(str, toolchain) then - -- FIXME: remove any usage - return Option.Some(toolchain :: any) :: Option + return Option.Some(toolchain :: Toolchain) end end