@cenk1cenk2/md-printer 2.3.2 → 2.3.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.
Files changed (30) hide show
  1. package/dist/commands/index.js +177 -208
  2. package/dist/commands/index.js.map +1 -1
  3. package/dist/constants/file.constants.js +5 -6
  4. package/dist/constants/file.constants.js.map +1 -1
  5. package/dist/constants/index.js +4 -3
  6. package/dist/constants/template.constants.js +13 -17
  7. package/dist/constants/template.constants.js.map +1 -1
  8. package/dist/hooks/not-found.hook.js +5 -3
  9. package/dist/hooks/not-found.hook.js.map +1 -1
  10. package/dist/hooks/update-notifier.hook.js +5 -3
  11. package/dist/hooks/update-notifier.hook.js.map +1 -1
  12. package/dist/interfaces/commands/index.js +0 -1
  13. package/dist/interfaces/commands/run.interface.js +0 -1
  14. package/dist/interfaces/index.js +0 -1
  15. package/oclif.manifest.json +10 -1
  16. package/package.json +28 -29
  17. package/templates/kilic.dev/main.css +59 -0
  18. package/templates/kilic.dev/settings.json +9 -0
  19. package/templates/privat-rechnung/tailwind.css +29 -9
  20. package/templates/privat-rechnung/template.html.j2 +3 -3
  21. package/dist/constants/index.js.map +0 -1
  22. package/dist/interfaces/commands/index.js.map +0 -1
  23. package/dist/interfaces/commands/run.interface.js.map +0 -1
  24. package/dist/interfaces/index.js.map +0 -1
  25. package/templates/label-25x38-cable/settings.json +0 -10
  26. package/templates/label-25x38-cable/tailwind.config.cjs +0 -74
  27. package/templates/label-25x38-cable/tailwind.css +0 -13
  28. package/templates/label-25x38-cable/template.html.j2 +0 -36
  29. /package/templates/{default → kilic.dev}/footer.html +0 -0
  30. /package/templates/{default → kilic.dev}/header.html +0 -0
