File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
testing/test-nx-utils/src/lib/utils Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -65,16 +65,29 @@ export async function generateWorkspaceAndProject(
6565export function registerPluginInWorkspace (
6666 tree : Tree ,
6767 configuration : PluginConfiguration ,
68+ pluginConfig ?: Record < string , unknown > ,
6869) {
6970 const normalizedPluginConfiguration =
7071 typeof configuration === 'string'
7172 ? {
7273 plugin : configuration ,
7374 }
7475 : configuration ;
76+
77+ const pluginName =
78+ typeof configuration === 'string' ? configuration : configuration . plugin ;
79+
7580 updateJson ( tree , 'nx.json' , ( json : NxJsonConfiguration ) => ( {
7681 ...json ,
7782 plugins : [ ...( json . plugins ?? [ ] ) , normalizedPluginConfiguration ] ,
83+ ...( pluginConfig
84+ ? {
85+ pluginsConfig : {
86+ ...json . pluginsConfig ,
87+ [ pluginName ] : pluginConfig ,
88+ } ,
89+ }
90+ : { } ) ,
7891 } ) ) ;
7992}
8093
Original file line number Diff line number Diff line change @@ -91,4 +91,38 @@ describe('registerPluginInWorkspace', () => {
9191 } ) ,
9292 ) ;
9393 } ) ;
94+
95+ it ( 'should register pluginsConfig when provided' , ( ) => {
96+ const tree = createTreeWithEmptyWorkspace ( { layout : 'apps-libs' } ) ;
97+
98+ registerPluginInWorkspace (
99+ tree ,
100+ {
101+ plugin : '@code-pushup/nx-plugin' ,
102+ options : { targetName : 'code-pushup' } ,
103+ } ,
104+ {
105+ projectPrefix : 'cli' ,
106+ bin : 'packages/cli/src/index.ts' ,
107+ } ,
108+ ) ;
109+
110+ const nxJson = JSON . parse ( tree . read ( 'nx.json' ) ?. toString ( ) ?? '{}' ) ;
111+ expect ( nxJson ) . toStrictEqual (
112+ expect . objectContaining ( {
113+ plugins : [
114+ {
115+ plugin : '@code-pushup/nx-plugin' ,
116+ options : { targetName : 'code-pushup' } ,
117+ } ,
118+ ] ,
119+ pluginsConfig : {
120+ '@code-pushup/nx-plugin' : {
121+ projectPrefix : 'cli' ,
122+ bin : 'packages/cli/src/index.ts' ,
123+ } ,
124+ } ,
125+ } ) ,
126+ ) ;
127+ } ) ;
94128} ) ;
You can’t perform that action at this time.
0 commit comments