Skip to content

Commit

Permalink
ESM-only
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Jan 30, 2025
1 parent 573a1e2 commit 20c6965
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
],
"rules": {
"@typescript-eslint/prefer-ts-expect-error": 0,
"@typescript-eslint/ban-ts-comment": 0
"@typescript-eslint/ban-ts-comment": 0,
"import/no-unresolved": "off"
}
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"name": "@electron/get",
"version": "0.0.0-development",
"type": "module",
"description": "Utility for downloading artifacts from different versions of Electron",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"repository": "https://github.com/electron/get",
"author": "Samuel Attard",
"license": "MIT",
"publishConfig": {
"provenance": true
},
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"build": "tsc",
"build:docs": "npx typedoc",
"eslint": "eslint --ext .ts src test",
"lint": "npm run prettier && npm run eslint",
Expand Down Expand Up @@ -46,12 +45,14 @@
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.0.0",
"@vitest/coverage-v8": "3.0.3",
"esbuild-plugin-file-path-extensions": "^2.1.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.31.0",
"husky": "^9.1.7",
"lint-staged": "^15.4.1",
"prettier": "^3.4.2",
"tsup": "^8.3.6",
"typedoc": "~0.25.13",
"typescript": "~5.4.5",
"vitest": "^3.0.3"
Expand Down
2 changes: 1 addition & 1 deletion src/GotDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fs from 'node:fs';
import path from 'node:path';
import ProgressBar from 'progress';

import { Downloader } from './Downloader';
import { Downloader } from './Downloader.js';

const PROGRESS_BAR_DELAY_IN_SECONDS = 30;

Expand Down
4 changes: 2 additions & 2 deletions src/artifact-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ElectronArtifactDetails, MirrorOptions } from './types';
import { ensureIsTruthyString, normalizeVersion } from './utils';
import { ElectronArtifactDetails, MirrorOptions } from './types.js';
import { ensureIsTruthyString, normalizeVersion } from './utils.js';

const BASE_URL = 'https://github.com/electron/electron/releases/download/';
const NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/';
Expand Down
6 changes: 3 additions & 3 deletions src/downloader-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DownloadOptions } from './types';
import { Downloader } from './Downloader';
import { DownloadOptions } from './types.js';
import { Downloader } from './Downloader.js';

// TODO: Resolve the downloader or default to GotDownloader
// Current thoughts are a dot-file traversal for something like
// ".electron.downloader" which would be a text file with the name of the
// npm module to import() and use as the downloader
import { GotDownloader } from './GotDownloader';
import { GotDownloader } from './GotDownloader.js';

export async function getDownloaderForSystem(): Promise<Downloader<DownloadOptions>> {
return new GotDownloader();
Expand Down
18 changes: 9 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import path from 'node:path';
import semver from 'semver';
import sumchecker from 'sumchecker';

import { getArtifactFileName, getArtifactRemoteURL, getArtifactVersion } from './artifact-utils';
import { getArtifactFileName, getArtifactRemoteURL, getArtifactVersion } from './artifact-utils.js';
import {
ElectronArtifactDetails,
ElectronDownloadCacheMode,
ElectronDownloadRequestOptions,
ElectronGenericArtifactDetails,
ElectronPlatformArtifactDetails,
ElectronPlatformArtifactDetailsWithDefaults,
} from './types';
import { Cache } from './Cache';
import { getDownloaderForSystem } from './downloader-resolver';
import { initializeProxy } from './proxy';
} from './types.js';
import { Cache } from './Cache.js';
import { getDownloaderForSystem } from './downloader-resolver.js';
import { initializeProxy } from './proxy.js';
import {
withTempDirectoryIn,
getHostArch,
Expand All @@ -27,11 +27,11 @@ import {
effectiveCacheMode,
shouldTryReadCache,
TempDirCleanUpMode,
} from './utils';
} from './utils.js';

export { getHostArch } from './utils';
export { initializeProxy } from './proxy';
export * from './types';
export { getHostArch } from './utils.js';
export { initializeProxy } from './proxy.js';
export * from './types.js';

const d = debug('@electron/get:index');

Expand Down
2 changes: 1 addition & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import debug from 'debug';
import { getEnv, setEnv } from './utils';
import { getEnv, setEnv } from './utils.js';

const d = debug('@electron/get:proxy');

Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Downloader } from './Downloader';
import { GotDownloader, GotDownloaderOptions } from './GotDownloader';
import { Downloader } from './Downloader.js';
import { GotDownloader, GotDownloaderOptions } from './GotDownloader.js';

export { Downloader, GotDownloader, GotDownloaderOptions };

Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ElectronDownloadCacheMode,
ElectronGenericArtifactDetails,
ElectronPlatformArtifactDetailsWithDefaults,
} from './types';
} from './types.js';

async function useAndRemoveDirectory<T>(
directory: string,
Expand Down
8 changes: 0 additions & 8 deletions tsconfig.esm.json

This file was deleted.

4 changes: 1 addition & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"extends": "@tsconfig/node22/tsconfig.json",
"compilerOptions": {
"sourceMap": true,
"outDir": "dist/cjs",
"outDir": "dist",
"types": ["node"],
"allowSyntheticDefaultImports": true,
"declaration": true
},
"include": ["src"]
}

0 comments on commit 20c6965

Please sign in to comment.