renovate 44.105.1 → 44.105.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.
Files changed (52) hide show
  1. package/dist/config/presets/forgejo/index.js +2 -34
  2. package/dist/config/presets/forgejo/index.js.map +1 -1
  3. package/dist/config/presets/gitea/common.js +52 -0
  4. package/dist/config/presets/gitea/common.js.map +1 -0
  5. package/dist/config/presets/gitea/index.js +2 -34
  6. package/dist/config/presets/gitea/index.js.map +1 -1
  7. package/dist/modules/datasource/api.js +3 -3
  8. package/dist/modules/datasource/forgejo-releases/index.js +9 -58
  9. package/dist/modules/datasource/forgejo-releases/index.js.map +1 -1
  10. package/dist/modules/datasource/forgejo-tags/index.js +9 -72
  11. package/dist/modules/datasource/forgejo-tags/index.js.map +1 -1
  12. package/dist/modules/datasource/gitea-releases/index.js +17 -53
  13. package/dist/modules/datasource/gitea-releases/index.js.map +1 -1
  14. package/dist/modules/datasource/gitea-tags/base.js +93 -0
  15. package/dist/modules/datasource/gitea-tags/base.js.map +1 -0
  16. package/dist/modules/datasource/gitea-tags/index.js +17 -67
  17. package/dist/modules/datasource/gitea-tags/index.js.map +1 -1
  18. package/dist/modules/datasource/gitea-tags/util.js +24 -0
  19. package/dist/modules/datasource/gitea-tags/util.js.map +1 -0
  20. package/dist/modules/datasource/go/base.js +1 -1
  21. package/dist/modules/datasource/go/common.js +1 -1
  22. package/dist/modules/datasource/go/index.js +1 -1
  23. package/dist/modules/datasource/go/releases-direct.js +1 -1
  24. package/dist/modules/manager/fingerprint.generated.js +2 -2
  25. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  26. package/dist/modules/manager/github-actions/extract.js +1 -1
  27. package/dist/modules/manager/gomod/line-parser.js +1 -1
  28. package/dist/modules/manager/gomod/line-parser.js.map +1 -1
  29. package/dist/modules/manager/quadlet/schema.js +1 -1
  30. package/dist/modules/manager/quadlet/schema.js.map +1 -1
  31. package/dist/modules/manager/renovate-config/extract.js +1 -1
  32. package/dist/modules/manager/terragrunt/index.js +1 -1
  33. package/dist/modules/manager/terragrunt/modules.js +1 -1
  34. package/dist/workers/repository/dependency-dashboard.js +8 -1
  35. package/dist/workers/repository/dependency-dashboard.js.map +1 -1
  36. package/dist/workers/repository/update/pr/changelog/api.js +1 -1
  37. package/dist/workers/repository/update/pr/changelog/forgejo/index.js +2 -41
  38. package/dist/workers/repository/update/pr/changelog/forgejo/index.js.map +1 -1
  39. package/dist/workers/repository/update/pr/changelog/forgejo/source.js +6 -11
  40. package/dist/workers/repository/update/pr/changelog/forgejo/source.js.map +1 -1
  41. package/dist/workers/repository/update/pr/changelog/gitea/common.js +56 -0
  42. package/dist/workers/repository/update/pr/changelog/gitea/common.js.map +1 -0
  43. package/dist/workers/repository/update/pr/changelog/gitea/index.js +2 -41
  44. package/dist/workers/repository/update/pr/changelog/gitea/index.js.map +1 -1
  45. package/dist/workers/repository/update/pr/changelog/gitea/source.js +3 -2
  46. package/dist/workers/repository/update/pr/changelog/gitea/source.js.map +1 -1
  47. package/package.json +1 -1
  48. package/renovate-schema.json +2 -2
  49. package/dist/modules/datasource/forgejo-releases/schema.js +0 -15
  50. package/dist/modules/datasource/forgejo-releases/schema.js.map +0 -1
  51. package/dist/modules/datasource/forgejo-tags/schema.js +0 -18
  52. package/dist/modules/datasource/forgejo-tags/schema.js.map +0 -1
@@ -1,40 +1,8 @@
1
- import { logger } from "../../../logger/index.js";
2
- import { ExternalHostError } from "../../../types/errors/external-host-error.js";
3
- import { PRESET_DEP_NOT_FOUND, PRESET_INVALID, fetchPreset, parsePreset } from "../util.js";
4
- import { getRepoContents } from "../../../modules/platform/gitea/gitea-helper.js";
5
1
  import { forgejoHttp } from "../../../modules/platform/forgejo/index.js";
2
+ import { createPresetSource } from "../gitea/common.js";
6
3
  //#region lib/config/presets/forgejo/index.ts
7
4
  const Endpoint = "https://code.forgejo.org/";
8
- async function fetchJSONFile(repo, fileName, endpoint, tag) {
9
- let res;
10
- try {
11
- res = await getRepoContents(forgejoHttp, repo, fileName, tag, { baseUrl: endpoint });
12
- } catch (err) {
13
- if (err instanceof ExternalHostError) throw err;
14
- logger.debug(`Preset file ${fileName} not found in ${repo}: ${err.message}`);
15
- throw new Error(PRESET_DEP_NOT_FOUND);
16
- }
17
- let contentString;
18
- if (res.type === "file") contentString = res.contentString;
19
- else {
20
- logger.debug(`Preset ${fileName} has unexpected type '${res.type}'. Only \`file\` is supported`);
21
- throw new Error(PRESET_INVALID);
22
- }
23
- return parsePreset(contentString, fileName);
24
- }
25
- function getPresetFromEndpoint(repo, filePreset, presetPath, endpoint = Endpoint, tag) {
26
- return fetchPreset({
27
- repo,
28
- filePreset,
29
- presetPath,
30
- endpoint,
31
- tag,
32
- fetch: fetchJSONFile
33
- });
34
- }
35
- function getPreset({ repo, presetName = "default", presetPath, tag }) {
36
- return getPresetFromEndpoint(repo, presetName, presetPath, Endpoint, tag);
37
- }
5
+ const { fetchJSONFile, getPresetFromEndpoint, getPreset } = createPresetSource(forgejoHttp, Endpoint);
38
6
  //#endregion
39
7
  export { Endpoint, fetchJSONFile, getPreset, getPresetFromEndpoint };
