Skip to content

Commit 899dab0

Browse files
authored
Merge pull request #22 from lokesh-coder/develop
Develop
2 parents 3f626ca + b021e91 commit 899dab0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1635
-74
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,31 @@
1414
<h3 align="center">
1515
> 𝙱𝚞𝚒𝚕𝚍 𝚖𝚘𝚍𝚎𝚛𝚗 𝚌𝚘𝚖𝚖𝚊𝚗𝚍-𝚕𝚒𝚗𝚎 𝚊𝚙𝚙𝚜_
1616
</h3>
17+
1718
<p align="center">
1819
<span>
1920
<a href="https://lesyjs.io/">Website</a>
2021
2122
<a href="https://lesyjs.io/docs/get-started/overview">Documentation</a>
2223
2324
<a href="https://codesandbox.io/s/lesy-pilot-playground-hzjgw?file=/src/index.js">Playground</a>
25+
26+
<a href="https://twitter.com/lesyjs">Twitter</a>
2427
</span>
2528
</p>
29+
30+
<h1></h1>
2631
<br/>
32+
<p align="center">
33+
34+
<img src="https://img.shields.io/coveralls/github/lokesh-coder/lesyjs?color=4a5874&labelColor=d5695f&style=flat-square"/>
35+
<img src="https://img.shields.io/github/workflow/status/lokesh-coder/lesyjs/Release?color=4a5874&labelColor=d5695f&style=flat-square"/>
36+
<img src="https://img.shields.io/npm/v/@lesy/core?color=4a5874&labelColor=d5695f&style=flat-square"/>
37+
<img src="https://img.shields.io/bundlephobia/minzip/@lesy/core?color=4a5874&labelColor=d5695f&label=core%20size%20&style=flat-square"/>
38+
<img src="https://img.shields.io/npm/dt/lesy?color=4a5874&labelColor=d5695f&style=flat-square"/>
39+
40+
</p>
41+
2742
<h1></h1>
2843

2944
## What is Lesy JS
@@ -74,8 +89,8 @@ Lesy can be installed from Lesy CLI or manually.
7489
Install `@lesy/compiler` via `npm` or `yarn`
7590

7691
```shell
77-
mkdir my-cli && cd my-cli
78-
npm install @lesy/compiler
92+
> mkdir my-cli && cd my-cli
93+
> npm install @lesy/compiler
7994
```
8095

