# fs-json-to-files

> fs-extra jsonfile fs-json-to-files Generate the corresponding file directory and file content based on the JSON configuration、 根据配置json生成对应的文件目录以及文件内容，

Latest version **1.0.5** (published 2024-01-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install fs-json-to-files
pnpm add fs-json-to-files
yarn add fs-json-to-files
bun add fs-json-to-files
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-01-04 |
| First published | 2023-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 104.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | xiangchuifeng |
| Maintainers | xiangchuifeng |
| Keywords | fs-extra, jsonfile, fs-json-to-files, write, json, file, mkdir, fs, extra, node-, fs- |

## Links

- npm: https://www.npmjs.com/package/fs-json-to-files
- Repository: https://github.com/xiangchuifeng/fs-json-to-files
- Homepage: https://github.com/xiangchuifeng/fs-json-to-files#readme
- Issues: https://github.com/xiangchuifeng/fs-json-to-files/issues
- npm.io page: https://npm.io/package/fs-json-to-files

## Dependencies (1)

- [minimist](https://npm.io/package/minimist.md) ^1.2.8

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.5 (latest) — 2024-01-04
- 1.0.4 — 2024-01-04
- 1.0.3 — 2023-12-05
- 1.0.2 — 2023-12-04
- 1.0.1 — 2023-12-04
- 1.0.0 — 2023-12-04

## README

# fs-json-to-files

<div align="center">
<img src="/images/tool-icon.png" width="400px" style="margin-left:200px;" />
</div>

use it, you can create you project folders by folder json data, width any you template content;

![v](https://img.shields.io/badge/fs--json--to--files-v1.0.5-brightgreen)


Installation
------------

    npm install fs-json-to-files


import it to your work root, if you create a project,if you need to create many files or folders, it can help you,  
at least, i think it

#### More specifically，this is a tool, generate your project folders,keep you folder structure, fill template content your configured;

i search in the web,many content about folders generate text tree, like:

```js
tree;
```

then it give me a snippet ![](/images/tree-result-text.png)

every time i build a new project, many folders、files require to create, need to fill content,  
if tree has reverse operation,it will be great;  
i search in the web, Almost no discovery of this feature；npm 、github 、or Blog、Forum；

so i did it , It took half a day , then It took another half day to publish。

### usage:

```js
// example.js

import { genFilesByJsonData } from "fs-json-to-files";
import { temps } from "./tmpData.js";
import { fileJsonData } from "./fileJsonData.js";

//  options?{ basePath}, default is your current folder,if need,you can config it with options.basePath
genFilesByJsonData(temps, fileJsonData,options?);
// You can use it when creating projects, updating requirements,
// and planning to create multiple file structures,
// instead of manually generating them one by one
```

![](/images/generated-folders.png)  
![](/images/generated-temp.png)

### his directory will be the current directory where your node command is executed

```js
  node example.js
```

### the fileJsonData example:

```js
// fileJsonData.js
// I prefer to use this data structure here,
// which is a one-to-one mapping of file structures without sub arrays such as children
// each Object will renerate one folder, the inner Object is also，done and done,
// if the value of key is type of string, it will be defined as a file,it can be followed a '-' ,
// the later is content template type that will fill.if no,the file will a empty file, no bad impact.

export const fileJsonData = {
  src: {
    views: {
      app: "app.vue-tempVue",
    },
    config: "config.js-tempA",
    common: {
      util: "util.js-tempA",
      data: {
        a: "a.js-tempA",
        b: {
          bb: "bb.js-tempB",
          cc: "cc.js-tempB",
        },
      },
    },
  },
};
```

### the temps example:

```js
// tmpData.js
// I have chosen to put the template type in a separate file, corresponding to the template in the JSON data file just now
export const temps = {
  tempVue: `
    <template>
      <div></div>
    </template>
    
    <script setup>
    
    </script>
    <style lang="less">
    
    </style>
  `,
  tempA: `
    export const A = ()=>{
      console.log('23333')
    }
  `,

  tempB: `
  export const B = ()=>{
    console.log('b3333')
  }
`,
};
```

---
_Source: https://npm.io/package/fs-json-to-files · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
