Skip to content

Commit

Permalink
chore: upgrade electron-installer-{debian,redhat} to ^2.0.0 (#928)
Browse files Browse the repository at this point in the history
* chore: upgrade electron-installer-common to 0.7.2
* chore: update code to use packagePaths
  • Loading branch information
malept authored Jun 12, 2019
1 parent df98fe8 commit 8be98bf
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 67 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@
},
"optionalDependencies": {
"@malept/electron-installer-flatpak": "^0.9.0",
"electron-installer-debian": "^1.2.0",
"electron-installer-debian": "^2.0.0",
"electron-installer-dmg": "^3.0.0",
"electron-installer-redhat": "^1.1.0",
"electron-installer-redhat": "^2.0.0",
"electron-installer-snap": "^3.2.0",
"electron-windows-store": "^2.1.0",
"electron-winstaller": "^3.0.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/maker/deb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@electron-forge/shared-types": "6.0.0-beta.39"
},
"optionalDependencies": {
"electron-installer-debian": "^1.2.0"
"electron-installer-debian": "^2.0.0"
}
}
}
21 changes: 8 additions & 13 deletions packages/maker/deb/src/MakerDeb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,22 @@ export default class MakerDeb extends MakerBase<MakerDebConfig> {
dir,
makeDir,
targetArch,
packageJSON,
}: MakerOptions) {
// eslint-disable-next-line global-require, import/no-unresolved
const installer = require('electron-installer-debian');

const arch = debianArch(targetArch);
const name = (this.config.options || {}).name || packageJSON.name;
const versionedName = `${name}_${installer.transformVersion(packageJSON.version)}_${arch}`;
const outPath = path.resolve(makeDir, `${versionedName}.deb`);
const outDir = path.resolve(makeDir);

await this.ensureFile(outPath);

await installer(Object.assign({
await this.ensureDirectory(outDir);
const { packagePaths } = await installer({
options: {},
}, this.config, {
arch,
...this.config,
arch: debianArch(targetArch),
src: dir,
dest: path.dirname(outPath),
dest: outDir,
rename: undefined,
}));
});

return [outPath];
return packagePaths;
}
}
21 changes: 4 additions & 17 deletions packages/maker/deb/test/MakerDeb_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MakerImpl extends MakerBase<MakerDebConfig> {
describe('MakerDeb', () => {
let MakerDeb: typeof MakerImpl;
let eidStub: SinonStub;
let ensureFileStub: SinonStub;
let ensureDirectoryStub: SinonStub;
let config: MakerDebConfig;
let maker: MakerImpl;
let createMaker: () => void;
Expand All @@ -30,17 +30,16 @@ describe('MakerDeb', () => {
const packageJSON = { version: '1.2.3' };

beforeEach(() => {
ensureFileStub = stub().returns(Promise.resolve());
eidStub = stub().resolves();
(eidStub as any).transformVersion = (version: string) => version;
ensureDirectoryStub = stub().returns(Promise.resolve());
eidStub = stub().returns({ packagePaths: ['/foo/bar.deb'] });
config = {};

MakerDeb = proxyquire.noPreserveCache().noCallThru().load('../src/MakerDeb', {
'electron-installer-debian': eidStub,
}).default;
createMaker = () => {
maker = new MakerDeb(config, []);
maker.ensureFile = ensureFileStub;
maker.ensureDirectory = ensureDirectoryStub;
maker.prepareConfig(targetArch as any);
};
createMaker();
Expand Down Expand Up @@ -86,18 +85,6 @@ describe('MakerDeb', () => {
});
});

if (process.platform === 'linux') {
it('should return the proper pre-release version in the outPath', async () => {
// eslint-disable-next-line import/no-unresolved
(eidStub as any).transformVersion = require('electron-installer-debian').transformVersion;
packageJSON.version = '1.2.3-beta.4';
const outPath = await (maker.make as any)({
dir, makeDir, appName, targetArch, packageJSON,
});
expect(outPath).to.match(/1\.2\.3~beta\.4/);
});
}

describe('debianArch', () => {
it('should convert ia32 to i386', () => {
expect(debianArch('ia32')).to.equal('i386');
Expand Down
4 changes: 2 additions & 2 deletions packages/maker/rpm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"@electron-forge/shared-types": "6.0.0-beta.39"
},
"optionalDependencies": {
"electron-installer-redhat": "^1.1.0"
"electron-installer-redhat": "^2.0.0"
}
}
}
20 changes: 7 additions & 13 deletions packages/maker/rpm/src/MakerRpm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import MakerBase, { MakerOptions } from '@electron-forge/maker-base';
import { ForgeArch, ForgePlatform } from '@electron-forge/shared-types';

import path from 'path';

import { MakerRpmConfig } from './Config';
Expand Down Expand Up @@ -28,25 +27,20 @@ export default class MakerRpm extends MakerBase<MakerRpmConfig> {
dir,
makeDir,
targetArch,
packageJSON,
}: MakerOptions) {
// eslint-disable-next-line global-require, import/no-unresolved
const installer = require('electron-installer-redhat');

const arch = rpmArch(targetArch);
const name = (this.config.options || {}).name || packageJSON.name;
const versionedName = `${name}-${packageJSON.version}.${arch}`;
const outPath = path.resolve(makeDir, `${versionedName}.rpm`);
const outDir = path.resolve(makeDir);

await this.ensureFile(outPath);
const rpmConfig = Object.assign({}, this.config, {
arch,
await this.ensureDirectory(outDir);
const { packagePaths } = await installer({
...this.config,
arch: rpmArch(targetArch),
src: dir,
dest: path.dirname(outPath),
dest: outDir,
rename: undefined,
});

await installer(rpmConfig);
return [outPath];
return packagePaths;
}
}
8 changes: 4 additions & 4 deletions packages/maker/rpm/test/MakerRpm_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MakerImpl extends MakerBase<MakerRpmConfig> {
describe('MakerRpm', () => {
let MakerRpm: typeof MakerImpl;
let eirStub: SinonStub;
let ensureFileStub: SinonStub;
let ensureDirectoryStub: SinonStub;
let config: MakerRpmConfig;
let maker: MakerImpl;
let createMaker: () => void;
Expand All @@ -30,16 +30,16 @@ describe('MakerRpm', () => {
const packageJSON = { version: '1.2.3' };

beforeEach(() => {
ensureFileStub = stub().returns(Promise.resolve());
eirStub = stub().resolves();
ensureDirectoryStub = stub().returns(Promise.resolve());
eirStub = stub().returns(Promise.resolve({ packagePaths: ['/foo/bar.rpm'] }));
config = {};

MakerRpm = proxyquire.noPreserveCache().noCallThru().load('../src/MakerRpm', {
'electron-installer-redhat': eirStub,
}).default;
createMaker = () => {
maker = new MakerRpm(config);
maker.ensureFile = ensureFileStub;
maker.ensureDirectory = ensureDirectoryStub;
maker.prepareConfig(targetArch as any);
};
createMaker();
Expand Down
55 changes: 41 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3094,17 +3094,31 @@ electron-installer-common@^0.6.2, electron-installer-common@^0.6.3:
semver "^6.0.0"
tmp-promise "^1.0.5"

electron-installer-debian@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/electron-installer-debian/-/electron-installer-debian-1.2.0.tgz#1cb3c457cd4fc5e5adaae4d587170eca3a85a219"
integrity sha512-gowfDlBY4NPZ6dMLsoSJzEeXlEa650NAjvtnYk6/Ikq9tFtS7xCs+Oyk91gNGDbFczA8QAelmR4KX4hV/eebKQ==
electron-installer-common@^0.7.1:
version "0.7.2"
resolved "https://registry.yarnpkg.com/electron-installer-common/-/electron-installer-common-0.7.2.tgz#034ffb3a3e393f2637a4fad29a7dfc65f1d47517"
integrity sha512-oe4HMkxB/BV7waa+LMj47aTTyjLFfkOP3Omz8rengoXhQYaSGmf2hNG058NoqzbozXM5Tjiwgh7dShUAPaVhdw==
dependencies:
asar "^2.0.1"
cross-spawn-promise "^0.10.1"
debug "^4.1.1"
electron-installer-common "^0.6.2"
fs-extra "^7.0.1"
fs-extra "^8.0.1"
glob "^7.1.4"
lodash "^4.17.11"
parse-author "^2.0.0"
semver "^6.0.0"
tmp-promise "^2.0.1"

electron-installer-debian@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/electron-installer-debian/-/electron-installer-debian-2.0.0.tgz#295431530e06403e71154fc3bd2d74a0ada1c4a3"
integrity sha512-FNdoIzCFhaHiOoLOacWvoUHV80AV/+iH6KNYNiYlB8LmqQKNTPKXNVfZHet/7yDZi2Md4DxRy4gsokEPvV8QSg==
dependencies:
debug "^4.1.1"
electron-installer-common "^0.7.1"
fs-extra "^8.0.1"
get-folder-size "^2.0.1"
lodash "^4.17.4"
pify "^4.0.1"
word-wrap "^1.2.3"
yargs "^13.2.2"

Expand All @@ -3119,16 +3133,15 @@ electron-installer-dmg@^3.0.0:
optionalDependencies:
appdmg "^0.6.0"

electron-installer-redhat@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/electron-installer-redhat/-/electron-installer-redhat-1.1.0.tgz#d8f20839fdb567946b33372d78101ff6d60aacb5"
integrity sha512-wea1fZ1VOEZBJ5Y+/D2So04PnhfwoEPFW4rD9UlP/ODIggkDHY6ZLsXj0SRPGKGJqmTzP16Taoj7YNsmxYEL2g==
electron-installer-redhat@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/electron-installer-redhat/-/electron-installer-redhat-2.0.0.tgz#a83563f6267aed64a619592cd0a6305ffa97ba6b"
integrity sha512-kf7+/t8XIp1I6LIV9v6K38rBHzmY6bUr3TunJZKdlIKQ7j6wyjjpgbpxSBcg3S7pgzq1kkgCYZvpr8CsLFVivw==
dependencies:
debug "^4.1.1"
electron-installer-common "^0.6.2"
fs-extra "^7.0.1"
electron-installer-common "^0.7.1"
fs-extra "^8.0.1"
lodash "^4.17.4"
nodeify "^1.0.1"
word-wrap "^1.2.3"
yargs "^13.2.2"

Expand Down Expand Up @@ -8161,13 +8174,27 @@ tmp-promise@^1.0.3, tmp-promise@^1.0.5:
bluebird "^3.5.0"
tmp "0.0.33"

tmp-promise@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-2.0.1.tgz#8856f057e782fc9c363a76335cf6165b8eddae19"
integrity sha512-2A0lDPWiuu+92AVO19p5D6eq2egvCPiVUkzR11jE+GG4QMjj4YQ4glr2RqzYT0TMeMs2tIXLPDYo4wWh2/WoSg==
dependencies:
tmp "0.1.0"

[email protected], tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
dependencies:
os-tmpdir "~1.0.2"

[email protected]:
version "0.1.0"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877"
integrity sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==
dependencies:
rimraf "^2.6.3"

tn1150@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/tn1150/-/tn1150-0.1.0.tgz#673503d24d56b87de8b8c77fee3fc0853d59a18d"
Expand Down

0 comments on commit 8be98bf

Please sign in to comment.