Skip to content

Commit

Permalink
use copy from fs with template paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ameyakoshti committed Aug 1, 2017
1 parent 6632e24 commit 70a6a41
Showing 1 changed file with 56 additions and 45 deletions.
101 changes: 56 additions & 45 deletions packages/generator-electrode/component/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"use strict";

var Generator = require("yeoman-generator");
var _ = require("lodash");
var chalk = require("chalk");
var Generator = require("yeoman-generator");
var path = require("path");
var extend = _.merge;
var parseAuthor = require("parse-author");
var optionOrPrompt = require("yeoman-option-or-prompt");
var nodeFS = require("fs");
var demoHelperPath = path.join(require.resolve("electrode-demo-helper"), "..");

module.exports = class extends Generator {
Expand Down Expand Up @@ -177,40 +176,52 @@ module.exports = class extends Generator {
lernaStructure: {
// Copy lerna and top level templates
if (!this.isAddon) {
this.copy("gitignore", ".gitignore");
this.template("_package.json", "package.json");
this.template("_readme.md", "README.md");
this.template("lerna.json", "lerna.json");
this.fs.copyTpl(this.templatePath("gitignore"), this.destinationPath(".gitignore"));
this.fs.copyTpl(
this.templatePath("_package.json"),
this.destinationPath("package.json"),
{
projectName: this.projectName,
developerName: this.developerName,
githubUrl: this.githubUrl,
ghUser: this.ghUser,
packageGitHubOrg: this.packageGitHubOrg,
ghRepo: this.ghRepo
}
);
this.fs.copyTpl(this.templatePath("_readme.md"), this.destinationPath("README.md"));
this.fs.copyTpl(this.templatePath("lerna.json"), this.destinationPath("lerna.json"));
}
}

project: {
this.copy("packages/component/babelrc", this.rootPath + ".babelrc");
this.copy("packages/component/gitignore", this.rootPath + ".gitignore");
this.copy("packages/component/npmignore", this.rootPath + ".npmignore");
this.copy("packages/component/editorconfig", this.rootPath + ".editorconfig");
this.fs.copy(this.templatePath("packages/component/babelrc"), this.destinationPath(".babelrc"));
this.fs.copy(this.templatePath("packages/component/gitignore"), this.destinationPath(".gitignore"));
this.fs.copy(this.templatePath("packages/component/npmignore"), this.destinationPath(".npmignore"));
this.fs.copy(this.templatePath("packages/component/editorconfig"), this.destinationPath(".editorconfig"));
this.fs.copy(this.templatePath("packages/component/_xclap.js"), this.destinationPath("xclap.js"));
this.fs.copy(this.templatePath("packages/component/_package.json"), this.destinationPath("package.json"));
this.fs.copy(this.templatePath("packages/component/_readme.md"), this.destinationPath("README.md"));

if (this.quoteType === "'") {
this.template("packages/component/eslintrc", this.rootPath + ".eslintrc");
this.fs.copy(this.templatePath("packages/component/eslintrc"), this.destinationPath(".eslintrc"));
}
this.template("packages/component/_xclap.js", this.rootPath + "xclap.js");
this.template("packages/component/_package.json", this.rootPath + "package.json");
this.template("packages/component/_readme.md", this.rootPath + "README.md");
}

component: {
this.template(
"packages/component/src/components/_component.jsx",
this.rootPath + "src/components/" + this.projectName + ".jsx"
this.fs.copyTpl(
this.templatePath("packages/component/src/components/_component.jsx"),
this.destinationPath(this.rootPath + "src/components/" + this.projectName + ".jsx")
);

this.template(
"packages/component/src/styles/_component.css",
this.rootPath + "src/styles/" + this.projectName + ".css"
this.fs.copyTpl(
this.templatePath("packages/component/src/styles/_component.css"),
this.destinationPath(this.rootPath + "src/styles/" + this.projectName + ".css")
);

this.template(
"packages/component/demo/examples/_component.example",
this.rootPath + "demo/examples/" + this.projectName + ".example"
this.fs.copyTpl(
this.templatePath("packages/component/demo/examples/_component.example"),
this.destinationPath(this.rootPath + "demo/examples/" + this.projectName + ".example")
);

this.fs.copyTpl(
Expand All @@ -225,41 +236,41 @@ module.exports = class extends Generator {
{packageName: this.projectName}
);

this.template(
"packages/component/src/lang/_DefaultMessages.js",
this.rootPath + "src/lang/default-messages.js"
this.fs.copyTpl(
this.templatePath("packages/component/src/lang/_DefaultMessages.js"),
this.destinationPath(this.rootPath + "src/lang/default-messages.js")
);
this.template(
"packages/component/src/lang/_en.json",
this.rootPath + "src/lang/en.json"

this.fs.copyTpl(
this.templatePath("packages/component/src/lang/_en.json"),
this.destinationPath(this.rootPath + "src/lang/en.json")
);

this.template(
"packages/component/src/lang/tenants/electrodeio/_defaultMessages.js",
this.rootPath + "src/lang/tenants/electrodeio/default-messages.js"
this.fs.copyTpl(
this.templatePath("packages/component/src/lang/tenants/electrodeio/_defaultMessages.js"),
this.destinationPath(this.rootPath + "src/lang/tenants/electrodeio/default-messages.js")
);

this.template(
"packages/component/src/_Component.js",
this.rootPath + "src/index.js"
this.fs.copyTpl(
this.templatePath("packages/component/src/_Component.js"),
this.destinationPath(this.rootPath + "src/index.js")
);
}

test: {
this.template(
"packages/component/test/client/eslintrc",
this.rootPath + "test/client/.eslintrc"
this.fs.copy(
this.templatePath("packages/component/test/client/eslintrc"),
this.destinationPath(this.rootPath + "test/client/.eslintrc")
);

this.template(
"packages/component/test/client/components/_component.spec.jsx",
this.rootPath + "test/client/components/" + this.projectName + ".spec.jsx"
this.fs.copyTpl(
this.templatePath("packages/component/test/client/components/_component.spec.jsx"),
this.destinationPath(this.rootPath + "test/client/components/" + this.projectName + ".spec.jsx")
);

this.copy(
"packages/component/test/client/components/helpers/_intlEnzymeTestHelper.js",
this.rootPath + "test/client/components/helpers/intl-enzyme-test-helper.js"
this.fs.copyTpl(
this.templatePath("packages/component/test/client/components/helpers/_intlEnzymeTestHelper.js"),
this.destinationPath(this.rootPath + "test/client/components/helpers/intl-enzyme-test-helper.js")
);
}

Expand Down

0 comments on commit 70a6a41

Please sign in to comment.