pug-tail 0.1.0-alpha.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 pug-tail might be problematic. Click here for more details.
- package/CHANGELOG.md +37 -0
- package/LICENSE +21 -0
- package/README.md +318 -0
- package/dist/cli/config/loader.d.ts +9 -0
- package/dist/cli/config/loader.d.ts.map +1 -0
- package/dist/cli/config/loader.js +82 -0
- package/dist/cli/config/loader.js.map +1 -0
- package/dist/cli/config/matcher.d.ts +3 -0
- package/dist/cli/config/matcher.d.ts.map +1 -0
- package/dist/cli/config/matcher.js +29 -0
- package/dist/cli/config/matcher.js.map +1 -0
- package/dist/cli/config/types.d.ts +26 -0
- package/dist/cli/config/types.d.ts.map +1 -0
- package/dist/cli/config/types.js +2 -0
- package/dist/cli/config/types.js.map +1 -0
- package/dist/cli/dataLoader.d.ts +8 -0
- package/dist/cli/dataLoader.d.ts.map +1 -0
- package/dist/cli/dataLoader.js +70 -0
- package/dist/cli/dataLoader.js.map +1 -0
- package/dist/cli/dependencyTracker.d.ts +19 -0
- package/dist/cli/dependencyTracker.d.ts.map +1 -0
- package/dist/cli/dependencyTracker.js +149 -0
- package/dist/cli/dependencyTracker.js.map +1 -0
- package/dist/cli/fileProcessor.d.ts +32 -0
- package/dist/cli/fileProcessor.d.ts.map +1 -0
- package/dist/cli/fileProcessor.js +218 -0
- package/dist/cli/fileProcessor.js.map +1 -0
- package/dist/cli/pathResolver.d.ts +12 -0
- package/dist/cli/pathResolver.d.ts.map +1 -0
- package/dist/cli/pathResolver.js +35 -0
- package/dist/cli/pathResolver.js.map +1 -0
- package/dist/cli/watcher.d.ts +22 -0
- package/dist/cli/watcher.d.ts.map +1 -0
- package/dist/cli/watcher.js +186 -0
- package/dist/cli/watcher.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +624 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/astTransformer.d.ts +32 -0
- package/dist/core/astTransformer.d.ts.map +1 -0
- package/dist/core/astTransformer.js +532 -0
- package/dist/core/astTransformer.js.map +1 -0
- package/dist/core/componentRegistry.d.ts +14 -0
- package/dist/core/componentRegistry.d.ts.map +1 -0
- package/dist/core/componentRegistry.js +32 -0
- package/dist/core/componentRegistry.js.map +1 -0
- package/dist/core/errorHandler.d.ts +24 -0
- package/dist/core/errorHandler.d.ts.map +1 -0
- package/dist/core/errorHandler.js +102 -0
- package/dist/core/errorHandler.js.map +1 -0
- package/dist/core/slotResolver.d.ts +9 -0
- package/dist/core/slotResolver.d.ts.map +1 -0
- package/dist/core/slotResolver.js +88 -0
- package/dist/core/slotResolver.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/transform.d.ts +26 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +247 -0
- package/dist/transform.js.map +1 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/astHelpers.d.ts +16 -0
- package/dist/utils/astHelpers.d.ts.map +1 -0
- package/dist/utils/astHelpers.js +66 -0
- package/dist/utils/astHelpers.js.map +1 -0
- package/dist/utils/attributeCategorizer.d.ts +6 -0
- package/dist/utils/attributeCategorizer.d.ts.map +1 -0
- package/dist/utils/attributeCategorizer.js +17 -0
- package/dist/utils/attributeCategorizer.js.map +1 -0
- package/dist/utils/attributes/addAttributeFallthrough.d.ts +4 -0
- package/dist/utils/attributes/addAttributeFallthrough.d.ts.map +1 -0
- package/dist/utils/attributes/addAttributeFallthrough.js +22 -0
- package/dist/utils/attributes/addAttributeFallthrough.js.map +1 -0
- package/dist/utils/attributes/createAttributesCode.d.ts +3 -0
- package/dist/utils/attributes/createAttributesCode.d.ts.map +1 -0
- package/dist/utils/attributes/createAttributesCode.js +21 -0
- package/dist/utils/attributes/createAttributesCode.js.map +1 -0
- package/dist/utils/attributes/extractAttributes.d.ts +4 -0
- package/dist/utils/attributes/extractAttributes.d.ts.map +1 -0
- package/dist/utils/attributes/extractAttributes.js +15 -0
- package/dist/utils/attributes/extractAttributes.js.map +1 -0
- package/dist/utils/attributes/findRootElements.d.ts +7 -0
- package/dist/utils/attributes/findRootElements.d.ts.map +1 -0
- package/dist/utils/attributes/findRootElements.js +36 -0
- package/dist/utils/attributes/findRootElements.js.map +1 -0
- package/dist/utils/attributes/index.d.ts +5 -0
- package/dist/utils/attributes/index.d.ts.map +1 -0
- package/dist/utils/attributes/index.js +5 -0
- package/dist/utils/attributes/index.js.map +1 -0
- package/dist/utils/babelHelpers.d.ts +3 -0
- package/dist/utils/babelHelpers.d.ts.map +1 -0
- package/dist/utils/babelHelpers.js +73 -0
- package/dist/utils/babelHelpers.js.map +1 -0
- package/dist/utils/componentDetector.d.ts +12 -0
- package/dist/utils/componentDetector.d.ts.map +1 -0
- package/dist/utils/componentDetector.js +206 -0
- package/dist/utils/componentDetector.js.map +1 -0
- package/dist/utils/dataFilesDetector.d.ts +4 -0
- package/dist/utils/dataFilesDetector.d.ts.map +1 -0
- package/dist/utils/dataFilesDetector.js +88 -0
- package/dist/utils/dataFilesDetector.js.map +1 -0
- package/dist/utils/deepClone.d.ts +5 -0
- package/dist/utils/deepClone.d.ts.map +1 -0
- package/dist/utils/deepClone.js +10 -0
- package/dist/utils/deepClone.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/scopeAnalyzer.d.ts +5 -0
- package/dist/utils/scopeAnalyzer.d.ts.map +1 -0
- package/dist/utils/scopeAnalyzer.js +267 -0
- package/dist/utils/scopeAnalyzer.js.map +1 -0
- package/dist/utils/usageDetector.d.ts +8 -0
- package/dist/utils/usageDetector.d.ts.map +1 -0
- package/dist/utils/usageDetector.js +148 -0
- package/dist/utils/usageDetector.js.map +1 -0
- package/docs/COMPONENTS.md +708 -0
- package/docs/CONFIGURATION.md +708 -0
- package/package.json +103 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyTracker.d.ts","sourceRoot":"","sources":["../../src/cli/dependencyTracker.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAE/B,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAEzB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACxB;AAKD,qBAAa,iBAAiB;IAE5B,OAAO,CAAC,aAAa,CAA2C;IAGhE,OAAO,CAAC,OAAO,CAAC,CAAQ;gBAEZ,OAAO,CAAC,EAAE,MAAM;IAU5B,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAiDlD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IA2B5C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAYlC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAiChD,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,qBAAqB;IAwC7B,OAAO,CAAC,qBAAqB;IAkB7B,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { resolveAbsolutePath } from './pathResolver.js';
|
|
4
|
+
export class DependencyTracker {
|
|
5
|
+
constructor(basedir) {
|
|
6
|
+
this.dependencyMap = new Map();
|
|
7
|
+
this.basedir = basedir;
|
|
8
|
+
}
|
|
9
|
+
analyzeDependencies(filePath) {
|
|
10
|
+
const absolutePath = resolveAbsolutePath(filePath);
|
|
11
|
+
const dependencies = new Set();
|
|
12
|
+
try {
|
|
13
|
+
const content = readFileSync(absolutePath, 'utf-8');
|
|
14
|
+
const fileDir = dirname(absolutePath);
|
|
15
|
+
const includeRegex = /^\s*(?:include|extends)(?::[\w-]+)?\s+(.+?)$/gm;
|
|
16
|
+
const matches = content.matchAll(includeRegex);
|
|
17
|
+
for (const match of matches) {
|
|
18
|
+
const rawPath = match[1]?.trim();
|
|
19
|
+
if (!rawPath)
|
|
20
|
+
continue;
|
|
21
|
+
try {
|
|
22
|
+
const depPath = this.resolveDependencyPath(rawPath, fileDir);
|
|
23
|
+
if (depPath) {
|
|
24
|
+
dependencies.add(depPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (_error) {
|
|
28
|
+
if (this.isDebug()) {
|
|
29
|
+
console.log(`[dependency] Could not resolve: ${rawPath} from ${filePath}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this.updateDependencyGraph(absolutePath, dependencies);
|
|
34
|
+
}
|
|
35
|
+
catch (_error) {
|
|
36
|
+
this.clearFileDependencies(absolutePath);
|
|
37
|
+
}
|
|
38
|
+
return dependencies;
|
|
39
|
+
}
|
|
40
|
+
getDependents(filePath) {
|
|
41
|
+
const absolutePath = resolveAbsolutePath(filePath);
|
|
42
|
+
const allDependents = new Set();
|
|
43
|
+
const visited = new Set();
|
|
44
|
+
const collectDependents = (path) => {
|
|
45
|
+
if (visited.has(path))
|
|
46
|
+
return;
|
|
47
|
+
visited.add(path);
|
|
48
|
+
const deps = this.dependencyMap.get(path);
|
|
49
|
+
if (!deps)
|
|
50
|
+
return;
|
|
51
|
+
for (const dependent of deps.dependents) {
|
|
52
|
+
allDependents.add(dependent);
|
|
53
|
+
collectDependents(dependent);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
collectDependents(absolutePath);
|
|
57
|
+
return allDependents;
|
|
58
|
+
}
|
|
59
|
+
removeFile(filePath) {
|
|
60
|
+
const absolutePath = resolveAbsolutePath(filePath);
|
|
61
|
+
this.clearFileDependencies(absolutePath);
|
|
62
|
+
this.dependencyMap.delete(absolutePath);
|
|
63
|
+
}
|
|
64
|
+
hasCircularDependency(filePath) {
|
|
65
|
+
const absolutePath = resolveAbsolutePath(filePath);
|
|
66
|
+
const visited = new Set();
|
|
67
|
+
const recursionStack = new Set();
|
|
68
|
+
const detectCycle = (path) => {
|
|
69
|
+
if (recursionStack.has(path))
|
|
70
|
+
return true;
|
|
71
|
+
if (visited.has(path))
|
|
72
|
+
return false;
|
|
73
|
+
visited.add(path);
|
|
74
|
+
recursionStack.add(path);
|
|
75
|
+
const deps = this.dependencyMap.get(path);
|
|
76
|
+
if (deps) {
|
|
77
|
+
for (const dep of deps.dependencies) {
|
|
78
|
+
if (detectCycle(dep))
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
recursionStack.delete(path);
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
return detectCycle(absolutePath);
|
|
86
|
+
}
|
|
87
|
+
resolveDependencyPath(rawPath, fileDir) {
|
|
88
|
+
const cleanPath = rawPath.replace(/['"]/g, '');
|
|
89
|
+
if (cleanPath.startsWith('/')) {
|
|
90
|
+
if (!this.basedir) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const resolved = resolve(this.basedir, cleanPath.slice(1));
|
|
94
|
+
return this.addPugExtension(resolved);
|
|
95
|
+
}
|
|
96
|
+
const resolved = resolve(fileDir, cleanPath);
|
|
97
|
+
return this.addPugExtension(resolved);
|
|
98
|
+
}
|
|
99
|
+
addPugExtension(path) {
|
|
100
|
+
if (path.endsWith('.pug')) {
|
|
101
|
+
return path;
|
|
102
|
+
}
|
|
103
|
+
return `${path}.pug`;
|
|
104
|
+
}
|
|
105
|
+
updateDependencyGraph(filePath, newDependencies) {
|
|
106
|
+
let fileInfo = this.dependencyMap.get(filePath);
|
|
107
|
+
if (!fileInfo) {
|
|
108
|
+
fileInfo = {
|
|
109
|
+
dependencies: new Set(),
|
|
110
|
+
dependents: new Set(),
|
|
111
|
+
};
|
|
112
|
+
this.dependencyMap.set(filePath, fileInfo);
|
|
113
|
+
}
|
|
114
|
+
for (const oldDep of fileInfo.dependencies) {
|
|
115
|
+
const depInfo = this.dependencyMap.get(oldDep);
|
|
116
|
+
if (depInfo) {
|
|
117
|
+
depInfo.dependents.delete(filePath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
fileInfo.dependencies = newDependencies;
|
|
121
|
+
for (const dep of newDependencies) {
|
|
122
|
+
let depInfo = this.dependencyMap.get(dep);
|
|
123
|
+
if (!depInfo) {
|
|
124
|
+
depInfo = {
|
|
125
|
+
dependencies: new Set(),
|
|
126
|
+
dependents: new Set(),
|
|
127
|
+
};
|
|
128
|
+
this.dependencyMap.set(dep, depInfo);
|
|
129
|
+
}
|
|
130
|
+
depInfo.dependents.add(filePath);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
clearFileDependencies(filePath) {
|
|
134
|
+
const fileInfo = this.dependencyMap.get(filePath);
|
|
135
|
+
if (!fileInfo)
|
|
136
|
+
return;
|
|
137
|
+
for (const dep of fileInfo.dependencies) {
|
|
138
|
+
const depInfo = this.dependencyMap.get(dep);
|
|
139
|
+
if (depInfo) {
|
|
140
|
+
depInfo.dependents.delete(filePath);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
fileInfo.dependencies.clear();
|
|
144
|
+
}
|
|
145
|
+
isDebug() {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=dependencyTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencyTracker.js","sourceRoot":"","sources":["../../src/cli/dependencyTracker.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,mBAA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CAAA;QAClC,CAAC;IACH,CAAC;IAKO,qBAAqB,CAAC,QAAgB;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACjD,IAAI,CAAC,QAAQ;YAAE,OAAM;QAGrB,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC3C,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;YACrC,CAAC;QACH,CAAC;QAED,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;IAC/B,CAAC;IAKO,OAAO;QACb,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TransformOptions } from '../transform.js';
|
|
2
|
+
import type { PugTailConfig } from './config/types.js';
|
|
3
|
+
export interface FileProcessorOptions {
|
|
4
|
+
outputDir?: string;
|
|
5
|
+
extension?: string;
|
|
6
|
+
transformOptions?: Omit<TransformOptions, 'filename'>;
|
|
7
|
+
data?: Record<string, unknown>;
|
|
8
|
+
dataKey?: string;
|
|
9
|
+
silent?: boolean;
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
config?: PugTailConfig;
|
|
12
|
+
}
|
|
13
|
+
export interface ProcessResult {
|
|
14
|
+
input: string;
|
|
15
|
+
output: string;
|
|
16
|
+
success: boolean;
|
|
17
|
+
ignored?: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class FileProcessor {
|
|
21
|
+
private options;
|
|
22
|
+
private rootPath?;
|
|
23
|
+
constructor(options?: FileProcessorOptions);
|
|
24
|
+
processFile(inputPath: string, rootPath?: string): Promise<ProcessResult>;
|
|
25
|
+
processFiles(inputPaths: string[], rootPath?: string): Promise<ProcessResult[]>;
|
|
26
|
+
processPattern(pattern: string, rootPath?: string): Promise<ProcessResult[]>;
|
|
27
|
+
processDirectory(dirPath: string, rootPath?: string): Promise<ProcessResult[]>;
|
|
28
|
+
processInputs(inputs: string[]): Promise<ProcessResult[]>;
|
|
29
|
+
setRootPath(rootPath: string): void;
|
|
30
|
+
private log;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=fileProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileProcessor.d.ts","sourceRoot":"","sources":["../../src/cli/fileProcessor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAMvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAYtD,MAAM,WAAW,oBAAoB;IAEnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,gBAAgB,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;IAErD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB;AAKD,MAAM,WAAW,aAAa;IAE5B,KAAK,EAAE,MAAM,CAAA;IAEb,MAAM,EAAE,MAAM,CAAA;IAEd,OAAO,EAAE,OAAO,CAAA;IAEhB,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AA6BD,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,QAAQ,CAAC,CAAQ;gBAEb,OAAO,GAAE,oBAAyB;IAcxC,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,CAAC;IAqInB,YAAY,CAChB,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,EAAE,CAAC;IA2BrB,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,EAAE,CAAC;IAoCrB,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,EAAE,CAAC;IAoErB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAuE/D,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASnC,OAAO,CAAC,GAAG;CAKZ"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { lstatSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
import { transform } from '../transform.js';
|
|
5
|
+
import { getDefaultOutputPatterns, shouldIncludeFile, } from './config/matcher.js';
|
|
6
|
+
import { getDirectory, isPugFile, resolveAbsolutePath, resolveOutputPath, } from './pathResolver.js';
|
|
7
|
+
export class FileProcessor {
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
if (options.config?.files?.root) {
|
|
11
|
+
this.rootPath = resolveAbsolutePath(options.config.files.root);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async processFile(inputPath, rootPath) {
|
|
15
|
+
const absoluteInput = resolveAbsolutePath(inputPath);
|
|
16
|
+
try {
|
|
17
|
+
const basePath = process.cwd();
|
|
18
|
+
const patterns = this.options.config?.files?.render || getDefaultOutputPatterns();
|
|
19
|
+
if (this.options.debug) {
|
|
20
|
+
this.log(`Checking file: ${inputPath}\n Absolute: ${absoluteInput}\n BasePath: ${basePath}\n Patterns: ${JSON.stringify(patterns)}`);
|
|
21
|
+
}
|
|
22
|
+
if (!shouldIncludeFile(absoluteInput, patterns, basePath)) {
|
|
23
|
+
if (this.options.debug) {
|
|
24
|
+
this.log(`Ignored: ${inputPath}`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
input: inputPath,
|
|
28
|
+
output: '',
|
|
29
|
+
success: true,
|
|
30
|
+
ignored: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (!isPugFile(absoluteInput)) {
|
|
34
|
+
return {
|
|
35
|
+
input: inputPath,
|
|
36
|
+
output: '',
|
|
37
|
+
success: false,
|
|
38
|
+
error: 'Not a Pug file',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const source = readFileSync(absoluteInput, 'utf-8');
|
|
42
|
+
if (this.options.debug) {
|
|
43
|
+
this.log(`Read source (${source.length} chars):\n${source.substring(0, 200)}...`);
|
|
44
|
+
}
|
|
45
|
+
const inputDir = getDirectory(absoluteInput);
|
|
46
|
+
const dataFilesBasePath = inputDir;
|
|
47
|
+
const effectiveRootPath = rootPath || this.rootPath;
|
|
48
|
+
const pathOptions = {
|
|
49
|
+
outputDir: this.options.outputDir,
|
|
50
|
+
extension: this.options.extension,
|
|
51
|
+
rootPath: effectiveRootPath,
|
|
52
|
+
};
|
|
53
|
+
const outputPath = resolveOutputPath(absoluteInput, pathOptions);
|
|
54
|
+
const result = transform(source, {
|
|
55
|
+
filename: absoluteInput,
|
|
56
|
+
...this.options.transformOptions,
|
|
57
|
+
basePath: dataFilesBasePath,
|
|
58
|
+
data: this.options.data,
|
|
59
|
+
dataKey: this.options.dataKey,
|
|
60
|
+
});
|
|
61
|
+
let output;
|
|
62
|
+
if (this.options.transformOptions?.output === 'ast') {
|
|
63
|
+
if (!result.ast) {
|
|
64
|
+
throw new Error('AST output is not available');
|
|
65
|
+
}
|
|
66
|
+
output = JSON.stringify(result.ast, null, 2);
|
|
67
|
+
}
|
|
68
|
+
else if (this.options.transformOptions?.output === 'pug-code') {
|
|
69
|
+
if (!result.code) {
|
|
70
|
+
throw new Error('Pug code output is not available');
|
|
71
|
+
}
|
|
72
|
+
output = result.code;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (!result.html) {
|
|
76
|
+
throw new Error('HTML output is not available');
|
|
77
|
+
}
|
|
78
|
+
output = result.html;
|
|
79
|
+
}
|
|
80
|
+
const outputDir = getDirectory(outputPath);
|
|
81
|
+
mkdirSync(outputDir, { recursive: true });
|
|
82
|
+
writeFileSync(outputPath, output, 'utf-8');
|
|
83
|
+
if (!this.options.silent) {
|
|
84
|
+
this.log(` rendered ${outputPath}`);
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
input: inputPath,
|
|
88
|
+
output: outputPath,
|
|
89
|
+
success: true,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
94
|
+
if (!this.options.silent) {
|
|
95
|
+
console.error(`Error processing ${inputPath}:`, errorMessage);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
input: inputPath,
|
|
99
|
+
output: '',
|
|
100
|
+
success: false,
|
|
101
|
+
error: errorMessage,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async processFiles(inputPaths, rootPath) {
|
|
106
|
+
const results = [];
|
|
107
|
+
for (const inputPath of inputPaths) {
|
|
108
|
+
const result = await this.processFile(inputPath, rootPath);
|
|
109
|
+
results.push(result);
|
|
110
|
+
}
|
|
111
|
+
return results;
|
|
112
|
+
}
|
|
113
|
+
async processPattern(pattern, rootPath) {
|
|
114
|
+
const files = await glob(pattern, {
|
|
115
|
+
ignore: ['node_modules/**', '.git/**'],
|
|
116
|
+
nodir: true,
|
|
117
|
+
absolute: true,
|
|
118
|
+
});
|
|
119
|
+
if (files.length === 0) {
|
|
120
|
+
if (!this.options.silent) {
|
|
121
|
+
console.warn(`No files found matching pattern: ${pattern}`);
|
|
122
|
+
}
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
if (this.options.debug) {
|
|
126
|
+
this.log(`Found ${files.length} files matching pattern: ${pattern}`);
|
|
127
|
+
}
|
|
128
|
+
return this.processFiles(files, rootPath);
|
|
129
|
+
}
|
|
130
|
+
async processDirectory(dirPath, rootPath) {
|
|
131
|
+
const absoluteDir = resolveAbsolutePath(dirPath);
|
|
132
|
+
const results = [];
|
|
133
|
+
const effectiveRootPath = rootPath || absoluteDir;
|
|
134
|
+
try {
|
|
135
|
+
const stat = lstatSync(absoluteDir);
|
|
136
|
+
if (!stat.isDirectory()) {
|
|
137
|
+
return [await this.processFile(absoluteDir, effectiveRootPath)];
|
|
138
|
+
}
|
|
139
|
+
const entries = readdirSync(absoluteDir);
|
|
140
|
+
for (const entry of entries) {
|
|
141
|
+
const entryPath = resolve(absoluteDir, entry);
|
|
142
|
+
const entryStat = lstatSync(entryPath);
|
|
143
|
+
if (entryStat.isDirectory()) {
|
|
144
|
+
const subResults = await this.processDirectory(entryPath, effectiveRootPath);
|
|
145
|
+
results.push(...subResults);
|
|
146
|
+
}
|
|
147
|
+
else if (entryStat.isFile()) {
|
|
148
|
+
const result = await this.processFile(entryPath, effectiveRootPath);
|
|
149
|
+
results.push(result);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return results;
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
156
|
+
if (!this.options.silent) {
|
|
157
|
+
console.error(`Error processing directory ${dirPath}:`, errorMessage);
|
|
158
|
+
}
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async processInputs(inputs) {
|
|
163
|
+
const results = [];
|
|
164
|
+
for (const input of inputs) {
|
|
165
|
+
const absolutePath = resolveAbsolutePath(input);
|
|
166
|
+
try {
|
|
167
|
+
if (input.includes('*') || input.includes('?') || input.includes('[')) {
|
|
168
|
+
let rootPath = this.rootPath;
|
|
169
|
+
if (!rootPath) {
|
|
170
|
+
const globMatch = input.match(/^(.+?)(?:\*\*|\*)/);
|
|
171
|
+
if (globMatch?.[1]) {
|
|
172
|
+
const extractedRoot = globMatch[1].replace(/[/\\]+$/, '');
|
|
173
|
+
if (extractedRoot) {
|
|
174
|
+
rootPath = resolveAbsolutePath(extractedRoot);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const patternResults = await this.processPattern(input, rootPath);
|
|
179
|
+
results.push(...patternResults);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const stat = lstatSync(absolutePath);
|
|
183
|
+
if (stat.isFile()) {
|
|
184
|
+
const rootPath = getDirectory(absolutePath);
|
|
185
|
+
const result = await this.processFile(absolutePath, rootPath);
|
|
186
|
+
results.push(result);
|
|
187
|
+
}
|
|
188
|
+
else if (stat.isDirectory()) {
|
|
189
|
+
const rootPath = absolutePath;
|
|
190
|
+
const dirResults = await this.processDirectory(absolutePath, rootPath);
|
|
191
|
+
results.push(...dirResults);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
196
|
+
if (!this.options.silent) {
|
|
197
|
+
console.error(`Error processing ${input}:`, errorMessage);
|
|
198
|
+
}
|
|
199
|
+
results.push({
|
|
200
|
+
input,
|
|
201
|
+
output: '',
|
|
202
|
+
success: false,
|
|
203
|
+
error: errorMessage,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return results;
|
|
208
|
+
}
|
|
209
|
+
setRootPath(rootPath) {
|
|
210
|
+
this.rootPath = resolveAbsolutePath(rootPath);
|
|
211
|
+
}
|
|
212
|
+
log(message) {
|
|
213
|
+
if (!this.options.silent) {
|
|
214
|
+
console.log(message);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=fileProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileProcessor.js","sourceRoot":"","sources":["../../src/cli/fileProcessor.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,YAAY,EACZ,SAAS,EAET,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAmE1B,MAAM,OAAO,aAAa;IAIxB,YAAY,UAAgC,EAAE;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;IASD,KAAK,CAAC,WAAW,CACf,SAAiB,EACjB,QAAiB;QAEjB,MAAM,aAAa,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAA;QAEpD,IAAI,CAAC;YAIH,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;YAC9B,MAAM,QAAQ,GACZ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,wBAAwB,EAAE,CAAA;YAElE,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;gBACvB,IAAI,C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,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,oBAAoB,KAAK,GAAG,EAAE,YAAY,CAAC,CAAA;gBAC3D,CAAC;gBAED,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK;oBACL,MAAM,EAAE,EAAE;oBACV,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,YAAY;iBACpB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAOD,WAAW,CAAC,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAC/C,CAAC;IAOO,GAAG,CAAC,OAAe;QACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface PathResolverOptions {
|
|
2
|
+
outputDir?: string;
|
|
3
|
+
extension?: string;
|
|
4
|
+
rootPath?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function resolveOutputPath(inputPath: string, options?: PathResolverOptions): string;
|
|
7
|
+
export declare function shouldIgnoreFile(filepath: string): boolean;
|
|
8
|
+
export declare function isPugFile(filepath: string): boolean;
|
|
9
|
+
export declare function getDirectory(filepath: string): string;
|
|
10
|
+
export declare function joinPath(...segments: string[]): string;
|
|
11
|
+
export declare function resolveAbsolutePath(filepath: string): string;
|
|
12
|
+
//# sourceMappingURL=pathResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathResolver.d.ts","sourceRoot":"","sources":["../../src/cli/pathResolver.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAElC,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AA2BD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,mBAAwB,GAChC,MAAM,CA0BR;AAuBD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAM1D;AAQD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEnD;AAQD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErD;AAQD,wBAAgB,QAAQ,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAEtD;AAQD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { basename, dirname, extname, join, relative, resolve } from 'node:path';
|
|
2
|
+
export function resolveOutputPath(inputPath, options = {}) {
|
|
3
|
+
const { outputDir, extension = '.html', rootPath } = options;
|
|
4
|
+
const ext = extname(inputPath);
|
|
5
|
+
const isPug = /\.(?:pug|jade)$/.test(ext);
|
|
6
|
+
const outputPath = isPug
|
|
7
|
+
? inputPath.replace(/\.(?:pug|jade)$/, extension)
|
|
8
|
+
: inputPath;
|
|
9
|
+
if (!outputDir) {
|
|
10
|
+
return outputPath;
|
|
11
|
+
}
|
|
12
|
+
const absoluteOutputDir = resolve(outputDir);
|
|
13
|
+
if (rootPath) {
|
|
14
|
+
const relativePath = relative(rootPath, outputPath);
|
|
15
|
+
return resolve(absoluteOutputDir, relativePath);
|
|
16
|
+
}
|
|
17
|
+
return resolve(absoluteOutputDir, basename(outputPath));
|
|
18
|
+
}
|
|
19
|
+
export function shouldIgnoreFile(filepath) {
|
|
20
|
+
const isIgnored = /([/\\]_)|(^_)/;
|
|
21
|
+
return isIgnored.test(filepath);
|
|
22
|
+
}
|
|
23
|
+
export function isPugFile(filepath) {
|
|
24
|
+
return /\.(?:pug|jade)$/.test(filepath);
|
|
25
|
+
}
|
|
26
|
+
export function getDirectory(filepath) {
|
|
27
|
+
return dirname(filepath);
|
|
28
|
+
}
|
|
29
|
+
export function joinPath(...segments) {
|
|
30
|
+
return join(...segments);
|
|
31
|
+
}
|
|
32
|
+
export function resolveAbsolutePath(filepath) {
|
|
33
|
+
return resolve(filepath);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=pathResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathResolver.js","sourceRoot":"","sources":["../../src/cli/pathResolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAuC/E,MAAM,UAAU,iBAAiB,CAC/B,SAAiB,EACjB,UAA+B,EAAE;IAEjC,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAG5D,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9B,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,KAAK;QACtB,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,SAAS,CAAC;QACjD,CAAC,CAAC,SAAS,CAAA;IAGb,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,UAAU,CAAA;IACnB,CAAC;IAGD,MAAM,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAG5C,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QACnD,OAAO,OAAO,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;IACjD,CAAC;IAGD,OAAO,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAA;AACzD,CAAC;AAuBD,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAI/C,MAAM,SAAS,GAAG,eAAe,CAAA;IACjC,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AACjC,CAAC;AAQD,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AACzC,CAAC;AAQD,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC;AAQD,MAAM,UAAU,QAAQ,CAAC,GAAG,QAAkB;IAC5C,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAA;AAC1B,CAAC;AAQD,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type FileProcessorOptions } from './fileProcessor.js';
|
|
2
|
+
export interface WatchOptions extends FileProcessorOptions {
|
|
3
|
+
paths: string[];
|
|
4
|
+
debounce?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class Watcher {
|
|
7
|
+
private options;
|
|
8
|
+
private processor;
|
|
9
|
+
private watcher?;
|
|
10
|
+
private debounceTimers;
|
|
11
|
+
private dependencyTracker;
|
|
12
|
+
constructor(options: WatchOptions);
|
|
13
|
+
start(): Promise<void>;
|
|
14
|
+
stop(): Promise<void>;
|
|
15
|
+
private handleFileAdded;
|
|
16
|
+
private handleFileChanged;
|
|
17
|
+
private handleFileDeleted;
|
|
18
|
+
private handleError;
|
|
19
|
+
private debounceProcess;
|
|
20
|
+
private processFile;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/cli/watcher.ts"],"names":[],"mappings":"AASA,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAM7E,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IAExD,KAAK,EAAE,MAAM,EAAE,CAAA;IAEf,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAKD,qBAAa,OAAO;IAClB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,SAAS,CAAe;IAChC,OAAO,CAAC,OAAO,CAAC,CAAoB;IACpC,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,iBAAiB,CAAmB;gBAEhC,OAAO,EAAE,YAAY;IAyB3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2EtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB3B,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,iBAAiB;IA8BzB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,eAAe;YAqBT,WAAW;CAyC1B"}
|