@lionweb/cli 0.5.0-beta.8 → 0.5.0-beta.9
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 +23 -6
- package/dist/m3/ts-types-generator.d.ts.map +1 -1
- package/dist/m3/ts-types-generator.js +7 -6
- package/dist/m3/ts-types-generator.js.map +1 -1
- package/dist/serialization-extractor.d.ts.map +1 -1
- package/dist/serialization-extractor.js +9 -18
- package/dist/serialization-extractor.js.map +1 -1
- package/package.json +6 -4
- package/CHANGELOG.md +0 -8
package/README.md
CHANGED
|
@@ -15,12 +15,6 @@ $ npx @lionweb/cli
|
|
|
15
15
|
|
|
16
16
|
produces information about which commands are available.
|
|
17
17
|
|
|
18
|
-
Build the executable from source as follows:
|
|
19
|
-
|
|
20
|
-
```shell
|
|
21
|
-
$ ./build.sh
|
|
22
|
-
```
|
|
23
|
-
|
|
24
18
|
|
|
25
19
|
## Extracting essential information from a serialization chunk
|
|
26
20
|
|
|
@@ -43,3 +37,26 @@ These extractions are:
|
|
|
43
37
|
This CLI utility does not perform any explicit validation apart from the file at the given path existing and being valid JSON.
|
|
44
38
|
It does some implicit validation as it can error out on incorrect serializations.
|
|
45
39
|
|
|
40
|
+
|
|
41
|
+
## Changelog
|
|
42
|
+
|
|
43
|
+
### 0.5.0
|
|
44
|
+
|
|
45
|
+
This is the first version corresponding to a release of LionWeb (version: 2023.1) as a whole.
|
|
46
|
+
|
|
47
|
+
* Make language-related functionality "multi-lingual", i.e. a serialization chunk can contain multiple `Language`s.
|
|
48
|
+
* (Languages will be sorted by name.)
|
|
49
|
+
* Improve extraction functionality: only catch JSON-parsing exceptions.
|
|
50
|
+
* Configure single entrypoint named `lionweb-cli`.
|
|
51
|
+
|
|
52
|
+
No changelog has been kept for previous versions, regardless of whether these were published or not.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Development
|
|
56
|
+
|
|
57
|
+
Build the executable from source as follows:
|
|
58
|
+
|
|
59
|
+
```shell
|
|
60
|
+
$ ./build.sh
|
|
61
|
+
```
|
|
62
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-types-generator.d.ts","sourceRoot":"","sources":["../../src/m3/ts-types-generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ts-types-generator.d.ts","sourceRoot":"","sources":["../../src/m3/ts-types-generator.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,mBAAmB,SAAgB,MAAM,EAAE,kBAWvD,CAAA"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { extname } from "path";
|
|
2
2
|
import { writeFileSync } from "fs";
|
|
3
|
-
import { GenerationOptions, readFileAsJson, tsTypesForLanguage } from "@lionweb/utilities";
|
|
4
3
|
import { deserializeLanguages } from "@lionweb/core";
|
|
4
|
+
import { GenerationOptions, readChunk, tsTypesForLanguage } from "@lionweb/utilities";
|
|
5
5
|
const generateTsTypesFromSerialization = async (path, generationOptions) => {
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
7
|
+
const languages = deserializeLanguages(await readChunk(path));
|
|
8
|
+
const extLessPath = path.substring(0, path.length - extname(path).length);
|
|
9
|
+
const tsFilePath = extLessPath + "-types.ts";
|
|
10
|
+
// TODO generate 1 file per Language:
|
|
11
11
|
writeFileSync(tsFilePath, languages.map((language) => tsTypesForLanguage(language, ...generationOptions)).join("\n\n"));
|
|
12
12
|
console.log(`generated TS types: "${path}" -> "${tsFilePath}"`);
|
|
13
13
|
}
|
|
14
|
-
catch (
|
|
14
|
+
catch (e) {
|
|
15
15
|
console.error(`"${path}" does not point to a valid JSON serialization of a language`);
|
|
16
|
+
throw e;
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
19
|
export const generateTsTypesWith = async (args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-types-generator.js","sourceRoot":"","sources":["../../src/m3/ts-types-generator.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AAmB,GAAG,KAAK,EAAE,IAAc,EAAE,EAAE;IACxD,MAAM,iBAAiB,GAAG,IAAI;SACzB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACrC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SAC3C,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,iBAAiB,CAAC;QACxD,8DAA8D;SACrD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAE,iBAAyB,CAAC,MAAM,CAAC,CAAC,CAAA,CAAI,wDAAwD;IAEpH,IAAI;SACC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACtC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gCAAgC,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAA;AACrF,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization-extractor.d.ts","sourceRoot":"","sources":["../src/serialization-extractor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialization-extractor.d.ts","sourceRoot":"","sources":["../src/serialization-extractor.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,wBAAwB,SAAgB,MAAM,kBAU1D,CAAA"}
|
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
import { writeFileSync } from "fs";
|
|
2
2
|
import { extname } from "path";
|
|
3
3
|
import { currentSerializationFormatVersion, deserializeLanguages, lioncoreKey } from "@lionweb/core";
|
|
4
|
-
import {
|
|
4
|
+
import { languagesAsText, readChunk, shortenedSerialization, sortedSerialization, writeJsonAsFile } from "@lionweb/utilities";
|
|
5
5
|
const isRecord = (json) => typeof json === "object" && !Array.isArray(json);
|
|
6
6
|
const isSerializedLanguages = (json) => isRecord(json)
|
|
7
7
|
&& json["serializationFormatVersion"] === currentSerializationFormatVersion
|
|
8
8
|
&& "languages" in json
|
|
9
9
|
&& Array.isArray(json["languages"])
|
|
10
10
|
&& json["languages"].some((language) => isRecord(language) && language["key"] === lioncoreKey);
|
|
11
|
-
const readChunk = async (path) => {
|
|
12
|
-
try {
|
|
13
|
-
return readFileAsJson(path);
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
console.error(`"${path}" is not a valid JSON file`);
|
|
17
|
-
throw e;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
11
|
export const extractFromSerialization = async (path) => {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const sortedJson = sortedSerialization(
|
|
24
|
-
writeJsonAsFile(
|
|
25
|
-
writeJsonAsFile(
|
|
26
|
-
if (isSerializedLanguages(
|
|
27
|
-
writeFileSync(
|
|
12
|
+
const chunk = await readChunk(path);
|
|
13
|
+
const extLessPath = path.substring(0, path.length - extname(path).length);
|
|
14
|
+
const sortedJson = sortedSerialization(chunk);
|
|
15
|
+
writeJsonAsFile(extLessPath + ".sorted.json", sortedJson);
|
|
16
|
+
writeJsonAsFile(extLessPath + ".shortened.json", shortenedSerialization(chunk)); // (could also sort)
|
|
17
|
+
if (isSerializedLanguages(chunk)) {
|
|
18
|
+
writeFileSync(extLessPath + ".txt", languagesAsText(deserializeLanguages(chunk)));
|
|
28
19
|
}
|
|
29
|
-
console.log(`extracted: "${path}" -> "${
|
|
20
|
+
console.log(`extracted: "${path}" -> "${extLessPath}"`);
|
|
30
21
|
};
|
|
31
22
|
//# sourceMappingURL=serialization-extractor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization-extractor.js","sourceRoot":"","sources":["../src/serialization-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,IAAI,CAAA;AAChC,OAAO,EAAC,OAAO,EAAC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G,mBAAmB,CAAC,KAAK,CAAC,CAAA;IAC7C,eAAe,CAAC,WAAW,GAAG,cAAc,EAAE,UAAU,CAAC,CAAA;IACzD,eAAe,CAAC,WAAW,GAAG,iBAAiB,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAA,CAAG,oBAAoB;IACtG,IAAI,qBAAqB,CAAC,KAAK,CAAC,EAAE;QAC9B,aAAa,CAAC,WAAW,GAAG,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACpF;IACD,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,SAAS,WAAW,GAAG,CAAC,CAAA;AAC3D,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/cli",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.9",
|
|
4
4
|
"description": "LionWeb CLI for {Java|Type}Script",
|
|
5
|
-
"bin":
|
|
5
|
+
"bin": {
|
|
6
|
+
"lionweb-cli": "./dist/lionweb-cli.js"
|
|
7
|
+
},
|
|
6
8
|
"main": "dist/index.js",
|
|
7
9
|
"types": "dist/index.d.ts",
|
|
8
10
|
"typings": "dist/index.d.ts",
|
|
@@ -16,8 +18,8 @@
|
|
|
16
18
|
"url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@lionweb/core": "0.5.0-beta.
|
|
20
|
-
"@lionweb/utilities": "0.5.0-beta.
|
|
21
|
+
"@lionweb/core": "0.5.0-beta.9",
|
|
22
|
+
"@lionweb/utilities": "0.5.0-beta.9"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@types/node": "20.6.3",
|
package/CHANGELOG.md
DELETED