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

famous-cli

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

famous-cli - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

lib/util/autogenerate.js

96

bin/famous.js

@@ -18,62 +18,64 @@ #!/usr/bin/env node

storage.getGlobal(function(error, config){
if (config.tracking) metrics.track('cli-event', {'command_data': process.argv.slice(2, process.argv.length).join(" ") || 'help'}, function(){});
if (config.tracking) {
metrics.track('cli-event', {'command_data': process.argv.slice(2, process.argv.length).join(' ') || 'help'}, function(){});
}
});
auto(function(){
program
.version(require('../package').version);
program
.version(require('../package').version);
program
.command('register')
.description('register with Famous Cloud Services.')
.action(register);
program
.command('register')
.description('register with Famous Cloud Services.')
.action(register);
program
.command('login')
.description('login with Famous Cloud Services.')
.action(login);
program
.command('login')
.description('login with Famous Cloud Services.')
.action(login);
program
.command('create')
.alias('init')
.description('create a famous project')
.option('-n, --name', 'Name your project')
.action(create);
program
.command('create')
.alias('init')
.description('create a famous project')
.option('-n, --name', 'Name your project')
.action(create);
program
.command('fork')
.description('fork a famous project')
.option('-n, --name', 'Name of forked project')
.action(fork);
program
.command('fork')
.description('fork a famous project')
.option('-n, --name', 'Name of forked project')
.action(fork);
program
.command('develop')
.alias('dev')
.description('run your famous project')
.action(develop);
program
.command('develop')
.alias('dev')
.description('run your famous project')
.action(develop);
program
.command('deploy')
.description('deploy a famous project')
.action(deploy);
program
.command('deploy')
.description('deploy a famous project')
.action(deploy);
program
.command('session')
.description('retrieve user session data')
.action(userGet);
program
.command('session')
.description('retrieve user session data')
.action(userGet);
// program
// .command('*')
// .action(function(env) {
// if (env !== 'project' && env !== 'user' && env !== 'widget') {
// program.help();
// }
// });
// program
// .command('*')
// .action(function(env) {
// if (env !== 'project' && env !== 'user' && env !== 'widget') {
// program.help();
// }
// });
program
.parse(process.argv);
program
.parse(process.argv);
if (program.args.length === 0) {
program.help();
}
if (program.args.length === 0) {
program.help();
}
});

@@ -14,5 +14,5 @@ 'use strict';

var trackingPrompt = {
type: 'confirm',
name: 'tracking',
message: "May famous anonymously report usage statistics to improve the tool over time?"
type: 'confirm',
name: 'tracking',
message: 'May famous anonymously report usage statistics to improve the tool over time?'
};

@@ -26,3 +26,3 @@

