Skip to content
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 · 10 comments
Closed

Allow pass configuration to custom electron-publisher provider #3261

zalewskip123 opened this issue Aug 21, 2018 · 10 comments
Labels

Comments

@zalewskip123
Copy link

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
Copy link
Author

I just create a project that describe my problem:

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

@develar
Copy link
Member

develar commented Aug 28, 2018

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

@zalewskip123
Copy link
Author

@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
Copy link
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.

@factorone
Copy link

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
Copy link
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).

@jbool24
Copy link
Contributor

jbool24 commented Aug 25, 2021

    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 this could be better documented because this totally opaque as far a the current docs go. Can you explain better for custom publishers?

@shehi
Copy link

shehi commented Oct 9, 2021

+1 t what @jbool24 said, @develar .

@BB-fat
Copy link

BB-fat commented Dec 30, 2021

I still not known how to get build info in electron-publisher-custom.js. Need help! @develar

@layerssss
Copy link

layerssss commented Jan 12, 2022

@jbool24 @BB-fat I've managed to come up with a minimum example (copying neccessary files to a folder). But yes this could be better documented.

https://gist.github.com/layerssss/5d7b69c0f8c6e54e8b501e6e0fe36186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants