Git Product home page Git Product logo

fs-json-to-files's Introduction

fs-json-to-files

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

v

Installation

npm install fs-json-to-files

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:

tree;

then it give me a snippet

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:

// example.js

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

genFilesByJsonData(temps, fileJsonData);
// You can use it when creating projects, updating requirements,
// and planning to create multiple file structures,
// instead of manually generating them one by one


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

  node example.js

the fileJsonData example:

// 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:

// 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')
  }
`,
};

fs-json-to-files's People

Contributors

xiangchuifeng avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.