functional-examples 0.0.1 → 0.1.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.
- package/README.md +63 -44
- package/README.md.template +28 -54
- package/dist/cli/commands/scan.d.ts +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/config/resolver.d.ts.map +1 -1
- package/dist/config/resolver.js +25 -2
- package/dist/config/resolver.js.map +1 -1
- package/dist/config/schema.d.ts +10 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +6 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/files/reader.d.ts +4 -20
- package/dist/files/reader.d.ts.map +1 -1
- package/dist/files/reader.js +6 -22
- package/dist/files/reader.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/pipeline.d.ts +2 -1
- package/dist/plugins/pipeline.d.ts.map +1 -1
- package/dist/plugins/pipeline.js +4 -3
- package/dist/plugins/pipeline.js.map +1 -1
- package/dist/regions/defaults.d.ts +11 -0
- package/dist/regions/defaults.d.ts.map +1 -0
- package/dist/regions/defaults.js +20 -0
- package/dist/regions/defaults.js.map +1 -0
- package/dist/regions/parser.d.ts +18 -56
- package/dist/regions/parser.d.ts.map +1 -1
- package/dist/regions/parser.js +81 -149
- package/dist/regions/parser.js.map +1 -1
- package/dist/scanner/scanner.d.ts.map +1 -1
- package/dist/scanner/scanner.js +14 -5
- package/dist/scanner/scanner.js.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/config/index.spec.d.ts.map +0 -1
- package/dist/config/index.spec.js +0 -142
- package/dist/config/index.spec.js.map +0 -1
- package/dist/extractors/loader.d.ts.map +0 -1
- package/dist/extractors/loader.js +0 -120
- package/dist/extractors/loader.js.map +0 -1
- package/dist/extractors/meta-yml-fn.d.ts.map +0 -1
- package/dist/extractors/meta-yml-fn.js +0 -66
- package/dist/extractors/meta-yml-fn.js.map +0 -1
- package/dist/extractors/meta-yml.d.ts.map +0 -1
- package/dist/extractors/meta-yml.js +0 -65
- package/dist/extractors/meta-yml.js.map +0 -1
- package/dist/extractors/registry.d.ts.map +0 -1
- package/dist/extractors/registry.js +0 -114
- package/dist/extractors/registry.js.map +0 -1
- package/dist/extractors/registry.spec.d.ts.map +0 -1
- package/dist/extractors/registry.spec.js +0 -102
- package/dist/extractors/registry.spec.js.map +0 -1
- package/dist/extractors/yaml-frontmatter-fn.d.ts.map +0 -1
- package/dist/extractors/yaml-frontmatter-fn.js +0 -73
- package/dist/extractors/yaml-frontmatter-fn.js.map +0 -1
- package/dist/extractors/yaml-frontmatter.d.ts.map +0 -1
- package/dist/extractors/yaml-frontmatter.js +0 -83
- package/dist/extractors/yaml-frontmatter.js.map +0 -1
- package/dist/extractors/yaml-frontmatter.spec.d.ts.map +0 -1
- package/dist/extractors/yaml-frontmatter.spec.js +0 -134
- package/dist/extractors/yaml-frontmatter.spec.js.map +0 -1
- package/dist/regions/index.d.ts +0 -7
- package/dist/regions/index.d.ts.map +0 -1
- package/dist/regions/index.js +0 -6
- package/dist/regions/index.js.map +0 -1
- package/dist/regions/languages.d.ts +0 -15
- package/dist/regions/languages.d.ts.map +0 -1
- package/dist/regions/languages.js +0 -182
- package/dist/regions/languages.js.map +0 -1
- package/dist/regions/parser.spec.d.ts.map +0 -1
- package/dist/regions/parser.spec.js +0 -190
- package/dist/regions/parser.spec.js.map +0 -1
- package/dist/regions/types.d.ts +0 -37
- package/dist/regions/types.d.ts.map +0 -1
- package/dist/regions/types.js +0 -5
- package/dist/regions/types.js.map +0 -1
- package/dist/scanner/scanner.spec.d.ts.map +0 -1
- package/dist/scanner/scanner.spec.js +0 -262
- package/dist/scanner/scanner.spec.js.map +0 -1
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { ExtractorRegistry, createDefaultRegistry } from './registry.js';
|
|
3
|
-
/**
|
|
4
|
-
* Helper to create a mock extractor for testing
|
|
5
|
-
*/
|
|
6
|
-
function createMockExtractor(name, canExtract, metadata) {
|
|
7
|
-
const fn = () => Promise.resolve({ metadata, files: [] });
|
|
8
|
-
fn.name = name;
|
|
9
|
-
fn.canExtract = () => canExtract;
|
|
10
|
-
return fn;
|
|
11
|
-
}
|
|
12
|
-
describe('ExtractorRegistry', () => {
|
|
13
|
-
describe('register', () => {
|
|
14
|
-
it('allows chaining registrations', () => {
|
|
15
|
-
const registry = new ExtractorRegistry();
|
|
16
|
-
const extractor1 = createMockExtractor('test1', false, {
|
|
17
|
-
id: '1',
|
|
18
|
-
title: '1',
|
|
19
|
-
});
|
|
20
|
-
const extractor2 = createMockExtractor('test2', false, {
|
|
21
|
-
id: '2',
|
|
22
|
-
title: '2',
|
|
23
|
-
});
|
|
24
|
-
const result = registry.register(extractor1).register(extractor2);
|
|
25
|
-
expect(result).toBe(registry);
|
|
26
|
-
expect(registry.getExtractors()).toHaveLength(2);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('findExtractor', () => {
|
|
30
|
-
it('returns first matching extractor', async () => {
|
|
31
|
-
const registry = new ExtractorRegistry();
|
|
32
|
-
const extractor1 = createMockExtractor('never-matches', false, {
|
|
33
|
-
id: '1',
|
|
34
|
-
title: '1',
|
|
35
|
-
});
|
|
36
|
-
const extractor2 = createMockExtractor('always-matches', true, {
|
|
37
|
-
id: '2',
|
|
38
|
-
title: '2',
|
|
39
|
-
});
|
|
40
|
-
registry.register(extractor1).register(extractor2);
|
|
41
|
-
const context = { path: '/test', isDirectory: false };
|
|
42
|
-
const found = await registry.findExtractor(context);
|
|
43
|
-
expect(found?.name).toBe('always-matches');
|
|
44
|
-
});
|
|
45
|
-
it('returns undefined when no extractor matches', async () => {
|
|
46
|
-
const registry = new ExtractorRegistry();
|
|
47
|
-
const extractor = createMockExtractor('never-matches', false, {
|
|
48
|
-
id: '1',
|
|
49
|
-
title: '1',
|
|
50
|
-
});
|
|
51
|
-
registry.register(extractor);
|
|
52
|
-
const context = { path: '/test', isDirectory: false };
|
|
53
|
-
const found = await registry.findExtractor(context);
|
|
54
|
-
expect(found).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('extract', () => {
|
|
58
|
-
it('uses first matching extractor', async () => {
|
|
59
|
-
const registry = new ExtractorRegistry();
|
|
60
|
-
const fn = () => Promise.resolve({
|
|
61
|
-
metadata: { id: 'test-id', title: 'Test Title' },
|
|
62
|
-
files: [{ path: 'test.ts', contents: 'code' }],
|
|
63
|
-
});
|
|
64
|
-
fn.name = 'test';
|
|
65
|
-
fn.canExtract = () => true;
|
|
66
|
-
registry.register(fn);
|
|
67
|
-
const context = { path: '/test', isDirectory: false };
|
|
68
|
-
const result = await registry.extract(context);
|
|
69
|
-
expect(result.metadata.id).toBe('test-id');
|
|
70
|
-
expect(result.metadata.title).toBe('Test Title');
|
|
71
|
-
});
|
|
72
|
-
it('throws when no extractor matches', async () => {
|
|
73
|
-
const registry = new ExtractorRegistry();
|
|
74
|
-
const context = { path: '/test', isDirectory: false };
|
|
75
|
-
await expect(registry.extract(context)).rejects.toThrow('No extractor found for file: /test');
|
|
76
|
-
});
|
|
77
|
-
it('throws with directory message for directories', async () => {
|
|
78
|
-
const registry = new ExtractorRegistry();
|
|
79
|
-
const context = { path: '/test', isDirectory: true };
|
|
80
|
-
await expect(registry.extract(context)).rejects.toThrow('No extractor found for directory: /test');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe('createDefaultRegistry', () => {
|
|
84
|
-
it('includes meta-yml extractor', () => {
|
|
85
|
-
const registry = createDefaultRegistry();
|
|
86
|
-
const extractors = registry.getExtractors();
|
|
87
|
-
expect(extractors.some((e) => e.name === 'meta-yml')).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
it('includes yaml-frontmatter extractor', () => {
|
|
90
|
-
const registry = createDefaultRegistry();
|
|
91
|
-
const extractors = registry.getExtractors();
|
|
92
|
-
expect(extractors.some((e) => e.name === 'yaml-frontmatter')).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
it('prioritizes meta-yml over yaml-frontmatter', () => {
|
|
95
|
-
const registry = createDefaultRegistry();
|
|
96
|
-
const extractors = registry.getExtractors();
|
|
97
|
-
const names = extractors.map((e) => e.name);
|
|
98
|
-
expect(names.indexOf('meta-yml')).toBeLessThan(names.indexOf('yaml-frontmatter'));
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
//# sourceMappingURL=registry.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.spec.js","sourceRoot":"","sources":["../../src/extractors/registry.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGzE;;GAEG;AACH,SAAS,mBAAmB,CAC1B,IAAY,EACZ,UAAmB,EACnB,QAAuC;IAEvC,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IACzD,EAAU,CAAC,IAAI,GAAG,IAAI,CAAC;IACvB,EAAU,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC;IAC1C,OAAO,EAA+B,CAAC;AACzC,CAAC;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,mBAAmB,CAAC,O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AyB,CAAC,SAAS,CAAC,CA4DxC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* YAML frontmatter extractor for single-file examples (function-based).
|
|
3
|
-
*
|
|
4
|
-
* Supports frontmatter in comment blocks:
|
|
5
|
-
* ```typescript
|
|
6
|
-
* // ---
|
|
7
|
-
* // title: Example Title
|
|
8
|
-
* // description: What this demonstrates
|
|
9
|
-
* // ---
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
import YAML from 'yaml';
|
|
13
|
-
import path from 'node:path';
|
|
14
|
-
/** Pattern to detect frontmatter start */
|
|
15
|
-
const FRONTMATTER_START = /^\/\/\s*---\s*$/;
|
|
16
|
-
/** Pattern to detect frontmatter end */
|
|
17
|
-
const FRONTMATTER_END = /^\/\/\s*---\s*$/;
|
|
18
|
-
/**
|
|
19
|
-
* Extractor for YAML frontmatter in single-file examples.
|
|
20
|
-
*/
|
|
21
|
-
export function createYamlFrontmatterExtractor() {
|
|
22
|
-
const extractor = async (context) => {
|
|
23
|
-
if (context.isDirectory || !context.content) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
const lines = context.content.split('\n');
|
|
27
|
-
const firstLine = lines[0]?.trimEnd();
|
|
28
|
-
if (!firstLine || !FRONTMATTER_START.test(firstLine)) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
const frontmatterLines = [];
|
|
32
|
-
let lineIndex = 1;
|
|
33
|
-
while (lineIndex < lines.length) {
|
|
34
|
-
const line = lines[lineIndex].trimEnd();
|
|
35
|
-
if (FRONTMATTER_END.test(line)) {
|
|
36
|
-
lineIndex++;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
frontmatterLines.push(line.replace(/^\/\/\s?/, ''));
|
|
40
|
-
lineIndex++;
|
|
41
|
-
}
|
|
42
|
-
const yamlContent = frontmatterLines.join('\n');
|
|
43
|
-
const parsed = YAML.parse(yamlContent);
|
|
44
|
-
const filename = path.basename(context.path);
|
|
45
|
-
const defaultId = filename.replace(/\.[^.]+$/, '').replace(/\//g, '-');
|
|
46
|
-
const metadata = {
|
|
47
|
-
id: defaultId,
|
|
48
|
-
title: defaultId,
|
|
49
|
-
...parsed,
|
|
50
|
-
};
|
|
51
|
-
const strippedContent = lines.slice(lineIndex).join('\n');
|
|
52
|
-
return {
|
|
53
|
-
metadata,
|
|
54
|
-
files: [
|
|
55
|
-
{
|
|
56
|
-
path: path.basename(context.path),
|
|
57
|
-
contents: strippedContent,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
strippedContent,
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
extractor.name = 'yaml-frontmatter';
|
|
64
|
-
extractor.canExtract = (context) => {
|
|
65
|
-
if (context.isDirectory || !context.content)
|
|
66
|
-
return false;
|
|
67
|
-
const lines = context.content.split('\n');
|
|
68
|
-
const firstLine = lines[0]?.trimEnd();
|
|
69
|
-
return FRONTMATTER_START.test(firstLine ?? '');
|
|
70
|
-
};
|
|
71
|
-
return extractor;
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=yaml-frontmatter-fn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-frontmatter-fn.js","sourceRoot":"","sources":["../../src/extractors/yaml-frontmatter-fn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,0CAA0C;AAC1C,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,wCAAwC;AACxC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,8BAA8B;IAG5C,MAAM,SAAS,GAAyC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxE,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC5C,OAAO,SA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AAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1D,OAAO;YACL,QAAQ;YACR,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;oBACjC,QAAQ,EAAE,eAAe;iBAC1B;aACF;YACD,eAAe;SAChB,CAAC;IACJ,CAAC,CAAC;IAEF,SAAS,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACpC,SAAS,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,EAAE;QACjC,IAAI,OAAO,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QACtC,OAAO,iBAAiB,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-frontmatter.d.ts","sourceRoot":"","sources":["../../src/extractors/yaml-frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAQ1F;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,iBAAiB;IAChE,QAAQ,CAAC,IAAI,sBAAsB;IAEnC,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO;IAYzC,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAwDtE"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* YAML frontmatter extractor for single-file examples.
|
|
3
|
-
*
|
|
4
|
-
* Supports frontmatter in comment blocks:
|
|
5
|
-
* ```typescript
|
|
6
|
-
* // ---
|
|
7
|
-
* // title: Example Title
|
|
8
|
-
* // description: What this demonstrates
|
|
9
|
-
* // ---
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
import YAML from 'yaml';
|
|
13
|
-
import path from 'node:path';
|
|
14
|
-
/** Pattern to detect frontmatter start */
|
|
15
|
-
const FRONTMATTER_START = /^\/\/\s*---\s*$/;
|
|
16
|
-
/** Pattern to detect frontmatter end */
|
|
17
|
-
const FRONTMATTER_END = /^\/\/\s*---\s*$/;
|
|
18
|
-
/**
|
|
19
|
-
* Extractor for YAML frontmatter in single-file examples.
|
|
20
|
-
* Used by cli-forge and flexibench patterns.
|
|
21
|
-
*/
|
|
22
|
-
export class YamlFrontmatterExtractor {
|
|
23
|
-
name = 'yaml-frontmatter';
|
|
24
|
-
canExtract(context) {
|
|
25
|
-
// Only works on files with content
|
|
26
|
-
if (context.isDirectory || !context.content) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
// Check if first non-empty line is frontmatter start
|
|
30
|
-
const lines = context.content.split('\n');
|
|
31
|
-
const firstLine = lines[0]?.trimEnd();
|
|
32
|
-
return FRONTMATTER_START.test(firstLine ?? '');
|
|
33
|
-
}
|
|
34
|
-
async extract(context) {
|
|
35
|
-
if (!context.content) {
|
|
36
|
-
throw new Error('No content provided for frontmatter extraction');
|
|
37
|
-
}
|
|
38
|
-
const lines = context.content.split('\n');
|
|
39
|
-
const frontmatterLines = [];
|
|
40
|
-
let lineIndex = 0;
|
|
41
|
-
// Skip the opening ---
|
|
42
|
-
const firstLine = lines[lineIndex]?.trimEnd();
|
|
43
|
-
if (!firstLine || !FRONTMATTER_START.test(firstLine)) {
|
|
44
|
-
throw new Error('Content does not start with frontmatter marker');
|
|
45
|
-
}
|
|
46
|
-
lineIndex++;
|
|
47
|
-
// Collect frontmatter lines until closing ---
|
|
48
|
-
while (lineIndex < lines.length) {
|
|
49
|
-
const line = lines[lineIndex].trimEnd();
|
|
50
|
-
if (FRONTMATTER_END.test(line)) {
|
|
51
|
-
lineIndex++;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
// Strip the leading // and optional space
|
|
55
|
-
frontmatterLines.push(line.replace(/^\/\/\s?/, ''));
|
|
56
|
-
lineIndex++;
|
|
57
|
-
}
|
|
58
|
-
// Parse YAML
|
|
59
|
-
const yamlContent = frontmatterLines.join('\n');
|
|
60
|
-
const parsed = YAML.parse(yamlContent);
|
|
61
|
-
// Generate ID from filename if not provided
|
|
62
|
-
const filename = path.basename(context.path);
|
|
63
|
-
const defaultId = filename.replace(/\.[^.]+$/, '').replace(/\//g, '-');
|
|
64
|
-
const metadata = {
|
|
65
|
-
id: defaultId,
|
|
66
|
-
title: defaultId,
|
|
67
|
-
...parsed,
|
|
68
|
-
};
|
|
69
|
-
// Content after frontmatter
|
|
70
|
-
const strippedContent = lines.slice(lineIndex).join('\n');
|
|
71
|
-
return {
|
|
72
|
-
metadata,
|
|
73
|
-
files: [
|
|
74
|
-
{
|
|
75
|
-
path: path.basename(context.path),
|
|
76
|
-
contents: strippedContent,
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
strippedContent,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=yaml-frontmatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-frontmatter.js","sourceRoot":"","sources":["../../src/extractors/yaml-frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,0CAA0C;AAC1C,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAC5C,wCAAwC;AACxC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IA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,CAAC;YACD,0CAA0C;YAC1C,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;YACpD,SAAS,EAAE,CAAC;QACd,CAAC;QAED,aAAa;QACb,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAA4B,CAAC;QAElE,4CAA4C;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEvE,MAAM,QAAQ,GAAG;YACf,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,SAAS;YAChB,GAAG,MAAM;SACV,CAAC;QAEF,4BAA4B;QAC5B,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1D,OAAO;YACL,QAAQ;YACR,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;oBACjC,QAAQ,EAAE,eAAe;iBAC1B;aACF;YACD,eAAe;SAChB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-frontmatter.spec.d.ts","sourceRoot":"","sources":["../../src/extractors/yaml-frontmatter.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { YamlFrontmatterExtractor } from './yaml-frontmatter.js';
|
|
3
|
-
describe('YamlFrontmatterExtractor', () => {
|
|
4
|
-
const extractor = new YamlFrontmatterExtractor();
|
|
5
|
-
describe('canExtract', () => {
|
|
6
|
-
it('returns true for file with frontmatter', () => {
|
|
7
|
-
const context = {
|
|
8
|
-
path: '/test/example.ts',
|
|
9
|
-
isDirectory: false,
|
|
10
|
-
content: `// ---
|
|
11
|
-
// title: Test
|
|
12
|
-
// ---
|
|
13
|
-
console.log('hello');`,
|
|
14
|
-
};
|
|
15
|
-
expect(extractor.canExtract(context)).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
it('returns false for file without frontmatter', () => {
|
|
18
|
-
const context = {
|
|
19
|
-
path: '/test/example.ts',
|
|
20
|
-
isDirectory: false,
|
|
21
|
-
content: `console.log('hello');`,
|
|
22
|
-
};
|
|
23
|
-
expect(extractor.canExtract(context)).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
it('returns false for directories', () => {
|
|
26
|
-
const context = {
|
|
27
|
-
path: '/test/example',
|
|
28
|
-
isDirectory: true,
|
|
29
|
-
entries: ['meta.yml'],
|
|
30
|
-
};
|
|
31
|
-
expect(extractor.canExtract(context)).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
it('returns false for empty content', () => {
|
|
34
|
-
const context = {
|
|
35
|
-
path: '/test/example.ts',
|
|
36
|
-
isDirectory: false,
|
|
37
|
-
content: '',
|
|
38
|
-
};
|
|
39
|
-
expect(extractor.canExtract(context)).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('extract', () => {
|
|
43
|
-
it('extracts metadata from frontmatter', async () => {
|
|
44
|
-
const context = {
|
|
45
|
-
path: '/test/example.ts',
|
|
46
|
-
isDirectory: false,
|
|
47
|
-
content: `// ---
|
|
48
|
-
// title: My Example
|
|
49
|
-
// description: A test example
|
|
50
|
-
// ---
|
|
51
|
-
console.log('hello');`,
|
|
52
|
-
};
|
|
53
|
-
const result = await extractor.extract(context);
|
|
54
|
-
expect(result.metadata.id).toBe('example');
|
|
55
|
-
expect(result.metadata.title).toBe('My Example');
|
|
56
|
-
expect(result.metadata.description).toBe('A test example');
|
|
57
|
-
expect(result.strippedContent).toBe("console.log('hello');");
|
|
58
|
-
});
|
|
59
|
-
it('generates id from filename if not provided', async () => {
|
|
60
|
-
const context = {
|
|
61
|
-
path: '/test/my-cool-example.ts',
|
|
62
|
-
isDirectory: false,
|
|
63
|
-
content: `// ---
|
|
64
|
-
// title: Cool Example
|
|
65
|
-
// ---
|
|
66
|
-
code();`,
|
|
67
|
-
};
|
|
68
|
-
const result = await extractor.extract(context);
|
|
69
|
-
expect(result.metadata.id).toBe('my-cool-example');
|
|
70
|
-
});
|
|
71
|
-
it('uses provided id over generated one', async () => {
|
|
72
|
-
const context = {
|
|
73
|
-
path: '/test/example.ts',
|
|
74
|
-
isDirectory: false,
|
|
75
|
-
content: `// ---
|
|
76
|
-
// id: custom-id
|
|
77
|
-
// title: Example
|
|
78
|
-
// ---
|
|
79
|
-
code();`,
|
|
80
|
-
};
|
|
81
|
-
const result = await extractor.extract(context);
|
|
82
|
-
expect(result.metadata.id).toBe('custom-id');
|
|
83
|
-
});
|
|
84
|
-
it('handles multiline description', async () => {
|
|
85
|
-
const context = {
|
|
86
|
-
path: '/test/example.ts',
|
|
87
|
-
isDirectory: false,
|
|
88
|
-
content: `// ---
|
|
89
|
-
// title: Example
|
|
90
|
-
// description: |
|
|
91
|
-
// This is a multiline
|
|
92
|
-
// description
|
|
93
|
-
// ---
|
|
94
|
-
code();`,
|
|
95
|
-
};
|
|
96
|
-
const result = await extractor.extract(context);
|
|
97
|
-
expect(result.metadata.description).toContain('multiline');
|
|
98
|
-
});
|
|
99
|
-
it('preserves extra metadata fields', async () => {
|
|
100
|
-
const context = {
|
|
101
|
-
path: '/test/example.ts',
|
|
102
|
-
isDirectory: false,
|
|
103
|
-
content: `// ---
|
|
104
|
-
// title: Example
|
|
105
|
-
// customField: custom value
|
|
106
|
-
// tags:
|
|
107
|
-
// - tag1
|
|
108
|
-
// - tag2
|
|
109
|
-
// ---
|
|
110
|
-
code();`,
|
|
111
|
-
};
|
|
112
|
-
const result = await extractor.extract(context);
|
|
113
|
-
// Extra fields are preserved in metadata
|
|
114
|
-
const metadata = result.metadata;
|
|
115
|
-
expect(metadata.customField).toBe('custom value');
|
|
116
|
-
expect(metadata.tags).toEqual(['tag1', 'tag2']);
|
|
117
|
-
});
|
|
118
|
-
it('creates file entry with stripped content', async () => {
|
|
119
|
-
const context = {
|
|
120
|
-
path: '/test/example.ts',
|
|
121
|
-
isDirectory: false,
|
|
122
|
-
content: `// ---
|
|
123
|
-
// title: Example
|
|
124
|
-
// ---
|
|
125
|
-
const x = 1;`,
|
|
126
|
-
};
|
|
127
|
-
const result = await extractor.extract(context);
|
|
128
|
-
expect(result.files).toHaveLength(1);
|
|
129
|
-
expect(result.files[0].path).toBe('example.ts');
|
|
130
|
-
expect(result.files[0].contents).toBe('const x = 1;');
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
//# sourceMappingURL=yaml-frontmatter.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yaml-frontmatter.spec.js","sourceRoot":"","sources":["../../src/extractors/yaml-frontmatter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,MAAM,SAAS,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAEjD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;YAChD,MAAM,OAAO,GAAsB;gBACjC,IAAI,EAAE,kBAAkB;gBACxB,WAAW,EAAE,KAAK;gBAClB,OAAO,EAAE;;;sBAGK;aACf,CAAC;YACF,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAA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AAI,CAAC,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/regions/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Region extraction system for code examples
|
|
3
|
-
*/
|
|
4
|
-
export type { RegionInfo, RegionMap, RegionOptions, LanguageConfig, } from './types.js';
|
|
5
|
-
export { LANGUAGE_CONFIGS, getLanguageConfig } from './languages.js';
|
|
6
|
-
export { parseRegions, extractRegion, stripRegionMarkers, listRegions, } from './parser.js';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/regions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
package/dist/regions/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/regions/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language configuration for region markers
|
|
3
|
-
*/
|
|
4
|
-
import type { LanguageConfig } from './types.js';
|
|
5
|
-
/**
|
|
6
|
-
* Comment syntax configuration for various programming languages.
|
|
7
|
-
* Maps file extensions to their comment patterns.
|
|
8
|
-
*/
|
|
9
|
-
export declare const LANGUAGE_CONFIGS: Record<string, LanguageConfig>;
|
|
10
|
-
/**
|
|
11
|
-
* Get the language configuration for a file extension.
|
|
12
|
-
* Falls back to JavaScript-style comments if unknown.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getLanguageConfig(extension: string): LanguageConfig;
|
|
15
|
-
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/regions/languages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAgN3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAInE"}
|