@shaclmate/cli 4.0.33 → 4.0.34
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 +32 -3
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { AstJsonGenerator, Cx2Generator, TsGenerator, ZodGenerator, } from "@shaclmate/compiler";
|
|
4
|
-
import {
|
|
4
|
+
import { TS_FEATURES, } from "@shaclmate/compiler/dist/generators/ts/TsFeature.js";
|
|
5
|
+
import { command, multioption, option, restPositionals, run, string, subcommands, } from "cmd-ts";
|
|
5
6
|
import { ExistingPath } from "cmd-ts/dist/cjs/batteries/fs.js";
|
|
6
7
|
import { generate } from "./commands/generate.js";
|
|
7
8
|
import { merge } from "./commands/merge.js";
|
|
@@ -67,12 +68,40 @@ run(subcommands({
|
|
|
67
68
|
name: "ts",
|
|
68
69
|
description: "generate TypeScript for the SHACL shapes graph",
|
|
69
70
|
args: {
|
|
71
|
+
features: multioption({
|
|
72
|
+
defaultValue: () => [
|
|
73
|
+
...TsGenerator.Configuration.default_.features,
|
|
74
|
+
],
|
|
75
|
+
long: "feature",
|
|
76
|
+
description: `features to generate: zero or more of [${TS_FEATURES.join(", ")}] (default: [${[...TsGenerator.Configuration.default_.features].join(", ")}])`,
|
|
77
|
+
type: {
|
|
78
|
+
async from(strings) {
|
|
79
|
+
return strings.map((string) => {
|
|
80
|
+
if (TS_FEATURES.some((tsFeature) => string === tsFeature)) {
|
|
81
|
+
return string;
|
|
82
|
+
}
|
|
83
|
+
throw new RangeError(`invalid feature: ${string}`);
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
70
88
|
inputPaths,
|
|
71
89
|
outputFilePath,
|
|
90
|
+
syntheticNamePrefix: option({
|
|
91
|
+
defaultValue: () => TsGenerator.Configuration.default_.syntheticNamePrefix,
|
|
92
|
+
description: `prefix to use for synthetic names in generated code (default: "${TsGenerator.Configuration.default_.syntheticNamePrefix}")`,
|
|
93
|
+
long: "synthetic-name-prefix",
|
|
94
|
+
}),
|
|
72
95
|
},
|
|
73
|
-
handler: async ({ inputPaths, outputFilePath }) => {
|
|
96
|
+
handler: async ({ features, inputPaths, outputFilePath, syntheticNamePrefix, }) => {
|
|
74
97
|
(await generate({
|
|
75
|
-
generator: new TsGenerator({
|
|
98
|
+
generator: new TsGenerator({
|
|
99
|
+
configuration: {
|
|
100
|
+
features: new Set(features),
|
|
101
|
+
syntheticNamePrefix,
|
|
102
|
+
},
|
|
103
|
+
logger,
|
|
104
|
+
}),
|
|
76
105
|
inputPaths,
|
|
77
106
|
outputFilePath,
|
|
78
107
|
})).unsafeCoerce();
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"shaclmate": "dist/cli.js"
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@shaclmate/compiler": "4.0.
|
|
6
|
+
"@shaclmate/compiler": "4.0.34",
|
|
7
7
|
"@rdfjs/dataset": "~2.0.2",
|
|
8
8
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
9
9
|
"@rdfjs/serializer-turtle": "~1.1.5",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
},
|
|
56
56
|
"type": "module",
|
|
57
57
|
"types": "./dist/index.d.ts",
|
|
58
|
-
"version": "4.0.
|
|
58
|
+
"version": "4.0.34"
|
|
59
59
|
}
|