Skip to content

Commit c7c2dd6

Browse files
Introduced linter, better readme, pull request template and contriubting guidelines
1 parent 59535bc commit c7c2dd6

19 files changed

+1749
-125
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
client/**

.eslintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"mocha": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": 2018
8+
},
9+
"extends": "airbnb-base",
10+
"overrides": [
11+
{
12+
"files": [
13+
"*.js"
14+
],
15+
"rules": {
16+
"no-console": "off"
17+
}
18+
},
19+
{
20+
"files": [
21+
"*.spec.js"
22+
],
23+
"rules": {
24+
"max-lines": [
25+
"error",
26+
1500
27+
],
28+
"max-lines-per-function": [
29+
"error",
30+
1500
31+
]
32+
}
33+
}
34+
]
35+
}

.github/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Contributing guidelines
2+
3+
- If you find a relevant issue that you can actively work on, mention it and start hacking away
4+
- Fork the repo and raise a PR that respects the [template](.github/pull_request_template.md)
5+
- Make sure you maintain a respectful decorum in comments and code

.github/pull_request_template.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--- Provide a general summary of your changes in the Title above -->
2+
3+
### Description
4+
<!--- Describe your changes in detail -->
5+
6+
### Motivation and Context
7+
<!--- Why is this change required? What problem does it solve? -->
8+
<!--- If it fixes an open issue, please link to the issue here. -->
9+
10+
### How Has This Been Tested?
11+
<!--- Please describe in detail how you tested your changes. -->
12+
<!--- Include details of your testing environment, tests ran to see how -->
13+
<!--- your change affects other areas of the code, etc. -->
14+
15+
### Screenshots, if any
16+
17+
### Types of changes
18+
19+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
20+
- [ ] Bug fix (non-breaking change which fixes an issue)
21+
- [ ] New feature (non-breaking change which adds functionality)
22+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
23+
24+
### Scope of the changes
25+
- [ ] User Interface
26+
- [ ] APIs
27+
28+
### Other checks
29+
30+
- [ ] My code follows the coding style of this project
31+
- [ ] I added unit tests that covers my code
32+
- [ ] I made sure there are no linter errors

README.md

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,72 @@
66

77
> Manage your node projects from user interface
88
9-
### RATIONALE
9+
## RATIONALE
10+
1011
* **No**de **P**roject **M**anager sounded very close to **Nopalm**(also sounding similar to `Napalm` :)). Hence the name!
1112
* I always faced difficulties in searching a relevant package while working on a node project and heavily craved for an UI since coming back and forth between browser and terminal killed productivity
12-
* To solve this, I thought of developing a <span style="color:#12344d; font-weight: bold">Nopalm (Node Project Manager)</span> with an exciting web user interface to search, install and uninstall packages from a single place
13+
* To solve this, I thought of developing <span style="color:#12344d; font-weight: bold">Nopalm (Node Project Manager)</span> with an exciting web user interface to search, install and uninstall packages from a single place
1314
* You can also scaffold a **new node project**
1415
* This project is heavily inspired from [Vue-UI](https://cli.vuejs.org/dev-guide/ui-api.html)
1516

16-
### USAGE
17+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app)
18+
19+
## USAGE
20+
1721
* Install the npm package globally and run the local server inside any node project directory / empty directory
1822
```shell
1923
npm i -g nopalm
2024
cd /path/to/target_dir && nopalm
2125
```
2226
* Visit [http://localhost:8001](http://localhost:8001) to start managing your node project
2327

24-
### To test locally
25-
##### Pre installed requirements
28+
## To run locally
29+
30+
#### Pre installed requirements
2631
- **node > 10**
2732
- **npm** or **yarn**
28-
##### Steps
33+
#### Steps
2934
* Clone the repository
30-
* Go to the **`client/`** folder and create **`.env.development.local`** and copy the following content
35+
* Install packages in `client` and `server`
36+
```shell
37+
npm i
38+
39+
cd client/
40+
npm i
41+
```
42+
**To run the development version**
43+
* Add this **.env** file in the `/client` folder
3144
```shell
32-
REACT_APP_API_BASE_URL='http://localhost:8001'
45+
echo "REACT_APP_API_BASE_URL='http://localhost:8001'" >> .env.development.local`
3346
```
3447
* Run the react client
3548
```shell
3649
cd client
37-
npm i
3850
npm run start
39-
* To run in an existing node project, go to the that particular directory and run this command
51+
* Run the server in an existing node project
4052
```shell
53+
cd /path/to/target_node_project
4154
npm run dev --prefix /path/to/nopalm
4255
```
43-
* Run the same command in an empty directory to create new node project !
44-
* Visit [http://localhost:3000](http://localhost:3000) to run this in development mode
56+
* Visit [https://localhost:3000](https://localhost:3000)
57+
**To run the production version**
58+
* Build the UI and run the server alone
59+
```shell
60+
cd client/
61+
62+
<!-- Build the React client -->
63+
npm run build
64+
65+
<!-- cd to target node project -->
66+
cd /path/to/target_node_project
67+
68+
npm run start --prefix /path/to/nopalm
69+
```
70+
* Visit [https://localhost:8001](https://localhost:8001)
71+
* Follow the same steps for testing in `empty directory`
72+
73+
## Testing APIs
74+
75+
Once you run the node server you might find [this](lib/collection/README.md) interesting to test it using Postman
76+
77+
## [Contributing Guidelines](.github/CONTRIBUTING.md)

lib/collection/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Postman Collection for the APIs
2+
3+
**Import the json file in the current directory to your Postman to test the apis**
4+
5+
[Reference Link](https://learning.postman.com/docs/getting-started/importing-and-exporting-data/) on how to import this into your Postman
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"info": {
3+
"_postman_id": "3451f7f6-17e6-4a2c-a6a9-a28f4c2337af",
4+
"name": "Node Project Manager",
5+
"description": "Project Manager UI client for Node",
6+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
7+
},
8+
"item": [
9+
{
10+
"name": "Installed packages - GET",
11+
"request": {
12+
"method": "GET",
13+
"header": [],
14+
"url": {
15+
"raw": "http://localhost:8001/api/packages/installed",
16+
"protocol": "http",
17+
"host": [
18+
"localhost"
19+
],
20+
"port": "8001",
21+
"path": [
22+
"api",
23+
"packages",
24+
"installed"
25+
]
26+
},
27+
"description": "Get all installed packages"
28+
},
29+
"response": []
30+
},
31+
{
32+
"name": "Install Package - POST",
33+
"request": {
34+
"method": "POST",
35+
"header": [],
36+
"body": {
37+
"mode": "raw",
38+
"raw": "{\n \"package\": {\n \"name\": \"chai\",\n \"version\": \"latest\",\n \"isDev\": true\n }\n}",
39+
"options": {
40+
"raw": {
41+
"language": "json"
42+
}
43+
}
44+
},
45+
"url": {
46+
"raw": "http://localhost:8001/api/packages/installed?package_manager=yarn",
47+
"protocol": "http",
48+
"host": [
49+
"localhost"
50+
],
51+
"port": "8001",
52+
"path": [
53+
"api",
54+
"packages",
55+
"installed"
56+
],
57+
"query": [
58+
{
59+
"key": "package_manager",
60+
"value": "yarn"
61+
}
62+
]
63+
},
64+
"description": "Install a package"
65+
},
66+
"response": []
67+
},
68+
{
69+
"name": "Uninstall package",
70+
"request": {
71+
"method": "DELETE",
72+
"header": [],
73+
"body": {
74+
"mode": "raw",
75+
"raw": "{\n \"package\": {\n \"name\": \"mocha\"\n }\n}",
76+
"options": {
77+
"raw": {
78+
"language": "json"
79+
}
80+
}
81+
},
82+
"url": {
83+
"raw": "http://localhost:8001/api/packages/installed?package_manager=npm",
84+
"protocol": "http",
85+
"host": [
86+
"localhost"
87+
],
88+
"port": "8001",
89+
"path": [
90+
"api",
91+
"packages",
92+
"installed"
93+
],
94+
"query": [
95+
{
96+
"key": "package_manager",
97+
"value": "npm"
98+
}
99+
]
100+
}
101+
},
102+
"response": []
103+
},
104+
{
105+
"name": "Get Package managers in project",
106+
"request": {
107+
"method": "GET",
108+
"header": [],
109+
"url": {
110+
"raw": "http://localhost:8001/api/package-managers",
111+
"protocol": "http",
112+
"host": [
113+
"localhost"
114+
],
115+
"port": "8001",
116+
"path": [
117+
"api",
118+
"package-managers"
119+
]
120+
},
121+
"description": "Get package managers used in the project"
122+
},
123+
"response": []
124+
}
125+
],
126+
"protocolProfileBehavior": {}
127+
}

lib/constants.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
module.exports = {
22
statusCodes: {
3-
BAD_REQUEST: 400,
4-
NOT_FOUND: 404,
5-
SUCCESS: 200,
6-
CREATED: 201,
7-
DELETED: 204,
8-
INTERNAL_ERROR: 500,
3+
BAD_REQUEST: 400,
4+
NOT_FOUND: 404,
5+
SUCCESS: 200,
6+
CREATED: 201,
7+
DELETED: 204,
8+
INTERNAL_ERROR: 500,
99
},
1010
messages: {
11-
INVALID_PROJECT: 'Invalid project. Please check if the current directory is a node project and has a package.json',
12-
INVALID_PACKAGE_INFORMATION: 'Invalid package information',
13-
INVALID_REQUEST_BODY: 'Invalid request. Please check the request body',
14-
SOMETHING_WRONG: 'Something went wrong',
15-
SUCCESSFUL_PACKAGE_INSTALL: 'Package is succesfully installed',
16-
SUCCESSFUL_PACKAGE_UNINSTALL: 'Package is succesfully uninstalled',
11+
INVALID_PROJECT: 'Invalid project. Please check if the current directory is a node project and has a package.json',
12+
INVALID_PACKAGE_INFORMATION: 'Invalid package information',
13+
INVALID_REQUEST_BODY: 'Invalid request. Please check the request body',
14+
SOMETHING_WRONG: 'Something went wrong',
15+
SUCCESSFUL_PACKAGE_INSTALL: 'Package is succesfully installed',
16+
SUCCESSFUL_PACKAGE_UNINSTALL: 'Package is succesfully uninstalled',
1717
},
1818
files: {
1919
PACKAGE_JSON: 'package.json',
2020
PACKAGE_LOCK_JSON: 'package-lock.json',
21-
YARN_LOCK: 'yarn.lock'
21+
YARN_LOCK: 'yarn.lock',
2222
},
2323
packageManagers: [
2424
{
2525
name: 'npm',
26-
file: 'PACKAGE_JSON'
26+
file: 'PACKAGE_JSON',
2727
},
2828
{
2929
name: 'yarn',
30-
file: 'YARN_LOCK'
31-
}
32-
]
30+
file: 'YARN_LOCK',
31+
},
32+
],
3333
};

lib/controllers/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const packageController = require('./packages');
42

53
module.exports = {

0 commit comments

Comments
 (0)