From 40f65d9fbb7c4fa55af67097343cc94943e31de5 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Mon, 8 Mar 2021 12:23:31 +0100 Subject: [PATCH] Remove ".js" from module imports --- src/example.ts | 2 +- src/index.ts | 57 +++++++++---------- src/scripts/classes/credentials.ts | 2 +- src/scripts/classes/mapping/platform-user.ts | 6 +- src/scripts/classes/mapping/post.ts | 10 ++-- src/scripts/classes/mapping/thread.ts | 20 +++---- src/scripts/classes/mapping/user-profile.ts | 14 ++--- src/scripts/classes/prefix-parser.ts | 2 +- .../classes/query/handiwork-search-query.ts | 10 ++-- .../classes/query/latest-search-query.ts | 12 ++-- .../classes/query/thread-search-query.ts | 14 ++--- src/scripts/fetch-data/fetch-handiwork.ts | 4 +- src/scripts/fetch-data/fetch-latest.ts | 4 +- src/scripts/fetch-data/fetch-platform-data.ts | 8 +-- src/scripts/fetch-data/fetch-query.ts | 14 ++--- src/scripts/fetch-data/fetch-thread.ts | 8 +-- src/scripts/network-helper.ts | 14 ++--- src/scripts/scrape-data/handiwork-parse.ts | 10 ++-- src/scripts/scrape-data/json-ld.ts | 4 +- src/scripts/search.ts | 6 +- src/scripts/shared.ts | 2 +- 21 files changed, 109 insertions(+), 114 deletions(-) diff --git a/src/example.ts b/src/example.ts index a4fe78e..cde9c79 100644 --- a/src/example.ts +++ b/src/example.ts @@ -27,7 +27,7 @@ import { Game, searchHandiwork, HandiworkSearchQuery -} from "./index.js"; +} from "./index"; // Configure the .env reader dotenv.config(); diff --git a/src/index.ts b/src/index.ts index 65a7637..9cdc8f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,27 +6,22 @@ "use strict"; // Modules from file -import shared from "./scripts/shared.js"; -import search from "./scripts/search.js"; -import { - authenticate, - urlExists, - isF95URL, - send2faCode -} from "./scripts/network-helper.js"; -import fetchLatestHandiworkURLs from "./scripts/fetch-data/fetch-latest.js"; -import fetchPlatformData from "./scripts/fetch-data/fetch-platform-data.js"; -import getHandiworkInformation from "./scripts/scrape-data/handiwork-parse.js"; -import { IBasic } from "./scripts/interfaces.js"; +import shared from "./scripts/shared"; +import search from "./scripts/search"; +import { authenticate, urlExists, isF95URL, send2faCode } from "./scripts/network-helper"; +import fetchLatestHandiworkURLs from "./scripts/fetch-data/fetch-latest"; +import fetchPlatformData from "./scripts/fetch-data/fetch-platform-data"; +import getHandiworkInformation from "./scripts/scrape-data/handiwork-parse"; +import { IBasic } from "./scripts/interfaces"; // Classes from file -import Credentials from "./scripts/classes/credentials.js"; -import LoginResult from "./scripts/classes/login-result.js"; -import UserProfile from "./scripts/classes/mapping/user-profile.js"; -import LatestSearchQuery from "./scripts/classes/query/latest-search-query.js"; -import HandiworkSearchQuery from "./scripts/classes/query/handiwork-search-query.js"; -import HandiWork from "./scripts/classes/handiwork/handiwork.js"; -import { UserNotLogged } from "./scripts/classes/errors.js"; +import Credentials from "./scripts/classes/credentials"; +import LoginResult from "./scripts/classes/login-result"; +import UserProfile from "./scripts/classes/mapping/user-profile"; +import LatestSearchQuery from "./scripts/classes/query/latest-search-query"; +import HandiworkSearchQuery from "./scripts/classes/query/handiwork-search-query"; +import HandiWork from "./scripts/classes/handiwork/handiwork"; +import { UserNotLogged } from "./scripts/classes/errors"; //#region Global variables @@ -36,20 +31,20 @@ const USER_NOT_LOGGED = "User not authenticated, unable to continue"; //#region Re-export classes -export { default as Animation } from "./scripts/classes/handiwork/animation.js"; -export { default as Asset } from "./scripts/classes/handiwork/asset.js"; -export { default as Comic } from "./scripts/classes/handiwork/comic.js"; -export { default as Game } from "./scripts/classes/handiwork/game.js"; -export { default as Handiwork } from "./scripts/classes/handiwork/handiwork.js"; +export { default as Animation } from "./scripts/classes/handiwork/animation"; +export { default as Asset } from "./scripts/classes/handiwork/asset"; +export { default as Comic } from "./scripts/classes/handiwork/comic"; +export { default as Game } from "./scripts/classes/handiwork/game"; +export { default as Handiwork } from "./scripts/classes/handiwork/handiwork"; -export { default as PlatformUser } from "./scripts/classes/mapping/platform-user.js"; -export { default as Post } from "./scripts/classes/mapping/post.js"; -export { default as Thread } from "./scripts/classes/mapping/thread.js"; -export { default as UserProfile } from "./scripts/classes/mapping/user-profile.js"; +export { default as PlatformUser } from "./scripts/classes/mapping/platform-user"; +export { default as Post } from "./scripts/classes/mapping/post"; +export { default as Thread } from "./scripts/classes/mapping/thread"; +export { default as UserProfile } from "./scripts/classes/mapping/user-profile"; -export { default as HandiworkSearchQuery } from "./scripts/classes/query/handiwork-search-query.js"; -export { default as LatestSearchQuery } from "./scripts/classes/query/latest-search-query.js"; -export { default as ThreadSearchQuery } from "./scripts/classes/query/thread-search-query.js"; +export { default as HandiworkSearchQuery } from "./scripts/classes/query/handiwork-search-query"; +export { default as LatestSearchQuery } from "./scripts/classes/query/latest-search-query"; +export { default as ThreadSearchQuery } from "./scripts/classes/query/thread-search-query"; //#endregion Re-export classes diff --git a/src/scripts/classes/credentials.ts b/src/scripts/classes/credentials.ts index 6123deb..7e8abca 100644 --- a/src/scripts/classes/credentials.ts +++ b/src/scripts/classes/credentials.ts @@ -6,7 +6,7 @@ "use strict"; // Modules from file -import { getF95Token } from "../network-helper.js"; +import { getF95Token } from "../network-helper"; /** * Represents the credentials used to access the platform. diff --git a/src/scripts/classes/mapping/platform-user.ts b/src/scripts/classes/mapping/platform-user.ts index 0be0c81..09edb42 100644 --- a/src/scripts/classes/mapping/platform-user.ts +++ b/src/scripts/classes/mapping/platform-user.ts @@ -10,9 +10,9 @@ import cheerio from "cheerio"; import { DateTime } from "luxon"; // Modules from files -import { urls } from "../../constants/url.js"; -import { fetchHTML } from "../../network-helper.js"; -import { GENERIC, MEMBER } from "../../constants/css-selector.js"; +import { urls } from "../../constants/url"; +import { fetchHTML } from "../../network-helper"; +import { GENERIC, MEMBER } from "../../constants/css-selector"; /** * Represents a generic user registered on the platform. diff --git a/src/scripts/classes/mapping/post.ts b/src/scripts/classes/mapping/post.ts index a09ce4c..a630c0d 100644 --- a/src/scripts/classes/mapping/post.ts +++ b/src/scripts/classes/mapping/post.ts @@ -9,11 +9,11 @@ import cheerio from "cheerio"; // Modules from file -import PlatformUser from "./platform-user.js"; -import { IPostElement, parseF95ThreadPost } from "../../scrape-data/post-parse.js"; -import { POST, THREAD } from "../../constants/css-selector.js"; -import { urls } from "../../constants/url.js"; -import { fetchHTML } from "../../network-helper.js"; +import PlatformUser from "./platform-user"; +import { IPostElement, parseF95ThreadPost } from "../../scrape-data/post-parse"; +import { POST, THREAD } from "../../constants/css-selector"; +import { urls } from "../../constants/url"; +import { fetchHTML } from "../../network-helper"; /** * Represents a post published by a user on the F95Zone platform. diff --git a/src/scripts/classes/mapping/thread.ts b/src/scripts/classes/mapping/thread.ts index 9923203..a20740b 100644 --- a/src/scripts/classes/mapping/thread.ts +++ b/src/scripts/classes/mapping/thread.ts @@ -10,20 +10,20 @@ import cheerio from "cheerio"; import { DateTime } from "luxon"; // Modules from files -import Post from "./post.js"; -import PlatformUser from "./platform-user.js"; -import { TCategory, TRating } from "../../interfaces.js"; -import { urls } from "../../constants/url.js"; -import { POST, THREAD } from "../../constants/css-selector.js"; -import { fetchHTML, fetchPOSTResponse } from "../../network-helper.js"; -import Shared from "../../shared.js"; +import Post from "./post"; +import PlatformUser from "./platform-user"; +import { TCategory, TRating } from "../../interfaces"; +import { urls } from "../../constants/url"; +import { POST, THREAD } from "../../constants/css-selector"; +import { fetchHTML, fetchPOSTResponse } from "../../network-helper"; +import Shared from "../../shared"; import { GenericAxiosError, ParameterError, UnexpectedResponseContentType -} from "../errors.js"; -import { Result } from "../result.js"; -import { getJSONLD, TJsonLD } from "../../scrape-data/json-ld.js"; +} from "../errors"; +import { Result } from "../result"; +import { getJSONLD, TJsonLD } from "../../scrape-data/json-ld"; /** * Represents a generic F95Zone platform thread. diff --git a/src/scripts/classes/mapping/user-profile.ts b/src/scripts/classes/mapping/user-profile.ts index 267fd77..308e573 100644 --- a/src/scripts/classes/mapping/user-profile.ts +++ b/src/scripts/classes/mapping/user-profile.ts @@ -9,13 +9,13 @@ import cheerio from "cheerio"; // Modules from files -import Post from "./post.js"; -import PlatformUser from "./platform-user.js"; -import { urls } from "../../constants/url.js"; -import { GENERIC, WATCHED_THREAD } from "../../constants/css-selector.js"; -import { fetchHTML } from "../../network-helper.js"; -import { GenericAxiosError, UnexpectedResponseContentType } from "../errors.js"; -import { Result } from "../result.js"; +import Post from "./post"; +import PlatformUser from "./platform-user"; +import { urls } from "../../constants/url"; +import { GENERIC, WATCHED_THREAD } from "../../constants/css-selector"; +import { fetchHTML } from "../../network-helper"; +import { GenericAxiosError, UnexpectedResponseContentType } from "../errors"; +import { Result } from "../result"; // Interfaces interface IWatchedThread { diff --git a/src/scripts/classes/prefix-parser.ts b/src/scripts/classes/prefix-parser.ts index 0f64776..5d548cf 100644 --- a/src/scripts/classes/prefix-parser.ts +++ b/src/scripts/classes/prefix-parser.ts @@ -6,7 +6,7 @@ "use strict"; // Modules from file -import shared, { TPrefixDict } from "../shared.js"; +import shared, { TPrefixDict } from "../shared"; /** * Convert prefixes and platform tags from string to ID and vice versa. diff --git a/src/scripts/classes/query/handiwork-search-query.ts b/src/scripts/classes/query/handiwork-search-query.ts index 13134bc..e55c328 100644 --- a/src/scripts/classes/query/handiwork-search-query.ts +++ b/src/scripts/classes/query/handiwork-search-query.ts @@ -10,11 +10,11 @@ import { IsInt, Min, validateSync } from "class-validator"; import { AxiosResponse } from "axios"; // Module from files -import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js"; -import { GenericAxiosError } from "../errors.js"; -import { Result } from "../result.js"; -import LatestSearchQuery, { TLatestOrder } from "./latest-search-query.js"; -import ThreadSearchQuery, { TThreadOrder } from "./thread-search-query.js"; +import { IQuery, TCategory, TQueryInterface } from "../../interfaces"; +import { GenericAxiosError } from "../errors"; +import { Result } from "../result"; +import LatestSearchQuery, { TLatestOrder } from "./latest-search-query"; +import ThreadSearchQuery, { TThreadOrder } from "./thread-search-query"; // Type definitions /** diff --git a/src/scripts/classes/query/latest-search-query.ts b/src/scripts/classes/query/latest-search-query.ts index d6d61aa..90ddf26 100644 --- a/src/scripts/classes/query/latest-search-query.ts +++ b/src/scripts/classes/query/latest-search-query.ts @@ -9,13 +9,13 @@ import { ArrayMaxSize, IsInt, Min, validateSync } from "class-validator"; // Modules from file -import { urls } from "../../constants/url.js"; -import PrefixParser from "../prefix-parser.js"; -import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js"; -import { fetchGETResponse } from "../../network-helper.js"; +import { urls } from "../../constants/url"; +import PrefixParser from "../prefix-parser"; +import { IQuery, TCategory, TQueryInterface } from "../../interfaces"; +import { fetchGETResponse } from "../../network-helper"; import { AxiosResponse } from "axios"; -import { GenericAxiosError } from "../errors.js"; -import { Result } from "../result.js"; +import { GenericAxiosError } from "../errors"; +import { Result } from "../result"; // Type definitions export type TLatestOrder = "date" | "likes" | "views" | "title" | "rating"; diff --git a/src/scripts/classes/query/thread-search-query.ts b/src/scripts/classes/query/thread-search-query.ts index 6f1d83d..cfa8308 100644 --- a/src/scripts/classes/query/thread-search-query.ts +++ b/src/scripts/classes/query/thread-search-query.ts @@ -9,14 +9,14 @@ import { IsInt, Min, validateSync } from "class-validator"; // Module from files -import { IQuery, TCategory, TQueryInterface } from "../../interfaces.js"; -import { urls } from "../../constants/url.js"; -import PrefixParser from "./../prefix-parser.js"; -import { fetchPOSTResponse } from "../../network-helper.js"; +import { IQuery, TCategory, TQueryInterface } from "../../interfaces"; +import { urls } from "../../constants/url"; +import PrefixParser from "./../prefix-parser"; +import { fetchPOSTResponse } from "../../network-helper"; import { AxiosResponse } from "axios"; -import { GenericAxiosError } from "../errors.js"; -import { Result } from "../result.js"; -import Shared from "../../shared.js"; +import { GenericAxiosError } from "../errors"; +import { Result } from "../result"; +import Shared from "../../shared"; // Type definitions export type TThreadOrder = "relevance" | "date" | "last_update" | "replies"; diff --git a/src/scripts/fetch-data/fetch-handiwork.ts b/src/scripts/fetch-data/fetch-handiwork.ts index 41c1d13..d3b37bd 100644 --- a/src/scripts/fetch-data/fetch-handiwork.ts +++ b/src/scripts/fetch-data/fetch-handiwork.ts @@ -9,8 +9,8 @@ import HandiworkSearchQuery from "../classes/query/handiwork-search-query"; import LatestSearchQuery from "../classes/query/latest-search-query"; import ThreadSearchQuery from "../classes/query/thread-search-query"; -import fetchLatestHandiworkURLs from "./fetch-latest.js"; -import fetchThreadHandiworkURLs from "./fetch-thread.js"; +import fetchLatestHandiworkURLs from "./fetch-latest"; +import fetchThreadHandiworkURLs from "./fetch-thread"; /** * Gets the URLs of the handiworks that match the passed parameters. diff --git a/src/scripts/fetch-data/fetch-latest.ts b/src/scripts/fetch-data/fetch-latest.ts index ca89d04..63d6b46 100644 --- a/src/scripts/fetch-data/fetch-latest.ts +++ b/src/scripts/fetch-data/fetch-latest.ts @@ -6,8 +6,8 @@ "use strict"; // Modules from file -import LatestSearchQuery from "../classes/query/latest-search-query.js"; -import { urls } from "../constants/url.js"; +import LatestSearchQuery from "../classes/query/latest-search-query"; +import { urls } from "../constants/url"; /** * Gets the URLs of the latest handiworks that match the passed parameters. diff --git a/src/scripts/fetch-data/fetch-platform-data.ts b/src/scripts/fetch-data/fetch-platform-data.ts index 8105d5c..b60c24e 100644 --- a/src/scripts/fetch-data/fetch-platform-data.ts +++ b/src/scripts/fetch-data/fetch-platform-data.ts @@ -12,10 +12,10 @@ import { readFileSync, writeFileSync, existsSync } from "fs"; import cheerio from "cheerio"; // Modules from file -import shared, { TPrefixDict } from "../shared.js"; -import { urls as f95url } from "../constants/url.js"; -import { GENERIC } from "../constants/css-selector.js"; -import { fetchHTML } from "../network-helper.js"; +import shared, { TPrefixDict } from "../shared"; +import { urls as f95url } from "../constants/url"; +import { GENERIC } from "../constants/css-selector"; +import { fetchHTML } from "../network-helper"; //#region Interface definitions diff --git a/src/scripts/fetch-data/fetch-query.ts b/src/scripts/fetch-data/fetch-query.ts index d8b1fbc..0b43f56 100644 --- a/src/scripts/fetch-data/fetch-query.ts +++ b/src/scripts/fetch-data/fetch-query.ts @@ -6,13 +6,13 @@ "use strict"; // Modules from files -import fetchHandiworkURLs from "./fetch-handiwork.js"; -import fetchLatestHandiworkURLs from "./fetch-latest.js"; -import fetchThreadHandiworkURLs from "./fetch-thread.js"; -import HandiworkSearchQuery from "../classes/query/handiwork-search-query.js"; -import LatestSearchQuery from "../classes/query/latest-search-query.js"; -import ThreadSearchQuery from "../classes/query/thread-search-query.js"; -import { IQuery } from "../interfaces.js"; +import fetchHandiworkURLs from "./fetch-handiwork"; +import fetchLatestHandiworkURLs from "./fetch-latest"; +import fetchThreadHandiworkURLs from "./fetch-thread"; +import HandiworkSearchQuery from "../classes/query/handiwork-search-query"; +import LatestSearchQuery from "../classes/query/latest-search-query"; +import ThreadSearchQuery from "../classes/query/thread-search-query"; +import { IQuery } from "../interfaces"; //#region Public methods diff --git a/src/scripts/fetch-data/fetch-thread.ts b/src/scripts/fetch-data/fetch-thread.ts index 317bfe8..8b25cba 100644 --- a/src/scripts/fetch-data/fetch-thread.ts +++ b/src/scripts/fetch-data/fetch-thread.ts @@ -9,10 +9,10 @@ import cheerio from "cheerio"; // Modules from file -import shared from "../shared.js"; -import { THREAD_SEARCH } from "../constants/css-selector.js"; -import { urls as f95urls } from "../constants/url.js"; -import ThreadSearchQuery from "../classes/query/thread-search-query.js"; +import shared from "../shared"; +import { THREAD_SEARCH } from "../constants/css-selector"; +import { urls as f95urls } from "../constants/url"; +import ThreadSearchQuery from "../classes/query/thread-search-query"; //#region Public methods diff --git a/src/scripts/network-helper.ts b/src/scripts/network-helper.ts index 04e5720..f672411 100644 --- a/src/scripts/network-helper.ts +++ b/src/scripts/network-helper.ts @@ -11,17 +11,17 @@ import cheerio from "cheerio"; import axiosCookieJarSupport from "axios-cookiejar-support"; // Modules from file -import shared from "./shared.js"; -import { urls } from "./constants/url.js"; -import { GENERIC } from "./constants/css-selector.js"; -import LoginResult from "./classes/login-result.js"; -import { failure, Result, success } from "./classes/result.js"; +import shared from "./shared"; +import { urls } from "./constants/url"; +import { GENERIC } from "./constants/css-selector"; +import LoginResult from "./classes/login-result"; +import { failure, Result, success } from "./classes/result"; import { GenericAxiosError, InvalidF95Token, UnexpectedResponseContentType -} from "./classes/errors.js"; -import Credentials from "./classes/credentials.js"; +} from "./classes/errors"; +import Credentials from "./classes/credentials"; // Configure axios to use the cookie jar axiosCookieJarSupport(axios); diff --git a/src/scripts/scrape-data/handiwork-parse.ts b/src/scripts/scrape-data/handiwork-parse.ts index 23b5227..9f79d34 100644 --- a/src/scripts/scrape-data/handiwork-parse.ts +++ b/src/scripts/scrape-data/handiwork-parse.ts @@ -9,11 +9,11 @@ import { DateTime } from "luxon"; // Modules from files -import HandiWork from "../classes/handiwork/handiwork.js"; -import Thread from "../classes/mapping/thread.js"; -import { IBasic, TAuthor, TEngine, TExternalPlatform, TStatus } from "../interfaces.js"; -import shared, { TPrefixDict } from "../shared.js"; -import { ILink, IPostElement } from "./post-parse.js"; +import HandiWork from "../classes/handiwork/handiwork"; +import Thread from "../classes/mapping/thread"; +import { IBasic, TAuthor, TEngine, TExternalPlatform, TStatus } from "../interfaces"; +import shared, { TPrefixDict } from "../shared"; +import { ILink, IPostElement } from "./post-parse"; export async function getHandiworkInformation(url: string): Promise; diff --git a/src/scripts/scrape-data/json-ld.ts b/src/scripts/scrape-data/json-ld.ts index b04efd2..360492a 100644 --- a/src/scripts/scrape-data/json-ld.ts +++ b/src/scripts/scrape-data/json-ld.ts @@ -9,8 +9,8 @@ import cheerio from "cheerio"; // Modules from file -import shared from "../shared.js"; -import { THREAD } from "../constants/css-selector.js"; +import shared from "../shared"; +import { THREAD } from "../constants/css-selector"; /** * Represents information contained in a JSON+LD tag. diff --git a/src/scripts/search.ts b/src/scripts/search.ts index 789f1e4..e74fbfc 100644 --- a/src/scripts/search.ts +++ b/src/scripts/search.ts @@ -7,9 +7,9 @@ "use strict"; // Modules from file -import { IBasic, IQuery } from "./interfaces.js"; -import getHandiworkInformation from "./scrape-data/handiwork-parse.js"; -import getURLsFromQuery from "./fetch-data/fetch-query.js"; +import { IBasic, IQuery } from "./interfaces"; +import getHandiworkInformation from "./scrape-data/handiwork-parse"; +import getURLsFromQuery from "./fetch-data/fetch-query"; /** * Gets the handiworks that match the passed parameters. diff --git a/src/scripts/shared.ts b/src/scripts/shared.ts index 876b324..a2c696f 100644 --- a/src/scripts/shared.ts +++ b/src/scripts/shared.ts @@ -14,7 +14,7 @@ import { join } from "path"; import log4js from "log4js"; // Modules from file -import Session from "./classes/session.js"; +import Session from "./classes/session"; // Types declaration export type TPrefixDict = { [n: number]: string };