diff options
| author | V1K1NGbg <victor@ilchev.com> | 2024-08-22 17:49:00 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
| commit | cfca48e5fcebb4e491b34097c77abc222baab150 (patch) | |
| tree | f4f658003491c35f0a722d77045c65ad9a3b25a9 /src | |
| parent | d7e2df280c9855521ed8b428cf2566daba61c7ee (diff) | |
| download | luarocks-cfca48e5fcebb4e491b34097c77abc222baab150.tar.gz luarocks-cfca48e5fcebb4e491b34097c77abc222baab150.tar.bz2 luarocks-cfca48e5fcebb4e491b34097c77abc222baab150.zip | |
Teal: convert luarocks.cmd.upload
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/upload.tl (renamed from src/luarocks/cmd/upload.lua) | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/luarocks/cmd/upload.lua b/src/luarocks/cmd/upload.tl index 6b84e452..df544d13 100644 --- a/src/luarocks/cmd/upload.lua +++ b/src/luarocks/cmd/upload.tl | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | 1 | ||
| 2 | local upload = {} | 2 | local record upload |
| 3 | record Response | ||
| 4 | module: string | ||
| 5 | is_new: boolean | ||
| 6 | module_url: boolean | ||
| 7 | manifests: {string} | ||
| 8 | record version | ||
| 9 | id: string | ||
| 10 | end | ||
| 11 | end | ||
| 12 | end | ||
| 3 | 13 | ||
| 4 | local signing = require("luarocks.signing") | 14 | local signing = require("luarocks.signing") |
| 5 | local util = require("luarocks.util") | 15 | local util = require("luarocks.util") |
| @@ -8,7 +18,13 @@ local pack = require("luarocks.pack") | |||
| 8 | local cfg = require("luarocks.core.cfg") | 18 | local cfg = require("luarocks.core.cfg") |
| 9 | local Api = require("luarocks.upload.api") | 19 | local Api = require("luarocks.upload.api") |
| 10 | 20 | ||
| 11 | function upload.add_to_parser(parser) | 21 | local type Response = upload.Response |
| 22 | |||
| 23 | local type Parser = require("luarocks.vendor.argparse").Parser | ||
| 24 | |||
| 25 | local type Args = require("luarocks.core.types.args").Args | ||
| 26 | |||
| 27 | function upload.add_to_parser(parser: Parser) | ||
| 12 | local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) ".. | 28 | local cmd = parser:command("upload", "Pack a source rock file (.src.rock extension) ".. |
| 13 | "and upload it and the rockspec to the public rocks repository.", util.see_also()) | 29 | "and upload it and the rockspec to the public rocks repository.", util.see_also()) |
| 14 | :summary("Upload a rockspec to the public rocks repository.") | 30 | :summary("Upload a rockspec to the public rocks repository.") |
| @@ -31,11 +47,11 @@ function upload.add_to_parser(parser) | |||
| 31 | cmd:flag("--debug"):hidden(true) | 47 | cmd:flag("--debug"):hidden(true) |
| 32 | end | 48 | end |
| 33 | 49 | ||
| 34 | local function is_dev_version(version) | 50 | local function is_dev_version(version: string): string |
| 35 | return version:match("^dev") or version:match("^scm") | 51 | return version:match("^dev") or version:match("^scm") |
| 36 | end | 52 | end |
| 37 | 53 | ||
| 38 | function upload.command(args) | 54 | function upload.command(args: Args): boolean, string, string |
| 39 | local api, err = Api.new(args) | 55 | local api, err = Api.new(args) |
| 40 | if not api then | 56 | if not api then |
| 41 | return nil, err | 57 | return nil, err |
| @@ -53,7 +69,7 @@ function upload.command(args) | |||
| 53 | local res, err = api:method("check_rockspec", { | 69 | local res, err = api:method("check_rockspec", { |
| 54 | package = rockspec.package, | 70 | package = rockspec.package, |
| 55 | version = rockspec.version | 71 | version = rockspec.version |
| 56 | }) | 72 | }) as (Response, string) |
| 57 | if not res then return nil, err end | 73 | if not res then return nil, err end |
| 58 | 74 | ||
| 59 | if not res.module then | 75 | if not res.module then |
| @@ -63,8 +79,8 @@ function upload.command(args) | |||
| 63 | return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload") | 79 | return nil, "Revision "..rockspec.version.." already exists on the server. "..util.see_help("upload") |
| 64 | end | 80 | end |
| 65 | 81 | ||
| 66 | local sigfname | 82 | local sigfname: string |
| 67 | local rock_sigfname | 83 | local rock_sigfname: string |
| 68 | 84 | ||
| 69 | if args.sign then | 85 | if args.sign then |
| 70 | sigfname, err = signing.sign_file(args.rockspec) | 86 | sigfname, err = signing.sign_file(args.rockspec) |
| @@ -74,7 +90,7 @@ function upload.command(args) | |||
| 74 | util.printout("Signed rockspec: "..sigfname) | 90 | util.printout("Signed rockspec: "..sigfname) |
| 75 | end | 91 | end |
| 76 | 92 | ||
| 77 | local rock_fname | 93 | local rock_fname: string |
| 78 | if args.src_rock then | 94 | if args.src_rock then |
| 79 | rock_fname = args.src_rock | 95 | rock_fname = args.src_rock |
| 80 | elseif not args.skip_pack and not is_dev_version(rockspec.version) then | 96 | elseif not args.skip_pack and not is_dev_version(rockspec.version) then |
| @@ -98,7 +114,7 @@ function upload.command(args) | |||
| 98 | res, err = api:method("upload", nil, { | 114 | res, err = api:method("upload", nil, { |
| 99 | rockspec_file = multipart.new_file(args.rockspec), | 115 | rockspec_file = multipart.new_file(args.rockspec), |
| 100 | rockspec_sig = sigfname and multipart.new_file(sigfname), | 116 | rockspec_sig = sigfname and multipart.new_file(sigfname), |
| 101 | }) | 117 | }) as (Response, string) |
| 102 | if not res then return nil, err end | 118 | if not res then return nil, err end |
| 103 | 119 | ||
| 104 | if res.is_new and #res.manifests == 0 then | 120 | if res.is_new and #res.manifests == 0 then |
| @@ -115,7 +131,7 @@ function upload.command(args) | |||
| 115 | res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, { | 131 | res, err = api:method("upload_rock/" .. ("%d"):format(res.version.id), nil, { |
| 116 | rock_file = multipart.new_file(rock_fname), | 132 | rock_file = multipart.new_file(rock_fname), |
| 117 | rock_sig = rock_sigfname and multipart.new_file(rock_sigfname), | 133 | rock_sig = rock_sigfname and multipart.new_file(rock_sigfname), |
| 118 | }) | 134 | }) as (Response, string) |
| 119 | if not res then return nil, err end | 135 | if not res then return nil, err end |
| 120 | end | 136 | end |
| 121 | 137 | ||
