Skip to content

Commit 07949db

Browse files
committed
Use vsce tool to query extension metadata
Querying the marketplace API directly is not supported
1 parent 8f26af4 commit 07949db

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

.github/workflows/bump-version.mjs

+14-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
import PackageJson from '@npmcli/package-json'
22
import assert from 'node:assert'
33
import 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
3424
let latest = versions

0 commit comments

Comments
 (0)