@cobol-ts/cli-generation 0.0.0-stage → 0.0.59

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 CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
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.
1
+ # @cobol-ts/cli-generation
2
+
3
+ Commander registration for the four generation subcommands. Maps an optional logical name and artefact kind to the injected generation operation. See [project-generation](../project-generation/README.md). Tests verify the exact selections and output.
4
+
5
+ `addGenerateCommand` takes a command name, optional artefact kind and injected `GenerateServices`. An omitted logical name means all configured files; a supplied name becomes a one-element selection. The adapter reports written paths and total, leaving generation and file writing to the application service.
6
+
7
+ ```sh
8
+ yarn cobolts -d modules/examples/init generate --help
9
+ ```
10
+
11
+ See the [CLI reference](../cobolts/README.md) for the complete command options.
@@ -0,0 +1,5 @@
1
+ export * from './src/generate';
2
+ export * from './src/generate.all';
3
+ export * from './src/generate.copybook';
4
+ export * from './src/generate.projection';
5
+ export * from './src/generate.projectionDefn';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
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/generate"), exports);
18
+ __exportStar(require("./src/generate.all"), exports);
19
+ __exportStar(require("./src/generate.copybook"), exports);
20
+ __exportStar(require("./src/generate.projection"), exports);
21
+ __exportStar(require("./src/generate.projectionDefn"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,qDAAkC;AAClC,0DAAuC;AACvC,4DAAyC;AACzC,gEAA6C"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliOptions } from '@cobol-ts/cli-common';
3
+ import { type GenerateServices } from './generate';
4
+ export declare function addGenerateAll(command: Command, services: GenerateServices, 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/generate.all.ts"],"names":[],"mappings":";;AAIA,wCAEC;AAJD,yCAAoE;AAEpE,SAAgB,cAAc,CAAC,OAAgB,EAAE,QAA0B,EAAE,OAAyB;IAClG,IAAA,6BAAkB,EAAC,OAAO,EAAE,KAAK,EAAE,mCAAmC,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AACzG,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const commander_1 = require("commander");
4
+ const generate_all_1 = require("./generate.all");
5
+ const generate_copybook_1 = require("./generate.copybook");
6
+ const generate_projection_1 = require("./generate.projection");
7
+ const generate_projectionDefn_1 = require("./generate.projectionDefn");
8
+ const paths = { projectRoot: 'project', directory: 'project/.cobolts', catalogue: 'files.yaml',
9
+ policy: 'generation.yaml', data: 'data.yaml', accumulator: 'accumulator.yaml' };
10
+ const cases = [
11
+ ['all', undefined, {}], ['copybook', 'customers', { logicalNames: ['customers'], artefactKinds: ['copybookType'] }],
12
+ ['projection', undefined, { artefactKinds: ['projectionType'] }],
13
+ ['projectionDefn', 'accounts', { logicalNames: ['accounts'], artefactKinds: ['projectionDefinition'] }]
14
+ ];
15
+ test.each(cases)('generate %s forwards exactly the selected artefact kinds and logical names', async (command, logical, expected) => {
16
+ const seen = [], output = [];
17
+ const services = {
18
+ paths: async () => paths, output: line => { output.push(line); },
19
+ generate: async (selectedPaths, selection) => {
20
+ expect(selectedPaths).toBe(paths);
21
+ seen.push(selection);
22
+ return { manifest: { sources: [], artefacts: [] }, written: ['output.ts'] };
23
+ }
24
+ };
25
+ const root = new commander_1.Command(), parent = root.command('generate');
26
+ for (const register of [generate_all_1.addGenerateAll, generate_copybook_1.addGenerateCopybook, generate_projection_1.addGenerateProjection, generate_projectionDefn_1.addGenerateProjectionDefn])
27
+ register(parent, services, () => ({}));
28
+ await root.parseAsync(['generate', command, ...(logical ? [logical] : [])], { from: 'user' });
29
+ expect(seen).toEqual([expected]);
30
+ expect(output).toEqual(['output.ts', 'Generated 1 files']);
31
+ });
32
+ //# sourceMappingURL=generate.command.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.command.spec.js","sourceRoot":"","sources":["../../src/generate.command.spec.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAIjC,iDAA6C;AAC7C,2DAAuD;AACvD,+DAA2D;AAC3D,uEAAmE;AAEnE,MAAM,KAAK,GAAiB,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY;IACvG,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAC,CAAA;AAElF,M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CAAC,6BAAc,EAAE,uCAAmB,EAAE,2CAAqB,EAAE,mDAAyB,CAAC;QAC1G,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;IAC3F,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;IAChC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliOptions } from '@cobol-ts/cli-common';
3
+ import { type GenerateServices } from './generate';
4
+ export declare function addGenerateCopybook(command: Command, services: GenerateServices, 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/generate.copybook.ts"],"names":[],"mappings":";;AAIA,kDAEC;AAJD,yCAAoE;AAEpE,SAAgB,mBAAmB,CAAC,OAAgB,EAAE,QAA0B,EAAE,OAAyB;IACvG,IAAA,6BAAkB,EAAC,OAAO,EAAE,UAAU,EAAE,qCAAqC,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;AACrH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Command } from 'commander';
2
+ import type { ArtefactKind } from '@cobol-ts/file-catalogue';
3
+ import type { Output, ResolveProjectPaths } from '@cobol-ts/project-context';
4
+ import type { CliOptions } from '@cobol-ts/cli-common';
5
+ import type { Generate } from '@cobol-ts/project-generation';
6
+ export declare function addGenerateCommand(parent: Command, name: string, description: string, services: GenerateServices, options: () => CliOptions, kind?: ArtefactKind): void;
7
+ export interface GenerateServices {
8
+ readonly generate: Generate;
9
+ readonly output: Output;
10
+ readonly paths: ResolveProjectPaths;
11
+ }
@@ -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/generate.ts"],"names":[],"mappings":";;AAMA,gDAiBC;AAjBD,SAAgB,kBAAkB,CAC9B,MAAe,EAAE,IAAY,EAAE,WAAmB,EAClD,QAA0B,EAAE,OAAyB,EAAE,IAAmB;IAE1E,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,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliOptions } from '@cobol-ts/cli-common';
3
+ import { type GenerateServices } from './generate';
4
+ export declare function addGenerateProjection(command: Command, services: GenerateServices, 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/generate.projection.ts"],"names":[],"mappings":";;AAIA,sDAEC;AAJD,yCAAoE;AAEpE,SAAgB,qBAAqB,CAAC,OAAgB,EAAE,QAA0B,EAAE,OAAyB;IACzG,IAAA,6BAAkB,EAAC,OAAO,EAAE,YAAY,EAAE,qCAAqC,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACzH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliOptions } from '@cobol-ts/cli-common';
3
+ import { type GenerateServices } from './generate';
4
+ export declare function addGenerateProjectionDefn(command: Command, services: GenerateServices, 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/generate.projectionDefn.ts"],"names":[],"mappings":";;AAIA,8DAEC;AAJD,yCAAoE;AAEpE,SAAgB,yBAAyB,CAAC,OAAgB,EAAE,QAA0B,EAAE,OAAyB;IAC7G,IAAA,6BAAkB,EAAC,OAAO,EAAE,gBAAgB,EAAE,yCAAyC,EAAE,QAAQ,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAA;AACvI,CAAC"}
package/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './src/generate'
2
+ export * from './src/generate.all'
3
+ export * from './src/generate.copybook'
4
+ export * from './src/generate.projection'
5
+ export * from './src/generate.projectionDefn'
package/package.json CHANGED
@@ -1,6 +1,68 @@
1
1
  {
2
2
  "name": "@cobol-ts/cli-generation",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Generation command delivery adapter",
4
+ "version": "0.0.59",
5
+ "main": "dist/index",
6
+ "types": "dist/index",
7
+ "browserslist": {
8
+ "development": [
9
+ "last 1 chrome version",
10
+ "last 1 firefox version",
11
+ "last 1 safari version"
12
+ ],
13
+ "production": [
14
+ ">0.2%",
15
+ "not dead",
16
+ "not op_mini all"
17
+ ]
18
+ },
19
+ "dependencies": {
20
+ "@cobol-ts/cli-common": "0.0.59",
21
+ "@cobol-ts/codegen": "0.0.59",
22
+ "@cobol-ts/file-catalogue": "0.0.59",
23
+ "@cobol-ts/project-context": "0.0.59",
24
+ "@cobol-ts/project-generation": "0.0.59",
25
+ "commander": "^12.1.0"
26
+ },
27
+ "devDependencies": {
28
+ "@testing-library/jest-dom": "^6.1.4",
29
+ "@types/jest": "^29.0.0",
30
+ "@types/node": "^20.0.0",
31
+ "jest": "^29.0.0",
32
+ "ts-jest": "^29.0.0",
33
+ "typescript": "^5.2.2"
34
+ },
35
+ "eslintConfig": {
36
+ "extends": [
37
+ "react-app",
38
+ "react-app/jest"
39
+ ],
40
+ "overrides": [
41
+ {
42
+ "files": [
43
+ "**/*.stories.*"
44
+ ],
45
+ "rules": {
46
+ "import/no-anonymous-default-export": "off"
47
+ }
48
+ }
49
+ ]
50
+ },
51
+ "files": [
52
+ "dist/index.js",
53
+ "dist/index.d.ts",
54
+ "dist/src/",
55
+ "dist/",
56
+ "dist/**/*"
57
+ ],
58
+ "keywords": [
59
+ "indexing"
60
+ ],
61
+ "license": "MIT",
62
+ "module": "./index.ts",
63
+ "repository": "git@github.com:intellimaintain/intellimaintain.git",
64
+ "scripts": {
65
+ "test": "jest --config jest.config.json --env node",
66
+ "test:watch": "npm run test -- --watch"
67
+ }
6
68
  }