@cobol-ts/cli-extraction 0.0.0-stage → 0.0.57

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-extraction
2
+
3
+ Registers `extract` with Commander. Resolves project options and output destinations, delegates extraction to [project-extraction](../project-extraction/README.md), and writes results and diagnostics separately.
4
+
5
+ `extract <name>` reads the named definition in extractions.yaml. `--format` selects YAML or JSON; `--output` directs the result to a file, `--noSources` omits provenance and `--raw` suppresses the summary. The data result and diagnostics remain separate.
6
+
7
+ ```sh
8
+ yarn cobolts -d modules/examples/init extract --help
9
+ ```
10
+
11
+ See the [CLI reference](../cobolts/README.md) for the complete command options.
@@ -0,0 +1 @@
1
+ export * from './src/extract';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
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/extract"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
4
+ const node_path_1 = require("node:path");
5
+ const commander_1 = require("commander");
6
+ const project_extraction_1 = require("@cobol-ts/project-extraction");
7
+ const extract_1 = require("./extract");
8
+ jest.mock('@cobol-ts/project-extraction', () => ({ runExtraction: jest.fn() }));
9
+ const paths = { projectRoot: 'project', directory: 'project/.cobolts', catalogue: 'files.yaml',
10
+ policy: 'generation.yaml', data: 'data.yaml', accumulator: 'accumulator.yaml' };
11
+ const contents = 'characteristics: []\n', summary = 'Extraction: 0 characteristics';
12
+ function fixture() {
13
+ const services = { paths: jest.fn(async () => paths), read: jest.fn(async () => ''),
14
+ extractSpreadsheet: jest.fn(async () => { throw new Error('unexpected spreadsheet access'); }),
15
+ output: jest.fn(), diagnostic: jest.fn(), write: jest.fn(async () => { }) };
16
+ jest.mocked(project_extraction_1.runExtraction).mockResolvedValueOnce({ contents, summary });
17
+ const root = new commander_1.Command().exitOverride();
18
+ (0, extract_1.addExtract)(root, services, () => ({ directory: 'project' }));
19
+ return { root, services };
20
+ }
21
+ test('extract sends default YAML to stdout and the summary to diagnostics', async () => {
22
+ const { root, services } = fixture();
23
+ await root.parseAsync(['extract', 'demo'], { from: 'user' });
24
+ expect(project_extraction_1.runExtraction).toHaveBeenLastCalledWith(yaml_jsyaml_1.jsYamlParser, paths, services, 'demo', { format: 'yaml' });
25
+ expect(services.output).toHaveBeenCalledWith(contents.trimEnd());
26
+ expect(services.diagnostic).toHaveBeenCalledWith(summary);
27
+ expect(services.write).not.toHaveBeenCalled();
28
+ });
29
+ test('extract forwards format, config and provenance flags, writes raw output without a summary', async () => {
30
+ const { root, services } = fixture();
31
+ await root.parseAsync(['extract', 'demo', '--config', 'custom.yaml', '--format', 'json', '--noSources',
32
+ '--raw', '--output', 'result.json'], { from: 'user' });
33
+ expect(project_extraction_1.runExtraction).toHaveBeenLastCalledWith(yaml_jsyaml_1.jsYamlParser, paths, services, 'demo', { config: 'custom.yaml', format: 'json', noSources: true, raw: true, output: 'result.json' });
34
+ expect(services.write).toHaveBeenCalledWith((0, node_path_1.resolve)('result.json'), contents);
35
+ expect(services.output).not.toHaveBeenCalled();
36
+ expect(services.diagnostic).not.toHaveBeenCalled();
37
+ });
38
+ //# sourceMappingURL=extract.command.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.command.spec.js","sourceRoot":"","sources":["../../src/extract.command.spec.ts"],"names":[],"mappings":";;AAAA,uDAAkD;AAClD,yCAAiC;AACjC,yCAAiC;AAEjC,qEAA0D;AAC1D,uCAA0D;AAE1D,IAAI,CAAC,IAAI,CAAC,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE,EAAC,CAAC,CAAC,CAAA;AAE7E,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;AAClF,MAAM,QAAQ,GAAG,uBAAuB,EAAE,OAAO,GAAG,+BAA+B,CAAA;AAEnF,SAAS,OAAO;IACZ,MAAM,QAAQ,GAAoB,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/F,kBAAkB,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,GAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA,CAAA,CAAC,CAAC;QAC3F,MAAM,EAAE,IAAI,CAAC,E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,EAAC,IAAI,EAAE,QAAQ,EAAC,GAAG,OAAO,EAAE,CAAA;IAClC,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa;QAClG,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;IACxD,MAAM,CAAC,kCAAa,CAAC,CAAC,wBAAwB,CAAC,0BAAY,EAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAC/E,EAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAC,CAAC,CAAA;IAC/F,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,IAAA,mBAAO,EAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC7E,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC9C,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;AACtD,CAAC,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Command } from 'commander';
2
+ import type { Diagnostic, Output, ResolveProjectPaths, Write } from '@cobol-ts/project-context';
3
+ import type { CliOptions } from '@cobol-ts/cli-common';
4
+ import { type ExtractionServices } from '@cobol-ts/project-extraction';
5
+ /** CLI adapter. A new type of extraction adds a new dispatch branch, not a new top-level command. */
6
+ export declare function addExtract(root: Command, services: ExtractServices, options: () => CliOptions): void;
7
+ export interface ExtractServices extends ExtractionServices {
8
+ readonly diagnostic: Diagnostic;
9
+ readonly output: Output;
10
+ readonly paths: ResolveProjectPaths;
11
+ readonly write: Write;
12
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addExtract = addExtract;
4
+ const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
5
+ const node_path_1 = require("node:path");
6
+ const project_extraction_1 = require("@cobol-ts/project-extraction");
7
+ /** CLI adapter. A new type of extraction adds a new dispatch branch, not a new top-level command. */
8
+ function addExtract(root, services, options) {
9
+ root.command('extract')
10
+ .description('Run a named extraction from .cobolts/extractions.yaml')
11
+ .argument('<name>', 'Name of the extraction in extractions.yaml')
12
+ .option('-c, --config <filename>', 'Config YAML relative to .cobolts (default extractions.yaml)')
13
+ .option('-o, --output <filename>', 'Write to file instead of stdout')
14
+ .option('-f, --format <format>', 'yaml or json (default yaml)', 'yaml')
15
+ .option('--noSources', 'Omit source provenance from the output')
16
+ .option('--raw', 'Suppress the trailing extraction summary')
17
+ .action(async (name, flags) => {
18
+ const paths = await services.paths(options());
19
+ const { contents, summary } = await (0, project_extraction_1.runExtraction)(yaml_jsyaml_1.jsYamlParser, paths, services, name, flags);
20
+ if (flags.output === undefined)
21
+ services.output(contents.trimEnd());
22
+ else
23
+ await services.write((0, node_path_1.resolve)(flags.output), contents);
24
+ if (!flags.raw)
25
+ services.diagnostic(summary);
26
+ });
27
+ }
28
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/extract.ts"],"names":[],"mappings":";;AAQA,gCAgBC;AAxBD,uDAAkD;AAClD,yCAAiC;AAIjC,qEAAoG;AAEpG,qGAAqG;AACrG,SAAgB,UAAU,CAAC,IAAa,EAAE,QAAyB,EAAE,OAAyB;IAC1F,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,uDAAuD,CAAC;SACpE,QAAQ,CAAC,QAAQ,EAAE,4CAA4C,CAAC;SAChE,MAAM,CAAC,yBAAyB,EAAE,6DAA6D,CAAC;SAChG,MAAM,CAAC,yBAAyB,EAAE,iCAAiC,CAAC;SACpE,MAAM,CAAC,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,CAAC;SACtE,MAAM,CAAC,aAAa,EAAE,wCAAwC,CAAC;SAC/D,MAAM,CAAC,OAAO,EAAE,0CAA0C,CAAC;SAC3D,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,KAAmB,EAAE,EAAE;QAChD,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC7C,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,MAAM,IAAA,kCAAa,EAAC,0BAAY,EAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;QAC1F,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;YAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;;YAC9D,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAA,mBAAO,EAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAA;QAC1D,IAAI,CAAC,KAAK,CAAC,GAAG;YAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACV,CAAC"}
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src/extract'
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@cobol-ts/cli-extraction",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Extraction command delivery adapter",
4
+ "version": "0.0.57",
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
+ "commander": "^12.1.0",
21
+ "@cobol-ts/cli-common": "0.0.57",
22
+ "@cobol-ts/project-context": "0.0.57",
23
+ "@cobol-ts/project-extraction": "0.0.57",
24
+ "@cobol-ts/yaml-jsyaml": "0.0.57"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "^5.2.2",
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
+ },
34
+ "eslintConfig": {
35
+ "extends": [
36
+ "react-app",
37
+ "react-app/jest"
38
+ ],
39
+ "overrides": [
40
+ {
41
+ "files": [
42
+ "**/*.stories.*"
43
+ ],
44
+ "rules": {
45
+ "import/no-anonymous-default-export": "off"
46
+ }
47
+ }
48
+ ]
49
+ },
50
+ "files": [
51
+ "dist/index.js",
52
+ "dist/index.d.ts",
53
+ "dist/src/",
54
+ "dist/",
55
+ "dist/**/*"
56
+ ],
57
+ "keywords": [
58
+ "indexing"
59
+ ],
60
+ "license": "MIT",
61
+ "module": "./index.ts",
62
+ "repository": "git@github.com:intellimaintain/intellimaintain.git",
63
+ "scripts": {
64
+ "test": "jest --config jest.config.json --env node",
65
+ "test:watch": "npm run test -- --watch"
66
+ }
6
67
  }