@oaftobark/spoq 0.1.2
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.js +61 -0
- package/bin.test.js +75 -0
- package/install.js +146 -0
- package/install.test.js +148 -0
- package/package.json +33 -0
package/bin.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const PLATFORMS = {
|
|
7
|
+
"darwin-arm64": "@oaftobark/spoq-darwin-arm64",
|
|
8
|
+
"darwin-x64": "@oaftobark/spoq-darwin-x64",
|
|
9
|
+
"linux-arm64": "@oaftobark/spoq-linux-arm64",
|
|
10
|
+
"linux-x64": "@oaftobark/spoq-linux-x64",
|
|
11
|
+
"win32-x64": "@oaftobark/spoq-win32-x64",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function getBinaryPath() {
|
|
15
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
16
|
+
const packageName = PLATFORMS[platformKey];
|
|
17
|
+
|
|
18
|
+
if (!packageName) {
|
|
19
|
+
console.error(`Unsupported platform: ${platformKey}`);
|
|
20
|
+
console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const binaryName = process.platform === "win32" ? "spoq.exe" : "spoq";
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const packagePath = require.resolve(`${packageName}/package.json`);
|
|
28
|
+
const packageDir = path.dirname(packagePath);
|
|
29
|
+
return path.join(packageDir, "bin", binaryName);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
// Package not found, check for local binary (fallback from postinstall)
|
|
32
|
+
const localBinary = path.join(__dirname, "bin", binaryName);
|
|
33
|
+
try {
|
|
34
|
+
require("fs").accessSync(localBinary, require("fs").constants.X_OK);
|
|
35
|
+
return localBinary;
|
|
36
|
+
} catch {
|
|
37
|
+
console.error(`Could not find spoq binary for ${platformKey}`);
|
|
38
|
+
console.error(
|
|
39
|
+
"Please try reinstalling: npm install -g @oaftobark/spoq"
|
|
40
|
+
);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const binaryPath = getBinaryPath();
|
|
47
|
+
const args = process.argv.slice(2);
|
|
48
|
+
|
|
49
|
+
const child = spawn(binaryPath, args, {
|
|
50
|
+
stdio: "inherit",
|
|
51
|
+
env: process.env,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
child.on("error", (err) => {
|
|
55
|
+
console.error(`Failed to start spoq: ${err.message}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
child.on("close", (code) => {
|
|
60
|
+
process.exit(code ?? 0);
|
|
61
|
+
});
|
package/bin.test.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const assert = require("assert");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
console.log("Running bin.js tests...\n");
|
|
5
|
+
|
|
6
|
+
// Test platform mapping
|
|
7
|
+
{
|
|
8
|
+
console.log("Test: Platform mappings");
|
|
9
|
+
const PLATFORMS = {
|
|
10
|
+
"darwin-arm64": "@oaftobark/spoq-darwin-arm64",
|
|
11
|
+
"darwin-x64": "@oaftobark/spoq-darwin-x64",
|
|
12
|
+
"linux-arm64": "@oaftobark/spoq-linux-arm64",
|
|
13
|
+
"linux-x64": "@oaftobark/spoq-linux-x64",
|
|
14
|
+
"win32-x64": "@oaftobark/spoq-win32-x64",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
assert.strictEqual(PLATFORMS["darwin-arm64"], "@oaftobark/spoq-darwin-arm64");
|
|
18
|
+
assert.strictEqual(PLATFORMS["darwin-x64"], "@oaftobark/spoq-darwin-x64");
|
|
19
|
+
assert.strictEqual(PLATFORMS["linux-arm64"], "@oaftobark/spoq-linux-arm64");
|
|
20
|
+
assert.strictEqual(PLATFORMS["linux-x64"], "@oaftobark/spoq-linux-x64");
|
|
21
|
+
assert.strictEqual(PLATFORMS["win32-x64"], "@oaftobark/spoq-win32-x64");
|
|
22
|
+
console.log(" PASS: All platform mappings correct\n");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
console.log("Test: Binary name for Unix platforms");
|
|
27
|
+
const binaryName = "darwin" === "win32" ? "spoq.exe" : "spoq";
|
|
28
|
+
assert.strictEqual(binaryName, "spoq");
|
|
29
|
+
console.log(" PASS: Unix binary name is 'spoq'\n");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
{
|
|
33
|
+
console.log("Test: Binary name for Windows platform");
|
|
34
|
+
const binaryName = "win32" === "win32" ? "spoq.exe" : "spoq";
|
|
35
|
+
assert.strictEqual(binaryName, "spoq.exe");
|
|
36
|
+
console.log(" PASS: Windows binary name is 'spoq.exe'\n");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
console.log("Test: Package path construction");
|
|
41
|
+
const packageName = "@oaftobark/spoq-darwin-arm64";
|
|
42
|
+
const packagePath = `${packageName}/package.json`;
|
|
43
|
+
assert.strictEqual(packagePath, "@oaftobark/spoq-darwin-arm64/package.json");
|
|
44
|
+
console.log(" PASS: Package path constructed correctly\n");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
console.log("Test: Supported platform key format");
|
|
49
|
+
const platformKey = `darwin-arm64`;
|
|
50
|
+
assert.ok(/^(darwin|linux|win32)-(arm64|x64)$/.test(platformKey));
|
|
51
|
+
console.log(" PASS: Platform key format validated\n");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
console.log("Test: Unsupported platform detection");
|
|
56
|
+
const platformKey = `freebsd-x64`;
|
|
57
|
+
const PLATFORMS = {
|
|
58
|
+
"darwin-arm64": "@oaftobark/spoq-darwin-arm64",
|
|
59
|
+
"darwin-x64": "@oaftobark/spoq-darwin-x64",
|
|
60
|
+
"linux-arm64": "@oaftobark/spoq-linux-arm64",
|
|
61
|
+
"linux-x64": "@oaftobark/spoq-linux-x64",
|
|
62
|
+
"win32-x64": "@oaftobark/spoq-win32-x64",
|
|
63
|
+
};
|
|
64
|
+
assert.strictEqual(PLATFORMS[platformKey], undefined);
|
|
65
|
+
console.log(" PASS: Unsupported platform returns undefined\n");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
{
|
|
69
|
+
console.log("Test: Local binary path construction");
|
|
70
|
+
const localBinary = path.join("/test/dir", "bin", "spoq");
|
|
71
|
+
assert.strictEqual(localBinary, "/test/dir/bin/spoq");
|
|
72
|
+
console.log(" PASS: Local binary path constructed correctly\n");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log("All bin.js tests passed!");
|
package/install.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall script for @oaftobark/spoq
|
|
5
|
+
*
|
|
6
|
+
* This script handles the fallback case when the optional platform-specific
|
|
7
|
+
* dependency fails to install (e.g., on unsupported platforms or when npm
|
|
8
|
+
* can't resolve the optional dependency).
|
|
9
|
+
*
|
|
10
|
+
* It downloads the appropriate binary from GitHub releases.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const https = require("https");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const { execSync } = require("child_process");
|
|
17
|
+
|
|
18
|
+
const PACKAGE_VERSION = require("./package.json").version;
|
|
19
|
+
const GITHUB_REPO = "oaftobark/spoq";
|
|
20
|
+
|
|
21
|
+
const PLATFORMS = {
|
|
22
|
+
"darwin-arm64": "spoq-darwin-arm64.tar.gz",
|
|
23
|
+
"darwin-x64": "spoq-darwin-x64.tar.gz",
|
|
24
|
+
"linux-arm64": "spoq-linux-arm64.tar.gz",
|
|
25
|
+
"linux-x64": "spoq-linux-x64.tar.gz",
|
|
26
|
+
"win32-x64": "spoq-win32-x64.zip",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function getPlatformKey() {
|
|
30
|
+
return `${process.platform}-${process.arch}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isPlatformPackageInstalled() {
|
|
34
|
+
const platformKey = getPlatformKey();
|
|
35
|
+
const packageNames = {
|
|
36
|
+
"darwin-arm64": "@oaftobark/spoq-darwin-arm64",
|
|
37
|
+
"darwin-x64": "@oaftobark/spoq-darwin-x64",
|
|
38
|
+
"linux-arm64": "@oaftobark/spoq-linux-arm64",
|
|
39
|
+
"linux-x64": "@oaftobark/spoq-linux-x64",
|
|
40
|
+
"win32-x64": "@oaftobark/spoq-win32-x64",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const packageName = packageNames[platformKey];
|
|
44
|
+
if (!packageName) return false;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
require.resolve(`${packageName}/package.json`);
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function downloadFile(url) {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
const request = (url) => {
|
|
57
|
+
https
|
|
58
|
+
.get(url, (response) => {
|
|
59
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
60
|
+
request(response.headers.location);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (response.statusCode !== 200) {
|
|
65
|
+
reject(new Error(`HTTP ${response.statusCode}: ${url}`));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const chunks = [];
|
|
70
|
+
response.on("data", (chunk) => chunks.push(chunk));
|
|
71
|
+
response.on("end", () => resolve(Buffer.concat(chunks)));
|
|
72
|
+
response.on("error", reject);
|
|
73
|
+
})
|
|
74
|
+
.on("error", reject);
|
|
75
|
+
};
|
|
76
|
+
request(url);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function extractTarGz(buffer, destDir) {
|
|
81
|
+
const tempFile = path.join(destDir, "temp.tar.gz");
|
|
82
|
+
fs.writeFileSync(tempFile, buffer);
|
|
83
|
+
try {
|
|
84
|
+
execSync(`tar -xzf "${tempFile}" -C "${destDir}"`, { stdio: "pipe" });
|
|
85
|
+
} finally {
|
|
86
|
+
fs.unlinkSync(tempFile);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function extractZip(buffer, destDir) {
|
|
91
|
+
const tempFile = path.join(destDir, "temp.zip");
|
|
92
|
+
fs.writeFileSync(tempFile, buffer);
|
|
93
|
+
try {
|
|
94
|
+
execSync(`unzip -o "${tempFile}" -d "${destDir}"`, { stdio: "pipe" });
|
|
95
|
+
} finally {
|
|
96
|
+
fs.unlinkSync(tempFile);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function main() {
|
|
101
|
+
// Skip if platform package is already installed
|
|
102
|
+
if (isPlatformPackageInstalled()) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const platformKey = getPlatformKey();
|
|
107
|
+
const archiveFile = PLATFORMS[platformKey];
|
|
108
|
+
|
|
109
|
+
if (!archiveFile) {
|
|
110
|
+
console.warn(`Warning: No prebuilt binary available for ${platformKey}`);
|
|
111
|
+
console.warn("You may need to build spoq from source.");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
console.log(`Platform package not found, downloading binary for ${platformKey}...`);
|
|
116
|
+
|
|
117
|
+
const binDir = path.join(__dirname, "bin");
|
|
118
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
119
|
+
|
|
120
|
+
const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/v${PACKAGE_VERSION}/${archiveFile}`;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const buffer = await downloadFile(downloadUrl);
|
|
124
|
+
|
|
125
|
+
if (archiveFile.endsWith(".tar.gz")) {
|
|
126
|
+
await extractTarGz(buffer, binDir);
|
|
127
|
+
} else if (archiveFile.endsWith(".zip")) {
|
|
128
|
+
await extractZip(buffer, binDir);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Make binary executable on Unix
|
|
132
|
+
if (process.platform !== "win32") {
|
|
133
|
+
const binaryPath = path.join(binDir, "spoq");
|
|
134
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
console.log("Binary downloaded successfully.");
|
|
138
|
+
} catch (err) {
|
|
139
|
+
console.warn(`Warning: Failed to download binary: ${err.message}`);
|
|
140
|
+
console.warn("You may need to build spoq from source or install manually.");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
main().catch((err) => {
|
|
145
|
+
console.warn(`Postinstall warning: ${err.message}`);
|
|
146
|
+
});
|
package/install.test.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const assert = require("assert");
|
|
2
|
+
|
|
3
|
+
console.log("Running install.js tests...\n");
|
|
4
|
+
|
|
5
|
+
// Platform Detection Tests
|
|
6
|
+
{
|
|
7
|
+
console.log("Test: Archive names for all platforms");
|
|
8
|
+
const PLATFORMS = {
|
|
9
|
+
"darwin-arm64": "spoq-darwin-arm64.tar.gz",
|
|
10
|
+
"darwin-x64": "spoq-darwin-x64.tar.gz",
|
|
11
|
+
"linux-arm64": "spoq-linux-arm64.tar.gz",
|
|
12
|
+
"linux-x64": "spoq-linux-x64.tar.gz",
|
|
13
|
+
"win32-x64": "spoq-win32-x64.zip",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
assert.strictEqual(PLATFORMS["darwin-arm64"], "spoq-darwin-arm64.tar.gz");
|
|
17
|
+
assert.strictEqual(PLATFORMS["darwin-x64"], "spoq-darwin-x64.tar.gz");
|
|
18
|
+
assert.strictEqual(PLATFORMS["linux-arm64"], "spoq-linux-arm64.tar.gz");
|
|
19
|
+
assert.strictEqual(PLATFORMS["linux-x64"], "spoq-linux-x64.tar.gz");
|
|
20
|
+
assert.strictEqual(PLATFORMS["win32-x64"], "spoq-win32-x64.zip");
|
|
21
|
+
console.log(" PASS: All archive names correct\n");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
console.log("Test: Unix platforms use tar.gz");
|
|
26
|
+
const PLATFORMS = {
|
|
27
|
+
"darwin-arm64": "spoq-darwin-arm64.tar.gz",
|
|
28
|
+
"darwin-x64": "spoq-darwin-x64.tar.gz",
|
|
29
|
+
"linux-arm64": "spoq-linux-arm64.tar.gz",
|
|
30
|
+
"linux-x64": "spoq-linux-x64.tar.gz",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
assert.ok(PLATFORMS["darwin-arm64"].endsWith(".tar.gz"));
|
|
34
|
+
assert.ok(PLATFORMS["darwin-x64"].endsWith(".tar.gz"));
|
|
35
|
+
assert.ok(PLATFORMS["linux-arm64"].endsWith(".tar.gz"));
|
|
36
|
+
assert.ok(PLATFORMS["linux-x64"].endsWith(".tar.gz"));
|
|
37
|
+
console.log(" PASS: Unix platforms use tar.gz format\n");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
{
|
|
41
|
+
console.log("Test: Windows platform uses zip");
|
|
42
|
+
const archive = "spoq-win32-x64.zip";
|
|
43
|
+
assert.ok(archive.endsWith(".zip"));
|
|
44
|
+
console.log(" PASS: Windows platform uses zip format\n");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
console.log("Test: Platform key construction");
|
|
49
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
50
|
+
assert.ok(typeof platformKey === "string");
|
|
51
|
+
assert.ok(platformKey.includes("-"));
|
|
52
|
+
console.log(" PASS: Platform key constructed correctly\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Download URL Construction Tests
|
|
56
|
+
{
|
|
57
|
+
console.log("Test: GitHub release URL construction");
|
|
58
|
+
const PACKAGE_VERSION = "0.1.0";
|
|
59
|
+
const GITHUB_REPO = "oaftobark/spoq";
|
|
60
|
+
const archiveFile = "spoq-darwin-arm64.tar.gz";
|
|
61
|
+
const url = `https://github.com/${GITHUB_REPO}/releases/download/v${PACKAGE_VERSION}/${archiveFile}`;
|
|
62
|
+
assert.strictEqual(url, "https://github.com/oaftobark/spoq/releases/download/v0.1.0/spoq-darwin-arm64.tar.gz");
|
|
63
|
+
console.log(" PASS: GitHub URL constructed correctly\n");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
{
|
|
67
|
+
console.log("Test: Version prefix in URL");
|
|
68
|
+
const PACKAGE_VERSION = "0.1.0";
|
|
69
|
+
const GITHUB_REPO = "oaftobark/spoq";
|
|
70
|
+
const url = `https://github.com/${GITHUB_REPO}/releases/download/v${PACKAGE_VERSION}/spoq-linux-x64.tar.gz`;
|
|
71
|
+
assert.ok(url.includes("/v0.1.0/"));
|
|
72
|
+
console.log(" PASS: Version prefix included in URL\n");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
{
|
|
76
|
+
console.log("Test: URLs for all platforms");
|
|
77
|
+
const PACKAGE_VERSION = "0.1.0";
|
|
78
|
+
const GITHUB_REPO = "oaftobark/spoq";
|
|
79
|
+
const platforms = ["darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", "win32-x64"];
|
|
80
|
+
|
|
81
|
+
platforms.forEach(platform => {
|
|
82
|
+
const archiveExt = platform.startsWith("win32") ? "zip" : "tar.gz";
|
|
83
|
+
const url = `https://github.com/${GITHUB_REPO}/releases/download/v${PACKAGE_VERSION}/spoq-${platform}.${archiveExt}`;
|
|
84
|
+
assert.ok(url.startsWith("https://github.com/"));
|
|
85
|
+
assert.ok(url.includes(platform));
|
|
86
|
+
});
|
|
87
|
+
console.log(" PASS: URLs for all platforms valid\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Package Resolution Tests
|
|
91
|
+
{
|
|
92
|
+
console.log("Test: Package name mappings");
|
|
93
|
+
const packageNames = {
|
|
94
|
+
"darwin-arm64": "@oaftobark/spoq-darwin-arm64",
|
|
95
|
+
"darwin-x64": "@oaftobark/spoq-darwin-x64",
|
|
96
|
+
"linux-arm64": "@oaftobark/spoq-linux-arm64",
|
|
97
|
+
"linux-x64": "@oaftobark/spoq-linux-x64",
|
|
98
|
+
"win32-x64": "@oaftobark/spoq-win32-x64",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
assert.strictEqual(packageNames["darwin-arm64"], "@oaftobark/spoq-darwin-arm64");
|
|
102
|
+
assert.strictEqual(packageNames["linux-x64"], "@oaftobark/spoq-linux-x64");
|
|
103
|
+
assert.strictEqual(packageNames["win32-x64"], "@oaftobark/spoq-win32-x64");
|
|
104
|
+
console.log(" PASS: Package names mapped correctly\n");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
{
|
|
108
|
+
console.log("Test: Unsupported platform returns undefined");
|
|
109
|
+
const platformKey = "freebsd-x64";
|
|
110
|
+
const packageNames = {
|
|
111
|
+
"darwin-arm64": "@oaftobark/spoq-darwin-arm64",
|
|
112
|
+
"darwin-x64": "@oaftobark/spoq-darwin-x64",
|
|
113
|
+
"linux-arm64": "@oaftobark/spoq-linux-arm64",
|
|
114
|
+
"linux-x64": "@oaftobark/spoq-linux-x64",
|
|
115
|
+
"win32-x64": "@oaftobark/spoq-win32-x64",
|
|
116
|
+
};
|
|
117
|
+
const packageName = packageNames[platformKey];
|
|
118
|
+
assert.strictEqual(packageName, undefined);
|
|
119
|
+
console.log(" PASS: Unsupported platform returns undefined\n");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// HTTP Response Handling Tests
|
|
123
|
+
{
|
|
124
|
+
console.log("Test: Redirect status codes");
|
|
125
|
+
const redirectCodes = [301, 302];
|
|
126
|
+
redirectCodes.forEach(code => {
|
|
127
|
+
assert.ok(code === 301 || code === 302);
|
|
128
|
+
});
|
|
129
|
+
console.log(" PASS: Redirect status codes handled\n");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
{
|
|
133
|
+
console.log("Test: Success status code");
|
|
134
|
+
const statusCode = 200;
|
|
135
|
+
assert.strictEqual(statusCode, 200);
|
|
136
|
+
console.log(" PASS: Success status code is 200\n");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
{
|
|
140
|
+
console.log("Test: Error status codes detection");
|
|
141
|
+
const errorCodes = [404, 500, 403];
|
|
142
|
+
errorCodes.forEach(code => {
|
|
143
|
+
assert.ok(code !== 200);
|
|
144
|
+
});
|
|
145
|
+
console.log(" PASS: Error status codes detected\n");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
console.log("All install.js tests passed!");
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oaftobark/spoq",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A terminal-based Spotify client",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/oaftobark/spoq.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"bin": {
|
|
11
|
+
"spoq": "bin.js"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"postinstall": "node install.js"
|
|
15
|
+
},
|
|
16
|
+
"optionalDependencies": {
|
|
17
|
+
"@oaftobark/spoq-darwin-arm64": "0.1.2",
|
|
18
|
+
"@oaftobark/spoq-darwin-x64": "0.1.2",
|
|
19
|
+
"@oaftobark/spoq-linux-arm64": "0.1.2",
|
|
20
|
+
"@oaftobark/spoq-linux-x64": "0.1.2",
|
|
21
|
+
"@oaftobark/spoq-win32-x64": "0.1.2"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=14"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"spotify",
|
|
28
|
+
"terminal",
|
|
29
|
+
"tui",
|
|
30
|
+
"music",
|
|
31
|
+
"cli"
|
|
32
|
+
]
|
|
33
|
+
}
|