-
Notifications
You must be signed in to change notification settings - Fork 70
Rework the implementation to use loopback-workspace 3.0 #5
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 |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| 'use strict'; | ||
| var util = require('util'); | ||
| var workspace = require('loopback-workspace'); | ||
| var Project = workspace.models.Project; | ||
|
|
||
| var actions = exports; | ||
|
|
||
|
|
@@ -11,20 +9,21 @@ var actions = exports; | |
|
|
||
| /** | ||
| * Load the project in `this.destinationRoo()`. | ||
| * Set `this.projectDir` and `this.project`. | ||
| * Set `this.projectDir`. | ||
| * @async | ||
| */ | ||
| actions.loadProject = function() { | ||
| if (this.options.nested && this.options.projectDir && this.options.project) { | ||
| if (this.options.nested && this.options.projectDir) { | ||
| this._externalProject = true; | ||
| this.projectDir = this.options.projectDir; | ||
| this.project = this.options.project; | ||
| return; | ||
| } | ||
|
|
||
| var done = this.async(); | ||
| this.projectDir = this.destinationRoot(); | ||
| process.env.WORKSPACE_DIR = this.projectDir; | ||
|
|
||
| /* TODO - validate the project | ||
|
Member
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. It would be nice maintain our convention of
Member
Author
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 is a short-lived item, I'll implement it in next few days. I do follow the convention in other comments. |
||
| var done = this.async(); | ||
| Project.isValidProjectDir(this.projectDir, function(err, isValid, message) { | ||
| if (err) { | ||
| return done(err); | ||
|
|
@@ -37,41 +36,30 @@ actions.loadProject = function() { | |
| message); | ||
| return done(new Error(msg)); | ||
| } | ||
|
|
||
| Project.loadFromFiles(this.projectDir, function(err, project) { | ||
| if (err) { | ||
| return done(err); | ||
| } | ||
|
|
||
| this.project = project; | ||
| done(); | ||
| }.bind(this)); | ||
| }.bind(this)); | ||
| */ | ||
| }; | ||
|
|
||
| /** | ||
| * Save `this.project`, update all project files. | ||
| * Save the current project, update all project files. | ||
| */ | ||
| actions.saveProject = function() { | ||
| if (this._externalProject) { | ||
| return; | ||
| } | ||
|
|
||
| var done = this.async(); | ||
| this.project.saveToFiles(this.projectDir, done); | ||
| // no-op in workspace 3.0 | ||
|
Member
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. Should we expose this again in workspace 3.0? Does it have value still?
Member
Author
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. Since all changes are saved automatically, it does not make sense to expose it in workspace 3.0. I am keeping the |
||
| }; | ||
|
|
||
| /** | ||
| * Load all models of `this.project`. | ||
| * Load all models of the current project. | ||
| * `this.projectModels` will contain an array of all models (Array.<Model>) | ||
| * `this.modelNames` will contain an array of names (Array.<string>) | ||
| */ | ||
| actions.loadModels = function() { | ||
| var done = this.async(); | ||
| this.project.models(function(err, results) { | ||
| if (err) { | ||
| return done(err); | ||
| } | ||
| workspace.models.ModelDefinition.all(function(err, results) { | ||
| if (err) return done(err); | ||
| this.projectModels = results; | ||
| this.modelNames = results.map(function(m) { | ||
| return m.name; | ||
|
|
||
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.
Might want to comment this or get rid of it