ai-pdf-builder 0.2.0 → 0.3.0
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.
Potentially problematic release.
This version of ai-pdf-builder might be problematic. Click here for more details.
- package/dist/chunk-6CO4SNHC.mjs +594 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +751 -0
- package/dist/cli.mjs +230 -0
- package/dist/index.mjs +28 -565
- package/package.json +6 -3
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
checkSystem,
|
|
4
|
+
generateAgreement,
|
|
5
|
+
generateMemo,
|
|
6
|
+
generateNDA,
|
|
7
|
+
generateProposal,
|
|
8
|
+
generateReport,
|
|
9
|
+
generateSAFE,
|
|
10
|
+
generateTermsheet,
|
|
11
|
+
generateWhitepaper,
|
|
12
|
+
listTemplates
|
|
13
|
+
} from "./chunk-6CO4SNHC.mjs";
|
|
14
|
+
|
|
15
|
+
// src/cli.ts
|
|
16
|
+
import * as fs from "fs";
|
|
17
|
+
import * as path from "path";
|
|
18
|
+
var VERSION = "0.2.0";
|
|
19
|
+
var HELP = `
|
|
20
|
+
ai-pdf-builder v${VERSION}
|
|
21
|
+
Generate professional PDFs from Markdown
|
|
22
|
+
|
|
23
|
+
USAGE:
|
|
24
|
+
ai-pdf-builder <command> [options]
|
|
25
|
+
|
|
26
|
+
COMMANDS:
|
|
27
|
+
generate <type> <input> Generate a PDF from markdown file
|
|
28
|
+
check Check system requirements
|
|
29
|
+
templates List available templates
|
|
30
|
+
help Show this help message
|
|
31
|
+
|
|
32
|
+
DOCUMENT TYPES:
|
|
33
|
+
whitepaper Technical documentation, litepapers
|
|
34
|
+
memo Executive summaries, internal memos
|
|
35
|
+
agreement Legal contracts, general agreements
|
|
36
|
+
termsheet Investment term sheets
|
|
37
|
+
safe SAFE agreements
|
|
38
|
+
nda Non-disclosure agreements
|
|
39
|
+
report Business reports, analysis
|
|
40
|
+
proposal Business proposals, pitches
|
|
41
|
+
|
|
42
|
+
OPTIONS:
|
|
43
|
+
-o, --output <file> Output file path (default: output.pdf)
|
|
44
|
+
-t, --title <title> Document title
|
|
45
|
+
-s, --subtitle <text> Document subtitle
|
|
46
|
+
-a, --author <name> Author name
|
|
47
|
+
-d, --date <date> Document date
|
|
48
|
+
-v, --version <ver> Document version
|
|
49
|
+
--no-toc Disable table of contents
|
|
50
|
+
--color-primary <hex> Primary brand color
|
|
51
|
+
--color-secondary <hex> Secondary brand color
|
|
52
|
+
|
|
53
|
+
EXAMPLES:
|
|
54
|
+
# Generate a whitepaper
|
|
55
|
+
ai-pdf-builder generate whitepaper ./content.md -o whitepaper.pdf -t "My Project"
|
|
56
|
+
|
|
57
|
+
# Generate a term sheet
|
|
58
|
+
ai-pdf-builder generate termsheet ./terms.md -t "Series Seed" -s "Acme Inc."
|
|
59
|
+
|
|
60
|
+
# Generate a SAFE
|
|
61
|
+
ai-pdf-builder generate safe ./safe.md -o safe-agreement.pdf
|
|
62
|
+
|
|
63
|
+
# Check if Pandoc/LaTeX are installed
|
|
64
|
+
ai-pdf-builder check
|
|
65
|
+
|
|
66
|
+
# List available templates
|
|
67
|
+
ai-pdf-builder templates
|
|
68
|
+
`;
|
|
69
|
+
function parseArgs(args) {
|
|
70
|
+
const options = {
|
|
71
|
+
output: "output.pdf",
|
|
72
|
+
toc: true
|
|
73
|
+
};
|
|
74
|
+
let command = "help";
|
|
75
|
+
let type;
|
|
76
|
+
let input;
|
|
77
|
+
let i = 0;
|
|
78
|
+
while (i < args.length) {
|
|
79
|
+
const arg = args[i];
|
|
80
|
+
if (arg === "generate" || arg === "check" || arg === "templates" || arg === "help") {
|
|
81
|
+
command = arg;
|
|
82
|
+
if (arg === "generate") {
|
|
83
|
+
type = args[++i];
|
|
84
|
+
input = args[++i];
|
|
85
|
+
}
|
|
86
|
+
} else if (arg === "-o" || arg === "--output") {
|
|
87
|
+
options.output = args[++i];
|
|
88
|
+
} else if (arg === "-t" || arg === "--title") {
|
|
89
|
+
options.title = args[++i];
|
|
90
|
+
} else if (arg === "-s" || arg === "--subtitle") {
|
|
91
|
+
options.subtitle = args[++i];
|
|
92
|
+
} else if (arg === "-a" || arg === "--author") {
|
|
93
|
+
options.author = args[++i];
|
|
94
|
+
} else if (arg === "-d" || arg === "--date") {
|
|
95
|
+
options.date = args[++i];
|
|
96
|
+
} else if (arg === "-v" || arg === "--version") {
|
|
97
|
+
options.version = args[++i];
|
|
98
|
+
} else if (arg === "--no-toc") {
|
|
99
|
+
options.toc = false;
|
|
100
|
+
} else if (arg === "--color-primary") {
|
|
101
|
+
options.colorPrimary = args[++i];
|
|
102
|
+
} else if (arg === "--color-secondary") {
|
|
103
|
+
options.colorSecondary = args[++i];
|
|
104
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
105
|
+
command = "help";
|
|
106
|
+
}
|
|
107
|
+
i++;
|
|
108
|
+
}
|
|
109
|
+
return { command, type, input, options };
|
|
110
|
+
}
|
|
111
|
+
async function runGenerate(type, input, options) {
|
|
112
|
+
if (!fs.existsSync(input)) {
|
|
113
|
+
console.error(`Error: Input file not found: ${input}`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
const content = fs.readFileSync(input, "utf-8");
|
|
117
|
+
const metadata = {
|
|
118
|
+
title: options.title || path.basename(input, path.extname(input)),
|
|
119
|
+
subtitle: options.subtitle || "",
|
|
120
|
+
author: options.author || "",
|
|
121
|
+
date: options.date || (/* @__PURE__ */ new Date()).toLocaleDateString("en-US", { month: "long", year: "numeric" }),
|
|
122
|
+
version: options.version || ""
|
|
123
|
+
};
|
|
124
|
+
const pdfOptions = {
|
|
125
|
+
outputPath: path.resolve(options.output),
|
|
126
|
+
toc: options.toc,
|
|
127
|
+
customColors: options.colorPrimary || options.colorSecondary ? {
|
|
128
|
+
primary: options.colorPrimary,
|
|
129
|
+
secondary: options.colorSecondary
|
|
130
|
+
} : void 0
|
|
131
|
+
};
|
|
132
|
+
console.log(`Generating ${type}...`);
|
|
133
|
+
let result;
|
|
134
|
+
switch (type) {
|
|
135
|
+
case "whitepaper":
|
|
136
|
+
result = await generateWhitepaper(content, metadata, pdfOptions);
|
|
137
|
+
break;
|
|
138
|
+
case "memo":
|
|
139
|
+
result = await generateMemo(content, metadata, pdfOptions);
|
|
140
|
+
break;
|
|
141
|
+
case "agreement":
|
|
142
|
+
result = await generateAgreement(content, metadata, pdfOptions);
|
|
143
|
+
break;
|
|
144
|
+
case "termsheet":
|
|
145
|
+
result = await generateTermsheet(content, metadata, pdfOptions);
|
|
146
|
+
break;
|
|
147
|
+
case "safe":
|
|
148
|
+
result = await generateSAFE(content, metadata, pdfOptions);
|
|
149
|
+
break;
|
|
150
|
+
case "nda":
|
|
151
|
+
result = await generateNDA(content, metadata, pdfOptions);
|
|
152
|
+
break;
|
|
153
|
+
case "report":
|
|
154
|
+
result = await generateReport(content, metadata, pdfOptions);
|
|
155
|
+
break;
|
|
156
|
+
case "proposal":
|
|
157
|
+
result = await generateProposal(content, metadata, pdfOptions);
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
console.error(`Unknown document type: ${type}`);
|
|
161
|
+
console.log("Valid types: whitepaper, memo, agreement, termsheet, safe, nda, report, proposal");
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
if (result.success) {
|
|
165
|
+
console.log(`\u2713 Generated: ${options.output}`);
|
|
166
|
+
console.log(` Size: ${(result.fileSize / 1024).toFixed(1)} KB`);
|
|
167
|
+
console.log(` Time: ${result.generationTime}ms`);
|
|
168
|
+
if (result.pageCount) {
|
|
169
|
+
console.log(` Pages: ${result.pageCount}`);
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
console.error(`\u2717 Error: ${result.error}`);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function runCheck() {
|
|
177
|
+
console.log("Checking system requirements...\n");
|
|
178
|
+
const check = checkSystem();
|
|
179
|
+
if (check.ready) {
|
|
180
|
+
console.log("\u2713 System is ready for PDF generation\n");
|
|
181
|
+
console.log(` Pandoc: ${check.pandoc?.version || "installed"}`);
|
|
182
|
+
console.log(` LaTeX: ${check.latex?.version || "installed"}`);
|
|
183
|
+
} else {
|
|
184
|
+
console.log("\u2717 System requirements not met\n");
|
|
185
|
+
console.log(` ${check.message}
|
|
186
|
+
`);
|
|
187
|
+
console.log("Install instructions:");
|
|
188
|
+
console.log(" macOS: brew install pandoc && brew install --cask basictex");
|
|
189
|
+
console.log(" Linux: sudo apt-get install pandoc texlive-full");
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function runTemplates() {
|
|
194
|
+
console.log("Available templates:\n");
|
|
195
|
+
const templates = listTemplates();
|
|
196
|
+
templates.forEach((t) => {
|
|
197
|
+
console.log(` ${t.name.padEnd(15)} - ${t.description || "No description"}`);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async function main() {
|
|
201
|
+
const args = process.argv.slice(2);
|
|
202
|
+
if (args.length === 0) {
|
|
203
|
+
console.log(HELP);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const { command, type, input, options } = parseArgs(args);
|
|
207
|
+
switch (command) {
|
|
208
|
+
case "generate":
|
|
209
|
+
if (!type || !input) {
|
|
210
|
+
console.error("Error: generate requires <type> and <input> arguments");
|
|
211
|
+
console.log("Usage: ai-pdf-builder generate <type> <input> [options]");
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
await runGenerate(type, input, options);
|
|
215
|
+
break;
|
|
216
|
+
case "check":
|
|
217
|
+
runCheck();
|
|
218
|
+
break;
|
|
219
|
+
case "templates":
|
|
220
|
+
runTemplates();
|
|
221
|
+
break;
|
|
222
|
+
case "help":
|
|
223
|
+
default:
|
|
224
|
+
console.log(HELP);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
main().catch((err) => {
|
|
228
|
+
console.error("Error:", err.message);
|
|
229
|
+
process.exit(1);
|
|
230
|
+
});
|