@likec4/generators 1.33.0 → 1.34.1
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/model/generate-likec4-model.d.ts +1 -1
- package/dist/model/generate-likec4-model.js +13 -16
- package/package.json +3 -3
- package/src/model/__snapshots__/likec4.computed-model.snap +1 -1
- package/src/model/__snapshots__/likec4.parsed-model.snap +1 -1
- package/src/model/generate-aux.spec.ts +1 -1
- package/src/model/generate-likec4-model.ts +13 -16
- /package/src/model/__snapshots__/{aux.generate-valid-code.snap → _aux.generate-valid-code.snap} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LikeC4Model } from '@likec4/core/model';
|
|
2
|
-
export declare function generateLikeC4Model(model: LikeC4Model<any>):
|
|
2
|
+
export declare function generateLikeC4Model(model: LikeC4Model<any>): string;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
import JSON5 from "json5";
|
|
2
|
-
import { CompositeGeneratorNode, toString } from "langium/generate";
|
|
3
2
|
import { capitalize } from "remeda";
|
|
4
3
|
import { generateAux } from "./generate-aux.js";
|
|
5
4
|
export function generateLikeC4Model(model) {
|
|
6
|
-
const out = new CompositeGeneratorNode();
|
|
7
5
|
const aux = generateAux(model);
|
|
8
6
|
const ModelData = capitalize(model.stage) + "LikeC4ModelData";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return `
|
|
8
|
+
/* prettier-ignore-start */
|
|
9
|
+
/* eslint-disable */
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
/******************************************************************************
|
|
12
|
+
* This file was generated
|
|
13
|
+
* DO NOT EDIT MANUALLY!
|
|
14
|
+
******************************************************************************/
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import { LikeC4Model } from '@likec4/core/model'
|
|
17
|
+
import type { ${ModelData} } from '@likec4/core/types'
|
|
18
|
+
${aux}
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(<${ModelData}<$Aux>>(${JSON5.stringify(model.$data, { space: 2, quote: "'" })} as unknown))
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return toString(out);
|
|
22
|
+
/* prettier-ignore-end */
|
|
23
|
+
`.trimStart();
|
|
27
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/generators",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
6
6
|
"homepage": "https://likec4.dev",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"json5": "^2.2.3",
|
|
35
35
|
"langium": "3.5.0",
|
|
36
36
|
"remeda": "^2.23.1",
|
|
37
|
-
"@likec4/core": "1.
|
|
37
|
+
"@likec4/core": "1.34.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "~20.19.1",
|
|
41
41
|
"typescript": "5.8.3",
|
|
42
42
|
"unbuild": "3.5.0",
|
|
43
43
|
"vitest": "3.2.4",
|
|
44
|
-
"@likec4/tsconfig": "1.
|
|
44
|
+
"@likec4/tsconfig": "1.34.1"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"typecheck": "tsc -b --verbose",
|
|
@@ -60,6 +60,6 @@ describe('generateAux', () => {
|
|
|
60
60
|
|
|
61
61
|
it('generate valid code', async ({ expect }) => {
|
|
62
62
|
const aux = generateAux(m.toLikeC4Model())
|
|
63
|
-
await expect(aux).toMatchFileSnapshot('__snapshots__/
|
|
63
|
+
await expect(aux).toMatchFileSnapshot('__snapshots__/_aux.generate-valid-code.snap')
|
|
64
64
|
})
|
|
65
65
|
})
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import type { LikeC4Model } from '@likec4/core/model'
|
|
2
2
|
import JSON5 from 'json5'
|
|
3
|
-
import { CompositeGeneratorNode, toString } from 'langium/generate'
|
|
4
3
|
import { capitalize } from 'remeda'
|
|
5
4
|
import { generateAux } from './generate-aux'
|
|
6
5
|
|
|
7
6
|
export function generateLikeC4Model(model: LikeC4Model<any>) {
|
|
8
|
-
const out = new CompositeGeneratorNode()
|
|
9
7
|
const aux = generateAux(model)
|
|
10
8
|
const ModelData = capitalize(model.stage) + 'LikeC4ModelData'
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return `
|
|
11
|
+
/* prettier-ignore-start */
|
|
12
|
+
/* eslint-disable */
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
/******************************************************************************
|
|
15
|
+
* This file was generated
|
|
16
|
+
* DO NOT EDIT MANUALLY!
|
|
17
|
+
******************************************************************************/
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
import { LikeC4Model } from '@likec4/core/model'
|
|
20
|
+
import type { ${ModelData} } from '@likec4/core/types'
|
|
21
|
+
${aux}
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(<${ModelData}<$Aux>>(${
|
|
26
24
|
JSON5.stringify(model.$data, { space: 2, quote: '\'' })
|
|
27
25
|
} as unknown))
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return toString(out)
|
|
27
|
+
/* prettier-ignore-end */
|
|
28
|
+
`.trimStart()
|
|
32
29
|
}
|
/package/src/model/__snapshots__/{aux.generate-valid-code.snap → _aux.generate-valid-code.snap}
RENAMED
|
File without changes
|