From 11723bd94e9dab8e045fa56815352a0b7df6ddb6 Mon Sep 17 00:00:00 2001 From: Oliver Foster Date: Tue, 17 Oct 2023 14:51:50 +0100 Subject: [PATCH] Fix: Allow register of private repos (fixes #200) (#201) * Fix: Allow register of private repos (fixes #200) * Update register.js --- lib/integration/PluginManagement/register.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/integration/PluginManagement/register.js b/lib/integration/PluginManagement/register.js index 879e639..590a0b0 100644 --- a/lib/integration/PluginManagement/register.js +++ b/lib/integration/PluginManagement/register.js @@ -3,6 +3,7 @@ import getBowerRegistryConfig from '../getBowerRegistryConfig.js' import fs from 'fs-extra' import path from 'path' import bower from 'bower' +import fetch from 'node-fetch' import chalk from 'chalk' import inquirer from 'inquirer' import { readValidateJSON } from '../../util/JSONReadValidate.js' @@ -120,11 +121,18 @@ async function exists (BOWER_REGISTRY_CONFIG, plugin) { } async function registerWithBowerRepo (BOWER_REGISTRY_CONFIG, plugin, repository) { - return new Promise((resolve, reject) => { - bower.commands.register(plugin.toString(), repository.url || repository, { - registry: BOWER_REGISTRY_CONFIG - }) - .on('end', resolve) - .on('error', reject) + const data = { + name: plugin.toString(), + url: repository.url || repository + } + const response = await fetch(`${BOWER_REGISTRY_CONFIG.register}packages`, { + headers: { + 'User-Agent': 'adapt-cli', + 'Content-Type': 'application/json' + }, + followRedirect: false, + method: 'POST', + body: JSON.stringify(data) }) + return (response?.status === 201) }