@@ -1,216 +1,185 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1
+ import { RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from "../constants/template.constants.js";
2
+ import { OUTPUT_FILE_ACCEPTED_TYPES } from "../constants/file.constants.js";
3
+ import "../constants/index.js";
4
+ import tailwind from "@tailwindcss/postcss";
3
5
  import { watch } from "chokidar";
4
- import { default as graymatter } from "gray-matter";
6
+ import graymatter from "gray-matter";
5
7
  import { mdToPdf } from "md-to-pdf";
6
8
  import Nunjucks from "nunjucks";
7
9
  import { basename, dirname, extname, join } from "path";
8
10
  import postcss from "postcss";
9
11
  import showdown from "showdown";
10
- import tailwind from "tailwindcss";
11
- import { Args, Flags, Command, ConfigService, FileSystemService, ParserService, JsonParser, YamlParser } from "@cenk1cenk2/oclif-common";
12
- import { OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from "../constants/index.js";
13
- class MDPrinter extends Command {
14
- static {
15
- __name(this, "MDPrinter");
16
- }
17
- static description = "Generates a PDF from the given markdown file with the selected HTML template.";
18
- static flags = {
19
- template: Flags.string({
20
- char: "t",
21
- default: "default",
22
- description: "HTML template for the generated PDF file."
23
- }),
24
- title: Flags.string({
25
- char: "T",
26
- description: "Overwrite document title."
27
- }),
28
- watch: Flags.boolean({
29
- char: "w",
30
- description: "Watch the changes on the given file."
31
- }),
32
- dev: Flags.boolean({
33
- char: "d",
34
- description: "Run with Chrome browser instead of publishing the file."
35
- })
36
- };
37
- static args = {
38
- file: Args.string({
39
- description: "File to be processed.",
40
- required: true
41
- }),
42
- output: Args.string({
43
- description: "Output file that will be generated. Overwrites the one define in front-matter.",
44
- required: false
45
- })
46
- };
47
- nunjucks = Nunjucks.configure({
48
- autoescape: false,
49
- throwOnUndefined: true,
50
- trimBlocks: true,
51
- lstripBlocks: false
52
- });
53
- cs;
54
- fs;
55
- async shouldRunBefore() {
56
- this.cs = this.app.get(ConfigService);
57
- this.fs = this.app.get(FileSystemService);
58
- await this.app.get(ParserService).register(JsonParser, YamlParser);
59
- this.nunjucks.addFilter("markdown_to_html", (markdown) => {
60
- return new showdown.Converter().makeHtml(markdown);
61
- });
62
- this.tasks.options = {
63
- silentRendererCondition: true
64
- };
65
- }
66
- async run() {
67
- this.tasks.add([
68
- {
69
- task: /* @__PURE__ */ __name(async (ctx) => {
70
- const file = join(process.cwd(), this.args.file);
71
- if (!this.fs.exists(file)) {
72
- throw new Error(`File does not exists: ${file}`);
73
- }
74
- this.logger.debug("Loading file: %s", file);
75
- ctx.file = file;
76
- switch (extname(ctx.file)) {
77
- case ".md": {
78
- const data = graymatter.read(ctx.file);
79
- ctx.content = await this.fs.read(file);
80
- ctx.content = data.content;
81
- ctx.metadata = data.data;
82
- break;
83
- }
84
- case ".yml": {
85
- ctx.content = await this.fs.read(file);
86
- ctx.metadata = await this.app.get(ParserService).parse(ctx.file, ctx.content);
87
- break;
88
- }
89
- default:
90
- throw new Error("File type is not accepted.");
91
- }
92
- }, "task")
93
- },
94
- {
95
- task: /* @__PURE__ */ __name(async (ctx) => {
96
- const template = ctx.metadata?.template ?? this.flags.template;
97
- this.logger.debug("Loading template: %s", template);
98
- ctx.templates = new RegExp(/\.\.?\//).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template);
99
- await Promise.all(RequiredTemplateFiles.map(async (file) => {
100
- const current = join(ctx.templates, file);
101
- if (!this.fs.exists(current)) {
102
- throw new Error(`Template does not exists: ${current}`);
103
- }
104
- }));
105
- const paths = {
106
- [TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),
107
- [TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),
108
- [TemplateFiles.TAILWIND_CSS]: join(ctx.templates, TemplateFiles.TAILWIND_CSS),
109
- [TemplateFiles.TAILWIND_CONFIG]: join(ctx.templates, TemplateFiles.TAILWIND_CONFIG),
110
- [TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),
111
- [TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),
112
- [TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)
113
- };
114
- ctx.options = await this.cs.extend([
115
- paths[TemplateFiles.SETTINGS],
116
- {
117
- dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,
118
- document_title: ctx.metadata?.document_title ?? this.flags.title ?? this.args.file
119
- }
120
- ]);
121
- this.logger.debug("Options: %o", ctx.options);
122
- if (this.fs.exists(paths[TemplateFiles.HEADER])) {
123
- this.logger.debug("Header exists for template.");
124
- ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER]);
125
- }
126
- if (this.fs.exists(paths[TemplateFiles.FOOTER])) {
127
- this.logger.debug("Footer exists for template.");
128
- ctx.options.pdf_options.footerTemplate = await this.fs.read(paths[TemplateFiles.FOOTER]);
129
- }
130
- if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {
131
- this.logger.debug("Design template exists for template.");
132
- ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE]);
133
- this.logger.debug("Metadata: %o", ctx.metadata);
134
- }
135
- if (this.fs.exists(paths[TemplateFiles.CSS])) {
136
- this.logger.debug("CSS exists for template.");
137
- ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS]);
138
- }
139
- if (this.fs.exists(paths[TemplateFiles.TAILWIND_CSS])) {
140
- this.logger.debug("Tailwind CSS exists for template, generating configuration from: %s -> %s", paths[TemplateFiles.TAILWIND_CONFIG], paths[TemplateFiles.TAILWIND_CSS]);
141
- ctx.options.css = await postcss([
142
- tailwind({
143
- ...await import(paths[TemplateFiles.TAILWIND_CONFIG]).then((m) => m.default),
144
- content: [
145
- {
146
- raw: ctx.template,
147
- extension: "html"
148
- }
149
- ]
150
- })
151
- ]).process(await this.fs.read(paths[TemplateFiles.TAILWIND_CSS]), {
152
- from: void 0
153
- }).then((result) => result.css);
154
- }
155
- }, "task")
156
- },
157
- {
158
- task: /* @__PURE__ */ __name(async (ctx) => {
159
- if (this.flags.dev) {
160
- ctx.options.devtools = true;
161
- this.logger.info("Running in dev mode.");
162
- }
163
- }, "task")
164
- }
165
- ]);
166
- }
167
- async shouldRunAfter(ctx) {
168
- if (this.flags.watch) {
169
- this.logger.info("Running in watch mode.");
170
- watch([
171
- TEMPLATE_DIRECTORY,
172
- this.args.file,
173
- join(ctx.templates, "**/*")
174
- ]).on("change", async () => {
175
- await this.run();
176
- await this.runTasks();
177
- this.logger.info("Waiting for the next change.");
178
- return this.runMd2Pdf(ctx);
179
- });
180
- }
181
- return this.runMd2Pdf(ctx);
182
- }
183
- async runMd2Pdf(ctx) {
184
- let pdf;
185
- if (ctx.template) {
186
- this.logger.debug("Rendering as template.");
187
- pdf = await mdToPdf({
188
- content: this.nunjucks.renderString(ctx.template, {
189
- ...ctx.metadata ?? {},
190
- content: ctx.content
191
- })
192
- }, ctx.options);
193
- } else {
194
- this.logger.debug("Rendering as plain file.");
195
- pdf = await mdToPdf({
196
- content: ctx.content
197
- }, ctx.options);
198
- }
199
- const output = pdf.filename;
200
- await this.fs.mkdir(dirname(output));
201
- if (!output) {
202
- throw new Error("Output should either be defined with the variable or front-matter.");
203
- } else if (!OUTPUT_FILE_ACCEPTED_TYPES.includes(extname(output))) {
204
- throw new Error(`Output file should be ending with the extension: ${OUTPUT_FILE_ACCEPTED_TYPES.join(", ")} -> current: ${extname(output)}`);
205
- }
206
- this.logger.debug("Output file will be: %s", output);
207
- if (pdf) {
208
- this.logger.info("Writing file to output: %s", output);
209
- await this.fs.write(output, pdf.content);
210
- }
211
- }
212
- }
213
- export {
214
- MDPrinter as default
12
+ import { Args, Command, ConfigService, FileSystemService, Flags, JsonParser, ParserService, YamlParser } from "@cenk1cenk2/oclif-common";
13
+
14
+ //#region src/commands/index.ts
15
+ var MDPrinter = class extends Command {
16
+ static description = "Generates a PDF from the given markdown file with the selected HTML template.";
17
+ static flags = {
18
+ template: Flags.string({
19
+ char: "t",
20
+ default: "default",
21
+ description: "HTML template for the generated PDF file."
22
+ }),
23
+ title: Flags.string({
24
+ char: "T",
25
+ description: "Overwrite document title."
26
+ }),
27
+ browser: Flags.string({
28
+ char: "b",
29
+ description: "Browser path that is going to be used for the PDF generation.",
30
+ default: "/usr/bin/brave"
31
+ }),
32
+ watch: Flags.boolean({
33
+ char: "w",
34
+ description: "Watch the changes on the given file."
35
+ }),
36
+ dev: Flags.boolean({
37
+ char: "d",
38
+ description: "Run with Chrome browser instead of publishing the file."
39
+ })
40
+ };
41
+ static args = {
42
+ file: Args.string({
43
+ description: "File to be processed.",
44
+ required: true
45
+ }),
46
+ output: Args.string({
47
+ description: "Output file that will be generated. Overwrites the one define in front-matter.",
48
+ required: false
49
+ })
50
+ };
51
+ nunjucks = Nunjucks.configure({
52
+ autoescape: false,
53
+ throwOnUndefined: true,
54
+ trimBlocks: true,
55
+ lstripBlocks: false
56
+ });
57
+ cs;
58
+ fs;
59
+ async shouldRunBefore() {
60
+ this.cs = this.app.get(ConfigService);
61
+ this.fs = this.app.get(FileSystemService);
62
+ await this.app.get(ParserService).register(JsonParser, YamlParser);
63
+ this.nunjucks.addFilter("markdown_to_html", (markdown) => {
64
+ return new showdown.Converter().makeHtml(markdown);
65
+ });
66
+ this.tasks.options = { silentRendererCondition: true };
67
+ }
68
+ async run() {
69
+ this.tasks.add([
70
+ { task: async (ctx) => {
71
+ const file = join(process.cwd(), this.args.file);
72
+ if (!this.fs.exists(file)) throw new Error(`File does not exists: ${file}`);
73
+ this.logger.debug("Loading file: %s", file);
74
+ ctx.file = file;
75
+ switch (extname(ctx.file)) {
76
+ case ".md": {
77
+ const data = graymatter.read(ctx.file);
78
+ ctx.content = await this.fs.read(file);
79
+ ctx.content = data.content;
80
+ ctx.metadata = data.data;
81
+ break;
82
+ }
83
+ case ".yml": {
84
+ ctx.content = await this.fs.read(file);
85
+ ctx.metadata = await this.app.get(ParserService).parse(ctx.file, ctx.content);
86
+ break;
87
+ }
88
+ default: throw new Error("File type is not accepted.");
89
+ }
90
+ } },
91
+ { task: async (ctx) => {
92
+ const template = ctx.metadata?.template ?? this.flags.template;
93
+ ctx.templates = (/* @__PURE__ */ new RegExp(/\.\.?\//)).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template);
94
+ this.logger.debug("Loading template: %s from %s", template, ctx.templates);
95
+ await Promise.all(RequiredTemplateFiles.map(async (file) => {
96
+ const current = join(ctx.templates, file);
97
+ if (!this.fs.exists(current)) throw new Error(`Template does not exists: ${current}`);
98
+ }));
99
+ const paths = {
100
+ [TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),
101
+ [TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),
102
+ [TemplateFiles.TAILWIND_CSS]: join(ctx.templates, TemplateFiles.TAILWIND_CSS),
103
+ [TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),
104
+ [TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),
105
+ [TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)
106
+ };
107
+ ctx.options = await this.cs.extend([paths[TemplateFiles.SETTINGS], {
108
+ dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,
109
+ document_title: ctx.metadata?.document_title ?? this.flags.title ?? this.args.file,
110
+ launch_options: { executablePath: this.flags.browser }
111
+ }]);
112
+ this.logger.debug("Options: %o", ctx.options);
113
+ if (this.fs.exists(paths[TemplateFiles.HEADER])) {
114
+ this.logger.debug("Header exists for template.");
115
+ ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER]);
116
+ }
117
+ if (this.fs.exists(paths[TemplateFiles.FOOTER])) {
118
+ this.logger.debug("Footer exists for template.");
119
+ ctx.options.pdf_options.footerTemplate = await this.fs.read(paths[TemplateFiles.FOOTER]);
120
+ }
121
+ if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {
122
+ this.logger.debug("Design template exists for template.");
123
+ ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE]);
124
+ this.logger.debug("Metadata: %o", ctx.metadata);
125
+ }
126
+ if (this.fs.exists(paths[TemplateFiles.CSS])) {
127
+ this.logger.debug("CSS exists for template.");
128
+ ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS]);
129
+ }
130
+ if (this.fs.exists(paths[TemplateFiles.TAILWIND_CSS])) {
131
+ this.logger.debug("Tailwind CSS exists for template: %s -> %s", paths[TemplateFiles.TAILWIND_CSS]);
132
+ ctx.options.css = await postcss([tailwind({ base: ctx.templates })]).process(await this.fs.read(paths[TemplateFiles.TAILWIND_CSS]), { from: paths[TemplateFiles.TAILWIND_CSS] }).then((result) => result.css);
133
+ }
134
+ } },
135
+ { task: async (ctx) => {
136
+ if (this.flags.dev) {
137
+ ctx.options.devtools = true;
138
+ this.logger.info("Running in dev mode.");
139
+ }
140
+ } }
141
+ ]);
142
+ }
143
+ async shouldRunAfter(ctx) {
144
+ if (this.flags.watch) {
145
+ this.logger.info("Running in watch mode.");
146
+ watch([
147
+ TEMPLATE_DIRECTORY,
148
+ this.args.file,
149
+ join(ctx.templates, "**/*")
150
+ ]).on("change", async () => {
151
+ await this.run();
152
+ await this.runTasks();
153
+ this.logger.info("Waiting for the next change.");
154
+ return this.runMd2Pdf(ctx);
155
+ });
156
+ }
157
+ return this.runMd2Pdf(ctx);
158
+ }
159
+ async runMd2Pdf(ctx) {
160
+ let pdf;
161
+ if (ctx.template) {
162
+ this.logger.debug("Rendering as template.");
163
+ pdf = await mdToPdf({ content: this.nunjucks.renderString(ctx.template, {
164
+ ...ctx.metadata ?? {},
165
+ content: ctx.content
166
+ }) }, ctx.options);
167
+ } else {
168
+ this.logger.debug("Rendering as plain file.");
169
+ pdf = await mdToPdf({ content: ctx.content }, ctx.options);
170
+ }
171
+ const output = pdf.filename;
172
+ await this.fs.mkdir(dirname(output));
173
+ if (!output) throw new Error("Output should either be defined with the variable or front-matter.");
174
+ else if (!OUTPUT_FILE_ACCEPTED_TYPES.includes(extname(output))) throw new Error(`Output file should be ending with the extension: ${OUTPUT_FILE_ACCEPTED_TYPES.join(", ")} -> current: ${extname(output)}`);
175
+ this.logger.debug("Output file will be: %s", output);
176
+ if (pdf) {
177
+ this.logger.info("Writing file to output: %s", output);
178
+ await this.fs.write(output, pdf.content);
179
+ }
180
+ }
215
181
  };
