seedcord 0.21.0 → 0.21.2

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
 
8
8
  <div align="center">
9
- <h3>The whole Discord bot, wired and typed</h3>
9
+ <h3>The whole Discord bot, typed end to end</h3>
10
10
  <a href="https://seedcord.org">Website</a> ·
11
11
  <a href="https://guide.seedcord.org">Guide</a> ·
12
12
  <a href="https://docs.seedcord.org">Reference</a> ·
package/dist/cli.mjs CHANGED
@@ -1,13 +1,14 @@
1
- import { n as SEEDCORD_CONFIG_FILENAMES, t as version } from "./src-CZ2Lqriy.mjs";
2
- import { createRequire } from "node:module";
1
+ import { n as SEEDCORD_CONFIG_FILENAMES, t as version } from "./src-DiTXfD0A.mjs";
2
+ import { createRequire, findPackageJSON } from "node:module";
3
3
  import { Command } from "@commander-js/extra-typings";
4
4
  import { LEVEL_COLOR, Logger, LoggerChannelRegistry } from "@seedcord/logger";
5
5
  import { formatBody, installNodeDefaults } from "@seedcord/logger/node";
6
6
  import { Envapter, Environment } from "envapt";
7
7
  import { SeedcordErrorCode, isSeedcordError, paint } from "@seedcord/errors";
8
- import { existsSync, realpathSync } from "node:fs";
8
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
9
9
  import { BRAND, SeedcordError, validateDiscordToken } from "@seedcord/errors/internal";
