Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ karma-xunit.xml
checkstyle.xml
.loopbackrc
loopback-sdk-angular-*.tgz
intl/*
!intl/en/
Copy link
Copy Markdown
Member

@Amir-61 Amir-61 Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add an empty line at the end of file;
  • I think you don't need !intl/, do you?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is an empty line EOF, or else github gives you an icon

13 changes: 7 additions & 6 deletions apidocs/describe-builtin-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/* eslint quotes: ["error", "single"] */
var fs = require('fs');
var g = require('strong-globalize')();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inside the try/catch below where require('loopback') is done. This is what allows apidocs.strongloop.com to work without installing any dependencies.

This line is the root cause of strongloop-internal/apidocs.strongloop.com#56 :-(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmg thanks for catching this!

var path = require('path');

var loopbackCoreJs = path.resolve(__dirname, 'loopback-core.js');
Expand All @@ -14,14 +15,14 @@ try {
var loopback = require('loopback');
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND' && fs.existsSync(loopbackCoreJs)) {
console.log('Cannot load the generator, node_modules were not installed.');
console.log('Ignoring the error since the output file is already there.');
g.log('Cannot load the generator, {{node_modules}} were not installed.');
g.log('Ignoring the error since the output file is already there.');
process.exit();
}
throw err;
}

console.log('Generating API docs for LoopBack built-in models.');
g.log('Generating API docs for {{LoopBack}} built-in models.');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{API docs}} or at least {{API}}; I leave the decision up to you :-)


var app = loopback();

Expand All @@ -47,10 +48,10 @@ modelNames.forEach(function(key) {
var model = loopback[key];
if (model.prototype instanceof loopback.PersistedModel) {
app.model(model, { dataSource: 'db' });
console.log(' added persisted model %s', key);
g.log(' added persisted model %s', key);
} else if (model.prototype instanceof loopback.Model) {
app.model(model);
console.log(' added model %s', key);
g.log(' added model %s', key);
}
});

Expand Down Expand Up @@ -78,4 +79,4 @@ script = script

fs.writeFileSync(loopbackCoreJs, script);

console.log('Done: %s', loopbackCoreJs);
g.log('Done: %s', loopbackCoreJs);
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var SG = require('strong-globalize');
SG.SetRootDir(__dirname);

exports.services = require('./lib/services');
11 changes: 11 additions & 0 deletions intl/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"0728b2dc3a43387122cef6a0f8e6ae88": "Done: {0}",
"49b1a42e7167e2916a647035e63fa38d": "Ignoring the error since the output file is already there.",
"55b88ce76ecf41ed740c06fe368d6927": " added persisted model {0}",
"8b3e8438920fd9cda69acce828e08c8c": " added model {0}",
"8f526d8f0c4d626df5716289394acf4b": "Cannot load the generator, {{node_modules}} were not installed.",
"e845a1cf62c0034ffc626e5b367e95bc": "Generating API docs for {{LoopBack}} built-in models.",
"0dad411c9eeeb7faf91fe1239f377053": "Skipping {0} as it is not a {{LoopBack}} model",
"e3754d2933e680229f6317b0db99b5df": "Warning: scope {0}.{1} is missing {{_targetClass}} property.\nThe {{Angular}} code for this scope won't be generated.\nPlease upgrade to the latest version of\n{{loopback-datasource-juggler}} to fix the problem.",
"fd8574ea2b57b9b8cf5164811a138fb4": "Warning: scope {0}.{1} targets class {2}, which is not exposed \nvia remoting. The {{Angular}} code for this scope won't be generated."
}
17 changes: 9 additions & 8 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var fs = require('fs');
var ejs = require('ejs');
var extend = require('util')._extend;
var g = require('strong-globalize')();

ejs.filters.q = function(obj) {
return JSON.stringify(obj, null, 2);
Expand Down Expand Up @@ -95,7 +96,7 @@ function describeModels(app, options) {
if (!c.ctor) {
// Skip classes that don't have a shared ctor
// as they are not LoopBack models
console.error('Skipping %j as it is not a LoopBack model', name);
g.error('Skipping %j as it is not a {{LoopBack}} model', name);
return;
}

Expand Down Expand Up @@ -179,20 +180,20 @@ function buildScopeMethod(models, modelName, method) {

if (modelClass.scopes[scopeName] === undefined) {
if (!targetClass) {
console.error(
'Warning: scope %s.%s is missing _targetClass property.' +
'\nThe Angular code for this scope won\'t be generated.' +
g.error(
'Warning: scope %s.%s is missing {{_targetClass}} property.' +
'\nThe {{Angular}} code for this scope won\'t be generated.' +
'\nPlease upgrade to the latest version of' +
'\nloopback-datasource-juggler to fix the problem.',
'\n{{loopback-datasource-juggler}} to fix the problem.',
modelName, scopeName);
modelClass.scopes[scopeName] = null;
return;
}

if (!findModelByName(models, targetClass)) {
console.error(
'Warning: scope %s.%s targets class %j, which is not exposed ' +
'\nvia remoting. The Angular code for this scope won\'t be generated.',
g.error(
'Warning: scope %s.%s targets class %j, which is not exposed \nvia' +
' remoting. The {{Angular}} code for this scope won\'t be generated.',
modelName, scopeName, targetClass);
modelClass.scopes[scopeName] = null;
return;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"url": "https://github.com/strongloop/loopback-sdk-angular/issues"
},
"dependencies": {
"ejs": "^1.0"
"ejs": "^1.0",
"strong-globalize": "^2.6.0"
},
"devDependencies": {
"angular": "^1.4.9",
Expand Down