From 442cbba6256302ed7654099a021bf88fd24a3c72 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 1 Nov 2022 15:30:04 +0100 Subject: [PATCH] Revert "auth-backend: add script for re-publishing openid-client" This reverts commit 6c7a73e597bc53e0bbe93eab2518b5d4e4b26a05. Signed-off-by: Patrik Oldsberg --- .../scripts/republish-openid-client.js | 109 ------------------ 1 file changed, 109 deletions(-) delete mode 100755 plugins/auth-backend/scripts/republish-openid-client.js diff --git a/plugins/auth-backend/scripts/republish-openid-client.js b/plugins/auth-backend/scripts/republish-openid-client.js deleted file mode 100755 index 9d4497e590..0000000000 --- a/plugins/auth-backend/scripts/republish-openid-client.js +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable import/no-extraneous-dependencies */ -/* - * Copyright 2022 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const fetch = require('node-fetch'); -const zlib = require('zlib'); - -// eslint-disable-next-line import/no-extraneous-dependencies -const libpub = require('libnpmpublish'); -const concatStream = require('concat-stream'); -const tar = require('tar-stream'); - -/* - -This works around an incompatibility in node versioning policies between Backstage and -the openid-client package. This script downloads a target version of the openid-client -package and re-publishes it as a new version of the openid-client-any-engine package. - -Usage: ./republish-openid-client.js - -Environment Variables: - -NPM_TOKEN: The NPM auth token to use for publishing. -NPM_OTP: The NPM OTP (2FA one time password) to use for publishing. - -*/ - -async function main(args) { - const [version] = args; - if (!version) { - throw new Error('No version provided, Usage: $0 '); - } - - const res = await fetch( - `https://registry.npmjs.org/openid-client/-/openid-client-${version}.tgz`, - ); - if (!res.ok) { - throw new Error(`Failed to fetch openid-client: ${res.status}`); - } - - const { data, manifest } = await new Promise((resolve, reject) => { - const extract = tar.extract(); - const pack = tar.pack(); - let foundPackageJson = undefined; - - res.body.pipe(zlib.createGunzip()).pipe(extract).on('error', reject); - - extract.on('entry', (header, stream, callback) => { - if (header.name === 'package/package.json') { - stream.pipe( - concatStream(fileContents => { - const packageJson = JSON.parse(fileContents.toString('utf8')); - packageJson.name = 'openid-client-any-engine'; - packageJson.description = - 'Re-publish of openid-client that allows any Node.js version above 12.19.0'; - packageJson.engines.node = '>=12.19.0'; - - foundPackageJson = packageJson; - - pack.entry( - { name: 'package/package.json' }, - JSON.stringify(packageJson, null, 2), - ); - callback(); - }), - ); - } else { - stream.pipe(pack.entry(header, callback)); - } - }); - - extract.on('finish', () => { - pack.finalize(); - }); - - pack - .pipe(zlib.createGzip()) - .pipe( - concatStream(d => { - resolve({ data: d, manifest: foundPackageJson }); - }), - ) - .on('error', reject); - }); - - await libpub.publish(manifest, data, { - token: process.env.NPM_TOKEN, - otp: process.env.NPM_OTP, - }); -} - -main(process.argv.slice(2)).catch(error => { - console.error(error); - process.exit(1); -});