From 9d0e1fe54c8374fcf08be64aadfeeb2136a54e2f Mon Sep 17 00:00:00 2001 From: develar Date: Tue, 28 Feb 2017 22:23:15 +0100 Subject: [PATCH] feat(deployment): support foo/bar repo as short form of owner foo and repo bar Close #1227 --- .idea/electron-builder.iml | 1 + packages/electron-builder/src/publish/publisher.ts | 10 ++++++++++ packages/electron-publish/src/gitHubPublisher.ts | 2 +- test/src/windows/oneClickInstallerTest.ts | 8 ++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.idea/electron-builder.iml b/.idea/electron-builder.iml index 449477ed9dc..ff2def88a02 100644 --- a/.idea/electron-builder.iml +++ b/.idea/electron-builder.iml @@ -13,6 +13,7 @@ + diff --git a/packages/electron-builder/src/publish/publisher.ts b/packages/electron-builder/src/publish/publisher.ts index 473702a671a..c08d00256b5 100644 --- a/packages/electron-builder/src/publish/publisher.ts +++ b/packages/electron-builder/src/publish/publisher.ts @@ -36,6 +36,16 @@ export async function getResolvedPublishConfig(packager: BuildInfo, publishConfi let owner = publishConfig.owner let project = provider === "github" ? (publishConfig).repo : (publishConfig).package + + if (provider === "github" && owner == null && project != null) { + const index = project.indexOf("/") + if (index > 0) { + const repo = project + project = repo.substring(0, index) + owner = repo.substring(index + 1) + } + } + if (!owner || !project) { const info = await getInfo() if (info == null) { diff --git a/packages/electron-publish/src/gitHubPublisher.ts b/packages/electron-publish/src/gitHubPublisher.ts index 89fe2703e07..16295b652dc 100644 --- a/packages/electron-publish/src/gitHubPublisher.ts +++ b/packages/electron-publish/src/gitHubPublisher.ts @@ -192,7 +192,7 @@ export class GitHubPublisher extends HttpPublisher { return httpExecutor.request(configureRequestOptions({ hostname: baseUrl.hostname, port: baseUrl.port, - path: (this.info.host != null && this.info.host !== "github.com") ? `/api/v3/${path}` : path, + path: (this.info.host != null && this.info.host !== "github.com") ? `/api/v3${path.startsWith("/") ? path : `/${path}`}` : path, headers: {Accept: "application/vnd.github.v3+json"} }, token, method), this.context.cancellationToken, data) } diff --git a/test/src/windows/oneClickInstallerTest.ts b/test/src/windows/oneClickInstallerTest.ts index 27b586619bd..c6069724d8c 100644 --- a/test/src/windows/oneClickInstallerTest.ts +++ b/test/src/windows/oneClickInstallerTest.ts @@ -150,8 +150,12 @@ test.ifNotCiMac("web installer", app({ test.ifAll.ifNotCiMac("web installer (default github)", app({ targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.ia32, Arch.x64), - appMetadata: { - repository: "foo/bar" + config: { + publish: { + provider: "github", + // test form without owner + repo: "foo/bar" + } }, }, { packed: async context => {