@lionweb/cli 0.6.0-beta.3 → 0.6.0
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 +20 -19
- package/dist/lionweb-cli.js +25 -13
- package/dist/lionweb-cli.js.map +1 -1
- package/dist/m3/diagram-generator.d.ts.map +1 -1
- package/dist/m3/diagram-generator.js +7 -5
- package/dist/m3/diagram-generator.js.map +1 -1
- package/dist/serialization/sorter.d.ts +2 -0
- package/dist/serialization/sorter.d.ts.map +1 -0
- package/dist/serialization/sorter.js +10 -0
- package/dist/serialization/sorter.js.map +1 -0
- package/dist/serialization/textualizer.d.ts.map +1 -1
- package/dist/serialization/textualizer.js +13 -7
- package/dist/serialization/textualizer.js.map +1 -1
- package/dist/validator.d.ts +2 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +9 -0
- package/dist/validator.js.map +1 -0
- package/package.json +8 -8
- package/build.sh +0 -6
- package/dist/serialization/extractor.d.ts +0 -2
- package/dist/serialization/extractor.d.ts.map +0 -1
- package/dist/serialization/extractor.js +0 -16
- package/dist/serialization/extractor.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,54 +15,55 @@ $ npx @lionweb/cli
|
|
|
15
15
|
|
|
16
16
|
produces information about which commands are available.
|
|
17
17
|
|
|
18
|
+
This CLI utility does not perform any explicit validation apart from the file at the given path existing and being valid JSON.
|
|
19
|
+
It does some implicit validation as it can error out on incorrect serializations.
|
|
18
20
|
|
|
19
|
-
## Extracting essential information from a serialization chunk
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
## Sorting a serialization chunk
|
|
23
|
+
|
|
24
|
+
Run the following command to sort a serialization chunk (e.g.):
|
|
22
25
|
|
|
23
26
|
```shell
|
|
24
|
-
npx @lionweb/cli
|
|
27
|
+
npx @lionweb/cli sort ../artifacts/chunks/languages/lioncore.json
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
These extractions are:
|
|
30
|
+
Sorting a serialization chunk means the following:
|
|
29
31
|
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* and all containments and references sorted by ID.
|
|
34
|
-
* A "shortened" JSON where keys are used as key names.
|
|
35
|
-
* If the serialization represents a language - i.e.: a LionCore model - then a textual version is generated as well.
|
|
32
|
+
* All nodes sorted by ID.
|
|
33
|
+
* For all nodes, their properties, containments, and references sorted by key (from the meta-pointer),
|
|
34
|
+
* All containments and references sorted by ID.
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
The sorting produces a serialization chunk that's also aligned on JSON-level with the specification.
|
|
37
|
+
That means that key-value pairs appear in precisely the same order as they do in the specification, and that missing key-value pairs are put in and get their default values.
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
## Changelog
|
|
42
41
|
|
|
43
42
|
### 0.6.0
|
|
44
43
|
|
|
45
|
-
*
|
|
44
|
+
* Change the `diagram` command to output PlantUML and Mermaid diagram files _per language_.
|
|
45
|
+
* Add a `validation` commmand to validate JSON files as serialization chunks.
|
|
46
|
+
* Remove the shortening functionality from `extract`.
|
|
47
|
+
* Rename the `extract` command → `sort`, and remove the textualization for chunks that are the serialization of languages.
|
|
48
|
+
* Textualizing a serialization chunk of languages will use the LionCore/M3-specific syntax _unless_ the flag `--languagesAsRegular` is an argument.
|
|
49
|
+
* Add a `repair` command.
|
|
46
50
|
* Add a `textualize` command – that's optionally language-aware – to render a JSON serialization chunk as pure text.
|
|
47
51
|
|
|
48
|
-
|
|
49
52
|
### 0.5.0
|
|
50
53
|
|
|
51
54
|
This is the first version corresponding to a release of LionWeb (version: 2023.1) as a whole.
|
|
52
55
|
|
|
53
56
|
* Make language-related functionality "multi-lingual", i.e. a serialization chunk can contain multiple `Language`s.
|
|
54
|
-
|
|
57
|
+
* (Languages will be sorted by name.)
|
|
55
58
|
* Improve extraction functionality: only catch JSON-parsing exceptions.
|
|
56
59
|
* Configure single entrypoint named `lionweb-cli`.
|
|
57
60
|
|
|
58
61
|
No changelog has been kept for previous versions, regardless of whether these were published or not.
|
|
59
62
|
|
|
60
|
-
|
|
61
63
|
## Development
|
|
62
64
|
|
|
63
65
|
Build the executable from source as follows:
|
|
64
66
|
|
|
65
67
|
```shell
|
|
66
|
-
$
|
|
68
|
+
$ npm run build
|
|
67
69
|
```
|
|
68
|
-
|
package/dist/lionweb-cli.js
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
import { argv } from "process";
|
|
3
3
|
import { diagramFromSerialization } from "./m3/diagram-generator.js";
|
|
4
4
|
import { generateTsTypesWith } from "./m3/ts-types-generator.js";
|
|
5
|
-
import {
|
|
5
|
+
import { sortSerialization } from "./serialization/sorter.js";
|
|
6
6
|
import { repairSerializationChunk } from "./serialization/repairer.js";
|
|
7
7
|
import { executeTextualizeCommand } from "./serialization/textualizer.js";
|
|
8
|
-
|
|
8
|
+
import { runValidation } from "./validator.js";
|
|
9
|
+
const main = async (args) => {
|
|
9
10
|
const DIAGRAM_COMMAND = "diagram";
|
|
10
|
-
const
|
|
11
|
+
const SORT_COMMAND = "sort";
|
|
11
12
|
const GENERATE_TS_TYPES_COMMAND = "generate-ts-types";
|
|
12
13
|
const REPAIR_COMMAND = "repair";
|
|
13
14
|
const TEXTUALIZE_COMMAND = "textualize";
|
|
14
|
-
const
|
|
15
|
+
const VALIDATE_COMMAND = "validate";
|
|
16
|
+
const commands = [DIAGRAM_COMMAND, SORT_COMMAND, GENERATE_TS_TYPES_COMMAND, REPAIR_COMMAND, TEXTUALIZE_COMMAND, VALIDATE_COMMAND].sort();
|
|
15
17
|
if (args.length <= 2) {
|
|
16
18
|
console.log(`lionweb-cli is a LionWeb utility around LionWeb-TypeScript
|
|
17
19
|
|
|
@@ -35,14 +37,13 @@ ${commands.map((command) => ` ${command}\n`).join(``)}
|
|
|
35
37
|
}
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
|
-
case
|
|
40
|
+
case SORT_COMMAND: {
|
|
39
41
|
if (commandArgs.length === 0) {
|
|
40
|
-
console.log(`The ${
|
|
41
|
-
If the chunk is the serialization of a LionCore Language/M2, then a textual rendering is also output.
|
|
42
|
+
console.log(`The ${SORT_COMMAND} command sorts JSON files that are serialization chunk – sorted serialization chunks can be easily compared.
|
|
42
43
|
(See the README.md for more information.)`);
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
|
-
commandArgs.forEach(
|
|
46
|
+
commandArgs.forEach(sortSerialization);
|
|
46
47
|
}
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
@@ -51,14 +52,15 @@ If the chunk is the serialization of a LionCore Language/M2, then a textual rend
|
|
|
51
52
|
console.log(`The ${GENERATE_TS_TYPES_COMMAND} command generates a TypeScript source files with type definitions for the given (JSON serializations of) languages, assuming the use of the dynamic façade.`);
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
|
-
generateTsTypesWith(commandArgs);
|
|
55
|
+
await generateTsTypesWith(commandArgs);
|
|
55
56
|
}
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
case REPAIR_COMMAND: {
|
|
59
60
|
if (commandArgs.length === 0) {
|
|
60
61
|
console.log(`The ${REPAIR_COMMAND} command "repairs" the given JSON files that represent serialization chunks.
|
|
61
|
-
Right now, that means that
|
|
62
|
+
Right now, that means that key-value pairs appear in precisely the same order as they do in the specification.
|
|
63
|
+
Missing key-value pairs are put in and get their default values.`);
|
|
62
64
|
}
|
|
63
65
|
else {
|
|
64
66
|
commandArgs.forEach(repairSerializationChunk);
|
|
@@ -70,18 +72,28 @@ Right now, that means that the ordering of the key-value pairs is precisely alig
|
|
|
70
72
|
console.log(`The ${TEXTUALIZE_COMMAND} command produces purely textual renderings of the given serialization chunks.
|
|
71
73
|
Chunks given after a '--language' or '--languages' flag (which are synonyms) are assumed to be serializations of languages.
|
|
72
74
|
These languages are then used to try and resolve the keys of languages' entities and their features to names.
|
|
75
|
+
If a serialization chunk is the serialization of a language (as instance of LionCore/M3), then the LionCore/M3-specific
|
|
76
|
+
textual syntax is used, unless a flag '--asRegular' is provided.
|
|
73
77
|
`);
|
|
74
78
|
}
|
|
75
79
|
else {
|
|
76
|
-
executeTextualizeCommand(commandArgs);
|
|
80
|
+
await executeTextualizeCommand(commandArgs);
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
case VALIDATE_COMMAND: {
|
|
85
|
+
if (commandArgs.length === 0) {
|
|
86
|
+
console.log(`The ${VALIDATE_COMMAND} command validates a serialization chunk. \nUsage: npx @lionweb/cli validate <path_to_chunk>`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
commandArgs.forEach(runValidation);
|
|
77
90
|
}
|
|
78
91
|
return;
|
|
79
92
|
}
|
|
80
|
-
// TODO generate schema, import Ecore
|
|
81
93
|
default: {
|
|
82
94
|
console.error(`command "${command}" is not recognized`);
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
97
|
};
|
|
86
|
-
main(argv);
|
|
98
|
+
await main(argv);
|
|
87
99
|
//# sourceMappingURL=lionweb-cli.js.map
|
package/dist/lionweb-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lionweb-cli.js","sourceRoot":"","sources":["../src/lionweb-cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAC,IAAI,EAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"lionweb-cli.js","sourceRoot":"","sources":["../src/lionweb-cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAC,IAAI,EAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2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pG,CAAA;YACL,CAAC;iBAAM,CAAC;gBACJ,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;YACtC,CAAC;YACD,OAAM;QACV,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,YAAY,OAAO,qBAAqB,CAAC,CAAA;QAC3D,CAAC;IACL,CAAC;AAEL,CAAC,CAAA;AAED,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram-generator.d.ts","sourceRoot":"","sources":["../../src/m3/diagram-generator.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,wBAAwB,SAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"diagram-generator.d.ts","sourceRoot":"","sources":["../../src/m3/diagram-generator.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,wBAAwB,SAAgB,MAAM,kBAc1D,CAAA"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { writeFileSync } from "fs";
|
|
2
|
-
import {
|
|
2
|
+
import { dirname } from "path";
|
|
3
3
|
import { deserializeLanguages } from "@lionweb/core";
|
|
4
4
|
import { generateMermaidForLanguage, generatePlantUmlForLanguage, readFileAsJson } from "@lionweb/utilities";
|
|
5
5
|
export const diagramFromSerialization = async (path) => {
|
|
6
6
|
try {
|
|
7
7
|
const json = readFileAsJson(path);
|
|
8
|
-
const
|
|
8
|
+
const dir = dirname(path);
|
|
9
9
|
const languages = deserializeLanguages(json);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
languages.forEach((language) => {
|
|
11
|
+
writeFileSync(`${dir}/${language.name}.puml`, generatePlantUmlForLanguage(language));
|
|
12
|
+
writeFileSync(`${dir}/${language.name}.md`, generateMermaidForLanguage(language));
|
|
13
|
+
});
|
|
14
|
+
console.log(`generated diagrams: "${path}" -> "${dir}/"`);
|
|
13
15
|
}
|
|
14
16
|
catch (_) {
|
|
15
17
|
console.error(`"${path}" does not point to a valid JSON serialization of a language`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram-generator.js","sourceRoot":"","sources":["../../src/m3/diagram-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,IAAI,CAAA;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAC,oBAAoB,EAAqB,MAAM,eAAe,CAAA;AACtE,OAAO,EAAC,0BAA0B,EAAE,2BAA2B,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAA;AAG1G,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAuB,CAAA;QACvD,MAAM,
|
|
1
|
+
{"version":3,"file":"diagram-generator.js","sourceRoot":"","sources":["../../src/m3/diagram-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,IAAI,CAAA;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAC,oBAAoB,EAAqB,MAAM,eAAe,CAAA;AACtE,OAAO,EAAC,0BAA0B,EAAE,2BAA2B,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAA;AAG1G,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAuB,CAAA;QACvD,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QACzB,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;QAC5C,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC3B,aAAa,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,OAAO,EAAE,2BAA2B,CAAC,QAAQ,CAAC,CAAC,CAAA;YACpF,aAAa,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,KAAK,EAAE,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAA;QAErF,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,SAAS,GAAG,IAAI,CAAC,CAAA;IAC7D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,8DAA8D,CAAC,CAAA;IACzF,CAAC;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorter.d.ts","sourceRoot":"","sources":["../../src/serialization/sorter.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,SAAgB,MAAM,kBAMnD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { extname } from "path";
|
|
2
|
+
import { readChunk, sortedSerializationChunk, writeJsonAsFile } from "@lionweb/utilities";
|
|
3
|
+
export const sortSerialization = async (path) => {
|
|
4
|
+
const chunk = await readChunk(path);
|
|
5
|
+
const extLessPath = path.substring(0, path.length - extname(path).length);
|
|
6
|
+
const sortedJson = sortedSerializationChunk(chunk);
|
|
7
|
+
writeJsonAsFile(extLessPath + ".sorted.json", sortedJson);
|
|
8
|
+
console.log(`sorted: "${path}" -> ${extLessPath}`);
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=sorter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorter.js","sourceRoot":"","sources":["../../src/serialization/sorter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAC,SAAS,EAAE,wBAAwB,EAAE,eAAe,EAAC,MAAM,oBAAoB,CAAA;AAGvF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IACpD,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;IACzE,MAAM,UAAU,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAA;IAClD,eAAe,CAAC,WAAW,GAAG,cAAc,EAAE,UAAU,CAAC,CAAA;IACzD,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,QAAQ,WAAW,EAAE,CAAC,CAAA;AACtD,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textualizer.d.ts","sourceRoot":"","sources":["../../src/serialization/textualizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textualizer.d.ts","sourceRoot":"","sources":["../../src/serialization/textualizer.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,wBAAwB,SAAgB,MAAM,EAAE,kBAW5D,CAAA"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import { writeFile } from "fs/promises";
|
|
2
2
|
import { extname } from "path";
|
|
3
|
-
import { genericAsTreeText, readChunk, tryLoadAllAsLanguages } from "@lionweb/utilities";
|
|
3
|
+
import { genericAsTreeText, languagesAsText, looksLikeSerializedLanguages, readChunk, tryLoadAllAsLanguages } from "@lionweb/utilities";
|
|
4
|
+
import { deserializeLanguages } from "@lionweb/core";
|
|
5
|
+
const languagesAsRegularFlag = "--languagesAsRegular";
|
|
4
6
|
export const executeTextualizeCommand = async (args) => {
|
|
5
|
-
const
|
|
7
|
+
const languagesAsRegular = args.some((arg) => arg === languagesAsRegularFlag);
|
|
8
|
+
const otherArgs = args.filter((arg) => arg !== languagesAsRegularFlag);
|
|
9
|
+
const indexLanguageArg = otherArgs.findIndex((arg) => arg === "--language" || arg === "--languages");
|
|
6
10
|
const languages = indexLanguageArg > -1
|
|
7
|
-
? await tryLoadAllAsLanguages(
|
|
11
|
+
? await tryLoadAllAsLanguages(otherArgs.slice(indexLanguageArg + 1))
|
|
8
12
|
: [];
|
|
9
|
-
const chunkPaths =
|
|
13
|
+
const chunkPaths = otherArgs.slice(0, indexLanguageArg > -1 ? indexLanguageArg : undefined);
|
|
10
14
|
chunkPaths.forEach((chunkPath) => {
|
|
11
|
-
textualizeSerializationChunk(chunkPath, languages);
|
|
15
|
+
textualizeSerializationChunk(chunkPath, languagesAsRegular, languages);
|
|
12
16
|
});
|
|
13
17
|
};
|
|
14
|
-
const textualizeSerializationChunk = async (path, languages = []) => {
|
|
18
|
+
const textualizeSerializationChunk = async (path, languagesAsRegular, languages = []) => {
|
|
15
19
|
const chunk = await readChunk(path);
|
|
16
20
|
const extLessPath = path.substring(0, path.length - extname(path).length);
|
|
17
|
-
await writeFile(extLessPath + ".txt",
|
|
21
|
+
await writeFile(extLessPath + ".txt", looksLikeSerializedLanguages(chunk) && !languagesAsRegular
|
|
22
|
+
? languagesAsText(deserializeLanguages(chunk))
|
|
23
|
+
: genericAsTreeText(chunk, languages));
|
|
18
24
|
console.log(`textualized: ${path}`);
|
|
19
25
|
};
|
|
20
26
|
//# sourceMappingURL=textualizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textualizer.js","sourceRoot":"","sources":["../../src/serialization/textualizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"textualizer.js","sourceRoot":"","sources":["../../src/serialization/textualizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAA;AAC5B,OAAO,EACH,iBAAiB,EACjB,eAAe,EACf,4BAA4B,EAC5B,SAAS,EACT,qBAA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,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;IACzE,MAAM,SAAS,CACX,WAAW,GAAG,MAAM,EACpB,4BAA4B,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB;QACtD,CAAC,CAAC,eAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,CAC5C,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQhD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { validateFileResultWithLanguage } from "@lionweb/validation";
|
|
2
|
+
export function runValidation(file) {
|
|
3
|
+
console.log(`Validating ${file}`);
|
|
4
|
+
const validationResult = validateFileResultWithLanguage(file);
|
|
5
|
+
console.log(validationResult.hasErrors()
|
|
6
|
+
? validationResult.issues.map(issue => issue.errorMsg()).join("\n")
|
|
7
|
+
: "No errors found");
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,8BAA8B,EAAC,MAAM,qBAAqB,CAAA;AAGlE,MAAM,UAAU,aAAa,CAAC,IAAY;IACtC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAA;IACjC,MAAM,gBAAgB,GAAG,8BAA8B,CAAC,IAAI,CAAC,CAAA;IAC7D,OAAO,CAAC,GAAG,CACP,gBAAgB,CAAC,SAAS,EAAE;QACxB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QACnE,CAAC,CAAC,iBAAiB,CAC1B,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/cli",
|
|
3
|
-
"version": "0.6.0
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "LionWeb CLI for {Java|Type}Script",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lionweb-cli": "./dist/lionweb-cli.js"
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lionweb/core": "0.6.0
|
|
22
|
-
"@lionweb/utilities": "0.6.0
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/node": "20.10.4",
|
|
26
|
-
"typescript": "5.3.3"
|
|
21
|
+
"@lionweb/core": "0.6.0",
|
|
22
|
+
"@lionweb/utilities": "0.6.0"
|
|
27
23
|
},
|
|
28
24
|
"scripts": {
|
|
29
|
-
"
|
|
25
|
+
"clean": "rm -rf dist/ lionweb-cli-*.tgz",
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"lint": "eslint src",
|
|
28
|
+
"test": "node dist/lionweb-cli.js",
|
|
29
|
+
"release": "npm publish"
|
|
30
30
|
}
|
|
31
31
|
}
|
package/build.sh
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/serialization/extractor.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,wBAAwB,SAAgB,MAAM,kBAU1D,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from "fs";
|
|
2
|
-
import { extname } from "path";
|
|
3
|
-
import { deserializeLanguages } from "@lionweb/core";
|
|
4
|
-
import { languagesAsText, looksLikeSerializedLanguages, readChunk, shortenedSerializationChunk, sortedSerializationChunk, writeJsonAsFile } from "@lionweb/utilities";
|
|
5
|
-
export const extractFromSerialization = async (path) => {
|
|
6
|
-
const chunk = await readChunk(path);
|
|
7
|
-
const extLessPath = path.substring(0, path.length - extname(path).length);
|
|
8
|
-
const sortedJson = sortedSerializationChunk(chunk);
|
|
9
|
-
writeJsonAsFile(extLessPath + ".sorted.json", sortedJson);
|
|
10
|
-
writeJsonAsFile(extLessPath + ".shortened.json", shortenedSerializationChunk(chunk)); // (could also sort)
|
|
11
|
-
if (looksLikeSerializedLanguages(chunk)) {
|
|
12
|
-
writeFileSync(extLessPath + ".txt", languagesAsText(deserializeLanguages(chunk)));
|
|
13
|
-
}
|
|
14
|
-
console.log(`extracted: "${path}" -> ${extLessPath}`);
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=extractor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.js","sourceRoot":"","sources":["../../src/serialization/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,IAAI,CAAA;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAA;AAClD,OAAO,EACH,eAAe,EACf,4BAA4B,EAC5B,SAAS,EACT,2BAA2B,EAC3B,wBAAwB,EACxB,eAAe,EAClB,MAAM,oBAAoB,CAAA;AAG3B,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAA;IACzE,MAAM,UAAU,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAA;IAClD,eAAe,CAAC,WAAW,GAAG,cAAc,EAAE,UAAU,CAAC,CAAA;IACzD,eAAe,CAAC,WAAW,GAAG,iBAAiB,EAAE,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAA,CAAG,oBAAoB;IAC3G,IAAI,4BAA4B,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,aAAa,CAAC,WAAW,GAAG,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACrF,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,QAAQ,WAAW,EAAE,CAAC,CAAA;AACzD,CAAC,CAAA"}
|