@shaclmate/cli 4.0.18 → 4.0.20
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/cli.js +29 -3
- package/dist/commands/generate.js +2 -1
- package/dist/commands/parseInputs.js +4 -4
- package/dist/logger.js +2 -1
- package/package.json +4 -5
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { AstJsonGenerator, Cx2Generator, TsGenerator, ZodGenerator, } from "@shaclmate/compiler";
|
|
3
4
|
import { command, option, restPositionals, run, string, subcommands, } from "cmd-ts";
|
|
4
5
|
import { ExistingPath } from "cmd-ts/dist/cjs/batteries/fs.js";
|
|
5
6
|
import { generate } from "./commands/generate.js";
|
|
6
7
|
import { merge } from "./commands/merge.js";
|
|
7
8
|
import { validate } from "./commands/validate.js";
|
|
9
|
+
import { logger } from "./logger.js";
|
|
8
10
|
const inputPaths = restPositionals({
|
|
9
11
|
displayName: "inputPaths",
|
|
10
12
|
description: "paths to RDF files or directories of RDF files containing SHACL shapes",
|
|
@@ -37,6 +39,30 @@ run(subcommands({
|
|
|
37
39
|
})).unsafeCoerce();
|
|
38
40
|
},
|
|
39
41
|
}),
|
|
42
|
+
cx2: command({
|
|
43
|
+
name: "cx2",
|
|
44
|
+
description: "generate Cytoscape Exchange Format Specification (Version 2)",
|
|
45
|
+
args: {
|
|
46
|
+
inputPaths,
|
|
47
|
+
outputFilePath,
|
|
48
|
+
visualPropertiesJsonFilePath: option({
|
|
49
|
+
description: "path to a file containing the visualProperties JSON object to include in the CX2 file",
|
|
50
|
+
long: "visual-properties-json-file-path",
|
|
51
|
+
type: ExistingPath,
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
handler: async ({ inputPaths, outputFilePath, visualPropertiesJsonFilePath, }) => {
|
|
55
|
+
let visualProperties;
|
|
56
|
+
if (visualPropertiesJsonFilePath) {
|
|
57
|
+
visualProperties = JSON.parse((await fs.promises.readFile(visualPropertiesJsonFilePath)).toString("utf-8"));
|
|
58
|
+
}
|
|
59
|
+
(await generate({
|
|
60
|
+
generator: new Cx2Generator({ visualProperties }),
|
|
61
|
+
inputPaths,
|
|
62
|
+
outputFilePath,
|
|
63
|
+
})).unsafeCoerce();
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
40
66
|
ts: command({
|
|
41
67
|
name: "ts",
|
|
42
68
|
description: "generate TypeScript for the SHACL shapes graph",
|
|
@@ -46,7 +72,7 @@ run(subcommands({
|
|
|
46
72
|
},
|
|
47
73
|
handler: async ({ inputPaths, outputFilePath }) => {
|
|
48
74
|
(await generate({
|
|
49
|
-
generator: new TsGenerator(),
|
|
75
|
+
generator: new TsGenerator({ logger }),
|
|
50
76
|
inputPaths,
|
|
51
77
|
outputFilePath,
|
|
52
78
|
})).unsafeCoerce();
|
|
@@ -61,7 +87,7 @@ run(subcommands({
|
|
|
61
87
|
},
|
|
62
88
|
handler: async ({ inputPaths, outputFilePath }) => {
|
|
63
89
|
(await generate({
|
|
64
|
-
generator: new ZodGenerator(),
|
|
90
|
+
generator: new ZodGenerator({ logger }),
|
|
65
91
|
inputPaths,
|
|
66
92
|
outputFilePath,
|
|
67
93
|
})).unsafeCoerce();
|
|
@@ -3,6 +3,7 @@ import Serializer from "@rdfjs/serializer-turtle";
|
|
|
3
3
|
import { Compiler, ShapesGraph } from "@shaclmate/compiler";
|
|
4
4
|
import { EitherAsync } from "purify-ts";
|
|
5
5
|
import SHACLValidator from "rdf-validate-shacl";
|
|
6
|
+
import { logger } from "../logger.js";
|
|
6
7
|
import { parseInputs } from "./parseInputs.js";
|
|
7
8
|
import { shaclShaclDataset } from "./shaclShaclDataset.js";
|
|
8
9
|
export async function generate({ generator, inputPaths, outputFilePath, }) {
|
|
@@ -24,7 +25,7 @@ export async function generate({ generator, inputPaths, outputFilePath, }) {
|
|
|
24
25
|
const output = await liftEither(ShapesGraph.builder()
|
|
25
26
|
.parseDataset(dataset, { prefixMap })
|
|
26
27
|
.map((_) => _.build())
|
|
27
|
-
.chain((shapesGraph) => new Compiler({ generator }).compile(shapesGraph)));
|
|
28
|
+
.chain((shapesGraph) => new Compiler({ generator, logger }).compile(shapesGraph)));
|
|
28
29
|
if (outputFilePath.length === 0) {
|
|
29
30
|
process.stdout.write(output);
|
|
30
31
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import DatasetFactory from "@rdfjs/dataset";
|
|
1
|
+
import datasetFactory from "@rdfjs/dataset";
|
|
3
2
|
import PrefixMap from "@rdfjs/prefix-map/PrefixMap.js";
|
|
3
|
+
import dataFactory from "@rdfx/data-factory";
|
|
4
4
|
import { RdfDirectory, RdfFileSystemEntry } from "@rdfx/fs";
|
|
5
5
|
import { Either, EitherAsync, Left } from "purify-ts";
|
|
6
6
|
import { logger } from "../logger.js";
|
|
7
7
|
export async function parseInputs(inputPaths) {
|
|
8
8
|
return EitherAsync(async ({ liftEither }) => {
|
|
9
|
-
const dataset =
|
|
9
|
+
const dataset = datasetFactory.dataset();
|
|
10
10
|
const prefixMapInit = [];
|
|
11
11
|
for (const inputPath of inputPaths) {
|
|
12
12
|
const parseInputFileSystemEntry = async (inputFileSystemEntry) => {
|
|
@@ -42,7 +42,7 @@ export async function parseInputs(inputPaths) {
|
|
|
42
42
|
}
|
|
43
43
|
return {
|
|
44
44
|
dataset,
|
|
45
|
-
prefixMap: new PrefixMap(prefixMapInit, { factory:
|
|
45
|
+
prefixMap: new PrefixMap(prefixMapInit, { factory: dataFactory }),
|
|
46
46
|
};
|
|
47
47
|
});
|
|
48
48
|
}
|
package/dist/logger.js
CHANGED
package/package.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"shaclmate": "dist/cli.js"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@shaclmate/compiler": "4.0.
|
|
7
|
-
"@rdfjs/data-model": "~2.1.1",
|
|
6
|
+
"@shaclmate/compiler": "4.0.20",
|
|
8
7
|
"@rdfjs/dataset": "~2.0.2",
|
|
9
8
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
10
9
|
"@rdfjs/serializer-turtle": "~1.1.5",
|
|
11
|
-
"@rdfx/
|
|
10
|
+
"@rdfx/data-factory": "0.0.11",
|
|
11
|
+
"@rdfx/fs": "0.0.11",
|
|
12
12
|
"cmd-ts": "~0.15.0",
|
|
13
13
|
"pino": "~9.1.0",
|
|
14
14
|
"pino-pretty": "~13.1.2",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"description": "Command line program to generate TypeScript code from SHACL shapes",
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@rdfjs/types": "~2.0.1",
|
|
23
|
-
"@types/rdfjs__data-model": "~2.0.9",
|
|
24
23
|
"@types/rdfjs__dataset": "~2.0.7",
|
|
25
24
|
"@types/rdfjs__prefix-map": "~0.1.5",
|
|
26
25
|
"@types/which": "~3.0.4"
|
|
@@ -56,5 +55,5 @@
|
|
|
56
55
|
},
|
|
57
56
|
"type": "module",
|
|
58
57
|
"types": "./dist/index.d.ts",
|
|
59
|
-
"version": "4.0.
|
|
58
|
+
"version": "4.0.20"
|
|
60
59
|
}
|