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

Allow pass configuration to custom electron-publisher provider #3261

Closed
zalewskip123 opened this Issue Aug 21, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@zalewskip123

zalewskip123 commented Aug 21, 2018

  • Electron-builder version: 20.28.1
  • Electron-updater version: 3.1.1
  • Target: Windows

Hi.

I try to make custom electron-publisher provider and i have two problems:

  1. I cannot pass any configuration to it by package.json ex:
  "build": {
    "appId": "appId",
    "productName": "productName",
    "publish": [
      {
        "provider": "generic",
        "url": "http://hostname:port/${name}/${os}/${arch}/${channel}/${version}/"
      },
      {
         "provider":  "custom",
         "url": "http://hostname:port/${name}/${os}/${arch}/${channel}/${version}/"
      }
    ]
  }

Will not pass configuration validation.

  1. I d`not know how to get installer meta info - os, channel, version etc. in doUpload function.

I have almost working solution but everything is hard coded into it:

node_modules/electron-publisher-custom/index.js

const {
  getCiTag,
  HttpPublisher,
  PublishContext,
  PublishOptions
} = require("electron-publish/out/publisher");
const { httpExecutor } = require("builder-util/out/nodeHttpExecutor");
const mime = require("mime");
const { configureRequestOptions } = require("builder-util-runtime");

class Publisher extends HttpPublisher {
  async doUpload(fileName, arch, dataLength, requestProcessor, file) {
    return await httpExecutor.doApiRequest(
      configureRequestOptions({
        hostname: "my.host.name", // TODO: from configuration
        protocol: "http:", // TODO: from configuration
        port: 8888, // TODO: from configuration
        path: "/some/path", // TODO: from configuration mixed with file meta about name/os/channel etc
        method: "POST",
        headers: {
          "X-File-Name": fileName,
          "Content-Type": mime.getType(fileName) || "application/octet-stream",
          "Content-Length": dataLength
        }
      }),
      this.context.cancellationToken,
      requestProcessor
    );
  }
}

module.exports = {
  default: Publisher
};

package.json:

  "build": {
    "appId": "appId",
    "productName": "productName",
    "publish": [
      {
        "provider": "generic",
        "url": "http://hostname:port/${name}/${os}/${arch}/${channel}/${version}/"
      },
      "custom"
    ]
  }

@zalewskip123 zalewskip123 referenced this issue Aug 27, 2018

Open

Cleanup #1

@zalewskip123

This comment has been minimized.

zalewskip123 commented Aug 27, 2018

I just create a project that describe my problem:

https://github.com/zalewskip123/electron-publisher-simple-http

@develar

This comment has been minimized.

Member

develar commented Aug 28, 2018

For what do you need simple http publisher if you can use https://www.minio.io?

@zalewskip123

This comment has been minimized.

zalewskip123 commented Aug 28, 2018

@develar
To integrate publishing process with my company infrastructure and processes.

We are doing not use minio or other cloud solutions at the moment.

Anyway my current implementation is good enough 😉 for company purposes so if there will be more 👎 for this I will close this issue.

@develar

This comment has been minimized.

Member

develar commented Aug 28, 2018

Ok, if you want to use your own solution instead of deploy minio and understand what are you doing, issue makes sense.

@develar develar added feature and removed reply-needed labels Aug 28, 2018

@factorone

This comment has been minimized.

factorone commented Oct 31, 2018

In terms of getting installer info dynamically, you could always try using file macros.

develar added a commit to develar/electron-builder that referenced this issue Nov 1, 2018

@develar

This comment has been minimized.

Member

develar commented Nov 1, 2018

    publish: {
      provider: "custom",
      boo: "foo",
    },

is allowed now (upcoming 20.31.1). Any property is allowed under publish configuration if provider is set to custom.

In addition to this, now you can put electron-publisher-${provider} under build resources dir (see custom provider test for example).

@develar develar closed this in 6570e4b Nov 1, 2018

develar added a commit that referenced this issue Nov 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment