Module ammcore.pkg.packageName¶
Utilities for parsing package name.
Index¶
Function
Parse a package name into separate components. |
Function¶
-
ammcore.pkg.packageName.parseFullPackageName(name:
string) ok:boolean, user?:string, repo?:string, name?:string¶ Parse a package name into separate components.
Package name consists of up to three components separated by dashes.
The first component represents a github username. It is optional, and must consist of letters and dashes.
The second one represents a github repository name. It is mandatory, and must form a valid lua identifier.
The third component represents a sub-package within a repository, if repository consists of multiple packages. It is optional, and must also form a valid lua identifier.
Examples of package names¶
Full package name, represents package
"taminomara-amm-ammcore"from repository"github.com/taminomara/amm":"taminomara-amm-ammcore" ────────┬─ ─┬─ ─────┬─ github username ─╯ │ │ github repo ─────────╯ │ package name ────────────────╯Short package name, represents package
"taminomara-amm"from repository"github.com/taminomara/amm":"taminomara-amm" ────────┬─ ─┬─ github username ─╯ │ github repo ─────────╯Local package
"example", not tied to any repository:"example" ─────┬─ package name ─╯Full package name, represents package
"example-username-repo-package"from repository"github.com/example-username/repo":"example-username-repo-package" ──────────────┬─ ──┬─ ─────┬─ github username ───────╯ │ │ github repo ────────────────╯ │ package name ───────────────────────╯Note
Notice that github username contains dashes; such user will not be able to publish
"example-username-repo", because AMM will think that it represents a package from repository"github.com/example/username".- Parameters:
name (
string) – package name.- Returns:
ok (
boolean) –trueif name is valid.user? (
string) – first package name component: github username, if there is any.repo? (
string) – second package name component, either github repo or a name.name? (
string) – third package name component, only set for github sub-packages.