@teleporthq/teleport-publisher-github 0.18.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 teleporthq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ [
2
+ {
3
+ "name": "package.json",
4
+ "content": "package.json content"
5
+ },
6
+ {
7
+ "name": "pages/index.js",
8
+ "content": "index file content",
9
+ "encoding": "base64"
10
+ },
11
+ {
12
+ "name": "components/Navbar.js",
13
+ "content": "navbar content"
14
+ }
15
+ ]
@@ -0,0 +1,108 @@
1
+ import { createGithubPublisher } from '../src'
2
+
3
+ import projectJSON from './project-files.json'
4
+ import githubFiles from './github-files-content.json'
5
+ import { generateProjectFiles } from '../src/utils'
6
+ import { GeneratedFolder } from '@teleporthq/teleport-types'
7
+
8
+ const project = projectJSON as GeneratedFolder
9
+ describe('teleport publisher github', () => {
10
+ it('creates a new instance of github publisher', () => {
11
+ const publisher = createGithubPublisher()
12
+ expect(publisher.getCommitMessage).toBeDefined()
13
+ expect(publisher.getMainBranchName).toBeDefined()
14
+ expect(publisher.getCommitBranchName).toBeDefined()
15
+ expect(publisher.getProject).toBeDefined()
16
+ expect(publisher.getRepository).toBeDefined()
17
+ expect(publisher.getRepositoryOwner).toBeDefined()
18
+
19
+ expect(publisher.setCommitMessage).toBeDefined()
20
+ expect(publisher.setMainBranchName).toBeDefined()
21
+ expect(publisher.setCommitBranchName).toBeDefined()
22
+ expect(publisher.setProject).toBeDefined()
23
+ expect(publisher.setRepository).toBeDefined()
24
+ expect(publisher.setRepositoryOwner).toBeDefined()
25
+
26
+ expect(publisher.publish).toBeDefined()
27
+ })
28
+
29
+ it('should set project', () => {
30
+ const publisher = createGithubPublisher()
31
+ publisher.setProject(project)
32
+
33
+ const publisherProject = JSON.stringify(publisher.getProject())
34
+ expect(publisherProject).toBe(JSON.stringify(project))
35
+ })
36
+
37
+ it('should set commit message', () => {
38
+ const MESSAGE = 'test message'
39
+ const publisher = createGithubPublisher()
40
+ publisher.setCommitMessage(MESSAGE)
41
+
42
+ const publisherCommitMessage = JSON.stringify(publisher.getCommitMessage())
43
+ expect(publisherCommitMessage).toBe(JSON.stringify(MESSAGE))
44
+ })
45
+
46
+ it('should set master branch name', () => {
47
+ const BRANCH = 'master'
48
+ const publisher = createGithubPublisher()
49
+ publisher.setMainBranchName(BRANCH)
50
+
51
+ const publisherMasterBranch = JSON.stringify(publisher.getMainBranchName())
52
+ expect(publisherMasterBranch).toBe(JSON.stringify(BRANCH))
53
+ })
54
+
55
+ it('should set commit branch name', () => {
56
+ const BRANCH = 'commit-branch'
57
+ const publisher = createGithubPublisher()
58
+ publisher.setCommitBranchName(BRANCH)
59
+
60
+ const publisherCommitBranch = JSON.stringify(publisher.getCommitBranchName())
61
+ expect(publisherCommitBranch).toBe(JSON.stringify(BRANCH))
62
+ })
63
+
64
+ it('should set repository name', () => {
65
+ const REPOSITORY = 'test-repo'
66
+ const publisher = createGithubPublisher()
67
+ publisher.setRepository(REPOSITORY)
68
+
69
+ const publisherRepository = JSON.stringify(publisher.getRepository())
70
+ expect(publisherRepository).toBe(JSON.stringify(REPOSITORY))
71
+ })
72
+
73
+ it('should set repository owner', () => {
74
+ const OWNER = 'test-owner'
75
+ const publisher = createGithubPublisher()
76
+ publisher.setRepositoryOwner(OWNER)
77
+
78
+ const publisherOwner = JSON.stringify(publisher.getRepositoryOwner())
79
+ expect(publisherOwner).toBe(JSON.stringify(OWNER))
80
+ })
81
+
82
+ it('should fail if no project is provided', async () => {
83
+ const publisher = createGithubPublisher()
84
+
85
+ await expect(publisher.publish()).rejects.toThrow(Error)
86
+ })
87
+
88
+ it('should fail if no auth data is provided', async () => {
89
+ const publisher = createGithubPublisher()
90
+ publisher.setProject(project)
91
+
92
+ await expect(publisher.publish()).rejects.toThrow(Error)
93
+ })
94
+
95
+ it('should fail if no repository is provided', async () => {
96
+ const publisher = createGithubPublisher({
97
+ authMeta: { basic: { username: 'test', password: 'test' } },
98
+ })
99
+ publisher.setProject(project)
100
+
101
+ await expect(publisher.publish()).rejects.toThrow(Error)
102
+ })
103
+
104
+ it('should generate github project files from generated folder', () => {
105
+ const files = generateProjectFiles({ folder: { ...project }, ignoreFolder: true })
106
+ expect(JSON.stringify(files)).toBe(JSON.stringify(githubFiles))
107
+ })
108
+ })
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "project-name",
3
+ "files": [
4
+ {
5
+ "name": "package",
6
+ "fileType": "json",
7
+ "content": "package.json content"
8
+ }
9
+ ],
10
+ "subFolders": [
11
+ {
12
+ "name": "pages",
13
+ "files": [
14
+ {
15
+ "name": "index",
16
+ "fileType": "js",
17
+ "content": "index file content",
18
+ "contentEncoding": "base64"
19
+ }
20
+ ],
21
+ "subFolders": []
22
+ },
23
+ {
24
+ "name": "components",
25
+ "files": [
26
+ {
27
+ "name": "Navbar",
28
+ "fileType": "js",
29
+ "content": "navbar content"
30
+ }
31
+ ],
32
+ "subFolders": []
33
+ },
34
+ {
35
+ "name": "static",
36
+ "files": [],
37
+ "subFolders": []
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,3 @@
1
+ import { PublisherFactory } from '@teleporthq/teleport-types';
2
+ import { GithubFactoryParams, GithubPublisher } from './types';
3
+ export declare const createGithubPublisher: PublisherFactory<GithubFactoryParams, GithubPublisher>;
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createGithubPublisher = void 0;
40
+ var teleport_types_1 = require("@teleporthq/teleport-types");
41
+ var utils_1 = require("./utils");
42
+ var createGithubPublisher = function (params) {
43
+ if (params === void 0) { params = {}; }
44
+ var authMeta = params.authMeta;
45
+ var project = params.project, repository = params.repository, repositoryOwner = params.repositoryOwner, mainBranch = params.mainBranch, commitBranch = params.commitBranch, commitMessage = params.commitMessage;
46
+ var getProject = function () { return project; };
47
+ var setProject = function (projectToSet) {
48
+ project = projectToSet;
49
+ };
50
+ var getRepository = function () { return repository; };
51
+ var setRepository = function (repo) {
52
+ repository = repo;
53
+ };
54
+ var getMainBranchName = function () { return mainBranch; };
55
+ var setMainBranchName = function (branch) {
56
+ mainBranch = branch;
57
+ };
58
+ var getCommitBranchName = function () { return commitBranch; };
59
+ var setCommitBranchName = function (branch) {
60
+ commitBranch = branch;
61
+ };
62
+ var getCommitMessage = function () { return commitMessage; };
63
+ var setCommitMessage = function (message) {
64
+ commitMessage = message;
65
+ };
66
+ var getRepositoryOwner = function () { return repositoryOwner; };
67
+ var setRepositoryOwner = function (owner) {
68
+ repositoryOwner = owner;
69
+ };
70
+ var publish = function (options) {
71
+ if (options === void 0) { options = {}; }
72
+ return __awaiter(void 0, void 0, void 0, function () {
73
+ var projectToPublish, auth, repo, repoOwner, mainBranchName, main, commitBranchName, commitMsg, githubPublishMeta, projectFiles, result, err_1;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0:
77
+ projectToPublish = options.project || project;
78
+ if (!projectToPublish) {
79
+ throw new teleport_types_1.MissingProjectUIDLError();
80
+ }
81
+ auth = options.authMeta || authMeta;
82
+ if (!auth) {
83
+ throw new teleport_types_1.GithubMissingAuthError();
84
+ }
85
+ repo = options.repository || repository;
86
+ if (!repo) {
87
+ throw new teleport_types_1.GithubMissingRepoError();
88
+ }
89
+ repoOwner = findRepositoryOwner(auth, options);
90
+ mainBranchName = options.mainBranch || mainBranch;
91
+ main = mainBranchName ? mainBranch : 'main';
92
+ commitBranchName = options.commitBranch || commitBranch;
93
+ commitMsg = options.commitMessage || commitMessage;
94
+ githubPublishMeta = {
95
+ authMeta: auth,
96
+ mainBranch: main,
97
+ commitBranch: commitBranchName ? commitBranchName : main,
98
+ commitMessage: commitMsg,
99
+ repository: repo,
100
+ repositoryOwner: repoOwner,
101
+ };
102
+ projectFiles = utils_1.generateProjectFiles({ folder: projectToPublish, ignoreFolder: true });
103
+ _a.label = 1;
104
+ case 1:
105
+ _a.trys.push([1, 3, , 4]);
106
+ return [4 /*yield*/, utils_1.publishToGithub(projectFiles, githubPublishMeta)];
107
+ case 2:
108
+ result = _a.sent();
109
+ return [2 /*return*/, { success: true, payload: result }];
110
+ case 3:
111
+ err_1 = _a.sent();
112
+ // A bit hacky here, the github library we are using is failing with a TypeError when the service is down
113
+ if (err_1 instanceof TypeError) {
114
+ throw new teleport_types_1.GithubServerError();
115
+ }
116
+ if (err_1.response.status === 401 && err_1.response.statusText === 'Unauthorized') {
117
+ throw new teleport_types_1.GithubInvalidTokenError();
118
+ }
119
+ throw new teleport_types_1.GithubUnexpectedError(err_1);
120
+ case 4: return [2 /*return*/];
121
+ }
122
+ });
123
+ });
124
+ };
125
+ var findRepositoryOwner = function (auth, options) {
126
+ if (auth && auth.basic && auth.basic.username) {
127
+ return auth.basic.username;
128
+ }
129
+ return options.repositoryOwner || repositoryOwner;
130
+ };
131
+ return {
132
+ getProject: getProject,
133
+ setProject: setProject,
134
+ getRepository: getRepository,
135
+ setRepository: setRepository,
136
+ getMainBranchName: getMainBranchName,
137
+ setMainBranchName: setMainBranchName,
138
+ getCommitBranchName: getCommitBranchName,
139
+ setCommitBranchName: setCommitBranchName,
140
+ getCommitMessage: getCommitMessage,
141
+ setCommitMessage: setCommitMessage,
142
+ getRepositoryOwner: getRepositoryOwner,
143
+ setRepositoryOwner: setRepositoryOwner,
144
+ publish: publish,
145
+ };
146
+ };
147
+ exports.createGithubPublisher = createGithubPublisher;
148
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAUmC;AAEnC,iCAA+D;AAGxD,IAAM,qBAAqB,GAA2D,UAC3F,MAAgC;IAAhC,uBAAA,EAAA,WAAgC;IAExB,IAAA,QAAQ,GAAK,MAAM,SAAX,CAAW;IACrB,IAAA,OAAO,GAA2E,MAAM,QAAjF,EAAE,UAAU,GAA+D,MAAM,WAArE,EAAE,eAAe,GAA8C,MAAM,gBAApD,EAAE,UAAU,GAAkC,MAAM,WAAxC,EAAE,YAAY,GAAoB,MAAM,aAA1B,EAAE,aAAa,GAAK,MAAM,cAAX,CAAW;IAE9F,IAAM,UAAU,GAAG,cAAM,OAAA,OAAO,EAAP,CAAO,CAAA;IAChC,IAAM,UAAU,GAAG,UAAC,YAA6B;QAC/C,OAAO,GAAG,YAAY,CAAA;IACxB,CAAC,CAAA;IAED,IAAM,aAAa,GAAG,cAAM,OAAA,UAAU,EAAV,CAAU,CAAA;IACtC,IAAM,aAAa,GAAG,UAAC,IAAY;QACjC,UAAU,GAAG,I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OAAO,OAAO,CAAC,eAAe,IAAI,eAAe,CAAA;IACnD,CAAC,CAAA;IAED,OAAO;QACL,UAAU,YAAA;QACV,UAAU,YAAA;QACV,aAAa,eAAA;QACb,aAAa,eAAA;QACb,iBAAiB,mBAAA;QACjB,iBAAiB,mBAAA;QACjB,mBAAmB,qBAAA;QACnB,mBAAmB,qBAAA;QACnB,gBAAgB,kBAAA;QAChB,gBAAgB,kBAAA;QAChB,kBAAkB,oBAAA;QAClB,kBAAkB,oBAAA;QAClB,OAAO,SAAA;KACR,CAAA;AACH,CAAC,CAAA;AA7GY,QAAA,qBAAqB,yBA6GjC"}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../teleport-types/dist/cjs/uidl.d.ts","../../../teleport-types/dist/cjs/generators.d.ts","../../../teleport-types/dist/cjs/errors.d.ts","../../../teleport-types/dist/cjs/vuidl.d.ts","../../../teleport-types/dist/cjs/index.d.ts","../../../teleport-github-gateway/dist/cjs/github-instance.d.ts","../../../teleport-github-gateway/dist/cjs/types.d.ts","../../../teleport-github-gateway/dist/cjs/index.d.ts","../../src/types.ts","../../src/utils.ts","../../src/index.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostic_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/util/types.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/ts3.6/base.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/base.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/jest/ts3.2/index.d.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"d1e076bd03d792a96993f458172927e0c5ac3cb8e1b566f54f925e6ef19bbebb","6a55786dc1b8e3c25bc00e1700a7eb297e20bccae7d4bb5e4a020b97daa2052f","eccf9c0b6e420c47b3e3eb87e8f0dc9df312a9583a6cce96756b18ebff176b70","75ecadee387dde7be130c85ed277fdfcee3923e452260ffaf217ebaefe7bd305","cd619820771edb23926bb084906215ab9c491255fa707488d15748b38909b747","c9318c4bb0f990c71d6add7e96f8a008f8d3d488cdca280483f772acaf595e99","17b0082643c87ac8ccdcac7261e2fc1d60302f138d5f39d49c393d2548c16119","fec98ff7f14f76cd4616a6a1c8c467362c4235fcd6c5fd386f01bb642ac628c5","3a393a3a2d6215087e4fbc4a4384056d8734322bd99167349ae6e1c8a8a7ebbf","14c9360771841b3aecaea0fe7e1f2df1a960c2f73f846649fa7b03df434c8bb0","8798f331b6fb63250dfc15ca87e46fca18f9b910a2ab89f1fe99589b2f54fc73","c7bdc99177a2a94d25fb13722adaaf5b3291bf70b4d1b27584ba189dd3889ba3",{"version":"d1c92b66c4105659fcad4eb76a1481f7311033e117d0678a1ec545e8ddb8d4c6","affectsGlobalScope":true},"e23424b97418eca3226fd24de079f1203eb70360622e4e093af2aff14d4be6ec","dee93c07b4df5e26010dc9ec4cdf4d6e4076bb4474d2a8371529217c8b2740a4","d55bc773f71c50f55decb39b64a5d8b9889a7c9e94305b36656ebf30e4f47469","04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef",{"version":"c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","dfc747ab8dd5f623055a4c26fd35e8cceca869fd3f1cf09701c941ca3679665a","c9f5f2920ff61d7158417b8440d5181ddc34a3dfef811a5677dd8a9fb91471e9","5cc0a492da3602510b8f5ed1852b1e0390002780d8758fbc8c0cd023ca7085f8","ec7dafafe751a5121f8f1c80201ebe7e7238c47e6329280a73c4d1ca4bb7fa28","64debeb10e4b7ae4ec9e89bfb4e04c6101ab98c3cc806d14e5488607cfec2753",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"a5782d6cea81fe43d2db7ed41e789458c933ab3ab60602f7b5b14c4da3370496","affectsGlobalScope":true},"b86b7ff709a82ef3cba2184136c025989958bad483ffb13e4ca35d720245adf4","6194335ee3353f7226ba31f31d6301d0c6be87228419c0a08976ccd9d4f1213e","5a173b7da4e6d073f9c18a02f387816a934614e7af306193995935fbb95f10b8","b447e123210c68f205f67b20c996c04a1eb64b0e591c5e06e164cd3d3a869b28","13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452","42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","c55776aa1db2b963a5fb820c0650362e721cba51ebf83b069696f2501378c0f3","e2236264a811ed1d09a2487a433e8f5216ae62378cf233954ae220cf886f6717","3ec1e108d587a5661ec790db607f482605ba9f3830e118ce578e3ffa3c42e22b","100b3bb9d39d2b1b5340f1bf45a52e94ef1692b45232b4ba00fac5c3cc56d331",{"version":"ec1a29ddaecb683aa360df0bd98ab5d4171d2d549554f7c5ab2a5c183a3dcb67","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58","2597718d91e306949d89e285bf34c44192014ef541c3bd7cbb825c022749e974","a6b0abdb67d63ebe964ba5fee31bc3daf10c12eecd46b24d778426010c04c67e","ac4801ebc2355ba32329070123b1cd15891bf71b41dcaf9e75b4744832126a59","fd2298fba0640e7295e7bd545e2dfbfcccbb00c27019e501c87965a02bbdebf6","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","71ddd49185b68f27bfac127ef5d22cb2672c278e53e5370d9020ef50ca9c377d","b1ea7a6eaa7608e0e0529aebd323b526a79c6c05a4e519ae5c779675004dcdf1","9fcb033a6208485d8f3fadde31eb5cbcaf99149cff3e40c0dc53ebc6d0dff4e9","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9","f4149f1aa299474c7040a35fe8f8ac2ad078cc1b190415adc1fff3ed52d490ea","3730099ed008776216268a97771de31753ef71e0a7d0ec650f588cba2a06ce44","8d649dbc429d7139a1d9a14ea2bf8af1dc089e0a879447539587463d4b6c248c","60c9e27816ec8ac8df7240598bb086e95b47edfb454c5cbf4003c812e0ed6e39","e361aecf17fc4034b4c122a1564471cdcd22ef3a51407803cb5a5fc020c04d02","4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"fc0ae4a8ad3c762b96f9d2c3700cb879a373458cb0bf3175478e3b4f85f7ef2f","fabbec378e1ddd86fcf2662e716c2b8318acedb664ee3a4cba6f9e8ee8269cf1","b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","efd55e8ca79171bf26c0d0e30221cb8ee1f5a31dd0c791ec4b2e886f42bab124","e222104af6cb9415238ad358488b74d76eceeff238c1268ec6e85655b05341da","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","eba230221317c985ab1953ccc3edc517f248b37db4fef7875cb2c8d08aff7be7","b83e796810e475da3564c6515bc0ae9577070596a33d89299b7d99f94ecfd921","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"f624e578325b8c58e55b30c998b1f4c3ec1b61a9fa66373da4250c89b7880d44","affectsGlobalScope":true},{"version":"d3002f620eab4bf6476c9da5c0efb2041d46f7df8b3032a5631bd206abef2c75","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":1,"noImplicitAny":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","sourceMap":true,"target":1},"fileIdsList":[[96,98],[92,93],[92,93,94,95],[97],[99],[89],[88,89],[43,48],[54,55,62,71],[44,54,62],[80],[48,55,63],[71,76],[51,54,62],[52],[51],[54],[54,56,71,79],[54,55,71],[62,71,79],[54,55,57,62,71,76,79],[57,76,79],[90],[79],[51,54,71],[64],[42],[78],[69,80,83],[54,72],[71],[74],[48,62],[40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87],[62],[68],[81],[43,48,54,56,65,71,79,83],[33,35],[35],[33,34],[33,37,38],[33,36],[33,36,37],[29],[29,30,31,32]],"referencedMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[34,39],[36,40],[35,41],[39,42],[37,43],[38,44],[30,45],[33,46],[32,45]],"exportedModulesMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[34,39],[36,40],[35,41],[39,42],[37,43],[38,44],[30,45],[33,46],[32,45]],"semanticDiagnosticsPerFile":[99,92,94,96,95,93,98,97,100,89,40,42,90,43,44,45,46,47,48,49,50,51,52,53,54,55,56,41,86,57,58,59,91,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,88,78,79,80,81,82,83,87,84,85,6,8,7,2,9,10,11,12,13,14,15,16,3,4,20,17,18,19,21,22,23,5,24,25,26,27,1,28,34,36,35,39,37,38,31,30,33,29,32]},"version":"4.3.5"}
@@ -0,0 +1,36 @@
1
+ import { ServiceAuth, PublisherFactoryParams, Publisher, GeneratedFolder } from '@teleporthq/teleport-types';
2
+ import { GithubFile } from '@teleporthq/teleport-github-gateway';
3
+ export interface GithubFactoryParams extends PublisherFactoryParams {
4
+ authMeta?: ServiceAuth;
5
+ repositoryOwner?: string;
6
+ repository?: string;
7
+ mainBranch?: string;
8
+ commitBranch?: string;
9
+ commitMessage?: string;
10
+ }
11
+ export interface GithubPublisher extends Publisher<GithubFactoryParams, string> {
12
+ getRepository: () => string;
13
+ setRepository: (repo: string) => void;
14
+ getMainBranchName: () => string;
15
+ setMainBranchName: (branch: string) => void;
16
+ getCommitBranchName: () => string;
17
+ setCommitBranchName: (branch: string) => void;
18
+ getCommitMessage: () => string;
19
+ setCommitMessage: (message: string) => void;
20
+ getRepositoryOwner: () => string;
21
+ setRepositoryOwner: (owner: string) => void;
22
+ }
23
+ export interface GithubPublishMeta {
24
+ authMeta: ServiceAuth;
25
+ repository: string;
26
+ repositoryOwner: string;
27
+ mainBranch?: string;
28
+ commitBranch?: string;
29
+ commitMessage?: string;
30
+ }
31
+ export interface ProjectFolderInfo {
32
+ folder: GeneratedFolder;
33
+ prefix?: string;
34
+ files?: GithubFile[];
35
+ ignoreFolder?: boolean;
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { GithubFile } from '@teleporthq/teleport-github-gateway';
2
+ import { GithubPublishMeta, ProjectFolderInfo } from './types';
3
+ export declare const generateProjectFiles: (folderInfo: ProjectFolderInfo) => GithubFile[];
4
+ export declare const publishToGithub: (files: GithubFile[], meta: GithubPublishMeta) => Promise<string>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.publishToGithub = exports.generateProjectFiles = void 0;
40
+ var teleport_github_gateway_1 = require("@teleporthq/teleport-github-gateway");
41
+ var generateProjectFiles = function (folderInfo) {
42
+ var folder = folderInfo.folder, _a = folderInfo.prefix, prefix = _a === void 0 ? '' : _a, _b = folderInfo.files, files = _b === void 0 ? [] : _b, _c = folderInfo.ignoreFolder, ignoreFolder = _c === void 0 ? false : _c;
43
+ var folderToPutFileTo = ignoreFolder ? '' : "" + prefix + folder.name + "/";
44
+ folder.files.forEach(function (file) {
45
+ var fileName = file.fileType
46
+ ? "" + folderToPutFileTo + file.name + "." + file.fileType
47
+ : "" + folderToPutFileTo + file.name;
48
+ var githubFile = {
49
+ name: fileName,
50
+ content: file.content,
51
+ };
52
+ if (file.contentEncoding) {
53
+ githubFile.encoding = file.contentEncoding;
54
+ }
55
+ files.push(githubFile);
56
+ });
57
+ folder.subFolders.forEach(function (subfolder) {
58
+ var subfolderInfo = {
59
+ files: files,
60
+ folder: subfolder,
61
+ prefix: folderToPutFileTo,
62
+ };
63
+ exports.generateProjectFiles(subfolderInfo);
64
+ });
65
+ return files;
66
+ };
67
+ exports.generateProjectFiles = generateProjectFiles;
68
+ var publishToGithub = function (files, meta) { return __awaiter(void 0, void 0, void 0, function () {
69
+ var authMeta, mainBranch, commitBranch, commitMessage, repository, repositoryOwner, repositoryIdentity, gitCommitMeta, githubGateway;
70
+ return __generator(this, function (_a) {
71
+ authMeta = meta.authMeta, mainBranch = meta.mainBranch, commitBranch = meta.commitBranch, commitMessage = meta.commitMessage, repository = meta.repository, repositoryOwner = meta.repositoryOwner;
72
+ repositoryIdentity = {
73
+ username: repositoryOwner,
74
+ repo: repository,
75
+ ref: mainBranch,
76
+ };
77
+ gitCommitMeta = {
78
+ repositoryIdentity: repositoryIdentity,
79
+ files: files,
80
+ branchName: commitBranch,
81
+ commitMessage: commitMessage,
82
+ };
83
+ githubGateway = teleport_github_gateway_1.createGithubGateway(authMeta);
84
+ return [2 /*return*/, githubGateway.commitFilesToRepo(gitCommitMeta)];
85
+ });
86
+ }); };
87
+ exports.publishToGithub = publishToGithub;
88
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+EAK4C;AAIrC,IAAM,oBAAoB,GAAG,UAAC,UAA6B;IACxD,IAAA,MAAM,GAAoD,UAAU,OAA9D,EAAE,KAAkD,UAAU,OAAjD,EAAX,MAAM,mBAAG,EAAE,KAAA,EAAE,KAAqC,UAAU,MAArC,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,KAAyB,UAAU,aAAf,EAApB,YAAY,mBAAG,KAAK,KAAA,CAAe;IAC5E,IAAM,iBAAiB,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAG,MAAM,GAAG,MAAM,CAAC,IAAI,MAAG,CAAA;IAExE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,IAAmB;QACvC,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ;YAC5B,CAAC,CAAC,KAAG,iBAAiB,GAAG,IAAI,CAAC,IAAI,SAAI,IAAI,CAAC,QAAU;YACrD,CAAC,CAAC,KAAG,iBAAiB,GAAG,IAAI,CAAC,IAAM,CAAA;QAEtC,IAAM,UAAU,GAAe;YAC7B,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;QAED,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAA;SAC3C;QAED,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,SAA0B;QACnD,IAAM,aAAa,GAAG;YACpB,KAAK,OAAA;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,iBAAiB;SAC1B,CAAA;QACD,4BAAoB,CAAC,aAAa,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AA/BY,QAAA,oBAAoB,wBA+BhC;AAEM,IAAM,eAAe,GAAG,UAAO,KAAmB,EAAE,IAAuB;;;QACxE,QAAQ,GAA2E,IAAI,SAA/E,EAAE,UAAU,GAA+D,IAAI,WAAnE,EAAE,YAAY,GAAiD,IAAI,aAArD,EAAE,aAAa,GAAkC,IAAI,cAAtC,EAAE,UAAU,GAAsB,IAAI,WAA1B,EAAE,eAAe,GAAK,IAAI,gBAAT,CAAS;QAEzF,kBAAkB,GAAuB;YAC7C,QAAQ,EAAE,eAAe;YACzB,IAAI,EAAE,UAAU;YAChB,GAAG,EAAE,UAAU;SAChB,CAAA;QAEK,aAAa,GAAqB;YACtC,kBAAkB,oBAAA;YAClB,KAAK,OAAA;YACL,UAAU,EAAE,YAAY;YACxB,aAAa,eAAA;SACd,CAAA;QAEK,aAAa,GAAG,6CAAmB,CAAC,QAAQ,CAAC,CAAA;QACnD,sBAAO,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAA;;KACtD,CAAA;AAlBY,QAAA,eAAe,mBAkB3B"}
@@ -0,0 +1,3 @@
1
+ import { PublisherFactory } from '@teleporthq/teleport-types';
2
+ import { GithubFactoryParams, GithubPublisher } from './types';
3
+ export declare const createGithubPublisher: PublisherFactory<GithubFactoryParams, GithubPublisher>;
@@ -0,0 +1,144 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { MissingProjectUIDLError, GithubMissingAuthError, GithubMissingRepoError, GithubInvalidTokenError, GithubUnexpectedError, GithubServerError, } from '@teleporthq/teleport-types';
38
+ import { publishToGithub, generateProjectFiles } from './utils';
39
+ export var createGithubPublisher = function (params) {
40
+ if (params === void 0) { params = {}; }
41
+ var authMeta = params.authMeta;
42
+ var project = params.project, repository = params.repository, repositoryOwner = params.repositoryOwner, mainBranch = params.mainBranch, commitBranch = params.commitBranch, commitMessage = params.commitMessage;
43
+ var getProject = function () { return project; };
44
+ var setProject = function (projectToSet) {
45
+ project = projectToSet;
46
+ };
47
+ var getRepository = function () { return repository; };
48
+ var setRepository = function (repo) {
49
+ repository = repo;
50
+ };
51
+ var getMainBranchName = function () { return mainBranch; };
52
+ var setMainBranchName = function (branch) {
53
+ mainBranch = branch;
54
+ };
55
+ var getCommitBranchName = function () { return commitBranch; };
56
+ var setCommitBranchName = function (branch) {
57
+ commitBranch = branch;
58
+ };
59
+ var getCommitMessage = function () { return commitMessage; };
60
+ var setCommitMessage = function (message) {
61
+ commitMessage = message;
62
+ };
63
+ var getRepositoryOwner = function () { return repositoryOwner; };
64
+ var setRepositoryOwner = function (owner) {
65
+ repositoryOwner = owner;
66
+ };
67
+ var publish = function (options) {
68
+ if (options === void 0) { options = {}; }
69
+ return __awaiter(void 0, void 0, void 0, function () {
70
+ var projectToPublish, auth, repo, repoOwner, mainBranchName, main, commitBranchName, commitMsg, githubPublishMeta, projectFiles, result, err_1;
71
+ return __generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0:
74
+ projectToPublish = options.project || project;
75
+ if (!projectToPublish) {
76
+ throw new MissingProjectUIDLError();
77
+ }
78
+ auth = options.authMeta || authMeta;
79
+ if (!auth) {
80
+ throw new GithubMissingAuthError();
81
+ }
82
+ repo = options.repository || repository;
83
+ if (!repo) {
84
+ throw new GithubMissingRepoError();
85
+ }
86
+ repoOwner = findRepositoryOwner(auth, options);
87
+ mainBranchName = options.mainBranch || mainBranch;
88
+ main = mainBranchName ? mainBranch : 'main';
89
+ commitBranchName = options.commitBranch || commitBranch;
90
+ commitMsg = options.commitMessage || commitMessage;
91
+ githubPublishMeta = {
92
+ authMeta: auth,
93
+ mainBranch: main,
94
+ commitBranch: commitBranchName ? commitBranchName : main,
95
+ commitMessage: commitMsg,
96
+ repository: repo,
97
+ repositoryOwner: repoOwner,
98
+ };
99
+ projectFiles = generateProjectFiles({ folder: projectToPublish, ignoreFolder: true });
100
+ _a.label = 1;
101
+ case 1:
102
+ _a.trys.push([1, 3, , 4]);
103
+ return [4 /*yield*/, publishToGithub(projectFiles, githubPublishMeta)];
104
+ case 2:
105
+ result = _a.sent();
106
+ return [2 /*return*/, { success: true, payload: result }];
107
+ case 3:
108
+ err_1 = _a.sent();
109
+ // A bit hacky here, the github library we are using is failing with a TypeError when the service is down
110
+ if (err_1 instanceof TypeError) {
111
+ throw new GithubServerError();
112
+ }
113
+ if (err_1.response.status === 401 && err_1.response.statusText === 'Unauthorized') {
114
+ throw new GithubInvalidTokenError();
115
+ }
116
+ throw new GithubUnexpectedError(err_1);
117
+ case 4: return [2 /*return*/];
118
+ }
119
+ });
120
+ });
121
+ };
122
+ var findRepositoryOwner = function (auth, options) {
123
+ if (auth && auth.basic && auth.basic.username) {
124
+ return auth.basic.username;
125
+ }
126
+ return options.repositoryOwner || repositoryOwner;
127
+ };
128
+ return {
129
+ getProject: getProject,
130
+ setProject: setProject,
131
+ getRepository: getRepository,
132
+ setRepository: setRepository,
133
+ getMainBranchName: getMainBranchName,
134
+ setMainBranchName: setMainBranchName,
135
+ getCommitBranchName: getCommitBranchName,
136
+ setCommitBranchName: setCommitBranchName,
137
+ getCommitMessage: getCommitMessage,
138
+ setCommitMessage: setCommitMessage,
139
+ getRepositoryOwner: getRepositoryOwner,
140
+ setRepositoryOwner: setRepositoryOwner,
141
+ publish: publish,
142
+ };
143
+ };
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAIL,uBAAuB,EACvB,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gB,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;;;;wBAG1E,qBAAM,eAAe,CAAC,YAAY,EAAE,iBAAiB,CAAC,EAAA;;wBAA/D,MAAM,GAAG,SAAsD;wBACrE,sBAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAA;;;wBAEzC,yGAAyG;wBACzG,IAAI,KAAG,YAAY,SAAS,EAAE;4BAC5B,MAAM,IAAI,iBAAiB,EAAE,CAAA;yBAC9B;wBAED,IAAI,KAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,KAAG,CAAC,QAAQ,CAAC,UAAU,KAAK,cAAc,EAAE;4BAC7E,MAAM,IAAI,uBAAuB,EAAE,CAAA;yBACpC;wBAED,MAAM,IAAI,qBAAqB,CAAC,KAAG,CAAC,CAAA;;;;;KAEvC,CAAA;IAED,IAAM,mBAAmB,GAAG,UAAC,IAAiB,EAAE,OAA4B;QAC1E,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;SAC3B;QACD,OAAO,OAAO,CAAC,eAAe,IAAI,eAAe,CAAA;IACnD,CAAC,CAAA;IAED,OAAO;QACL,UAAU,YAAA;QACV,UAAU,YAAA;QACV,aAAa,eAAA;QACb,aAAa,eAAA;QACb,iBAAiB,mBAAA;QACjB,iBAAiB,mBAAA;QACjB,mBAAmB,qBAAA;QACnB,mBAAmB,qBAAA;QACnB,gBAAgB,kBAAA;QAChB,gBAAgB,kBAAA;QAChB,kBAAkB,oBAAA;QAClB,kBAAkB,oBAAA;QAClB,OAAO,SAAA;KACR,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../../node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../../node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../teleport-types/dist/cjs/uidl.d.ts","../../../teleport-types/dist/cjs/generators.d.ts","../../../teleport-types/dist/cjs/errors.d.ts","../../../teleport-types/dist/cjs/vuidl.d.ts","../../../teleport-types/dist/cjs/index.d.ts","../../../teleport-github-gateway/dist/cjs/github-instance.d.ts","../../../teleport-github-gateway/dist/cjs/types.d.ts","../../../teleport-github-gateway/dist/cjs/index.d.ts","../../src/types.ts","../../src/utils.ts","../../src/index.ts","../../../../node_modules/@types/node/assert/strict.d.ts","../../../../node_modules/@types/node/globals.d.ts","../../../../node_modules/@types/node/async_hooks.d.ts","../../../../node_modules/@types/node/buffer.d.ts","../../../../node_modules/@types/node/child_process.d.ts","../../../../node_modules/@types/node/cluster.d.ts","../../../../node_modules/@types/node/console.d.ts","../../../../node_modules/@types/node/constants.d.ts","../../../../node_modules/@types/node/crypto.d.ts","../../../../node_modules/@types/node/dgram.d.ts","../../../../node_modules/@types/node/diagnostic_channel.d.ts","../../../../node_modules/@types/node/dns.d.ts","../../../../node_modules/@types/node/dns/promises.d.ts","../../../../node_modules/@types/node/domain.d.ts","../../../../node_modules/@types/node/events.d.ts","../../../../node_modules/@types/node/fs.d.ts","../../../../node_modules/@types/node/fs/promises.d.ts","../../../../node_modules/@types/node/http.d.ts","../../../../node_modules/@types/node/http2.d.ts","../../../../node_modules/@types/node/https.d.ts","../../../../node_modules/@types/node/inspector.d.ts","../../../../node_modules/@types/node/module.d.ts","../../../../node_modules/@types/node/net.d.ts","../../../../node_modules/@types/node/os.d.ts","../../../../node_modules/@types/node/path.d.ts","../../../../node_modules/@types/node/perf_hooks.d.ts","../../../../node_modules/@types/node/process.d.ts","../../../../node_modules/@types/node/punycode.d.ts","../../../../node_modules/@types/node/querystring.d.ts","../../../../node_modules/@types/node/readline.d.ts","../../../../node_modules/@types/node/repl.d.ts","../../../../node_modules/@types/node/stream.d.ts","../../../../node_modules/@types/node/stream/promises.d.ts","../../../../node_modules/@types/node/string_decoder.d.ts","../../../../node_modules/@types/node/timers.d.ts","../../../../node_modules/@types/node/timers/promises.d.ts","../../../../node_modules/@types/node/tls.d.ts","../../../../node_modules/@types/node/trace_events.d.ts","../../../../node_modules/@types/node/tty.d.ts","../../../../node_modules/@types/node/url.d.ts","../../../../node_modules/@types/node/util.d.ts","../../../../node_modules/@types/node/util/types.d.ts","../../../../node_modules/@types/node/v8.d.ts","../../../../node_modules/@types/node/vm.d.ts","../../../../node_modules/@types/node/worker_threads.d.ts","../../../../node_modules/@types/node/zlib.d.ts","../../../../node_modules/@types/node/globals.global.d.ts","../../../../node_modules/@types/node/wasi.d.ts","../../../../node_modules/@types/node/ts3.6/base.d.ts","../../../../node_modules/@types/node/assert.d.ts","../../../../node_modules/@types/node/base.d.ts","../../../../node_modules/@types/node/index.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/diffLines.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/printDiffs.d.ts","../../../../node_modules/@types/jest/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/types.d.ts","../../../../node_modules/@types/jest/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/@types/jest/index.d.ts","../../../../node_modules/@types/jest/ts3.2/index.d.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"d1e076bd03d792a96993f458172927e0c5ac3cb8e1b566f54f925e6ef19bbebb","6a55786dc1b8e3c25bc00e1700a7eb297e20bccae7d4bb5e4a020b97daa2052f","eccf9c0b6e420c47b3e3eb87e8f0dc9df312a9583a6cce96756b18ebff176b70","75ecadee387dde7be130c85ed277fdfcee3923e452260ffaf217ebaefe7bd305","cd619820771edb23926bb084906215ab9c491255fa707488d15748b38909b747","c9318c4bb0f990c71d6add7e96f8a008f8d3d488cdca280483f772acaf595e99","17b0082643c87ac8ccdcac7261e2fc1d60302f138d5f39d49c393d2548c16119","fec98ff7f14f76cd4616a6a1c8c467362c4235fcd6c5fd386f01bb642ac628c5","3a393a3a2d6215087e4fbc4a4384056d8734322bd99167349ae6e1c8a8a7ebbf","14c9360771841b3aecaea0fe7e1f2df1a960c2f73f846649fa7b03df434c8bb0","8798f331b6fb63250dfc15ca87e46fca18f9b910a2ab89f1fe99589b2f54fc73","c7bdc99177a2a94d25fb13722adaaf5b3291bf70b4d1b27584ba189dd3889ba3",{"version":"d1c92b66c4105659fcad4eb76a1481f7311033e117d0678a1ec545e8ddb8d4c6","affectsGlobalScope":true},"e23424b97418eca3226fd24de079f1203eb70360622e4e093af2aff14d4be6ec","dee93c07b4df5e26010dc9ec4cdf4d6e4076bb4474d2a8371529217c8b2740a4","d55bc773f71c50f55decb39b64a5d8b9889a7c9e94305b36656ebf30e4f47469","04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef",{"version":"c8155caf28fc7b0a564156a5df28ad8a844a3bd32d331d148d8f3ce88025c870","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","dfc747ab8dd5f623055a4c26fd35e8cceca869fd3f1cf09701c941ca3679665a","c9f5f2920ff61d7158417b8440d5181ddc34a3dfef811a5677dd8a9fb91471e9","5cc0a492da3602510b8f5ed1852b1e0390002780d8758fbc8c0cd023ca7085f8","ec7dafafe751a5121f8f1c80201ebe7e7238c47e6329280a73c4d1ca4bb7fa28","64debeb10e4b7ae4ec9e89bfb4e04c6101ab98c3cc806d14e5488607cfec2753",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"a5782d6cea81fe43d2db7ed41e789458c933ab3ab60602f7b5b14c4da3370496","affectsGlobalScope":true},"b86b7ff709a82ef3cba2184136c025989958bad483ffb13e4ca35d720245adf4","6194335ee3353f7226ba31f31d6301d0c6be87228419c0a08976ccd9d4f1213e","5a173b7da4e6d073f9c18a02f387816a934614e7af306193995935fbb95f10b8","b447e123210c68f205f67b20c996c04a1eb64b0e591c5e06e164cd3d3a869b28","13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452","42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","c55776aa1db2b963a5fb820c0650362e721cba51ebf83b069696f2501378c0f3","e2236264a811ed1d09a2487a433e8f5216ae62378cf233954ae220cf886f6717","3ec1e108d587a5661ec790db607f482605ba9f3830e118ce578e3ffa3c42e22b","100b3bb9d39d2b1b5340f1bf45a52e94ef1692b45232b4ba00fac5c3cc56d331",{"version":"ec1a29ddaecb683aa360df0bd98ab5d4171d2d549554f7c5ab2a5c183a3dcb67","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58","2597718d91e306949d89e285bf34c44192014ef541c3bd7cbb825c022749e974","a6b0abdb67d63ebe964ba5fee31bc3daf10c12eecd46b24d778426010c04c67e","ac4801ebc2355ba32329070123b1cd15891bf71b41dcaf9e75b4744832126a59","fd2298fba0640e7295e7bd545e2dfbfcccbb00c27019e501c87965a02bbdebf6","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","71ddd49185b68f27bfac127ef5d22cb2672c278e53e5370d9020ef50ca9c377d","b1ea7a6eaa7608e0e0529aebd323b526a79c6c05a4e519ae5c779675004dcdf1","9fcb033a6208485d8f3fadde31eb5cbcaf99149cff3e40c0dc53ebc6d0dff4e9","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9","f4149f1aa299474c7040a35fe8f8ac2ad078cc1b190415adc1fff3ed52d490ea","3730099ed008776216268a97771de31753ef71e0a7d0ec650f588cba2a06ce44","8d649dbc429d7139a1d9a14ea2bf8af1dc089e0a879447539587463d4b6c248c","60c9e27816ec8ac8df7240598bb086e95b47edfb454c5cbf4003c812e0ed6e39","e361aecf17fc4034b4c122a1564471cdcd22ef3a51407803cb5a5fc020c04d02","4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"fc0ae4a8ad3c762b96f9d2c3700cb879a373458cb0bf3175478e3b4f85f7ef2f","fabbec378e1ddd86fcf2662e716c2b8318acedb664ee3a4cba6f9e8ee8269cf1","b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","efd55e8ca79171bf26c0d0e30221cb8ee1f5a31dd0c791ec4b2e886f42bab124","e222104af6cb9415238ad358488b74d76eceeff238c1268ec6e85655b05341da","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","eba230221317c985ab1953ccc3edc517f248b37db4fef7875cb2c8d08aff7be7","b83e796810e475da3564c6515bc0ae9577070596a33d89299b7d99f94ecfd921","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"f624e578325b8c58e55b30c998b1f4c3ec1b61a9fa66373da4250c89b7880d44","affectsGlobalScope":true},{"version":"d3002f620eab4bf6476c9da5c0efb2041d46f7df8b3032a5631bd206abef2c75","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":99,"noImplicitAny":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","sourceMap":true,"target":1},"fileIdsList":[[96,98],[92,93],[92,93,94,95],[97],[99],[89],[88,89],[43,48],[54,55,62,71],[44,54,62],[80],[48,55,63],[71,76],[51,54,62],[52],[51],[54],[54,56,71,79],[54,55,71],[62,71,79],[54,55,57,62,71,76,79],[57,76,79],[90],[79],[51,54,71],[64],[42],[78],[69,80,83],[54,72],[71],[74],[48,62],[40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87],[62],[68],[81],[43,48,54,56,65,71,79,83],[33,35],[35],[33,34],[33,37,38],[33,36],[33,36,37],[29],[29,30,31,32]],"referencedMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[34,39],[36,40],[35,41],[39,42],[37,43],[38,44],[30,45],[33,46],[32,45]],"exportedModulesMap":[[99,1],[94,2],[96,3],[95,2],[98,4],[100,5],[40,6],[90,7],[43,8],[44,9],[45,10],[46,11],[47,12],[48,13],[49,14],[51,15],[52,16],[53,17],[54,17],[55,18],[56,19],[57,20],[58,21],[59,22],[91,23],[60,17],[61,24],[62,25],[64,26],[65,27],[66,28],[69,17],[70,29],[71,30],[72,31],[74,17],[75,32],[76,33],[88,34],[78,35],[79,36],[80,37],[82,31],[84,38],[85,31],[34,39],[36,40],[35,41],[39,42],[37,43],[38,44],[30,45],[33,46],[32,45]],"semanticDiagnosticsPerFile":[99,92,94,96,95,93,98,97,100,89,40,42,90,43,44,45,46,47,48,49,50,51,52,53,54,55,56,41,86,57,58,59,91,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,88,78,79,80,81,82,83,87,84,85,6,8,7,2,9,10,11,12,13,14,15,16,3,4,20,17,18,19,21,22,23,5,24,25,26,27,1,28,34,36,35,39,37,38,31,30,33,29,32]},"version":"4.3.5"}
@@ -0,0 +1,36 @@
1
+ import { ServiceAuth, PublisherFactoryParams, Publisher, GeneratedFolder } from '@teleporthq/teleport-types';
2
+ import { GithubFile } from '@teleporthq/teleport-github-gateway';
3
+ export interface GithubFactoryParams extends PublisherFactoryParams {
4
+ authMeta?: ServiceAuth;
5
+ repositoryOwner?: string;
6
+ repository?: string;
7
+ mainBranch?: string;
8
+ commitBranch?: string;
9
+ commitMessage?: string;
10
+ }
11
+ export interface GithubPublisher extends Publisher<GithubFactoryParams, string> {
12
+ getRepository: () => string;
13
+ setRepository: (repo: string) => void;
14
+ getMainBranchName: () => string;
15
+ setMainBranchName: (branch: string) => void;
16
+ getCommitBranchName: () => string;
17
+ setCommitBranchName: (branch: string) => void;
18
+ getCommitMessage: () => string;
19
+ setCommitMessage: (message: string) => void;
20
+ getRepositoryOwner: () => string;
21
+ setRepositoryOwner: (owner: string) => void;
22
+ }
23
+ export interface GithubPublishMeta {
24
+ authMeta: ServiceAuth;
25
+ repository: string;
26
+ repositoryOwner: string;
27
+ mainBranch?: string;
28
+ commitBranch?: string;
29
+ commitMessage?: string;
30
+ }
31
+ export interface ProjectFolderInfo {
32
+ folder: GeneratedFolder;
33
+ prefix?: string;
34
+ files?: GithubFile[];
35
+ ignoreFolder?: boolean;
36
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { GithubFile } from '@teleporthq/teleport-github-gateway';
2
+ import { GithubPublishMeta, ProjectFolderInfo } from './types';
3
+ export declare const generateProjectFiles: (folderInfo: ProjectFolderInfo) => GithubFile[];
4
+ export declare const publishToGithub: (files: GithubFile[], meta: GithubPublishMeta) => Promise<string>;
@@ -0,0 +1,83 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { createGithubGateway, } from '@teleporthq/teleport-github-gateway';
38
+ export var generateProjectFiles = function (folderInfo) {
39
+ var folder = folderInfo.folder, _a = folderInfo.prefix, prefix = _a === void 0 ? '' : _a, _b = folderInfo.files, files = _b === void 0 ? [] : _b, _c = folderInfo.ignoreFolder, ignoreFolder = _c === void 0 ? false : _c;
40
+ var folderToPutFileTo = ignoreFolder ? '' : "" + prefix + folder.name + "/";
41
+ folder.files.forEach(function (file) {
42
+ var fileName = file.fileType
43
+ ? "" + folderToPutFileTo + file.name + "." + file.fileType
44
+ : "" + folderToPutFileTo + file.name;
45
+ var githubFile = {
46
+ name: fileName,
47
+ content: file.content,
48
+ };
49
+ if (file.contentEncoding) {
50
+ githubFile.encoding = file.contentEncoding;
51
+ }
52
+ files.push(githubFile);
53
+ });
54
+ folder.subFolders.forEach(function (subfolder) {
55
+ var subfolderInfo = {
56
+ files: files,
57
+ folder: subfolder,
58
+ prefix: folderToPutFileTo,
59
+ };
60
+ generateProjectFiles(subfolderInfo);
61
+ });
62
+ return files;
63
+ };
64
+ export var publishToGithub = function (files, meta) { return __awaiter(void 0, void 0, void 0, function () {
65
+ var authMeta, mainBranch, commitBranch, commitMessage, repository, repositoryOwner, repositoryIdentity, gitCommitMeta, githubGateway;
66
+ return __generator(this, function (_a) {
67
+ authMeta = meta.authMeta, mainBranch = meta.mainBranch, commitBranch = meta.commitBranch, commitMessage = meta.commitMessage, repository = meta.repository, repositoryOwner = meta.repositoryOwner;
68
+ repositoryIdentity = {
69
+ username: repositoryOwner,
70
+ repo: repository,
71
+ ref: mainBranch,
72
+ };
73
+ gitCommitMeta = {
74
+ repositoryIdentity: repositoryIdentity,
75
+ files: files,
76
+ branchName: commitBranch,
77
+ commitMessage: commitMessage,
78
+ };
79
+ githubGateway = createGithubGateway(authMeta);
80
+ return [2 /*return*/, githubGateway.commitFilesToRepo(gitCommitMeta)];
81
+ });
82
+ }); };
83
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EACL,mBAAmB,GAIpB,MAAM,qCAAqC,CAAA;AAI5C,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAAC,UAA6B;IACxD,IAAA,MAAM,GAAoD,UAAU,OAA9D,EAAE,KAAkD,UAAU,OAAjD,EAAX,MAAM,mBAAG,EAAE,KAAA,EAAE,KAAqC,UAAU,MAArC,EAAV,KAAK,mBAAG,EAAE,KAAA,EAAE,KAAyB,UAAU,aAAf,EAApB,YAAY,mBAAG,KAAK,KAAA,CAAe;IAC5E,IAAM,iBAAiB,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAG,MAAM,GAAG,MAAM,CAAC,IAAI,MAAG,CAAA;IAExE,MAAM,CAAC,KAAK,CAAC,OAAO,CAA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AG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;QACnD,sBAAO,aAAa,CAAC,iBAAiB,CAAC,aAAa,CAAC,EAAA;;KACtD,CAAA"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@teleporthq/teleport-publisher-github",
3
+ "version": "0.18.0",
4
+ "description": "Project github publisher",
5
+ "author": "teleportHQ",
6
+ "license": "MIT",
7
+ "homepage": "https://teleporthq.io/",
8
+ "main": "dist/cjs/index.js",
9
+ "module": "dist/esm/index.js",
10
+ "types": "dist/cjs/index.d.ts",
11
+ "sideEffects": false,
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+ssh://git@github.com/teleporthq/teleport-code-generators.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/teleporthq/teleport-code-generators/issues"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "clean": "rimraf dist",
24
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.json --module commonjs --outDir dist/cjs"
25
+ },
26
+ "dependencies": {
27
+ "@teleporthq/teleport-github-gateway": "^0.18.0",
28
+ "@teleporthq/teleport-types": "^0.18.0"
29
+ },
30
+ "gitHead": "7b47f013bf1889e19b31875a8f3abdc43b22615a"
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,125 @@
1
+ import {
2
+ GeneratedFolder,
3
+ PublisherFactory,
4
+ ServiceAuth,
5
+ MissingProjectUIDLError,
6
+ GithubMissingAuthError,
7
+ GithubMissingRepoError,
8
+ GithubInvalidTokenError,
9
+ GithubUnexpectedError,
10
+ GithubServerError,
11
+ } from '@teleporthq/teleport-types'
12
+
13
+ import { publishToGithub, generateProjectFiles } from './utils'
14
+ import { GithubFactoryParams, GithubPublisher, GithubPublishMeta } from './types'
15
+
16
+ export const createGithubPublisher: PublisherFactory<GithubFactoryParams, GithubPublisher> = (
17
+ params: GithubFactoryParams = {}
18
+ ): GithubPublisher => {
19
+ const { authMeta } = params
20
+ let { project, repository, repositoryOwner, mainBranch, commitBranch, commitMessage } = params
21
+
22
+ const getProject = () => project
23
+ const setProject = (projectToSet: GeneratedFolder) => {
24
+ project = projectToSet
25
+ }
26
+
27
+ const getRepository = () => repository
28
+ const setRepository = (repo: string) => {
29
+ repository = repo
30
+ }
31
+
32
+ const getMainBranchName = () => mainBranch
33
+ const setMainBranchName = (branch: string) => {
34
+ mainBranch = branch
35
+ }
36
+
37
+ const getCommitBranchName = () => commitBranch
38
+ const setCommitBranchName = (branch: string) => {
39
+ commitBranch = branch
40
+ }
41
+
42
+ const getCommitMessage = () => commitMessage
43
+ const setCommitMessage = (message: string) => {
44
+ commitMessage = message
45
+ }
46
+
47
+ const getRepositoryOwner = () => repositoryOwner
48
+ const setRepositoryOwner = (owner: string) => {
49
+ repositoryOwner = owner
50
+ }
51
+
52
+ const publish = async (options: GithubFactoryParams = {}) => {
53
+ const projectToPublish = options.project || project
54
+ if (!projectToPublish) {
55
+ throw new MissingProjectUIDLError()
56
+ }
57
+
58
+ const auth = options.authMeta || authMeta
59
+ if (!auth) {
60
+ throw new GithubMissingAuthError()
61
+ }
62
+
63
+ const repo = options.repository || repository
64
+ if (!repo) {
65
+ throw new GithubMissingRepoError()
66
+ }
67
+
68
+ const repoOwner = findRepositoryOwner(auth, options)
69
+
70
+ const mainBranchName = options.mainBranch || mainBranch
71
+ const main = mainBranchName ? mainBranch : 'main'
72
+ const commitBranchName = options.commitBranch || commitBranch
73
+ const commitMsg = options.commitMessage || commitMessage
74
+
75
+ const githubPublishMeta: GithubPublishMeta = {
76
+ authMeta: auth,
77
+ mainBranch: main,
78
+ commitBranch: commitBranchName ? commitBranchName : main,
79
+ commitMessage: commitMsg,
80
+ repository: repo,
81
+ repositoryOwner: repoOwner,
82
+ }
83
+
84
+ const projectFiles = generateProjectFiles({ folder: projectToPublish, ignoreFolder: true })
85
+
86
+ try {
87
+ const result = await publishToGithub(projectFiles, githubPublishMeta)
88
+ return { success: true, payload: result }
89
+ } catch (err) {
90
+ // A bit hacky here, the github library we are using is failing with a TypeError when the service is down
91
+ if (err instanceof TypeError) {
92
+ throw new GithubServerError()
93
+ }
94
+
95
+ if (err.response.status === 401 && err.response.statusText === 'Unauthorized') {
96
+ throw new GithubInvalidTokenError()
97
+ }
98
+
99
+ throw new GithubUnexpectedError(err)
100
+ }
101
+ }
102
+
103
+ const findRepositoryOwner = (auth: ServiceAuth, options: GithubFactoryParams): string => {
104
+ if (auth && auth.basic && auth.basic.username) {
105
+ return auth.basic.username
106
+ }
107
+ return options.repositoryOwner || repositoryOwner
108
+ }
109
+
110
+ return {
111
+ getProject,
112
+ setProject,
113
+ getRepository,
114
+ setRepository,
115
+ getMainBranchName,
116
+ setMainBranchName,
117
+ getCommitBranchName,
118
+ setCommitBranchName,
119
+ getCommitMessage,
120
+ setCommitMessage,
121
+ getRepositoryOwner,
122
+ setRepositoryOwner,
123
+ publish,
124
+ }
125
+ }
package/src/types.ts ADDED
@@ -0,0 +1,45 @@
1
+ import {
2
+ ServiceAuth,
3
+ PublisherFactoryParams,
4
+ Publisher,
5
+ GeneratedFolder,
6
+ } from '@teleporthq/teleport-types'
7
+ import { GithubFile } from '@teleporthq/teleport-github-gateway'
8
+
9
+ export interface GithubFactoryParams extends PublisherFactoryParams {
10
+ authMeta?: ServiceAuth
11
+ repositoryOwner?: string
12
+ repository?: string
13
+ mainBranch?: string
14
+ commitBranch?: string
15
+ commitMessage?: string
16
+ }
17
+
18
+ export interface GithubPublisher extends Publisher<GithubFactoryParams, string> {
19
+ getRepository: () => string
20
+ setRepository: (repo: string) => void
21
+ getMainBranchName: () => string
22
+ setMainBranchName: (branch: string) => void
23
+ getCommitBranchName: () => string
24
+ setCommitBranchName: (branch: string) => void
25
+ getCommitMessage: () => string
26
+ setCommitMessage: (message: string) => void
27
+ getRepositoryOwner: () => string
28
+ setRepositoryOwner: (owner: string) => void
29
+ }
30
+
31
+ export interface GithubPublishMeta {
32
+ authMeta: ServiceAuth
33
+ repository: string
34
+ repositoryOwner: string
35
+ mainBranch?: string
36
+ commitBranch?: string
37
+ commitMessage?: string
38
+ }
39
+
40
+ export interface ProjectFolderInfo {
41
+ folder: GeneratedFolder
42
+ prefix?: string
43
+ files?: GithubFile[]
44
+ ignoreFolder?: boolean
45
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { GeneratedFolder, GeneratedFile } from '@teleporthq/teleport-types'
2
+ import {
3
+ createGithubGateway,
4
+ GithubFile,
5
+ RepositoryIdentity,
6
+ GithubCommitMeta,
7
+ } from '@teleporthq/teleport-github-gateway'
8
+
9
+ import { GithubPublishMeta, ProjectFolderInfo } from './types'
10
+
11
+ export const generateProjectFiles = (folderInfo: ProjectFolderInfo): GithubFile[] => {
12
+ const { folder, prefix = '', files = [], ignoreFolder = false } = folderInfo
13
+ const folderToPutFileTo = ignoreFolder ? '' : `${prefix}${folder.name}/`
14
+
15
+ folder.files.forEach((file: GeneratedFile) => {
16
+ const fileName = file.fileType
17
+ ? `${folderToPutFileTo}${file.name}.${file.fileType}`
18
+ : `${folderToPutFileTo}${file.name}`
19
+
20
+ const githubFile: GithubFile = {
21
+ name: fileName,
22
+ content: file.content,
23
+ }
24
+
25
+ if (file.contentEncoding) {
26
+ githubFile.encoding = file.contentEncoding
27
+ }
28
+
29
+ files.push(githubFile)
30
+ })
31
+
32
+ folder.subFolders.forEach((subfolder: GeneratedFolder) => {
33
+ const subfolderInfo = {
34
+ files,
35
+ folder: subfolder,
36
+ prefix: folderToPutFileTo,
37
+ }
38
+ generateProjectFiles(subfolderInfo)
39
+ })
40
+
41
+ return files
42
+ }
43
+
44
+ export const publishToGithub = async (files: GithubFile[], meta: GithubPublishMeta) => {
45
+ const { authMeta, mainBranch, commitBranch, commitMessage, repository, repositoryOwner } = meta
46
+
47
+ const repositoryIdentity: RepositoryIdentity = {
48
+ username: repositoryOwner,
49
+ repo: repository,
50
+ ref: mainBranch,
51
+ }
52
+
53
+ const gitCommitMeta: GithubCommitMeta = {
54
+ repositoryIdentity,
55
+ files,
56
+ branchName: commitBranch,
57
+ commitMessage,
58
+ }
59
+
60
+ const githubGateway = createGithubGateway(authMeta)
61
+ return githubGateway.commitFilesToRepo(gitCommitMeta)
62
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist/esm"
5
+ },
6
+ "include": [
7
+ "./src"
8
+ ]
9
+ }