@digimakers/cli 0.3.21 → 0.3.23
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.
- package/dist/index.js +23 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,16 +36,32 @@ async function main() {
|
|
|
36
36
|
await yargs(hideBin(process.argv))
|
|
37
37
|
.scriptName('digimaker')
|
|
38
38
|
.usage('$0 <command> [options]')
|
|
39
|
+
// Root options
|
|
39
40
|
.option('gemini-key', {
|
|
40
41
|
type: 'string',
|
|
41
42
|
description: 'Gemini API key (overrides GEMINI_API_KEY)',
|
|
43
|
+
})
|
|
44
|
+
.option('cheaper', {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
default: false,
|
|
47
|
+
description: 'Use cheaper models or better models?',
|
|
42
48
|
})
|
|
43
49
|
.middleware((argv) => {
|
|
44
50
|
if (argv.geminiKey) {
|
|
45
51
|
process.env.GEMINI_API_KEY = String(argv.geminiKey);
|
|
46
52
|
process.env.GOOGLE_GENERATIVE_AI_API_KEY = String(argv.geminiKey);
|
|
47
53
|
}
|
|
54
|
+
if (argv.cheaper) {
|
|
55
|
+
process.env.MAIN_GEMINI_MODEL = 'gemini-2.5-flash';
|
|
56
|
+
process.env.CODE_FORMATTER_GEMINI_MODEL = 'gemini-2.0-flash';
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
process.env.MAIN_GEMINI_MODEL = 'gemini-2.5-pro';
|
|
60
|
+
process.env.CODE_FORMATTER_GEMINI_MODEL = 'gemini-2.5-flash-lite';
|
|
61
|
+
}
|
|
48
62
|
})
|
|
63
|
+
// Main conversion command to convert docx
|
|
64
|
+
// E.g., > digimaker convert <optional-path>
|
|
49
65
|
.command('convert [path]', 'Convert .docx files to PDF', (yargs) => yargs
|
|
50
66
|
.positional('path', {
|
|
51
67
|
type: 'string',
|
|
@@ -74,6 +90,7 @@ async function main() {
|
|
|
74
90
|
if (!hasKey) {
|
|
75
91
|
return;
|
|
76
92
|
}
|
|
93
|
+
// Find and store docx files to convert
|
|
77
94
|
const targetPath = path.resolve(argv.path);
|
|
78
95
|
const files = await findDocxFiles(targetPath, { recursive: argv.recursive });
|
|
79
96
|
if (files.length === 0) {
|
|
@@ -81,12 +98,15 @@ async function main() {
|
|
|
81
98
|
return;
|
|
82
99
|
}
|
|
83
100
|
logger.info(`Converting ${files.length} file(s) with concurrency ${argv.concurrency}...`);
|
|
101
|
+
// Prepare the frontend server for data injection and PDF generation
|
|
102
|
+
// Used by puppeteer, see pdf-generator.ts
|
|
84
103
|
const server = await startServer();
|
|
85
104
|
try {
|
|
105
|
+
// Start conversion and generation process
|
|
86
106
|
const generator = await createPdfGenerator(server.url);
|
|
87
107
|
const results = await convertWithConcurrency(files, generator, argv.output, argv.concurrency);
|
|
88
108
|
await generator.close();
|
|
89
|
-
//
|
|
109
|
+
// Log the summary of things
|
|
90
110
|
const succeeded = results.filter((r) => r.success);
|
|
91
111
|
const failed = results.filter((r) => !r.success);
|
|
92
112
|
logger.info('');
|
|
@@ -106,9 +126,11 @@ async function main() {
|
|
|
106
126
|
}
|
|
107
127
|
}
|
|
108
128
|
finally {
|
|
129
|
+
// Stop the frontend server once done
|
|
109
130
|
await stopServer(server);
|
|
110
131
|
}
|
|
111
132
|
})
|
|
133
|
+
// Command for testing PDF generation using sample data
|
|
112
134
|
.command('generate', 'Generate a PDF from sample data (for testing)', (yargs) => yargs
|
|
113
135
|
.option('output', {
|
|
114
136
|
alias: 'o',
|