servcraft 0.1.4 → 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.
- package/dist/cli/index.cjs +41 -5
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +37 -5
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/add-module.ts +80 -8
- package/src/cli/commands/init.ts +1 -1
- package/.claude/settings.local.json +0 -30
- package/npm-cache/_update-notifier-last-checked +0 -0
package/dist/cli/index.cjs
CHANGED
|
@@ -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
|
|
|
@@ -621,7 +625,7 @@ model User {
|
|
|
621
625
|
}
|
|
622
626
|
function generateEntryFile(options) {
|
|
623
627
|
const isTS = options.language === "typescript";
|
|
624
|
-
return `${isTS ? "import { createServer } from './core/server.js';\nimport { logger } from './core/logger.js';" : "
|
|
628
|
+
return `${isTS ? "import 'dotenv/config';\nimport { createServer } from './core/server.js';\nimport { logger } from './core/logger.js';" : "require('dotenv').config();\nconst { createServer } = require('./core/server.js');\nconst { logger } = require('./core/logger.js');"}
|
|
625
629
|
|
|
626
630
|
async function main()${isTS ? ": Promise<void>" : ""} {
|
|
627
631
|
const server = createServer();
|
|
@@ -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
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
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":
|