Skip to content

Commit ac1e241

Browse files
richard-coxnwmac
andauthored
Move git tools and some components into their own package (#4752)
* Move git tools and some components into their own package - this then becomes more of a git library - includes git - entities (and new git endpoint currently hidden), effects, actions, etc - commit list base items - git scm service and related items * fix unit tests * Update public_api.ts * Update public_api.ts * Fix lint issues Co-authored-by: Neil MacDougall <[email protected]> Co-authored-by: Neil MacDougall <[email protected]>
1 parent 46735f9 commit ac1e241

File tree

81 files changed

+991
-750
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+991
-750
lines changed

angular.json

+28
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,34 @@
388388
}
389389
}
390390
}
391+
},
392+
"git": {
393+
"root": "src/frontend/packages/git",
394+
"sourceRoot": "src/frontend/packages/git/src",
395+
"projectType": "library",
396+
"prefix": "lib",
397+
"architect": {
398+
"test": {
399+
"builder": "@angular-devkit/build-angular:karma",
400+
"options": {
401+
"main": "src/frontend/packages/git/src/test.ts",
402+
"tsConfig": "src/frontend/packages/git/tsconfig.spec.json",
403+
"karmaConfig": "src/frontend/packages/git/karma.conf.js"
404+
}
405+
},
406+
"lint": {
407+
"builder": "@angular-devkit/build-angular:tslint",
408+
"options": {
409+
"tsConfig": [
410+
"src/tsconfig.json"
411+
],
412+
"tslintConfig": "src/frontend/packages/git/tslint.json",
413+
"files": [
414+
"src/frontend/packages/git/src/**/*.ts"
415+
]
416+
}
417+
}
418+
}
391419
}
392420

393421
},

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"test-frontend:cloud-foundry": "NG_TEST_SUITE=cloud-foundry ng test cloud-foundry --code-coverage --watch=false",
2929
"test-frontend:cf-autoscaler": "NG_TEST_SUITE=autoscaler ng test cf-autoscaler --code-coverage --watch=false",
3030
"test-frontend:kubernetes": "NG_TEST_SUITE=kubernetes ng test kubernetes --code-coverage --watch=false",
31+
"test-frontend:git": "NG_TEST_SUITE=git ng test git --code-coverage --watch=false",
3132
"posttest": "nyc report --reporter=html --reporter=lcovonly --reporter=json --tempDir=coverage/nyc",
3233
"codecov": "codecov -f coverage/coverage-final.json -F frontend",
3334
"lint": "ng lint --format stylish",

src/frontend/packages/cf-autoscaler/src/store/autoscaler.store.module.ts

-56
This file was deleted.

src/frontend/packages/cloud-foundry/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"version": "0.0.1",
44
"peerDependencies": {
55
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
6-
"@angular/core": "^6.0.0-rc.0 || ^6.0.0"
6+
"@angular/core": "^6.0.0-rc.0 || ^6.0.0",
7+
"@stratosui/git": "^0.0.1"
78
},
89
"stratos": {
910
"module": "CloudFoundryPackageModule",
1011
"routingModule": "CloudFoundryRoutingModule",
1112
"theming": "sass/_all-theme#apply-theme-stratos-cloud-foundry",
12-
"backend": [ "cloudfoundry", "cfapppush", "cfappssh", "userinvite" ]
13+
"backend": ["cloudfoundry", "cfapppush", "cfappssh", "userinvite"]
1314
}
1415
}

src/frontend/packages/cloud-foundry/src/actions/deploy-applications.actions.ts

+1-83
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,22 @@
11
import { Action } from '@ngrx/store';
2+
import { GitBranch, GitSCM } from '@stratosui/git';
23

3-
import { PaginatedAction } from '../../../store/src/types/pagination.types';
4-
import { EntityRequestAction } from '../../../store/src/types/request.types';
5-
import { gitBranchesEntityType, gitCommitEntityType } from '../cf-entity-types';
6-
import { CF_ENDPOINT_TYPE } from '../cf-types';
7-
import { GitSCM } from '../shared/data-services/scm/scm';
84
import { DockerAppDetails, GitAppDetails, OverrideAppDetails, SourceType } from '../store/types/deploy-application.types';
9-
import { GitBranch, GitCommit } from '../store/types/git.types';
105

