/
githubmirror
/
taro
Обзор
Документация
Войти
/
githubmirror
/
taro
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/taro-cli/src/create/plugin.ts
55 строк
1 KB
liuzejia
lint: 修改node模块的引入
24 июн 2024, 16:25
24 июн 2024, 16:25
1965b18
Код
Авторство
О чём код?
import * as path from 'node:path' import { createPlugin } from '@tarojs/binding' import { chalk, fs } from '@tarojs/helper' import { getRootPath } from '../util' import Creator from './creator' export interface IPluginConf { pluginName: string type: string description?: string projectDir: string projectName: string template: string version:string } export default class Plugin extends Creator { public conf: IPluginConf constructor (options: IPluginConf) { super() this.conf = { ...options, projectName: path.basename(options.projectDir), version: this.getCliVersion() } } getCliVersion () { const pkgPath = path.join(this._rootPath, 'package.json') const pkg = fs.readJSONSync(pkgPath) return pkg.version } async create () { const { projectDir, template, pluginName } = this.conf const templatePath = this.templatePath(template) if (!fs.existsSync(templatePath)) { console.log(chalk.red(`创建插件失败:找不到模板${templatePath}`)) return } createPlugin({ projectRoot: projectDir, projectName: pluginName, templateRoot: getRootPath(), template, version: this.conf.version, description: this.conf.description, pluginType: this.conf.type, }) } }