1.0.0-beta.1 • Published 2 years ago

directory-json-formatter v1.0.0-beta.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Directory JSON Formatter

The Directory JSON Formatter is a Node.js package that allows you to generate a JSON representation of the directory structure of a project. It uses the fs and path modules to recursively traverse the directory tree and build a JSON object that represents the directory structure.

Table of Contents

Features

Generates a JSON representation of the directory structure of a project

  • Excludes the .git directory from the output
  • Includes .js files in the output

Installation

You can install the Directory JSON Formatter package using npm: npm install directory-json-formatter

Usage

To use the Directory JSON Formatter package, you can import the listFilesAndFolders function from the package and call it with the path to the directory you want to generate the JSON for. For example:

import listFilesAndFolders from 'directory-json-formatter';
const data = { root: { files: [] } };
await listFilesAndFolders('.', '', data.root);
console.log(JSON.stringify(data, null, 2));

This will generate a JSON representation of the directory structure of the current working directory and log it to the console.

Testing

The Directory JSON Formatter package includes a set of unit tests that you can run using the npm test command.

Dependencies

Main Dependencies

  • fs: Node.js built-in module for working with the file system
  • path: Node.js built-in module for working with file paths
  • url: Node.js built-in module for working with URLs

Development Dependencies

  • mocha: Test framework for Node.js
  • assert: Assertion library for Node.js

Project structure

{
  "root": {
    "files": [
      "index.js",
      "package-lock.json",
      "package.json"
    ],
    "dir-formatter": {
      "files": []
    },
    "node_modules": [
      ".bin",
      "ansi-colors",
      "ansi-regex",
      "ansi-styles",
      "anymatch",
      "argparse",
      "balanced-match",
      "binary-extensions",
      "brace-expansion",
      "braces",
      "browser-stdout",
      "camelcase",
      "chalk",
      "chokidar",
      "cliui",
      "color-convert",
      "color-name",
      "concat-map",
      "debug",
      "decamelize",
      "diff",
      "emoji-regex",
      "escalade",
      "escape-string-regexp",
      "fill-range",
      "find-up",
      "flat",
      "fs",
      "fs.realpath",
      "get-caller-file",
      "glob",
      "glob-parent",
      "has-flag",
      "he",
      "inflight",
      "inherits",
      "is-binary-path",
      "is-extglob",
      "is-fullwidth-code-point",
      "is-glob",
      "is-number",
      "is-plain-obj",
      "is-unicode-supported",
      "js-yaml",
      "locate-path",
      "log-symbols",
      "minimatch",
      "mocha",
      "ms",
      "nanoid",
      "normalize-path",
      "once",
      "p-limit",
      "p-locate",
      "path",
      "path-exists",
      "path-is-absolute",
      "picomatch",
      "process",
      "randombytes",
      "readdirp",
      "require-directory",
      "safe-buffer",
      "serialize-javascript",
      "string-width",
      "strip-ansi",
      "strip-json-comments",
      "supports-color",
      "to-regex-range",
      "util",
      "workerpool",
      "wrap-ansi",
      "wrappy",
      "y18n",
      "yargs",
      "yargs-parser",
      "yargs-unparser",
      "yocto-queue"
    ],
    "test": {
      "files": [
        "test.js"
      ]
    }
  }
}
1.0.0-beta.1

2 years ago