@@ -5,6 +5,9 @@ console.warn(
5
5
'Currently there are two tag-names missing or faulty: "ui5-notification-overflow-action" and "ui5-timeline-item"\n These have to be adjusted manually!\n'
6
6
) ;
7
7
8
+ // To only create a single component, add the component (module) name here:
9
+ CREATE_SINGLE_COMPONENT = false ;
10
+
8
11
const mainWebComponentsSpec = require ( '@ui5/webcomponents/dist/api.json' ) ;
9
12
const fioriWebComponentsSpec = require ( '@ui5/webcomponents-fiori/dist/api.json' ) ;
10
13
const dedent = require ( 'dedent' ) ;
@@ -732,59 +735,61 @@ resolvedWebComponents.forEach((componentSpec) => {
732
735
} ;
733
736
734
737
const [ mainDescription , description = '' ] = formatDescription ( ) ;
738
+ if ( CREATE_SINGLE_COMPONENT === componentSpec . module || ! CREATE_SINGLE_COMPONENT ) {
739
+ const webComponentWrapper = createWebComponentWrapper (
740
+ componentSpec . module ,
741
+ componentSpec . tagname ,
742
+ mainDescription ,
743
+ propTypes ,
744
+ uniqueAdditionalImports ,
745
+ defaultProps ,
746
+ ( componentSpec . properties || [ ] )
747
+ . filter ( filterNonPublicAttributes )
748
+ . filter ( ( { type } ) => type !== 'boolean' && type !== 'Boolean' )
749
+ . map ( ( { name } ) => name ) ,
750
+ ( componentSpec . properties || [ ] )
751
+ . filter ( filterNonPublicAttributes )
752
+ . filter ( ( { type } ) => type === 'boolean' || type === 'Boolean' )
753
+ . map ( ( { name } ) => name ) ,
754
+ ( componentSpec . slots || [ ] ) . filter ( filterNonPublicAttributes ) . map ( ( { name } ) => name ) ,
755
+ ( componentSpec . events || [ ] ) . filter ( filterNonPublicAttributes ) . map ( ( { name } ) => name )
756
+ ) ;
735
757
736
- const webComponentWrapper = createWebComponentWrapper (
737
- componentSpec . module ,
738
- componentSpec . tagname ,
739
- mainDescription ,
740
- propTypes ,
741
- uniqueAdditionalImports ,
742
- defaultProps ,
743
- ( componentSpec . properties || [ ] )
744
- . filter ( filterNonPublicAttributes )
745
- . filter ( ( { type } ) => type !== 'boolean' && type !== 'Boolean' )
746
- . map ( ( { name } ) => name ) ,
747
- ( componentSpec . properties || [ ] )
748
- . filter ( filterNonPublicAttributes )
749
- . filter ( ( { type } ) => type === 'boolean' || type === 'Boolean' )
750
- . map ( ( { name } ) => name ) ,
751
- ( componentSpec . slots || [ ] ) . filter ( filterNonPublicAttributes ) . map ( ( { name } ) => name ) ,
752
- ( componentSpec . events || [ ] ) . filter ( filterNonPublicAttributes ) . map ( ( { name } ) => name )
753
- ) ;
754
-
755
- // check if folder exists and create it if necessary
756
- const webComponentFolderPath = path . join ( WEB_COMPONENTS_ROOT_DIR , componentSpec . module ) ;
757
- if ( ! fs . existsSync ( webComponentFolderPath ) ) {
758
- fs . mkdirSync ( webComponentFolderPath ) ;
759
- }
758
+ // check if folder exists and create it if necessary
759
+ const webComponentFolderPath = path . join ( WEB_COMPONENTS_ROOT_DIR , componentSpec . module ) ;
760
+ if ( ! fs . existsSync ( webComponentFolderPath ) ) {
761
+ fs . mkdirSync ( webComponentFolderPath ) ;
762
+ }
760
763
761
- fs . writeFileSync ( path . join ( webComponentFolderPath , 'index.tsx' ) , webComponentWrapper ) ;
764
+ fs . writeFileSync ( path . join ( webComponentFolderPath , 'index.tsx' ) , webComponentWrapper ) ;
762
765
763
- // create lib export
764
- const libContent = prettier . format (
765
- `
766
+ // create lib export
767
+ const libContent = prettier . format (
768
+ `
766
769
import { ${ componentSpec . module } } from '../webComponents/${ componentSpec . module } ';
767
770
import type { ${ componentSpec . module } PropTypes } from '../webComponents/${ componentSpec . module } ';
768
771
769
772
export { ${ componentSpec . module } };
770
773
export type { ${ componentSpec . module } PropTypes };` ,
771
- prettierConfig
772
- ) ;
773
- fs . writeFileSync ( path . join ( LIB_DIR , `${ componentSpec . module } .ts` ) , libContent ) ;
774
+ prettierConfig
775
+ ) ;
776
+ fs . writeFileSync ( path . join ( LIB_DIR , `${ componentSpec . module } .ts` ) , libContent ) ;
774
777
775
- // create test
776
- if ( ! fs . existsSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .test.tsx` ) ) ) {
777
- const webComponentTest = createWebComponentTest ( componentSpec . module ) ;
778
- fs . writeFileSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .test.tsx` ) , webComponentTest ) ;
779
- }
778
+ // create test
779
+ if ( ! fs . existsSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .test.tsx` ) ) ) {
780
+ const webComponentTest = createWebComponentTest ( componentSpec . module ) ;
781
+ fs . writeFileSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .test.tsx` ) , webComponentTest ) ;
782
+ }
780
783
781
- // create demo
782
- if (
783
- ! fs . existsSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .stories.tsx` ) ) &&
784
- ! fs . existsSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .stories.mdx` ) ) &&
785
- ! COMPONENTS_WITHOUT_DEMOS . has ( componentSpec . module )
786
- ) {
787
- const webComponentDemo = createWebComponentDemo ( componentSpec , allComponentProperties , description ) ;
788
- fs . writeFileSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .stories.mdx` ) , webComponentDemo ) ;
784
+ // create demo
785
+ if (
786
+ CREATE_SINGLE_COMPONENT === componentSpec . module ||
787
+ ( ! fs . existsSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .stories.tsx` ) ) &&
788
+ ! fs . existsSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .stories.mdx` ) ) &&
789
+ ! COMPONENTS_WITHOUT_DEMOS . has ( componentSpec . module ) )
790
+ ) {
791
+ const webComponentDemo = createWebComponentDemo ( componentSpec , allComponentProperties , description ) ;
792
+ fs . writeFileSync ( path . join ( webComponentFolderPath , `${ componentSpec . module } .stories.mdx` ) , webComponentDemo ) ;
793
+ }
789
794
}
790
795
} ) ;
0 commit comments