@replaystage/cli 2.1.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/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 +2 -7
- package/dist/commands/creator.js +25 -667
- package/dist/index.js +1 -1
- package/dist/manifest.d.ts +1 -0
- package/dist/manifest.js +47 -6
- package/dist/validate.d.ts +2 -2
- package/dist/validate.js +16 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { cmdCreateGame, cmdDelete, cmdGames, cmdInit, cmdPublish, cmdReleases, c
|
|
|
5
5
|
import { CliError, DEFAULT_STREAMS, emitError, emitSuccess, extractBoolFlag, extractFlag, } from './output.js';
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
7
|
const pkgJson = require('../package.json');
|
|
8
|
-
export const CLI_VERSION = pkgJson.version ?? '2.1.
|
|
8
|
+
export const CLI_VERSION = pkgJson.version ?? '2.1.1';
|
|
9
9
|
export { CliError } from './output.js';
|
|
10
10
|
export { validateManifestObject, buildStarterManifest } from './manifest.js';
|
|
11
11
|
export { validateProjectBundle } from './validate.js';
|
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")');
|
|
@@ -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
|
}
|
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,7 +30,7 @@ export interface ValidationReport {
|
|
|
30
30
|
warnings: string[];
|
|
31
31
|
manifest: ReplayStageManifest;
|
|
32
32
|
}
|
|
33
|
-
export declare function discoverMediaFile(slot: 'icon' | 'cover', artworkUrl: string, slug: string, repoDir: string, distDir?: string): Promise<DiscoveredMediaItem | null>;
|
|
33
|
+
export declare function discoverMediaFile(slot: 'icon' | 'cover' | 'poster', artworkUrl: string, slug: string, repoDir: string, distDir?: string): Promise<DiscoveredMediaItem | null>;
|
|
34
34
|
export declare function validateProjectBundle(options: {
|
|
35
35
|
cwd: string;
|
|
36
36
|
distDir?: string;
|
package/dist/validate.js
CHANGED
|
@@ -57,9 +57,10 @@ async function fileExists(target) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
export async function discoverMediaFile(slot, artworkUrl, slug, repoDir, distDir) {
|
|
60
|
-
// Expected format: `/media/<slug>/<filename>`
|
|
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 @@ export 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,6 +83,7 @@ export 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),
|
|
@@ -208,6 +216,12 @@ export async function validateProjectBundle(options) {
|
|
|
208
216
|
else if (!manifest.artwork.cover.startsWith('http://') && !manifest.artwork.cover.startsWith('https://')) {
|
|
209
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.`);
|
|
210
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
|
+
}
|
|
211
225
|
const version = options.versionOverride?.trim() || manifest.version;
|
|
212
226
|
return {
|
|
213
227
|
slug: manifest.slug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replaystage/cli",
|
|
3
|
-
"version": "2.1.
|
|
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",
|