question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow pass configuration to custom electron-publisher provider

See original GitHub issue
  • 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"
    ]
  }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
jbool24commented, 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?

5reactions
develarcommented, 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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron-publisher-alioss - npm
Start using electron-publisher-alioss in your project by running `npm i ... Allow pass configuration to custom electron-publisher provider), ...
Read more >
Publish - electron-builder
To force publishing to another providers, explicitly specify publish configuration for snap . You can publish to multiple providers. For example, to publish ......
Read more >
electron-publisher-alioss - npm package - Snyk
Cause we can now only to pass the configuration to the publisher by using the "custom" provider(ISSUE#3261: Allow pass configuration to ...
Read more >
Implement a custom configuration provider - .NET
You may need to implement a custom configuration provider when one of the available providers doesn't suit your application needs.
Read more >
Option patterns with custom configuration provider in .NET
However, IOptionsMonitor<T> will have a feature to update the value. Let's experience the feature. Go back to the configuration of AddJsonFile() , you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found