diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7eb7d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ + + +# LPM + +/out +/lpm_modules \ No newline at end of file diff --git a/.luaurc b/.luaurc new file mode 100644 index 0000000..8b5aba8 --- /dev/null +++ b/.luaurc @@ -0,0 +1,5 @@ +{ + "aliases": { + "lpm": "./lpm_modules/" + } +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..40abe42 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "luau-lsp.require.directoryAliases": { + "@lpm/": "./lpm_modules/", + "@lune/": "~/.lune/.typedefs/0.8.0/" + }, + "luau-lsp.require.mode": "relativeToFile", + "luau-lsp.types.definitionFiles": [ + "C:\\Users\\plain/.lpm/.typedefs/1.0.1/def.d.lua" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1bfe499 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# asset-dl + +Download assets by version. + +## Usage + +```bash +asset-dl [VERSION NUMBER] +``` diff --git a/lpm-package.toml b/lpm-package.toml new file mode 100644 index 0000000..edfe15b --- /dev/null +++ b/lpm-package.toml @@ -0,0 +1,11 @@ +# Autogenerated by Spearhead-Industries/lpm + +author = "plainenglish" +description = "CLI Tool for downloading roblox assets by version." +entrypoint = "./src/main.lua" +licence = "MIT" +name = "asset-dl" +repository = "" +version = "1.0.0" + +[dependencies] diff --git a/src/main.lua b/src/main.lua new file mode 100644 index 0000000..eb85461 --- /dev/null +++ b/src/main.lua @@ -0,0 +1,34 @@ +local process = require("@lune/process"); +local net = require("@lune/net"); +local fs = require("@lune/fs"); + +function main(argc: number, argv: {string}): number + local asset_id = argv[1]; + local output = argv[2]; + local version_id = argv[3]; + + local ver = ""; + if version_id then + ver = `version/{version_id}`; + end + + local info = net.request({ + url = `https://assetdelivery.roblox.com/v1/assetId/{asset_id}/{ver}` + }); + + assert(info.ok, "Request for asset metadata failed."); + info = net.jsonDecode(info.body); + assert(info.location, "No location available"); + + local asset = net.request({ + url = info.location + }); + + assert(asset.ok, "Asset failed to download"); + + fs.writeFile(output, asset.body); + + return 0; +end + +process.exit(main(#process.args, process.args)) \ No newline at end of file