@canyonjs/git-provider 0.0.2 → 0.0.5

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.
Files changed (3) hide show
  1. package/README.md +12 -16
  2. package/dist/index.mjs +3 -3
  3. package/package.json +23 -17
package/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
 
5
5
  ## 能力与现状
6
6
 
7
- | 能力 | GitLab | GitHub |
8
- | --- | --- | --- |
9
- | `getRepoInfo` | 支持(Project API) | 支持(`owner/repo` 或数字仓库 id) |
10
- | `getCompare` | **已实现**:比较 API + 逐文件 Raw 内容与行级差异 | **未实现**(调用会抛错) |
7
+ | 能力 | GitLab | GitHub |
8
+ | ------------- | ------------------------------------------------ | ---------------------------------- |
9
+ | `getRepoInfo` | 支持(Project API) | 支持(`owner/repo` 或数字仓库 id) |
10
+ | `getCompare` | **已实现**:比较 API + 逐文件 Raw 内容与行级差异 | **未实现**(调用会抛错) |
11
11
 
12
12
  `getCompare` 返回结构化结果 **`Compare`**:
13
13
 
@@ -37,11 +37,7 @@ pnpm run build
37
37
  ## 用法示例
38
38
 
39
39
  ```ts
40
- import {
41
- createScmAdapter,
42
- type Compare,
43
- type ScmConfig,
44
- } from "@canyonjs/git-provider";
40
+ import { createScmAdapter, type Compare, type ScmConfig } from "@canyonjs/git-provider";
45
41
 
46
42
  const config: ScmConfig = {
47
43
  type: "gitlab",
@@ -66,13 +62,13 @@ GitHub 仅 token、`base` 固定为 `https://api.github.com`。
66
62
 
67
63
  ## 开发与脚本
68
64
 
69
- | 脚本 | 说明 |
70
- | --- | --- |
71
- | `pnpm run build` | 使用 tsdown 产出 `dist` |
72
- | `pnpm run dev` | 监听构建 |
73
- | `pnpm run typecheck` | TypeScript 检查 |
74
- | `pnpm run test` | Vitest |
75
- | `pnpm run debug` | 本地脚本 `src/debug.ts`(可自行改为写 token、仓库与 ref) |
65
+ | 脚本 | 说明 |
66
+ | -------------------- | --------------------------------------------------------- |
67
+ | `pnpm run build` | 使用 tsdown 产出 `dist` |
68
+ | `pnpm run dev` | 监听构建 |
69
+ | `pnpm run typecheck` | TypeScript 检查 |
70
+ | `pnpm run test` | Vitest |
71
+ | `pnpm run debug` | 本地脚本 `src/debug.ts`(可自行改为写 token、仓库与 ref) |
76
72
 
77
73
  目录概览:**`src/adapter.ts`** 定义 **`ScmAdapter`**;**`src/gitlab.ts`** / **`src/github.ts`** 为实现;**`src/diff-line.ts`** 为行号计算与扩展名判定;**`src/types.ts`** 为配置与各数据结构类型。
78
74
 
package/dist/index.mjs CHANGED
@@ -199,14 +199,14 @@ var GitlabAdapter = class {
199
199
  }
200
200
  fileRawUrl(repoID, filePath, ref) {
201
201
  const encodedPath = encodeURIComponent(filePath);
202
- return `${this.base}/api/v4/projects/${encodeURIComponent(repoID)}/repository/files/${encodedPath}/raw?ref=${encodeURIComponent(ref)}`;
202
+ return `${this.base}/projects/${encodeURIComponent(repoID)}/repository/files/${encodedPath}/raw?ref=${encodeURIComponent(ref)}`;
203
203
  }
204
204
  async getRawFileText(repoID, filePath, ref) {
205
205
  const { data } = await get(this.fileRawUrl(repoID, filePath, ref), { headers: this.headers() });
206
206
  return typeof data === "string" ? data : "";
207
207
  }
