File tree Expand file tree Collapse file tree 1 file changed +14
-24
lines changed Expand file tree Collapse file tree 1 file changed +14
-24
lines changed Original file line number Diff line number Diff line change 11import PackageJson from '@npmcli/package-json'
22import assert from 'node:assert'
33import semver from 'semver'
4+ import { spawnSync } from 'child_process'
45
5- let res = await fetch ( 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' , {
6- method : 'POST' ,
7- headers : {
8- accept : 'application/json;api-version=7.2-preview.1;excludeUrls=true' ,
9- 'content-type' : 'application/json' ,
10- } ,
11- body : JSON . stringify ( {
12- assetTypes : null ,
13- flags : 2151 ,
14- filters : [
15- {
16- criteria : [ { filterType : 7 , value : 'bradlc.vscode-tailwindcss' } ] ,
17- direction : 2 ,
18- pageSize : 100 ,
19- pageNumber : 1 ,
20- sortBy : 0 ,
21- sortOrder : 0 ,
22- pagingToken : null ,
23- } ,
24- ] ,
25- } ) ,
26- } )
6+ // Let `vsce` get the metadata for the extension
7+ // Querying the marketplace API directly is not supported or recommended
8+ let stdout = spawnSync ( 'node_modules/.bin/vsce' , [
9+ 'show' ,
10+ 'bradlc.vscode-tailwindcss' ,
11+ '--json' ,
12+ ] ) . stdout . toString ( 'utf8' )
2713
28- let { results } = await res . json ( )
14+ let metadata = JSON . parse ( stdout )
15+
16+ if ( ! metadata ) {
17+ throw new Error ( 'Failed to get extension metadata' )
18+ }
2919
3020/** @type {string[] } */
31- let versions = results [ 0 ] . extensions [ 0 ] . versions . map ( ( { version } ) => version )
21+ let versions = metadata . versions . map ( ( { version } ) => version )
3222
3323// Determine the latest version of the extension
3424let latest = versions
You can’t perform that action at this time.
0 commit comments