ppackage 2.3.5 → 2.3.7
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/index.js +7 -18
- package/lib/util.js +22 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,7 +10,9 @@ const passthru = require('nyks/child_process/passthru');
|
|
|
10
10
|
const wait = require('nyks/child_process/wait');
|
|
11
11
|
const trim = require('mout/string/trim');
|
|
12
12
|
|
|
13
|
-
const Dockerfile
|
|
13
|
+
const Dockerfile = require('./lib/dockerfile');
|
|
14
|
+
const {git_to_https} = require('./lib/util');
|
|
15
|
+
|
|
14
16
|
const {Parser, Composer} = require('yaml');
|
|
15
17
|
|
|
16
18
|
|
|
@@ -155,11 +157,11 @@ class ppackage {
|
|
|
155
157
|
if(fs.existsSync(GIT_FOLDER))
|
|
156
158
|
throw `Cowardly aborting working with existing git project`;
|
|
157
159
|
|
|
158
|
-
await passthru("git", ["config", "--global", "core.askPass", path.join(__dirname, "bin/askpass")]);
|
|
159
160
|
let {repository_url} = await this._find_repo();
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
|
|
163
|
+
let cloneopts = ["--bare", "--config", `core.askPass=${path.join(__dirname, "bin/askpass")}`];
|
|
164
|
+
await passthru("git", ["clone", ...cloneopts, repository_url, GIT_FOLDER]);
|
|
163
165
|
|
|
164
166
|
await passthru("git", ["config", "--unset", "core.bare"]);
|
|
165
167
|
await passthru("git", ["reset", "HEAD", "--", "."]);
|
|
@@ -186,19 +188,6 @@ class ppackage {
|
|
|
186
188
|
// git config --global url."https://git.ivsdev.net/".insteadOf "git@git.ivsdev.net:"
|
|
187
189
|
// yet, this is broader
|
|
188
190
|
|
|
189
|
-
static _git_to_https(repository_url) {
|
|
190
|
-
|
|
191
|
-
const SSH_MASK = new RegExp("^git@([^:]+):(.*)");
|
|
192
|
-
if(SSH_MASK.test(repository_url))
|
|
193
|
-
return repository_url.replace(SSH_MASK, "https://$1/$2");
|
|
194
|
-
|
|
195
|
-
// git+ssh://git@github.com/131/ppackage.git
|
|
196
|
-
const GIT_SSH_MASK = new RegExp("^git\\+ssh://git@([^/]+)/(.*)");
|
|
197
|
-
if(GIT_SSH_MASK.test(repository_url))
|
|
198
|
-
return repository_url.replace(GIT_SSH_MASK, "https://$1/$2");
|
|
199
|
-
|
|
200
|
-
return repository_url;
|
|
201
|
-
}
|
|
202
191
|
|
|
203
192
|
async _find_repo() {
|
|
204
193
|
let repository_url;
|
|
@@ -209,7 +198,7 @@ class ppackage {
|
|
|
209
198
|
repository_url = body.repository.url;
|
|
210
199
|
}
|
|
211
200
|
|
|
212
|
-
repository_url =
|
|
201
|
+
repository_url = git_to_https(repository_url);
|
|
213
202
|
return {repository_url};
|
|
214
203
|
}
|
|
215
204
|
|
package/lib/util.js
CHANGED
|
@@ -28,6 +28,27 @@ const tokenize = function(str) {
|
|
|
28
28
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
const git_to_https = function(repository_url) {
|
|
32
|
+
const GIT_PREFIX = new RegExp("^git\\+");
|
|
33
|
+
if(GIT_PREFIX.test(repository_url))
|
|
34
|
+
repository_url = repository_url.replace(GIT_PREFIX, "");
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
|
|
37
|
+
if(process.env.SSH_AUTH_SOCK)
|
|
38
|
+
return repository_url;
|
|
39
|
+
|
|
40
|
+
const SSH_MASK = new RegExp("^git@([^:]+):(.*)");
|
|
41
|
+
if(SSH_MASK.test(repository_url))
|
|
42
|
+
return repository_url.replace(SSH_MASK, "https://$1/$2");
|
|
43
|
+
|
|
44
|
+
// git+ssh://git@github.com/131/ppackage.git
|
|
45
|
+
const GIT_SSH_MASK = new RegExp("^ssh://git@([^/]+)/(.*)");
|
|
46
|
+
if(GIT_SSH_MASK.test(repository_url))
|
|
47
|
+
return repository_url.replace(GIT_SSH_MASK, "https://$1/$2");
|
|
48
|
+
|
|
49
|
+
return repository_url;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
module.exports = {tokenize, git_to_https};
|
|
33
54
|
|