Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zakarialaoui10/dir2tree
a user-friendly Node.js tool for creating organized json tree from a root directory .
https://github.com/zakarialaoui10/dir2tree
automation github-actions javascript json morocco nodejs tree-structure
Last synced: 7 days ago
JSON representation
a user-friendly Node.js tool for creating organized json tree from a root directory .
- Host: GitHub
- URL: https://github.com/zakarialaoui10/dir2tree
- Owner: zakarialaoui10
- License: mit
- Created: 2023-06-18T18:25:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-04T21:03:34.000Z (8 months ago)
- Last Synced: 2024-04-04T22:23:41.275Z (8 months ago)
- Topics: automation, github-actions, javascript, json, morocco, nodejs, tree-structure
- Language: JavaScript
- Homepage:
- Size: 71.5 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Demo
[Want to try !](https://replit.com/@zakariaelalaoui/dir2tree#generated.json)
## Install ![npm](https://img.shields.io/npm/v/dir2tree)
```bash
npm install dir2tree
```
## Import
### Common Js
```js
const dir2tree=require("dir2tree")
```
### Es Module
```js
import dir2tree from dir2tree
```
## Syntaxe
### Initialise
```js
const MyTree=dir2tree(ROOT,OPTIONS,CALLBACKS)
MyTree.write(Target,"generated_file.json")
```
#### Arguments
- **`ROOT`** : The path to the root directory that we want handle. it's ***`required`***
- **`OPTIONS`** : An object containing various configuration options to control the behavior of the tree generation.it's ***`optional`*** , These options might include :
- **`fileContent`** : (***Boolean***)
- **`fileName`** : (***Boolean***)
- **`fileExtension`** : (***Boolean***)
- **`length`** : (***Boolean***)
- **`size`** : (***Boolean***)
- **`linesCount`** : (***Boolean***)
- **`created`** : (***Boolean***)
- **`lastModified`** : (***Boolean***)
- **`skip`** :
- **`folder`** : (***String[]***)
- **`file`** : (***String[]***)
- **`extension`** : (***String[]***)
- **`sortBy`** : (***String***) , possible values : `"names"`,`"extension"`,`"size"`,`"lines"`,`"created"`,`"lastmodified"`,
- **`order`** : (***Number***)
- **`CALLBACKS`** : it's ***`optional`***
### Methodes
- **`.write(Target, filename)`**
- **`.flat(depth, separator)`**
### Use It in your Github Repository
Create a workflow file like the one below.
.github/workflow/dir2tree.yml
```yml
name: Generate Directory Tree using zakarialaoui10/dir2tree
on:
push:
branches:
- main
jobs:
build:
permissions :
contents : write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Generate Directory Tree
uses: zakarialaoui10/dir2tree@main
- name: Commit & Push
run: |
git config user.name github-actions
git config user.email [email protected]
git add -A .
git commit -m "generated by zakarialaoui10/dir2tree"
git push
env:
CUSTOM_TOKEN: ${{ secrets.CUSTOM_TOKEN }}
```
## License
This projet is licensed under the terms of MIT License .