@drift-agent/api-drift-engine 2.5.4 → 5.2.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  API schema diff engine — detect breaking changes in **OpenAPI**, **GraphQL**, and **gRPC** schemas.
4
4
 
5
- Thin npm wrapper around the [`drift-guard`](https://github.com/DriftAgent/api-drift-engine) Go binary. On install, the correct pre-built binary for your platform is downloaded automatically.
5
+ Thin npm wrapper around the [`drift-agent`](https://github.com/DriftAgent/api-drift-engine) Go binary. On install, the correct pre-built binary for your platform is downloaded automatically.
6
6
 
7
7
  ## Installation
8
8
 
@@ -14,32 +14,32 @@ Requires Node.js ≥ 16. The binary is downloaded for your platform (macOS arm64
14
14
 
15
15
  ## CLI
16
16
 
17
- After installing, the `drift-guard` binary is available as an npm bin:
17
+ After installing, the `drift-agent` binary is available as an npm bin:
18
18
 
19
19
  ```sh
20
- npx drift-guard --help
20
+ npx drift-agent --help
21
21
  ```
22
22
 
23
23
  ### OpenAPI
24
24
 
25
25
  ```sh
26
- drift-guard openapi --base old.yaml --head new.yaml
27
- drift-guard openapi --base old.yaml --head new.yaml --format json
28
- drift-guard openapi --base old.yaml --head new.yaml --fail-on-breaking
26
+ drift-agent openapi --base old.yaml --head new.yaml
27
+ drift-agent openapi --base old.yaml --head new.yaml --format json
28
+ drift-agent openapi --base old.yaml --head new.yaml --fail-on-breaking
29
29
  ```
30
30
 
31
31
  ### GraphQL
32
32
 
33
33
  ```sh
34
- drift-guard graphql --base old.graphql --head new.graphql
35
- drift-guard graphql --base old.graphql --head new.graphql --format markdown
34
+ drift-agent graphql --base old.graphql --head new.graphql
35
+ drift-agent graphql --base old.graphql --head new.graphql --format markdown
36
36
  ```
37
37
 
38
38
  ### gRPC / Protobuf
39
39
 
40
40
  ```sh
41
- drift-guard grpc --base old.proto --head new.proto
42
- drift-guard grpc --base old.proto --head new.proto --format json
41
+ drift-agent grpc --base old.proto --head new.proto
42
+ drift-agent grpc --base old.proto --head new.proto --format json
43
43
  ```
44
44
 
45
45
  ### Impact analysis
@@ -48,15 +48,15 @@ Scan source code for references to each breaking change:
48
48
 
49
49
  ```sh
50
50
  # From a saved diff JSON
51
- drift-guard openapi --base old.yaml --head new.yaml --format json > diff.json
52
- drift-guard impact --diff diff.json --scan ./src
51
+ drift-agent openapi --base old.yaml --head new.yaml --format json > diff.json
52
+ drift-agent impact --diff diff.json --scan ./src
53
53
 
54
54
  # Pipe mode
55
- drift-guard openapi --base old.yaml --head new.yaml --format json \
56
- | drift-guard impact --scan ./src
55
+ drift-agent openapi --base old.yaml --head new.yaml --format json \
56
+ | drift-agent impact --scan ./src
57
57
 
58
58
  # Output as markdown
59
- drift-guard impact --diff diff.json --scan ./src --format markdown
59
+ drift-agent impact --diff diff.json --scan ./src --format markdown
60
60
  ```
61
61
 
62
62
  ## Node.js / TypeScript API
package/index.d.ts CHANGED
@@ -34,7 +34,7 @@ export interface Hit {
34
34
  }
35
35
 
36
36
  export interface ImpactOptions {
37
- format?: "text" | "json" | "markdown";
37
+ format?: "text" | "json" | "markdown" | "github";
38
38
  }
39
39
 
40
40
  /** Diff two OpenAPI 3.x schemas (YAML or JSON). */
@@ -51,5 +51,5 @@ export function compareGRPC(base: string, head: string): DiffResult;
51
51
  * Returns Hit[] when format is "json" (default), otherwise a formatted string.
52
52
  */
53
53
  export function impact(diffResult: DiffResult, scanDir?: string, options?: ImpactOptions & { format: "json" }): Hit[];
54
- export function impact(diffResult: DiffResult, scanDir?: string, options?: ImpactOptions & { format: "text" | "markdown" }): string;
54
+ export function impact(diffResult: DiffResult, scanDir?: string, options?: ImpactOptions & { format: "text" | "markdown" | "github" }): string;
55
55
  export function impact(diffResult: DiffResult, scanDir?: string, options?: ImpactOptions): Hit[] | string;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Programmatic API — wraps the drift-guard binary and returns parsed results.
2
+ // Programmatic API — wraps the drift-agent binary and returns parsed results.
3
3
 
4
4
  const path = require("path");
5
5
  const { spawnSync } = require("child_process");
@@ -7,22 +7,22 @@ const { spawnSync } = require("child_process");
7
7
  const BIN = path.join(
8
8
  __dirname,
9
9
  "bin",
10
- process.platform === "win32" ? "drift-guard.exe" : "drift-guard"
10
+ process.platform === "win32" ? "drift-agent.exe" : "drift-agent"
11
11
  );
12
12
 
13
13
  /**
14
- * Run the drift-guard binary and return its stdout.
14
+ * Run the drift-agent binary and return its stdout.
15
15
  * @param {string[]} args
16
16
  * @returns {string}
17
17
  */
18
18
  function run(args) {
19
19
  const result = spawnSync(BIN, args, { encoding: "utf8" });
20
20
  if (result.error) {
21
- throw new Error(`drift-guard binary error: ${result.error.message}`);
21
+ throw new Error(`drift-agent binary error: ${result.error.message}`);
22
22
  }
23
23
  if (result.status !== 0 && result.status !== 1) {
24
24
  // exit 1 means breaking changes found (--fail-on-breaking), not a crash
25
- throw new Error(`drift-guard exited with code ${result.status}: ${result.stderr}`);
25
+ throw new Error(`drift-agent exited with code ${result.status}: ${result.stderr}`);
26
26
  }
27
27
  return result.stdout;
28
28
  }
@@ -70,7 +70,7 @@ function impact(diffResult, scanDir = ".", options = {}) {
70
70
  const os = require("os");
71
71
 
72
72
  // Write the diff result to a temp file so we can pass --diff
73
- const tmp = require("path").join(os.tmpdir(), `drift-guard-diff-${Date.now()}.json`);
73
+ const tmp = require("path").join(os.tmpdir(), `drift-agent-diff-${Date.now()}.json`);
74
74
  try {
75
75
  fs.writeFileSync(tmp, JSON.stringify(diffResult));
76
76
  const out = run(["impact", "--diff", tmp, "--scan", scanDir, "--format", format]);
package/install.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // postinstall: downloads the drift-guard binary from GitHub Releases.
2
+ // postinstall: downloads the drift-agent binary from GitHub Releases.
3
3
  "use strict";
4
4
 
5
5
  const https = require("https");
@@ -11,7 +11,7 @@ const { execSync } = require("child_process");
11
11
  const VERSION = require("./package.json").version;
12
12
  const REPO = "DriftAgent/api-drift-engine";
13
13
  const BIN_DIR = path.join(__dirname, "bin");
14
- const BIN_PATH = path.join(BIN_DIR, process.platform === "win32" ? "drift-guard.exe" : "drift-guard");
14
+ const BIN_PATH = path.join(BIN_DIR, process.platform === "win32" ? "drift-agent.exe" : "drift-agent");
15
15
 
16
16
  // Map Node.js platform/arch → goreleaser archive naming
17
17
  function getPlatformInfo() {
@@ -32,7 +32,7 @@ function getPlatformInfo() {
32
32
  }
33
33
 
34
34
  const ext = goos === "windows" ? "zip" : "tar.gz";
35
- const archive = `drift-guard_${VERSION}_${goos}_${goarch}.${ext}`;
35
+ const archive = `drift-agent_${VERSION}_${goos}_${goarch}.${ext}`;
36
36
  const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${archive}`;
37
37
 
38
38
  return { url, archive, ext };
@@ -64,10 +64,10 @@ async function install() {
64
64
  }
65
65
 
66
66
  const { url, archive, ext } = getPlatformInfo();
67
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "drift-guard-"));
67
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "drift-agent-"));
68
68
  const archivePath = path.join(tmpDir, archive);
69
69
 
70
- process.stdout.write(`Downloading drift-guard v${VERSION}...\n`);
70
+ process.stdout.write(`Downloading drift-agent v${VERSION}...\n`);
71
71
 
72
72
  try {
73
73
  await download(url, archivePath);
@@ -80,18 +80,18 @@ async function install() {
80
80
  execSync(`unzip -o "${archivePath}" -d "${tmpDir}"`);
81
81
  }
82
82
 
83
- const extracted = path.join(tmpDir, process.platform === "win32" ? "drift-guard.exe" : "drift-guard");
83
+ const extracted = path.join(tmpDir, process.platform === "win32" ? "drift-agent.exe" : "drift-agent");
84
84
  fs.copyFileSync(extracted, BIN_PATH);
85
85
  fs.chmodSync(BIN_PATH, 0o755);
86
86
 
87
- process.stdout.write(`drift-guard installed to ${BIN_PATH}\n`);
87
+ process.stdout.write(`drift-agent installed to ${BIN_PATH}\n`);
88
88
  } finally {
89
89
  fs.rmSync(tmpDir, { recursive: true, force: true });
90
90
  }
91
91
  }
92
92
 
93
93
  install().catch((err) => {
94
- process.stderr.write(`drift-guard install failed: ${err.message}\n`);
94
+ process.stderr.write(`drift-agent install failed: ${err.message}\n`);
95
95
  process.stderr.write("You can install it manually: https://github.com/DriftAgent/api-drift-engine/releases\n");
96
96
  // Do not exit(1) — allow npm install to succeed even if binary download fails.
97
97
  });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@drift-agent/api-drift-engine",
3
- "version": "2.5.4",
3
+ "version": "5.2.0",
4
4
  "description": "API schema diff engine — detect breaking changes in OpenAPI, GraphQL, and gRPC schemas",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "bin": {
8
- "drift-guard": "run.js"
8
+ "drift-agent": "run.js"
9
9
  },
10
10
  "scripts": {
11
11
  "postinstall": "node install.js"
package/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // Thin shim: passes all arguments to the drift-guard binary.
2
+ // Thin shim: passes all arguments to the drift-agent binary.
3
3
  "use strict";
4
4
 
5
5
  const path = require("path");
@@ -8,14 +8,14 @@ const { spawnSync } = require("child_process");
8
8
  const bin = path.join(
9
9
  __dirname,
10
10
  "bin",
11
- process.platform === "win32" ? "drift-guard.exe" : "drift-guard"
11
+ process.platform === "win32" ? "drift-agent.exe" : "drift-agent"
12
12
  );
13
13
 
14
14
  const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
15
15
 
16
16
  if (result.error) {
17
17
  process.stderr.write(
18
- `drift-guard: could not run binary: ${result.error.message}\n` +
18
+ `drift-agent: could not run binary: ${result.error.message}\n` +
19
19
  `Make sure the package installed correctly or download manually:\n` +
20
20
  `https://github.com/DriftAgent/api-drift-engine/releases\n`
21
21
  );