ppackage 2.3.4 → 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.
- package/index.js +11 -19
- package/lib/util.js +18 -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
|
|
|
@@ -19,6 +21,7 @@ const GIT_FOLDER = ".git";
|
|
|
19
21
|
const NPM_PACKAGE_PATH = 'package.json';
|
|
20
22
|
const DOCKERIGNORE_PATH = ".dockerignore";
|
|
21
23
|
const NPMIGNORE_PATH = ".npmignore";
|
|
24
|
+
const NPMRC_PATH = ".npmrc"; //default ignored by npm
|
|
22
25
|
const GITIGNORE_PATH = ".gitignore";
|
|
23
26
|
|
|
24
27
|
|
|
@@ -154,16 +157,16 @@ class ppackage {
|
|
|
154
157
|
if(fs.existsSync(GIT_FOLDER))
|
|
155
158
|
throw `Cowardly aborting working with existing git project`;
|
|
156
159
|
|
|
157
|
-
await passthru("git", ["config", "--global", "core.askPass", path.join(__dirname, "bin/askpass")]);
|
|
158
160
|
let {repository_url} = await this._find_repo();
|
|
159
161
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
|
|
163
|
+
let cloneopts = ["--bare", "--config", `core.askPass=${path.join(__dirname, "bin/askpass")}`];
|
|
164
|
+
await passthru("git", ["clone", ...cloneopts, repository_url, GIT_FOLDER]);
|
|
162
165
|
|
|
163
166
|
await passthru("git", ["config", "--unset", "core.bare"]);
|
|
164
167
|
await passthru("git", ["reset", "HEAD", "--", "."]);
|
|
165
168
|
|
|
166
|
-
for(let line of [GITIGNORE_PATH, DOCKERIGNORE_PATH, NPMIGNORE_PATH])
|
|
169
|
+
for(let line of [GITIGNORE_PATH, DOCKERIGNORE_PATH, NPMIGNORE_PATH, NPMRC_PATH])
|
|
167
170
|
await passthru("git", ["checkout", "--", line]).catch(()=>{});
|
|
168
171
|
|
|
169
172
|
let restore = [];
|
|
@@ -185,19 +188,6 @@ class ppackage {
|
|
|
185
188
|
// git config --global url."https://git.ivsdev.net/".insteadOf "git@git.ivsdev.net:"
|
|
186
189
|
// yet, this is broader
|
|
187
190
|
|
|
188
|
-
static _git_to_https(repository_url) {
|
|
189
|
-
|
|
190
|
-
const SSH_MASK = new RegExp("^git@([^:]+):(.*)");
|
|
191
|
-
if(SSH_MASK.test(repository_url))
|
|
192
|
-
return repository_url.replace(SSH_MASK, "https://$1/$2");
|
|
193
|
-
|
|
194
|
-
// git+ssh://git@github.com/131/ppackage.git
|
|
195
|
-
const GIT_SSH_MASK = new RegExp("^git\\+ssh://git@([^/]+)/(.*)");
|
|
196
|
-
if(GIT_SSH_MASK.test(repository_url))
|
|
197
|
-
return repository_url.replace(GIT_SSH_MASK, "https://$1/$2");
|
|
198
|
-
|
|
199
|
-
return repository_url;
|
|
200
|
-
}
|
|
201
191
|
|
|
202
192
|
async _find_repo() {
|
|
203
193
|
let repository_url;
|
|
@@ -208,7 +198,9 @@ class ppackage {
|
|
|
208
198
|
repository_url = body.repository.url;
|
|
209
199
|
}
|
|
210
200
|
|
|
211
|
-
|
|
201
|
+
if(!process.env.SSH_AUTH_SOCK)
|
|
202
|
+
repository_url = git_to_https(repository_url);
|
|
203
|
+
|
|
212
204
|
return {repository_url};
|
|
213
205
|
}
|
|
214
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
|
-
|
|
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
|
|