Skip to content

Commit 5826301

Browse files
committed
feat: display dependencies and config plugin data
1 parent 039f75b commit 5826301

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

src/extension.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ export async function activate(context: ExtensionContext) {
112112
label: ENTRY_OPTION.VIEW_LICENSE,
113113
description: selectedEntry.github.license.name
114114
},
115+
!!selectedEntry.github.stats.dependencies && {
116+
label: ENTRY_OPTION.VIEW_DEPENDENCIES,
117+
description: `$(package) ${numberFormatter.format(selectedEntry.github.stats.dependencies)} ${selectedEntry.github.stats.dependencies === 1 ? 'dependency' : 'dependencies'}`
118+
},
115119
{ label: ENTRY_OPTION.VIEW_BUNDLEPHOBIA },
116120
{ label: 'details', kind: QuickPickItemKind.Separator },
117121
{
@@ -122,6 +126,10 @@ export async function activate(context: ExtensionContext) {
122126
label: ENTRY_OPTION.COMPATIBILITY,
123127
description: compatibilityList.join(', ')
124128
},
129+
selectedEntry.configPlugin && {
130+
label: ENTRY_OPTION.CONFIG_PLUGIN,
131+
description: typeof selectedEntry.configPlugin === 'string' ? selectedEntry.configPlugin : 'included'
132+
},
125133
...examplesActions,
126134
{ label: 'copy data', kind: QuickPickItemKind.Separator },
127135
{ label: ENTRY_OPTION.COPY_NAME },
@@ -207,6 +215,19 @@ export async function activate(context: ExtensionContext) {
207215
await openListWithSearch(packagesPick);
208216
break;
209217
}
218+
case ENTRY_OPTION.VIEW_DEPENDENCIES: {
219+
env.openExternal(Uri.parse(`https://www.npmjs.com/package/${selectedEntry.npmPkg}?activeTab=dependencies`));
220+
break;
221+
}
222+
case ENTRY_OPTION.CONFIG_PLUGIN: {
223+
if (typeof selectedEntry.configPlugin === 'string') {
224+
env.openExternal(Uri.parse(selectedEntry.configPlugin));
225+
} else {
226+
const searchValue = deduplicateSearchTokens(packagesPick.value, ['configPlugin']);
227+
await openListWithSearch(packagesPick, searchValue);
228+
}
229+
break;
230+
}
210231
}
211232

212233
optionPick.hide();

src/types.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,38 @@ export type PackageData = {
1717
fireos?: boolean;
1818
tvos?: boolean;
1919
visionos?: boolean;
20-
unmaintained?: boolean | string;
20+
unmaintained?: boolean;
2121
dev?: boolean;
2222
template?: boolean;
23-
newArchitecture?: boolean | string;
23+
newArchitecture?: boolean | 'new-arch-only';
2424
newArchitectureNote?: string;
25+
configPlugin?: boolean | string;
2526
alternatives?: string[];
27+
npmPkg: string;
28+
examples?: string[];
29+
images?: string[];
2630
github: {
2731
name: string;
28-
isPackagePrivate: boolean;
2932
fullName: string;
3033
description: string;
3134
registry?: string;
3235
topics?: string[];
3336
hasTypes?: boolean;
3437
newArchitecture?: boolean;
3538
isArchived?: boolean;
39+
isPrivate?: boolean;
40+
hasNativeCode: boolean;
41+
configPlugin?: boolean;
42+
moduleType?: 'expo' | 'nitro' | 'turbo';
3643
urls: {
3744
repo: string;
38-
clone: string;
3945
homepage?: string | null;
4046
};
4147
stats: {
4248
hasIssues: boolean;
4349
hasWiki: boolean;
4450
hasSponsorships: boolean;
51+
hasDiscussions: boolean;
4552
hasTopics?: boolean;
4653
updatedAt: Date | string;
4754
createdAt: Date | string;
@@ -50,6 +57,7 @@ export type PackageData = {
5057
subscribers: number;
5158
stars: number;
5259
forks: number;
60+
dependencies?: number;
5361
};
5462
license: {
5563
key: string;
@@ -69,16 +77,13 @@ export type PackageData = {
6977
npm?: {
7078
downloads?: number;
7179
weekDownloads?: number;
72-
start?: string;
73-
end?: string;
74-
period?: string;
80+
size?: number;
81+
latestRelease?: string;
82+
latestReleaseDate?: string;
7583
};
7684
score: number;
7785
matchingScoreModifiers: string[];
7886
topicSearchString: string;
79-
examples?: string[];
80-
images?: string[];
81-
npmPkg: string;
8287
popularity?: number;
8388
matchScore?: number;
8489
};

src/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ export enum ENTRY_OPTION {
1414
VISIT_NPM = 'Visit npm registry entry',
1515
VIEW_BUNDLEPHOBIA = 'View BundlePhobia analysis',
1616
VIEW_LICENSE = 'View license details',
17+
VIEW_DEPENDENCIES = 'View dependencies',
1718
COPY_NAME = 'Copy package name',
1819
COPY_REPO_URL = 'Copy GitHub repository URL',
1920
COPY_NPM_URL = 'Copy npm registry URL',
2021
GO_BACK = '$(newline) Go back to search',
2122
PLATFORMS = 'Platforms',
22-
COMPATIBILITY = 'Compatibility'
23+
COMPATIBILITY = 'Compatibility',
24+
CONFIG_PLUGIN = 'Config plugin'
2325
}
2426

2527
export enum STRINGS {
@@ -60,7 +62,8 @@ function getDetailLabel(item: PackageData) {
6062
'•',
6163
getPlatformsList(item).join(', '),
6264
(item.newArchitecture || item.expoGo || item.github.hasTypes) && '•',
63-
(item.newArchitecture || item.expoGo) && `$(verified) New Architecture`,
65+
(item.newArchitecture || item.expoGo) &&
66+
`$(verified) New Architecture${item.newArchitecture === 'new-arch-only' ? ' only' : ''}`,
6467
item.github.hasTypes && `$(symbol-type-parameter) Types`
6568
]
6669
.filter(Boolean)

0 commit comments

Comments
 (0)