@replaystage/cli 2.0.0 → 2.1.1
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 +9 -6
- package/dist/commands/admin.js +6 -1
- package/dist/commands/auth.js +14 -4
- package/dist/commands/creator-publish.d.ts +5 -0
- package/dist/commands/creator-publish.js +315 -0
- package/dist/commands/creator-scaffold.d.ts +5 -0
- package/dist/commands/creator-scaffold.js +362 -0
- package/dist/commands/creator.d.ts +4 -6
- package/dist/commands/creator.js +77 -443
- package/dist/http.d.ts +4 -0
- package/dist/http.js +82 -44
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -5
- package/dist/manifest.d.ts +1 -0
- package/dist/manifest.js +49 -8
- package/dist/output.js +1 -1
- package/dist/validate.d.ts +2 -1
- package/dist/validate.js +53 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,18 +6,21 @@ Unified, zero-dependency agent-native CLI for **ReplayStage** ([replaystage.com]
|
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
# 1. Mint a personal API Key (RSKEY_...) at https://studio.replaystage.com/account
|
|
9
|
-
npx -y replaystage login --token
|
|
9
|
+
echo "RSKEY_..." | npx -y replaystage login --token-stdin --json
|
|
10
10
|
|
|
11
|
-
# 2. Initialize
|
|
11
|
+
# 2. Initialize manifest or sync latest @replaystage/sdk into your portrait game repo
|
|
12
12
|
npx -y replaystage init my-game --title "My Game" --zh "我的游戏" --genre arcade --json
|
|
13
|
+
npx -y replaystage sdk sync
|
|
13
14
|
|
|
14
|
-
# 3. Validate your build output offline
|
|
15
|
-
npx -y replaystage validate ./dist --json
|
|
15
|
+
# 3. Validate your build output offline (--strict fails on warnings)
|
|
16
|
+
npx -y replaystage validate ./dist --strict --json
|
|
16
17
|
|
|
17
|
-
# 4.
|
|
18
|
+
# 4. Dry-run or publish (new games default to unlisted preview; pass --live to publish publicly)
|
|
19
|
+
npx -y replaystage publish ./dist --dry-run --json
|
|
18
20
|
npx -y replaystage publish ./dist --json
|
|
19
21
|
|
|
20
|
-
# 5.
|
|
22
|
+
# 5. Update metadata/artwork without re-uploading the bundle, or promote to public Lobby
|
|
23
|
+
npx -y replaystage update my-game --json
|
|
21
24
|
npx -y replaystage visibility my-game live --json
|
|
22
25
|
```
|
|
23
26
|
|
package/dist/commands/admin.js
CHANGED
|
@@ -268,8 +268,10 @@ export async function cmdAdmin(args, opts) {
|
|
|
268
268
|
}
|
|
269
269
|
async function probeUrl(label, url) {
|
|
270
270
|
const started = Date.now();
|
|
271
|
+
const controller = new AbortController();
|
|
272
|
+
const timer = setTimeout(() => controller.abort(), 12_000);
|
|
271
273
|
try {
|
|
272
|
-
const res = await fetch(url, { redirect: 'manual' });
|
|
274
|
+
const res = await fetch(url, { redirect: 'manual', signal: controller.signal });
|
|
273
275
|
const ms = Date.now() - started;
|
|
274
276
|
const ok = res.status >= 200 && res.status < 400;
|
|
275
277
|
let extra = '';
|
|
@@ -294,6 +296,9 @@ async function probeUrl(label, url) {
|
|
|
294
296
|
extra: err instanceof Error ? err.message : String(err),
|
|
295
297
|
};
|
|
296
298
|
}
|
|
299
|
+
finally {
|
|
300
|
+
clearTimeout(timer);
|
|
301
|
+
}
|
|
297
302
|
}
|
|
298
303
|
export async function cmdAudit(args, opts) {
|
|
299
304
|
const liveFlag = extractBoolFlag(args, ['--live']);
|
package/dist/commands/auth.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { clearStoredToken, getConfigFilePath, readStoredConfig, requireAuthToken, resolveApiBase, writeStoredConfig, } from '../config.js';
|
|
2
2
|
import { apiRequestJson } from '../http.js';
|
|
3
|
-
import { CliError, assertNoUnknownFlags, emitSuccess, extractFlag, } from '../output.js';
|
|
3
|
+
import { CliError, assertNoUnknownFlags, emitSuccess, extractBoolFlag, extractFlag, } from '../output.js';
|
|
4
|
+
async function readTokenFromStdin() {
|
|
5
|
+
const chunks = [];
|
|
6
|
+
for await (const chunk of process.stdin) {
|
|
7
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
|
|
8
|
+
}
|
|
9
|
+
return Buffer.concat(chunks).toString('utf8').trim();
|
|
10
|
+
}
|
|
4
11
|
export async function cmdLogin(args, opts) {
|
|
5
|
-
const
|
|
12
|
+
const stdinFlag = extractBoolFlag(args, ['--token-stdin']);
|
|
13
|
+
const { value: flagToken, rest } = extractFlag(stdinFlag.rest, ['--token', '-t']);
|
|
6
14
|
assertNoUnknownFlags(rest);
|
|
7
|
-
const token =
|
|
15
|
+
const token = stdinFlag.present
|
|
16
|
+
? await readTokenFromStdin()
|
|
17
|
+
: (flagToken || opts.token || rest[0] || '').trim();
|
|
8
18
|
if (!token) {
|
|
9
|
-
throw new CliError('INVALID_ARGUMENTS', 'Usage: replaystage login --token <RSKEY_...> [--api <url>] [--json]');
|
|
19
|
+
throw new CliError('INVALID_ARGUMENTS', 'Usage: replaystage login --token <RSKEY_...> | --token-stdin [--api <url>] [--json]');
|
|
10
20
|
}
|
|
11
21
|
if (!token.startsWith('RSKEY_') && !token.startsWith('RSSESS_')) {
|
|
12
22
|
throw new CliError('INVALID_TOKEN_FORMAT', 'Expected an account API key starting with "RSKEY_" (mint one at https://studio.replaystage.com/account).');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GlobalOptions } from '../output.js';
|
|
2
|
+
export declare function cmdValidate(args: string[], opts: GlobalOptions): Promise<void>;
|
|
3
|
+
export declare function cmdPublish(args: string[], opts: GlobalOptions): Promise<void>;
|
|
4
|
+
export declare function cmdReleases(args: string[], opts: GlobalOptions): Promise<void>;
|
|
5
|
+
export declare function cmdRollback(args: string[], opts: GlobalOptions): Promise<void>;
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { DEFAULT_PORTAL_ORIGIN, DEFAULT_STUDIO_ORIGIN, requireAuthToken, resolveApiBase, } from '../config.js';
|
|
3
|
+
import { apiRequestJson } from '../http.js';
|
|
4
|
+
import { SLUG_RE, VALID_CREATOR_VISIBILITIES } from '../manifest.js';
|
|
5
|
+
import { CliError, assertNoUnknownFlags, emitSuccess, extractBoolFlag, extractFlag, } from '../output.js';
|
|
6
|
+
import { validateProjectBundle } from '../validate.js';
|
|
7
|
+
import { formatBytes } from './creator-scaffold.js';
|
|
8
|
+
async function runPool(items, concurrency, worker) {
|
|
9
|
+
let cursor = 0;
|
|
10
|
+
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
11
|
+
while (cursor < items.length) {
|
|
12
|
+
const idx = cursor;
|
|
13
|
+
cursor += 1;
|
|
14
|
+
const item = items[idx];
|
|
15
|
+
if (item !== undefined) {
|
|
16
|
+
await worker(item);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
await Promise.all(workers);
|
|
21
|
+
}
|
|
22
|
+
export async function cmdValidate(args, opts) {
|
|
23
|
+
let rest = args;
|
|
24
|
+
const manifestFlag = extractFlag(rest, ['--manifest', '-m']);
|
|
25
|
+
rest = manifestFlag.rest;
|
|
26
|
+
const versionFlag = extractFlag(rest, ['--version']);
|
|
27
|
+
rest = versionFlag.rest;
|
|
28
|
+
const strictFlag = extractBoolFlag(rest, ['--strict']);
|
|
29
|
+
rest = strictFlag.rest;
|
|
30
|
+
assertNoUnknownFlags(rest);
|
|
31
|
+
const distDir = rest[0] || 'dist';
|
|
32
|
+
const report = await validateProjectBundle({
|
|
33
|
+
cwd: opts.cwd,
|
|
34
|
+
distDir,
|
|
35
|
+
manifestPath: manifestFlag.value,
|
|
36
|
+
versionOverride: versionFlag.value,
|
|
37
|
+
});
|
|
38
|
+
if (strictFlag.present && report.warnings.length > 0) {
|
|
39
|
+
throw new CliError('VALIDATION_WARNINGS', `Strict validation failed with ${report.warnings.length} warning(s). Resolve all warnings or omit --strict.`, {
|
|
40
|
+
details: {
|
|
41
|
+
slug: report.slug,
|
|
42
|
+
version: report.version,
|
|
43
|
+
warnings: report.warnings,
|
|
44
|
+
errors: report.warnings,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
emitSuccess(opts, {
|
|
49
|
+
slug: report.slug,
|
|
50
|
+
version: report.version,
|
|
51
|
+
manifestPath: report.manifestPath,
|
|
52
|
+
distDir: report.distDir,
|
|
53
|
+
entryPath: report.entryPath,
|
|
54
|
+
fileCount: report.fileCount,
|
|
55
|
+
totalBytes: report.totalBytes,
|
|
56
|
+
media: report.media.map(m => ({ slot: m.slot, filename: m.filename, bytes: m.bytes })),
|
|
57
|
+
warnings: report.warnings,
|
|
58
|
+
}, () => {
|
|
59
|
+
const lines = [
|
|
60
|
+
`Valid ReplayStage bundle: ${report.slug} v${report.version}`,
|
|
61
|
+
` Manifest: ${report.manifestPath}`,
|
|
62
|
+
` Dist: ${report.distDir} (${report.fileCount} files, ${formatBytes(report.totalBytes)}, entry ${report.entryPath})`,
|
|
63
|
+
];
|
|
64
|
+
if (report.media.length > 0) {
|
|
65
|
+
lines.push(` Media: ${report.media.map(m => `${m.slot}=${m.filename}`).join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
for (const w of report.warnings) {
|
|
68
|
+
lines.push(` [WARN] ${w}`);
|
|
69
|
+
}
|
|
70
|
+
return lines;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export async function cmdPublish(args, opts) {
|
|
74
|
+
let rest = args;
|
|
75
|
+
const manifestFlag = extractFlag(rest, ['--manifest', '-m']);
|
|
76
|
+
rest = manifestFlag.rest;
|
|
77
|
+
const versionFlag = extractFlag(rest, ['--version']);
|
|
78
|
+
rest = versionFlag.rest;
|
|
79
|
+
const visFlag = extractFlag(rest, ['--visibility']);
|
|
80
|
+
rest = visFlag.rest;
|
|
81
|
+
const unlistedFlag = extractBoolFlag(rest, ['--unlisted']);
|
|
82
|
+
rest = unlistedFlag.rest;
|
|
83
|
+
const liveFlag = extractBoolFlag(rest, ['--live']);
|
|
84
|
+
rest = liveFlag.rest;
|
|
85
|
+
const betaFlag = extractBoolFlag(rest, ['--beta']);
|
|
86
|
+
rest = betaFlag.rest;
|
|
87
|
+
const hiddenFlag = extractBoolFlag(rest, ['--hidden']);
|
|
88
|
+
rest = hiddenFlag.rest;
|
|
89
|
+
const skipHealthFlag = extractBoolFlag(rest, ['--skip-health']);
|
|
90
|
+
rest = skipHealthFlag.rest;
|
|
91
|
+
const dryRunFlag = extractBoolFlag(rest, ['--dry-run']);
|
|
92
|
+
rest = dryRunFlag.rest;
|
|
93
|
+
assertNoUnknownFlags(rest);
|
|
94
|
+
const selectedVisFlags = [
|
|
95
|
+
visFlag.value,
|
|
96
|
+
unlistedFlag.present ? 'unlisted' : undefined,
|
|
97
|
+
liveFlag.present ? 'live' : undefined,
|
|
98
|
+
betaFlag.present ? 'beta' : undefined,
|
|
99
|
+
hiddenFlag.present ? 'hidden' : undefined,
|
|
100
|
+
].filter((v) => Boolean(v));
|
|
101
|
+
if (selectedVisFlags.length > 1) {
|
|
102
|
+
throw new CliError('INVALID_ARGUMENTS', 'Specify at most one visibility flag (--unlisted, --live, --beta, --hidden, or --visibility).');
|
|
103
|
+
}
|
|
104
|
+
const explicitVisibility = selectedVisFlags[0];
|
|
105
|
+
if (explicitVisibility &&
|
|
106
|
+
!VALID_CREATOR_VISIBILITIES.includes(explicitVisibility)) {
|
|
107
|
+
throw new CliError('INVALID_ARGUMENTS', `Invalid visibility "${explicitVisibility}". Allowed: ${VALID_CREATOR_VISIBILITIES.join(', ')}.`);
|
|
108
|
+
}
|
|
109
|
+
const distDir = rest[0] || 'dist';
|
|
110
|
+
// 1. Offline preflight validation (fail fast before touching network!)
|
|
111
|
+
const report = await validateProjectBundle({
|
|
112
|
+
cwd: opts.cwd,
|
|
113
|
+
distDir,
|
|
114
|
+
manifestPath: manifestFlag.value,
|
|
115
|
+
versionOverride: versionFlag.value,
|
|
116
|
+
});
|
|
117
|
+
if (dryRunFlag.present) {
|
|
118
|
+
emitSuccess(opts, {
|
|
119
|
+
dryRun: true,
|
|
120
|
+
slug: report.slug,
|
|
121
|
+
version: report.version,
|
|
122
|
+
visibility: explicitVisibility ?? 'unlisted (new) / preserve (existing)',
|
|
123
|
+
entryPath: report.entryPath,
|
|
124
|
+
bundle: { fileCount: report.fileCount, totalBytes: report.totalBytes },
|
|
125
|
+
media: report.media.map(m => ({ slot: m.slot, filename: m.filename, bytes: m.bytes })),
|
|
126
|
+
warnings: report.warnings,
|
|
127
|
+
}, () => {
|
|
128
|
+
const lines = [
|
|
129
|
+
`[DRY RUN] Would publish ${report.slug} v${report.version}`,
|
|
130
|
+
` Dist: ${report.distDir} (${report.fileCount} files, ${formatBytes(report.totalBytes)}, entry ${report.entryPath})`,
|
|
131
|
+
` Media: ${report.media.length > 0 ? report.media.map(m => `${m.slot}=${m.filename}`).join(', ') : '(none discovered)'}`,
|
|
132
|
+
` Visibility: ${explicitVisibility ?? 'unlisted (new) / preserve (existing)'}`,
|
|
133
|
+
];
|
|
134
|
+
for (const w of report.warnings) {
|
|
135
|
+
lines.push(` [WARN] ${w}`);
|
|
136
|
+
}
|
|
137
|
+
return lines;
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const apiBase = await resolveApiBase(opts.apiBase);
|
|
142
|
+
const token = await requireAuthToken({
|
|
143
|
+
flagToken: opts.token,
|
|
144
|
+
allowPublishEnvFallback: true,
|
|
145
|
+
cwd: opts.cwd,
|
|
146
|
+
});
|
|
147
|
+
const slug = report.slug;
|
|
148
|
+
const version = report.version;
|
|
149
|
+
let createdSlot = false;
|
|
150
|
+
// 2. If using an account key (RSKEY_ / RSSESS_), auto-register the game slot when new
|
|
151
|
+
if (token.startsWith('RSKEY_') || token.startsWith('RSSESS_')) {
|
|
152
|
+
const owned = await apiRequestJson({
|
|
153
|
+
apiBase,
|
|
154
|
+
method: 'GET',
|
|
155
|
+
path: '/v1/creator/games',
|
|
156
|
+
token,
|
|
157
|
+
});
|
|
158
|
+
const existsInAccount = (owned.games ?? []).some(g => g.slug === slug);
|
|
159
|
+
if (!existsInAccount) {
|
|
160
|
+
await apiRequestJson({
|
|
161
|
+
apiBase,
|
|
162
|
+
method: 'POST',
|
|
163
|
+
path: '/v1/creator/games',
|
|
164
|
+
token,
|
|
165
|
+
body: {
|
|
166
|
+
slug,
|
|
167
|
+
titleEn: report.manifest.locales.en.title,
|
|
168
|
+
titleZh: report.manifest.locales['zh-Hans'].title,
|
|
169
|
+
genre: report.manifest.genre,
|
|
170
|
+
accentColor: report.manifest.accentColor,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
createdSlot = true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// 3. Upload immutable bundle files concurrently
|
|
177
|
+
await runPool(report.files, 8, async (file) => {
|
|
178
|
+
const bytes = await readFile(file.absPath);
|
|
179
|
+
const encodedRel = file.relPath.split('/').map(encodeURIComponent).join('/');
|
|
180
|
+
await apiRequestJson({
|
|
181
|
+
apiBase,
|
|
182
|
+
method: 'PUT',
|
|
183
|
+
path: `/v1/publish/${encodeURIComponent(slug)}/files/${encodeURIComponent(version)}/${encodedRel}`,
|
|
184
|
+
token,
|
|
185
|
+
rawBody: bytes,
|
|
186
|
+
contentType: file.contentType,
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
// 4. Upload discovered local artwork (<= 2 MB each) and rewrite local refs to canonical /media/<slug>/<file>
|
|
190
|
+
const mediaUploaded = [];
|
|
191
|
+
const releaseManifest = {
|
|
192
|
+
...report.manifest,
|
|
193
|
+
artwork: { ...report.manifest.artwork },
|
|
194
|
+
};
|
|
195
|
+
for (const media of report.media) {
|
|
196
|
+
const bytes = await readFile(media.absPath);
|
|
197
|
+
const uploaded = await apiRequestJson({
|
|
198
|
+
apiBase,
|
|
199
|
+
method: 'PUT',
|
|
200
|
+
path: `/v1/publish/${encodeURIComponent(slug)}/media/${encodeURIComponent(media.filename)}`,
|
|
201
|
+
token,
|
|
202
|
+
rawBody: bytes,
|
|
203
|
+
contentType: media.contentType,
|
|
204
|
+
});
|
|
205
|
+
const canonicalUrl = uploaded.url || `/media/${slug}/${media.filename}`;
|
|
206
|
+
releaseManifest.artwork[media.slot] = canonicalUrl;
|
|
207
|
+
mediaUploaded.push(canonicalUrl);
|
|
208
|
+
}
|
|
209
|
+
// 5. Finalize atomic pointer release
|
|
210
|
+
const releaseRes = await apiRequestJson({
|
|
211
|
+
apiBase,
|
|
212
|
+
method: 'POST',
|
|
213
|
+
path: `/v1/publish/${encodeURIComponent(slug)}/release`,
|
|
214
|
+
token,
|
|
215
|
+
body: {
|
|
216
|
+
version,
|
|
217
|
+
manifest: releaseManifest,
|
|
218
|
+
fileCount: report.fileCount,
|
|
219
|
+
totalBytes: report.totalBytes,
|
|
220
|
+
...(explicitVisibility ? { visibility: explicitVisibility } : {}),
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
// 6. Verify live edge health unless skipped
|
|
224
|
+
let health = null;
|
|
225
|
+
if (!skipHealthFlag.present && releaseRes.origin) {
|
|
226
|
+
const controller = new AbortController();
|
|
227
|
+
const timer = setTimeout(() => controller.abort(), 10_000);
|
|
228
|
+
try {
|
|
229
|
+
const probe = await fetch(`${releaseRes.origin}/_rs/health`, { signal: controller.signal });
|
|
230
|
+
health = { ok: probe.ok, status: probe.status };
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
health = { ok: false, status: 0 };
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
clearTimeout(timer);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const playUrl = releaseRes.playUrl || `${DEFAULT_PORTAL_ORIGIN}/play/${slug}`;
|
|
240
|
+
const studioUrl = `${DEFAULT_STUDIO_ORIGIN}/games/${slug}`;
|
|
241
|
+
const emulatorUrl = `${DEFAULT_STUDIO_ORIGIN}/emulator?game=${encodeURIComponent(slug)}`;
|
|
242
|
+
emitSuccess(opts, {
|
|
243
|
+
slug,
|
|
244
|
+
version,
|
|
245
|
+
releaseId: releaseRes.releaseId,
|
|
246
|
+
visibility: releaseRes.visibility,
|
|
247
|
+
createdSlot,
|
|
248
|
+
playUrl,
|
|
249
|
+
origin: releaseRes.origin,
|
|
250
|
+
studioUrl,
|
|
251
|
+
emulatorUrl,
|
|
252
|
+
bundle: releaseRes.bundle ?? { fileCount: report.fileCount, totalBytes: report.totalBytes },
|
|
253
|
+
mediaUploaded,
|
|
254
|
+
health,
|
|
255
|
+
warnings: report.warnings,
|
|
256
|
+
}, () => {
|
|
257
|
+
const lines = [
|
|
258
|
+
`Published ${slug} v${version} (${releaseRes.visibility})`,
|
|
259
|
+
` Play URL: ${playUrl}`,
|
|
260
|
+
` Game Origin: ${releaseRes.origin}`,
|
|
261
|
+
` Emulator: ${emulatorUrl}`,
|
|
262
|
+
` Bundle: ${report.fileCount} files (${formatBytes(report.totalBytes)})`,
|
|
263
|
+
` Media: ${mediaUploaded.length > 0 ? mediaUploaded.join(', ') : '(none uploaded)'}`,
|
|
264
|
+
];
|
|
265
|
+
if (releaseRes.visibility === 'unlisted') {
|
|
266
|
+
lines.push(` Preview: Unlisted (noindex, direct-link playable). Promote when ready with: replaystage visibility ${slug} live`);
|
|
267
|
+
}
|
|
268
|
+
for (const w of report.warnings) {
|
|
269
|
+
lines.push(` [WARN] ${w}`);
|
|
270
|
+
}
|
|
271
|
+
return lines;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
export async function cmdReleases(args, opts) {
|
|
275
|
+
assertNoUnknownFlags(args);
|
|
276
|
+
const slug = args[0]?.trim().toLowerCase();
|
|
277
|
+
if (!slug || !SLUG_RE.test(slug)) {
|
|
278
|
+
throw new CliError('INVALID_ARGUMENTS', 'Usage: replaystage releases <slug> [--json]');
|
|
279
|
+
}
|
|
280
|
+
const apiBase = await resolveApiBase(opts.apiBase);
|
|
281
|
+
const token = await requireAuthToken({ flagToken: opts.token, cwd: opts.cwd });
|
|
282
|
+
const data = await apiRequestJson({
|
|
283
|
+
apiBase,
|
|
284
|
+
method: 'GET',
|
|
285
|
+
path: `/v1/creator/games/${encodeURIComponent(slug)}/releases`,
|
|
286
|
+
token,
|
|
287
|
+
});
|
|
288
|
+
emitSuccess(opts, { slug, releases: data.releases }, () => [
|
|
289
|
+
`Releases for ${slug}:`,
|
|
290
|
+
...(data.releases.length === 0
|
|
291
|
+
? [' (no releases published yet)']
|
|
292
|
+
: data.releases.map(r => ` v${r.version.padEnd(14)} ${r.status.padEnd(10)} ${String(r.fileCount).padStart(4)} files ${formatBytes(r.totalBytes).padEnd(10)} ${r.createdAt}`)),
|
|
293
|
+
]);
|
|
294
|
+
}
|
|
295
|
+
export async function cmdRollback(args, opts) {
|
|
296
|
+
assertNoUnknownFlags(args);
|
|
297
|
+
const [slugRaw, versionRaw] = args;
|
|
298
|
+
const slug = slugRaw?.trim().toLowerCase();
|
|
299
|
+
const version = versionRaw?.trim();
|
|
300
|
+
if (!slug || !SLUG_RE.test(slug) || !version) {
|
|
301
|
+
throw new CliError('INVALID_ARGUMENTS', 'Usage: replaystage rollback <slug> <version> [--json]');
|
|
302
|
+
}
|
|
303
|
+
const apiBase = await resolveApiBase(opts.apiBase);
|
|
304
|
+
const token = await requireAuthToken({ flagToken: opts.token, cwd: opts.cwd });
|
|
305
|
+
const res = await apiRequestJson({
|
|
306
|
+
apiBase,
|
|
307
|
+
method: 'POST',
|
|
308
|
+
path: `/v1/creator/games/${encodeURIComponent(slug)}/rollback`,
|
|
309
|
+
token,
|
|
310
|
+
body: { version },
|
|
311
|
+
});
|
|
312
|
+
emitSuccess(opts, { slug, version, ...res }, () => [
|
|
313
|
+
`Rolled back ${slug} to v${version}.`,
|
|
314
|
+
]);
|
|
315
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GlobalOptions } from '../output.js';
|
|
2
|
+
export declare function formatBytes(bytes: number): string;
|
|
3
|
+
export declare function cmdInit(args: string[], opts: GlobalOptions): Promise<void>;
|
|
4
|
+
export declare function cmdCreateGame(args: string[], opts: GlobalOptions): Promise<void>;
|
|
5
|
+
export declare function cmdSdk(args: string[], opts: GlobalOptions): Promise<void>;
|