Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 23 additions & 5 deletions app/exec/extension/_lib/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export class GalleryBase {
// }
}

protected getExtensionPackage(): fs.ReadStream | GalleryInterfaces.ExtensionPackage {
if (!this.settings.galleryUrl || this.settings.galleryUrl.startsWith("https://marketplace.visualstudio.com")) {
// Hosted ADO is known to work with a fs.ReadStream.
return fs.createReadStream(this.settings.vsixPath);
} else {
// ADO Server requires using the compat JSON API.
// If we don't have known compatibility we use this code path.
return { extensionManifest: fs.readFileSync(this.settings.vsixPath, "base64") };
}
};

protected getExtInfo(): Promise<CoreExtInfo> {
if (!this.vsixInfoPromise) {
this.vsixInfoPromise = GalleryBase.getExtInfo({
Expand Down Expand Up @@ -293,7 +304,6 @@ export class PackagePublisher extends GalleryBase {
* @return Q.Promise that is resolved when publish is complete
*/
public publish(): Promise<GalleryInterfaces.PublishedExtension> {
const extPackage = fs.createReadStream(this.settings.vsixPath)
trace.debug("Publishing %s", this.settings.vsixPath);

// Check if the app is already published. If so, call the update endpoint. Otherwise, create.
Expand All @@ -314,7 +324,7 @@ export class PackagePublisher extends GalleryBase {
extInfo.version
} --service-url ${this.settings.galleryUrl} --token <your PAT>`,
)}`;
return this.createOrUpdateExtension(extPackage).then(ext => {
return this.createOrUpdateExtension(this.getExtensionPackage()).then(ext => {
if (this.settings.noWaitValidation) {
trace.info(validationMessage);
return ext;
Expand Down Expand Up @@ -355,16 +365,24 @@ export class PackagePublisher extends GalleryBase {
}

private createOrUpdateExtension(
extPackage: fs.ReadStream,
extPackage: fs.ReadStream | GalleryInterfaces.ExtensionPackage,
): Promise<GalleryInterfaces.PublishedExtension> {
return this.checkVsixPublished().then(extInfo => {
let publishPromise: Promise<GalleryInterfaces.PublishedExtension>;
if (extInfo && extInfo.published) {
trace.info("It is, %s the extension", colors.cyan("update").toString());
publishPromise = this.galleryClient.updateExtension(null, extPackage, extInfo.publisher, extInfo.id, this.settings.bypassScopeCheck).catch(errHandler.httpErr);
if (extPackage instanceof fs.ReadStream) {
publishPromise = this.galleryClient.updateExtension(null, extPackage, extInfo.publisher, extInfo.id, undefined, undefined, this.settings.bypassScopeCheck).catch(errHandler.httpErr);
} else {
publishPromise = this.galleryClient.updateExtensionJson(extPackage, extInfo.publisher, extInfo.id);
}
} else {
trace.info("It isn't, %s a new extension.", colors.cyan("create").toString());
publishPromise = this.galleryClient.createExtension(null, extPackage).catch(errHandler.httpErr);
if (extPackage instanceof fs.ReadStream) {
publishPromise = this.galleryClient.createExtension(null, extPackage).catch(errHandler.httpErr);
} else {
publishPromise = this.galleryClient.createExtensionJson(extPackage).catch(errHandler.httpErr);
}
}
return publishPromise.then(() => {
return this.galleryClient.getExtension(
Expand Down
193 changes: 148 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tfx-cli",
"version": "0.21.0",
"version": "0.21.1",
"description": "CLI for Azure DevOps Services and Team Foundation Server",
"repository": {
"type": "git",
Expand All @@ -20,7 +20,7 @@
"dependencies": {
"app-root-path": "1.0.0",
"archiver": "2.0.3",
"azure-devops-node-api": "^10.2.2",
"azure-devops-node-api": "^14.0.0",
"clipboardy": "~1.2.3",
"colors": "~1.3.0",
"glob": "7.1.2",
Expand Down