{"_id":"@5oo/scaf","name":"@5oo/scaf","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.7":{"name":"@5oo/scaf","bin":{"scaf":"bin/scaf"},"publishConfig":{"access":"public"},"version":"1.0.7","description":"`scaf` is a scaffolding tool. It allows you to define a template in JavaScript and then use scaffold that template out.","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","license":"MIT","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"scripts":{"test":"jest","build":"tsup src/index.ts --format cjs,esm --splitting --dts","dev":"node -r esbuild-register ./src/index.ts","lint":"eslint \"src/**/*.ts\"","clean":"rm -rf node_modules && rm -rf dist"},"keywords":[],"author":{"name":"logikaljay"},"devDependencies":{"@types/node":"^18.16.2","@types/prompt":"^1.1.5","esbuild-register":"^3.4.2","jest":"^29.5.0","prompt":"^1.3.0","ts-jest":"^29.1.0","tsup":"^6.7.0"},"gitHead":"1c8f3ba9bbb036053022a7daf55ecfe3ddc28925","_id":"@5oo/scaf@1.0.7","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-Ruyiq6amo7caKjRlwcUOlc921v2rS6/ILOiIIVzgR9YD/fMdjVOs89zkBjKtcwQZVv+9t1VVZVMO1lmAXPmR5w==","shasum":"20a1a49c2a25633a4fb2db72b2ea4cc7753e541f","tarball":"https://registry.npmjs.org/@5oo/scaf/-/scaf-1.0.7.tgz","fileCount":7,"unpackedSize":484658,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD53QVrQB/CHZnQ9s4ybDhM9c0PmoaaadQ7/ikzakmWnAIhAKCZ3ZFXhGe/hPuBfAVoXsV63uW6/ctY7+/rMrEtxNIE"}]},"_npmUser":{"name":"logikaljay","email":"logikal@gmail.com"},"directories":{},"maintainers":[{"name":"logikaljay","email":"logikal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scaf_1.0.7_1685941160468_0.7500592725351707"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-05T04:59:20.357Z","1.0.7":"2023-06-05T04:59:20.627Z","modified":"2023-06-05T04:59:20.847Z"},"maintainers":[{"name":"logikaljay","email":"logikal@gmail.com"}],"description":"`scaf` is a scaffolding tool. It allows you to define a template in JavaScript and then use scaffold that template out.","keywords":[],"author":{"name":"logikaljay"},"license":"MIT","readme":"# @logikaljay/scaf\n\n`scaf` is a scaffolding tool. It allows you to define a template in JavaScript and then use scaffold that template out.\n\n## Installation\n\n`scaf` should then be installed as a devDependency.\n\n```\n$ npm i -D @logikaljay/scaf\n```\n\n## Setting up your template\n\nYour template should export `files` and `variables`.\n\n### `files`\n\n`files` is an array of objects that conform to the `ScaffoldFile` type.\n\n**`file.name` `string`**\n\nThe name of the file.\n\n**`file.content` `string`**\n\nThe content of the file.\n\n\n### `variables`\n\n`variables` is an array of strings that will be collected at runtime.\n\nWhen the user supplies data for each variable, they can be modified by modifiers (see below).\n\n### `argv`\n\nYou can automatically assign variables at runtime by providing arguments to `scaf`.\n\nFirstly, make sure your template exports an called `argv`. This object must be keyed by a string and the values must be RegExp.\nThe RegExp can use [named groups](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Groups_and_backreferences#using_named_groups) to set even more variables.\n\nEG:\n\n**template.js**\n```js\nmodule.exports.argv = {\n  endpoint: /\\/api\\/(?<service>\\w+)\\/(?<domain>\\w+)\\/(?<title>\\w+)/i\n}\n```\n\n```bash\n$ scaf /api/core/Auth/GetSessions\n\nScaffolding with input \n{\n  \"service\": \"core\",\n  \"domain\": \"auth\",\n  \"title\": \"GetSessions\",\n  \"endpoint\": \"/api/core/Auth/GetSessions\"\n}\n```\n\n## Modifiers\n\nA `modifier` is used in the template by augmenting the name of the variable with the name of the modifier.\n\n### Examples\n\nWhen using the `{{title}}` variable, you can use the `toUpperCase` modifier on it: `{{title:toUpperCase}}`.\n\nWhen using the `{{name}}` variable, make sure that it is title case so it can be displayed nicely: `{{name:toTitleCase}}`\n\nYou can also chain multiple modifiers together, they will be run in the order you chain them: `{{name:toUpperCase:toLowerCase}}` will result in a lowercase string being\n\n**Available modifiers:**\n\n`slug`  - replaces all ` ` with `-` and then `encodeURI`s the result.\n\n`toLowerCase` - converts the input to lower case.\n\n`toUpperCase` - summons a magical unicorn to fuck your shit up.\n\n`toPascalCase` - converts the input `ToPascalCase`.\n\n`toKebabCase` - converts the input `to-kebab-case`.\n\n`toCamelCase` - converts the input `toCamelCase`.\n\n`toTitleCase` - converts the input `To title case`.\n\n### Todo\n\n- [ ] multiple templates\n- [ ] init to generate a template\n- [x] argv processing using named RegExp groups\n- [x] documentation","readmeFilename":"readme.md"}