diff --git a/README.md b/README.md index b77fffa6..e71128c1 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/manifest.rs b/src/manifest.rs index fdd7d157..dc25085a 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -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, + + /// URL of the package source repository. + /// + /// Example: "https://github.com/Sleitnick/Knit.git" + #[serde(default)] + pub repository: Option, } // Metadata we require when this manifest will be used to generate package folders diff --git a/src/test_package.rs b/src/test_package.rs index 8929fa01..d7284d69 100644 --- a/src/test_package.rs +++ b/src/test_package.rs @@ -39,6 +39,8 @@ impl PackageBuilder { include: Vec::new(), exclude: Vec::new(), private: false, + homepage: None, + repository: None, }, place: Default::default(), dependencies: Default::default(), diff --git a/test-projects/manifest-links/default.project.json b/test-projects/manifest-links/default.project.json new file mode 100644 index 00000000..98a976cd --- /dev/null +++ b/test-projects/manifest-links/default.project.json @@ -0,0 +1,6 @@ +{ + "name": "minimal", + "tree": { + "$path": "src" + } +} \ No newline at end of file diff --git a/test-projects/manifest-links/src/init.luau b/test-projects/manifest-links/src/init.luau new file mode 100644 index 00000000..4d71952c --- /dev/null +++ b/test-projects/manifest-links/src/init.luau @@ -0,0 +1 @@ +return "hey" diff --git a/test-projects/manifest-links/wally.toml b/test-projects/manifest-links/wally.toml new file mode 100644 index 00000000..900af2f8 --- /dev/null +++ b/test-projects/manifest-links/wally.toml @@ -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" diff --git a/test-registries/primary-registry/contents/biff/manifest-links/0.1.0.zip b/test-registries/primary-registry/contents/biff/manifest-links/0.1.0.zip new file mode 100644 index 00000000..5fa7df36 Binary files /dev/null and b/test-registries/primary-registry/contents/biff/manifest-links/0.1.0.zip differ diff --git a/test-registries/primary-registry/index/biff/manifest-links b/test-registries/primary-registry/index/biff/manifest-links new file mode 100644 index 00000000..46e3c976 --- /dev/null +++ b/test-registries/primary-registry/index/biff/manifest-links @@ -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":{}} \ No newline at end of file diff --git a/tests/integration/install.rs b/tests/integration/install.rs index fa102fdf..a7bb5415 100644 --- a/tests/integration/install.rs +++ b/tests/integration/install.rs @@ -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"); diff --git a/tests/integration/snapshots/integration__install__manifest_links.snap b/tests/integration/snapshots/integration__install__manifest_links.snap new file mode 100644 index 00000000..cdbc3cd0 --- /dev/null +++ b/tests/integration/snapshots/integration__install__manifest_links.snap @@ -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" diff --git a/wally-registry-frontend/src/app/package/[packageScope]/[packageName]/page.tsx b/wally-registry-frontend/src/app/package/[packageScope]/[packageName]/page.tsx index 311d8add..110fc4e1 100644 --- a/wally-registry-frontend/src/app/package/[packageScope]/[packageName]/page.tsx +++ b/wally-registry-frontend/src/app/package/[packageScope]/[packageName]/page.tsx @@ -192,6 +192,40 @@ const DependencyLink = ({ packageInfo }: { packageInfo: string }) => { return {packageInfo} } +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 ( + <> + + {urlNoSchema(url)} + + + ) +} + const DownloadLink = ({ url, filename, @@ -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) @@ -443,14 +477,17 @@ export default function Package() { {capitalize(packageMetadata.package.realm)} - {/* TODO: Re-implement when Wally API supports custom source repos */} - {/* {packageMetadata?.package.registry && ( - - - {packageMetadata?.package.registry.replace("https://", "")} - - - )} */} + {packageMetadata?.package.homepage && ( + + + + )} + + {packageMetadata?.package.repository && ( + + + + )} {packageMetadata.package.authors.length > 0 && ( diff --git a/wally-registry-frontend/src/types/wally.d.ts b/wally-registry-frontend/src/types/wally.d.ts index ee65c196..df839f40 100644 --- a/wally-registry-frontend/src/types/wally.d.ts +++ b/wally-registry-frontend/src/types/wally.d.ts @@ -14,6 +14,8 @@ export interface WallyPackageMetadata { realm: string registry: string version: string + homepage: string?, + repository: string?, } place: {