Skip to content

Commit

Permalink
Fix: Allow register of private repos (fixes #200)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Oct 4, 2023
1 parent c0777a7 commit c87882e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/integration/PluginManagement/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -120,11 +121,19 @@ 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)
})
if (response.status !== 201) return false;
return true;
}

0 comments on commit c87882e

Please sign in to comment.