116
export const SET_APP_SOURCE_DETAILS = '[Deploy App] Application Source';
127
export const CHECK_PROJECT_EXISTS = '[Deploy App] Check Project exists';
138
export const PROJECT_DOESNT_EXIST = '[Deploy App] Project Doesn\'t exist';
149
export const PROJECT_FETCH_FAILED = '[Deploy App] Project Fetch Failed';
1510
export const PROJECT_EXISTS = '[Deploy App] Project exists';
16-
export const FETCH_BRANCHES_FOR_PROJECT = '[Deploy App] Fetch branches';
17-
export const FETCH_BRANCH_FOR_PROJECT = '[Deploy App] Fetch branch';
1811
export const SAVE_APP_DETAILS = '[Deploy App] Save app details';
1912
export const SAVE_APP_OVERRIDE_DETAILS = '[Deploy App] Save app override details';
20-
export const FETCH_COMMIT = '[Deploy App] Fetch commit';
21-
export const FETCH_COMMITS = '[Deploy App] Fetch commits';
2213
export const SET_DEPLOY_CF_SETTINGS = '[Deploy App] Set CF Settings';
2314
export const DELETE_DEPLOY_APP_SECTION = '[Deploy App] Delete section';
2415
export const SET_BRANCH = '[Deploy App] Set branch';
2516
export const SET_DEPLOY_BRANCH = '[Deploy App] Set deploy branch';
2617
export const SET_DEPLOY_COMMIT = '[Deploy App] Set deploy commit';
2718
export const DELETE_COMMIT = '[Deploy App] Delete commit';
2819

