-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate-maintenance-system.js
More file actions
284 lines (243 loc) Β· 9.21 KB
/
validate-maintenance-system.js
File metadata and controls
284 lines (243 loc) Β· 9.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/env node
/**
* Maintenance System Validation
* Validates that all maintenance components are properly configured
*/
const fs = require('fs');
const path = require('path');
class MaintenanceSystemValidator {
constructor() {
this.issues = [];
this.warnings = [];
this.validations = 0;
}
/**
* Run all validations
*/
async validate() {
console.log('π Validating Cross-Page Integration Maintenance System...\n');
this.validateFiles();
this.validatePackageScripts();
this.validateDirectories();
this.validateGitHubWorkflow();
this.validateDocumentation();
this.generateReport();
return this.issues.length === 0;
}
/**
* Validate required files exist
*/
validateFiles() {
console.log('π Validating Files...');
const requiredFiles = [
'scripts/cross-page-maintenance.js',
'scripts/content-preview-updater.js',
'scripts/maintenance-integration.js',
'scripts/cross-page-dashboard.js',
'scripts/maintenance-status.js',
'test-cross-page-maintenance.js',
'CROSS_PAGE_MAINTENANCE_PROCEDURES.md',
'MAINTENANCE_SYSTEM_README.md'
];
requiredFiles.forEach(file => {
this.validations++;
if (fs.existsSync(file)) {
console.log(` β
${file}`);
} else {
console.log(` β ${file}`);
this.issues.push(`Missing required file: ${file}`);
}
});
// Check for optional files
const optionalFiles = [
'scripts/integration-maintenance.js',
'test-cross-page-integration.js',
'test-cross-page-links.js'
];
optionalFiles.forEach(file => {
if (fs.existsSync(file)) {
console.log(` βΉοΈ ${file} (optional)`);
}
});
}
/**
* Validate package.json scripts
*/
validatePackageScripts() {
console.log('\nπ¦ Validating Package Scripts...');
try {
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const requiredScripts = [
'maintenance:cross-page',
'maintenance:cross-page:links',
'maintenance:cross-page:previews',
'maintenance:cross-page:test',
'test:cross-page-maintenance',
'content:update-previews',
'content:watch-previews',
'dashboard:cross-page',
'maintenance:status',
'maintenance:integration',
'maintenance:integration:daily',
'maintenance:integration:weekly',
'maintenance:integration:monthly',
'maintenance:check-status'
];
requiredScripts.forEach(script => {
this.validations++;
if (packageJson.scripts && packageJson.scripts[script]) {
console.log(` β
${script}`);
} else {
console.log(` β ${script}`);
this.issues.push(`Missing package script: ${script}`);
}
});
} catch (error) {
this.issues.push(`Error reading package.json: ${error.message}`);
}
}
/**
* Validate required directories
*/
validateDirectories() {
console.log('\nπ Validating Directories...');
const requiredDirs = [
'scripts',
'.github/workflows'
];
const optionalDirs = [
'maintenance-logs',
'maintenance-reports'
];
requiredDirs.forEach(dir => {
this.validations++;
if (fs.existsSync(dir)) {
console.log(` β
${dir}/`);
} else {
console.log(` β ${dir}/`);
this.issues.push(`Missing required directory: ${dir}`);
}
});
optionalDirs.forEach(dir => {
if (fs.existsSync(dir)) {
console.log(` βΉοΈ ${dir}/ (will be created automatically)`);
} else {
console.log(` β οΈ ${dir}/ (will be created when needed)`);
this.warnings.push(`Directory ${dir} will be created automatically when needed`);
}
});
}
/**
* Validate GitHub workflow
*/
validateGitHubWorkflow() {
console.log('\nπ Validating GitHub Workflow...');
const workflowFile = '.github/workflows/cross-page-maintenance.yml';
this.validations++;
if (fs.existsSync(workflowFile)) {
console.log(` β
${workflowFile}`);
try {
const workflowContent = fs.readFileSync(workflowFile, 'utf8');
// Check for key workflow components
const requiredComponents = [
'cross-page-maintenance',
'test:cross-page-maintenance',
'maintenance:cross-page',
'content:update-previews'
];
requiredComponents.forEach(component => {
if (workflowContent.includes(component)) {
console.log(` β
Contains ${component}`);
} else {
console.log(` β οΈ Missing ${component}`);
this.warnings.push(`GitHub workflow missing component: ${component}`);
}
});
} catch (error) {
this.warnings.push(`Error reading workflow file: ${error.message}`);
}
} else {
console.log(` β ${workflowFile}`);
this.issues.push(`Missing GitHub workflow: ${workflowFile}`);
}
}
/**
* Validate documentation
*/
validateDocumentation() {
console.log('\nπ Validating Documentation...');
const docFiles = [
'CROSS_PAGE_MAINTENANCE_PROCEDURES.md',
'MAINTENANCE_SYSTEM_README.md'
];
docFiles.forEach(docFile => {
this.validations++;
if (fs.existsSync(docFile)) {
console.log(` β
${docFile}`);
try {
const content = fs.readFileSync(docFile, 'utf8');
// Check for key sections
const keySections = ['Overview', 'Usage', 'Maintenance'];
const foundSections = keySections.filter(section =>
content.includes(`# ${section}`) || content.includes(`## ${section}`)
);
if (foundSections.length > 0) {
console.log(` βΉοΈ Contains ${foundSections.length}/${keySections.length} key sections`);
}
} catch (error) {
this.warnings.push(`Error reading ${docFile}: ${error.message}`);
}
} else {
console.log(` β ${docFile}`);
this.issues.push(`Missing documentation: ${docFile}`);
}
});
}
/**
* Generate validation report
*/
generateReport() {
console.log('\nπ Validation Summary:');
console.log(` Total Validations: ${this.validations}`);
console.log(` Issues Found: ${this.issues.length}`);
console.log(` Warnings: ${this.warnings.length}`);
if (this.issues.length === 0) {
console.log(' Status: π’ HEALTHY');
} else if (this.issues.length < 3) {
console.log(' Status: π‘ NEEDS ATTENTION');
} else {
console.log(' Status: π΄ CRITICAL ISSUES');
}
if (this.issues.length > 0) {
console.log('\nβ Issues to Fix:');
this.issues.forEach((issue, index) => {
console.log(` ${index + 1}. ${issue}`);
});
}
if (this.warnings.length > 0) {
console.log('\nβ οΈ Warnings:');
this.warnings.forEach((warning, index) => {
console.log(` ${index + 1}. ${warning}`);
});
}
if (this.issues.length === 0) {
console.log('\nπ Maintenance system is properly configured!');
console.log('\nπ Quick Start Commands:');
console.log(' npm run maintenance:check-status - Check system health');
console.log(' npm run maintenance:integration - Run maintenance');
console.log(' npm run test:cross-page-maintenance - Run tests');
console.log(' npm run dashboard:cross-page - Start dashboard');
}
}
}
// CLI interface
if (require.main === module) {
const validator = new MaintenanceSystemValidator();
validator.validate().then(isValid => {
process.exit(isValid ? 0 : 1);
}).catch(error => {
console.error('β Validation failed:', error.message);
process.exit(1);
});
}
module.exports = MaintenanceSystemValidator;