ppackage 2.3.5 → 2.3.6

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.
Files changed (3) hide show
  1. package/index.js +9 -18
  2. package/lib/util.js +18 -1
  3. 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 = require('./lib/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
- let cloneargs = ["clone", "--bare", repository_url, GIT_FOLDER];
162
- await passthru("git", cloneargs);
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,9 @@ class ppackage {
209
198
  repository_url = body.repository.url;
210
199
  }
211
200
 
212
- repository_url = ppackage._git_to_https(repository_url);
201
+ if(!process.env.SSH_AUTH_SOCK)
202
+ repository_url = git_to_https(repository_url);
203
+
213
204
  return {repository_url};
214
205
  }
215
206
 
package/lib/util.js CHANGED
@@ -28,6 +28,23 @@ 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
- module.exports = {tokenize};
36
+ const SSH_MASK = new RegExp("^git@([^:]+):(.*)");
37
+ if(SSH_MASK.test(repository_url))
38
+ return repository_url.replace(SSH_MASK, "https://$1/$2");
39
+
40
+ // git+ssh://git@github.com/131/ppackage.git
41
+ const GIT_SSH_MASK = new RegExp("^ssh://git@([^/]+)/(.*)");
42
+ if(GIT_SSH_MASK.test(repository_url))
43
+ return repository_url.replace(GIT_SSH_MASK, "https://$1/$2");
44
+
45
+ return repository_url;
46
+ };
47
+
48
+
49
+ module.exports = {tokenize, git_to_https};
33
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ppackage",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {