timely update

use bunjs instead of pnpm
remove mocha and use bun test
import my latest eslint config
This commit is contained in:
zS1L3NT Mac 2023-12-22 03:24:30 +08:00
parent 1053ccc036
commit d4d6fa1662
No known key found for this signature in database
GPG Key ID: 02BE07CD431E4F42
12 changed files with 55 additions and 2927 deletions

View File

@ -3,5 +3,5 @@ indent_size = 4
indent_style = tab indent_style = tab
[{*.yml, *.yaml}] [{*.yml, *.yaml}]
indent_size = 2 indent_size = 4
indent_style = space indent_style = space

View File

@ -4,34 +4,33 @@
"es2021": true, "es2021": true,
"node": true "node": true
}, },
"extends": [ "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
// "next/core-web-vitals",
"eslint:recommended",
// "plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"overrides": [], "overrides": [],
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"parserOptions": { "parserOptions": {
"ecmaVersion": "latest", "ecmaVersion": "latest",
"sourceType": "module" "sourceType": "module"
}, },
"plugins": [ "plugins": ["@typescript-eslint", "simple-import-sort"],
// "react",
"@typescript-eslint",
"simple-import-sort"
],
"rules": { "rules": {
"@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "warn", "@typescript-eslint/ban-types": "warn",
"@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"linebreak-style": ["error", "unix"], "linebreak-style": ["error", "unix"],
"no-empty": "warn", "no-empty": "warn",
"no-empty-function": "off", "no-empty-function": "off",
"no-empty-pattern": "warn", "no-empty-pattern": "warn",
// "react/react-in-jsx-scope": "off", "react/react-in-jsx-scope": "off",
"simple-import-sort/imports": [ "simple-import-sort/imports": [
"warn", "warn",
{ {

1
.npmrc
View File

@ -1 +0,0 @@
shamefully-hoist=true

BIN
bun.lockb Executable file

Binary file not shown.

View File

@ -1,10 +1,10 @@
{ {
"name": "ytmusic-api", "name": "ytmusic-api",
"version": "4.4.0", "version": "4.5.0",
"description": "YouTube Music API", "description": "YouTube Music API",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"author": "zS1L3NT <zechariahtan144@gmail.com> (http://www.zectan.com)", "author": "zS1L3NT <dev@zectan.com> (http://www.zectan.com)",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {
"type": "git", "type": "git",
@ -12,14 +12,9 @@
}, },
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"test": "ts-mocha --timeout 30000 src/__tests__/**/*.spec.ts",
"docs:dev": "vuepress dev docs", "docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs", "docs:build": "vuepress build docs",
"lint": "eslint src", "clean": "tsc --noEmit && eslint src --fix && prettier src --write && rm tsconfig.tsbuildinfo"
"lint:fix": "eslint src --fix",
"prettier": "prettier src --check",
"prettier:fix": "prettier src --write",
"clean": "tsc --noEmit && eslint src --fix && prettier src --write"
}, },
"dependencies": { "dependencies": {
"axios": "^0.27.2", "axios": "^0.27.2",
@ -29,20 +24,15 @@
}, },
"devDependencies": { "devDependencies": {
"@types/json-schema": "^7.0.11", "@types/json-schema": "^7.0.11",
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.17",
"@types/tough-cookie": "^4.0.2", "@types/tough-cookie": "^4.0.2",
"@typescript-eslint/eslint-plugin": "latest", "@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest", "@typescript-eslint/parser": "latest",
"@vuepress/plugin-search": "^2.0.0-beta.46", "@vuepress/plugin-search": "^2.0.0-beta.46",
"bun-types": "^1.0.18-1",
"eslint": "latest", "eslint": "latest",
"eslint-config-prettier": "latest", "eslint-config-prettier": "latest",
"eslint-plugin-simple-import-sort": "latest", "eslint-plugin-simple-import-sort": "latest",
"mocha": "^10.2.0",
"mocha.parallel": "^0.15.6",
"prettier": "latest", "prettier": "latest",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "latest", "typescript": "latest",
"vuepress": "^2.0.0-beta.46" "vuepress": "^2.0.0-beta.46"
}, },

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
declare module "mocha.parallel"

View File

@ -3,9 +3,9 @@ import checkType from "../utils/checkType"
import traverseList from "../utils/traverseList" import traverseList from "../utils/traverseList"
import traverseString from "../utils/traverseString" import traverseString from "../utils/traverseString"
import AlbumParser from "./AlbumParser" import AlbumParser from "./AlbumParser"
import PlaylistParser from "./PlaylistParser"
import SongParser from "./SongParser" import SongParser from "./SongParser"
import VideoParser from "./VideoParser" import VideoParser from "./VideoParser"
import PlaylistParser from "./PlaylistParser";
export default class ArtistParser { export default class ArtistParser {
public static parse(data: any, artistId: string): ArtistFull { public static parse(data: any, artistId: string): ArtistFull {
@ -46,15 +46,12 @@ export default class ArtistParser {
featuredOn: featuredOn:
traverseList(data, "musicCarouselShelfRenderer") traverseList(data, "musicCarouselShelfRenderer")
?.at(3) ?.at(3)
?.contents.map((item: any) => ?.contents.map((item: any) => PlaylistParser.parseArtistFeaturedOn(item)) ??
PlaylistParser.parseArtistFeaturedOn(item), [],
) ?? [],
similarArtists: similarArtists:
traverseList(data, "musicCarouselShelfRenderer") traverseList(data, "musicCarouselShelfRenderer")
?.at(4) ?.at(4)
?.contents.map((item: any) => ?.contents.map((item: any) => this.parseSimilarArtists(item)) ?? [],
this.parseSimilarArtists(item),
) ?? [],
}, },
ArtistFull, ArtistFull,
) )

View File

@ -107,8 +107,8 @@ export const ArtistFull = z.object({
topAlbums: z.array(AlbumDetailed), topAlbums: z.array(AlbumDetailed),
topSingles: z.array(AlbumDetailed), topSingles: z.array(AlbumDetailed),
topVideos: z.array(VideoDetailed.omit({ duration: true })), topVideos: z.array(VideoDetailed.omit({ duration: true })),
featuredOn: z.array(PlaylistDetailed), featuredOn: z.array(PlaylistDetailed),
similarArtists: z.array(ArtistDetailed), similarArtists: z.array(ArtistDetailed),
}) })
export type AlbumFull = z.infer<typeof AlbumFull> export type AlbumFull = z.infer<typeof AlbumFull>

View File

@ -1,5 +1,5 @@
import { equal } from "assert" import { equal } from "assert"
import describeParallel from "mocha.parallel" import { afterAll, beforeAll, describe, it } from "bun:test"
import { z } from "zod" import { z } from "zod"
import { import {
@ -27,10 +27,10 @@ const expect = (data: any, schema: z.Schema) => {
} }
const ytmusic = new YTMusic() const ytmusic = new YTMusic()
before(() => ytmusic.initialize()) beforeAll(() => ytmusic.initialize())
queries.forEach(query => { queries.forEach(query => {
describeParallel("Query: " + query, () => { describe("Query: " + query, () => {
it("Search suggestions", async () => { it("Search suggestions", async () => {
const suggestions = await ytmusic.getSearchSuggestions(query) const suggestions = await ytmusic.getSearchSuggestions(query)
expect(suggestions, z.array(z.string())) expect(suggestions, z.array(z.string()))
@ -124,4 +124,4 @@ queries.forEach(query => {
}) })
}) })
after(() => console.log("Issues:", errors)) afterAll(() => console.log("Issues:", errors))

View File

@ -2,16 +2,16 @@
"compilerOptions": { "compilerOptions": {
/** Transpiler */ /** Transpiler */
"target": "esnext", "target": "esnext",
"lib": ["esnext"], // "dom", "dom.iterable", "esnext" "lib": ["esnext"],
"module": "commonjs", // esnext "module": "esnext",
"moduleResolution": "node", "moduleResolution": "bundler",
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
/** Project */ /** Project */
"rootDir": "src", "rootDir": "src",
"outDir": "dist", "outDir": "dist",
"typeRoots": ["./node_modules/@types", "./src/@types"], "types": ["bun-types"],
"declaration": true, "declaration": true,
/** Type Checking */ /** Type Checking */
@ -28,16 +28,15 @@
"noImplicitOverride": true, "noImplicitOverride": true,
"allowUnusedLabels": true, "allowUnusedLabels": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"forceConsistentCasingInFileNames": true "forceConsistentCasingInFileNames": true,
/** Other */ /** Other */
// "noEmit": true, "noEmit": true,
// "allowJs": true, "allowJs": true,
// "jsx": "react-jsx", "jsx": "react-jsx",
// "skipLibCheck": true, "skipLibCheck": true,
// "isolatedModules": true, "isolatedModules": true,
// "incremental": true "incremental": true
}, },
"include": ["src"], "include": ["src", "src/tests"]
"exclude": ["src/__tests__"]
} }