-
Notifications
You must be signed in to change notification settings - Fork 24
Globalize loopback-angular-sdk-cli #46
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,5 @@ | |
| *.swo | ||
| node_modules | ||
| /test/sandbox | ||
| intl/* | ||
| !intl/en/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,31 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| var fs = require('fs'); | ||
| var path = require('path'); | ||
| var SG = require('strong-globalize'); | ||
| SG.SetRootDir(path.resolve(__dirname, '..')); | ||
| var g = SG(); | ||
|
Contributor
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. This should be at the beginning of the file. |
||
| var fs = require('fs'); | ||
| var semver = require('semver'); | ||
| var optimist = require('optimist'); | ||
| var generator = require('loopback-sdk-angular'); | ||
|
|
||
| var argv = optimist | ||
| .usage('Generate Angular $resource services for your LoopBack application.' + | ||
| .usage(g.f( | ||
| 'Generate {{Angular $resource}} services ' + | ||
| 'for your {{LoopBack}} application.' + | ||
| '\nUsage:' + | ||
| '\n $0 [options] server/app.js [client/js/lb-services.js]') | ||
| .describe('m', 'The name for generated Angular module.') | ||
| '\n $0 {{[options] server/app.js [client/js/lb-services.js]}}')) | ||
| .describe('m', g.f('The name for generated {{Angular}} module.')) | ||
| .default('m', 'lbServices') | ||
| .describe('u', 'URL of the REST API end-point') | ||
| .describe('u', g.f('URL of the REST API end-point')) | ||
| .alias({ u : 'url', m: 'module-name' }) | ||
| .demand(1) | ||
| .argv; | ||
|
|
||
| var appFile = path.resolve(argv._[0]); | ||
| var outputFile = argv._[1]; | ||
|
|
||
| console.error('Loading LoopBack app %j', appFile); | ||
| g.error('Loading {{LoopBack}} app %j', appFile); | ||
| var app = require(appFile); | ||
| assertLoopBackVersion(); | ||
|
|
||
|
|
@@ -34,15 +39,15 @@ function runGenerator() { | |
| var ngModuleName = argv['module-name'] || 'lbServices'; | ||
| var apiUrl = argv['url'] || app.get('restApiRoot') || '/api'; | ||
|
|
||
| console.error('Generating %j for the API endpoint %j', ngModuleName, apiUrl); | ||
| g.error('Generating %j for the API endpoint %j', ngModuleName, apiUrl); | ||
| var result = generator.services(app, ngModuleName, apiUrl); | ||
|
|
||
| if (outputFile) { | ||
| outputFile = path.resolve(outputFile); | ||
| console.error('Saving the generated services source to %j', outputFile); | ||
| g.error('Saving the generated services source to %j', outputFile); | ||
| fs.writeFileSync(outputFile, result); | ||
| } else { | ||
| console.error('Dumping to stdout'); | ||
| g.error('Dumping to {{stdout}}'); | ||
| process.stdout.write(result); | ||
| } | ||
|
|
||
|
|
@@ -67,10 +72,10 @@ function assertLoopBackVersion() { | |
| var loopback = Module._load('loopback', Module._cache[appFile]); | ||
|
|
||
| if (semver.lt(loopback.version, '1.6.0')) { | ||
| console.error( | ||
| '\nThe code generator does not support applications based\n' + | ||
| 'on LoopBack versions older than 1.6.0. Please upgrade your\n' + | ||
| 'project to a recent version of LoopBack and run this tool again.\n'); | ||
| g.error('\n' + | ||
| 'The code generator does not support applications based on\n' + | ||
| '{{LoopBack}} versions older than 1.6.0. Please upgrade your project\n' + | ||
| 'to a recent version of {{LoopBack}} and run this tool again.\n'); | ||
| process.exit(1); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "03bb755ed8213986b1862be937b296bb": "The name for generated {{Angular}} module.", | ||
| "25eecfaa310e55ace4ef6eba593ba32e": "Generating {0} for the API endpoint {1}", | ||
| "3669f5dd8a727a4f4247d7ad86993e0c": "\nThe code generator does not support applications based on\n{{LoopBack}} versions older than 1.6.0. Please upgrade your project\nto a recent version of {{LoopBack}} and run this tool again.\n", | ||
| "af39e85bbd74a37c9a8beec4268564bd": "Generate {{Angular $resource}} services for your {{LoopBack}} application.\nUsage:\n $0 {{[options] server/app.js [client/js/lb-services.js]}}", | ||
| "dbef1e1c2cc9f52ae9aacca33e9d92c2": "Saving the generated services source to {0}", | ||
| "dff77762368d4e45c34a01e661ad2c06": "Loading {{LoopBack}} app {0}", | ||
| "efc6bce92bcb061e3e354a888c7bd76a": "Dumping to {{stdout}}", | ||
| "fc1c9755ca71e88d7aaa4be225d07bc8": "URL of the REST API end-point" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@0candy i moved it up but i need path.
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.
You're the first one to run into this case, but I see your point. Do you need to SetRootDir outside index.js though?
Uh oh!
There was an error while loading. Please reload this page.
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.
do i? @0candy
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.
It can go after path.