ci: scripts/create 添加 version 参数

This commit is contained in:
pengzhanbo 2022-05-04 15:03:07 +08:00
parent 118b05add1
commit e57f70a75b

View File

@ -1,6 +1,7 @@
import { readTemplateList } from './readTpl' import { readTemplateList } from './readTpl'
import path from 'path' import path from 'path'
import fs from 'fs'
import { upperCase, lowerCase, packageName } from './utils' import { upperCase, lowerCase, packageName } from './utils'
import { compile } from 'handlebars' import { compile } from 'handlebars'
import type { ConfigOptions } from './getConfig' import type { ConfigOptions } from './getConfig'
@ -12,6 +13,8 @@ import execa from 'execa'
const packagesRoot = path.join(__dirname, '../../packages') const packagesRoot = path.join(__dirname, '../../packages')
const spinner = ora() const spinner = ora()
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf-8'))
const generatorFile = async (config: ConfigOptions): Promise<void> => { const generatorFile = async (config: ConfigOptions): Promise<void> => {
const templateList = readTemplateList(path.join(__dirname, './template')) const templateList = readTemplateList(path.join(__dirname, './template'))
@ -24,6 +27,7 @@ const generatorFile = async (config: ConfigOptions): Promise<void> => {
lowerName: lowerCase(name), lowerName: lowerCase(name),
client, client,
shared, shared,
version: pkg.version,
} }
const include = [!client && 'client', !shared && 'shared'].filter(Boolean).join('|') const include = [!client && 'client', !shared && 'shared'].filter(Boolean).join('|')
const filterRE = new RegExp(`/(${include})/`) const filterRE = new RegExp(`/(${include})/`)