testify-api-cli 1.0.0

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # testify-cli-npm
package/bin/testify.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require('child_process');
3
+ const path = require('path');
4
+
5
+ const isWindows = process.platform === 'win32';
6
+ const binName = isWindows ? 'testify.exe' : 'testify';
7
+ const binPath = path.join(__dirname, binName);
8
+
9
+ const result = spawnSync(binPath, process.argv.slice(2), {
10
+ stdio: 'inherit',
11
+ });
12
+
13
+ process.exit(result.status === null ? 1 : result.status);
package/install.js ADDED
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+
3
+ const https = require('https');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { execSync } = require('child_process');
7
+
8
+ const binDir = path.join(__dirname, 'bin');
9
+ const packageJsonPath = path.join(__dirname, 'package.json');
10
+
11
+ try {
12
+ if (!fs.existsSync(binDir)) {
13
+ fs.mkdirSync(binDir, { recursive: true });
14
+ }
15
+
16
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
17
+ const version = pkg.version;
18
+
19
+ const platform = process.platform;
20
+ const arch = process.arch;
21
+
22
+ let assetName = '';
23
+ let isWindows = platform === 'win32';
24
+
25
+ if (platform === 'darwin') {
26
+ if (arch === 'x64') assetName = 'testify_darwin_amd64.tar.gz';
27
+ else if (arch === 'arm64') assetName = 'testify_darwin_arm64.tar.gz';
28
+ } else if (platform === 'linux') {
29
+ if (arch === 'x64') assetName = 'testify_linux_amd64.tar.gz';
30
+ else if (arch === 'arm64') assetName = 'testify_linux_arm64.tar.gz';
31
+ } else if (platform === 'win32') {
32
+ if (arch === 'x64') assetName = 'testify_windows_amd64.zip';
33
+ else if (arch === 'arm64') assetName = 'testify_windows_arm64.zip';
34
+ }
35
+
36
+ if (!assetName) {
37
+ console.error(`ERROR: Unsupported platform/architecture: ${platform}/${arch}`);
38
+ process.exit(1);
39
+ }
40
+
41
+ const url = `https://github.com/nityam123-pixle/testify-cli/releases/download/v${version}/${assetName}`;
42
+ const archivePath = path.join(binDir, assetName);
43
+
44
+ function download(url, dest) {
45
+ return new Promise((resolve, reject) => {
46
+ https.get(url, (response) => {
47
+ if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
48
+ download(response.headers.location, dest).then(resolve).catch(reject);
49
+ } else if (response.statusCode === 200) {
50
+ const file = fs.createWriteStream(dest);
51
+ response.pipe(file);
52
+ file.on('finish', () => {
53
+ file.close();
54
+ resolve();
55
+ });
56
+ file.on('error', (err) => {
57
+ if (fs.existsSync(dest)) fs.unlinkSync(dest);
58
+ reject(err);
59
+ });
60
+ } else {
61
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
62
+ }
63
+ }).on('error', reject);
64
+ });
65
+ }
66
+
67
+ download(url, archivePath).then(() => {
68
+ try {
69
+ if (isWindows) {
70
+ execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`);
71
+ } else {
72
+ execSync(`tar -xzf "${archivePath}" -C "${binDir}"`);
73
+ }
74
+
75
+ if (fs.existsSync(archivePath)) {
76
+ fs.unlinkSync(archivePath);
77
+ }
78
+
79
+ if (!isWindows) {
80
+ const binPath = path.join(binDir, 'testify');
81
+ if (fs.existsSync(binPath)) {
82
+ fs.chmodSync(binPath, 0o755);
83
+ }
84
+ }
85
+
86
+ console.log(`✓ Testify v${version} installed`);
87
+ } catch (err) {
88
+ console.error(`ERROR: Extraction failed: ${err.message}`);
89
+ process.exit(1);
90
+ }
91
+ }).catch((err) => {
92
+ console.error(`ERROR: Download failed: ${err.message}`);
93
+ process.exit(1);
94
+ });
95
+
96
+ } catch (err) {
97
+ console.error(`ERROR: Installation failed: ${err.message}`);
98
+ process.exit(1);
99
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "testify-api-cli",
3
+ "version": "1.0.0",
4
+ "description": "Zero-config API testing for your terminal",
5
+ "homepage": "https://github.com/nityam123-pixle/testify-cli",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nityam123-pixle/testify-cli-npm.git"
9
+ },
10
+ "bin": {
11
+ "testify": "./bin/testify.js"
12
+ },
13
+ "files": [
14
+ "bin/testify.js",
15
+ "install.js"
16
+ ],
17
+ "scripts": {
18
+ "postinstall": "node install.js"
19
+ },
20
+ "os": [
21
+ "darwin",
22
+ "linux",
23
+ "win32"
24
+ ],
25
+ "license": "Apache-2.0",
26
+ "keywords": [
27
+ "api",
28
+ "testing",
29
+ "cli",
30
+ "rest",
31
+ "postman-alternative"
32
+ ]
33
+ }