File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ nodeLinker : node-modules
Original file line number Diff line number Diff line change 1919 "lint" : " eslint src/" ,
2020 "bench" : " node --expose-gc --import tsx src/sparstogram.bench.ts" ,
2121 "bump" : " bumpp --execute=\" npm test && npm run lint && npm run build\" " ,
22- "pub" : " bash scripts/pub.sh " ,
22+ "pub" : " node scripts/publish.cjs " ,
2323 "prepublishOnly" : " npm run lint && npm run build"
2424 },
2525 "repository" : {
5050 "@types/mocha" : " ^10.0.10" ,
5151 "@typescript-eslint/eslint-plugin" : " ^8.32.1" ,
5252 "@typescript-eslint/parser" : " ^8.32.1" ,
53+ "bumpp" : " ^10.4.0" ,
5354 "chai" : " ^5.2.0" ,
5455 "eslint" : " ^9.27.0" ,
5556 "mocha" : " ^11.4.0" ,
56- "bumpp" : " ^10.4.0" ,
5757 "rimraf" : " ^6.0.1" ,
5858 "tinybench" : " ^6.0.0" ,
5959 "tsx" : " ^4.21.0" ,
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ const { execSync } = require ( 'child_process' ) ;
4+ const { join } = require ( 'path' ) ;
5+
6+ const rootDir = join ( __dirname , '..' ) ;
7+ const version = `v${ require ( join ( rootDir , 'package.json' ) ) . version } ` ;
8+
9+ try {
10+ process . chdir ( rootDir ) ;
11+
12+ // Verify the version is tagged
13+ const tags = execSync ( `git tag -l ${ version } ` , { encoding : 'utf8' } ) . trim ( ) ;
14+ if ( ! tags ) {
15+ console . error ( `Error: tag '${ version } ' not found. Run 'npm run bump' first.` ) ;
16+ process . exit ( 1 ) ;
17+ }
18+
19+ // Ensure working tree is clean
20+ const staged = execSync ( 'git diff --cached --quiet' , { stdio : 'pipe' } ) . toString ( ) ;
21+ const unstaged = execSync ( 'git diff --quiet' , { stdio : 'pipe' } ) . toString ( ) ;
22+
23+ console . log ( `Publishing ${ version } to npm...` ) ;
24+ execSync ( 'npm publish --access public' , { stdio : 'inherit' } ) ;
25+
26+ console . log ( 'Pushing to remote...' ) ;
27+ execSync ( 'git push --follow-tags' , { stdio : 'inherit' } ) ;
28+
29+ console . log ( `\nPublished ${ version } ` ) ;
30+ } catch ( error ) {
31+ if ( error . status && ! error . message . includes ( 'npm publish' ) ) {
32+ // git diff --quiet exits non-zero when there are changes
33+ console . error ( 'Error: working tree not clean. Commit or stash changes first.' ) ;
34+ } else {
35+ console . error ( `Failed to publish:` , error . message ) ;
36+ }
37+ process . exit ( 1 ) ;
38+ }
You can’t perform that action at this time.
0 commit comments