Commit 053a388f authored by jlopez's avatar jlopez
Browse files

Add npm packages

parent 9c2dd363
......@@ -150,6 +150,9 @@ class DBquery
else if($distrib == "CPAN") {
$package = array($row['name'], $row['version'], $row['description'], "https://metacpan.org/pod/".$row['name'], "http://www.cpan.org/authors/id/".$row['download']);
}
else if($distrib == "NPM") {
$package = array($row['name'], $row['version'], $row['description'],$row['doc']);
}
else if($distrib == "Bioconductor" || $distrib == "Conda" || $distrib == "Ruby") {
$package = array($row['name'], $row['version'], $row['description'], $row['doc']);
}
......@@ -179,4 +182,4 @@ class DBquery
//LOAD DATA LOCAL INFILE "/home/jimmy/jimmy/web/wicopa/packages/fedora:28/packages.csv" INTO TABLE fedora COLUMNS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';
}
\ No newline at end of file
}
<?php
/**
* Created by PhpStorm.
* User: jimmy
* Date: 15/03/19
* Time: 14:39
*/
require_once "./dao/DBquery.php";
$db = new DBquery();
$distrib = "";
if(isset($_GET['distrib'])) {
$distrib = $_GET['distrib'];
}
$filter = "";
if(isset($_GET['filter'])) {
$filter = $_GET['filter'];
}
if(isset($_GET['filter'])) {
$filter = $_GET['filter'];
}
$patternName = false;
$patternDescription = false;
if(isset($_GET['patternName'])) {
if($_GET['patternName'] == "true") {
$patternName = true;
}
}
if(isset($_GET['patternDescription'])) {
if($_GET['patternDescription'] == "true") {
$patternDescription = true;
}
}
$limit = "25";
if(isset($_GET['limit'])) {
$limit = $_GET['limit'];
}
$result = $db->getPackages($distrib, $filter, $patternName, $patternDescription, $limit);
echo '
<div class="container">
<div class="row justify-content-center">
<h4>Packages found : '.count($result).'</h4>
</div>
</div>
<table id="Table_PackagesNPM" class="table table-striped table-bordered">
<thead>
<tr>
<th>Choose</th>
<th>Name</th>
<th>Version</th>
<th>Description</th>
<th>Documentation</th>
</tr>
</thead>
<tbody id="TablePackagesCRAN">
<tr>';
foreach ($result as $t) {
echo '<td><label class="custom-control custom-checkbox">
<input type="checkbox" onclick="generatePackageSelected(this)" data-pname="'.$t[0].'" data-pversion="'.$t[1].'" data-psection="NPM" id="checkbox$'.'PackagesNPM'.'$'.$t[0].'$'.$t[1].'" class="custom-control-input" name="type">
<span class="custom-control-indicator"></span>
</label></td>';
echo '<td>'.$t[0].'</td>';
echo '<td>'.$t[1].'</td>';
echo '<td>'.$t[2].'</td>';
echo '<td><a href="'.$t[3].'">documentation</a></td>';
echo '</tr>';
}
echo '</tr>
</tbody>
</table>
';
return $result;
\ No newline at end of file
......@@ -472,6 +472,45 @@ foreach ($db->getAllSectionParent() as $s){
</div>
';
}
else if($s == "NPM") {
echo '
<br/>
<label for="findNPMPackages">Find packages with pattern :</label>
<input type="email" class="form-control" id="findNPMPackages">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="patternNPMName" checked>
<label class="form-check-label" for="patternNPMName">Pattern on name</label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="patternNPMDescription" checked>
<label class="form-check-label" for="patternNPMDescription">Pattern on description</label>
</div>
<br/>
<div class="form-group">
<label for="limitNPM" class="font-check-label">Max found :</label>
<select class="custom-select" id="limitNPM">
<option value="5">5</option>
<option value="10" selected="selected">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="100">200</option>
<option value="1000000000">all</option>
</select>
</div>
<br/>
<button type="button" class="btn btn-primary" onclick="showPackage(\'NPM\')">Search</button>
<br/><br/>
<div id="containPackagesNPM">
</div>
';
}
else if($s == "Conda") {
......@@ -1025,8 +1064,37 @@ foreach ($db->getAllSectionParent() as $s){
}
nrow += 1;
}
}
if(SELECTED_PACKAGES["NPM"].length > 0) {
PREVIEW += "\n\n############### Install NPM ##############\n";
if(isSingularity) {
PREVIEW += "\n\tcurl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -";
PREVIEW += "\n\t" + manager + " install -y nodejs\n";
} else {
PREVIEW += "\nRUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -";
PREVIEW += "\nRUN" + manager + " install -y nodejs\n";
}
nrow += 3;
for(var i = 0; i < SELECTED_PACKAGES["NPM"].length; i++) {
var version = "@"+SELECTED_PACKAGES["NPM"][i][1];
if(isSingularity) {
PREVIEW += "\n\tnpm install -g "+SELECTED_PACKAGES["NPM"][i][0]+version;
} else {
PREVIEW += "\nRUN npm install "+SELECTED_PACKAGES["NPM"][i][0]+version;
}
nrow += 1;
}
}
if(SELECTED_PACKAGES["CPAN"].length > 0) {
......
/usr/local/lib/node_modules/all-the-packages
\ No newline at end of file
/usr/local/lib/node_modules/nice-package
\ No newline at end of file
const registry = require('all-the-packages')
var fs = require('fs');
var stream = fs.createWriteStream("./packages.csv");
console.log("Start");
var index = 0;
stream.once('open', function(fd) {
registry
.on('package', function (pkg) {
//console.log(`${pkg.name} - ${pkg.description}\n`)
index++;
var name = pkg.name;
var version = pkg.version;
var description = pkg.description;
var doc = "https://www.npmjs.com/package/"+name;
var line = '"' + name + '";"' + version + '";"' + description + '";"' + doc + '"\n';
//console.log(line);
stream.write(line);
console.log(index);
})
.on('end', function () {
// done
})
// stream.end();
});
console.log(index);
console.log("End");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment