generator-discord 1.3.3 → 1.3.5
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/README.md +1 -1
- package/app/index.d.ts.map +1 -1
- package/app/index.js +11 -4
- package/app/index.js.map +1 -1
- package/package.json +7 -8
- package/src/index.ts +17 -4
- package/templates/python/main.py +2 -2
- package/templates/rust/Cargo.lock +1460 -0
- package/templates/rust/Cargo.toml +1 -1
- package/templates/typescript/package.json +1 -1
- package/test/templates.test.ts +0 -105
|
@@ -6,5 +6,5 @@ edition = "2021"
|
|
|
6
6
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
7
7
|
|
|
8
8
|
[dependencies]
|
|
9
|
-
serenity = { version = "0.11.
|
|
9
|
+
serenity = { version = "0.11.7", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
|
|
10
10
|
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
|
package/test/templates.test.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { createHelpers } from 'yeoman-test';
|
|
3
|
-
import { spawn, exec } from 'child_process';
|
|
4
|
-
import * as dotenv from 'dotenv';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import url from 'url';
|
|
7
|
-
|
|
8
|
-
const __dirname = url.fileURLToPath(new URL('../', import.meta.url));
|
|
9
|
-
const TIMEOUT = 30_000; // 30 seconds
|
|
10
|
-
|
|
11
|
-
dotenv.config();
|
|
12
|
-
|
|
13
|
-
const { BOT_TOKEN } = process.env;
|
|
14
|
-
if (!BOT_TOKEN) {
|
|
15
|
-
throw new Error('You must specify a valid bot token in the BOT_TOKEN environment variable');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const defaultAnswers = {
|
|
19
|
-
botName: 'test-run-bot',
|
|
20
|
-
botType: 'typescript',
|
|
21
|
-
botToken: BOT_TOKEN,
|
|
22
|
-
openWithCode: false,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
describe('Check if the templates work', () => {
|
|
26
|
-
const targetRoot = path.join(__dirname, 'test-temp');
|
|
27
|
-
const moduleRoot = path.join(__dirname, 'app');
|
|
28
|
-
const resultRoot = path.join(targetRoot, defaultAnswers.botName);
|
|
29
|
-
|
|
30
|
-
test('Should generate and run TypeScript Discord Bot', async () => {
|
|
31
|
-
const context = createHelpers({}).run(moduleRoot);
|
|
32
|
-
|
|
33
|
-
context.targetDirectory = targetRoot;
|
|
34
|
-
context.cleanTestDirectory(true);
|
|
35
|
-
await context
|
|
36
|
-
.onGenerator(generator => {
|
|
37
|
-
generator.destinationRoot(targetRoot);
|
|
38
|
-
})
|
|
39
|
-
.withAnswers(defaultAnswers)
|
|
40
|
-
.then(async () => {
|
|
41
|
-
const result = await runBot('node', ['./dist/src/index.js'], resultRoot);
|
|
42
|
-
expect(result).toContain(BOT_OUTPUT_START);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
context.cleanup();
|
|
46
|
-
}, 120_000);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
test.skip('Should generate and run Python Discord Bot', async () => {
|
|
50
|
-
const context = createHelpers({}).run(moduleRoot);
|
|
51
|
-
|
|
52
|
-
context.targetDirectory = targetRoot;
|
|
53
|
-
context.cleanTestDirectory(true);
|
|
54
|
-
await context
|
|
55
|
-
.onGenerator(generator => {
|
|
56
|
-
generator.destinationRoot(targetRoot);
|
|
57
|
-
})
|
|
58
|
-
.withAnswers({...defaultAnswers, botType: 'python' })
|
|
59
|
-
.then(async () => {
|
|
60
|
-
// install dependencies
|
|
61
|
-
await exec('pip3 install -r requirements.txt', { cwd: resultRoot });
|
|
62
|
-
|
|
63
|
-
const result = await runBot('python', ['main.py'], resultRoot);
|
|
64
|
-
expect(result).toContain(BOT_OUTPUT_START);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
context.cleanup();
|
|
68
|
-
}, 120_000);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
async function runBot(command: string, args: string[], root: string): Promise<string> {
|
|
73
|
-
const childProcess = spawn(command, args, { cwd: root, stdio: 'pipe', timeout: TIMEOUT });
|
|
74
|
-
|
|
75
|
-
const result = await new Promise<string>((resolve) => {
|
|
76
|
-
// timeout
|
|
77
|
-
const timeout = setTimeout(() => {
|
|
78
|
-
resolve('TIMEOUT');
|
|
79
|
-
}, TIMEOUT);
|
|
80
|
-
|
|
81
|
-
// output
|
|
82
|
-
childProcess.stdout.on('data', (data) => {
|
|
83
|
-
clearTimeout(timeout);
|
|
84
|
-
|
|
85
|
-
resolve(data.toString());
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
childProcess.stderr.on('data', (data) => {
|
|
89
|
-
clearTimeout(timeout);
|
|
90
|
-
|
|
91
|
-
resolve(data.toString());
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
childProcess.on('close', () => {
|
|
95
|
-
clearTimeout(timeout);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
childProcess.kill('SIGINT');
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const BOT_OUTPUT_START = 'Bot is logged in as';
|