Skip to content

Commit

Permalink
Do lookup magic to fix Pyright... *sigh*
Browse files Browse the repository at this point in the history
Thankfully fixes open-vsx#624
  • Loading branch information
filiptronicek committed Jan 9, 2023
1 parent ab83951 commit aaaefd1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions extensions-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"type": "number",
"description": "Timeout to build the extension vsix from sources."
},
"msMarketplaceIdOverride": {
"type": "string",
"description": "A property to set a different lookup ID when querying the Microsoft Marketplace. Please do not ever use if not absolutely necessary."
},
"target": {
"type": "array",
"description": "A list of platforms to target. If unspecified, a universal extension will be published in case of building from source and if the vsix is resolved from GitHub Releases, all of the attached platform-specific assets will be published.",
Expand Down
3 changes: 2 additions & 1 deletion extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@
"ms-pyright.vscode-pyright": {
"repository": "https://github.com/Microsoft/pyright",
"location": "packages/vscode-pyright",
"prepublish": "npm i && cd packages/vscode-pyright && npm run prepackage"
"prepublish": "npm i && cd packages/vscode-pyright && npm run prepackage",
"msMarketplaceIdOverride": "ms-pyright.pyright"
},
"ms-python.black-formatter": {
"repository": "https://github.com/microsoft/vscode-black-formatter",
Expand Down
16 changes: 10 additions & 6 deletions lib/resolveExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,18 @@ exports.resolveExtension = async function ({ id, repository, location }, ms) {
}
}

// check tags
if (ms) {
const tags = (await exec(`git log -3 --no-walk --tags --oneline --format="%H"`, { cwd: repoPath, quiet: true })).stdout.split('\n').map(t => t.trim()).filter(t => !!t);
for (const tag of tags) {
const version = await resolveVersion(tag)
if (version && ms.version.includes(version)) {
const releaseTags = (await exec(`git log -3 --no-walk --tags --oneline --format="%H"`, { cwd: repoPath, quiet: true })).stdout.split('\n').map(t => t.trim()).filter(t => !!t);
for (const tag of releaseTags) {
const versionAtTag = await resolveVersion(tag);
if (!versionAtTag) {
continue;
}
if (ms) {
if (ms.version.includes(versionAtTag)) {
return { version: ms.version, path: repoPath, resolution: { tag } };
}
} else {
return { version: versionAtTag, path: repoPath, resolution: { tag } };
}
}

Expand Down
3 changes: 2 additions & 1 deletion publish-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ const ensureBuildPrerequisites = async () => {
timeoutDelay = 5;
}
try {
const extensionId = extension.msMarketplaceIdOverride ?? extension.id;
/** @type {[PromiseSettledResult<PublishedExtension | undefined>]} */
let [msExtension] = await Promise.allSettled([msGalleryApi.getExtension(extension.id, flags)]);
let [msExtension] = await Promise.allSettled([msGalleryApi.getExtension(extensionId, flags)]);
if (msExtension.status === 'fulfilled') {
const lastNonPrereleaseVersion = msExtension.value?.versions.find(version => !isPreReleaseVersion(version.properties));
context.msVersion = lastNonPrereleaseVersion?.version;
Expand Down
1 change: 1 addition & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface Extension {
custom?: string[]
timeout?: number
target?: string[]
msMarketplaceIdOverride?: string
}

export interface ExtensionResolution {
Expand Down

0 comments on commit aaaefd1

Please sign in to comment.