roomshare 0.1.13
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 +17 -0
- package/bin/roomshare.js +77 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# roomshare
|
|
2
|
+
|
|
3
|
+
`roomshare` is a thin Bun wrapper for [`@elefunc/send`](https://www.npmjs.com/package/@elefunc/send).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add -g roomshare
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
roomshare
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This package forwards to `@elefunc/send@0.1.13`. Visible help text and in-app branding may still refer to the source package.
|
package/bin/roomshare.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { delimiter, dirname, extname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const SOURCE_PACKAGE = "@elefunc/send";
|
|
9
|
+
const TARGET_COMMAND = "roomshare";
|
|
10
|
+
const SOURCE_PARTS = SOURCE_PACKAGE.split("/");
|
|
11
|
+
|
|
12
|
+
const commandExists = command => {
|
|
13
|
+
for (const directory of (process.env.PATH ?? "").split(delimiter)) {
|
|
14
|
+
if (!directory) continue;
|
|
15
|
+
if (existsSync(join(directory, command))) return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const fail = message => {
|
|
21
|
+
console.error(`[${TARGET_COMMAND}] ${message}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const parseSingleBin = packageJson => {
|
|
26
|
+
const value = packageJson.bin;
|
|
27
|
+
if (typeof value === "string" && value.trim()) {
|
|
28
|
+
return value.trim();
|
|
29
|
+
}
|
|
30
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
31
|
+
const entries = Object.entries(value).filter(([, target]) => typeof target === "string" && target.trim());
|
|
32
|
+
if (entries.length === 1) return entries[0][1];
|
|
33
|
+
if (entries.length === 0) fail(`source package ${SOURCE_PACKAGE} does not expose a CLI bin`);
|
|
34
|
+
fail(`source package ${SOURCE_PACKAGE} exposes multiple CLI bins; wrapper requires exactly one`);
|
|
35
|
+
}
|
|
36
|
+
fail(`source package ${SOURCE_PACKAGE} does not expose a CLI bin`);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const findSourceRoot = () => {
|
|
40
|
+
let directory = dirname(fileURLToPath(import.meta.url));
|
|
41
|
+
for (;;) {
|
|
42
|
+
const candidate = join(directory, "node_modules", ...SOURCE_PARTS, "package.json");
|
|
43
|
+
if (existsSync(candidate)) return dirname(candidate);
|
|
44
|
+
const parent = dirname(directory);
|
|
45
|
+
if (parent === directory) break;
|
|
46
|
+
directory = parent;
|
|
47
|
+
}
|
|
48
|
+
fail(`unable to locate installed dependency ${SOURCE_PACKAGE}`);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const sourceRoot = findSourceRoot();
|
|
52
|
+
const sourcePackageJsonPath = join(sourceRoot, "package.json");
|
|
53
|
+
const sourcePackageJson = JSON.parse(readFileSync(sourcePackageJsonPath, "utf8"));
|
|
54
|
+
const binTarget = parseSingleBin(sourcePackageJson);
|
|
55
|
+
const binPath = join(sourceRoot, binTarget);
|
|
56
|
+
if (!existsSync(binPath)) fail(`source bin not found at ${binPath}`);
|
|
57
|
+
|
|
58
|
+
const firstLine = readFileSync(binPath, "utf8").split(/\r?\n/, 1)[0] ?? "";
|
|
59
|
+
const extension = extname(binPath).toLowerCase();
|
|
60
|
+
let runner = null;
|
|
61
|
+
if (firstLine.startsWith("#!")) {
|
|
62
|
+
if (firstLine.includes("bun")) runner = "bun";
|
|
63
|
+
else if (firstLine.includes("node")) runner = commandExists("node") ? "node" : commandExists("bun") ? "bun" : "node";
|
|
64
|
+
}
|
|
65
|
+
if (!runner) {
|
|
66
|
+
if ([".ts", ".tsx", ".cts", ".mts"].includes(extension)) runner = commandExists("bun") ? "bun" : "node";
|
|
67
|
+
else if ([".js", ".cjs", ".mjs"].includes(extension)) runner = commandExists("node") ? "node" : "bun";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const args = process.argv.slice(2);
|
|
71
|
+
const child = runner
|
|
72
|
+
? spawnSync(runner, [binPath, ...args], { stdio: "inherit" })
|
|
73
|
+
: spawnSync(binPath, args, { stdio: "inherit" });
|
|
74
|
+
|
|
75
|
+
if (child.error) fail(child.error.message);
|
|
76
|
+
if (typeof child.status === "number") process.exit(child.status);
|
|
77
|
+
process.exit(1);
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "roomshare",
|
|
3
|
+
"version": "0.1.13",
|
|
4
|
+
"description": "Thin Bun wrapper for @elefunc/send.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "bun@1.3.11",
|
|
8
|
+
"engines": {
|
|
9
|
+
"bun": ">=1.3.11"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"roomshare": "./bin/roomshare.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"README.md",
|
|
17
|
+
"package.json"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@elefunc/send": "0.1.13"
|
|
24
|
+
}
|
|
25
|
+
}
|