Skip to content

Commit 8ca279e

Browse files
refactor: update deno template and loader logic (#11060)
* refactor: update deno template and loader logic * yeet --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 5a656b8 commit 8ca279e

File tree

18 files changed

+96
-148
lines changed

18 files changed

+96
-148
lines changed

packages/create-discord-bot/bin/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { styleText } from 'node:util';
66
import { Option, program } from 'commander';
77
import prompts from 'prompts';
88
import validateProjectName from 'validate-npm-package-name';
9-
import packageJSON from '../package.json' assert { type: 'json' };
9+
import packageJSON from '../package.json' with { type: 'json' };
1010
import { createDiscordBot } from '../src/create-discord-bot.js';
1111
import { resolvePackageManager } from '../src/helpers/packageManager.js';
1212
import { DEFAULT_PROJECT_NAME, PACKAGE_MANAGERS } from '../src/util/constants.js';

packages/create-discord-bot/src/helpers/packageManager.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export type PackageManager = 'bun' | 'deno' | 'npm' | 'pnpm' | 'yarn';
1414
export function resolvePackageManager(): PackageManager {
1515
const npmConfigUserAgent = process.env.npm_config_user_agent;
1616

17+
// @ts-expect-error: We're not using Deno's types, so its global is not declared
18+
if (typeof Deno !== 'undefined') {
19+
return 'deno';
20+
}
21+
1722
// If this is not present, return the default package manager.
1823
if (!npmConfigUserAgent) {
1924
return DEFAULT_PACKAGE_MANAGER;

packages/create-discord-bot/template/Deno/.prettierrc.json

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["denoland.vscode-deno", "tamasfe.even-better-toml", "codezombiech.gitignore"]
2+
"recommendations": ["denoland.vscode-deno"]
33
}

packages/create-discord-bot/template/Deno/.vscode/settings.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
"editor.defaultFormatter": "denoland.vscode-deno",
33
"editor.formatOnSave": true,
44
"editor.codeActionsOnSave": {
5-
"source.fixAll": true,
6-
"source.organizeImports": false
5+
"source.fixAll": "always",
6+
"source.organizeImports": "always"
77
},
88
"editor.trimAutoWhitespace": false,
99
"files.insertFinalNewline": true,
1010
"files.eol": "\n",
11-
"npm.packageManager": "[REPLACE_ME]",
12-
"deno.enable": "[REPLACE_BOOL]",
13-
"deno.lint": "[REPLACE_BOOL]",
14-
"deno.unstable": false
11+
"deno.enable": "[REPLACE_BOOL]"
1512
}

packages/create-discord-bot/template/Deno/deno.jsonc

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,25 @@
22
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
33
"tasks": {
44
"lint": "deno lint",
5-
"deploy": "deno run --allow-read --allow-env --allow-net src/util/deploy.ts",
5+
"deploy": "deno run --env-file --allow-read --allow-env --allow-net src/util/deploy.ts",
66
"format": "deno fmt",
77
"fmt": "deno fmt",
8-
"start": "deno run --allow-read --allow-env --allow-net src/index.ts",
8+
"start": "deno run --env-file --allow-read --allow-env --allow-net src/index.ts",
9+
},
10+
"fmt": {
11+
"useTabs": true,
12+
"lineWidth": 120,
13+
"singleQuote": true,
914
},
1015
"lint": {
11-
"include": ["src/"],
1216
"rules": {
1317
"tags": ["recommended"],
1418
"exclude": ["require-await", "no-await-in-sync-fn"],
1519
},
1620
},
17-
"fmt": {
18-
"useTabs": true,
19-
"lineWidth": 120,
20-
"semiColons": true,
21-
"singleQuote": true,
22-
"proseWrap": "preserve",
23-
"include": ["src/"],
24-
},
25-
"compilerOptions": {
26-
"alwaysStrict": true,
27-
"emitDecoratorMetadata": true,
28-
"verbatimModuleSyntax": true,
29-
"lib": ["deno.window"],
30-
"noFallthroughCasesInSwitch": true,
31-
"noImplicitReturns": true,
32-
"noUnusedLocals": true,
33-
"noUnusedParameters": true,
34-
"removeComments": false,
35-
"strict": true,
36-
"allowUnreachableCode": false,
37-
"allowUnusedLabels": false,
38-
"exactOptionalPropertyTypes": false,
39-
"noImplicitOverride": true,
21+
"imports": {
22+
"@discordjs/core": "npm:@discordjs/core@^2.2.1",
23+
"discord.js": "npm:discord.js@^14.22.1",
24+
"zod": "npm:zod@^3.25.76",
4025
},
4126
}

packages/create-discord-bot/template/Deno/src/commands/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { RESTPostAPIApplicationCommandsJSONBody, CommandInteraction } from 'npm:discord.js@^14.22.0';
2-
import { z } from 'npm:zod@^3.25.76';
1+
import type { CommandInteraction, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
2+
import { z } from 'zod';
33
import type { StructurePredicate } from '../util/loaders.ts';
44

55
/**

packages/create-discord-bot/template/Deno/src/events/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import type { ClientEvents } from 'npm:discord.js@^14.22.0';
2-
import { z } from 'npm:zod@^3.25.76';
1+
import type { ClientEvents } from 'discord.js';
2+
import { z } from 'zod';
33
import type { StructurePredicate } from '../util/loaders.ts';
44

55
/**
66
* Defines the structure of an event.
77
*/
8-
export type Event<T extends keyof ClientEvents = keyof ClientEvents> = {
8+
export type Event<EventName extends keyof ClientEvents = keyof ClientEvents> = {
99
/**
1010
* The function to execute when the event is emitted.
1111
*
1212
* @param parameters - The parameters of the event
1313
*/
14-
execute(...parameters: ClientEvents[T]): Promise<void> | void;
14+
execute(...parameters: ClientEvents[EventName]): Promise<void> | void;
1515
/**
1616
* The name of the event to listen to
1717
*/
18-
name: T;
18+
name: EventName;
1919
/**
2020
* Whether or not the event should only be listened to once
2121
*

packages/create-discord-bot/template/Deno/src/events/interactionCreate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Events } from 'npm:discord.js@^14.22.0';
1+
import { Events } from 'discord.js';
22
import type { Event } from './index.ts';
33
import { loadCommands } from '../util/loaders.ts';
44

packages/create-discord-bot/template/Deno/src/events/ready.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Events } from 'npm:discord.js@^14.22.0';
1+
import { Events } from 'discord.js';
22
import type { Event } from './index.ts';
33

44
export default {

0 commit comments

Comments
 (0)