File tree 1 file changed +14
-24
lines changed
1 file changed +14
-24
lines changed Original file line number Diff line number Diff line change 1
1
import PackageJson from '@npmcli/package-json'
2
2
import assert from 'node:assert'
3
3
import semver from 'semver'
4
+ import { spawnSync } from 'child_process'
4
5
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' )
27
13
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
+ }
29
19
30
20
/** @type {string[] } */
31
- let versions = results [ 0 ] . extensions [ 0 ] . versions . map ( ( { version } ) => version )
21
+ let versions = metadata . versions . map ( ( { version } ) => version )
32
22
33
23
// Determine the latest version of the extension
34
24
let latest = versions
You can’t perform that action at this time.
0 commit comments