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) }