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

Commit ec2da3d

Browse files
author
Anton Cherednikov
committed
Merge branch 'feature/ptf-675/_service_promote' into 'develop'
PTF-675: [CLI]: Service Promote See merge request cs-platform/public/cli!13
2 parents bcdfdaf + b5a04e8 commit ec2da3d

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $ npm install -g codestore-cli
2222
$ codestore COMMAND
2323
running command...
2424
$ codestore (-v|--version|version)
25-
codestore-cli/1.2.1 darwin-x64 node-v12.16.3
25+
codestore-cli/1.2.2 darwin-x64 node-v12.16.3
2626
$ codestore --help [COMMAND]
2727
USAGE
2828
$ codestore COMMAND
@@ -49,6 +49,7 @@ USAGE
4949
* [`codestore service:delete`](#codestore-servicedelete)
5050
* [`codestore service:list`](#codestore-servicelist)
5151
* [`codestore service:logs`](#codestore-servicelogs)
52+
* [`codestore service:promote [ID]`](#codestore-servicepromote-id)
5253
* [`codestore service:pull [ID]`](#codestore-servicepull-id)
5354
* [`codestore service:push`](#codestore-servicepush)
5455

@@ -286,6 +287,18 @@ ALIASES
286287
$ codestore logs
287288
```
288289

290+
## `codestore service:promote [ID]`
291+
292+
Create new service
293+
294+
```
295+
USAGE
296+
$ codestore service:promote [ID]
297+
298+
ALIASES
299+
$ codestore pull
300+
```
301+
289302
## `codestore service:pull [ID]`
290303

291304
Create new service

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "codestore-cli",
33
"description": "Command Line Interface of code.store. Add services, deploy, debug, perform all operations from your terminal.",
4-
"version": "1.2.1",
4+
"version": "1.2.2",
55
"bin": {
66
"codestore": "./bin/run",
77
"cs": "./bin/run"

src/commands/service/promote.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Command from '../../lib/command';
2+
import Aliases from '../../common/constants/aliases';
3+
4+
export default class Promote extends Command {
5+
public static description = 'Promotes service from private env to demo';
6+
7+
public static aliases = [Aliases.PULL];
8+
9+
public static args = [
10+
{ name: 'id' },
11+
];
12+
13+
private async getServiceId(args): Promise<{serviceId: number}> {
14+
if (args.id) {
15+
return { serviceId: +args.id };
16+
}
17+
return this.serviceWorker.loadValuesFromYaml();
18+
}
19+
20+
public async execute(): Promise<void> {
21+
const { args } = this.parse(Promote);
22+
23+
const { serviceId } = await this.getServiceId(args);
24+
25+
await this.codestore.Service.promote(serviceId);
26+
27+
this.log(`Successfully promoted service with id ${serviceId} to demo environment`);
28+
}
29+
}

src/lib/api-services/service/index.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { ApolloClient } from 'apollo-boost';
22
import {
3-
LIST_SERVICES, CREATE_SERVICE, DEPLOY_SERVICE, LIST_BUSINESS_DOMAINS, DELETE_SERVICE, DOWNLOAD_SERVICE, PUSH_SERVICE, SINGLE_SERVICE, GENERATE_SERVICE_ENTITIES,
3+
LIST_SERVICES,
4+
CREATE_SERVICE,
5+
DEPLOY_SERVICE,
6+
LIST_BUSINESS_DOMAINS,
7+
DELETE_SERVICE,
8+
DOWNLOAD_SERVICE,
9+
PUSH_SERVICE,
10+
SINGLE_SERVICE,
11+
GENERATE_SERVICE_ENTITIES,
12+
PROMOTE_SERVICE,
413
} from './queries';
514
import { IService, IServiceCreateResult, IServiceCreate } from '../../../interfaces/service.interface';
615
import ServiceStateEnum from '../../../common/constants/service-state.enum';
@@ -125,4 +134,15 @@ export default class Service {
125134

126135
return data.generateServiceEntities.data;
127136
}
137+
138+
public async promote(serviceId: number): Promise<IService> {
139+
const { data: { promote } } = await this.apiClient.mutate({
140+
mutation: PROMOTE_SERVICE,
141+
variables: {
142+
id: serviceId,
143+
},
144+
});
145+
146+
return promote;
147+
}
128148
}

src/lib/api-services/service/queries.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export const PUSH_SERVICE = gql`mutation pushService($base64Service: String!, $n
6060
}
6161
}`;
6262

63+
export const PROMOTE_SERVICE = gql`mutation promoteService($id: Int!){
64+
promoteService(id: $id){
65+
${SERVICE}
66+
}
67+
}`;
68+
6369
export const GENERATE_SERVICE_ENTITIES = gql`mutation generateServiceEntities($base64Service: String!){
6470
generateServiceEntities(base64Service:$base64Service){
6571
data

0 commit comments

Comments
 (0)