@korajs/cli 0.1.1 → 0.1.3

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/bin.cjs CHANGED
@@ -27,7 +27,7 @@ var import_citty5 = require("citty");
27
27
 
28
28
  // src/commands/create/create-command.ts
29
29
  var import_node_child_process2 = require("child_process");
30
- var import_node_fs = require("fs");
30
+ var import_node_fs2 = require("fs");
31
31
  var import_node_path3 = require("path");
32
32
  var import_node_url2 = require("url");
33
33
  var import_citty = require("citty");
@@ -147,13 +147,16 @@ async function findSchemaFile(projectRoot) {
147
147
  return null;
148
148
  }
149
149
  async function resolveProjectBinary(projectRoot, binaryName) {
150
- const binaryPath = (0, import_node_path.join)(projectRoot, "node_modules", ".bin", binaryName);
151
- try {
152
- await (0, import_promises.access)(binaryPath);
153
- return binaryPath;
154
- } catch {
155
- return null;
150
+ const binDir = (0, import_node_path.join)(projectRoot, "node_modules", ".bin");
151
+ const candidates = process.platform === "win32" ? [(0, import_node_path.join)(binDir, `${binaryName}.cmd`), (0, import_node_path.join)(binDir, binaryName)] : [(0, import_node_path.join)(binDir, binaryName)];
152
+ for (const candidate of candidates) {
153
+ try {
154
+ await (0, import_promises.access)(candidate);
155
+ return candidate;
156
+ } catch {
157
+ }
156
158
  }
159
+ return null;
157
160
  }
158
161
  function isKoraProject(pkg) {
159
162
  if (typeof pkg !== "object" || pkg === null) return false;
@@ -305,6 +308,7 @@ function createReadline(options) {
305
308
  }
306
309
 
307
310
  // src/commands/create/template-engine.ts
311
+ var import_node_fs = require("fs");
308
312
  var import_promises2 = require("fs/promises");
309
313
  var import_node_path2 = require("path");
310
314
  var import_node_url = require("url");
@@ -316,8 +320,15 @@ function substituteVariables(template, context) {
316
320
  });
317
321
  }
318
322
  function getTemplatePath(templateName) {
323
+ let dir = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
324
+ for (let i = 0; i < 5; i++) {
325
+ if ((0, import_node_fs.existsSync)((0, import_node_path2.resolve)(dir, "templates"))) {
326
+ return (0, import_node_path2.resolve)(dir, "templates", templateName);
327
+ }
328
+ dir = (0, import_node_path2.dirname)(dir);
329
+ }
319
330
  const currentDir = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
320
- return (0, import_node_path2.resolve)(currentDir, "..", "..", "..", "templates", templateName);
331
+ return (0, import_node_path2.resolve)(currentDir, "..", "templates", templateName);
321
332
  }
322
333
  async function scaffoldTemplate(templateName, targetDir, context) {
323
334
  const templateDir = getTemplatePath(templateName);
@@ -441,9 +452,18 @@ function isValidPackageManager(value) {
441
452
  }
442
453
  function resolveKoraVersion() {
443
454
  try {
444
- const cliDir = (0, import_node_path3.resolve)((0, import_node_path3.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url)), "..", "..", "..");
445
- const pkg = JSON.parse((0, import_node_fs.readFileSync)((0, import_node_path3.resolve)(cliDir, "package.json"), "utf-8"));
446
- return pkg.version === "0.0.0" ? "latest" : `^${pkg.version}`;
455
+ let dir = (0, import_node_path3.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
456
+ for (let i = 0; i < 5; i++) {
457
+ const pkgPath = (0, import_node_path3.resolve)(dir, "package.json");
458
+ if ((0, import_node_fs2.existsSync)(pkgPath)) {
459
+ const pkg = JSON.parse((0, import_node_fs2.readFileSync)(pkgPath, "utf-8"));
460
+ if (pkg.name === "@korajs/cli") {
461
+ return pkg.version === "0.0.0" ? "latest" : `^${pkg.version}`;
462
+ }
463
+ }
464
+ dir = (0, import_node_path3.dirname)(dir);
465
+ }
466
+ return "latest";
447
467
  } catch {
448
468
  return "latest";
449
469
  }
@@ -557,7 +577,9 @@ var ProcessManager = class {
557
577
  const options = {
558
578
  cwd: config.cwd,
559
579
  env: { ...process.env, ...config.env },
560
- stdio: ["ignore", "pipe", "pipe"]
580
+ stdio: ["ignore", "pipe", "pipe"],
581
+ // On Windows, .cmd shims require shell to execute
582
+ shell: process.platform === "win32"
561
583
  };
562
584
  const child = (0, import_node_child_process4.spawn)(config.command, config.args, options);
563
585
  let resolveExit;
@@ -638,7 +660,7 @@ function delay(ms) {
638
660
 
639
661
  // src/commands/dev/schema-watcher.ts
640
662
  var import_node_child_process5 = require("child_process");
641
- var import_node_fs2 = require("fs");
663
+ var import_node_fs3 = require("fs");
642
664
  var SchemaWatcher = class {
643
665
  constructor(config) {
644
666
  this.config = config;
@@ -650,7 +672,7 @@ var SchemaWatcher = class {
650
672
  debounceTimer = null;
651
673
  start() {
652
674
  if (this.watcher) return;
653
- this.watcher = (0, import_node_fs2.watch)(this.config.schemaPath, () => {
675
+ this.watcher = (0, import_node_fs3.watch)(this.config.schemaPath, () => {
654
676
  this.scheduleRegeneration();
655
677
  });
656
678
  this.watcher.on("error", (error) => {
@@ -787,7 +809,7 @@ var devCommand = (0, import_citty2.defineCommand)({
787
809
  }
788
810
  if (shouldStartSync && syncServerFile === null && managedSyncStore) {
789
811
  const hasServerPackage = await fileExists(
790
- (0, import_node_path5.join)(projectRoot, "node_modules", "@kora", "server", "package.json")
812
+ (0, import_node_path5.join)(projectRoot, "node_modules", "@korajs", "server", "package.json")
791
813
  );
792
814
  if (!hasServerPackage) {
793
815
  logger.warn(