seedcord 0.22.0-next.0 → 0.22.0-next.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/dist/cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as SEEDCORD_CONFIG_FILENAMES, t as version } from "./src-
|
|
1
|
+
import { n as SEEDCORD_CONFIG_FILENAMES, t as version } from "./src-CbQWW68A.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { Command, Option } from "@commander-js/extra-typings";
|
|
4
4
|
import { SeedcordErrorCode, isSeedcordError, paint } from "@seedcord/errors";
|
|
@@ -14,7 +14,7 @@ import chalk from "chalk";
|
|
|
14
14
|
import { basename, delimiter, dirname, join, posix, relative, resolve, win32 } from "node:path";
|
|
15
15
|
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
|
|
16
16
|
import { CONSOLE_LEVEL, CONSOLE_METHODS, consoleRecord, logsFolderIn, routeConsole, traceError } from "@seedcord/logger/internal";
|
|
17
|
-
import { BOT_FILES_KEY, BUILT_FILES_READY_KEY, BotLayout, asError, encodeFile, hasErrorCode, importFailed, isInside, isPlainObject, isPortInUse, isStringArray, pluralize, posixRelative, recordThrownBy, routeLeavesOf, setDevFiles, toPosixPath, unlessAborted, vitePluginThrew, withoutQuery, workerdPath } from "@seedcord/utils/internal";
|
|
17
|
+
import { BOT_FILES_KEY, BUILT_FILES_READY_KEY, BotLayout, asError, encodeFile, hasErrorCode, importFailed, isInside, isInteractive, isPlainObject, isPortInUse, isStringArray, pluralize, posixRelative, recordThrownBy, routeLeavesOf, setDevFiles, toPosixPath, unlessAborted, vitePluginThrew, withoutQuery, workerdPath } from "@seedcord/utils/internal";
|
|
18
18
|
import { spawn } from "node:child_process";
|
|
19
19
|
import { HostAugmentTarget, HostListenHost, HostPluginKeys, HostShutdown, HostStartup, HostVersion, SeedcordBrand } from "@seedcord/types/internal";
|
|
20
20
|
import { Visitor, createBuilder, createLogger, createServer, createServerModuleRunner, loadEnv, mergeConfig, preview } from "vite";
|
|
@@ -1474,12 +1474,12 @@ var ProjectLoader = class {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
async readConfig(projectDir = process.cwd(), check) {
|
|
1476
1476
|
try {
|
|
1477
|
-
var _usingCtx$
|
|
1477
|
+
var _usingCtx$8 = _usingCtx();
|
|
1478
1478
|
const configPath = realPath(locateConfig(projectDir));
|
|
1479
1479
|
const configDir = realPath(dirname(configPath));
|
|
1480
1480
|
const mode = this.shell.applyMode(this.defaultMode, configDir);
|
|
1481
1481
|
const target = detectTarget(configDir);
|
|
1482
|
-
const stack = _usingCtx$
|
|
1482
|
+
const stack = _usingCtx$8.a(new AsyncDisposableStack());
|
|
1483
1483
|
const configModules = stack.use(await this.openModules(configDir, target, mode, "config"));
|
|
1484
1484
|
const config = await this.resolveConfig(configModules, configPath, target, mode);
|
|
1485
1485
|
const project = new Project(config, new ProjectFiles(config), configModules);
|
|
@@ -1490,9 +1490,9 @@ var ProjectLoader = class {
|
|
|
1490
1490
|
const loaded = new LoadedConfig(config, project.files);
|
|
1491
1491
|
return loaded.hasVitePlugins ? new LoadedConfig(config, project.files, stack.move()) : loaded;
|
|
1492
1492
|
} catch (_) {
|
|
1493
|
-
_usingCtx$
|
|
1493
|
+
_usingCtx$8.e = _;
|
|
1494
1494
|
} finally {
|
|
1495
|
-
await _usingCtx$
|
|
1495
|
+
await _usingCtx$8.d();
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
async openProject(loaded) {
|
|
@@ -1913,7 +1913,7 @@ function lazyWorkerEnv(cloudflareConfig, mode, loaded) {
|
|
|
1913
1913
|
}
|
|
1914
1914
|
async function openModuleLoader(projectDir, target, mode, use, devCopy) {
|
|
1915
1915
|
try {
|
|
1916
|
-
var _usingCtx$
|
|
1916
|
+
var _usingCtx$7 = _usingCtx();
|
|
1917
1917
|
const runsWorkerCode = target.kind === "edge" && use !== "config";
|
|
1918
1918
|
const workerEnv = target.kind === "edge" ? lazyWorkerEnv(target.cloudflareConfig, mode, devCopy?.workerEnv) : void 0;
|
|
1919
1919
|
if (runsWorkerCode) await workerEnv?.();
|
|
@@ -1937,7 +1937,7 @@ async function openModuleLoader(projectDir, target, mode, use, devCopy) {
|
|
|
1937
1937
|
},
|
|
1938
1938
|
plugins: [...workerEnv ? [edgeStandIns(workerEnv)] : [], userPlugins]
|
|
1939
1939
|
});
|
|
1940
|
-
const onFailure = _usingCtx$
|
|
1940
|
+
const onFailure = _usingCtx$7.a(new AsyncDisposableStack());
|
|
1941
1941
|
const server = await openViteServer(onFailure, config);
|
|
1942
1942
|
const runner = createServerModuleRunner(botEnvironment(server.environments), { hmr: false });
|
|
1943
1943
|
onFailure.defer(() => runner.close());
|
|
@@ -1946,9 +1946,9 @@ async function openModuleLoader(projectDir, target, mode, use, devCopy) {
|
|
|
1946
1946
|
onFailure.move();
|
|
1947
1947
|
return loader;
|
|
1948
1948
|
} catch (_) {
|
|
1949
|
-
_usingCtx$
|
|
1949
|
+
_usingCtx$7.e = _;
|
|
1950
1950
|
} finally {
|
|
1951
|
-
await _usingCtx$
|
|
1951
|
+
await _usingCtx$7.d();
|
|
1952
1952
|
}
|
|
1953
1953
|
}
|
|
1954
1954
|
|
|
@@ -2542,13 +2542,13 @@ function scopesInCode(found, configuredGuilds) {
|
|
|
2542
2542
|
}
|
|
2543
2543
|
async function loadInstance({ projectLoader }, projectDir) {
|
|
2544
2544
|
try {
|
|
2545
|
-
var _usingCtx$
|
|
2546
|
-
const project = _usingCtx$
|
|
2545
|
+
var _usingCtx$6 = _usingCtx();
|
|
2546
|
+
const project = _usingCtx$6.a(await openProjectWithSteps(quietSteps, projectLoader, { projectDir }));
|
|
2547
2547
|
return await importInstance(project.modules, project.config.instance);
|
|
2548
2548
|
} catch (_) {
|
|
2549
|
-
_usingCtx$
|
|
2549
|
+
_usingCtx$6.e = _;
|
|
2550
2550
|
} finally {
|
|
2551
|
-
await _usingCtx$
|
|
2551
|
+
await _usingCtx$6.d();
|
|
2552
2552
|
}
|
|
2553
2553
|
}
|
|
2554
2554
|
async function loadCodeScopes(steps, { projectLoader }, projectDir) {
|
|
@@ -3054,13 +3054,13 @@ var BuildRunner = class BuildRunner {
|
|
|
3054
3054
|
}
|
|
3055
3055
|
async run(projectDir = process.cwd()) {
|
|
3056
3056
|
try {
|
|
3057
|
-
var _usingCtx$
|
|
3057
|
+
var _usingCtx$5 = _usingCtx();
|
|
3058
3058
|
const { steps, typeChecker } = this.deps;
|
|
3059
3059
|
const opened = await openProjectWithSteps(steps, this.deps.projectLoader, {
|
|
3060
3060
|
projectDir,
|
|
3061
3061
|
check: checkBuildTarget
|
|
3062
3062
|
});
|
|
3063
|
-
const build = _usingCtx$
|
|
3063
|
+
const build = _usingCtx$5.a(this.deps.buildFor(opened));
|
|
3064
3064
|
const { project } = build;
|
|
3065
3065
|
const { config, modules } = project;
|
|
3066
3066
|
printResolvedConfig(steps, config);
|
|
@@ -3080,9 +3080,9 @@ var BuildRunner = class BuildRunner {
|
|
|
3080
3080
|
nextCommands: build.nextCommands(bundle)
|
|
3081
3081
|
};
|
|
3082
3082
|
} catch (_) {
|
|
3083
|
-
_usingCtx$
|
|
3083
|
+
_usingCtx$5.e = _;
|
|
3084
3084
|
} finally {
|
|
3085
|
-
await _usingCtx$
|
|
3085
|
+
await _usingCtx$5.d();
|
|
3086
3086
|
}
|
|
3087
3087
|
}
|
|
3088
3088
|
async bundle(build, instance) {
|
|
@@ -3357,9 +3357,9 @@ var CodegenRunner = class CodegenRunner {
|
|
|
3357
3357
|
}
|
|
3358
3358
|
async run(check) {
|
|
3359
3359
|
try {
|
|
3360
|
-
var _usingCtx$
|
|
3360
|
+
var _usingCtx$4 = _usingCtx();
|
|
3361
3361
|
const { steps, projectLoader } = this.deps;
|
|
3362
|
-
const { config, files, modules } = _usingCtx$
|
|
3362
|
+
const { config, files, modules } = _usingCtx$4.a(await openProjectWithSteps(steps, projectLoader));
|
|
3363
3363
|
printResolvedConfig(steps, config);
|
|
3364
3364
|
const instance = await steps.step("load bot", () => importInstance(modules, config.instance));
|
|
3365
3365
|
return await this.generate({
|
|
@@ -3369,9 +3369,9 @@ var CodegenRunner = class CodegenRunner {
|
|
|
3369
3369
|
modules
|
|
3370
3370
|
}, check);
|
|
3371
3371
|
} catch (_) {
|
|
3372
|
-
_usingCtx$
|
|
3372
|
+
_usingCtx$4.e = _;
|
|
3373
3373
|
} finally {
|
|
3374
|
-
await _usingCtx$
|
|
3374
|
+
await _usingCtx$4.d();
|
|
3375
3375
|
}
|
|
3376
3376
|
}
|
|
3377
3377
|
async writeFrom(bot) {
|
|
@@ -3433,12 +3433,6 @@ var CodegenCommand = class extends BaseCommand {
|
|
|
3433
3433
|
}
|
|
3434
3434
|
};
|
|
3435
3435
|
|
|
3436
|
-
//#endregion
|
|
3437
|
-
//#region src/core/interactive.ts
|
|
3438
|
-
function isInteractive() {
|
|
3439
|
-
return process.stdin.isTTY === true && process.stdout.isTTY === true && !process.env.CI;
|
|
3440
|
-
}
|
|
3441
|
-
|
|
3442
3436
|
//#endregion
|
|
3443
3437
|
//#region src/core/output/stderrSteps.ts
|
|
3444
3438
|
function stderrSteps(stdout = process.stdout, stderr = process.stderr) {
|
|
@@ -7749,13 +7743,13 @@ var DevRunner = class DevRunner {
|
|
|
7749
7743
|
}
|
|
7750
7744
|
async runSession() {
|
|
7751
7745
|
try {
|
|
7752
|
-
var _usingCtx$
|
|
7746
|
+
var _usingCtx$3 = _usingCtx();
|
|
7753
7747
|
const { store, tunnel } = this.deps;
|
|
7754
7748
|
resetChannelColors();
|
|
7755
7749
|
store.setPhase("starting");
|
|
7756
7750
|
store.setBusy(true);
|
|
7757
7751
|
const restarts = this.restarts;
|
|
7758
|
-
const { config, files } = _usingCtx$
|
|
7752
|
+
const { config, files } = _usingCtx$3.a(await this.deps.projectLoader.readConfig());
|
|
7759
7753
|
if (this.next !== "session" || this.restarts !== restarts) return;
|
|
7760
7754
|
profileMark("config");
|
|
7761
7755
|
store.setIdleAnimation(config.idleAnimation);
|
|
@@ -7771,9 +7765,9 @@ var DevRunner = class DevRunner {
|
|
|
7771
7765
|
this.currentSession = null;
|
|
7772
7766
|
}
|
|
7773
7767
|
} catch (_) {
|
|
7774
|
-
_usingCtx$
|
|
7768
|
+
_usingCtx$3.e = _;
|
|
7775
7769
|
} finally {
|
|
7776
|
-
await _usingCtx$
|
|
7770
|
+
await _usingCtx$3.d();
|
|
7777
7771
|
}
|
|
7778
7772
|
}
|
|
7779
7773
|
async quit() {
|
|
@@ -7816,26 +7810,56 @@ var DevRunner = class DevRunner {
|
|
|
7816
7810
|
//#endregion
|
|
7817
7811
|
//#region src/commands/dev/runPlain.ts
|
|
7818
7812
|
const logger = cliLogger("Dev");
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7813
|
+
const COMMANDS = /* @__PURE__ */ new Map([
|
|
7814
|
+
["restart", (runner) => runner.restart()],
|
|
7815
|
+
["disconnect", (runner) => runner.disconnect()],
|
|
7816
|
+
["quit", (runner) => runner.quit()]
|
|
7817
|
+
]);
|
|
7818
|
+
function commandOn(line) {
|
|
7819
|
+
try {
|
|
7820
|
+
return COMMANDS.get(JSON.parse(line)?.do);
|
|
7821
|
+
} catch {
|
|
7822
|
+
return;
|
|
7823
|
+
}
|
|
7824
|
+
}
|
|
7825
|
+
function leaveToRun(command) {
|
|
7826
|
+
command.catch(() => void 0);
|
|
7827
|
+
}
|
|
7828
|
+
async function runPlain(store, runner, input) {
|
|
7833
7829
|
try {
|
|
7834
|
-
|
|
7830
|
+
var _usingCtx$2 = _usingCtx();
|
|
7831
|
+
let failure;
|
|
7832
|
+
const answer = () => {
|
|
7833
|
+
const { phase, commandUpdatePrompt, error } = store.getState();
|
|
7834
|
+
if (commandUpdatePrompt !== null) runner.refreshCommands(true);
|
|
7835
|
+
if (phase === "restart-required") {
|
|
7836
|
+
logger.info("Restarting to pick up the change");
|
|
7837
|
+
leaveToRun(runner.restart());
|
|
7838
|
+
} else if (phase === "error" && error !== null) {
|
|
7839
|
+
failure ??= error;
|
|
7840
|
+
leaveToRun(runner.quit());
|
|
7841
|
+
}
|
|
7842
|
+
};
|
|
7843
|
+
_usingCtx$2.u(createInterface({
|
|
7844
|
+
input,
|
|
7845
|
+
terminal: false
|
|
7846
|
+
})).on("line", (line) => {
|
|
7847
|
+
const command = commandOn(line);
|
|
7848
|
+
if (command) leaveToRun(command(runner));
|
|
7849
|
+
else logger.warn(`Ignoring stdin line: ${line}`);
|
|
7850
|
+
});
|
|
7851
|
+
store.on("change", answer);
|
|
7852
|
+
try {
|
|
7853
|
+
await runner.run();
|
|
7854
|
+
} finally {
|
|
7855
|
+
store.off("change", answer);
|
|
7856
|
+
}
|
|
7857
|
+
if (failure) throw failure;
|
|
7858
|
+
} catch (_) {
|
|
7859
|
+
_usingCtx$2.e = _;
|
|
7835
7860
|
} finally {
|
|
7836
|
-
|
|
7861
|
+
_usingCtx$2.d();
|
|
7837
7862
|
}
|
|
7838
|
-
if (failure) throw failure;
|
|
7839
7863
|
}
|
|
7840
7864
|
|
|
7841
7865
|
//#endregion
|
|
@@ -7855,7 +7879,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
7855
7879
|
try {
|
|
7856
7880
|
var _usingCtx$1 = _usingCtx();
|
|
7857
7881
|
_usingCtx$1.u(DevSignals.own(() => void runner.quit()));
|
|
7858
|
-
await (isInteractive() ? this.runDevApp(store, runner, stateFolder) : runPlain(store, runner));
|
|
7882
|
+
await (isInteractive() ? this.runDevApp(store, runner, stateFolder) : runPlain(store, runner, process.stdin));
|
|
7859
7883
|
} catch (_) {
|
|
7860
7884
|
_usingCtx$1.e = _;
|
|
7861
7885
|
} finally {
|