Skip to content

Commit

Permalink
Add Homepage and Repository fields to manifests (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: MobiusCraftFlip <[email protected]>
  • Loading branch information
Dekkonot and MobiusCraftFlip authored Nov 17, 2024
1 parent a73d5fa commit 4fa2344
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 10 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ realm = "shared"
# keep internal code private and isolated.
registry = "https://github.com/upliftgames/wally-index"

# Wally will display this link on the package's page on wally.run.
# A value should only be set if there is a dedicated website for
# the package other than the source repository.
homepage = "https://eryn.io/roblox-lua-promise/"

# Wally will display this link on package's page on wally.run.
# The repository field should be a URL to the source repository for a package.
repository = "https://github.com/evaera/roblox-lua-promise"

# You can also specify files to include or exclude from the package
# By default gitignore files are respected and Wally won't include hidden
# files/directories or packages downloaded by Wally.
Expand Down
12 changes: 12 additions & 0 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ pub struct Package {
/// Example: true
#[serde(default)]
pub private: bool,

/// URL of the package homepage.
///
/// Example: "https://github.com/sleitnick/knit"
#[serde(default)]
pub homepage: Option<String>,

/// URL of the package source repository.
///
/// Example: "https://github.com/Sleitnick/Knit.git"
#[serde(default)]
pub repository: Option<String>,
}

// Metadata we require when this manifest will be used to generate package folders
Expand Down
2 changes: 2 additions & 0 deletions src/test_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ impl PackageBuilder {
include: Vec::new(),
exclude: Vec::new(),
private: false,
homepage: None,
repository: None,
},
place: Default::default(),
dependencies: Default::default(),
Expand Down
6 changes: 6 additions & 0 deletions test-projects/manifest-links/default.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "minimal",
"tree": {
"$path": "src"
}
}
1 change: 1 addition & 0 deletions test-projects/manifest-links/src/init.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return "hey"
8 changes: 8 additions & 0 deletions test-projects/manifest-links/wally.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "biff/minimal"
version = "0.1.0"
license = "MIT"
realm = "server"
registry = "test-registries/primary-registry"
repository = "https://github.com/UpliftGames/player-module.git"
homepage = "https://github.com/UpliftGames/player-module"
Binary file not shown.
1 change: 1 addition & 0 deletions test-registries/primary-registry/index/biff/manifest-links
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"package":{"name":"biff/minimal","version":"0.1.0","registry":"test-registries/primary-registry","realm":"server","description":null,"license":"MIT","authors":[],"include":[],"exclude":[],"private":false,"homepage":"https://github.com/UpliftGames/player-module","repository":"https://github.com/UpliftGames/player-module.git"},"place":{"shared-packages":null,"server-packages":null},"dependencies":{},"server-dependencies":{},"dev-dependencies":{}}
5 changes: 5 additions & 0 deletions tests/integration/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ fn cross_realm_explicit_dependency() {
run_install_test("cross-realm-explicit-dependency");
}

#[test]
fn manifest_links() {
run_install_test("manifest-links");
}

#[test]
fn locked_pass() {
let result = run_locked_install("diamond-graph/root/latest");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: tests/integration/install.rs
expression: result
---
default.project.json: "{\n \"name\": \"minimal\",\n \"tree\": {\n \"$path\": \"src\"\n }\n}"
src:
init.luau: "return \"hey\"\n"
wally.lock: "# This file is automatically @generated by Wally.\n# It is not intended for manual editing.\nregistry = \"test\"\n\n[[package]]\nname = \"biff/minimal\"\nversion = \"0.1.0\"\ndependencies = []\n"
wally.toml: "[package]\nname = \"biff/minimal\"\nversion = \"0.1.0\"\nlicense = \"MIT\"\nrealm = \"server\"\nregistry = \"test-registries/primary-registry\"\nrepository = \"https://github.com/UpliftGames/player-module.git\"\nhomepage = \"https://github.com/UpliftGames/player-module\"\n"
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,40 @@ const DependencyLink = ({ packageInfo }: { packageInfo: string }) => {
return <DependencyLinkItem href={"/"}>{packageInfo}</DependencyLinkItem>
}

const MetadataLink = ({
url
}: {
url: string

}) => {
const Link = styled.a`
overflow: hidden;
text-overflow: ellipsis;
display: flex;
white-space: nowrap;
width: 100%;
display: inline-block;
font-size: 18px;
`

const urlNoSchema = (original: string) => {
try {
const url = new URL(original)
return `${url.host}${url?.pathname}`
} catch {
return original
}
}

return (
<>
<Link href={url} title={url}>
{urlNoSchema(url)}
</Link>
</>
)
}

const DownloadLink = ({
url,
filename,
Expand Down Expand Up @@ -288,8 +322,8 @@ export default function Package() {
(pack: WallyPackageMetadata) => !pack.package.version.includes("-")
)
? packageData.versions.filter(
(pack: WallyPackageMetadata) => !pack.package.version.includes("-")
)
(pack: WallyPackageMetadata) => !pack.package.version.includes("-")
)
: packageData.versions

setPackageHistory(filteredPackageData)
Expand Down Expand Up @@ -443,14 +477,17 @@ export default function Package() {
{capitalize(packageMetadata.package.realm)}
</MetaItem>

{/* TODO: Re-implement when Wally API supports custom source repos */}
{/* {packageMetadata?.package.registry && (
<MetaItem title="Repository" width="full">
<a href={packageMetadata?.package.registry}>
{packageMetadata?.package.registry.replace("https://", "")}
</a>
</MetaItem>
)} */}
{packageMetadata?.package.homepage && (
<MetaItem title="Homepage" width="full">
<MetadataLink url={packageMetadata?.package.homepage} />
</MetaItem>
)}

{packageMetadata?.package.repository && (
<MetaItem title="Repository" width="full">
<MetadataLink url={packageMetadata?.package.repository} />
</MetaItem>
)}

{packageMetadata.package.authors.length > 0 && (
<MetaItem title="Authors" width="full">
Expand Down
2 changes: 2 additions & 0 deletions wally-registry-frontend/src/types/wally.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface WallyPackageMetadata {
realm: string
registry: string
version: string
homepage: string?,
repository: string?,
}

place: {
Expand Down

0 comments on commit 4fa2344

Please sign in to comment.