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