Skip to content

Commit 14d1589

Browse files
committed
Cleanup of bump and pub
1 parent 1fc04f4 commit 14d1589

7 files changed

Lines changed: 2999 additions & 1695 deletions

File tree

.yarn/install-state.gz

238 KB
Binary file not shown.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
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": {
@@ -50,10 +50,10 @@
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",

scripts/bump.sh

Lines changed: 0 additions & 49 deletions
This file was deleted.

scripts/pub.sh

Lines changed: 0 additions & 32 deletions
This file was deleted.

scripts/publish.cjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)