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

@electron-forge/maker-zip should have keyResolver for macUpdateManifestBaseUrl file URLs #3379

Open
3 tasks done
TranquilMarmot opened this issue Oct 10, 2023 · 0 comments
Open
3 tasks done

Comments

@TranquilMarmot
Copy link

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

I'm using @electron-forge/publisher-s3 and have keyResolver set in forge.config.ts:

publishers: [
    {
      // https://www.electronforge.io/config/publishers/s3
      name: "@electron-forge/publisher-s3",
      config: {
        endpoint: `https://${process.env.PUBLISH_S3_URL}`,
        bucket: process.env.PUBLISH_S3_BUCKET,
        region: "us-east-1",
        public: true,
        keyResolver: (fileName: string, platform: string, arch: string) =>
          getS3FilePath(
            platform,
            arch,
            pkg.version,
            fileName.split(".").pop()!,
          ),
      },
    },
]

getS3FilePath results in something like:

https://my-bucket.s3.amazonaws.com/releases/darwin/arm64/my-electron-app-1.0.0.zip

Now, we want to use @electron-forge/maker-zip with the macUpdateManifestBaseUrl but it will use the default path that @electron-forge/publisher-s3 would use.

In forge.config.ts:

  makers: [
    new MakerZIP((arch) => ({
      macUpdateManifestBaseUrl: `https://my-bucket.s3.amazonaws.com/releases/darwin/${arch}`
  ]

This results in the following RELEASES.json file:

{
  "currentRelease": "1.0.0",
  "releases": [
    {
      "version": "1.0.0",
      "updateTo": {
        "name": "My Electron App v1.0.0",
        "version": "1.0.0",
        "pub_date": "2023-10-10T18:00:07.611Z",
        "url": "https://my-bucket.s3.amazonaws.com/releases/darwin/arm64/My%20Electron%20App-darwin-arm64-1.0.0.zip",
        "notes": ""
      }
    }
  ]
}

This doesn't match up with where the bundle is actually uploaded to S3 using @electron-forge/publisher-s3.

Proposed solution

Allow passing a function as urlKeyResolver like keyResolver in @electron-forge/publisher-s3

The platform parameter isn't needed since it will always be darwin, the arch parameter isn't needed since that's passed in via the maker options.

fileName will be the name of the file being written.

  makers: [
    new MakerZIP((arch) => ({
      macUpdateManifestBaseUrl: `https://my-bucket.s3.amazonaws.com/releases/darwin/${arch}`,
      urlKeyResolver: (fileName: string) =>
          getS3FilePath(
            "darwin",
            arch,
            pkg.version,
            fileName.split(".").pop()!,
          )
  ]

Then, when writing the url into RELEASES.json, it will go through that instead.

Alternatives considered

Removing keyResolver from @electron-forge/publisher-s3 will cause the two to match up, but we'd like more control over the file names.

Additional information

No response

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

No branches or pull requests

1 participant