Skip to content

Commit

Permalink
feat(status): check git installation
Browse files Browse the repository at this point in the history
(closes bleenco#249)
  • Loading branch information
Izak88 committed Oct 23, 2017
1 parent befbca4 commit 954173e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/api/server-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ export function setupRoutes(): express.Router {

router.get('/ready', (req: express.Request, res: express.Response) => {
Observable.merge(...[
system.isGitInstalled(),
system.isSQLiteInstalled(),
docker.isDockerInstalled(),
docker.isDockerRunning(),
Expand Down Expand Up @@ -588,17 +589,20 @@ export function setupRoutes(): express.Router {
});

router.get('/status', (req: express.Request, res: express.Response) => {
system.isSQLiteInstalled().subscribe(sqlite => {
docker.isDockerInstalled().subscribe(dockerInstalled => {
if (dockerInstalled) {
docker.isDockerRunning().subscribe(dockerRunning => {
const data = { sqlite: sqlite, docker: dockerInstalled, dockerRunning: dockerRunning };
system.isGitInstalled().subscribe(git => {
system.isSQLiteInstalled().subscribe(sqlite => {
docker.isDockerInstalled().subscribe(dockerInstalled => {
if (dockerInstalled) {
docker.isDockerRunning().subscribe(dockerRunning => {
const data = {
sqlite: sqlite, docker: dockerInstalled, dockerRunning: dockerRunning, git: git };
res.status(200).json({ data: data });
});
} else {
const data = { sqlite: sqlite, docker: false, dockerRunning: false, git: git };
res.status(200).json({ data: data });
});
} else {
const data = { sqlite: sqlite, docker: false, dockerRunning: false };
res.status(200).json({ data: data });
}
}
});
});
});
});
Expand Down
15 changes: 15 additions & 0 deletions src/api/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@ export function isSQLiteInstalled(): Observable<boolean> {
});
});
}

export function isGitInstalled(): Observable<boolean> {
return new Observable((observer: Observer<boolean>) => {
const git = spawn('which', ['git']);
git.on('close', code => {
if (code === 0) {
observer.next(true);
} else {
observer.next(false);
}

observer.complete();
});
});
}
3 changes: 3 additions & 0 deletions src/app/components/app-setup/app-setup.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ <h2>
<div class="setup-list-item">
<img class="icon" [src]="serverStatus.sqlite ? 'images/icons/check-true.svg' : 'images/icons/check-false.svg'" name="sqlite3-installed-icon"> SQLite3 Installed
</div>
<div class="setup-list-item">
<img class="icon" [src]="serverStatus.git ? 'images/icons/check-true.svg' : 'images/icons/check-false.svg'" name="git-installed-icon"> Git Installed
</div>
</div>
<hr/>
<p *ngIf="!readyToSetup">Please make sure that all of the above checkmarks are green as it is mandatory to run Abstruse on this server.</p>
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/app-setup/app-setup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ServerStatus {
sqlite: boolean;
docker: boolean;
dockerRunning: boolean;
git: boolean;
}

export interface User {
Expand Down Expand Up @@ -40,7 +41,8 @@ export class AppSetupComponent implements OnInit {
this.serverStatus = {
sqlite: false,
docker: false,
dockerRunning: false
dockerRunning: false,
git: false
};

this.readyToSetup = false;
Expand Down

0 comments on commit 954173e

Please sign in to comment.