1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.setIonicRemote = exports.addIonicRemote = exports.getIonicRemote = exports.initializeRepo = exports.isRepoInitialized = exports.getTopLevel = exports.isGitInstalled = void 0;
|
4 | const utils_fs_1 = require("@ionic/utils-fs");
|
5 | const path = require("path");
|
6 | async function isGitInstalled({ shell }) {
|
7 | return Boolean(await shell.cmdinfo('git', ['--version']));
|
8 | }
|
9 | exports.isGitInstalled = isGitInstalled;
|
10 | async function getTopLevel({ shell }) {
|
11 | return shell.cmdinfo('git', ['rev-parse', '--show-toplevel']);
|
12 | }
|
13 | exports.getTopLevel = getTopLevel;
|
14 | async function isRepoInitialized(dir) {
|
15 | return utils_fs_1.pathExists(path.join(dir, '.git'));
|
16 | }
|
17 | exports.isRepoInitialized = isRepoInitialized;
|
18 | async function initializeRepo({ shell }, dir) {
|
19 | await shell.run('git', ['init'], { cwd: dir });
|
20 | }
|
21 | exports.initializeRepo = initializeRepo;
|
22 | async function getIonicRemote({ shell }, dir) {
|
23 | const regex = /ionic\t(.+) \(\w+\)/;
|
24 |
|
25 | const remotes = await shell.output('git', ['remote', '-v'], { cwd: dir });
|
26 | for (const line of remotes.split('\n')) {
|
27 | const match = regex.exec(line.trim());
|
28 | if (match) {
|
29 | return match[1];
|
30 | }
|
31 | }
|
32 | }
|
33 | exports.getIonicRemote = getIonicRemote;
|
34 | async function addIonicRemote({ shell }, dir, url) {
|
35 | await shell.run('git', ['remote', 'add', 'ionic', url], { cwd: dir });
|
36 | }
|
37 | exports.addIonicRemote = addIonicRemote;
|
38 | async function setIonicRemote({ shell }, dir, url) {
|
39 | await shell.run('git', ['remote', 'set-url', 'ionic', url], { cwd: dir });
|
40 | }
|
41 | exports.setIonicRemote = setIonicRemote;
|