|
| 1 | +#!/usr/bin/env zx |
| 2 | + |
| 3 | +await $`npm run lint` |
| 4 | +await $`npm run check` |
| 5 | +await $`npm run build` |
| 6 | +await $`npx svelte-package` |
| 7 | +const out = await $`npx vite build -c vite.dist.config.js` |
| 8 | + |
| 9 | +// Calculate stats |
| 10 | +const sizes = out.stdout |
| 11 | + .split('\n') |
| 12 | + .find((i) => i.includes('index.umd.cjs')) |
| 13 | + .split(' ') |
| 14 | + .filter((i) => !isNaN(parseFloat(i))) |
| 15 | +const cloc = JSON.parse(await $`npx cloc src/lib --json`).SUM.code.toString() |
| 16 | + |
| 17 | +// Write stats into `/build` |
| 18 | +const shields = { schemaVersion: 1, color: 'blue' } |
| 19 | +await fs.writeJson('build/_min.json', { ...shields, label: 'minified', message: `${sizes[0]} kB` }) |
| 20 | +await fs.writeJson('build/_gzip.json', { ...shields, label: 'gzipped', message: `${sizes[1]} kB` }) |
| 21 | +await fs.writeJson('build/_loc.json', { ...shields, label: 'lines of code', message: cloc }) |
| 22 | + |
| 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 | +echo` |
| 32 | +To deploy the demo, run: |
| 33 | +$ npx gh-pages -d build -t -f |
| 34 | +
|
| 35 | +To publish into npm, run: |
| 36 | +$ cd dist && npm publish --access public |
| 37 | +` |
0 commit comments