40
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/config/presets/forgejo/index.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { forgejoHttp } from '../../../modules/platform/forgejo/index.ts';\nimport { getRepoContents } from '../../../modules/platform/gitea/gitea-helper.ts';\nimport type { RepoContents } from '../../../modules/platform/gitea/schema.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport type { Nullish } from '../../../types/index.ts';\nimport type { Preset, PresetConfig } from '../types.ts';\nimport {\n PRESET_DEP_NOT_FOUND,\n PRESET_INVALID,\n fetchPreset,\n parsePreset,\n} from '../util.ts';\n\nexport const Endpoint = 'https://code.forgejo.org/';\n\nexport async function fetchJSONFile(\n repo: string,\n fileName: string,\n endpoint: string,\n tag?: string | null,\n): Promise<Nullish<Preset>> {\n let res: RepoContents;\n try {\n res = await getRepoContents(forgejoHttp, repo, fileName, tag, {\n baseUrl: endpoint,\n });\n } catch (err) {\n if (err instanceof ExternalHostError) {\n throw err;\n }\n logger.debug(\n `Preset file ${fileName} not found in ${repo}: ${err.message}`,\n );\n throw new Error(PRESET_DEP_NOT_FOUND);\n }\n\n let contentString: string;\n if (res.type === 'file') {\n contentString = res.contentString;\n } else {\n logger.debug(\n `Preset ${fileName} has unexpected type '${res.type}'. Only \\`file\\` is supported`,\n );\n throw new Error(PRESET_INVALID);\n }\n return parsePreset(contentString, fileName);\n}\n\nexport function getPresetFromEndpoint(\n repo: string,\n filePreset: string,\n presetPath?: string,\n endpoint = Endpoint,\n tag?: string,\n): Promise<Nullish<Preset>> {\n return fetchPreset({\n repo,\n filePreset,\n presetPath,\n endpoint,\n tag,\n fetch: fetchJSONFile,\n });\n}\n\nexport function getPreset({\n repo,\n presetName = 'default',\n presetPath,\n tag,\n}: PresetConfig): Promise<Nullish<Preset>> {\n return getPresetFromEndpoint(repo, presetName, presetPath, Endpoint, tag);\n}\n"],"mappings":";;;;;;AAcA,MAAa,WAAW;AAExB,eAAsB,cACpB,MACA,UACA,UACA,KAC0B;CAC1B,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,gBAAgB,aAAa,MAAM,UAAU,KAAK,EAC5D,SAAS,SACX,CAAC;CACH,SAAS,KAAK;EACZ,IAAI,eAAe,mBACjB,MAAM;EAER,OAAO,MACL,eAAe,SAAS,gBAAgB,KAAK,IAAI,IAAI,SACvD;EACA,MAAM,IAAI,MAAM,oBAAoB;CACtC;CAEA,IAAI;CACJ,IAAI,IAAI,SAAS,QACf,gBAAgB,IAAI;MACf;EACL,OAAO,MACL,UAAU,SAAS,wBAAwB,IAAI,KAAK,8BACtD;EACA,MAAM,IAAI,MAAM,cAAc;CAChC;CACA,OAAO,YAAY,eAAe,QAAQ;AAC5C;AAEA,SAAgB,sBACd,MACA,YACA,YACA,WAAW,UACX,KAC0B;CAC1B,OAAO,YAAY;EACjB;EACA;EACA;EACA;EACA;EACA,OAAO;CACT,CAAC;AACH;AAEA,SAAgB,UAAU,EACxB,MACA,aAAa,WACb,YACA,OACyC;CACzC,OAAO,sBAAsB,MAAM,YAAY,YAAY,UAAU,GAAG;AAC1E"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/config/presets/forgejo/index.ts"],"sourcesContent":["import { forgejoHttp } from '../../../modules/platform/forgejo/index.ts';\nimport { createPresetSource } from '../gitea/common.ts';\n\nexport const Endpoint = 'https://code.forgejo.org/';\n\nexport const { fetchJSONFile, getPresetFromEndpoint, getPreset } =\n createPresetSource(forgejoHttp, Endpoint);\n"],"mappings":";;;AAGA,MAAa,WAAW;AAExB,MAAa,EAAE,eAAe,uBAAuB,cACnD,mBAAmB,aAAa,QAAQ"}
@@ -0,0 +1,52 @@
1
+ import { logger } from "../../../logger/index.js";
2
+ import { ExternalHostError } from "../../../types/errors/external-host-error.js";
3
+ import { PRESET_DEP_NOT_FOUND, PRESET_INVALID, fetchPreset, parsePreset } from "../util.js";
4
+ import { getRepoContents } from "../../../modules/platform/gitea/gitea-helper.js";
5
+ //#region lib/config/presets/gitea/common.ts
6
+ /**
7
+ * Builds the preset source of a platform which speaks the Gitea API.
8
+ *
9
+ * Forgejo is a fork of Gitea and serves the same contents API, so the Gitea
10
+ * and Forgejo sources only differ in their Http client and default endpoint.
11
+ */
12
+ function createPresetSource(http, defaultEndpoint) {
13
+ async function fetchJSONFile(repo, fileName, endpoint, tag) {
14
+ let res;
15
+ try {
16
+ res = await getRepoContents(http, repo, fileName, tag, { baseUrl: endpoint });
17
+ } catch (err) {
18
+ if (err instanceof ExternalHostError) throw err;
19
+ logger.debug(`Preset file ${fileName} not found in ${repo}: ${err.message}`);
20
+ throw new Error(PRESET_DEP_NOT_FOUND);
21
+ }
22
+ let contentString;
23
+ if (res.type === "file") contentString = res.contentString;
24
+ else {
25
+ logger.debug(`Preset ${fileName} has unexpected type '${res.type}'. Only \`file\` is supported`);
26
+ throw new Error(PRESET_INVALID);
27
+ }
28
+ return parsePreset(contentString, fileName);
29
+ }
30
+ function getPresetFromEndpoint(repo, filePreset, presetPath, endpoint = defaultEndpoint, tag) {
31
+ return fetchPreset({
32
+ repo,
33
+ filePreset,
34
+ presetPath,
35
+ endpoint,
36
+ tag,
37
+ fetch: fetchJSONFile
38
+ });
39
+ }
40
+ function getPreset({ repo, presetName = "default", presetPath, tag }) {
41
+ return getPresetFromEndpoint(repo, presetName, presetPath, defaultEndpoint, tag);
42
+ }
43
+ return {
44
+ fetchJSONFile,
45
+ getPresetFromEndpoint,
46
+ getPreset
47
+ };
48
+ }
49
+ //#endregion
50
+ export { createPresetSource };
51
+
52
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","names":[],"sources":["../../../../lib/config/presets/gitea/common.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { getRepoContents } from '../../../modules/platform/gitea/gitea-helper.ts';\nimport type { RepoContents } from '../../../modules/platform/gitea/schema.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport type { Nullish } from '../../../types/index.ts';\nimport type { GiteaHttp } from '../../../util/http/gitea.ts';\nimport type { Preset, PresetConfig } from '../types.ts';\nimport {\n PRESET_DEP_NOT_FOUND,\n PRESET_INVALID,\n fetchPreset,\n parsePreset,\n} from '../util.ts';\n\nexport interface GiteaPresetSource {\n fetchJSONFile: (\n repo: string,\n fileName: string,\n endpoint: string,\n tag?: string | null,\n ) => Promise<Nullish<Preset>>;\n getPresetFromEndpoint: (\n repo: string,\n filePreset: string,\n presetPath?: string,\n endpoint?: string,\n tag?: string,\n ) => Promise<Nullish<Preset>>;\n getPreset: (config: PresetConfig) => Promise<Nullish<Preset>>;\n}\n\n/**\n * Builds the preset source of a platform which speaks the Gitea API.\n *\n * Forgejo is a fork of Gitea and serves the same contents API, so the Gitea\n * and Forgejo sources only differ in their Http client and default endpoint.\n */\nexport function createPresetSource(\n http: GiteaHttp,\n defaultEndpoint: string,\n): GiteaPresetSource {\n async function fetchJSONFile(\n repo: string,\n fileName: string,\n endpoint: string,\n tag?: string | null,\n ): Promise<Nullish<Preset>> {\n let res: RepoContents;\n try {\n res = await getRepoContents(http, repo, fileName, tag, {\n baseUrl: endpoint,\n });\n } catch (err) {\n if (err instanceof ExternalHostError) {\n throw err;\n }\n logger.debug(\n `Preset file ${fileName} not found in ${repo}: ${err.message}`,\n );\n throw new Error(PRESET_DEP_NOT_FOUND);\n }\n\n let contentString: string;\n if (res.type === 'file') {\n contentString = res.contentString;\n } else {\n logger.debug(\n `Preset ${fileName} has unexpected type '${res.type}'. Only \\`file\\` is supported`,\n );\n throw new Error(PRESET_INVALID);\n }\n return parsePreset(contentString, fileName);\n }\n\n function getPresetFromEndpoint(\n repo: string,\n filePreset: string,\n presetPath?: string,\n endpoint = defaultEndpoint,\n tag?: string,\n ): Promise<Nullish<Preset>> {\n return fetchPreset({\n repo,\n filePreset,\n presetPath,\n endpoint,\n tag,\n fetch: fetchJSONFile,\n });\n }\n\n function getPreset({\n repo,\n presetName = 'default',\n presetPath,\n tag,\n }: PresetConfig): Promise<Nullish<Preset>> {\n return getPresetFromEndpoint(\n repo,\n presetName,\n presetPath,\n defaultEndpoint,\n tag,\n );\n }\n\n return { fetchJSONFile, getPresetFromEndpoint, getPreset };\n}\n"],"mappings":";;;;;;;;;;;AAqCA,SAAgB,mBACd,MACA,iBACmB;CACnB,eAAe,cACb,MACA,UACA,UACA,KAC0B;EAC1B,IAAI;EACJ,IAAI;GACF,MAAM,MAAM,gBAAgB,MAAM,MAAM,UAAU,KAAK,EACrD,SAAS,SACX,CAAC;EACH,SAAS,KAAK;GACZ,IAAI,eAAe,mBACjB,MAAM;GAER,OAAO,MACL,eAAe,SAAS,gBAAgB,KAAK,IAAI,IAAI,SACvD;GACA,MAAM,IAAI,MAAM,oBAAoB;EACtC;EAEA,IAAI;EACJ,IAAI,IAAI,SAAS,QACf,gBAAgB,IAAI;OACf;GACL,OAAO,MACL,UAAU,SAAS,wBAAwB,IAAI,KAAK,8BACtD;GACA,MAAM,IAAI,MAAM,cAAc;EAChC;EACA,OAAO,YAAY,eAAe,QAAQ;CAC5C;CAEA,SAAS,sBACP,MACA,YACA,YACA,WAAW,iBACX,KAC0B;EAC1B,OAAO,YAAY;GACjB;GACA;GACA;GACA;GACA;GACA,OAAO;EACT,CAAC;CACH;CAEA,SAAS,UAAU,EACjB,MACA,aAAa,WACb,YACA,OACyC;EACzC,OAAO,sBACL,MACA,YACA,YACA,iBACA,GACF;CACF;CAEA,OAAO;EAAE;EAAe;EAAuB;CAAU;AAC3D"}
@@ -1,40 +1,8 @@
1
- import { logger } from "../../../logger/index.js";
2
- import { ExternalHostError } from "../../../types/errors/external-host-error.js";
3
- import { PRESET_DEP_NOT_FOUND, PRESET_INVALID, fetchPreset, parsePreset } from "../util.js";
4
- import { getRepoContents } from "../../../modules/platform/gitea/gitea-helper.js";
5
1
  import { giteaHttp } from "../../../modules/platform/gitea/index.js";