182
+
183
+ //#endregion
184
+ export { MDPrinter as default };
216
185
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/commands/index.ts"],"sourcesContent":["import { watch } from 'chokidar'\nimport { default as graymatter } from 'gray-matter'\nimport { mdToPdf } from 'md-to-pdf'\nimport type { PdfConfig } from 'md-to-pdf/dist/lib/config.js'\nimport type { PdfOutput } from 'md-to-pdf/dist/lib/generate-output.js'\nimport Nunjucks from 'nunjucks'\nimport { basename, dirname, extname, join } from 'path'\nimport postcss from 'postcss'\nimport showdown from 'showdown'\nimport tailwind from 'tailwindcss'\n\nimport type { ShouldRunAfterHook, ShouldRunBeforeHook } from '@cenk1cenk2/oclif-common'\nimport { Args, Flags, Command, ConfigService, FileSystemService, ParserService, JsonParser, YamlParser } from '@cenk1cenk2/oclif-common'\nimport { OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from '@constants'\nimport type { MdPrinterCtx } from '@interfaces'\n\nexport default class MDPrinter extends Command<typeof MDPrinter, MdPrinterCtx> implements ShouldRunBeforeHook, ShouldRunAfterHook {\n static description = 'Generates a PDF from the given markdown file with the selected HTML template.'\n\n static flags = {\n template: Flags.string({\n char: 't',\n default: 'default',\n description: 'HTML template for the generated PDF file.'\n }),\n title: Flags.string({\n char: 'T',\n description: 'Overwrite document title.'\n }),\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch the changes on the given file.'\n }),\n dev: Flags.boolean({\n char: 'd',\n description: 'Run with Chrome browser instead of publishing the file.'\n })\n }\n\n static args = {\n file: Args.string({\n description: 'File to be processed.',\n required: true\n }),\n output: Args.string({\n description: 'Output file that will be generated. Overwrites the one define in front-matter.',\n required: false\n })\n }\n\n private nunjucks = Nunjucks.configure({\n autoescape: false,\n throwOnUndefined: true,\n trimBlocks: true,\n lstripBlocks: false\n })\n private cs: ConfigService\n private fs: FileSystemService\n\n public async shouldRunBefore(): Promise<void> {\n this.cs = this.app.get(ConfigService)\n this.fs = this.app.get(FileSystemService)\n\n await this.app.get(ParserService).register(JsonParser, YamlParser)\n\n this.nunjucks.addFilter('markdown_to_html', (markdown: string) => {\n return new showdown.Converter().makeHtml(markdown)\n })\n this.tasks.options = { silentRendererCondition: true }\n }\n\n public async run(): Promise<void> {\n this.tasks.add([\n {\n task: async(ctx): Promise<void> => {\n const file = join(process.cwd(), this.args.file)\n\n if (!this.fs.exists(file)) {\n throw new Error(`File does not exists: ${file}`)\n }\n\n this.logger.debug('Loading file: %s', file)\n\n ctx.file = file\n switch (extname(ctx.file)) {\n case '.md': {\n const data = graymatter.read(ctx.file)\n\n ctx.content = await this.fs.read(file)\n ctx.content = data.content\n\n ctx.metadata = data.data\n\n break\n }\n\n case '.yml': {\n ctx.content = await this.fs.read(file)\n\n ctx.metadata = await this.app.get(ParserService).parse(ctx.file, ctx.content)\n\n break\n }\n\n default:\n throw new Error('File type is not accepted.')\n }\n }\n },\n\n {\n task: async(ctx): Promise<void> => {\n const template = ctx.metadata?.template ?? this.flags.template\n\n this.logger.debug('Loading template: %s', template)\n\n ctx.templates = new RegExp(/\\.\\.?\\//).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template)\n\n await Promise.all(\n RequiredTemplateFiles.map(async(file) => {\n const current = join(ctx.templates, file)\n\n if (!this.fs.exists(current)) {\n throw new Error(`Template does not exists: ${current}`)\n }\n })\n )\n\n const paths: Record<TemplateFiles, string> = {\n [TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),\n [TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),\n [TemplateFiles.TAILWIND_CSS]: join(ctx.templates, TemplateFiles.TAILWIND_CSS),\n [TemplateFiles.TAILWIND_CONFIG]: join(ctx.templates, TemplateFiles.TAILWIND_CONFIG),\n [TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),\n [TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),\n [TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)\n }\n\n ctx.options = await this.cs.extend<PdfConfig>([\n paths[TemplateFiles.SETTINGS],\n {\n dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,\n document_title: ctx.metadata?.document_title ?? this.flags.title ?? this.args.file\n // https://github.com/simonhaenisch/md-to-pdf/issues/247\n // launch_options: {\n // headless: true\n // }\n }\n ])\n\n this.logger.debug('Options: %o', ctx.options)\n\n if (this.fs.exists(paths[TemplateFiles.HEADER])) {\n this.logger.debug('Header exists for template.')\n\n ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.FOOTER])) {\n this.logger.debug('Footer exists for template.')\n\n ctx.options.pdf_options.footerTemplate = await this.fs.read(paths[TemplateFiles.FOOTER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {\n this.logger.debug('Design template exists for template.')\n\n ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE])\n\n this.logger.debug('Metadata: %o', ctx.metadata)\n }\n\n if (this.fs.exists(paths[TemplateFiles.CSS])) {\n this.logger.debug('CSS exists for template.')\n ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TAILWIND_CSS])) {\n this.logger.debug('Tailwind CSS exists for template, generating configuration from: %s -> %s', paths[TemplateFiles.TAILWIND_CONFIG], paths[TemplateFiles.TAILWIND_CSS])\n\n ctx.options.css = await postcss([\n tailwind({\n ...(await import(paths[TemplateFiles.TAILWIND_CONFIG]).then((m) => m.default)),\n content: [ { raw: ctx.template, extension: 'html' } ]\n })\n ])\n .process(await this.fs.read(paths[TemplateFiles.TAILWIND_CSS]), { from: undefined })\n .then((result) => result.css)\n }\n }\n },\n\n {\n task: async(ctx): Promise<void> => {\n if (this.flags.dev) {\n ctx.options.devtools = true\n\n this.logger.info('Running in dev mode.')\n }\n }\n }\n ])\n }\n\n public async shouldRunAfter(ctx: MdPrinterCtx): Promise<void> {\n if (this.flags.watch) {\n this.logger.info('Running in watch mode.')\n\n watch([TEMPLATE_DIRECTORY, this.args.file, join(ctx.templates, '**/*')]).on('change', async() => {\n await this.run()\n await this.runTasks()\n\n this.logger.info('Waiting for the next change.')\n\n return this.runMd2Pdf(ctx)\n })\n }\n\n return this.runMd2Pdf(ctx)\n }\n\n private async runMd2Pdf(ctx: MdPrinterCtx): Promise<void> {\n let pdf: PdfOutput\n\n if (ctx.template) {\n this.logger.debug('Rendering as template.')\n pdf = await mdToPdf({ content: this.nunjucks.renderString(ctx.template, { ...(ctx.metadata ?? {}), content: ctx.content }) }, ctx.options)\n } else {\n this.logger.debug('Rendering as plain file.')\n pdf = await mdToPdf({ content: ctx.content }, ctx.options)\n }\n\n const output = pdf.filename\n\n await this.fs.mkdir(dirname(output))\n\n if (!output) {\n throw new Error('Output should either be defined with the variable or front-matter.')\n } else if (!OUTPUT_FILE_ACCEPTED_TYPES.includes(extname(output))) {\n throw new Error(`Output file should be ending with the extension: ${OUTPUT_FILE_ACCEPTED_TYPES.join(', ')} -> current: ${extname(output)}`)\n }\n\n this.logger.debug('Output file will be: %s', output)\n\n if (pdf) {\n this.logger.info('Writing file to output: %s', output)\n\n await this.fs.write(output, pdf.content)\n }\n }\n}\n"],"mappings":";;AAAA,SAASA,aAAa;AACtB,SAASC,WAAWC,kBAAkB;AACtC,SAASC,eAAe;AAGxB,OAAOC,cAAc;AACrB,SAASC,UAAUC,SAASC,SAASC,YAAY;AACjD,OAAOC,aAAa;AACpB,OAAOC,cAAc;AACrB,OAAOC,cAAc;AAGrB,SAASC,MAAMC,OAAOC,SAASC,eAAeC,mBAAmBC,eAAeC,YAA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QAAQ4B,MAAAA,CAAAA,EAAS;IAC5I;AAEA,SAAK4B,OAAOC,MAAM,2BAA2B7B,MAAAA;AAE7C,QAAIwE,KAAK;AACP,WAAK5C,OAAOuC,KAAK,8BAA8BnE,MAAAA;AAE/C,YAAM,KAAKQ,GAAGqE,MAAM7E,QAAQwE,IAAIxC,OAAO;IACzC;EACF;AACF;","names":["watch","default","graymatter","mdToPdf","Nunjucks","basename","dirname","extname","join","postcss","showdown","tailwind","Args","Flags","Command","ConfigService","FileSystemService","ParserService","JsonParser","YamlParser","OUTPUT_FILE_ACCEPTED_TYPES","RequiredTemplateFiles","TEMPLATE_DIRECTORY","TemplateFiles","description","flags","template","string","char","title","boolean","dev","args","file","required","output","nunjucks","configure","autoescape","throwOnUndefined","trimBlocks","lstripBlocks","cs","fs","shouldRunBefore","app","get","register","addFilter","markdown","Converter","makeHtml","tasks","options","silentRendererCondition","run","add","task","ctx","process","cwd","exists","Error","logger","debug","data","read","content","metadata","parse","templates","RegExp","test","config","root","Promise","all","map","current","paths","SETTINGS","CSS","TAILWIND_CSS","TAILWIND_CONFIG","HEADER","FOOTER","TEMPLATE","extend","dest","document_title","pdf_options","headerTemplate","footerTemplate","css","then","m","raw","extension","from","undefined","result","devtools","info","shouldRunAfter","on","runTasks","runMd2Pdf","pdf","renderString","filename","mkdir","includes","write"]}
1
+ {"version":3,"file":"index.js","names":["markdown: string","paths: Record<TemplateFiles, string>","ctx: MdPrinterCtx","pdf: PdfOutput"],"sources":["../../src/commands/index.ts"],"sourcesContent":["import tailwind from '@tailwindcss/postcss'\nimport { watch } from 'chokidar'\nimport { default as graymatter } from 'gray-matter'\nimport { mdToPdf } from 'md-to-pdf'\nimport type { PdfConfig } from 'md-to-pdf/dist/lib/config.js'\nimport type { PdfOutput } from 'md-to-pdf/dist/lib/generate-output.js'\nimport Nunjucks from 'nunjucks'\nimport { basename, dirname, extname, join } from 'path'\nimport postcss from 'postcss'\nimport showdown from 'showdown'\n\nimport type { ShouldRunAfterHook, ShouldRunBeforeHook } from '@cenk1cenk2/oclif-common'\nimport { Args, Flags, Command, ConfigService, FileSystemService, ParserService, JsonParser, YamlParser } from '@cenk1cenk2/oclif-common'\nimport { OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from '@constants'\nimport type { MdPrinterCtx } from '@interfaces'\n\nexport default class MDPrinter extends Command<typeof MDPrinter, MdPrinterCtx> implements ShouldRunBeforeHook, ShouldRunAfterHook {\n static description = 'Generates a PDF from the given markdown file with the selected HTML template.'\n\n static flags = {\n template: Flags.string({\n char: 't',\n default: 'default',\n description: 'HTML template for the generated PDF file.'\n }),\n title: Flags.string({\n char: 'T',\n description: 'Overwrite document title.'\n }),\n browser: Flags.string({\n char: 'b',\n description: 'Browser path that is going to be used for the PDF generation.',\n default: '/usr/bin/brave'\n }),\n watch: Flags.boolean({\n char: 'w',\n description: 'Watch the changes on the given file.'\n }),\n dev: Flags.boolean({\n char: 'd',\n description: 'Run with Chrome browser instead of publishing the file.'\n })\n }\n\n static args = {\n file: Args.string({\n description: 'File to be processed.',\n required: true\n }),\n output: Args.string({\n description: 'Output file that will be generated. Overwrites the one define in front-matter.',\n required: false\n })\n }\n\n private nunjucks = Nunjucks.configure({\n autoescape: false,\n throwOnUndefined: true,\n trimBlocks: true,\n lstripBlocks: false\n })\n private cs: ConfigService\n private fs: FileSystemService\n\n public async shouldRunBefore(): Promise<void> {\n this.cs = this.app.get(ConfigService)\n this.fs = this.app.get(FileSystemService)\n\n await this.app.get(ParserService).register(JsonParser, YamlParser)\n\n this.nunjucks.addFilter('markdown_to_html', (markdown: string) => {\n return new showdown.Converter().makeHtml(markdown)\n })\n this.tasks.options = { silentRendererCondition: true }\n }\n\n public async run(): Promise<void> {\n this.tasks.add([\n {\n task: async(ctx): Promise<void> => {\n const file = join(process.cwd(), this.args.file)\n\n if (!this.fs.exists(file)) {\n throw new Error(`File does not exists: ${file}`)\n }\n\n this.logger.debug('Loading file: %s', file)\n\n ctx.file = file\n switch (extname(ctx.file)) {\n case '.md': {\n const data = graymatter.read(ctx.file)\n\n ctx.content = await this.fs.read(file)\n ctx.content = data.content\n\n ctx.metadata = data.data\n\n break\n }\n\n case '.yml': {\n ctx.content = await this.fs.read(file)\n\n ctx.metadata = await this.app.get(ParserService).parse(ctx.file, ctx.content)\n\n break\n }\n\n default:\n throw new Error('File type is not accepted.')\n }\n }\n },\n\n {\n task: async(ctx): Promise<void> => {\n const template = ctx.metadata?.template ?? this.flags.template\n\n ctx.templates = new RegExp(/\\.\\.?\\//).test(template) ? join(process.cwd(), template) : join(this.config.root, TEMPLATE_DIRECTORY, template)\n\n this.logger.debug('Loading template: %s from %s', template, ctx.templates)\n\n await Promise.all(\n RequiredTemplateFiles.map(async(file) => {\n const current = join(ctx.templates, file)\n\n if (!this.fs.exists(current)) {\n throw new Error(`Template does not exists: ${current}`)\n }\n })\n )\n\n const paths: Record<TemplateFiles, string> = {\n [TemplateFiles.SETTINGS]: join(ctx.templates, TemplateFiles.SETTINGS),\n [TemplateFiles.CSS]: join(ctx.templates, TemplateFiles.CSS),\n [TemplateFiles.TAILWIND_CSS]: join(ctx.templates, TemplateFiles.TAILWIND_CSS),\n [TemplateFiles.HEADER]: join(ctx.templates, TemplateFiles.HEADER),\n [TemplateFiles.FOOTER]: join(ctx.templates, TemplateFiles.FOOTER),\n [TemplateFiles.TEMPLATE]: join(ctx.templates, TemplateFiles.TEMPLATE)\n }\n\n ctx.options = await this.cs.extend<PdfConfig>([\n paths[TemplateFiles.SETTINGS],\n {\n dest: this.args?.output ?? ctx.metadata?.dest ?? `${basename(this.args.file, extname(this.args.file))}.pdf`,\n document_title: ctx.metadata?.document_title ?? this.flags.title ?? this.args.file,\n // https://github.com/simonhaenisch/md-to-pdf/issues/247\n launch_options: {\n executablePath: this.flags.browser\n // headless: true\n }\n }\n ])\n\n this.logger.debug('Options: %o', ctx.options)\n\n if (this.fs.exists(paths[TemplateFiles.HEADER])) {\n this.logger.debug('Header exists for template.')\n\n ctx.options.pdf_options.headerTemplate = await this.fs.read(paths[TemplateFiles.HEADER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.FOOTER])) {\n this.logger.debug('Footer exists for template.')\n\n ctx.options.pdf_options.footerTemplate = await this.fs.read(paths[TemplateFiles.FOOTER])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TEMPLATE])) {\n this.logger.debug('Design template exists for template.')\n\n ctx.template = await this.fs.read(paths[TemplateFiles.TEMPLATE])\n\n this.logger.debug('Metadata: %o', ctx.metadata)\n }\n\n if (this.fs.exists(paths[TemplateFiles.CSS])) {\n this.logger.debug('CSS exists for template.')\n ctx.options.css = await this.fs.read(paths[TemplateFiles.CSS])\n }\n\n if (this.fs.exists(paths[TemplateFiles.TAILWIND_CSS])) {\n this.logger.debug('Tailwind CSS exists for template: %s -> %s', paths[TemplateFiles.TAILWIND_CSS])\n\n ctx.options.css = await postcss([\n tailwind({\n // content: [{ raw: ctx.template, extension: 'html' }],\n base: ctx.templates\n })\n ])\n .process(await this.fs.read(paths[TemplateFiles.TAILWIND_CSS]), { from: paths[TemplateFiles.TAILWIND_CSS] })\n .then((result) => result.css)\n }\n }\n },\n\n {\n task: async(ctx): Promise<void> => {\n if (this.flags.dev) {\n ctx.options.devtools = true\n\n this.logger.info('Running in dev mode.')\n }\n }\n }\n ])\n }\n\n public async shouldRunAfter(ctx: MdPrinterCtx): Promise<void> {\n if (this.flags.watch) {\n this.logger.info('Running in watch mode.')\n\n watch([TEMPLATE_DIRECTORY, this.args.file, join(ctx.templates, '**/*')]).on('change', async() => {\n await this.run()\n await this.runTasks()\n\n this.logger.info('Waiting for the next change.')\n\n return this.runMd2Pdf(ctx)\n })\n }\n\n return this.runMd2Pdf(ctx)\n }\n\n private async runMd2Pdf(ctx: MdPrinterCtx): Promise<void> {\n let pdf: PdfOutput\n\n if (ctx.template) {\n this.logger.debug('Rendering as template.')\n pdf = await mdToPdf({ content: this.nunjucks.renderString(ctx.template, { ...(ctx.metadata ?? {}), content: ctx.content }) }, ctx.options)\n } else {\n this.logger.debug('Rendering as plain file.')\n pdf = await mdToPdf({ content: ctx.content }, ctx.options)\n }\n\n const output = pdf.filename\n\n await this.fs.mkdir(dirname(output))\n\n if (!output) {\n throw new Error('Output should either be defined with the variable or front-matter.')\n } else if (!OUTPUT_FILE_ACCEPTED_TYPES.includes(extname(output))) {\n throw new Error(`Output file should be ending with the extension: ${OUTPUT_FILE_ACCEPTED_TYPES.join(', ')} -> current: ${extname(output)}`)\n }\n\n this.logger.debug('Output file will be: %s', output)\n\n if (pdf) {\n this.logger.info('Writing file to output: %s', output)\n\n await this.fs.write(output, pdf.content)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAqB,YAArB,cAAuC,QAA2F;CAChI,OAAO,cAAc;CAErB,OAAO,QAAQ;EACb,UAAU,MAAM,OAAO;GACrB,MAAM;GACN,SAAS;GACT,aAAa;EACd,EAAC;EACF,OAAO,MAAM,OAAO;GAClB,MAAM;GACN,aAAa;EACd,EAAC;EACF,SAAS,MAAM,OAAO;GACpB,MAAM;GACN,aAAa;GACb,SAAS;EACV,EAAC;EACF,OAAO,MAAM,QAAQ;GACnB,MAAM;GACN,aAAa;EACd,EAAC;EACF,KAAK,MAAM,QAAQ;GACjB,MAAM;GACN,aAAa;EACd,EAAC;CACH;CAED,OAAO,OAAO;EACZ,MAAM,KAAK,OAAO;GAChB,aAAa;GACb,UAAU;EACX,EAAC;EACF,QAAQ,KAAK,OAAO;GAClB,aAAa;GACb,UAAU;EACX,EAAC;CACH;CAED,AAAQ,WAAW,SAAS,UAAU;EACpC,YAAY;EACZ,kBAAkB;EAClB,YAAY;EACZ,cAAc;CACf,EAAC;CACF,AAAQ;CACR,AAAQ;CAER,MAAa,kBAAiC;AAC5C,OAAK,KAAK,KAAK,IAAI,IAAI,cAAc;AACrC,OAAK,KAAK,KAAK,IAAI,IAAI,kBAAkB;AAEzC,QAAM,KAAK,IAAI,IAAI,cAAc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AAQ,EAAE,SAAS,KAAK,SAAS,aAAa,IAAI,UAAU;IAAE,GAAI,IAAI,YAAY,CAAE;IAAG,SAAS,IAAI;GAAS,EAAC,CAAE,GAAE,IAAI,QAAQ;EAC3I,OAAM;AACL,QAAK,OAAO,MAAM,2BAA2B;AAC7C,SAAM,MAAM,QAAQ,EAAE,SAAS,IAAI,QAAS,GAAE,IAAI,QAAQ;EAC3D;EAED,MAAM,SAAS,IAAI;AAEnB,QAAM,KAAK,GAAG,MAAM,QAAQ,OAAO,CAAC;AAEpC,OAAK,OACH,OAAM,IAAI,MAAM;YACN,2BAA2B,SAAS,QAAQ,OAAO,CAAC,CAC9D,OAAM,IAAI,MAAM,CAAC,iDAAiD,EAAE,2BAA2B,KAAK,KAAK,CAAC,aAAa,EAAE,QAAQ,OAAO,EAAE;AAG5I,OAAK,OAAO,MAAM,2BAA2B,OAAO;AAEpD,MAAI,KAAK;AACP,QAAK,OAAO,KAAK,8BAA8B,OAAO;AAEtD,SAAM,KAAK,GAAG,MAAM,QAAQ,IAAI,QAAQ;EACzC;CACF;AACF"}
@@ -1,7 +1,6 @@
1
- const OUTPUT_FILE_ACCEPTED_TYPES = [
2
- ".pdf"
3
- ];
4
- export {
5
- OUTPUT_FILE_ACCEPTED_TYPES
6
- };
1
+ //#region src/constants/file.constants.ts
2
+ const OUTPUT_FILE_ACCEPTED_TYPES = [".pdf"];
3
+
4
+ //#endregion
5
+ export { OUTPUT_FILE_ACCEPTED_TYPES };
7
6
  //# sourceMappingURL=file.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/file.constants.ts"],"sourcesContent":["export const OUTPUT_FILE_ACCEPTED_TYPES = ['.pdf']\n"],"mappings":"AAAO,MAAMA,6BAA6B;EAAC;;","names":["OUTPUT_FILE_ACCEPTED_TYPES"]}
1
+ {"version":3,"file":"file.constants.js","names":[],"sources":["../../src/constants/file.constants.ts"],"sourcesContent":["export const OUTPUT_FILE_ACCEPTED_TYPES = ['.pdf']\n"],"mappings":";AAAA,MAAa,6BAA6B,CAAC,MAAO"}
@@ -1,3 +1,4 @@
1
- export * from "./template.constants.js";
2
- export * from "./file.constants.js";
3
- //# sourceMappingURL=index.js.map
1
+ import { RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles } from "./template.constants.js";
2
+ import { OUTPUT_FILE_ACCEPTED_TYPES } from "./file.constants.js";
3
+
4
+ export { OUTPUT_FILE_ACCEPTED_TYPES, RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles };
@@ -1,20 +1,16 @@
1
- var TemplateFiles = /* @__PURE__ */ function(TemplateFiles2) {
2
- TemplateFiles2["FOOTER"] = "footer.html";
3
- TemplateFiles2["HEADER"] = "header.html";
4
- TemplateFiles2["TEMPLATE"] = "template.html.j2";
5
- TemplateFiles2["TAILWIND_CSS"] = "tailwind.css";
6
- TemplateFiles2["TAILWIND_CONFIG"] = "tailwind.config.cjs";
7
- TemplateFiles2["CSS"] = "main.css";
8
- TemplateFiles2["SETTINGS"] = "settings.json";
9
- return TemplateFiles2;
1
+ //#region src/constants/template.constants.ts
2
+ let TemplateFiles = /* @__PURE__ */ function(TemplateFiles$1) {
3
+ TemplateFiles$1["FOOTER"] = "footer.html";
4
+ TemplateFiles$1["HEADER"] = "header.html";
5
+ TemplateFiles$1["TEMPLATE"] = "template.html.j2";
6
+ TemplateFiles$1["TAILWIND_CSS"] = "tailwind.css";
7
+ TemplateFiles$1["CSS"] = "main.css";
8
+ TemplateFiles$1["SETTINGS"] = "settings.json";
9
+ return TemplateFiles$1;
10
10
  }({});
11
- const RequiredTemplateFiles = [
12
- "settings.json"
13
- ];
11
+ const RequiredTemplateFiles = [TemplateFiles.SETTINGS];
14
12
  const TEMPLATE_DIRECTORY = "templates";
15
- export {
16
- RequiredTemplateFiles,
17
- TEMPLATE_DIRECTORY,
18
- TemplateFiles
19
- };
13
+
14
+ //#endregion
15
+ export { RequiredTemplateFiles, TEMPLATE_DIRECTORY, TemplateFiles };
20
16
  //# sourceMappingURL=template.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/template.constants.ts"],"sourcesContent":["export enum TemplateFiles {\n FOOTER = 'footer.html',\n HEADER = 'header.html',\n TEMPLATE = 'template.html.j2',\n TAILWIND_CSS = 'tailwind.css',\n TAILWIND_CONFIG = 'tailwind.config.cjs',\n CSS = 'main.css',\n SETTINGS = 'settings.json'\n}\n\nexport const RequiredTemplateFiles = [TemplateFiles.SETTINGS]\n\nexport const TEMPLATE_DIRECTORY = 'templates'\n"],"mappings":"AAAO,IAAKA,gBAAAA,yBAAAA,gBAAAA;;;;;;;;SAAAA;;AAUL,MAAMC,wBAAwB;;;AAE9B,MAAMC,qBAAqB;","names":["TemplateFiles","RequiredTemplateFiles","TEMPLATE_DIRECTORY"]}
1
+ {"version":3,"file":"template.constants.js","names":[],"sources":["../../src/constants/template.constants.ts"],"sourcesContent":["export enum TemplateFiles {\n FOOTER = 'footer.html',\n HEADER = 'header.html',\n TEMPLATE = 'template.html.j2',\n TAILWIND_CSS = 'tailwind.css',\n CSS = 'main.css',\n SETTINGS = 'settings.json'\n}\n\nexport const RequiredTemplateFiles = [TemplateFiles.SETTINGS]\n\nexport const TEMPLATE_DIRECTORY = 'templates'\n"],"mappings":";AAAA,IAAY,0DAAL;AACL;AACA;AACA;AACA;AACA;AACA;;AACD;AAED,MAAa,wBAAwB,CAAC,cAAc,QAAS;AAE7D,MAAa,qBAAqB"}
@@ -1,6 +1,8 @@
1
1
  import { notFoundHook } from "@cenk1cenk2/oclif-common";
2
+
3
+ //#region src/hooks/not-found.hook.ts
2
4
  var not_found_hook_default = notFoundHook;
3
- export {
4
- not_found_hook_default as default
5
- };
5
+
6
+ //#endregion
7
+ export { not_found_hook_default as default };
6
8
  //# sourceMappingURL=not-found.hook.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/not-found.hook.ts"],"sourcesContent":["import { notFoundHook } from '@cenk1cenk2/oclif-common'\n\nexport default notFoundHook\n"],"mappings":"AAAA,SAASA,oBAAoB;AAE7B,IAAA,yBAAeA;","names":["notFoundHook"]}
1
+ {"version":3,"file":"not-found.hook.js","names":[],"sources":["../../src/hooks/not-found.hook.ts"],"sourcesContent":["import { notFoundHook } from '@cenk1cenk2/oclif-common'\n\nexport default notFoundHook\n"],"mappings":";;;AAEA,6BAAe"}
@@ -1,6 +1,8 @@
1
1
  import { updateNotifierHook } from "@cenk1cenk2/oclif-common";
2
+
3
+ //#region src/hooks/update-notifier.hook.ts
2
4
  var update_notifier_hook_default = updateNotifierHook;
3
- export {
4
- update_notifier_hook_default as default
5
- };
5
+
6
+ //#endregion
7
+ export { update_notifier_hook_default as default };
6
8
  //# sourceMappingURL=update-notifier.hook.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/update-notifier.hook.ts"],"sourcesContent":["import { updateNotifierHook } from '@cenk1cenk2/oclif-common'\n\nexport default updateNotifierHook\n"],"mappings":"AAAA,SAASA,0BAA0B;AAEnC,IAAA,+BAAeA;","names":["updateNotifierHook"]}
1
+ {"version":3,"file":"update-notifier.hook.js","names":[],"sources":["../../src/hooks/update-notifier.hook.ts"],"sourcesContent":["import { updateNotifierHook } from '@cenk1cenk2/oclif-common'\n\nexport default updateNotifierHook\n"],"mappings":";;;AAEA,mCAAe"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=run.interface.js.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
@@ -72,6 +72,15 @@
72
72
  "multiple": false,
73
73
  "type": "option"
74
74
  },
75
+ "browser": {
76
+ "char": "b",
77
+ "description": "Browser path that is going to be used for the PDF generation.",
78
+ "name": "browser",
79
+ "default": "/usr/bin/brave",
80
+ "hasDynamicHelp": false,
81
+ "multiple": false,
82
+ "type": "option"
83
+ },
75
84
  "watch": {
76
85
  "char": "w",
77
86
  "description": "Watch the changes on the given file.",
@@ -97,5 +106,5 @@
97
106
  "enableJsonFlag": false
98
107
  }
99
108
  },
100
- "version": "2.3.1"
109
+ "version": "2.3.2"
101
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/md-printer",
3
- "version": "2.3.2",
3
+ "version": "2.3.3",
4
4
  "description": "A markdown printer.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -16,11 +16,11 @@
16
16
  "scripts": {
17
17
  "dev": "./bin/dev.js",
18
18
  "start": "./bin/run.js",
19
- "build": "tsup-node",
20
- "dev:start": "tsup-node --watch",
19
+ "build": "tsdown src/",
20
+ "dev:start": "tsdown --watch src/",
21
21
  "clean": "rimraf oclif.manifset.json",
22
- "format": "prettier --write src/ --log-level warn && eslint --fix src/",
23
- "lint": "eslint src/",
22
+ "format": "prettier --write src/ --log-level warn && eslint --fix",
23
+ "lint": "eslint",
24
24
  "manifest": "oclif manifest",
25
25
  "docs:toc": "oclif readme"
26
26
  },
@@ -71,44 +71,43 @@
71
71
  ],
72
72
  "dependencies": {
73
73
  "@cenk1cenk2/oclif-common": "^6.3.29",
74
- "@listr2/manager": "^2.0.13",
75
- "@oclif/core": "^4.2.0",
76
- "@oclif/plugin-help": "^6.2.20",
77
- "@tailwindcss/forms": "^0.5.9",
78
- "@tailwindcss/typography": "^0.5.15",
74
+ "@listr2/manager": "^3.0.1",
75
+ "@oclif/core": "^4.5.0",
76
+ "@oclif/plugin-help": "^6.2.30",
77
+ "@tailwindcss/forms": "^0.5.10",
78
+ "@tailwindcss/postcss": "^4.1.11",
79
+ "@tailwindcss/typography": "^0.5.16",
79
80
  "chokidar": "^4.0.3",
80
- "fs-extra": "^11.2.0",
81
+ "fs-extra": "^11.3.0",
81
82
  "gray-matter": "^4.0.3",
82
- "listr2": "^8.2.5",
83
+ "listr2": "^9.0.1",
83
84
  "md-to-pdf": "^5.2.4",
84
85
  "nunjucks": "^3.2.4",
85
- "postcss": "^8.4.49",
86
+ "postcss": "^8.5.6",
86
87
  "showdown": "^2.1.0",
87
- "tailwindcss": "^3.4.17"
88
+ "source-map-support": "^0.5.21",
89
+ "tailwindcss": "^4.1.11"
88
90
  },
89
91
  "devDependencies": {
90
- "@cenk1cenk2/cz-cc": "^1.8.0",
91
- "@cenk1cenk2/eslint-config": "^3.1.16",
92
- "@swc/core": "^1.10.1",
92
+ "@cenk1cenk2/cz-cc": "^2.0.2",
93
+ "@cenk1cenk2/eslint-config": "^3.1.54",
93
94
  "@types/config": "^3.3.5",
94
95
  "@types/fs-extra": "^11.0.4",
95
- "@types/node": "^22.10.2",
96
+ "@types/node": "^24.0.15",
96
97
  "@types/nunjucks": "^3.2.6",
97
98
  "@types/showdown": "^2.0.6",
98
- "eslint": "^9.17.0",
99
- "execa": "^9.5.2",
100
- "globby": "^14.0.2",
101
- "lint-staged": "^15.2.11",
102
- "oclif": "^4.17.4",
103
- "prettier": "^3.4.2",
104
- "simple-git-hooks": "^2.11.1",
105
- "source-map-support": "^0.5.21",
99
+ "eslint": "^9.31.0",
100
+ "execa": "^9.6.0",
101
+ "globby": "^14.1.0",
102
+ "lint-staged": "^16.1.2",
103
+ "oclif": "^4.21.2",
104
+ "prettier": "^3.6.2",
105
+ "simple-git-hooks": "^2.13.0",
106
106
  "theme-colors": "^0.1.0",
107
107
  "ts-node": "^10.9.2",
108
108
  "tsconfig-paths": "^4.2.0",
109
- "tsconfig-replace-paths": "^0.0.14",
110
- "tsup": "^8.3.5",
111
- "typescript": "^5.7.2"
109
+ "tsdown": "^0.12.9",
110
+ "typescript": "^5.8.3"
112
111
  },
113
112
  "config": {
114
113
  "commitizen": {
@@ -0,0 +1,59 @@
1
+ @import url(https://unpkg.com/github-markdown-css/github-markdown-light.css);
2
+ @import url(https://fonts.googleapis.com/css2?family=Montserrat:wght@400);
3
+ @import url(https://fonts.googleapis.com/css2?family=Roboto+Mono);
4
+
5
+ .markdown-body {
6
+ font-size: 11px;
7
+ font-family: 'Montserrat', sans-serif;
8
+ }
9
+
10
+ .page-break {
11
+ page-break-after: always;
12
+ }
13
+
14
+ .markdown-body pre > code {
15
+ white-space: pre-wrap;
16
+ padding: 0;
17
+ margin: 0;
18
+
19
+ font-family: 'Roboto Mono', monospace;
20
+ }
21
+
22
+ .markdown-body .document-title-header {
23
+ height: 500px;
24
+ margin: auto auto;
25
+ padding-top: 50%;
26
+ page-break-after: always;
27
+ border-bottom: 0;
28
+ font-size: 2.5em;
29
+ }
30
+
31
+ .markdown-body pre {
32
+ background-color: #1e2127;
33
+ padding: 12px 8px;
34
+ }
35
+
36
+ .markdown-body output pre {
37
+ margin-top: -36px;
38
+ background-color: #1e2127;
39
+ border-top-left-radius: 0;
40
+ border-top-right-radius: 0;
41
+ border-top-color: #38404b;
42
+ border-top-width: 2px;
43
+ border-top-style: solid;
44
+ }
45
+
46
+ .markdown-body output::before {
47
+ padding: 4px 16px;
48
+ position: relative;
49
+ top: -24px;
50
+ border-top-left-radius: 4px;
51
+ border-top-right-radius: 4px;
52
+ color: #a0a0a0;
53
+ background-color: #1e2127;
54
+ content: '> output';
55
+ font-size: 0.85em;
56
+ border-top-color: #38404b;
57
+ border-top-width: 2px;
58
+ border-top-style: solid;
59
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "body_class": ["markdown-body"],
3
+ "highlight_style": "atom-one-dark",
4
+ "pdf_options": {
5
+ "format": "A4",
6
+ "margin": "18mm 12mm",
7
+ "printBackground": true
8
+ }
9
+ }
@@ -1,13 +1,33 @@
1
- html {
2
- font-size: 12px;
3
- }
1
+ @import 'tailwindcss';
2
+
3
+ @import url(https://fonts.googleapis.com/css2?family=Montserrat:wght@400) layer(utilities);
4
+
5
+ @config './tailwind.config.cjs';
4
6
 
5
- .page-break {
6
- page-break-after: always;
7
+ /*
8
+ The default border color has changed to `currentcolor` in Tailwind CSS v4,
9
+ so we've added these compatibility styles to make sure everything still
10
+ looks the same as it did with Tailwind CSS v3.
11
+
12
+ If we ever want to remove these styles, we need to add an explicit border
13
+ color utility to any element that depends on these defaults.
14
+ */
15
+ @layer base {
16
+ *,
17
+ ::after,
18
+ ::before,
19
+ ::backdrop,
20
+ ::file-selector-button {
21
+ border-color: var(--color-gray-200, currentcolor);
22
+ }
7
23
  }
8
24
 
9
- @tailwind base;
10
- @tailwind components;
11
- @tailwind utilities;
25
+ @layer base {
26
+ html {
27
+ font-size: 12px;
28
+ }
12
29
 
13
- @import url(https://fonts.googleapis.com/css2?family=Montserrat:wght@400);
30
+ .page-break {
31
+ page-break-after: always;
32
+ }
33
+ }
@@ -85,7 +85,7 @@
85
85
  {% endfor %}
86
86
  </tbody>
87
87
  <tfoot class="text-black border-t-2 border-primary-500">
88
- <tr class="border-0 !bg-gray-200">
88
+ <tr class="border-0 bg-gray-200!">
89
89
  <td></td>
90
90
  <td></td>
91
91
  <th class="text-center">Gesamt</th>
@@ -116,7 +116,7 @@
116
116
  </tr>
117
117
  </thead>
118
118
  <tfoot class="text-black border-t-2 border-primary-500">
119
- <tr class="border-0 !bg-gray-100 font-semibold text-center">
119
+ <tr class="border-0 bg-gray-100! font-semibold text-center">
120
120
  <td>{{ payment.name }}</td>
121
121
  <td>{{ payment.bank }}</td>
122
122
  <td>{{ payment.bic }}</td>
@@ -125,7 +125,7 @@
125
125
  </tfoot>
126
126
  </table>
127
127
  </div>
128
- <hr class="border-t-2 !mt-0 !mb-2" style="margin-top: 0 !important; margin-bottom: 1.5em !important;" />
128
+ <hr class="border-t-2 mt-0! mb-2!" style="margin-top: 0 !important; margin-bottom: 1.5em !important;" />
129
129
  <div class="grid grid-cols-2 font-semibold">
130
130
  <div class="flex flex-row items-center text-center">
131
131
  <div class="w-full">
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["export * from './template.constants.js'\nexport * from './file.constants.js'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +0,0 @@
1
- {
2
- "body_class": [],
3
- "pdf_options": {
4
- "format": null,
5
- "width": "38mm",
6
- "height": "25mm",
7
- "margin": "0.5mm 0.5mm 0.5mm 0.5mm",
8
- "printBackground": false
9
- }
10
- }
@@ -1,74 +0,0 @@
1
- const colors = require('theme-colors').getColors
2
-
3
- /** @type {import("tailwindcss").Config} */
4
- module.exports = {
5
- content: ['./template.html.j2'],
6
- theme: {
7
- extend: {
8
- fontFamily: {
9
- sans: ['Montserrat'],
10
- serif: ['Montserrat']
11
- },
12
- colors: {
13
- primary: colors('#cd0043')
14
- },
15
- typography: (theme) => ({
16
- css: {
17
- a: {
18
- color: theme('colors.primary.500'),
19
- textDecoration: 'none'
20
- },
21
- h1: {
22
- fontWeight: 700,
23
- paddingTop: theme('padding.0.75'),
24
- paddingBottom: theme('padding.0.75'),
25
- marginBottom: 0,
26
- marginTop: 0,
27
- borderWidth: 0
28
- },
29
- h2: {
30
- paddingTop: theme('padding.0.5'),
31
- paddingBottom: theme('padding.0.5'),
32
- marginBottom: 0,
33
- marginTop: 0,
34
- borderWidth: 0
35
- },
36
- h3: {
37
- paddingTop: theme('padding.0.25'),
38
- paddingBottom: theme('padding.0.25'),
39
- marginBottom: 0,
40
- marginTop: 0,
41
- borderWidth: 0
42
- },
43
- blockquote: {
44
- fontWeight: 400,
45
- color: theme('colors.gray.600'),
46
- fontStyle: 'normal',
47
- quotes: '"\\201C""\\201D""\\2018""\\2019"'
48
- },
49
- 'blockquote p:first-of-type::before': {
50
- content: ''
51
- },
52
- 'blockquote p:last-of-type::after': {
53
- content: ''
54
- },
55
- 'ul > li': {
56
- paddingLeft: '1em',
57
- textAlign: 'left'
58
- },
59
- 'ol > li': {
60
- paddingLeft: '1em',
61
- textAlign: 'left'
62
- },
63
- 'ol > li::before': {
64
- top: 'calc(0.875em - 0.1em)'
65
- },
66
- 'ul > li::before': {
67
- top: 'calc(0.875em - 0.1em)'
68
- }
69
- }
70
- })
71
- }
72
- },
73
- plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')]
74
- }
@@ -1,13 +0,0 @@
1
- html {
2
- font-size: 8px;
3
- }
4
-
5
- .page-break {
6
- page-break-after: always;
7
- }
8
-
9
- @tailwind base;
10
- @tailwind components;
11
- @tailwind utilities;
12
-
13
- @import url(https://fonts.googleapis.com/css2?family=Montserrat:wght@400);
@@ -1,36 +0,0 @@
1
- <!--
2
- vim: ft=html
3
- -->
4
- <!DOCTYPE html>
5
- <html lang="en">
6
-
7
- <head>
8
- <meta charset="UTF-8">
9
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
10
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
11
- <title>Document</title>
12
- </head>
13
-
14
- <body>
15
- <div class="h-full w-full leading-tight prose border-2 rounded-md overflow-hidden">
16
- <div class="flex flex-col h-full w-full items-center">
17
- <div class="basis-1/2 flex flex-row flex-nowrap">
18
- <div class="basis-1/4">
19
- <span></span>
20
- </div>
21
- <div class="basis-auto">
22
- {{ top | markdown_to_html | default("") }}
23
- </div>
24
- </div>
25
- <div class="basis-1/2 flex flex-row flex-nowrap">
26
- <div class="basis-1/4">
27
- <span></span>
28
- </div>
29
- <div class="basis-auto">
30
- {{ bottom | markdown_to_html | default("") }}
31
- </div>
32
- </div>
33
- </div>
34
- </body>
35
-
36
- </html>
File without changes
File without changes