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

fix: handle missing manifest in zip maker #3405

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/maker/zip/src/MakerZIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export default class MakerZIP extends MakerBase<MakerZIPConfig> {
if (targetPlatform === 'darwin' && this.config.macUpdateManifestBaseUrl) {
const parsed = new URL(this.config.macUpdateManifestBaseUrl);
parsed.pathname += '/RELEASES.json';
const response = await got.get(parsed.toString());
const response = await got.get(parsed.toString(), {
throwHttpErrors: false,
});
let currentValue: SquirrelMacReleases = {
currentRelease: '',
releases: [],
Expand Down
24 changes: 24 additions & 0 deletions packages/maker/zip/test/MakerZip_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ describe('MakerZip', () => {
expect(foo.releases[0].updateTo).to.have.property('url');
});

it('should generate a valid RELEASES.json manifest with no current file', async () => {
maker.config = {
macUpdateManifestBaseUrl: 'fake://test/foo',
};
getStub.returns(Promise.resolve({ statusCode: 404, body: 'GARBAGE' }));
const output = await maker.make({
dir: darwinDir,
makeDir,
appName,
targetArch,
targetPlatform: 'darwin',
packageJSON,
forgeConfig: null as any,
});

const foo = await fs.readJson(output[1]);
expect(foo).to.have.property('currentRelease', '1.2.3');
expect(foo).to.have.property('releases');
expect(foo.releases).to.be.an('array').with.lengthOf(1);
expect(foo.releases[0]).to.have.property('version');
expect(foo.releases[0]).to.have.property('updateTo');
expect(foo.releases[0].updateTo).to.have.property('url');
});

it('should extend the current RELEASES.json manifest if it exists', async () => {
maker.config = {
macUpdateManifestBaseUrl: 'fake://test/foo',
Expand Down