@digimakers/cli 0.1.4 → 0.2.1

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.
@@ -0,0 +1 @@
1
+ code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.block-comment,.token.prolog,.token.doctype,.token.cdata{color:#999}.token.punctuation{color:#ccc}.token.tag,.token.attr-name,.token.namespace,.token.deleted{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.number,.token.function{color:#f08d49}.token.property,.token.class-name,.token.constant,.token.symbol{color:#f8c555}.token.selector,.token.important,.token.atrule,.token.keyword,.token.builtin{color:#cc99cd}.token.string,.token.char,.token.attr-value,.token.regex,.token.variable{color:#7ec699}.token.operator,.token.entity,.token.url{color:#67cdcc}.token.important,.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}:root{--offwhite-color: #f5f5f5;--codeblock-background-color: #2d2d2d}.pagedjs_pages{display:flex;flex-direction:column;align-items:center}.pagedjs_page{background-color:#fff;margin-bottom:30px;box-shadow:0 5px 15px #00000080}.pagedjs_sheet{background-color:#fff}body{scrollbar-gutter:stable!important;margin:0;padding:0}@page{size:A4;margin:0}body.print-mode,body.print-mode app-root{height:auto!important;overflow:visible!important}img{max-height:240mm;object-fit:contain}@media print{body{background:#fff!important}.pane-left{display:none!important}.split-layout,.pane-right,app-lesson-preview,.pdf-preview{display:block!important;width:100%!important;height:auto!important;overflow:visible!important;padding:0!important;margin:0!important;background:transparent!important}.pagedjs_pages{display:block!important}.pagedjs_page{box-shadow:none!important;margin:0!important;page-break-after:always;break-after:page}.pagedjs_page:last-child{page-break-after:auto;break-after:auto}}@font-face{font-family:Poppins;src:url("./media/Poppins-Regular-JNHL4IDV.ttf") format("opentype");font-weight:400;font-style:normal}@font-face{font-family:Jetbrains;src:url("./media/JetBrainsMono-Regular-2AOUELG6.ttf") format("opentype");font-weight:400;font-style:normal}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import 'dotenv/config';
3
3
  import yargs from 'yargs';
4
4
  import { hideBin } from 'yargs/helpers';
5
5
  import path from 'path';
6
- import { startServer, stopServer, createPdfGenerator, findDocxFiles, parseDocx, sampleLessonData, logger, } from '@digimakers/core';
6
+ import { startServer, stopServer, createPdfGenerator, convertWithConcurrency, findDocxFiles, sampleLessonData, logger, POOL_SIZE, } from '@digimakers/core';
7
7
  const OUTPUT_DIR = path.resolve(process.cwd(), 'output');
8
8
  async function main() {
9
9
  await yargs(hideBin(process.argv))
@@ -26,6 +26,12 @@ async function main() {
26
26
  type: 'boolean',
27
27
  default: false,
28
28
  description: 'Recursively search directories',
29
+ })
30
+ .option('concurrency', {
31
+ alias: 'c',
32
+ type: 'number',
33
+ default: POOL_SIZE,
34
+ description: 'Maximum concurrent file processing',
29
35
  }), async (argv) => {
30
36
  const targetPath = path.resolve(argv.path);
31
37
  const files = await findDocxFiles(targetPath, { recursive: argv.recursive });
@@ -33,20 +39,30 @@ async function main() {
33
39
  logger.warn('No .docx files found');
34
40
  return;
35
41
  }
36
- logger.info(`Converting ${files.length} file(s)...`);
42
+ logger.info(`Converting ${files.length} file(s) with concurrency ${argv.concurrency}...`);
37
43
  const server = await startServer();
38
44
  try {
39
45
  const generator = await createPdfGenerator(server.url);
40
- const items = await Promise.all(files.map(async (file) => {
41
- const result = await parseDocx(file.path);
42
- return {
43
- data: result.data,
44
- options: { outputDir: argv.output, filename: file.name },
45
- };
46
- }));
47
- await generator.generateBatch(items);
46
+ const results = await convertWithConcurrency(files, generator, argv.output, argv.concurrency);
48
47
  await generator.close();
49
- logger.info(`Done! ${files.length} PDF(s) saved to ${argv.output}`);
48
+ // Summary
49
+ const succeeded = results.filter((r) => r.success);
50
+ const failed = results.filter((r) => !r.success);
51
+ logger.info('');
52
+ logger.info('=== Conversion Summary ===');
53
+ logger.info(`Succeeded: ${succeeded.length}`);
54
+ logger.info(`Failed: ${failed.length}`);
55
+ if (failed.length > 0) {
56
+ logger.info('');
57
+ logger.info('Failed files:');
58
+ for (const f of failed) {
59
+ logger.info(` - ${f.file}: ${f.error}`);
60
+ }
61
+ }
62
+ if (succeeded.length > 0) {
63
+ logger.info('');
64
+ logger.info(`PDFs saved to: ${argv.output}`);
65
+ }
50
66
  }
51
67
  finally {
52
68
  await stopServer(server);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digimakers/cli",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "CLI tool to convert .docx lesson sheets into stylised PDFs",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1 +0,0 @@
1
- code[class*=language-],pre[class*=language-]{color:#ccc;background:none;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.block-comment,.token.prolog,.token.doctype,.token.cdata{color:#999}.token.punctuation{color:#ccc}.token.tag,.token.attr-name,.token.namespace,.token.deleted{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.number,.token.function{color:#f08d49}.token.property,.token.class-name,.token.constant,.token.symbol{color:#f8c555}.token.selector,.token.important,.token.atrule,.token.keyword,.token.builtin{color:#cc99cd}.token.string,.token.char,.token.attr-value,.token.regex,.token.variable{color:#7ec699}.token.operator,.token.entity,.token.url{color:#67cdcc}.token.important,.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}:root{--offwhite-color: #f5f5f5}.pagedjs_pages{display:flex;flex-direction:column;align-items:center}.pagedjs_page{background-color:#fff;margin-bottom:30px;box-shadow:0 5px 15px #00000080}.pagedjs_sheet{background-color:#fff}body{scrollbar-gutter:stable!important;margin:0;padding:0}@page{size:A4;margin:0}body.print-mode,body.print-mode app-root{height:auto!important;overflow:visible!important}@media print{body{background:#fff!important}.pane-left{display:none!important}.split-layout,.pane-right,app-lesson-preview,.pdf-preview{display:block!important;width:100%!important;height:auto!important;overflow:visible!important;padding:0!important;margin:0!important;background:transparent!important}.pagedjs_pages{display:block!important}.pagedjs_page{box-shadow:none!important;margin:0!important;page-break-after:always;break-after:page}.pagedjs_page:last-child{page-break-after:auto;break-after:auto}}@font-face{font-family:Poppins;src:url("./media/Poppins-Regular-JNHL4IDV.ttf") format("opentype");font-weight:400;font-style:normal}@font-face{font-family:Jetbrains;src:url("./media/JetBrainsMono-Regular-2AOUELG6.ttf") format("opentype");font-weight:400;font-style:normal}