vintasend-pug 0.13.2 → 0.13.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,3 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Main function to compile pug templates to JSON
|
|
4
|
+
*/
|
|
5
|
+
export declare function compilePugTemplates(inputDir?: string, outputFile?: string): void;
|
|
6
|
+
export declare function runCli(args?: string[]): void;
|
|
3
7
|
//# sourceMappingURL=compile-pug-templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-pug-templates.d.ts","sourceRoot":"","sources":["../../src/scripts/compile-pug-templates.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"compile-pug-templates.d.ts","sourceRoot":"","sources":["../../src/scripts/compile-pug-templates.ts"],"names":[],"mappings":";AAsCA;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,GAAE,MAAsB,EAChC,UAAU,GAAE,MAAkC,GAC7C,IAAI,CA6BN;AAeD,wBAAgB,MAAM,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,IAAI,CAenE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
/**
|
|
5
6
|
* Recursively finds all .pug files in a directory
|
|
6
7
|
*/
|
|
@@ -26,15 +27,13 @@ function findPugFiles(dir, baseDir, files = new Map()) {
|
|
|
26
27
|
/**
|
|
27
28
|
* Main function to compile pug templates to JSON
|
|
28
29
|
*/
|
|
29
|
-
function compilePugTemplates(inputDir = './templates', outputFile = 'compiled-templates.json') {
|
|
30
|
+
export function compilePugTemplates(inputDir = './templates', outputFile = 'compiled-templates.json') {
|
|
30
31
|
// Validate input directory exists
|
|
31
32
|
if (!fs.existsSync(inputDir)) {
|
|
32
|
-
|
|
33
|
-
process.exit(1);
|
|
33
|
+
throw new Error(`Directory "${inputDir}" does not exist.`);
|
|
34
34
|
}
|
|
35
35
|
if (!fs.statSync(inputDir).isDirectory()) {
|
|
36
|
-
|
|
37
|
-
process.exit(1);
|
|
36
|
+
throw new Error(`"${inputDir}" is not a directory.`);
|
|
38
37
|
}
|
|
39
38
|
console.log(`Searching for .pug files in: ${inputDir}`);
|
|
40
39
|
// Find all pug files
|
|
@@ -51,9 +50,7 @@ function compilePugTemplates(inputDir = './templates', outputFile = 'compiled-te
|
|
|
51
50
|
fs.writeFileSync(outputFile, outputContent, 'utf-8');
|
|
52
51
|
console.log(`\nSuccessfully compiled templates to: ${outputFile}`);
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
const args = process.argv.slice(2);
|
|
56
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
53
|
+
function printHelp() {
|
|
57
54
|
console.log('Usage: compile-pug-templates [input-directory] [output-file]');
|
|
58
55
|
console.log('');
|
|
59
56
|
console.log('Arguments:');
|
|
@@ -64,8 +61,23 @@ if (args.includes('--help') || args.includes('-h')) {
|
|
|
64
61
|
console.log(' compile-pug-templates');
|
|
65
62
|
console.log(' compile-pug-templates ./templates');
|
|
66
63
|
console.log(' compile-pug-templates ./templates ./compiled-templates.json');
|
|
67
|
-
process.exit(0);
|
|
68
64
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
export function runCli(args = process.argv.slice(2)) {
|
|
66
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
67
|
+
printHelp();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const [inputDir, outputFile] = args;
|
|
71
|
+
try {
|
|
72
|
+
compilePugTemplates(inputDir, outputFile);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
76
|
+
console.error(`Error: ${message}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const isExecutedDirectly = process.argv[1] !== undefined && fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
|
81
|
+
if (isExecutedDirectly) {
|
|
82
|
+
runCli(process.argv.slice(2));
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vintasend-pug",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"pug": "^3.0.3",
|
|
28
|
-
"vintasend": "^0.13.
|
|
28
|
+
"vintasend": "^0.13.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@biomejs/biome": "^2.4.5",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
|
|
5
6
|
interface PugTemplatesMap {
|
|
6
7
|
[key: string]: string;
|
|
@@ -38,19 +39,17 @@ function findPugFiles(
|
|
|
38
39
|
/**
|
|
39
40
|
* Main function to compile pug templates to JSON
|
|
40
41
|
*/
|
|
41
|
-
function compilePugTemplates(
|
|
42
|
+
export function compilePugTemplates(
|
|
42
43
|
inputDir: string = './templates',
|
|
43
44
|
outputFile: string = 'compiled-templates.json',
|
|
44
45
|
): void {
|
|
45
46
|
// Validate input directory exists
|
|
46
47
|
if (!fs.existsSync(inputDir)) {
|
|
47
|
-
|
|
48
|
-
process.exit(1);
|
|
48
|
+
throw new Error(`Directory "${inputDir}" does not exist.`);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (!fs.statSync(inputDir).isDirectory()) {
|
|
52
|
-
|
|
53
|
-
process.exit(1);
|
|
52
|
+
throw new Error(`"${inputDir}" is not a directory.`);
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
console.log(`Searching for .pug files in: ${inputDir}`);
|
|
@@ -74,10 +73,7 @@ function compilePugTemplates(
|
|
|
74
73
|
console.log(`\nSuccessfully compiled templates to: ${outputFile}`);
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
const args = process.argv.slice(2);
|
|
79
|
-
|
|
80
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
76
|
+
function printHelp(): void {
|
|
81
77
|
console.log('Usage: compile-pug-templates [input-directory] [output-file]');
|
|
82
78
|
console.log('');
|
|
83
79
|
console.log('Arguments:');
|
|
@@ -88,10 +84,28 @@ if (args.includes('--help') || args.includes('-h')) {
|
|
|
88
84
|
console.log(' compile-pug-templates');
|
|
89
85
|
console.log(' compile-pug-templates ./templates');
|
|
90
86
|
console.log(' compile-pug-templates ./templates ./compiled-templates.json');
|
|
91
|
-
process.exit(0);
|
|
92
87
|
}
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
export function runCli(args: string[] = process.argv.slice(2)): void {
|
|
90
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
91
|
+
printHelp();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const [inputDir, outputFile] = args;
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
compilePugTemplates(inputDir, outputFile);
|
|
97
|
+
try {
|
|
98
|
+
compilePugTemplates(inputDir, outputFile);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
101
|
+
console.error(`Error: ${message}`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const isExecutedDirectly =
|
|
107
|
+
process.argv[1] !== undefined && fileURLToPath(import.meta.url) === path.resolve(process.argv[1]);
|
|
108
|
+
|
|
109
|
+
if (isExecutedDirectly) {
|
|
110
|
+
runCli(process.argv.slice(2));
|
|
111
|
+
}
|