Skip to content

Commit 600af0f

Browse files
ZEJIA-LIUZakaryCodeliuzejia
authored
feat(cli): 支持 create 传递framework,css和typescript并且调整 templateSource 的优先级 (#16157)
* fix: 修复 readConfig 时引入 babel 导致问题 # Conflicts: # packages/taro-helper/src/utils.ts * feat: vite 小程序端的 chunks 拆分 * fix(harmony): 修复读取配置时缺少常量注入 * fix: 修复读取配置时缺少常量的注入 * chore(release): publish 4.0.3-alpha.0 --tag=alpha * feat: 修复vite的分chunk * chore(release): publish 4.0.3-alpha.1 --tag=alpha * fix: 修改readConfig方法 * chore(release): publish 4.0.3-alpah.2 --tag=alpha * chore(release): publish 4.0.3-alpha.3 --tag=alpha * feat: 修改mini chunks * chore(release): publish 4.0.3-alpha.4 --tag=alpha * feat: 支持 create 传递framework,css和typescript并且调整 templateSource 的优先级 * fix(lint): lint --------- Co-authored-by: ZakaryCode <[email protected]> Co-authored-by: liuzejia <[email protected]>
1 parent 4558798 commit 600af0f

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

packages/taro-cli/src/create/page.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,19 @@ export default class Page extends Creator {
162162
let templateSource = DEFAULT_TEMPLATE_SRC
163163
if (!homedir) chalk.yellow('找不到用户根目录,使用默认模版源!')
164164

165-
const taroConfigPath = path.join(homedir, TARO_CONFIG_FOLDER)
166-
const taroConfig = path.join(taroConfigPath, TARO_BASE_CONFIG)
167-
168-
if (fs.existsSync(taroConfig)) {
169-
const config = await fs.readJSON(taroConfig)
170-
templateSource = config && config.templateSource ? config.templateSource : DEFAULT_TEMPLATE_SRC
165+
if (this.conf.templateSource) {
166+
templateSource = this.conf.templateSource
171167
} else {
172-
templateSource = this.conf.templateSource || DEFAULT_TEMPLATE_SRC
173-
174-
await fs.createFile(taroConfig)
175-
await fs.writeJSON(taroConfig, { templateSource })
168+
const taroConfigPath = path.join(homedir, TARO_CONFIG_FOLDER)
169+
const taroConfig = path.join(taroConfigPath, TARO_BASE_CONFIG)
170+
if (fs.existsSync(taroConfig)) {
171+
const config = await fs.readJSON(taroConfig)
172+
templateSource = config && config.templateSource ? config.templateSource : DEFAULT_TEMPLATE_SRC
173+
} else {
174+
await fs.createFile(taroConfig)
175+
await fs.writeJSON(taroConfig, { templateSource })
176+
templateSource = DEFAULT_TEMPLATE_SRC
177+
}
176178
}
177179

178180
// 从模板源下载模板

packages/taro-cli/src/presets/commands/create.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export default (ctx: IPluginContext) => {
4343
const description = options.description || ''
4444
const afterCreate = options.afterCreate
4545
const templateSource = options.templateSource
46+
const framework = options.framework
47+
const css = options.css
48+
const typescript = options.typescript
4649
const clone = options.clone
4750
const { chalk } = ctx.helper
4851
const { appPath } = ctx.paths
@@ -57,6 +60,9 @@ export default (ctx: IPluginContext) => {
5760
const page = new Page({
5861
clone,
5962
subPkg: options.subpkg,
63+
framework,
64+
css,
65+
typescript,
6066
pageDir: options.dir,
6167
pageName: name,
6268
projectDir: appPath,

0 commit comments

Comments
 (0)