tinyship 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 ADDED
@@ -0,0 +1,11 @@
1
+ # Tinyship CLI
2
+
3
+ Deploy static frontend projects to Tinyship.
4
+
5
+ ```bash
6
+ npx tinyship login
7
+ npx tinyship deploy
8
+ ```
9
+
10
+ This package is a small launcher. The matching native binary is installed through platform-specific optional dependencies.
11
+
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+ const { existsSync } = require("node:fs");
6
+ const { dirname, join } = require("node:path");
7
+
8
+ const packageByPlatform = {
9
+ "linux-x64": "tinyship-cli-linux-x64",
10
+ "linux-arm64": "tinyship-cli-linux-arm64",
11
+ "darwin-x64": "tinyship-cli-darwin-x64",
12
+ "darwin-arm64": "tinyship-cli-darwin-arm64",
13
+ "win32-x64": "tinyship-cli-win32-x64",
14
+ "win32-arm64": "tinyship-cli-win32-arm64"
15
+ };
16
+
17
+ if (process.argv.includes("--version") || process.argv.includes("-v")) {
18
+ const pkg = require("../package.json");
19
+ console.log(pkg.version);
20
+ process.exit(0);
21
+ }
22
+
23
+ const platformKey = `${process.platform}-${process.arch}`;
24
+ const packageName = packageByPlatform[platformKey];
25
+
26
+ const fail = (message) => {
27
+ console.error(`tinyship: ${message}`);
28
+ process.exit(1);
29
+ };
30
+
31
+ const resolveBinary = () => {
32
+ if (process.env.TINYSHIP_CLI_BINARY) {
33
+ return process.env.TINYSHIP_CLI_BINARY;
34
+ }
35
+
36
+ if (!packageName) {
37
+ fail(`unsupported platform ${platformKey}`);
38
+ }
39
+
40
+ let packageJsonPath;
41
+ try {
42
+ packageJsonPath = require.resolve(`${packageName}/package.json`);
43
+ } catch {
44
+ fail(
45
+ `missing platform package ${packageName}. Reinstall with optional dependencies enabled.`
46
+ );
47
+ }
48
+
49
+ const binaryName = process.platform === "win32" ? "tinyship.exe" : "tinyship";
50
+ const binaryPath = join(dirname(packageJsonPath), "bin", binaryName);
51
+ if (!existsSync(binaryPath)) {
52
+ fail(`platform package ${packageName} is installed, but binary is missing`);
53
+ }
54
+ return binaryPath;
55
+ };
56
+
57
+ const result = spawnSync(resolveBinary(), process.argv.slice(2), {
58
+ stdio: "inherit",
59
+ windowsHide: false
60
+ });
61
+
62
+ if (result.error) {
63
+ fail(result.error.message);
64
+ }
65
+
66
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "tinyship",
3
+ "version": "0.1.0",
4
+ "description": "Tinyship CLI for deploying static frontends.",
5
+ "license": "MIT",
6
+ "homepage": "https://tinyship.run",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/tinyship/tinyship.git",
10
+ "directory": "tinyship-npm/packages/tinyship"
11
+ },
12
+ "bin": {
13
+ "tinyship": "./bin/tinyship.js"
14
+ },
15
+ "files": [
16
+ "bin",
17
+ "README.md"
18
+ ],
19
+ "engines": {
20
+ "node": ">=18"
21
+ }
22
+ }