-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from trueberryless-org/npm-packages
Add support for NPM packages and GitLab repositories
- Loading branch information
Showing
8 changed files
with
155 additions
and
20 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
"starlight-plugin-show-latest-version": minor | ||
--- | ||
|
||
Add version support for NPM and GitLab. | ||
|
||
⚠️ **BREAKING CHANGE:** The configuration interface changed. | ||
|
||
Please follow the steps below to use the plugin like before or read the [documentation](https://starlight-plugin-show-latest-version.trueberryless.org/configuration/#source) for the newly defined API. | ||
|
||
Change the removed `repo` configuration to the new [`source`](https://starlight-plugin-show-latest-version.trueberryless.org/configuration/#source) configuration object: | ||
|
||
```diff | ||
// astro.config.ts | ||
starlightPluginShowLatestVersion({ | ||
- repo: "${slug}", | ||
+ source: { | ||
+ type: "github", | ||
+ slug: "${slug}", | ||
+ }, | ||
}), | ||
``` | ||
|
||
Note that you can now use `"npm"`, `"github"` or `"gitlab"` as the source type. This means that the plugin can be better customised to where you publish and release your packages. |
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,5 @@ | ||
--- | ||
"starlight-plugin-show-latest-version-docs": minor | ||
--- | ||
|
||
Update documentation for new `source` configuration |
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
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
27 changes: 27 additions & 0 deletions
27
packages/starlight-plugin-show-latest-version/libs/urlBuilder.ts
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 @@ | ||
export const releasePageUrls: Record< | ||
"github" | "gitlab" | "npm", | ||
(slug: string) => string | ||
> = { | ||
github: (slug) => `https://github.com/${slug}/releases`, | ||
gitlab: (slug) => `https://gitlab.com/${slug}/-/releases`, | ||
npm: (slug) => `https://www.npmjs.com/package/${slug}?activeTab=versions`, | ||
}; | ||
|
||
export const latestReleaseApis: Record< | ||
"github" | "gitlab" | "npm", | ||
(slug: string) => string | ||
> = { | ||
github: (slug) => `https://api.github.com/repos/${slug}/releases/latest`, | ||
gitlab: (slug) => | ||
`https://gitlab.com/api/v4/projects/${encodeURIComponent(slug)}/releases`, | ||
npm: (slug) => `https://registry.npmjs.org/${slug}/latest`, | ||
}; | ||
|
||
export const extractVersion: Record< | ||
"github" | "gitlab" | "npm", | ||
(data: any) => string | null | ||
> = { | ||
github: (data) => data?.tag_name || null, | ||
gitlab: (data) => data?.[0]?.tag_name || null, | ||
npm: (data) => data?.version || null, | ||
}; |
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