{"id":13438069,"url":"https://github.com/SpencerCDixon/redux-cli","last_synced_at":"2025-03-19T18:31:45.670Z","repository":{"id":57350387,"uuid":"51549635","full_name":"SpencerCDixon/redux-cli","owner":"SpencerCDixon","description":"An opinionated CLI for building redux/react apps quicker","archived":false,"fork":false,"pushed_at":"2018-03-25T10:41:58.000Z","size":5589,"stargazers_count":880,"open_issues_count":23,"forks_count":63,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-17T01:12:09.358Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpencerCDixon.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-11T21:50:34.000Z","updated_at":"2024-11-30T06:03:52.000Z","dependencies_parsed_at":"2022-08-28T19:01:33.932Z","dependency_job_id":null,"html_url":"https://github.com/SpencerCDixon/redux-cli","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpencerCDixon%2Fredux-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpencerCDixon%2Fredux-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpencerCDixon%2Fredux-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpencerCDixon%2Fredux-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpencerCDixon","download_url":"https://codeload.github.com/SpencerCDixon/redux-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244483397,"owners_count":20460104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:02.658Z","updated_at":"2025-03-19T18:31:45.656Z","avatar_url":"https://github.com/SpencerCDixon.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/SpencerCDixon/redux-cli.svg?branch=master)](https://travis-ci.org/SpencerCDixon/redux-cli)\n[![Code Climate](https://codeclimate.com/github/SpencerCDixon/redux-cli/badges/gpa.svg)](https://codeclimate.com/github/SpencerCDixon/redux-cli)\n\u003ca href=\"https://zenhub.io\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png\"\u003e\u003c/a\u003e\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n[![Gitter Chat Channel](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/redux-cli/Lobby?utm_source=share-link\u0026utm_medium=link\u0026utm_campaign=share-link)\n\n```\n______         _                   _____  _     _____\n| ___ \\       | |                 /  __ \\| |   |_   _|\n| |_/ /___  __| |_   ___  ________| /  \\/| |     | |\n|    // _ \\/ _` | | | \\ \\/ /______| |    | |     | |\n| |\\ \\  __/ (_| | |_| |\u003e  \u003c       | \\__/\\| |_____| |_\n\\_| \\_\\___|\\__,_|\\__,_/_/\\_\\       \\____/\\_____/\\___/\n```\n\n## Quick Start\n\n```javascript\nnpm i redux-cli -g       // install blueprint-cli globally\nblueprint new \u003cproject name\u003e // create a new blueprint project\nblueprint new \u003cproject name\u003e -S // OR use ssh to pull project down (if ssh setup with github)\nblueprint init                  // OR configure a current project to use the CLI\n\n// Start generating components/tests and save time \\(• ◡ •)/\n//(g is alias for generate)\nblueprint g dumb SimpleButton\n```\n\n![Blueprint CLI Usage Gif](redux-cli.gif)\n\n## Table Of Contents\n\n1.  [Getting Started](#getting-started)\n2.  [Configuring Existing Project](#config-existing-project)\n3.  [Commands](#commands)\n4.  [Generators](#generators)\n5.  [Roadmap](#roadmap)\n6.  [Examples](#examples)\n7.  [Creating Custom Blueprints](#creating-blueprints)\n8.  [Issues/Contributing](#contributing)\n9.  [Changelog](#changelog)\n\n### Getting Started\nRunning `blueprint new \u003cproject name\u003e` will pull down the amazing [Redux Starter Kit](https://github.com/davezuko/react-redux-starter-kit) and\ninitialize a new git repo.  Running `new` will automatically set up a `.blueprintrc`\nto work with this specific starter kit.  If you want to integrate the CLI in an\nexisting project or store your components in different paths please see [config existing project](#config-existing-project)\n\n### Config Existing Project\nThere is an `init` subcommand for you to specify all paths to where components\nlive in your project.  The `init` command just creates a `.blueprintrc` in your\nproject root.  If you want to you can just create the `.blueprintrc` manually.\n\nFinal `.blueprintrc` might look like this:\n\n```javascript\n{\n  \"sourceBase\":\"src\",\n  \"testBase\":\"tests\",\n  \"smartPath\":\"containers\",\n  \"dumbPath\":\"components\",\n  \"fileCasing\": \"default\"\n}\n```\n\n**Note on configuration**:\nThis project tries to walk on a fine line between convention and configuration.\nSince the majority of React applications will separate their smart/dumb\ncomponents if you pass in those paths you'll get those generators for free.\nHowever, some of the other generators might not write files to the exact paths\nthat you use for your project.  It's easy to override the CLI generators with\nyour own so that the generators will write files to the correct location.\n[See: creating custom blueprints](#creating-blueprints).\n\nAlternatively, if you use this CLI as a result of `blueprint new \u003cproject name\u003e` the\nstarter kit will come pre-configured with a bunch of blueprints (generators)\nthat work out of the gate.  Currently, I'm working on a PR for the\n`react-redux-starter-kit` with a bunch of blueprints.  More starter kits and\nblueprints to come!\n\n#### Default Settings\n|Key Name|Required|Description|\n|---|---|---|\n|**sourceBase**|✓|where you keep your pre-compiled source (relative from root of project)|\n|**testBase**|✓|where you keep your tests (relative from root of project)|\n|**smartPath**|✓|where you keep your smart (container) components (relative of sourceBase)|\n|**dumbPath**|✓|where you keep your dumb (pure) components (relative of sourceBase)|\n|**fileCasing**|✓|how do you want generated files to be named (pascal/camel/snake/dashes/default)|\n\n#### .blueprintrc\nIt's possible to put `.blueprintrc` files in other locations to better share\nconfigs.  It looks for files in the following locations and deep merges the\nfiles it finds together.  The defaultSettings will be overwritten by any\nfollowing options while the `--config=path/to/file` option will override\neverything.\n\nSee the whole list and more ENV tricks\nat [rc](https://github.com/dominictarr/rc)\n\n1. defaultSettings\n2. /etc/blueprint/config\n3. /etc/blueprintrc\n4. ~/.config/blueprint/config\n5. ~/.config/blueprint\n6. ~/.blueprint/config\n7. ~/.blueprintrc\n9. $BLUEPRINT_CONFIG\n10. --config=path/to/file\n\n**Note** - All files found at these locations will have their objects deep\nmerged together. Later file override earlier ones\n\n### Commands\n\n|Command|Description|Alias|\n|---|---|---|\n|`blueprint new \u003cproject name\u003e`|creates a new blueprint project||\n|`blueprint init`|configure an existing blueprint app to use the CLI||\n|`blueprint generate \u003cgenerator name\u003e `|generates files and tests for you automatically|`blueprint g`|\n|`blueprint help g`|show all generators you have available||\n\n\n### Generators\n\n|Name|Description|Options|\n|---|---|---|\n|`blueprint g dumb \u003ccomp name\u003e`|generates a dumb component and test file||\n|`blueprint g smart \u003csmart name\u003e`|generates a smart connected component and test file||\n|`blueprint g form \u003cform name\u003e`|generates a form component (assumes redux-form)||\n|`blueprint g duck \u003cduck name\u003e`|generates a redux duck and test file||\n\nYou can also see what files would get created with the `--dry-run` option like\nso:\n\n```\nblueprint g dumb MyNewComponent --dry-run\n\n// Output:\n\n  info: installing blueprint...\n  would create: /MyNewComponent.js\n  would create: /MyNewComponent.test.js\n  info: finished installing blueprint.\n```\n\n### Roadmap\n\n#### 2.0\n\n* rename to blueprint-cli\n* replace commander with yargs for cli\n* extend .blueprintrc settings.\n* Allow .blueprintrc files to set search * path for blueprint directories\n* Enable npm blueprint packages\n* Enable better options support for blueprint generation\n* Add Copy command to cli\n* Add config command to cli\n* Add blueprintrc and blueprint-package blueprints\n* Update existing blueprints and move into own package, to be included by default\n\n#### 2.X\n\n* Replace \"new\" command with alternate ways of project creation\n* Enable blueprint partials\n* Enable blueprints for assets: icons, images, css, fonts\n* Enable ability to insert text into existing files\n* Enable generators that can invoke other generators. Inspired by rails scaffold\n\n### Examples\nBelow are some examples of using the generator to speed up development:\n\n```\n// generates a dumb component\nblueprint g dumb SimpleButton\n\n// generates a smart component\nblueprint g smart CommentContainer\n\n// generate a redux-form with \u003cform\u003e tags in render statement\nblueprint g form ContactForm\n\n// generate a Redux 'duck' (reducer, constants, action creators)\nblueprint g duck todos\n```\n\n### Creating Blueprints\nBlueprints are template generators with optional custom install logic.\n\n`blueprint generate` comes with a default set of blueprints.  Every project has\ntheir own configuration \u0026 needs, therefore blueprints have been made easy to override\nand extend.\n\n**Preliminary steps**:\n\n1.  Create a `blueprints` folder in your root directory.  Blueprint CLI will search\nfor blueprints there _first_ before generating blueprints that come by default.\n2.  Create a sub directory inside `blueprints` for the new blueprint OR use the\nblueprint generator (super meta I know) that comes with Blueprint CLI by typing:\n`blueprint g blueprint \u003cnew blueprint name\u003e`.\n3.  If you created the directory yourself than make sure to create a `index.js`\nfile that exports your blueprint and a `files` folder with what you want\ngenerated.\n\n**Customizing the blueprint**:\n\nBlueprints follow a simple structure. Let's take the built-in\n`smart` blueprint as an example:\n\n```\nblueprints/smart\n├── files\n│   ├── __root__\n│   │   └── __smart__\n│   │       └── __name__.js\n│   └── __test__\n│       └── __smart__\n│           └── __name__.test.js\n└── index.js\n```\n\n#### File Tokens\n\n`files` contains templates for all the files to be generated into your project.\n\nThe `__name__` token is subtituted with the\nentity name at install time.  Entity names can be configued in\neither PascalCase, snake_case, camelCase, or dashes-case so teams can customize their file\nnames accordingly.  By default, the `__name__` will return whatever is entered\nin the generate CLI command.\n\nFor example, when the user\ninvokes `blueprint g smart commentContainer` then `__name__` becomes\n`commentContainer`.\n\nThe `__root__` token is subsituted with the absolute path to your source.\nWhatever path is in your `.blueprintrc`'s `sourceBase` will be used here.\n\nThe `__test__` token is substitued with the absolute path to your tests.\nWhatever path is in your `.blueprintrc`'s `testBase` will be used here.\n\nThe `__path__` token is substituted with the blueprint\nname at install time. For example, when the user invokes\n`blueprint generate smart foo` then `__path__` becomes\n`smart`.\n\nThe `__smart__` token is a custom token I added in the `index.js` it pulls from\nyour `.blueprintrc` configuration file to use whatever you have set as your\n`smartPath`.\n\n#### Template Variables (AKA Locals)\n\nVariables can be inserted into templates with\n`\u003c%= someVariableName %\u003e`.  The blueprints use [EJS](http://www.embeddedjs.com/)\nfor their template rendering so feel free to use any functionality that EJS\nsupports.\n\nFor example, the built-in `dumb` blueprint\n`files/__root__/__name__.js` looks like this:\n\n```js\nimport React, { Component, PropTypes } from 'react';\n\nconst propTypes = {\n};\n\nclass \u003c%= pascalEntityName %\u003e extends Component {\n  render() {\n    return (\n    )\n  }\n}\n\n\u003c%= pascalEntityName %\u003e.propTypes = propTypes;\nexport default \u003c%= pascalEntityName %\u003e;\n```\n\n`\u003c%= pascalEntityName %\u003e` is replaced with the real\nvalue at install time.  If we were to type: `blueprint g dumb simple-button` all\ninstances of `\u003c%= pascalEntityName %\u003e` would be converted to: `SimpleButton`.\n\nThe following template variables are provided by default:\n\n- `pascalEntityName`\n- `camelEntityName`\n- `snakeEntityName`\n- `dashesEntityName`\n\nThe mechanism for providing custom template variables is\ndescribed below.\n\n#### Index.js\n\nCustom installation (and soon uninstallation) behaviour can be added\nby overriding the hooks documented below. `index.js` should\nexport a plain object, which will extend the prototype of the\n`Blueprint` class.\n\n```js\nmodule.exports = {\n  locals: function(options) {\n    // Return custom template variables here.\n    return {};\n  },\n\n  fileMapTokens: function(options) {\n    // Return custom tokens to be replaced in your files\n    return {\n      __token__: function(options){\n        // logic to determine value goes here\n        return 'value';\n      }\n    }\n  },\n\n  filesPath: function() {\n    // if you want to store generated files in a folder named\n    // something other than 'files' you can override this\n    return path.join(this.path, 'files');\n  },\n\n  // before and after install hooks\n  beforeInstall: function(options) {},\n  afterInstall: function(options) {},\n};\n```\n\n#### Blueprint Hooks\n\nAs shown above, the following hooks are available to\nblueprint authors:\n\n- `locals`\n- `fileMapTokens`\n- `filesPath`\n- `beforeInstall`\n- `afterInstall`\n\n#### locals\n\nUse `locals` to add custom tempate variables. The method\nreceives one argument: `options`. Options is an object\ncontaining general and entity-specific options.\n\nWhen the following is called on the command line:\n\n```sh\nblueprint g dumb foo --html=button --debug\n```\n\nThe object passed to `locals` looks like this:\n\n```js\n{\n  entity: {\n    name: 'foo',\n    options: {\n      _: ['dumb', 'foo'],\n      html: 'button'\n    },\n    rawArgs: [\n      ... array of rawArgs passed to cli ...\n    ]\n  },\n  debug: true\n}\n```\n\nThis hook must return an object. It will be merged with the\naforementioned default locals.\n\n#### fileMapTokens\n\nUse `fileMapTokens` to add custom fileMap tokens for use\nin the `mapFile` method. The hook must return an object in the\nfollowing pattern:\n\n```js\n{\n  __token__: function(options){\n    // logic to determine value goes here\n    return 'value';\n  }\n}\n```\n\nIt will be merged with the default `fileMapTokens`, and can be used\nto override any of the default tokens.\n\nTokens are used in the files folder (see `files`), and get replaced with\nvalues when the `mapFile` method is called.\n\n#### filesPath\n\nUse `filesPath` to define where the blueprint files to install are located.\nThis can be used to customize which set of files to install based on options\nor environmental variables. It defaults to the `files` directory within the\nblueprint's folder.\n\n#### beforeInstall \u0026 afterInstall\n\nCalled before any of the template files are processed and receives\nthe the `options` and `locals` hashes as parameters. Typically used for\nvalidating any additional command line options or for any asynchronous\nsetup that is needed.\n\n### Contributing\nThis CLI is very much in the beginning phases and I would love to have people\nhelp me to make it more robust.  Currently, it's pretty opinonated to use the\ntooling/templates I prefer in my projects but I'm open to PR's to make it more\nuniversal and support other platforms (I'm on Mac).\n\nThis repo uses Zenhub for managing issues.  If you want to see what's currently\nbeing worked on or in the pipeline make sure to install the [Zenhub Chrome\nExtension](https://chrome.google.com/webstore/detail/zenhub-for-github/ogcgkffhplmphkaahpmffcafajaocjbd?hl=en-US)\nand check out this projects 'Boards'.\n\n#### Development Setup/Contributing\nUse `npm link` is to install the CLI locally when testing it and adding\nfeatures.\n\n```\nnvm use 5.1.0    // install node V5.1 if not present (nvm install 5.1.0)\nnpm install\nnpm i eslint babel-eslint -g  // make sure you have eslint installed globally\nnpm start        // to compile src into lib\nnpm test         // make sure all tests are passing\n\n// to test the cli in the local directory you can:\nnpm link         // will install the npm package locally so you can run 'blueprint \u003ccommands\u003e'\nblueprint \u003crun commands here\u003e\n```\n\n### Package Utility Scripts:  \n```\nnpm start        // will watch files in src and compile using babel\nnpm test         // runs test suite with linting.  Throws when lint failing\nnpm run lint     // lints all files in src and test\n```\n\n### Changelog\n\n`1.8.0` - adds `--dry-run` option to generators so you can see files before committing\n`1.7.0` - adds option to use a ui kit boilerplate with the `-U` flag.  \n`1.6.0` - adds option to use a different boilerplate with the `-B` flag.  Fixes windows issues  \n`1.5.1` - fixes windows support, addes ejs eslint plugin, fixes bug with UI in windows  \n`1.4.1` - default to https instead of ssh for pulling project down  \n`1.4.0` - better generator help messages  \n`1.3.5` - properly passes cli options to blueprints so they can use them  \n`1.3.3` - fixes init command, adds --debug to generators, improves error messages for broken templates  \n`1.3.0` - major internal refactor, addition of customizable blueprints  \n`1.1.1` - adds support for html tag in render when generating components  \n`1.0.1` - adds fileCasing to generators so Linux users can use snake_case_file_names  \n`1.0` - first public release with stable api (new/generate/init)  \n","funding_links":[],"categories":["Uncategorized","Code Design","Boilerplate","JavaScript","Marks"],"sub_categories":["Uncategorized","Boilerplate","Other","[React - A JavaScript library for building user interfaces](http://facebook.github.io/react)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpencerCDixon%2Fredux-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSpencerCDixon%2Fredux-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSpencerCDixon%2Fredux-cli/lists"}