Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

machinepack

Package Overview
Dependencies
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

machinepack - npm Package Compare versions

Comparing version 2.0.7 to 2.0.8

159

bin/machinepack-info.js

@@ -11,5 +11,4 @@ #!/usr/bin/env node

var chalk = require('chalk');
var Machine = require('machine');
var convertToEcmascriptCompatibleVarname = require('convert-to-ecmascript-compatible-varname');
// TODO: use machinepack-javascript to do this
var Javascript = require('machinepack-javascript');
var Machines = require('machinepack-machines');

@@ -24,110 +23,13 @@

(Machine.build({
inputs: {
dir: {
example: '/Users/mikermcneil/machinepack-foo/'
}
},
defaultExit: 'success',
exits: {
error: {
description: 'Unexpected error occurred'
},
notMachinepack: {
description: 'The specified path is not the root directory of a machinepack'
},
success: {
example: {
npmModuleName: 'machinepack-fs',
variableName: 'Filesystem',
friendlyName: 'Filesystem Utilities',
identity: 'machinepack-fs',
version: '1.6.0',
description: 'Work with the local filesystem; list files, write files, etc.',
keywords: ['keywords'],
machines: ['do-something'],
machineDir: 'machines/'
}
}
},
fn: function (inputs, exits){
// Dependencies
var Path = require('path');
var Filesystem = require('machinepack-fs');
var Machinepacks = require('machinepack-machines');
var convertToEcmascriptCompatibleVarname = require('convert-to-ecmascript-compatible-varname');
// TODO: use machinepack-javascript to do this
var machinepackPath = Path.resolve(process.cwd(), inputs.dir);
var packageJsonPath = Path.resolve(machinepackPath, 'package.json');
Filesystem.readJson({
source: packageJsonPath
}).exec({
error: function (err){
return exits.error(err);
},
doesNotExist: function (){
return exits.notMachinepack();
},
success: function (jsonData){
// Not a machinepack
if (!jsonData.machinepack) {
return exits.notMachinepack();
}
var machinepackMetadata;
try {
machinepackMetadata = {
identity: jsonData.name,
npmModuleName: jsonData.name,
friendlyName: jsonData.machinepack.friendlyName,
version: jsonData.version,
description: jsonData.description,
keywords: jsonData.keywords,
machines: jsonData.machinepack.machines,
machineDir: jsonData.machinepack.machineDir
};
// If a friendlyName is not explicitly specified, build one from `identity`
machinepackMetadata.friendlyName = (function determineSuitableFriendlyName (){
var friendlyName = (jsonData.machinepack&&jsonData.machinepack.friendlyName) || machinepackMetadata.identity;
// If friendlyname still has "machinepack-" prefix in it, wipe it out
friendlyName = friendlyName.replace(/^machinepack-/, '');
// Then capitalize whatever's left
return friendlyName[0].toUpperCase() + friendlyName.slice(1);
})();
// Build `variableName` from friendlyName, but first...
machinepackMetadata.variableName = (function determineSuitableVariableName (){
var variableName = machinepackMetadata.friendlyName;
// convert to a ecmascript-compatible variable
variableName = convertToEcmascriptCompatibleVarname(variableName);
// then capitalize the first letter)
return variableName[0].toUpperCase() + variableName.slice(1);
})();
}
catch (e) {
return exits.error(e);
}
return exits.success(machinepackMetadata);
}
});
}
}))({
Machines.readPackageJson({
dir: process.cwd()
}, {
error: function (err){
console.error('Unexpected error occurred:\n',err);
}).exec({
error: function(err) {
console.error('Unexpected error occurred:\n', err);
},
notMachinepack: function (){
console.error('This is '+chalk.red('not a machinepack')+'.');
notMachinepack: function() {
console.error('This is ' + chalk.red('not a machinepack') + '.');
console.error('Be sure and check that the package.json file has a valid `machinepack` property, or run `machinepack init` if you aren\'t sure.');
},
success: function (machinepack){
success: function(machinepack) {
// console.log();

@@ -140,3 +42,3 @@ //console.log(chalk.bold(machinepack.friendlyName)/*+' '+chalk.gray('('+machinepack.identity+')')*/);

console.log(''+chalk.bold(machinepack.friendlyName)+' -- '+chalk.reset(machinepack.description));
console.log('' + chalk.bold(machinepack.friendlyName) + ' -- ' + chalk.reset(machinepack.description));
// console.log(chalk.gray('('+machinepack.identity+')'));

@@ -146,5 +48,26 @@ console.log();

var urls = (function(_urls) {
if (machinepack.nodeMachineUrl) {
_urls.push(machinepack.nodeMachineUrl);
}
if (machinepack.npmUrl) {
_urls.push(machinepack.npmUrl);
}
if (machinepack.githubUrl) {
_urls.push(machinepack.githubUrl);
}
return _urls;
})([]);
if (urls.length > 0) {
console.log(chalk.bold('URLS'));
_.each(urls, function(url) {
console.log(' ' + chalk.underline(url));
});
console.log();
console.log();
}
console.log(chalk.bold('INSTALLATION'));
// console.log();
console.log(chalk.white(' npm install '+chalk.bold(machinepack.npmModuleName) + '@^'+machinepack.version + ' --save'));
console.log(chalk.white(' npm install ' + chalk.bold(machinepack.npmPackageName) + '@^' + machinepack.version + ' --save'));
console.log();

@@ -155,3 +78,3 @@ console.log();

// console.log();
console.log(' var '+machinepack.variableName+' = require(\''+machinepack.npmModuleName + '\');');
console.log(' var ' + machinepack.variableName + ' = require(\'' + machinepack.npmPackageName + '\');');
console.log();

@@ -164,10 +87,12 @@ console.log();

if (machinepack.machines.length < 1) {
console.log('\n'+chalk.gray(' none'));
}
else {
console.log(chalk.gray(' none'));
} else {
// console.log('%s %s:', chalk.bold(chalk.blue(machinepack.machines.length)), machinepack.machines.length===1?'Machine':'Machines');
_.each(machinepack.machines,function (machineIdentity){
_.each(machinepack.machines, function(machineIdentity) {
// Calculate appropriate machine method name
var methodName = convertToEcmascriptCompatibleVarname(machineIdentity);
console.log(' %s.%s() %s',chalk.white(machinepack.variableName), chalk.yellow(methodName), chalk.gray('('+machineIdentity+')'));
var methodName = Javascript.convertToEcmascriptCompatibleVarname({
string: machineIdentity,
force: true
}).execSync();
console.log(' %s.%s() %s', chalk.white(machinepack.variableName), chalk.yellow(methodName), chalk.gray('(' + machineIdentity + ')'));
});

@@ -180,4 +105,4 @@ }

console.log();
// console.log(chalk.gray.bold('NPM')+'\n' + chalk.gray(machinepack.npmModuleName + '\n' + 'v'+machinepack.version));
// console.log(chalk.gray.bold('NPM')+'\n' + chalk.gray(machinepack.npmPackageName + '\n' + 'v'+machinepack.version));
}
});
{
"name": "machinepack",
"version": "2.0.7",
"version": "2.0.8",
"description": "CLI tool for working with machinepacks and their machines.",

@@ -44,8 +44,8 @@ "bin": {

"machinepack-fs": "^1.6.0",
"machine": "^1.2.3",
"machine": "^2.0.2",
"chalk": "^0.5.1",
"machinepack-machines": "^1.0.0",
"yargs": "^1.3.3",
"convert-to-ecmascript-compatible-varname": "^0.1.1"
"machinepack-javascript": "^0.2.1"
}
}
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