mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-21 03:55:31 +00:00
Move models to resin
This commit is contained in:
parent
698ddd168c
commit
8b81fbdbbd
@ -7,7 +7,6 @@ log = require('../log/log')
|
||||
resin = require('../resin')
|
||||
widgets = require('../widgets/widgets')
|
||||
patterns = require('../patterns/patterns')
|
||||
applicationModel = require('../models/application')
|
||||
authHooks = require('../hooks/auth')
|
||||
config = require('../config')
|
||||
|
||||
@ -29,14 +28,14 @@ exports.create = authHooks.failIfNotLoggedIn (name, program) ->
|
||||
# Maybe we should break or handle better?
|
||||
slugifiedType = device.getDeviceSlug(type)
|
||||
|
||||
applicationModel.create(name, slugifiedType).then ->
|
||||
resin.models.application.create(name, slugifiedType).then ->
|
||||
return callback()
|
||||
.catch(callback)
|
||||
|
||||
], errors.handle
|
||||
|
||||
exports.list = authHooks.failIfNotLoggedIn ->
|
||||
applicationModel.getAll().then (applications) ->
|
||||
resin.models.application.getAll().then (applications) ->
|
||||
|
||||
log.out table.horizontal applications, (application) ->
|
||||
application.device_type = device.getDisplayName(application.device_type)
|
||||
@ -50,7 +49,7 @@ exports.list = authHooks.failIfNotLoggedIn ->
|
||||
.catch(errors.handle)
|
||||
|
||||
exports.info = authHooks.failIfNotLoggedIn (id) ->
|
||||
applicationModel.get(id).then (application) ->
|
||||
resin.models.application.get(id).then (application) ->
|
||||
|
||||
log.out table.vertical application, (application) ->
|
||||
application.device_type = device.getDisplayName(application.device_type)
|
||||
@ -67,7 +66,7 @@ exports.restart = authHooks.failIfNotLoggedIn (id) ->
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
||||
patterns.remove 'application', program.parent.yes, (callback) ->
|
||||
applicationModel.remove(id).then ->
|
||||
resin.models.application.remove(id).then ->
|
||||
return callback()
|
||||
.catch(callback)
|
||||
, errors.handle
|
||||
|
@ -1,4 +1,3 @@
|
||||
deviceModel = require('../models/device')
|
||||
getDeviceDisplayName = require('../device/device').getDisplayName
|
||||
log = require('../log/log')
|
||||
table = require('../table/table')
|
||||
@ -10,7 +9,7 @@ authHooks = require('../hooks/auth')
|
||||
config = require('../config')
|
||||
|
||||
exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
|
||||
deviceModel.getAll(applicationId).then (devices) ->
|
||||
resin.models.device.getAll(applicationId).then (devices) ->
|
||||
|
||||
log.out table.horizontal devices, (device) ->
|
||||
device.application = device.application[0].app_name
|
||||
@ -26,7 +25,7 @@ exports.list = authHooks.failIfNotLoggedIn (applicationId) ->
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
||||
patterns.remove 'device', program.parent.yes, (callback) ->
|
||||
deviceModel.remove(id).then ->
|
||||
resin.models.device.remove(id).then ->
|
||||
return callback()
|
||||
.catch(callback)
|
||||
, errors.handle
|
||||
|
@ -3,7 +3,7 @@ table = require('../table/table')
|
||||
errors = require('../errors/errors')
|
||||
patterns = require('../patterns/patterns')
|
||||
log = require('../log/log')
|
||||
environemtVariablesModel = require('../models/environment-variables')
|
||||
resin = require('../resin')
|
||||
authHooks = require('../hooks/auth')
|
||||
|
||||
SYSTEM_VAR_REGEX = /^RESIN_/
|
||||
@ -17,7 +17,7 @@ exports.list = authHooks.failIfNotLoggedIn (program) ->
|
||||
if not applicationId?
|
||||
errors.handle(new Error('You have to specify an application'))
|
||||
|
||||
environemtVariablesModel.getAll(applicationId).then (environmentVariables) ->
|
||||
resin.models.environmentVariables.getAll(applicationId).then (environmentVariables) ->
|
||||
|
||||
if not program.parent.verbose?
|
||||
environmentVariables = _.reject(environmentVariables, isSystemVariable)
|
||||
@ -27,7 +27,7 @@ exports.list = authHooks.failIfNotLoggedIn (program) ->
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
||||
patterns.remove 'environment variable', program.parent.yes, (callback) ->
|
||||
environemtVariablesModel.remove(id).then ->
|
||||
resin.models.environmentVariables.remove(id).then ->
|
||||
return callback()
|
||||
.catch(callback)
|
||||
, errors.handle
|
||||
|
@ -6,7 +6,6 @@ patterns = require('../patterns/patterns')
|
||||
table = require('../table/table')
|
||||
helpers = require('../helpers/helpers')
|
||||
errors = require('../errors/errors')
|
||||
keyModel = require('../models/key')
|
||||
config = require('../config')
|
||||
|
||||
exports.list = authHooks.failIfNotLoggedIn ->
|
||||
|
@ -1,5 +0,0 @@
|
||||
canvas = require('./_canvas')
|
||||
|
||||
exports.getAll = ->
|
||||
return canvas.get
|
||||
resource: 'user__has__public_key'
|
@ -1,2 +1,3 @@
|
||||
module.exports =
|
||||
server: require('./server/server')
|
||||
models: require('./models')
|
||||
|
@ -1,9 +1,9 @@
|
||||
_ = require('lodash')
|
||||
Canvas = require('resin-platform-api')
|
||||
Promise = require('bluebird')
|
||||
config = require('../config')
|
||||
resin = require('../resin')
|
||||
promisifiedServerRequest = Promise.promisify(resin.server.request)
|
||||
config = require('../../config')
|
||||
server = require('../server/server')
|
||||
promisifiedServerRequest = Promise.promisify(server.request, server)
|
||||
|
||||
class CanvasRequestService extends Canvas(_, Promise)
|
||||
_request: (params) ->
|
@ -6,9 +6,9 @@ chaiAsPromised = require('chai-as-promised')
|
||||
expect = chai.expect
|
||||
chai.use(chaiAsPromised)
|
||||
|
||||
mock = require('../../tests/utils/mock')
|
||||
mock = require('../../../tests/utils/mock')
|
||||
canvas = require('./_canvas')
|
||||
config = require('../config')
|
||||
config = require('../../config')
|
||||
|
||||
URI =
|
||||
application: url.resolve(config.apiPrefix, 'application')
|
@ -1,7 +1,7 @@
|
||||
_ = require('lodash')
|
||||
Promise = require('bluebird')
|
||||
canvas = require('./_canvas')
|
||||
errors = require('../errors/errors')
|
||||
errors = require('../../errors/errors')
|
||||
|
||||
exports.getAll = ->
|
||||
return canvas.get
|
@ -1,7 +1,7 @@
|
||||
canvas = require('./_canvas')
|
||||
_ = require('lodash')
|
||||
Promise = require('bluebird')
|
||||
errors = require('../errors/errors')
|
||||
errors = require('../../errors/errors')
|
||||
|
||||
exports.getAll = (applicationId) ->
|
||||
return canvas.get
|
@ -1,6 +1,6 @@
|
||||
Promise = require('bluebird')
|
||||
canvas = require('./_canvas')
|
||||
errors = require('../errors/errors')
|
||||
errors = require('../../errors/errors')
|
||||
|
||||
exports.getAll = (applicationId) ->
|
||||
return canvas.get
|
4
lib/resin/models/index.coffee
Normal file
4
lib/resin/models/index.coffee
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports =
|
||||
application: require('./application')
|
||||
device: require('./device')
|
||||
environmentVariables: require('./environment-variables')
|
Loading…
Reference in New Issue
Block a user