Skip to content

Commit

Permalink
Add support for OpenVSX publishing (#71)
Browse files Browse the repository at this point in the history
Python prelease control and sorting fix
  • Loading branch information
serayuzgur authored Jul 26, 2024
1 parent 6b81218 commit c8c50cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/vscode-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
vsce publish -p $VSCE_TOKEN
env:
VSCE_TOKEN: ${{ secrets.VSC_PAT }}
- name: Publish to OpenVSX
run: |
npm install -g ovsx
ovsx publish -p $OVSX_PAT
env:
OVSX_TOKEN: ${{ secrets.OVSX_PAT }}

- name: Send Download Link to Slack
uses: slackapi/[email protected]
Expand Down
23 changes: 14 additions & 9 deletions vscode/src/core/fetchers/PypiFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,21 @@ export class PypiFetcher extends Fetcher {
}
checkPreRelease(version: string): boolean {
if (!Settings.python.ignoreUnstable) return false;
// alpha and beta regexes for python
const aORb = /\..*a|b.*/;
return (
version.indexOf("-alpha") !== -1 ||
version.indexOf("-beta") !== -1 ||
version.indexOf("-rc") !== -1 ||
version.indexOf("-SNAPSHOT") !== -1 ||
version.indexOf("-dev") !== -1 ||
version.indexOf("-preview") !== -1 ||
version.indexOf("-experimental") !== -1 ||
version.indexOf("-canary") !== -1 ||
version.indexOf("-pre") !== -1
version.indexOf(".alpha") !== -1 ||
version.indexOf(".beta") !== -1 ||
version.indexOf(".rc") !== -1 ||
version.indexOf(".SNAPSHOT") !== -1 ||
version.indexOf(".dev") !== -1 ||
version.indexOf(".preview") !== -1 ||
version.indexOf(".experimental") !== -1 ||
version.indexOf(".canary") !== -1 ||
version.indexOf(".pre") !== -1 ||
aORb.test(version)


);
}
mapVersions(dep: Dependency, item?: Item): Dependency {
Expand Down
12 changes: 8 additions & 4 deletions vscode/src/semver/compareVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ function indexOrEnd(str: string, q: string) {
return str.indexOf(q) === -1 ? str.length : str.indexOf(q);
}

function lastIndexOrEnd(str: string, q: string) {
return str.lastIndexOf(q) === -1 ? str.length : str.lastIndexOf(q);
}

function split(v: string) {
const c = v.replace(/^v/, "").replace(/\+.*$/, "");
const patchIndex = indexOrEnd(c, "-");

const patchIndex = CurrentLanguage === Language.Python ? lastIndexOrEnd(c, '.') : indexOrEnd(c, "-");
const arr = c.substring(0, patchIndex).split(".");
arr.push(c.substring(patchIndex + 1));
return arr;
Expand Down Expand Up @@ -43,7 +48,6 @@ function compareVersions(v1: string, v2: string) {

var sp1 = s1[s1.length - 1];
var sp2 = s2[s2.length - 1];

if (sp1 && sp2) {
const p1 = sp1
.split(".")
Expand All @@ -55,12 +59,12 @@ function compareVersions(v1: string, v2: string) {
for (let i = 0; i < maxLimit; i++) {
if (
p1[i] === undefined ||
(typeof p2[i] === "string" && typeof p1[i] === "number")
(typeof p1[i] === "string" && typeof p2[i] === "number")
)
return -1;
if (
p2[i] === undefined ||
(typeof p1[i] === "string" && typeof p2[i] === "number")
(typeof p2[i] === "string" && typeof p1[i] === "number")
)
return 1;

Expand Down

0 comments on commit c8c50cd

Please sign in to comment.