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 1.0.6 to 1.1.0

16

bin/machinepack-add.js

@@ -23,12 +23,8 @@ #!/usr/bin/env node

// TODO: consider another machine to validate/sanitize this stuff
// (even so, it would probably be taken care of within `promptAboutNewMachine()`)
var machineMetadata = answers;
Machinepacks.generateNewMachine({
machinepackRootPath: process.cwd(),
identity: machineMetadata.identity,
friendlyName: machineMetadata.friendlyName,
description: machineMetadata.description,
extendedDescription: machineMetadata.extendedDescription,
identity: answers.identity,
friendlyName: answers.friendlyName,
description: answers.description,
extendedDescription: answers.extendedDescription,
inputs: {},

@@ -42,3 +38,3 @@ defaultExit: 'success',

description: 'Done.',
example: '...'
example: 'TODO'
}

@@ -52,3 +48,3 @@ },

// Done!
console.log('New machine (`%s`) successfully added to machinepack.', machineMetadata.identity);
console.log('New machine (`%s`) successfully added to machinepack.', answers.identity);
}

@@ -55,0 +51,0 @@ });

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

var Path = require('path');
var _ = require('lodash');
var program = require('commander');
var Filesystem = require('machinepack-fs');
var Machinepacks = require('machinepack-machinepacks');

@@ -20,2 +18,3 @@

