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 6adf18b
Show file tree
Hide file tree
Showing 12 changed files with 30 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"
}
}
6 changes: 3 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,6 +45,7 @@
"@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",
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"]
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,11 @@ es6-error@^4.1.1:
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==

esbuild-plugin-file-path-extensions@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/esbuild-plugin-file-path-extensions/-/esbuild-plugin-file-path-extensions-2.1.4.tgz#cad9d1d3133e95146eeabd76fdf3956a66f6348b"
integrity sha512-lNjylaAsJMprYg28zjUyBivP3y0ms9b7RJZ5tdhDUFLa3sCbqZw4wDnbFUSmnyZYWhCYDPxxp7KkXM2TXGw3PQ==

esbuild@^0.24.2:
version "0.24.2"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.2.tgz#b5b55bee7de017bff5fb8a4e3e44f2ebe2c3567d"
Expand Down

0 comments on commit 6adf18b

Please sign in to comment.