likec4 0.42.1 → 0.42.2

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 CHANGED
@@ -1,19 +1,13 @@
1
1
  # LikeC4
2
2
 
3
- `likec4` is a CLI tool for various operations and automation over LikeC4 projects, such as:
4
-
5
- 1. LikeC4
6
- 1. Install
7
- 1. Local installation
8
- 2. Global installation
9
- 2. Usage
10
- 1. Preview diagrams
11
- 2. Build static website
12
- 3. Export to PNG
13
- 4. Export to Mermaid, Dot, D2
14
- 5. Generate React components
15
- 6. Generate structured data
16
- 3. Support
3
+ `likec4` is a CLI tool for various operations and automation over LikeC4 projects.
4
+
5
+ Features:
6
+
7
+ - preview diagrams in a local web server (with fast hot-reload on changes)
8
+ - build a static website for sharing and embedding diagrams
9
+ - export to PNG, Mermaid, Dot, D2
10
+ - generate React components
17
11
 
18
12
  ## Install
19
13
 
@@ -39,7 +33,8 @@ You can reference it directly in the `package.json#scripts` object:
39
33
  }
40
34
  ```
41
35
 
42
- > Check out the template repository [likec4/template](https://github.com/likec4/template)
36
+ > **Template:**
37
+ > Check out the template repository [likec4/template](https://github.com/likec4/template)
43
38
  > with pre-configured CI for building and deploying to github pages.
44
39
 
45
40
  To use the binary, you can call it with [`npx`](https://docs.npmjs.com/cli/v10/commands/npx) while in the project directory:
@@ -64,47 +59,93 @@ likec4 ...
64
59
 
65
60
  ## Usage
66
61
 
62
+ > Refer to the help:
63
+ >
64
+ > ```sh
65
+ > likec4 build -h
66
+ > likec4 codegen react -h
67
+ > ```
68
+ >
69
+ > Almost all commands have a `--help` option and provide usage examples.
70
+
67
71
  ### Preview diagrams
68
72
 
69
73
  In a folder with LikeC4 sources:
70
74
 
71
75
  ```sh
72
76
  likec4 serve
77
+
78
+ # Aliases:
79
+ likec4 start
80
+ likec4 dev
73
81
  ```
74
82
 
75
- This will recursively search for `*.c4`, `*.likec4` files and serve them in a local web server.
83
+ This recursively searchs for `*.c4`, `*.likec4` files in current folder, parses and serves diagrams in a local web server.
84
+ Any changes in the sources trigger a super-fast hot update and you see changes in the browser immediately.
76
85
 
77
- Any changes to the sources will trigger a live-update of diagrams.
86
+ > **Tip:**
87
+ > You can use `likec4 serve [path]` in a separate terminal window and keep it running while you're editing diagrams in editor, or even serve multiple projects at once.
78
88
 
79
- Refer to the help for more options:
89
+ ### Build static website
90
+
91
+ Example [https://template.likec4.dev](https://template.likec4.dev/view/cloud)
92
+ Build a single-page application with all diagrams:
80
93
 
81
94
  ```sh
82
- likec4 serve --help
95
+ likec4 build -o ./dist
83
96
  ```
84
97
 
85
- ### Build static website
98
+ When you deploy the website, you can use "Share" button to get a link to a specific diagram.
99
+
100
+ > **Tip:**
101
+ > [likec4/template](https://github.com/likec4/template) repository demonstrates how to deploy to github pages.
102
+
103
+ There is also a supplementary command to preview the build:
86
104
 
87
105
  ```sh
88
- likec4 build -o ./dist
106
+ likec4 preview -o ./dist
89
107
  ```
90
108
 
91
- The output folder will contain a static website (single-page application).
92
-
93
109
  ### Export to PNG
94
110
 
95
- ...
111
+ ```sh
112
+ likec4 export png -o ./assets
113
+ ```
114
+
115
+ This command starts temporary local web server and uses [Playwright](https://playwright.dev/) to take screenshots of diagrams.
96
116
 
97
117
  ### Export to Mermaid, Dot, D2
98
118
 
99
- ...
119
+ Export to various formats via codegen:
120
+
121
+ ```sh
122
+ likec4 codegen mmd
123
+ likec4 codegen mermaid
124
+ likec4 codegen dot
125
+ likec4 codegen d2
126
+ ```
100
127
 
101
128
  ### Generate React components
102
129
 
103
- ...
130
+ ```sh
131
+ likec4 codegen react --outfile ./src/likec4.generated.tsx
132
+ ```
133
+
134
+ > Output file should have `.tsx` extension
135
+ > By default, it generates `likec4.generated.tsx` in current directory
104
136
 
105
137
  ### Generate structured data
106
138
 
107
- ...
139
+ ```sh
140
+ likec4 codegen views-data --outfile ./src/likec4.generated.ts
141
+
142
+ #Aliases
143
+ likec4 codegen views ...
144
+ likec4 codegen ts ...
145
+ ```
146
+
147
+ > Output file should have `.ts` extension
148
+ > By default, it generates `likec4.generated.ts` in current directory
108
149
 
109
150
  ## Support
110
151
 
@@ -1,5 +1,5 @@
1
1
  export function isElementRef(expr) {
2
- return "element" in expr && "isDescedants" in expr;
2
+ return "element" in expr;
3
3
  }
4
4
  export function isWildcard(expr) {
5
5
  return "wildcard" in expr;