functional-examples 0.0.0-alpha.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.
- package/README.md +148 -0
- package/dist/cli/commands/generate.d.ts +10 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +64 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +14 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +95 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +20 -0
- package/dist/cli/commands/scan.d.ts.map +1 -0
- package/dist/cli/commands/scan.js +182 -0
- package/dist/cli/commands/scan.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +10 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +65 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/index.d.ts +88 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +43 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/plugin-commands.d.ts +17 -0
- package/dist/cli/plugin-commands.d.ts.map +1 -0
- package/dist/cli/plugin-commands.js +45 -0
- package/dist/cli/plugin-commands.js.map +1 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +9 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.spec.d.ts +5 -0
- package/dist/config/index.spec.d.ts.map +1 -0
- package/dist/config/index.spec.js +142 -0
- package/dist/config/index.spec.js.map +1 -0
- package/dist/config/loader.d.ts +7 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +85 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/merger.d.ts +27 -0
- package/dist/config/merger.d.ts.map +1 -0
- package/dist/config/merger.js +41 -0
- package/dist/config/merger.js.map +1 -0
- package/dist/config/resolver.d.ts +28 -0
- package/dist/config/resolver.d.ts.map +1 -0
- package/dist/config/resolver.js +165 -0
- package/dist/config/resolver.js.map +1 -0
- package/dist/config/schema.d.ts +53 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +42 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/types.d.ts +17 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +5 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validator.d.ts +6 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +17 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/extractors/index.d.ts +9 -0
- package/dist/extractors/index.d.ts.map +1 -0
- package/dist/extractors/index.js +9 -0
- package/dist/extractors/index.js.map +1 -0
- package/dist/extractors/loader.d.ts +19 -0
- package/dist/extractors/loader.d.ts.map +1 -0
- package/dist/extractors/loader.js +120 -0
- package/dist/extractors/loader.js.map +1 -0
- package/dist/extractors/meta-yml-fn.d.ts +19 -0
- package/dist/extractors/meta-yml-fn.d.ts.map +1 -0
- package/dist/extractors/meta-yml-fn.js +66 -0
- package/dist/extractors/meta-yml-fn.js.map +1 -0
- package/dist/extractors/meta-yml.d.ts +24 -0
- package/dist/extractors/meta-yml.d.ts.map +1 -0
- package/dist/extractors/meta-yml.js +65 -0
- package/dist/extractors/meta-yml.js.map +1 -0
- package/dist/extractors/registry.d.ts +58 -0
- package/dist/extractors/registry.d.ts.map +1 -0
- package/dist/extractors/registry.js +114 -0
- package/dist/extractors/registry.js.map +1 -0
- package/dist/extractors/registry.spec.d.ts +2 -0
- package/dist/extractors/registry.spec.d.ts.map +1 -0
- package/dist/extractors/registry.spec.js +102 -0
- package/dist/extractors/registry.spec.js.map +1 -0
- package/dist/extractors/types.d.ts +34 -0
- package/dist/extractors/types.d.ts.map +1 -0
- package/dist/extractors/types.js +8 -0
- package/dist/extractors/types.js.map +1 -0
- package/dist/extractors/yaml-frontmatter-fn.d.ts +18 -0
- package/dist/extractors/yaml-frontmatter-fn.d.ts.map +1 -0
- package/dist/extractors/yaml-frontmatter-fn.js +73 -0
- package/dist/extractors/yaml-frontmatter-fn.js.map +1 -0
- package/dist/extractors/yaml-frontmatter.d.ts +22 -0
- package/dist/extractors/yaml-frontmatter.d.ts.map +1 -0
- package/dist/extractors/yaml-frontmatter.js +83 -0
- package/dist/extractors/yaml-frontmatter.js.map +1 -0
- package/dist/extractors/yaml-frontmatter.spec.d.ts +2 -0
- package/dist/extractors/yaml-frontmatter.spec.d.ts.map +1 -0
- package/dist/extractors/yaml-frontmatter.spec.js +134 -0
- package/dist/extractors/yaml-frontmatter.spec.js.map +1 -0
- package/dist/files/index.d.ts +5 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +5 -0
- package/dist/files/index.js.map +1 -0
- package/dist/files/reader.d.ts +50 -0
- package/dist/files/reader.d.ts.map +1 -0
- package/dist/files/reader.js +62 -0
- package/dist/files/reader.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/pipeline.d.ts +11 -0
- package/dist/plugins/pipeline.d.ts.map +1 -0
- package/dist/plugins/pipeline.js +24 -0
- package/dist/plugins/pipeline.js.map +1 -0
- package/dist/plugins/registry.d.ts +57 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +93 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/validation.d.ts +64 -0
- package/dist/plugins/validation.d.ts.map +1 -0
- package/dist/plugins/validation.js +55 -0
- package/dist/plugins/validation.js.map +1 -0
- package/dist/regions/index.d.ts +7 -0
- package/dist/regions/index.d.ts.map +1 -0
- package/dist/regions/index.js +6 -0
- package/dist/regions/index.js.map +1 -0
- package/dist/regions/languages.d.ts +15 -0
- package/dist/regions/languages.d.ts.map +1 -0
- package/dist/regions/languages.js +182 -0
- package/dist/regions/languages.js.map +1 -0
- package/dist/regions/parser.d.ts +63 -0
- package/dist/regions/parser.d.ts.map +1 -0
- package/dist/regions/parser.js +175 -0
- package/dist/regions/parser.js.map +1 -0
- package/dist/regions/parser.spec.d.ts +2 -0
- package/dist/regions/parser.spec.d.ts.map +1 -0
- package/dist/regions/parser.spec.js +190 -0
- package/dist/regions/parser.spec.js.map +1 -0
- package/dist/regions/types.d.ts +37 -0
- package/dist/regions/types.d.ts.map +1 -0
- package/dist/regions/types.js +5 -0
- package/dist/regions/types.js.map +1 -0
- package/dist/scanner/candidates.d.ts +24 -0
- package/dist/scanner/candidates.d.ts.map +1 -0
- package/dist/scanner/candidates.js +83 -0
- package/dist/scanner/candidates.js.map +1 -0
- package/dist/scanner/index.d.ts +8 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +6 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/scan.d.ts +40 -0
- package/dist/scanner/scan.d.ts.map +1 -0
- package/dist/scanner/scan.js +44 -0
- package/dist/scanner/scan.js.map +1 -0
- package/dist/scanner/scanner.d.ts +29 -0
- package/dist/scanner/scanner.d.ts.map +1 -0
- package/dist/scanner/scanner.js +296 -0
- package/dist/scanner/scanner.js.map +1 -0
- package/dist/scanner/scanner.spec.d.ts +2 -0
- package/dist/scanner/scanner.spec.d.ts.map +1 -0
- package/dist/scanner/scanner.spec.js +262 -0
- package/dist/scanner/scanner.spec.js.map +1 -0
- package/dist/scanner/types.d.ts +43 -0
- package/dist/scanner/types.d.ts.map +1 -0
- package/dist/scanner/types.js +5 -0
- package/dist/scanner/types.js.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +4 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/merger.d.ts +35 -0
- package/dist/schema/merger.d.ts.map +1 -0
- package/dist/schema/merger.js +161 -0
- package/dist/schema/merger.js.map +1 -0
- package/dist/schema/typegen.d.ts +13 -0
- package/dist/schema/typegen.d.ts.map +1 -0
- package/dist/schema/typegen.js +125 -0
- package/dist/schema/typegen.js.map +1 -0
- package/dist/schema/validator.d.ts +7 -0
- package/dist/schema/validator.d.ts.map +1 -0
- package/dist/schema/validator.js +32 -0
- package/dist/schema/validator.js.map +1 -0
- package/dist/types/default-map.d.ts +21 -0
- package/dist/types/default-map.d.ts.map +1 -0
- package/dist/types/default-map.js +32 -0
- package/dist/types/default-map.js.map +1 -0
- package/dist/types/extended-iterable.d.ts +197 -0
- package/dist/types/extended-iterable.d.ts.map +1 -0
- package/dist/types/extended-iterable.js +769 -0
- package/dist/types/extended-iterable.js.map +1 -0
- package/dist/types/guards.d.ts +2 -0
- package/dist/types/guards.d.ts.map +1 -0
- package/dist/types/guards.js +2 -0
- package/dist/types/guards.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { parseRegions, extractRegion, stripRegionMarkers, listRegions } from './parser.js';
|
|
3
|
+
describe('parseRegions', () => {
|
|
4
|
+
describe('JavaScript/TypeScript style', () => {
|
|
5
|
+
it('parses single region', () => {
|
|
6
|
+
const code = `
|
|
7
|
+
const before = 1;
|
|
8
|
+
// #region setup
|
|
9
|
+
const x = 1;
|
|
10
|
+
const y = 2;
|
|
11
|
+
// #endregion setup
|
|
12
|
+
const after = 2;
|
|
13
|
+
`;
|
|
14
|
+
const regions = parseRegions(code, { extension: 'ts' });
|
|
15
|
+
expect(regions.setup).toBeDefined();
|
|
16
|
+
expect(regions.setup.content).toBe('const x = 1;\nconst y = 2;');
|
|
17
|
+
expect(regions.setup.startLine).toBe(3);
|
|
18
|
+
expect(regions.setup.endLine).toBe(6);
|
|
19
|
+
});
|
|
20
|
+
it('parses multiple regions', () => {
|
|
21
|
+
const code = `
|
|
22
|
+
// #region imports
|
|
23
|
+
import { foo } from 'bar';
|
|
24
|
+
// #endregion imports
|
|
25
|
+
// #region main
|
|
26
|
+
console.log('hello');
|
|
27
|
+
// #endregion main
|
|
28
|
+
`;
|
|
29
|
+
const regions = parseRegions(code, { extension: 'js' });
|
|
30
|
+
expect(Object.keys(regions)).toEqual(['imports', 'main']);
|
|
31
|
+
expect(regions.imports.content).toBe("import { foo } from 'bar';");
|
|
32
|
+
expect(regions.main.content).toBe("console.log('hello');");
|
|
33
|
+
});
|
|
34
|
+
it('parses nested regions', () => {
|
|
35
|
+
const code = `
|
|
36
|
+
// #region outer
|
|
37
|
+
const a = 1;
|
|
38
|
+
// #region inner
|
|
39
|
+
const b = 2;
|
|
40
|
+
// #endregion inner
|
|
41
|
+
const c = 3;
|
|
42
|
+
// #endregion outer
|
|
43
|
+
`;
|
|
44
|
+
const regions = parseRegions(code, { extension: 'ts' });
|
|
45
|
+
expect(regions.outer.content).toBe('const a = 1;\nconst b = 2;\nconst c = 3;');
|
|
46
|
+
expect(regions.inner.content).toBe('const b = 2;');
|
|
47
|
+
});
|
|
48
|
+
it('throws on unclosed region', () => {
|
|
49
|
+
const code = `
|
|
50
|
+
// #region unclosed
|
|
51
|
+
const x = 1;
|
|
52
|
+
`;
|
|
53
|
+
expect(() => parseRegions(code, { extension: 'ts' })).toThrow("Unclosed region 'unclosed'");
|
|
54
|
+
});
|
|
55
|
+
it('throws on mismatched region', () => {
|
|
56
|
+
const code = `
|
|
57
|
+
// #region foo
|
|
58
|
+
// #endregion bar
|
|
59
|
+
`;
|
|
60
|
+
expect(() => parseRegions(code, { extension: 'ts' })).toThrow("Mismatched region: opened 'foo'");
|
|
61
|
+
});
|
|
62
|
+
it('throws on unexpected endregion', () => {
|
|
63
|
+
const code = `
|
|
64
|
+
// #endregion orphan
|
|
65
|
+
`;
|
|
66
|
+
expect(() => parseRegions(code, { extension: 'ts' })).toThrow("Unexpected #endregion 'orphan'");
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('Python style', () => {
|
|
70
|
+
it('parses regions with hash comments', () => {
|
|
71
|
+
const code = `
|
|
72
|
+
import os
|
|
73
|
+
# #region setup
|
|
74
|
+
db = create_connection()
|
|
75
|
+
# #endregion setup
|
|
76
|
+
`;
|
|
77
|
+
const regions = parseRegions(code, { extension: 'py' });
|
|
78
|
+
expect(regions.setup.content).toBe('db = create_connection()');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('SQL style', () => {
|
|
82
|
+
it('parses regions with double-dash comments', () => {
|
|
83
|
+
const code = `
|
|
84
|
+
SELECT * FROM users;
|
|
85
|
+
-- #region migration
|
|
86
|
+
ALTER TABLE users ADD COLUMN email VARCHAR(255);
|
|
87
|
+
-- #endregion migration
|
|
88
|
+
`;
|
|
89
|
+
const regions = parseRegions(code, { extension: 'sql' });
|
|
90
|
+
expect(regions.migration.content).toBe('ALTER TABLE users ADD COLUMN email VARCHAR(255);');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe('HTML style', () => {
|
|
94
|
+
it('parses regions with HTML comments', () => {
|
|
95
|
+
const code = `
|
|
96
|
+
<html>
|
|
97
|
+
<!-- #region header -->
|
|
98
|
+
<head><title>Test</title></head>
|
|
99
|
+
<!-- #endregion header -->
|
|
100
|
+
</html>
|
|
101
|
+
`;
|
|
102
|
+
const regions = parseRegions(code, { extension: 'html' });
|
|
103
|
+
expect(regions.header.content).toBe('<head><title>Test</title></head>');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
describe('CSS style', () => {
|
|
107
|
+
it('parses regions with block comments', () => {
|
|
108
|
+
const code = `
|
|
109
|
+
body { margin: 0; }
|
|
110
|
+
/* #region theme */
|
|
111
|
+
.dark { background: black; }
|
|
112
|
+
/* #endregion theme */
|
|
113
|
+
`;
|
|
114
|
+
const regions = parseRegions(code, { extension: 'css' });
|
|
115
|
+
expect(regions.theme.content).toBe('.dark { background: black; }');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe('extractRegion', () => {
|
|
120
|
+
it('extracts specific region', () => {
|
|
121
|
+
const code = `
|
|
122
|
+
// #region setup
|
|
123
|
+
const x = 1;
|
|
124
|
+
// #endregion setup
|
|
125
|
+
// #region main
|
|
126
|
+
const y = 2;
|
|
127
|
+
// #endregion main
|
|
128
|
+
`;
|
|
129
|
+
const setup = extractRegion(code, 'setup', { extension: 'ts' });
|
|
130
|
+
expect(setup).toBe('const x = 1;');
|
|
131
|
+
});
|
|
132
|
+
it('throws with helpful message when region not found', () => {
|
|
133
|
+
const code = `
|
|
134
|
+
// #region existing
|
|
135
|
+
code();
|
|
136
|
+
// #endregion existing
|
|
137
|
+
`;
|
|
138
|
+
expect(() => extractRegion(code, 'missing', { extension: 'ts' })).toThrow("Region 'missing' not found. Available regions: existing");
|
|
139
|
+
});
|
|
140
|
+
it('provides hint when no regions exist', () => {
|
|
141
|
+
const code = `const x = 1;`;
|
|
142
|
+
expect(() => extractRegion(code, 'missing', { extension: 'ts' })).toThrow('No regions found in code');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
describe('stripRegionMarkers', () => {
|
|
146
|
+
it('removes all region markers', () => {
|
|
147
|
+
const code = `
|
|
148
|
+
const before = 1;
|
|
149
|
+
// #region setup
|
|
150
|
+
const x = 1;
|
|
151
|
+
// #endregion setup
|
|
152
|
+
const after = 2;
|
|
153
|
+
`;
|
|
154
|
+
const stripped = stripRegionMarkers(code, { extension: 'ts' });
|
|
155
|
+
expect(stripped).not.toContain('#region');
|
|
156
|
+
expect(stripped).not.toContain('#endregion');
|
|
157
|
+
expect(stripped).toContain('const x = 1;');
|
|
158
|
+
expect(stripped).toContain('const before = 1;');
|
|
159
|
+
expect(stripped).toContain('const after = 2;');
|
|
160
|
+
});
|
|
161
|
+
it('handles multiple language styles', () => {
|
|
162
|
+
const pyCode = `
|
|
163
|
+
# #region test
|
|
164
|
+
code()
|
|
165
|
+
# #endregion test
|
|
166
|
+
`;
|
|
167
|
+
const stripped = stripRegionMarkers(pyCode, { extension: 'py' });
|
|
168
|
+
expect(stripped.trim()).toBe('code()');
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
describe('listRegions', () => {
|
|
172
|
+
it('returns all region IDs', () => {
|
|
173
|
+
const code = `
|
|
174
|
+
// #region a
|
|
175
|
+
// #endregion a
|
|
176
|
+
// #region b
|
|
177
|
+
// #endregion b
|
|
178
|
+
// #region c
|
|
179
|
+
// #endregion c
|
|
180
|
+
`;
|
|
181
|
+
const ids = listRegions(code, { extension: 'ts' });
|
|
182
|
+
expect(ids).toEqual(['a', 'b', 'c']);
|
|
183
|
+
});
|
|
184
|
+
it('returns empty array when no regions', () => {
|
|
185
|
+
const code = `const x = 1;`;
|
|
186
|
+
const ids = listRegions(code, { extension: 'ts' });
|
|
187
|
+
expect(ids).toEqual([]);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
//# sourceMappingURL=parser.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.spec.js","sourceRoot":"","sources":["../../src/regions/parser.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3F,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;QAC3C,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;YAC9B,MAAM,IAAI,GAAG;;;;;;;CAOlB,CAAC;YACI,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAExD,MAAM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AS,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,MAAM,GAAG;;;;CAIlB,CAAC;QACE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,IAAI,GAAG;;;;;;;CAOhB,CAAC;QACE,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC7C,MAAM,IAAI,GAAG,cAAc,CAAC;QAC5B,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for region extraction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Information about a parsed region
|
|
6
|
+
*/
|
|
7
|
+
export interface RegionInfo {
|
|
8
|
+
/** 1-based line number where the region starts */
|
|
9
|
+
startLine: number;
|
|
10
|
+
/** 1-based line number where the region ends */
|
|
11
|
+
endLine: number;
|
|
12
|
+
/** Content within the region (markers excluded) */
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Map of region IDs to their information
|
|
17
|
+
*/
|
|
18
|
+
export type RegionMap = Record<string, RegionInfo>;
|
|
19
|
+
/**
|
|
20
|
+
* Options for region parsing
|
|
21
|
+
*/
|
|
22
|
+
export interface RegionOptions {
|
|
23
|
+
/** File extension to determine comment syntax (e.g., 'ts', 'py') */
|
|
24
|
+
extension?: string;
|
|
25
|
+
/** Language name override (e.g., 'typescript', 'python') */
|
|
26
|
+
language?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Configuration for a programming language's comment syntax
|
|
30
|
+
*/
|
|
31
|
+
export interface LanguageConfig {
|
|
32
|
+
/** Line comment prefix (e.g., '//' for JS, '#' for Python) */
|
|
33
|
+
lineComment?: string;
|
|
34
|
+
/** Block comment delimiters [start, end] */
|
|
35
|
+
blockComment?: [string, string];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/regions/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/regions/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Candidate resolution for the scanner.
|
|
3
|
+
* Evaluates include/exclude patterns and returns Dirent candidates.
|
|
4
|
+
*/
|
|
5
|
+
import type { Dirent } from 'node:fs';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve candidates by evaluating include patterns against the root.
|
|
8
|
+
* Returns Dirent entries for files and directories that match.
|
|
9
|
+
*
|
|
10
|
+
* @param root - Absolute path to the config root
|
|
11
|
+
* @param include - Glob patterns to include
|
|
12
|
+
* @param exclude - Glob patterns to exclude
|
|
13
|
+
* @returns Array of Dirent entries
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveCandidates(root: string, include: string[], exclude: string[]): Promise<Dirent[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Determine the default include pattern based on directory structure.
|
|
18
|
+
* Returns ['examples/*'] if an examples directory exists, otherwise ['*'].
|
|
19
|
+
*
|
|
20
|
+
* @param root - Absolute path to the config root
|
|
21
|
+
* @returns Default include pattern array
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDefaultIncludePattern(root: string): Promise<string[]>;
|
|
24
|
+
//# sourceMappingURL=candidates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../src/scanner/candidates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,SAAS,CAAC;AAkC7C;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BnB;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,EAAE,CAAC,CAUnB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Candidate resolution for the scanner.
|
|
3
|
+
* Evaluates include/exclude patterns and returns Dirent candidates.
|
|
4
|
+
*/
|
|
5
|
+
import { glob } from '@functional-examples/devkit';
|
|
6
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
/**
|
|
9
|
+
* A list of polyglot vendor dirs and other
|
|
10
|
+
* directories that probably just make sense to
|
|
11
|
+
* never crawl
|
|
12
|
+
*/
|
|
13
|
+
const ALWAYS_IGNORE = ['node_modules', '.git'];
|
|
14
|
+
/**
|
|
15
|
+
* Create a Dirent-like object from a Stats object.
|
|
16
|
+
* This allows us to stat individual files instead of reading entire directories.
|
|
17
|
+
*/
|
|
18
|
+
function createDirentFromStats(name, parentPath, stats) {
|
|
19
|
+
return {
|
|
20
|
+
name,
|
|
21
|
+
path: path.join(parentPath, name),
|
|
22
|
+
parentPath,
|
|
23
|
+
isFile: () => stats.isFile(),
|
|
24
|
+
isDirectory: () => stats.isDirectory(),
|
|
25
|
+
isBlockDevice: () => stats.isBlockDevice(),
|
|
26
|
+
isCharacterDevice: () => stats.isCharacterDevice(),
|
|
27
|
+
isFIFO: () => stats.isFIFO(),
|
|
28
|
+
isSocket: () => stats.isSocket(),
|
|
29
|
+
isSymbolicLink: () => stats.isSymbolicLink(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolve candidates by evaluating include patterns against the root.
|
|
34
|
+
* Returns Dirent entries for files and directories that match.
|
|
35
|
+
*
|
|
36
|
+
* @param root - Absolute path to the config root
|
|
37
|
+
* @param include - Glob patterns to include
|
|
38
|
+
* @param exclude - Glob patterns to exclude
|
|
39
|
+
* @returns Array of Dirent entries
|
|
40
|
+
*/
|
|
41
|
+
export async function resolveCandidates(root, include, exclude) {
|
|
42
|
+
// Use tinyglobby to match patterns
|
|
43
|
+
const matches = await glob(include, {
|
|
44
|
+
cwd: root,
|
|
45
|
+
ignore: ALWAYS_IGNORE.concat(exclude),
|
|
46
|
+
onlyFiles: false,
|
|
47
|
+
expandDirectories: false,
|
|
48
|
+
absolute: false,
|
|
49
|
+
});
|
|
50
|
+
// Stat each match to get Dirent-like info
|
|
51
|
+
const candidates = [];
|
|
52
|
+
await Promise.all(matches.map(async (match) => {
|
|
53
|
+
const fullPath = path.join(root, match);
|
|
54
|
+
const name = path.basename(match);
|
|
55
|
+
const parentPath = path.dirname(fullPath);
|
|
56
|
+
try {
|
|
57
|
+
const stats = await stat(fullPath);
|
|
58
|
+
candidates.push(createDirentFromStats(name, parentPath, stats));
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// File doesn't exist or can't be stat'd, skip
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
return candidates;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Determine the default include pattern based on directory structure.
|
|
68
|
+
* Returns ['examples/*'] if an examples directory exists, otherwise ['*'].
|
|
69
|
+
*
|
|
70
|
+
* @param root - Absolute path to the config root
|
|
71
|
+
* @returns Default include pattern array
|
|
72
|
+
*/
|
|
73
|
+
export async function getDefaultIncludePattern(root) {
|
|
74
|
+
try {
|
|
75
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
76
|
+
const hasExamplesDir = entries.some((entry) => entry.isDirectory() && entry.name === 'examples');
|
|
77
|
+
return hasExamplesDir ? ['examples/*'] : ['*'];
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return ['*'];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//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G,CAAC,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scanner module - orchestrates extractors to discover examples
|
|
3
|
+
*/
|
|
4
|
+
export { scanExamples } from './scanner.js';
|
|
5
|
+
export { scan } from './scan.js';
|
|
6
|
+
export type { ScanOptions } from './scan.js';
|
|
7
|
+
export type { FileConflict, PathMapping, ScanResult, } from './types.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience function for scanning examples with minimal boilerplate.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the full config discovery pipeline:
|
|
5
|
+
* `findConfigFile` → `loadConfig` → `resolveConfig` → `scanExamples`
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolvedConfig } from '../types/index.js';
|
|
8
|
+
import type { ScanResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for the convenience `scan()` function.
|
|
11
|
+
*/
|
|
12
|
+
export interface ScanOptions {
|
|
13
|
+
/** Working directory to search for config. Defaults to process.cwd() */
|
|
14
|
+
root?: string;
|
|
15
|
+
/** Pre-built config — skips file discovery + loading */
|
|
16
|
+
config?: ResolvedConfig;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Scan for examples using automatic config discovery.
|
|
20
|
+
*
|
|
21
|
+
* This is the simplest entry point for programmatic scanning.
|
|
22
|
+
* It discovers the nearest config file, loads it, resolves plugins,
|
|
23
|
+
* and runs the scanner — all in one call.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { scan } from 'functional-examples';
|
|
28
|
+
*
|
|
29
|
+
* // Auto-discover config from cwd
|
|
30
|
+
* const result = await scan();
|
|
31
|
+
*
|
|
32
|
+
* // Discover config from a specific directory
|
|
33
|
+
* const result = await scan({ root: '/path/to/project' });
|
|
34
|
+
*
|
|
35
|
+
* // Skip discovery and use a pre-resolved config
|
|
36
|
+
* const result = await scan({ config: myResolvedConfig });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function scan(options?: ScanOptions): Promise<ScanResult>;
|
|
40
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/scanner/scan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAiBrE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convenience function for scanning examples with minimal boilerplate.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the full config discovery pipeline:
|
|
5
|
+
* `findConfigFile` → `loadConfig` → `resolveConfig` → `scanExamples`
|
|
6
|
+
*/
|
|
7
|
+
import { findConfigFile, loadConfig } from '../config/loader.js';
|
|
8
|
+
import { resolveConfig } from '../config/resolver.js';
|
|
9
|
+
import { scanExamples } from './scanner.js';
|
|
10
|
+
/**
|
|
11
|
+
* Scan for examples using automatic config discovery.
|
|
12
|
+
*
|
|
13
|
+
* This is the simplest entry point for programmatic scanning.
|
|
14
|
+
* It discovers the nearest config file, loads it, resolves plugins,
|
|
15
|
+
* and runs the scanner — all in one call.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { scan } from 'functional-examples';
|
|
20
|
+
*
|
|
21
|
+
* // Auto-discover config from cwd
|
|
22
|
+
* const result = await scan();
|
|
23
|
+
*
|
|
24
|
+
* // Discover config from a specific directory
|
|
25
|
+
* const result = await scan({ root: '/path/to/project' });
|
|
26
|
+
*
|
|
27
|
+
* // Skip discovery and use a pre-resolved config
|
|
28
|
+
* const result = await scan({ config: myResolvedConfig });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export async function scan(options) {
|
|
32
|
+
if (options?.config) {
|
|
33
|
+
return scanExamples(options.config);
|
|
34
|
+
}
|
|
35
|
+
const root = options?.root ?? process.cwd();
|
|
36
|
+
const configPath = await findConfigFile(root);
|
|
37
|
+
if (!configPath) {
|
|
38
|
+
throw new Error(`No functional-examples config found starting from ${root}`);
|
|
39
|
+
}
|
|
40
|
+
const rawConfig = await loadConfig(configPath);
|
|
41
|
+
const resolved = await resolveConfig(rawConfig);
|
|
42
|
+
return scanExamples(resolved);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/scanner/scan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAa5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAqB;IAC9C,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;IAE9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,qDAAqD,IAAI,EAAE,CAC5D,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,SAAS,CAAC,CAAC;IAChD,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core scanner that orchestrates multiple extractors
|
|
3
|
+
*/
|
|
4
|
+
import { type ResolvedConfig } from '../types/index.js';
|
|
5
|
+
import type { ScanResult } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Scan a directory for examples using the provided extractors.
|
|
8
|
+
*
|
|
9
|
+
* The scanner:
|
|
10
|
+
* 1. Runs all extractors in parallel against the root
|
|
11
|
+
* 2. Collects claimed files and detects conflicts
|
|
12
|
+
* 3. Resolves conflicts via path mappings (or errors if unresolved)
|
|
13
|
+
* 4. Applies include/exclude filters AFTER extraction
|
|
14
|
+
* 5. Returns unified results
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { resolveConfig, scanExamples } from 'functional-examples';
|
|
19
|
+
*
|
|
20
|
+
* const config = await resolveConfig({ root: './examples' });
|
|
21
|
+
* const result = await scanExamples(config);
|
|
22
|
+
*
|
|
23
|
+
* for (const example of result.examples) {
|
|
24
|
+
* console.log(example.title);
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function scanExamples<TMetadata = Record<string, unknown>>(config: ResolvedConfig<TMetadata>): Promise<ScanResult<TMetadata>>;
|
|
29
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/scanner/scanner.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EAOL,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAA6B,UAAU,EAAE,MAAM,YAAY,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,MAAM,EAAE,cAAc,CAAC,SAAS,CAAC,GAChC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CA8MhC"}
|