Archived
0
0
Fork 0

build: fix production build not detecting command

This commit is contained in:
Daryl Ronningen 2021-06-20 06:07:32 -07:00
parent 15e55c1349
commit 6fc680136d
Signed by: Daryl Ronningen
GPG key ID: FD23F0C934A5EC6B
5 changed files with 61 additions and 6 deletions

View file

@ -16,7 +16,7 @@
"scripts": { "scripts": {
"clean": "rimraf dist", "clean": "rimraf dist",
"compile:dev": "tsc", "compile:dev": "tsc",
"compile:prod": "rollup -c --compact && yarn compile:dev && cp -r dist/src/commands dist/commands && rimraf dist/src", "compile:prod": "rollup -c --compact",
"commit": "commit", "commit": "commit",
"coverage": "NODE_CONFIG_ENV=tests nyc yarn run test", "coverage": "NODE_CONFIG_ENV=tests nyc yarn run test",
"lint": "eslint --format=pretty src/**/*.ts", "lint": "eslint --format=pretty src/**/*.ts",
@ -87,6 +87,7 @@
"nyc": "^15.1.0", "nyc": "^15.1.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rollup": "^2.52.1", "rollup": "^2.52.1",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"sinon": "^11.1.1", "sinon": "^11.1.1",
"standard-version": "^9.3.0", "standard-version": "^9.3.0",

View file

@ -17,9 +17,10 @@
import typescript from '@rollup/plugin-typescript'; import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json';
import { terser } from 'rollup-plugin-terser'; import { terser } from 'rollup-plugin-terser';
import multiInput from 'rollup-plugin-multi-input';
export default { export default {
input: 'src/index.ts', input: ['src/index.ts', 'src/commands/**/*.ts'],
output: { output: {
dir: 'dist', dir: 'dist',
format: 'cjs', format: 'cjs',
@ -28,5 +29,6 @@ export default {
typescript({ module: 'ESNext', include: ['src/**/*.ts', '*.json'] }), typescript({ module: 'ESNext', include: ['src/**/*.ts', '*.json'] }),
json({ compact: true, preferConst: true }), json({ compact: true, preferConst: true }),
terser(), terser(),
multiInput(),
], ],
}; };

29
src/commands/utils/vm.ts Normal file
View file

@ -0,0 +1,29 @@
/*
* This file is part of ArgonBot
*
* ArgonBot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ArgonBot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
*/
import Command from '@structures/command';
import type { Client } from 'discord.js';
export class vm extends Command {
public constructor(client: Client) {
super(client);
}
public run(): void {
console.log('Test');
}
}

View file

@ -14,6 +14,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>. * along with ArgonBot. If not, see <https: //www.gnu.org/licenses/>.
*/ */
import path from 'path';
require('module-alias/register'); require('module-alias/register');
import process from 'process'; import process from 'process';
@ -108,9 +110,11 @@ client.on('ready', async () => {
files?.forEach((file) => { files?.forEach((file) => {
if(file.endsWith('js')) { if(file.endsWith('js')) {
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
const fileCommand = require(file).default; const fileCommand = require(file);
const command = new fileCommand(); console.log(fileCommand);
const command = new fileCommand[path.basename(file, path.extname(file))]();
commands.set(command.options.name, command); commands.set(command.options.name, command);

View file

@ -1576,6 +1576,7 @@ __metadata:
nyc: ^15.1.0 nyc: ^15.1.0
rimraf: ^3.0.2 rimraf: ^3.0.2
rollup: ^2.52.1 rollup: ^2.52.1
rollup-plugin-multi-input: ^1.3.1
rollup-plugin-terser: ^7.0.2 rollup-plugin-terser: ^7.0.2
sinon: ^11.1.1 sinon: ^11.1.1
sodium: ^3.0.2 sodium: ^3.0.2
@ -2536,6 +2537,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"core-js@npm:^3.1.3":
version: 3.14.0
resolution: "core-js@npm:3.14.0"
checksum: a450089e5796496c7f4a84b13139d853fec5233077833ed142fe401bf9ff4ec2a5bae781f3879ef76cefcfe8a274218d3d4d7d813f5f7f32911fbd36e13a6dc4
languageName: node
linkType: hard
"core-util-is@npm:^1.0.2, core-util-is@npm:~1.0.0": "core-util-is@npm:^1.0.2, core-util-is@npm:~1.0.0":
version: 1.0.2 version: 1.0.2
resolution: "core-util-is@npm:1.0.2" resolution: "core-util-is@npm:1.0.2"
@ -3240,7 +3248,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"fast-glob@npm:^3.1.1, fast-glob@npm:^3.2.2": "fast-glob@npm:^3.0.0, fast-glob@npm:^3.1.1, fast-glob@npm:^3.2.2":
version: 3.2.5 version: 3.2.5
resolution: "fast-glob@npm:3.2.5" resolution: "fast-glob@npm:3.2.5"
dependencies: dependencies:
@ -4862,7 +4870,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.21, lodash@npm:^4.5.1": "lodash@npm:^4.17.11, lodash@npm:^4.17.15, lodash@npm:^4.17.19, lodash@npm:^4.17.21, lodash@npm:^4.5.1":
version: 4.17.21 version: 4.17.21
resolution: "lodash@npm:4.17.21" resolution: "lodash@npm:4.17.21"
checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7
@ -6580,6 +6588,17 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"rollup-plugin-multi-input@npm:^1.3.1":
version: 1.3.1
resolution: "rollup-plugin-multi-input@npm:1.3.1"
dependencies:
core-js: ^3.1.3
fast-glob: ^3.0.0
lodash: ^4.17.11
checksum: b4e3288ac5173b8e7ec236a8ae6fd20110d90a22b51ea7eb89034e7011615edd3d55e018ba684af1fbb04bcaa469398b4913b21a18517417e40895e14ff8a503
languageName: node
linkType: hard
"rollup-plugin-terser@npm:^7.0.2": "rollup-plugin-terser@npm:^7.0.2":
version: 7.0.2 version: 7.0.2
resolution: "rollup-plugin-terser@npm:7.0.2" resolution: "rollup-plugin-terser@npm:7.0.2"