@discord-ts-dev/cli 1.0.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # @discord-ts-dev/cli
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 96e1908: First publish to npm. Add `repository`, `bugs` and `homepage` metadata, and ship
8
+ `CHANGELOG.md` and `LICENSE` in the tarball. See ADR 0012.
9
+
10
+ Internal dependencies move from the `workspace:*` protocol to a caret range.
11
+ npm does not rewrite `workspace:` on pack or publish, so the protocol reached
12
+ the registry verbatim and every consumer install failed with
13
+ `EUNSUPPORTEDPROTOCOL`. Caret ranges are what `updateInternalDependencies`
14
+ already expects, and they resolve once the dependencies are published.
15
+
16
+ ## 1.0.0
17
+
18
+ ### Major Changes
19
+
20
+ - e95d73e: Drop `@nestjs/*` for a standalone runtime and move to ESM (`NodeNext`, `type: module`). `Injectable`, `Module`, `SetMetadata`, `UseGuards`, `UsePipes`, `Logger` now come from `@discord-ts-dev/common`; update example imports accordingly
21
+
22
+ ### Minor Changes
23
+
24
+ - e85b103: Run on Bun instead of Node.js. The CLI spawns the runtime it is already running under (`process.execPath`) rather than `node` for build output, uses `Bun.spawnSync` / `Bun.file` / `Bun.stdout`, and its shebang is `#!/usr/bin/env bun` - the `discord` bin needs Bun now. Core reads config files via `Bun.pathToFileURL` and paints route logs with `Bun.color`. Node APIs with no Bun equivalent stay: `node:path`, `node:fs` `realpathSync`/`existsSync`, `node:vm` in the music-bot eval command, and `node:assert` in tests.
25
+ - 9f0dea9: Declare `exports` maps so deep subpaths stop being implicitly public. The CLI runner is now importable: `main(argv, deps)`, `COMMANDS`, `usage()` and the `CliDeps` injection point are exported, and `main` only runs when the file is the entry point - tests no longer spawn processes.
26
+
27
+ ### Patch Changes
28
+
29
+ - 58bdc90: Fix two validation bugs found by the coverage pass: `validateDto` now calls `class-validator` with `forbidUnknownValues: false`, so plain DTOs without validator decorators pass instead of being blocked with "an unknown value was passed"; `resolveDiscordOptions` no longer clobbers `forRootAsync({ skipValidation: true })` with `undefined`. `deployWithModule()` and `bootstrapApp()` take an optional runtime factory for tests. The CLI runner sets `process.exitCode` instead of calling `process.exit`, so output flushes before the process ends.
30
+ - 76feef4: Add bun smoke tests with per-package test scripts
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) discord.ts contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bun
2
+ export interface CliCommand {
3
+ file: string;
4
+ args: string[];
5
+ help: string;
6
+ /** Built output, so a missing file means "build first". */
7
+ needsBuild?: boolean;
8
+ }
9
+ export declare const COMMANDS: Record<string, CliCommand>;
10
+ /** Side effects `main` needs, injectable so tests never spawn or exit. */
11
+ export interface CliDeps {
12
+ cwd: string;
13
+ exists: (file: string) => Promise<boolean>;
14
+ spawn: (argv: string[]) => {
15
+ exitCode: number | null;
16
+ };
17
+ out: (text: string) => void;
18
+ err: (text: string) => void;
19
+ exit: (code: number) => void;
20
+ }
21
+ export declare function usage(): string;
22
+ export declare function main(argv: string[], deps?: CliDeps): Promise<void>;
23
+ /** True when this module is the process entry. Realpath so bin symlinks match. */
24
+ export declare function isEntry(entry: string | undefined, moduleUrl: string): boolean;
25
+ export declare function mainIfEntry(argv: string[], moduleUrl: string, deps?: CliDeps): Promise<void>;
26
+ export declare function processDeps(): CliDeps;
package/dist/cli.js ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env bun
2
+ // ponytail: path.resolve and realpathSync have no Bun equivalent; both are
3
+ // Bun-native implementations of the node modules.
4
+ import { realpathSync } from 'node:fs';
5
+ import * as path from 'node:path';
6
+ // ponytail: no arg-parser dep, five commands fit in one table. Bun runs both
7
+ // TS source and build output, so no runtime switch.
8
+ export const COMMANDS = {
9
+ dev: { file: 'src/main.ts', args: [], help: 'boot bot from TS source' },
10
+ 'dev:shard': { file: 'src/main.ts', args: ['--shards'], help: 'boot shards from TS source' },
11
+ deploy: { file: 'src/deploy.ts', args: [], help: 'sync commands without login' },
12
+ start: { file: 'dist/main.js', args: [], help: 'boot bot from build output', needsBuild: true },
13
+ 'start:shard': {
14
+ file: 'dist/main.js',
15
+ args: ['--shards'],
16
+ help: 'boot shards from build output',
17
+ needsBuild: true,
18
+ },
19
+ };
20
+ export function usage() {
21
+ const rows = Object.entries(COMMANDS)
22
+ .map(([name, cmd]) => ` discord ${name.padEnd(12)} ${cmd.help}`)
23
+ .join('\n');
24
+ return `Usage: discord <command>\n\n${rows}\n`;
25
+ }
26
+ export async function main(argv, deps = processDeps()) {
27
+ const [, , cmd, ...rest] = argv;
28
+ if (!cmd || cmd === '--help' || cmd === '-h') {
29
+ deps.out(usage());
30
+ deps.exit(cmd ? 0 : 1);
31
+ return;
32
+ }
33
+ const found = COMMANDS[cmd];
34
+ if (!found) {
35
+ deps.err(`[discord.ts] unknown command "${cmd}".\n\n${usage()}`);
36
+ deps.exit(1);
37
+ return;
38
+ }
39
+ if (rest.includes('--help') || rest.includes('-h')) {
40
+ deps.out(usage());
41
+ deps.exit(0);
42
+ return;
43
+ }
44
+ const file = path.resolve(deps.cwd, found.file);
45
+ if (!(await deps.exists(file))) {
46
+ deps.err(`[discord.ts] missing ${found.file}. Run inside your bot app${found.needsBuild ? ' after building' : ''}.`);
47
+ deps.exit(1);
48
+ return;
49
+ }
50
+ const run = deps.spawn([process.execPath, file, ...found.args, ...rest]);
51
+ deps.exit(run.exitCode ?? 1);
52
+ }
53
+ /** True when this module is the process entry. Realpath so bin symlinks match. */
54
+ export function isEntry(entry, moduleUrl) {
55
+ if (entry === undefined)
56
+ return false;
57
+ try {
58
+ return realpathSync(entry) === realpathSync(Bun.fileURLToPath(moduleUrl));
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ }
64
+ export async function mainIfEntry(argv, moduleUrl, deps = processDeps()) {
65
+ if (isEntry(argv[1], moduleUrl))
66
+ await main(argv, deps);
67
+ }
68
+ export function processDeps() {
69
+ return {
70
+ cwd: process.cwd(),
71
+ exists: (file) => Bun.file(file).exists(),
72
+ spawn: (argv) => Bun.spawnSync(argv, { stdio: ['inherit', 'inherit', 'inherit'] }),
73
+ out: (text) => void Bun.stdout.write(text),
74
+ err: (text) => void Bun.stderr.write(text),
75
+ exit: (code) => {
76
+ process.exitCode = code;
77
+ },
78
+ };
79
+ }
80
+ await mainIfEntry(Bun.argv, import.meta.url);
81
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,2EAA2E;AAC3E,kDAAkD;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAUlC,6EAA6E;AAC7E,oDAAoD;AACpD,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AC,IAAI,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@discord-ts-dev/cli",
3
+ "version": "1.0.1",
4
+ "description": "discord.ts command runner: dev, shard, deploy, start",
5
+ "homepage": "https://github.com/discord-ts-dev/discord.ts#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/discord-ts-dev/discord.ts/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/discord-ts-dev/discord.ts.git",
13
+ "directory": "packages/cli"
14
+ },
15
+ "bin": {
16
+ "discord": "dist/cli.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "CHANGELOG.md",
21
+ "LICENSE"
22
+ ],
23
+ "type": "module",
24
+ "main": "dist/cli.js",
25
+ "types": "dist/cli.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/cli.d.ts",
29
+ "default": "./dist/cli.js"
30
+ }
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json",
34
+ "typecheck": "tsc -p tsconfig.json --noEmit",
35
+ "lint": "oxlint .",
36
+ "format": "oxfmt --write src",
37
+ "test": "bun test --preload=../../scripts/test-preload.ts"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^26.4.1",
41
+ "typescript": "^7.0.2"
42
+ }
43
+ }