@cobol-ts/codegen 0.0.2 → 0.0.4
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/dist/index.js.map +1 -0
- package/dist/src/codegen.d.ts +33 -0
- package/dist/src/codegen.js +154 -0
- package/dist/src/codegen.js.map +1 -0
- package/dist/src/codegen.spec.d.ts +1 -0
- package/dist/src/codegen.spec.js +229 -0
- package/dist/src/codegen.spec.js.map +1 -0
- package/package.json +10 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ArtefactKind, ArtefactManifest } from '@cobol-ts/file-catalogue';
|
|
2
|
+
import type { TextFiles } from '@cobol-ts/files';
|
|
3
|
+
import type { ErrorsOr } from '@cobol-ts/errors';
|
|
4
|
+
/** Project-owned TypeScript names. No COBOL or example-specific names are embedded in codegen. */
|
|
5
|
+
export interface CodegenNames {
|
|
6
|
+
readonly source: string;
|
|
7
|
+
readonly projection: string;
|
|
8
|
+
readonly variable: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CodegenSelection {
|
|
11
|
+
readonly logicalNames?: readonly string[];
|
|
12
|
+
readonly artefactKinds?: readonly ArtefactKind[];
|
|
13
|
+
}
|
|
14
|
+
export interface CodegenOptions {
|
|
15
|
+
readonly selection?: CodegenSelection;
|
|
16
|
+
readonly files: TextFiles;
|
|
17
|
+
readonly catalogue: string;
|
|
18
|
+
readonly policy: string;
|
|
19
|
+
/** Discovered .cobolts directory; both YAML roots are resolved from here. */
|
|
20
|
+
readonly configDirectory: string;
|
|
21
|
+
readonly names: Readonly<Record<string, CodegenNames>>;
|
|
22
|
+
}
|
|
23
|
+
export interface GenerationResult {
|
|
24
|
+
readonly manifest: ArtefactManifest;
|
|
25
|
+
/** Paths actually written, in generation order. Manual artefacts are never included. */
|
|
26
|
+
readonly written: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate TypeScript source from the copybook AST. Both projection printers
|
|
30
|
+
* use the same in-memory default projection. Generated TypeScript is never
|
|
31
|
+
* loaded or executed by the generator.
|
|
32
|
+
*/
|
|
33
|
+
export declare function generateCode(options: CodegenOptions): Promise<ErrorsOr<GenerationResult>>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateCode = generateCode;
|
|
4
|
+
const file_catalogue_1 = require("@cobol-ts/file-catalogue");
|
|
5
|
+
const copybook_1 = require("@cobol-ts/copybook");
|
|
6
|
+
const copybook_typescript_1 = require("@cobol-ts/copybook-typescript");
|
|
7
|
+
const default_projection_typescript_1 = require("@cobol-ts/default-projection-typescript");
|
|
8
|
+
const projection_typescript_1 = require("@cobol-ts/projection-typescript");
|
|
9
|
+
const failure = (context, cause) => ({
|
|
10
|
+
errors: [`${context}: ${cause instanceof Error ? cause.message : String(cause)}`]
|
|
11
|
+
});
|
|
12
|
+
function getArtefact(manifest, logicalName, kind) {
|
|
13
|
+
const artefact = manifest.artefacts.find(item => item.logicalName === logicalName && item.kind === kind);
|
|
14
|
+
return artefact ? { value: artefact } : { errors: [`Missing resolved artefact ${logicalName}/${kind}`] };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Generate TypeScript source from the copybook AST. Both projection printers
|
|
18
|
+
* use the same in-memory default projection. Generated TypeScript is never
|
|
19
|
+
* loaded or executed by the generator.
|
|
20
|
+
*/
|
|
21
|
+
async function generateCode(options) {
|
|
22
|
+
const { files, names } = options;
|
|
23
|
+
const selected = (logicalName, kind) => (!options.selection?.logicalNames || options.selection.logicalNames.includes(logicalName)) &&
|
|
24
|
+
(!options.selection?.artefactKinds || options.selection.artefactKinds.includes(kind));
|
|
25
|
+
const manifestResult = await (0, file_catalogue_1.readArtefactManifest)(files, options.catalogue, options.policy, options.configDirectory);
|
|
26
|
+
if ('errors' in manifestResult)
|
|
27
|
+
return manifestResult;
|
|
28
|
+
const manifest = manifestResult.value;
|
|
29
|
+
const requested = options.selection?.logicalNames ?? [];
|
|
30
|
+
const unknown = requested.filter(name => !manifest.sources.some(source => source.logicalName === name));
|
|
31
|
+
if (unknown.length)
|
|
32
|
+
return { errors: unknown.map(name => `Unknown logical file ${name}`) };
|
|
33
|
+
const verified = await (0, file_catalogue_1.verifyManualArtefacts)(files, manifest);
|
|
34
|
+
if ('errors' in verified)
|
|
35
|
+
return verified;
|
|
36
|
+
// Validate project naming before writing anything.
|
|
37
|
+
const nameErrors = [];
|
|
38
|
+
for (const source of manifest.sources) {
|
|
39
|
+
if (source.definition.type !== 'cobol')
|
|
40
|
+
continue;
|
|
41
|
+
if (!names[source.logicalName])
|
|
42
|
+
nameErrors.push(`Missing TypeScript names for ${source.logicalName}`);
|
|
43
|
+
if (!source.copybookPath)
|
|
44
|
+
nameErrors.push(`Missing copybook path for ${source.logicalName}`);
|
|
45
|
+
}
|
|
46
|
+
if (nameErrors.length)
|
|
47
|
+
return { errors: nameErrors };
|
|
48
|
+
const written = [];
|
|
49
|
+
async function write(artefact, lines) {
|
|
50
|
+
if (artefact.mode === 'manual' || !selected(artefact.logicalName, artefact.kind))
|
|
51
|
+
return { value: undefined };
|
|
52
|
+
const result = await (0, file_catalogue_1.writeGeneratedArtefact)(files, artefact, lines);
|
|
53
|
+
if ('value' in result)
|
|
54
|
+
written.push(artefact.path);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
const ref = (logicalName, kind) => ({ logicalName, kind });
|
|
58
|
+
// Ownership is validated before writing, so an authored definition cannot
|
|
59
|
+
// accidentally be paired with a type generated from a different default.
|
|
60
|
+
const ownershipErrors = [];
|
|
61
|
+
for (const source of manifest.sources) {
|
|
62
|
+
if (source.definition.type !== 'cobol')
|
|
63
|
+
continue;
|
|
64
|
+
const definition = getArtefact(manifest, source.logicalName, 'projectionDefinition');
|
|
65
|
+
const projectedType = getArtefact(manifest, source.logicalName, 'projectionType');
|
|
66
|
+
if ('errors' in definition)
|
|
67
|
+
return definition;
|
|
68
|
+
if ('errors' in projectedType)
|
|
69
|
+
return projectedType;
|
|
70
|
+
if (definition.value.mode === 'manual' && projectedType.value.mode !== 'manual') {
|
|
71
|
+
ownershipErrors.push(`${source.logicalName}: A manual projection definition requires a manual projection type`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (ownershipErrors.length)
|
|
75
|
+
return { errors: ownershipErrors };
|
|
76
|
+
for (const source of manifest.sources) {
|
|
77
|
+
if (source.definition.type !== 'cobol')
|
|
78
|
+
continue;
|
|
79
|
+
if (options.selection?.logicalNames && !options.selection.logicalNames.includes(source.logicalName))
|
|
80
|
+
continue;
|
|
81
|
+
const logicalName = source.logicalName;
|
|
82
|
+
const itemNames = names[logicalName];
|
|
83
|
+
const sourceResult = getArtefact(manifest, logicalName, 'copybookType');
|
|
84
|
+
const definitionResult = getArtefact(manifest, logicalName, 'projectionDefinition');
|
|
85
|
+
const projectedTypeResult = getArtefact(manifest, logicalName, 'projectionType');
|
|
86
|
+
if ('errors' in sourceResult)
|
|
87
|
+
return sourceResult;
|
|
88
|
+
if ('errors' in definitionResult)
|
|
89
|
+
return definitionResult;
|
|
90
|
+
if ('errors' in projectedTypeResult)
|
|
91
|
+
return projectedTypeResult;
|
|
92
|
+
const sourceArtefact = sourceResult.value;
|
|
93
|
+
const definitionArtefact = definitionResult.value;
|
|
94
|
+
const typeArtefact = projectedTypeResult.value;
|
|
95
|
+
if (!['copybookType', 'projectionDefinition', 'projectionType'].some(kind => selected(logicalName, kind)))
|
|
96
|
+
continue;
|
|
97
|
+
if (sourceArtefact.mode === 'manual' && definitionArtefact.mode === 'manual' && typeArtefact.mode === 'manual')
|
|
98
|
+
continue;
|
|
99
|
+
let text;
|
|
100
|
+
try {
|
|
101
|
+
text = await files.read(source.copybookPath);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return failure(`Reading copybook ${logicalName}: ${source.copybookPath}`, error);
|
|
105
|
+
}
|
|
106
|
+
const ast = (0, copybook_1.parseCopybook)(text);
|
|
107
|
+
if ('errors' in ast)
|
|
108
|
+
return { errors: ast.errors.map(error => `${logicalName}: ${error}`) };
|
|
109
|
+
if (sourceArtefact.mode === 'generated' && selected(logicalName, 'copybookType')) {
|
|
110
|
+
const lines = (0, copybook_typescript_1.generateCopybookTypescript)(ast.value);
|
|
111
|
+
if ('errors' in lines)
|
|
112
|
+
return { errors: lines.errors.map(error => `${logicalName}/copybookType: ${error}`) };
|
|
113
|
+
const result = await write(sourceArtefact, lines.value);
|
|
114
|
+
if ('errors' in result)
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
if (!selected(logicalName, 'projectionDefinition') && !selected(logicalName, 'projectionType'))
|
|
118
|
+
continue;
|
|
119
|
+
if (definitionArtefact.mode === 'manual' && typeArtefact.mode === 'manual')
|
|
120
|
+
continue;
|
|
121
|
+
const built = (0, default_projection_typescript_1.createDefaultProjection)(ast.value);
|
|
122
|
+
if ('errors' in built)
|
|
123
|
+
return { errors: built.errors.map(error => `${logicalName}/projectionDefinition: ${error}`) };
|
|
124
|
+
if (definitionArtefact.mode === 'generated' && selected(logicalName, 'projectionDefinition')) {
|
|
125
|
+
const from = ref(logicalName, 'projectionDefinition');
|
|
126
|
+
const sourceImport = (0, file_catalogue_1.artefactImport)(manifest, from, ref(logicalName, 'copybookType'));
|
|
127
|
+
const projectionImport = (0, file_catalogue_1.artefactImport)(manifest, from, ref(logicalName, 'projectionType'));
|
|
128
|
+
if ('errors' in sourceImport)
|
|
129
|
+
return sourceImport;
|
|
130
|
+
if ('errors' in projectionImport)
|
|
131
|
+
return projectionImport;
|
|
132
|
+
const lines = (0, default_projection_typescript_1.printDefaultProjectionTypescript)(built.value, itemNames.source, itemNames.projection, {
|
|
133
|
+
variableName: itemNames.variable,
|
|
134
|
+
copybookImport: sourceImport.value,
|
|
135
|
+
projectionImport: projectionImport.value
|
|
136
|
+
});
|
|
137
|
+
if ('errors' in lines)
|
|
138
|
+
return { errors: lines.errors.map(error => `${logicalName}/projectionDefinition: ${error}`) };
|
|
139
|
+
const result = await write(definitionArtefact, lines.value);
|
|
140
|
+
if ('errors' in result)
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
if (typeArtefact.mode === 'generated' && selected(logicalName, 'projectionType')) {
|
|
144
|
+
const lines = (0, projection_typescript_1.generateProjectionTypescript)(built.value, itemNames.projection);
|
|
145
|
+
if ('errors' in lines)
|
|
146
|
+
return { errors: lines.errors.map(error => `${logicalName}/projectionType: ${error}`) };
|
|
147
|
+
const result = await write(typeArtefact, lines.value);
|
|
148
|
+
if ('errors' in result)
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return { value: { manifest, written } };
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/codegen.ts"],"names":[],"mappings":";;AAmDA,oCAsGC;AAzJD,6DAA4H;AAG5H,iDAAgD;AAChD,uEAAwE;AACxE,2FAAiH;AACjH,2EAA4E;AA+B5E,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,KAAc,EAAmB,EAAE,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,GAAG,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;CACpF,CAAC,CAAA;AAEF,SAAS,WAAW,CAAC,QAA0B,EAAE,WAAmB,EAAE,IAAkB;IACpF,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,KAAK,WAAW,IAAI,IA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OAAO,EAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,WAAW,oBAAoB,KAAK,EAAE,CAAC,EAAC,CAAA;YAC5G,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;YACrD,IAAI,QAAQ,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAA;QACzC,CAAC;IACL,CAAC;IACD,OAAO,EAAC,KAAK,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,EAAC,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_path_1 = require("node:path");
|
|
4
|
+
const codegen_1 = require("./codegen");
|
|
5
|
+
const projectRoot = (0, node_path_1.resolve)('/tmp/codegen-test-application');
|
|
6
|
+
const catalogue = (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts/files.yaml');
|
|
7
|
+
const policy = (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts/generation.yaml');
|
|
8
|
+
const copybook = (0, node_path_1.resolve)('/tmp/codegen-test-definitions/copybooks/CUSTOMER.cpy');
|
|
9
|
+
const sourceText = [
|
|
10
|
+
'01 CUSTOMER.',
|
|
11
|
+
' 05 CUSTOMER-ID PIC 9(4).',
|
|
12
|
+
' 05 CUSTOMER-NAME PIC X(8).',
|
|
13
|
+
''
|
|
14
|
+
].join('\n');
|
|
15
|
+
const catalogueYaml = [
|
|
16
|
+
'root: ../copybooks',
|
|
17
|
+
'files:',
|
|
18
|
+
' customers:',
|
|
19
|
+
' type: cobol',
|
|
20
|
+
' copybook: CUSTOMER.cpy',
|
|
21
|
+
''
|
|
22
|
+
].join('\n');
|
|
23
|
+
const policyYaml = [
|
|
24
|
+
`root: ${(0, node_path_1.join)(projectRoot, 'src/generated').replace(/\\/g, '/')}`,
|
|
25
|
+
'templates:',
|
|
26
|
+
' copybookType: "${name}.copybook.types.ts"',
|
|
27
|
+
' projectionDefinition: "${name}.projection.ts"',
|
|
28
|
+
' projectionType: "${name}.projection.types.ts"',
|
|
29
|
+
''
|
|
30
|
+
].join('\n');
|
|
31
|
+
const names = {
|
|
32
|
+
customers: { source: 'CustomerCB', projection: 'Customer', variable: 'customerProjection' }
|
|
33
|
+
};
|
|
34
|
+
const paths = {
|
|
35
|
+
source: (0, node_path_1.join)(projectRoot, 'src/generated/customers.copybook.types.ts'),
|
|
36
|
+
definition: (0, node_path_1.join)(projectRoot, 'src/generated/customers.projection.ts'),
|
|
37
|
+
projection: (0, node_path_1.join)(projectRoot, 'src/generated/customers.projection.types.ts')
|
|
38
|
+
};
|
|
39
|
+
function fixture(overrides) {
|
|
40
|
+
const contents = new Map([
|
|
41
|
+
[catalogue, catalogueYaml],
|
|
42
|
+
[policy, overrides?.policy ?? policyYaml],
|
|
43
|
+
[copybook, overrides?.copybook ?? sourceText]
|
|
44
|
+
]);
|
|
45
|
+
const writes = [];
|
|
46
|
+
const files = {
|
|
47
|
+
async read(filename) {
|
|
48
|
+
const text = contents.get(filename);
|
|
49
|
+
if (text === undefined)
|
|
50
|
+
throw new Error(`ENOENT: ${filename}`);
|
|
51
|
+
return text;
|
|
52
|
+
},
|
|
53
|
+
async write(filename, lines) {
|
|
54
|
+
writes.push({ path: filename, lines: [...lines] });
|
|
55
|
+
contents.set(filename, lines.join('\n') + (lines.length ? '\n' : ''));
|
|
56
|
+
},
|
|
57
|
+
async exists(filename) { return contents.has(filename); }
|
|
58
|
+
};
|
|
59
|
+
const run = () => (0, codegen_1.generateCode)({ files, catalogue, policy, configDirectory: (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts'), names });
|
|
60
|
+
return { contents, writes, run };
|
|
61
|
+
}
|
|
62
|
+
describe('generateCode', () => {
|
|
63
|
+
describe('source generation', () => {
|
|
64
|
+
it('writes complete copybook, definition and projection types in dependency order', async () => {
|
|
65
|
+
const test = fixture();
|
|
66
|
+
const result = await test.run();
|
|
67
|
+
expect('errors' in result ? result : {
|
|
68
|
+
written: result.value.written,
|
|
69
|
+
artefacts: result.value.manifest.artefacts.map(a => [a.logicalName, a.kind, a.mode])
|
|
70
|
+
}).toEqual({
|
|
71
|
+
written: [paths.source, paths.definition, paths.projection],
|
|
72
|
+
artefacts: [
|
|
73
|
+
['customers', 'copybookType', 'generated'],
|
|
74
|
+
['customers', 'projectionDefinition', 'generated'],
|
|
75
|
+
['customers', 'projectionType', 'generated']
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
expect(test.writes).toEqual([
|
|
79
|
+
{ path: paths.source, lines: [
|
|
80
|
+
'export type CustomerCB = {',
|
|
81
|
+
' customerId(): number',
|
|
82
|
+
' customerName(): string',
|
|
83
|
+
'}'
|
|
84
|
+
] },
|
|
85
|
+
{ path: paths.definition, lines: [
|
|
86
|
+
'import {defineProjection} from "@cobol-ts/cursor-projection"',
|
|
87
|
+
'import type {ProjectionDefinition} from "@cobol-ts/cursor-loader-types"',
|
|
88
|
+
'import type {CustomerCB} from "./customers.copybook.types"',
|
|
89
|
+
'import type {Customer} from "./customers.projection.types"',
|
|
90
|
+
'',
|
|
91
|
+
'/** Original COBOL source contract used to author customerProjection. */',
|
|
92
|
+
'export type CustomerProjectionSource = CustomerCB',
|
|
93
|
+
'',
|
|
94
|
+
'export const customerProjection = defineProjection<Customer>({',
|
|
95
|
+
' customerId: {type: "integer", path: ["CUSTOMER","CUSTOMER-ID"]},',
|
|
96
|
+
' customerName: {type: "string", path: ["CUSTOMER","CUSTOMER-NAME"]},',
|
|
97
|
+
'} satisfies ProjectionDefinition<Customer>)'
|
|
98
|
+
] },
|
|
99
|
+
{ path: paths.projection, lines: [
|
|
100
|
+
'export type Customer = {',
|
|
101
|
+
' customerId(): number',
|
|
102
|
+
' customerName(): string',
|
|
103
|
+
'}'
|
|
104
|
+
] }
|
|
105
|
+
]);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
describe('selective generation', () => {
|
|
109
|
+
it.each([
|
|
110
|
+
[['copybookType'], [paths.source]],
|
|
111
|
+
[['projectionDefinition'], [paths.definition]],
|
|
112
|
+
[['projectionType'], [paths.projection]]
|
|
113
|
+
])('writes only the selected artefact kinds', async (kinds, written) => {
|
|
114
|
+
const test = fixture();
|
|
115
|
+
const result = await (0, codegen_1.generateCode)({
|
|
116
|
+
files: {
|
|
117
|
+
read: async (path) => {
|
|
118
|
+
const contents = test.contents.get(path);
|
|
119
|
+
if (contents === undefined)
|
|
120
|
+
throw new Error(`ENOENT: ${path}`);
|
|
121
|
+
return contents;
|
|
122
|
+
},
|
|
123
|
+
write: async (path, lines) => { test.writes.push({ path, lines }); },
|
|
124
|
+
exists: async (path) => test.contents.has(path)
|
|
125
|
+
},
|
|
126
|
+
catalogue, policy, configDirectory: (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts'), names,
|
|
127
|
+
selection: { artefactKinds: [...kinds] }
|
|
128
|
+
});
|
|
129
|
+
expect('errors' in result ? result : result.value.written).toEqual([...written]);
|
|
130
|
+
expect(test.writes.map(item => item.path)).toEqual([...written]);
|
|
131
|
+
});
|
|
132
|
+
it('rejects an unknown logical name without writing', async () => {
|
|
133
|
+
const test = fixture();
|
|
134
|
+
const result = await (0, codegen_1.generateCode)({
|
|
135
|
+
files: {
|
|
136
|
+
read: async (path) => {
|
|
137
|
+
const contents = test.contents.get(path);
|
|
138
|
+
if (contents === undefined)
|
|
139
|
+
throw new Error(`ENOENT: ${path}`);
|
|
140
|
+
return contents;
|
|
141
|
+
},
|
|
142
|
+
write: async (path, lines) => { test.writes.push({ path, lines }); },
|
|
143
|
+
exists: async (path) => test.contents.has(path)
|
|
144
|
+
},
|
|
145
|
+
catalogue, policy, configDirectory: (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts'), names,
|
|
146
|
+
selection: { logicalNames: ['unknown'] }
|
|
147
|
+
});
|
|
148
|
+
expect(result).toEqual({ errors: ['Unknown logical file unknown'] });
|
|
149
|
+
expect(test.writes).toEqual([]);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe('manual ownership', () => {
|
|
153
|
+
const manualPolicy = policyYaml + [
|
|
154
|
+
'overrides:',
|
|
155
|
+
' customers:',
|
|
156
|
+
' projectionDefinition:',
|
|
157
|
+
' mode: manual',
|
|
158
|
+
' path: src/authored/customer.ts',
|
|
159
|
+
''
|
|
160
|
+
].join('\n');
|
|
161
|
+
const manualPath = (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts/src/authored/customer.ts');
|
|
162
|
+
it('rejects a manual definition with a generated companion type before writing', async () => {
|
|
163
|
+
const test = fixture({ policy: manualPolicy });
|
|
164
|
+
test.contents.set(manualPath, 'export const customerProjection = {}\n');
|
|
165
|
+
expect(await test.run()).toEqual({ errors: [
|
|
166
|
+
'customers: A manual projection definition requires a manual projection type'
|
|
167
|
+
] });
|
|
168
|
+
expect(test.writes).toEqual([]);
|
|
169
|
+
});
|
|
170
|
+
it('preserves a manually owned definition and companion type', async () => {
|
|
171
|
+
const bothManual = manualPolicy + [
|
|
172
|
+
' projectionType:',
|
|
173
|
+
' mode: manual',
|
|
174
|
+
' path: src/authored/customer.types.ts',
|
|
175
|
+
''
|
|
176
|
+
].join('\n');
|
|
177
|
+
const test = fixture({ policy: bothManual });
|
|
178
|
+
const typePath = (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts/src/authored/customer.types.ts');
|
|
179
|
+
test.contents.set(manualPath, 'export const customerProjection = {}\n');
|
|
180
|
+
test.contents.set(typePath, 'export type Customer = {}\n');
|
|
181
|
+
const result = await test.run();
|
|
182
|
+
expect('errors' in result ? result : result.value.written).toEqual([paths.source]);
|
|
183
|
+
expect(test.writes.map(item => item.path)).toEqual([paths.source]);
|
|
184
|
+
expect(test.contents.get(manualPath)).toEqual('export const customerProjection = {}\n');
|
|
185
|
+
expect(test.contents.get(typePath)).toEqual('export type Customer = {}\n');
|
|
186
|
+
});
|
|
187
|
+
it('rejects a missing manual artefact before making any writes', async () => {
|
|
188
|
+
const test = fixture({ policy: manualPolicy });
|
|
189
|
+
expect(await test.run()).toEqual({ errors: [
|
|
190
|
+
`Manual artefact customers/projectionDefinition does not exist: ${manualPath}`
|
|
191
|
+
] });
|
|
192
|
+
expect(test.writes).toEqual([]);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
describe('errors and validation', () => {
|
|
196
|
+
it('reports missing project names before generating any files', async () => {
|
|
197
|
+
const test = fixture();
|
|
198
|
+
const result = await (0, codegen_1.generateCode)({
|
|
199
|
+
files: {
|
|
200
|
+
read: async (filename) => {
|
|
201
|
+
const content = test.contents.get(filename);
|
|
202
|
+
if (content === undefined)
|
|
203
|
+
throw new Error('ENOENT');
|
|
204
|
+
return content;
|
|
205
|
+
},
|
|
206
|
+
write: async (filename, lines) => { test.writes.push({ path: filename, lines }); },
|
|
207
|
+
exists: async (filename) => test.contents.has(filename)
|
|
208
|
+
},
|
|
209
|
+
catalogue, policy, configDirectory: (0, node_path_1.resolve)('/tmp/codegen-test-definitions/.cobolts'), names: {}
|
|
210
|
+
});
|
|
211
|
+
expect(result).toEqual({ errors: ['Missing TypeScript names for customers'] });
|
|
212
|
+
expect(test.writes).toEqual([]);
|
|
213
|
+
});
|
|
214
|
+
it('does not execute TypeScript or require a projection loader', async () => {
|
|
215
|
+
const test = fixture();
|
|
216
|
+
const result = await test.run();
|
|
217
|
+
expect('errors' in result ? result : result.value.written).toEqual([
|
|
218
|
+
paths.source, paths.definition, paths.projection
|
|
219
|
+
]);
|
|
220
|
+
});
|
|
221
|
+
it('returns copybook parsing errors before writing', async () => {
|
|
222
|
+
const test = fixture({ copybook: 'INVALID TEXT DATA' });
|
|
223
|
+
const result = await test.run();
|
|
224
|
+
expect('errors' in result).toEqual(true);
|
|
225
|
+
expect(test.writes).toEqual([]);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
//# sourceMappingURL=codegen.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.spec.js","sourceRoot":"","sources":["../../src/codegen.spec.ts"],"names":[],"mappings":";;AAAA,yCAAuC;AAEvC,uCAAyD;AAEzD,MAAM,WAAW,GAAG,IAAA,mBAAO,EAAC,+BAA+B,CAAC,CAAA;AAC5D,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,mDAAmD,CAAC,CAAA;AAC9E,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,wDAAwD,CAAC,CAAA;AAChF,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,sDAAsD,CAAC,CAAA;AAChF,MAAM,UAAU,GAAG;IACf,cAAc;IACd,6BAA6B;IAC7B,+BAA+B;IAC/B,EAAE;CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACZ,MAAM,aAAa,GAAG;IAClB,oBAAoB;IACpB,QAAQ;IACR,cAAc;IACd,iBAAiB;IACjB,4BAA4B;IAC5B,EAAE;CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACZ,MAAM,UAAU,GAAG;IACf,SAAS,IAAA,gBAAI,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;IACjE,YAAY;IACZ,6CAA6C;IAC7C,iDAAiD;IACjD,iDAAiD;IACjD,EAAE;CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACZ,MAAM,KAAK,GAA2C;IAClD,SAAS,EAAE,EAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAC;CAC5F,CAAA;AACD,MAAM,KAAK,GAAG;IACV,MAAM,EAAE,IAAA,gBAAI,EAAC,WAAW,EAAE,2CAA2C,CAAC;IACtE,UAAU,EAAE,IAAA,gBAAI,EAAC,WAAW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,EAAE,KAAK,EAAE,EAAE;aACnG,CAAC,CAAA;YACF,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,CAAC,wCAAwC,CAAC,EAAC,CAAC,CAAA;YAC5E,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACnC,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;YACxE,MAAM,IAAI,GAAG,OAAO,EAAE,CAAA;YACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;YAC/B,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;gBAC/D,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU;aACnD,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;YAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,EAAC,QAAQ,EAAE,mBAAmB,EAAC,CAAC,CAAA;YACrD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;YAC/B,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACnC,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/codegen",
|
|
3
3
|
"description": "Orchestrates source generation from COBOL copybooks through a shared in-memory default projection",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index",
|
|
7
7
|
"browserslist": {
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
]
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@cobol-ts/file-catalogue": "0.0.
|
|
21
|
-
"@cobol-ts/files": "0.0.
|
|
22
|
-
"@cobol-ts/copybook": "0.0.
|
|
23
|
-
"@cobol-ts/copybook-typescript": "0.0.
|
|
24
|
-
"@cobol-ts/default-projection-typescript": "0.0.
|
|
25
|
-
"@cobol-ts/projection-typescript": "0.0.
|
|
26
|
-
"@cobol-ts/errors": "0.0.
|
|
20
|
+
"@cobol-ts/file-catalogue": "0.0.4",
|
|
21
|
+
"@cobol-ts/files": "0.0.4",
|
|
22
|
+
"@cobol-ts/copybook": "0.0.4",
|
|
23
|
+
"@cobol-ts/copybook-typescript": "0.0.4",
|
|
24
|
+
"@cobol-ts/default-projection-typescript": "0.0.4",
|
|
25
|
+
"@cobol-ts/projection-typescript": "0.0.4",
|
|
26
|
+
"@cobol-ts/errors": "0.0.4"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"typescript": "^5.2.2",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"dist/index.js",
|
|
54
54
|
"dist/index.d.ts",
|
|
55
55
|
"dist/src/",
|
|
56
|
-
"build/"
|
|
56
|
+
"build/",
|
|
57
|
+
"dist/**/*"
|
|
57
58
|
],
|
|
58
59
|
"keywords": [
|
|
59
60
|
"indexing"
|