reciple 6.0.0-dev.16 → 6.0.0-dev.18
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/dist/lib/bin.mjs +6 -3
- package/dist/lib/reciple/classes/RecipleClient.js +2 -1
- package/dist/lib/reciple/classes/RecipleConfig.js +8 -8
- package/dist/lib/reciple/classes/managers/ClientModuleManager.js +1 -2
- package/dist/types/reciple/classes/RecipleClient.d.ts +2 -0
- package/dist/types/reciple/classes/RecipleConfig.d.ts +2 -2
- package/package.json +2 -2
- package/resource/reciple.yml +3 -1
package/dist/lib/bin.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { RecipleClient } from './reciple/classes/RecipleClient.js';
|
|
3
3
|
import { RecipleConfig } from './reciple/classes/RecipleConfig.js';
|
|
4
4
|
import { rawVersion } from './reciple/version.js';
|
|
5
|
-
import { existsSync, readdirSync } from 'fs';
|
|
5
|
+
import { existsSync, mkdirSync, readdirSync } from 'fs';
|
|
6
6
|
import { cwd, flags } from './reciple/flags.js';
|
|
7
7
|
import { input } from 'fallout-utility';
|
|
8
8
|
import chalk from 'chalk';
|
|
@@ -10,7 +10,10 @@ import 'dotenv/config';
|
|
|
10
10
|
import path from 'path';
|
|
11
11
|
import { inspect } from 'util';
|
|
12
12
|
const allowedFiles = ['node_modules', 'reciple.yml', 'package.json'];
|
|
13
|
-
const configPath = path.
|
|
13
|
+
const configPath = path.resolve(cwd, 'reciple.yml');
|
|
14
|
+
console.log(cwd);
|
|
15
|
+
if (!existsSync(cwd))
|
|
16
|
+
mkdirSync(cwd, { recursive: true });
|
|
14
17
|
if (readdirSync(cwd).filter(f => !f.startsWith('.') && allowedFiles.indexOf(f)).length > 0 && !existsSync(flags.config ?? configPath)) {
|
|
15
18
|
const ask = (flags.yes ? 'y' : null) ?? input('This directory does not contain reciple.yml. Would you like to init axis here? [y/n] ') ?? '';
|
|
16
19
|
if (ask.toString().toLowerCase() !== 'y')
|
|
@@ -25,7 +28,7 @@ catch (err) {
|
|
|
25
28
|
process.exit(1);
|
|
26
29
|
}
|
|
27
30
|
const config = configParser.getConfig();
|
|
28
|
-
const client = new RecipleClient({ config: config, ...config.client });
|
|
31
|
+
const client = new RecipleClient({ config: config, cwd, ...config.client });
|
|
29
32
|
/**
|
|
30
33
|
* Start
|
|
31
34
|
*/
|
|
@@ -39,7 +39,8 @@ class RecipleClient extends discord_js_1.Client {
|
|
|
39
39
|
this.logger = (0, util_1.createLogger)(!!options.config?.fileLogging.stringifyLoggedJSON, options.config?.fileLogging.debugmode);
|
|
40
40
|
this.config = { ...this.config, ...(options.config ?? {}) };
|
|
41
41
|
if (this.config.fileLogging.enabled)
|
|
42
|
-
this.logger.logFile(path_1.default.
|
|
42
|
+
this.logger.logFile(path_1.default.resolve(flags_1.cwd, this.config.fileLogging.logFilePath ?? 'logs/latest.log'), false);
|
|
43
|
+
this.cwd = options.cwd ?? process.cwd();
|
|
43
44
|
this.applicationCommands = new ApplicationCommandManager_1.ApplicationCommandManager(this);
|
|
44
45
|
}
|
|
45
46
|
get isClientLogsSilent() {
|
|
@@ -19,7 +19,7 @@ class RecipleConfig {
|
|
|
19
19
|
*/
|
|
20
20
|
constructor(configPath) {
|
|
21
21
|
this.config = RecipleConfig.getDefaultConfig();
|
|
22
|
-
this.configPath = path_1.default.
|
|
22
|
+
this.configPath = path_1.default.resolve(process.cwd(), 'reciple.yml');
|
|
23
23
|
if (!configPath)
|
|
24
24
|
throw new Error('Config path is not defined');
|
|
25
25
|
this.configPath = configPath;
|
|
@@ -62,17 +62,17 @@ class RecipleConfig {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Parse token from config
|
|
65
|
-
* @param
|
|
65
|
+
* @param askIfEmpty Ask for token if the token is undefined
|
|
66
66
|
*/
|
|
67
|
-
parseToken(
|
|
68
|
-
let token = flags_1.token || this.config?.token ||
|
|
67
|
+
parseToken(askIfEmpty = true) {
|
|
68
|
+
let token = flags_1.token || this.config?.token || undefined;
|
|
69
69
|
if (!token)
|
|
70
|
-
return token || (
|
|
70
|
+
return token || (askIfEmpty ? this._askToken() : null);
|
|
71
71
|
const envToken = token.toString().split(':');
|
|
72
72
|
if (envToken.length === 2 && envToken[0].toLocaleLowerCase() === 'env' && envToken[1]) {
|
|
73
|
-
token = process.env[envToken[1]] ||
|
|
73
|
+
token = process.env[envToken[1]] || undefined;
|
|
74
74
|
}
|
|
75
|
-
return token || (
|
|
75
|
+
return token || (askIfEmpty == null ? this._askToken() : null);
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Check if the config version is supported
|
|
@@ -103,4 +103,4 @@ class RecipleConfig {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
exports.RecipleConfig = RecipleConfig;
|
|
106
|
-
RecipleConfig.defaultConfigPath = path_1.default.
|
|
106
|
+
RecipleConfig.defaultConfigPath = path_1.default.resolve(__dirname, '../../../../resource/reciple.yml');
|
|
@@ -9,7 +9,6 @@ const fs_1 = require("fs");
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const util_1 = require("util");
|
|
11
11
|
const wildcard_match_1 = __importDefault(require("wildcard-match"));
|
|
12
|
-
const flags_1 = require("../../flags");
|
|
13
12
|
const RecipleModule_1 = require("../RecipleModule");
|
|
14
13
|
class ClientModuleManager {
|
|
15
14
|
constructor(options) {
|
|
@@ -175,7 +174,7 @@ class ClientModuleManager {
|
|
|
175
174
|
if (!(0, fs_1.lstatSync)(dir).isDirectory())
|
|
176
175
|
continue;
|
|
177
176
|
modules.push(...(0, fs_1.readdirSync)(dir)
|
|
178
|
-
.map(file => path_1.default.
|
|
177
|
+
.map(file => path_1.default.resolve(!dir.startsWith('/') ? this.client.cwd : '', dir, file))
|
|
179
178
|
.filter(file => (options?.filter ? options.filter(file) : file.endsWith('.js'))));
|
|
180
179
|
}
|
|
181
180
|
return modules.filter(file => !(options?.ignoredFiles ?? this.client.config.ignoredFiles).some(ignored => (0, wildcard_match_1.default)(ignored)(path_1.default.basename(file))));
|
|
@@ -13,6 +13,7 @@ import { Logger } from 'fallout-utility';
|
|
|
13
13
|
*/
|
|
14
14
|
export interface RecipleClientOptions extends ClientOptions {
|
|
15
15
|
config?: Config;
|
|
16
|
+
cwd?: string;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Reciple client events
|
|
@@ -45,6 +46,7 @@ export declare class RecipleClient<Ready extends boolean = boolean> extends Clie
|
|
|
45
46
|
readonly applicationCommands: ApplicationCommandManager;
|
|
46
47
|
readonly cooldowns: CommandCooldownManager;
|
|
47
48
|
readonly modules: ClientModuleManager;
|
|
49
|
+
readonly cwd: string;
|
|
48
50
|
readonly logger: Logger;
|
|
49
51
|
readonly version: string;
|
|
50
52
|
get isClientLogsSilent(): boolean;
|
|
@@ -82,9 +82,9 @@ export declare class RecipleConfig {
|
|
|
82
82
|
getConfig(): Config;
|
|
83
83
|
/**
|
|
84
84
|
* Parse token from config
|
|
85
|
-
* @param
|
|
85
|
+
* @param askIfEmpty Ask for token if the token is undefined
|
|
86
86
|
*/
|
|
87
|
-
parseToken(
|
|
87
|
+
parseToken(askIfEmpty?: boolean): string | null;
|
|
88
88
|
/**
|
|
89
89
|
* Check if the config version is supported
|
|
90
90
|
*/
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reciple",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.18",
|
|
4
4
|
"bin": "./dist/lib/bin.mjs",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "./dist/lib/index.js",
|
|
8
8
|
"types": "./dist/types/index.d.ts",
|
|
9
|
-
"module": "./esm.mjs",
|
|
9
|
+
"module": "./dist/lib/esm.mjs",
|
|
10
10
|
"author": "FalloutStudios",
|
|
11
11
|
"description": "Handler for Discord.js",
|
|
12
12
|
"homepage": "https://reciple.js.org",
|