208
208
  async getRepoInfo(repoID) {
209
- const { data } = await get(`${this.base}/api/v4/projects/${encodeURIComponent(repoID)}`, { headers: this.headers() });
209
+ const { data } = await get(`${this.base}/projects/${encodeURIComponent(repoID)}`, { headers: this.headers() });
210
210
  return {
211
211
  id: String(data.id),
212
212
  pathWithNamespace: data.path_with_namespace,
@@ -214,7 +214,7 @@ var GitlabAdapter = class {
214
214
  };
215
215
  }
216
216
  async getCompare(repoID, base, head) {
217
- const { data } = await get(`${this.base}/api/v4/projects/${encodeURIComponent(repoID)}/repository/compare?from=${encodeURIComponent(base)}&to=${encodeURIComponent(head)}`, { headers: this.headers() });
217
+ const { data } = await get(`${this.base}/projects/${encodeURIComponent(repoID)}/repository/compare?from=${encodeURIComponent(base)}&to=${encodeURIComponent(head)}`, { headers: this.headers() });
218
218
  const diffRows = data.diffs ?? [];
219
219
  const comparedPaths = diffRows.map(comparedRefsFromGitlabDiff).filter((entry) => entry != null).filter((entry) => pathMatchesLineDiffExtensions(entry.keyPath));
220
220
  const lineBuckets = comparedPaths.length > 1500 ? /* @__PURE__ */ new Map() : await computeLineBucketsByRef(comparedPaths, base, head, (path, ref) => this.getRawFileText(repoID, path, ref));
package/package.json CHANGED
@@ -1,47 +1,53 @@
1
1
  {
2
2
  "name": "@canyonjs/git-provider",
3
- "type": "module",
4
- "version": "0.0.2",
3
+ "version": "0.0.5",
5
4
  "description": "GitLab provider client with adapter architecture.",
6
5
  "keywords": [
6
+ "api",
7
7
  "git",
8
- "gitlab",
9
- "api"
8
+ "gitlab"
10
9
  ],
11
- "author": "canyonjs",
12
- "license": "MIT",
13
10
  "homepage": "https://github.com/canyon-project/git-provider#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/canyon-project/git-provider/issues"
13
+ },
14
+ "license": "MIT",
15
+ "author": "canyonjs",
14
16
  "repository": {
15
17
  "type": "git",
16
18
  "url": "git+https://github.com/canyon-project/git-provider.git"
17
19
  },
18
- "bugs": {
19
- "url": "https://github.com/canyon-project/git-provider/issues"
20
- },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "type": "module",
24
+ "sideEffects": false,
21
25
  "types": "./dist/index.d.ts",
22
26
  "exports": {
23
27
  ".": "./dist/index.mjs",
24
28
  "./package.json": "./package.json"
25
29
  },
26
- "files": [
27
- "dist"
28
- ],
29
- "sideEffects": false,
30
+ "dependencies": {
31
+ "diff": "^9.0.0"
32
+ },
30
33
  "devDependencies": {
31
34
  "@types/node": "^25.5.0",
32
35
  "@typescript/native-preview": "7.0.0-dev.20260505.1",
36
+ "oxfmt": "^0.48.0",
37
+ "oxlint": "^1.63.0",
33
38
  "tsdown": "^0.21.7",
34
39
  "tsx": "^4.21.0",
35
40
  "vitest": "^4.1.2"
36
41
  },
37
- "dependencies": {
38
- "diff": "^9.0.0"
39
- },
40
42
  "scripts": {
41
43
  "build": "tsdown",
42
44
  "dev": "tsdown --watch",
43
45
  "test": "vitest run",
44
46
  "typecheck": "tsgo --noEmit",
45
- "debug": "tsx src/debug.ts"
47
+ "debug": "tsx src/debug.ts",
48
+ "lint": "oxlint",
49
+ "lint:fix": "oxlint --fix",
50
+ "fmt": "oxfmt",
51
+ "fmt:check": "oxfmt --check"
46
52
  }
47
53
  }