prev-cli 0.24.0 → 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 +54 -8
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -886,7 +886,15 @@ async function createViteConfig(options) {
886
886
  mdx({
887
887
  remarkPlugins: [remarkGfm],
888
888
  rehypePlugins: [rehypeHighlight],
889
- providerImportSource: "@mdx-js/react"
889
+ providerImportSource: "@mdx-js/react",
890
+ include: [
891
+ path8.join(rootDir, "**/*.md"),
892
+ path8.join(rootDir, "**/*.mdx")
893
+ ],
894
+ exclude: [
895
+ "**/node_modules/**",
896
+ "**/.git/**"
897
+ ]
890
898
  }),
891
899
  react(),
892
900
  createConfigPlugin(config),
@@ -1087,7 +1095,11 @@ async function createViteConfig(options) {
1087
1095
  main: path8.join(srcRoot2, "theme/index.html")
1088
1096
  }
1089
1097
  }
1090
- }
1098
+ },
1099
+ assetsInclude: [
1100
+ "**/node_modules/**/*.md",
1101
+ "**/node_modules/**/*.mdx"
1102
+ ]
1091
1103
  };
1092
1104
  }
1093
1105
 
@@ -1177,11 +1189,11 @@ function clearCache(rootDir) {
1177
1189
  }
1178
1190
  function setupKeyboardShortcuts(rootDir, url, quit) {
1179
1191
  if (!process.stdin.isTTY)
1180
- return;
1192
+ return () => {};
1181
1193
  process.stdin.setRawMode(true);
1182
1194
  process.stdin.resume();
1183
1195
  process.stdin.setEncoding("utf8");
1184
- process.stdin.on("data", (key) => {
1196
+ const handler = (key) => {
1185
1197
  switch (key.toLowerCase()) {
1186
1198
  case "o":
1187
1199
  openBrowser(url);
@@ -1197,7 +1209,15 @@ function setupKeyboardShortcuts(rootDir, url, quit) {
1197
1209
  quit();
1198
1210
  break;
1199
1211
  }
1200
- });
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
+ };
1201
1221
  }
1202
1222
  async function startDev(rootDir, options = {}) {
1203
1223
  const port = options.port ?? await getRandomPort();
@@ -1214,11 +1234,37 @@ async function startDev(rootDir, options = {}) {
1214
1234
  printWelcome("dev");
1215
1235
  server.printUrls();
1216
1236
  printReady();
1217
- setupKeyboardShortcuts(rootDir, url, async () => {
1218
- 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(`
1219
1248
  Shutting down...`);
1220
- 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]);
1221
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");
1222
1268
  });
1223
1269
  return server;
1224
1270
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prev-cli",
3
- "version": "0.24.0",
3
+ "version": "0.24.2",
4
4
  "description": "Transform MDX directories into beautiful documentation websites",
5
5
  "type": "module",
6
6
  "license": "MIT",