Skip to content

Commit

Permalink
fix: 深度可选config
Browse files Browse the repository at this point in the history
  • Loading branch information
xuasir committed Mar 5, 2021
1 parent bd1723d commit cc01c41
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
14 changes: 10 additions & 4 deletions packages/cli/src/exports/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import type { IPluginAPI } from './pluginAPI'

export interface IConfig extends IProjectConfig {
libBuild: ILibBuildConfig
lint: Partial<ILintConfig>
changelog: Partial<IChangelogConfig>
release: Partial<IReleaseConfig>
lint: ILintConfig
changelog: IChangelogConfig
release: IReleaseConfig
}

type IDeepPartial<T> = {
[K in keyof T]?:
| (T[K] extends Record<string, any> ? IDeepPartial<T[K]> : T[K])
| undefined
}

export type IPlugin = IPluginBase<(api: IPluginAPI) => void>
Expand All @@ -23,4 +29,4 @@ export interface IPreset {
export const createPlugin = (plugin: IPlugin) => plugin
export const createPreset = (preset: IPreset) => preset

export const defineConfig = (config: Partial<IConfig>) => config
export const defineConfig = (config: IDeepPartial<IConfig>) => config
6 changes: 4 additions & 2 deletions packages/plugin-build-lib/src/plugin/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export const libBuildSchema = createSchema<ILibBuildConfig>((joi) =>
targets: joi.array(),
pointPkgs: joi.array(),
pkgOrder: joi.array(),
rollupChain: joi.function()
rollupChain: joi.function(),
rollTypes: joi.boolean()
})
)

export const defaultLibBuildConfig: () => ILibBuildConfig = () => {
return {
targets: []
targets: [],
rollTypes: false
}
}
1 change: 1 addition & 0 deletions packages/plugin-build-lib/src/plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@ export interface ILibBuildConfig {
* shared should be roll before core
*/
pkgOrder?: string[]
rollTypes?: boolean
}
2 changes: 1 addition & 1 deletion packages/plugin-cmd-lib/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default createPlugin({
DefaultTargets.includes(target)
) as ILibBuildTargets[]
}
if (args?.rollTypes) {
if (args?.rollTypes || config?.rollTypes) {
targets.push('rollTypes')
}

Expand Down

0 comments on commit cc01c41

Please sign in to comment.