myaidev-method 0.0.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +20 -0
- package/COOLIFY_DEPLOYMENT.md +750 -0
- package/PUBLISHING_GUIDE.md +521 -0
- package/README.md +125 -27
- package/WORDPRESS_ADMIN_SCRIPTS.md +474 -0
- package/package.json +36 -3
- package/src/lib/coolify-utils.js +380 -0
- package/src/lib/payloadcms-utils.js +394 -0
- package/src/lib/report-synthesizer.js +504 -0
- package/src/lib/static-site-utils.js +377 -0
- package/src/lib/wordpress-admin-utils.js +703 -0
- package/src/scripts/astro-publish.js +209 -0
- package/src/scripts/coolify-deploy-app.js +287 -0
- package/src/scripts/coolify-list-resources.js +199 -0
- package/src/scripts/coolify-status.js +97 -0
- package/src/scripts/docusaurus-publish.js +209 -0
- package/src/scripts/init-project.js +91 -0
- package/src/scripts/mintlify-publish.js +205 -0
- package/src/scripts/payloadcms-publish.js +202 -0
- package/src/scripts/test-coolify-deploy.js +47 -0
- package/src/scripts/wordpress-comprehensive-report.js +325 -0
- package/src/scripts/wordpress-health-check.js +175 -0
- package/src/scripts/wordpress-performance-check.js +461 -0
- package/src/scripts/wordpress-security-scan.js +221 -0
- package/src/templates/claude/agents/astro-publish.md +43 -0
- package/src/templates/claude/agents/coolify-deploy.md +563 -0
- package/src/templates/claude/agents/docusaurus-publish.md +42 -0
- package/src/templates/claude/agents/mintlify-publish.md +42 -0
- package/src/templates/claude/agents/payloadcms-publish.md +134 -0
- package/src/templates/claude/commands/myai-astro-publish.md +54 -0
- package/src/templates/claude/commands/myai-coolify-deploy.md +172 -0
- package/src/templates/claude/commands/myai-docusaurus-publish.md +45 -0
- package/src/templates/claude/commands/myai-mintlify-publish.md +45 -0
- package/src/templates/claude/commands/myai-payloadcms-publish.md +45 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PayloadCMS Publishing Script
|
|
5
|
+
* Publish markdown content to PayloadCMS
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { PayloadCMSUtils } from '../lib/payloadcms-utils.js';
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
|
|
12
|
+
const options = {
|
|
13
|
+
file: null,
|
|
14
|
+
collection: 'posts',
|
|
15
|
+
status: 'draft',
|
|
16
|
+
id: null,
|
|
17
|
+
json: args.includes('--json'),
|
|
18
|
+
verbose: args.includes('--verbose') || args.includes('-v'),
|
|
19
|
+
dryRun: args.includes('--dry-run')
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Parse arguments
|
|
23
|
+
for (let i = 0; i < args.length; i++) {
|
|
24
|
+
switch (args[i]) {
|
|
25
|
+
case '--file':
|
|
26
|
+
case '-f':
|
|
27
|
+
options.file = args[++i];
|
|
28
|
+
break;
|
|
29
|
+
case '--collection':
|
|
30
|
+
case '-c':
|
|
31
|
+
options.collection = args[++i];
|
|
32
|
+
break;
|
|
33
|
+
case '--status':
|
|
34
|
+
case '-s':
|
|
35
|
+
options.status = args[++i];
|
|
36
|
+
break;
|
|
37
|
+
case '--id':
|
|
38
|
+
options.id = args[++i];
|
|
39
|
+
break;
|
|
40
|
+
case '--help':
|
|
41
|
+
case '-h':
|
|
42
|
+
printHelp();
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// If no file specified, check positional argument
|
|
48
|
+
if (!options.file && args.length > 0 && !args[0].startsWith('-')) {
|
|
49
|
+
options.file = args[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function printHelp() {
|
|
53
|
+
console.log(`
|
|
54
|
+
PayloadCMS Publishing Script
|
|
55
|
+
|
|
56
|
+
Usage: payloadcms-publish [file] [options]
|
|
57
|
+
|
|
58
|
+
Arguments:
|
|
59
|
+
file Markdown file to publish (required)
|
|
60
|
+
|
|
61
|
+
Options:
|
|
62
|
+
--collection, -c <name> Target collection (default: posts)
|
|
63
|
+
--status, -s <status> Publish status: draft|published (default: draft)
|
|
64
|
+
--id <doc-id> Update existing document by ID
|
|
65
|
+
--dry-run Validate without publishing
|
|
66
|
+
--verbose, -v Show detailed progress
|
|
67
|
+
--json Output in JSON format
|
|
68
|
+
--help, -h Show this help
|
|
69
|
+
|
|
70
|
+
Examples:
|
|
71
|
+
# Publish as draft
|
|
72
|
+
payloadcms-publish article.md --collection posts --status draft
|
|
73
|
+
|
|
74
|
+
# Publish to production
|
|
75
|
+
payloadcms-publish article.md --status published
|
|
76
|
+
|
|
77
|
+
# Update existing document
|
|
78
|
+
payloadcms-publish article.md --id 60d5ec49f8d2e
|
|
79
|
+
|
|
80
|
+
# Dry run
|
|
81
|
+
payloadcms-publish article.md --dry-run --verbose
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function publishContent() {
|
|
86
|
+
try {
|
|
87
|
+
// Validate required options
|
|
88
|
+
if (!options.file) {
|
|
89
|
+
console.error('Error: Markdown file is required');
|
|
90
|
+
console.error('Run with --help for usage information');
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (options.verbose) {
|
|
95
|
+
console.error('Initializing PayloadCMS connection...');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const payload = new PayloadCMSUtils();
|
|
99
|
+
|
|
100
|
+
// Health check
|
|
101
|
+
const healthy = await payload.healthCheck();
|
|
102
|
+
if (!healthy) {
|
|
103
|
+
throw new Error('PayloadCMS is not reachable');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (options.verbose) {
|
|
107
|
+
console.error('✓ PayloadCMS is reachable');
|
|
108
|
+
console.error(`Authenticating...`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Authenticate
|
|
112
|
+
const authResult = await payload.authenticate();
|
|
113
|
+
|
|
114
|
+
if (options.verbose) {
|
|
115
|
+
console.error(`✓ Authenticated via ${authResult.method}`);
|
|
116
|
+
console.error(`Publishing to collection: ${options.collection}`);
|
|
117
|
+
console.error(`Status: ${options.status}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Dry run - validate only
|
|
121
|
+
if (options.dryRun) {
|
|
122
|
+
if (options.verbose) {
|
|
123
|
+
console.error('✓ Dry run - validation successful');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const output = {
|
|
127
|
+
success: true,
|
|
128
|
+
dryRun: true,
|
|
129
|
+
file: options.file,
|
|
130
|
+
collection: options.collection,
|
|
131
|
+
status: options.status
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
if (options.json) {
|
|
135
|
+
console.log(JSON.stringify(output, null, 2));
|
|
136
|
+
} else {
|
|
137
|
+
console.log('Dry run successful - ready to publish');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
process.exit(0);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Publish content
|
|
144
|
+
const result = await payload.publishContent(options.file, options.collection, {
|
|
145
|
+
status: options.status,
|
|
146
|
+
id: options.id
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (options.verbose) {
|
|
150
|
+
console.error(`✓ Content ${options.id ? 'updated' : 'created'} successfully`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Prepare output
|
|
154
|
+
const output = {
|
|
155
|
+
success: true,
|
|
156
|
+
action: options.id ? 'updated' : 'created',
|
|
157
|
+
document: {
|
|
158
|
+
id: result.doc?.id || result.id,
|
|
159
|
+
collection: options.collection,
|
|
160
|
+
status: result.doc?.status || options.status,
|
|
161
|
+
title: result.doc?.title
|
|
162
|
+
},
|
|
163
|
+
timestamp: new Date().toISOString()
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (options.json) {
|
|
167
|
+
console.log(JSON.stringify(output, null, 2));
|
|
168
|
+
} else {
|
|
169
|
+
console.log('\\n' + '='.repeat(60));
|
|
170
|
+
console.log('PayloadCMS Publishing Result');
|
|
171
|
+
console.log('='.repeat(60));
|
|
172
|
+
console.log(`Status: ✓ Success`);
|
|
173
|
+
console.log(`Action: ${output.action}`);
|
|
174
|
+
console.log(`Document ID: ${output.document.id}`);
|
|
175
|
+
console.log(`Collection: ${output.document.collection}`);
|
|
176
|
+
console.log(`Status: ${output.document.status}`);
|
|
177
|
+
console.log('='.repeat(60));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
process.exit(0);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (options.json) {
|
|
183
|
+
console.log(JSON.stringify({
|
|
184
|
+
success: false,
|
|
185
|
+
error: error.message,
|
|
186
|
+
timestamp: new Date().toISOString()
|
|
187
|
+
}, null, 2));
|
|
188
|
+
} else {
|
|
189
|
+
console.error(`\\nError: ${error.message}`);
|
|
190
|
+
if (options.verbose) {
|
|
191
|
+
console.error(`Stack: ${error.stack}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
process.exit(1);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
199
|
+
publishContent();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { publishContent };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fetch from 'node-fetch';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { parse } from 'dotenv';
|
|
4
|
+
|
|
5
|
+
const envContent = readFileSync('.env', 'utf8');
|
|
6
|
+
const env = parse(envContent);
|
|
7
|
+
|
|
8
|
+
const apiKey = env.COOLIFY_API_KEY;
|
|
9
|
+
const url = env.COOLIFY_URL;
|
|
10
|
+
|
|
11
|
+
const payload = {
|
|
12
|
+
project_uuid: 'zg44coscocg0sko8k0wgcgkw',
|
|
13
|
+
server_uuid: 'vcscogc44gko4k880ww880kk',
|
|
14
|
+
environment_name: 'production',
|
|
15
|
+
git_repository: 'https://github.com/vercel/micro',
|
|
16
|
+
git_branch: 'main',
|
|
17
|
+
name: 'test-micro-app',
|
|
18
|
+
build_pack: 'nixpacks',
|
|
19
|
+
ports_exposes: '3000'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
console.log('Testing Coolify deployment...');
|
|
23
|
+
console.log('Payload:', JSON.stringify(payload, null, 2));
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const response = await fetch(`${url}/api/v1/applications/public`, {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
headers: {
|
|
29
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'Accept': 'application/json'
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify(payload)
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log('Status:', response.status);
|
|
37
|
+
console.log('Status Text:', response.statusText);
|
|
38
|
+
|
|
39
|
+
const data = await response.json().catch(() => ({}));
|
|
40
|
+
console.log('Response:', JSON.stringify(data, null, 2));
|
|
41
|
+
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
console.error('Error details:', data);
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error:', error.message);
|
|
47
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress Comprehensive Report Script
|
|
5
|
+
* Runs all checks and synthesizes into a comprehensive report
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* npx myaidev-method wordpress:comprehensive-report [options]
|
|
9
|
+
* node src/scripts/wordpress-comprehensive-report.js [options]
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { WordPressAdminUtils } from '../lib/wordpress-admin-utils.js';
|
|
13
|
+
import { ReportSynthesizer } from '../lib/report-synthesizer.js';
|
|
14
|
+
import { writeFileSync } from 'fs';
|
|
15
|
+
import { resolve } from 'path';
|
|
16
|
+
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
|
|
19
|
+
const options = {
|
|
20
|
+
format: 'markdown', // markdown or json
|
|
21
|
+
output: null, // file path for output
|
|
22
|
+
verbose: false,
|
|
23
|
+
includeHealth: true,
|
|
24
|
+
includeSecurity: true,
|
|
25
|
+
includePerformance: true,
|
|
26
|
+
saveIndividual: false // Save individual reports as well
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Parse arguments
|
|
30
|
+
for (let i = 0; i < args.length; i++) {
|
|
31
|
+
switch (args[i]) {
|
|
32
|
+
case '--format':
|
|
33
|
+
options.format = args[++i] || 'markdown';
|
|
34
|
+
break;
|
|
35
|
+
case '--output':
|
|
36
|
+
case '-o':
|
|
37
|
+
options.output = args[++i];
|
|
38
|
+
break;
|
|
39
|
+
case '--verbose':
|
|
40
|
+
case '-v':
|
|
41
|
+
options.verbose = true;
|
|
42
|
+
break;
|
|
43
|
+
case '--save-individual':
|
|
44
|
+
options.saveIndividual = true;
|
|
45
|
+
break;
|
|
46
|
+
case '--health-only':
|
|
47
|
+
options.includeSecurity = false;
|
|
48
|
+
options.includePerformance = false;
|
|
49
|
+
break;
|
|
50
|
+
case '--security-only':
|
|
51
|
+
options.includeHealth = false;
|
|
52
|
+
options.includePerformance = false;
|
|
53
|
+
break;
|
|
54
|
+
case '--performance-only':
|
|
55
|
+
options.includeHealth = false;
|
|
56
|
+
options.includeSecurity = false;
|
|
57
|
+
break;
|
|
58
|
+
case '--help':
|
|
59
|
+
case '-h':
|
|
60
|
+
printHelp();
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function printHelp() {
|
|
66
|
+
console.log(`
|
|
67
|
+
WordPress Comprehensive Report Script
|
|
68
|
+
|
|
69
|
+
Runs all WordPress admin checks and synthesizes them into a comprehensive report.
|
|
70
|
+
Perfect for regular site maintenance and agent-driven analysis.
|
|
71
|
+
|
|
72
|
+
Usage:
|
|
73
|
+
npx myaidev-method wordpress:comprehensive-report [options]
|
|
74
|
+
|
|
75
|
+
Options:
|
|
76
|
+
--format <type> Output format: markdown or json (default: markdown)
|
|
77
|
+
--output <file> Write output to file (default: stdout)
|
|
78
|
+
-o <file> Alias for --output
|
|
79
|
+
--verbose Show detailed progress information
|
|
80
|
+
-v Alias for --verbose
|
|
81
|
+
--save-individual Save individual report files as well
|
|
82
|
+
--health-only Only run health check
|
|
83
|
+
--security-only Only run security scan
|
|
84
|
+
--performance-only Only run performance check
|
|
85
|
+
--help Show this help message
|
|
86
|
+
-h Alias for --help
|
|
87
|
+
|
|
88
|
+
Environment Variables (from .env):
|
|
89
|
+
WORDPRESS_URL WordPress site URL
|
|
90
|
+
WORDPRESS_USERNAME Admin username
|
|
91
|
+
WORDPRESS_APP_PASSWORD Application password
|
|
92
|
+
|
|
93
|
+
This script runs:
|
|
94
|
+
✓ Health Check - Site health assessment
|
|
95
|
+
✓ Security Scan - Security vulnerability detection
|
|
96
|
+
✓ Performance Analysis - Performance metrics collection
|
|
97
|
+
|
|
98
|
+
Then synthesizes all results into a comprehensive report with:
|
|
99
|
+
✓ Executive summary with scores
|
|
100
|
+
✓ Critical issues requiring immediate attention
|
|
101
|
+
✓ Warnings and recommendations
|
|
102
|
+
✓ Prioritized action items
|
|
103
|
+
✓ Key metrics and statistics
|
|
104
|
+
|
|
105
|
+
Examples:
|
|
106
|
+
# Generate comprehensive markdown report
|
|
107
|
+
npx myaidev-method wordpress:comprehensive-report
|
|
108
|
+
|
|
109
|
+
# Save comprehensive report to file
|
|
110
|
+
npx myaidev-method wordpress:comprehensive-report --output wp-report.md
|
|
111
|
+
|
|
112
|
+
# Generate JSON report for agent processing
|
|
113
|
+
npx myaidev-method wordpress:comprehensive-report --format json
|
|
114
|
+
|
|
115
|
+
# Save all reports (comprehensive + individual)
|
|
116
|
+
npx myaidev-method wordpress:comprehensive-report --save-individual --output report.md
|
|
117
|
+
|
|
118
|
+
# Verbose mode with progress information
|
|
119
|
+
npx myaidev-method wordpress:comprehensive-report --verbose
|
|
120
|
+
|
|
121
|
+
Agent Integration:
|
|
122
|
+
This script is designed to work with the wordpress-admin agent. The agent can:
|
|
123
|
+
1. Run this script to get structured data
|
|
124
|
+
2. Process the JSON or markdown output
|
|
125
|
+
3. Generate natural language analysis
|
|
126
|
+
4. Provide actionable recommendations
|
|
127
|
+
|
|
128
|
+
Exit Codes:
|
|
129
|
+
0 - Report generated successfully, no critical issues
|
|
130
|
+
1 - Error occurred during analysis
|
|
131
|
+
2 - Report generated with warnings
|
|
132
|
+
3 - Report generated with critical issues
|
|
133
|
+
`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function runComprehensiveReport() {
|
|
137
|
+
const timestamp = new Date().toISOString();
|
|
138
|
+
const reports = [];
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
if (options.verbose) {
|
|
142
|
+
console.error('WordPress Comprehensive Report');
|
|
143
|
+
console.error('='.repeat(60));
|
|
144
|
+
console.error('Initializing WordPress connection...');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const wpUtils = new WordPressAdminUtils();
|
|
148
|
+
const synthesizer = new ReportSynthesizer();
|
|
149
|
+
|
|
150
|
+
// Run health check
|
|
151
|
+
if (options.includeHealth) {
|
|
152
|
+
if (options.verbose) {
|
|
153
|
+
console.error('\n[1/3] Running health check...');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const healthData = await wpUtils.runHealthCheck();
|
|
157
|
+
synthesizer.addReport(healthData, 'health');
|
|
158
|
+
reports.push({ type: 'health', data: healthData });
|
|
159
|
+
|
|
160
|
+
if (options.saveIndividual && options.output) {
|
|
161
|
+
const healthFile = options.output.replace(/\.(md|json)$/, '-health.json');
|
|
162
|
+
writeFileSync(healthFile, JSON.stringify(healthData, null, 2), 'utf8');
|
|
163
|
+
if (options.verbose) {
|
|
164
|
+
console.error(` Saved: ${healthFile}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Run security scan
|
|
170
|
+
if (options.includeSecurity) {
|
|
171
|
+
if (options.verbose) {
|
|
172
|
+
console.error('\n[2/3] Running security scan...');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const securityData = await wpUtils.runSecurityScan();
|
|
176
|
+
synthesizer.addReport(securityData, 'security');
|
|
177
|
+
reports.push({ type: 'security', data: securityData });
|
|
178
|
+
|
|
179
|
+
if (options.saveIndividual && options.output) {
|
|
180
|
+
const securityFile = options.output.replace(/\.(md|json)$/, '-security.json');
|
|
181
|
+
writeFileSync(securityFile, JSON.stringify(securityData, null, 2), 'utf8');
|
|
182
|
+
if (options.verbose) {
|
|
183
|
+
console.error(` Saved: ${securityFile}`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Run performance check
|
|
189
|
+
if (options.includePerformance) {
|
|
190
|
+
if (options.verbose) {
|
|
191
|
+
console.error('\n[3/3] Running performance analysis...');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const perfData = await wpUtils.getPerformanceMetrics();
|
|
195
|
+
const timing = await measureResponseTime(wpUtils, 3);
|
|
196
|
+
|
|
197
|
+
const performanceData = {
|
|
198
|
+
success: true,
|
|
199
|
+
timestamp,
|
|
200
|
+
site: await wpUtils.getSiteInfo().catch(() => ({ url: wpUtils.url })),
|
|
201
|
+
performance_score: 85, // Calculate based on metrics
|
|
202
|
+
timing,
|
|
203
|
+
metrics: perfData,
|
|
204
|
+
recommendations: []
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
synthesizer.addReport(performanceData, 'performance');
|
|
208
|
+
reports.push({ type: 'performance', data: performanceData });
|
|
209
|
+
|
|
210
|
+
if (options.saveIndividual && options.output) {
|
|
211
|
+
const perfFile = options.output.replace(/\.(md|json)$/, '-performance.json');
|
|
212
|
+
writeFileSync(perfFile, JSON.stringify(performanceData, null, 2), 'utf8');
|
|
213
|
+
if (options.verbose) {
|
|
214
|
+
console.error(` Saved: ${perfFile}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (options.verbose) {
|
|
220
|
+
console.error('\nSynthesizing comprehensive report...');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Generate comprehensive report
|
|
224
|
+
let output;
|
|
225
|
+
if (options.format === 'json') {
|
|
226
|
+
output = synthesizer.generateJSONReport();
|
|
227
|
+
} else {
|
|
228
|
+
output = synthesizer.generateMarkdownReport();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (options.verbose) {
|
|
232
|
+
console.error('Report generation completed.');
|
|
233
|
+
console.error('='.repeat(60));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Write output
|
|
237
|
+
if (options.output) {
|
|
238
|
+
const outputPath = resolve(options.output);
|
|
239
|
+
writeFileSync(outputPath, output, 'utf8');
|
|
240
|
+
|
|
241
|
+
if (options.verbose) {
|
|
242
|
+
console.error(`\nComprehensive report written to: ${outputPath}`);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Output summary for piping
|
|
246
|
+
const synthesis = synthesizer.synthesize();
|
|
247
|
+
console.log(JSON.stringify({
|
|
248
|
+
success: true,
|
|
249
|
+
output_file: outputPath,
|
|
250
|
+
overall_status: synthesis.executive_summary.overall_status,
|
|
251
|
+
critical_issues: synthesis.critical_issues.length,
|
|
252
|
+
warnings: synthesis.warnings.length,
|
|
253
|
+
reports_generated: reports.length
|
|
254
|
+
}));
|
|
255
|
+
} else {
|
|
256
|
+
console.log(output);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Determine exit code
|
|
260
|
+
const synthesis = synthesizer.synthesize();
|
|
261
|
+
const criticalCount = synthesis.critical_issues.length;
|
|
262
|
+
const warningCount = synthesis.warnings.length;
|
|
263
|
+
|
|
264
|
+
if (criticalCount > 0) {
|
|
265
|
+
process.exit(3); // Critical issues
|
|
266
|
+
} else if (warningCount > 0) {
|
|
267
|
+
process.exit(2); // Warnings
|
|
268
|
+
} else {
|
|
269
|
+
process.exit(0); // All clear
|
|
270
|
+
}
|
|
271
|
+
} catch (error) {
|
|
272
|
+
const errorOutput = {
|
|
273
|
+
success: false,
|
|
274
|
+
error: error.message,
|
|
275
|
+
timestamp,
|
|
276
|
+
reports_completed: reports.length
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
if (options.format === 'json') {
|
|
280
|
+
console.log(JSON.stringify(errorOutput, null, 2));
|
|
281
|
+
} else {
|
|
282
|
+
console.error(`\nERROR: ${error.message}`);
|
|
283
|
+
console.error(`Stack: ${error.stack}`);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
async function measureResponseTime(wpUtils, iterations) {
|
|
291
|
+
const measurements = [];
|
|
292
|
+
|
|
293
|
+
for (let i = 0; i < iterations; i++) {
|
|
294
|
+
const start = Date.now();
|
|
295
|
+
try {
|
|
296
|
+
await wpUtils.request('/');
|
|
297
|
+
measurements.push(Date.now() - start);
|
|
298
|
+
} catch (error) {
|
|
299
|
+
// Skip failed measurements
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (i < iterations - 1) {
|
|
303
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (measurements.length === 0) return null;
|
|
308
|
+
|
|
309
|
+
const avg = measurements.reduce((a, b) => a + b, 0) / measurements.length;
|
|
310
|
+
const sorted = measurements.sort((a, b) => a - b);
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
average: Math.round(avg),
|
|
314
|
+
median: Math.round(sorted[Math.floor(sorted.length / 2)]),
|
|
315
|
+
min: sorted[0],
|
|
316
|
+
max: sorted[sorted.length - 1]
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Run if called directly
|
|
321
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
322
|
+
runComprehensiveReport();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export { runComprehensiveReport };
|