From 0d5378722336fa8da133d5749954d95bf272d063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 2 Jul 2014 15:32:14 +0200 Subject: [PATCH 1/4] clean up TODO comments Use the convention // TODO({author}) --- acl/index.js | 2 +- app/index.js | 5 +++-- test/acl.test.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/acl/index.js b/acl/index.js index cad6d79..dd28032 100644 --- a/acl/index.js +++ b/acl/index.js @@ -125,7 +125,7 @@ module.exports = yeoman.generators.Base.extend({ this.aclDef = { property: answers.property, accessType: answers.accessType, - principalType: 'ROLE', // TODO support all principal types + principalType: 'ROLE', // TODO(bajtos) support all principal types principalId: answers.role, permission: answers.permission }; diff --git a/app/index.js b/app/index.js index 8809fa5..96c92be 100644 --- a/app/index.js +++ b/app/index.js @@ -48,7 +48,7 @@ module.exports = yeoman.generators.Base.extend({ if (err) return done(err); this.templates = list.map(function(t) { return { - // TODO - workspace does not provide template details yet + // TODO(bajtos) - workspace does not provide template details yet // name: util.format('%s (%s)', t.name, t.description), // value: t.name name: t, @@ -73,7 +73,7 @@ module.exports = yeoman.generators.Base.extend({ default: name }, /* - TODO: not all templates are projects, some of them are mere components + TODO(bajtos) not all templates are projects, some of them are components The only functional project template is 'api-server' at the moment { name: 'template', @@ -87,6 +87,7 @@ module.exports = yeoman.generators.Base.extend({ this.prompt(prompts, function(props) { this.appname = props.appname; + // TODO(bajtos) see the TODO comment above //this.template = props.template; this.template = 'api-server'; diff --git a/test/acl.test.js b/test/acl.test.js index 558de5c..8c5370e 100644 --- a/test/acl.test.js +++ b/test/acl.test.js @@ -47,7 +47,7 @@ describe('loopback:acl generator', function() { var carAcls = def.acls; expect(carAcls).to.eql([{ - id: 1, // TODO fix workspace to not add this extra property + id: 1, // TODO(bajtos) fix workspace to not add this extra property accessType: '*', permission: 'AUDIT', principalType: 'ROLE', From d40b06fa9010f147efec56d554e4d17f67cfb9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 2 Jul 2014 15:53:43 +0200 Subject: [PATCH 2/4] app: Provide custom copyRecursive implementation Override `Workspace.copyRecursive` with yeoman's `directory` to enable conflict detection for templated files. --- app/index.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/index.js b/app/index.js index 96c92be..c171b17 100644 --- a/app/index.js +++ b/app/index.js @@ -21,20 +21,17 @@ module.exports = yeoman.generators.Base.extend({ }); }, - injectProjectWriteFile: function() { - /* TODO inject `this.directory` to replace `ncp` in workspace - // Modify Project.writeFile use yeoman's write - var _projectWriteFile = Project.writeFile; - Project.writeFile = function(filepath, content, encoding, cb) { - this.write(filepath, content, { encoding: encoding }); - cb(); + injectWorkspaceCopyRecursive: function() { + var originalMethod = Workspace.copyRecursive; + Workspace.copyRecursive = function(src, dest, cb) { + this.directory(src, dest); + process.nextTick(cb); }.bind(this); - // Restore Project.writeFile when done + // Restore the original method when done this.on('end', function() { - Project.writeFile = _projectWriteFile; + Workspace.copyRecursive = originalMethod; }); - */ }, initWorkspace: function() { From fea4cd9645a9ef2f13195e4182f877a580c51d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 2 Jul 2014 15:56:38 +0200 Subject: [PATCH 3/4] test/app: check *.js files are created --- test/app.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/app.test.js b/test/app.test.js index 3aca181..f0f793c 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -20,10 +20,10 @@ describe('loopback:app generator', function() { 'rest/datasources.json', 'rest/models.json', - // TODO rest/rest.js + 'rest/rest.js', 'server/config.json', - // TODO server/server.js + 'server/server.js', ]; var gen = givenAppGenerator(); From cebe998f6f9189aae4c11ca597a7215fd9abcc6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 2 Jul 2014 16:01:57 +0200 Subject: [PATCH 4/4] actions: validate the workspace dir in loadProject Call `Workspace.isValidDir` from `actions.loadProject` to ensure the working directory is a valid workspace. --- lib/actions.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/actions.js b/lib/actions.js index 9f36575..f12f95e 100644 --- a/lib/actions.js +++ b/lib/actions.js @@ -1,5 +1,6 @@ 'use strict'; var workspace = require('loopback-workspace'); +var Workspace = workspace.models.Workspace; var actions = exports; @@ -22,22 +23,8 @@ actions.loadProject = function() { this.projectDir = this.destinationRoot(); process.env.WORKSPACE_DIR = this.projectDir; - /* TODO - validate the project var done = this.async(); - Project.isValidProjectDir(this.projectDir, function(err, isValid, message) { - if (err) { - return done(err); - } - - if (!isValid) { - var msg = util.format( - 'The directory %s is not a valid LoopBack project. %s', - this.projectDir, - message); - return done(new Error(msg)); - } - }.bind(this)); - */ + Workspace.isValidDir(done); }; /**