From 7e45dee34c7683cbe7f7bc7e940aec29c513ed33 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:49:08 -0300 Subject: Teal: convert luarocks.admin.cmd.make_manifest --- src/luarocks/admin/cmd/make_manifest.lua | 50 ----------------------------- src/luarocks/admin/cmd/make_manifest.tl | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 50 deletions(-) delete mode 100644 src/luarocks/admin/cmd/make_manifest.lua create mode 100644 src/luarocks/admin/cmd/make_manifest.tl diff --git a/src/luarocks/admin/cmd/make_manifest.lua b/src/luarocks/admin/cmd/make_manifest.lua deleted file mode 100644 index 18f74b5d..00000000 --- a/src/luarocks/admin/cmd/make_manifest.lua +++ /dev/null @@ -1,50 +0,0 @@ - ---- Module implementing the luarocks-admin "make_manifest" command. --- Compile a manifest file for a repository. -local make_manifest = {} - -local writer = require("luarocks.manif.writer") -local index = require("luarocks.admin.index") -local cfg = require("luarocks.core.cfg") -local util = require("luarocks.util") -local deps = require("luarocks.deps") -local fs = require("luarocks.fs") -local dir = require("luarocks.dir") - -function make_manifest.add_to_parser(parser) - local cmd = parser:command("make_manifest", "Compile a manifest file for a repository.", util.see_also()) - - cmd:argument("repository", "Local repository pathname.") - :args("?") - - cmd:flag("--local-tree", "If given, do not write versioned versions of the manifest file.\n".. - "Use this when rebuilding the manifest of a local rocks tree.") - util.deps_mode_option(cmd) -end - ---- Driver function for "make_manifest" command. --- @return boolean or (nil, string): True if manifest was generated, --- or nil and an error message. -function make_manifest.command(args) - local repo = args.repository or cfg.rocks_dir - - util.printout("Making manifest for "..repo) - - if repo:match("/lib/luarocks") and not args.local_tree then - util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") - end - - local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) - if ok and not args.local_tree then - util.printout("Generating index.html for "..repo) - index.make_index(repo) - end - if args.local_tree then - for luaver in util.lua_versions() do - fs.delete(dir.path(repo, "manifest-"..luaver)) - end - end - return ok, err -end - -return make_manifest diff --git a/src/luarocks/admin/cmd/make_manifest.tl b/src/luarocks/admin/cmd/make_manifest.tl new file mode 100644 index 00000000..8f6efd3c --- /dev/null +++ b/src/luarocks/admin/cmd/make_manifest.tl @@ -0,0 +1,55 @@ + +--- Module implementing the luarocks-admin "make_manifest" command. +-- Compile a manifest file for a repository. +local record make_manifest +end + +local writer = require("luarocks.manif.writer") +local index = require("luarocks.admin.index") +local cfg = require("luarocks.core.cfg") +local util = require("luarocks.util") +local deps = require("luarocks.deps") +local fs = require("luarocks.fs") +local dir = require("luarocks.dir") + +local type Parser = require("luarocks.vendor.argparse").Parser + +local type Args = require("luarocks.core.types.args").Args + +function make_manifest.add_to_parser(parser: Parser) + local cmd = parser:command("make_manifest", "Compile a manifest file for a repository.", util.see_also()) + + cmd:argument("repository", "Local repository pathname.") + :args("?") + + cmd:flag("--local-tree", "If given, do not write versioned versions of the manifest file.\n".. + "Use this when rebuilding the manifest of a local rocks tree.") + util.deps_mode_option(cmd as Parser) +end + +--- Driver function for "make_manifest" command. +-- @return boolean or (nil, string): True if manifest was generated, +-- or nil and an error message. +function make_manifest.command(args: Args): boolean, string + local repo = args.repository or cfg.rocks_dir + + util.printout("Making manifest for "..repo) + + if repo:match("/lib/luarocks") and not args.local_tree then + util.warning("This looks like a local rocks tree, but you did not pass --local-tree.") + end + + local ok, err = writer.make_manifest(repo, deps.get_deps_mode(args), not args.local_tree) + if ok and not args.local_tree then + util.printout("Generating index.html for "..repo) + index.make_index(repo) + end + if args.local_tree then + for luaver in util.lua_versions() do + fs.delete(dir.path(repo, "manifest-"..luaver)) + end + end + return ok, err +end + +return make_manifest -- cgit v1.2.3-55-g6feb