{"_id":"scaffoldit","_rev":"15-0204cdadb69ff9d98e4063602469e2d4","name":"scaffoldit","description":"scaffolding library for node.js","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"author":{"name":"Craig Condon"},"name":"scaffoldit","description":"scaffolding library for node.js","version":"0.0.1","repository":{"type":"git","url":"git://github.com/crcn/scaffold.git"},"dependencies":{"mustache":"*","celeri":"*","step":"*","findit":"*","mkdirp":"*"},"devDependencies":{"colors":"*"},"main":"./lib/index.js","_npmUser":{"name":"architectd","email":"craig.j.condon@gmail.com"},"_id":"scaffoldit@0.0.1","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"5fe00e94144477680d6eeaf3cd2bbda86c885143","tarball":"https://registry.npmjs.org/scaffoldit/-/scaffoldit-0.0.1.tgz","integrity":"sha512-ofcs9vbh4hU+sCVj7fYlvSxCAZhUwRAWJJvvfXIVssm5diAeCK7zkNlJc2RQMWT/1yCa//Q7Ey5kAC0PkZpXPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAzB+JxpPlrB7AE0MFLLtWGRqjZpSdIal9mBnKiY0jkgAiB24j4m4dqV4l1k6g2iJlA4h7By8qwK9Z4dQ8vZArd9Rw=="}]},"maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}],"directories":{}},"0.0.2":{"author":{"name":"Craig Condon"},"name":"scaffoldit","description":"scaffolding library for node.js","version":"0.0.2","repository":{"type":"git","url":"git://github.com/crcn/scaffold.git"},"dependencies":{"mustache":"*","celeri":"*","step":"*","findit":"*","mkdirp":"*"},"devDependencies":{"colors":"*"},"main":"./lib/index.js","_npmUser":{"name":"architectd","email":"craig.j.condon@gmail.com"},"_id":"scaffoldit@0.0.2","engines":{"node":"*"},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"59b754df3a0960e57ef8289707ea09f092c0bcd0","tarball":"https://registry.npmjs.org/scaffoldit/-/scaffoldit-0.0.2.tgz","integrity":"sha512-ET3BHGMlaOkldZpR289FFpNDG60Jb1/llZLMw8EaGKz4jowobIg6qF/Zn4fl9n3/WTWKYtVA035zrWa5f4vS2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXim6K8RwSm3F8UUaXmo7oWjNznlZtxHUwhdhKt1g65wIga5UyQqmekJ7UA5LddLvqUi/Zl8tHNL8RiydWzJvc9Ww="}]},"maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}]}},"readme":"\n### What's this?\n\nA library which allows to you very easily take input from a user, and use that data to build stuff. Like so: \n\n\n```javascript\n\nvar scaffoldit = require('../');\nrequire('colors');\n\nscaffoldit({\n\t\n\t/**\n\t * another place to put default values\n\t */\n\t\n\tparams: {\n\t\t'_src': __dirname + '/tpl/hello.mu.txt'\n\t},\n\t\n\t/**\n\t * input required by the user\n\t */\n\t\n\tinput: {\n\t\t'name': {\n\t\t\tmsg: 'What is your name?',\n\t\t\tvalue: 'Craig'\n\t\t},\n\t\t'hasDog': '(confirm) Do you have a dog?'\n\t},\n\t\n\t/**\n\t * called after gathering *all* input data - \n\t * builds the stuff\n\t */\n\t\n\tbuild: function(ops, next) {\n\t\t\n\t\tconsole.log('Building template...'.grey);\n\t\t\n\t\tscaffoldit.fromFile(ops, next);\n\t},\n\t\n\t/**\n\t * called after the entire build process is complete\n\t */\n\t\n\tcomplete: function(err, result) {\n\t\t\n\t\tconsole.log(result.green);\n\t}\n});\n\n````\n\nThe hello.mu.txt [mustache](https://github.com/janl/mustache.js) template looks like:\n\n\n````text\n\nhello {{name}}!\n\n{{#hasDog}}\nYou have a dog.\n{{/has}}\n\n{{^hasDog}}\nYou do NOT have a dog.\n{{/hasDog}}\n\n````\n\nAnd the result is: \n\n![Alt example](http://i.imgur.com/3Q9Fa.png)\n\n\n### scaffoldit(ops)\n\nOptions include:\n\n- `params` - Default parameter values to pass onto the build callback.\n- `input` - Inputs that require a value from the user.\n\t- `[param_name]` - The parameter name for the given input.\n\t\t- `msg` - The message to display to the user.\n\t\t- `default` - The optional default value to use for the param. Can be a value, or callback.\n\t\t- `type` - Optional param for the type of input.\n- `build` - The build function for the parameters given.\n- `complete` - Called once the build is complete.\n\n\n### Types of inputs\n\nYou can easily specify the type of input by adding `(type-of-input)` before the message. Like to:\n\n````javascript\n\nscaffoldit({\n\tinput: {\n\t\tusername: \"(prompt) Username:\",\n\t\tpassword: \"(password) Password:\",\n\t\thasFriends: \"(confirm) Do you have any friends?\"\n\t}\n});\n\n````\n\n`(prompt)` is the default option if you omit the type of input.\n\n\n### Default Parameters\n\n````javascript\n\nscaffoldit({\n\t\n\tinput: {\n\t\tprojectName: {\n\t\t\tmsg: \"What is your project name?\",\n\t\t\tdefault: function(params, callback)\t{ \n\t\t\t\t\n\t\t\t\tcallback(50);\n\t\t\t}\n\t\t},\n\t\tprojectSrc: {\n\t\t\tmsg: \"Where is your project located?\",\n\t\t\tdefault: '/usr/local/bin'\n\t\t}\n\t}\n});\n\n````\n\n\n### scaffoldit.fromDir(params, src, dest)\n\nScans the target directory for [mustache](https://github.com/janl/mustache.js) templates, and replaces any template variables with the parameters given. The destination is where the files are written to. Make sure to set the *name* of the template file to something like `my-file.tpl.html`, or `my-file.mu.html`.\n\nNote that `tpl`, and `mu` are removed in the destination file.\n\n````javascript\n\nscaffoldit({\n\tinput: {\n\t\tprojectName: \"What is your project name?\"\n\t},\n\tbuild: function(ops, next) {\n\t\t\n\t\tscaffoldit.fromDir(ops, '/path/to/input/dir','/path/to/output/dir');\n\t},\n\tcomplete: function() {\n\t\t//...\n\t}\n})\n\n````\n\nOr you can do something like this:\n\n````javascript\n\nscaffoldit({\n\tparams: {\n\t\t'_src': '/path/to/input/dir',\n\t\t'_dest': '/path/to/output/dir'\n\t},\n\tinput: {\n\t\tprojectName: \"What is your project name?\"\n\t},\n\tbuild: scaffoldit.fromDir,\n\tcomplete: function() {\n\t\t//...\n\t}\n});\n\n````\n\n\n### scaffoldit.fromFile(params, templateSrc, callback)\n\nloads the target [mustache](https://github.com/janl/mustache.js) template file and fills it with the parameters given. Again, make sure to use this format `my-file.mu.format`, or `my-file.tpl.format` for consistency.\n\n````javascript\n\nscaffoldit({\n\tinput: {\n\t\tname: {\n\t\t\tmsg: \"What's your name?\",\n\t\t\tdefault: \"Craig\"\n\t\t},\n\t\t_src: {\n\t\t\tmsg: \"Where is the template?\",\n\t\t\tdefault: \"/path/to/template.file\"\n\t\t},\n\t\tbuild: scaffoldit.fromFile,\n\t\tcomplete: function(err, content) {\n\t\t\t\n\t\t\tconsole.log(content);\n\t\t}\n\n\t}\n});\n\n````\n\n\n","maintainers":[{"name":"architectd","email":"craig.j.condon@gmail.com"}],"time":{"modified":"2022-06-26T16:22:33.577Z","created":"2012-01-01T23:54:16.737Z","0.0.1":"2012-01-01T23:54:17.522Z","0.0.2":"2012-02-17T20:54:30.898Z"},"author":{"name":"Craig Condon"},"repository":{"type":"git","url":"git://github.com/crcn/scaffold.git"}}