8196
Then create a index file and add the below code
@@ -90,7 +105,7 @@ Lesy can be installed from Lesy CLI or manually.
90105
```
91106

92107
```shell
93-
./index hello
108+
> ./index hello
94109
```
95110

96111
## Lesy core parts

docs/package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/markdown/docs/dev/recipies/sample2.md

Lines changed: 99 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,43 @@ Few things are considered as rules while developing,
1818
First lets see how the code is organised.
1919

2020
```bash
21-
lesy/
22-
benchmark/
23-
docs/
24-
packages/
25-
cli/
26-
compiler/ # includes ts node if it is typescript project
27-
core/ # handles user input and output
28-
testbed/
29-
types/
30-
helpers/
31-
validator/
32-
misc/
33-
pilot-ui/
34-
test-utils/
35-
plugins/
36-
lesy-plugin-config/
37-
lesy-plugin-demo/
38-
lesy-plugin-generator/
39-
lesy-plugin-help/
40-
lesy-plugin-pilot/
41-
lesy-plugin-prompt/
42-
lesy-plugin-sidekick/
43-
lesy-plugin-store/
44-
lesy-plugin-validator/
21+
lesy
22+
├── benchmark/
23+
├── docs/
24+
└── packages/
25+
├── cli/
26+
├── compiler/ # includes ts node if it is typescript project
27+
├── core/ # handles user input and output
28+
├── testbed/
29+
├── types/
30+
├── helpers/
31+
│ └── validator/
32+
├── misc/
33+
│ ├── pilot-ui/
34+
│ └── test-utils/
35+
└── plugins/
36+
├── lesy-plugin-config/
37+
├── lesy-plugin-demo/
38+
├── lesy-plugin-generator/
39+
├── lesy-plugin-help/
40+
├── lesy-plugin-pilot/
41+
├── lesy-plugin-prompt/
42+
├── lesy-plugin-sidekick/
43+
├── lesy-plugin-store/
44+
└── lesy-plugin-validator/
4545
```
4646

4747
There were around **18 packages** in the lesy framework. But what really matters is `core` and `compiler`, others are supporting features.
4848

49+
> Below content is being updated with more examples and illustration.
50+
4951
### Core
5052

5153
As the name says, it is the heart <i class="ri-heart-3-fill text-primary"></i> of the project. Main responsibility of the core is take user commands, convert them to objects and run them. Nothing more. It is slim, and can live without other things in the project.
5254

5355
Core components include,
5456

55-
#### Command Contoller
57+
#### [Command Contoller](https://github.com/lokesh-coder/lesyjs/blob/master/packages/core/src/command.ts)
5658

5759
Takes commands, process and strore them in a nice format
5860

@@ -78,26 +80,96 @@ Orchestrate all the above components and run commands and middlewares
7880

7981
### Compiler
8082

83+
Compiler takes care of fewer tasks:
84+
85+
- If it is typescript project, loads ts-node to run ts files
86+
- If src file is provided, loads all files provided and pass to core
87+
- Runs code module and pass args provided in parse
88+
- Loads default plugins
89+
- Sets default config
90+
- If global workspace value is set, it just returns core promise.
91+
8192
### Plugins
8293

94+
Plugins directory consist of all lesy plugins
95+
8396
### Misc
8497

98+
It consist of two packages, Pilot UI and test utils. Both packages are internally used and not published to npm.
99+
100+
- Pilot UI is build with Angular and manages complete user interface logic. It is compiled and build by pilot plugin. Then the dist directory is served.
101+
102+
- Test utils used inside few of the packages. It contains few helper methods.
103+
85104
### Testbed
86105

106+
Used for integration test. Basically Testbed will run lesy with user provided data and collect all console output and returns.
107+
87108
### Types
88109

110+
Contains all the type definition files of the core package.
111+
89112
### CLI
90113

91-
### Helpers
114+
This package contains few lesy libraries and templates to scaffold new project based on the answers provided by users while initialising.
115+
116+
Unlike other packages, lesy CLI is not part of @lesy organisation in the npm. This is because, if it is under @lesy scope, then user have to do `npx @lesy/cli new my-cli`. To improve the user and developer experience, CLI package has been moved out of lesy org.
117+
118+
### Validator
119+
120+
This package is used to validate a object against a rules defined in another object. It works independently and not coupled with lesy in any way.
121+
122+
This library accepts custom rules.
123+
124+
### Compile and Build
92125

93-
### Build
126+
Lesy is build with node and typescript. And this project is maintained as a monorepo. Based on the need, either `ncc` or `tsc` compiler is used. `ncc` is mainly used to compress the file and reduce the size.
127+
128+
[lerna]() is used to handle bootstraping and executing build script in all projects.
94129

95130
### Release
96131

132+
[lerna]() is handle quite a few things here,
133+
134+
- Versioning based on **conventional commits**
135+
- Release all packages to npm
136+
- Create tag and push to github
137+
- Create release notes in github
138+
- Update CHANGELOG file
139+
- Update the new version in all package.json files
140+
97141
### Docs
98142

143+
Documentation is made using [gatsby](). All the markdown is build and published to `gh-pages` by the github actions.
144+
99145
### Pilot UI
100146

147+
Pilot UI is a angular project. Basically Pilot command in lesy will exposes necessary data though web sockets and Pilot UI receives and display.
148+
149+
When running command from UI, it send run signal and Pilot cmd runs the command and sends the ouput.
150+
101151
### Benchmark
102152

153+
[benny]() is used for benchmarking. [commander](), [gluegun](), and [yargs]() are used for comparition. The output JSON is used in the Performance page to represent as bar chart.
154+
103155
### How it works
156+
157+
<a href="/images/lesy-core-flow.png" target="_blank"><img src="/images/lesy-core-flow.png"/></a>
158+
159+
**core** has two main methods. `bootstrap` and `run`
160+
161+
**bootstrap(userData)**
162+
163+
- Takes the user provided data(commands, featutes, etc.,)
164+
- Passes all data to loader to extract the content.
165+
- Extracted content is saved in state
166+
- Executes middlewares hooked to `INIT` and `START`
167+
168+
**run(argv)**
169+
170+
- Takes user provided command args from the terminal or from `parse` method
171+
- Parse arguments and flags
172+
- Find the correct command from the args
173+
- Validate args and flags
174+
- Run command
175+
- During this flow it executes middlewares hooked to `PRE_PARSE`, `POST_PARSE`, `PRE_VALIDATE`,`PRE_RUN`,`END`

docs/src/markdown/docs/main/develop/roadmap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ icon: lightbulb-flash-fill
99
- Autocorrect mispelled args
1010
- Notification
1111

12+
### Others
13+
14+
- Support for desktop app
15+
- Allow pilot to show registered middlewares
16+
1217
<!-- ### Improvement for Pilot plugin-->

docs/src/markdown/docs/main/get-started/installation.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Setting up Lesy is pretty simple and straightforward. And there are two ways to
1111
One easy way is using `npx` to generate project boilerplate with one command.
1212

1313
```shell
14-
npx lesy my-cli
14+
npx lesy new my-cli
1515
```
1616

1717
Alternatively you can install **Lesy** globally with `npm` or `yarn`.
@@ -34,10 +34,10 @@ This will ask you few questions like, is it typescript project, install pilot. I
3434

3535
```shell
3636
# with npx
37-
npx lesy my-cli --yes
37+
npx lesy new my-cli --yes
3838

