froggy-docs 1.0.5 → 1.0.7
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/bin/froggy-docs +0 -0
- package/lib/src/web_server.dart +23 -14
- package/package.json +1 -1
package/bin/froggy-docs
CHANGED
|
Binary file
|
package/lib/src/web_server.dart
CHANGED
|
@@ -9,6 +9,8 @@ import 'package:path/path.dart' as p;
|
|
|
9
9
|
const defaultPort = 8080;
|
|
10
10
|
|
|
11
11
|
Future<void> startServer({int port = defaultPort}) async {
|
|
12
|
+
_debugPaths();
|
|
13
|
+
|
|
12
14
|
final handler = const Pipeline()
|
|
13
15
|
.addMiddleware(logRequests())
|
|
14
16
|
.addHandler(_router.call);
|
|
@@ -29,24 +31,33 @@ const _corsHeaders = {
|
|
|
29
31
|
String get _packageDir {
|
|
30
32
|
final exePath = Platform.resolvedExecutable;
|
|
31
33
|
final exeDir = File(exePath).parent.path;
|
|
32
|
-
|
|
33
|
-
print('DEBUG: exePath = $exePath');
|
|
34
|
-
print('DEBUG: exeDir = $exeDir');
|
|
35
|
-
print('DEBUG: packageDir = $packageDir');
|
|
36
|
-
print('DEBUG: webDir = ${p.join(packageDir, 'frontend', 'web')}');
|
|
37
|
-
return packageDir;
|
|
34
|
+
return p.dirname(exeDir);
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
String get webDir => p.join(_packageDir, 'frontend', 'web');
|
|
41
38
|
String get deployDir => p.join(_packageDir, 'frontend', 'deploy', 'web');
|
|
42
39
|
|
|
40
|
+
String get userWebDir => p.join(Directory.current.path, 'frontend', 'web');
|
|
41
|
+
|
|
42
|
+
void _debugPaths() {
|
|
43
|
+
print('DEBUG: packageDir = $_packageDir');
|
|
44
|
+
print('DEBUG: webDir = $webDir');
|
|
45
|
+
print('DEBUG: userWebDir = $userWebDir');
|
|
46
|
+
print('DEBUG: currentDir = ${Directory.current.path}');
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
Router get _router {
|
|
44
50
|
final router = Router();
|
|
45
51
|
|
|
46
52
|
router.get('/froggy_docs.json', (Request request) async {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
var file = File(p.join(userWebDir, 'froggy_docs.json'));
|
|
54
|
+
if (await file.existsSync()) {
|
|
55
|
+
return Response.ok(
|
|
56
|
+
file.openRead(),
|
|
57
|
+
headers: {'Content-Type': 'application/json'},
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
file = File(p.join(webDir, 'froggy_docs.json'));
|
|
50
61
|
if (await file.existsSync()) {
|
|
51
62
|
return Response.ok(
|
|
52
63
|
file.openRead(),
|
|
@@ -57,9 +68,7 @@ Router get _router {
|
|
|
57
68
|
});
|
|
58
69
|
|
|
59
70
|
router.get('/', (Request request) async {
|
|
60
|
-
final indexFile = File(
|
|
61
|
-
p.join(Directory.current.path, deployDir, 'index.html'),
|
|
62
|
-
);
|
|
71
|
+
final indexFile = File(p.join(webDir, 'index.html'));
|
|
63
72
|
if (await indexFile.existsSync()) {
|
|
64
73
|
return Response.ok(
|
|
65
74
|
indexFile.openRead(),
|
|
@@ -141,14 +150,14 @@ Router get _router {
|
|
|
141
150
|
// ═════════════════════════════════════════════════════════════
|
|
142
151
|
|
|
143
152
|
router.get('/<path|[^/]+>', (Request request, String path) async {
|
|
144
|
-
var file = File(p.join(
|
|
153
|
+
var file = File(p.join(deployDir, path));
|
|
145
154
|
if (await file.existsSync()) {
|
|
146
155
|
return Response.ok(
|
|
147
156
|
file.openRead(),
|
|
148
157
|
headers: {'Content-Type': _getContentType(path)},
|
|
149
158
|
);
|
|
150
159
|
}
|
|
151
|
-
file = File(p.join(
|
|
160
|
+
file = File(p.join(webDir, path));
|
|
152
161
|
if (await file.existsSync()) {
|
|
153
162
|
return Response.ok(
|
|
154
163
|
file.openRead(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froggy-docs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Auto-generate API documentation from code annotations. Works with any programming language.",
|
|
5
5
|
"author": "Kaung Mrat Thu <kaungmyatthuu.dev@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/Kaung-Myat/froggydocs",
|