prev-cli 0.24.1 → 0.24.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.
Files changed (2) hide show
  1. package/dist/cli.js +53 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -887,7 +887,14 @@ async function createViteConfig(options) {
887
887
  remarkPlugins: [remarkGfm],
888
888
  rehypePlugins: [rehypeHighlight],
889
889
  providerImportSource: "@mdx-js/react",
890
- exclude: /node_modules/
890
+ include: [
891
+ path8.join(rootDir, "**/*.md"),
892
+ path8.join(rootDir, "**/*.mdx")
893
+ ],
894
+ exclude: [
895
+ "**/node_modules/**",
896
+ "**/.git/**"
897
+ ]
891
898
  }),
892
899
  react(),
893
900
  createConfigPlugin(config),
@@ -1088,7 +1095,11 @@ async function createViteConfig(options) {
1088
1095
  main: path8.join(srcRoot2, "theme/index.html")
1089
1096
  }
1090
1097
  }
1091
- }
1098
+ },
1099
+ assetsInclude: [
1100
+ "**/node_modules/**/*.md",
1101
+ "**/node_modules/**/*.mdx"
1102
+ ]
1092
1103
  };
1093
1104
  }
1094
1105
 
@@ -1178,11 +1189,11 @@ function clearCache(rootDir) {
1178
1189
  }
1179
1190
  function setupKeyboardShortcuts(rootDir, url, quit) {
1180
1191
  if (!process.stdin.isTTY)
1181
- return;
1192
+ return () => {};
1182
1193
  process.stdin.setRawMode(true);
1183
1194
  process.stdin.resume();
1184
1195
  process.stdin.setEncoding("utf8");
1185
- process.stdin.on("data", (key) => {
1196
+ const handler = (key) => {
1186
1197
  switch (key.toLowerCase()) {
1187
1198
  case "o":
1188
1199
  openBrowser(url);
@@ -1198,7 +1209,15 @@ function setupKeyboardShortcuts(rootDir, url, quit) {
1198
1209
  quit();
1199
1210
  break;
1200
1211
  }
1201
- });
1212
+ };
1213
+ process.stdin.on("data", handler);
1214
+ return () => {
1215
+ process.stdin.off("data", handler);
1216
+ if (process.stdin.isTTY) {
1217
+ process.stdin.setRawMode(false);
1218
+ }
1219
+ process.stdin.pause();
1220
+ };
1202
1221
  }
1203
1222
  async function startDev(rootDir, options = {}) {
1204
1223
  const port = options.port ?? await getRandomPort();
@@ -1215,11 +1234,37 @@ async function startDev(rootDir, options = {}) {
1215
1234
  printWelcome("dev");
1216
1235
  server.printUrls();
1217
1236
  printReady();
1218
- setupKeyboardShortcuts(rootDir, url, async () => {
1219
- console.log(`
1237
+ let isShuttingDown = false;
1238
+ let cleanupStdin = () => {};
1239
+ const shutdown = async (signal) => {
1240
+ if (isShuttingDown)
1241
+ return;
1242
+ isShuttingDown = true;
1243
+ if (signal) {
1244
+ console.log(`
1245
+ Received ${signal}, shutting down...`);
1246
+ } else {
1247
+ console.log(`
1220
1248
  Shutting down...`);
1221
- await server.close();
1249
+ }
1250
+ cleanupStdin();
1251
+ const closePromise = server.close();
1252
+ const timeoutPromise = new Promise((resolve) => {
1253
+ setTimeout(() => {
1254
+ console.log(" Force closing (timeout)...");
1255
+ resolve();
1256
+ }, 3000);
1257
+ });
1258
+ await Promise.race([closePromise, timeoutPromise]);
1222
1259
  process.exit(0);
1260
+ };
1261
+ cleanupStdin = setupKeyboardShortcuts(rootDir, url, () => shutdown());
1262
+ process.on("SIGINT", () => shutdown("SIGINT"));
1263
+ process.on("SIGTERM", () => shutdown("SIGTERM"));
1264
+ process.on("uncaughtException", (err) => {
1265
+ console.error(`
1266
+ Uncaught exception:`, err.message);
1267
+ shutdown("uncaughtException");
1223
1268
  });
1224
1269
  return server;
1225
1270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prev-cli",
3
- "version": "0.24.1",
3
+ "version": "0.24.2",
4
4
  "description": "Transform MDX directories into beautiful documentation websites",
5
5
  "type": "module",
6
6
  "license": "MIT",