3939
# with global lesy
40-
lesy my-cli --yes
40+
lesy new my-cli --yes
4141
```
4242

4343
### Project structure
@@ -82,18 +82,9 @@ npm install @lesy/compiler
8282
#!/usr/bin/env node
8383

8484
const lesy = require("@lesy/compiler");
85+
const commands = [{ name: "hello", run: () => console.log("hello world") }];
8586

86-
lesy({
87-
root: __dirname,
88-
commands: [
89-
{
90-
name: "default",
91-
run: () => console.log("hello"),
92-
},
93-
"./src/commands",
94-
],
95-
/* ...other props */
96-
}).parse();
87+
lesy({ commands }).parse();
9788
```
9889

9990
**Step 4**: Update bin property in `package.json` file

docs/src/styles/tailwind.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ p {
6464
@apply leading-none;
6565
}
6666

67-
.content h4 a {
67+
.content h4 a.anchor {
6868
@apply hidden;
6969
}
7070

79.7 KB
Loading

lerna.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
"command": {
1212
"bootstrap": {
1313
"ignore": "@lesy/lesy-pilot-ui",
14-
"npmClientArgs": [
15-
"--no-package-lock"
16-
]
14+
"npmClientArgs": ["--no-package-lock"]
1715
},
1816
"version": {
19-
"message": "chore(release): 🎉 publish %s"
17+
"message": "chore(release): 🎉 publish %s",
18+
"ignoreChanges": [
19+
"./docs/**",
20+
"./benchmark/**",
21+
"/coverage/**",
22+
"**/__fixtures__/**",
23+
"**/__tests__/**",
24+
"**/*.md",
25+
"**/package-lock.json"
26+
]
2027
}
2128
}
2229
}

packages/core/__tests__/__snapshots__/core.spec.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Object {
8989
"getCommandById": [Function],
9090
"getCommandByName": [Function],
9191
"getCommands": [Function],
92+
"getMiddlewares": [Function],
9293
"runCommand": [Function],
9394
},
9495
"root": StringContaining "/packages/core/__tests__",

packages/core/__tests__/core.spec.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,29 @@ describe("Core", () => {
103103
it("should get all middlewares", () => {
104104
expect(core["mwCtrl"].get()).toEqual({
105105
END: [
106-
{ on: "END", run: expect.any(Function) },
107-
{ on: "END", run: expect.any(Function) },
106+
{ on: "END", run: expect.any(Function), source: "__OBJ__" },
107+
{
108+
on: "END",
109+
run: expect.any(Function),
110+
source: `${__dirname}/plugin/middleware.js`,
111+
},
112+
],
113+
INIT: [{ on: "INIT", run: expect.any(Function), source: "__OBJ__" }],
114+
POST_PARSE: [
115+
{ on: "POST_PARSE", run: expect.any(Function), source: "__OBJ__" },
108116
],
109-
INIT: [{ on: "INIT", run: expect.any(Function) }],
110-
POST_PARSE: [{ on: "POST_PARSE", run: expect.any(Function) }],
111117
POST_RUN: [],
112118
POST_VALIDATE: [],
113-
PRE_PARSE: [{ on: "PRE_PARSE", run: expect.any(Function) }],
114-
PRE_RUN: [{ on: "PRE_RUN", run: expect.any(Function) }],
115-
PRE_VALIDATE: [{ on: "PRE_VALIDATE", run: expect.any(Function) }],
116-
START: [{ on: "START", run: expect.any(Function) }],
119+
PRE_PARSE: [
120+
{ on: "PRE_PARSE", run: expect.any(Function), source: "__OBJ__" },
121+
],
122+
PRE_RUN: [
123+
{ on: "PRE_RUN", run: expect.any(Function), source: "__OBJ__" },
124+
],
125+
PRE_VALIDATE: [
126+
{ on: "PRE_VALIDATE", run: expect.any(Function), source: "__OBJ__" },
127+
],
128+
START: [{ on: "START", run: expect.any(Function), source: "__OBJ__" }],
117129
});
118130
});
119131
it("should get config", () => {

0 commit comments

Comments
 (0)