create-enerthya 0.1.3
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/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +103 -0
- package/dist/cli.js.map +1 -0
- package/package.json +29 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join, dirname } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const TEMPLATE_DIR = join(__dirname, '..', 'template');
|
|
7
|
+
const config = {
|
|
8
|
+
name: process.argv[2] || 'my-enerthya-bot',
|
|
9
|
+
};
|
|
10
|
+
const root = join(process.cwd(), config.name);
|
|
11
|
+
if (existsSync(root)) {
|
|
12
|
+
console.error(`Directory "${config.name}" already exists.`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
mkdirSync(root, { recursive: true });
|
|
16
|
+
const files = {
|
|
17
|
+
'package.json': JSON.stringify({
|
|
18
|
+
name: config.name,
|
|
19
|
+
version: '0.1.0',
|
|
20
|
+
type: 'module',
|
|
21
|
+
private: true,
|
|
22
|
+
scripts: {
|
|
23
|
+
dev: 'tsx watch src/index.ts',
|
|
24
|
+
build: 'tsc',
|
|
25
|
+
start: 'node dist/index.js',
|
|
26
|
+
},
|
|
27
|
+
dependencies: {
|
|
28
|
+
'@enerthya/core': '^0.1.2',
|
|
29
|
+
'@enerthya/utils': '^0.1.2',
|
|
30
|
+
'discord.js': '^14.16.0',
|
|
31
|
+
},
|
|
32
|
+
devDependencies: {
|
|
33
|
+
typescript: '^5.9.3',
|
|
34
|
+
tsx: '^4.19.0',
|
|
35
|
+
'@types/node': '^22.16.4',
|
|
36
|
+
},
|
|
37
|
+
}, null, 2),
|
|
38
|
+
'tsconfig.json': JSON.stringify({
|
|
39
|
+
compilerOptions: {
|
|
40
|
+
target: 'ESNext',
|
|
41
|
+
module: 'NodeNext',
|
|
42
|
+
moduleResolution: 'NodeNext',
|
|
43
|
+
strict: true,
|
|
44
|
+
esModuleInterop: true,
|
|
45
|
+
skipLibCheck: true,
|
|
46
|
+
outDir: './dist',
|
|
47
|
+
rootDir: './src',
|
|
48
|
+
resolveJsonModule: true,
|
|
49
|
+
},
|
|
50
|
+
include: ['src'],
|
|
51
|
+
}, null, 2),
|
|
52
|
+
'.env.example': `# Discord
|
|
53
|
+
DISCORD_TOKEN=your_bot_token_here
|
|
54
|
+
DISCORD_PREFIX=!
|
|
55
|
+
DISCORD_GUILD_ID=your_guild_id_here
|
|
56
|
+
|
|
57
|
+
# Bot owners (comma-separated)
|
|
58
|
+
OWNERS=123456789012345678
|
|
59
|
+
`,
|
|
60
|
+
'src/index.ts': `import { EnerthyaBuilder } from '@enerthya/core';
|
|
61
|
+
import { info } from '@enerthya/utils';
|
|
62
|
+
|
|
63
|
+
const builder = new EnerthyaBuilder({
|
|
64
|
+
token: process.env.DISCORD_TOKEN ?? '',
|
|
65
|
+
prefix: process.env.DISCORD_PREFIX ?? '!',
|
|
66
|
+
guildId: process.env.DISCORD_GUILD_ID,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// --- Ping command ---
|
|
70
|
+
builder.command({
|
|
71
|
+
name: 'ping',
|
|
72
|
+
description: 'Check bot latency',
|
|
73
|
+
slash: { enabled: true },
|
|
74
|
+
execute: async (ctx) => {
|
|
75
|
+
const latency = Date.now() - ctx.createdTimestamp;
|
|
76
|
+
await ctx.reply(\`Pong! \\\`\${latency}ms\\\`\`);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Start
|
|
81
|
+
builder.start();
|
|
82
|
+
|
|
83
|
+
info('Bot is starting...');
|
|
84
|
+
`,
|
|
85
|
+
};
|
|
86
|
+
for (const [path, content] of Object.entries(files)) {
|
|
87
|
+
const fullPath = join(root, path);
|
|
88
|
+
const dir = dirname(fullPath);
|
|
89
|
+
if (!existsSync(dir))
|
|
90
|
+
mkdirSync(dir, { recursive: true });
|
|
91
|
+
writeFileSync(fullPath, content, 'utf-8');
|
|
92
|
+
}
|
|
93
|
+
console.log(`
|
|
94
|
+
✨ Created "${config.name}" successfully!
|
|
95
|
+
|
|
96
|
+
cd ${config.name}
|
|
97
|
+
cp .env.example .env
|
|
98
|
+
npm install
|
|
99
|
+
npm run dev
|
|
100
|
+
|
|
101
|
+
Happy coding! 🚀
|
|
102
|
+
`);
|
|
103
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAgB,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;AAEvD,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,iBAAiB;CAC3C,CAAC;AAEF,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAE9C,IAAI,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I,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,OAAO,CAAC,GAAG,CAAC;aACC,MAAM,CAAC,IAAI;;OAEjB,MAAM,CAAC,IAAI;;;;;;CAMjB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-enerthya",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Scaffold a new Enerthya Discord bot project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-enerthya": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": ["dist", "template"],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"check": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"chalk": "^5.4.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.16.4"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/Enerthya/enerthya-packages.git",
|
|
23
|
+
"directory": "packages/create-enerthya"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT"
|
|
29
|
+
}
|