1
1
#!/usr/bin/env zx
2
2
3
+ const args = process . argv . slice ( 2 )
4
+
3
5
await $ `npm run lint`
4
6
await $ `npm run check`
5
- await $ `npm run build`
6
7
await $ `npx svelte-package`
7
8
const 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`
8
22
9
23
// Calculate stats
10
24
const sizes = out . stdout
11
25
. split ( '\n' )
12
- . find ( ( i ) => i . includes ( 'index.umd.cjs ' ) )
26
+ . find ( ( i ) => i . includes ( 'index.umd.js ' ) )
13
27
. split ( ' ' )
14
28
. filter ( ( i ) => ! isNaN ( parseFloat ( i ) ) )
15
29
const 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:
20
34
await fs . writeJson ( 'build/_gzip.json' , { ...shields , label : 'gzipped' , message : `${ sizes [ 1 ] } kB` } )
21
35
await fs . writeJson ( 'build/_loc.json' , { ...shields , label : 'lines of code' , message : cloc } )
22
36
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
-
31
37
echo `
38
+ Build complete!
39
+
32
40
To deploy the demo, run:
33
41
$ npx gh-pages -d build -t -f
34
42
0 commit comments