Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backstage/release-manifests

Package Overview
Dependencies
Maintainers
3
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backstage/release-manifests - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12-next.0

dist/manifest.cjs.js

6

CHANGELOG.md
# @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 @@

87

dist/index.cjs.js
'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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc