-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/fragmentation
- Loading branch information
Showing
23 changed files
with
373 additions
and
117 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,116 @@ | ||
"use strict"; | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
|
||
var _jargon = require("jargon"); | ||
|
||
var _jargon2 = _interopRequireDefault(_jargon); | ||
|
||
var yeoman = require("yeoman-generator"); | ||
var chalk = require("chalk"); | ||
var yosay = require("yosay"); | ||
|
||
module.exports = yeoman.generators.Base.extend({ | ||
initializing: function yoInitializing() { | ||
this.pkg = require("../../package.json"); | ||
}, | ||
|
||
prompting: function yoPrompt() { | ||
var done = this.async(); | ||
|
||
// Have Yeoman greet the user. | ||
this.log(yosay("Welcome to the stylish " + chalk.red("FamScudl") + " generator! our base path is " + this.destinationRoot())); | ||
|
||
var prompts = [{ | ||
type: "input", | ||
name: "name", | ||
message: "What is the model name? (use camel case please)", | ||
"default": "myModel" | ||
}, { | ||
type: "input", | ||
name: "attributeString", | ||
message: "Provide the model attributes sepparated by a comma? (like name,link,email,contactPhone)", | ||
"default": "name" | ||
}]; | ||
|
||
this.prompt(prompts, (function (props) { | ||
this.props = props; | ||
done(); | ||
}).bind(this)); | ||
}, | ||
|
||
writing: function yoWriting() { | ||
var _this = this; | ||
|
||
var context = { | ||
name: this.props.name, | ||
Name: (0, _jargon2["default"])(this.props.name).pascal.toString(), | ||
names: (0, _jargon2["default"])(this.props.name).plural.toString(), | ||
_name: (0, _jargon2["default"])(this.props.name).snake.toString(), | ||
attributes: this.props.attributes, | ||
attributeString: this.props.attributeString | ||
}; | ||
|
||
context.attributes = context.attributeString.split(","); | ||
|
||
//filling a strings that are going to be used in the templates to mock a test entity | ||
context.attributesWithValues = ""; | ||
context.fieldsWithValues = ""; | ||
context.validateString = ""; | ||
context.attributes.forEach(function (attributeName, index) { | ||
if (index > 0) { | ||
var breakLine = ",\n"; | ||
context.attributesWithValues += breakLine; | ||
context.fieldsWithValues += breakLine; | ||
context.validateString += breakLine; | ||
} | ||
var snakeAttributeName = (0, _jargon2["default"])(attributeName).snake.toString(); | ||
context.attributesWithValues += "\"" + attributeName + "\": \"test " + attributeName + "\""; | ||
context.fieldsWithValues += "\"" + snakeAttributeName + "\": " + context.name + "." + attributeName; | ||
context.validateString += "this.ensure(\"" + attributeName + "\", isNotEmpty);"; | ||
}); | ||
context.attributesJson = JSON.stringify(context.attributesWithValues); | ||
|
||
//copy common steps | ||
["_common.steps.js", "_accessToken.steps.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_", ""); | ||
_this.fs.copyTpl(_this.templatePath("es6/features/steps/" + templatePath), _this.destinationPath("es6/features/steps/" + newName), context); | ||
}, this); | ||
|
||
//copy common functions | ||
["_jsonWebToken.js", "_language.js", "_request.js", "_values.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_", ""); | ||
_this.fs.copyTpl(_this.templatePath("es6/features/steps/common/" + templatePath), _this.destinationPath("es6/features/steps/common/" + newName), context); | ||
}, this); | ||
|
||
//copy support files | ||
["_hooks.js", "_world.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_", ""); | ||
_this.fs.copyTpl(_this.templatePath("es6/features/support/" + templatePath), _this.destinationPath("es6/features/support/" + newName), context); | ||
}, this); | ||
|
||
//copy controllers | ||
["_applicationController.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_model", "" + context.name).replace("_", ""); | ||
_this.fs.copyTpl(_this.templatePath("es6/app/controllers/" + templatePath), _this.destinationPath("es6/app/controllers/" + newName), context); | ||
}, this); | ||
|
||
//copy managers | ||
["_accountManager.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_model", "" + context.name).replace("_", ""); | ||
_this.fs.copyTpl(_this.templatePath("es6/app/managers/" + templatePath), _this.destinationPath("es6/app/managers/" + newName), context); | ||
}, this); | ||
|
||
//copy misc | ||
["_errors.js", "_server.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_", ""); | ||
_this.fs.copyTpl(_this.templatePath("es6/app/" + templatePath), _this.destinationPath("es6/app/" + newName), context); | ||
}, this); | ||
}, | ||
|
||
install: function yoInstall() { | ||
this.installDependencies({ | ||
skipInstall: true | ||
}); | ||
} | ||
}); |
This file contains 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
This file contains 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,38 @@ | ||
"use strict"; | ||
|
||
var path = require("path"); | ||
var assert = require("yeoman-generator").assert; | ||
var helpers = require("yeoman-generator").test; | ||
var os = require("os"); | ||
|
||
describe("troupe", function () { | ||
var name = undefined; | ||
|
||
before(function (done) { | ||
name = "model"; | ||
helpers.run(path.join(__dirname, "../../generators/common")).inDir(path.join(os.tmpdir(), "./temp-test")).withOptions({ "skip-install": true }).withPrompts({ | ||
name: name, | ||
attributes: "name" | ||
}).on("end", done); | ||
}); | ||
|
||
it("creates cucumber js files", function () { | ||
assert.file(["es6/features/steps/common/jsonWebToken.js", "es6/features/steps/common/language.js", "es6/features/steps/common/request.js", "es6/features/steps/common/values.js", "es6/features/steps/accessToken.steps.js", "es6/features/support/hooks.js", "es6/features/support/world.js"]); | ||
}); | ||
|
||
it("creates a common step file", function () { | ||
assert.file(["es6/features/steps/common.steps.js"]); | ||
}); | ||
|
||
it("creates the controllers", function () { | ||
assert.file(["es6/app/controllers/applicationController.js"]); | ||
}); | ||
|
||
it("creates the managers", function () { | ||
assert.file(["es6/app/managers/accountManager.js"]); | ||
}); | ||
|
||
it("creates misc files", function () { | ||
assert.file(["es6/app/errors.js", "es6/app/server.js"]); | ||
}); | ||
}); |
This file contains 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
This file contains 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
Oops, something went wrong.