11#!/usr/bin/env zx
22
3+ const args = process . argv . slice ( 2 )
4+
35await $ `npm run lint`
46await $ `npm run check`
5- await $ `npm run build`
67await $ `npx svelte-package`
78const out = await $ `npx vite build -c vite.dist.config.js`
9+ await fs . copy ( 'dist/dist/index.umd.js' , 'dist/dist/index.umd.cjs' )
10+
11+ // Prepare `/dist`
12+ const pkg = await fs . readJson ( 'package.json' )
13+ pkg . scripts = undefined
14+ await fs . writeJson ( 'dist/package.json' , pkg , { spaces : 2 } )
15+ await fs . copy ( 'README.md' , 'dist/README.md' )
16+ await fs . copy ( 'LICENSE' , 'dist/LICENSE' )
17+ await $ `cd dist && npx publint`
18+
19+ if ( args . includes ( '--packageOnly' ) ) process . exit ( )
20+
21+ await $ `npm run build`
822
923// Calculate stats
1024const sizes = out . stdout
1125 . split ( '\n' )
12- . find ( ( i ) => i . includes ( 'index.umd.cjs ' ) )
26+ . find ( ( i ) => i . includes ( 'index.umd.js ' ) )
1327 . split ( ' ' )
1428 . filter ( ( i ) => ! isNaN ( parseFloat ( i ) ) )
1529const cloc = JSON . parse ( await $ `npx cloc src/lib --json` ) . SUM . code . toString ( )
@@ -20,15 +34,9 @@ await fs.writeJson('build/_min.json', { ...shields, label: 'minified', message:
2034await fs . writeJson ( 'build/_gzip.json' , { ...shields , label : 'gzipped' , message : `${ sizes [ 1 ] } kB` } )
2135await fs . writeJson ( 'build/_loc.json' , { ...shields , label : 'lines of code' , message : cloc } )
2236
23- // Prepare `/dist`
24- const pkg = await fs . readJson ( 'package.json' )
25- pkg . scripts = undefined
26- await fs . writeJson ( 'dist/package.json' , pkg , { spaces : 2 } )
27- await fs . copy ( 'README.md' , 'dist/README.md' )
28- await fs . copy ( 'LICENSE' , 'dist/LICENSE' )
29- await $ `cd dist && npx publint`
30-
3137echo `
38+ Build complete!
39+
3240To deploy the demo, run:
3341$ npx gh-pages -d build -t -f
3442
0 commit comments