Skip to content

Commit

Permalink
feat: convert package to esm, use got v12 (#100)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This package is now pure ESM. gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
BREAKING CHANGE: requires node > 14.16
BREAKING CHANGE: upgrade to got v12
  • Loading branch information
scttcper authored Jun 3, 2022
1 parent 1c19d0f commit fadf2b8
Show file tree
Hide file tree
Showing 11 changed files with 3,472 additions and 10,862 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
orbs:
node: circleci/node@4
node: circleci/node@5
codecov: codecov/codecov@3
jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ coverage:
range: "50..100"
status:
project: no
patch: no
patch: false
comment:
require_changes: yes
require_changes: true
behavior: once
14,228 changes: 3,422 additions & 10,806 deletions package-lock.json

Large diffs are not rendered by default.

51 changes: 22 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"transmission",
"typescript"
],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"type": "module",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts",
"files": [
"dist"
],
Expand All @@ -19,48 +20,40 @@
"lint": "eslint --ext .ts .",
"lint:fix": "eslint --fix --ext .ts .",
"prepare": "npm run build",
"build": "tsc -p tsconfig.build.json",
"build": "tsc",
"build:docs": "typedoc",
"test": "jest --runInBand",
"test:watch": "jest --watch --runInBand",
"test:ci": "jest --ci --runInBand --reporters=default --reporters=jest-junit --coverage"
"test": "vitest run",
"test:watch": "vitest",
"test:ci": "vitest run --coverage"
},
"dependencies": {
"@ctrl/shared-torrent": "^3.0.5",
"got": "^11.8.3",
"@ctrl/url-join": "^1.0.4"
"@ctrl/shared-torrent": "^4.1.0",
"@ctrl/url-join": "^2.0.0",
"got": "^12.1.0"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "7.16.8",
"@babel/preset-typescript": "7.16.7",
"@ctrl/eslint-config": "3.3.1",
"@jest/globals": "27.4.6",
"@types/node": "17.0.14",
"jest": "27.4.7",
"jest-junit": "13.0.0",
"p-wait-for": "3.2.0",
"typedoc": "0.22.11",
"typescript": "4.5.5"
"@ctrl/eslint-config": "3.4.4",
"@sindresorhus/tsconfig": "3.0.1",
"@types/node": "17.0.38",
"c8": "7.11.3",
"p-wait-for": "4.1.0",
"typedoc": "0.22.17",
"typescript": "4.7.2",
"vitest": "0.13.1"
},
"jest": {
"testEnvironment": "node",
"coverageProvider": "v8"
},
"babel": {
"presets": [
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
},
"publishConfig": {
"access": "public"
},
"release": {
"branch": "master"
"branches": [
"master"
]
},
"engines": {
"node": ">=10.19.0"
"node": ">=14.16"
}
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './transmission';
export * from './types';
export * from './transmission.js';
export * from './types.js';
8 changes: 4 additions & 4 deletions src/transmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
SetTorrentOptions,
Torrent,
TorrentIds,
} from './types';
} from './types.js';

const defaults: TorrentSettings = {
baseUrl: 'http://localhost:9091/',
Expand Down Expand Up @@ -368,11 +368,11 @@ export class Transmission implements TorrentClient {
arguments: args,
},
headers,
retry: 0,
retry: { limit: 0 },
// allow proxy agent
agent: this.config.agent,
timeout: this.config.timeout,
timeout: { request: this.config.timeout },
responseType: 'json',
...(this.config.agent ? { agent: this.config.agent } : {}),
});

return res;
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface DefaultResponse {
arguments: any;
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
result: 'success' | string;
}

Expand Down Expand Up @@ -56,6 +57,7 @@ export type TorrentIds = number | 'recently-active' | Array<number | string>;
/**
* Allows the user to pass a single hash, this will be converted to an array
*/
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
export type NormalizedTorrentIds = TorrentIds | string;

export interface GetTorrentRepsonse extends DefaultResponse {
Expand Down
4 changes: 2 additions & 2 deletions test/transmission.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import fs from 'fs';
import path from 'path';

import { afterEach, describe, expect, it } from '@jest/globals';
import pWaitFor from 'p-wait-for';
import { afterEach, describe, expect, it } from 'vitest';

import { TorrentState } from '@ctrl/shared-torrent';

import { Transmission } from '../src/index';
import { Transmission } from '../src/index.js';

const baseUrl = 'http://localhost:9091/';
const torrentName = 'ubuntu-18.04.1-desktop-amd64.iso';
Expand Down
4 changes: 0 additions & 4 deletions tsconfig.build.json

This file was deleted.

19 changes: 7 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
{
"compileOnSave": false,
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"moduleResolution": "Node",
"lib": ["ES2019"],
"target": "ES2018",
"module": "CommonJS",
"esModuleInterop": true,
"strict": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"declaration": true,
"sourceMap": false,
"outDir": "dist"
"outDir": "dist",
"strictNullChecks": false,
"noPropertyAccessFromIndexSignature": false
},
"ts-node": {
"transpileOnly": true
}
}
8 changes: 8 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-expect-error
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
threads: false,
},
});

0 comments on commit fadf2b8

Please sign in to comment.