@cobol-ts/cobolts 0.0.0-stage → 0.0.2

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.
Files changed (53) hide show
  1. package/README.md +71 -2
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +19 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/bin.d.ts +2 -0
  6. package/dist/src/bin.js +9 -0
  7. package/dist/src/bin.js.map +1 -0
  8. package/dist/src/cli.d.ts +3 -0
  9. package/dist/src/cli.integration.spec.d.ts +1 -0
  10. package/dist/src/cli.integration.spec.js +244 -0
  11. package/dist/src/cli.integration.spec.js.map +1 -0
  12. package/dist/src/cli.js +37 -0
  13. package/dist/src/cli.js.map +1 -0
  14. package/dist/src/cli.spec.d.ts +1 -0
  15. package/dist/src/cli.spec.js +192 -0
  16. package/dist/src/cli.spec.js.map +1 -0
  17. package/dist/src/commands/config.files.d.ts +3 -0
  18. package/dist/src/commands/config.files.js +10 -0
  19. package/dist/src/commands/config.files.js.map +1 -0
  20. package/dist/src/commands/config.list.d.ts +3 -0
  21. package/dist/src/commands/config.list.js +11 -0
  22. package/dist/src/commands/config.list.js.map +1 -0
  23. package/dist/src/commands/config.validate.d.ts +3 -0
  24. package/dist/src/commands/config.validate.js +14 -0
  25. package/dist/src/commands/config.validate.js.map +1 -0
  26. package/dist/src/commands/config.view.d.ts +3 -0
  27. package/dist/src/commands/config.view.js +11 -0
  28. package/dist/src/commands/config.view.js.map +1 -0
  29. package/dist/src/commands/display.d.ts +4 -0
  30. package/dist/src/commands/display.js +29 -0
  31. package/dist/src/commands/display.js.map +1 -0
  32. package/dist/src/commands/generate.all.d.ts +3 -0
  33. package/dist/src/commands/generate.all.js +8 -0
  34. package/dist/src/commands/generate.all.js.map +1 -0
  35. package/dist/src/commands/generate.copybook.d.ts +3 -0
  36. package/dist/src/commands/generate.copybook.js +8 -0
  37. package/dist/src/commands/generate.copybook.js.map +1 -0
  38. package/dist/src/commands/generate.d.ts +4 -0
  39. package/dist/src/commands/generate.js +20 -0
  40. package/dist/src/commands/generate.js.map +1 -0
  41. package/dist/src/commands/generate.projection.d.ts +3 -0
  42. package/dist/src/commands/generate.projection.js +8 -0
  43. package/dist/src/commands/generate.projection.js.map +1 -0
  44. package/dist/src/commands/generate.projectionDefn.d.ts +3 -0
  45. package/dist/src/commands/generate.projectionDefn.js +8 -0
  46. package/dist/src/commands/generate.projectionDefn.js.map +1 -0
  47. package/dist/src/context.d.ts +30 -0
  48. package/dist/src/context.js +90 -0
  49. package/dist/src/context.js.map +1 -0
  50. package/dist/src/context.spec.d.ts +1 -0
  51. package/dist/src/context.spec.js +35 -0
  52. package/dist/src/context.spec.js.map +1 -0
  53. package/package.json +68 -3
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
- # Temporary Holding Version
1
+ # cobolts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Commander-based CLI for viewing file configurations and generating TypeScript source. It uses `@cobol-ts/codegen` and never loads or executes generated TypeScript.
4
+
5
+ ## Layout
6
+
7
+ ```text
8
+ example/
9
+ definitions/
10
+ .cobolts/
11
+ files.yaml
12
+ generation.yaml
13
+ copybooks/
14
+ CUSTOMER.cpy
15
+ application/
16
+ src/generated/
17
+ ```
18
+
19
+ The closest `.cobolts` directory found by walking upwards from the current working directory is the **configuration directory**. It is discovered, not configured. `files.yaml` contains a `root` and `files` map; `generation.yaml` contains a separate `root`, filename templates, optional manual overrides, and code-generation naming. Relative roots are interpreted from `.cobolts` and may point into separate workspace packages; absolute roots are also permitted.
20
+
21
+ Source filenames are relative to `files.root`; generated filenames are relative to `generation.root`. Manual override paths are interpreted relative to `.cobolts`.
22
+
23
+ ## Commands
24
+
25
+ ```text
26
+ cobolts -d ./examples/example/definitions config files
27
+ cobolts config files
28
+ cobolts config list
29
+ cobolts config view
30
+ cobolts config validate
31
+ cobolts generate all [logicalName]
32
+ cobolts generate copybook [logicalName]
33
+ cobolts generate projectionDefn [logicalName]
34
+ cobolts generate projection [logicalName]
35
+ ```
36
+
37
+ `-d <path>` / `--directory <path>` sets the starting directory of upward discovery (default: current working directory). The existing `--root <directory>` option remains available for compatibility. `--catalogue` and `--policy` specify alternative configuration filenames relative to `.cobolts`.
38
+
39
+ For each COBOL logical file, provide the declaration and export names under `names` in `generation.yaml`:
40
+
41
+ ```yaml
42
+ names:
43
+ customers:
44
+ source: CustomerRecordCB
45
+ projection: Customer
46
+ variable: customerProjection
47
+ ```
48
+
49
+ In the monorepo, definitions tests generate and assert source text before application tests compile and exercise those generated files.
50
+
51
+ ## Display data (no generated TypeScript)
52
+
53
+ Bind physical data files separately in `.cobolts/data.yaml`:
54
+
55
+ ```yaml
56
+ root: ../data
57
+ files:
58
+ customers: customers.fb
59
+ customerPreferences: customer-preferences.fb
60
+ ```
61
+
62
+ Examples:
63
+
64
+ ```bash
65
+ cobolts -d modules/examples/example/definitions display customers
66
+ cobolts -d modules/examples/example/definitions display customers --count 2
67
+ cobolts -d modules/examples/example/definitions display customers --all --raw
68
+ cobolts -d modules/examples/example/definitions display customers --skip 1 --count 1
69
+ cobolts -d modules/examples/example/definitions display customers --input ./another-customers.fb
70
+ ```
71
+
72
+ Normally stdout begins with `# <physical-filename>` followed by JSONL. `--raw` suppresses that header for piping into JSONL tools. The command constructs a default projection in memory from the copybook, reads the configured data and streams one line per record. `generation.yaml` and generated `.ts` files are not used. The `config list` and `config view` commands include `data.yaml` when it exists; `config validate` validates the bindings and checks configured input files exist.
@@ -0,0 +1,2 @@
1
+ export * from './src/cli';
2
+ export * from './src/context';
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./src/cli"), exports);
18
+ __exportStar(require("./src/context"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,gDAA6B"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const cli_1 = require("./cli");
5
+ (0, cli_1.createCoboltsCommand)().parseAsync(process.argv).catch((error) => {
6
+ console.error(error instanceof Error ? error.message : String(error));
7
+ process.exitCode = 1;
8
+ });
9
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../../src/bin.ts"],"names":[],"mappings":";;;AACA,+BAA0C;AAE1C,IAAA,0BAAoB,GAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACrE,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACrE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;AACxB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ import { type CliServices } from './context';
3
+ export declare function createCoboltsCommand(services?: CliServices): Command;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const promises_1 = require("node:fs/promises");
4
+ const node_os_1 = require("node:os");
5
+ const node_path_1 = require("node:path");
6
+ const cli_1 = require("./cli");
7
+ const context_1 = require("./context");
8
+ const exampleDefinitions = (0, node_path_1.resolve)(__dirname, '../../../examples/example/definitions');
9
+ const exampleApplication = (0, node_path_1.resolve)(__dirname, '../../../examples/example/application');
10
+ const logicalNames = ['customers', 'customerPreferences'];
11
+ const artefactNames = logicalNames.flatMap(name => [
12
+ `${name}.copybook.types.ts`,
13
+ `${name}.projection.ts`,
14
+ `${name}.projection.types.ts`
15
+ ]);
16
+ async function createProject() {
17
+ const root = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cobolts-cli-'));
18
+ const config = (0, node_path_1.join)(root, '.cobolts');
19
+ const nested = (0, node_path_1.join)(root, 'src', 'nested');
20
+ await (0, promises_1.mkdir)(config, { recursive: true });
21
+ await (0, promises_1.mkdir)((0, node_path_1.join)(root, 'copybooks'), { recursive: true });
22
+ await (0, promises_1.mkdir)((0, node_path_1.join)(root, 'data'), { recursive: true });
23
+ await (0, promises_1.mkdir)(nested, { recursive: true });
24
+ const catalogue = (0, node_path_1.join)(config, 'files.yaml');
25
+ const policy = (0, node_path_1.join)(config, 'generation.yaml');
26
+ const data = (0, node_path_1.join)(config, 'data.yaml');
27
+ const copybooks = ['CUSTOMER.cpy', 'CUSTOMER-PREFERENCES.cpy'].map(name => (0, node_path_1.join)(root, 'copybooks', name));
28
+ await (0, promises_1.copyFile)((0, node_path_1.join)(exampleDefinitions, '.cobolts', 'files.yaml'), catalogue);
29
+ await (0, promises_1.copyFile)((0, node_path_1.join)(exampleDefinitions, '.cobolts', 'data.yaml'), data);
30
+ for (const filename of ['customers.fb', 'customer-preferences.fb']) {
31
+ await (0, promises_1.copyFile)((0, node_path_1.join)(exampleDefinitions, 'data', filename), (0, node_path_1.join)(root, 'data', filename));
32
+ }
33
+ await (0, promises_1.writeFile)(policy, (await (0, promises_1.readFile)((0, node_path_1.join)(exampleDefinitions, '.cobolts', 'generation.yaml'), 'utf8')).replace('root: ../../application/src/generated', 'root: ../src/generated'), 'utf8');
34
+ for (const filename of copybooks) {
35
+ await (0, promises_1.copyFile)((0, node_path_1.join)(exampleDefinitions, 'copybooks', (0, node_path_1.basename)(filename)), filename);
36
+ }
37
+ return { root, config, nested, catalogue, policy, data, copybooks };
38
+ }
39
+ async function run(root, ...args) {
40
+ const output = [];
41
+ const command = (0, cli_1.createCoboltsCommand)({ ...context_1.nodeCliServices, output: line => { output.push(line); } });
42
+ await command.parseAsync(['-d', root, ...args], { from: 'user' });
43
+ return output;
44
+ }
45
+ describe('cobolts with a real .cobolts project', () => {
46
+ let project;
47
+ beforeEach(async () => { project = await createProject(); });
48
+ afterEach(async () => { await (0, promises_1.rm)(project.root, { recursive: true, force: true }); });
49
+ describe('configuration discovery', () => {
50
+ it('resolves the short -d option from a nested directory', async () => {
51
+ expect(await run(project.nested, 'config', 'list')).toEqual([
52
+ project.catalogue, project.policy, project.data, ...project.copybooks
53
+ ]);
54
+ });
55
+ it('resolves the long --directory option from a nested directory', async () => {
56
+ const output = [];
57
+ const command = (0, cli_1.createCoboltsCommand)({ ...context_1.nodeCliServices, output: line => { output.push(line); } });
58
+ await command.parseAsync(['--directory', project.nested, 'config', 'list'], { from: 'user' });
59
+ expect(output).toEqual([project.catalogue, project.policy, project.data, ...project.copybooks]);
60
+ });
61
+ it('finds the project from a nested working directory', async () => {
62
+ expect(await (0, context_1.discoverPaths)({ root: project.nested })).toEqual({
63
+ projectRoot: project.root,
64
+ directory: project.config,
65
+ catalogue: project.catalogue,
66
+ policy: project.policy,
67
+ data: project.data
68
+ });
69
+ });
70
+ it('prefers the nearest .cobolts directory', async () => {
71
+ const nearer = (0, node_path_1.join)(project.root, 'src', '.cobolts');
72
+ await (0, promises_1.mkdir)(nearer);
73
+ expect(await (0, context_1.discoverPaths)({ root: project.nested })).toEqual({
74
+ projectRoot: (0, node_path_1.dirname)(nearer),
75
+ directory: nearer,
76
+ catalogue: (0, node_path_1.join)(nearer, 'files.yaml'),
77
+ policy: (0, node_path_1.join)(nearer, 'generation.yaml'),
78
+ data: (0, node_path_1.join)(nearer, 'data.yaml')
79
+ });
80
+ });
81
+ it('reports a missing .cobolts directory', async () => {
82
+ const missing = await (0, promises_1.mkdtemp)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'cobolts-no-config-'));
83
+ try {
84
+ // The temp folder has no .cobolts directory in any parent.
85
+ await expect((0, context_1.discoverPaths)({ root: missing })).rejects.toThrow('Directory ".cobolts" not found');
86
+ }
87
+ finally {
88
+ await (0, promises_1.rm)(missing, { recursive: true, force: true });
89
+ }
90
+ });
91
+ it('honours explicit catalogue and policy paths relative to the project root', async () => {
92
+ expect(await (0, context_1.discoverPaths)({
93
+ root: project.nested,
94
+ catalogue: 'other/files.yaml',
95
+ policy: 'config/output.yaml'
96
+ })).toEqual({
97
+ projectRoot: project.root,
98
+ directory: project.config,
99
+ catalogue: (0, node_path_1.join)(project.config, 'other', 'files.yaml'),
100
+ policy: (0, node_path_1.join)(project.config, 'config', 'output.yaml'),
101
+ data: project.data
102
+ });
103
+ });
104
+ });
105
+ describe('config commands', () => {
106
+ it('prints the complete catalogue with its filename', async () => {
107
+ expect(await run(project.nested, 'config', 'files')).toEqual([
108
+ `${project.catalogue}\n${await (0, promises_1.readFile)(project.catalogue, 'utf8')}`
109
+ ]);
110
+ });
111
+ it('lists both configs followed by each copybook', async () => {
112
+ expect(await run(project.nested, 'config', 'list')).toEqual([
113
+ project.catalogue, project.policy, project.data, ...project.copybooks
114
+ ]);
115
+ });
116
+ it('lists source files even when the generation policy is invalid', async () => {
117
+ await (0, promises_1.writeFile)(project.policy, 'root: [invalid\n', 'utf8');
118
+ expect(await run(project.nested, 'config', 'list')).toEqual([
119
+ project.catalogue, project.policy, project.data, ...project.copybooks
120
+ ]);
121
+ });
122
+ it('views files in exactly the same order as list', async () => {
123
+ const files = [project.catalogue, project.policy, project.data, ...project.copybooks];
124
+ expect(await run(project.nested, 'config', 'view')).toEqual(await Promise.all(files.map(async (filename) => `${filename}\n${await (0, promises_1.readFile)(filename, 'utf8')}`)));
125
+ });
126
+ it('validates the catalogue, generation policy and referenced files', async () => {
127
+ expect(await run(project.nested, 'config', 'validate')).toEqual([
128
+ 'Valid: 2 logical files, 6 artefacts'
129
+ ]);
130
+ });
131
+ it('reports invalid YAML and does not generate output', async () => {
132
+ await (0, promises_1.writeFile)(project.catalogue, 'customers: [unterminated\n', 'utf8');
133
+ await expect(run(project.nested, 'config', 'validate')).rejects.toThrow();
134
+ expect((await (0, promises_1.readdir)(project.root)).sort()).toEqual(['.cobolts', 'copybooks', 'data', 'src']);
135
+ });
136
+ it('rejects a missing copybook rather than reporting valid configuration', async () => {
137
+ await (0, promises_1.rm)(project.copybooks[0]);
138
+ await expect(run(project.nested, 'config', 'validate')).rejects.toThrow();
139
+ });
140
+ });
141
+ describe('generation commands', () => {
142
+ it('generates six TypeScript files using the actual codegen pipeline', async () => {
143
+ const generated = artefactNames.map(filename => (0, node_path_1.join)(project.root, 'src', 'generated', filename));
144
+ expect(await run(project.nested, 'generate', 'all')).toEqual([
145
+ ...generated, 'Generated 6 files'
146
+ ]);
147
+ // Compare complete output with the committed, handwritten integration project's generated contracts.
148
+ const actual = await Promise.all(generated.map(filename => (0, promises_1.readFile)(filename, 'utf8')));
149
+ const expected = await Promise.all(artefactNames.map(filename => (0, promises_1.readFile)((0, node_path_1.join)(exampleApplication, 'src', 'generated', filename), 'utf8')));
150
+ expect(actual).toEqual(expected);
151
+ // Regenerating does not alter the resulting files.
152
+ expect(await run(project.nested, 'generate', 'all')).toEqual([
153
+ ...generated, 'Generated 6 files'
154
+ ]);
155
+ expect(await Promise.all(generated.map(filename => (0, promises_1.readFile)(filename, 'utf8')))).toEqual(expected);
156
+ });
157
+ it('generates only the selected artefact kind for one logical file', async () => {
158
+ const path = (0, node_path_1.join)(project.root, 'src', 'generated', 'customers.copybook.types.ts');
159
+ expect(await run(project.nested, 'generate', 'copybook', 'customers')).toEqual([
160
+ path, 'Generated 1 files'
161
+ ]);
162
+ expect(await (0, promises_1.readdir)((0, node_path_1.dirname)(path))).toEqual(['customers.copybook.types.ts']);
163
+ expect(await (0, promises_1.readFile)(path, 'utf8')).toEqual(await (0, promises_1.readFile)((0, node_path_1.join)(exampleApplication, 'src', 'generated', 'customers.copybook.types.ts'), 'utf8'));
164
+ });
165
+ it.each([
166
+ ['projectionDefn', 'projection.ts'],
167
+ ['projection', 'projection.types.ts']
168
+ ])('generates only %s artefacts for both logical files', async (command, suffix) => {
169
+ const files = logicalNames.map(name => (0, node_path_1.join)(project.root, 'src', 'generated', `${name}.${suffix}`));
170
+ expect(await run(project.nested, 'generate', command)).toEqual([...files, 'Generated 2 files']);
171
+ expect((await (0, promises_1.readdir)((0, node_path_1.dirname)(files[0]))).sort()).toEqual(files.map(filename => (0, node_path_1.basename)(filename)).sort());
172
+ expect(await Promise.all(files.map(filename => (0, promises_1.readFile)(filename, 'utf8')))).toEqual(await Promise.all(files.map(filename => (0, promises_1.readFile)((0, node_path_1.join)(exampleApplication, 'src', 'generated', (0, node_path_1.basename)(filename)), 'utf8'))));
173
+ });
174
+ it('preserves manually owned projection files and generates the remaining artefacts', async () => {
175
+ const manualDefinition = (0, node_path_1.join)(project.root, 'src', 'authored', 'customer.projection.ts');
176
+ const manualType = (0, node_path_1.join)(project.root, 'src', 'authored', 'customer.projection.types.ts');
177
+ await (0, promises_1.mkdir)((0, node_path_1.dirname)(manualDefinition), { recursive: true });
178
+ await (0, promises_1.writeFile)(manualDefinition, 'export const customerProjection = {}\n', 'utf8');
179
+ await (0, promises_1.writeFile)(manualType, 'export type Customer = {}\n', 'utf8');
180
+ await (0, promises_1.writeFile)(project.policy, [
181
+ await (0, promises_1.readFile)(project.policy, 'utf8'),
182
+ 'overrides:',
183
+ ' customers:',
184
+ ' projectionDefinition:',
185
+ ' mode: manual',
186
+ ' path: ../src/authored/customer.projection.ts',
187
+ ' projectionType:',
188
+ ' mode: manual',
189
+ ' path: ../src/authored/customer.projection.types.ts',
190
+ ''
191
+ ].join('\n'), 'utf8');
192
+ const generated = [
193
+ (0, node_path_1.join)(project.root, 'src', 'generated', 'customers.copybook.types.ts'),
194
+ ...artefactNames.slice(3).map(name => (0, node_path_1.join)(project.root, 'src', 'generated', name))
195
+ ];
196
+ expect(await run(project.nested, 'generate', 'all')).toEqual([...generated, 'Generated 4 files']);
197
+ expect(await (0, promises_1.readFile)(manualDefinition, 'utf8')).toEqual('export const customerProjection = {}\n');
198
+ expect(await (0, promises_1.readFile)(manualType, 'utf8')).toEqual('export type Customer = {}\n');
199
+ expect((await (0, promises_1.readdir)((0, node_path_1.join)(project.root, 'src', 'generated'))).sort()).toEqual(generated.map(filename => (0, node_path_1.basename)(filename)).sort());
200
+ });
201
+ it('does not create files for an unknown logical name', async () => {
202
+ await expect(run(project.nested, 'generate', 'all', 'unknown')).rejects.toThrow('Unknown logical file unknown');
203
+ expect((await (0, promises_1.readdir)(project.root)).sort()).toEqual(['.cobolts', 'copybooks', 'data', 'src']);
204
+ });
205
+ });
206
+ });
207
+ describe('cobolts display with real customer fixtures', () => {
208
+ let project;
209
+ beforeEach(async () => { project = await createProject(); });
210
+ afterEach(async () => { await (0, promises_1.rm)(project.root, { recursive: true, force: true }); });
211
+ it('emits the first two customers as JSONL with the source filename header', async () => {
212
+ const output = await run(project.nested, 'display', 'customers', '--count', '2');
213
+ expect(output).toEqual([
214
+ `# ${(0, node_path_1.join)(project.root, 'data/customers.fb')}`,
215
+ JSON.stringify({
216
+ customerId: 1001, customerName: 'ALICE ', contactValue: 'GB0042',
217
+ contactParts: { region: 'GB', number: '0042' }, orderCount: 1,
218
+ orders: [{ productCode: 'A001', productParts: { productCategory: 'A0', productNumber: '01' }, quantity: 2 }]
219
+ }),
220
+ JSON.stringify({
221
+ customerId: 1002, customerName: 'BOB ', contactValue: 'US1234',
222
+ contactParts: { region: 'US', number: '1234' }, orderCount: 3,
223
+ orders: [
224
+ { productCode: 'B001', productParts: { productCategory: 'B0', productNumber: '01' }, quantity: 1 },
225
+ { productCode: 'C202', productParts: { productCategory: 'C2', productNumber: '02' }, quantity: 3 },
226
+ { productCode: 'D303', productParts: { productCategory: 'D3', productNumber: '03' }, quantity: 5 }
227
+ ]
228
+ })
229
+ ]);
230
+ });
231
+ it('emits only JSONL, including zero active orders, with --raw --all', async () => {
232
+ const output = await run(project.nested, 'display', 'customers', '--raw', '--all');
233
+ expect(output.length).toEqual(3);
234
+ expect(JSON.parse(output[2])).toEqual({
235
+ customerId: 1003, customerName: 'CARA ', contactValue: 'DE5678',
236
+ contactParts: { region: 'DE', number: '5678' }, orderCount: 0, orders: []
237
+ });
238
+ });
239
+ it('reports invalid data bindings through config validate', async () => {
240
+ await (0, promises_1.writeFile)(project.data, 'root: ../data\nfiles:\n missing: missing.fb\n');
241
+ await expect(run(project.nested, 'config', 'validate')).rejects.toThrow('Data configuration.files.missing: Unknown logical file');
242
+ });
243
+ });
244
+ //# sourceMappingURL=cli.integration.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.integration.spec.js","sourceRoot":"","sources":["../../src/cli.integration.spec.ts"],"names":[],"mappings":";;AAAA,+CAA2F;AAC3F,qCAA8B;AAC9B,yCAA0D;AAC1D,+BAA0C;AAC1C,uCAAwD;AAExD,MAAM,kBAAkB,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,uCAAuC,CAAC,CAAA;AACtF,MAAM,kBAAkB,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,uCAAuC,CAAC,CAAA;AACtF,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,qBAAqB,CAAU,CAAA;AAClE,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,C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C,kEAAkE,EAAE,KAAK,IAAI,EAAE;QAC9E,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QAClF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YACnC,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ;YACtE,YAAY,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;SAC1E,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACnE,MAAM,IAAA,oBAAS,EAAC,OAAO,CAAC,IAAI,EAAE,gDAAgD,CAAC,CAAA;QAC/E,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,wDAAwD,CAAC,CAAA;IACrI,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCoboltsCommand = createCoboltsCommand;
4
+ const commander_1 = require("commander");
5
+ const context_1 = require("./context");
6
+ const config_files_1 = require("./commands/config.files");
7
+ const config_list_1 = require("./commands/config.list");
8
+ const config_view_1 = require("./commands/config.view");
9
+ const config_validate_1 = require("./commands/config.validate");
10
+ const generate_all_1 = require("./commands/generate.all");
11
+ const generate_copybook_1 = require("./commands/generate.copybook");
12
+ const generate_projectionDefn_1 = require("./commands/generate.projectionDefn");
13
+ const generate_projection_1 = require("./commands/generate.projection");
14
+ const display_1 = require("./commands/display");
15
+ function createCoboltsCommand(services = context_1.nodeCliServices) {
16
+ const root = new commander_1.Command('cobolts')
17
+ .description('COBOL, CSV and JSONL file catalogue and TypeScript code generation')
18
+ .option('-d, --directory <path>', 'Directory from which to search upwards for .cobolts')
19
+ .option('--root <directory>', 'Legacy alias for the discovery starting directory')
20
+ .option('--catalogue <filename>', 'Catalogue path relative to the discovered .cobolts directory')
21
+ .option('--policy <filename>', 'Generation policy path relative to the discovered .cobolts directory')
22
+ .option('--data <filename>', 'Data configuration path relative to the discovered .cobolts directory');
23
+ const options = () => root.opts();
24
+ const config = root.command('config').description('Inspect and validate source configuration');
25
+ (0, config_files_1.addConfigFiles)(config, services, options);
26
+ (0, config_list_1.addConfigList)(config, services, options);
27
+ (0, config_view_1.addConfigView)(config, services, options);
28
+ (0, config_validate_1.addConfigValidate)(config, services, options);
29
+ const generate = root.command('generate').description('Generate TypeScript artefacts');
30
+ (0, generate_all_1.addGenerateAll)(generate, services, options);
31
+ (0, generate_copybook_1.addGenerateCopybook)(generate, services, options);
32
+ (0, generate_projectionDefn_1.addGenerateProjectionDefn)(generate, services, options);
33
+ (0, generate_projection_1.addGenerateProjection)(generate, services, options);
34
+ (0, display_1.addDisplay)(root, services, options);
35
+ return root;
36
+ }
37
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";;AAYA,oDAqBC;AAjCD,yCAAiC;AACjC,uCAA4E;AAC5E,0DAAsD;AACtD,wDAAoD;AACpD,wDAAoD;AACpD,gEAA4D;AAC5D,0DAAsD;AACtD,oEAAgE;AAChE,gFAA4E;AAC5E,wEAAoE;AACpE,gDAA6C;AAE7C,SAAgB,oBAAoB,CAAC,WAAwB,yBAAe;IACxE,MAAM,IAAI,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC;SAC9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{};
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("./cli");
4
+ const paths = {
5
+ projectRoot: '/project',
6
+ directory: '/project/.cobolts',
7
+ catalogue: '/project/.cobolts/files.yaml',
8
+ policy: '/project/.cobolts/generation.yaml',
9
+ data: '/project/.cobolts/data.yaml'
10
+ };
11
+ function fixture(overrides = {}) {
12
+ const printed = [];
13
+ const resolutions = [];
14
+ const generations = [];
15
+ const reads = [];
16
+ const filenames = [paths.catalogue, paths.policy, '/project/.cobolts/copybooks/CUSTOMER.cpy'];
17
+ const services = {
18
+ output: message => { printed.push(message); },
19
+ read: async (filename) => {
20
+ reads.push(filename);
21
+ if (overrides.readError)
22
+ throw new Error(overrides.readError);
23
+ return `contents:${filename}`;
24
+ },
25
+ paths: async (options) => {
26
+ resolutions.push(options);
27
+ if (overrides.pathsError)
28
+ throw new Error(overrides.pathsError);
29
+ return paths;
30
+ },
31
+ list: async () => {
32
+ if (overrides.listError)
33
+ throw new Error(overrides.listError);
34
+ return filenames;
35
+ },
36
+ validateData: async () => undefined,
37
+ display: async (_paths, options) => ({
38
+ filename: '/project/data/customers.fb',
39
+ lines: (async function* () { yield JSON.stringify({ id: 1001 }); yield JSON.stringify({ id: 1002 }); })()
40
+ }),
41
+ manifest: async () => {
42
+ if (overrides.manifestError)
43
+ throw new Error(overrides.manifestError);
44
+ return { sources: [{ logicalName: 'customers', definition: { type: 'cobol', copybook: 'copybooks/CUSTOMER.cpy' } }], artefacts: [] };
45
+ },
46
+ generate: async (_paths, selection) => {
47
+ generations.push(selection);
48
+ if (overrides.generateError)
49
+ throw new Error(overrides.generateError);
50
+ return { manifest: { sources: [], artefacts: [] }, written: ['/project/src/generated/customers.ts'] };
51
+ }
52
+ };
53
+ return { printed, resolutions, generations, reads, filenames, services };
54
+ }
55
+ async function run(services, ...args) {
56
+ await (0, cli_1.createCoboltsCommand)(services).parseAsync(args, { from: 'user' });
57
+ }
58
+ describe('cobolts config', () => {
59
+ describe('files', () => {
60
+ it('prints the catalogue filename and its complete contents', async () => {
61
+ const f = fixture();
62
+ await run(f.services, 'config', 'files');
63
+ expect(f.printed).toEqual([`${paths.catalogue}\ncontents:${paths.catalogue}`]);
64
+ expect(f.reads).toEqual([paths.catalogue]);
65
+ expect(f.generations).toEqual([]);
66
+ });
67
+ it('reports a catalogue read failure without printing partial content', async () => {
68
+ const f = fixture({ readError: 'Access denied' });
69
+ await expect(run(f.services, 'config', 'files')).rejects.toThrow('Access denied');
70
+ expect(f.printed).toEqual([]);
71
+ expect(f.reads).toEqual([paths.catalogue]);
72
+ });
73
+ });
74
+ describe('list', () => {
75
+ it('lists configurations followed by copybooks in their resolved order', async () => {
76
+ const f = fixture();
77
+ await run(f.services, 'config', 'list');
78
+ expect(f.printed).toEqual(f.filenames);
79
+ expect(f.reads).toEqual([]);
80
+ });
81
+ it('reports discovery failures without printing filenames', async () => {
82
+ const f = fixture({ pathsError: 'Directory ".cobolts" not found' });
83
+ await expect(run(f.services, 'config', 'list')).rejects.toThrow('Directory ".cobolts" not found');
84
+ expect(f.printed).toEqual([]);
85
+ });
86
+ });
87
+ describe('view', () => {
88
+ it('views all listed files in the same order with their full contents', async () => {
89
+ const f = fixture();
90
+ await run(f.services, 'config', 'view');
91
+ expect(f.printed).toEqual(f.filenames.map(path => `${path}\ncontents:${path}`));
92
+ expect(f.reads).toEqual(f.filenames);
93
+ });
94
+ it('does not read anything if listing the files fails', async () => {
95
+ const f = fixture({ listError: 'Invalid catalogue' });
96
+ await expect(run(f.services, 'config', 'view')).rejects.toThrow('Invalid catalogue');
97
+ expect(f.printed).toEqual([]);
98
+ expect(f.reads).toEqual([]);
99
+ });
100
+ });
101
+ describe('validate', () => {
102
+ it('validates configuration and reads referenced files without generating', async () => {
103
+ const f = fixture();
104
+ await run(f.services, 'config', 'validate');
105
+ expect(f.printed).toEqual(['Valid: 1 logical files, 0 artefacts']);
106
+ expect(f.reads).toEqual(f.filenames);
107
+ expect(f.generations).toEqual([]);
108
+ });
109
+ it('propagates manifest validation errors without claiming success', async () => {
110
+ const f = fixture({ manifestError: 'Invalid generation policy' });
111
+ await expect(run(f.services, 'config', 'validate')).rejects.toThrow('Invalid generation policy');
112
+ expect(f.printed).toEqual([]);
113
+ expect(f.reads).toEqual([]);
114
+ });
115
+ it('rejects unreadable referenced copybooks without claiming success', async () => {
116
+ const f = fixture({ readError: 'Missing copybook' });
117
+ await expect(run(f.services, 'config', 'validate')).rejects.toThrow('Missing copybook');
118
+ expect(f.printed).toEqual([]);
119
+ expect(f.generations).toEqual([]);
120
+ });
121
+ });
122
+ });
123
+ describe('cobolts generate', () => {
124
+ describe('artefact selection', () => {
125
+ it.each([
126
+ ['all', undefined],
127
+ ['copybook', 'copybookType'],
128
+ ['projectionDefn', 'projectionDefinition'],
129
+ ['projection', 'projectionType']
130
+ ])('%s selects the corresponding artefact kind', async (command, kind) => {
131
+ const f = fixture();
132
+ await run(f.services, 'generate', command);
133
+ expect(f.generations).toEqual([kind ? { artefactKinds: [kind] } : {}]);
134
+ expect(f.printed).toEqual(['/project/src/generated/customers.ts', 'Generated 1 files']);
135
+ });
136
+ it.each([
137
+ ['all', {}],
138
+ ['copybook', { artefactKinds: ['copybookType'] }],
139
+ ['projectionDefn', { artefactKinds: ['projectionDefinition'] }],
140
+ ['projection', { artefactKinds: ['projectionType'] }]
141
+ ])('%s selects one logical file', async (command, selection) => {
142
+ const f = fixture();
143
+ await run(f.services, 'generate', command, 'customers');
144
+ expect(f.generations).toEqual([{ logicalNames: ['customers'], ...selection }]);
145
+ });
146
+ it.each([
147
+ ['-d', '../project'],
148
+ ['--directory', '/project']
149
+ ])('passes %s as the starting directory for discovery', async (option, directory) => {
150
+ const f = fixture();
151
+ await run(f.services, option, directory, 'config', 'list');
152
+ expect(f.resolutions).toEqual([{ directory }]);
153
+ expect(f.printed).toEqual(f.filenames);
154
+ });
155
+ it('uses global root and configuration overrides', async () => {
156
+ const f = fixture();
157
+ await run(f.services, '--root', '/project', '--catalogue', 'elsewhere/files.yaml', '--policy', 'different.yaml', 'generate', 'all');
158
+ expect(f.resolutions).toEqual([{ root: '/project', catalogue: 'elsewhere/files.yaml', policy: 'different.yaml' }]);
159
+ });
160
+ });
161
+ describe('failure handling', () => {
162
+ it('propagates generation failures and does not print a success summary', async () => {
163
+ const f = fixture({ generateError: 'Unknown logical file missing' });
164
+ await expect(run(f.services, 'generate', 'all', 'missing')).rejects.toThrow('Unknown logical file missing');
165
+ expect(f.generations).toEqual([{ logicalNames: ['missing'] }]);
166
+ expect(f.printed).toEqual([]);
167
+ });
168
+ it('does not invoke generation if configuration discovery fails', async () => {
169
+ const f = fixture({ pathsError: 'Directory ".cobolts" not found' });
170
+ await expect(run(f.services, 'generate', 'copybook')).rejects.toThrow('Directory ".cobolts" not found');
171
+ expect(f.generations).toEqual([]);
172
+ expect(f.printed).toEqual([]);
173
+ });
174
+ });
175
+ });
176
+ describe('cobolts display', () => {
177
+ it('prints a filename header followed by JSONL records by default', async () => {
178
+ const f = fixture();
179
+ await run(f.services, 'display', 'customers');
180
+ expect(f.printed).toEqual([
181
+ '# /project/data/customers.fb',
182
+ '{"id":1001}',
183
+ '{"id":1002}'
184
+ ]);
185
+ });
186
+ it('omits the filename header with --raw', async () => {
187
+ const f = fixture();
188
+ await run(f.services, 'display', 'customers', '--raw');
189
+ expect(f.printed).toEqual(['{"id":1001}', '{"id":1002}']);
190
+ });
191
+ });
192
+ //# sourceMappingURL=cli.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.spec.js","sourceRoot":"","sources":["../../src/cli.spec.ts"],"names":[],"mappings":";;AAAA,+BAA0C;AAI1C,MAAM,KAAK,GAAa;IACpB,WAAW,EAAE,UAAU;IACvB,SAAS,EAAE,mBAAmB;IAC9B,SAAS,EAAE,8BAA8B;IACzC,MAAM,EAAE,mCAAmC;IAC3C,IAAI,EAAE,6BAA6B;CACtC,CAAA;AAUD,SAAS,OAAO,CAAC,YAA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AAC,UAAU,EAAE,gCAAgC,EAAC,CAAC,CAAA;YACjE,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAA;YACvG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YACjC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA;AAGF,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,+DAA+D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,CAAC,GAAG,OAAO,EAAE,CAAA;QACnB,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;QAC7C,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;YACtB,8BAA8B;YAC9B,aAAa;YACb,aAAa;SAChB,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,CAAC,GAAG,OAAO,EAAE,CAAA;QACnB,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;QACtD,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addConfigFiles(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addConfigFiles = addConfigFiles;
4
+ function addConfigFiles(command, services, options) {
5
+ command.command('files').description('Print the file catalogue with its filename').action(async () => {
6
+ const paths = await services.paths(options());
7
+ services.output(`${paths.catalogue}\n${await services.read(paths.catalogue)}`);
8
+ });
9
+ }
10
+ //# sourceMappingURL=config.files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.files.js","sourceRoot":"","sources":["../../../src/commands/config.files.ts"],"names":[],"mappings":";;AAGA,wCAKC;AALD,SAAgB,cAAc,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IAC7F,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,4CAA4C,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACjG,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7C,QAAQ,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,KAAK,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;IAClF,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addConfigList(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addConfigList = addConfigList;
4
+ function addConfigList(command, services, options) {
5
+ command.command('list').description('List configuration files and referenced copybooks').action(async () => {
6
+ const paths = await services.paths(options());
7
+ for (const filename of await services.list(paths))
8
+ services.output(filename);
9
+ });
10
+ }
11
+ //# sourceMappingURL=config.list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.list.js","sourceRoot":"","sources":["../../../src/commands/config.list.ts"],"names":[],"mappings":";;AAGA,sCAKC;AALD,SAAgB,aAAa,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IAC5F,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,mDAAmD,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACvG,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7C,KAAK,MAAM,QAAQ,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAChF,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addConfigValidate(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addConfigValidate = addConfigValidate;
4
+ function addConfigValidate(command, services, options) {
5
+ command.command('validate').description('Validate the catalogue and generation policy').action(async () => {
6
+ const paths = await services.paths(options());
7
+ const manifest = await services.manifest(paths);
8
+ await services.validateData(paths);
9
+ for (const filename of await services.list(paths))
10
+ await services.read(filename);
11
+ services.output(`Valid: ${manifest.sources.length} logical files, ${manifest.artefacts.length} artefacts`);
12
+ });
13
+ }
14
+ //# sourceMappingURL=config.validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.validate.js","sourceRoot":"","sources":["../../../src/commands/config.validate.ts"],"names":[],"mappings":";;AAGA,8CAQC;AARD,SAAgB,iBAAiB,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IAChG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,8CAA8C,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACtG,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7C,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC/C,MAAM,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QAClC,KAAK,MAAM,QAAQ,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChF,QAAQ,CAAC,MAAM,CAAC,UAAU,QAAQ,CAAC,OAAO,CAAC,MAAM,mBAAmB,QAAQ,CAAC,SAAS,CAAC,MAAM,YAAY,CAAC,CAAA;IAC9G,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addConfigView(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addConfigView = addConfigView;
4
+ function addConfigView(command, services, options) {
5
+ command.command('view').description('Print configuration files and referenced copybooks, in list order').action(async () => {
6
+ const paths = await services.paths(options());
7
+ for (const filename of await services.list(paths))
8
+ services.output(`${filename}\n${await services.read(filename)}`);
9
+ });
10
+ }
11
+ //# sourceMappingURL=config.view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.view.js","sourceRoot":"","sources":["../../../src/commands/config.view.ts"],"names":[],"mappings":";;AAGA,sCAKC;AALD,SAAgB,aAAa,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IAC5F,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,mEAAmE,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACvH,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7C,KAAK,MAAM,QAAQ,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,QAAQ,KAAK,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACvH,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ /** Print one optional filename header followed by one JSON value per line. */
4
+ export declare function addDisplay(root: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addDisplay = addDisplay;
4
+ /** Print one optional filename header followed by one JSON value per line. */
5
+ function addDisplay(root, services, options) {
6
+ root.command('display')
7
+ .description('Stream a configured physical data file as JSONL')
8
+ .argument('<logical-name>', 'Logical filename from files.yaml')
9
+ .option('-n, --count <number>', 'Maximum number of records to display (default 10)')
10
+ .option('-a, --all', 'Display all records')
11
+ .option('-s, --skip <number>', 'Skip the first N records (default 0)')
12
+ .option('-r, --raw', 'Omit the filename header; stdout is strict JSONL')
13
+ .option('-i, --input <filename>', 'Override the physical filename from data.yaml')
14
+ .action(async (logicalName, flags) => {
15
+ const paths = await services.paths(options());
16
+ const result = await services.display(paths, {
17
+ logicalName,
18
+ ...(flags.count !== undefined ? { count: Number(flags.count) } : {}),
19
+ ...(flags.skip !== undefined ? { skip: Number(flags.skip) } : {}),
20
+ ...(flags.all ? { all: true } : {}),
21
+ ...(flags.input !== undefined ? { input: flags.input } : {})
22
+ });
23
+ if (!flags.raw)
24
+ services.output(`# ${result.filename}`);
25
+ for await (const line of result.lines)
26
+ services.output(line);
27
+ });
28
+ }
29
+ //# sourceMappingURL=display.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display.js","sourceRoot":"","sources":["../../../src/commands/display.ts"],"names":[],"mappings":";;AAYA,gCAqBC;AAtBD,8EAA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AAI,CAAC,KAAK,CAAC,GAAG;YAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;QACvD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;YAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;AACV,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addGenerateAll(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGenerateAll = addGenerateAll;
4
+ const generate_1 = require("./generate");
5
+ function addGenerateAll(command, services, options) {
6
+ (0, generate_1.addGenerateCommand)(command, 'all', 'Generate all applicable artefacts', services, options, undefined);
7
+ }
8
+ //# sourceMappingURL=generate.all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.all.js","sourceRoot":"","sources":["../../../src/commands/generate.all.ts"],"names":[],"mappings":";;AAIA,wCAEC;AAJD,yCAA6C;AAE7C,SAAgB,cAAc,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IAC7F,IAAA,6BAAkB,EAAC,OAAO,EAAE,KAAK,EAAE,mCAAmC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AACzG,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addGenerateCopybook(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGenerateCopybook = addGenerateCopybook;
4
+ const generate_1 = require("./generate");
5
+ function addGenerateCopybook(command, services, options) {
6
+ (0, generate_1.addGenerateCommand)(command, 'copybook', 'Generate source-side copybook types', services, options, 'copybookType');
7
+ }
8
+ //# sourceMappingURL=generate.copybook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.copybook.js","sourceRoot":"","sources":["../../../src/commands/generate.copybook.ts"],"names":[],"mappings":";;AAIA,kDAEC;AAJD,yCAA6C;AAE7C,SAAgB,mBAAmB,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IAClG,IAAA,6BAAkB,EAAC,OAAO,EAAE,UAAU,EAAE,qCAAqC,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;AACrH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { ArtefactKind } from '@cobol-ts/file-catalogue';
3
+ import type { CliServices, CliOptions } from '../context';
4
+ export declare function addGenerateCommand(parent: Command, name: string, description: string, services: CliServices, options: () => CliOptions, kind?: ArtefactKind): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGenerateCommand = addGenerateCommand;
4
+ function addGenerateCommand(parent, name, description, services, options, kind) {
5
+ parent.command(name)
6
+ .description(description)
7
+ .argument('[logicalName]', 'Generate for one logical file; omit for all')
8
+ .action(async (logicalName) => {
9
+ const paths = await services.paths(options());
10
+ const selection = {
11
+ ...(logicalName ? { logicalNames: [logicalName] } : {}),
12
+ ...(kind ? { artefactKinds: [kind] } : {})
13
+ };
14
+ const result = await services.generate(paths, selection);
15
+ for (const filename of result.written)
16
+ services.output(filename);
17
+ services.output(`Generated ${result.written.length} files`);
18
+ });
19
+ }
20
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/generate.ts"],"names":[],"mappings":";;AAIA,gDAiBC;AAjBD,SAAgB,kBAAkB,CAC9B,MAAe,EAAE,IAAY,EAAE,WAAmB,EAClD,QAAqB,EAAE,OAAyB,EAAE,IAAmB;IAErE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;SACf,WAAW,CAAC,WAAW,CAAC;SACxB,QAAQ,CAAC,eAAe,EAAE,6CAA6C,CAAC;SACxE,MAAM,CAAC,KAAK,EAAE,WAA+B,EAAE,EAAE;QAC9C,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7C,MAAM,SAAS,GAAG;YACd,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,YAAY,EAAE,CAAC,WAAW,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,aAAa,EAAE,CAAC,IAAI,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3C,CAAA;QACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACxD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO;YAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAChE,QAAQ,CAAC,MAAM,CAAC,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,QAAQ,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACV,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addGenerateProjection(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGenerateProjection = addGenerateProjection;
4
+ const generate_1 = require("./generate");
5
+ function addGenerateProjection(command, services, options) {
6
+ (0, generate_1.addGenerateCommand)(command, 'projection', 'Generate projected TypeScript types', services, options, 'projectionType');
7
+ }
8
+ //# sourceMappingURL=generate.projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.projection.js","sourceRoot":"","sources":["../../../src/commands/generate.projection.ts"],"names":[],"mappings":";;AAIA,sDAEC;AAJD,yCAA6C;AAE7C,SAAgB,qBAAqB,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IACpG,IAAA,6BAAkB,EAAC,OAAO,EAAE,YAAY,EAAE,qCAAqC,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACzH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliServices, CliOptions } from '../context';
3
+ export declare function addGenerateProjectionDefn(command: Command, services: CliServices, options: () => CliOptions): void;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGenerateProjectionDefn = addGenerateProjectionDefn;
4
+ const generate_1 = require("./generate");
5
+ function addGenerateProjectionDefn(command, services, options) {
6
+ (0, generate_1.addGenerateCommand)(command, 'projectionDefn', 'Generate default projection definitions', services, options, 'projectionDefinition');
7
+ }
8
+ //# sourceMappingURL=generate.projectionDefn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.projectionDefn.js","sourceRoot":"","sources":["../../../src/commands/generate.projectionDefn.ts"],"names":[],"mappings":";;AAIA,8DAEC;AAJD,yCAA6C;AAE7C,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,QAAqB,EAAE,OAAyB;IACxG,IAAA,6BAAkB,EAAC,OAAO,EAAE,gBAAgB,EAAE,yCAAyC,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAA;AACvI,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { ArtefactManifest, FileCatalogue, GenerationPolicy } from '@cobol-ts/file-catalogue';
2
+ import { type DisplayOptions, type DisplayStream } from '@cobol-ts/file-display';
3
+ import type { CodegenNames, CodegenSelection, GenerationResult } from '@cobol-ts/codegen';
4
+ export interface CliOptions {
5
+ readonly root?: string;
6
+ readonly directory?: string;
7
+ readonly catalogue?: string;
8
+ readonly policy?: string;
9
+ readonly data?: string;
10
+ }
11
+ export interface CliPaths {
12
+ readonly projectRoot: string;
13
+ readonly directory: string;
14
+ readonly catalogue: string;
15
+ readonly policy: string;
16
+ readonly data: string;
17
+ }
18
+ export interface CliServices {
19
+ readonly output: (message: string) => void;
20
+ readonly read: (filename: string) => Promise<string>;
21
+ readonly paths: (options: CliOptions) => Promise<CliPaths>;
22
+ readonly list: (paths: CliPaths) => Promise<readonly string[]>;
23
+ readonly manifest: (paths: CliPaths) => Promise<ArtefactManifest>;
24
+ readonly validateData: (paths: CliPaths) => Promise<void>;
25
+ readonly generate: (paths: CliPaths, selection?: CodegenSelection) => Promise<GenerationResult>;
26
+ readonly display: (paths: CliPaths, options: Omit<DisplayOptions, 'configDirectory' | 'catalogue' | 'data'>) => Promise<DisplayStream>;
27
+ }
28
+ export declare function discoverPaths(options: CliOptions): Promise<CliPaths>;
29
+ export declare function namingFor(catalogue: FileCatalogue, policy: GenerationPolicy): Readonly<Record<string, CodegenNames>>;
30
+ export declare const nodeCliServices: CliServices;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nodeCliServices = void 0;
4
+ exports.discoverPaths = discoverPaths;
5
+ exports.namingFor = namingFor;
6
+ const node_path_1 = require("node:path");
7
+ const files_1 = require("@cobol-ts/files");
8
+ const file_catalogue_1 = require("@cobol-ts/file-catalogue");
9
+ const codegen_1 = require("@cobol-ts/codegen");
10
+ const file_display_1 = require("@cobol-ts/file-display");
11
+ const errors_1 = require("@cobol-ts/errors");
12
+ async function discoverPaths(options) {
13
+ const startDirectory = options.directory ?? options.root ?? process.cwd();
14
+ const directory = await (0, files_1.findDirectoryUp)('.cobolts', (0, node_path_1.resolve)(startDirectory));
15
+ const projectRoot = (0, node_path_1.dirname)(directory);
16
+ const catalogue = options.catalogue ? (0, node_path_1.resolve)(directory, options.catalogue) : (0, node_path_1.join)(directory, 'files.yaml');
17
+ const policy = options.policy ? (0, node_path_1.resolve)(directory, options.policy) : (0, node_path_1.join)(directory, 'generation.yaml');
18
+ const data = options.data ? (0, node_path_1.resolve)(directory, options.data) : (0, node_path_1.join)(directory, 'data.yaml');
19
+ return { projectRoot, directory, catalogue, policy, data };
20
+ }
21
+ function namingFor(catalogue, policy) {
22
+ const result = {};
23
+ for (const [name, definition] of Object.entries(catalogue.files)) {
24
+ if (definition.type !== 'cobol')
25
+ continue;
26
+ const override = policy.names?.[name];
27
+ if (!override)
28
+ throw new Error(`Generation policy.names.${name}: Explicit source, projection and variable names are required`);
29
+ result[name] = override;
30
+ }
31
+ for (const name of Object.keys(policy.names ?? {})) {
32
+ if (!Object.prototype.hasOwnProperty.call(catalogue.files, name))
33
+ throw new Error(`Generation policy.names.${name}: Unknown logical file`);
34
+ }
35
+ return result;
36
+ }
37
+ exports.nodeCliServices = {
38
+ output: message => console.log(message),
39
+ read: filename => files_1.nodeTextFiles.read(filename),
40
+ paths: discoverPaths,
41
+ async list(paths) {
42
+ const catalogue = (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readFileCatalogue)(files_1.nodeTextFiles, paths.catalogue));
43
+ const result = [paths.catalogue, paths.policy];
44
+ if (await files_1.nodeTextFiles.exists(paths.data))
45
+ result.push(paths.data);
46
+ const sourceRoot = (0, node_path_1.resolve)(paths.directory, catalogue.root);
47
+ for (const definition of Object.values(catalogue.files)) {
48
+ if (definition.type !== 'cobol')
49
+ continue;
50
+ const path = (0, node_path_1.resolve)(sourceRoot, definition.copybook);
51
+ if (!result.includes(path))
52
+ result.push(path);
53
+ }
54
+ return result;
55
+ },
56
+ async validateData(paths) {
57
+ if (!await files_1.nodeTextFiles.exists(paths.data))
58
+ return;
59
+ const catalogue = (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readFileCatalogue)(files_1.nodeTextFiles, paths.catalogue));
60
+ const data = (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readDataFileConfiguration)(files_1.nodeTextFiles, paths.data));
61
+ const bindings = (0, errors_1.valueOrThrow)((0, file_catalogue_1.resolveDataFiles)(catalogue, data, paths.directory));
62
+ for (const binding of bindings) {
63
+ if (!await files_1.nodeTextFiles.exists(binding.filename)) {
64
+ throw new Error(`Data file ${binding.logicalName} does not exist: ${binding.filename}`);
65
+ }
66
+ }
67
+ },
68
+ async manifest(paths) {
69
+ return (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readArtefactManifest)(files_1.nodeTextFiles, paths.catalogue, paths.policy, paths.directory));
70
+ },
71
+ async display(paths, options) {
72
+ return (0, errors_1.valueOrThrow)(await (0, file_display_1.openFileDisplay)({
73
+ ...options, configDirectory: paths.directory,
74
+ catalogue: paths.catalogue, data: paths.data
75
+ }, files_1.nodeTextFiles));
76
+ },
77
+ async generate(paths, selection) {
78
+ const catalogue = (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readFileCatalogue)(files_1.nodeTextFiles, paths.catalogue));
79
+ const policy = (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readGenerationPolicy)(files_1.nodeTextFiles, paths.policy));
80
+ return (0, errors_1.valueOrThrow)(await (0, codegen_1.generateCode)({
81
+ files: files_1.nodeTextFiles,
82
+ catalogue: paths.catalogue,
83
+ policy: paths.policy,
84
+ configDirectory: paths.directory,
85
+ names: namingFor(catalogue, policy),
86
+ selection
87
+ }));
88
+ }
89
+ };
90
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;AAoCA,sCAQC;AAED,8BAYC;AA1DD,yCAAgD;AAChD,2CAA8D;AAC9D,6DAAmJ;AAEnJ,+CAA8C;AAC9C,yDAA+F;AAE/F,6CAA6C;AA6BtC,KAAK,UAAU,aAAa,CAAC,OAAmB;IACnD,MAAM,cAAc,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;IACzE,MAAM,SAAS,GAAG,MAAM,IAAA,uBAAe,EA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YACtC,GAAG,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS;YAC5C,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI;SAC/C,EAAE,qBAAa,CAAC,CAAC,CAAA;IACtB,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS;QAC3B,MAAM,SAAS,GAAG,IAAA,qBAAY,EAAC,MAAM,IAAA,kCAAiB,EAAC,qBAAa,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;QACvF,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,MAAM,IAAA,qCAAoB,EAAC,qBAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QACpF,OAAO,IAAA,qBAAY,EAAC,MAAM,IAAA,sBAAY,EAAC;YACnC,KAAK,EAAE,qBAAa;YACpB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,eAAe,EAAE,KAAK,CAAC,SAAS;YAChC,KAAK,EAAE,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;YACnC,SAAS;SACZ,CAAC,CAAC,CAAA;IACP,CAAC;CACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const context_1 = require("./context");
4
+ const catalogue = { root: '../copybooks', files: {
5
+ customers: { type: 'cobol', copybook: 'copybooks/CUSTOMER.cpy' },
6
+ events: { type: 'jsonl' }
7
+ } };
8
+ const policy = {
9
+ root: 'src/generated',
10
+ templates: {
11
+ copybookType: '${name}.copybook.types.ts',
12
+ projectionDefinition: '${name}.projection.ts',
13
+ projectionType: '${name}.projection.types.ts'
14
+ },
15
+ overrides: {}
16
+ };
17
+ describe('generation naming', () => {
18
+ it('uses the explicit names from the project policy', () => {
19
+ expect((0, context_1.namingFor)(catalogue, { ...policy, names: {
20
+ customers: { source: 'CustomerRecordCB', projection: 'Customer', variable: 'customerProjection' }
21
+ } })).toEqual({
22
+ customers: { source: 'CustomerRecordCB', projection: 'Customer', variable: 'customerProjection' }
23
+ });
24
+ });
25
+ it('reports a missing COBOL naming contract', () => {
26
+ expect(() => (0, context_1.namingFor)(catalogue, policy)).toThrow('Generation policy.names.customers: Explicit source, projection and variable names are required');
27
+ });
28
+ it('rejects names that do not belong to a catalogue entry', () => {
29
+ expect(() => (0, context_1.namingFor)(catalogue, { ...policy, names: {
30
+ customers: { source: 'CustomerRecordCB', projection: 'Customer', variable: 'customerProjection' },
31
+ missing: { source: 'MissingCB', projection: 'Missing', variable: 'missingProjection' }
32
+ } })).toThrow('Generation policy.names.missing: Unknown logical file');
33
+ });
34
+ });
35
+ //# sourceMappingURL=context.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.spec.js","sourceRoot":"","sources":["../../src/context.spec.ts"],"names":[],"mappings":";;AAAA,uCAAmC;AAGnC,MAAM,SAAS,GAAkB,EAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE;QAC3D,SAAS,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAC;QAC9D,MAAM,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC;KAC1B,EAAC,CAAA;AACF,MAAM,MAAM,GAAqB;IAC7B,IAAI,EAAE,eAAe;IACrB,SAAS,EAAE;QACP,YAAY,EAAE,2BAA2B;QACzC,oBAAoB,EAAE,uBAAuB;QAC7C,cAAc,EAAE,6BAA6B;KAChD;IACD,SAAS,EAAE,EAAE;CAChB,CAAA;AAED,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,IAAA,mBAAS,EAAC,SAAS,EAAE,EAAC,GAAG,MAAM,EAAE,KAAK,EAAE;gBAC3C,SAAS,EAAE,EAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAC;aAClG,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACT,SAAS,EAAE,EAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAC;SAClG,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,gGAAgG,CAAC,CAAA;IACxJ,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,mBAAS,EAAC,SAAS,EAAE,EAAC,GAAG,MAAM,EAAE,KAAK,EAAE;gBACjD,SAAS,EAAE,EAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAC;gBAC/F,OAAO,EAAE,EAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAC;aACvF,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,uDAAuD,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@cobol-ts/cobolts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Commander CLI for COBOL file catalogues and source generation",
4
+ "version": "0.0.2",
5
+ "main": "dist/index",
6
+ "types": "dist/index",
7
+ "bin": {
8
+ "cobolts": "dist/bin.js"
9
+ },
10
+ "browserslist": {
11
+ "development": [
12
+ "last 1 chrome version",
13
+ "last 1 firefox version",
14
+ "last 1 safari version"
15
+ ],
16
+ "production": [
17
+ ">0.2%",
18
+ "not dead",
19
+ "not op_mini all"
20
+ ]
21
+ },
22
+ "dependencies": {
23
+ "commander": "^12.1.0",
24
+ "@cobol-ts/files": "0.0.2",
25
+ "@cobol-ts/file-catalogue": "0.0.2",
26
+ "@cobol-ts/codegen": "0.0.2",
27
+ "@cobol-ts/file-display": "0.0.2",
28
+ "@cobol-ts/errors": "0.0.2"
29
+ },
30
+ "devDependencies": {
31
+ "typescript": "^5.2.2",
32
+ "@testing-library/jest-dom": "^6.1.4",
33
+ "@types/jest": "^29.0.0",
34
+ "@types/node": "^14.0.0",
35
+ "jest": "^29.0.0",
36
+ "ts-jest": "^29.0.0"
37
+ },
38
+ "eslintConfig": {
39
+ "extends": [
40
+ "react-app",
41
+ "react-app/jest"
42
+ ],
43
+ "overrides": [
44
+ {
45
+ "files": [
46
+ "**/*.stories.*"
47
+ ],
48
+ "rules": {
49
+ "import/no-anonymous-default-export": "off"
50
+ }
51
+ }
52
+ ]
53
+ },
54
+ "files": [
55
+ "dist/index.js",
56
+ "dist/index.d.ts",
57
+ "dist/src/",
58
+ "dist/",
59
+ "build/",
60
+ "bin.js"
61
+ ],
62
+ "keywords": [
63
+ "indexing"
64
+ ],
65
+ "license": "MIT",
66
+ "repository": "git@github.com:intellimaintain/intellimaintain.git",
67
+ "scripts": {
68
+ "test": "jest --config jest.config.json --env node",
69
+ "test:watch": "npm run test -- --watch"
70
+ }
6
71
  }