@vividengine/fastio-cli 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.
Files changed (4) hide show
  1. package/README.md +36 -0
  2. package/install.js +95 -0
  3. package/package.json +38 -0
  4. package/run.js +21 -0
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @vividengine/fastio-cli
2
+
3
+ Command-line interface for the [Fast.io](https://fast.io) cloud storage platform.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @vividengine/fastio-cli
9
+ ```
10
+
11
+ Or run without installing:
12
+
13
+ ```bash
14
+ npx @vividengine/fastio-cli --help
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # Authenticate
21
+ fastio auth login
22
+
23
+ # List your organizations
24
+ fastio org list
25
+
26
+ # Upload a file
27
+ fastio upload file --workspace <ID> ./myfile.txt
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ See the [GitHub repository](https://github.com/MediaFire/fastio_cli) for full documentation.
33
+
34
+ ## License
35
+
36
+ Apache License 2.0
package/install.js ADDED
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execSync } = require("child_process");
5
+ const fs = require("fs");
6
+ const https = require("https");
7
+ const http = require("http");
8
+ const path = require("path");
9
+ const os = require("os");
10
+
11
+ const REPO = "MediaFire/fastio_cli";
12
+ const VERSION = require("./package.json").version;
13
+
14
+ const PLATFORM_MAP = {
15
+ "darwin-arm64": "fastio-darwin-arm64",
16
+ "darwin-x64": "fastio-darwin-x64",
17
+ "linux-arm64": "fastio-linux-arm64",
18
+ "linux-x64": "fastio-linux-x64",
19
+ "win32-x64": "fastio-windows-x64.exe",
20
+ };
21
+
22
+ function getPlatformKey() {
23
+ const platform = os.platform();
24
+ const arch = os.arch();
25
+ return `${platform}-${arch}`;
26
+ }
27
+
28
+ function getBinaryName() {
29
+ const key = getPlatformKey();
30
+ const name = PLATFORM_MAP[key];
31
+ if (!name) {
32
+ console.error(`Unsupported platform: ${key}`);
33
+ console.error(`Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`);
34
+ process.exit(1);
35
+ }
36
+ return name;
37
+ }
38
+
39
+ function getInstallDir() {
40
+ return path.dirname(require.resolve("./package.json"));
41
+ }
42
+
43
+ function getBinaryPath() {
44
+ const dir = getInstallDir();
45
+ const isWindows = os.platform() === "win32";
46
+ return path.join(dir, isWindows ? "fastio.exe" : "fastio");
47
+ }
48
+
49
+ function download(url) {
50
+ return new Promise((resolve, reject) => {
51
+ const client = url.startsWith("https") ? https : http;
52
+ client
53
+ .get(url, { headers: { "User-Agent": "fastio-cli-npm" } }, (res) => {
54
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
55
+ return download(res.headers.location).then(resolve, reject);
56
+ }
57
+ if (res.statusCode !== 200) {
58
+ return reject(new Error(`Download failed: HTTP ${res.statusCode}`));
59
+ }
60
+ const chunks = [];
61
+ res.on("data", (chunk) => chunks.push(chunk));
62
+ res.on("end", () => resolve(Buffer.concat(chunks)));
63
+ res.on("error", reject);
64
+ })
65
+ .on("error", reject);
66
+ });
67
+ }
68
+
69
+ async function main() {
70
+ const binaryName = getBinaryName();
71
+ const binaryPath = getBinaryPath();
72
+
73
+ if (fs.existsSync(binaryPath)) {
74
+ return;
75
+ }
76
+
77
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${binaryName}`;
78
+ console.log(`Downloading fastio v${VERSION} for ${getPlatformKey()}...`);
79
+
80
+ try {
81
+ const data = await download(url);
82
+ fs.writeFileSync(binaryPath, data);
83
+ fs.chmodSync(binaryPath, 0o755);
84
+ console.log(`Installed fastio to ${binaryPath}`);
85
+ } catch (err) {
86
+ console.error(`Failed to download fastio: ${err.message}`);
87
+ console.error(`URL: ${url}`);
88
+ console.error("");
89
+ console.error("You can download manually from:");
90
+ console.error(` https://github.com/${REPO}/releases`);
91
+ process.exit(1);
92
+ }
93
+ }
94
+
95
+ main();
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@vividengine/fastio-cli",
3
+ "version": "0.1.0",
4
+ "description": "Command-line interface for the Fast.io cloud storage platform",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/MediaFire/fastio_cli"
9
+ },
10
+ "homepage": "https://fast.io",
11
+ "keywords": [
12
+ "cli",
13
+ "cloud-storage",
14
+ "fast-io",
15
+ "file-management",
16
+ "mcp"
17
+ ],
18
+ "bin": {
19
+ "fastio": "run.js"
20
+ },
21
+ "scripts": {
22
+ "postinstall": "node install.js"
23
+ },
24
+ "files": [
25
+ "install.js",
26
+ "run.js",
27
+ "README.md"
28
+ ],
29
+ "os": [
30
+ "darwin",
31
+ "linux",
32
+ "win32"
33
+ ],
34
+ "cpu": [
35
+ "x64",
36
+ "arm64"
37
+ ]
38
+ }
package/run.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execFileSync } = require("child_process");
5
+ const path = require("path");
6
+ const os = require("os");
7
+
8
+ const dir = path.dirname(require.resolve("./package.json"));
9
+ const isWindows = os.platform() === "win32";
10
+ const binary = path.join(dir, isWindows ? "fastio.exe" : "fastio");
11
+
12
+ try {
13
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
14
+ } catch (err) {
15
+ if (err.status !== undefined) {
16
+ process.exit(err.status);
17
+ }
18
+ console.error(`Failed to run fastio: ${err.message}`);
19
+ console.error("Try reinstalling: npm install -g @vividengine/fastio-cli");
20
+ process.exit(1);
21
+ }