Skip to content

Commit

Permalink
updated bot.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed May 1, 2024
1 parent a903b7b commit 2079075
Show file tree
Hide file tree
Showing 80 changed files with 171 additions and 291 deletions.
13 changes: 9 additions & 4 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetch from "axios"
import gulp from "gulp"
import esbuild from "gulp-esbuild"
import filter from "gulp-filter"
Expand Down Expand Up @@ -42,7 +41,7 @@ function _cleanTemp() {

function _checkGulpfile(cb) {
fetch("https://raw.githubusercontent.com/bot-ts/framework/master/Gulpfile.js")
.then((res) => res.data)
.then((res) => res.text())
.then(async (remote) => {
const local = await fs.promises.readFile(
path.join(__dirname, "Gulpfile.js"),
Expand Down Expand Up @@ -134,13 +133,14 @@ function _copyConfig() {
.pipe(gulp.dest(__dirname, { overwrite: false }))
}

function _updateDependencies(cb) {
function _updatePackageJSON(cb) {
const localPackageJSON = JSON.parse(fs.readFileSync("./package.json", "utf8"))
const remotePackageJSON = JSON.parse(
fs.readFileSync("./temp/package.json", "utf8"),
)

localPackageJSON.main = remotePackageJSON.main
localPackageJSON.type = remotePackageJSON.type
localPackageJSON.version = remotePackageJSON.version

localPackageJSON.engines = {
Expand All @@ -153,6 +153,11 @@ function _updateDependencies(cb) {
...remotePackageJSON.scripts,
}

localPackageJSON.imports = {
...localPackageJSON.imports,
...remotePackageJSON.imports,
}

for (const baseKey of ["dependencies", "devDependencies"]) {
const dependencies = localPackageJSON[baseKey]
const newDependencies = remotePackageJSON[baseKey]
Expand Down Expand Up @@ -269,7 +274,7 @@ export const update = gulp.series(
_copyTemp,
_copyConfig,
_removeDuplicates,
_updateDependencies,
_updatePackageJSON,
_updateDatabaseFile,
_gitLog,
_cleanTemp,
Expand Down
40 changes: 26 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"regex-parser": "^2.2.11",
"simple-git": "^3.24.0",
"tims": "^2.1.0",
"types-package-json": "^2.0.39",
"yargs-parser": "^21.0.1"
},
"devDependencies": {
Expand All @@ -69,12 +70,11 @@
"@types/figlet": "^1.5.4",
"@types/gulp-filter": "^3.0.34",
"@types/gulp-rename": "^2.0.1",
"@types/node": "^18.15.11",
"@types/node": "^20.12.7",
"@types/prettier": "^2.6.3",
"@types/vinyl-paths": "^0.0.31",
"@types/ws": "^8.5.3",
"@types/yargs-parser": "^21.0.0",
"axios": "^0.27.2",
"del": "^6.1.1",
"dirname-filename-esm": "^1.1.1",
"discord-api-types": "^0.36.1",
Expand All @@ -95,5 +95,8 @@
"node": ">=20.x.x",
"npm": ">=9.x.x",
"git": ">=2.x.x"
},
"imports": {
"#app": "./dist/app.js"
}
}
92 changes: 0 additions & 92 deletions src/app/core.ts

This file was deleted.

59 changes: 0 additions & 59 deletions src/app/handler.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/app/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ export abstract class Paginator {

export class DynamicPaginator extends Paginator {
constructor(
public readonly options: PaginatorOptions & DynamicPaginatorOptions,
public override readonly options: PaginatorOptions &
DynamicPaginatorOptions,
) {
super(options)
}
Expand All @@ -291,7 +292,7 @@ export class DynamicPaginator extends Paginator {

export class StaticPaginator extends Paginator {
constructor(
public readonly options: PaginatorOptions & StaticPaginatorOptions,
public override readonly options: PaginatorOptions & StaticPaginatorOptions,
) {
super(options)

Expand Down
15 changes: 8 additions & 7 deletions src/app/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import dayjs from "dayjs"
import discord from "discord.js"
import prettify from "ghom-prettify"
import * as prettier from "prettier"
import axios from "axios"
import chalk from "chalk"
import EventEmitter from "events"
import simpleGit from "simple-git"

import type { PackageJson } from "types-package-json"

import v10 from "discord-api-types/v10"
import utc from "dayjs/plugin/utc.js"
import relative from "dayjs/plugin/relativeTime.js"
Expand All @@ -25,11 +26,9 @@ export type PermissionsNames = keyof typeof v10.PermissionFlagsBits

export async function checkUpdates() {
// fetch latest bot.ts codebase
const remoteJSON = await axios
.get(
"https://raw.githubusercontent.com/bot-ts/framework/master/package.json",
)
.then((res) => res.data)
const remoteJSON: PackageJson = await fetch(
"https://raw.githubusercontent.com/bot-ts/framework/master/package.json",
).then((res) => res.json() as any)

const versionValue = (version: string): number => {
const [, major, minor, patch] = /(\d+)\.(\d+)\.(\d+)/
Expand Down Expand Up @@ -58,6 +57,8 @@ export async function checkUpdates() {
)
logger.warn(chalk.bold(`this update may break your bot!`))
} else if (
packageJSON.devDependencies &&
remoteJSON.devDependencies &&
isOlder(
packageJSON.devDependencies["@ghom/bot.ts-cli"],
remoteJSON.devDependencies["@ghom/bot.ts-cli"],
Expand Down Expand Up @@ -128,7 +129,7 @@ export function fullPath(..._path: string[]): string {

export const packageJSON = JSON.parse(
fs.readFileSync(fullPath("package.json"), "utf-8"),
)
) as PackageJson

export const startedAt = Date.now()

Expand Down
Loading

0 comments on commit 2079075

Please sign in to comment.