@amiable-dev/docusaurus-plugin-stentorosaur 0.18.0 → 0.19.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/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -1
- package/scripts/postinstall.js +115 -0
package/lib/version.d.ts
CHANGED
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amiable-dev/docusaurus-plugin-stentorosaur",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "A Docusaurus plugin for displaying status monitoring dashboard powered by GitHub Issues and Actions, similar to Upptime",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-status.d.ts",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"watch": "tsc --build --watch",
|
|
46
46
|
"dev": "tsc --build --watch",
|
|
47
47
|
"prebuild": "node scripts/generate-version.js",
|
|
48
|
+
"postinstall": "node scripts/postinstall.js",
|
|
48
49
|
"update-status": "node scripts/update-status.js",
|
|
49
50
|
"setup-status-branch": "node scripts/setup-status-branch.js",
|
|
50
51
|
"migrate-to-status-branch": "node scripts/migrate-to-status-branch.js",
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall script for @amiable-dev/docusaurus-plugin-stentorosaur
|
|
5
|
+
* Automatically integrates status monitoring commands into the consuming project's Makefile
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// Find the consuming project root (go up from node_modules)
|
|
12
|
+
function findProjectRoot() {
|
|
13
|
+
let current = process.cwd();
|
|
14
|
+
|
|
15
|
+
// If we're in node_modules, go up to find project root
|
|
16
|
+
while (current.includes('node_modules')) {
|
|
17
|
+
current = path.dirname(current);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Verify this looks like a project root
|
|
21
|
+
if (fs.existsSync(path.join(current, 'package.json'))) {
|
|
22
|
+
return current;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Status monitoring section to add to help
|
|
29
|
+
const STATUS_HELP_SECTION = `
|
|
30
|
+
@echo ""
|
|
31
|
+
@echo "$(GREEN)Status Monitoring:$(NC) (run 'make status-help' for full list)"
|
|
32
|
+
@echo " $(YELLOW)status-add-system $(NC) Add endpoint to monitor (name=x url=y)"
|
|
33
|
+
@echo " $(YELLOW)status-list $(NC) List all monitored systems"
|
|
34
|
+
@echo " $(YELLOW)status-test $(NC) Test monitoring configuration"
|
|
35
|
+
@echo " $(YELLOW)status-help $(NC) Show all status commands"`;
|
|
36
|
+
|
|
37
|
+
// Include statement
|
|
38
|
+
const INCLUDE_STATEMENT = '-include node_modules/@amiable-dev/docusaurus-plugin-stentorosaur/templates/Makefile.status';
|
|
39
|
+
|
|
40
|
+
function patchMakefile(projectRoot) {
|
|
41
|
+
const makefilePath = path.join(projectRoot, 'Makefile');
|
|
42
|
+
|
|
43
|
+
if (!fs.existsSync(makefilePath)) {
|
|
44
|
+
console.log('[stentorosaur] No Makefile found - skipping integration');
|
|
45
|
+
console.log('[stentorosaur] Run "make status-help" after creating a Makefile with the include statement');
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let content = fs.readFileSync(makefilePath, 'utf8');
|
|
50
|
+
let modified = false;
|
|
51
|
+
|
|
52
|
+
// Check if include statement already exists
|
|
53
|
+
if (!content.includes('docusaurus-plugin-stentorosaur/templates/Makefile.status')) {
|
|
54
|
+
// Add include at the end
|
|
55
|
+
content = content.trimEnd() + '\n\n# Status Monitoring (Stentorosaur)\n' + INCLUDE_STATEMENT + '\n';
|
|
56
|
+
modified = true;
|
|
57
|
+
console.log('[stentorosaur] Added Makefile.status include statement');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Check if status help section exists in help target
|
|
61
|
+
if (content.includes('help:') && !content.includes('Status Monitoring:')) {
|
|
62
|
+
// Find the help target and add status section before the next target or end
|
|
63
|
+
// Look for pattern: help target ends with empty @echo "" line
|
|
64
|
+
const helpPattern = /(help:.*?@echo\s+["']["']\s*\n)(\n*#|\n*[a-zA-Z_-]+:|$)/s;
|
|
65
|
+
const match = content.match(helpPattern);
|
|
66
|
+
|
|
67
|
+
if (match) {
|
|
68
|
+
// Insert status help section after the last @echo "" in help target
|
|
69
|
+
const insertPoint = match.index + match[1].length;
|
|
70
|
+
content = content.slice(0, insertPoint) + STATUS_HELP_SECTION + '\n' + content.slice(insertPoint);
|
|
71
|
+
modified = true;
|
|
72
|
+
console.log('[stentorosaur] Added Status Monitoring section to make help');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (modified) {
|
|
77
|
+
fs.writeFileSync(makefilePath, content);
|
|
78
|
+
console.log('[stentorosaur] Makefile updated successfully');
|
|
79
|
+
return true;
|
|
80
|
+
} else {
|
|
81
|
+
console.log('[stentorosaur] Makefile already configured');
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function main() {
|
|
87
|
+
// Skip if running in CI or during npm publish
|
|
88
|
+
if (process.env.CI || process.env.npm_config_ignore_scripts) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const projectRoot = findProjectRoot();
|
|
93
|
+
|
|
94
|
+
if (!projectRoot) {
|
|
95
|
+
// Likely running during development of the plugin itself
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Don't run if this is the plugin's own directory
|
|
100
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
101
|
+
if (fs.existsSync(pkgPath)) {
|
|
102
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
103
|
+
if (pkg.name === '@amiable-dev/docusaurus-plugin-stentorosaur') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
patchMakefile(projectRoot);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
console.error('[stentorosaur] Warning: Could not patch Makefile:', err.message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main();
|