Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
dfbd140a
Commit
dfbd140a
authored
Feb 11, 2021
by
aniket-engg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linting for remix-url-resolver done
parent
28773548
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
32 deletions
+25
-32
.eslintrc
libs/remix-url-resolver/.eslintrc
+1
-6
resolve.ts
libs/remix-url-resolver/src/resolve.ts
+23
-25
package.json
package.json
+1
-1
No files found.
libs/remix-url-resolver/.eslintrc
View file @
dfbd140a
{
"extends": "../../.eslintrc",
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
},
"rules": {},
"env": {
"browser": true,
"amd": true,
...
...
libs/remix-url-resolver/src/resolve.ts
View file @
dfbd140a
// eslint-disable-next-line no-unused-vars
import
axios
,
{
AxiosResponse
}
from
'axios'
import
{
BzzNode
as
Bzz
}
from
'@erebos/bzz-node'
...
...
@@ -27,9 +28,9 @@ export class RemixURLResolver {
gistAccessToken
:
string
protocol
:
string
constructor
(
gistToken
?:
string
,
protocol
=
'http:'
)
{
constructor
(
gistToken
?:
string
,
protocol
=
'http:'
)
{
this
.
previouslyHandled
=
{}
this
.
gistAccessToken
=
gistToken
?
gistToken
:
''
this
.
gistAccessToken
=
gistToken
||
''
this
.
protocol
=
protocol
}
...
...
@@ -38,24 +39,21 @@ export class RemixURLResolver {
* @param root The root of the github import statement
* @param filePath path of the file in github
*/
async
handleGithubCall
(
root
:
string
,
filePath
:
string
):
Promise
<
HandlerResponse
>
{
let
param
=
'?'
param
+=
this
.
gistAccessToken
?
'access_token='
+
this
.
gistAccessToken
:
''
async
handleGithubCall
(
root
:
string
,
filePath
:
string
):
Promise
<
HandlerResponse
>
{
const
regex
=
filePath
.
match
(
/blob
\/([^/]
+
)\/(
.*
)
/
)
let
reference
=
'master'
if
(
regex
)
{
// if we have /blob/master/+path we extract the branch name "master" and add it as a parameter to the github api
// the ref can be branch name, tag, commit id
reference
=
regex
[
1
]
param
+=
'&ref='
+
reference
filePath
=
filePath
.
replace
(
`blob/
${
reference
}
/`
,
''
)
}
//eslint-disable-next-line no-useless-catch
//
eslint-disable-next-line no-useless-catch
try
{
const
req
:
string
=
`https://raw.githubusercontent.com/
${
root
}
/
${
reference
}
/
${
filePath
}
`
const
response
:
AxiosResponse
=
await
axios
.
get
(
req
)
return
{
content
:
response
.
data
,
cleanUrl
:
root
+
'/'
+
filePath
}
}
catch
(
e
)
{
}
catch
(
e
)
{
throw
e
}
}
...
...
@@ -65,12 +63,12 @@ export class RemixURLResolver {
* @param url The url of the import statement
* @param cleanUrl
*/
async
handleHttp
(
url
:
string
,
cleanUrl
:
string
):
Promise
<
HandlerResponse
>
{
//eslint-disable-next-line no-useless-catch
async
handleHttp
(
url
:
string
,
cleanUrl
:
string
):
Promise
<
HandlerResponse
>
{
//
eslint-disable-next-line no-useless-catch
try
{
const
response
:
AxiosResponse
=
await
axios
.
get
(
url
)
return
{
content
:
response
.
data
,
cleanUrl
}
}
catch
(
e
)
{
return
{
content
:
response
.
data
,
cleanUrl
}
}
catch
(
e
)
{
throw
e
}
}
...
...
@@ -80,24 +78,24 @@ export class RemixURLResolver {
* @param url The url of the import statement
* @param cleanUrl
*/
async
handleHttps
(
url
:
string
,
cleanUrl
:
string
):
Promise
<
HandlerResponse
>
{
//eslint-disable-next-line no-useless-catch
async
handleHttps
(
url
:
string
,
cleanUrl
:
string
):
Promise
<
HandlerResponse
>
{
//
eslint-disable-next-line no-useless-catch
try
{
const
response
:
AxiosResponse
=
await
axios
.
get
(
url
)
return
{
content
:
response
.
data
,
cleanUrl
}
}
catch
(
e
)
{
}
catch
(
e
)
{
throw
e
}
}
async
handleSwarm
(
url
:
string
,
cleanUrl
:
string
):
Promise
<
HandlerResponse
>
{
//eslint-disable-next-line no-useless-catch
async
handleSwarm
(
url
:
string
,
cleanUrl
:
string
):
Promise
<
HandlerResponse
>
{
//
eslint-disable-next-line no-useless-catch
try
{
const
bzz
=
new
Bzz
({
url
:
this
.
protocol
+
'//swarm-gateways.net'
});
const
url
=
bzz
.
getDownloadURL
(
cleanUrl
,
{
mode
:
'raw'
})
const
bzz
=
new
Bzz
({
url
:
this
.
protocol
+
'//swarm-gateways.net'
})
const
url
=
bzz
.
getDownloadURL
(
cleanUrl
,
{
mode
:
'raw'
})
const
response
:
AxiosResponse
=
await
axios
.
get
(
url
)
return
{
content
:
response
.
data
,
cleanUrl
}
}
catch
(
e
)
{
}
catch
(
e
)
{
throw
e
}
}
...
...
@@ -106,10 +104,10 @@ export class RemixURLResolver {
* Handle an import statement based on IPFS
* @param url The url of the IPFS import statement
*/
async
handleIPFS
(
url
:
string
):
Promise
<
HandlerResponse
>
{
async
handleIPFS
(
url
:
string
):
Promise
<
HandlerResponse
>
{
// replace ipfs:// with /ipfs/
url
=
url
.
replace
(
/^ipfs:
\/\/?
/
,
'ipfs/'
)
//eslint-disable-next-line no-useless-catch
//
eslint-disable-next-line no-useless-catch
try
{
const
req
=
'https://ipfsgw.komputing.org/'
+
url
// If you don't find greeter.sol on ipfs gateway use local
...
...
@@ -171,9 +169,9 @@ export class RemixURLResolver {
]
}
public
async
resolve
(
filePath
:
string
,
customHandlers
?:
Handler
[]):
Promise
<
Imported
>
{
public
async
resolve
(
filePath
:
string
,
customHandlers
?:
Handler
[]):
Promise
<
Imported
>
{
let
imported
:
Imported
=
this
.
previouslyHandled
[
filePath
]
if
(
imported
)
{
if
(
imported
)
{
return
imported
}
const
builtinHandlers
:
Handler
[]
=
this
.
getHandlers
()
...
...
@@ -184,7 +182,7 @@ export class RemixURLResolver {
const
{
content
,
cleanUrl
}
=
await
handler
.
handle
(
match
)
imported
=
{
content
,
cleanUrl
:
cleanUrl
?
cleanUrl
:
filePath
,
cleanUrl
:
cleanUrl
||
filePath
,
type
:
handler
.
type
}
this
.
previouslyHandled
[
filePath
]
=
imported
...
...
package.json
View file @
dfbd140a
...
...
@@ -41,7 +41,7 @@
"workspace-schematic"
:
"nx workspace-schematic"
,
"dep-graph"
:
"nx dep-graph"
,
"help"
:
"nx help"
,
"lint:libs"
:
"nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui"
,
"lint:libs"
:
"nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix
-url-resolver,remix
d,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui"
,
"build:libs"
:
"nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd"
,
"test:libs"
:
"nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd"
,
"publish:libs"
:
"npm run build:libs & lerna publish --skip-git & npm run bumpVersion:libs"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment