Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit bc6619d

Browse files
committed
fix(): server commands separated from client commands
1 parent 186f6fe commit bc6619d

File tree

12 files changed

+113
-67
lines changed

12 files changed

+113
-67
lines changed

dist/main.js

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reactive.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,38 @@
11
{
2-
"name": "@rxdi/deploy-commit",
3-
"main": "./src/main.ts"
4-
}
2+
"name": "@rxdi/deploy-commit",
3+
"main": "./src/main.ts",
4+
"packages": [
5+
{
6+
"name": "@rxdi/core",
7+
"version": "^0.2.7"
8+
},
9+
{
10+
"name": "chalk",
11+
"version": "^2.4.2"
12+
},
13+
{
14+
"name": "cli-table",
15+
"version": "^0.3.1"
16+
},
17+
{
18+
"name": "graphql",
19+
"version": "^14.2.1"
20+
},
21+
{
22+
"name": "graphql-request",
23+
"version": "^1.8.2"
24+
},
25+
{
26+
"name": "ora",
27+
"version": "^3.2.0"
28+
}
29+
],
30+
"ipfs": [
31+
{
32+
"provider": "https://ipfs.io/ipfs/",
33+
"dependencies": [
34+
"QmbrwcffVB3y8iUVvifynhSYfv1LCHX1ETVi8Q8pmqSJsH"
35+
]
36+
}
37+
]
38+
}

src/app/app.injection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export enum COMMANDS {
2828
scan = "scan",
2929
checkout = "checkout",
3030
commit = "commit",
31-
push = "push"
31+
push = "push",
32+
install = "install",
33+
i = "i"
3234
}
33-
export type MAIN_COMMANDS = "--status" | "--help" | " ";
35+
36+
export type MAIN_ARGUMENTS = "--status" | "--help" | "--local-node" | "--cloudflare" | "--infura" | "--ipfs";

src/app/core/core.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { LoggerService } from "./logger/logger.service";
77
import { GraphService } from "./graph/graph.service";
88
import { FileService } from "./file/file.service";
99
import { TestFactoryService } from "./test-factory/test-factory.service";
10-
import { InstallService } from './tasks/install/install.service';
10+
import { InstallService } from "./tasks/install/install.service";
1111