2
+ import { createPresetSource } from "./common.js";
6
3
  //#region lib/config/presets/gitea/index.ts
7
4
  const Endpoint = "https://gitea.com/";
8
- async function fetchJSONFile(repo, fileName, endpoint, tag) {
9
- let res;
10
- try {
11
- res = await getRepoContents(giteaHttp, repo, fileName, tag, { baseUrl: endpoint });
12
- } catch (err) {
13
- if (err instanceof ExternalHostError) throw err;
14
- logger.debug(`Preset file ${fileName} not found in ${repo}: ${err.message}`);
15
- throw new Error(PRESET_DEP_NOT_FOUND);
16
- }
17
- let contentString;
18
- if (res.type === "file") contentString = res.contentString;
19
- else {
20
- logger.debug(`Preset ${fileName} has unexpected type '${res.type}'. Only \`file\` is supported`);
21
- throw new Error(PRESET_INVALID);
22
- }
23
- return parsePreset(contentString, fileName);
24
- }
25
- function getPresetFromEndpoint(repo, filePreset, presetPath, endpoint = Endpoint, tag) {
26
- return fetchPreset({
27
- repo,
28
- filePreset,
29
- presetPath,
30
- endpoint,
31
- tag,
32
- fetch: fetchJSONFile
33
- });
34
- }
35
- function getPreset({ repo, presetName = "default", presetPath, tag }) {
36
- return getPresetFromEndpoint(repo, presetName, presetPath, Endpoint, tag);
37
- }
5
+ const { fetchJSONFile, getPresetFromEndpoint, getPreset } = createPresetSource(giteaHttp, Endpoint);
38
6
  //#endregion
39
7
  export { Endpoint, fetchJSONFile, getPreset, getPresetFromEndpoint };
40
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/config/presets/gitea/index.ts"],"sourcesContent":["import { logger } from '../../../logger/index.ts';\nimport { getRepoContents } from '../../../modules/platform/gitea/gitea-helper.ts';\nimport { giteaHttp } from '../../../modules/platform/gitea/index.ts';\nimport type { RepoContents } from '../../../modules/platform/gitea/schema.ts';\nimport { ExternalHostError } from '../../../types/errors/external-host-error.ts';\nimport type { Nullish } from '../../../types/index.ts';\nimport type { Preset, PresetConfig } from '../types.ts';\nimport {\n PRESET_DEP_NOT_FOUND,\n PRESET_INVALID,\n fetchPreset,\n parsePreset,\n} from '../util.ts';\n\nexport const Endpoint = 'https://gitea.com/';\n\nexport async function fetchJSONFile(\n repo: string,\n fileName: string,\n endpoint: string,\n tag?: string | null,\n): Promise<Nullish<Preset>> {\n let res: RepoContents;\n try {\n res = await getRepoContents(giteaHttp, repo, fileName, tag, {\n baseUrl: endpoint,\n });\n } catch (err) {\n if (err instanceof ExternalHostError) {\n throw err;\n }\n logger.debug(\n `Preset file ${fileName} not found in ${repo}: ${err.message}`,\n );\n throw new Error(PRESET_DEP_NOT_FOUND);\n }\n\n let contentString: string;\n if (res.type === 'file') {\n contentString = res.contentString;\n } else {\n logger.debug(\n `Preset ${fileName} has unexpected type '${res.type}'. Only \\`file\\` is supported`,\n );\n throw new Error(PRESET_INVALID);\n }\n return parsePreset(contentString, fileName);\n}\n\nexport function getPresetFromEndpoint(\n repo: string,\n filePreset: string,\n presetPath?: string,\n endpoint = Endpoint,\n tag?: string,\n): Promise<Nullish<Preset>> {\n return fetchPreset({\n repo,\n filePreset,\n presetPath,\n endpoint,\n tag,\n fetch: fetchJSONFile,\n });\n}\n\nexport function getPreset({\n repo,\n presetName = 'default',\n presetPath,\n tag,\n}: PresetConfig): Promise<Nullish<Preset>> {\n return getPresetFromEndpoint(repo, presetName, presetPath, Endpoint, tag);\n}\n"],"mappings":";;;;;;AAcA,MAAa,WAAW;AAExB,eAAsB,cACpB,MACA,UACA,UACA,KAC0B;CAC1B,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,gBAAgB,WAAW,MAAM,UAAU,KAAK,EAC1D,SAAS,SACX,CAAC;CACH,SAAS,KAAK;EACZ,IAAI,eAAe,mBACjB,MAAM;EAER,OAAO,MACL,eAAe,SAAS,gBAAgB,KAAK,IAAI,IAAI,SACvD;EACA,MAAM,IAAI,MAAM,oBAAoB;CACtC;CAEA,IAAI;CACJ,IAAI,IAAI,SAAS,QACf,gBAAgB,IAAI;MACf;EACL,OAAO,MACL,UAAU,SAAS,wBAAwB,IAAI,KAAK,8BACtD;EACA,MAAM,IAAI,MAAM,cAAc;CAChC;CACA,OAAO,YAAY,eAAe,QAAQ;AAC5C;AAEA,SAAgB,sBACd,MACA,YACA,YACA,WAAW,UACX,KAC0B;CAC1B,OAAO,YAAY;EACjB;EACA;EACA;EACA;EACA;EACA,OAAO;CACT,CAAC;AACH;AAEA,SAAgB,UAAU,EACxB,MACA,aAAa,WACb,YACA,OACyC;CACzC,OAAO,sBAAsB,MAAM,YAAY,YAAY,UAAU,GAAG;AAC1E"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/config/presets/gitea/index.ts"],"sourcesContent":["import { giteaHttp } from '../../../modules/platform/gitea/index.ts';\nimport { createPresetSource } from './common.ts';\n\nexport const Endpoint = 'https://gitea.com/';\n\nexport const { fetchJSONFile, getPresetFromEndpoint, getPreset } =\n createPresetSource(giteaHttp, Endpoint);\n"],"mappings":";;;AAGA,MAAa,WAAW;AAExB,MAAa,EAAE,eAAe,uBAAuB,cACnD,mBAAmB,WAAW,QAAQ"}
@@ -29,14 +29,14 @@ import { DotnetVersionDatasource } from "./dotnet-version/index.js";
29
29
  import { ElmPackageDatasource } from "./elm-package/index.js";
30
30
  import { EndoflifeDateDatasource } from "./endoflife-date/index.js";
31
31
  import { FlutterVersionDatasource } from "./flutter-version/index.js";
32
- import { ForgejoTagsDatasource } from "./forgejo-tags/index.js";
32
+ import { GiteaReleasesDatasource } from "./gitea-releases/index.js";
33
33
  import { ForgejoReleasesDatasource } from "./forgejo-releases/index.js";
34
+ import { GiteaTagsDatasource } from "./gitea-tags/index.js";
35
+ import { ForgejoTagsDatasource } from "./forgejo-tags/index.js";
34
36
  import { GalaxyDatasource } from "./galaxy/index.js";
35
37
  import { GalaxyCollectionDatasource } from "./galaxy-collection/index.js";
36
38
  import { GitRefsDatasource } from "./git-refs/index.js";
37
39
  import { GitTagsDatasource } from "./git-tags/index.js";
38
- import { GiteaTagsDatasource } from "./gitea-tags/index.js";
39
- import { GiteaReleasesDatasource } from "./gitea-releases/index.js";
40
40
  import { GithubDigestDatasource } from "./github-digest/index.js";
41
41
  import { GithubReleaseAttachmentsDatasource } from "./github-release-attachments/index.js";
42
42
  import { GithubReleasesDatasource } from "./github-releases/index.js";
@@ -1,68 +1,19 @@
1
- import { withCache } from "../../../util/cache/package/with-cache.js";
2
- import { Datasource } from "../datasource.js";
3
1
  import { ForgejoHttp } from "../../../util/http/forgejo.js";
4
- import { Commits, Tag } from "../forgejo-tags/schema.js";
5
- import { ForgejoTagsDatasource } from "../forgejo-tags/index.js";
6
- import { Releases } from "./schema.js";
2
+ import { GiteaReleasesDatasource } from "../gitea-releases/index.js";
7
3
  //#region lib/modules/datasource/forgejo-releases/index.ts
