-
Notifications
You must be signed in to change notification settings - Fork 82
Add option to leave out definitions for common modules + namespace models #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,6 @@ masterApp.post('/setup', function(req, res, next) { | |
var name = opts.name; | ||
var models = opts.models; | ||
var enableAuth = opts.enableAuth; | ||
var includeSchema = opts.includeSchema; | ||
var setupFn = compileSetupFn(name, opts.setupFn); | ||
|
||
if (!name) | ||
|
@@ -105,19 +104,8 @@ masterApp.post('/setup', function(req, res, next) { | |
res.send(500, err); | ||
return; | ||
} | ||
|
||
try { | ||
if (includeSchema) { | ||
// the new options-based API | ||
servicesScript = generator.services(lbApp, { | ||
ngModuleName: name, | ||
apiUrl: apiUrl, | ||
includeSchema: includeSchema, | ||
}); | ||
} else { | ||
// the old API, test it to verify backwards compatibility | ||
servicesScript = generator.services(lbApp, name, apiUrl); | ||
} | ||
servicesScript = generateService(generator, lbApp, apiUrl, opts); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep "the old API" branch, we need to keep it covered by unit-tests to prevent regressions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #224 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, this is handled by |
||
} catch (err) { | ||
console.error('Cannot generate services script:', err.stack); | ||
servicesScript = 'throw new Error("Error generating services script.");'; | ||
|
@@ -161,6 +149,28 @@ masterApp.listen(port, function() { | |
runAndExit(process.argv[2], process.argv.slice(3)); | ||
}); | ||
|
||
function generateService(generator, lbApp, apiUrl, opts) { | ||
var servicesScript; | ||
if (opts.includeSchema !== undefined || | ||
opts.includeCommonModules !== undefined || | ||
opts.namespaceModels !== undefined || | ||
opts.namespaceDelimiter !== undefined) { | ||
// the new options-based API | ||
|
||
// build options object for new options-based API | ||
var generatorOptions = opts; | ||
generatorOptions.ngModuleName = opts.name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes! Added - thanks! |
||
generatorOptions.apiUrl = apiUrl; | ||
|
||
servicesScript = generator.services(lbApp, generatorOptions); | ||
} else { | ||
// the old API, test it to verify backwards compatibility | ||
servicesScript = generator.services(lbApp, opts.name, apiUrl); | ||
} | ||
|
||
return servicesScript; | ||
} | ||
|
||
function runAndExit(cmd, args) { | ||
console.log('Running %s %s', cmd, args.join(' ')); | ||
var child = require('child_process').spawn(cmd, args, { stdio: 'inherit' }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modelName
won't be available any more, are you sure it's not used anywhere in the template?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modelName
should be available inside the for loop, as this deleted code just updates the variable, rather than creating a new one (the formatting that used to be in the template is now ingetFormattedModelName
inservices.js
). I double-checked that there isn't anywhere outside the for loop where modelName is used - it's just inside this for loop that we reference it directly.