Skip to content

Commit c0b8166

Browse files
chore: expose local release build
1 parent 156d5c7 commit c0b8166

4 files changed

Lines changed: 59 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ yarn-error.log
1010
dist/
1111
dev/
1212

13-
*.tgz
1413
coverage/
1514

1615
.vscode
2.63 MB
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dev": "NODE_ENV=development node ./scripts/make.mjs",
1212
"dev:native": "react-native start",
1313
"release": "node ./scripts/release.mjs",
14+
"build:local": "node ./scripts/build-local.mjs",
1415
"prettier": "prettier --write src docs-website/src",
1516
"flow": "flow check --color always",
1617
"eslint": "eslint ./src -c ./.eslintrc.js --cache --cache-location ./.cache/.eslintcache",

scripts/build-local.mjs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Build script that creates a versioned .tgz package in the builds/ folder
5+
* Usage: node scripts/build-local.mjs [version-suffix]
6+
*
7+
* Examples:
8+
* node scripts/build-local.mjs -> builds/nozbe-watermelondb-v0.28.1-0.tgz
9+
* node scripts/build-local.mjs dev -> builds/nozbe-watermelondb-v0.28.1-0-dev.tgz
10+
* node scripts/build-local.mjs feature-x -> builds/nozbe-watermelondb-v0.28.1-0-feature-x.tgz
11+
*/
12+
13+
import { execa } from 'execa'
14+
import fs from 'fs-extra'
15+
import path from 'path'
16+
import { fileURLToPath } from 'url'
17+
18+
import pkg from './pkg.cjs'
19+
20+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
21+
const rootDir = path.resolve(__dirname, '..')
22+
const distPath = path.join(rootDir, 'dist')
23+
const buildsPath = path.join(rootDir, 'builds')
24+
25+
const suffix = process.argv[2] || ''
26+
const versionTag = suffix ? `v${pkg.version}-${suffix}` : `v${pkg.version}`
27+
const tgzName = `nozbe-watermelondb-${versionTag}.tgz`
28+
const tgzPath = path.join(buildsPath, tgzName)
29+
30+
async function main() {
31+
console.log(`Building WatermelonDB v${pkg.version}...`)
32+
33+
// Run the standard build
34+
await execa('yarn', ['build'], {
35+
cwd: rootDir,
36+
stdio: 'inherit',
37+
env: { ...process.env, NODE_ENV: 'production' }
38+
})
39+
40+
// Ensure builds directory exists
41+
await fs.ensureDir(buildsPath)
42+
43+
// Pack the dist folder into a tgz
44+
console.log(`\nPacking to ${tgzName}...`)
45+
await execa('yarn', ['pack', '--filename', tgzPath], {
46+
cwd: distPath,
47+
stdio: 'inherit'
48+
})
49+
50+
console.log(`\n✅ Build complete: builds/${tgzName}`)
51+
console.log(`\nTo use in another project, add to package.json:`)
52+
console.log(` "@nozbe/watermelondb": "file:${tgzPath}"`)
53+
}
54+
55+
main().catch((err) => {
56+
console.error('Build failed:', err)
57+
process.exit(1)
58+
})

0 commit comments

Comments
 (0)