flowdoc-gen 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.
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- findConfigFile,
4
- generate,
5
- loadConfig,
6
- resolveConfig
7
- } from "./chunk-XXW6UJOX.js";
8
-
9
- // src/serve.ts
10
- import { createServer } from "http";
11
- import { createReadStream, existsSync } from "fs";
12
- import { join, extname, resolve } from "path";
13
- import chalk from "chalk";
14
- import open from "open";
15
- import chokidar from "chokidar";
16
- var MIME_TYPES = {
17
- ".html": "text/html",
18
- ".js": "application/javascript",
19
- ".css": "text/css",
20
- ".json": "application/json",
21
- ".svg": "image/svg+xml",
22
- ".png": "image/png",
23
- ".ico": "image/x-icon"
24
- };
25
- var serve = async (opts = {}) => {
26
- const cwd = process.cwd();
27
- const outputDir = opts.output ?? join(cwd, "docs-output");
28
- const port = opts.port ?? 4e3;
29
- await generate({ ...opts, quiet: false });
30
- const server = createServer((req, res) => {
31
- const url = req.url === "/" || req.url === "" ? "/index.html" : req.url ?? "/index.html";
32
- const filePath = join(outputDir, url);
33
- if (!existsSync(filePath)) {
34
- res.writeHead(404);
35
- res.end("Not found");
36
- return;
37
- }
38
- const ext = extname(filePath);
39
- const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
40
- res.writeHead(200, { "Content-Type": contentType });
41
- createReadStream(filePath).pipe(res);
42
- });
43
- server.listen(port, () => {
44
- const url = `http://localhost:${port}`;
45
- console.log();
46
- console.log(` ${chalk.bold("flowdoc")} is running at ${chalk.cyan(url)}`);
47
- if (opts.watch) {
48
- console.log(` ${chalk.dim("watching for changes\u2026")}`);
49
- }
50
- console.log();
51
- if (!opts.noOpen) {
52
- void open(url);
53
- }
54
- });
55
- if (!opts.watch) return;
56
- const configPath = opts.config ?? findConfigFile(cwd) ?? "";
57
- let watchGlob = "src/**/*.ts";
58
- if (configPath) {
59
- try {
60
- const raw = await loadConfig(configPath);
61
- const config = resolveConfig(raw, cwd);
62
- const entryDir = resolve(cwd, config.entry).replace(/\/[^/]+$/, "");
63
- watchGlob = `${entryDir}/**/*.ts`;
64
- } catch {
65
- }
66
- }
67
- let rebuilding = false;
68
- const watcher = chokidar.watch(watchGlob, {
69
- ignoreInitial: true,
70
- ignored: ["**/node_modules/**", "**/dist/**", "**/docs-output/**"]
71
- });
72
- const rebuild = async (filePath) => {
73
- if (rebuilding) return;
74
- rebuilding = true;
75
- console.log(` ${chalk.dim("\u2192")} ${chalk.yellow(filePath.replace(cwd + "/", ""))} changed \u2014 regenerating\u2026`);
76
- try {
77
- await generate({ ...opts, quiet: true });
78
- console.log(` ${chalk.green("\u2713")} docs updated`);
79
- } catch (err) {
80
- console.error(` ${chalk.red("\u2717")} regeneration failed:`, err instanceof Error ? err.message : err);
81
- } finally {
82
- rebuilding = false;
83
- }
84
- };
85
- watcher.on("add", rebuild).on("change", rebuild).on("unlink", rebuild);
86
- process.on("SIGINT", () => {
87
- void watcher.close();
88
- server.close();
89
- process.exit(0);
90
- });
91
- };
92
- export {
93
- serve
94
- };
@@ -1,7 +0,0 @@
1
- import {
2
- serve
3
- } from "./chunk-P6Z6T3W4.js";
4
- import "./chunk-SAMPAR3A.js";
5
- export {
6
- serve
7
- };
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- findConfigFile,
4
- generate,
5
- loadConfig,
6
- resolveConfig
7
- } from "./chunk-3GGK6LWE.js";
8
-
9
- // src/serve.ts
10
- import { createServer } from "http";
11
- import { createReadStream, existsSync } from "fs";
12
- import { join, extname, resolve } from "path";
13
- import chalk from "chalk";
14
- import open from "open";
15
- import chokidar from "chokidar";
16
- var MIME_TYPES = {
17
- ".html": "text/html",
18
- ".js": "application/javascript",
19
- ".css": "text/css",
20
- ".json": "application/json",
21
- ".svg": "image/svg+xml",
22
- ".png": "image/png",
23
- ".ico": "image/x-icon"
24
- };
25
- var serve = async (opts = {}) => {
26
- const cwd = process.cwd();
27
- const outputDir = opts.output ?? join(cwd, "docs-output");
28
- const port = opts.port ?? 4e3;
29
- await generate({ ...opts, quiet: false });
30
- const server = createServer((req, res) => {
31
- const url = req.url === "/" || req.url === "" ? "/index.html" : req.url ?? "/index.html";
32
- const filePath = join(outputDir, url);
33
- if (!existsSync(filePath)) {
34
- res.writeHead(404);
35
- res.end("Not found");
36
- return;
37
- }
38
- const ext = extname(filePath);
39
- const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
40
- res.writeHead(200, { "Content-Type": contentType });
41
- createReadStream(filePath).pipe(res);
42
- });
43
- server.listen(port, () => {
44
- const url = `http://localhost:${port}`;
45
- console.log();
46
- console.log(` ${chalk.bold("flowdoc")} is running at ${chalk.cyan(url)}`);
47
- if (opts.watch) {
48
- console.log(` ${chalk.dim("watching for changes\u2026")}`);
49
- }
50
- console.log();
51
- if (!opts.noOpen) {
52
- void open(url);
53
- }
54
- });
55
- if (!opts.watch) return;
56
- const configPath = opts.config ?? findConfigFile(cwd) ?? "";
57
- let watchGlob = "src/**/*.ts";
58
- if (configPath) {
59
- try {
60
- const raw = await loadConfig(configPath);
61
- const config = resolveConfig(raw, cwd);
62
- const entryDir = resolve(cwd, config.entry).replace(/\/[^/]+$/, "");
63
- watchGlob = `${entryDir}/**/*.ts`;
64
- } catch {
65
- }
66
- }
67
- let rebuilding = false;
68
- const watcher = chokidar.watch(watchGlob, {
69
- ignoreInitial: true,
70
- ignored: ["**/node_modules/**", "**/dist/**", "**/docs-output/**"]
71
- });
72
- const rebuild = async (filePath) => {
73
- if (rebuilding) return;
74
- rebuilding = true;
75
- console.log(` ${chalk.dim("\u2192")} ${chalk.yellow(filePath.replace(cwd + "/", ""))} changed \u2014 regenerating\u2026`);
76
- try {
77
- await generate({ ...opts, quiet: true });
78
- console.log(` ${chalk.green("\u2713")} docs updated`);
79
- } catch (err) {
80
- console.error(` ${chalk.red("\u2717")} regeneration failed:`, err instanceof Error ? err.message : err);
81
- } finally {
82
- rebuilding = false;
83
- }
84
- };
85
- watcher.on("add", rebuild).on("change", rebuild).on("unlink", rebuild);
86
- process.on("SIGINT", () => {
87
- void watcher.close();
88
- server.close();
89
- process.exit(0);
90
- });
91
- };
92
- export {
93
- serve
94
- };