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/init command add source root #15991

Merged
merged 8 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 增加create page clone 参数
  • Loading branch information
weiyanhai committed Jun 27, 2024
commit e59ee64a4e8ec12aaf3500dcb8b6888911d44030
8 changes: 5 additions & 3 deletions packages/taro-cli/src/create/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
projectName: string
npm: NpmType
template: string
templateSource?: string,
clone?: boolean
templateSource?: string
description?: string
pageName: string
date?: string
Expand All @@ -32,7 +33,8 @@
typescript?: boolean
compiler?: CompilerType
template?: string
templateSource?: string
templateSource?: string,

Check warning on line 36 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (macos-11)

Unexpected separator (,)

Check warning on line 36 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (windows-latest)

Unexpected separator (,)

Check warning on line 36 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (ubuntu-latest)

Unexpected separator (,)

Check warning on line 36 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (ubuntu-latest)

Unexpected separator (,)
clone?: boolean
}

type TCustomTemplateInfo = Omit<ITemplateInfo & {
Expand Down Expand Up @@ -126,15 +128,15 @@
templateSource = config && config.templateSource ? config.templateSource : DEFAULT_TEMPLATE_SRC
} else {
await fs.createFile(taroConfig)
await fs.writeJSON(taroConfig, {

Check failure on line 131 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (macos-11)

Trailing spaces not allowed

Check failure on line 131 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (windows-latest)

Trailing spaces not allowed

Check failure on line 131 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (ubuntu-latest)

Trailing spaces not allowed

Check failure on line 131 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (ubuntu-latest)

Trailing spaces not allowed
templateSource: this.conf.templateSource || DEFAULT_TEMPLATE_SRC

Check failure on line 132 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (macos-11)

Trailing spaces not allowed

Check failure on line 132 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (windows-latest)

Trailing spaces not allowed

Check failure on line 132 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (ubuntu-latest)

Trailing spaces not allowed

Check failure on line 132 in packages/taro-cli/src/create/page.ts

View workflow job for this annotation

GitHub Actions / Testing on Node.js 16.x (ubuntu-latest)

Trailing spaces not allowed
})

templateSource = this.conf.templateSource || DEFAULT_TEMPLATE_SRC
}

// 从模板源下载模板
await fetchTemplate(templateSource, this.templatePath(''))
await fetchTemplate(templateSource, this.templatePath(''), this.conf.clone)
}

async create () {
Expand Down
4 changes: 4 additions & 0 deletions packages/taro-cli/src/presets/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export default (ctx: IPluginContext) => {
const type = options.type || createTemplateTypeEnum.PAGE
const name = _[1] || options.name
const description = options.description || ''
const templateSource = options.templateSource
const clone = options.clone
const { chalk } = ctx.helper
const { appPath } = ctx.paths

Expand All @@ -50,9 +52,11 @@ export default (ctx: IPluginContext) => {

const Page = require('../../create/page').default
const page = new Page({
clone,
pageName: name,
projectDir: appPath,
description,
templateSource,
async modifyCustomTemplateConfig (cb: TSetCustomTemplateConfig) {
await ctx.applyPlugins({ name: hooks.MODIFY_CREATE_TEMPLATE, opts: cb })
}
Expand Down
Loading
Loading