Skip to content

Commit 11723bd

Browse files
authored
Fix: Allow register of private repos (fixes #200) (#201)
* Fix: Allow register of private repos (fixes #200) * Update register.js
1 parent c14df8d commit 11723bd

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

lib/integration/PluginManagement/register.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import getBowerRegistryConfig from '../getBowerRegistryConfig.js'
33
import fs from 'fs-extra'
44
import path from 'path'
55
import bower from 'bower'
6+
import fetch from 'node-fetch'
67
import chalk from 'chalk'
78
import inquirer from 'inquirer'
89
import { readValidateJSON } from '../../util/JSONReadValidate.js'
@@ -120,11 +121,18 @@ async function exists (BOWER_REGISTRY_CONFIG, plugin) {
120121
}
121122

122123
async function registerWithBowerRepo (BOWER_REGISTRY_CONFIG, plugin, repository) {
123-
return new Promise((resolve, reject) => {
124-
bower.commands.register(plugin.toString(), repository.url || repository, {
125-
registry: BOWER_REGISTRY_CONFIG
126-
})
127-
.on('end', resolve)
128-
.on('error', reject)
124+
const data = {
125+
name: plugin.toString(),
126+
url: repository.url || repository
127+
}
128+
const response = await fetch(`${BOWER_REGISTRY_CONFIG.register}packages`, {
129+
headers: {
130+
'User-Agent': 'adapt-cli',
131+
'Content-Type': 'application/json'
132+
},
133+
followRedirect: false,
134+
method: 'POST',
135+
body: JSON.stringify(data)
129136
})
137+
return (response?.status === 201)
130138
}

0 commit comments

Comments
 (0)