update vso-node-api

This commit is contained in:
Joao Moreno 2016-09-19 12:07:41 +02:00
parent f4bfb5d18d
commit 0ab19dd838
6 changed files with 33 additions and 14887 deletions

View file

@ -41,7 +41,7 @@
"semver": "^5.1.0",
"tmp": "0.0.29",
"url-join": "^1.1.0",
"vso-node-api": "^3.0.2",
"vso-node-api": "^5.0.5",
"yauzl": "^2.3.1",
"yazl": "^2.2.2"
},

View file

@ -1,9 +1,9 @@
import * as fs from 'fs';
import { ExtensionQueryFlags, PublishedExtension, ExtensionQueryFilterType, PagingDirection } from 'vso-node-api/interfaces/GalleryInterfaces';
import { ExtensionQueryFlags, PublishedExtension, ExtensionQueryFilterType, PagingDirection, SortByType, SortOrderType } from 'vso-node-api/interfaces/GalleryInterfaces';
import { pack, readManifest, writeManifest, IPackageResult } from './package';
import * as tmp from 'tmp';
import { getPublisher } from './store';
import { getGalleryAPI, getRawGalleryAPI, read } from './util';
import { getGalleryAPI, read } from './util';
import { validatePublisher } from './validation';
import { Manifest } from './manifest';
import * as denodeify from 'denodeify';
@ -152,9 +152,9 @@ export function list(publisher: string): Promise<any> {
.then(p => p.pat)
.then(getGalleryAPI)
.then(api => {
const criteira = [{ filterType: ExtensionQueryFilterType.Tag, value: 'vscode' }];
const filters = [{ criteria: criteira, direction: PagingDirection.Backward, pageSize: 1000, pagingToken: null }];
const query = { filters, flags: ExtensionQueryFlags.IncludeVersions };
const criteria = [{ filterType: ExtensionQueryFilterType.InstallationTarget, value: 'Microsoft.VisualStudio.Code' }];
const filters = [{ criteria, direction: PagingDirection.Forward, pageNumber: 0, pageSize: 1000, pagingToken: null, sortBy: SortByType.Relevance, sortOrder: SortOrderType.Default }];
const query = { filters, flags: ExtensionQueryFlags.IncludeLatestVersionOnly | ExtensionQueryFlags.IncludeVersionProperties, assetTypes: [] };
return api.queryExtensions(query).then(result => {
return result.results[0].extensions
@ -187,11 +187,8 @@ export function unpublish(options: IUnpublishOptions = {}): Promise<any> {
return read(`This will FOREVER delete '${ fullName }'! Are you sure? [y/N] `)
.then(answer => /^y$/i.test(answer) ? null : Promise.reject('Aborted'))
.then(() => pat)
.then(getRawGalleryAPI)
.then(api => {
const deleteExtension = denodeify<string, string, string, void>(api.deleteExtension.bind(api));
return deleteExtension(publisher, name, '');
})
.then(getGalleryAPI)
.then(api => api.deleteExtension(publisher, name))
.then(() => console.log(`Successfully deleted ${ fullName }!`));
});
}

View file

@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import { home } from 'osenv';
import { read, getGalleryAPI, getRawGalleryAPI } from './util';
import { read, getGalleryAPI } from './util';
import { validatePublisher } from './validation';
import * as denodeify from 'denodeify';
@ -116,24 +116,27 @@ export function createPublisher(publisherName: string): Promise<any> {
validatePublisher(publisherName);
return read(`Publisher human-friendly name: `, { default: publisherName }).then(displayName => {
return read(`Personal Access Token:`, { silent: true, replace: '*' })
.then(pat => {
const api = getGalleryAPI(pat);
const raw = {
publisherName,
displayName,
extensions: [],
flags: null,
lastUpdated: null,
longDescription: '',
publisherId: null,
shortDescription: ''
};
return read(`E-mail: `).then(email => {
return read(`Personal Access Token:`, { silent: true, replace: '*' })
.then(pat => {
const api = getGalleryAPI(pat);
const raw = {
publisherName,
displayName,
extensions: [],
flags: null,
lastUpdated: null,
longDescription: '',
publisherId: null,
shortDescription: '',
emailAddress: [email]
};
return api.createPublisher(raw)
.then(() => ({ name: publisherName, pat }));
})
.then(publisher => load().then(store => addPublisherToStore(store, publisher)));
return api.createPublisher(raw)
.then(() => ({ name: publisherName, pat }));
})
.then(publisher => load().then(store => addPublisherToStore(store, publisher)));
});
})
.then(() => console.log(`Successfully created publisher '${ publisherName }'.`));
}
@ -142,11 +145,8 @@ export function deletePublisher(publisherName: string): Promise<any> {
return getPublisher(publisherName).then(({ pat }) => {
return read(`This will FOREVER delete '${ publisherName }'! Are you sure? [y/N] `)
.then(answer => /^y$/i.test(answer) ? null : Promise.reject('Aborted'))
.then(() => {
const rawApi = getRawGalleryAPI(pat);
const deletePublisher = denodeify<string, void>(rawApi.deletePublisher.bind(rawApi));
return deletePublisher(publisherName);
})
.then(() => getGalleryAPI(pat))
.then(api => api.deletePublisher(publisherName))
.then(() => load().then(store => removePublisherFromStore(store, publisherName)))
.then(() => console.log(`Successfully deleted publisher '${ publisherName }'.`));
});

View file

@ -1,7 +1,7 @@
import { assign } from 'lodash';
import * as _read from 'read';
import { WebApi, getBasicHandler } from 'vso-node-api/WebApi';
import { IGalleryApi, IQGalleryApi } from 'vso-node-api/GalleryApi';
import { IGalleryApi } from 'vso-node-api/GalleryApi';
import * as denodeify from 'denodeify';
const __read = denodeify<_read.Options,string>(_read);
@ -9,13 +9,7 @@ export function read(prompt: string, options: _read.Options = {}): Promise<strin
return __read(assign({ prompt }, options));
}
export function getGalleryAPI(pat: string): IQGalleryApi {
const authHandler = getBasicHandler('oauth', pat);
const vsoapi = new WebApi('oauth', authHandler);
return vsoapi.getQGalleryApi('https://marketplace.visualstudio.com');
}
export function getRawGalleryAPI(pat: string): IGalleryApi {
export function getGalleryAPI(pat: string): IGalleryApi {
const authHandler = getBasicHandler('oauth', pat);
const vsoapi = new WebApi('oauth', authHandler);
return vsoapi.getGalleryApi('https://marketplace.visualstudio.com');

1
typings/tsd.d.ts vendored
View file

@ -3,7 +3,6 @@
/// <reference path="glob/glob.d.ts" />
/// <reference path="minimatch/minimatch.d.ts" />
/// <reference path="q/Q.d.ts" />
/// <reference path="vso-node-api/vso-node-api.d.ts" />
/// <reference path="tmp/tmp.d.ts" />
/// <reference path="commander/commander.d.ts" />
/// <reference path="es6-promise/es6-promise.d.ts" />

File diff suppressed because it is too large Load diff