Skip to content

Commit

Permalink
Fix: Allow register of private repos (fixes #200) (#201)
Browse files Browse the repository at this point in the history
* Fix: Allow register of private repos (fixes #200)

* Update register.js
  • Loading branch information
oliverfoster committed Oct 17, 2023
1 parent c14df8d commit 11723bd
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 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,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)
}

0 comments on commit 11723bd

Please sign in to comment.