Skip to content

Commit

Permalink
[fix] 1.add appName foler;2.fix bug with fs.copy
Browse files Browse the repository at this point in the history
  • Loading branch information
xingtao committed Jan 6, 2020
1 parent 7e0b163 commit ed93149
Show file tree
Hide file tree
Showing 9 changed files with 13,599 additions and 7,721 deletions.
3 changes: 3 additions & 0 deletions NOTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
使用Yeomon 构造react+webpack cli工具

## 功能日志
* 2019-01-06
* 修复写入路径,现项目默认生成在appName 文件夹下;
* 修复文件copy报错,npm push .gitignore文件被忽略;
* 2019-12-10prompts 使用区分common_prompts,react_prompts,vue_prompts;
* 2019-12-11 增加配置忽略文件 _*.* 默认为忽略文件,如_package.json
* 模板文件tpl 默认使用copyTpl遍历替换;
Expand Down
33 changes: 16 additions & 17 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,33 @@ module.exports = class extends Generator {

/**
* 写入模板文件 vue/react
* @param template
* @param template > template name
* @returns {boolean}
* @param root > project name
*/
writing_flow(template) {
writing_flow(root, template) {
console.log("writing now !!!");
if (!template) {
return false;
}

this.fs.copy(
this.templatePath(`${template}/`),
this.destinationPath("./"),
this.destinationPath(`./${root}`),
template_config.options.bind(this)(template)
);
this.writing_plugin(template);
this.writing_plugin(root, template);
this.fs.copy(
this.templatePath(`${template}/.babelrc`),
this.destinationPath(".babelrc")
this.destinationPath(`${root}/.babelrc`)
);
this.fs.copy(
this.templatePath(`${template}/.gitignore`),
this.destinationPath(".gitignore")
this.templatePath(`${template}/_.gitignore`),
this.destinationPath(`${root}/.gitignore`)
);
this.fs.copyTpl(
this.templatePath(`${template}/_package.json`), // 第一个参数:from
this.destinationPath("package.json"), // 第二个参数:to
this.destinationPath(`${root}/package.json`), // 第二个参数:to
{
props: this.props
}
Expand All @@ -66,9 +67,11 @@ module.exports = class extends Generator {

/**
* 写入template 插件
* @param template
* @param template > template name
* @param root > project name
* @return {boolean}
*/
writing_plugin(template) {
writing_plugin(root, template) {
if (!template) {
return false;
}
Expand All @@ -77,14 +80,14 @@ module.exports = class extends Generator {
if (this.props.pluginSelect.includes("redux")) {
this.fs.copy(
this.templatePath(`${template}/src/redux`),
this.destinationPath("./src/redux")
this.destinationPath(`${root}/src/redux`)
);
}
} else if (this.props.mvvmFrame.key === "vue") {
if (this.props.pluginSelect.includes("vuex")) {
this.fs.copy(
this.templatePath(`${template}/src/vuex/`),
this.destinationPath("./src/vuex/")
this.destinationPath(`${root}/src/vuex/`)
);
}
}
Expand All @@ -94,17 +97,13 @@ module.exports = class extends Generator {

writing() {
if (this.props.mvvmFrame) {
this.writing_flow(this.props.mvvmFrame.key);
this.writing_flow(this.props.appName, this.props.mvvmFrame.key);
}
/* // 动态写入dep
const pkgJson = {
dependencies: {
vue: '^2.0.0'
}
};
this.fs.extendJSON(this.destinationPath('projects/vue/package.json'), pkgJson); */
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.export = merge(base, {
module.exports = merge(base, {
plugins:[
// new CleanWebpackPlugin(),
// new ManifestPlugin({
Expand Down
Loading

0 comments on commit ed93149

Please sign in to comment.