Allow pass configuration to custom electron-publisher provider
zalewskip123 opened this issue · comments
- 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:
- 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.
- 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"
]
}
I just create a project that describe my problem:
https://github.com/zalewskip123/electron-publisher-simple-http
For what do you need simple http publisher if you can use https://www.minio.io?
@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.
Ok, if you want to use your own solution instead of deploy minio and understand what are you doing, issue makes sense.
In terms of getting installer info dynamically, you could always try using file macros.
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).
publish: { provider: "custom", boo: "foo", },
is allowed now (upcoming 20.31.1). Any property is allowed under publish configuration if
provider
is set tocustom
.In addition to this, now you can put
electron-publisher-${provider}
under build resources dir (seecustom 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?
I still not known how to get build info in electron-publisher-custom.js
. Need help! @develar
@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