@electron-forge/publisher-static 7.1.0

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/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@electron-forge/publisher-static",
3
+ "version": "7.1.0",
4
+ "description": "Base publisher for Electron Forge",
5
+ "repository": "https://github.com/electron/forge",
6
+ "author": "Samuel Attard",
7
+ "license": "MIT",
8
+ "main": "dist/PublisherStatic.js",
9
+ "typings": "dist/PublisherStatic.d.ts",
10
+ "scripts": {
11
+ "test": "yarn test:base test/**/*_spec.ts",
12
+ "test:base": "cross-env TS_NODE_FILES=1 mocha --config ../../../.mocharc.js"
13
+ },
14
+ "dependencies": {
15
+ "@electron-forge/publisher-base": "7.1.0",
16
+ "@electron-forge/shared-types": "7.1.0"
17
+ },
18
+ "devDependencies": {
19
+ "chai": "^4.3.3",
20
+ "mocha": "^9.0.1"
21
+ },
22
+ "engines": {
23
+ "node": ">= 16.4.0"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "src"
31
+ ]
32
+ }
@@ -0,0 +1,30 @@
1
+ import path from 'path';
2
+
3
+ import { PublisherBase, PublisherOptions } from '@electron-forge/publisher-base';
4
+ import { ForgeArch, ForgePlatform } from '@electron-forge/shared-types';
5
+
6
+ interface StaticArtifact {
7
+ path: string;
8
+ platform: ForgePlatform;
9
+ arch: ForgeArch;
10
+ keyPrefix: string;
11
+ }
12
+
13
+ interface StaticPublisherConfig {
14
+ /**
15
+ * Custom function to provide the key to upload a given file to
16
+ */
17
+ keyResolver?: (fileName: string, platform: string, arch: string) => string;
18
+ }
19
+
20
+ export default abstract class PublisherStatic<C extends StaticPublisherConfig> extends PublisherBase<C> {
21
+ protected keyForArtifact(artifact: StaticArtifact): string {
22
+ if (this.config.keyResolver) {
23
+ return this.config.keyResolver(path.basename(artifact.path), artifact.platform, artifact.arch);
24
+ }
25
+
26
+ return `${artifact.keyPrefix}/${artifact.platform}/${artifact.arch}/${path.basename(artifact.path)}`;
27
+ }
28
+ }
29
+
30
+ export { PublisherStatic, StaticPublisherConfig, PublisherOptions };