New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

smartfacecloud-updater

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartfacecloud-updater - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

1

bin/global-exec.js

@@ -5,2 +5,3 @@ #!/usr/bin/env node

var args = require('minimist')(process.argv.slice(2));
args.workspacePath = args.workspacePath || '/home/ubuntu/workspace';
thisPackage(args);

88

index.js
const execFile = require('child_process').execFile;
const fs = require('fs');
const path = require('path');
const semver = require('semver');
const PACKAGE_VERSION = '0.0.1';
const PACKAGE_VERSION = '0.0.2';

@@ -26,3 +27,10 @@ const CURRENT_VERSION = {

}
// console.log('globallyInstalledPackages', globallyInstalledPackages);
const packagesThatCanBeInstalled = filterPackageSnapshotsThatCanBeUpdated(packageSnapshots);
if (!(packagesThatCanBeInstalled instanceof Array)) {
return console.log('packagesThatCanBeInstalled is not an Array');
} else if (packagesThatCanBeInstalled.length === 0) {
return console.log('packagesThatCanBeInstalled has length zero');
}
// console.log('packagesThatCanBeInstalled', packagesThatCanBeInstalled)
//In the future the below logic can be more complex

@@ -32,3 +40,3 @@ //There will be ways to update workspace via migrations

const snapshotKey = packagesThatCanBeInstalled.pop();
installSnapshot(snapshotKey, callbackAllInstalled);
installSnapshot(snapshotKey, globallyInstalledPackages.dependencies);
});

@@ -39,9 +47,32 @@ }

function callbackAllInstalled(err, data) {
console.log(err, data);
execNpmGlobalDependenciesList(function(err, data) {
console.log(err, data);
function buildListOfPackagesWithTagsToInstall(packagesToInstall) {
return packagesToInstall.map(item => {
return item.name + '@' + item.version;
});
}
function callbackAllInstalled(packagesToInstall, err, data) {
console.log('callbackAllInstalled', packagesToInstall, err, data);
execNpmGlobalDependenciesList(function(err, globallyInstalledPackages) {
console.log(err, globallyInstalledPackages);
if (err) {
return console.log('err', err);
}
packagesToInstall.forEach(elem => {
elem.installed = false;
if (globallyInstalledPackages.dependencies &&
globallyInstalledPackages.dependencies[elem.name] &&
globallyInstalledPackages.dependencies[elem.name].version &&
globallyInstalledPackages.dependencies[elem.name].version === elem.version) {
elem.installed = true;
}
});
process.stdout.write('smartface-cloud-updater has finished processing packagesInstalled');
process.stdout.write(JSON.stringify({
packagesInstalled: packagesToInstall
}));
process.stdout.write('smartface-cloud-updater json was sent');
});
}
function execNpmGlobalDependenciesList(callback) {

@@ -80,3 +111,3 @@ var cliArgs = ['list', '-g', '--json', '--depth', '0'];

}
if (!semver.gt(key, PACKAGE_VERSION)) {
if (!semver.gte(key, PACKAGE_VERSION)) {
return false;

@@ -89,12 +120,13 @@ }

function installPackages(packageSnapshots, callbackAllInstalled) {
const packages = Object.keys(packageSnapshots).map(function(key) {
return key + '@' + packageSnapshots[key];
});
const cmd = ['install', '-g', '--json'].concat(packages).join(' ');
execNpmWrapper(['install', '-g', '--json'].concat(packages), callbackAllInstalled);
function installPackages(packagesToInstall) {
const packages = buildListOfPackagesWithTagsToInstall(packagesToInstall);
execNpmWrapper(['install', '-g', '--json'].concat(packages), callbackAllInstalled.bind(null, packagesToInstall));
}
function installSnapshot(snapshotKey, callbackAllInstalled) {
fs.readFile('snapshots/' + CURRENT_VERSION.major + '.x/' + snapshotKey + '.json', function(err, data) {
function installSnapshot(snapshotKey, globallyInstalledPackages) {
const dataFilePath = path.join(__dirname, 'snapshots', CURRENT_VERSION.major + '.x', snapshotKey + '.json');
fs.readFile(dataFilePath, function(err, data) {
if (err) {
return console.error(err);
}
var json;

@@ -104,11 +136,31 @@ try {

} catch (e) {
console.log('installSnapshot no json file');
console.log('installSnapshot no json file', e);
return;
}
installPackages(json, callbackAllInstalled);
const packagesToInstall = filterUninstalledSnapshotPackages(globallyInstalledPackages, json);
// return console.log('packagesToInstall', packagesToInstall);
installPackages(packagesToInstall);
});
}
function filterUninstalledSnapshotPackages(globallyInstalledPackages, snapshotPackages) {
return Object.keys(snapshotPackages).filter(key => {
if (!globallyInstalledPackages[key]) {
return true;
}
if (semver.lt(globallyInstalledPackages[key].version, snapshotPackages[key])) {
return true;
}
return false;
}).map(key => {
return {
name: key,
version: snapshotPackages[key]
};
});
}
function loadDataFile(callback) {
fs.readFile('data.json', function(err, data) {
const dataFilePath = path.join(__dirname, 'data.json');
fs.readFile(dataFilePath, function(err, data) {
if (err) {

@@ -115,0 +167,0 @@ return callback(err);

{
"name": "smartfacecloud-updater",
"version": "0.0.1",
"version": "0.0.2",
"description": "Auto updater for SmartfaceCloud",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc