silgi 0.20.37 → 0.20.39

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.
@@ -1,4 +1,4 @@
1
- const version = "0.20.37";
1
+ const version = "0.20.39";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
package/dist/cli/dev.mjs CHANGED
@@ -1,15 +1,14 @@
1
+ import { basename } from 'node:path';
1
2
  import { watch } from 'chokidar';
2
3
  import { defineCommand, runCommand } from 'citty';
3
4
  import consola from 'consola';
4
5
  import { useSilgiCLI } from 'silgi/core';
5
6
  import { version } from 'silgi/meta';
6
7
  import { s as silgiCLIIClose } from '../_chunks/silgiApp.mjs';
7
- import { basename } from 'pathe';
8
- import { h as hasError } from './compatibility.mjs';
9
- import { s as scanFiles, w as writeScanFiles, g as generateApp, c as commonArgs, p as prepare } from './prepare.mjs';
8
+ import { c as commonArgs, p as prepare } from './prepare.mjs';
10
9
  import 'ufo';
11
10
  import 'unctx';
12
- import 'semver/functions/satisfies.js';
11
+ import 'pathe';
13
12
  import 'silgi/kit';
14
13
  import 'node:fs';
15
14
  import 'node:fs/promises';
@@ -21,6 +20,8 @@ import '@clack/prompts';
21
20
  import 'dotenv';
22
21
  import 'mlly';
23
22
  import 'dev-jiti';
23
+ import './compatibility.mjs';
24
+ import 'semver/functions/satisfies.js';
24
25
  import 'node:url';
25
26
  import 'defu';
26
27
  import 'exsolve';
@@ -42,19 +43,9 @@ import 'pathe/utils';
42
43
  import 'node:child_process';
43
44
  import 'picocolors';
44
45
 
45
- async function reloadScan(silgi, path, _stats) {
46
- const startTime = performance.now();
47
- silgi.errors = [];
46
+ async function reloadScan(path, _stats) {
47
+ const silgi = useSilgiCLI();
48
48
  await silgi.callHook("reload:scan", path, _stats);
49
- await scanFiles(silgi, silgi.options.devServer.watch);
50
- if (!hasError("Parser", silgi)) {
51
- await writeScanFiles(silgi);
52
- }
53
- await generateApp(silgi);
54
- silgi.errors = [];
55
- const endTime = performance.now();
56
- const elapsedTime = Math.round(endTime - startTime);
57
- silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
58
49
  }
59
50
 
60
51
  const dev = defineCommand({
@@ -79,19 +70,30 @@ const dev = defineCommand({
79
70
  rawArgs: ["--commands", "run"]
80
71
  });
81
72
  const silgi = useSilgiCLI();
73
+ silgi.options.dev = true;
82
74
  let watcher;
83
75
  if (silgi.options.devServer.watch.length > 0) {
84
76
  watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
85
- watcher.on("add", async (...data) => async () => {
77
+ watcher.on("add", async (path, stats) => {
78
+ const startTime = performance.now();
79
+ await reloadScan(path, stats);
86
80
  await runCommand(prepare, {
87
81
  rawArgs: ["--commands", "run"]
88
82
  });
89
- await reloadScan(silgi, ...data);
90
- }).on("change", async (...data) => async () => {
83
+ silgi.errors = [];
84
+ const endTime = performance.now();
85
+ const elapsedTime = Math.round(endTime - startTime);
86
+ silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
87
+ }).on("change", async (path, stats) => {
88
+ const startTime = performance.now();
89
+ await reloadScan(path, stats);
91
90
  await runCommand(prepare, {
92
91
  rawArgs: ["--commands", "run"]
93
92
  });
94
- await reloadScan(silgi, ...data);
93
+ silgi.errors = [];
94
+ const endTime = performance.now();
95
+ const elapsedTime = Math.round(endTime - startTime);
96
+ silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
95
97
  });
96
98
  }
97
99
  process.on("SIGINT", async () => {
@@ -564,11 +564,11 @@ async function installModules(silgi, prepare = false) {
564
564
  silgi.options.isPreparingModules = prepare;
565
565
  const jiti = createJiti(silgi.options.rootDir, {
566
566
  alias: silgi.options.alias,
567
- fsCache: false,
568
- moduleCache: false
567
+ fsCache: true,
568
+ moduleCache: true
569
569
  });
570
570
  for (const module of silgi.scanModules) {
571
- if (hasInstalledModule(module.meta.configKey)) {
571
+ if (hasInstalledModule(module.meta.configKey) && !silgi.options.dev) {
572
572
  silgi.logger.info(`Module ${module.meta.configKey} installed`);
573
573
  }
574
574
  try {
@@ -899,7 +899,7 @@ async function readScanFile(silgi) {
899
899
  throw new Error("Failed to inject imports");
900
900
  }
901
901
  const jiti = createJiti(silgi.options.rootDir, {
902
- fsCache: false,
902
+ fsCache: true,
903
903
  moduleCache: false,
904
904
  debug: silgi.options.debug,
905
905
  alias: silgi.options.alias
@@ -1290,11 +1290,10 @@ class SchemaParser {
1290
1290
  }
1291
1291
 
1292
1292
  async function scanFiles$1(silgi, watchFiles) {
1293
- const isWatch = watchFiles && watchFiles.length > 0;
1294
1293
  const filePaths = /* @__PURE__ */ new Set();
1295
1294
  const scannedPaths = [];
1296
1295
  const dir = silgi.options.serverDir;
1297
- const files = isWatch ? watchFiles : (await globby(dir, { cwd: silgi.options.rootDir, ignore: silgi.options.ignore })).sort();
1296
+ const files = (await globby(dir, { cwd: silgi.options.rootDir, ignore: silgi.options.ignore })).sort();
1298
1297
  if (files.length) {
1299
1298
  const siblings = await readdir(dirname(dir)).catch(() => []);
1300
1299
  const directory = basename(dir);
@@ -2664,4 +2663,4 @@ const prepare$1 = {
2664
2663
  default: prepare
2665
2664
  };
2666
2665
 
2667
- export { prepare$1 as a, commonArgs as c, generateApp as g, prepare as p, run$1 as r, scanFiles$1 as s, writeScanFiles as w };
2666
+ export { prepare$1 as a, commonArgs as c, prepare as p, run$1 as r };
@@ -1,4 +1,4 @@
1
- const version = "0.20.37";
1
+ const version = "0.20.39";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
@@ -1,4 +1,4 @@
1
- const version = "0.20.37";
1
+ const version = "0.20.39";
2
2
  const peerDependencies = {
3
3
  "@fastify/deepmerge": "^3.0.0",
4
4
  "@nuxt/kit": "^3.15.3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.20.37",
4
+ "version": "0.20.39",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {