Skip to content

Commit c4a4137

Browse files
committed
fix: npm wrapper as cli.js to avoid gitignore, unpublish before republish
1 parent 8d24507 commit c4a4137

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ jobs:
4545
cd npm
4646
npm version "$VERSION" --no-git-tag-version
4747
48+
- name: Unpublish npm version if it exists
49+
continue-on-error: true
50+
run: |
51+
VERSION=${GITHUB_REF_NAME#v}
52+
npm unpublish "@xdevplatform/xurl@${VERSION}" --registry=https://registry.npmjs.org
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55+
4856
- name: Publish to npm
4957
run: |
5058
cd npm

npm/cli.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env node
2+
3+
const { execFileSync } = require("child_process");
4+
const path = require("path");
5+
const fs = require("fs");
6+
7+
const binary = path.join(__dirname, "binary", process.platform === "win32" ? "xurl.exe" : "xurl");
8+
9+
if (!fs.existsSync(binary)) {
10+
console.error("xurl binary not found. Try reinstalling: npm install -g @xdevplatform/xurl");
11+
process.exit(1);
12+
}
13+
14+
try {
15+
const result = execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
16+
} catch (e) {
17+
process.exit(e.status || 1);
18+
}

npm/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
"homepage": "https://github.com/xdevplatform/xurl",
1111
"keywords": ["x", "twitter", "api", "cli", "curl", "oauth"],
1212
"bin": {
13-
"xurl": "bin/xurl"
13+
"xurl": "cli.js"
1414
},
1515
"scripts": {
1616
"postinstall": "node install.js"
1717
},
1818
"files": [
19-
"bin/",
20-
"binary/",
19+
"cli.js",
2120
"install.js"
2221
]
2322
}

0 commit comments

Comments
 (0)