@seedcord/cli 0.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/LICENSE +190 -0
- package/README.md +13 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +4198 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.ts +207 -0
- package/dist/index.mjs +718 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { ILogger } from '@seedcord/types';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
|
|
4
|
+
interface ModuleLoader {
|
|
5
|
+
importModule<TModule = unknown>(entryPath: string): Promise<TModule>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type MaybePromise<TValue> = TValue | Promise<TValue>;
|
|
9
|
+
interface SeedcordLike {
|
|
10
|
+
start: () => MaybePromise<unknown>;
|
|
11
|
+
}
|
|
12
|
+
declare class SeedcordInstanceLoader {
|
|
13
|
+
private readonly modules;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
constructor(modules: ModuleLoader, logger: ILogger);
|
|
16
|
+
load(instancePath: string): Promise<SeedcordLike>;
|
|
17
|
+
private isSeedcordLike;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface SeedcordBuildConfig {
|
|
21
|
+
/**
|
|
22
|
+
* Directory where build artifacts should be emitted. Defaults to ./dist relative to the config directory.
|
|
23
|
+
*/
|
|
24
|
+
outDir?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional tsconfig path to use for builds. Defaults to the nearest tsconfig.build.json or tsconfig.json.
|
|
27
|
+
*/
|
|
28
|
+
tsconfig?: string;
|
|
29
|
+
/**
|
|
30
|
+
* File name (or relative path) for the bootstrap file emitted inside the build output.
|
|
31
|
+
*/
|
|
32
|
+
bootstrap?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration used by the Seedcord CLI when running `seedcord dev` or `seedcord build`.
|
|
36
|
+
*/
|
|
37
|
+
interface SeedcordDevConfig {
|
|
38
|
+
/**
|
|
39
|
+
* Root directory used for resolving relative paths. Defaults to the config directory.
|
|
40
|
+
*/
|
|
41
|
+
root?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Path to the module whose default export is a configured Seedcord instance.
|
|
44
|
+
*/
|
|
45
|
+
instance: string;
|
|
46
|
+
/**
|
|
47
|
+
* Entry file that should be executed when starting the bot (and copied into the build output).
|
|
48
|
+
*/
|
|
49
|
+
entry: string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional build configuration overrides.
|
|
52
|
+
*/
|
|
53
|
+
build?: SeedcordBuildConfig;
|
|
54
|
+
}
|
|
55
|
+
interface ResolvedSeedcordBuildConfig {
|
|
56
|
+
outDir: string;
|
|
57
|
+
bootstrap: string;
|
|
58
|
+
tsconfig?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fully resolved configuration with absolute file system paths.
|
|
62
|
+
*/
|
|
63
|
+
interface ResolvedSeedcordDevConfig extends Required<Omit<SeedcordDevConfig, 'build'>> {
|
|
64
|
+
/**
|
|
65
|
+
* Absolute path to the config file that produced this resolution.
|
|
66
|
+
*/
|
|
67
|
+
configFile: string;
|
|
68
|
+
/**
|
|
69
|
+
* Resolved build options with absolute paths.
|
|
70
|
+
*/
|
|
71
|
+
build: ResolvedSeedcordBuildConfig;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Supported configuration filenames discovered by the CLI.
|
|
75
|
+
*/
|
|
76
|
+
declare const SEEDCORD_CONFIG_FILENAMES: readonly ["seedcord.config.ts", "seedcord.config.mts"];
|
|
77
|
+
/**
|
|
78
|
+
* Helper so config files receive proper type inference.
|
|
79
|
+
*/
|
|
80
|
+
declare function defineConfig(config: SeedcordDevConfig): SeedcordDevConfig;
|
|
81
|
+
|
|
82
|
+
declare class ConfigLoader {
|
|
83
|
+
private readonly modules;
|
|
84
|
+
private readonly logger;
|
|
85
|
+
constructor(modules: ModuleLoader, logger: ILogger);
|
|
86
|
+
load(configPath: string): Promise<ResolvedSeedcordDevConfig>;
|
|
87
|
+
private unwrapConfig;
|
|
88
|
+
private resolveWithinRoot;
|
|
89
|
+
private assertEntryWithinRoot;
|
|
90
|
+
private resolveBuildOptions;
|
|
91
|
+
private resolveBootstrap;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare class ConfigLocator {
|
|
95
|
+
private readonly logger;
|
|
96
|
+
constructor(logger: ILogger);
|
|
97
|
+
locate(baseDir?: string): string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Coordinates config discovery, loading, and starting a Seedcord instance.
|
|
102
|
+
*/
|
|
103
|
+
declare class SeedcordDevRunner {
|
|
104
|
+
private readonly locator;
|
|
105
|
+
private readonly configLoader;
|
|
106
|
+
private readonly instanceLoader;
|
|
107
|
+
private readonly logger;
|
|
108
|
+
constructor(locator: ConfigLocator, configLoader: ConfigLoader, instanceLoader: SeedcordInstanceLoader, logger: ILogger);
|
|
109
|
+
static create(logger: ILogger): SeedcordDevRunner;
|
|
110
|
+
run(): Promise<void>;
|
|
111
|
+
private loadConfig;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
declare class DevCommand {
|
|
115
|
+
private readonly runner;
|
|
116
|
+
private readonly logger;
|
|
117
|
+
constructor(runner: SeedcordDevRunner, logger: ILogger);
|
|
118
|
+
register(program: Command): void;
|
|
119
|
+
static create(logger: ILogger): DevCommand;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare class BootstrapWriter {
|
|
123
|
+
private readonly logger;
|
|
124
|
+
constructor(logger: ILogger);
|
|
125
|
+
write(config: ResolvedSeedcordDevConfig, emittedEntry: string): Promise<void>;
|
|
126
|
+
private formatImportPath;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface EntryPointCollection {
|
|
130
|
+
entryMap: Record<string, string>;
|
|
131
|
+
primaryKey: string;
|
|
132
|
+
}
|
|
133
|
+
declare class EntryPointCollector {
|
|
134
|
+
collect(config: ResolvedSeedcordDevConfig, tsconfigPath: string): EntryPointCollection;
|
|
135
|
+
private parseTsconfig;
|
|
136
|
+
private shouldEmitFile;
|
|
137
|
+
private isWithinRoot;
|
|
138
|
+
private createEntryKey;
|
|
139
|
+
private createEntryFallback;
|
|
140
|
+
private formatDiagnostics;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
declare class RelativeSpecifierTransformer {
|
|
144
|
+
transform(outDir: string): Promise<void>;
|
|
145
|
+
private collectJavaScriptFiles;
|
|
146
|
+
private rewriteFile;
|
|
147
|
+
private extractSpecifierReplacements;
|
|
148
|
+
private scheduleReplacement;
|
|
149
|
+
private appendJsExtension;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
interface BuildResult {
|
|
153
|
+
emittedEntry: string;
|
|
154
|
+
}
|
|
155
|
+
declare class TypeScriptProjectBuilder {
|
|
156
|
+
private readonly logger;
|
|
157
|
+
private readonly entries;
|
|
158
|
+
private readonly specifierTransformer;
|
|
159
|
+
constructor(logger: ILogger, entries?: EntryPointCollector, specifierTransformer?: RelativeSpecifierTransformer);
|
|
160
|
+
build(config: ResolvedSeedcordDevConfig): Promise<BuildResult>;
|
|
161
|
+
private resolveTsconfig;
|
|
162
|
+
private resolveEmittedEntry;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
declare class SeedcordBuildRunner {
|
|
166
|
+
private readonly locator;
|
|
167
|
+
private readonly configLoader;
|
|
168
|
+
private readonly builder;
|
|
169
|
+
private readonly bootstrapWriter;
|
|
170
|
+
private readonly logger;
|
|
171
|
+
constructor(locator: ConfigLocator, configLoader: ConfigLoader, builder: TypeScriptProjectBuilder, bootstrapWriter: BootstrapWriter, logger: ILogger);
|
|
172
|
+
static create(logger: ILogger): SeedcordBuildRunner;
|
|
173
|
+
run(): Promise<void>;
|
|
174
|
+
private loadConfig;
|
|
175
|
+
private assertEntryExists;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
declare class BuildCommand {
|
|
179
|
+
private readonly runner;
|
|
180
|
+
private readonly logger;
|
|
181
|
+
constructor(runner: SeedcordBuildRunner, logger: ILogger);
|
|
182
|
+
register(program: Command): void;
|
|
183
|
+
static create(logger: ILogger): BuildCommand;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
type TsconfigOption = string | false;
|
|
187
|
+
interface RuntimeModuleLoaderOptions {
|
|
188
|
+
tsconfig?: TsconfigOption;
|
|
189
|
+
forceTsx?: boolean;
|
|
190
|
+
}
|
|
191
|
+
declare class RuntimeModuleLoader implements ModuleLoader {
|
|
192
|
+
private readonly options;
|
|
193
|
+
private readonly jiti;
|
|
194
|
+
constructor(options?: RuntimeModuleLoaderOptions);
|
|
195
|
+
importModule<TModule = unknown>(entryPath: string): Promise<TModule>;
|
|
196
|
+
private shouldUseTsx;
|
|
197
|
+
private importWithTsx;
|
|
198
|
+
private importWithNode;
|
|
199
|
+
private resolveTsconfig;
|
|
200
|
+
private findNearestTsconfig;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
declare function resolveDefaultExport<TValue>(moduleExport: TValue): unknown;
|
|
204
|
+
|
|
205
|
+
declare const version: string;
|
|
206
|
+
|
|
207
|
+
export { BootstrapWriter, BuildCommand, ConfigLoader, ConfigLocator, DevCommand, type ModuleLoader, type ResolvedSeedcordDevConfig, RuntimeModuleLoader, SEEDCORD_CONFIG_FILENAMES, SeedcordBuildRunner, type SeedcordDevConfig, SeedcordDevRunner, SeedcordInstanceLoader, TypeScriptProjectBuilder, defineConfig, resolveDefaultExport, version };
|