| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #!/usr/bin/env node
- const fs = require('fs');
- const path = require('path');
- const { spawnSync } = require('child_process');
- const root = path.resolve(__dirname, '..');
- function fail(message) {
- console.error(`FAIL ${message}`);
- process.exitCode = 1;
- }
- function ok(message) {
- console.log(`OK ${message}`);
- }
- function checkFile(relativePath) {
- const fullPath = path.join(root, relativePath);
- if (!fs.existsSync(fullPath)) fail(`missing ${relativePath}`);
- else ok(relativePath);
- }
- function checkJson(relativePath) {
- const fullPath = path.join(root, relativePath);
- try {
- JSON.parse(fs.readFileSync(fullPath, 'utf8'));
- ok(`${relativePath} json`);
- } catch (error) {
- fail(`${relativePath} json: ${error.message}`);
- }
- }
- function checkNode(relativePath) {
- const fullPath = path.join(root, relativePath);
- const child = spawnSync(process.execPath, ['--check', fullPath], { encoding: 'utf8' });
- if (child.status === 0) ok(`${relativePath} syntax`);
- else fail(`${relativePath} syntax: ${child.stderr || child.stdout}`);
- }
- function walk(dir, predicate, result = []) {
- for (const name of fs.readdirSync(dir)) {
- const fullPath = path.join(dir, name);
- const stat = fs.statSync(fullPath);
- if (stat.isDirectory()) walk(fullPath, predicate, result);
- else if (predicate(fullPath)) result.push(fullPath);
- }
- return result;
- }
- [
- 'README.md',
- 'openclaw-startup.md',
- 'skill-package-manifest.json',
- 'install.js',
- 'memory-templates/industry-trend-profile.json',
- 'scripts/industry-trend-runner.js',
- 'scripts/industry-trend-report.js',
- 'skills/industry-trend-runner/SKILL.md',
- 'skills/industry-trend-runner/api-config.json'
- ].forEach(checkFile);
- [
- 'skill-package-manifest.json',
- 'memory-templates/industry-trend-profile.json'
- ].forEach(checkJson);
- walk(path.join(root, 'skills'), file => path.basename(file) === 'api-config.json')
- .forEach(file => checkJson(path.relative(root, file)));
- walk(path.join(root, 'scripts'), file => file.endsWith('.js'))
- .forEach(file => checkNode(path.relative(root, file)));
- checkNode('install.js');
- if (process.exitCode) process.exit(process.exitCode);
|