Move config to resin module

This commit is contained in:
Juan Cruz Viotti 2014-11-26 13:42:05 -04:00
parent 912ebf6752
commit 9529e6c335
19 changed files with 22 additions and 29 deletions

View File

@ -2,7 +2,6 @@ _ = require('lodash')
async = require('async')
resin = require('../resin')
authHooks = require('../hooks/auth')
config = require('../config')
exports.create = authHooks.failIfNotLoggedIn (name, program) ->
async.waterfall [

View File

@ -2,7 +2,6 @@ open = require('open')
async = require('async')
resin = require('../resin')
authHooks = require('../hooks/auth')
config = require('../config')
exports.login = (credentials) ->
async.waterfall [
@ -22,4 +21,4 @@ exports.logout = authHooks.failIfNotLoggedIn ->
resin.auth.logout()
exports.signup = ->
open(config.urls.signup)
open(resin.config.urls.signup)

View File

@ -1,6 +1,5 @@
resin = require('../resin')
authHooks = require('../hooks/auth')
config = require('../config')
exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
resin.models.device.getAll(applicationId).then (devices) ->
@ -25,4 +24,4 @@ exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
, resin.errors.handle
exports.identify = authHooks.failIfNotLoggedIn (uuid) ->
resin.server.post(config.urls.identify, { uuid }, resin.errors.handle)
resin.server.post(resin.config.urls.identify, { uuid }, resin.errors.handle)

View File

@ -2,10 +2,9 @@ _ = require('lodash')
resin = require('../resin')
authHooks = require('../hooks/auth')
helpers = require('../helpers/helpers')
config = require('../config')
exports.list = authHooks.failIfNotLoggedIn ->
resin.server.get config.urls.keys, (error, response, keys) ->
resin.server.get resin.config.urls.keys, (error, response, keys) ->
resin.errors.handle(error) if error?
resin.log.out resin.ui.widgets.table.horizontal keys, (key) ->
delete key.public_key
@ -18,13 +17,13 @@ exports.info = authHooks.failIfNotLoggedIn (id) ->
# TODO: We don't have a way to query a single ssh key yet.
# As a workaround, we request all of them, and filter
# the one we need. Fix once we have a better way.
resin.server.get config.urls.keys, (error, response, keys) ->
resin.server.get resin.config.urls.keys, (error, response, keys) ->
resin.errors.handle(error) if error?
key = _.findWhere(keys, { id })
if not key?
resin.errors.handle(new resin.errors.NotFound("key #{id}"))
key.public_key = '\n' + helpers.formatLongString(key.public_key, config.sshKeyWidth)
key.public_key = '\n' + helpers.formatLongString(key.public_key, resin.config.sshKeyWidth)
resin.log.out(resin.ui.widgets.table.vertical(key, _.identity, [ 'ID', 'Title', 'Public Key' ]))
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->

View File

@ -1,6 +1,5 @@
open = require('open')
config = require('../config')
authHooks = require('../hooks/auth')
exports.preferences = authHooks.failIfNotLoggedIn ->
open(config.urls.preferences)
open(resin.config.urls.preferences)

View File

@ -1,6 +1,5 @@
_ = require('lodash')
resin = require('./resin')
config = require('./config')
packageJSON = require('../package.json')
program = require('commander')
@ -126,7 +125,7 @@ program
.description('Remove environment variable')
.action(env.remove)
resin.data.prefix.set config.dataPrefix, (error) ->
resin.data.prefix.set resin.config.dataPrefix, (error) ->
throw error if error?
program.parse(process.argv)
resin.log.setQuiet(program.quiet)

View File

@ -1,7 +1,6 @@
expect = require('chai').expect
mock = require('../../tests/utils/mock')
fsUtils = require('./fs-utils')
config = require('../config')
resin = require('../resin')
FILESYSTEM =
@ -30,7 +29,7 @@ describe 'FsUtils:', ->
it 'should return true for valid paths', ->
for validPath in [
config.dataPrefix
resin.config.dataPrefix
'/Users/johndoe'
'../parent'
'./file/../file2'
@ -41,7 +40,7 @@ describe 'FsUtils:', ->
beforeEach (done) ->
mock.fs.init(FILESYSTEM)
resin.data.prefix.set(config.dataPrefix, done)
resin.data.prefix.set(resin.config.dataPrefix, done)
afterEach ->
mock.fs.restore()

View File

@ -2,7 +2,6 @@ _ = require('lodash')
nock = require('nock')
sinon = require('sinon')
expect = require('chai').expect
config = require('../config')
resin = require('../resin')
authHooks = require('./auth')
johnDoeFixture = require('../../tests/fixtures/johndoe')
@ -20,7 +19,7 @@ describe 'Auth Hooks:', ->
beforeEach (done) ->
mock.fs.init()
resin.data.prefix.set(config.dataPrefix, done)
resin.data.prefix.set(resin.config.dataPrefix, done)
afterEach ->
mock.fs.restore()
@ -58,7 +57,7 @@ describe 'Auth Hooks:', ->
describe 'if logged in', ->
beforeEach (done) ->
nock(config.remoteUrl)
nock(resin.config.remoteUrl)
.post('/login_', johnDoeFixture.credentials)
.reply(200, johnDoeFixture.token)

View File

@ -4,7 +4,7 @@ _ = require('lodash')
async = require('async')
auth = require('./auth')
data = require('../data/data')
config = require('../../config')
config = require('../config')
mock = require('../../../tests/utils/mock')
johnDoeFixture = require('../../../tests/fixtures/johndoe')
janeDoeFixture = require('../../../tests/fixtures/janedoe')

View File

@ -5,7 +5,7 @@ fs = require('fs')
fsUtils = require('../../fs-utils/fs-utils')
rimraf = require('rimraf')
dataPrefix = require('./data-prefix')
config = require('../../config')
config = require('../config')
mock = require('../../../tests/utils/mock')
PREFIXES =

View File

@ -3,7 +3,7 @@ _ = require('lodash')
fsUtils = require('../../fs-utils/fs-utils')
mock = require('../../../tests/utils/mock')
async = require('async')
config = require('../../config')
config = require('../config')
data = require('./data')
FILES_FIXTURES =

View File

@ -8,3 +8,4 @@ module.exports =
auth: require('./auth/auth')
device: require('./device/device')
ui: require('./ui')
config: require('./config')

View File

@ -1,7 +1,7 @@
_ = require('lodash')
Canvas = require('resin-platform-api')
Promise = require('bluebird')
config = require('../../config')
config = require('../config')
server = require('../server/server')
promisifiedServerRequest = Promise.promisify(server.request, server)

View File

@ -9,7 +9,7 @@ chai.use(chaiAsPromised)
data = require('../data/data')
mock = require('../../../tests/utils/mock')
canvas = require('./_canvas')
config = require('../../config')
config = require('../config')
URI =
application: url.resolve(config.apiPrefix, 'application')

View File

@ -3,7 +3,7 @@ request = require('request')
urlResolve = require('url').resolve
async = require('async')
connection = require('../../connection/connection')
config = require('../../config')
config = require('../config')
token = require('../token/token')
exports.request = (options = {}, callback) ->

View File

@ -2,7 +2,7 @@ expect = require('chai').expect
nock = require('nock')
url = require('url')
server = require('./server')
config = require('../../config')
config = require('../config')
token = require('../token/token')
data = require('../data/data')
mock = require('../../../tests/utils/mock')

View File

@ -1,7 +1,7 @@
expect = require('chai').expect
async = require('async')
token = require('./token')
config = require('../../config')
config = require('../config')
data = require('../data/data')
mock = require('../../../tests/utils/mock')

View File

@ -1,6 +1,6 @@
mockFs = require('mock-fs')
sinon = require('sinon')
config = require('../../lib/config')
resin = require('../../lib/resin')
connection = require('../../lib/connection/connection')
exports.fs =
@ -10,7 +10,7 @@ exports.fs =
# Mock data prefix automatically to remove
# duplication in most of the tests
mockFsOptions[config.dataPrefix] = mockFs.directory()
mockFsOptions[resin.config.dataPrefix] = mockFs.directory()
for key, value of filesystemConfig
mockFsOptions[value.name] = value.contents