-
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.
now features generate separately from controllers
- Loading branch information
1 parent
7f20320
commit 63bf6ed
Showing
24 changed files
with
311 additions
and
77 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,61 @@ | ||
"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"); | ||
|
||
module.exports = yeoman.generators.Base.extend({ | ||
initializing: function yoInitializing() { | ||
this.pkg = require("../../package.json"); | ||
}, | ||
|
||
prompting: function yoPrompt() { | ||
var done = this.async(); | ||
|
||
var prompts = [{ | ||
type: "input", | ||
name: "name", | ||
message: "What is the model name? (use camel case please)", | ||
"default": "myModel" | ||
}]; | ||
|
||
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() | ||
}; | ||
|
||
//copy feature steps | ||
["_modelController.common.steps.js", "_modelController.show.steps.js", "_modelController.create.steps.js", "_modelController.update.steps.js", "_modelController.delete.steps.js", "_modelController.list.steps.js"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_model", "" + context.name); | ||
_this.fs.copyTpl(_this.templatePath("features/steps/" + templatePath), _this.destinationPath("features/steps/" + context.name + "/" + newName), context); | ||
}, this); | ||
|
||
//copy features | ||
["_modelController.show.feature", "_modelController.create.feature", "_modelController.update.feature", "_modelController.delete.feature", "_modelController.list.feature"].forEach(function (templatePath) { | ||
var newName = templatePath.replace("_model", "" + context.name); | ||
_this.fs.copyTpl(_this.templatePath("features/" + templatePath), _this.destinationPath("features/" + context.name + "/" + 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,25 @@ | ||
"use strict"; | ||
|
||
var path = require("path"); | ||
var assert = require("yeoman-generator").assert; | ||
var helpers = require("yeoman-generator").test; | ||
var os = require("os"); | ||
|
||
describe("forbin-scudl:features", function () { | ||
var name = undefined; | ||
|
||
before(function (done) { | ||
name = "model"; | ||
helpers.run(path.join(__dirname, "../../generators/features")).inDir(path.join(os.tmpdir(), "./temp-test")).withOptions({ "skip-install": true }).withPrompts({ | ||
name: name | ||
}).on("end", done); | ||
}); | ||
|
||
it("creates step files", function () { | ||
assert.file(["features/steps/" + name + "/" + name + "Controller.common.steps.js", "features/steps/" + name + "/" + name + "Controller.show.steps.js", "features/steps/" + name + "/" + name + "Controller.create.steps.js", "features/steps/" + name + "/" + name + "Controller.update.steps.js", "features/steps/" + name + "/" + name + "Controller.delete.steps.js", "features/steps/" + name + "/" + name + "Controller.list.steps.js"]); | ||
}); | ||
|
||
it("creates feature files", function () { | ||
assert.file(["features/" + name + "/" + name + "Controller.show.feature", "features/" + name + "/" + name + "Controller.create.feature", "features/" + name + "/" + name + "Controller.update.feature", "features/" + name + "/" + name + "Controller.delete.feature", "features/" + name + "/" + name + "Controller.list.feature"]); | ||
}); | ||
}); |
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,72 @@ | ||
var yeoman = require("yeoman-generator"); | ||
|
||
import inflect from "jargon"; | ||
|
||
module.exports = yeoman.generators.Base.extend({ | ||
initializing: function yoInitializing() { | ||
this.pkg = require("../../package.json"); | ||
}, | ||
|
||
prompting: function yoPrompt() { | ||
var done = this.async(); | ||
|
||
var prompts = [{ | ||
type: "input", | ||
name: "name", | ||
message: "What is the model name? (use camel case please)", | ||
default: "myModel" | ||
}]; | ||
|
||
this.prompt(prompts, function (props) { | ||
this.props = props; | ||
|
||
done(); | ||
}.bind(this)); | ||
}, | ||
|
||
writing: function yoWriting() { | ||
const context = { | ||
name: this.props.name, | ||
Name: inflect(this.props.name).pascal.toString(), | ||
names: inflect(this.props.name).plural.toString(), | ||
_name: inflect(this.props.name).snake.toString() | ||
}; | ||
|
||
//copy feature steps | ||
["_modelController.common.steps.js", | ||
"_modelController.show.steps.js", | ||
"_modelController.create.steps.js", | ||
"_modelController.update.steps.js", | ||
"_modelController.delete.steps.js", | ||
"_modelController.list.steps.js"] | ||
.forEach((templatePath) => { | ||
let newName = templatePath.replace("_model", `${context.name}`); | ||
this.fs.copyTpl( | ||
this.templatePath("features/steps/" + templatePath), | ||
this.destinationPath(`features/steps/${context.name}/${newName}`), | ||
context | ||
); | ||
}, this); | ||
|
||
//copy features | ||
["_modelController.show.feature", | ||
"_modelController.create.feature", | ||
"_modelController.update.feature", | ||
"_modelController.delete.feature", | ||
"_modelController.list.feature"] | ||
.forEach((templatePath) => { | ||
let newName = templatePath.replace("_model", `${context.name}`); | ||
this.fs.copyTpl( | ||
this.templatePath("features/" + templatePath), | ||
this.destinationPath(`features/${context.name}/${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,40 @@ | ||
const path = require("path"); | ||
const assert = require("yeoman-generator").assert; | ||
const helpers = require("yeoman-generator").test; | ||
const os = require("os"); | ||
|
||
describe("forbin-scudl:features", () => { | ||
let name; | ||
|
||
before((done) => { | ||
name = "model"; | ||
helpers.run(path.join(__dirname, "../../generators/features")) | ||
.inDir(path.join(os.tmpdir(), "./temp-test")) | ||
.withOptions({ "skip-install": true }) | ||
.withPrompts({ | ||
name: name | ||
}) | ||
.on("end", done); | ||
}); | ||
|
||
it("creates step files", () => { | ||
assert.file([ | ||
`features/steps/${name}/${name}Controller.common.steps.js`, | ||
`features/steps/${name}/${name}Controller.show.steps.js`, | ||
`features/steps/${name}/${name}Controller.create.steps.js`, | ||
`features/steps/${name}/${name}Controller.update.steps.js`, | ||
`features/steps/${name}/${name}Controller.delete.steps.js`, | ||
`features/steps/${name}/${name}Controller.list.steps.js` | ||
]); | ||
}); | ||
|
||
it("creates feature files", () => { | ||
assert.file([ | ||
`features/${name}/${name}Controller.show.feature`, | ||
`features/${name}/${name}Controller.create.feature`, | ||
`features/${name}/${name}Controller.update.feature`, | ||
`features/${name}/${name}Controller.delete.feature`, | ||
`features/${name}/${name}Controller.list.feature` | ||
]); | ||
}); | ||
}); |
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 @@ | ||
module.exports = require("../../es5/lib/features.index.js"); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.