@icyouo/evt-cli 0.1.5 → 0.1.6

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 CHANGED
@@ -63,6 +63,10 @@ evt validate
63
63
  use that value when `--profile` is omitted. Passing `--profile <name>` still
64
64
  overrides the default for one command.
65
65
 
66
+ Runtime state is kept under `.evt/` in the active config root. Session cache and
67
+ live-test reports are written to `.evt/cache/`. The older `.cache/session.local.json`
68
+ path is still read as a compatibility fallback, but new writes use `.evt/cache/`.
69
+
66
70
  ## Data Layout
67
71
 
68
72
  Recommended project data layout:
package/README.zh-CN.md CHANGED
@@ -62,6 +62,10 @@ evt validate
62
62
  `.evt/config.json`。需要 profile 的命令在未传 `--profile` 时会使用这个默认值。
63
63
  临时传入 `--profile <name>` 仍然可以覆盖本次命令。
64
64
 
65
+ 运行时状态统一放在当前 config root 下的 `.evt/`。登录 session cache 和真实接口测试
66
+ 报告会写到 `.evt/cache/`。旧的 `.cache/session.local.json` 仍会作为兼容 fallback 读取,
67
+ 但新的写入都会进入 `.evt/cache/`。
68
+
65
69
  ## 数据目录
66
70
 
67
71
  项目数据目录结构:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icyouo/evt-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Run YAML-defined HTTP APIs and interactive workflows from your terminal.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "scripts": {
28
28
  "ci:local": "node scripts/local-ci.js",
29
29
  "test": "node --test",
30
- "check": "node --check bin/evt.js && node --check src/index.js && node --check src/util/settings.js && node --check src/flow/inputResolver.js && node --check src/api/liveTester.js && node --check scripts/sync-api-coverage.js && node --check scripts/check-api-coverage.js && node --check scripts/check-api-audit.js && node --check scripts/local-ci.js && node --check scripts/build-package.js && node --check skills/evt-api-scanner/scripts/discover.js && node --check skills/evt-api-scanner/scripts/scan.js",
30
+ "check": "node --check bin/evt.js && node --check src/index.js && node --check src/util/paths.js && node --check src/util/settings.js && node --check src/cache/sessionCache.js && node --check src/flow/inputResolver.js && node --check src/api/liveTester.js && node --check scripts/sync-api-coverage.js && node --check scripts/check-api-coverage.js && node --check scripts/check-api-audit.js && node --check scripts/local-ci.js && node --check scripts/build-package.js && node --check skills/evt-api-scanner/scripts/discover.js && node --check skills/evt-api-scanner/scripts/scan.js",
31
31
  "package:local": "node scripts/build-package.js",
32
32
  "sync:api": "node scripts/sync-api-coverage.js",
33
33
  "coverage:api": "node scripts/check-api-coverage.js",
@@ -4,7 +4,7 @@ const { buildRequest } = require("../http/requestBuilder");
4
4
  const { readCache } = require("../cache/sessionCache");
5
5
  const { loadFlow } = require("../config/loaders");
6
6
  const { runFlow } = require("../flow/runner");
7
- const { resolveCliPath } = require("../util/paths");
7
+ const { defaultCacheDir } = require("../util/paths");
8
8
  const { redact } = require("../util/redact");
9
9
 
10
10
  function isPlainObject(value) {
@@ -16,7 +16,7 @@ function nowCompact() {
16
16
  }
17
17
 
18
18
  function ensureCacheDir() {
19
- const dir = resolveCliPath(".cache");
19
+ const dir = defaultCacheDir();
20
20
  fs.mkdirSync(dir, { recursive: true });
21
21
  return dir;
22
22
  }
@@ -1,6 +1,6 @@
1
1
  const fs = require("node:fs");
2
2
  const path = require("node:path");
3
- const { defaultCachePath } = require("../util/paths");
3
+ const { defaultCachePath, legacyCachePath } = require("../util/paths");
4
4
 
5
5
  function resolveCachePath(cachePath) {
6
6
  return cachePath ? path.resolve(cachePath) : defaultCachePath();
@@ -8,10 +8,12 @@ function resolveCachePath(cachePath) {
8
8
 
9
9
  function readCache(cachePath) {
10
10
  const file = resolveCachePath(cachePath);
11
- if (!fs.existsSync(file)) {
11
+ const legacyFile = !cachePath ? legacyCachePath() : undefined;
12
+ const readableFile = fs.existsSync(file) ? file : legacyFile;
13
+ if (!readableFile || !fs.existsSync(readableFile)) {
12
14
  return {};
13
15
  }
14
- return JSON.parse(fs.readFileSync(file, "utf8"));
16
+ return JSON.parse(fs.readFileSync(readableFile, "utf8"));
15
17
  }
16
18
 
17
19
  function writeCache(cachePath, value) {
package/src/util/paths.js CHANGED
@@ -25,13 +25,23 @@ function resolveConfigDir(name) {
25
25
  }
26
26
 
27
27
  function defaultCachePath() {
28
+ return resolveCliPath(".evt", "cache", "session.local.json");
29
+ }
30
+
31
+ function legacyCachePath() {
28
32
  return resolveCliPath(".cache", "session.local.json");
29
33
  }
30
34
 
35
+ function defaultCacheDir() {
36
+ return resolveCliPath(".evt", "cache");
37
+ }
38
+
31
39
  module.exports = {
32
40
  cliRoot,
33
41
  configRoot,
42
+ defaultCacheDir,
34
43
  defaultCachePath,
44
+ legacyCachePath,
35
45
  resolveCliPath,
36
46
  resolveConfigDir,
37
47
  setConfigRoot
@@ -0,0 +1,30 @@
1
+ const fs = require("node:fs");
2
+ const os = require("node:os");
3
+ const path = require("node:path");
4
+ const test = require("node:test");
5
+ const assert = require("node:assert/strict");
6
+ const { readCache, resolveCachePath, writeCache } = require("../src/cache/sessionCache");
7
+ const { defaultCachePath, setConfigRoot } = require("../src/util/paths");
8
+
9
+ test("uses .evt/cache as the default session cache directory", () => {
10
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "evt-cache-new-"));
11
+ setConfigRoot(root);
12
+
13
+ assert.equal(defaultCachePath(), path.join(root, ".evt", "cache", "session.local.json"));
14
+ assert.equal(resolveCachePath(), path.join(root, ".evt", "cache", "session.local.json"));
15
+
16
+ writeCache(undefined, { token: "new-token" });
17
+ assert.equal(fs.existsSync(path.join(root, ".evt", "cache", "session.local.json")), true);
18
+ assert.deepEqual(readCache(), { token: "new-token" });
19
+ });
20
+
21
+ test("reads legacy .cache session cache when new cache does not exist", () => {
22
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "evt-cache-legacy-"));
23
+ setConfigRoot(root);
24
+ fs.mkdirSync(path.join(root, ".cache"), { recursive: true });
25
+ fs.writeFileSync(path.join(root, ".cache", "session.local.json"), JSON.stringify({
26
+ token: "legacy-token"
27
+ }));
28
+
29
+ assert.deepEqual(readCache(), { token: "legacy-token" });
30
+ });