diff --git a/README.md b/README.md index 9be0835..3caeaef 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,43 @@ +```markdown +# [ANY Experience Gallery](https://gallery.any.coop) + +## Contribution +Thank you for your desire to develop Anytype together! + +❤️ This project and everyone involved in it is governed by the [Code of Conduct](https://github.com/anyproto/.github/blob/main/docs/CODE_OF_CONDUCT.md). + + + +🫢 For security findings, please email [security@anytype.io](mailto:security@anytype.io) and refer to our [security guide](https://github.com/anyproto/.github/blob/main/docs/SECURITY.md) for more information. + +🤝 Follow us on [Github](https://github.com/anyproto) and join the [Contributors Community](https://github.com/orgs/anyproto/discussions). + +--- +Made by Any — a Swiss association 🇨🇭 + +Licensed under [MIT](./LICENSE.md). + +``` + +--- + +## Enhancements + +- **Validation script:** Added `scripts/validate-manifests.js` — a small Node.js utility that scans each folder under `experiences/` and checks for a valid `manifest.json` and that the `screenshots/` directory exists and contains at least one file. + +### Usage + +Run from the repository root with Node.js installed: + +```bash +node scripts/validate-manifests.js +``` + +Exit codes: +- `0` — all manifests and screenshots are valid +- `1` — one or more issues were found (errors will be printed) + +This script helps keep the collection consistent and can be integrated into CI to catch missing or malformed manifests early. # [ANY Experience Gallery](https://gallery.any.coop) ## Contribution diff --git a/scripts/validate-manifests.js b/scripts/validate-manifests.js new file mode 100644 index 0000000..d5bbc79 --- /dev/null +++ b/scripts/validate-manifests.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node +const fs = require('fs'); +const path = require('path'); + +const root = path.resolve(__dirname, '..'); +const experiencesDir = path.join(root, 'experiences'); + +let errors = []; + +if (!fs.existsSync(experiencesDir) || !fs.statSync(experiencesDir).isDirectory()) { + console.error('No experiences directory found at', experiencesDir); + process.exit(1); +} + +const entries = fs.readdirSync(experiencesDir, { withFileTypes: true }).filter(d => d.isDirectory()); + +entries.forEach(dirent => { + const dir = path.join(experiencesDir, dirent.name); + const manifestPath = path.join(dir, 'manifest.json'); + if (!fs.existsSync(manifestPath)) { + errors.push(`${dirent.name}: missing manifest.json`); + return; + } + try { + const content = fs.readFileSync(manifestPath, 'utf8'); + JSON.parse(content); + } catch (e) { + errors.push(`${dirent.name}: invalid JSON in manifest.json — ${e.message}`); + } + const screenshotsDir = path.join(dir, 'screenshots'); + if (!fs.existsSync(screenshotsDir) || !fs.statSync(screenshotsDir).isDirectory()) { + errors.push(`${dirent.name}: missing screenshots/ directory`); + } else { + const imgs = fs.readdirSync(screenshotsDir).filter(f => !f.startsWith('.')); + if (imgs.length === 0) { + errors.push(`${dirent.name}: screenshots/ is empty`); + } + } +}); + +if (errors.length) { + console.error('Validation failed:'); + errors.forEach(e => console.error(' -', e)); + process.exit(1); +} else { + console.log('All experience manifests and screenshots look good!'); + process.exit(0); +}