forked from CodebuffAI/codebuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.js
More file actions
executable file
·51 lines (41 loc) · 1.21 KB
/
Copy pathpublish.js
File metadata and controls
executable file
·51 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
import { execSync } from 'child_process'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
function log(message) {
console.log(`📦 ${message}`)
}
function run(command, options = {}) {
log(`Running: ${command}`)
try {
return execSync(command, { stdio: 'inherit', ...options })
} catch (error) {
console.error(`❌ Command failed: ${command}`)
process.exit(1)
}
}
function main() {
const args = process.argv.slice(2)
const isDryRun = args.includes('--dry-run')
log('Starting SDK publishing process...')
// Verify the package
log('Verifying package contents...')
run('npm pack --dry-run')
if (isDryRun) {
log('Dry run complete! Package is ready for publishing.')
log('To publish for real, run: bun run publish-sdk')
return
}
// Publish
log('Publishing to npm...')
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
run('npm publish')
log('✅ SDK published successfully!')
log(`📦 Package: ${packageJson.name}@${packageJson.version}`)
}
if (import.meta.url === `file://${process.argv[1]}`) {
main()
}