Skip to content

Commit

Permalink
🌪️ Before the disaster
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Oct 14, 2024
1 parent 3cc8f8c commit 25051e2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 29 deletions.
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"@babel/cli": "^7.24.7",
"@babel/core": "^7.24.7",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@babel/plugin-transform-async-generator-functions": "^7.24.7",
"@babel/plugin-transform-async-to-generator": "^7.24.7",
"@babel/plugin-transform-modules-commonjs": "^7.24.7",
"@babel/preset-env": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@types/babel__core": "^7.20.5",
Expand All @@ -54,21 +58,29 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/socket.io-client": "^3.0.0",
"@yao-pkg/pkg": "^5.11.2",
"bytes-formatter": "^21.6.12",
"chokidar": "^3.6.0",
"cli-progress": "^3.12.0",
"concurrently": "^8.2.2",
"concurrently": "^9.0.1",
"esbuild": "^0.21.3",
"esbuild-node-externals": "^1.13.1",
"figlet": "^1.7.0",
"fs-extra": "^11.2.0",
"glob": "^10.3.15",
"glob": "^11.0.0",
"gradient-string": "^2.0.2",
"javascript-obfuscator": "^4.1.0",
"node-fetch": "^3.3.2",
"prompts": "^2.4.2",
"randomstring": "^1.3.0",
"rollup": "^4.18.0",
"rollup-plugin-esbuild": "^6.1.1",
"rollup-plugin-node-externals": "^7.1.2",
"rollup-plugin-typescript-paths": "^1.5.0",
"socket.io-client": "^4.7.5",
"sucrase": "^3.34.0",
"terser": "^5.31.1",
Expand All @@ -77,5 +89,8 @@
"tsconfig-paths": "^4.2.0",
"tscpaths": "^0.0.9",
"yargs": "^17.7.2"
},
"engines": {
"node": "20.x"
}
}
1 change: 0 additions & 1 deletion plugins/plugin_base/src/discord/base/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class Discord {
this.timestamp = Date.now()

const onAutoComplete = (autoCompleteInteraction: AutocompleteInteraction): void => {
console.log(autoCompleteInteraction.commandName)
if (autoCompleteInteraction.commandName === 'config') {
const config = Config.all.find((config) => config.name === autoCompleteInteraction.options.getSubcommand())
if (config?.autoComplete !== undefined) config.autoComplete(autoCompleteInteraction)
Expand Down
1 change: 0 additions & 1 deletion plugins/tickets/src/discord/base/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class Discord {
this.timestamp = Date.now()

const onAutoComplete = (autoCompleteInteraction: AutocompleteInteraction): void => {
console.log(autoCompleteInteraction.commandName)
if (autoCompleteInteraction.commandName === 'config') {
const config = Config.all.find((config) => config.name === autoCompleteInteraction.options.getSubcommand())
if (config?.autoComplete !== undefined) config.autoComplete(autoCompleteInteraction)
Expand Down
1 change: 0 additions & 1 deletion plugins/utils/src/discord/base/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class Discord {
this.timestamp = Date.now()

const onAutoComplete = (autoCompleteInteraction: AutocompleteInteraction): void => {
console.log(autoCompleteInteraction.commandName)
if (autoCompleteInteraction.commandName === 'config') {
const config = Config.all.find((config) => config.name === autoCompleteInteraction.options.getSubcommand())
if (config?.autoComplete !== undefined) config.autoComplete(autoCompleteInteraction)
Expand Down
63 changes: 57 additions & 6 deletions release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ import obfuscate from 'javascript-obfuscator'
import os from 'os'
import path, { basename, dirname, join } from 'path'
import { cwd } from 'process'
import { rollup } from 'rollup'
import { Readable } from 'stream'
import { minify } from 'terser'

import communjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import esbuild from "rollup-plugin-esbuild"
import externals from "rollup-plugin-node-externals"
import { typescriptPaths } from "rollup-plugin-typescript-paths"

const SIGNATURE_LENGTH = 512

interface BuildInfo {
Expand Down Expand Up @@ -147,9 +155,18 @@ class Build {
const data = await readFile(file, { encoding: 'utf-8' })
const result = await babel.transformAsync(data, {
presets: ["@babel/preset-env", "@babel/preset-typescript"],
plugins: !file.includes('node_modules') ? ["babel-plugin-transform-import-meta", "@babel/plugin-transform-modules-commonjs", "@babel/plugin-syntax-dynamic-import"] : [['babel-plugin-cjs-esm-interop', { format: 'cjs' }]],
plugins: !file.includes('node_modules')
? [
"babel-plugin-transform-import-meta",
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-transform-async-generator-functions",
"@babel/plugin-syntax-top-level-await"
]
: [
['babel-plugin-cjs-esm-interop', { format: 'cjs' }]
],
filename: fileName,

});

if (typeof result?.code !== 'string') continue
Expand Down Expand Up @@ -268,6 +285,9 @@ class Build {
"node_modules/**/*.node"
]
}
packageJson.engines = {
node: "20.x"
}

const remove = ['devDependencies', 'scripts', 'keywords', 'repository', 'bugs', 'homepage', 'type']

Expand All @@ -280,7 +300,7 @@ class Build {
async install(): Promise<void> {
console.debug('\n\nInstalando Modulos...')
if (existsSync(`${this.options.outBuild}/node_modules`)) execProcess(`cd ${this.options.outBuild} && rm -r node_modules`)
await execProcess(`cd ${this.options.outBuild} && npm i && npm rebuild better_sqlite3 && npm rebuild`)
await execProcess(`cd ${this.options.outBuild} && bun i`)
}

async clear(): Promise<void> {
Expand All @@ -299,18 +319,43 @@ class Build {
this.progressBar.stop()
}

async rollup() {
const bundle = await rollup({
input: await glob(`${this.options.source}/build/esm/**/*.js`, { ignore: ['**/node_modules/**/*'] }),
logLevel: 'debug',
plugins: [
esbuild({ target: 'node20' }),
typescriptPaths({ preserveExtensions: false }),
communjs(),
json(),
externals(),
nodeResolve()
]
})

bundle.write({
dir: 'dist',
format: 'cjs',
exports: 'named',
compact: true,
esModule: false,
dynamicImportInCjs: true,
noConflict: true,
preserveModules: true,
})
}

async esbuild(options?: { entryPoints: string[], outfile: string }) {
const packagePath = path.join(process.cwd(), `${this.options.outBuild}/package.json`)
const packageJson = JSON.parse(await readFile(packagePath, { encoding: 'utf-8' })) as Record<string, string | object | null>
await build({
entryPoints: options?.entryPoints ?? [`${this.options.outBuild}/src/app.js`],
bundle: true,
minify: true,
logLevel: 'silent',
logLevel: 'debug',
outfile: options?.outfile ?? `${this.options.outBuild}/bundle.cjs`,
platform: 'node',
format: 'cjs'
// plugins: []
format: 'cjs',
})
await rm(path.join(process.cwd(), `${this.options.outBuild}/node_modules`), { recursive: true })
await rm(path.join(process.cwd(), `${this.options.outBuild}/src`), { recursive: true })
Expand All @@ -325,6 +370,7 @@ class Build {
})
}


async pkgbuild(): Promise<void> {
const args = ['.', '--compress', 'Brotli', '--no-bytecode', '--public-packages', '"*"', '--public']
const builds: string[] = []
Expand Down Expand Up @@ -456,6 +502,7 @@ const archs = ['arm64', 'x64'];
{ command: 'compress', alias: ['-c'], rank: 5 },
{ command: 'obfuscate', alias: ['-f'], rank: 6 },
{ command: 'esbuild', alias: ['-esb'], rank: 7 },
{ command: 'rollup', alias: [''], rank: 7 },
{ command: 'pkg', alias: [''], rank: 7 },
{ command: 'sing', alias: ['-sn'], rank: 8 },
]
Expand Down Expand Up @@ -650,6 +697,10 @@ release [options] <input>
buildFunctions.push(async () => { await build.sign(); await build.singCheck() })
break
}
case 'rollup': {
buildFunctions.push(() => build.rollup())
break
}
}
}
if (newArgs.find((arg) => arg.command === 'pkg')?.command !== undefined) buildFunctions.push(() => build.saveManifest())
Expand Down
18 changes: 0 additions & 18 deletions test.ts

This file was deleted.

0 comments on commit 25051e2

Please sign in to comment.