|
4 | 4 |
|
5 | 5 | An [npm initializer][npm/init] to scaffold a node project and include basic tools like lint, testing, etc. |
6 | 6 |
|
| 7 | +> _`npm init <initializer>` can be used to set up a new or existing npm package._ |
| 8 | +> _`initializer` in this case is an npm package named `create-<initializer>`, which will be installed by `npx`, and then have its main bin executed -- presumably creating or updating `package.json` and running any other initialization-related operations._ |
| 9 | +> _[— Source: `docs.npmjs.com`][npm/init]_ |
| 10 | +
|
7 | 11 | ## Requirements |
8 | 12 |
|
9 | | -- `npm >= 6.x` |
10 | | -- `node >= 8.*` |
| 13 | +- `npm >= x.x` |
| 14 | +- `node >= x.x` |
11 | 15 |
|
12 | 16 | ## Usage |
13 | 17 |
|
14 | | -```bash |
15 | | -npm init node-project [params] |
16 | | -``` |
17 | | - |
18 | | -## How does this work? |
19 | | - |
20 | | -> _`npm init <initializer>` can be used to set up a new or existing npm package._ |
21 | | -> _`initializer` in this case is an npm package named `create-<initializer>`, which will be installed by `npx`, and then have its main bin executed -- presumably creating or updating `package.json` and running any other initialization-related operations._ |
22 | | -> _[— Source: `docs.npmjs.com`][npm/init]_ |
| 18 | +`npm init node-project path/to/project [params]` |
23 | 19 |
|
24 | 20 | ## Params |
25 | 21 |
|
26 | | -- Project path |
| 22 | +### Project path |
| 23 | + |
| 24 | +`npm init node-project path/to/project [params]` |
| 25 | + |
| 26 | +Will create a new folder for the project in the specified path. |
| 27 | + |
| 28 | +## About this package |
| 29 | + |
| 30 | +So, this started as a dry thing. |
| 31 | +I'm not super expert with NodeJS, but every time that I start a new project, I hate to go to other project, copy files like eslintrc, editorconfig, install the same dependencies, create folder structure, etc. |
| 32 | +So, the idea is to have a create package to use it in the form of: |
| 33 | +`npm init node-project a-demo-project` |
| 34 | +and with this have a new folder my-new-project with everything ready to work. |
| 35 | + |
| 36 | +I know there are a lot of similar packages out there, but the idea is to learn more about nodejs api, handling files, packages, etc. |
| 37 | + |
| 38 | +So far, what this package will do (already does) is: |
| 39 | +1. Create the folder for the new project |
| 40 | +2. Create a git repo |
| 41 | +3. Copy the structure for files (src, and root files like eslintrc, gitignore, readme, etc) |
| 42 | +4. Create a github repository |
| 43 | +5. Install eslint and jest dependencies |
| 44 | +6. Update package.json |
| 45 | +7. Commit and push the initial commit |
| 46 | + |
| 47 | +What I have in my TODO list: |
| 48 | +1. Fix the structure of modules, classes and etc |
| 49 | +2. ~~Avoid as much dependencies as possible~~ |
| 50 | +3. ~~Understand about the difference for eslint airbnb and eslint plugin node~~ |
| 51 | +4. Add unit testing |
| 52 | +5. ~~Improve the calls for shell (right now is with exec, but I need to use spawn in order to have the stdout inherit, but that mess with the sync method and the responses)~~ |
| 53 | +6. ~~Add documentation for classes, modules and methods~~ |
| 54 | +7. Add options to create the project with params instead of questionnaire |
| 55 | +8. ~~Add questionnaire for the creation~~ |
| 56 | +9. Publish the npm package |
| 57 | +10. Add a good error handler |
| 58 | +11. Color for the console messages |
| 59 | +12. Modify template structure (the one that is generated in the new project) to include unit test |
| 60 | +13. Include license files to the template copy/update process |
| 61 | +14. A logger ? (just for learning) |
| 62 | +15. ~~CWD for git commands~~ |
| 63 | +16. Best place for the auth.json |
| 64 | +17. Ability to handle auth for different github accounts |
| 65 | +18. Option to questionnaire with all the default values |
| 66 | + |
| 67 | +## Github Auth |
| 68 | + |
| 69 | +If you are planning to allow this script to create your github repositories, is required to generate a Github Token. |
| 70 | + |
| 71 | +1. Visit https://github.com/settings/tokens. |
| 72 | +2. Click Generate new token. |
| 73 | +``` |
| 74 | + Token Description: (your computer name) |
| 75 | + Scopes: |
| 76 | + [X] repo |
| 77 | + [X] repo:status |
| 78 | + [X] repo_deployment |
| 79 | + [X] public_repo |
| 80 | + [X] repo:invite |
| 81 | + [X] delete_repo |
| 82 | +``` |
| 83 | +3. Click Generate token. |
| 84 | +4. Copy the generated string to a safe place, such as a password safe. |
| 85 | +5. Open Terminal and add the github token. Note: The file may be empty, you can use `auth-example.json` to copy and paste. |
27 | 86 |
|
28 | | -`npm init node-project path/to/project` |
| 87 | +``` |
| 88 | +# nano ~/auth.json |
29 | 89 |
|
30 | | -Will create a new folder for the project and use the forlder name as the project name. |
| 90 | +{ |
| 91 | + "github-oauth": { |
| 92 | + "github.com": "YOUR_TOKEN" |
| 93 | + } |
| 94 | +} |
| 95 | +``` |
31 | 96 |
|
32 | 97 |
|
33 | 98 |
|
|
0 commit comments