Skip to content

Commit

Permalink
remove deprecated options
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Jan 17, 2025
1 parent 13ede9e commit 0b4fdcc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 76 deletions.
8 changes: 1 addition & 7 deletions src/artifact-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ export async function getArtifactRemoteURL(details: ElectronArtifactDetails): Pr
const opts: MirrorOptions = details.mirrorOptions || {};
let base = mirrorVar('mirror', opts, BASE_URL);
if (details.version.includes('nightly')) {
const nightlyDeprecated = mirrorVar('nightly_mirror', opts, '');
if (nightlyDeprecated) {
base = nightlyDeprecated;
console.warn(`nightly_mirror is deprecated, please use nightlyMirror`);
} else {
base = mirrorVar('nightlyMirror', opts, NIGHTLY_BASE_URL);
}
base = mirrorVar('nightlyMirror', opts, NIGHTLY_BASE_URL);
}
const path = mirrorVar('customDir', opts, details.version).replace(
'{{ version }}',
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ async function validateArtifact(
isGeneric: true,
version: artifactDetails.version,
artifactName: 'SHASUMS256.txt',
force: false,
downloadOptions: artifactDetails.downloadOptions,
cacheRoot: artifactDetails.cacheRoot,
downloader: artifactDetails.downloader,
Expand Down
14 changes: 0 additions & 14 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ export type DownloadOptions = any;
* ```
*/
export interface MirrorOptions {
/**
* @deprecated
* @see {@link MirrorOptions.nightlyMirror}
*/
nightly_mirror?: string;
/**
* The mirror URL for [`electron-nightly`](https://npmjs.com/package/electron-nightly),
* which lives in a separate npm package.
Expand Down Expand Up @@ -108,13 +103,6 @@ export enum ElectronDownloadCacheMode {
* @category Download Electron
*/
export interface ElectronDownloadRequestOptions {
/**
* Whether to download an artifact regardless of whether it's in the cache directory.
*
* @defaultValue `false`
* @deprecated This option is deprecated and directly maps to {@link cacheMode | `cacheMode: ElectronDownloadCacheMode.WriteOnly`}
*/
force?: boolean;
/**
* When set to `true`, disables checking that the artifact download completed successfully
* with the correct payload.
Expand Down Expand Up @@ -184,8 +172,6 @@ export interface ElectronDownloadRequestOptions {
* should not move or delete the file path that is returned as the path
* points directly to the disk cache.
*
* This option cannot be used in conjunction with {@link ElectronDownloadRequestOptions.force}.
*
* @defaultValue {@link ElectronDownloadCacheMode.ReadWrite}
*/
cacheMode?: ElectronDownloadCacheMode;
Expand Down
9 changes: 0 additions & 9 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ export function setEnv(key: string, value: string | undefined): void {
export function effectiveCacheMode(
artifactDetails: ElectronPlatformArtifactDetailsWithDefaults | ElectronGenericArtifactDetails,
): ElectronDownloadCacheMode {
if (artifactDetails.force) {
if (artifactDetails.cacheMode) {
throw new Error(
'Setting both "force" and "cacheMode" is not supported, please exclusively use "cacheMode"',
);
}
return ElectronDownloadCacheMode.WriteOnly;
}

return artifactDetails.cacheMode || ElectronDownloadCacheMode.ReadWrite;
}

Expand Down
49 changes: 4 additions & 45 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import crypto from 'node:crypto';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
Expand Down Expand Up @@ -45,46 +44,6 @@ describe('Public API', () => {
expect(path.extname(zipPath)).toEqual('.zip');
});

it('should not redownload when force=false', async () => {
const zipPath = await download('2.0.9', {
cacheRoot,
downloader,
force: false,
});
await fs.promises.writeFile(zipPath, 'bad content');
const zipPath2 = await download('2.0.9', {
cacheRoot,
downloader,
force: false,
});
expect(zipPath).toEqual(zipPath2);
expect(await fs.promises.readFile(zipPath, 'utf8')).toEqual('bad content');
});

it('should redownload when force=true', async () => {
const zipPath = await download('2.0.9', {
cacheRoot,
downloader,
force: true,
});
const hash = crypto
.createHash('sha256')
.update(await fs.promises.readFile(zipPath))
.digest('hex');
await fs.promises.writeFile(zipPath, 'bad content');
const zipPath2 = await download('2.0.9', {
cacheRoot,
downloader,
force: true,
});
expect(zipPath).toEqual(zipPath2);
const hash2 = crypto
.createHash('sha256')
.update(await fs.promises.readFile(zipPath2))
.digest('hex');
expect(hash).toEqual(hash2);
});

it('should accept a custom downloader', async () => {
const zipPath = await download('2.0.3', {
cacheRoot,
Expand Down Expand Up @@ -316,13 +275,13 @@ describe('Public API', () => {
await downloadArtifact({
artifactName: 'electron',
downloader,
force: true,
cacheMode: ElectronDownloadCacheMode.WriteOnly,
version: 'v1.3.5',
});
await downloadArtifact({
artifactName: 'electron',
downloader,
force: true,
cacheMode: ElectronDownloadCacheMode.WriteOnly,
version: 'v2.0.3',
});

Expand All @@ -334,7 +293,7 @@ describe('Public API', () => {
await downloadArtifact({
artifactName: 'electron',
downloader,
force: true,
cacheMode: ElectronDownloadCacheMode.WriteOnly,
version: 'v1.3.3',
});

Expand All @@ -346,7 +305,7 @@ describe('Public API', () => {
await downloadArtifact({
artifactName: 'electron',
downloader,
force: true,
cacheMode: ElectronDownloadCacheMode.WriteOnly,
version: 'v1.0.0',
});

Expand Down

0 comments on commit 0b4fdcc

Please sign in to comment.