mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Move config to resin module
This commit is contained in:
parent
912ebf6752
commit
9529e6c335
@ -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 [
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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) ->
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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 =
|
||||
|
@ -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 =
|
||||
|
@ -8,3 +8,4 @@ module.exports =
|
||||
auth: require('./auth/auth')
|
||||
device: require('./device/device')
|
||||
ui: require('./ui')
|
||||
config: require('./config')
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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) ->
|
||||
|
@ -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')
|
||||
|
@ -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')
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user