@replaystage/cli 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 +48 -2
- package/bin/replaystage.js +23 -0
- package/dist/index.d.ts +172 -0
- package/dist/index.js +5957 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/package.json +52 -3
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @replaystage/cli (`replaystage`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Deploy, validate, and iterate playable web games on **ReplayStage** (`replaystage.com` & `replay.st`) directly from your terminal or autonomous AI coding agents (Antigravity, Claude Code, Cursor, Gemini CLI).
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Pre-flight offline validation (checks index.html, bundle size <= 25MB, and prohibited files)
|
|
9
|
+
npx -y replaystage validate ./dist --json
|
|
10
|
+
|
|
11
|
+
# 2. Publish as a playable draft preview (zero login required)
|
|
12
|
+
npx -y replaystage publish ./dist \
|
|
13
|
+
--title "Neon Drift '86" \
|
|
14
|
+
--tagline "Synthwave endless drift arcade" \
|
|
15
|
+
--tool antigravity \
|
|
16
|
+
--category racing \
|
|
17
|
+
--aspect-ratio 16:9 \
|
|
18
|
+
--draft \
|
|
19
|
+
--json
|
|
20
|
+
|
|
21
|
+
# 3. Push an incremental update to the same URL (.replaystage.json)
|
|
22
|
+
npx -y replaystage publish ./dist --changelog "Tuned drift physics" --json
|
|
23
|
+
|
|
24
|
+
# 4. Promote draft to the public arcade leaderboard
|
|
25
|
+
npx -y replaystage publish ./dist --public --changelog "v1.0 Launch" --json
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Responsive Aspect Ratio & Screen Formats
|
|
29
|
+
|
|
30
|
+
ReplayStage automatically conforms game stages to specified aspect ratios:
|
|
31
|
+
|
|
32
|
+
- **Presets**: `auto` (fluid responsive), `16:9`, `9:16` (vertical/mobile), `4:3`, `3:4`, `1:1`.
|
|
33
|
+
- **Custom Ratio**: `W:H` or `W/H` (e.g. `21:9`, `5:3`, `800:600`), bounded between `1:4` (0.25) and `4:1` (4.0).
|
|
34
|
+
- **HTML Meta Tag**: Declare in your entry `index.html` `<head>` for automatic detection:
|
|
35
|
+
```html
|
|
36
|
+
<meta name="replaystage:aspect-ratio" content="9:16">
|
|
37
|
+
```
|
|
38
|
+
- **CLI Flag Priority**: Explicit `--aspect-ratio <ratio>` overrides the HTML `<meta>` tag, which overrides the default `auto`. Persisted in `.replaystage.json`.
|
|
39
|
+
|
|
40
|
+
## Creator Authentication (`rps_...` API Tokens)
|
|
41
|
+
|
|
42
|
+
Generate a Personal API Token in `https://replaystage.com/settings` to bind all CLI & AI agent deployments directly to your `@handle`:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx -y replaystage login --token rps_<your_token>
|
|
46
|
+
npx -y replaystage whoami
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or pass `REPLAYSTAGE_TOKEN=rps_<your_token>` in CI / agent environments.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const distPath = path.resolve(__dirname, "../dist/index.js");
|
|
9
|
+
|
|
10
|
+
// If dist artifact does not exist (e.g. dev testing before pnpm build), auto-build on-the-fly
|
|
11
|
+
if (!fs.existsSync(distPath)) {
|
|
12
|
+
const cliRoot = path.resolve(__dirname, "..");
|
|
13
|
+
try {
|
|
14
|
+
execFileSync("npx", ["tsup"], { cwd: cliRoot, stdio: "ignore" });
|
|
15
|
+
} catch {
|
|
16
|
+
// If auto-build fails, continue to let import report error
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const cliModule = await import(pathToFileURL(distPath).href);
|
|
21
|
+
if (typeof cliModule.runCli === "function") {
|
|
22
|
+
await cliModule.runCli(process.argv);
|
|
23
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
|
|
3
|
+
interface UserInfo {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
handle?: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
}
|
|
9
|
+
interface CliConfig {
|
|
10
|
+
apiUrl?: string;
|
|
11
|
+
token?: string;
|
|
12
|
+
user?: UserInfo;
|
|
13
|
+
}
|
|
14
|
+
declare function getConfigDir(): string;
|
|
15
|
+
declare function getConfigPath(): string;
|
|
16
|
+
declare function readConfig(): CliConfig;
|
|
17
|
+
declare function writeConfig(config: CliConfig): void;
|
|
18
|
+
declare function clearConfig(): void;
|
|
19
|
+
declare function getToken(): string | null;
|
|
20
|
+
declare function setToken(token: string, user?: UserInfo, apiUrl?: string): void;
|
|
21
|
+
declare function clearToken(): void;
|
|
22
|
+
declare function resolveToken(cliToken?: string): string | null;
|
|
23
|
+
declare function resolveApiUrl(cliApiUrl?: string): string;
|
|
24
|
+
|
|
25
|
+
declare function computeFingerprint(input: string | Buffer | Uint8Array): Promise<string>;
|
|
26
|
+
declare function computeFileFingerprint(filePath: string): Promise<string>;
|
|
27
|
+
|
|
28
|
+
interface PackagedBundle {
|
|
29
|
+
format: "single-html" | "directory" | "zip";
|
|
30
|
+
entryPoint: string;
|
|
31
|
+
fileCount: number;
|
|
32
|
+
totalBytes: number;
|
|
33
|
+
totalSizeBytes: number;
|
|
34
|
+
buffer: Buffer;
|
|
35
|
+
bundleBuffer: Buffer;
|
|
36
|
+
fileHash: string;
|
|
37
|
+
files: string[];
|
|
38
|
+
extractedTitle?: string;
|
|
39
|
+
extractedTagline?: string;
|
|
40
|
+
extractedAspectRatio?: string;
|
|
41
|
+
}
|
|
42
|
+
declare function extractHtmlMetadata(html: string): {
|
|
43
|
+
title?: string;
|
|
44
|
+
tagline?: string;
|
|
45
|
+
aspectRatio?: string;
|
|
46
|
+
rawAspectRatio?: string;
|
|
47
|
+
};
|
|
48
|
+
declare function computeSha256(buf: Buffer | Uint8Array): string;
|
|
49
|
+
declare function createZipFromFiles(fileMap: Record<string, Buffer>): Buffer;
|
|
50
|
+
declare function packageGame(targetPath: string): Promise<PackagedBundle>;
|
|
51
|
+
|
|
52
|
+
interface ValidationResult {
|
|
53
|
+
valid: boolean;
|
|
54
|
+
targetPath: string;
|
|
55
|
+
format?: string;
|
|
56
|
+
entryPoint?: string;
|
|
57
|
+
fileCount?: number;
|
|
58
|
+
totalSizeBytes?: number;
|
|
59
|
+
sha256?: string;
|
|
60
|
+
fileHash?: string;
|
|
61
|
+
files?: string[];
|
|
62
|
+
aspectRatio?: string;
|
|
63
|
+
errors: string[];
|
|
64
|
+
warnings: string[];
|
|
65
|
+
}
|
|
66
|
+
declare function checkHtmlDependencies(content: string): {
|
|
67
|
+
valid: boolean;
|
|
68
|
+
errors: string[];
|
|
69
|
+
};
|
|
70
|
+
declare function validateGamePackage(targetPath: string): Promise<ValidationResult>;
|
|
71
|
+
|
|
72
|
+
interface UploadBundleOptions {
|
|
73
|
+
apiUrl: string;
|
|
74
|
+
bundleBuffer: Buffer;
|
|
75
|
+
title: string;
|
|
76
|
+
tagline: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
aiTool: string;
|
|
79
|
+
category?: string;
|
|
80
|
+
token?: string | null;
|
|
81
|
+
fileHash?: string;
|
|
82
|
+
extraHeaders?: Record<string, string>;
|
|
83
|
+
submissionType?: "maker" | "hunter";
|
|
84
|
+
makerName?: string | null;
|
|
85
|
+
visibility?: string;
|
|
86
|
+
prompt?: string;
|
|
87
|
+
changelog?: string;
|
|
88
|
+
aspectRatio?: string;
|
|
89
|
+
errorMsgFallback?: string;
|
|
90
|
+
}
|
|
91
|
+
interface UploadResponse {
|
|
92
|
+
success: boolean;
|
|
93
|
+
slug: string;
|
|
94
|
+
url: string;
|
|
95
|
+
shortUrl?: string;
|
|
96
|
+
embedUrl?: string;
|
|
97
|
+
claim_token?: string;
|
|
98
|
+
claimToken?: string;
|
|
99
|
+
claimUrl?: string;
|
|
100
|
+
fileHash?: string;
|
|
101
|
+
isAnonymous?: boolean;
|
|
102
|
+
expiresAt?: string;
|
|
103
|
+
status?: string;
|
|
104
|
+
visibility?: string;
|
|
105
|
+
semver?: string;
|
|
106
|
+
versionNumber?: number;
|
|
107
|
+
promotedToPublic?: boolean;
|
|
108
|
+
error?: string;
|
|
109
|
+
message?: string;
|
|
110
|
+
data?: any;
|
|
111
|
+
}
|
|
112
|
+
type UploadResult = UploadResponse;
|
|
113
|
+
interface UpdateBundleOptions {
|
|
114
|
+
apiUrl?: string;
|
|
115
|
+
bundleBuffer?: Buffer;
|
|
116
|
+
title?: string;
|
|
117
|
+
tagline?: string;
|
|
118
|
+
description?: string;
|
|
119
|
+
visibility?: "draft" | "unlisted" | "public" | string;
|
|
120
|
+
changelog?: string;
|
|
121
|
+
aspectRatio?: string;
|
|
122
|
+
manageToken?: string;
|
|
123
|
+
token?: string | null;
|
|
124
|
+
errorMsgFallback?: string;
|
|
125
|
+
extraHeaders?: Record<string, string>;
|
|
126
|
+
}
|
|
127
|
+
type UpdateResponse = UploadResponse;
|
|
128
|
+
type UpdateResult = UpdateResponse;
|
|
129
|
+
declare function uploadGameBundle(options: UploadBundleOptions): Promise<UploadResponse>;
|
|
130
|
+
declare const uploadGame: typeof uploadGameBundle;
|
|
131
|
+
declare function updateGameBundle(slug: string, options: UpdateBundleOptions): Promise<UpdateResponse>;
|
|
132
|
+
declare const updateGame: typeof updateGameBundle;
|
|
133
|
+
declare function fetchWhoami(apiUrl: string, token: string): Promise<any>;
|
|
134
|
+
|
|
135
|
+
interface ProjectConfig {
|
|
136
|
+
slug: string;
|
|
137
|
+
manageToken?: string;
|
|
138
|
+
apiUrl?: string;
|
|
139
|
+
version: string;
|
|
140
|
+
title?: string;
|
|
141
|
+
updatedAt: string;
|
|
142
|
+
visibility?: "draft" | "unlisted" | "public" | string;
|
|
143
|
+
aspectRatio?: string;
|
|
144
|
+
}
|
|
145
|
+
declare function resolveProjectDirectory(targetPath: string): string | null;
|
|
146
|
+
declare function getProjectConfigPath(targetDir: string): string | null;
|
|
147
|
+
declare function readProjectConfig(targetDir: string): ProjectConfig | null;
|
|
148
|
+
declare function writeProjectConfig(targetDir: string, config: ProjectConfig): void;
|
|
149
|
+
declare function incrementVersion(currentVersion?: string): string;
|
|
150
|
+
declare function promoteDraftVersion(currentVersion?: string): string;
|
|
151
|
+
|
|
152
|
+
declare function printJson(data: any): void;
|
|
153
|
+
declare function printErrorJson(error: string, message: string, code?: number, extra?: Record<string, any>): void;
|
|
154
|
+
declare function logInfo(message: string, isJsonMode?: boolean): void;
|
|
155
|
+
declare function logSuccess(message: string, isJsonMode?: boolean): void;
|
|
156
|
+
declare function logWarn(message: string, isJsonMode?: boolean): void;
|
|
157
|
+
declare function logError(message: string, isJsonMode?: boolean): void;
|
|
158
|
+
declare function printPublishSuccess(res: {
|
|
159
|
+
title: string;
|
|
160
|
+
slug: string;
|
|
161
|
+
url: string;
|
|
162
|
+
shortUrl?: string;
|
|
163
|
+
claim_token?: string;
|
|
164
|
+
claimUrl?: string;
|
|
165
|
+
aiTool?: string;
|
|
166
|
+
fileHash?: string;
|
|
167
|
+
}): void;
|
|
168
|
+
|
|
169
|
+
declare function createProgram(): Command;
|
|
170
|
+
declare function runCli(argv?: string[]): Promise<void>;
|
|
171
|
+
|
|
172
|
+
export { type CliConfig, type PackagedBundle, type ProjectConfig, type UpdateBundleOptions, type UpdateResponse, type UpdateResult, type UploadBundleOptions, type UploadResponse, type UploadResult, type UserInfo, type ValidationResult, checkHtmlDependencies, clearConfig, clearToken, computeFileFingerprint, computeFingerprint, computeSha256, createProgram, createZipFromFiles, extractHtmlMetadata, fetchWhoami, getConfigDir, getConfigPath, getProjectConfigPath, getToken, incrementVersion, logError, logInfo, logSuccess, logWarn, packageGame, printErrorJson, printJson, printPublishSuccess, promoteDraftVersion, readConfig, readProjectConfig, resolveApiUrl, resolveProjectDirectory, resolveToken, runCli, setToken, updateGame, updateGameBundle, uploadGame, uploadGameBundle, validateGamePackage, writeConfig, writeProjectConfig };
|