Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | 12x 15x 12x 12x 12x 17x 4x 4x 3x 3x 1x 1x 3x 3x 2x 2x 1x 1x 5x 5x 1x 1x 5x 5x 7x 7x 1x 1x 1x 1x 1x 1x | import request from 'superagent';
import searchPackages from './modules/searchPackages';
import createRepository from './modules/createRepository';
import showRepository from './modules/showRepository';
import getRepositories from './modules/getRepositories';
import getDistributions from './modules/getDistributions';
import listPackages from './modules/listPackages';
import deletePackage from './modules/deletePackage';
import uploadPackage from './modules/uploadPackage';
import promotePackage from './modules/promotePackage';
import showPackage from './modules/showPackage';
import showVersionedPackage from './modules/showVersionedPackage';
import validateOptions from './modules/validateOptions';
import { version as VERSION } from '../package.json';
const API_VERSION = "api/v1";
export default class packagecloud {
/** JavaScript Client for the packagecloud API.
* @class packagecloud
* @param {Object} options - Repository options.
* @param {string} options.token - a packagecloud API Token.
* @param {string} options.baseUrl - <Optional>URL to the packagecloud API.
*/
constructor(options) {
validateOptions(options, ['token']);
this.token = options.token;
this.baseUrl = (options.baseUrl || 'https://packagecloud.io').replace(/\/+$/, "");
this.requestOptions = {
baseUrl: `${this.baseUrl}/${API_VERSION}/`
};
}
_setHeaders(request) {
return request
.auth(this.token, '')
.set({ 'X-packagecloud-JS-Client': VERSION });
}
/** Create a repository.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.name - The repository name.
* @param {boolean} options.privacy - Set the public or private status.
* @return {Promise} The superagent promise object.
*/
createRepository(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(createRepository(request, opts));
}
/** Show repository information.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @return {Promise} The superagent promise object.
*/
showRepository(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(showRepository(request, opts));
}
/** Get a list of repositories for the authenticated user.
* @memberof! packagecloud#
* @return {Promise} The superagent promise object.
*/
getRepositories() {
return this._setHeaders(getRepositories(request, this.requestOptions))
}
/** Get a list of supported distributions on packagecloud.
* @memberof! packagecloud#
* @return {Promise} The superagent promise object.
*/
getDistributions() {
return this._setHeaders(getDistributions(request, this.requestOptions));
}
/** Get a list of packages from a repository.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @return {Promise} The superagent promise object.
*/
listPackages(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(listPackages(request, opts));
}
/** Search for packages in a repository.
* @memberof! packagecloud#
* @param {Object} options - Search options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.filename - The query string to search for package filename.
* @param {string} options.type - The type of package to search, supports: all, debs, gems, rpms, python, dscs, java.
* @param {string} options.dist - Overrides options.type. The name of the distribution the package is intended for. (i.e., ubuntu, el/6)
* @param {string} options.perPage - The number of packages to return from the results set, default is 30.
* @return {Promise} The superagent promise object.
*/
searchPackages(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(searchPackages(request, opts));
}
/** Delete a package.
* @memberof! packagecloud#
* @param {Object} options - Promote package options.
* @param {string} options.repository - The fully-qualified name for the source repository, i.e., 'username/sourcerepo'.
* @param {string} options.distroFqname - The fully-qualified distribution/version, i.e., 'ubuntu/precise'.
* @param {string} options.group - The name of the group this package belongs to for Java packages.
* @param {string} options.scope - The package scope. Required if deleting a scoped Node.JS package
* @param {string} options.filename - The filename of the package.
* @return {Promise} The superagent promise object.
*/
deletePackage(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(deletePackage(request, opts));
}
/** Upload a package.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.file - The file to be uploaded, must be a Buffer or ./path/to/file.
* @param {string} options.filename - The filename of the package.
* @return {Promise} The superagent promise object.
*/
uploadPackage(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(uploadPackage(request, opts));
}
/** Promote package.
* @memberof! packagecloud#
* @param {Object} options - Promote package options.
* @param {string} options.sourceRepo - The fully-qualified name for the source repository, i.e., 'username/sourcerepo'.
* @param {string} options.destination - The fully-qualified destination repository name, i.e., 'username/destrepo'.
* @param {string} options.distroFqname - The fully-qualified distribution/version, i.e., 'ubuntu/precise'.
* @param {string} options.group - The name of the group this package belongs to for Java packages.
* @param {string} options.scope - The package scope. Required if deleting a scoped Node.JS package
* @param {string} options.filename - The filename of the package.
*/
promotePackage(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(promotePackage(request, opts));
}
/** Get package information for Debian and RPM packages.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.type - The type of package, supported: deb, rpm.
* @param {string} options.distro - The distribution name, i.e., 'ubuntu'.
* @param {string} options.distroVersion - The distribution version, i.e., 'precise'.
* @param {string} options.name - The name of the package.
* @param {string} options.arch - The architecture of the package. NOTE: debs use amd64 while rpms use x86_64 for arch.
* @param {string} options.version - The version of the package without epoch.
* @param {string} options.release - <Optional> The release, if the package contains one.
* @return {Promise} The superagent promise object.
*/
showPackage(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(showPackage(request, opts));
}
/** Get package information for RubyGem, Python, and Java packages.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.type - The type of package, supported types: gem, python, java.
* @param {string} options.name - The name of the package.
* @param {string} options.version - The version number of the package.
* @return {Promise} The superagent promise object.
*/
showVersionedPackage(options) {
let opts = Object.assign({}, this.requestOptions, options);
return this._setHeaders(showVersionedPackage(request, opts));
}
/** Get package information for RubyGem packages.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.name - The name of the gem package.
* @param {string} options.version - The version number of the gem package.
* @return {Promise} The superagent promise object.
*/
showGemPackage(options) {
options.type = "gem";
return this.showVersionedPackage(options);
}
/** Get package information for Python packages.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.name - The name of the gem package.
* @param {string} options.version - The version number of the python package.
* @return {Promise} The superagent promise object.
*/
showPythonPackage(options) {
options.type = "python";
return this.showVersionedPackage(options);
}
/** Get package information for Java packages.
* @memberof! packagecloud#
* @param {Object} options - Repository options.
* @param {string} options.repo - The fully-qualified repository name, i.e., 'username/reponame'.
* @param {string} options.name - The name of the gem package.
* @param {string} options.version - The version number of the gem package.
* @return {Promise} The superagent promise object.
*/
showJavaPackage(options) {
options.type = "java";
return this.showVersionedPackage(options);
}
}
|