apiskill 0.1.0 → 0.1.2
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/README.md +2 -2
- package/README.zh.md +2 -2
- package/dist/assets/index-BeAJ1G-n.css +1 -0
- package/dist/assets/index-CPxVZ06Y.js +299 -0
- package/dist/index.html +2 -2
- package/docs/cli.md +1 -1
- package/docs/cli.zh.md +1 -1
- package/docs/web.md +1 -1
- package/docs/web.zh.md +2 -2
- package/package.json +1 -1
- package/scripts/apiskill-cli.mjs +13 -4
- package/scripts/lib/cache-paths.mjs +8 -0
- package/scripts/lib/openapi-store.mjs +2 -3
- package/scripts/mcp-server.mjs +2 -1
- package/src/App.tsx +213 -186
- package/src/styles.css +160 -3
- package/vite.config.ts +2 -1
- package/dist/assets/index-DH0wsJCI.js +0 -299
- package/dist/assets/index-vocUDpcf.css +0 -1
package/dist/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>API Skill Console</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-CPxVZ06Y.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BeAJ1G-n.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
package/docs/cli.md
CHANGED
|
@@ -12,7 +12,7 @@ apiskill --help
|
|
|
12
12
|
apiskill run web
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`apiskill run web` starts the web console and writes cache data to
|
|
15
|
+
`apiskill run web` starts the web console and writes cache data to the user-writable `~/.apiskill/cache` directory by default. `--cwd` uses `<cwd>/cache`; `--cache-dir` selects an explicit location:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
apiskill run web --port 8890
|
package/docs/cli.zh.md
CHANGED
|
@@ -12,7 +12,7 @@ apiskill --help
|
|
|
12
12
|
apiskill run web
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`apiskill run web` 会启动 Web
|
|
15
|
+
`apiskill run web` 会启动 Web 控制台,默认把缓存写入用户可写的 `~/.apiskill/cache`。使用 `--cwd` 时缓存位于 `<cwd>/cache`,也可以用 `--cache-dir` 指定其他目录:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
apiskill run web --port 8890
|
package/docs/web.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install -g apiskill
|
|
|
11
11
|
apiskill run web
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Global npm installations use the user-writable `~/.apiskill/cache` directory by default. Use `--cwd` for a project-local `<cwd>/cache`, or `--cache-dir` for an explicit path. When developing this repository, you can also use:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
npm install
|
package/docs/web.zh.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install -g apiskill
|
|
|
11
11
|
apiskill run web
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
通过 npm 全局安装时,默认缓存目录是用户可写的 `~/.apiskill/cache`。使用 `--cwd` 可切换为项目目录下的 `<cwd>/cache`,使用 `--cache-dir` 可指定其他位置。开发本仓库时也可以使用:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
npm install
|
|
@@ -22,7 +22,7 @@ npm run dev
|
|
|
22
22
|
|
|
23
23
|
## 导入来源
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
“新建文档”弹窗通过 Tab 支持空白文档和四种导入方式:
|
|
26
26
|
|
|
27
27
|
- 直接导入 OpenAPI/Swagger JSON 或 YAML 地址。
|
|
28
28
|
- 爬取 Swagger UI、Knife4j、Redoc 页面。
|
package/package.json
CHANGED
package/scripts/apiskill-cli.mjs
CHANGED
|
@@ -19,14 +19,17 @@ import {
|
|
|
19
19
|
import { crawlOpenApi, importFromCurl, importFromLocalFile, importFromUrl } from './lib/openapi-importer.mjs';
|
|
20
20
|
import { checkCache, formatCheckText, queryEndpoints } from './lib/apiskill-core.mjs';
|
|
21
21
|
import { startMockServer } from './lib/mock-server.mjs';
|
|
22
|
+
import { getDefaultCacheDir } from './lib/cache-paths.mjs';
|
|
22
23
|
|
|
23
24
|
const program = new Command();
|
|
24
25
|
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
26
|
+
const packageJson = JSON.parse(await readFile(resolve(packageRoot, 'package.json'), 'utf8'));
|
|
27
|
+
const cliVersion = typeof packageJson.version === 'string' ? packageJson.version : '0.0.0';
|
|
25
28
|
|
|
26
29
|
program
|
|
27
30
|
.name('apiskill')
|
|
28
31
|
.description('API Skill CLI: import OpenAPI docs and create/query/edit/delete local API configs.')
|
|
29
|
-
.version(
|
|
32
|
+
.version(cliVersion, '-V, --cli-version', 'Print CLI version')
|
|
30
33
|
.showHelpAfterError()
|
|
31
34
|
.addHelpText(
|
|
32
35
|
'after',
|
|
@@ -64,8 +67,8 @@ run
|
|
|
64
67
|
.option('-p, --port <number>', 'Web server port', '8888')
|
|
65
68
|
.option('--host <host>', 'Host to bind', '127.0.0.1')
|
|
66
69
|
.option('--strict-port', 'Fail if the requested port is already in use')
|
|
67
|
-
.option('--cwd <dir>', 'Project directory
|
|
68
|
-
.option('--cache-dir <dir>', 'Cache directory. Defaults to
|
|
70
|
+
.option('--cwd <dir>', 'Project directory. Uses <cwd>/cache unless --cache-dir is provided')
|
|
71
|
+
.option('--cache-dir <dir>', 'Cache directory. Defaults to ~/.apiskill/cache')
|
|
69
72
|
.action(async (options) => {
|
|
70
73
|
await runWeb(options);
|
|
71
74
|
});
|
|
@@ -294,7 +297,11 @@ function registerMockCommand(command) {
|
|
|
294
297
|
|
|
295
298
|
async function runWeb(options) {
|
|
296
299
|
const projectRoot = resolve(options.cwd || process.cwd());
|
|
297
|
-
const cacheDir = options.cacheDir
|
|
300
|
+
const cacheDir = options.cacheDir
|
|
301
|
+
? resolve(projectRoot, options.cacheDir)
|
|
302
|
+
: options.cwd
|
|
303
|
+
? resolve(projectRoot, 'cache')
|
|
304
|
+
: getDefaultCacheDir();
|
|
298
305
|
const port = Number(options.port) || 8888;
|
|
299
306
|
const host = options.host || '127.0.0.1';
|
|
300
307
|
|
|
@@ -305,6 +312,8 @@ async function runWeb(options) {
|
|
|
305
312
|
const server = await createServer({
|
|
306
313
|
root: packageRoot,
|
|
307
314
|
configFile: resolve(packageRoot, 'vite.config.ts'),
|
|
315
|
+
configLoader: 'runner',
|
|
316
|
+
cacheDir: resolve(cacheDir, '.vite'),
|
|
308
317
|
clearScreen: false,
|
|
309
318
|
server: {
|
|
310
319
|
host,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export function getDefaultCacheDir(env = process.env) {
|
|
5
|
+
if (env.APISKILL_CACHE_DIR) return resolve(env.APISKILL_CACHE_DIR);
|
|
6
|
+
if (env.APISKILL_ROOT) return resolve(env.APISKILL_ROOT, 'cache');
|
|
7
|
+
return resolve(homedir(), '.apiskill', 'cache');
|
|
8
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { basename, dirname, resolve } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
4
|
import { parse as parseYaml } from 'yaml';
|
|
5
|
+
import { getDefaultCacheDir } from './cache-paths.mjs';
|
|
6
6
|
|
|
7
7
|
export const METHODS = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const cacheDir = process.env.APISKILL_CACHE_DIR || resolve(rootDir, 'cache');
|
|
9
|
+
const cacheDir = getDefaultCacheDir();
|
|
11
10
|
const versionsDir = resolve(cacheDir, 'versions');
|
|
12
11
|
const latestMetaPath = resolve(cacheDir, 'latest-import.json');
|
|
13
12
|
const legacyCachePath = resolve(cacheDir, 'openapi-cache.json');
|
package/scripts/mcp-server.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
queryApi,
|
|
18
18
|
searchEndpoints,
|
|
19
19
|
} from './lib/apiskill-core.mjs';
|
|
20
|
+
import { getDefaultCacheDir } from './lib/cache-paths.mjs';
|
|
20
21
|
|
|
21
22
|
const SERVER_VERSION = '0.1.0';
|
|
22
23
|
|
|
@@ -238,7 +239,7 @@ const handlers = {
|
|
|
238
239
|
|
|
239
240
|
function buildHelp() {
|
|
240
241
|
const rootDir = process.env.APISKILL_ROOT || '/Users/dobby/dev/apiskill';
|
|
241
|
-
const cacheDir =
|
|
242
|
+
const cacheDir = getDefaultCacheDir();
|
|
242
243
|
const readTools = [
|
|
243
244
|
'apiskill_check',
|
|
244
245
|
'apiskill_help',
|