10
10
  import { delimiter, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
11
+ import { isPlainObject, routeLeavesOf } from "@seedcord/utils/internal";
11
12
  import { pathToFileURL } from "node:url";
12
13
  import { createJiti } from "jiti";
13
14
  import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
@@ -17,7 +18,6 @@ import { isCommandClass, wrapHot } from "@seedcord/core/internal";
17
18
  import { HostAugmentTarget, HostPluginKeys, HostShutdown, HostStartup, HostVersion, SeedcordBrand } from "@seedcord/types/internal";
18
19
  import { isTsOrJsFile } from "@seedcord/utils/node";
19
20
  import { ApplicationCommandOptionType, ApplicationCommandType, InteractionContextType, RESTJSONErrorCodes, Routes } from "discord-api-types/v10";
20
- import { routeLeavesOf } from "@seedcord/utils/internal";
21
21
  import { DiscordAPIError, REST } from "@discordjs/rest";
22
22
  import { autocompleteMultiselect, cancel, confirm, intro, isCancel, log, multiselect, note, outro, select, spinner } from "@clack/prompts";
23
23
  import { createInterface } from "node:readline";
@@ -65,9 +65,6 @@ function isObjectWithDefault(value) {
65
65
 
66
66
  //#endregion
67
67
  //#region src/core/config/ConfigLoader.ts
68
- function isPlainObject(value) {
69
- return typeof value === "object" && value !== null && !Array.isArray(value);
70
- }
71
68
  function isOptionalString(value) {
72
69
  return value === void 0 || typeof value === "string";
73
70
  }
@@ -3228,6 +3225,70 @@ var HmrPlugin = class extends TypedEventEmitter {
3228
3225
  }
3229
3226
  };
3230
3227
 
3228
+ //#endregion
3229
+ //#region src/commands/dev/runtime/seedcordDependents.ts
3230
+ const PROJECT_FIELDS = [
3231
+ "dependencies",
3232
+ "devDependencies",
3233
+ "optionalDependencies"
3234
+ ];
3235
+ const PACKAGE_FIELDS = ["dependencies", "peerDependencies"];
3236
+ function dependencyNames(manifestPath, fields) {
3237
+ const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, "utf8")) : void 0;
3238
+ if (!isPlainObject(manifest)) return [];
3239
+ return fields.flatMap((field) => {
3240
+ const deps = manifest[field];
3241
+ return isPlainObject(deps) ? Object.keys(deps) : [];
3242
+ });
3243
+ }
3244
+ function installedManifest(name, fromManifest) {
3245
+ try {
3246
+ return findPackageJSON(name, pathToFileURL(fromManifest));
3247
+ } catch (error) {
3248
+ if (Error.isError(error) && "code" in error && error.code === "ERR_MODULE_NOT_FOUND") return void 0;
3249
+ throw error;
3250
+ }
3251
+ }
3252
+ function isSeedcordPackage(name) {
3253
+ return name.startsWith("@seedcord/");
3254
+ }
3255
+ function installedGraph(projectDir) {
3256
+ const edges = /* @__PURE__ */ new Map();
3257
+ const listsSeedcord = /* @__PURE__ */ new Set();
3258
+ const collect = (manifestPath, fields) => {
3259
+ if (edges.has(manifestPath)) return;
3260
+ const children = /* @__PURE__ */ new Map();
3261
+ edges.set(manifestPath, children);
3262
+ for (const name of dependencyNames(manifestPath, fields)) {
3263
+ if (isSeedcordPackage(name)) listsSeedcord.add(manifestPath);
3264
+ const depManifest = installedManifest(name, manifestPath);
3265
+ if (depManifest === void 0) continue;
3266
+ children.set(name, depManifest);
3267
+ collect(depManifest, PACKAGE_FIELDS);
3268
+ }
3269
+ };
3270
+ collect(join(projectDir, "package.json"), PROJECT_FIELDS);
3271
+ return {
3272
+ edges,
3273
+ listsSeedcord
3274
+ };
3275
+ }
3276
+ function seedcordDependents(projectDir) {
3277
+ const { edges, listsSeedcord } = installedGraph(projectDir);
3278
+ const parentsOf = /* @__PURE__ */ new Map();
3279
+ for (const [manifest, children] of edges) for (const depManifest of children.values()) parentsOf.set(depManifest, [...parentsOf.get(depManifest) ?? [], manifest]);
3280
+ const dependsOnSeedcord = new Set(listsSeedcord);
3281
+ const queue = [...listsSeedcord];
3282
+ for (const manifest of queue) for (const parent of parentsOf.get(manifest) ?? []) {
3283
+ if (dependsOnSeedcord.has(parent)) continue;
3284
+ dependsOnSeedcord.add(parent);
3285
+ queue.push(parent);
3286
+ }
3287
+ const found = /* @__PURE__ */ new Set();
3288
+ for (const children of edges.values()) for (const [name, depManifest] of children) if (dependsOnSeedcord.has(depManifest) && !isSeedcordPackage(name)) found.add(name);
3289
+ return [...found];
3290
+ }
3291
+
3231
3292
  //#endregion
3232
3293
  //#region src/commands/dev/runtime/vite.config.ts
3233
3294
  function logsIgnore(root) {
@@ -3305,11 +3366,14 @@ var ViteDevRuntime = class {
3305
3366
  });
3306
3367
  const hmrPlugin = new HmrPlugin(this.context.config);
3307
3368
  this.hmrPlugin = hmrPlugin;
3308
- const config = mergeConfig(vite_config_default, {
3369
+ const projectDir = dirname(this.context.config.configFile);
3370
+ const base = structuredClone(vite_config_default);
3371
+ const config = mergeConfig(base, {
3309
3372
  root: projectRoot,
3310
3373
  configFile: false,
3311
3374
  server: { watch: { ignored: [logsIgnore(projectRoot)] } },
3312
- plugins: [tsconfigPaths({ root: dirname(this.context.config.configFile) }), hmrPlugin.plugin]
3375
+ ssr: { noExternal: seedcordDependents(projectDir) },
3376
+ plugins: [tsconfigPaths({ root: projectDir }), hmrPlugin.plugin]
3313
3377
  });
3314
3378
  this.viteServer = await createServer(config);
3315
3379
  this.evaluatedModules = new EvaluatedModules();