@yolo-labs/yolo-cli 0.34.0 → 0.35.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/dist/cli.js +6 -2
- package/dist/tileapp-developer.js +5 -1
- package/dist/tileapp-personal.js +3 -1
- package/dist/tileapp-validator.js +70 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -754,7 +754,7 @@ function tileAppUsage(sub, message) {
|
|
|
754
754
|
sign: 'Usage: yolo tileapp sign <manifest.json> --publisher <id> [--key <keyId>] [--stdout]\n',
|
|
755
755
|
publish: 'Usage: yolo tileapp publish <manifest.json> --personal [--bundle-dir <dir>] [--context <dir>] [--dockerfile <f>] [--builder auto|podman|skopeo] (personal app)\n'
|
|
756
756
|
+ ' or: yolo tileapp publish <manifest.json> [--channel beta|stable] [--image-digest <d>] (marketplace)\n',
|
|
757
|
-
validate: 'Usage: yolo tileapp validate <manifest.json> [--bundle-dir <dir>]\n',
|
|
757
|
+
validate: 'Usage: yolo tileapp validate <manifest.json> [--bundle-dir <dir>] [--personal]\n',
|
|
758
758
|
dev: 'Usage: yolo tileapp dev <manifest.json> [--port N] [--host H] [--bundle-dir <dir>] [--deny]\n',
|
|
759
759
|
install: 'Usage: yolo tileapp install <appId> --workspace <workspaceId> [--accept-optional <perm>]...\n',
|
|
760
760
|
'add-tile': 'Usage: yolo tileapp add-tile <appId> --workspace <workspaceId> [--name <name>] [--version <v>]\n',
|
|
@@ -1044,6 +1044,7 @@ async function runTileAppValidateCmd(args) {
|
|
|
1044
1044
|
const { runTileAppValidate, devExitCode } = await import('./tileapp-developer.js');
|
|
1045
1045
|
let manifestPath;
|
|
1046
1046
|
let bundleDir;
|
|
1047
|
+
let personal = false;
|
|
1047
1048
|
for (let i = 0; i < args.length; i++) {
|
|
1048
1049
|
const a = args[i];
|
|
1049
1050
|
if (a === '--bundle-dir') {
|
|
@@ -1051,6 +1052,9 @@ async function runTileAppValidateCmd(args) {
|
|
|
1051
1052
|
if (bundleDir === undefined)
|
|
1052
1053
|
return tileAppUsage('validate', '--bundle-dir requires a value');
|
|
1053
1054
|
}
|
|
1055
|
+
else if (a === '--personal') {
|
|
1056
|
+
personal = true;
|
|
1057
|
+
}
|
|
1054
1058
|
else if (!a.startsWith('-') && !manifestPath)
|
|
1055
1059
|
manifestPath = a;
|
|
1056
1060
|
else
|
|
@@ -1058,7 +1062,7 @@ async function runTileAppValidateCmd(args) {
|
|
|
1058
1062
|
}
|
|
1059
1063
|
if (!manifestPath)
|
|
1060
1064
|
return tileAppUsage('validate', 'a manifest path is required');
|
|
1061
|
-
const result = runTileAppValidate({ manifestPath, bundleDir });
|
|
1065
|
+
const result = runTileAppValidate({ manifestPath, bundleDir, personal });
|
|
1062
1066
|
if (result.ok) {
|
|
1063
1067
|
process.stdout.write(`${result.output}\n`);
|
|
1064
1068
|
return 0;
|
|
@@ -110,7 +110,11 @@ export function runTileAppValidate(opts) {
|
|
|
110
110
|
const read = readManifestFile(opts.manifestPath);
|
|
111
111
|
if (!read.ok)
|
|
112
112
|
return { ok: false, kind: 'io', message: read.message };
|
|
113
|
-
|
|
113
|
+
// A runtime personal app publishes an OCI archive and gets no R2 bundle, so
|
|
114
|
+
// only a PURE-UI personal manifest may use the `media/<file>` ref form.
|
|
115
|
+
const v = validateManifest(read.manifest, {
|
|
116
|
+
allowPlatformHostedScreenshots: !!opts.personal && !isRuntimeManifest(read.manifest),
|
|
117
|
+
});
|
|
114
118
|
const errors = [...v.errors, ...publishGateErrors(read.manifest)];
|
|
115
119
|
// A non-object manifest is fully reported by validateManifest; bail before the
|
|
116
120
|
// bundle/runtime checks (which deref manifest fields) so we never crash on it.
|
package/dist/tileapp-personal.js
CHANGED
|
@@ -255,7 +255,9 @@ export async function runTileAppPublishPersonal(opts) {
|
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
// Pure-UI path: strict schema lint (the server re-validates authoritatively).
|
|
258
|
-
|
|
258
|
+
// This IS the path that gets an R2 bundle, so the `media/<file>` screenshot
|
|
259
|
+
// form is available to it — see ScreenshotRefOptions.
|
|
260
|
+
const v = validateManifest(read.manifest, { allowPlatformHostedScreenshots: true });
|
|
259
261
|
if (v.errors.length > 0) {
|
|
260
262
|
return { ok: false, kind: 'validation', message: `manifest invalid:\n - ${v.errors.join('\n - ')}` };
|
|
261
263
|
}
|
|
@@ -15,6 +15,74 @@
|
|
|
15
15
|
* confirmed authoritatively at publish — `validate` says so in its output.
|
|
16
16
|
*/
|
|
17
17
|
const ID_RE = /^[a-z0-9][a-z0-9-]{1,63}$/;
|
|
18
|
+
// ── Store screenshots ───────────────────────────────────────────────────────
|
|
19
|
+
// Mirror of `common-api/src/types/tileapp-screenshots.ts`. The rules a
|
|
20
|
+
// publisher needs BEFORE uploading (count, ref form, extension) are checked
|
|
21
|
+
// here so `yolo tileapp validate` catches them offline; the dimension/content
|
|
22
|
+
// rules that need the image bytes are in
|
|
23
|
+
// `docs/TILEAPP_SCREENSHOT_GUIDELINES.md` and checked at review.
|
|
24
|
+
//
|
|
25
|
+
// 🚨 This file mirrors the server's PUBLISH-time validator
|
|
26
|
+
// (`validateManifestForPublish`), NOT its read-time one. The server splits the
|
|
27
|
+
// two on purpose: on the read path a validation failure SKIPS the app and it
|
|
28
|
+
// vanishes from the store, so `validateManifest` there checks structure only.
|
|
29
|
+
// The CLI is a publish lint, so strict is correct here — but don't "sync" the
|
|
30
|
+
// server's looser read-time rules back into this file.
|
|
31
|
+
const MAX_SCREENSHOTS = 6;
|
|
32
|
+
const SCREENSHOT_EXTENSIONS = ['.webp', '.png'];
|
|
33
|
+
const RELATIVE_SCREENSHOT_RE = /^media\/[a-z0-9][a-z0-9._-]*$/;
|
|
34
|
+
function hasAllowedScreenshotExt(pathname) {
|
|
35
|
+
const lower = pathname.toLowerCase();
|
|
36
|
+
return SCREENSHOT_EXTENSIONS.some((ext) => lower.endsWith(ext));
|
|
37
|
+
}
|
|
38
|
+
function validateScreenshotRef(ref, opts = {}) {
|
|
39
|
+
if (typeof ref !== 'string' || ref.length === 0)
|
|
40
|
+
return 'must be a non-empty string';
|
|
41
|
+
if (ref.length > 500)
|
|
42
|
+
return 'must be at most 500 characters';
|
|
43
|
+
if (/^https:\/\//i.test(ref)) {
|
|
44
|
+
let url;
|
|
45
|
+
try {
|
|
46
|
+
url = new URL(ref);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return `is not a valid URL: ${ref}`;
|
|
50
|
+
}
|
|
51
|
+
if (!hasAllowedScreenshotExt(url.pathname))
|
|
52
|
+
return `must end in ${SCREENSHOT_EXTENSIONS.join(' or ')}: ${ref}`;
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
// `media/<file>` is the PLATFORM-HOSTED form — valid only for a publishing
|
|
56
|
+
// path that actually has a store behind it (a pure-UI personal app's R2
|
|
57
|
+
// bundle). See ScreenshotRefOptions.
|
|
58
|
+
if (!opts.allowPlatformHostedScreenshots) {
|
|
59
|
+
return `must be an absolute https:// URL — the "media/<file>" form requires platform-hosted storage, which this publishing path does not have. Host the image and reference it by URL. Got: ${ref}`;
|
|
60
|
+
}
|
|
61
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(ref))
|
|
62
|
+
return `must be an https:// URL or a "media/<file>" path, got: ${ref}`;
|
|
63
|
+
if (!RELATIVE_SCREENSHOT_RE.test(ref)) {
|
|
64
|
+
return `relative refs must look like "media/<file>" with no subdirectories, got: ${ref}`;
|
|
65
|
+
}
|
|
66
|
+
if (!hasAllowedScreenshotExt(ref))
|
|
67
|
+
return `must end in ${SCREENSHOT_EXTENSIONS.join(' or ')}: ${ref}`;
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
function validateScreenshots(refs, opts = {}) {
|
|
71
|
+
if (refs === undefined)
|
|
72
|
+
return [];
|
|
73
|
+
if (!Array.isArray(refs))
|
|
74
|
+
return ['screenshots must be an array of strings when present'];
|
|
75
|
+
if (refs.length > MAX_SCREENSHOTS) {
|
|
76
|
+
return [`screenshots may list at most ${MAX_SCREENSHOTS} images (got ${refs.length})`];
|
|
77
|
+
}
|
|
78
|
+
const errors = [];
|
|
79
|
+
for (const ref of refs) {
|
|
80
|
+
const err = validateScreenshotRef(ref, opts);
|
|
81
|
+
if (err)
|
|
82
|
+
errors.push(`screenshots entry ${err}`);
|
|
83
|
+
}
|
|
84
|
+
return errors;
|
|
85
|
+
}
|
|
18
86
|
const SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+].+)?$/;
|
|
19
87
|
function isObj(v) {
|
|
20
88
|
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
@@ -79,7 +147,7 @@ export function parsePermissionShape(raw) {
|
|
|
79
147
|
* (not fail-fast) so the author sees all problems at once — matching the
|
|
80
148
|
* server. Returns `{ ok, errors }`.
|
|
81
149
|
*/
|
|
82
|
-
export function validateManifest(raw) {
|
|
150
|
+
export function validateManifest(raw, opts = {}) {
|
|
83
151
|
const errors = [];
|
|
84
152
|
if (!isObj(raw))
|
|
85
153
|
return { ok: false, errors: ['manifest is not an object'] };
|
|
@@ -174,9 +242,7 @@ export function validateManifest(raw) {
|
|
|
174
242
|
}
|
|
175
243
|
if (raw.category !== undefined && !isStr(raw.category))
|
|
176
244
|
errors.push('category must be a string when present');
|
|
177
|
-
|
|
178
|
-
errors.push('screenshots must be an array of strings when present');
|
|
179
|
-
}
|
|
245
|
+
errors.push(...validateScreenshots(raw.screenshots, opts));
|
|
180
246
|
if (raw.changelog !== undefined && !isStr(raw.changelog))
|
|
181
247
|
errors.push('changelog must be a string when present');
|
|
182
248
|
if (raw.featured !== undefined && typeof raw.featured !== 'boolean')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolo-labs/yolo-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "YOLO Studio substrate CLI — owns yolo plan/workspace/artifact substrate-tooling commands. Distinct from yolo-code (the agent CLI) and yolo-router (the LLM gateway client).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|