Open Assets
CLI

open-assets validate

Check assets.json for missing fields, duplicate ids, missing template files and broken localizations, fix them interactively, and fail CI with exit code 1.

open-assets validate [options] [dir]
ArgumentDefaultDescription
dir.Project directory containing assets.json

validate runs a fixed list of checks against the config and the files it points to, prints a line per check and exits 1 if any failed.

Examples

open-assets validate
open-assets validate ./marketing --config assets.staging.json
open-assets validate --fix

Options

FlagEnv varDefaultDescription
--config <path>OPEN_ASSETS_CONFIGassets.jsonPath to config file
--fix--Interactively fix issues (e.g. remove missing templates)

Checks

Pass lines start with ✓, failures with ✗. Messages are quoted exactly.

CheckFailure message
Root name is setMissing top-level 'name' field
collections is a non-empty arrayMissing or empty 'collections' array (stops here)
Each collection has idCollection missing 'id' field (rest of that collection skipped)
Collection ids are uniqueDuplicate collection id: "<id>"
sourceSize.width and height are set and non-zeroCollection "<id>" missing or invalid 'sourceSize'
templates is non-emptyCollection "<id>" has no templates
Each template has srcCollection "<id>" has a template without 'src'
Each src exists on disk<src> not found
localizations file existsCollection "<id>" localizations file not found: <path>
Localizations file has sourceLanguageCollection "<id>" localizations missing "sourceLanguage"
Localizations file has stringsCollection "<id>" localizations has no strings defined
Every code in locales is definedCollection "<id>" requests locale "<code>" but it is not defined in <path>
Localizations file parsesCollection "<id>" localizations error: <message>

Passing checks also print the export size count and one Output: <type> line per typed export entry.

Not checked: version, export entry shapes, size values, duplicate template or size names, output config (xcode.path, copy-source.format), or assets that templates reference.

Output

  Validating assets.json...

  ✓ name: "Demo Assets"
  ✓ 3 collection(s) defined
  ✓ Collection "screenshots" sourceSize: 440×956
  ✓ src/screenshots/01-hero.html exists
  ✓ Collection "screenshots" has 4 export size(s)

  All checks passed.

On failure the last line is <n> error(s) found. If any templates are missing or collections are empty, it adds Run with --fix to remove missing templates and empty collections.

--fix

With --fix, after reporting, it asks one y/N question per problem:

  1. Remove template "<src>" from collection "<id>"? (y/N) for each missing template file.
  2. Remove empty collection "<id>"? (y/N) for each collection that was empty, or became empty after step 1.

If you accepted any, it rewrites the config (two-space JSON) and prints Updated <config> (<n> fix(es) applied). It only removes entries; it never creates files. The exit code is still 1 for that run. Run validate again to confirm.

Exit codes

CodeWhen
0All checks passed
1Config missing or invalid JSON, or at least one check failed (also after --fix)

Last updated on

On this page