Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Official Expo skill for EAS Workflows — CI/CD pipelines for building and deploying Expo apps.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/validate.js
1#!/usr/bin/env node23import { readFile } from 'node:fs/promises';4import { resolve } from 'node:path';5import process from 'node:process';67import Ajv2020 from 'ajv/dist/2020.js';8import addFormats from 'ajv-formats';9import yaml from 'js-yaml';1011import { fetchCached } from './fetch.js';1213const SCHEMA_URL = 'https://api.expo.dev/v2/workflows/schema';1415async function fetchSchema() {16const data = await fetchCached(SCHEMA_URL);17const body = JSON.parse(data);18return body.data;19}2021function createValidator(schema) {22const ajv = new Ajv2020({ allErrors: true, strict: true });23addFormats(ajv);24return ajv.compile(schema);25}2627async function validateFile(validator, filePath) {28const content = await readFile(filePath, 'utf-8');2930let doc;31try {32doc = yaml.load(content);33} catch (e) {34return { valid: false, error: `YAML parse error: ${e.message}` };35}3637const valid = validator(doc);38if (!valid) {39return { valid: false, error: formatErrors(validator.errors) };40}4142return { valid: true };43}4445function formatErrors(errors) {46return errors47.map((error) => {48const path = error.instancePath || '(root)';49const allowed = error.params?.allowedValues?.join(', ');50return ` ${path}: ${error.message}${allowed ? ` (allowed: ${allowed})` : ''}`;51})52.join('\n');53}5455if (import.meta.main) {56const args = process.argv.slice(2);57const files = args.filter((a) => !a.startsWith('-'));5859if (files.length === 0 || args.includes('--help') || args.includes('-h')) {60console.log(`Usage: validate <workflow.yml> [workflow2.yml ...]6162Validates EAS workflow YAML files against the official schema.`);63process.exit(files.length === 0 ? 1 : 0);64}6566const schema = await fetchSchema();67const validator = createValidator(schema);6869let hasErrors = false;7071for (const file of files) {72const filePath = resolve(process.cwd(), file);73const result = await validateFile(validator, filePath);7475if (result.valid) {76console.log(`✓ ${file}`);77} else {78console.error(`✗ ${file}\n${result.error}`);79hasErrors = true;80}81}8283process.exit(hasErrors ? 1 : 0);84}85