@electron-forge/maker-base 7.10.1 → 8.0.0-alpha.1

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.
@@ -0,0 +1,102 @@
1
+ import { ForgeArch, ForgePlatform, IForgeMaker, ResolvedForgeConfig } from '@electron-forge/shared-types';
2
+ export 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): Promise<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
+ clone(): Maker<C>;
61
+ /**
62
+ * Makers must implement this method and return an array of absolute paths
63
+ * to the artifacts generated by your maker
64
+ */
65
+ make(opts: MakerOptions): Promise<string[]>;
66
+ /**
67
+ * Helpers
68
+ */
69
+ /**
70
+ * Ensures the directory exists and is forced to be empty.
71
+ *
72
+ * I.e. If the directory already exists it is deleted and recreated, this
73
+ * is a destructive operation
74
+ */
75
+ ensureDirectory(dir: string): Promise<void>;
76
+ /**
77
+ * Ensures the path to the file exists and the file does not exist
78
+ *
79
+ * I.e. If the file already exists it is deleted and the path created
80
+ */
81
+ ensureFile(file: string): Promise<void>;
82
+ /**
83
+ * Checks if the specified binaries exist, which are required for the maker to be used.
84
+ */
85
+ externalBinariesExist(): boolean;
86
+ /**
87
+ * Throws an error if any of the binaries don't exist.
88
+ */
89
+ ensureExternalBinariesExist(): void;
90
+ /**
91
+ * Checks if the given module is installed, used for testing if optional dependencies
92
+ * are installed or not
93
+ */
94
+ isInstalled(module: string): boolean;
95
+ /**
96
+ * Normalize the given semver-formatted version to a 4-part dot delimited version number without
97
+ * prerelease information for use in Windows apps.
98
+ */
99
+ normalizeWindowsVersion(version: string): string;
100
+ }
101
+ export { Maker as MakerBase };
102
+ //# sourceMappingURL=Maker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Maker.d.ts","sourceRoot":"","sources":["../src/Maker.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAItC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,GAAG,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EG;IACH,qBAAqB,IAAI,OAAO;IAMhC;;OAEG;IACH,2BAA2B,IAAI,IAAI;IAQnC;;;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 ADDED
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MakerBase = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const which_1 = __importDefault(require("which"));
10
+ class Maker {
11
+ /**
12
+ * @param configOrConfigFetcher - Either a configuration object for this maker or a simple method that returns such a configuration for a given target architecture
13
+ * @param platformsToMakeOn - If you want this maker to run on platforms different from `defaultPlatforms` you can provide those platforms here
14
+ */
15
+ constructor(configOrConfigFetcher = {}, platformsToMakeOn) {
16
+ this.configOrConfigFetcher = configOrConfigFetcher;
17
+ this.platformsToMakeOn = platformsToMakeOn;
18
+ this.requiredExternalBinaries = [];
19
+ Object.defineProperty(this, '__isElectronForgeMaker', {
20
+ value: true,
21
+ enumerable: false,
22
+ configurable: false,
23
+ });
24
+ }
25
+ get platforms() {
26
+ if (this.platformsToMakeOn)
27
+ return this.platformsToMakeOn;
28
+ return this.defaultPlatforms;
29
+ }
30
+ // TODO: Remove this, it is an eye-sore and is a nasty hack to provide forge
31
+ // v5 style functionality in the new API
32
+ async prepareConfig(targetArch) {
33
+ if (typeof this.configOrConfigFetcher === 'function') {
34
+ this.config = await Promise.resolve(this.configOrConfigFetcher(targetArch));
35
+ }
36
+ else {
37
+ this.config = this.configOrConfigFetcher;
38
+ }
39
+ }
40
+ /**
41
+ * Makers must implement this method and return true or false indicating whether
42
+ * this maker can be run on the current platform. Normally this is just a process.platform
43
+ * check but it can be a deeper check for dependencies like fake-root or other
44
+ * required external build tools.
45
+ *
46
+ * If the issue is a missing dependency you should log out a HELPFUL error message
47
+ * telling the developer exactly what is missing and if possible how to get it.
48
+ */
49
+ isSupportedOnCurrentPlatform() {
50
+ if (this.isSupportedOnCurrentPlatform ===
51
+ Maker.prototype.isSupportedOnCurrentPlatform) {
52
+ throw new Error(`Maker ${this.name} did not implement the isSupportedOnCurrentPlatform method`);
53
+ }
54
+ return true;
55
+ }
56
+ clone() {
57
+ const MakerClass = this.constructor;
58
+ return new MakerClass(this.configOrConfigFetcher, this.platformsToMakeOn);
59
+ }
60
+ /**
61
+ * Makers must implement this method and return an array of absolute paths
62
+ * to the artifacts generated by your maker
63
+ */
64
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
+ async make(opts) {
66
+ if (this.make === Maker.prototype.make) {
67
+ throw new Error(`Maker ${this.name} did not implement the make method`);
68
+ }
69
+ return [];
70
+ }
71
+ /**
72
+ * Helpers
73
+ */
74
+ /**
75
+ * Ensures the directory exists and is forced to be empty.
76
+ *
77
+ * I.e. If the directory already exists it is deleted and recreated, this
78
+ * is a destructive operation
79
+ */
80
+ async ensureDirectory(dir) {
81
+ if (await fs_extra_1.default.pathExists(dir)) {
82
+ await fs_extra_1.default.remove(dir);
83
+ }
84
+ return fs_extra_1.default.mkdirs(dir);
85
+ }
86
+ /**
87
+ * Ensures the path to the file exists and the file does not exist
88
+ *
89
+ * I.e. If the file already exists it is deleted and the path created
90
+ */
91
+ async ensureFile(file) {
92
+ if (await fs_extra_1.default.pathExists(file)) {
93
+ await fs_extra_1.default.remove(file);
94
+ }
95
+ await fs_extra_1.default.mkdirs(node_path_1.default.dirname(file));
96
+ }
97
+ /**
98
+ * Checks if the specified binaries exist, which are required for the maker to be used.
99
+ */
100
+ externalBinariesExist() {
101
+ return this.requiredExternalBinaries.every((binary) => which_1.default.sync(binary, { nothrow: true }) !== null);
102
+ }
103
+ /**
104
+ * Throws an error if any of the binaries don't exist.
105
+ */
106
+ ensureExternalBinariesExist() {
107
+ if (!this.externalBinariesExist()) {
108
+ throw new Error(`Cannot make for ${this.name}, the following external binaries need to be installed: ${this.requiredExternalBinaries.join(', ')}`);
109
+ }
110
+ }
111
+ /**
112
+ * Checks if the given module is installed, used for testing if optional dependencies
113
+ * are installed or not
114
+ */
115
+ isInstalled(module) {
116
+ try {
117
+ require(module);
118
+ return true;
119
+ }
120
+ catch {
121
+ // Package doesn't exist -- must not be installable on this platform
122
+ return false;
123
+ }
124
+ }
125
+ /**
126
+ * Normalize the given semver-formatted version to a 4-part dot delimited version number without
127
+ * prerelease information for use in Windows apps.
128
+ */
129
+ normalizeWindowsVersion(version) {
130
+ const noPrerelease = version.replace(/[-+].*/, '');
131
+ return `${noPrerelease}.0`;
132
+ }
133
+ }
134
+ exports.default = Maker;
135
+ exports.MakerBase = Maker;
136
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTWFrZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvTWFrZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsMERBQTZCO0FBUTdCLHdEQUEwQjtBQUMxQixrREFBMEI7QUFvQzFCLE1BQThCLEtBQUs7SUFZakM7OztPQUdHO0lBQ0gsWUFDVSx3QkFBc0QsRUFBTyxFQUMzRCxpQkFBbUM7UUFEckMsMEJBQXFCLEdBQXJCLHFCQUFxQixDQUF3QztRQUMzRCxzQkFBaUIsR0FBakIsaUJBQWlCLENBQWtCO1FBWHhDLDZCQUF3QixHQUFhLEVBQUUsQ0FBQztRQWE3QyxNQUFNLENBQUMsY0FBYyxDQUFDLElBQUksRUFBRSx3QkFBd0IsRUFBRTtZQUNwRCxLQUFLLEVBQUUsSUFBSTtZQUNYLFVBQVUsRUFBRSxLQUFLO1lBQ2pCLFlB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FDLGVBQUssQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLEVBQUUsT0FBTyxFQUFFLElBQUksRUFBRSxDQUFDLEtBQUssSUFBSSxDQUMzRCxDQUFDO0lBQ0osQ0FBQztJQUVEOztPQUVHO0lBQ0gsMkJBQTJCO1FBQ3pCLElBQUksQ0FBQyxJQUFJLENBQUMscUJBQXFCLEVBQUUsRUFBRSxDQUFDO1lBQ2xDLE1BQU0sSUFBSSxLQUFLLENBQ2IsbUJBQW1CLElBQUksQ0FBQyxJQUFJLDJEQUEyRCxJQUFJLENBQUMsd0JBQXdCLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxFQUFFLENBQ2xJLENBQUM7UUFDSixDQUFDO0lBQ0gsQ0FBQztJQUVEOzs7T0FHRztJQUNILFdBQVcsQ0FBQyxNQUFjO1FBQ3hCLElBQUksQ0FBQztZQUNILE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztZQUNoQixPQUFPLElBQUksQ0FBQztRQUNkLENBQUM7UUFBQyxNQUFNLENBQUM7WUFDUCxvRUFBb0U7WUFDcEUsT0FBTyxLQUFLLENBQUM7UUFDZixDQUFDO0lBQ0gsQ0FBQztJQUVEOzs7T0FHRztJQUNILHVCQUF1QixDQUFDLE9BQWU7UUFDckMsTUFBTSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxRQUFRLEVBQUUsRUFBRSxDQUFDLENBQUM7UUFDbkQsT0FBTyxHQUFHLFlBQVksSUFBSSxDQUFDO0lBQzdCLENBQUM7Q0FDRjtBQXpKRCx3QkF5SkM7QUFFaUIsMEJBQVMifQ==
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electron-forge/maker-base",
3
- "version": "7.10.1",
3
+ "version": "8.0.0-alpha.1",
4
4
  "description": "Base maker for Electron Forge",
5
5
  "repository": "https://github.com/electron/forge",
6
6
  "author": "Samuel Attard",
@@ -14,7 +14,7 @@
14
14
  "node": ">= 16.4.0"
15
15
  },
16
16
  "dependencies": {
17
- "@electron-forge/shared-types": "7.10.1",
17
+ "@electron-forge/shared-types": "8.0.0-alpha.1",
18
18
  "fs-extra": "^10.0.0",
19
19
  "which": "^2.0.2"
20
20
  },
@@ -25,5 +25,5 @@
25
25
  "dist",
26
26
  "src"
27
27
  ],
28
- "gitHead": "a9c9eb7b8476e9c4bbcc4ef80f0ac16166effe94"
28
+ "gitHead": "b9e0db1e38fafbeace24f539be01e32a4aeed258"
29
29
  }