Skip to content

Commit 577bb48

Browse files
authored
Approach 0.1.0 for the project (#1)
* Template for the new project * Utils created - Copy folder recursively - Replace a string by a dictionary - Get object format for placeholders * Generic process to build the new project * Project class - some issues with git values * Dependencies and linter * Command for dependencies with output for results * Note for a fix needed * Fix linting rules * Update copy to do it sync and method to promify the exec * Constructor default values for project and git methods * Git utilities module * Wrap function for packageGenerator * Renamed git handler module * Included information for the oauth for github * commit and addRemote methods for git * github handler to create repositories * git method to push * git values for project object * Updated error msg for exec promised * Included logic to create github repository, commit and push * documentation * Added documentation for methods * MD fixes on readme * Included eslint-plugin-node * Promisified spawn for npm commands * Fix for the status code from github response * First approach for the questionnarie * Function to generate project name with dashes * New keywords * First licenses files * Updates on the TO-DOs progress * Fix typo on questionnarie module name * Test and cleanup scripts * Method to delete a directory * Adding questions for auth and github * Move auth to its own module and add method to delete github repo * :nailcare: Linter happiness * 🔜 progress on the to-do list * cwd for exec method * Fix keywords and templating dictionary values * 🔜 Update progress on to-do list * Messaging for different processes * 💅 Linter happiness * Validations for questionnaire when project use github or has remote * Validations for questionnaire when project use github or has remote * 🔜 Updated the progress on to-do list * Fix issue with path for auth.json * New settings object to handle testing packages * Improve folder structure for project * 💅 Improve documentation * Changed the settings to object instead of instance of class * Using settings on auth * Fix message when a github repository is deleted * 💅 Linter happiness * Include extra properties to create the github repo * Add bin value in package.json
1 parent f040b53 commit 577bb48

File tree

23 files changed

+1412
-589
lines changed

23 files changed

+1412
-589
lines changed

.eslintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"extends": "airbnb-base",
2+
"extends": ["airbnb-base", "plugin:node/recommended"],
33
"rules": {
4-
"no-console": off
4+
"no-console": off,
55
}
66
}

README.md

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,95 @@
44

55
An [npm initializer][npm/init] to scaffold a node project and include basic tools like lint, testing, etc.
66

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+
> _[&mdash; Source: `docs.npmjs.com`][npm/init]_
10+
711
## Requirements
812

9-
- `npm >= 6.x`
10-
- `node >= 8.*`
13+
- `npm >= x.x`
14+
- `node >= x.x`
1115

1216
## Usage
1317

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-
> _[&mdash; Source: `docs.npmjs.com`][npm/init]_
18+
`npm init node-project path/to/project [params]`
2319

2420
## Params
2521

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.
2786

28-
`npm init node-project path/to/project`
87+
```
88+
# nano ~/auth.json
2989
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+
```
3196

3297

3398

auth-example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"github": {
3+
"token": "YOUR_TOKEN"
4+
}
5+
}

licenses/isc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ISC License (ISC)
2+
3+
Copyright PROJECT_YEAR PROJECT_AUTHOR_NAME
4+
5+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

licenses/mit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright PROJECT_YEAR PROJECT_AUTHOR_NAME
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)