commandkit 0.1.6-dev.20231207091249 → 0.1.6-dev.20231207113539
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/build.mjs +2 -2
- package/bin/common.mjs +1 -1
- package/bin/development.mjs +3 -3
- package/bin/index.mjs +1 -1
- package/bin/production.mjs +2 -2
- package/dist/index.js +29 -14
- package/dist/index.mjs +29 -14
- package/package.json +1 -1
package/bin/build.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
import { appendFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
3
5
|
import { build } from 'tsup';
|
|
4
6
|
import { Colors, erase, findCommandKitConfig, panic, write } from './common.mjs';
|
|
5
7
|
import ora from 'ora';
|
|
6
|
-
import { appendFile } from 'node:fs/promises';
|
|
7
|
-
import { join } from 'node:path';
|
|
8
8
|
|
|
9
9
|
export async function bootstrapProductionBuild(config) {
|
|
10
10
|
const {
|
package/bin/common.mjs
CHANGED
package/bin/development.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { config as dotenv } from 'dotenv';
|
|
3
|
-
import { build } from 'tsup';
|
|
4
|
-
import child_process from 'node:child_process';
|
|
5
|
-
import ora from 'ora';
|
|
6
3
|
import { join } from 'node:path';
|
|
4
|
+
import { build } from 'tsup';
|
|
7
5
|
import { Colors, erase, findCommandKitConfig, panic, write } from './common.mjs';
|
|
8
6
|
import { parseEnv } from './parse-env.mjs';
|
|
7
|
+
import child_process from 'node:child_process';
|
|
8
|
+
import ora from 'ora';
|
|
9
9
|
|
|
10
10
|
const RESTARTING_MSG_PATTERN = /^Restarting '|".+'|"\n?$/;
|
|
11
11
|
const FAILED_RUNNING_PATTERN = /^Failed running '.+'|"\n?$/;
|
package/bin/index.mjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Command } from 'commander';
|
|
6
6
|
import { bootstrapDevelopmentServer } from './development.mjs';
|
|
7
|
-
import { bootstrapProductionBuild } from './build.mjs';
|
|
8
7
|
import { bootstrapProductionServer } from './production.mjs';
|
|
8
|
+
import { bootstrapProductionBuild } from './build.mjs';
|
|
9
9
|
|
|
10
10
|
const program = new Command('commandkit');
|
|
11
11
|
|
package/bin/production.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { config as dotenv } from 'dotenv';
|
|
3
|
-
import
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { Colors, findCommandKitConfig, panic, write } from './common.mjs';
|
|
6
|
-
import { existsSync } from 'node:fs';
|
|
7
6
|
import { parseEnv } from './parse-env.mjs';
|
|
7
|
+
import child_process from 'node:child_process';
|
|
8
8
|
|
|
9
9
|
export async function bootstrapProductionServer(config) {
|
|
10
10
|
const {
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,10 @@ async function getFolderPaths(directory, nesting) {
|
|
|
82
82
|
return folderPaths;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
// src/utils/clone.ts
|
|
86
|
+
var import_rfdc = __toESM(require("rfdc"));
|
|
87
|
+
var clone = (0, import_rfdc.default)();
|
|
88
|
+
|
|
85
89
|
// src/utils/colors.ts
|
|
86
90
|
var resetColor = "\x1B[0m";
|
|
87
91
|
var colors_default = {
|
|
@@ -464,10 +468,6 @@ function permissions_default({ interaction, targetCommand }) {
|
|
|
464
468
|
// src/handlers/command-handler/validations/index.ts
|
|
465
469
|
var validations_default = [devOnly_default, permissions_default];
|
|
466
470
|
|
|
467
|
-
// src/utils/clone.ts
|
|
468
|
-
var import_rfdc = __toESM(require("rfdc"));
|
|
469
|
-
var clone = (0, import_rfdc.default)();
|
|
470
|
-
|
|
471
471
|
// src/handlers/command-handler/CommandHandler.ts
|
|
472
472
|
var CommandHandler = class {
|
|
473
473
|
#data;
|
|
@@ -480,7 +480,7 @@ var CommandHandler = class {
|
|
|
480
480
|
}
|
|
481
481
|
async init() {
|
|
482
482
|
await this.#buildCommands();
|
|
483
|
-
this.#
|
|
483
|
+
this.#buildBuiltInValidations();
|
|
484
484
|
const devOnlyCommands = this.#data.commands.filter((cmd) => cmd.options?.devOnly);
|
|
485
485
|
if (devOnlyCommands.length && !this.#data.devGuildIds.length) {
|
|
486
486
|
console.log(
|
|
@@ -572,9 +572,9 @@ var CommandHandler = class {
|
|
|
572
572
|
this.#data.commands.push(commandObj);
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
|
-
#
|
|
576
|
-
for (const
|
|
577
|
-
this.#data.builtInValidations.push(
|
|
575
|
+
#buildBuiltInValidations() {
|
|
576
|
+
for (const builtInValidationFunction of validations_default) {
|
|
577
|
+
this.#data.builtInValidations.push(builtInValidationFunction);
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
handleCommands() {
|
|
@@ -640,6 +640,11 @@ var CommandHandler = class {
|
|
|
640
640
|
return this.#data.commands;
|
|
641
641
|
}
|
|
642
642
|
async reloadCommands(type) {
|
|
643
|
+
if (!this.#data.commandsPath) {
|
|
644
|
+
throw new Error(
|
|
645
|
+
'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
|
|
646
|
+
);
|
|
647
|
+
}
|
|
643
648
|
this.#data.commands = [];
|
|
644
649
|
await this.#buildCommands();
|
|
645
650
|
if (this.#data.bulkRegister) {
|
|
@@ -660,8 +665,6 @@ var CommandHandler = class {
|
|
|
660
665
|
});
|
|
661
666
|
}
|
|
662
667
|
}
|
|
663
|
-
async useUpdatedValidations() {
|
|
664
|
-
}
|
|
665
668
|
};
|
|
666
669
|
|
|
667
670
|
// src/handlers/event-handler/EventHandler.ts
|
|
@@ -730,6 +733,11 @@ var EventHandler = class {
|
|
|
730
733
|
return this.#data.events;
|
|
731
734
|
}
|
|
732
735
|
async reloadEvents(commandHandler) {
|
|
736
|
+
if (!this.#data.eventsPath) {
|
|
737
|
+
throw new Error(
|
|
738
|
+
'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
|
|
739
|
+
);
|
|
740
|
+
}
|
|
733
741
|
this.#data.events = [];
|
|
734
742
|
await this.#buildEvents();
|
|
735
743
|
this.#data.client.removeAllListeners();
|
|
@@ -748,12 +756,13 @@ var ValidationHandler = class {
|
|
|
748
756
|
};
|
|
749
757
|
}
|
|
750
758
|
async init() {
|
|
751
|
-
await this.#buildValidations();
|
|
759
|
+
this.#data.validations = await this.#buildValidations();
|
|
752
760
|
}
|
|
753
761
|
async #buildValidations() {
|
|
754
762
|
const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
|
|
755
763
|
const validationPaths = await getFilePaths(this.#data.validationsPath, true);
|
|
756
764
|
const validationFilePaths = validationPaths.filter((path3) => allowedExtensions.test(path3));
|
|
765
|
+
const validationFunctions = [];
|
|
757
766
|
for (const validationFilePath of validationFilePaths) {
|
|
758
767
|
const modulePath = toFileURL(validationFilePath);
|
|
759
768
|
let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
|
|
@@ -773,15 +782,21 @@ var ValidationHandler = class {
|
|
|
773
782
|
);
|
|
774
783
|
continue;
|
|
775
784
|
}
|
|
776
|
-
|
|
785
|
+
validationFunctions.push(validationFunction);
|
|
777
786
|
}
|
|
787
|
+
return validationFunctions;
|
|
778
788
|
}
|
|
779
789
|
get validations() {
|
|
780
790
|
return this.#data.validations;
|
|
781
791
|
}
|
|
782
792
|
async reloadValidations() {
|
|
783
|
-
this.#data.
|
|
784
|
-
|
|
793
|
+
if (!this.#data.validationsPath) {
|
|
794
|
+
throw new Error(
|
|
795
|
+
'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
const newValidations = await this.#buildValidations();
|
|
799
|
+
this.#data.validations = newValidations;
|
|
785
800
|
}
|
|
786
801
|
};
|
|
787
802
|
|
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,10 @@ async function getFolderPaths(directory, nesting) {
|
|
|
49
49
|
return folderPaths;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// src/utils/clone.ts
|
|
53
|
+
import rfdc from "rfdc";
|
|
54
|
+
var clone = rfdc();
|
|
55
|
+
|
|
52
56
|
// src/utils/colors.ts
|
|
53
57
|
var resetColor = "\x1B[0m";
|
|
54
58
|
var colors_default = {
|
|
@@ -431,10 +435,6 @@ function permissions_default({ interaction, targetCommand }) {
|
|
|
431
435
|
// src/handlers/command-handler/validations/index.ts
|
|
432
436
|
var validations_default = [devOnly_default, permissions_default];
|
|
433
437
|
|
|
434
|
-
// src/utils/clone.ts
|
|
435
|
-
import rfdc from "rfdc";
|
|
436
|
-
var clone = rfdc();
|
|
437
|
-
|
|
438
438
|
// src/handlers/command-handler/CommandHandler.ts
|
|
439
439
|
var CommandHandler = class {
|
|
440
440
|
#data;
|
|
@@ -447,7 +447,7 @@ var CommandHandler = class {
|
|
|
447
447
|
}
|
|
448
448
|
async init() {
|
|
449
449
|
await this.#buildCommands();
|
|
450
|
-
this.#
|
|
450
|
+
this.#buildBuiltInValidations();
|
|
451
451
|
const devOnlyCommands = this.#data.commands.filter((cmd) => cmd.options?.devOnly);
|
|
452
452
|
if (devOnlyCommands.length && !this.#data.devGuildIds.length) {
|
|
453
453
|
console.log(
|
|
@@ -539,9 +539,9 @@ var CommandHandler = class {
|
|
|
539
539
|
this.#data.commands.push(commandObj);
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
#
|
|
543
|
-
for (const
|
|
544
|
-
this.#data.builtInValidations.push(
|
|
542
|
+
#buildBuiltInValidations() {
|
|
543
|
+
for (const builtInValidationFunction of validations_default) {
|
|
544
|
+
this.#data.builtInValidations.push(builtInValidationFunction);
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
handleCommands() {
|
|
@@ -607,6 +607,11 @@ var CommandHandler = class {
|
|
|
607
607
|
return this.#data.commands;
|
|
608
608
|
}
|
|
609
609
|
async reloadCommands(type) {
|
|
610
|
+
if (!this.#data.commandsPath) {
|
|
611
|
+
throw new Error(
|
|
612
|
+
'Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'
|
|
613
|
+
);
|
|
614
|
+
}
|
|
610
615
|
this.#data.commands = [];
|
|
611
616
|
await this.#buildCommands();
|
|
612
617
|
if (this.#data.bulkRegister) {
|
|
@@ -627,8 +632,6 @@ var CommandHandler = class {
|
|
|
627
632
|
});
|
|
628
633
|
}
|
|
629
634
|
}
|
|
630
|
-
async useUpdatedValidations() {
|
|
631
|
-
}
|
|
632
635
|
};
|
|
633
636
|
|
|
634
637
|
// src/handlers/event-handler/EventHandler.ts
|
|
@@ -697,6 +700,11 @@ var EventHandler = class {
|
|
|
697
700
|
return this.#data.events;
|
|
698
701
|
}
|
|
699
702
|
async reloadEvents(commandHandler) {
|
|
703
|
+
if (!this.#data.eventsPath) {
|
|
704
|
+
throw new Error(
|
|
705
|
+
'Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'
|
|
706
|
+
);
|
|
707
|
+
}
|
|
700
708
|
this.#data.events = [];
|
|
701
709
|
await this.#buildEvents();
|
|
702
710
|
this.#data.client.removeAllListeners();
|
|
@@ -715,12 +723,13 @@ var ValidationHandler = class {
|
|
|
715
723
|
};
|
|
716
724
|
}
|
|
717
725
|
async init() {
|
|
718
|
-
await this.#buildValidations();
|
|
726
|
+
this.#data.validations = await this.#buildValidations();
|
|
719
727
|
}
|
|
720
728
|
async #buildValidations() {
|
|
721
729
|
const allowedExtensions = /\.(js|mjs|cjs|ts)$/i;
|
|
722
730
|
const validationPaths = await getFilePaths(this.#data.validationsPath, true);
|
|
723
731
|
const validationFilePaths = validationPaths.filter((path3) => allowedExtensions.test(path3));
|
|
732
|
+
const validationFunctions = [];
|
|
724
733
|
for (const validationFilePath of validationFilePaths) {
|
|
725
734
|
const modulePath = toFileURL(validationFilePath);
|
|
726
735
|
let importedFunction = (await import(`${modulePath}?t=${Date.now()}`)).default;
|
|
@@ -740,15 +749,21 @@ var ValidationHandler = class {
|
|
|
740
749
|
);
|
|
741
750
|
continue;
|
|
742
751
|
}
|
|
743
|
-
|
|
752
|
+
validationFunctions.push(validationFunction);
|
|
744
753
|
}
|
|
754
|
+
return validationFunctions;
|
|
745
755
|
}
|
|
746
756
|
get validations() {
|
|
747
757
|
return this.#data.validations;
|
|
748
758
|
}
|
|
749
759
|
async reloadValidations() {
|
|
750
|
-
this.#data.
|
|
751
|
-
|
|
760
|
+
if (!this.#data.validationsPath) {
|
|
761
|
+
throw new Error(
|
|
762
|
+
'Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
const newValidations = await this.#buildValidations();
|
|
766
|
+
this.#data.validations = newValidations;
|
|
752
767
|
}
|
|
753
768
|
};
|
|
754
769
|
|
package/package.json
CHANGED