@korajs/cli 0.1.1 → 0.1.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/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");
@@ -305,6 +305,7 @@ function createReadline(options) {
305
305
  }
306
306
 
307
307
  // src/commands/create/template-engine.ts
308
+ var import_node_fs = require("fs");
308
309
  var import_promises2 = require("fs/promises");
309
310
  var import_node_path2 = require("path");
310
311
  var import_node_url = require("url");
@@ -316,8 +317,15 @@ function substituteVariables(template, context) {
316
317
  });
317
318
  }
318
319
  function getTemplatePath(templateName) {
320
+ let dir = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
321
+ for (let i = 0; i < 5; i++) {
322
+ if ((0, import_node_fs.existsSync)((0, import_node_path2.resolve)(dir, "templates"))) {
323
+ return (0, import_node_path2.resolve)(dir, "templates", templateName);
324
+ }
325
+ dir = (0, import_node_path2.dirname)(dir);
326
+ }
319
327
  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);
328
+ return (0, import_node_path2.resolve)(currentDir, "..", "templates", templateName);
321
329
  }
322
330
  async function scaffoldTemplate(templateName, targetDir, context) {
323
331
  const templateDir = getTemplatePath(templateName);
@@ -441,9 +449,18 @@ function isValidPackageManager(value) {
441
449
  }
442
450
  function resolveKoraVersion() {
443
451
  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}`;
452
+ let dir = (0, import_node_path3.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
453
+ for (let i = 0; i < 5; i++) {
454
+ const pkgPath = (0, import_node_path3.resolve)(dir, "package.json");
455
+ if ((0, import_node_fs2.existsSync)(pkgPath)) {
456
+ const pkg = JSON.parse((0, import_node_fs2.readFileSync)(pkgPath, "utf-8"));
457
+ if (pkg.name === "@korajs/cli") {
458
+ return pkg.version === "0.0.0" ? "latest" : `^${pkg.version}`;
459
+ }
460
+ }
461
+ dir = (0, import_node_path3.dirname)(dir);
462
+ }
463
+ return "latest";
447
464
  } catch {
448
465
  return "latest";
449
466
  }
@@ -638,7 +655,7 @@ function delay(ms) {
638
655
 
639
656
  // src/commands/dev/schema-watcher.ts
640
657
  var import_node_child_process5 = require("child_process");
641
- var import_node_fs2 = require("fs");
658
+ var import_node_fs3 = require("fs");
642
659
  var SchemaWatcher = class {
643
660
  constructor(config) {
644
661
  this.config = config;
@@ -650,7 +667,7 @@ var SchemaWatcher = class {
650
667
  debounceTimer = null;
651
668
  start() {
652
669
  if (this.watcher) return;
653
- this.watcher = (0, import_node_fs2.watch)(this.config.schemaPath, () => {
670
+ this.watcher = (0, import_node_fs3.watch)(this.config.schemaPath, () => {
654
671
  this.scheduleRegeneration();
655
672
  });
656
673
  this.watcher.on("error", (error) => {