slash-client 0.0.0-stage → 0.1.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 +22 -2
- package/bin/slash.js +51 -0
- package/package.json +25 -5
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# slash-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Slash** is a social network that lives in your terminal: posts, threads, hashtags, a For You feed, images and videos (with sound) drawn right in the shell, and end-to-end encrypted messages.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install -g slash-client
|
|
7
|
+
slash # the interactive shell, then /register
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Or one command at a time:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
slash feed
|
|
14
|
+
slash post "deployed ✓ #devops" -m screenshot.png
|
|
15
|
+
slash like 3
|
|
16
|
+
slash dm @alice "see you at 8"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Images use the Kitty, iTerm2 or Sixel graphics protocols when your terminal supports them, and 24-bit half blocks or coloured ASCII when it doesn't (`/set media`).
|
|
20
|
+
|
|
21
|
+
On its first run, `slash` downloads the native binary for your platform (Windows, macOS or Linux, x64 or ARM64) from slash.maxence.gg into `~/.slash/bin`. Nothing runs at install time.
|
|
22
|
+
|
|
23
|
+
More: https://slash.maxence.gg
|
package/bin/slash.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Launcher of Slash : runs the Go binary of this platform, downloaded from the server on the first run into
|
|
3
|
+
// ~/.slash/bin (one per version). A package slash-client-<os>-<cpu> installed next to it is used first when there.
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const { spawnSync } = require("node:child_process");
|
|
7
|
+
const fs = require("node:fs");
|
|
8
|
+
const os = require("node:os");
|
|
9
|
+
const path = require("node:path");
|
|
10
|
+
|
|
11
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
12
|
+
const pkg = `slash-client-${process.platform}-${process.arch}`;
|
|
13
|
+
const goName = { win32: "windows", darwin: "darwin", linux: "linux" }[process.platform];
|
|
14
|
+
const goArch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
15
|
+
|
|
16
|
+
function fromPackage() {
|
|
17
|
+
try {
|
|
18
|
+
return require.resolve(`${pkg}/bin/slash${ext}`);
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function fromCache() {
|
|
25
|
+
const file = path.join(os.homedir(), ".slash", "bin", `slash-${require("../package.json").version}${ext}`);
|
|
26
|
+
if (fs.existsSync(file)) return file;
|
|
27
|
+
if (!goName || !goArch) return null;
|
|
28
|
+
|
|
29
|
+
const server = (process.env.SLASH_SERVER || "https://slash.maxence.gg").replace(/\/$/, "");
|
|
30
|
+
const url = `${server}/downloads/slash-${goName}-${goArch}${ext}`;
|
|
31
|
+
process.stderr.write(`slash : downloading the binary for ${goName}/${goArch}…\n`);
|
|
32
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
33
|
+
// ? Node 18+ : fetch, in a child process so that the launcher stays synchronous
|
|
34
|
+
const script = `fetch(${JSON.stringify(url)}).then(r=>{if(!r.ok)throw new Error("HTTP "+r.status);return r.arrayBuffer()}).then(b=>require("fs").writeFileSync(${JSON.stringify(file)},Buffer.from(b),{mode:0o755})).catch(e=>{console.error(e.message);process.exit(1)})`;
|
|
35
|
+
const result = spawnSync(process.execPath, ["-e", script], { stdio: "inherit" });
|
|
36
|
+
return result.status === 0 ? file : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const binary = fromPackage() || fromCache();
|
|
40
|
+
if (!binary) {
|
|
41
|
+
console.error(`slash : no build for ${process.platform}/${process.arch}. See https://slash.maxence.gg/#install`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ? The terminal goes to the binary as it is (raw mode, sizes, images)
|
|
46
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit", windowsHide: false });
|
|
47
|
+
if (result.error) {
|
|
48
|
+
console.error(`slash : ${result.error.message}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
process.exit(result.status ?? (result.signal ? 1 : 0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "slash-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Slash : a social network living in your terminal (posts, images, videos, encrypted messages)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"terminal",
|
|
7
|
+
"cli",
|
|
8
|
+
"social",
|
|
9
|
+
"twitter",
|
|
10
|
+
"tui",
|
|
11
|
+
"sixel",
|
|
12
|
+
"kitty"
|
|
13
|
+
],
|
|
14
|
+
"bin": {
|
|
15
|
+
"slash": "bin/slash.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"homepage": "https://slash.maxence.gg"
|
|
26
|
+
}
|