|
3 | 3 | const _ = require('lodash'), |
4 | 4 | BbPromise = require('bluebird'), |
5 | 5 | tables = require('./tables/core'), |
6 | | - dynamodb = require('./dynamodb/core'); |
| 6 | + dynamodbLocal = require('dynamodb-localhost'); |
7 | 7 |
|
8 | 8 | module.exports = function(S) { // Always pass in the ServerlessPlugin Class |
9 | 9 | const SCli = require(S.getServerlessPath('utils/cli')); |
@@ -45,6 +45,12 @@ module.exports = function(S) { // Always pass in the ServerlessPlugin Class |
45 | 45 | context: 'dynamodb', |
46 | 46 | contextAction: 'remove' |
47 | 47 | }); |
| 48 | + S.addAction(this.install.bind(this), { |
| 49 | + handler: 'dynamodbInstall', |
| 50 | + description: 'Install dynamodb local database. This is a single time operation.', |
| 51 | + context: 'dynamodb', |
| 52 | + contextAction: 'install' |
| 53 | + }); |
48 | 54 | S.addAction(this.start.bind(this), { |
49 | 55 | handler: 'dynamodbStart', |
50 | 56 | description: 'Start dynamodb local database', |
@@ -101,7 +107,15 @@ module.exports = function(S) { // Always pass in the ServerlessPlugin Class |
101 | 107 | */ |
102 | 108 |
|
103 | 109 | remove() { |
104 | | - return dynamodb.remove(); |
| 110 | + return new BbPromise(function(resolve, reject) { |
| 111 | + dynamodbLocal.remove(resolve); |
| 112 | + }); |
| 113 | + } |
| 114 | + |
| 115 | + install() { |
| 116 | + return new BbPromise(function(resolve, reject) { |
| 117 | + dynamodbLocal.install(resolve); |
| 118 | + }); |
105 | 119 | } |
106 | 120 |
|
107 | 121 | table(evt) { |
@@ -132,18 +146,18 @@ module.exports = function(S) { // Always pass in the ServerlessPlugin Class |
132 | 146 | options = _.merge({ |
133 | 147 | sharedDb: evt.options.sharedDb || true |
134 | 148 | }, |
135 | | - evt.options, { downloadFrom: config.downloadFrom }, |
| 149 | + evt.options, |
136 | 150 | config && config.start |
137 | | - ), |
138 | | - _spinner = SCli.spinner(); |
| 151 | + ); |
139 | 152 | if (options.create) { |
140 | | - dynamodb.start(options).then(function() { |
141 | | - console.log(""); // seperator |
142 | | - self.table(evt).then(resolve, reject); |
143 | | - }); |
| 153 | + dynamodbLocal.start(options); |
| 154 | + console.log(""); // seperator |
| 155 | + self.table(evt); |
| 156 | + resolve(); |
144 | 157 | } else { |
145 | | - _spinner.start(); |
146 | | - dynamodb.start(options, _spinner).then(resolve, reject); |
| 158 | + dynamodbLocal.start(options); |
| 159 | + console.log(""); |
| 160 | + resolve(); |
147 | 161 | } |
148 | 162 | }); |
149 | 163 | } |
|
0 commit comments