@backstage/release-manifests
Advanced tools
Comparing version 0.0.11 to 0.0.12-next.0
# @backstage/release-manifests | ||
## 0.0.12-next.0 | ||
### Patch Changes | ||
- 2e140dc: Switch to native fetch for loading release manifests | ||
## 0.0.11 | ||
@@ -4,0 +10,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var manifest = require('./manifest.cjs.js'); | ||
var fetch = require('cross-fetch'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch); | ||
const VERSIONS_BASE_URL = "https://versions.backstage.io"; | ||
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com/backstage/versions/main"; | ||
function wait(waitMs, signal) { | ||
return new Promise((resolve, reject) => { | ||
const timeout = setTimeout(() => { | ||
if (!signal.aborted) { | ||
resolve(); | ||
} | ||
}, waitMs); | ||
signal.addEventListener("abort", () => { | ||
clearTimeout(timeout); | ||
reject(new Error("Aborted")); | ||
}); | ||
}); | ||
} | ||
async function withFallback(fn1, fn2, fallbackDelayMs) { | ||
const c1 = new AbortController(); | ||
const c2 = new AbortController(); | ||
const promise1 = fn1(c1.signal).then((res) => { | ||
c2.abort(); | ||
return res; | ||
}); | ||
const promise2 = wait(fallbackDelayMs, c2.signal).then(() => fn2(c2.signal)).then((res) => { | ||
c1.abort(); | ||
return res; | ||
}); | ||
return Promise.any([promise1, promise2]).catch(() => promise1); | ||
} | ||
async function getManifestByVersion(options) { | ||
const versionEnc = encodeURIComponent(options.version); | ||
const res = await withFallback( | ||
(signal) => fetch__default["default"](`${VERSIONS_BASE_URL}/v1/releases/${versionEnc}/manifest.json`, { | ||
signal | ||
}), | ||
(signal) => fetch__default["default"](`${GITHUB_RAW_BASE_URL}/v1/releases/${versionEnc}/manifest.json`, { | ||
signal | ||
}), | ||
500 | ||
); | ||
if (res.status === 404) { | ||
throw new Error(`No release found for ${options.version} version`); | ||
} | ||
if (res.status !== 200) { | ||
throw new Error( | ||
`Unexpected response status ${res.status} when fetching release from ${res.url}.` | ||
); | ||
} | ||
return res.json(); | ||
} | ||
async function getManifestByReleaseLine(options) { | ||
const releaseEnc = encodeURIComponent(options.releaseLine); | ||
const res = await withFallback( | ||
(signal) => fetch__default["default"](`${VERSIONS_BASE_URL}/v1/tags/${releaseEnc}/manifest.json`, { | ||
signal | ||
}), | ||
async (signal) => { | ||
const baseUrl = `${GITHUB_RAW_BASE_URL}/v1/tags/${releaseEnc}`; | ||
const linkRes = await fetch__default["default"](baseUrl, { signal }); | ||
if (!linkRes.ok) { | ||
return linkRes; | ||
} | ||
const link = (await linkRes.text()).trim(); | ||
return fetch__default["default"](new URL(`${link}/manifest.json`, baseUrl), { signal }); | ||
}, | ||
1e3 | ||
); | ||
if (res.status === 404) { | ||
throw new Error(`No '${options.releaseLine}' release line found`); | ||
} | ||
if (res.status !== 200) { | ||
throw new Error( | ||
`Unexpected response status ${res.status} when fetching release from ${res.url}.` | ||
); | ||
} | ||
return res.json(); | ||
} | ||
exports.getManifestByReleaseLine = getManifestByReleaseLine; | ||
exports.getManifestByVersion = getManifestByVersion; | ||
exports.getManifestByReleaseLine = manifest.getManifestByReleaseLine; | ||
exports.getManifestByVersion = manifest.getManifestByVersion; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -37,2 +37,2 @@ /** | ||
export { GetManifestByReleaseLineOptions, GetManifestByVersionOptions, ReleaseManifest, getManifestByReleaseLine, getManifestByVersion }; | ||
export { type GetManifestByReleaseLineOptions, type GetManifestByVersionOptions, type ReleaseManifest, getManifestByReleaseLine, getManifestByVersion }; |
@@ -1,81 +0,2 @@ | ||
import fetch from 'cross-fetch'; | ||
const VERSIONS_BASE_URL = "https://versions.backstage.io"; | ||
const GITHUB_RAW_BASE_URL = "https://raw.githubusercontent.com/backstage/versions/main"; | ||
function wait(waitMs, signal) { | ||
return new Promise((resolve, reject) => { | ||
const timeout = setTimeout(() => { | ||
if (!signal.aborted) { | ||
resolve(); | ||
} | ||
}, waitMs); | ||
signal.addEventListener("abort", () => { | ||
clearTimeout(timeout); | ||
reject(new Error("Aborted")); | ||
}); | ||
}); | ||
} | ||
async function withFallback(fn1, fn2, fallbackDelayMs) { | ||
const c1 = new AbortController(); | ||
const c2 = new AbortController(); | ||
const promise1 = fn1(c1.signal).then((res) => { | ||
c2.abort(); | ||
return res; | ||
}); | ||
const promise2 = wait(fallbackDelayMs, c2.signal).then(() => fn2(c2.signal)).then((res) => { | ||
c1.abort(); | ||
return res; | ||
}); | ||
return Promise.any([promise1, promise2]).catch(() => promise1); | ||
} | ||
async function getManifestByVersion(options) { | ||
const versionEnc = encodeURIComponent(options.version); | ||
const res = await withFallback( | ||
(signal) => fetch(`${VERSIONS_BASE_URL}/v1/releases/${versionEnc}/manifest.json`, { | ||
signal | ||
}), | ||
(signal) => fetch(`${GITHUB_RAW_BASE_URL}/v1/releases/${versionEnc}/manifest.json`, { | ||
signal | ||
}), | ||
500 | ||
); | ||
if (res.status === 404) { | ||
throw new Error(`No release found for ${options.version} version`); | ||
} | ||
if (res.status !== 200) { | ||
throw new Error( | ||
`Unexpected response status ${res.status} when fetching release from ${res.url}.` | ||
); | ||
} | ||
return res.json(); | ||
} | ||
async function getManifestByReleaseLine(options) { | ||
const releaseEnc = encodeURIComponent(options.releaseLine); | ||
const res = await withFallback( | ||
(signal) => fetch(`${VERSIONS_BASE_URL}/v1/tags/${releaseEnc}/manifest.json`, { | ||
signal | ||
}), | ||
async (signal) => { | ||
const baseUrl = `${GITHUB_RAW_BASE_URL}/v1/tags/${releaseEnc}`; | ||
const linkRes = await fetch(baseUrl, { signal }); | ||
if (!linkRes.ok) { | ||
return linkRes; | ||
} | ||
const link = (await linkRes.text()).trim(); | ||
return fetch(new URL(`${link}/manifest.json`, baseUrl), { signal }); | ||
}, | ||
1e3 | ||
); | ||
if (res.status === 404) { | ||
throw new Error(`No '${options.releaseLine}' release line found`); | ||
} | ||
if (res.status !== 200) { | ||
throw new Error( | ||
`Unexpected response status ${res.status} when fetching release from ${res.url}.` | ||
); | ||
} | ||
return res.json(); | ||
} | ||
export { getManifestByReleaseLine, getManifestByVersion }; | ||
export { getManifestByReleaseLine, getManifestByVersion } from './manifest.esm.js'; | ||
//# sourceMappingURL=index.esm.js.map |
{ | ||
"name": "@backstage/release-manifests", | ||
"version": "0.0.12-next.0", | ||
"description": "Helper library for receiving release manifests", | ||
"version": "0.0.11", | ||
"main": "dist/index.cjs.js", | ||
"types": "dist/index.d.ts", | ||
"backstage": { | ||
"role": "common-library" | ||
}, | ||
"publishConfig": { | ||
@@ -13,5 +14,5 @@ "access": "public", | ||
}, | ||
"backstage": { | ||
"role": "common-library" | ||
}, | ||
"keywords": [ | ||
"backstage" | ||
], | ||
"homepage": "https://backstage.io", | ||
@@ -23,27 +24,30 @@ "repository": { | ||
}, | ||
"keywords": [ | ||
"backstage" | ||
], | ||
"license": "Apache-2.0", | ||
"sideEffects": false, | ||
"main": "dist/index.cjs.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "backstage-cli package build", | ||
"clean": "backstage-cli package clean", | ||
"lint": "backstage-cli package lint", | ||
"test": "backstage-cli package test", | ||
"prepack": "backstage-cli package prepack", | ||
"postpack": "backstage-cli package postpack", | ||
"clean": "backstage-cli package clean" | ||
"test": "backstage-cli package test" | ||
}, | ||
"dependencies": { | ||
"cross-fetch": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.24.0", | ||
"@backstage/test-utils": "^1.4.5", | ||
"@backstage/cli": "0.29.3-next.0", | ||
"@backstage/test-utils": "1.7.3-next.0", | ||
"msw": "^1.0.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"typesVersions": { | ||
"*": { | ||
"index": [ | ||
"dist/index.d.ts" | ||
] | ||
} | ||
}, | ||
"module": "dist/index.esm.js" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
0
12
202
25303
11
- Removedcross-fetch@^4.0.0
- Removedcross-fetch@4.1.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)