Skip to content

Commit cde9806

Browse files
committed
Merge branch 'develop'
2 parents a0d530f + c8b671b commit cde9806

File tree

23 files changed

+984
-5322
lines changed

23 files changed

+984
-5322
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/*
22
.env
3+
.idea

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Changelog
22

3+
## 0.1.5
4+
* Using https instead curl
5+
* File management with promises
6+
* Several minor fixes and code improvements
7+
38
## 0.1.4
49

5-
* Handle the Github tokens for multiple accounts/users
10+
* Partial support to Github tokens for multiple accounts/users
611
* Fix problem with keywords on package.json
712
* Post install script to setup github auth details
813

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ An [npm initializer][npm/init] to scaffold a node project and include basic tool
1313
## Requirements
1414

1515
- `npm >= 6.5`
16-
- `node >= 10.9`
16+
- `node >= 10.1.0`
1717

1818
## Usage
1919

@@ -62,6 +62,7 @@ So, the idea is to have an automated way to initialize new NodeJS projects and w
6262
12. Improve the template structure (the one that is generated in the new project) to include unit test
6363
13. Include license files to the template copy/update process
6464
18. Option to questionnaire with all the default values
65+
2. Logic to handle multiple auth files and multiple github accounts
6566

6667
## Configure Github Authentication
6768

@@ -77,17 +78,16 @@ If you are planning to allow this script to create your Github repositories, is
7778
[X] repo_deployment
7879
[X] public_repo
7980
[X] repo:invite
80-
[X] delete_repo
8181
```
8282
3. Click Generate token.
8383
4. Copy the generated string to a safe place, such as a password safe.
8484
5. Open Terminal and add the Github token.
8585

8686
```
87-
# nano ~/auth.json
87+
# nano ~/create-nodejs-project.json
8888
8989
{
90-
"Github": [
90+
"github": [
9191
{
9292
"user": "YOUR_USER",
9393
"token": "YOUR_TOKEN"
File renamed without changes.

install/index.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
1-
const fs = require('fs');
2-
const inquirer = require('inquirer');
1+
const questions = require('../src/questionnaire/questions');
2+
const settings = require('../src/settings');
3+
const auth = require('../src/auth');
34

4-
const utils = require('../src/utils');
5+
const AUTH_PATH = settings.authPath;
56

6-
async function install() {
7-
const authPath = utils.fs.resolvePath('~/auth.json');
7+
/**
8+
* Install function for the package, it set up the github auth details
9+
* TODO Consider the case for a previous auth file with different tokens
10+
*/
11+
(async () => {
12+
let user;
813

9-
const answers = await inquirer.prompt([
10-
{
11-
type: 'input',
12-
name: 'user',
13-
message: 'What is your github user?',
14-
},
14+
try {
15+
user = await auth.firstUser(AUTH_PATH);
16+
} catch (e) {
17+
// console.log('fixme');
18+
}
1519

16-
{
17-
type: 'input',
18-
name: 'token',
19-
message: 'What is your GitHub token?',
20-
},
21-
]);
20+
const authUser = await questions.getGithubUser(user.user || '');
21+
const authToken = await questions.getAuthToken(user.user || '', user.token || '');
2222

23-
// Write file
24-
const data = {
23+
const authDetails = {
2524
github: [
2625
{
27-
user: answers.user,
28-
token: answers.token,
26+
user: authUser.github.user,
27+
token: authToken.github.token,
2928
},
3029
],
3130
};
3231

33-
fs.writeFileSync(authPath, JSON.stringify(data));
34-
console.log(`File ${authPath} created with your github details`);
35-
}
36-
37-
install();
32+
await auth.writeAuthFile(authDetails, AUTH_PATH);
33+
console.log(`File ${AUTH_PATH} created with your github details`);
34+
})();

0 commit comments

Comments
 (0)