starlight-package-managers 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PackageManagers.astro +26 -8
- package/README.md +5 -5
- package/package.json +5 -5
- package/pkg.ts +12 -0
package/PackageManagers.astro
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { Tabs, TabItem } from '@astrojs/starlight/components'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
2
|
+
import { Code, Tabs, TabItem } from '@astrojs/starlight/components'
|
|
3
|
+
import type { ComponentProps } from 'astro/types'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type CommandOptions,
|
|
7
|
+
type CommandType,
|
|
8
|
+
getCommand,
|
|
9
|
+
getSupportedPkgManagers,
|
|
10
|
+
type PackageManager,
|
|
11
|
+
getIcon,
|
|
12
|
+
} from './pkg'
|
|
6
13
|
|
|
7
14
|
export type PackageManagersProps = Props
|
|
8
15
|
|
|
9
16
|
interface Props extends CommandOptions {
|
|
17
|
+
frame?: 'none' | 'terminal'
|
|
18
|
+
icons?: boolean
|
|
10
19
|
pkg?: string | undefined
|
|
11
20
|
pkgManagers?: PackageManager[]
|
|
21
|
+
title?: string | undefined
|
|
12
22
|
type?: CommandType
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
const { pkg, pkgManagers, type = 'add', ...options } = Astro.props
|
|
25
|
+
const { frame = 'terminal', icons = true, pkg, pkgManagers, title = undefined, type = 'add', ...options } = Astro.props
|
|
16
26
|
const singlePkgManager = pkgManagers?.length === 1 ? pkgManagers[0] : undefined
|
|
27
|
+
const ecFrame = frame === 'terminal' ? 'terminal' : 'code'
|
|
28
|
+
|
|
29
|
+
function getTabItemProps(pkgManager: PackageManager) {
|
|
30
|
+
const props: ComponentProps<typeof TabItem> = { label: pkgManager }
|
|
31
|
+
const icon = getIcon(pkgManager) as ComponentProps<typeof TabItem>['icon']
|
|
32
|
+
if (icons && icon) props.icon = icon
|
|
33
|
+
return props
|
|
34
|
+
}
|
|
17
35
|
---
|
|
18
36
|
|
|
19
37
|
{
|
|
20
38
|
singlePkgManager ? (
|
|
21
|
-
<Code code={getCommand(singlePkgManager, type, pkg, options)} lang="sh"
|
|
39
|
+
<Code code={getCommand(singlePkgManager, type, pkg, options)} lang="sh" {title} frame={ecFrame} />
|
|
22
40
|
) : (
|
|
23
41
|
<starlight-package-managers>
|
|
24
42
|
<Tabs>
|
|
25
43
|
{getSupportedPkgManagers(type, pkgManagers).map((pkgManager) => (
|
|
26
|
-
<TabItem
|
|
27
|
-
<Code code={getCommand(pkgManager, type, pkg, options)} lang="sh"
|
|
44
|
+
<TabItem {...getTabItemProps(pkgManager)}>
|
|
45
|
+
<Code code={getCommand(pkgManager, type, pkg, options)} lang="sh" {title} frame={ecFrame} />
|
|
28
46
|
</TabItem>
|
|
29
47
|
))}
|
|
30
48
|
</Tabs>
|
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<h1>starlight-package-managers 🗃</h1>
|
|
3
3
|
<p>Quickly display npm related commands for multiple package managers in your Starlight documentation site.</p>
|
|
4
4
|
<p>
|
|
5
|
-
<a href="https://github.com/HiDeoo/
|
|
6
|
-
<img alt="Demo of starlight-package-managers" src="https://github.com/HiDeoo/
|
|
5
|
+
<a href="https://github.com/HiDeoo/starlight-package-managers/assets/494699/5666eb82-4e80-4ce9-ac07-3f711e51062c" title="Demo of starlight-package-managers">
|
|
6
|
+
<img alt="Demo of starlight-package-managers" src="https://github.com/HiDeoo/starlight-package-managers/assets/494699/5666eb82-4e80-4ce9-ac07-3f711e51062c" width="520" />
|
|
7
7
|
</a>
|
|
8
8
|
</p>
|
|
9
9
|
</div>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
## Getting Started
|
|
22
22
|
|
|
23
|
-
Want to get started immediately? Check out the [getting started guide](https://starlight-package-managers.vercel.app/
|
|
23
|
+
Want to get started immediately? Check out the [getting started guide](https://starlight-package-managers.vercel.app/getting-started/) or a [live demo](https://starlight-package-managers.vercel.app/demo/).
|
|
24
24
|
|
|
25
25
|
## Description
|
|
26
26
|
|
|
@@ -61,9 +61,9 @@ By this one:
|
|
|
61
61
|
## Features
|
|
62
62
|
|
|
63
63
|
- Support for various package managers: [npm](https://www.npmjs.com), [yarn](https://yarnpkg.com), [pnpm](https://pnpm.io), [bun](https://bun.sh) & [ni](https://github.com/antfu/ni).
|
|
64
|
-
- Support for various types of command: [`add`](https://starlight-package-managers.vercel.app/
|
|
64
|
+
- Support for various types of command: [`add`](https://starlight-package-managers.vercel.app/usage/#add), [`create`](https://starlight-package-managers.vercel.app/usage/#create), [`exec`](https://starlight-package-managers.vercel.app/usage/#exec) & [`run`](https://starlight-package-managers.vercel.app/usage/#run).
|
|
65
65
|
- Synced tabs between each instance on the same page.
|
|
66
|
-
- Customizable output with [extra arguments](https://starlight-package-managers.vercel.app/
|
|
66
|
+
- Customizable output with [extra arguments](https://starlight-package-managers.vercel.app/usage/#extra-arguments), [comments](https://starlight-package-managers.vercel.app/usage/#comment) & [prefixes](https://starlight-package-managers.vercel.app/usage/#prefix).
|
|
67
67
|
|
|
68
68
|
## Documentation
|
|
69
69
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starlight-package-managers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Quickly display npm related commands for multiple package managers in your Starlight documentation site.",
|
|
6
6
|
"author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"./package.json": "./package.json"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@astrojs/starlight": "0.
|
|
13
|
+
"@astrojs/starlight": "0.21.0",
|
|
14
14
|
"@playwright/test": "1.36.2",
|
|
15
|
-
"astro": "3.
|
|
15
|
+
"astro": "4.3.7",
|
|
16
16
|
"vitest": "0.33.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@astrojs/starlight": ">=0.
|
|
20
|
-
"astro": ">=
|
|
19
|
+
"@astrojs/starlight": ">=0.21.0",
|
|
20
|
+
"astro": ">=4.2.7"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=18.14.1"
|
package/pkg.ts
CHANGED
|
@@ -38,10 +38,22 @@ const commands: Commands = {
|
|
|
38
38
|
},
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
const icons: Record<PackageManager, string | undefined> = {
|
|
42
|
+
npm: 'seti:npm',
|
|
43
|
+
yarn: 'seti:yarn',
|
|
44
|
+
pnpm: 'pnpm',
|
|
45
|
+
bun: 'bun',
|
|
46
|
+
ni: undefined,
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
export function getSupportedPkgManagers(type: CommandType, userPkgManagers: PackageManager[] | undefined) {
|
|
42
50
|
return (userPkgManagers ?? defaultPkgManagers).filter((pkgManager) => commands[pkgManager][type] !== undefined)
|
|
43
51
|
}
|
|
44
52
|
|
|
53
|
+
export function getIcon(pkgManager: PackageManager) {
|
|
54
|
+
return icons[pkgManager]
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
export function getCommand(
|
|
46
58
|
pkgManager: PackageManager,
|
|
47
59
|
type: CommandType,
|