Skip to content

Commit 3120b80

Browse files
:trollface: Version: 0.2.0-alpha.1
1 parent 15622ae commit 3120b80

File tree

12 files changed

+12199
-10124
lines changed

12 files changed

+12199
-10124
lines changed

bin/backed.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,22 @@ class Server {
180180
* @param {object} server - configuration
181181
* @param {string} server.entry path to where your build is located
182182
* @param {string} server.docs path to where your docs are located
183-
* @param {string} server.path src path of the component
184183
* @param {string} server.bowerPath path to bower_components
185184
* @param {string} server.nodeModulesPath path to node_modules
186185
* @param {string} server.demo path to the demo
187-
* @param {string} server.index path to your index.html file we serve a helper/docs index by default
186+
* @param {string} server.index path to your index.html file we serve a helper/docs index by default (not support for now)
187+
* @param {array} server.use static files to include [{path: some/path, static: some//path}] when static is undefined path will be used.
188188
*/
189-
serve(server) {
189+
serve(server = {
190+
entry: '/',
191+
demo: 'demo',
192+
docs: 'docs',
193+
use: [{path: null, static: null}],
194+
bowerPath: 'bower_components',
195+
nodeModulesPath: 'node_modules',
196+
index: null}) {
190197
if (server) {
191-
if (server.elementLocation) {
192-
logger.warn('Deprecated::server.elementLocation, support ends @0.2.0 [visit](https://github.com/vandeurenglenn/backed-cli#serve) to learn more');
193-
app.use(`/${server.elementLocation}`, express.static(
194-
this.appLocation(server.path, 'some-element.js')));
195-
}
198+
this.handleOldOptions(server);
196199
if (server.use) {
197200
for (let use of server.use) {
198201
app.use(use.path, express.static(this.appLocation(use.static || use.path)));
@@ -208,13 +211,13 @@ class Server {
208211
// this.appLocation(server.path, 'some-element.js')));
209212

210213
app.use('/', express.static(
211-
this.appLocation(server.entry, 'dist')));
214+
this.appLocation(server.entry)));
212215

213216
app.use('/demo', express.static(
214-
this.appLocation(server.demo, 'demo')));
217+
this.appLocation(server.demo)));
215218

216219
app.use('/docs', express.static(
217-
this.appLocation(server.docs, 'docs')));
220+
this.appLocation(server.docs)));
218221

219222
app.use('/package.json', express.static(
220223
this.appLocation('package.json')
@@ -243,7 +246,7 @@ class Server {
243246
logger.log(`${global.config.name}::serving app from http://localhost:${server.port}/${server.entry.replace('/', '')}`);
244247
});
245248
} else {
246-
return logger.warn(`${global.config.name}::server config not found [example](https://github.com/vandeurenglenn/backed-cli/config/backed.json)`);
249+
return logger.warn(`${global.config.name}::server config not found [example](https://raw.githubusercontent.com/VandeurenGlenn/backed-cli/master/config/backed.json)`);
247250
}
248251
}
249252

@@ -263,6 +266,12 @@ class Server {
263266
root += `\\${path}`;
264267
return root;
265268
}
269+
270+
handleOldOptions(options) {
271+
if (options.path || options.elementLocation) {
272+
logger.warn(`${options.path ? 'server.path' : 'server.elementLocation'} is no longer supported, [visit](https://github.com/vandeurenglenn/backed-cli#serve) to learn more'`);
273+
}
274+
}
266275
}
267276

268277
const {readFileSync} = require('fs');

0 commit comments

Comments
 (0)