apigrip 0.2.2 → 0.2.3
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/cli/commands/serve.js +11 -2
- package/package.json +3 -2
- package/server/index.js +4 -2
package/cli/commands/serve.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { parseSpec } from '../../core/spec-parser.js';
|
|
4
4
|
import { createServer } from '../../server/index.js';
|
|
5
|
-
import { findProjectForDir } from '../../core/projects-store.js';
|
|
5
|
+
import { findProjectForDir, loadProjects } from '../../core/projects-store.js';
|
|
6
6
|
import { discoverSpec } from '../../core/spec-discovery.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -39,7 +39,16 @@ async function resolveServeProject(argv) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// 4.
|
|
42
|
+
// 4. Fall back to the first bookmarked project
|
|
43
|
+
const projects = loadProjects();
|
|
44
|
+
if (projects.length > 0) {
|
|
45
|
+
const proj = projects[0];
|
|
46
|
+
const discovered = proj.spec ? null : await discoverSpec(proj.path);
|
|
47
|
+
const specPath = proj.spec || discovered?.specPath || null;
|
|
48
|
+
return { projectDir: proj.path, specPath };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 5. Start without a project — user can open from history in the UI
|
|
43
52
|
return { projectDir: null, specPath: null };
|
|
44
53
|
}
|
|
45
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apigrip",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A spec-first, read-only OpenAPI client for developers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.cjs",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"build": "vite build --config client/vite.config.js",
|
|
29
29
|
"test": "node --test $(find test -name '*.test.js')",
|
|
30
30
|
"test:client": "vitest run --config client/vitest.config.js",
|
|
31
|
-
"prepare": "npm run build"
|
|
31
|
+
"prepare": "test -d client/src && npm run build || true",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
32
33
|
},
|
|
33
34
|
"keywords": [
|
|
34
35
|
"openapi",
|
package/server/index.js
CHANGED
|
@@ -49,8 +49,10 @@ export function createServer(options = {}) {
|
|
|
49
49
|
app.use(express.static(clientDist));
|
|
50
50
|
|
|
51
51
|
// SPA fallback: serve index.html for all non-API routes
|
|
52
|
-
app.get('/{*splat}', (req, res) => {
|
|
53
|
-
res.sendFile(indexHtml)
|
|
52
|
+
app.get('/{*splat}', (req, res, next) => {
|
|
53
|
+
res.sendFile(indexHtml, (err) => {
|
|
54
|
+
if (err) next(err);
|
|
55
|
+
});
|
|
54
56
|
});
|
|
55
57
|
} else {
|
|
56
58
|
app.get('/{*splat}', (req, res) => {
|