Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add CLI doc pages #90

Merged
merged 4 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .scripts/load-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ for (const component of components_yaml.components) {
const component_version_file = Path.join(component_path, '.version')

if (!fs.existsSync(component_version_file) || fs.readFileSync(component_version_file).toString() != component.version) {
if(fs.existsSync(component_path))
fs.rmSync(component_path, { recursive: true})
if (fs.existsSync(component_path))
fs.rmSync(component_path, { recursive: true })

fs.mkdirSync(component_path, { recursive: true })

const fileName = `${component.filePrefix}-${component.version}.zip`
const file_path = Path.join(component_path, fileName)
const fileName = component.containsVersion ? `${component.filePrefix}-${component.version}.zip` : `${component.filePrefix}.zip`;
const file_path = Path.join(component_path, fileName);
const downloaded_stream = fs.createWriteStream(file_path);

const url = `${component.url}/releases/download/${component.version}/${fileName}`
Expand All @@ -37,7 +37,7 @@ for (const component of components_yaml.components) {
const file_content = fs.readFileSync(file_path)
const jszip_instance = new JSZip()
const result = await jszip_instance.loadAsync(file_content)
for(let key of Object.keys(result.files)) {
for (let key of Object.keys(result.files)) {
const item = result.files[key];
if (item.dir) {
fs.mkdirSync(Path.join(component_path, item.name))
Expand Down
5 changes: 5 additions & 0 deletions doc-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ components:
url: https://github.com/lenra-io/components-api
version: v1.0.0-beta.81
filePrefix: lenra-api-docs
containsVersion: true
- name: cli
url: https://github.com/lenra-io/lenra_cli
version: v1.0.0-beta.27
filePrefix: lenra-cli-docs
2 changes: 1 addition & 1 deletion src/markdown/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ First of all, you have to install [git](https://git-scm.com/book/en/v2/Getting-S
Simply install the latest package using the cargo-cli.

```bash
cargo install lenra_cli@version
cargo install lenra_cli@~1.0.0-beta.0
```

For more installation instructions, you can directly check the CLI repository.
Expand Down
6 changes: 3 additions & 3 deletions src/markdown/guides/todo-list-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description: How to create a first app ? Look at this guide to create a todo list app.
---

Now that you know the basics of a lenra app, we can create our first app : a basic TODO List.
Now that you know the basics of a Lenra app, we can create our first app : a basic TODO List.

> Note : To follow this guide, you must have basic knowledge about javascript, Mongo query language and API call (using axios).

Expand Down Expand Up @@ -342,9 +342,9 @@ As you can see, we use the same component that we used to call the `addTaskForm`

The `coll` property defines the **collection** where we want to run the query.

Then the `query` is a [simple mongo query](https://www.mongodb.com/docs/manual/tutorial/query-documents/) with the lenra specificity : the `@me` to reference the current user. It is the same trick we used to create our task before. This query will filter the `tasks` collection to give us only the task associated with the current user. The result of this query is the `data` argument in our view function.
Then the `query` is a [simple mongo query](https://www.mongodb.com/docs/manual/tutorial/query-documents/) with the Lenra specificity : the `@me` to reference the current user. It is the same trick we used to create our task before. This query will filter the `tasks` collection to give us only the task associated with the current user. The result of this query is the `data` argument in our view function.

And we’re done ! Restart the lenra CLI (`lenra dev`). The task list should now be visible !
And we’re done ! Restart the Lenra CLI (`lenra dev`). The task list should now be visible !

## Add some features

Expand Down
12 changes: 6 additions & 6 deletions src/views/.menu.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
- }


mixin createMenuItem(menuPage)
mixin createMenuItem(menuPage, level)
- let pageName = menuPage.properties.name || menuPage.properties.title;
- let className = menuPage.properties.icon ? "lenra-icon-" + menuPage.properties.icon : "";
a(class=className href='/'+menuPage.href)= pageName
- let subPages = childrenPages(menuPage);
if (subPages.length)
if (subPages.length && level<3)
details(open=currentPage.path.startsWith(menuPage.href))
summary Open/Close
ul
+createMenuItems(subPages)
+createMenuItems(subPages, level + 1)


mixin createMenuItems(pages)
mixin createMenuItems(pages, level)
each page in pages
li(class=(page.path==currentPage.path ? 'selected' : ''))
+createMenuItem(page)
+createMenuItem(page, level)

menu.invert-colors
+createMenuItems(childrenPages())
+createMenuItems(childrenPages(), 1)