|
1 | 1 | import type { ChangelogCliOptions, ChangelogGenerateOptions } from './changelog.interface'
|
2 |
| -import { VipGit, VipLodash } from '@142vip/utils' |
| 2 | +import { VipConfig, VipGit } from '@142vip/utils' |
3 | 3 |
|
4 | 4 | /**
|
5 | 5 | * 默认配置
|
@@ -34,17 +34,25 @@ export const ChangelogDefaultConfig = {
|
34 | 34 | * 将用户自定义配置和默认配置合并
|
35 | 35 | */
|
36 | 36 | export async function mergeConfig(cliOptions: ChangelogCliOptions): Promise<ChangelogGenerateOptions> {
|
37 |
| - const { loadConfig } = await import('c12') |
| 37 | + // const { loadConfig } = await import('c12') |
38 | 38 |
|
39 | 39 | // 本地配置,形如:changelog.config.ts
|
40 |
| - const changelogConfig = await loadConfig<ChangelogGenerateOptions>({ |
41 |
| - // 配置文件名,eg: changelog.config.ts |
42 |
| - name: 'changelog', |
| 40 | + // const changelogConfig = await loadConfig<ChangelogGenerateOptions>({ |
| 41 | + // // 配置文件名,eg: changelog.config.ts |
| 42 | + // name: 'changelog', |
| 43 | + // packageJson: true, |
| 44 | + // }).then(c => VipLodash.merge({}, ChangelogDefaultConfig, c.config)) |
| 45 | + |
| 46 | + // cli配置合并 |
| 47 | + // const config = VipLodash.merge({}, changelogConfig, cliOptions) as ChangelogGenerateOptions |
| 48 | + |
| 49 | + // 新写法 |
| 50 | + const changelogConfig = await VipConfig.loadCliConfig<ChangelogGenerateOptions>('changelog', ChangelogDefaultConfig, { |
43 | 51 | packageJson: true,
|
44 |
| - }).then(c => VipLodash.merge({}, ChangelogDefaultConfig, c.config)) |
| 52 | + }) |
45 | 53 |
|
46 | 54 | // cli配置合并
|
47 |
| - const config = VipLodash.merge({}, changelogConfig, cliOptions) as ChangelogGenerateOptions |
| 55 | + const config = VipConfig.mergeCommanderConfig<ChangelogGenerateOptions>(changelogConfig, cliOptions) |
48 | 56 |
|
49 | 57 | // 发布的版本
|
50 | 58 | if (config.to == null) {
|
|
0 commit comments