@electron-forge/maker-base 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/package.json +7 -3
- package/src/Maker.ts +177 -0
- package/test/config-fetcher_spec.ts +42 -0
- package/test/ensure-output_spec.ts +58 -0
- package/test/support_spec.ts +19 -0
- package/test/version_spec.ts +22 -0
- package/dist/Maker.d.ts +0 -101
- package/dist/Maker.d.ts.map +0 -1
- package/dist/Maker.js +0 -126
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2016 Samuel Attard
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
the Software without restriction, including without limitation the rights to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
17
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
18
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
19
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electron-forge/maker-base",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Base maker for Electron Forge",
|
|
5
5
|
"repository": "https://github.com/electron/forge",
|
|
6
6
|
"author": "Samuel Attard",
|
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
"node": ">= 14.17.5"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@electron-forge/shared-types": "6.0.
|
|
19
|
+
"@electron-forge/shared-types": "^6.0.2",
|
|
20
20
|
"fs-extra": "^10.0.0",
|
|
21
21
|
"which": "^2.0.2"
|
|
22
|
-
}
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "11cf4b58359c9881c05c06e0d62be575a0ed70d1"
|
|
23
27
|
}
|
package/src/Maker.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import { ForgeArch, ForgePlatform, IForgeMaker, ResolvedForgeConfig } from '@electron-forge/shared-types';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import which from 'which';
|
|
6
|
+
|
|
7
|
+
export type EmptyConfig = Record<string, never>;
|
|
8
|
+
|
|
9
|
+
export interface MakerOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The directory containing the packaged Electron application
|
|
12
|
+
*/
|
|
13
|
+
dir: string;
|
|
14
|
+
/**
|
|
15
|
+
* The directory you should put all your artifacts in (potentially in sub folders)
|
|
16
|
+
* NOTE: this directory is not guarunteed to already exist
|
|
17
|
+
*/
|
|
18
|
+
makeDir: string;
|
|
19
|
+
/**
|
|
20
|
+
* The resolved human friendly name of the project
|
|
21
|
+
*/
|
|
22
|
+
appName: string;
|
|
23
|
+
/**
|
|
24
|
+
* The target platform you should make for
|
|
25
|
+
*/
|
|
26
|
+
targetPlatform: ForgePlatform;
|
|
27
|
+
/**
|
|
28
|
+
* The target architecture you should make for
|
|
29
|
+
*/
|
|
30
|
+
targetArch: ForgeArch;
|
|
31
|
+
/**
|
|
32
|
+
* Fully resolved forge configuration, you shouldn't really need this
|
|
33
|
+
*/
|
|
34
|
+
forgeConfig: ResolvedForgeConfig;
|
|
35
|
+
/**
|
|
36
|
+
* The application's package.json file
|
|
37
|
+
*/
|
|
38
|
+
packageJSON: any; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default abstract class Maker<C> implements IForgeMaker {
|
|
42
|
+
public config!: C;
|
|
43
|
+
|
|
44
|
+
public abstract name: string;
|
|
45
|
+
|
|
46
|
+
public abstract defaultPlatforms: ForgePlatform[];
|
|
47
|
+
|
|
48
|
+
public requiredExternalBinaries: string[] = [];
|
|
49
|
+
|
|
50
|
+
/** @internal */
|
|
51
|
+
__isElectronForgeMaker!: true;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param configOrConfigFetcher - Either a configuration object for this maker or a simple method that returns such a configuration for a given target architecture
|
|
55
|
+
* @param platformsToMakeOn - If you want this maker to run on platforms different from `defaultPlatforms` you can provide those platforms here
|
|
56
|
+
*/
|
|
57
|
+
constructor(private configOrConfigFetcher: C | ((arch: ForgeArch) => C) = {} as C, protected platformsToMakeOn?: ForgePlatform[]) {
|
|
58
|
+
Object.defineProperty(this, '__isElectronForgeMaker', {
|
|
59
|
+
value: true,
|
|
60
|
+
enumerable: false,
|
|
61
|
+
configurable: false,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get platforms(): ForgePlatform[] {
|
|
66
|
+
if (this.platformsToMakeOn) return this.platformsToMakeOn;
|
|
67
|
+
return this.defaultPlatforms;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// TODO: Remove this, it is an eye-sore and is a nasty hack to provide forge
|
|
71
|
+
// v5 style functionality in the new API
|
|
72
|
+
prepareConfig(targetArch: ForgeArch): void {
|
|
73
|
+
if (typeof this.configOrConfigFetcher === 'function') {
|
|
74
|
+
this.config = (this.configOrConfigFetcher as unknown as (arch: ForgeArch) => C)(targetArch);
|
|
75
|
+
} else {
|
|
76
|
+
this.config = this.configOrConfigFetcher as C;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Makers must implement this method and return true or false indicating whether
|
|
82
|
+
* this maker can be run on the current platform. Normally this is just a process.platform
|
|
83
|
+
* check but it can be a deeper check for dependencies like fake-root or other
|
|
84
|
+
* required external build tools.
|
|
85
|
+
*
|
|
86
|
+
* If the issue is a missing dependency you should log out a HELPFUL error message
|
|
87
|
+
* telling the developer exactly what is missing and if possible how to get it.
|
|
88
|
+
*/
|
|
89
|
+
isSupportedOnCurrentPlatform(): boolean {
|
|
90
|
+
if (this.isSupportedOnCurrentPlatform === Maker.prototype.isSupportedOnCurrentPlatform) {
|
|
91
|
+
throw new Error(`Maker ${this.name} did not implement the isSupportedOnCurrentPlatform method`);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Makers must implement this method and return an array of absolute paths
|
|
98
|
+
* to the artifacts generated by your maker
|
|
99
|
+
*/
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
101
|
+
async make(opts: MakerOptions): Promise<string[]> {
|
|
102
|
+
if (this.make === Maker.prototype.make) {
|
|
103
|
+
throw new Error(`Maker ${this.name} did not implement the make method`);
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Helpers
|
|
110
|
+
*/
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Ensures the directory exists and is forced to be empty.
|
|
114
|
+
*
|
|
115
|
+
* I.e. If the directory already exists it is deleted and recreated, this
|
|
116
|
+
* is a destructive operation
|
|
117
|
+
*/
|
|
118
|
+
async ensureDirectory(dir: string): Promise<void> {
|
|
119
|
+
if (await fs.pathExists(dir)) {
|
|
120
|
+
await fs.remove(dir);
|
|
121
|
+
}
|
|
122
|
+
return fs.mkdirs(dir);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Ensures the path to the file exists and the file does not exist
|
|
127
|
+
*
|
|
128
|
+
* I.e. If the file already exists it is deleted and the path created
|
|
129
|
+
*/
|
|
130
|
+
async ensureFile(file: string): Promise<void> {
|
|
131
|
+
if (await fs.pathExists(file)) {
|
|
132
|
+
await fs.remove(file);
|
|
133
|
+
}
|
|
134
|
+
await fs.mkdirs(path.dirname(file));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Checks if the specified binaries exist, which are required for the maker to be used.
|
|
139
|
+
*/
|
|
140
|
+
externalBinariesExist(): boolean {
|
|
141
|
+
return this.requiredExternalBinaries.every((binary) => which.sync(binary, { nothrow: true }) !== null);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Throws an error if any of the binaries don't exist.
|
|
146
|
+
*/
|
|
147
|
+
ensureExternalBinariesExist(): void {
|
|
148
|
+
if (!this.externalBinariesExist()) {
|
|
149
|
+
throw new Error(`Cannot make for ${this.name}, the following external binaries need to be installed: ${this.requiredExternalBinaries.join(', ')}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Checks if the given module is installed, used for testing if optional dependencies
|
|
155
|
+
* are installed or not
|
|
156
|
+
*/
|
|
157
|
+
isInstalled(module: string): boolean {
|
|
158
|
+
try {
|
|
159
|
+
require(module);
|
|
160
|
+
return true;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
// Package doesn't exist -- must not be installable on this platform
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Normalize the given semver-formatted version to a 4-part dot delimited version number without
|
|
169
|
+
* prerelease information for use in Windows apps.
|
|
170
|
+
*/
|
|
171
|
+
normalizeWindowsVersion(version: string): string {
|
|
172
|
+
const noPrerelease = version.replace(/-.*/, '');
|
|
173
|
+
return `${noPrerelease}.0`;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export { Maker as MakerBase };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { stub } from 'sinon';
|
|
3
|
+
|
|
4
|
+
import { MakerBase } from '../src/Maker';
|
|
5
|
+
|
|
6
|
+
class MakerImpl extends MakerBase<{ a: number }> {
|
|
7
|
+
name = 'test';
|
|
8
|
+
|
|
9
|
+
defaultPlatforms = [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('prepareConfig', () => {
|
|
13
|
+
it('should call the provided configure function', () => {
|
|
14
|
+
const fetcher = stub();
|
|
15
|
+
fetcher.returns({
|
|
16
|
+
a: 123,
|
|
17
|
+
});
|
|
18
|
+
const maker = new MakerImpl(fetcher, []);
|
|
19
|
+
expect(maker.config).to.be.undefined;
|
|
20
|
+
expect(fetcher.callCount).to.equal(0);
|
|
21
|
+
maker.prepareConfig('x64');
|
|
22
|
+
expect(maker.config).to.deep.equal({
|
|
23
|
+
a: 123,
|
|
24
|
+
});
|
|
25
|
+
expect(fetcher.callCount).to.equal(1);
|
|
26
|
+
expect(fetcher.firstCall.args).to.deep.equal(['x64']);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should hand through the provided object', () => {
|
|
30
|
+
const maker = new MakerImpl(
|
|
31
|
+
{
|
|
32
|
+
a: 234,
|
|
33
|
+
},
|
|
34
|
+
[]
|
|
35
|
+
);
|
|
36
|
+
expect(maker.config).to.be.undefined;
|
|
37
|
+
maker.prepareConfig('x64');
|
|
38
|
+
expect(maker.config).to.deep.equal({
|
|
39
|
+
a: 234,
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import { expect } from 'chai';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
|
|
7
|
+
import { EmptyConfig, MakerBase } from '../src/Maker';
|
|
8
|
+
|
|
9
|
+
class MakerImpl extends MakerBase<EmptyConfig> {
|
|
10
|
+
name = 'test';
|
|
11
|
+
|
|
12
|
+
defaultPlatforms = [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('ensure-output', () => {
|
|
16
|
+
const maker = new MakerImpl({}, []);
|
|
17
|
+
const tmpPath = path.resolve(os.tmpdir(), 'forge-ensure');
|
|
18
|
+
|
|
19
|
+
before(async () => {
|
|
20
|
+
await fs.mkdirs(tmpPath);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('ensureDirectory', () => {
|
|
24
|
+
it('should delete the directory contents if it exists', async () => {
|
|
25
|
+
await fs.mkdirs(path.resolve(tmpPath, 'foo'));
|
|
26
|
+
fs.writeFileSync(path.resolve(tmpPath, 'foo', 'touchedFile'), '');
|
|
27
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'foo', 'touchedFile'))).to.equal(true);
|
|
28
|
+
await maker.ensureDirectory(path.resolve(tmpPath, 'foo'));
|
|
29
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'foo', 'touchedFile'))).to.equal(false);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should create the directory if it does not exist', async () => {
|
|
33
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'bar'))).to.equal(false);
|
|
34
|
+
await maker.ensureDirectory(path.resolve(tmpPath, 'bar'));
|
|
35
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'bar'))).to.equal(true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('ensureFile', () => {
|
|
40
|
+
it('should delete the file if it exists', async () => {
|
|
41
|
+
await fs.mkdirs(path.resolve(tmpPath, 'foo'));
|
|
42
|
+
fs.writeFileSync(path.resolve(tmpPath, 'foo', 'touchedFile'), '');
|
|
43
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'foo', 'touchedFile'))).to.equal(true);
|
|
44
|
+
await maker.ensureFile(path.resolve(tmpPath, 'foo'));
|
|
45
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'foo', 'touchedFile'))).to.equal(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should create the containing directory if it does not exist', async () => {
|
|
49
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'bar'))).to.equal(false);
|
|
50
|
+
await maker.ensureFile(path.resolve(tmpPath, 'bar', 'file'));
|
|
51
|
+
expect(await fs.pathExists(path.resolve(tmpPath, 'bar'))).to.equal(true);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterEach(async () => {
|
|
56
|
+
await fs.remove(tmpPath);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
|
|
3
|
+
import { EmptyConfig, MakerBase } from '../src/Maker';
|
|
4
|
+
|
|
5
|
+
class MakerImpl extends MakerBase<EmptyConfig> {
|
|
6
|
+
name = 'test';
|
|
7
|
+
|
|
8
|
+
defaultPlatforms = [];
|
|
9
|
+
|
|
10
|
+
requiredExternalBinaries = ['bash', 'nonexistent'];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
describe('ensureExternalBinariesExist', () => {
|
|
14
|
+
const maker = new MakerImpl({}, []);
|
|
15
|
+
|
|
16
|
+
it('throws an error when one of the binaries does not exist', () => {
|
|
17
|
+
expect(() => maker.ensureExternalBinariesExist()).to.throw(/the following external binaries need to be installed: bash, nonexistent/);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
|
|
3
|
+
import { EmptyConfig, MakerBase } from '../src/Maker';
|
|
4
|
+
|
|
5
|
+
class MakerImpl extends MakerBase<EmptyConfig> {
|
|
6
|
+
name = 'test';
|
|
7
|
+
|
|
8
|
+
defaultPlatforms = [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('normalizeWindowsVersion', () => {
|
|
12
|
+
const maker = new MakerImpl({}, []);
|
|
13
|
+
|
|
14
|
+
it('removes everything after the dash', () => {
|
|
15
|
+
for (const version of ['1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-0.3.7', '1.0.0-x.7.z.92']) {
|
|
16
|
+
expect(maker.normalizeWindowsVersion(version)).to.equal('1.0.0.0');
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
it('does not truncate the version when there is no dash', () => {
|
|
20
|
+
expect(maker.normalizeWindowsVersion('2.0.0')).to.equal('2.0.0.0');
|
|
21
|
+
});
|
|
22
|
+
});
|
package/dist/Maker.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { ForgeArch, ForgePlatform, IForgeMaker, ResolvedForgeConfig } from '@electron-forge/shared-types';
|
|
2
|
-
export declare type EmptyConfig = Record<string, never>;
|
|
3
|
-
export interface MakerOptions {
|
|
4
|
-
/**
|
|
5
|
-
* The directory containing the packaged Electron application
|
|
6
|
-
*/
|
|
7
|
-
dir: string;
|
|
8
|
-
/**
|
|
9
|
-
* The directory you should put all your artifacts in (potentially in sub folders)
|
|
10
|
-
* NOTE: this directory is not guarunteed to already exist
|
|
11
|
-
*/
|
|
12
|
-
makeDir: string;
|
|
13
|
-
/**
|
|
14
|
-
* The resolved human friendly name of the project
|
|
15
|
-
*/
|
|
16
|
-
appName: string;
|
|
17
|
-
/**
|
|
18
|
-
* The target platform you should make for
|
|
19
|
-
*/
|
|
20
|
-
targetPlatform: ForgePlatform;
|
|
21
|
-
/**
|
|
22
|
-
* The target architecture you should make for
|
|
23
|
-
*/
|
|
24
|
-
targetArch: ForgeArch;
|
|
25
|
-
/**
|
|
26
|
-
* Fully resolved forge configuration, you shouldn't really need this
|
|
27
|
-
*/
|
|
28
|
-
forgeConfig: ResolvedForgeConfig;
|
|
29
|
-
/**
|
|
30
|
-
* The application's package.json file
|
|
31
|
-
*/
|
|
32
|
-
packageJSON: any;
|
|
33
|
-
}
|
|
34
|
-
export default abstract class Maker<C> implements IForgeMaker {
|
|
35
|
-
private configOrConfigFetcher;
|
|
36
|
-
protected platformsToMakeOn?: string[] | undefined;
|
|
37
|
-
config: C;
|
|
38
|
-
abstract name: string;
|
|
39
|
-
abstract defaultPlatforms: ForgePlatform[];
|
|
40
|
-
requiredExternalBinaries: string[];
|
|
41
|
-
/** @internal */
|
|
42
|
-
__isElectronForgeMaker: true;
|
|
43
|
-
/**
|
|
44
|
-
* @param configOrConfigFetcher - Either a configuration object for this maker or a simple method that returns such a configuration for a given target architecture
|
|
45
|
-
* @param platformsToMakeOn - If you want this maker to run on platforms different from `defaultPlatforms` you can provide those platforms here
|
|
46
|
-
*/
|
|
47
|
-
constructor(configOrConfigFetcher?: C | ((arch: ForgeArch) => C), platformsToMakeOn?: string[] | undefined);
|
|
48
|
-
get platforms(): ForgePlatform[];
|
|
49
|
-
prepareConfig(targetArch: ForgeArch): void;
|
|
50
|
-
/**
|
|
51
|
-
* Makers must implement this method and return true or false indicating whether
|
|
52
|
-
* this maker can be run on the current platform. Normally this is just a process.platform
|
|
53
|
-
* check but it can be a deeper check for dependencies like fake-root or other
|
|
54
|
-
* required external build tools.
|
|
55
|
-
*
|
|
56
|
-
* If the issue is a missing dependency you should log out a HELPFUL error message
|
|
57
|
-
* telling the developer exactly what is missing and if possible how to get it.
|
|
58
|
-
*/
|
|
59
|
-
isSupportedOnCurrentPlatform(): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Makers must implement this method and return an array of absolute paths
|
|
62
|
-
* to the artifacts generated by your maker
|
|
63
|
-
*/
|
|
64
|
-
make(opts: MakerOptions): Promise<string[]>;
|
|
65
|
-
/**
|
|
66
|
-
* Helpers
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* Ensures the directory exists and is forced to be empty.
|
|
70
|
-
*
|
|
71
|
-
* I.e. If the directory already exists it is deleted and recreated, this
|
|
72
|
-
* is a destructive operation
|
|
73
|
-
*/
|
|
74
|
-
ensureDirectory(dir: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Ensures the path to the file exists and the file does not exist
|
|
77
|
-
*
|
|
78
|
-
* I.e. If the file already exists it is deleted and the path created
|
|
79
|
-
*/
|
|
80
|
-
ensureFile(file: string): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Checks if the specified binaries exist, which are required for the maker to be used.
|
|
83
|
-
*/
|
|
84
|
-
externalBinariesExist(): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Throws an error if any of the binaries don't exist.
|
|
87
|
-
*/
|
|
88
|
-
ensureExternalBinariesExist(): void;
|
|
89
|
-
/**
|
|
90
|
-
* Checks if the given module is installed, used for testing if optional dependencies
|
|
91
|
-
* are installed or not
|
|
92
|
-
*/
|
|
93
|
-
isInstalled(module: string): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Normalize the given semver-formatted version to a 4-part dot delimited version number without
|
|
96
|
-
* prerelease information for use in Windows apps.
|
|
97
|
-
*/
|
|
98
|
-
normalizeWindowsVersion(version: string): string;
|
|
99
|
-
}
|
|
100
|
-
export { Maker as MakerBase };
|
|
101
|
-
//# sourceMappingURL=Maker.d.ts.map
|
package/dist/Maker.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Maker.d.ts","sourceRoot":"","sources":["../src/Maker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAI1G,oBAAY,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAA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ACH,qBAAqB,IAAI,OAAO;IAIhC;;OAEG;IACH,2BAA2B,IAAI,IAAI;IAMnC;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAUpC;;;OAGG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAIjD;AAED,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,CAAC"}
|
package/dist/Maker.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.MakerBase = exports.default = void 0;
|
|
6
|
-
var _path = _interopRequireDefault(require("path"));
|
|
7
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
8
|
-
var _which = _interopRequireDefault(require("which"));
|
|
9
|
-
function _interopRequireDefault(obj) {
|
|
10
|
-
return obj && obj.__esModule ? obj : {
|
|
11
|
-
default: obj
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
class Maker {
|
|
15
|
-
/**
|
|
16
|
-
* @param configOrConfigFetcher - Either a configuration object for this maker or a simple method that returns such a configuration for a given target architecture
|
|
17
|
-
* @param platformsToMakeOn - If you want this maker to run on platforms different from `defaultPlatforms` you can provide those platforms here
|
|
18
|
-
*/ constructor(configOrConfigFetcher = {}, platformsToMakeOn){
|
|
19
|
-
this.configOrConfigFetcher = configOrConfigFetcher;
|
|
20
|
-
this.platformsToMakeOn = platformsToMakeOn;
|
|
21
|
-
this.requiredExternalBinaries = [];
|
|
22
|
-
Object.defineProperty(this, '__isElectronForgeMaker', {
|
|
23
|
-
value: true,
|
|
24
|
-
enumerable: false,
|
|
25
|
-
configurable: false
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
get platforms() {
|
|
29
|
-
if (this.platformsToMakeOn) return this.platformsToMakeOn;
|
|
30
|
-
return this.defaultPlatforms;
|
|
31
|
-
}
|
|
32
|
-
// TODO: Remove this, it is an eye-sore and is a nasty hack to provide forge
|
|
33
|
-
// v5 style functionality in the new API
|
|
34
|
-
prepareConfig(targetArch) {
|
|
35
|
-
if (typeof this.configOrConfigFetcher === 'function') {
|
|
36
|
-
this.config = this.configOrConfigFetcher(targetArch);
|
|
37
|
-
} else {
|
|
38
|
-
this.config = this.configOrConfigFetcher;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Makers must implement this method and return true or false indicating whether
|
|
43
|
-
* this maker can be run on the current platform. Normally this is just a process.platform
|
|
44
|
-
* check but it can be a deeper check for dependencies like fake-root or other
|
|
45
|
-
* required external build tools.
|
|
46
|
-
*
|
|
47
|
-
* If the issue is a missing dependency you should log out a HELPFUL error message
|
|
48
|
-
* telling the developer exactly what is missing and if possible how to get it.
|
|
49
|
-
*/ isSupportedOnCurrentPlatform() {
|
|
50
|
-
if (this.isSupportedOnCurrentPlatform === Maker.prototype.isSupportedOnCurrentPlatform) {
|
|
51
|
-
throw new Error(`Maker ${this.name} did not implement the isSupportedOnCurrentPlatform method`);
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Makers must implement this method and return an array of absolute paths
|
|
57
|
-
* to the artifacts generated by your maker
|
|
58
|
-
*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
59
|
-
async make(opts) {
|
|
60
|
-
if (this.make === Maker.prototype.make) {
|
|
61
|
-
throw new Error(`Maker ${this.name} did not implement the make method`);
|
|
62
|
-
}
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Helpers
|
|
67
|
-
*/ /**
|
|
68
|
-
* Ensures the directory exists and is forced to be empty.
|
|
69
|
-
*
|
|
70
|
-
* I.e. If the directory already exists it is deleted and recreated, this
|
|
71
|
-
* is a destructive operation
|
|
72
|
-
*/ async ensureDirectory(dir) {
|
|
73
|
-
if (await _fsExtra.default.pathExists(dir)) {
|
|
74
|
-
await _fsExtra.default.remove(dir);
|
|
75
|
-
}
|
|
76
|
-
return _fsExtra.default.mkdirs(dir);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Ensures the path to the file exists and the file does not exist
|
|
80
|
-
*
|
|
81
|
-
* I.e. If the file already exists it is deleted and the path created
|
|
82
|
-
*/ async ensureFile(file) {
|
|
83
|
-
if (await _fsExtra.default.pathExists(file)) {
|
|
84
|
-
await _fsExtra.default.remove(file);
|
|
85
|
-
}
|
|
86
|
-
await _fsExtra.default.mkdirs(_path.default.dirname(file));
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Checks if the specified binaries exist, which are required for the maker to be used.
|
|
90
|
-
*/ externalBinariesExist() {
|
|
91
|
-
return this.requiredExternalBinaries.every((binary)=>_which.default.sync(binary, {
|
|
92
|
-
nothrow: true
|
|
93
|
-
}) !== null
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Throws an error if any of the binaries don't exist.
|
|
98
|
-
*/ ensureExternalBinariesExist() {
|
|
99
|
-
if (!this.externalBinariesExist()) {
|
|
100
|
-
throw new Error(`Cannot make for ${this.name}, the following external binaries need to be installed: ${this.requiredExternalBinaries.join(', ')}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Checks if the given module is installed, used for testing if optional dependencies
|
|
105
|
-
* are installed or not
|
|
106
|
-
*/ isInstalled(module) {
|
|
107
|
-
try {
|
|
108
|
-
require(module);
|
|
109
|
-
return true;
|
|
110
|
-
} catch (e) {
|
|
111
|
-
// Package doesn't exist -- must not be installable on this platform
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Normalize the given semver-formatted version to a 4-part dot delimited version number without
|
|
117
|
-
* prerelease information for use in Windows apps.
|
|
118
|
-
*/ normalizeWindowsVersion(version) {
|
|
119
|
-
const noPrerelease = version.replace(/-.*/, '');
|
|
120
|
-
return `${noPrerelease}.0`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.default = Maker;
|
|
124
|
-
exports.MakerBase = Maker;
|
|
125
|
-
|
|
126
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9NYWtlci50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgcGF0aCBmcm9tICdwYXRoJztcblxuaW1wb3J0IHsgRm9yZ2VBcmNoLCBGb3JnZVBsYXRmb3JtLCBJRm9yZ2VNYWtlciwgUmVzb2x2ZWRGb3JnZUNvbmZpZyB9IGZyb20gJ0BlbGVjdHJvbi1mb3JnZS9zaGFyZWQtdHlwZXMnO1xuaW1wb3J0IGZzIGZyb20gJ2ZzLWV4dHJhJztcbmltcG9ydCB3aGljaCBmcm9tICd3aGljaCc7XG5cbmV4cG9ydCB0eXBlIEVtcHR5Q29uZmlnID0gUmVjb3JkPHN0cmluZywgbmV2ZXI+O1xuXG5leHBvcnQgaW50ZXJmYWNlIE1ha2VyT3B0aW9ucyB7XG4gIC8qKlxuICAgKiBUaGUgZGlyZWN0b3J5IGNvbnRhaW5pbmcgdGhlIHBhY2thZ2VkIEVsZWN0cm9uIGFwcGxpY2F0aW9uXG4gICAqL1xuICBkaXI6IHN0cmluZztcbiAgLyoqXG4gICAqIFRoZSBkaXJlY3RvcnkgeW91IHNob3VsZCBwdXQgYWxsIHlvdXIgYXJ0aWZhY3RzIGluIChwb3RlbnRpYWxseSBpbiBzdWIgZm9sZGVycylcbiAgICogTk9URTogdGhpcyBkaXJlY3RvcnkgaXMgbm90IGd1YXJ1bnRlZWQgdG8gYWxyZWFkeSBleGlzdFxuICAgKi9cbiAgbWFrZURpcjogc3RyaW5nO1xuICAvKipcbiAgICogVGhlIHJlc29sdmVkIGh1bWFuIGZyaWVuZGx5IG5hbWUgb2YgdGhlIHByb2plY3RcbiAgICovXG4gIGFwcE5hbWU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