storage.getGlobal,
function (config, callback) {
function (config, cb) {
if (!config) {

@@ -32,3 +32,3 @@ config = {};

if (config.tracking) {
return callback('already answered');
return cb('already answered');
}

@@ -38,8 +38,8 @@

if (!answers) {
return callback("invalid answers from prompt");
return cb('invalid answers from prompt');
}
return metrics.setTracking(answers.tracking, callback)
return metrics.setTracking(answers.tracking, cb);
});
}
],
],
function (error) {

@@ -55,2 +55,18 @@ if (error === 'already answered') {

/**
* update
* run the update command
* @param {function} callback function to execute with the return code from the update command
*/
var update = function (callback) {
var child = spawn('npm', ['install', '-g', 'famous-cli']);
child.on('close', function (code) {
if (code === 0) {
return callback(null);
}
return callback(code);
});
};
/**
* autoupdate

@@ -68,4 +84,7 @@ * check for update and execute if the current version in package.json is behind the latest version published in npm

}
ver('famous-cli', function(err, version) {
if (err) {
return callback(err);
}
if (current < version) {

@@ -80,20 +99,4 @@ console.log(chalk.bold('Famous'), 'CLI version', current, 'is out of date.', 'Updating to', version);

/**
* update
* run the update command
* @param {function} callback function to execute with the return code from the update command
*/
var update = function (callback) {
var child = spawn('npm', ['install', '-g', 'famous-cli']);
child.on('close', function (code) {
if (code === 0) {
return callback(null);
}
return callback(code);
});
};
/** **/
module.exports = autoupdate;
'use strict';
var inquirer = require('inquirer');
var async = require('async');
var fs = require('fs');
var chalk = require('chalk');
var inquirer = require('inquirer');
var updateProject = require('./project/update');
var famouserror = require('./error');
var storage = require('../res/sdk-bundle').storage;
var chalk = require('chalk');
var createUser = require('../res/sdk-bundle').user.create;
var login = require('../res/sdk-bundle').user.login;
var register = require('./user/create');
var auto = require('./util/autogenerate');
var link = require('./project/link');
var npm = require('./util/npm');
/**
*
*/
var noSession = function(callback) {
var loginPrompt = {
type: 'input',
name: 'login',
message: 'No current user session. Login to an existing Famous Cloud Services account?: '
};
async.waterfall([
function(callback){
inquirer.prompt([loginPrompt], function(answers) {
callback(null, answers)
});
},
function(response, callback){
if (/[yY]/.test(response.login)) {
login();
} else {
auto.generate(function(error, data){
createUser(data, function(err, dat) {
callback(err, {email: data.email, password: data.password});
});
});
}
},
login,
storage.setGlobal,
function (data, callback) {
storage.getGlobal(callback);
}
],
function (error, data) {
callback(error, data);
});
};
/**
*
*/
var deployProject = function() {

@@ -28,16 +74,17 @@ async.waterfall([

}, function(data, callback) {
storage.getGlobal(function(err, data) {
storage.getGlobal(function(err, config) {
if (!data || !data.authentication_token) {
return callback(new Error('no-token'), null);
return noSession(callback);
// return callback(new Error('no-token'), null);
}
return callback(err, data);
return callback(err, config);
});
}, function(data, callback) {
storage.getProjectMeta(function(err, data) {
if (!data || !data.widget_id) {
storage.getProjectMeta(function(err, config) {
if (!config || !config.widget_id) {
link(null, function() {
return callback(err, data);
})
return callback(err, config);
});
} else {
return callback(err, data);
return callback(err, config);
}

@@ -53,3 +100,3 @@ });

if (error) {
if (error.message == 'not-empty-folder') {
if (error.message === 'not-empty-folder') {
console.log(

@@ -59,11 +106,11 @@ chalk.red('\n\r Directory is empty, please use'),

);
} else if (error.message == 'error-npm-install') {
} else if (error.message === 'error-npm-install') {
console.log(
chalk.red('\n\r Error while building\r')
);
} else if (error.message == 'error-build') {
} else if (error.message === 'error-build') {
console.log(
chalk.red('\n\r Error while building\n\r')
);
} else if (error.message == 'no-token') {
} else if (error.message === 'no-token') {
console.log(

@@ -86,3 +133,4 @@ chalk.red('\n\r You must be authenticated, please login or register:')

/** **/
module.exports = deployProject;

@@ -1,2 +0,2 @@

'use strict'
'use strict';

@@ -10,7 +10,18 @@ var fs = require('fs');

var develop = function develop(options) {
var runDev = function() {
var dev = spawn('npm', ['run', 'dev']);
dev.stdout.pipe(process.stdout);
dev.stderr.pipe(process.stderr);
dev.on('close', function (code) {
console.log('child process exited with code ' + code);
});
};
var develop = function develop() {
var jsonPath = path.join(process.cwd(), 'package.json');
var json;
fs.readFile(jsonPath, 'utf8', function (err, data) {
if (err) throw err;
if (err) {
throw err;
}

@@ -23,4 +34,2 @@ try {

var modulesPath = path.join(process.cwd(), 'node_modules');
if (json && json.scripts && json.scripts.dev) {

@@ -32,3 +41,3 @@ npm.checkInstall(null, function(){

} else {
console.log(chalk.bold.red('You don\'t appear to be in a famous project'))
console.log(chalk.bold.red('You don\'t appear to be in a famous project'));
}

@@ -38,11 +47,3 @@ });

var runDev = function() {
var dev = spawn('npm', ['run', 'dev']);
dev.stdout.pipe(process.stdout);
dev.stderr.pipe(process.stderr);
dev.on('close', function (code) {
console.log('child process exited with code ' + code);
});
};
module.exports = develop;

@@ -20,3 +20,3 @@ 'use strict';

var message = chalk.bold('\n\r');
data.errors.forEach(function(current, index, array) {
data.errors.forEach(function(current) {
message += chalk.red(current) + '\n\r';

@@ -23,0 +23,0 @@ });

'use strict';
var fs = require('fs-extra');
var https = require('https');
var path = require('path');

@@ -25,5 +24,5 @@ var chalk = require('chalk');

var dirPath = path.join(process.cwd(), name);
try {
var stats = fs.lstatSync(dirPath);
fs.lstatSync(dirPath);
console.log(chalk.bold.red('Directory name already exists.'));

@@ -36,3 +35,5 @@ process.exit(1);

fs.copy(path.join(tempPath, 'engine-seed-master'), dirPath, function (err) {
if (err) return console.error(err);
if (err) {
return console.error(err);
}
if (typeof callback === 'function') {

@@ -48,3 +49,3 @@ return callback(null);

if (err) {
return cb(true);
return callback(true);
}

@@ -54,8 +55,10 @@ if (!items || !items.length) {

seedTools.extract(tempZipPath, tempPath, function() {
fs.copy(path.join(tempPath, 'engine-seed-master'), process.cwd(), function(err) {
if (err) return console.error(err);
fs.copy(path.join(tempPath, 'engine-seed-master'), process.cwd(), function(error) {
if (error) {
return console.error(error);
}
if (typeof callback === 'function') {
return callback(null);
}
})
});
});

@@ -71,3 +74,3 @@ });

};

@@ -77,2 +80,1 @@

module.exports = initProject;
'use strict';
var fs = require('fs-extra');
var https = require('https');
var path = require('path');

@@ -23,5 +22,5 @@ var chalk = require('chalk');

var dirPath = path.join(process.cwd(), name);
try {
var stats = fs.lstatSync(dirPath);
fs.lstatSync(dirPath);
console.log(chalk.bold.red('Directory name already exists.'));

@@ -35,3 +34,5 @@ process.exit(1);

fs.copy(path.join(tempPath, name), dirPath, function (err) {
if (err) return console.error(err);
if (err) {
return console.error(err);
}
if (typeof callback === 'function') {

@@ -44,3 +45,3 @@ return callback(null);

}
}
}
};

@@ -47,0 +48,0 @@

@@ -7,8 +7,6 @@ 'use strict';

var crypto = require('crypto');
var os = require('os');
var pjson = require('../../package.json');
exports.setTracking = function setTracking(tracking, cb) {
var setTracking = exports.setTracking = function setTracking(tracking, cb) {
if (tracking) {

@@ -37,8 +35,8 @@ var seed = Math.floor(Date.now() * Math.random()).toString();

}
if (data === undefined) {
data = {};
}
var config = storage.getGlobal(function(error, config) {
storage.getGlobal(function(error, config) {
if (data instanceof Function) {

@@ -45,0 +43,0 @@ cb = data;

'use strict';
var inquirer = require('inquirer');
var async = require('async');

@@ -27,3 +26,3 @@ var chalk = require('chalk');

});
callback(null, name)
callback(null, name);
},

@@ -34,9 +33,10 @@ link

if (error) {
console.log(chalk.blue('A seed project has been created at: ' + process.cwd()))
console.log(chalk.blue('A seed project has been created at: ' + process.cwd()));
// console.log(error);
} else {
console.log(chalk.blue('A seed project has been created at: ' + process.cwd()))
console.log(chalk.blue('A seed project has been created at: ' + process.cwd()));
}
if (data) {
// log autodeploy
}
});

@@ -43,0 +43,0 @@ };

'use strict';
var inquirer = require('inquirer');
var async = require('async');

@@ -25,3 +24,3 @@ var chalk = require('chalk');

if (!name) {
console.log(chalk.bold.red('Famous fork currently only works with the options twitterus-tutorial and carousel-tutorial'))
console.log(chalk.bold.red('Famous fork currently only works with the options twitterus-tutorial and carousel-tutorial'));
}

@@ -41,3 +40,3 @@

],
function (error, answers) {
function (error, data) {
if (error) {

@@ -48,6 +47,7 @@ console.log(error);

// console.log('A hub container has been created with the id of: ', answers.container.id);
console.log(chalk.blue('A seed project has been created at: ' + process.cwd()))
console.log(chalk.blue('A seed project has been created at: ' + process.cwd()));
}
if (data) {
//log autodeploy
}
});

@@ -54,0 +54,0 @@ };

@@ -22,3 +22,3 @@ 'use strict';

}
data.containers.forEach(function(index, current, array) {
data.containers.forEach(function(index) {
console.log(chalk.bold('\n' + 'Container - ') + index.name + ' (' + index.id + ')');

@@ -25,0 +25,0 @@ console.log(chalk.yellow('Sharable link: ', 'https://' + config.hostname + '/codemanager/v1/containers/' + index.id + '/share' ));

@@ -1,5 +0,4 @@

'use strict'
'use strict';
var setProjectMeta = require('../../res/sdk-bundle').storage.setProjectMeta;
var getProjectMeta = require('../../res/sdk-bundle').storage.getProjectMeta;
var createWidget = require('../../res/sdk-bundle').widget.create;

@@ -12,8 +11,11 @@ var createContainer = require('../../res/sdk-bundle').container.create;

createWidget({name: name}, function(error, res) {
createWidget({name: name}, function(error, response) {
if (error) {
callback(error);
} else {
var data = {name: res.block.name, block_id: res.block.id};
createContainer(data, function(error, res) {
var data = {name: response.block.name, block_id: response.block.id};
createContainer(data, function(err, res) {
if (err) {
callback(err);
}
var containerData = {

@@ -35,4 +37,4 @@ container_id: res.container.id,

});
}
};
module.exports = link;
'use strict';
var push = require('../widget/push');
/** **/
module.exports = push;
'use strict';
var readdir = require('recursive-readdir');

@@ -21,2 +14,3 @@ var async = require('async');

var file = require('../util/file');
var slash = require('slash');

@@ -33,22 +27,22 @@

// Fetch the current directory
function(callback) {
function(cb) {
var workspace = path.join(process.cwd(), 'public');
callback(null, workspace);
cb(null, workspace);
},
// Rescursive lookup to find all files
function(p, callback) {
function(p, cb) {
readdir(p, function (err, files) {
return callback(err, files);
return cb(err, files);
});
},
function(files, callback) {
function(files, cb) {
file.getTotalSizeInBytes(files, function(err, size) {
if (err || size > 75000000) {
return callback(new Error('space-limt'), { status: 666, errors: ['Your project must be less than 75MB'] })
return cb(new Error('space-limt'), { status: 666, errors: ['Your project must be less than 75MB'] });
}
return callback(null, files)
return cb(null, files);
});
},
// Turn the files into a manifest object
function(files, callback) {
function(files, cb) {
files.forEach(function(current) {

@@ -60,3 +54,3 @@ var relative = current.replace(path.join(process.cwd(), 'public'), '');

value: current,
relative: relative,
relative: slash(relative),
options: {

@@ -68,17 +62,17 @@ filename: baseName,

});
return callback(null, { manifest: manifest });
return cb(null, { manifest: manifest });
},
// Fetch Container-id and Widget-id
function(config, callback) {
function(conf, cb) {
getProjectMeta(function(error, data) {
// @TODO handle error case where we don't have a widget_id
var meta = data;
config.widgetId = meta.widget_id;
return callback(error, config);
conf.widgetId = meta.widget_id;
return cb(error, conf);
});
},
// Push
function(config, callback) {
widgetPush(config.widgetId, config.manifest, function(err, data) {
return callback(err, data);
function(conf, cb) {
widgetPush(conf.widgetId, conf.manifest, function(err, data) {
return cb(err, data);
});

@@ -95,3 +89,2 @@ }

}
return;
}

@@ -106,3 +99,5 @@ getProjectMeta(function(error, results) {

if (typeof callback == 'function') return callback(err, data);
if (typeof callback === 'function') {
return callback(err, data);
}
});

@@ -109,0 +104,0 @@ };

@@ -9,3 +9,2 @@ 'use strict';

var famouserror = require('../error');
var metrics = require('../metrics/mixpanel');
var chalk = require('chalk');

@@ -43,8 +42,2 @@

var loginPrompt = {
type: 'confirm',
name: 'login',
message: 'Account creation successful, would you like to login?'
};
async.waterfall([

@@ -51,0 +44,0 @@ function(callback){

@@ -27,3 +27,3 @@ 'use strict';

function(answer, callback) {
if (answer.logout == true) {
if (answer.logout === true) {
logout(function(err, data) {

@@ -42,3 +42,3 @@ return callback(err, data);

if (err) {
var message = famouserror.message(error, data);
var message = famouserror.message(err, data);
if (message) {

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

@@ -13,3 +13,3 @@ 'use strict';

var total = 0;
results.forEach(function(current, index, array) {
results.forEach(function(current) {
total += current.size;

@@ -19,4 +19,4 @@ });

});
}
};
module.exports = file;

@@ -27,3 +27,3 @@ 'use strict';

try {
var stats = fs.lstatSync(modulesPath);
fs.lstatSync(modulesPath);
return callback(null, data);

@@ -33,3 +33,3 @@ } catch (e) {

var install = spawn('npm', ['install']);
install.stdout.pipe(process.stdout)
install.stdout.pipe(process.stdout);
install.stderr.pipe(process.stderr);

@@ -43,4 +43,4 @@ install.on('close', function (code) {

}
}
};
module.exports = npm;
module.exports = npm;

@@ -1,5 +0,5 @@

'use strict'
'use strict';
var fs = require('fs');
var tar = require('tar');
var tar = require('tar-fs');
var zlib = require('zlib');

@@ -12,3 +12,3 @@ var https = require('https');

var file = fs.createWriteStream(dest);
var request = https.get(source, function(response) {
https.get(source, function(response) {
response.pipe(file);

@@ -24,7 +24,11 @@ file.on('finish', function() {

.pipe(zlib.createGunzip())
.pipe(tar.Extract({ path: dest}))
.on('error', function(error) { cb(error)})
.on("end", function() { cb(null)})
.pipe(tar.extract(dest))
.on('error', function(error) {
cb(error);
})
.on('finish', function() {
cb(null);
});
};
module.exports = seedTools;
module.exports = seedTools;

@@ -24,13 +24,13 @@ 'use strict';

// Fetch the current directory
function(callback) {
callback(null, process.cwd() + '/public');
function(cb) {
cb(null, path.join(process.cwd(), '/public');
},
// Rescursive lookup to find all files
function(p, callback) {
function(p, cb) {
readdir(p, function (err, files) {
return callback(err, files);
return cb(err, files);
});
},
// Turn the files into a manifest object
function(files, callback) {
function(files, cb) {
files.forEach(function(current) {

@@ -47,17 +47,17 @@ var contentType = mime.lookup(current);

});
return callback(null, { manifest: manifest });
return cb(null, { manifest: manifest });
},
// Fetch Container-id and Widget-id
function(config, callback) {
function(conf, cb) {
getProjectMeta(function(error, data) {
// @TODO handle error case where we don't have a widget_id
var meta = data;
config.widgetId = meta.widget_id;
return callback(error, config);
conf.widgetId = meta.widget_id;
return cb(error, conf);
});
},
// Push
function(config, callback) {
widgetPush(config.widgetId, config.manifest, function(err, data) {
return callback(err, data);
function(conf, cb) {
widgetPush(conf.widgetId, conf.manifest, function(err, data) {
return cb(err, data);
});

@@ -74,3 +74,2 @@ }

}
return;
}

@@ -85,3 +84,5 @@ getProjectMeta(function(error, results) {

if (typeof callback == 'function') return callback(err, data);
if (typeof callback === 'function') {
return callback(err, data);
}
});

@@ -88,0 +89,0 @@ };

{
"name": "famous-cli",
"version": "0.2.8",
"description": "CLI interface for Famous Industries Web Services",
"main": "index.js",
"repository": "https://github.famo.us/hub/famous-cli.git",
"preferGlobal": "true",
"bin": {
"famous": "bin/famous.js"
},
"scripts": {
"test": "tap spec",
"name": "famous-cli",
"version": "0.2.9",
"description": "CLI interface for Famous Industries Web Services",
"main": "index.js",
"repository": "https://github.famo.us/hub/famous-cli.git",
"preferGlobal": "true",
"bin": {
"famous": "bin/famous.js"
},
"scripts": {
"test": "tap spec",
"lint": "eslint bin/ lib/",

@@ -38,3 +38,5 @@ "debug": "node --debug server.js"

"recursive-readdir": "1.2.1",
"tar": "^2.1.1",
"slash": "^1.0.0",
"uuid": "^2.0.1",
"tar-fs": "^1.5.1",
"win-spawn": "^2.0.0"

@@ -41,0 +43,0 @@ },

@@ -10,2 +10,2 @@ var storage = require('../res/sdk-bundle').storage;

"mixpanel_id":"75fgF0zZO7d7sdfs1HwbfgO/R5r7c2nl7IkmYK5bY="
}, function(){});
}, function(){});
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