Skip to content

Commit

Permalink
Switch to emlearn index
Browse files Browse the repository at this point in the history
  • Loading branch information
vshymanskyy committed Oct 15, 2024
1 parent 58bdf71 commit 4d643dd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ViperIDE",
"version": "0.5.5",
"version": "0.5.6",
"description": "An innovative MicroPython / CircuitPython IDE for Web and Mobile",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions src/package_mgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ const MIP_INDEXES = [{
url: 'https://vsh.pp.ua/mip-featured',
},{
name: 'emlearn-micropython',
url: 'https://vsh.pp.ua/emlearn',
url: 'https://emlearn.github.io/emlearn-micropython/builds',
},{
name: 'micropython-lib',
url: 'https://micropython.org/pi/v2',
}]

function rewriteUrl(url, { base=null, branch=null } = {}) {
//const input_url = url;
if (url.startsWith('http://')) {
url = 'https://' + url.slice(7)
}
Expand All @@ -36,10 +37,10 @@ function rewriteUrl(url, { base=null, branch=null } = {}) {
url = 'github:' + url.split('/').slice(3).join('/')
}
} else if (url.startsWith('https://gitlab.com/')) {
const gitlabRegex = /https:\/\/gitlab\.com\/([^/]+)\/([^/]+)\/-\/raw\/([^/]+)\/(.*)$/
const gitlabRegex = /https:\/\/gitlab\.com\/([^/]+)\/([^/]+)\/-\/(blob|tree)\/([^/]+)\/(.*?)(\?ref_type=.*)?$/
const match = url.match(gitlabRegex)
if (match) {
const [, user, repo, urlBranch, filePath] = match
const [, user, repo, , urlBranch, filePath] = match
branch = branch || urlBranch;
url = `gitlab:${user}/${repo}/${filePath}`
} else {
Expand All @@ -63,6 +64,7 @@ function rewriteUrl(url, { base=null, branch=null } = {}) {
base = base.replace(/\/[^/]*\.[^/]*$/, '') // Strip filename, if any
url = base + '/' + url
}
//console.log("Translated", input_url, "=>", url)
return url
}

Expand Down

0 comments on commit 4d643dd

Please sign in to comment.