8
- var ForgejoReleasesDatasource = class ForgejoReleasesDatasource extends Datasource {
4
+ /**
5
+ * Forgejo is a fork of Gitea and serves the same API, so the lookup is
6
+ * inherited and only the identity of the datasource differs.
7
+ */
8
+ var ForgejoReleasesDatasource = class ForgejoReleasesDatasource extends GiteaReleasesDatasource {
9
9
  static id = "forgejo-releases";
10
- http = new ForgejoHttp(ForgejoReleasesDatasource.id);
11
10
  static defaultRegistryUrls = ["https://code.forgejo.org"];
12
- static cacheNamespace = `datasource-${ForgejoReleasesDatasource.id}`;
13
- releaseTimestampSupport = true;
14
- releaseTimestampNote = "The release timestamp is determined from the `published_at` field in the results.";
15
- sourceUrlSupport = "package";
16
- sourceUrlNote = "The source URL is determined by using the `packageName` and `registryUrl`.";
11
+ defaultRegistryUrls = ForgejoReleasesDatasource.defaultRegistryUrls;
12
+ cacheNamespace = "datasource-forgejo-releases";
13
+ http = new ForgejoHttp(ForgejoReleasesDatasource.id);
17
14
  constructor() {
18
15
  super(ForgejoReleasesDatasource.id);
19
16
  }
20
- async _getReleases({ registryUrl, packageName: repo }) {
21
- const url = `${ForgejoTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/releases?draft=false`;
22
- const tags = (await this.http.getJson(url, { paginate: true }, Releases)).body;
23
- return {
24
- sourceUrl: ForgejoTagsDatasource.getSourceUrl(repo, registryUrl),
25
- registryUrl: ForgejoTagsDatasource.getRegistryURL(registryUrl),
26
- releases: tags.map(({ tag_name, published_at, prerelease }) => ({
27
- version: tag_name,
28
- gitRef: tag_name,
29
- releaseTimestamp: published_at,
30
- isStable: !prerelease
31
- }))
32
- };
33
- }
34
- getReleases(config) {
35
- return withCache({
36
- namespace: ForgejoReleasesDatasource.cacheNamespace,
37
- key: ForgejoTagsDatasource.getCacheKey(config.registryUrl, config.packageName, "releases"),
38
- fallback: true
39
- }, () => this._getReleases(config));
40
- }
41
- async _getTagCommit(registryUrl, repo, tag) {
42
- const url = `${ForgejoTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/tags/${tag}`;
43
- const { body } = await this.http.getJson(url, Tag);
44
- return body.commit.sha;
45
- }
46
- getTagCommit(registryUrl, repo, tag) {
47
- return withCache({
48
- namespace: ForgejoReleasesDatasource.cacheNamespace,
49
- key: ForgejoTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`)
50
- }, () => this._getTagCommit(registryUrl, repo, tag));
51
- }
52
- async _getDigest({ packageName: repo, registryUrl }, newValue) {
53
- if (newValue?.length) return this.getTagCommit(registryUrl, repo, newValue);
54
- const url = `${ForgejoTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;
55
- const { body } = await this.http.getJson(url, Commits);
56
- if (body.length === 0) return null;
57
- return body[0].sha;
58
- }
59
- getDigest(config, newValue) {
60
- return withCache({
61
- namespace: ForgejoReleasesDatasource.cacheNamespace,
62
- key: ForgejoTagsDatasource.getCacheKey(config.registryUrl, config.packageName, "digest"),
63
- fallback: true
64
- }, () => this._getDigest(config, newValue));
65
- }
66
17
  };
67
18
  //#endregion
68
19
  export { ForgejoReleasesDatasource };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/forgejo-releases/index.ts"],"sourcesContent":["import type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { ForgejoHttp } from '../../../util/http/forgejo.ts';\nimport { Datasource } from '../datasource.ts';\nimport { ForgejoTagsDatasource } from '../forgejo-tags/index.ts';\nimport { Commits, Tag } from '../forgejo-tags/schema.ts';\nimport type {\n DigestConfig,\n GetReleasesConfig,\n ReleaseResult,\n} from '../types.ts';\nimport { Releases } from './schema.ts';\n\nexport class ForgejoReleasesDatasource extends Datasource {\n static readonly id = 'forgejo-releases';\n\n override http = new ForgejoHttp(ForgejoReleasesDatasource.id);\n\n static readonly defaultRegistryUrls = ['https://code.forgejo.org'];\n\n private static readonly cacheNamespace: PackageCacheNamespace = `datasource-${ForgejoReleasesDatasource.id}`;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timestamp is determined from the `published_at` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(ForgejoReleasesDatasource.id);\n }\n\n // getReleases fetches list of tags for the repository\n private async _getReleases({\n registryUrl,\n packageName: repo,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n const url = `${ForgejoTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/releases?draft=false`;\n const tags = (\n await this.http.getJson(\n url,\n {\n paginate: true,\n },\n Releases,\n )\n ).body;\n\n const dependency: ReleaseResult = {\n sourceUrl: ForgejoTagsDatasource.getSourceUrl(repo, registryUrl),\n registryUrl: ForgejoTagsDatasource.getRegistryURL(registryUrl),\n releases: tags.map(({ tag_name, published_at, prerelease }) => ({\n version: tag_name,\n gitRef: tag_name,\n releaseTimestamp: published_at,\n isStable: !prerelease,\n })),\n };\n\n return dependency;\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: ForgejoReleasesDatasource.cacheNamespace,\n key: ForgejoTagsDatasource.getCacheKey(\n config.registryUrl,\n config.packageName,\n 'releases',\n ),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n // getTagCommit fetched the commit has for specified tag\n private async _getTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = `${ForgejoTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/tags/${tag}`;\n\n const { body } = await this.http.getJson(url, Tag);\n\n return body.commit.sha;\n }\n\n getTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n return withCache(\n {\n namespace: ForgejoReleasesDatasource.cacheNamespace,\n key: ForgejoTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`),\n },\n () => this._getTagCommit(registryUrl, repo, tag),\n );\n }\n\n // getDigest fetched the latest commit for repository main branch\n // however, if newValue is provided, then getTagCommit is called\n private async _getDigest(\n { packageName: repo, registryUrl }: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n if (newValue?.length) {\n return this.getTagCommit(registryUrl, repo, newValue);\n }\n\n const url = `${ForgejoTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;\n const { body } = await this.http.getJson(url, Commits);\n\n if (body.length === 0) {\n return null;\n }\n\n return body[0].sha;\n }\n\n override getDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n return withCache(\n {\n namespace: ForgejoReleasesDatasource.cacheNamespace,\n key: ForgejoTagsDatasource.getCacheKey(\n config.registryUrl,\n config.packageName,\n 'digest',\n ),\n fallback: true,\n },\n () => this._getDigest(config, newValue),\n );\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAa,4BAAb,MAAa,kCAAkC,WAAW;CACxD,OAAgB,KAAK;CAErB,OAAgB,IAAI,YAAY,0BAA0B,EAAE;CAE5D,OAAgB,sBAAsB,CAAC,0BAA0B;CAEjE,OAAwB,iBAAwC,cAAc,0BAA0B;CAExG,0BAA4C;CAC5C,uBACE;CACF,mBAAqC;CACrC,gBACE;CAEF,cAAc;EACZ,MAAM,0BAA0B,EAAE;CACpC;CAGA,MAAc,aAAa,EACzB,aACA,aAAa,QACsC;EACnD,MAAM,MAAM,GAAG,sBAAsB,UACnC,WACF,EAAE,QAAQ,KAAK;EACf,MAAM,QACJ,MAAM,KAAK,KAAK,QACd,KACA,EACE,UAAU,KACZ,GACA,QACF,EAAA,CACA;EAaF,OAAO;GAVL,WAAW,sBAAsB,aAAa,MAAM,WAAW;GAC/D,aAAa,sBAAsB,eAAe,WAAW;GAC7D,UAAU,KAAK,KAAK,EAAE,UAAU,cAAc,kBAAkB;IAC9D,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,UAAU,CAAC;GACb,EAAE;EAGY;CAClB;CAEA,YAAY,QAA0D;EACpE,OAAO,UACL;GACE,WAAW,0BAA0B;GACrC,KAAK,sBAAsB,YACzB,OAAO,aACP,OAAO,aACP,UACF;GACA,UAAU;EACZ,SACM,KAAK,aAAa,MAAM,CAChC;CACF;CAGA,MAAc,cACZ,aACA,MACA,KACwB;EACxB,MAAM,MAAM,GAAG,sBAAsB,UACnC,WACF,EAAE,QAAQ,KAAK,QAAQ;EAEvB,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,GAAG;EAEjD,OAAO,KAAK,OAAO;CACrB;CAEA,aACE,aACA,MACA,KACwB;EACxB,OAAO,UACL;GACE,WAAW,0BAA0B;GACrC,KAAK,sBAAsB,YAAY,aAAa,MAAM,OAAO,KAAK;EACxE,SACM,KAAK,cAAc,aAAa,MAAM,GAAG,CACjD;CACF;CAIA,MAAc,WACZ,EAAE,aAAa,MAAM,eACrB,UACwB;EACxB,IAAI,UAAU,QACZ,OAAO,KAAK,aAAa,aAAa,MAAM,QAAQ;EAGtD,MAAM,MAAM,GAAG,sBAAsB,UACnC,WACF,EAAE,QAAQ,KAAK;EACf,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,OAAO;EAErD,IAAI,KAAK,WAAW,GAClB,OAAO;EAGT,OAAO,KAAK,EAAE,CAAC;CACjB;CAEA,UACE,QACA,UACwB;EACxB,OAAO,UACL;GACE,WAAW,0BAA0B;GACrC,KAAK,sBAAsB,YACzB,OAAO,aACP,OAAO,aACP,QACF;GACA,UAAU;EACZ,SACM,KAAK,WAAW,QAAQ,QAAQ,CACxC;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/forgejo-releases/index.ts"],"sourcesContent":["import type { DatasourceName } from '../../../datasource-list.generated.ts';\nimport type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { ForgejoHttp } from '../../../util/http/forgejo.ts';\nimport { GiteaReleasesDatasource } from '../gitea-releases/index.ts';\n\n/**\n * Forgejo is a fork of Gitea and serves the same API, so the lookup is\n * inherited and only the identity of the datasource differs.\n */\nexport class ForgejoReleasesDatasource extends GiteaReleasesDatasource {\n static override readonly id: DatasourceName = 'forgejo-releases';\n\n static override readonly defaultRegistryUrls = ['https://code.forgejo.org'];\n\n override readonly defaultRegistryUrls =\n ForgejoReleasesDatasource.defaultRegistryUrls;\n\n protected override readonly cacheNamespace: PackageCacheNamespace =\n 'datasource-forgejo-releases';\n\n override http = new ForgejoHttp(ForgejoReleasesDatasource.id);\n\n constructor() {\n super(ForgejoReleasesDatasource.id);\n }\n}\n"],"mappings":";;;;;;;AASA,IAAa,4BAAb,MAAa,kCAAkC,wBAAwB;CACrE,OAAyB,KAAqB;CAE9C,OAAyB,sBAAsB,CAAC,0BAA0B;CAE1E,sBACE,0BAA0B;CAE5B,iBACE;CAEF,OAAgB,IAAI,YAAY,0BAA0B,EAAE;CAE5D,cAAc;EACZ,MAAM,0BAA0B,EAAE;CACpC;AACF"}
@@ -1,82 +1,19 @@
1
- import { regEx } from "../../../util/regex.js";
2
- import { ensureTrailingSlash } from "../../../util/url.js";
3
- import { withCache } from "../../../util/cache/package/with-cache.js";
4
- import { Datasource } from "../datasource.js";
5
1
  import { ForgejoHttp } from "../../../util/http/forgejo.js";
6
- import { Commits, Tag, Tags } from "./schema.js";
2
+ import { GiteaTagsDatasource } from "../gitea-tags/index.js";
7
3
  //#region lib/modules/datasource/forgejo-tags/index.ts
8
- var ForgejoTagsDatasource = class ForgejoTagsDatasource extends Datasource {
4
+ /**
5
+ * Forgejo is a fork of Gitea and serves the same API, so the lookup is
6
+ * inherited and only the identity of the datasource differs.
7
+ */
8
+ var ForgejoTagsDatasource = class ForgejoTagsDatasource extends GiteaTagsDatasource {
9
9
  static id = "forgejo-tags";
10
- http = new ForgejoHttp(ForgejoTagsDatasource.id);
11
10
  static defaultRegistryUrls = ["https://code.forgejo.org"];
12
- static cacheNamespace = `datasource-${ForgejoTagsDatasource.id}`;
13
- releaseTimestampSupport = true;
14
- releaseTimestampNote = "The release timestamp is determined from the `created` field in the results.";
15
- sourceUrlSupport = "package";
16
- sourceUrlNote = "The source URL is determined by using the `packageName` and `registryUrl`.";
11
+ defaultRegistryUrls = ForgejoTagsDatasource.defaultRegistryUrls;
12
+ cacheNamespace = "datasource-forgejo-tags";
13
+ http = new ForgejoHttp(ForgejoTagsDatasource.id);
17
14
  constructor() {
18
15
  super(ForgejoTagsDatasource.id);
19
16
  }
20
- static getRegistryURL(registryUrl) {
21
- return registryUrl ?? this.defaultRegistryUrls[0];
22
- }
23
- static getApiUrl(registryUrl) {
24
- const res = ForgejoTagsDatasource.getRegistryURL(registryUrl).replace(regEx(/\/api\/v1$/), "");
25
- return `${ensureTrailingSlash(res)}api/v1/`;
26
- }
27
- static getCacheKey(registryUrl, repo, type) {
28
- return `${ForgejoTagsDatasource.getRegistryURL(registryUrl)}:${repo}:${type}`;
29
- }
30
- static getSourceUrl(packageName, registryUrl) {
31
- const url = ForgejoTagsDatasource.getRegistryURL(registryUrl);
32
- return `${ensureTrailingSlash(url)}${packageName}`;
33
- }
34
- async _getReleases({ registryUrl, packageName: repo }) {
35
- const url = `${ForgejoTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/tags`;
36
- const tags = (await this.http.getJson(url, { paginate: true }, Tags)).body;
37
- return {
38
- sourceUrl: ForgejoTagsDatasource.getSourceUrl(repo, registryUrl),
39
- registryUrl: ForgejoTagsDatasource.getRegistryURL(registryUrl),
40
- releases: tags.map(({ name, commit }) => ({
41
- version: name,
42
- gitRef: name,
43
- newDigest: commit.sha,
44
- releaseTimestamp: commit.created
45
- }))
46
- };
47
- }
48
- getReleases(config) {
49
- return withCache({
50
- namespace: ForgejoTagsDatasource.cacheNamespace,
51
- key: ForgejoTagsDatasource.getCacheKey(config.registryUrl, config.packageName, "tags"),
52
- fallback: true
53
- }, () => this._getReleases(config));
54
- }
55
- async _getTagCommit(registryUrl, repo, tag) {
56
- const url = `${ForgejoTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/tags/${tag}`;
57
- const { body } = await this.http.getJson(url, Tag);
58
- return body.commit.sha;
59
- }
60
- getTagCommit(registryUrl, repo, tag) {
61
- return withCache({
62
- namespace: ForgejoTagsDatasource.cacheNamespace,
63
- key: ForgejoTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`)
64
- }, () => this._getTagCommit(registryUrl, repo, tag));
65
- }
66
- async _getDigest({ packageName: repo, registryUrl }, newValue) {
67
- if (newValue?.length) return this.getTagCommit(registryUrl, repo, newValue);
68
- const url = `${ForgejoTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;
69
- const { body } = await this.http.getJson(url, Commits);
70
- if (body.length === 0) return null;
71
- return body[0].sha;
72
- }
73
- getDigest(config, newValue) {
74
- return withCache({
75
- namespace: ForgejoTagsDatasource.cacheNamespace,
76
- key: ForgejoTagsDatasource.getCacheKey(config.registryUrl, config.packageName, "digest"),
77
- fallback: true
78
- }, () => this._getDigest(config, newValue));
79
- }
80
17
  };
81
18
  //#endregion
82
19
  export { ForgejoTagsDatasource };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/forgejo-tags/index.ts"],"sourcesContent":["import type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { ForgejoHttp } from '../../../util/http/forgejo.ts';\nimport { regEx } from '../../../util/regex.ts';\nimport { ensureTrailingSlash } from '../../../util/url.ts';\nimport { Datasource } from '../datasource.ts';\nimport type {\n DigestConfig,\n GetReleasesConfig,\n ReleaseResult,\n} from '../types.ts';\nimport { Commits, Tag, Tags } from './schema.ts';\n\nexport class ForgejoTagsDatasource extends Datasource {\n static readonly id = 'forgejo-tags';\n\n override http = new ForgejoHttp(ForgejoTagsDatasource.id);\n\n static readonly defaultRegistryUrls = ['https://code.forgejo.org'];\n\n private static readonly cacheNamespace: PackageCacheNamespace = `datasource-${ForgejoTagsDatasource.id}`;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timestamp is determined from the `created` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(ForgejoTagsDatasource.id);\n }\n\n static getRegistryURL(registryUrl?: string): string {\n // fallback to default API endpoint if custom not provided\n return registryUrl ?? this.defaultRegistryUrls[0];\n }\n\n static getApiUrl(registryUrl?: string): string {\n const res = ForgejoTagsDatasource.getRegistryURL(registryUrl).replace(\n regEx(/\\/api\\/v1$/),\n '',\n );\n return `${ensureTrailingSlash(res)}api/v1/`;\n }\n\n static getCacheKey(\n registryUrl: string | undefined,\n repo: string,\n type: string,\n ): string {\n return `${ForgejoTagsDatasource.getRegistryURL(registryUrl)}:${repo}:${type}`;\n }\n\n static getSourceUrl(packageName: string, registryUrl?: string): string {\n const url = ForgejoTagsDatasource.getRegistryURL(registryUrl);\n const normalizedUrl = ensureTrailingSlash(url);\n return `${normalizedUrl}${packageName}`;\n }\n\n // getReleases fetches list of tags for the repository\n private async _getReleases({\n registryUrl,\n packageName: repo,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n const url = `${ForgejoTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/tags`;\n const tags = (\n await this.http.getJson(\n url,\n {\n paginate: true,\n },\n Tags,\n )\n ).body;\n\n const dependency: ReleaseResult = {\n sourceUrl: ForgejoTagsDatasource.getSourceUrl(repo, registryUrl),\n registryUrl: ForgejoTagsDatasource.getRegistryURL(registryUrl),\n releases: tags.map(({ name, commit }) => ({\n version: name,\n gitRef: name,\n newDigest: commit.sha,\n releaseTimestamp: commit.created,\n })),\n };\n\n return dependency;\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: ForgejoTagsDatasource.cacheNamespace,\n key: ForgejoTagsDatasource.getCacheKey(\n config.registryUrl,\n config.packageName,\n 'tags',\n ),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n // getTagCommit fetched the commit has for specified tag\n private async _getTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = `${ForgejoTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/tags/${tag}`;\n\n const { body } = await this.http.getJson(url, Tag);\n\n return body.commit.sha;\n }\n\n getTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n return withCache(\n {\n namespace: ForgejoTagsDatasource.cacheNamespace,\n key: ForgejoTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`),\n },\n () => this._getTagCommit(registryUrl, repo, tag),\n );\n }\n\n // getDigest fetched the latest commit for repository main branch\n // however, if newValue is provided, then getTagCommit is called\n private async _getDigest(\n { packageName: repo, registryUrl }: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n if (newValue?.length) {\n return this.getTagCommit(registryUrl, repo, newValue);\n }\n\n const url = `${ForgejoTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;\n const { body } = await this.http.getJson(url, Commits);\n\n if (body.length === 0) {\n return null;\n }\n\n return body[0].sha;\n }\n\n override getDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n return withCache(\n {\n namespace: ForgejoTagsDatasource.cacheNamespace,\n key: ForgejoTagsDatasource.getCacheKey(\n config.registryUrl,\n config.packageName,\n 'digest',\n ),\n fallback: true,\n },\n () => this._getDigest(config, newValue),\n );\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAa,wBAAb,MAAa,8BAA8B,WAAW;CACpD,OAAgB,KAAK;CAErB,OAAgB,IAAI,YAAY,sBAAsB,EAAE;CAExD,OAAgB,sBAAsB,CAAC,0BAA0B;CAEjE,OAAwB,iBAAwC,cAAc,sBAAsB;CAEpG,0BAA4C;CAC5C,uBACE;CACF,mBAAqC;CACrC,gBACE;CAEF,cAAc;EACZ,MAAM,sBAAsB,EAAE;CAChC;CAEA,OAAO,eAAe,aAA8B;EAElD,OAAO,eAAe,KAAK,oBAAoB;CACjD;CAEA,OAAO,UAAU,aAA8B;EAC7C,MAAM,MAAM,sBAAsB,eAAe,WAAW,CAAC,CAAC,QAC5D,MAAM,YAAY,GAClB,EACF;EACA,OAAO,GAAG,oBAAoB,GAAG,EAAE;CACrC;CAEA,OAAO,YACL,aACA,MACA,MACQ;EACR,OAAO,GAAG,sBAAsB,eAAe,WAAW,EAAE,GAAG,KAAK,GAAG;CACzE;CAEA,OAAO,aAAa,aAAqB,aAA8B;EACrE,MAAM,MAAM,sBAAsB,eAAe,WAAW;EAE5D,OAAO,GADe,oBAAoB,GACpB,IAAI;CAC5B;CAGA,MAAc,aAAa,EACzB,aACA,aAAa,QACsC;EACnD,MAAM,MAAM,GAAG,sBAAsB,UACnC,WACF,EAAE,QAAQ,KAAK;EACf,MAAM,QACJ,MAAM,KAAK,KAAK,QACd,KACA,EACE,UAAU,KACZ,GACA,IACF,EAAA,CACA;EAaF,OAAO;GAVL,WAAW,sBAAsB,aAAa,MAAM,WAAW;GAC/D,aAAa,sBAAsB,eAAe,WAAW;GAC7D,UAAU,KAAK,KAAK,EAAE,MAAM,cAAc;IACxC,SAAS;IACT,QAAQ;IACR,WAAW,OAAO;IAClB,kBAAkB,OAAO;GAC3B,EAAE;EAGY;CAClB;CAEA,YAAY,QAA0D;EACpE,OAAO,UACL;GACE,WAAW,sBAAsB;GACjC,KAAK,sBAAsB,YACzB,OAAO,aACP,OAAO,aACP,MACF;GACA,UAAU;EACZ,SACM,KAAK,aAAa,MAAM,CAChC;CACF;CAGA,MAAc,cACZ,aACA,MACA,KACwB;EACxB,MAAM,MAAM,GAAG,sBAAsB,UACnC,WACF,EAAE,QAAQ,KAAK,QAAQ;EAEvB,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,GAAG;EAEjD,OAAO,KAAK,OAAO;CACrB;CAEA,aACE,aACA,MACA,KACwB;EACxB,OAAO,UACL;GACE,WAAW,sBAAsB;GACjC,KAAK,sBAAsB,YAAY,aAAa,MAAM,OAAO,KAAK;EACxE,SACM,KAAK,cAAc,aAAa,MAAM,GAAG,CACjD;CACF;CAIA,MAAc,WACZ,EAAE,aAAa,MAAM,eACrB,UACwB;EACxB,IAAI,UAAU,QACZ,OAAO,KAAK,aAAa,aAAa,MAAM,QAAQ;EAGtD,MAAM,MAAM,GAAG,sBAAsB,UACnC,WACF,EAAE,QAAQ,KAAK;EACf,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,OAAO;EAErD,IAAI,KAAK,WAAW,GAClB,OAAO;EAGT,OAAO,KAAK,EAAE,CAAC;CACjB;CAEA,UACE,QACA,UACwB;EACxB,OAAO,UACL;GACE,WAAW,sBAAsB;GACjC,KAAK,sBAAsB,YACzB,OAAO,aACP,OAAO,aACP,QACF;GACA,UAAU;EACZ,SACM,KAAK,WAAW,QAAQ,QAAQ,CACxC;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/forgejo-tags/index.ts"],"sourcesContent":["import type { DatasourceName } from '../../../datasource-list.generated.ts';\nimport type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { ForgejoHttp } from '../../../util/http/forgejo.ts';\nimport { GiteaTagsDatasource } from '../gitea-tags/index.ts';\n\n/**\n * Forgejo is a fork of Gitea and serves the same API, so the lookup is\n * inherited and only the identity of the datasource differs.\n */\nexport class ForgejoTagsDatasource extends GiteaTagsDatasource {\n static override readonly id: DatasourceName = 'forgejo-tags';\n\n static override readonly defaultRegistryUrls = ['https://code.forgejo.org'];\n\n override readonly defaultRegistryUrls =\n ForgejoTagsDatasource.defaultRegistryUrls;\n\n protected override readonly cacheNamespace: PackageCacheNamespace =\n 'datasource-forgejo-tags';\n\n override http = new ForgejoHttp(ForgejoTagsDatasource.id);\n\n constructor() {\n super(ForgejoTagsDatasource.id);\n }\n}\n"],"mappings":";;;;;;;AASA,IAAa,wBAAb,MAAa,8BAA8B,oBAAoB;CAC7D,OAAyB,KAAqB;CAE9C,OAAyB,sBAAsB,CAAC,0BAA0B;CAE1E,sBACE,sBAAsB;CAExB,iBACE;CAEF,OAAgB,IAAI,YAAY,sBAAsB,EAAE;CAExD,cAAc;EACZ,MAAM,sBAAsB,EAAE;CAChC;AACF"}
@@ -1,29 +1,25 @@
1
- import { withCache } from "../../../util/cache/package/with-cache.js";
2
- import { Datasource } from "../datasource.js";
3
- import { GiteaHttp } from "../../../util/http/gitea.js";
4
- import { Commits, Tag } from "../gitea-tags/schema.js";
5
- import { GiteaTagsDatasource } from "../gitea-tags/index.js";
1
+ import { getApiUrl, getSourceUrl } from "../gitea-tags/util.js";
2
+ import { GiteaDatasource } from "../gitea-tags/base.js";
6
3
  import { Releases } from "./schema.js";
7
4
  //#region lib/modules/datasource/gitea-releases/index.ts
8
- var GiteaReleasesDatasource = class GiteaReleasesDatasource extends Datasource {
5
+ var GiteaReleasesDatasource = class GiteaReleasesDatasource extends GiteaDatasource {
9
6
  static id = "gitea-releases";
10
- http = new GiteaHttp(GiteaReleasesDatasource.id);
11
- static defaultRegistryUrls = ["https://gitea.com"];
12
- static cacheNamespace = `datasource-${GiteaReleasesDatasource.id}`;
13
- releaseTimestampSupport = true;
14
- releaseTimestampNote = "The release timestamp is determined from the `published_at` field in the results.";
15
- sourceUrlSupport = "package";
16
- sourceUrlNote = "The source URL is determined by using the `packageName` and `registryUrl`.";
17
- constructor() {
18
- super(GiteaReleasesDatasource.id);
7
+ defaultRegistryUrls = GiteaReleasesDatasource.defaultRegistryUrls;
8
+ cacheNamespace = "datasource-gitea-releases";
9
+ /** Subclasses for other Gitea-compatible hosts pass their own id. */
10
+ constructor(id = GiteaReleasesDatasource.id) {
11
+ super(id, {
12
+ cacheKeyType: "releases",
13
+ releaseTimestampField: "published_at"
14
+ });
19
15
  }
20
- async _getReleases({ registryUrl, packageName: repo }) {
21
- const url = `${GiteaTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/releases?draft=false`;
22
- const tags = (await this.http.getJson(url, { paginate: true }, Releases)).body;
16
+ async _getReleases(registryUrl, repo) {
17
+ const url = `${getApiUrl(registryUrl)}repos/${repo}/releases?draft=false`;
18
+ const releases = (await this.http.getJson(url, { paginate: true }, Releases)).body;
23
19
  return {
24
- sourceUrl: GiteaTagsDatasource.getSourceUrl(repo, registryUrl),
25
- registryUrl: GiteaTagsDatasource.getRegistryURL(registryUrl),
26
- releases: tags.map(({ tag_name, published_at, prerelease }) => ({
20
+ sourceUrl: getSourceUrl(repo, registryUrl),
21
+ registryUrl,
22
+ releases: releases.map(({ tag_name, published_at, prerelease }) => ({
27
23
  version: tag_name,
28
24
  gitRef: tag_name,
29
25
  releaseTimestamp: published_at,
@@ -31,38 +27,6 @@ var GiteaReleasesDatasource = class GiteaReleasesDatasource extends Datasource {
31
27
  }))
32
28
  };
33
29
  }
34
- getReleases(config) {
35
- return withCache({
36
- namespace: GiteaReleasesDatasource.cacheNamespace,
37
- key: GiteaTagsDatasource.getCacheKey(config.registryUrl, config.packageName, "releases"),
38
- fallback: true
39
- }, () => this._getReleases(config));
40
- }
41
- async _getTagCommit(registryUrl, repo, tag) {
42
- const url = `${GiteaTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/tags/${tag}`;
43
- const { body } = await this.http.getJson(url, Tag);
44
- return body.commit.sha;
45
- }
46
- getTagCommit(registryUrl, repo, tag) {
47
- return withCache({
48
- namespace: GiteaReleasesDatasource.cacheNamespace,
49
- key: GiteaTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`)
50
- }, () => this._getTagCommit(registryUrl, repo, tag));
51
- }
52
- async _getDigest({ packageName: repo, registryUrl }, newValue) {
53
- if (newValue?.length) return this.getTagCommit(registryUrl, repo, newValue);
54
- const url = `${GiteaTagsDatasource.getApiUrl(registryUrl)}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;
55
- const { body } = await this.http.getJson(url, Commits);
56
- if (body.length === 0) return null;
57
- return body[0].sha;
58
- }
59
- getDigest(config, newValue) {
60
- return withCache({
61
- namespace: GiteaReleasesDatasource.cacheNamespace,
62
- key: GiteaTagsDatasource.getCacheKey(config.registryUrl, config.packageName, "digest"),
63
- fallback: true
64
- }, () => this._getDigest(config, newValue));
65
- }
66
30
  };
67
31
  //#endregion
68
32
  export { GiteaReleasesDatasource };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/gitea-releases/index.ts"],"sourcesContent":["import type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { withCache } from '../../../util/cache/package/with-cache.ts';\nimport { GiteaHttp } from '../../../util/http/gitea.ts';\nimport { Datasource } from '../datasource.ts';\nimport { GiteaTagsDatasource } from '../gitea-tags/index.ts';\nimport { Commits, Tag } from '../gitea-tags/schema.ts';\nimport type {\n DigestConfig,\n GetReleasesConfig,\n ReleaseResult,\n} from '../types.ts';\nimport { Releases } from './schema.ts';\n\nexport class GiteaReleasesDatasource extends Datasource {\n static readonly id = 'gitea-releases';\n\n override http = new GiteaHttp(GiteaReleasesDatasource.id);\n\n static readonly defaultRegistryUrls = ['https://gitea.com'];\n\n private static readonly cacheNamespace: PackageCacheNamespace = `datasource-${GiteaReleasesDatasource.id}`;\n\n override readonly releaseTimestampSupport = true;\n override readonly releaseTimestampNote =\n 'The release timestamp is determined from the `published_at` field in the results.';\n override readonly sourceUrlSupport = 'package';\n override readonly sourceUrlNote =\n 'The source URL is determined by using the `packageName` and `registryUrl`.';\n\n constructor() {\n super(GiteaReleasesDatasource.id);\n }\n\n // getReleases fetches list of tags for the repository\n private async _getReleases({\n registryUrl,\n packageName: repo,\n }: GetReleasesConfig): Promise<ReleaseResult | null> {\n const url = `${GiteaTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/releases?draft=false`;\n const tags = (\n await this.http.getJson(\n url,\n {\n paginate: true,\n },\n Releases,\n )\n ).body;\n\n const dependency: ReleaseResult = {\n sourceUrl: GiteaTagsDatasource.getSourceUrl(repo, registryUrl),\n registryUrl: GiteaTagsDatasource.getRegistryURL(registryUrl),\n releases: tags.map(({ tag_name, published_at, prerelease }) => ({\n version: tag_name,\n gitRef: tag_name,\n releaseTimestamp: published_at,\n isStable: !prerelease,\n })),\n };\n\n return dependency;\n }\n\n getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {\n return withCache(\n {\n namespace: GiteaReleasesDatasource.cacheNamespace,\n key: GiteaTagsDatasource.getCacheKey(\n config.registryUrl,\n config.packageName,\n 'releases',\n ),\n fallback: true,\n },\n () => this._getReleases(config),\n );\n }\n\n // getTagCommit fetched the commit has for specified tag\n private async _getTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n const url = `${GiteaTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/tags/${tag}`;\n\n const { body } = await this.http.getJson(url, Tag);\n\n return body.commit.sha;\n }\n\n getTagCommit(\n registryUrl: string | undefined,\n repo: string,\n tag: string,\n ): Promise<string | null> {\n return withCache(\n {\n namespace: GiteaReleasesDatasource.cacheNamespace,\n key: GiteaTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`),\n },\n () => this._getTagCommit(registryUrl, repo, tag),\n );\n }\n\n // getDigest fetched the latest commit for repository main branch\n // however, if newValue is provided, then getTagCommit is called\n private async _getDigest(\n { packageName: repo, registryUrl }: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n if (newValue?.length) {\n return this.getTagCommit(registryUrl, repo, newValue);\n }\n\n const url = `${GiteaTagsDatasource.getApiUrl(\n registryUrl,\n )}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;\n const { body } = await this.http.getJson(url, Commits);\n\n if (body.length === 0) {\n return null;\n }\n\n return body[0].sha;\n }\n\n override getDigest(\n config: DigestConfig,\n newValue?: string,\n ): Promise<string | null> {\n return withCache(\n {\n namespace: GiteaReleasesDatasource.cacheNamespace,\n key: GiteaTagsDatasource.getCacheKey(\n config.registryUrl,\n config.packageName,\n 'digest',\n ),\n fallback: true,\n },\n () => this._getDigest(config, newValue),\n );\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAa,0BAAb,MAAa,gCAAgC,WAAW;CACtD,OAAgB,KAAK;CAErB,OAAgB,IAAI,UAAU,wBAAwB,EAAE;CAExD,OAAgB,sBAAsB,CAAC,mBAAmB;CAE1D,OAAwB,iBAAwC,cAAc,wBAAwB;CAEtG,0BAA4C;CAC5C,uBACE;CACF,mBAAqC;CACrC,gBACE;CAEF,cAAc;EACZ,MAAM,wBAAwB,EAAE;CAClC;CAGA,MAAc,aAAa,EACzB,aACA,aAAa,QACsC;EACnD,MAAM,MAAM,GAAG,oBAAoB,UACjC,WACF,EAAE,QAAQ,KAAK;EACf,MAAM,QACJ,MAAM,KAAK,KAAK,QACd,KACA,EACE,UAAU,KACZ,GACA,QACF,EAAA,CACA;EAaF,OAAO;GAVL,WAAW,oBAAoB,aAAa,MAAM,WAAW;GAC7D,aAAa,oBAAoB,eAAe,WAAW;GAC3D,UAAU,KAAK,KAAK,EAAE,UAAU,cAAc,kBAAkB;IAC9D,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,UAAU,CAAC;GACb,EAAE;EAGY;CAClB;CAEA,YAAY,QAA0D;EACpE,OAAO,UACL;GACE,WAAW,wBAAwB;GACnC,KAAK,oBAAoB,YACvB,OAAO,aACP,OAAO,aACP,UACF;GACA,UAAU;EACZ,SACM,KAAK,aAAa,MAAM,CAChC;CACF;CAGA,MAAc,cACZ,aACA,MACA,KACwB;EACxB,MAAM,MAAM,GAAG,oBAAoB,UACjC,WACF,EAAE,QAAQ,KAAK,QAAQ;EAEvB,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,GAAG;EAEjD,OAAO,KAAK,OAAO;CACrB;CAEA,aACE,aACA,MACA,KACwB;EACxB,OAAO,UACL;GACE,WAAW,wBAAwB;GACnC,KAAK,oBAAoB,YAAY,aAAa,MAAM,OAAO,KAAK;EACtE,SACM,KAAK,cAAc,aAAa,MAAM,GAAG,CACjD;CACF;CAIA,MAAc,WACZ,EAAE,aAAa,MAAM,eACrB,UACwB;EACxB,IAAI,UAAU,QACZ,OAAO,KAAK,aAAa,aAAa,MAAM,QAAQ;EAGtD,MAAM,MAAM,GAAG,oBAAoB,UACjC,WACF,EAAE,QAAQ,KAAK;EACf,MAAM,EAAE,SAAS,MAAM,KAAK,KAAK,QAAQ,KAAK,OAAO;EAErD,IAAI,KAAK,WAAW,GAClB,OAAO;EAGT,OAAO,KAAK,EAAE,CAAC;CACjB;CAEA,UACE,QACA,UACwB;EACxB,OAAO,UACL;GACE,WAAW,wBAAwB;GACnC,KAAK,oBAAoB,YACvB,OAAO,aACP,OAAO,aACP,QACF;GACA,UAAU;EACZ,SACM,KAAK,WAAW,QAAQ,QAAQ,CACxC;CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../lib/modules/datasource/gitea-releases/index.ts"],"sourcesContent":["import type { DatasourceName } from '../../../datasource-list.generated.ts';\nimport type { PackageCacheNamespace } from '../../../util/cache/package/types.ts';\nimport { GiteaDatasource } from '../gitea-tags/base.ts';\nimport { getApiUrl, getSourceUrl } from '../gitea-tags/util.ts';\nimport type { ReleaseResult } from '../types.ts';\nimport { Releases } from './schema.ts';\n\nexport class GiteaReleasesDatasource extends GiteaDatasource {\n static readonly id: DatasourceName = 'gitea-releases';\n\n override readonly defaultRegistryUrls =\n GiteaReleasesDatasource.defaultRegistryUrls;\n\n protected readonly cacheNamespace: PackageCacheNamespace =\n 'datasource-gitea-releases';\n\n /** Subclasses for other Gitea-compatible hosts pass their own id. */\n constructor(id: string = GiteaReleasesDatasource.id) {\n super(id, {\n cacheKeyType: 'releases',\n releaseTimestampField: 'published_at',\n });\n }\n\n // _getReleases fetches list of releases for the repository\n protected async _getReleases(\n registryUrl: string,\n repo: string,\n ): Promise<ReleaseResult | null> {\n const url = `${getApiUrl(registryUrl)}repos/${repo}/releases?draft=false`;\n const releases = (\n await this.http.getJson(\n url,\n {\n paginate: true,\n },\n Releases,\n )\n ).body;\n\n const dependency: ReleaseResult = {\n sourceUrl: getSourceUrl(repo, registryUrl),\n registryUrl,\n releases: releases.map(({ tag_name, published_at, prerelease }) => ({\n version: tag_name,\n gitRef: tag_name,\n releaseTimestamp: published_at,\n isStable: !prerelease,\n })),\n };\n\n return dependency;\n }\n}\n"],"mappings":";;;;AAOA,IAAa,0BAAb,MAAa,gCAAgC,gBAAgB;CAC3D,OAAgB,KAAqB;CAErC,sBACE,wBAAwB;CAE1B,iBACE;;CAGF,YAAY,KAAa,wBAAwB,IAAI;EACnD,MAAM,IAAI;GACR,cAAc;GACd,uBAAuB;EACzB,CAAC;CACH;CAGA,MAAgB,aACd,aACA,MAC+B;EAC/B,MAAM,MAAM,GAAG,UAAU,WAAW,EAAE,QAAQ,KAAK;EACnD,MAAM,YACJ,MAAM,KAAK,KAAK,QACd,KACA,EACE,UAAU,KACZ,GACA,QACF,EAAA,CACA;EAaF,OAAO;GAVL,WAAW,aAAa,MAAM,WAAW;GACzC;GACA,UAAU,SAAS,KAAK,EAAE,UAAU,cAAc,kBAAkB;IAClE,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,UAAU,CAAC;GACb,EAAE;EAGY;CAClB;AACF"}
@@ -0,0 +1,93 @@
1
+ import { parseUrl } from "../../../util/url.js";
2
+ import { withCache } from "../../../util/cache/package/with-cache.js";
3
+ import { Datasource } from "../datasource.js";
4
+ import { GiteaHttp } from "../../../util/http/gitea.js";
5
+ import { Commits, Tag } from "./schema.js";
6
+ import { getApiUrl, getCacheKey, getSourceUrl } from "./util.js";
7
+ //#region lib/modules/datasource/gitea-tags/base.ts
8
+ /**
9
+ * Shared implementation of the datasources which speak the Gitea API.
10
+ *
11
+ * Forgejo is a fork of Gitea and serves the same API, so the Forgejo
12
+ * datasources extend the Gitea ones and only differ in their id, their default
13
+ * registry URL and their cache namespace. The digest lookup and the caching of
14
+ * `getReleases()` are the same for tags and releases, so they live here and a
15
+ * subclass only fetches and maps the releases of its own endpoint.
16
+ */
17
+ var GiteaDatasource = class extends Datasource {
18
+ static defaultRegistryUrls = ["https://gitea.com"];
19
+ http = new GiteaHttp(this.id);
20
+ releaseTimestampSupport = true;
21
+ releaseTimestampNote;
22
+ sourceUrlSupport = "package";
23
+ sourceUrlNote = "The source URL is determined by using the `packageName` and `registryUrl`.";
24
+ /** Discriminates the cache keys of the two endpoints. */
25
+ cacheKeyType;
26
+ /**
27
+ * @param endpoint describes the endpoint `getReleases()` reads: the
28
+ * discriminator of its cache keys, and the field the release timestamp comes
29
+ * from, which is rendered into the generated documentation.
30
+ */
31
+ constructor(id, endpoint) {
32
+ super(id);
33
+ this.cacheKeyType = endpoint.cacheKeyType;
34
+ this.releaseTimestampNote = `The release timestamp is determined from the \`${endpoint.releaseTimestampField}\` field in the results.`;
35
+ }
36
+ static getSourceUrl(packageName, registryUrl) {
37
+ return getSourceUrl(packageName, registryUrl ?? this.defaultRegistryUrls[0]);
38
+ }
39
+ /** Falls back to the default registry URL when none is configured. */
40
+ getRegistryUrl(registryUrl) {
41
+ return registryUrl ?? this.defaultRegistryUrls[0];
42
+ }
43
+ /**
44
+ * Only results from the public default instance may be written to the
45
+ * shared package cache; a self-hosted instance may serve private
46
+ * repositories.
47
+ */
48
+ isPublicRegistry(registryUrl) {
49
+ return parseUrl(registryUrl)?.hostname === parseUrl(this.defaultRegistryUrls[0])?.hostname;
50
+ }
51
+ getReleases({ registryUrl, packageName: repo }) {
52
+ const resolvedUrl = this.getRegistryUrl(registryUrl);
53
+ return withCache({
54
+ namespace: this.cacheNamespace,
55
+ key: getCacheKey(resolvedUrl, repo, this.cacheKeyType),
56
+ fallback: true,
57
+ cacheable: this.isPublicRegistry(resolvedUrl)
58
+ }, () => this._getReleases(resolvedUrl, repo));
59
+ }
60
+ async _getTagCommit(registryUrl, repo, tag) {
61
+ const url = `${getApiUrl(registryUrl)}repos/${repo}/tags/${tag}`;
62
+ const { body } = await this.http.getJson(url, Tag);
63
+ return body.commit.sha;
64
+ }
65
+ getTagCommit(registryUrl, repo, tag) {
66
+ const resolvedUrl = this.getRegistryUrl(registryUrl);
67
+ return withCache({
68
+ namespace: this.cacheNamespace,
69
+ key: getCacheKey(resolvedUrl, repo, `tag-${tag}`),
70
+ cacheable: this.isPublicRegistry(resolvedUrl)
71
+ }, () => this._getTagCommit(resolvedUrl, repo, tag));
72
+ }
73
+ async _getDigest(registryUrl, repo, newValue) {
74
+ if (newValue?.length) return this.getTagCommit(registryUrl, repo, newValue);
75
+ const url = `${getApiUrl(registryUrl)}repos/${repo}/commits?stat=false&verification=false&files=false&page=1&limit=1`;
76
+ const { body } = await this.http.getJson(url, Commits);
77
+ if (body.length === 0) return null;
78
+ return body[0].sha;
79
+ }
80
+ getDigest({ packageName: repo, registryUrl }, newValue) {
81
+ const resolvedUrl = this.getRegistryUrl(registryUrl);
82
+ return withCache({
83
+ namespace: this.cacheNamespace,
84
+ key: getCacheKey(resolvedUrl, repo, "digest"),
85
+ fallback: true,
86
+ cacheable: this.isPublicRegistry(resolvedUrl)
87
+ }, () => this._getDigest(resolvedUrl, repo, newValue));
88
+ }
89
+ };
90
+ //#endregion
91
+ export { GiteaDatasource };
92
+
93
+ //# sourceMappingURL=base.js.map