-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GradlePluginPortal] add gradle plugin portal (#6449)
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
services/gradle-plugin-portal/gradle-plugin-portal.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict' | ||
|
||
const { redirector } = require('..') | ||
|
||
module.exports = redirector({ | ||
category: 'version', | ||
isDeprecated: false, | ||
route: { | ||
base: 'gradle-plugin-portal/v', | ||
// TODO: add /:versionPrefix? when maven-metadata have versionPrefix attribute. | ||
pattern: ':pluginId', | ||
}, | ||
examples: [ | ||
{ | ||
title: 'Gradle Plugin Portal', | ||
namedParams: { | ||
pluginId: 'com.gradle.plugin-publish', | ||
}, | ||
staticPreview: { | ||
label: 'plugin portal', | ||
message: 'v0.14.0', | ||
color: 'blue', | ||
}, | ||
}, | ||
], | ||
transformPath: () => `/maven-metadata/v`, | ||
transformQueryParams: ({ pluginId }) => { | ||
const groupPath = pluginId.replace(/\./g, '/') | ||
const artifactId = `${pluginId}.gradle.plugin` | ||
const metadataUrl = `https://plugins.gradle.org/m2/${groupPath}/${artifactId}/maven-metadata.xml` | ||
return { | ||
metadataUrl, | ||
label: 'plugin portal', | ||
color: 'blue', | ||
} | ||
}, | ||
overrideTransformedQueryParams: true, | ||
dateAdded: new Date('2021-05-30'), | ||
}) |
27 changes: 27 additions & 0 deletions
27
services/gradle-plugin-portal/gradle-plugin-portal.tester.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict' | ||
|
||
const t = (module.exports = require('../tester').createServiceTester()) | ||
|
||
t.create('gradle plugin portal') | ||
.get('/com.gradle.plugin-publish') | ||
.expectRedirect( | ||
`/maven-metadata/v.svg?color=blue&label=plugin%20portal&metadataUrl=${encodeURIComponent( | ||
'https://plugins.gradle.org/m2/com/gradle/plugin-publish/com.gradle.plugin-publish.gradle.plugin/maven-metadata.xml' | ||
)}` | ||
) | ||
|
||
t.create('gradle plugin portal with custom labels') | ||
.get('/com.gradle.plugin-publish?label=custom%20label') | ||
.expectRedirect( | ||
`/maven-metadata/v.svg?color=blue&label=custom%20label&metadataUrl=${encodeURIComponent( | ||
'https://plugins.gradle.org/m2/com/gradle/plugin-publish/com.gradle.plugin-publish.gradle.plugin/maven-metadata.xml' | ||
)}` | ||
) | ||
|
||
t.create('gradle plugin portal with custom color') | ||
.get('/com.gradle.plugin-publish?color=gray') | ||
.expectRedirect( | ||
`/maven-metadata/v.svg?color=gray&label=plugin%20portal&metadataUrl=${encodeURIComponent( | ||
'https://plugins.gradle.org/m2/com/gradle/plugin-publish/com.gradle.plugin-publish.gradle.plugin/maven-metadata.xml' | ||
)}` | ||
) |