@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/dist/http.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { CliError } from './output.js';
|
|
2
|
+
const RETRYABLE_STATUSES = new Set([408, 429, 500, 502, 503, 504]);
|
|
3
|
+
function delay(ms) {
|
|
4
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
5
|
+
}
|
|
6
|
+
function parseRetryAfterMs(header) {
|
|
7
|
+
if (!header)
|
|
8
|
+
return null;
|
|
9
|
+
const seconds = Number(header.trim());
|
|
10
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
11
|
+
return Math.min(10_000, Math.round(seconds * 1000));
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
2
15
|
export async function apiRequestJson(opts) {
|
|
3
16
|
const headers = {
|
|
4
17
|
Accept: 'application/json',
|
|
@@ -16,54 +29,79 @@ export async function apiRequestJson(opts) {
|
|
|
16
29
|
requestBody = JSON.stringify(opts.body);
|
|
17
30
|
}
|
|
18
31
|
const url = `${opts.apiBase.replace(/\/+$/, '')}${opts.path}`;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
headers,
|
|
24
|
-
body: requestBody,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
throw new CliError('NETWORK_ERROR', `Failed to reach ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
29
|
-
}
|
|
30
|
-
const text = await res.text();
|
|
31
|
-
let parsed = {};
|
|
32
|
-
if (text) {
|
|
32
|
+
const timeoutMs = opts.timeoutMs ?? (opts.rawBody !== undefined ? 45_000 : 25_000);
|
|
33
|
+
const maxRetries = opts.retries ?? (opts.method === 'POST' ? 0 : 2);
|
|
34
|
+
for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
|
|
35
|
+
let res;
|
|
33
36
|
try {
|
|
34
|
-
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
39
|
+
try {
|
|
40
|
+
res = await fetch(url, {
|
|
41
|
+
method: opts.method,
|
|
42
|
+
headers,
|
|
43
|
+
body: requestBody,
|
|
44
|
+
signal: controller.signal,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
}
|
|
35
50
|
}
|
|
36
|
-
catch {
|
|
37
|
-
|
|
51
|
+
catch (err) {
|
|
52
|
+
const isTimeout = err instanceof Error && err.name === 'AbortError';
|
|
53
|
+
if (attempt < maxRetries) {
|
|
54
|
+
await delay(350 * 2 ** attempt);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
throw new CliError(isTimeout ? 'REQUEST_TIMEOUT' : 'NETWORK_ERROR', isTimeout
|
|
58
|
+
? `Request timed out after ${timeoutMs}ms: ${opts.method} ${url}`
|
|
59
|
+
: `Failed to reach ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
38
60
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const details = {
|
|
54
|
-
method: opts.method,
|
|
55
|
-
path: opts.path,
|
|
56
|
-
};
|
|
57
|
-
if (Array.isArray(parsed.details)) {
|
|
58
|
-
details.errors = parsed.details;
|
|
61
|
+
if (!res.ok && RETRYABLE_STATUSES.has(res.status) && attempt < maxRetries) {
|
|
62
|
+
const retryMs = parseRetryAfterMs(res.headers.get('retry-after')) ?? 350 * 2 ** attempt;
|
|
63
|
+
await delay(retryMs);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const text = await res.text();
|
|
67
|
+
let parsed = {};
|
|
68
|
+
if (text) {
|
|
69
|
+
try {
|
|
70
|
+
parsed = JSON.parse(text);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
parsed = { raw: text };
|
|
74
|
+
}
|
|
59
75
|
}
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
if (!res.ok) {
|
|
77
|
+
const serverCode = typeof parsed.code === 'string' ? parsed.code : undefined;
|
|
78
|
+
const serverError = typeof parsed.error === 'string' ? parsed.error : `HTTP ${res.status}`;
|
|
79
|
+
const mappedCode = serverCode ||
|
|
80
|
+
(res.status === 401
|
|
81
|
+
? 'AUTH_INVALID'
|
|
82
|
+
: res.status === 403
|
|
83
|
+
? 'FORBIDDEN'
|
|
84
|
+
: res.status === 404
|
|
85
|
+
? 'NOT_FOUND'
|
|
86
|
+
: res.status === 409
|
|
87
|
+
? 'CONFLICT'
|
|
88
|
+
: `HTTP_${res.status}`);
|
|
89
|
+
const details = {
|
|
90
|
+
method: opts.method,
|
|
91
|
+
path: opts.path,
|
|
92
|
+
};
|
|
93
|
+
if (Array.isArray(parsed.details)) {
|
|
94
|
+
details.errors = parsed.details;
|
|
95
|
+
}
|
|
96
|
+
else if (parsed.details && typeof parsed.details === 'object') {
|
|
97
|
+
Object.assign(details, parsed.details);
|
|
98
|
+
}
|
|
99
|
+
throw new CliError(mappedCode, serverError, {
|
|
100
|
+
status: res.status,
|
|
101
|
+
details,
|
|
102
|
+
});
|
|
62
103
|
}
|
|
63
|
-
|
|
64
|
-
status: res.status,
|
|
65
|
-
details,
|
|
66
|
-
});
|
|
104
|
+
return parsed;
|
|
67
105
|
}
|
|
68
|
-
|
|
106
|
+
throw new CliError('NETWORK_ERROR', `Failed to complete request to ${url}`);
|
|
69
107
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OutputStreams } from './output.js';
|
|
2
|
-
export declare const CLI_VERSION
|
|
2
|
+
export declare const CLI_VERSION: string;
|
|
3
3
|
export { CliError } from './output.js';
|
|
4
4
|
export { validateManifestObject, buildStarterManifest } from './manifest.js';
|
|
5
5
|
export { validateProjectBundle } from './validate.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
1
2
|
import { cmdAdmin, cmdAudit, cmdCatalog, cmdDaily } from './commands/admin.js';
|
|
2
3
|
import { cmdLogin, cmdLogout, cmdWhoami } from './commands/auth.js';
|
|
3
|
-
import { cmdCreateGame, cmdGames, cmdInit, cmdPublish, cmdReleases, cmdRollback, cmdStats, cmdTokens, cmdValidate, cmdVisibility, } from './commands/creator.js';
|
|
4
|
+
import { cmdCreateGame, cmdDelete, cmdGames, cmdInit, cmdPublish, cmdReleases, cmdRollback, cmdSdk, cmdStats, cmdTokens, cmdUpdate, cmdValidate, cmdVisibility, } from './commands/creator.js';
|
|
4
5
|
import { CliError, DEFAULT_STREAMS, emitError, emitSuccess, extractBoolFlag, extractFlag, } from './output.js';
|
|
5
|
-
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const pkgJson = require('../package.json');
|
|
8
|
+
export const CLI_VERSION = pkgJson.version ?? '2.1.1';
|
|
6
9
|
export { CliError } from './output.js';
|
|
7
10
|
export { validateManifestObject, buildStarterManifest } from './manifest.js';
|
|
8
11
|
export { validateProjectBundle } from './validate.js';
|
|
@@ -17,15 +20,18 @@ Global Flags:
|
|
|
17
20
|
-v, --version Print CLI version
|
|
18
21
|
|
|
19
22
|
Authentication:
|
|
20
|
-
login --token <RSKEY_> Validate and save personal API key (
|
|
23
|
+
login --token <RSKEY_> Validate and save personal API key (also supports --token-stdin)
|
|
21
24
|
whoami Show authenticated creator identity, role, and scopes
|
|
22
25
|
logout Clear saved local credentials
|
|
23
26
|
|
|
24
27
|
Creator Workflow:
|
|
25
28
|
init <slug> Create starter replaystage.manifest.json in the current directory
|
|
26
29
|
create-game <slug> Scaffold a complete Tier 2 portrait starter game project
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
sdk sync [dir] Download latest @replaystage/sdk ESM bundle & .d.ts into src/sdk
|
|
31
|
+
validate [distDir] Run offline preflight checks (--strict fails on warnings)
|
|
32
|
+
publish [distDir] Upload immutable bundle + media (--dry-run previews without upload)
|
|
33
|
+
update [slug] Sync manifest metadata & artwork without re-uploading bundle
|
|
34
|
+
delete <slug> --yes Delete a game slot and revoke its CI tokens
|
|
29
35
|
games List your registered games
|
|
30
36
|
releases <slug> List immutable release history
|
|
31
37
|
rollback <slug> <ver> Atomically switch live pointer back to a previous version
|
|
@@ -77,8 +83,11 @@ export async function runCli(rawArgs, runtime = {}) {
|
|
|
77
83
|
'logout',
|
|
78
84
|
'init',
|
|
79
85
|
'create-game',
|
|
86
|
+
'sdk',
|
|
80
87
|
'validate',
|
|
81
88
|
'publish',
|
|
89
|
+
'update',
|
|
90
|
+
'delete',
|
|
82
91
|
'games',
|
|
83
92
|
'releases',
|
|
84
93
|
'rollback',
|
|
@@ -109,12 +118,21 @@ export async function runCli(rawArgs, runtime = {}) {
|
|
|
109
118
|
case 'create-game':
|
|
110
119
|
await cmdCreateGame(cmdArgs, opts);
|
|
111
120
|
break;
|
|
121
|
+
case 'sdk':
|
|
122
|
+
await cmdSdk(cmdArgs, opts);
|
|
123
|
+
break;
|
|
112
124
|
case 'validate':
|
|
113
125
|
await cmdValidate(cmdArgs, opts);
|
|
114
126
|
break;
|
|
115
127
|
case 'publish':
|
|
116
128
|
await cmdPublish(cmdArgs, opts);
|
|
117
129
|
break;
|
|
130
|
+
case 'update':
|
|
131
|
+
await cmdUpdate(cmdArgs, opts);
|
|
132
|
+
break;
|
|
133
|
+
case 'delete':
|
|
134
|
+
await cmdDelete(cmdArgs, opts);
|
|
135
|
+
break;
|
|
118
136
|
case 'games':
|
|
119
137
|
await cmdGames(cmdArgs, opts);
|
|
120
138
|
break;
|
package/dist/manifest.d.ts
CHANGED
package/dist/manifest.js
CHANGED
|
@@ -24,14 +24,39 @@ export function slugToTitle(slug) {
|
|
|
24
24
|
function isNonEmptyString(val) {
|
|
25
25
|
return typeof val === 'string' && val.trim().length > 0;
|
|
26
26
|
}
|
|
27
|
+
function isSafeHttpUrl(val) {
|
|
28
|
+
if (val.length === 0 || val.length > 300)
|
|
29
|
+
return false;
|
|
30
|
+
try {
|
|
31
|
+
const u = new URL(val);
|
|
32
|
+
return u.protocol === 'https:' || u.protocol === 'http:';
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function isSafeArtworkRef(val) {
|
|
39
|
+
if (!isNonEmptyString(val) || val.length > 256)
|
|
40
|
+
return false;
|
|
41
|
+
const trimmed = val.trim();
|
|
42
|
+
if (/[\u0000-\u001f\u007f]/.test(trimmed))
|
|
43
|
+
return false;
|
|
44
|
+
if (trimmed.startsWith('https://'))
|
|
45
|
+
return isSafeHttpUrl(trimmed);
|
|
46
|
+
if (trimmed.startsWith('//') || trimmed.includes('..') || trimmed.includes('\\'))
|
|
47
|
+
return false;
|
|
48
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed))
|
|
49
|
+
return false;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
27
52
|
export function validateManifestObject(raw) {
|
|
28
53
|
const errors = [];
|
|
29
54
|
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
30
55
|
return { valid: false, errors: ['Manifest must be a JSON object'] };
|
|
31
56
|
}
|
|
32
57
|
const m = raw;
|
|
33
|
-
if (!isNonEmptyString(m.slug) || !SLUG_RE.test(m.slug) || m.slug.length <
|
|
34
|
-
errors.push('slug must be
|
|
58
|
+
if (!isNonEmptyString(m.slug) || !SLUG_RE.test(m.slug) || m.slug.length < 2 || m.slug.length > 40) {
|
|
59
|
+
errors.push('slug must be 2-40 chars lowercase kebab-case (e.g. "neon-stack")');
|
|
35
60
|
}
|
|
36
61
|
if (!isNonEmptyString(m.version) || m.version.length > 64) {
|
|
37
62
|
errors.push('version must be a non-empty string (e.g. "1.0.0")');
|
|
@@ -43,7 +68,7 @@ export function validateManifestObject(raw) {
|
|
|
43
68
|
errors.push(`genre must be one of: ${VALID_GENRES.join(', ')}`);
|
|
44
69
|
}
|
|
45
70
|
if (!isNonEmptyString(m.accentColor) || !HEX_COLOR_RE.test(m.accentColor)) {
|
|
46
|
-
errors.push('accentColor must be a 6-digit hex color (e.g. "#
|
|
71
|
+
errors.push('accentColor must be a 6-digit hex color (e.g. "#0F62FE")');
|
|
47
72
|
}
|
|
48
73
|
if (!isNonEmptyString(m.aspectRatio) || !ASPECT_RATIO_RE.test(m.aspectRatio)) {
|
|
49
74
|
errors.push('aspectRatio must match "<w>:<h>" (e.g. "9:16")');
|
|
@@ -91,15 +116,31 @@ export function validateManifestObject(raw) {
|
|
|
91
116
|
errors.push('artwork is required');
|
|
92
117
|
}
|
|
93
118
|
else {
|
|
94
|
-
if (!
|
|
95
|
-
errors.push('artwork.icon
|
|
96
|
-
if (!
|
|
97
|
-
errors.push('artwork.cover
|
|
119
|
+
if (!isSafeArtworkRef(artwork.icon))
|
|
120
|
+
errors.push('artwork.icon must be a safe relative path or https:// URL');
|
|
121
|
+
if (!isSafeArtworkRef(artwork.cover))
|
|
122
|
+
errors.push('artwork.cover must be a safe relative path or https:// URL');
|
|
123
|
+
if (artwork.poster !== undefined && artwork.poster !== '' && !isSafeArtworkRef(artwork.poster)) {
|
|
124
|
+
errors.push('artwork.poster must be a safe relative path or https:// URL');
|
|
125
|
+
}
|
|
98
126
|
}
|
|
99
127
|
const platforms = m.platforms;
|
|
100
128
|
if (!platforms || typeof platforms.web !== 'boolean') {
|
|
101
129
|
errors.push('platforms.web must be a boolean');
|
|
102
130
|
}
|
|
131
|
+
else {
|
|
132
|
+
for (const key of ['ios', 'android']) {
|
|
133
|
+
const store = platforms[key];
|
|
134
|
+
if (store && typeof store === 'object' && !Array.isArray(store)) {
|
|
135
|
+
const storeUrl = store.storeUrl;
|
|
136
|
+
if (storeUrl !== undefined && storeUrl !== '') {
|
|
137
|
+
if (typeof storeUrl !== 'string' || !isSafeHttpUrl(storeUrl.trim())) {
|
|
138
|
+
errors.push(`platforms.${key}.storeUrl must be a valid http(s) URL`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
103
144
|
if (errors.length > 0) {
|
|
104
145
|
return { valid: false, errors };
|
|
105
146
|
}
|
|
@@ -131,7 +172,7 @@ export function buildStarterManifest(options) {
|
|
|
131
172
|
const titleEn = options.titleEn?.trim() || slugToTitle(options.slug);
|
|
132
173
|
const titleZh = options.titleZh?.trim() || titleEn;
|
|
133
174
|
const genre = options.genre ?? 'arcade';
|
|
134
|
-
const accentColor = options.accentColor ?? '#
|
|
175
|
+
const accentColor = options.accentColor ?? '#0F62FE';
|
|
135
176
|
return {
|
|
136
177
|
schemaVersion: 1,
|
|
137
178
|
slug: options.slug,
|
package/dist/output.js
CHANGED
|
@@ -63,7 +63,7 @@ export function extractFlag(args, names) {
|
|
|
63
63
|
for (const name of names) {
|
|
64
64
|
if (arg === name) {
|
|
65
65
|
const next = args[i + 1];
|
|
66
|
-
if (next === undefined || next
|
|
66
|
+
if (next === undefined || /^-[a-zA-Z-]/.test(next)) {
|
|
67
67
|
throw new CliError('INVALID_ARGUMENTS', `Flag "${name}" requires a value.`);
|
|
68
68
|
}
|
|
69
69
|
value = next;
|
package/dist/validate.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface BundleFileItem {
|
|
|
11
11
|
contentType: string;
|
|
12
12
|
}
|
|
13
13
|
export interface DiscoveredMediaItem {
|
|
14
|
-
slot: 'icon' | 'cover';
|
|
14
|
+
slot: 'icon' | 'cover' | 'poster';
|
|
15
15
|
filename: string;
|
|
16
16
|
absPath: string;
|
|
17
17
|
bytes: number;
|
|
@@ -30,6 +30,7 @@ export interface ValidationReport {
|
|
|
30
30
|
warnings: string[];
|
|
31
31
|
manifest: ReplayStageManifest;
|
|
32
32
|
}
|
|
33
|
+
export declare function discoverMediaFile(slot: 'icon' | 'cover' | 'poster', artworkUrl: string, slug: string, repoDir: string, distDir?: string): Promise<DiscoveredMediaItem | null>;
|
|
33
34
|
export declare function validateProjectBundle(options: {
|
|
34
35
|
cwd: string;
|
|
35
36
|
distDir?: string;
|
package/dist/validate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readdir, stat } from 'node:fs/promises';
|
|
1
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { loadAndValidateManifest } from './manifest.js';
|
|
4
4
|
import { CliError } from './output.js';
|
|
@@ -56,10 +56,11 @@ async function fileExists(target) {
|
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
async function discoverMediaFile(slot, artworkUrl, slug, repoDir, distDir) {
|
|
60
|
-
// Expected format: `/media/<slug>/<filename>`
|
|
59
|
+
export async function discoverMediaFile(slot, artworkUrl, slug, repoDir, distDir) {
|
|
60
|
+
// Expected format: `/media/<slug>/<filename>` or local repo-relative path (e.g. `public/icon.svg`)
|
|
61
61
|
const expectedPrefix = `/media/${slug}/`;
|
|
62
62
|
let filename = '';
|
|
63
|
+
const directCandidates = [];
|
|
63
64
|
if (artworkUrl.startsWith(expectedPrefix)) {
|
|
64
65
|
filename = artworkUrl.slice(expectedPrefix.length);
|
|
65
66
|
}
|
|
@@ -67,7 +68,13 @@ async function discoverMediaFile(slot, artworkUrl, slug, repoDir, distDir) {
|
|
|
67
68
|
filename = path.basename(artworkUrl);
|
|
68
69
|
}
|
|
69
70
|
else if (!artworkUrl.startsWith('http://') && !artworkUrl.startsWith('https://')) {
|
|
70
|
-
|
|
71
|
+
const cleanRel = artworkUrl.replace(/^\.\/+/, '');
|
|
72
|
+
if (!cleanRel.includes('..')) {
|
|
73
|
+
directCandidates.push(path.join(repoDir, cleanRel));
|
|
74
|
+
if (distDir)
|
|
75
|
+
directCandidates.push(path.join(distDir, cleanRel));
|
|
76
|
+
}
|
|
77
|
+
filename = path.basename(cleanRel);
|
|
71
78
|
}
|
|
72
79
|
else {
|
|
73
80
|
return null;
|
|
@@ -76,13 +83,15 @@ async function discoverMediaFile(slot, artworkUrl, slug, repoDir, distDir) {
|
|
|
76
83
|
return null;
|
|
77
84
|
}
|
|
78
85
|
const candidates = [
|
|
86
|
+
...directCandidates,
|
|
79
87
|
path.join(repoDir, 'public', 'media', slug, filename),
|
|
80
88
|
path.join(repoDir, 'media', slug, filename),
|
|
81
89
|
path.join(repoDir, 'media', filename),
|
|
82
90
|
path.join(repoDir, 'public', filename),
|
|
83
91
|
path.join(repoDir, filename),
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
...(distDir
|
|
93
|
+
? [path.join(distDir, 'media', slug, filename), path.join(distDir, filename)]
|
|
94
|
+
: []),
|
|
86
95
|
];
|
|
87
96
|
for (const candidate of candidates) {
|
|
88
97
|
if (await fileExists(candidate)) {
|
|
@@ -168,17 +177,51 @@ export async function validateProjectBundle(options) {
|
|
|
168
177
|
}
|
|
169
178
|
await walk(resolvedDistDir, '');
|
|
170
179
|
const normalizedEntry = manifest.runtime.entryPath.replace(/^\/+/, '') || 'index.html';
|
|
171
|
-
const
|
|
172
|
-
if (!
|
|
180
|
+
const entryItem = files.find(f => f.relPath === normalizedEntry);
|
|
181
|
+
if (!entryItem) {
|
|
173
182
|
throw new CliError('ENTRY_MISSING', `Entry file "${normalizedEntry}" (from runtime.entryPath) was not found inside ${resolvedDistDir}.`, { details: { entryPath: normalizedEntry, distDir: resolvedDistDir } });
|
|
174
183
|
}
|
|
184
|
+
// Static entry HTML sanity checks (catch common blank-screen & bridge security mistakes early)
|
|
185
|
+
try {
|
|
186
|
+
const entryHtml = await readFile(entryItem.absPath, 'utf8');
|
|
187
|
+
if (/https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?/i.test(entryHtml)) {
|
|
188
|
+
warnings.push(`Entry "${normalizedEntry}" references a localhost/127.0.0.1 URL — replace dev URLs before publishing.`);
|
|
189
|
+
}
|
|
190
|
+
if (/postMessage\s*\([^)]*,\s*['"]\*['"]\s*\)/.test(entryHtml)) {
|
|
191
|
+
warnings.push(`Entry "${normalizedEntry}" uses wildcard postMessage(..., '*') — use @replaystage/sdk for strict origin checks.`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// non-fatal if entry cannot be decoded as UTF-8
|
|
196
|
+
}
|
|
197
|
+
if (manifest.runtime.originSlug !== manifest.slug) {
|
|
198
|
+
warnings.push(`runtime.originSlug ("${manifest.runtime.originSlug}") differs from slug ("${manifest.slug}").`);
|
|
199
|
+
}
|
|
200
|
+
if (manifest.locales.en.tagline.includes('in an instant portrait stage.') ||
|
|
201
|
+
manifest.locales['zh-Hans'].tagline.includes('在竖屏舞台点开即玩')) {
|
|
202
|
+
warnings.push('Manifest still contains starter placeholder tagline copy — replace with real bilingual copy before going live.');
|
|
203
|
+
}
|
|
175
204
|
const media = [];
|
|
176
205
|
const iconMedia = await discoverMediaFile('icon', manifest.artwork.icon, manifest.slug, repoDir, resolvedDistDir);
|
|
177
|
-
if (iconMedia)
|
|
206
|
+
if (iconMedia) {
|
|
178
207
|
media.push(iconMedia);
|
|
208
|
+
}
|
|
209
|
+
else if (!manifest.artwork.icon.startsWith('http://') && !manifest.artwork.icon.startsWith('https://')) {
|
|
210
|
+
warnings.push(`Artwork "icon" (${manifest.artwork.icon}) was not found locally — add public/media/${manifest.slug}/${path.basename(manifest.artwork.icon)} so lobby cards render cleanly.`);
|
|
211
|
+
}
|
|
179
212
|
const coverMedia = await discoverMediaFile('cover', manifest.artwork.cover, manifest.slug, repoDir, resolvedDistDir);
|
|
180
|
-
if (coverMedia)
|
|
213
|
+
if (coverMedia) {
|
|
181
214
|
media.push(coverMedia);
|
|
215
|
+
}
|
|
216
|
+
else if (!manifest.artwork.cover.startsWith('http://') && !manifest.artwork.cover.startsWith('https://')) {
|
|
217
|
+
warnings.push(`Artwork "cover" (${manifest.artwork.cover}) was not found locally — add public/media/${manifest.slug}/${path.basename(manifest.artwork.cover)} so lobby cards render cleanly.`);
|
|
218
|
+
}
|
|
219
|
+
if (manifest.artwork.poster) {
|
|
220
|
+
const posterMedia = await discoverMediaFile('poster', manifest.artwork.poster, manifest.slug, repoDir, resolvedDistDir);
|
|
221
|
+
if (posterMedia) {
|
|
222
|
+
media.push(posterMedia);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
182
225
|
const version = options.versionOverride?.trim() || manifest.version;
|
|
183
226
|
return {
|
|
184
227
|
slug: manifest.slug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replaystage/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Unified agent-native CLI for building, validating, previewing, publishing, and operating ReplayStage portrait games.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^
|
|
36
|
+
"@types/node": "^22.15.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc -p tsconfig.json",
|