From 52347e1fa8f22e8e02341badba30179804a6eed4 Mon Sep 17 00:00:00 2001 From: Thomas DA ROCHA <8969556+taorepoara@users.noreply.github.com> Date: Mon, 10 Apr 2023 12:21:48 +0200 Subject: [PATCH] feat: Add CLI doc pages (#90) * feat: Add CLI doc pages * fix: Uppercase L for Lenra * feat: Upgrade CLI doc version * fix: Cargo install version --- .scripts/load-api.js | 10 +++++----- doc-deps.yml | 5 +++++ src/markdown/getting-started/install.md | 2 +- src/markdown/guides/todo-list-app.md | 6 +++--- src/views/.menu.pug | 12 ++++++------ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.scripts/load-api.js b/.scripts/load-api.js index 4d3ca4d..e7f2638 100644 --- a/.scripts/load-api.js +++ b/.scripts/load-api.js @@ -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}` @@ -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)) diff --git a/doc-deps.yml b/doc-deps.yml index d1986b8..9a4cba2 100644 --- a/doc-deps.yml +++ b/doc-deps.yml @@ -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 diff --git a/src/markdown/getting-started/install.md b/src/markdown/getting-started/install.md index 8e7fe0b..843d3d1 100644 --- a/src/markdown/getting-started/install.md +++ b/src/markdown/getting-started/install.md @@ -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. diff --git a/src/markdown/guides/todo-list-app.md b/src/markdown/guides/todo-list-app.md index 936dbcc..3bb059d 100644 --- a/src/markdown/guides/todo-list-app.md +++ b/src/markdown/guides/todo-list-app.md @@ -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). @@ -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 diff --git a/src/views/.menu.pug b/src/views/.menu.pug index 583154d..bfb7679 100644 --- a/src/views/.menu.pug +++ b/src/views/.menu.pug @@ -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)