Skip to content

Commit dc87f05

Browse files
Introduce react redux store, existing project save and other major improvements
1 parent a2d3e56 commit dc87f05

36 files changed

+1227
-884
lines changed

.vscode/settings.json

Lines changed: 0 additions & 2 deletions
This file was deleted.

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
99
## RATIONALE
1010

11-
* **No**de **P**roject **M**anager sounded very close to **Nopalm**(also sounding similar to `Napalm` :)). Hence the name!
12-
* 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
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
14-
* You can also scaffold a **new node project**
15-
* This project is heavily inspired from [Vue-UI](https://cli.vuejs.org/dev-guide/ui-api.html)
11+
* **No**de **P**roject **M**anager sounded very close to **Nopalm**(also sounding similar to `Napalm`). Hence the name (and the logo)!
12+
* Having trouble in creating and managing multiple node projects during local development?
13+
* With `nopalm` you can create/scaffold a new project from a various defined presets, manage existing node project and its package dependencies efficiently
14+
* This project is heavily inspired from [Vue-UI](https://cli.vuejs.org/dev-guide/ui-api.html) and [NPM-GUI](https://www.npmjs.com/package/npm-gui) and tries to improve on these projects
1615

1716
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app)
1817

@@ -23,9 +22,13 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
2322
npm i -g nopalm
2423
cd /path/to/target_dir && nopalm
2524
```
25+
* Use npx to save the trouble of installing as well. In an empty or node project directory, run
26+
```shell
27+
npx nopalm
28+
```
2629
* Visit [http://localhost:8001](http://localhost:8001) to start managing your node project
2730

28-
## To run locally
31+
## To run / develop locally
2932

3033
#### Pre installed requirements
3134
- **node > 10**
@@ -40,14 +43,14 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
4043
npm i
4144
```
4245
**To run the development version**
43-
* Add this **.env** file in the `/client` folder
44-
```shell
45-
echo "REACT_APP_API_BASE_URL='http://localhost:8001'" >> .env.development.local`
46-
```
4746
* Run the react client
4847
```shell
4948
cd client
50-
npm run start
49+
npm run dev'
50+
* Alias the nopalm server
51+
```shell
52+
53+
```
5154
* Run the server in an existing node project
5255
```shell
5356
cd /path/to/target_node_project
@@ -74,4 +77,4 @@ This project was bootstrapped with [Create React App](https://github.com/faceboo
7477
7578
Once you run the node server you might find [this](lib/collection/README.md) interesting to test it using Postman
7679
77-
## [Contributing Guidelines](.github/CONTRIBUTING.md)
80+
## [Contributing Guidelines](.github/CONTRIBUTING.md)

addon/templates/cli/default_ts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"license": "ISC",
1515
"devDependencies": {
1616
"@types/node": "^16.11.6",
17-
"typescript": "^5.4.5"
17+
"typescript": "^5.4.5",
18+
"ts-node": "^10.4.0"
1819
}
1920
}

addon/templates/cli/oclif_ts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"devDependencies": {
1919
"typescript": "^4.4.4",
20-
"@types/node": "^16.11.6"
20+
"@types/node": "^16.11.6",
21+
"ts-node": "^10.4.0"
2122
}
2223
}

client/src/App.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import NopalmLogo from './logos/NopalmLogo';
2222

2323
// import SocialMediaLinks from './components/SocialMediaLinks';
2424

25-
import { AppProps, SettingsResultProps } from './helpers/types';
26-
2725
import { useDispatch, useSelector } from 'react-redux';
2826

2927
import { AppDispatch, RootState } from './store/store';
@@ -34,14 +32,10 @@ const { Header, Content, Sider } = Layout;
3432

3533
type MenuItem = Required<MenuProps>['items'][number];
3634

37-
const routesToPages: {
38-
[key: string]: (settings: SettingsResultProps,
39-
reflectUpdatedUserSettings?: () => void,
40-
routeChangeHandler?: () => void) => JSX.Element
41-
} = {
42-
project_details: (settings) => <ProjectDetails settings={settings} />,
43-
packages: (settings, reflectUpdatedUserSettings, routeChangeHandler) => <Packages settings={settings} routeChangeHandler={routeChangeHandler} />,
44-
settings: (settings, reflectUpdatedUserSettings) => <Settings settings={settings} reflectUpdatedUserSettings={reflectUpdatedUserSettings} />,
35+
const routesToPages = {
36+
project_details: () => <ProjectDetails />,
37+
packages: () => <Packages />,
38+
settings: () => <Settings />,
4539
};
4640

4741
function getMenuItem(
@@ -64,7 +58,7 @@ const items: MenuItem[] = [
6458
getMenuItem('Settings', 'settings', <Link to='/settings'><SettingOutlined /></Link>),
6559
];
6660

67-
const App: React.FC<AppProps> = (props) => {
61+
const App: React.FC = () => {
6862
const [collapsed, setCollapsed] = useState(true);
6963

7064
const { token } = theme.useToken();
@@ -113,7 +107,7 @@ const App: React.FC<AppProps> = (props) => {
113107
borderRadius: token.borderRadiusLG,
114108
}}
115109
>
116-
{routesToPages[currentActiveRoute](props.settings, props.reflectUpdatedUserSettings, routeChangeHandler)}
110+
{routesToPages[currentActiveRoute]()}
117111
</div>
118112
</Content>
119113
{/* <Footer style={{

client/src/api/Dataservice.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const API_BASE_URL = import.meta.env.VITE_APP_API_BASE_URL;
22

3-
import { InstalledPackageProps, ProjectDetailsProps, SettingsResultProps } from '../helpers/types';
3+
import { InstalledPackageProps, NewProjectDefaults, ProjectDetailsProps, SettingsResultProps } from '../helpers/types';
44

5-
async function getProjectDetails(): Promise<{ project: ProjectDetailsProps, isEmptyDir: boolean, defaults: object }> {
5+
async function getProjectDetails(): Promise<{ project: ProjectDetailsProps, isEmptyDir: boolean, defaults: NewProjectDefaults }> {
66
const urlPath = 'project';
77

88
const result = await fetch(`${API_BASE_URL}/${urlPath}`);
@@ -151,7 +151,7 @@ async function createNewProject(projectDetails) {
151151
headers: {
152152
'Content-Type': 'application/json'
153153
},
154-
body: projectDetails
154+
body: JSON.stringify(projectDetails)
155155
})).json();
156156

157157
return requestPromise.then((res) => {
@@ -166,6 +166,30 @@ async function createNewProject(projectDetails) {
166166
}
167167
}
168168

169+
async function updateProject(projectDetails) {
170+
const urlPath = 'project';
171+
172+
try {
173+
const requestPromise = (await fetch(`${API_BASE_URL}/${urlPath}`, {
174+
method: 'PATCH',
175+
headers: {
176+
'Content-Type': 'application/json'
177+
},
178+
body: JSON.stringify(projectDetails)
179+
})).json();
180+
181+
return requestPromise.then((res) => {
182+
if (res.msg === 'Successfully updated the project') {
183+
return true;
184+
}
185+
186+
return false;
187+
});
188+
} catch (ex) {
189+
return false;
190+
}
191+
}
192+
169193
const Dataservice = {
170194
getProjectDetails,
171195
getInstalledPackages,
@@ -175,7 +199,8 @@ const Dataservice = {
175199
uninstallPackage,
176200
getSettings,
177201
updateSettings,
178-
createNewProject
202+
createNewProject,
203+
updateProject
179204
};
180205

181206
export default Dataservice;

client/src/components/AccentColorPicker.tsx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
11
import React from 'react';
22

3-
import * as antDColor from '@ant-design/colors'
4-
53
import { theme, Tooltip } from 'antd';
64

5+
import * as colors from '@ant-design/colors';
6+
7+
import { useSelector } from 'react-redux';
8+
79
import './AccentColorPicker.scss';
810

911
import { AccentColors, AccentColorPickerProps } from '../helpers/types';
1012

13+
import { RootState } from '../store/store';
14+
1115
const AccentColorPicker: React.FC<AccentColorPickerProps> = (props: AccentColorPickerProps) => {
1216
const { token } = theme.useToken();
1317

18+
const settings = useSelector((state: RootState) => state.app.globalSettings);
19+
1420
return (
1521
<div className='accent-color-picker-container'>
1622
{
17-
Object.keys(AccentColors).map(accentColor => (
18-
// capitalized color name
19-
<Tooltip key={accentColor} title={`${accentColor[0].toUpperCase()}${accentColor.slice(1)}`}>
20-
<div onClick={() => props.onColorChange(accentColor)}
21-
style={{
22-
background: antDColor[accentColor].primary,
23-
boxShadow: props.selectedAccentColor === accentColor ? `0 0 2px ${antDColor[accentColor].primary}` : '',
24-
border: props.selectedAccentColor === accentColor ? `3px solid ${token.colorBgContainer}` : ''
25-
}}
26-
className='accent-color' />
27-
</Tooltip>
28-
))
23+
Object.keys(AccentColors).map(accentColor => {
24+
const accentColorCasted = accentColor as AccentColors;
25+
26+
return (
27+
// capitalized color name
28+
<Tooltip key={accentColorCasted} title={`${accentColorCasted[0].toUpperCase()}${accentColorCasted.slice(1)}`}>
29+
<div onClick={() => props.onColorChange(accentColorCasted)}
30+
style={{
31+
background: colors[accentColorCasted].primary,
32+
boxShadow: settings.appearance.accent_color === accentColorCasted ? `0 0 2px ${colors[accentColorCasted].primary}` : '',
33+
border: settings.appearance.accent_color === accentColorCasted ? `3px solid ${token.colorBgContainer}` : ''
34+
}}
35+
className='accent-color' />
36+
</Tooltip>
37+
);
38+
})
2939
}
3040
</div>
3141
)

0 commit comments

Comments
 (0)