declastruct-github 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.test/assets/getSampleRepo.js +0 -3
- package/dist/.test/assets/getSampleRepo.js.map +1 -1
- package/dist/domain.objects/DeclaredGithubBranchProtection.d.ts +2 -1
- package/dist/domain.objects/DeclaredGithubBranchProtection.js +1 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.js.map +1 -1
- package/dist/domain.objects/DeclaredGithubRepo.d.ts +6 -4
- package/dist/domain.objects/DeclaredGithubRepo.js.map +1 -1
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.js +3 -2
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.js.map +1 -1
- package/dist/domain.operations/repo/setRepo.js +9 -5
- package/dist/domain.operations/repo/setRepo.js.map +1 -1
- package/package.json +3 -3
- package/readme.md +93 -53
|
@@ -10,10 +10,7 @@ const getSampleRepo = (input) => DeclaredGithubRepo_1.DeclaredGithubRepo.as({
|
|
|
10
10
|
owner: input.owner,
|
|
11
11
|
name: input.name,
|
|
12
12
|
description: null,
|
|
13
|
-
homepage: null,
|
|
14
|
-
private: false,
|
|
15
13
|
visibility: 'public',
|
|
16
|
-
archived: false,
|
|
17
14
|
});
|
|
18
15
|
exports.getSampleRepo = getSampleRepo;
|
|
19
16
|
//# sourceMappingURL=getSampleRepo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSampleRepo.js","sourceRoot":"","sources":["../../../src/.test/assets/getSampleRepo.ts"],"names":[],"mappings":";;;AAAA,gFAA6E;AAE7E;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,KAG7B,EAAsB,EAAE,CACvB,uCAAkB,CAAC,EAAE,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC,KAAK;IAClB,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,
|
|
1
|
+
{"version":3,"file":"getSampleRepo.js","sourceRoot":"","sources":["../../../src/.test/assets/getSampleRepo.ts"],"names":[],"mappings":";;;AAAA,gFAA6E;AAE7E;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,KAG7B,EAAsB,EAAE,CACvB,uCAAkB,CAAC,EAAE,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC,KAAK;IAClB,IAAI,EAAE,KAAK,CAAC,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC;AATQ,QAAA,aAAa,iBASrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DomainEntity, RefByUnique } from 'domain-objects';
|
|
1
|
+
import { DomainEntity, DomainLiteral, RefByUnique } from 'domain-objects';
|
|
2
2
|
import { DeclaredGithubBranch } from './DeclaredGithubBranch';
|
|
3
3
|
/**
|
|
4
4
|
* .what = a declarative structure which represents GitHub branch protection rules
|
|
@@ -104,5 +104,6 @@ export declare class DeclaredGithubBranchProtection extends DomainEntity<Declare
|
|
|
104
104
|
build<TDobj extends import("domain-objects").Refable<TShape, TPrimary, TUnique>, TShape extends import("domain-objects/dist/reference/Refable").DomainObjectShape = any, TPrimary extends readonly string[] = any, TUnique extends readonly string[] = any>(props: RefByUnique<TDobj, TShape, TPrimary, TUnique>): RefByUnique<TDobj, TShape, TPrimary, TUnique>;
|
|
105
105
|
as<TDobj_1 extends import("domain-objects").Refable<TShape_1, TPrimary_1, TUnique_1>, TShape_1 extends import("domain-objects/dist/reference/Refable").DomainObjectShape = any, TPrimary_1 extends readonly string[] = any, TUnique_1 extends readonly string[] = any>(props: RefByUnique<TDobj_1, TShape_1, TPrimary_1, TUnique_1>): RefByUnique<TDobj_1, TShape_1, TPrimary_1, TUnique_1>;
|
|
106
106
|
};
|
|
107
|
+
requiredStatusChecks: typeof DomainLiteral;
|
|
107
108
|
};
|
|
108
109
|
}
|
|
@@ -8,5 +8,6 @@ exports.DeclaredGithubBranchProtection = DeclaredGithubBranchProtection;
|
|
|
8
8
|
DeclaredGithubBranchProtection.unique = ['branch'];
|
|
9
9
|
DeclaredGithubBranchProtection.nested = {
|
|
10
10
|
branch: (domain_objects_1.RefByUnique),
|
|
11
|
+
requiredStatusChecks: domain_objects_1.DomainLiteral,
|
|
11
12
|
};
|
|
12
13
|
//# sourceMappingURL=DeclaredGithubBranchProtection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclaredGithubBranchProtection.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubBranchProtection.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"DeclaredGithubBranchProtection.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubBranchProtection.ts"],"names":[],"mappings":";;;AAAA,mDAA0E;AAqH1E,MAAa,8BACX,SAAQ,6BAA4C;;AADtD,wEASC;AALe,qCAAM,GAAG,CAAC,QAAQ,CAAU,CAAC;AAC7B,qCAAM,GAAG;IACrB,MAAM,EAAE,CAAA,4BAAwC,CAAA;IAChD,oBAAoB,EAAE,8BAAa;CACpC,CAAC"}
|
|
@@ -35,13 +35,14 @@ export interface DeclaredGithubRepo {
|
|
|
35
35
|
description: string | null;
|
|
36
36
|
/**
|
|
37
37
|
* .what = homepage URL
|
|
38
|
-
* .note =
|
|
38
|
+
* .note = optional; defaults to null
|
|
39
39
|
*/
|
|
40
|
-
homepage
|
|
40
|
+
homepage?: string | null;
|
|
41
41
|
/**
|
|
42
42
|
* .what = whether the repo is private
|
|
43
|
+
* .note = optional; derived from visibility !== 'public' if not provided
|
|
43
44
|
*/
|
|
44
|
-
private
|
|
45
|
+
private?: boolean;
|
|
45
46
|
/**
|
|
46
47
|
* .what = visibility setting
|
|
47
48
|
* .note = public, private, or internal (for enterprise)
|
|
@@ -49,8 +50,9 @@ export interface DeclaredGithubRepo {
|
|
|
49
50
|
visibility: 'public' | 'private' | 'internal';
|
|
50
51
|
/**
|
|
51
52
|
* .what = whether the repo is archived
|
|
53
|
+
* .note = optional; defaults to false
|
|
52
54
|
*/
|
|
53
|
-
archived
|
|
55
|
+
archived?: boolean;
|
|
54
56
|
}
|
|
55
57
|
export declare class DeclaredGithubRepo extends DomainEntity<DeclaredGithubRepo> implements DeclaredGithubRepo {
|
|
56
58
|
static unique: readonly ["owner", "name"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclaredGithubRepo.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubRepo.ts"],"names":[],"mappings":";;;AACA,mDAA8C;
|
|
1
|
+
{"version":3,"file":"DeclaredGithubRepo.js","sourceRoot":"","sources":["../../src/domain.objects/DeclaredGithubRepo.ts"],"names":[],"mappings":";;;AACA,mDAA8C;AAkE9C,MAAa,kBACX,SAAQ,6BAAgC;;AAD1C,gDAKC;AADe,yBAAM,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC"}
|
|
@@ -25,14 +25,15 @@ const getOrThrow = (obj, key) => {
|
|
|
25
25
|
* .why = transforms external API shape to our domain model with type safety and validation
|
|
26
26
|
*/
|
|
27
27
|
const castToDeclaredGithubRepo = (input) => {
|
|
28
|
+
const visibility = input.visibility ?? 'public';
|
|
28
29
|
return DeclaredGithubRepo_1.DeclaredGithubRepo.as({
|
|
29
30
|
id: getOrThrow(input, 'id'),
|
|
30
31
|
owner: getOrThrow(getOrThrow(input, 'owner'), 'login'),
|
|
31
32
|
name: getOrThrow(input, 'name'),
|
|
32
33
|
description: input.description ?? null,
|
|
33
34
|
homepage: input.homepage ?? null,
|
|
34
|
-
private:
|
|
35
|
-
visibility
|
|
35
|
+
private: input.private ?? visibility !== 'public',
|
|
36
|
+
visibility,
|
|
36
37
|
archived: input.archived ?? false,
|
|
37
38
|
createdAt: input.created_at ? (0, uni_time_1.asUniDateTime)(input.created_at) : undefined,
|
|
38
39
|
updatedAt: input.updated_at ? (0, uni_time_1.asUniDateTime)(input.updated_at) : undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"castToDeclaredGithubRepo.js","sourceRoot":"","sources":["../../../src/domain.operations/repo/castToDeclaredGithubRepo.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AAEnD,mDAAyD;AACzD,uCAAqE;AAErE,gFAA6E;AAE7E;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,GAAM,EACN,GAAM,EACc,EAAE;IACtB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAEvB,kCAAkC;IAClC,IAAI,IAAA,yBAAc,EAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,uBAAuB;IACvB,wCAAuB,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE;QACpE,KAAK,EAAE,GAAG;QACV,GAAG;KACJ,CAAC,CAAC;AACL,CAAC,CAAC;AAOF;;;GAGG;AACI,MAAM,wBAAwB,GAAG,CACtC,KAAyB,EACQ,EAAE;IACnC,OAAO,uCAAkB,CAAC,EAAE,CAAC;QAC3B,EAAE,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC;QAC3B,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QACtD,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC;QAC/B,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,IAAI;QACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;QAChC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"castToDeclaredGithubRepo.js","sourceRoot":"","sources":["../../../src/domain.operations/repo/castToDeclaredGithubRepo.ts"],"names":[],"mappings":";;;AAAA,iDAAmD;AAEnD,mDAAyD;AACzD,uCAAqE;AAErE,gFAA6E;AAE7E;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,GAAM,EACN,GAAM,EACc,EAAE;IACtB,MAAM,KAAK,GAAG,GAAG,CAA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13
13
|
exports.setRepo = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
14
14
|
const desired = input.finsert ?? input.upsert;
|
|
15
|
+
// apply defaults for optional fields
|
|
16
|
+
const desiredHomepage = desired.homepage ?? null;
|
|
17
|
+
const desiredPrivate = desired.private ?? desired.visibility !== 'public';
|
|
18
|
+
const desiredArchived = desired.archived ?? false;
|
|
15
19
|
// get cached GitHub client
|
|
16
20
|
const github = (0, getGithubClient_1.getGithubClient)({}, context);
|
|
17
21
|
// check whether it already exists
|
|
@@ -33,10 +37,10 @@ exports.setRepo = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
|
33
37
|
owner: desired.owner,
|
|
34
38
|
repo: desired.name,
|
|
35
39
|
description: desired.description ?? undefined,
|
|
36
|
-
homepage:
|
|
37
|
-
private:
|
|
40
|
+
homepage: desiredHomepage ?? undefined,
|
|
41
|
+
private: desiredPrivate,
|
|
38
42
|
visibility: desired.visibility === 'internal' ? undefined : desired.visibility,
|
|
39
|
-
archived:
|
|
43
|
+
archived: desiredArchived,
|
|
40
44
|
});
|
|
41
45
|
return (0, castToDeclaredGithubRepo_1.castToDeclaredGithubRepo)(updated.data);
|
|
42
46
|
}
|
|
@@ -55,8 +59,8 @@ exports.setRepo = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
|
55
59
|
org: desired.owner,
|
|
56
60
|
name: desired.name,
|
|
57
61
|
description: desired.description ?? undefined,
|
|
58
|
-
homepage:
|
|
59
|
-
private:
|
|
62
|
+
homepage: desiredHomepage ?? undefined,
|
|
63
|
+
private: desiredPrivate,
|
|
60
64
|
visibility: desired.visibility === 'internal' ? undefined : desired.visibility,
|
|
61
65
|
});
|
|
62
66
|
return (0, castToDeclaredGithubRepo_1.castToDeclaredGithubRepo)(created.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setRepo.js","sourceRoot":"","sources":["../../../src/domain.operations/repo/setRepo.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3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AI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YAC3C,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE;gBACpD,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC;QACH,kEAAkE;QAClE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YAC7C,GAAG,EAAE,OAAO,CAAC,KAAK;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,SAAS;YAC7C,QAAQ,EAAE,eAAe,IAAI,SAAS;YACtC,OAAO,EAAE,cAAc;YACvB,UAAU,EACR,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU;SACrE,CAAC,CAAC;QAEH,OAAO,IAAA,mDAAwB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declastruct-github",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "declarative control of GitHub constructs via declastruct - manage repos, branches, and protection rules",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.1",
|
|
6
6
|
"repository": "ehmpathy/declastruct-github",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/declastruct-github",
|
|
8
8
|
"keywords": [
|
|
@@ -55,8 +55,7 @@
|
|
|
55
55
|
"@ehmpathy/uni-time": "1.7.4",
|
|
56
56
|
"@octokit/rest": "^21.0.0",
|
|
57
57
|
"as-procedure": "1.1.1",
|
|
58
|
-
"
|
|
59
|
-
"domain-objects": "0.29.1",
|
|
58
|
+
"domain-objects": "0.29.2",
|
|
60
59
|
"helpful-errors": "1.5.3",
|
|
61
60
|
"simple-in-memory-cache": "0.4.0",
|
|
62
61
|
"type-fns": "1.19.0",
|
|
@@ -79,6 +78,7 @@
|
|
|
79
78
|
"cz-conventional-changelog": "3.3.0",
|
|
80
79
|
"declapract": "0.12.0",
|
|
81
80
|
"declapract-typescript-ehmpathy": "0.39.5",
|
|
81
|
+
"declastruct": "1.1.7",
|
|
82
82
|
"depcheck": "1.4.3",
|
|
83
83
|
"eslint": "8.56.0",
|
|
84
84
|
"eslint-config-airbnb-typescript": "18.0.0",
|
package/readme.md
CHANGED
|
@@ -23,39 +23,59 @@ npm install -s declastruct-github
|
|
|
23
23
|
declare the resources you wish to have - and what state you wish them to be in
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
+
import { UnexpectedCodePathError } from 'helpful-errors';
|
|
26
27
|
import { getDeclastructGithubProvider, DeclaredGithubRepo, DeclaredGithubRepoConfig } from 'declastruct-github';
|
|
27
28
|
|
|
28
|
-
export const getProviders = async () => [
|
|
29
|
-
getDeclastructGithubProvider(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
export const getProviders = async (): Promise<DeclastructProvider[]> => [
|
|
30
|
+
getDeclastructGithubProvider(
|
|
31
|
+
{
|
|
32
|
+
credentials: {
|
|
33
|
+
token:
|
|
34
|
+
process.env.GITHUB_TOKEN ??
|
|
35
|
+
UnexpectedCodePathError.throw('github token not supplied'),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
log: console,
|
|
40
|
+
},
|
|
41
|
+
),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export const getResources = async (): Promise<DomainEntity<any>[]> => {
|
|
45
|
+
// declare the repo
|
|
37
46
|
const repo = DeclaredGithubRepo.as({
|
|
38
|
-
|
|
47
|
+
owner: 'ehmpathy',
|
|
48
|
+
name: 'declastruct-github',
|
|
49
|
+
description: 'declarative control of Github resource constructs, via declastruct',
|
|
50
|
+
visibility: 'public',
|
|
39
51
|
});
|
|
52
|
+
|
|
53
|
+
// declare config for the repo
|
|
40
54
|
const repoConfig = DeclaredGithubRepoConfig.as({
|
|
41
|
-
repo
|
|
55
|
+
repo,
|
|
56
|
+
|
|
57
|
+
// explicitly set the main branch
|
|
58
|
+
defaultBranch: 'main',
|
|
59
|
+
|
|
60
|
+
// we only use issues; the rest is noise today
|
|
61
|
+
hasIssues: true,
|
|
62
|
+
hasProjects: false,
|
|
63
|
+
hasWiki: false,
|
|
64
|
+
hasDownloads: false,
|
|
65
|
+
isTemplate: false,
|
|
42
66
|
|
|
43
|
-
//
|
|
67
|
+
// only squash merges are allowed
|
|
44
68
|
allowSquashMerge: true,
|
|
45
|
-
allowMergeCommit: false,
|
|
69
|
+
allowMergeCommit: false, // but especially not merge merges. never merge merges
|
|
46
70
|
allowRebaseMerge: false,
|
|
47
71
|
|
|
48
|
-
//
|
|
72
|
+
// always cleanup after yourself
|
|
73
|
+
deleteBranchOnMerge: true,
|
|
49
74
|
});
|
|
50
75
|
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
repo,
|
|
55
|
-
repoConfig,
|
|
56
|
-
// ... all the resources you wish for will go here
|
|
57
|
-
],
|
|
58
|
-
}
|
|
76
|
+
// and return the full set
|
|
77
|
+
return [repo, repoConfig];
|
|
78
|
+
};
|
|
59
79
|
```
|
|
60
80
|
|
|
61
81
|
### plan 🔮
|
|
@@ -82,22 +102,47 @@ npx declastruct apply --plan provision/github/.temp/plan.json
|
|
|
82
102
|
## example.2
|
|
83
103
|
|
|
84
104
|
```ts
|
|
85
|
-
export const
|
|
105
|
+
export const getProviders = async (): Promise<DeclastructProvider[]> => [
|
|
106
|
+
getDeclastructGithubProvider(
|
|
107
|
+
{
|
|
108
|
+
credentials: {
|
|
109
|
+
token:
|
|
110
|
+
process.env.GITHUB_TOKEN ??
|
|
111
|
+
UnexpectedCodePathError.throw('github token not supplied'),
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
log: {
|
|
116
|
+
info: () => {},
|
|
117
|
+
debug: () => {},
|
|
118
|
+
warn: console.warn,
|
|
119
|
+
error: console.error,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
),
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
export const getResources = async (): Promise<DomainEntity<any>[]> => {
|
|
86
126
|
// declare the repo
|
|
87
127
|
const repo = DeclaredGithubRepo.as({
|
|
88
|
-
|
|
128
|
+
owner: 'ehmpathy',
|
|
129
|
+
name: 'declastruct-github',
|
|
130
|
+
description: 'declarative control of Github resource constructs, via declastruct',
|
|
131
|
+
visibility: 'public',
|
|
89
132
|
});
|
|
90
133
|
|
|
91
|
-
//
|
|
92
|
-
const branchMain =
|
|
93
|
-
repo: refByUnique(repo),
|
|
134
|
+
// ref the main branch
|
|
135
|
+
const branchMain = RefByUnique.as<typeof DeclaredGithubBranch>({
|
|
94
136
|
name: 'main',
|
|
95
|
-
|
|
137
|
+
repo,
|
|
138
|
+
});
|
|
96
139
|
|
|
97
140
|
// declare config for the repo
|
|
98
141
|
const repoConfig = DeclaredGithubRepoConfig.as({
|
|
142
|
+
repo,
|
|
143
|
+
|
|
99
144
|
// explicitly set the main branch
|
|
100
|
-
defaultBranch:
|
|
145
|
+
defaultBranch: branchMain.name,
|
|
101
146
|
|
|
102
147
|
// we only use issues; the rest is noise today
|
|
103
148
|
hasIssues: true,
|
|
@@ -117,37 +162,32 @@ export const getResources = async () => {
|
|
|
117
162
|
|
|
118
163
|
// declare protection for that branch, too
|
|
119
164
|
const branchMainProtection = DeclaredGithubBranchProtection.as({
|
|
120
|
-
branch:
|
|
165
|
+
branch: branchMain,
|
|
121
166
|
|
|
122
167
|
enforceAdmins: true, // yes, even admins need to follow this (note: they can still take the time to go and change the settings temporarily for the exceptions)
|
|
123
168
|
allowsDeletions: false, // dont allow the `main` branch to be deleted
|
|
124
169
|
allowsForcePushes: false, // dont allow `main` branch to be force pushed to
|
|
125
170
|
requireLinearHistory: false, // # no ugly merge commits, woo! 🎉
|
|
126
171
|
|
|
127
|
-
|
|
172
|
+
requiredStatusChecks: {
|
|
128
173
|
strict: true, // branch must be up to date. otherwise, we dont know if it will really pass once it is merged
|
|
129
|
-
contexts
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return [
|
|
145
|
-
|
|
146
|
-
branchMain,
|
|
147
|
-
repoConfig,
|
|
148
|
-
branchMainProtection,
|
|
149
|
-
]
|
|
150
|
-
}
|
|
174
|
+
contexts: [
|
|
175
|
+
'suite / install / npm',
|
|
176
|
+
'suite / test-commits',
|
|
177
|
+
'suite / test-types',
|
|
178
|
+
'suite / test-format',
|
|
179
|
+
'suite / test-lint',
|
|
180
|
+
'suite / test-unit',
|
|
181
|
+
'suite / test-integration',
|
|
182
|
+
'suite / test-acceptance-locally',
|
|
183
|
+
'pullreq-title', // "review / pullreq-title",
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// and return the full set
|
|
189
|
+
return [repo, branchMain, repoConfig, branchMainProtection];
|
|
190
|
+
};
|
|
151
191
|
```
|
|
152
192
|
|
|
153
193
|
# use imperatively
|