29-
export const FETCH_BRANCH_START = '[GitHub] Fetch branch start';
30-
export const FETCH_BRANCH_SUCCESS = '[GitHub] Fetch branch succeeded';
31-
export const FETCH_BRANCH_FAILED = '[GitHub] Fetch branch failed';
32-
33-
export const FETCH_BRANCHES_START = '[GitHub] Fetch branches start';
34-
export const FETCH_BRANCHES_SUCCESS = '[GitHub] Fetch branches succeeded';
35-
export const FETCH_BRANCHES_FAILED = '[GitHub] Fetch branches failed';
36-
3720
export class SetAppSourceDetails implements Action {
3821
constructor(public sourceType: SourceType) { }
3922
type = SET_APP_SOURCE_DETAILS;
@@ -59,38 +42,6 @@ export class ProjectExists implements Action {
5942
type = PROJECT_EXISTS;
6043
}
6144

62-
export class FetchBranchForProject implements EntityRequestAction {
63-
constructor(public scm: GitSCM, public projectName: string, public guid: string, public branchName: string) {
64-
this.guid = this.guid || `${scm.getType()}-${this.projectName}-${this.branchName}`;
65-
}
66-
actions = [
67-
FETCH_BRANCH_START,
68-
FETCH_BRANCH_SUCCESS,
69-
FETCH_BRANCH_FAILED
70-
];
71-
public endpointType = CF_ENDPOINT_TYPE;
72-
type = FETCH_BRANCH_FOR_PROJECT;
73-
entityType = gitBranchesEntityType;
74-
}
75-
76-
export class FetchBranchesForProject implements PaginatedAction {
77-
constructor(public scm: GitSCM, public projectName: string) {
78-
this.paginationKey = FetchBranchesForProject.createPaginationKey(scm, projectName);
79-
}
80-
actions = [
81-
FETCH_BRANCHES_START,
82-
FETCH_BRANCHES_SUCCESS,
83-
FETCH_BRANCHES_FAILED
84-
];
85-
public endpointType = CF_ENDPOINT_TYPE;
86-
type = FETCH_BRANCHES_FOR_PROJECT;
87-
entityType = gitBranchesEntityType;
88-
paginationKey: string;
89-
flattenPagination = true;
90-
91-
static createPaginationKey = (scm: GitSCM, projectName: string) => scm.getType() + ':' + projectName;
92-
}
93-
9445
export class SaveAppDetails implements Action {
9546
constructor(public git: GitAppDetails, public docker: DockerAppDetails) { }
9647
type = SAVE_APP_DETAILS;
@@ -101,39 +52,6 @@ export class SaveAppOverrides implements Action {
10152
type = SAVE_APP_OVERRIDE_DETAILS;
10253
}
10354

104-
export class FetchCommit implements EntityRequestAction {
105-
commit: GitCommit;
106-
public endpointType = CF_ENDPOINT_TYPE;
107-
constructor(public scm: GitSCM, public commitSha: string, public projectName: string) { }
108-
type = FETCH_COMMIT;
109-
entityType = gitCommitEntityType;
110-
}
111-
112-
export class FetchCommits implements PaginatedAction {
113-
114-
/**
115-
* Creates an instance of FetchCommits.
116-
* @param projectName For example `cloudfoundry-incubator/stratos`
117-
* @param sha Branch name, tag, etc
118-
*/
119-
constructor(public scm: GitSCM, public projectName: string, public sha: string) {
120-
this.paginationKey = scm.getType() + projectName + sha;
121-
}
122-
actions = [
123-
'[Deploy App] Fetch commits start',
124-
'[Deploy App] Fetch commits success',
125-
'[Deploy App] Fetch commits failed',
126-
];
127-
public endpointType = CF_ENDPOINT_TYPE;
128-
type = FETCH_COMMITS;
129-
entityType = gitCommitEntityType;
130-
paginationKey: string;
131-
initialParams = {
132-
'order-direction': 'asc',
133-
'order-direction-field': 'date',
134-
};
135-
}
136-
13755
export class StoreCFSettings implements Action {
13856
constructor(public cloudFoundryDetails: any) { }
13957
type = SET_DEPLOY_CF_SETTINGS;

src/frontend/packages/cloud-foundry/src/actions/github.actions.ts

-16
This file was deleted.

src/frontend/packages/cloud-foundry/src/cf-entity-catalog.ts

-26
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ import { CfEventActionBuilders } from './entity-action-builders/cf-event.action-
3939
import { CfInfoDefinitionActionBuilders } from './entity-action-builders/cf-info.action-builders';
4040
import { DomainActionBuilders } from './entity-action-builders/domin.action-builder';
4141
import { FeatureFlagActionBuilders } from './entity-action-builders/feature-flag.action-builder';
42-
import {
43-
GitBranchActionBuilders,
44-
GitCommitActionBuilders,
45-
GitCommitActionBuildersConfig,
46-
GitRepoActionBuilders,
47-
} from './entity-action-builders/git-action-builder';
4842
import { OrganizationActionBuilders } from './entity-action-builders/organization.action-builders';
4943
import { QuotaDefinitionActionBuilder } from './entity-action-builders/quota-definition.action-builders';
5044
import { RoutesActionBuilders } from './entity-action-builders/routes.action-builder';
@@ -62,7 +56,6 @@ import { UserProvidedServiceActionBuilder } from './entity-action-builders/user-
6256
import { UserActionBuilders } from './entity-action-builders/user.action-builders';
6357
import { AppStat } from './store/types/app-metadata.types';
6458
import { CfUser } from './store/types/cf-user.types';
65-
import { GitBranch, GitCommit, GitRepo } from './store/types/git.types';
6659

6760
/**
6861
* A strongly typed collection of Cloud Foundry Catalog Entities.
@@ -172,25 +165,6 @@ export class CfEntityCatalog {
172165
DomainActionBuilders
173166
>;
174167

175-
public gitCommit: StratosBaseCatalogEntity<
176-
IBasicCFMetaData,
177-
GitCommit,
178-
GitCommitActionBuildersConfig,
179-
GitCommitActionBuilders
180-
>;
181-
182-
public gitRepo: StratosBaseCatalogEntity<
183-
IBasicCFMetaData,
184-
GitRepo,
185-
GitRepoActionBuilders
186-
>;
187-
188-
public gitBranch: StratosBaseCatalogEntity<
189-
IBasicCFMetaData,
190-
GitBranch,
191-
GitBranchActionBuilders
192-
>;
193-
194168
public event: StratosBaseCatalogEntity<
195169
IBasicCFMetaData,
196170
APIResource<CfEvent>,

src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import {
2222
cfUserEntityType,
2323
domainEntityType,
2424
featureFlagEntityType,
25-
gitBranchesEntityType,
26-
gitCommitEntityType,
27-
gitRepoEntityType,
2825
organizationEntityType,
2926
privateDomainsEntityType,
3027
quotaDefinitionEntityType,
@@ -49,7 +46,7 @@ import { getAPIResourceGuid } from './store/selectors/api.selectors';
4946
import { CfUser, CfUserRoleParams, OrgUserRoleNames, SpaceUserRoleNames } from './store/types/cf-user.types';
5047

5148
const entityCache: {
52-
[key: string]: EntitySchema
49+
[key: string]: EntitySchema;
5350
} = {};
5451

5552
const AppSummarySchema = new CFEntitySchema(appSummaryEntityType, {}, { idAttribute: 'guid' });
@@ -61,15 +58,6 @@ entityCache[appStatsEntityType] = AppStatSchema;
6158
const AppEnvVarSchema = new CFEntitySchema(appEnvVarsEntityType, {}, { idAttribute: getAPIResourceGuid });
6259
entityCache[appEnvVarsEntityType] = AppEnvVarSchema;
6360

64-
const GithubBranchSchema = new CFEntitySchema(gitBranchesEntityType, {}, { idAttribute: 'entityId' });
65-
entityCache[gitBranchesEntityType] = GithubBranchSchema;
66-
67-
const GithubRepoSchema = new CFEntitySchema(gitRepoEntityType);
68-
entityCache[gitRepoEntityType] = GithubRepoSchema;
69-
70-
const GithubCommitSchema = new CFEntitySchema(gitCommitEntityType, {}, { idAttribute: commit => commit.guid });
71-
entityCache[gitCommitEntityType] = GithubCommitSchema;
72-
7361
const CFInfoSchema = new CFEntitySchema(cfInfoEntityType);
7462
entityCache[cfInfoEntityType] = CFInfoSchema;
7563

0 commit comments

Comments
 (0)