@@ -24,10 +24,33 @@ function getPath(rootPath, result = []) {
2424 return result ;
2525}
2626
27+ const tsc = {
28+ compilerOptions : {
29+ // allowJs: true,
30+ allowSyntheticDefaultImports : true ,
31+ esModuleInterop : true ,
32+ outDir : 'lib' ,
33+ // isolatedModules: true,
34+ declaration : true ,
35+ jsx : 'react' ,
36+ lib : [ 'es6' ] ,
37+ resolveJsonModule : true ,
38+ moduleResolution : 'node' ,
39+ strict : true ,
40+ target : 'esnext' ,
41+ baseUrl : '.' ,
42+ } ,
43+ exclude : [ 'node_modules' ] ,
44+ include : [ 'src/**/*' ] ,
45+ } ;
46+
2747( async ( ) => {
2848 const root = path . join ( process . cwd ( ) , 'src' ) ;
2949 const output = path . join ( process . cwd ( ) , 'lib' ) ;
30- await fs . emptyDir ( root ) ;
50+ const tscPath = path . join ( process . cwd ( ) , 'tsconfig.json' ) ;
51+ await fs . remove ( output ) ;
52+ await fs . writeJSON ( tscPath , tsc ) ;
53+ await fs . remove ( root ) ;
3154 await fs . copy ( path . join ( process . cwd ( ) , '../../components' ) , root ) ;
3255 const files = await getPath ( root ) ;
3356 files . forEach ( itemPath => {
@@ -36,12 +59,21 @@ function getPath(rootPath, result = []) {
3659 const outputFile = itemPath . replace ( root , output ) ;
3760 fs . outputFileSync ( outputFile . replace ( / .( t s x | t s ) $ / , '.js' ) , code ) ;
3861 // eslint-disable-next-line prettier/prettier
39- console . log ( `♻️: ${ itemPath . replace ( process . cwd ( ) , '' ) . replace ( / ^ \/ / , '' ) } -> ${ outputFile . replace ( process . cwd ( ) , '' ) . replace ( / ^ \/ / , '' ) } ` ) ;
62+ console . log ( `♻️: ${ itemPath . replace ( process . cwd ( ) , '' ) . replace ( / ^ \/ / , '' ) } -> ${ outputFile . replace ( process . cwd ( ) , '' ) . replace ( / ^ \/ / , '' ) . replace ( / \. t s x $ / , '.js' ) } ` ) ;
63+ }
64+ if ( / .( m d ) $ / . test ( itemPath ) ) {
65+ const outputMd = itemPath . replace ( root , output ) ;
66+ fs . ensureFileSync ( outputMd ) ;
67+ fs . copyFileSync ( itemPath , outputMd ) ;
68+ // eslint-disable-next-line prettier/prettier
69+ console . log ( `📋: ${ itemPath . replace ( process . cwd ( ) , '' ) . replace ( / ^ \/ / , '' ) } -> ${ outputMd . replace ( process . cwd ( ) , '' ) . replace ( / ^ \/ / , '' ) } ` ) ;
4070 }
4171 } ) ;
72+ await execute ( 'npm run type' ) ;
4273 await execute ( 'npm publish' ) ;
4374 await fs . remove ( root ) ;
4475 await fs . remove ( output ) ;
76+ await fs . remove ( tscPath ) ;
4577 await fs . remove ( path . join ( process . cwd ( ) , 'package-lock.json' ) ) ;
4678 await fs . remove ( path . join ( process . cwd ( ) , 'node_modules' ) ) ;
4779} ) ( ) ;
0 commit comments