var originalIdentity = program.args[0];
if (!program.args[0]) {

@@ -25,2 +24,4 @@ console.error('`originalIdentity` required');

}
var newIdentity = program.args[1];
if (!program.args[1]) {

@@ -32,7 +33,7 @@ console.error('`newIdentity` required');

var originalIdentity = program.args[0];
var newIdentity = program.args[1];
Machinepacks.getMachinesDir({
dir: Path.resolve(process.cwd())
Machinepacks.copyMachine({
originalIdentity: originalIdentity,
newIdentity: newIdentity,
dir: process.cwd()
}).exec({

@@ -42,48 +43,5 @@ error: function (err){

},
success: function (pathToMachines){
Filesystem.cp({
source: Path.resolve(pathToMachines, originalIdentity+'.js'),
destination: Path.resolve(pathToMachines, newIdentity+'.js')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
Filesystem.readJson({
source: Path.resolve(process.cwd(), 'package.json')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (jsonData){
try {
jsonData.machinepack.machines = _.union(jsonData.machinepack.machines, [newIdentity]);
}
catch (e) {
console.error('Unexpected error occurred:\n',err);
return;
}
Filesystem.writeJson({
json: jsonData,
destination: Path.resolve(process.cwd(), 'package.json'),
force: true
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
// Done.
console.log('Copied: `%s` to new machine: `%s`', originalIdentity, newIdentity);
}
});
}
});
},
});
success: function (){
console.log('Copied: `%s` to new machine: `%s`', originalIdentity, newIdentity);
}
});

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

var Path = require('path');
var _ = require('lodash');
var program = require('commander');
var Filesystem = require('machinepack-fs');
var Machinepacks = require('machinepack-machinepacks');

@@ -19,60 +17,13 @@

Machinepacks.promptAboutNewMachinepack().exec({
Machinepacks.initialize({
dir: process.cwd()
}, {
error: function (err){
console.error('Unexpected error occurred:\n', err);
},
then: function (metadata){
Filesystem.readJson({
source: Path.resolve(process.cwd(), 'package.json')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (jsonData){
jsonData.machinepack = jsonData.machinepack || {};
jsonData.machinepack.friendlyName = metadata.friendlyName || jsonData.machinepack.friendlyName;
jsonData.machinepack.machines = jsonData.machinepack.machines || [];
jsonData.description = metadata.description || jsonData.description;
jsonData.machinepack.machineDir = jsonData.machinepack.machineDir || 'machines/';
(function (done){
Filesystem.mkdir({
destination: jsonData.machinepack.machineDir
}).exec({
error: function (err){
return done(err);
},
// If something already exists at the machine directory path, no problem,
// just ignore it and continue.
alreadyExists: function (){
return done();
},
success: function (){
return done();
}
});
})(function (err) {
if (err){
console.error('Unexpected error occurred:\n',err);
return;
}
Filesystem.writeJson({
json: jsonData,
destination: Path.resolve(process.cwd(), 'package.json'),
force: true
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
// Done.
console.log('Initialized current module as a machinepack');
}
});
});
}
});
success: function (machines){
console.log('Initialized current module as a machinepack');
}
});

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

var chalk = require('chalk');
var Filesystem = require('machinepack-fs');
var Machinepacks = require('machinepack-machinepacks');

@@ -20,19 +19,3 @@ var program = require('commander');

(function listMachines(inputs, exits){
Filesystem.readJson({
source: Path.resolve(inputs.dir, 'package.json')
}).exec({
error: function (err){
return exits.error(err);
},
success: function (jsonData){
try {
return exits.success(jsonData.machinepack.machines);
}
catch (e) {
return exits.error(e);
}
}
});
})({
Machinepacks.listMachines({
dir: process.cwd()

@@ -43,2 +26,6 @@ }, {

},
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 (machines){

@@ -45,0 +32,0 @@ console.log();

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

var Path = require('path');
var _ = require('lodash');
var program = require('commander');
var Filesystem = require('machinepack-fs');
var Machinepacks = require('machinepack-machinepacks');

@@ -20,7 +18,10 @@

if (!program.args[0]) {
var originalIdentity = program.args[0];
if (!originalIdentity) {
console.error('`originalIdentity` required');
process.exit(1);
}
if (!program.args[1]) {
var newIdentity = program.args[1];
if (!newIdentity) {
console.error('`newIdentity` required');

@@ -31,7 +32,6 @@ process.exit(1);

var originalIdentity = program.args[0];
var newIdentity = program.args[1];
Machinepacks.getMachinesDir({
dir: Path.resolve(process.cwd())
Machinepacks.renameMachine({
originalIdentity: originalIdentity,
newIdentity: newIdentity,
dir: process.cwd()
}).exec({

@@ -41,49 +41,5 @@ error: function (err){

},
success: function (pathToMachines){
Filesystem.mv({
source: Path.resolve(pathToMachines, originalIdentity+'.js'),
destination: Path.resolve(pathToMachines, newIdentity+'.js')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
Filesystem.readJson({
source: Path.resolve(process.cwd(), 'package.json')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (jsonData){
try {
jsonData.machinepack.machines = _.difference(jsonData.machinepack.machines, [originalIdentity]);
jsonData.machinepack.machines = _.union(jsonData.machinepack.machines, [newIdentity]);
}
catch (e) {
console.error('Unexpected error occurred:\n',err);
return;
}
Filesystem.writeJson({
json: jsonData,
destination: Path.resolve(process.cwd(), 'package.json'),
force: true
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
// Done.
console.log('Machine with former identity: `%s` is now: `%s`', originalIdentity, newIdentity);
}
});
}
});
},
});
success: function (){
console.log('Machine with former identity: `%s` is now: `%s`', originalIdentity, newIdentity);
}
});

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

var Path = require('path');
var _ = require('lodash');
var program = require('commander');
var chalk = require('chalk');
var Filesystem = require('machinepack-fs');
var Machinepacks = require('machinepack-machinepacks');

@@ -21,4 +18,4 @@

if (!program.args[0]) {
var identity = program.args[0];
if (!identity) {
console.error('`identity` required');

@@ -28,6 +25,7 @@ process.exit(1);

var identity = program.args[0];
Machinepacks.getMachinesDir({
dir: Path.resolve(process.cwd())
Machinepacks.removeMachine({
identity: identity,
dir: process.cwd()
}).exec({

@@ -37,53 +35,8 @@ error: function (err){

},
success: function (pathToMachines){
Filesystem.readJson({
source: Path.resolve(process.cwd(), 'package.json')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (jsonData){
try {
if (!_.contains(jsonData.machinepack.machines, identity)) {
console.error('Cannot remove machine `'+chalk.red(identity)+'`. No machine with that identity exists in this machinepack.');
return;
}
jsonData.machinepack.machines = _.difference(jsonData.machinepack.machines, [identity]);
}
catch (e) {
console.error('Unexpected error occurred:\n',err);
return;
}
// Completely remove a file or directory (like rm -rf).
Filesystem.rmrf({
dir: Path.resolve(pathToMachines, identity+'.js')
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
Filesystem.writeJson({
json: jsonData,
destination: Path.resolve(process.cwd(), 'package.json'),
force: true
}).exec({
error: function (err){
console.error('Unexpected error occurred:\n',err);
},
success: function (){
// Done.
console.log('`%s` has been removed from this machinepack.', chalk.blue(identity));
}
});
}
});
},
});
notFound: function (){
console.error('Cannot remove machine `' + chalk.red(identity) + '`. No machine with that identity exists in this machinepack.');
},
success: function (){
console.log('`%s` has been removed from this machinepack.', chalk.blue(identity));
}
});

@@ -27,1 +27,32 @@ #!/usr/bin/env node

}
// Aliases:
if (program.args[0] === 'list' || program.args[0] === 'machines') {
return _alias('ls');
}
if (program.args[0] === 'initialize' || program.args[0] === 'new') {
return _alias('init');
}
if (program.args[0] === 'remove') {
return _alias('rm');
}
if (program.args[0] === 'run') {
return _alias('exec');
}
if (program.args[0] === 'touch') {
return _alias('add');
}
if (program.args[0] === 'move') {
return _alias('mv');
}
if (program.args[0] === 'copy') {
return _alias('cp');
}
function _alias (aliasFor){
process.argv.splice(process.argv.indexOf(program.args[0]),1);
require('./machinepack-'+aliasFor);
}
{
"name": "machinepack",
"version": "1.0.6",
"version": "1.1.0",
"description": "CLI tool for working with machinepacks and their machines.",

@@ -33,4 +33,4 @@ "bin": {

"chalk": "^0.5.1",
"machinepack-machinepacks": "~0.0.5"
"machinepack-machinepacks": "^0.1.0"
}
}
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