1212
@Module({
1313
providers: [

src/app/core/executor/executor.service.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import "jest";
22
import { Container, createTestBed } from "@rxdi/core";
33
import { ExecutorService } from "./executor.service";
4-
import { createFakeInjectable } from "../test-factory/test-factory.service";
4+
import { createFakeInjectables } from "../test-factory/test-factory.service";
55

66
describe("Executor Service", () => {
77
beforeAll(async () => {
88
await createTestBed({
9-
imports: [],
109
providers: [
1110
ExecutorService,
12-
...createFakeInjectable()
11+
...createFakeInjectables()
1312
]
1413
}).toPromise();
1514
});

src/app/core/executor/executor.service.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { COMMANDS } from "../../app.injection";
33
import { TransactionService } from "../transaction/transaction.service";
44
import { ITransactionType, IStatusQueryType } from "../api-introspection";
55
import { StatusService } from "../status/status.service";
6+
import { InstallService } from "../tasks/install/install.service";
67

78
@Injectable()
89
export class ExecutorService {
9-
taskMap = new Map<
10+
taskMapServer = new Map<
1011
COMMANDS,
11-
() => Promise<ITransactionType | ITransactionType[]>
12+
() => Promise<ITransactionType | ITransactionType[] | {}>
1213
>([
1314
[COMMANDS.add, this.transactionService.addTransaction],
1415
[COMMANDS.checkout, this.transactionService.checkoutTransaction],
@@ -17,14 +18,26 @@ export class ExecutorService {
1718
[COMMANDS.push, this.transactionService.pushTransactions]
1819
]);
1920

21+
taskMapClient = new Map<
22+
COMMANDS,
23+
() => Promise<ITransactionType | ITransactionType[] | {}>
24+
>([
25+
[COMMANDS.install, this.installService.install],
26+
[COMMANDS.i, this.installService.install]
27+
]);
28+
2029
constructor(
2130
private transactionService: TransactionService,
22-
private statusService: StatusService
31+
private statusService: StatusService,
32+
private installService: InstallService
2333
) {}
2434

2535
async execute(command: COMMANDS) {
26-
if (this.taskMap.has(command) && await this.isServerStarted()) {
27-
return await this.taskMap.get(command)();
36+
if (this.taskMapClient.has(command)) {
37+
return await this.taskMapClient.get(command)();
38+
}
39+
if (this.taskMapServer.has(command) && (await this.isServerStarted())) {
40+
return await this.taskMapServer.get(command)();
2841
}
2942
return null;
3043
}

src/app/core/helpers/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { MAIN_COMMANDS } from "app/app.injection";
1+
import { MAIN_ARGUMENTS } from "app/app.injection";
22

3-
export const includes = (i: MAIN_COMMANDS) =>
3+
export const includes = (i: MAIN_ARGUMENTS) =>
44
process.argv.toString().includes(i);
55
export const nextOrDefault = (
6-
i: MAIN_COMMANDS,
6+
i: MAIN_ARGUMENTS,
77
fb: any = true,
88
type = p => p
99
) => {

src/app/core/tasks/install/install.service.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import 'jest';
2-
import { Container, createTestBed } from '@gapi/core';
3-
import { InstallService } from './install.service';
1+
import "jest";
2+
import { Container, createTestBed } from "@rxdi/core";
3+
import { InstallService } from "./install.service";
44

5-
describe('Install Service', () => {
5+
describe("Install Service", () => {
66
beforeAll(async () => {
77
await createTestBed({
88
imports: [],
99
providers: [InstallService]
1010
}).toPromise();
1111
});
1212

13-
it('should be defined', done => {
13+
it("should be defined", done => {
1414
expect(Container.has(InstallService)).toBeTruthy();
1515
done();
1616
});

src/app/core/tasks/install/install.service.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {
44
Container,
55
ExternalImporter,
66
FileService,
7-
ExternalImporterIpfsConfig,
8-
ConfigService
7+
ExternalImporterIpfsConfig
98
} from "@rxdi/core";
109
import { Observable, combineLatest } from "rxjs";
1110
import { includes } from "../../helpers";
@@ -41,11 +40,9 @@ export const DownloadDependencies = (
4140
export class InstallService {
4241
constructor(
4342
private externalImporter: ExternalImporter,
44-
private fileService: FileService,
45-
private externalImporterConfig: ExternalImporterIpfsConfig,
46-
private configService: ConfigService
43+
private fileService: FileService
4744
) {}
48-
run() {
45+
install = () => {
4946
let p = null;
5047
if (includes("--local-node")) {
5148
p = this.externalImporter.getProvider("local");
@@ -132,12 +129,10 @@ export class InstallService {
132129
})
133130
];
134131
}
135-
combineLatest(modulesToDownload)
136-
.pipe(
137-
tap(() => (hash ? this.externalImporter.addPackageToJson(hash) : null)),
138-
tap(() => this.externalImporter.filterUniquePackages())
139-
)
140-
.subscribe(
132+
return combineLatest(modulesToDownload).pipe(
133+
tap(() => (hash ? this.externalImporter.addPackageToJson(hash) : null)),
134+
tap(() => this.externalImporter.filterUniquePackages()),
135+
tap(
141136
res => {
142137
console.log(
143138
"Default ipfs provider: ",
@@ -157,6 +152,7 @@ export class InstallService {
157152
e => {
158153
throw new Error(e);
159154
}
160-
);
161-
}
155+
)
156+
).toPromise();
157+
};
162158
}

0 commit comments

Comments
 (0)