ppackage 2.2.1 → 2.3.1
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/bin/askpass +11 -0
- package/bin/ddev +1 -0
- package/index.js +75 -0
- package/package.json +12 -4
- package/.npmignore +0 -7
package/bin/askpass
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/node
|
|
2
|
+
|
|
3
|
+
let response, [,, what] = process.argv;
|
|
4
|
+
if(/Username/.test(what))
|
|
5
|
+
response = process.env.GIT_USER_LOGIN;
|
|
6
|
+
if(/Password/.test(what))
|
|
7
|
+
response = process.env.GIT_USER_PASSWORD;
|
|
8
|
+
if(!response)
|
|
9
|
+
process.exit(1);
|
|
10
|
+
process.stdout.write(response);
|
|
11
|
+
|
package/bin/ddev
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cnyks ddev --ir://run=$*
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
const semver = require('semver');
|
|
5
6
|
const {spawn} = require('child_process');
|
|
6
7
|
|
|
@@ -12,6 +13,15 @@ const Dockerfile = require('./lib/dockerfile');
|
|
|
12
13
|
const {Parser, Composer} = require('yaml');
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
|
|
17
|
+
const GIT_FOLDER = ".git";
|
|
18
|
+
const NPM_PACKAGE_PATH = 'package.json';
|
|
19
|
+
const DOCKERIGNORE_PATH = ".dockerignore";
|
|
20
|
+
const NPMIGNORE_PATH = ".npmignore";
|
|
21
|
+
const GITIGNORE_PATH = ".gitignore";
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
15
25
|
const laxParser = function(body) {
|
|
16
26
|
const tokens = new Parser().parse(body);
|
|
17
27
|
const docs = new Composer({merge : true, uniqueKeys : false}).compose(tokens);
|
|
@@ -137,6 +147,71 @@ class ppackage {
|
|
|
137
147
|
return target_version;
|
|
138
148
|
}
|
|
139
149
|
|
|
150
|
+
|
|
151
|
+
async gitify() {
|
|
152
|
+
|
|
153
|
+
if(fs.existsSync(GIT_FOLDER))
|
|
154
|
+
throw `Cowardly aborting working with existing git project`;
|
|
155
|
+
|
|
156
|
+
await passthru("git", ["config", "--global", "core.askPass", path.join(__dirname, "bin/askpass")]);
|
|
157
|
+
let {repository_url} = await this._find_repo();
|
|
158
|
+
|
|
159
|
+
let cloneargs = ["clone", "--bare", repository_url, GIT_FOLDER];
|
|
160
|
+
await passthru("git", cloneargs);
|
|
161
|
+
|
|
162
|
+
await passthru("git", ["config", "--unset", "core.bare"]);
|
|
163
|
+
await passthru("git", ["reset", "HEAD", "--", "."]);
|
|
164
|
+
|
|
165
|
+
for(let line of [GITIGNORE_PATH, DOCKERIGNORE_PATH, NPMIGNORE_PATH])
|
|
166
|
+
await passthru("git", ["restore", line]).catch(()=>{});
|
|
167
|
+
|
|
168
|
+
let restore = [];
|
|
169
|
+
if(fs.existsSync(DOCKERIGNORE_PATH)) {
|
|
170
|
+
let ignore = fs.readFileSync(DOCKERIGNORE_PATH, 'utf8');
|
|
171
|
+
restore.push(...ignore.split("\n"));
|
|
172
|
+
}
|
|
173
|
+
if(fs.existsSync(NPMIGNORE_PATH)) {
|
|
174
|
+
let ignore = fs.readFileSync(NPMIGNORE_PATH, 'utf8');
|
|
175
|
+
restore.push(...ignore.split("\n"));
|
|
176
|
+
}
|
|
177
|
+
restore = restore.map(v => v.trim()).filter(v => v && v[0] != "#");
|
|
178
|
+
|
|
179
|
+
for(let line of restore)
|
|
180
|
+
await passthru("git", ["restore", line]).catch(()=>{});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
// git config --global url."https://git.ivsdev.net/".insteadOf "git@git.ivsdev.net:"
|
|
185
|
+
// yet, this is broader
|
|
186
|
+
|
|
187
|
+
static _git_to_https(repository_url) {
|
|
188
|
+
|
|
189
|
+
const SSH_MASK = new RegExp("^git@([^:]+):(.*)");
|
|
190
|
+
if(SSH_MASK.test(repository_url))
|
|
191
|
+
return repository_url.replace(SSH_MASK, "https://$1/$2");
|
|
192
|
+
|
|
193
|
+
// git+ssh://git@github.com/131/ppackage.git
|
|
194
|
+
const GIT_SSH_MASK = new RegExp("^git\\+ssh://git@([^/]+)/(.*)");
|
|
195
|
+
if(GIT_SSH_MASK.test(repository_url))
|
|
196
|
+
return repository_url.replace(GIT_SSH_MASK, "https://$1/$2");
|
|
197
|
+
|
|
198
|
+
return repository_url;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async _find_repo() {
|
|
202
|
+
let repository_url;
|
|
203
|
+
|
|
204
|
+
if(fs.existsSync(NPM_PACKAGE_PATH)) {
|
|
205
|
+
let body = JSON.parse(fs.readFileSync(NPM_PACKAGE_PATH));
|
|
206
|
+
if(body.repository && body.repository.type == "git")
|
|
207
|
+
repository_url = body.repository.url;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
repository_url = ppackage._git_to_https(repository_url);
|
|
211
|
+
return {repository_url};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
140
215
|
}
|
|
141
216
|
|
|
142
217
|
|
package/package.json
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ppackage",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"ppackage": "./bin/ppackage"
|
|
7
|
+
"ppackage": "./bin/ppackage",
|
|
8
|
+
"ddev": "./bin/ddev",
|
|
9
|
+
"askpass": "./bin/askpass"
|
|
8
10
|
},
|
|
9
11
|
"dependencies": {
|
|
12
|
+
"cnyks": "^3.1.3",
|
|
10
13
|
"mout": "^1.0.0",
|
|
11
14
|
"nyks": "^6.1.8",
|
|
12
15
|
"semver": "^5.3.0",
|
|
13
16
|
"yaml": "^2.4.2"
|
|
14
17
|
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git@github.com:131/ppackage.git"
|
|
21
|
+
},
|
|
15
22
|
"devDependencies": {
|
|
16
23
|
"eslint": "^8.57.0",
|
|
17
|
-
"eslint-plugin-ivs": "^4.0.
|
|
24
|
+
"eslint-plugin-ivs": "^4.0.1",
|
|
18
25
|
"expect.js": "^0.3.1",
|
|
19
26
|
"mocha": "^3.1.2",
|
|
20
27
|
"nyc": "^15.0.1"
|
|
21
28
|
},
|
|
22
29
|
"scripts": {
|
|
23
|
-
"eslint": "eslint ."
|
|
30
|
+
"eslint": "eslint .",
|
|
31
|
+
"mocha": "node node_modules/mocha/bin/_mocha -b"
|
|
24
32
|
},
|
|
25
33
|
"author": "",
|
|
26
34
|
"license": "ISC"
|