declastruct-github 1.0.0
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/LICENSE +21 -0
- package/dist/.test/assets/getSampleGithubContext.d.ts +6 -0
- package/dist/.test/assets/getSampleGithubContext.js +18 -0
- package/dist/.test/assets/getSampleGithubContext.js.map +1 -0
- package/dist/.test/assets/getSampleRepo.d.ts +9 -0
- package/dist/.test/assets/getSampleRepo.js +19 -0
- package/dist/.test/assets/getSampleRepo.js.map +1 -0
- package/dist/access/daos/DeclaredGithubBranchDao.d.ts +10 -0
- package/dist/access/daos/DeclaredGithubBranchDao.js +35 -0
- package/dist/access/daos/DeclaredGithubBranchDao.js.map +1 -0
- package/dist/access/daos/DeclaredGithubBranchProtectionDao.d.ts +9 -0
- package/dist/access/daos/DeclaredGithubBranchProtectionDao.js +34 -0
- package/dist/access/daos/DeclaredGithubBranchProtectionDao.js.map +1 -0
- package/dist/access/daos/DeclaredGithubRepoConfigDao.d.ts +9 -0
- package/dist/access/daos/DeclaredGithubRepoConfigDao.js +34 -0
- package/dist/access/daos/DeclaredGithubRepoConfigDao.js.map +1 -0
- package/dist/access/daos/DeclaredGithubRepoDao.d.ts +9 -0
- package/dist/access/daos/DeclaredGithubRepoDao.js +34 -0
- package/dist/access/daos/DeclaredGithubRepoDao.js.map +1 -0
- package/dist/access/sdks/getGithubClient.d.ts +8 -0
- package/dist/access/sdks/getGithubClient.js +22 -0
- package/dist/access/sdks/getGithubClient.js.map +1 -0
- package/dist/contract/sdks/declastruct.acceptance.test.d.ts +1 -0
- package/dist/contract/sdks/declastruct.acceptance.test.js +104 -0
- package/dist/contract/sdks/declastruct.acceptance.test.js.map +1 -0
- package/dist/contract/sdks/index.d.ts +10 -0
- package/dist/contract/sdks/index.js +20 -0
- package/dist/contract/sdks/index.js.map +1 -0
- package/dist/domain.objects/ContextGithubApi.d.ts +9 -0
- package/dist/domain.objects/ContextGithubApi.js +3 -0
- package/dist/domain.objects/ContextGithubApi.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubBranch.d.ts +39 -0
- package/dist/domain.objects/DeclaredGithubBranch.js +12 -0
- package/dist/domain.objects/DeclaredGithubBranch.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.d.ts +108 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.js +12 -0
- package/dist/domain.objects/DeclaredGithubBranchProtection.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubRepo.d.ts +57 -0
- package/dist/domain.objects/DeclaredGithubRepo.js +9 -0
- package/dist/domain.objects/DeclaredGithubRepo.js.map +1 -0
- package/dist/domain.objects/DeclaredGithubRepoConfig.d.ts +100 -0
- package/dist/domain.objects/DeclaredGithubRepoConfig.js +12 -0
- package/dist/domain.objects/DeclaredGithubRepoConfig.js.map +1 -0
- package/dist/domain.objects/DeclastructGithubProvider.d.ts +17 -0
- package/dist/domain.objects/DeclastructGithubProvider.js +3 -0
- package/dist/domain.objects/DeclastructGithubProvider.js.map +1 -0
- package/dist/domain.operations/branch/castToDeclaredGithubBranch.d.ts +15 -0
- package/dist/domain.operations/branch/castToDeclaredGithubBranch.js +39 -0
- package/dist/domain.operations/branch/castToDeclaredGithubBranch.js.map +1 -0
- package/dist/domain.operations/branch/getBranch.d.ts +14 -0
- package/dist/domain.operations/branch/getBranch.integration.test.d.ts +1 -0
- package/dist/domain.operations/branch/getBranch.integration.test.js +59 -0
- package/dist/domain.operations/branch/getBranch.integration.test.js.map +1 -0
- package/dist/domain.operations/branch/getBranch.js +50 -0
- package/dist/domain.operations/branch/getBranch.js.map +1 -0
- package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.d.ts +11 -0
- package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.js +37 -0
- package/dist/domain.operations/branch/getBranchCommitShaByRepoDefault.js.map +1 -0
- package/dist/domain.operations/branch/getBranches.d.ts +23 -0
- package/dist/domain.operations/branch/getBranches.integration.test.d.ts +1 -0
- package/dist/domain.operations/branch/getBranches.integration.test.js +40 -0
- package/dist/domain.operations/branch/getBranches.integration.test.js.map +1 -0
- package/dist/domain.operations/branch/getBranches.js +33 -0
- package/dist/domain.operations/branch/getBranches.js.map +1 -0
- package/dist/domain.operations/branch/setBranch.d.ts +12 -0
- package/dist/domain.operations/branch/setBranch.integration.test.d.ts +1 -0
- package/dist/domain.operations/branch/setBranch.integration.test.js +65 -0
- package/dist/domain.operations/branch/setBranch.integration.test.js.map +1 -0
- package/dist/domain.operations/branch/setBranch.js +100 -0
- package/dist/domain.operations/branch/setBranch.js.map +1 -0
- package/dist/domain.operations/branch/setBranch.test.d.ts +1 -0
- package/dist/domain.operations/branch/setBranch.test.js +151 -0
- package/dist/domain.operations/branch/setBranch.test.js.map +1 -0
- package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.d.ts +14 -0
- package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.js +66 -0
- package/dist/domain.operations/branchProtection/castToDeclaredGithubBranchProtection.js.map +1 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.d.ts +14 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.d.ts +1 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.js +63 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.integration.test.js.map +1 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.js +53 -0
- package/dist/domain.operations/branchProtection/getBranchProtection.js.map +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.d.ts +12 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.d.ts +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.js +96 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.integration.test.js.map +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.js +90 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.js.map +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.test.d.ts +1 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.test.js +173 -0
- package/dist/domain.operations/branchProtection/setBranchProtection.test.js.map +1 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.d.ts +11 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.d.ts +1 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.js +212 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.integration.test.js.map +1 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.js +44 -0
- package/dist/domain.operations/provider/getDeclastructGithubProvider.js.map +1 -0
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.d.ts +10 -0
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.js +42 -0
- package/dist/domain.operations/repo/castToDeclaredGithubRepo.js.map +1 -0
- package/dist/domain.operations/repo/getRepo.d.ts +14 -0
- package/dist/domain.operations/repo/getRepo.integration.test.d.ts +1 -0
- package/dist/domain.operations/repo/getRepo.integration.test.js +45 -0
- package/dist/domain.operations/repo/getRepo.integration.test.js.map +1 -0
- package/dist/domain.operations/repo/getRepo.js +38 -0
- package/dist/domain.operations/repo/getRepo.js.map +1 -0
- package/dist/domain.operations/repo/getRepos.d.ts +21 -0
- package/dist/domain.operations/repo/getRepos.integration.test.d.ts +1 -0
- package/dist/domain.operations/repo/getRepos.integration.test.js +28 -0
- package/dist/domain.operations/repo/getRepos.integration.test.js.map +1 -0
- package/dist/domain.operations/repo/getRepos.js +41 -0
- package/dist/domain.operations/repo/getRepos.js.map +1 -0
- package/dist/domain.operations/repo/setRepo.d.ts +12 -0
- package/dist/domain.operations/repo/setRepo.integration.test.d.ts +1 -0
- package/dist/domain.operations/repo/setRepo.integration.test.js +29 -0
- package/dist/domain.operations/repo/setRepo.integration.test.js.map +1 -0
- package/dist/domain.operations/repo/setRepo.js +70 -0
- package/dist/domain.operations/repo/setRepo.js.map +1 -0
- package/dist/domain.operations/repo/setRepo.test.d.ts +1 -0
- package/dist/domain.operations/repo/setRepo.test.js +150 -0
- package/dist/domain.operations/repo/setRepo.test.js.map +1 -0
- package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.d.ts +15 -0
- package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.js +36 -0
- package/dist/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.js.map +1 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.d.ts +14 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.d.ts +1 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.js +55 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.integration.test.js.map +1 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.js +47 -0
- package/dist/domain.operations/repoConfig/getRepoConfig.js.map +1 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.d.ts +12 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.d.ts +1 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.js +87 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.integration.test.js.map +1 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.js +65 -0
- package/dist/domain.operations/repoConfig/setRepoConfig.js.map +1 -0
- package/package.json +104 -0
- package/readme.md +181 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setRepo = void 0;
|
|
4
|
+
const as_procedure_1 = require("as-procedure");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const getGithubClient_1 = require("../../access/sdks/getGithubClient");
|
|
7
|
+
const castToDeclaredGithubRepo_1 = require("./castToDeclaredGithubRepo");
|
|
8
|
+
const getRepo_1 = require("./getRepo");
|
|
9
|
+
/**
|
|
10
|
+
* .what = sets a GitHub repository: upsert or finsert
|
|
11
|
+
* .why = enables declarative creation and updates of repos following declastruct patterns
|
|
12
|
+
*/
|
|
13
|
+
exports.setRepo = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
14
|
+
const desired = input.finsert ?? input.upsert;
|
|
15
|
+
// get cached GitHub client
|
|
16
|
+
const github = (0, getGithubClient_1.getGithubClient)({}, context);
|
|
17
|
+
// check whether it already exists
|
|
18
|
+
const before = await (0, getRepo_1.getRepo)({
|
|
19
|
+
by: {
|
|
20
|
+
unique: {
|
|
21
|
+
owner: desired.owner,
|
|
22
|
+
name: desired.name,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}, context);
|
|
26
|
+
// if it's a finsert and had a before, then return that
|
|
27
|
+
if (before && input.finsert)
|
|
28
|
+
return before;
|
|
29
|
+
// if its an upsert and had a before, then this requires an update operation
|
|
30
|
+
if (before && input.upsert) {
|
|
31
|
+
try {
|
|
32
|
+
const updated = await github.repos.update({
|
|
33
|
+
owner: desired.owner,
|
|
34
|
+
repo: desired.name,
|
|
35
|
+
description: desired.description ?? undefined,
|
|
36
|
+
homepage: desired.homepage ?? undefined,
|
|
37
|
+
private: desired.private,
|
|
38
|
+
visibility: desired.visibility === 'internal' ? undefined : desired.visibility,
|
|
39
|
+
archived: desired.archived,
|
|
40
|
+
});
|
|
41
|
+
return (0, castToDeclaredGithubRepo_1.castToDeclaredGithubRepo)(updated.data);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (!(error instanceof Error))
|
|
45
|
+
throw error;
|
|
46
|
+
throw new helpful_errors_1.HelpfulError('github.setRepo.update error', {
|
|
47
|
+
cause: error,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// otherwise, create it
|
|
52
|
+
try {
|
|
53
|
+
// use createInOrg which works for both orgs and personal accounts
|
|
54
|
+
const created = await github.repos.createInOrg({
|
|
55
|
+
org: desired.owner,
|
|
56
|
+
name: desired.name,
|
|
57
|
+
description: desired.description ?? undefined,
|
|
58
|
+
homepage: desired.homepage ?? undefined,
|
|
59
|
+
private: desired.private,
|
|
60
|
+
visibility: desired.visibility === 'internal' ? undefined : desired.visibility,
|
|
61
|
+
});
|
|
62
|
+
return (0, castToDeclaredGithubRepo_1.castToDeclaredGithubRepo)(created.data);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (!(error instanceof Error))
|
|
66
|
+
throw error;
|
|
67
|
+
throw new helpful_errors_1.HelpfulError('github.setRepo.create error', { cause: error });
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=setRepo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setRepo.js","sourceRoot":"","sources":["../../../src/domain.operations/repo/setRepo.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3C,mDAA8C;AAI9C,uEAAoE;AAGpE,yEAAsE;AACtE,uCAAoC;AAEpC;;;GAGG;AACU,QAAA,OAAO,GAAG,IAAA,0BAAW,EAChC,KAAK,EACH,KAGE,EACF,OAA6C,EACH,EAAE;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC;IAE9C,2BAA2B;IAC3B,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,kCAAkC;IAClC,MAAM,MAAM,GAAG,MAAM,IAAA,iBAAO,EAC1B;QACE,EAAE,EAAE;YACF,MAAM,EAAE;gBACN,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB;SACF;KACF,EACD,OAAO,CACR,CAAC;IAEF,uDAAuD;IACvD,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAE3C,4EAA4E;IAC5E,IAAI,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;gBACxC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB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M,KAAK,CAAC;QAC3C,MAAM,IAAI,6BAAY,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const castModule = __importStar(require("./castToDeclaredGithubRepo"));
|
|
27
|
+
const getRepoModule = __importStar(require("./getRepo"));
|
|
28
|
+
// create mock functions first
|
|
29
|
+
const mockUpdate = jest.fn();
|
|
30
|
+
const mockCreateForAuthenticatedUser = jest.fn();
|
|
31
|
+
const mockCreateInOrg = jest.fn();
|
|
32
|
+
jest.mock('../../access/sdks/getGithubClient', () => ({
|
|
33
|
+
getGithubClient: jest.fn(() => ({
|
|
34
|
+
repos: {
|
|
35
|
+
update: mockUpdate,
|
|
36
|
+
createForAuthenticatedUser: mockCreateForAuthenticatedUser,
|
|
37
|
+
createInOrg: mockCreateInOrg,
|
|
38
|
+
},
|
|
39
|
+
})),
|
|
40
|
+
}));
|
|
41
|
+
jest.mock('./castToDeclaredGithubRepo');
|
|
42
|
+
jest.mock('./getRepo');
|
|
43
|
+
const { setRepo } = require('./setRepo');
|
|
44
|
+
const context = {
|
|
45
|
+
github: { token: 'test-token' },
|
|
46
|
+
log: console,
|
|
47
|
+
};
|
|
48
|
+
const repoSample = {
|
|
49
|
+
owner: 'test-owner',
|
|
50
|
+
name: 'test-repo',
|
|
51
|
+
description: 'Test repository',
|
|
52
|
+
homepage: null,
|
|
53
|
+
private: false,
|
|
54
|
+
visibility: 'public',
|
|
55
|
+
archived: false,
|
|
56
|
+
};
|
|
57
|
+
describe('setRepo', () => {
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
jest.clearAllMocks();
|
|
60
|
+
});
|
|
61
|
+
it('returns early for finsert if repo already exists (before)', async () => {
|
|
62
|
+
const before = { ...repoSample, id: 123 };
|
|
63
|
+
getRepoModule.getRepo.mockResolvedValue(before);
|
|
64
|
+
const result = await setRepo({ finsert: repoSample }, context);
|
|
65
|
+
expect(result).toBe(before);
|
|
66
|
+
expect(getRepoModule.getRepo).toHaveBeenCalled();
|
|
67
|
+
expect(mockUpdate).not.toHaveBeenCalled();
|
|
68
|
+
expect(mockCreateForAuthenticatedUser).not.toHaveBeenCalled();
|
|
69
|
+
expect(mockCreateInOrg).not.toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
it('updates repo if upsert and repo exists (before)', async () => {
|
|
72
|
+
const before = { ...repoSample, id: 123 };
|
|
73
|
+
getRepoModule.getRepo.mockResolvedValue(before);
|
|
74
|
+
const updatedRepoResponse = {
|
|
75
|
+
id: 123,
|
|
76
|
+
owner: { login: 'test-owner' },
|
|
77
|
+
name: 'test-repo',
|
|
78
|
+
description: 'Updated description',
|
|
79
|
+
private: false,
|
|
80
|
+
};
|
|
81
|
+
mockUpdate.mockResolvedValue({ data: updatedRepoResponse });
|
|
82
|
+
castModule.castToDeclaredGithubRepo.mockReturnValue({
|
|
83
|
+
...repoSample,
|
|
84
|
+
id: 123,
|
|
85
|
+
description: 'Updated description',
|
|
86
|
+
});
|
|
87
|
+
const result = await setRepo({ upsert: repoSample }, context);
|
|
88
|
+
expect(getRepoModule.getRepo).toHaveBeenCalled();
|
|
89
|
+
expect(mockUpdate).toHaveBeenCalledWith({
|
|
90
|
+
owner: 'test-owner',
|
|
91
|
+
repo: 'test-repo',
|
|
92
|
+
description: 'Test repository',
|
|
93
|
+
homepage: undefined,
|
|
94
|
+
private: false,
|
|
95
|
+
visibility: 'public',
|
|
96
|
+
archived: false,
|
|
97
|
+
});
|
|
98
|
+
expect(result.name).toEqual('test-repo');
|
|
99
|
+
});
|
|
100
|
+
it('creates repo if it does not exist (before = null)', async () => {
|
|
101
|
+
getRepoModule.getRepo.mockResolvedValue(null);
|
|
102
|
+
const createdRepoResponse = {
|
|
103
|
+
id: 456,
|
|
104
|
+
owner: { login: 'test-owner' },
|
|
105
|
+
name: 'test-repo',
|
|
106
|
+
description: 'Test repository',
|
|
107
|
+
private: false,
|
|
108
|
+
};
|
|
109
|
+
mockCreateInOrg.mockResolvedValue({ data: createdRepoResponse });
|
|
110
|
+
castModule.castToDeclaredGithubRepo.mockReturnValue({
|
|
111
|
+
...repoSample,
|
|
112
|
+
id: 456,
|
|
113
|
+
});
|
|
114
|
+
const result = await setRepo({ finsert: repoSample }, context);
|
|
115
|
+
expect(getRepoModule.getRepo).toHaveBeenCalled();
|
|
116
|
+
expect(mockCreateInOrg).toHaveBeenCalledWith({
|
|
117
|
+
org: 'test-owner',
|
|
118
|
+
name: 'test-repo',
|
|
119
|
+
description: 'Test repository',
|
|
120
|
+
homepage: undefined,
|
|
121
|
+
private: false,
|
|
122
|
+
visibility: 'public',
|
|
123
|
+
});
|
|
124
|
+
expect(result.id).toEqual(456);
|
|
125
|
+
});
|
|
126
|
+
it('filters out internal visibility when creating repo', async () => {
|
|
127
|
+
getRepoModule.getRepo.mockResolvedValue(null);
|
|
128
|
+
const repoWithInternalVisibility = {
|
|
129
|
+
...repoSample,
|
|
130
|
+
visibility: 'internal',
|
|
131
|
+
};
|
|
132
|
+
mockCreateInOrg.mockResolvedValue({
|
|
133
|
+
data: { id: 789, owner: { login: 'test-owner' }, name: 'test-repo' },
|
|
134
|
+
});
|
|
135
|
+
castModule.castToDeclaredGithubRepo.mockReturnValue({
|
|
136
|
+
...repoSample,
|
|
137
|
+
id: 789,
|
|
138
|
+
});
|
|
139
|
+
await setRepo({ finsert: repoWithInternalVisibility }, context);
|
|
140
|
+
expect(mockCreateInOrg).toHaveBeenCalledWith({
|
|
141
|
+
org: 'test-owner',
|
|
142
|
+
name: 'test-repo',
|
|
143
|
+
description: 'Test repository',
|
|
144
|
+
homepage: undefined,
|
|
145
|
+
private: false,
|
|
146
|
+
visibility: undefined, // internal filtered out
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=setRepo.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setRepo.test.js","sourceRoot":"","sources":["../../../src/domain.operations/repo/setRepo.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,uEAAyD;AACzD,yDAA2C;AAE3C,8BAA8B;AAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAC7B,MAAM,8BAA8B,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACjD,MAAM,eAAe,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AAElC,IAAI,CAAC,IAAI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AAC,IAAI,CAAC,CAAC;QAE7D,MAAM,0BAA0B,GAAG;YACjC,GAAG,UAAU;YACb,UAAU,EAAE,UAAmB;SAChC,CAAC;QAEF,eAAe,CAAC,iBAAiB,CAAC;YAChC,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;SACrE,CAAC,CAAC;QACF,UAAU,CAAC,wBAAsC,CAAC,eAAe,CAAC;YACjE,GAAG,UAAU;YACb,EAAE,EAAE,GAAG;SACR,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,0BAA0B,EAAE,EAAE,OAAO,CAAC,CAAC;QAEhE,MAAM,CAAC,eAAe,CAAC,CAAC,oBAAoB,CAAC;YAC3C,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,WAAW;YACjB,WAAW,EAAE,iBAAiB;YAC9B,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,SAAS,EAAE,wBAAwB;SAChD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Endpoints } from '@octokit/types';
|
|
2
|
+
import { RefByUnique } from 'domain-objects';
|
|
3
|
+
import { HasMetadata } from 'type-fns';
|
|
4
|
+
import { DeclaredGithubRepo } from '../../domain.objects/DeclaredGithubRepo';
|
|
5
|
+
import { DeclaredGithubRepoConfig } from '../../domain.objects/DeclaredGithubRepoConfig';
|
|
6
|
+
type GithubRepoResponse = Endpoints['GET /repos/{owner}/{repo}']['response']['data'];
|
|
7
|
+
/**
|
|
8
|
+
* .what = casts GitHub API repository response to DeclaredGithubRepoConfig
|
|
9
|
+
* .why = transforms external API shape to our repo config domain model with type safety and validation
|
|
10
|
+
*/
|
|
11
|
+
export declare const castToDeclaredGithubRepoConfig: (input: {
|
|
12
|
+
response: GithubRepoResponse;
|
|
13
|
+
repo: RefByUnique<typeof DeclaredGithubRepo>;
|
|
14
|
+
}) => HasMetadata<DeclaredGithubRepoConfig>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.castToDeclaredGithubRepoConfig = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
const DeclaredGithubRepo_1 = require("../../domain.objects/DeclaredGithubRepo");
|
|
6
|
+
const DeclaredGithubRepoConfig_1 = require("../../domain.objects/DeclaredGithubRepoConfig");
|
|
7
|
+
/**
|
|
8
|
+
* .what = casts GitHub API repository response to DeclaredGithubRepoConfig
|
|
9
|
+
* .why = transforms external API shape to our repo config domain model with type safety and validation
|
|
10
|
+
*/
|
|
11
|
+
const castToDeclaredGithubRepoConfig = (input) => {
|
|
12
|
+
return DeclaredGithubRepoConfig_1.DeclaredGithubRepoConfig.as({
|
|
13
|
+
repo: input.repo instanceof DeclaredGithubRepo_1.DeclaredGithubRepo
|
|
14
|
+
? (0, domain_objects_1.refByUnique)(input.repo)
|
|
15
|
+
: input.repo,
|
|
16
|
+
hasIssues: input.response.has_issues,
|
|
17
|
+
hasProjects: input.response.has_projects,
|
|
18
|
+
hasWiki: input.response.has_wiki,
|
|
19
|
+
hasDownloads: input.response.has_downloads,
|
|
20
|
+
isTemplate: input.response.is_template,
|
|
21
|
+
defaultBranch: input.response.default_branch,
|
|
22
|
+
allowSquashMerge: input.response.allow_squash_merge,
|
|
23
|
+
allowMergeCommit: input.response.allow_merge_commit,
|
|
24
|
+
allowRebaseMerge: input.response.allow_rebase_merge,
|
|
25
|
+
allowAutoMerge: input.response.allow_auto_merge,
|
|
26
|
+
deleteBranchOnMerge: input.response.delete_branch_on_merge,
|
|
27
|
+
allowUpdateBranch: input.response.allow_update_branch,
|
|
28
|
+
squashMergeCommitTitle: input.response.squash_merge_commit_title,
|
|
29
|
+
squashMergeCommitMessage: input.response.squash_merge_commit_message,
|
|
30
|
+
mergeCommitTitle: input.response.merge_commit_title,
|
|
31
|
+
mergeCommitMessage: input.response.merge_commit_message,
|
|
32
|
+
webCommitSignoffRequired: input.response.web_commit_signoff_required,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.castToDeclaredGithubRepoConfig = castToDeclaredGithubRepoConfig;
|
|
36
|
+
//# sourceMappingURL=castToDeclaredGithubRepoConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"castToDeclaredGithubRepoConfig.js","sourceRoot":"","sources":["../../../src/domain.operations/repoConfig/castToDeclaredGithubRepoConfig.ts"],"names":[],"mappings":";;;AACA,mDAA0D;AAG1D,gFAA6E;AAC7E,4FAAyF;AAKzF;;;GAGG;AACI,MAAM,8BAA8B,GAAG,CAAC,KAG9C,EAAyC,EAAE;IAC1C,OAAO,mDAAwB,CAAC,EAAE,CAAC;QACjC,IAAI,EACF,KAAK,CAAC,IAAI,YAAY,uCAAkB;YACtC,CAAC,CAAC,IAAA,4BAAW,EAA4B,KAAK,CAAC,IAAI,CAAC;YACpD,CAAC,CAAC,KAAK,CAAC,IAAI;QAChB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU;QACpC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,YAAY;QACxC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ;QAChC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa;QAC1C,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,WAAW;QACtC,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc;QAC5C,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB;QACnD,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB;QACnD,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB;QACnD,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,gBAAgB;QAC/C,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,sBAAsB;QAC1D,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,mBAAmB;QACrD,sBAAsB,EAAE,KAAK,CAAC,QAAQ,CAAC,yBAG1B;QACb,wBAAwB,EAAE,KAAK,CAAC,QAAQ,CAAC,2BAI5B;QACb,gBAAgB,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAGpB;QACb,kBAAkB,EAAE,KAAK,CAAC,QAAQ,CAAC,oBAItB;QACb,wBAAwB,EAAE,KAAK,CAAC,QAAQ,CAAC,2BAA2B;KACrE,CAA0C,CAAC;AAC9C,CAAC,CAAC;AAzCW,QAAA,8BAA8B,kCAyCzC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RefByUnique } from 'domain-objects';
|
|
2
|
+
import { HasMetadata, PickOne } from 'type-fns';
|
|
3
|
+
import { VisualogicContext } from 'visualogic';
|
|
4
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
5
|
+
import { DeclaredGithubRepoConfig } from '../../domain.objects/DeclaredGithubRepoConfig';
|
|
6
|
+
/**
|
|
7
|
+
* .what = gets a GitHub repository's configuration
|
|
8
|
+
* .why = retrieves current config state of a repo from GitHub API for declarative management
|
|
9
|
+
*/
|
|
10
|
+
export declare const getRepoConfig: (input: {
|
|
11
|
+
by: PickOne<{
|
|
12
|
+
unique: RefByUnique<typeof DeclaredGithubRepoConfig>;
|
|
13
|
+
}>;
|
|
14
|
+
}, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubRepoConfig> | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const test_fns_1 = require("test-fns");
|
|
4
|
+
const getSampleGithubContext_1 = require("../../.test/assets/getSampleGithubContext");
|
|
5
|
+
const getSampleRepo_1 = require("../../.test/assets/getSampleRepo");
|
|
6
|
+
const getRepoConfig_1 = require("./getRepoConfig");
|
|
7
|
+
const log = console;
|
|
8
|
+
describe('getRepoConfig', () => {
|
|
9
|
+
const context = { log, ...(0, getSampleGithubContext_1.getSampleGithubContext)() };
|
|
10
|
+
(0, test_fns_1.given)('a live example repo exists', () => {
|
|
11
|
+
(0, test_fns_1.then)('we should be able to get its config', async () => {
|
|
12
|
+
const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
|
|
13
|
+
owner: 'ehmpathy',
|
|
14
|
+
name: 'declastruct-github-demo',
|
|
15
|
+
});
|
|
16
|
+
const config = await (0, getRepoConfig_1.getRepoConfig)({
|
|
17
|
+
by: {
|
|
18
|
+
unique: {
|
|
19
|
+
repo: {
|
|
20
|
+
owner: sampleRepo.owner,
|
|
21
|
+
name: sampleRepo.name,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}, context);
|
|
26
|
+
console.log(config);
|
|
27
|
+
expect(config).toBeDefined();
|
|
28
|
+
expect(config?.repo.owner).toBe(sampleRepo.owner);
|
|
29
|
+
expect(config?.repo.name).toBe(sampleRepo.name);
|
|
30
|
+
expect(config?.defaultBranch).toBeDefined();
|
|
31
|
+
expect(typeof config?.hasIssues).toBe('boolean');
|
|
32
|
+
expect(typeof config?.hasProjects).toBe('boolean');
|
|
33
|
+
expect(typeof config?.hasWiki).toBe('boolean');
|
|
34
|
+
expect(typeof config?.allowSquashMerge).toBe('boolean');
|
|
35
|
+
expect(typeof config?.allowMergeCommit).toBe('boolean');
|
|
36
|
+
expect(typeof config?.allowRebaseMerge).toBe('boolean');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
(0, test_fns_1.given)('a repo that does not exist', () => {
|
|
40
|
+
(0, test_fns_1.then)('it should return null', async () => {
|
|
41
|
+
const config = await (0, getRepoConfig_1.getRepoConfig)({
|
|
42
|
+
by: {
|
|
43
|
+
unique: {
|
|
44
|
+
repo: {
|
|
45
|
+
owner: 'ehmpathy',
|
|
46
|
+
name: 'repo-that-does-not-exist-99999',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}, context);
|
|
51
|
+
expect(config).toBeNull();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=getRepoConfig.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepoConfig.integration.test.js","sourceRoot":"","sources":["../../../src/domain.operations/repoConfig/getRepoConfig.integration.test.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAEvC,sFAAmF;AACnF,oEAAiE;AACjE,mDAAgD;AAEhD,MAAM,GAAG,GAAG,OAAO,CAAC;AAEpB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAA,+CAAsB,GAAE,EAAE,CAAC;IAErD,IAAA,gBAAK,EAAC,4BAA4B,EAAE,GAAG,EAAE;QACvC,IAAA,eAAI,EAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;YACrD,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAa,EAChC;gBACE,EAAE,EAAE;oBACF,MAAM,EAAE;wBACN,IAAI,EAAE;4BACJ,KAAK,EAAE,UAAU,CAAC,KAAK;4BACvB,IAAI,EAAE,UAAU,CAAC,IAAI;yBACtB;qBACF;iBACF;aACF,EACD,OAAO,CACR,CAAC;YAEF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,EAAE,IAAI,C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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRepoConfig = void 0;
|
|
4
|
+
const as_procedure_1 = require("as-procedure");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const getGithubClient_1 = require("../../access/sdks/getGithubClient");
|
|
7
|
+
const castToDeclaredGithubRepoConfig_1 = require("./castToDeclaredGithubRepoConfig");
|
|
8
|
+
/**
|
|
9
|
+
* .what = gets a GitHub repository's configuration
|
|
10
|
+
* .why = retrieves current config state of a repo from GitHub API for declarative management
|
|
11
|
+
*/
|
|
12
|
+
exports.getRepoConfig = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
13
|
+
// get cached GitHub client
|
|
14
|
+
const github = (0, getGithubClient_1.getGithubClient)({}, context);
|
|
15
|
+
// determine owner and repo name from input
|
|
16
|
+
const { repo } = (() => {
|
|
17
|
+
if (input.by.unique) {
|
|
18
|
+
return {
|
|
19
|
+
repo: input.by.unique.repo,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
helpful_errors_1.UnexpectedCodePathError.throw('not referenced by unique. how not?', {
|
|
23
|
+
input,
|
|
24
|
+
});
|
|
25
|
+
})();
|
|
26
|
+
// execute the GitHub API call
|
|
27
|
+
try {
|
|
28
|
+
const response = await github.repos.get({
|
|
29
|
+
owner: repo.owner,
|
|
30
|
+
repo: repo.name,
|
|
31
|
+
});
|
|
32
|
+
return (0, castToDeclaredGithubRepoConfig_1.castToDeclaredGithubRepoConfig)({
|
|
33
|
+
response: response.data,
|
|
34
|
+
repo,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (!(error instanceof Error))
|
|
39
|
+
throw error;
|
|
40
|
+
// return null for 404/not found
|
|
41
|
+
if (error.message.includes('Not Found'))
|
|
42
|
+
return null;
|
|
43
|
+
// throw helpful error for all other failures
|
|
44
|
+
throw new helpful_errors_1.HelpfulError('github.getRepoConfig error', { cause: error });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=getRepoConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepoConfig.js","sourceRoot":"","sources":["../../../src/domain.operations/repoConfig/getRepoConfig.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,mDAAuE;AAIvE,uEAAoE;AAGpE,qFAAkF;AAElF;;;GAGG;AACU,QAAA,aAAa,GAAG,IAAA,0BAAW,EACtC,KAAK,EACH,KAIC,EACD,OAA6C,EACU,EAAE;IACzD,2BAA2B;IAC3B,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,2CAA2C;IAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE;QACrB,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;aAC3B,CAAC;QACJ,CAAC;QAED,wCAAuB,CAAC,KAAK,CAAC,oCAAoC,EAAE;YAClE,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC;IAEL,8BAA8B;IAC9B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;QACH,OAAO,IAAA,+DAA8B,EAAC;YACpC,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAE3C,gCAAgC;QAChC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,OAAO,IAAI,CAAC;QAErD,6CAA6C;QAC7C,MAAM,IAAI,6BAAY,CAAC,4BAA4B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HasMetadata, PickOne } from 'type-fns';
|
|
2
|
+
import { VisualogicContext } from 'visualogic';
|
|
3
|
+
import { ContextGithubApi } from '../../domain.objects/ContextGithubApi';
|
|
4
|
+
import { DeclaredGithubRepoConfig } from '../../domain.objects/DeclaredGithubRepoConfig';
|
|
5
|
+
/**
|
|
6
|
+
* .what = sets a GitHub repository's configuration: upsert or finsert
|
|
7
|
+
* .why = enables declarative updates of repo config following declastruct patterns
|
|
8
|
+
*/
|
|
9
|
+
export declare const setRepoConfig: (input: PickOne<{
|
|
10
|
+
finsert: DeclaredGithubRepoConfig;
|
|
11
|
+
upsert: DeclaredGithubRepoConfig;
|
|
12
|
+
}>, context: ContextGithubApi & VisualogicContext) => Promise<HasMetadata<DeclaredGithubRepoConfig>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getSampleGithubContext_1 = require("../../.test/assets/getSampleGithubContext");
|
|
4
|
+
const getSampleRepo_1 = require("../../.test/assets/getSampleRepo");
|
|
5
|
+
const getRepoConfig_1 = require("./getRepoConfig");
|
|
6
|
+
const setRepoConfig_1 = require("./setRepoConfig");
|
|
7
|
+
const log = console;
|
|
8
|
+
describe('setRepoConfig', () => {
|
|
9
|
+
const context = { log, ...(0, getSampleGithubContext_1.getSampleGithubContext)() };
|
|
10
|
+
describe('live tests', () => {
|
|
11
|
+
it('should update repo config settings', async () => {
|
|
12
|
+
const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
|
|
13
|
+
owner: 'ehmpathy',
|
|
14
|
+
name: 'declastruct-github-demo',
|
|
15
|
+
});
|
|
16
|
+
// Get current config
|
|
17
|
+
const currentConfig = await (0, getRepoConfig_1.getRepoConfig)({
|
|
18
|
+
by: {
|
|
19
|
+
unique: {
|
|
20
|
+
repo: {
|
|
21
|
+
owner: sampleRepo.owner,
|
|
22
|
+
name: sampleRepo.name,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}, context);
|
|
27
|
+
expect(currentConfig).toBeDefined();
|
|
28
|
+
// Update config with upsert
|
|
29
|
+
const result = await (0, setRepoConfig_1.setRepoConfig)({
|
|
30
|
+
upsert: {
|
|
31
|
+
repo: sampleRepo,
|
|
32
|
+
hasIssues: true,
|
|
33
|
+
hasProjects: false,
|
|
34
|
+
hasWiki: false,
|
|
35
|
+
hasDownloads: false,
|
|
36
|
+
allowSquashMerge: true,
|
|
37
|
+
allowMergeCommit: false,
|
|
38
|
+
allowRebaseMerge: false,
|
|
39
|
+
allowAutoMerge: true,
|
|
40
|
+
deleteBranchOnMerge: true, // ensure this is set to true
|
|
41
|
+
},
|
|
42
|
+
}, context);
|
|
43
|
+
expect(result).toBeDefined();
|
|
44
|
+
expect(result.repo.owner).toBe(sampleRepo.owner);
|
|
45
|
+
expect(result.repo.name).toBe(sampleRepo.name);
|
|
46
|
+
expect(result.deleteBranchOnMerge).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
it('should return existing config for finsert', async () => {
|
|
49
|
+
const sampleRepo = (0, getSampleRepo_1.getSampleRepo)({
|
|
50
|
+
owner: 'ehmpathy',
|
|
51
|
+
name: 'declastruct-github-demo',
|
|
52
|
+
});
|
|
53
|
+
// Get current config
|
|
54
|
+
const currentConfig = await (0, getRepoConfig_1.getRepoConfig)({
|
|
55
|
+
by: {
|
|
56
|
+
unique: {
|
|
57
|
+
repo: {
|
|
58
|
+
owner: sampleRepo.owner,
|
|
59
|
+
name: sampleRepo.name,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}, context);
|
|
64
|
+
expect(currentConfig).toBeDefined();
|
|
65
|
+
// Finsert should return existing config without making changes
|
|
66
|
+
const result = await (0, setRepoConfig_1.setRepoConfig)({
|
|
67
|
+
finsert: {
|
|
68
|
+
repo: { owner: sampleRepo.owner, name: sampleRepo.name },
|
|
69
|
+
hasIssues: true,
|
|
70
|
+
hasProjects: true,
|
|
71
|
+
hasWiki: true,
|
|
72
|
+
hasDownloads: true,
|
|
73
|
+
isTemplate: false,
|
|
74
|
+
defaultBranch: 'main',
|
|
75
|
+
allowSquashMerge: true,
|
|
76
|
+
allowMergeCommit: true,
|
|
77
|
+
allowRebaseMerge: true,
|
|
78
|
+
},
|
|
79
|
+
}, context);
|
|
80
|
+
expect(result).toBeDefined();
|
|
81
|
+
expect(result.repo.name).toBe(sampleRepo.name);
|
|
82
|
+
// Should match current config, not the finsert values
|
|
83
|
+
expect(result).toEqual(currentConfig);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=setRepoConfig.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setRepoConfig.integration.test.js","sourceRoot":"","sources":["../../../src/domain.operations/repoConfig/setRepoConfig.integration.test.ts"],"names":[],"mappings":";;AAAA,sFAAmF;AACnF,oEAAiE;AACjE,mDAAgD;AAChD,mDAAgD;AAEhD,MAAM,GAAG,GAAG,OAAO,CAAC;AAEpB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAA,+CAAsB,GAAE,EAAE,CAAC;IAErD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;YAClD,MAAM,UAAU,GAAG,IAAA,6BAAa,EAAC;gBAC/B,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;gBACjB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;YAEH,qBAAqB;YACrB,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAa,EACvC;gBACE,EAAE,EAAE;oBACF,MAAM,EAAE;wBACN,IAAI,EAAE;4BACJ,KAAK,EAAE,UAAU,CAAC,KAAK;4BACvB,IAAI,EAAE,UAAU,CAAC,IAAI;yBACtB;qBACF;iBACF;aACF,EACD,OAAO,CACR,CAAC;YAEF,MAAM,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;YAEpC,+DAA+D;YAC/D,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAa,EAChC;gBACE,OAAO,EAAE;oBACP,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE;oBACxD,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,IAAI;oBACjB,OAAO,EAAE,IAAI;oBACb,YAAY,EAAE,IAAI;oBAClB,UAAU,EAAE,KAAK;oBACjB,aAAa,EAAE,MAAM;oBACrB,gBAAgB,EAAE,IAAI;oBACtB,gBAAgB,EAAE,IAAI;oBACtB,gBAAgB,EAAE,IAAI;iBACvB;aACF,EACD,OAAO,CACR,CAAC;YAEF,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/C,sDAAsD;YACtD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setRepoConfig = void 0;
|
|
4
|
+
const as_procedure_1 = require("as-procedure");
|
|
5
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
6
|
+
const getGithubClient_1 = require("../../access/sdks/getGithubClient");
|
|
7
|
+
const castToDeclaredGithubRepoConfig_1 = require("./castToDeclaredGithubRepoConfig");
|
|
8
|
+
const getRepoConfig_1 = require("./getRepoConfig");
|
|
9
|
+
/**
|
|
10
|
+
* .what = sets a GitHub repository's configuration: upsert or finsert
|
|
11
|
+
* .why = enables declarative updates of repo config following declastruct patterns
|
|
12
|
+
*/
|
|
13
|
+
exports.setRepoConfig = (0, as_procedure_1.asProcedure)(async (input, context) => {
|
|
14
|
+
const desired = input.finsert ?? input.upsert;
|
|
15
|
+
// get cached GitHub client
|
|
16
|
+
const github = (0, getGithubClient_1.getGithubClient)({}, context);
|
|
17
|
+
// check whether it already exists
|
|
18
|
+
const before = await (0, getRepoConfig_1.getRepoConfig)({
|
|
19
|
+
by: {
|
|
20
|
+
unique: {
|
|
21
|
+
repo: desired.repo,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}, context);
|
|
25
|
+
// if it's a finsert and had a before, then return that
|
|
26
|
+
if (before && input.finsert)
|
|
27
|
+
return before;
|
|
28
|
+
// update the repo config (always use update since config is part of repo, not a separate resource)
|
|
29
|
+
try {
|
|
30
|
+
const repoRef = desired.repo;
|
|
31
|
+
const updated = await github.repos.update({
|
|
32
|
+
owner: repoRef.owner,
|
|
33
|
+
repo: repoRef.name,
|
|
34
|
+
has_issues: desired.hasIssues,
|
|
35
|
+
has_projects: desired.hasProjects,
|
|
36
|
+
has_wiki: desired.hasWiki,
|
|
37
|
+
has_downloads: desired.hasDownloads,
|
|
38
|
+
is_template: desired.isTemplate,
|
|
39
|
+
default_branch: desired.defaultBranch,
|
|
40
|
+
allow_squash_merge: desired.allowSquashMerge,
|
|
41
|
+
allow_merge_commit: desired.allowMergeCommit,
|
|
42
|
+
allow_rebase_merge: desired.allowRebaseMerge,
|
|
43
|
+
allow_auto_merge: desired.allowAutoMerge,
|
|
44
|
+
delete_branch_on_merge: desired.deleteBranchOnMerge,
|
|
45
|
+
allow_update_branch: desired.allowUpdateBranch,
|
|
46
|
+
squash_merge_commit_title: desired.squashMergeCommitTitle,
|
|
47
|
+
squash_merge_commit_message: desired.squashMergeCommitMessage,
|
|
48
|
+
merge_commit_title: desired.mergeCommitTitle,
|
|
49
|
+
merge_commit_message: desired.mergeCommitMessage,
|
|
50
|
+
web_commit_signoff_required: desired.webCommitSignoffRequired,
|
|
51
|
+
});
|
|
52
|
+
return (0, castToDeclaredGithubRepoConfig_1.castToDeclaredGithubRepoConfig)({
|
|
53
|
+
response: updated.data,
|
|
54
|
+
repo: desired.repo,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (!(error instanceof Error))
|
|
59
|
+
throw error;
|
|
60
|
+
throw new helpful_errors_1.HelpfulError('github.setRepoConfig.update error', {
|
|
61
|
+
cause: error,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=setRepoConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setRepoConfig.js","sourceRoot":"","sources":["../../../src/domain.operations/repoConfig/setRepoConfig.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3C,mDAA8C;AAI9C,uEAAoE;AAGpE,qFAAkF;AAClF,mDAAgD;AAEhD;;;GAGG;AACU,QAAA,aAAa,GAAG,IAAA,0BAAW,EACtC,KAAK,EACH,KAGE,EACF,OAA6C,EACG,EAAE;IAClD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC;IAE9C,2BAA2B;IAC3B,MAAM,MAAM,GAAG,IAAA,iCAAe,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAE5C,kCAAkC;IAClC,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAa,EAChC;QACE,EAAE,EAAE;YACF,MAAM,EAAE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