folder_structure

Small utility to build out your file structure. So when looking at package.json, you get a general idea of your project. Including how directories, blank files, downloads, and scripts are to be used. It can also sync node_modules to a location you desir

Usage no npm install needed!

<script type="module">
  import folderStructure from 'https://cdn.skypack.dev/folder_structure';
</script>

README

Small utility to build out your file structure.

So when looking at package.json, you get a general idea of your project. Including building out directories, blank files, downloading files, syncing npm modules to local directories (feature in progress implemented), and running javascript scripts (OS-agnostic) and commands.

(Note: npm is behind github. Refactoring code and stabilizing. Probably time to switch to develop. Was in a rush and forgot.)

npm install -g folder_structure

The only command that works right now is build-folderstruct. Fortunately, it is the most useful. It builds your directory out and runs each script.

Alpha example:

{
  "name": "folder_structure",
  "version": "0.1.0",
  "description": "Server-side module for folder structure building.",
  "main": "app.js",
  "scripts": {
    "bundle": "./node_modules/.bin/browserify index.js > bundle.js",
    "test": "./node_modules/.bin/mocha --reporter spec"
  },
  "keywords": [
    "folder",
    "folder-layout",
    "sync-directory"
  ],
  "author": "TamusJRoyce",
  "license": "SEE LICENSE IN license.txt",
  "devDependencies": {
    "chai": "^4.2.0",
    "mocha": "^5.2.0"
  },
  "folderLayout_note": "Your paths can be windows or posix based. They will be automatically detected converted to relative paths for processing.",
  "folderLayout": [
    "./README.md",
    "./server/app/",
    "./server/scripts/setup/",
    "./server/scripts/prerun/",
    "./server/scripts/postrun/",
    "./server/scripts/database/",
    "./client/site/",
    "./client/site/assets/",
    "./client/site/scripts/",
    "./client/site/styles/",
    "./src/",
    "./src/test/",
    "./src/"
  ]
}

Notice above: "folderLayout" shows a desired file structure.

Here is a more advanced one. This one initializes blank files and executes scripts to build out file content (only if the file did not exist before). This comes from package.json in this repository!

{
  "...": "...",
  "bin": {
    "folder-structure": "./bin/cli.js",
    "build-folderstruct": "./bin/cli-build_directory_structure.js",
    "init-folderstruct": "./bin/cli-init_directory_structure.js"
  },
  "folderLayout_note": "Your paths can be windows or posix based. They will be automatically detected converted to relative paths for processing.",
  "folderLayout": [
    "./test/",
    "./test/tests.js",
    "./bin/",
    "./bin/cli.js",
    [
      "./test/mocha.opts",
      "echo server-tests >> ./test/mocha.opts",
      "echo --recursive >> ./test/mocha.opts"
    ],
    [
      "./license.txt",
      "wget https://api.github.com/licenses/mit -O license.txt",
      "curl -o license.txt https://api.github.com/licenses/mit",
      "node --eval \"const https = require('https'); fs = require('fs'); https.get('https://api.github.com/licenses/mit', {json:true}, function(error,response,body) {if (error) {return console.log(error)$
    ],
    [
      "./.gitignore",
      "echo package.lock >> ./.gitignore",
      "echo ./node_modules/ >> ./.gitignore"
    ],
    {
      "chain": [
        "./README.md",
        "node --eval \"const package = require('./package.json'); console.log(package.description);\" >> ./README.md"
      ]
    }
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/tamusjroyce/nodejs_folder_structure.git"
  }
}

Deprecated: "structure" "structure" will still be processed. But for clarity, it is advised to switch to folderLayout.

This tool is not meant convert package.json into a Makefile-like format. Its focus is purely project initialization. Please use pre-build and post-build hooks if you need to perform tasks unrelated to filesystem setup.

I find it useful to describe your desired folder structure in package.json. And at the same time, allow it to be built out. I hope you do too!

Hopefully Helpful! -TamusJRoyce