Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 支持选择模板 #119

Open
2nthony opened this issue Jul 31, 2020 · 3 comments
Open

feat: 支持选择模板 #119

2nthony opened this issue Jul 31, 2020 · 3 comments

Comments

@2nthony
Copy link
Member

2nthony commented Jul 31, 2020

提供初始化项目类型(支持多模板

使用 cli 生成文件时,我想通过选择我要生成的项目是什么类型,vue组件 或者 工具型 的开源项目

以致于生成后的整套文件完整的,只需要关注我要开发的文件 src 即可;不再需要修改文件以免受失误而造成的工程出错。

PS: vue组件 和 工具型 应该成为模板,以方便的扩展(或许可以优化为 本地或者在线模板。

@2nthony
Copy link
Member Author

2nthony commented Aug 3, 2020

理想的过程

vue-sfc-cli init

# 1
# Q
choose a type of the project
# A
🔘 vue 组件
🔘 插件

# 2
the project name

# 3
the owner

@2nthony
Copy link
Member Author

2nthony commented Aug 3, 2020

关于扩展

基本文件

// /commons 必要的文件,如CI和脚本

扩展/定制模板(vue 组件例子

// vue
// /templates/vue-component/index.js
exports.name = 'vue 组件' // 模板名称
exports.apply = api => {
  // 做任何事情
  api.on('packageJson', json => json.dependencies.vue = 'v2.6.10')
  // 必要的文件不会因此而过滤
  api.on('files', files => {
    const newFiles = [...files, 'src/index.js', 'src/component.vue']
    return newFiles
  })
}

@2nthony
Copy link
Member Author

2nthony commented Aug 3, 2020

使用到

inquirer,命令行提问

@2nthony 2nthony changed the title feat: 令人舒适的一步到位配套设施 feat: 支持选择模板 Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant