Comparing version 1.0.1 to 1.1.0
const TaskExecutor = require('../util/task-executor'); | ||
const { spawn } = require('child_process'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
@@ -5,0 +4,0 @@ |
@@ -6,7 +6,6 @@ const path = require('path'); | ||
this.sourcesRoot = config.get('sources.root'); | ||
this.scope = config.get('cnav.scope'); | ||
} | ||
location(repo) { | ||
if (this.scope === '<all>') { | ||
if (repo.scope === '<all>') { | ||
return path.join( | ||
@@ -16,6 +15,6 @@ this.sourcesRoot, | ||
repo.namespace, | ||
repo.name | ||
repo.alias | ||
); | ||
} else { | ||
return path.join(this.sourcesRoot, this.scope, repo.name); | ||
return path.join(this.sourcesRoot, repo.scope, repo.alias); | ||
} | ||
@@ -22,0 +21,0 @@ } |
@@ -6,3 +6,2 @@ const path = require('path'); | ||
const CodeNavRepo = require('./codenav-repo'); | ||
const { spawn } = require('child_process'); | ||
const fs = require('fs'); | ||
@@ -16,4 +15,2 @@ | ||
}); | ||
this.shellCmd = config.get('shell.cmd'); | ||
this.scope = config.get('cnav.scope'); | ||
this.codeNavRepo = new CodeNavRepo(config); | ||
@@ -23,3 +20,4 @@ this.cloneCmd = new CloneCmd(this.codeNavRepo); | ||
register(urlConnection) { | ||
register(options) { | ||
const { scope, urlConnection } = options; | ||
const parsed = ConnectionUrl.parse(urlConnection); | ||
@@ -36,5 +34,5 @@ if (!parsed) { | ||
namespace: parsed.namespace, | ||
name: parsed.name, | ||
alias: parsed.name, | ||
host: parsed.host, | ||
scope: this.scope, | ||
scope: scope, | ||
}); | ||
@@ -48,9 +46,9 @@ } | ||
} | ||
return (item) => item[e[0]].startsWith(e[1]); | ||
return (item) => item[e[0]] === e[1]; | ||
}); | ||
} | ||
list(filters, dispaly) { | ||
list(filters, display) { | ||
this.store.list(this._predicates(filters), (item) => { | ||
if (dispaly.location) { | ||
if (display.location) { | ||
const target = this.codeNavRepo.location(item); | ||
@@ -66,21 +64,15 @@ if (fs.existsSync(target)) { | ||
clone(filters) { | ||
stream(filters, callback) { | ||
this.store.list(this._predicates(filters), (item) => callback(item)); | ||
} | ||
remove(filters) { | ||
this.store.list(this._predicates(filters), (item) => { | ||
this.cloneCmd.process(item); | ||
this.store.del(item.ID); | ||
}); | ||
} | ||
goto(filters) { | ||
clone(filters) { | ||
this.store.list(this._predicates(filters), (item) => { | ||
const target = this.codeNavRepo.location(item); | ||
if (!fs.existsSync(target)) { | ||
console.log( | ||
`${item.namespace}/${item.name} is not checked out` | ||
); | ||
return; | ||
} | ||
spawn(this.shellCmd, ['-i'], { | ||
cwd: target, | ||
stdio: 'inherit', | ||
}); | ||
this.cloneCmd.process(item); | ||
}); | ||
@@ -87,0 +79,0 @@ } |
@@ -19,2 +19,6 @@ const levelUp = require('levelup'); | ||
del(key) { | ||
return this.mainDB.del(key); | ||
} | ||
list(predicates, callback) { | ||
@@ -21,0 +25,0 @@ return this.mainDB.createReadStream().on('data', (data) => { |
const https = require('https'); | ||
const http = require('http'); | ||
const QueryString = require('query-string'); | ||
@@ -26,2 +27,3 @@ const client = { | ||
'Content-Type': 'application/json', | ||
connection: 'keep-alive', | ||
}), | ||
@@ -45,7 +47,11 @@ }); | ||
get(path) { | ||
return this._sendRequest({ | ||
path: path, | ||
method: 'GET', | ||
}); | ||
get(path, query) { | ||
const finalQuery = query || {}; | ||
return this._sendRequest( | ||
{ | ||
path: `${path}?${QueryString.stringify(finalQuery)}`, | ||
method: 'GET', | ||
}, | ||
query | ||
); | ||
} | ||
@@ -52,0 +58,0 @@ } |
{ | ||
"name": "codenav", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "code navigation", | ||
"bin": { | ||
"cnav": "./cli/bin/cnav" | ||
"cnav": "./cli/bin/cnav", | ||
"goto": "./cli/bin/goto" | ||
}, | ||
@@ -38,4 +39,5 @@ "scripts": { | ||
"leveldown": "^5.6.0", | ||
"levelup": "^4.4.0" | ||
"levelup": "^4.4.0", | ||
"query-string": "^6.13.6" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
27099
20
450
4
+ Addedquery-string@^6.13.6
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addedfilter-obj@1.1.0(transitive)
+ Addedquery-string@6.14.1(transitive)
+ Addedsplit-on-first@1.1.0(transitive)
+ Addedstrict-uri-encode@2.0.0(transitive)