Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Allow register of private repos (fixes #200) #201

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}