@backstage/release-manifests
Advanced tools
Comparing version 0.0.0-nightly-20230919021144 to 0.0.0-nightly-20241123023427
# @backstage/release-manifests | ||
## 0.0.0-nightly-20230919021144 | ||
## 0.0.0-nightly-20241123023427 | ||
### Patch Changes | ||
- 2e140dc: Switch to native fetch for loading release manifests | ||
## 0.0.11 | ||
### Patch Changes | ||
- 4aa43f62aa: Updated dependency `cross-fetch` to `^4.0.0`. | ||
## 0.0.10 | ||
### Patch Changes | ||
- 406b786a2a2c: Mark package as being free of side effects, allowing more optimized Webpack builds. | ||
@@ -8,0 +20,0 @@ - 8cec7664e146: Removed `@types/node` dependency |
'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.0-nightly-20241123023427", | ||
"description": "Helper library for receiving release manifests", | ||
"version": "0.0.0-nightly-20230919021144", | ||
"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": "^3.1.5" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.0.0-nightly-20230919021144", | ||
"@backstage/test-utils": "^0.0.0-nightly-20230919021144", | ||
"@backstage/cli": "0.0.0-nightly-20241123023427", | ||
"@backstage/test-utils": "0.0.0-nightly-20241123023427", | ||
"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
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
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
25364
11
- Removedcross-fetch@^3.1.5
- Removedcross-fetch@3.2.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)