@makano/rew 1.2.63 → 1.2.65
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/lib/rew/cli/utils.js +33 -13
- package/package.json +1 -1
package/lib/rew/cli/utils.js
CHANGED
|
@@ -263,12 +263,12 @@ module.exports = {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
if (c.install.file) {
|
|
267
|
-
this.runFileWithArgv(path.join(installPath, c.exec[c.install.file] || c.install.file), {}, []);
|
|
268
|
-
}
|
|
269
266
|
if (c.install.requirements) {
|
|
270
267
|
this.installReq(c, opts);
|
|
271
268
|
}
|
|
269
|
+
if (c.install.file) {
|
|
270
|
+
this.runFileWithArgv(path.join(installPath, c.exec[c.install.file] || c.install.file), {}, [installPath]);
|
|
271
|
+
}
|
|
272
272
|
if (c.install.exec) {
|
|
273
273
|
// this.installReq(c);
|
|
274
274
|
if(conf({}).create('').get('executables') == false){
|
|
@@ -405,20 +405,37 @@ module.exports = {
|
|
|
405
405
|
}
|
|
406
406
|
},
|
|
407
407
|
async cloneGit(gitpath, opts) {
|
|
408
|
-
|
|
408
|
+
let p = gitpath.split('github:')[1];
|
|
409
409
|
const clonePath = path.join(cachepath, 'rew-git-clone-'+gen_key(gitpath).substring(0, 12));
|
|
410
|
+
const load = loading("Finding Repo...".yellow).start();
|
|
411
|
+
|
|
412
|
+
let branch = null; // Default branch
|
|
413
|
+
let commit = null;
|
|
414
|
+
|
|
415
|
+
// Extracting branch or commit if specified
|
|
416
|
+
if (p.includes('@')) {
|
|
417
|
+
[p, branch] = p.split('@');
|
|
418
|
+
}
|
|
419
|
+
if (branch?.includes('#')) {
|
|
420
|
+
[branch, commit] = branch.split('#');
|
|
421
|
+
}
|
|
422
|
+
if (p.includes('#')) {
|
|
423
|
+
[p, commit] = p.split('#');
|
|
424
|
+
}
|
|
425
|
+
|
|
410
426
|
const url = `https://github.com/${p}`;
|
|
411
427
|
const apiurl = `https://api.github.com/repos/${p}/commits`;
|
|
412
|
-
|
|
428
|
+
|
|
413
429
|
try {
|
|
414
430
|
const response = await req(apiurl);
|
|
431
|
+
if(!commit) commit = response.data[0].sha;
|
|
415
432
|
if (response.status !== 200) {
|
|
416
433
|
load.stop();
|
|
417
434
|
return log(' Package not found in github'.red.bold, ':end');
|
|
418
435
|
}
|
|
419
436
|
let pull = false;
|
|
420
437
|
if(fs.existsSync(clonePath)){
|
|
421
|
-
if(fs.existsSync(path.join(clonePath,
|
|
438
|
+
if(fs.existsSync(path.join(clonePath, commit))){
|
|
422
439
|
load.stop();
|
|
423
440
|
log('Found Cache'.yellow);
|
|
424
441
|
return clonePath+'/clone';
|
|
@@ -427,20 +444,23 @@ module.exports = {
|
|
|
427
444
|
}
|
|
428
445
|
}
|
|
429
446
|
fs.mkdirSync(clonePath, { recursive: true });
|
|
430
|
-
fs.writeFileSync(path.join(clonePath,
|
|
431
|
-
load.text = 'Cloning from github'.blue.bold;
|
|
432
|
-
await sleep(100)
|
|
433
|
-
if(pull) execSync(`cd ${clonePath}/clone && git pull`, { stdio: opts.verbose ? 'inherit' : 'ignore' });
|
|
434
|
-
else execSync(`git clone ${url} ${clonePath}/clone`, { stdio: opts.verbose ? 'pipe' : 'ignore' });
|
|
435
|
-
load.text = 'Installing npm packages'.green.bold;
|
|
447
|
+
fs.writeFileSync(path.join(clonePath, commit), '');
|
|
448
|
+
load.text = pull ? 'Updating repository'.blue.bold : 'Cloning from github'.blue.bold;
|
|
436
449
|
await sleep(100)
|
|
437
|
-
execSync(`cd ${clonePath}/clone &&
|
|
450
|
+
if(pull) execSync(`cd ${clonePath}/clone && git fetch --all${response.data[0].sha !== commit ? ` && git reset --hard ${commit}` : ''}`, { stdio: opts.verbose ? 'inherit' : 'ignore' });
|
|
451
|
+
else execSync(`git clone ${url} ${clonePath}/clone && cd ${clonePath}/clone${response.data[0].sha !== commit ? ` && git reset --hard ${commit}` : ''}${branch ? ' && git checkout '+branch : ''}`, { stdio: opts.verbose ? 'pipe' : 'ignore' });
|
|
452
|
+
if (fs.existsSync(path.join(clonePath, 'clone', 'package.json'))) {
|
|
453
|
+
load.text = 'Installing npm packages'.green.bold;
|
|
454
|
+
await sleep(100);
|
|
455
|
+
execSync(`cd ${clonePath}/clone && npm install`, { stdio: opts.verbose ? 'inherit' : 'ignore' });
|
|
456
|
+
}
|
|
438
457
|
load.stop();
|
|
439
458
|
return clonePath+'/clone';
|
|
440
459
|
} catch (e) {
|
|
441
460
|
const logFile = path.join(logspath, 'logs-'+Date.now()+'.log');
|
|
442
461
|
fs.writeFileSync(logFile, e.toString() +'\n'+ e.stack);
|
|
443
462
|
load.stop();
|
|
463
|
+
if(opts.verbose) console.error(e);
|
|
444
464
|
log(' Something went wrong, check logs at'.red.bold, logFile.green, ':end');
|
|
445
465
|
}
|
|
446
466
|
},
|