servcraft 0.1.5 → 0.1.6

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.
@@ -23,6 +23,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  mod
24
24
  ));
25
25
 
26
+ // node_modules/tsup/assets/cjs_shims.js
27
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
28
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
29
+
26
30
  // src/cli/index.ts
27
31
  var import_commander5 = require("commander");
28
32
 
@@ -3555,11 +3559,43 @@ export interface ${name.charAt(0).toUpperCase() + name.slice(1)}Data {
3555
3559
  await writeFile(import_path4.default.join(dir, fileName), content);
3556
3560
  }
3557
3561
  }
3562
+ async function findServercraftModules() {
3563
+ const scriptDir = import_path4.default.dirname(new URL(importMetaUrl).pathname);
3564
+ const possiblePaths = [
3565
+ // Local node_modules (when servcraft is a dependency)
3566
+ import_path4.default.join(process.cwd(), "node_modules", "servcraft", "src", "modules"),
3567
+ // From dist/cli/index.js -> src/modules (npx or global install)
3568
+ import_path4.default.resolve(scriptDir, "..", "..", "src", "modules"),
3569
+ // From src/cli/commands/add-module.ts -> src/modules (development)
3570
+ import_path4.default.resolve(scriptDir, "..", "..", "modules")
3571
+ ];
3572
+ for (const p of possiblePaths) {
3573
+ try {
3574
+ const stats = await fs5.stat(p);
3575
+ if (stats.isDirectory()) {
3576
+ return p;
3577
+ }
3578
+ } catch {
3579
+ }
3580
+ }
3581
+ return null;
3582
+ }
3558
3583
  async function generateModuleFiles(moduleName, moduleDir) {
3559
- const sourceModuleDir = import_path4.default.join(process.cwd(), "src", "modules", moduleName);
3560
- if (await fileExists(sourceModuleDir)) {
3561
- await copyModuleFromSource(sourceModuleDir, moduleDir);
3562
- return;
3584
+ const moduleNameMap = {
3585
+ "users": "user",
3586
+ "rate-limit": "rate-limit",
3587
+ "feature-flag": "feature-flag",
3588
+ "api-versioning": "api-versioning",
3589
+ "media-processing": "media-processing"
3590
+ };
3591
+ const sourceDirName = moduleNameMap[moduleName] || moduleName;
3592
+ const servercraftModulesDir = await findServercraftModules();
3593
+ if (servercraftModulesDir) {
3594
+ const sourceModuleDir = import_path4.default.join(servercraftModulesDir, sourceDirName);
3595
+ if (await fileExists(sourceModuleDir)) {
3596
+ await copyModuleFromSource(sourceModuleDir, moduleDir);
3597
+ return;
3598
+ }
3563
3599
  }
3564
3600
  switch (moduleName) {
3565
3601
  case "auth":