@@ -32,7 +32,7 @@ const pRm = promisify(fs.rm);
3232
3333const execSync = ( cmd : string ) => {
3434 return new Promise ( ( resolve , reject ) => {
35- exec ( cmd , ( res , stdout ) => {
35+ exec ( cmd , ( res , stdout ) => {
3636 if ( res ) {
3737 console . error ( res ) ;
3838 reject ( false ) ;
@@ -43,30 +43,12 @@ const execSync = (cmd: string) => {
4343 } ) ;
4444} ;
4545
46- // tsc shuimo-ui.mjs --target esnext --declaration --emitDeclarationOnly --allowJs --skipLibCheck --declarationMap --exactOptionalPropertyTypes
4746
48- const tscDeclaration = ( path : string , fileName : string ) => {
49-
50- const filePath = `./config/output/dist/${ path } /${ fileName } ` ;
51- const outPath = `./config/output/dist/${ path } ` ;
52-
53- const args = [
54- `../../node_modules/.bin/vue-tsc ${ filePath } ` ,
55- `--outDir ${ outPath } ` ,
56- '--target esnext' ,
57- '--declaration' ,
58- '--emitDeclarationOnly' ,
59- '--allowJs' ,
60- '--skipLibCheck' ,
61- '--declarationMap' ,
62- ] ;
63-
64- return execSync ( args . join ( ' ' ) ) ;
65- } ;
6647const init = ( lib : 'vue' | 'react' | 'lit' ) => {
6748 const cp = async ( name : string , path : string = '' , type : 'file' | 'document' = 'document' ) => {
6849 return pCp ( `../../${ path } ${ name } ` , `./config/output/${ name } ` , type === 'document' ? { recursive : true } : undefined ) ;
6950 } ;
51+
7052 const rm = ( path : string , options ?: RmOptions ) => {
7153 return pRm ( path , options ?? { recursive : true , force : true } ) ;
7254 } ;
@@ -88,13 +70,21 @@ const init = (lib: 'vue' | 'react' | 'lit') => {
8870 } ;
8971
9072
91- return { cp, cpLib, rename, rmLib } ;
73+ const renameTypes = async ( ) => {
74+ await Promise . all ( [
75+ pCp ( `./config/output/types/shuimo-ui.d.ts` , `./config/output/types/shuimo-ui.d.mts` ) ,
76+ pCp ( `./config/output/types/shuimo-ui.d.ts` , `./config/output/types/shuimo-ui.d.cts` ) ,
77+ ] ) ;
78+ return rm ( `./config/output/types/shuimo-ui.d.ts` ) ;
79+ } ;
80+
81+ return { cp, cpLib, rename, rmLib, renameTypes } ;
9282
9383} ;
9484
9585const run = async ( ) => {
9686
97- const { cp, rename, cpLib, rmLib } = init ( 'vue' ) ;
87+ const { cp, rename, cpLib, rmLib, renameTypes } = init ( 'vue' ) ;
9888
9989 const removeRes = await rmLib ( 'dist' ) ;
10090 const buildRes = await execSync ( 'vite build -c ./config/vue.config.ts' ) ;
@@ -114,17 +104,10 @@ const run = async () => {
114104 cpLib ( 'types' ) ,
115105 cpLib ( 'dist' ) ,
116106 cpLib ( 'index.ts' ) ,
117- cpLib ( 'package.json' , '' , 'file' )
107+ cpLib ( 'package.json' , '' , 'file' ) ,
118108 ] ) ;
119109
120- if ( res . every ( r => r ) ) {
121- console . log ( 'build success, now build ts declaration file' ) ;
122- Promise . all ( [
123- // tscDeclaration('es', 'shuimo-ui.mjs'),
124- tscDeclaration ( 'cjs' , 'shuimo-ui.cjs' ) ,
125- tscDeclaration ( 'umd' , 'shuimo-ui.umd.js' )
126- ] ) ;
127- }
110+ await renameTypes ( )
128111
129112
130113 // todo remove "@shuimo-design/types": "workspace:*"
0 commit comments