|
| 1 | +# Primer CSS Module Generator |
| 2 | + |
| 3 | +[](https://www.npmjs.org/package/generator-primer-module) |
| 4 | +[](https://travis-ci.org/primer/primer-css) |
| 5 | + |
| 6 | +Primer is the CSS framework that powers GitHub's front-end design. This is a |
| 7 | +[Yeoman] generator that we use to scaffold new Primer modules. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +### In the Monorepo |
| 12 | + |
| 13 | +1. `cd` to the top level directory of the `primer-css` repository |
| 14 | +1. Run: |
| 15 | + |
| 16 | + ```sh |
| 17 | + npm run new-module |
| 18 | + ``` |
| 19 | + |
| 20 | + You can also pass the module name as a positional argument like this: |
| 21 | + |
| 22 | + ```sh |
| 23 | + npm run new-module -- primer-module-name |
| 24 | + ``` |
| 25 | + |
| 26 | +1. Answer the interactive prompts. |
| 27 | + |
| 28 | + > If you don't know some of the answers (aside from the module name, which |
| 29 | + > is required), it's okay to press <kbd>enter</kbd> or <kbd>return</kbd>. |
| 30 | + |
| 31 | +1. If all goes well, the new module will be bootstrapped and ready to use. You |
| 32 | + should see a directory with this structure: |
| 33 | + |
| 34 | + ``` |
| 35 | + modules/primer-module-name/ |
| 36 | + ├── LICENSE |
| 37 | + ├── README.md |
| 38 | + ├── index.scss |
| 39 | + ├── lib |
| 40 | + │ └── module-name.scss |
| 41 | + └── package.json |
| 42 | + ``` |
| 43 | + |
| 44 | +1. If you have any TODOs left from unanswered prompts, fill them out! You can |
| 45 | + list them again with: |
| 46 | + |
| 47 | + ```sh |
| 48 | + ack TODO modules/primer-module-name |
| 49 | + ``` |
| 50 | + |
| 51 | + (Note: you can use `grep` if you don't have `ack` installed.) |
| 52 | +
|
| 53 | +
|
| 54 | +### Standalone installation |
| 55 | +
|
| 56 | +This repository is distributed with [npm][npm]. After [installing |
| 57 | +npm][install-npm], you can install `generator-primer-module` with this command. |
| 58 | +
|
| 59 | +```sh |
| 60 | +npm install --save generator-primer-module |
| 61 | +``` |
| 62 | +
|
| 63 | +You'll also need to install the [`yo` CLI](https://github.com/yeoman/yo): |
| 64 | + |
| 65 | +```sh |
| 66 | +npm install -g yo |
| 67 | +``` |
| 68 | + |
| 69 | +### Standalone usage |
| 70 | + |
| 71 | +It's possible to use this generator to create "standalone" Primer modules that |
| 72 | +live outside of the Primer CSS monorepo, with the following caveats: |
| 73 | +
|
| 74 | +* When prompted to add the new module to existing meta-packages, you will need |
| 75 | + to un-select them all. |
| 76 | +* You will also need to manually install all of the monorepo's top-level dev |
| 77 | + dependencies to get tools like `primer-module-build` and `ava`. |
| 78 | +* The `npm test` command will not work, because it references a test spec in |
| 79 | + the monorepo. |
| 80 | + |
| 81 | +To run the generator, just pass `primer-module` to the `yo` CLI: |
| 82 | + |
| 83 | +```sh |
| 84 | +yo primer-module |
| 85 | +``` |
| 86 | + |
| 87 | +Then answer the interactiv prompts. **Note that, unlike most other generators, |
| 88 | +this one creates a new directory with the provided module name in the current |
| 89 | +working directory.** |
| 90 | + |
| 91 | +You can also pass the module name as a positional argument, as in: |
| 92 | + |
| 93 | +```sh |
| 94 | +yo primer-module primer-foo-bar |
| 95 | +``` |
| 96 | + |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +[MIT](./LICENSE) © [GitHub](https://github.com/) |
| 101 | + |
| 102 | +[primer]: https://github.com/primer/primer |
| 103 | +[docs]: http://primercss.io/ |
| 104 | +[npm]: https://www.npmjs.com/ |
| 105 | +[install-npm]: https://docs.npmjs.com/getting-started/installing-node |
| 106 | +[sass]: http://sass-lang.com/ |
| 107 | +[yeoman]: http://yeoman.io |
0 commit comments