Skip to content

Commit

Permalink
Upgrade morpho to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
lqtian committed Jun 2, 2016
1 parent dc89d4e commit 01a2f38
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 30 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ require('styles/main.less');

// App JavaScript files
require('scripts/app.js');

require('morpho');

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"webpack-dev-server": "^1.14.1",
"worker-loader": "^0.7.0",
"yaml-js": "^0.1.3",
"file-loader": "^0.8.5",
"morpho": "~0.0.1-alpha.6"
},
"engines": {
Expand Down
1 change: 1 addition & 0 deletions scripts/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ require('scripts/directives/tryoperation.js');
// Enums
require('scripts/enums/defaults.js');
require('scripts/enums/strings.js');
require('scripts/enums/simpleYaml.js');

// Filter
require('scripts/filters/formdata.js');
Expand Down
File renamed without changes.
60 changes: 31 additions & 29 deletions scripts/services/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,30 @@ SwaggerEditor.service('Builder', function Builder(SwayWorker, simpleYaml, Prefer
}
Preferences.set('simpleYAML', enableSimpleYaml);

var prom = new Promise(function(resolve1, reject1) {
if(enableSimpleYaml){
var errors = [];
simpleYaml.model = Morpho.convertFrom['yaml'].call(Morpho, stringValue, errors, {addDefaults:true}, function(errors){
if(errors&&errors.length>0){
var newError = _.map(errors,function(error){
return {simpleYamlError:error};
});
var prom = new Promise(function(resolve1, reject1) {
if(enableSimpleYaml){
var errors = [];
simpleYaml.model = Morpho.convertFrom['yaml'].call(Morpho, stringValue, errors, {addDefaults:true}, function(errors){
if(errors&&errors.length>0){
var newError = _.map(errors,function(error){
return {simpleYamlError:error};
});

reject({
errors: newError,
specs: null
});
} else {
resolve1();
reject({
errors: newError,
specs: simpleYaml.swagger
});
} else {
resolve1();
}
});
var result;
if(!!simpleYaml.model){
simpleYaml.swagger = json = Morpho.convertTo['swagger'].call(Morpho, simpleYaml.model, errors, {returnJSON:true});
}
});
var result;
if(!!simpleYaml.model){
simpleYaml.swagger = json = Morpho.convertTo['swagger'].call(Morpho, simpleYaml.model, errors, {returnJSON:true});
}
}
else {resolve1();}
});
else {resolve1();}
});

prom.then(function() {
// Add `title` from object key to definitions
Expand All @@ -106,17 +106,19 @@ SwaggerEditor.service('Builder', function Builder(SwayWorker, simpleYaml, Prefer
}
}

SwayWorker.run({
definition: json
}, function(data) {
if (data.errors.length) {
reject(data);
} else {
resolve(data);
}
SwayWorker.run({
definition: json
}, function(data) {
if (data.errors.length) {
reject(data);
} else {
resolve(data);
}
});
});
});
};

this.buildDocs = buildDocs;

});
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ var config = {
},
{
test: /\.worker.js$/,
loader: 'worker-loader'
loader: 'worker-loader',
exclude: 'node_modules/'
},
{
test: /simpleYamlWorker.js$/,
loader: 'file?name=[name].[ext]'
},
{
test: /\.png$/,
Expand Down

0 comments on commit 01a2f38

Please sign in to comment.