UNPKG

2.33 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright © 2020 Atomist, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18const project_1 = require("./project/project");
19function gitHubComRepository(details) {
20 return Object.assign(Object.assign({}, details), { type: RepositoryProviderType.GitHubCom, cloneUrl: () => {
21 if (details.credential) {
22 // GitHub App tokens start with v1. and are expected in the password field
23 if (details.credential.token.startsWith("v1.")) {
24 return `https://atomist:${details.credential.token}@github.com/${details.owner}/${details.repo}.git`;
25 }
26 else {
27 return `https://${details.credential.token}:x-oauth-basic@github.com/${details.owner}/${details.repo}.git`;
28 }
29 }
30 else {
31 return `https://github.com/${details.owner}/${details.repo}.git`;
32 }
33 } });
34}
35exports.gitHubComRepository = gitHubComRepository;
36var RepositoryProviderType;
37(function (RepositoryProviderType) {
38 RepositoryProviderType[RepositoryProviderType["GitHubCom"] = 0] = "GitHubCom";
39 RepositoryProviderType[RepositoryProviderType["GitHubEnterprise"] = 1] = "GitHubEnterprise";
40})(RepositoryProviderType = exports.RepositoryProviderType || (exports.RepositoryProviderType = {}));
41function createProjectLoader() {
42 return new DefaultProjectLoader();
43}
44exports.createProjectLoader = createProjectLoader;
45class DefaultProjectLoader {
46 async load(id, baseDir) {
47 return project_1.load(id, baseDir);
48 }
49 async clone(id, options) {
50 return project_1.clone(id, options);
51 }
52}
53exports.DefaultProjectLoader = DefaultProjectLoader;
54//# sourceMappingURL=project.js.map
\No newline at end of file