xpose-cli 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install.js +9 -7
- package/bin/test-install.js +15 -7
- package/package.json +3 -2
package/bin/install.js
CHANGED
|
@@ -5,7 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const https = require('https');
|
|
7
7
|
const crypto = require('crypto');
|
|
8
|
-
const
|
|
8
|
+
const tar = require('tar');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* xpose binary downloader
|
|
@@ -153,15 +153,17 @@ async function download() {
|
|
|
153
153
|
|
|
154
154
|
console.log(`Extracting binary...`);
|
|
155
155
|
try {
|
|
156
|
-
// Unpack the tar.gz archive
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
// Unpack the tar.gz archive using the 'tar' package
|
|
157
|
+
// This is cross-platform and doesn't require the system 'tar' command
|
|
158
|
+
await tar.x({
|
|
159
|
+
file: dest,
|
|
160
|
+
cwd: BIN_DIR
|
|
161
|
+
});
|
|
162
162
|
|
|
163
163
|
// Ensure permissions on Unix
|
|
164
|
+
const isWin = os.platform() === 'win32';
|
|
164
165
|
if (!isWin) {
|
|
166
|
+
const binName = isWin ? 'xpose.exe' : 'xpose';
|
|
165
167
|
const finalBinPath = path.join(BIN_DIR, binName);
|
|
166
168
|
fs.chmodSync(finalBinPath, 0o755);
|
|
167
169
|
}
|
package/bin/test-install.js
CHANGED
|
@@ -2,14 +2,13 @@ const assert = require('assert');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const crypto = require('crypto');
|
|
5
|
-
const
|
|
5
|
+
const tar = require('tar');
|
|
6
6
|
const { getFileContent } = require('./install');
|
|
7
7
|
|
|
8
8
|
// Setup temporary test environment
|
|
9
9
|
const TEST_DIR = path.join(__dirname, '..', 'test_tmp');
|
|
10
10
|
const BIN_DIR = path.join(TEST_DIR, 'bin');
|
|
11
11
|
const DUMMY_BIN = 'xpose';
|
|
12
|
-
const DUMMY_CONTENT = 'dummy binary content';
|
|
13
12
|
const ARCHIVE_NAME = 'test-target.tar.gz';
|
|
14
13
|
|
|
15
14
|
if (!fs.existsSync(BIN_DIR)) {
|
|
@@ -17,7 +16,7 @@ if (!fs.existsSync(BIN_DIR)) {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
async function testExtraction() {
|
|
20
|
-
console.log('Running testExtraction...');
|
|
19
|
+
console.log('Running testExtraction (using tar package)...');
|
|
21
20
|
|
|
22
21
|
const archivePath = path.join(BIN_DIR, ARCHIVE_NAME);
|
|
23
22
|
const dummyBinPath = path.join(TEST_DIR, DUMMY_BIN);
|
|
@@ -29,14 +28,22 @@ async function testExtraction() {
|
|
|
29
28
|
fs.writeFileSync(dummyBinPath, '#!/bin/sh\necho "xpose version 0.0.0-test"');
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
// 2. Archive it
|
|
33
|
-
|
|
31
|
+
// 2. Archive it using the 'tar' package (simulating CI build output)
|
|
32
|
+
await tar.c({
|
|
33
|
+
gzip: true,
|
|
34
|
+
file: archivePath,
|
|
35
|
+
cwd: TEST_DIR
|
|
36
|
+
}, [DUMMY_BIN]);
|
|
37
|
+
|
|
34
38
|
fs.unlinkSync(dummyBinPath); // Remove original dummy
|
|
35
39
|
|
|
36
|
-
// 3. Run extraction logic
|
|
40
|
+
// 3. Run extraction logic using the 'tar' package (simulating install.js)
|
|
37
41
|
console.log(`Extracting ${ARCHIVE_NAME}...`);
|
|
38
42
|
try {
|
|
39
|
-
|
|
43
|
+
await tar.x({
|
|
44
|
+
file: archivePath,
|
|
45
|
+
cwd: BIN_DIR
|
|
46
|
+
});
|
|
40
47
|
|
|
41
48
|
const extractedPath = path.join(BIN_DIR, DUMMY_BIN);
|
|
42
49
|
assert(fs.existsSync(extractedPath), 'Extracted binary should exist');
|
|
@@ -48,6 +55,7 @@ async function testExtraction() {
|
|
|
48
55
|
assert((stats.mode & 0o777) === 0o755, 'Binary should have correct permissions');
|
|
49
56
|
|
|
50
57
|
console.log('Testing binary execution...');
|
|
58
|
+
const { execSync } = require('child_process');
|
|
51
59
|
const output = execSync(`"${extractedPath}"`).toString();
|
|
52
60
|
assert(output.includes('xpose version'), 'Binary should be executable and return expected output');
|
|
53
61
|
console.log('✅ Binary execution successful');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xpose-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Cloudflare Tunnel CLI for developers - Vivid TUI, auto-copy, and smart defaults.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"xpose": "bin/cli.js"
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"node": ">=16.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"cli-progress": "^3.12.0"
|
|
34
|
+
"cli-progress": "^3.12.0",
|
|
35
|
+
"tar": "^6.2.1"
|
|
35
36
|
}
|
|
36
37
|
}
|