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

cml-cli

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cml-cli - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23

lib/banner.js

165

index.js

@@ -7,126 +7,57 @@ 'use strict';

var path = require('path');
var spawnSync = require('child_process').spawnSync;
var spawn = require('child_process').spawn;
var moment = require('moment');
var config = require(path.join(process.env.HOME, process.env.CML_CONFIG));
require('autocmdr/lib/help')(program);
/**
* Spawns a gulp task process
* @param {[String]} task_name Task name
* @param {[String]} cwd Working directory
* @return {[Object]} Process data
*/
function run_task(task_name, cwd) {
console.log(chalk.grey('Starting task: ') + chalk.bold.white(task_name));
console.log(chalk.grey('Working directory: ') + chalk.bold.white(cwd));
return spawnSync('gulp', [task_name], {
cwd: cwd
});
}
var empty_project = require('./lib/empty_project');
var spawn_task = require('./lib/spawn_task');
var handle_task = require('./lib/handle_task');
var remove_compiled_assets = require('./lib/remove_compiled_assets');
function spawn_task(task_name, cwd) {
program
.version(pkg.version)
.option('-b, --build', 'create production build')
.option('-d, --development', 'start development')
.option('-D, --docs', 'generate project docs')
.option('-l, --lint', 'lint markup, styles and script sources')
.option('-t, --test', 'run tests')
.option('-R, --reset', 'reset project to empty state (removes every view, script, style and assets)')
.option('-g, --generate', 'generate view, page or pattern')
.parse(process.argv);
console.log(chalk.grey('Starting task: ') + chalk.bold.white(task_name));
console.log(chalk.grey('Working directory: ') + chalk.bold.white(cwd));
return spawn('gulp', [task_name], {
cwd: cwd
});
if (program.build) {
remove_compiled_assets([
path.join(config.publicDir, config.publicPaths.fontsDir),
path.join(config.publicDir, config.publicPaths.imagesDir),
path.join(config.publicDir, config.publicPaths.stylesDir),
path.join(config.publicDir, config.publicPaths.scriptsDir)
], function () {
console.log(chalk.underline.green.bold('\nCompiled assets cleaned'));
handle_task(spawn_task('build', process.env.HOME));
});
}
/**
* Handles synchronous task output
* @param {[Object]} task Task result object
* @return
*/
function handle_task_sync(task) {
if (task.error) {
console.error(chalk.bold.red(task.stderr));
console.dir(JSON.stringify(task.error));
return;
}
console.log(chalk.green(task.stdout.toString()));
else if (program.development) {
handle_task(spawn_task('development', process.env.HOME));
}
function handle_task(task_process) {
var command_close_handler = function(code, signal) {
task_process.stdout.unref();
task_process.stderr.unref();
task_process.stdin.unref();
process.exit(1);
};
// subprocess exit
var command_exit_handler = function(code, signal) {
task_process.stdout.unref();
task_process.stderr.unref();
task_process.stdin.unref();
process.exit(1);
};
// subprocess error
var command_error_handler = function(err) {
task_process.stdout.unref();
task_process.stderr.unref();
task_process.stdin.unref();
task_process.kill('SIGTERM');
process.exit(1);
};
var command_buffer_handler = function(data) {
//console.log(data.toString().replace(/(\n|\r)$/gim, ''));
var stdout = data.toString();
if (!(/error:/gi).test(stdout)) {
stdout = stdout
.replace(/\[[0-9:]{6,10}\]/gi, chalk.white.bold('$&'))
.replace(/[0-9.,]{1,32}\s\w/gi, chalk.white.bold('$&'))
.replace(/gulp-[a-z]+/gi, chalk.blue.bold('$&'))
.replace(/\'.+\'/gi, chalk.blue.bold('$&'))
.replace(/finished|starting/gi, chalk.cyan.bold('$&'))
.replace(/warning: .+/gi, chalk.yellow.bold('$&'))
.replace(/doiuse: .+/gi, chalk.yellow.bold('$&'))
.replace(/(\n|\r)$/g, '');
} else {
stdout = stdout
.replace(/.+/gi, chalk.red('$&'))
.replace(/(\n|\r)$/g, '');
}
console.log(stdout);
};
task_process.stdout.on('data', command_buffer_handler);
task_process.stderr.on('data', command_buffer_handler);
task_process.stdin.on('data', command_buffer_handler);
task_process.on('close', command_close_handler);
task_process.on('exit', command_exit_handler);
task_process.on('error', command_error_handler);
else if (program.docs) {
handle_task(spawn_task('docs', process.env.HOME));
}
program
.version(pkg.version)
.option('-b, --build', 'create production build')
.option('-d, --development', 'start development')
.option('-D, --docs', 'generate project docs')
.option('-l, --lint', 'lint markup, styles and script sources')
.option('-t, --test', 'run tests')
.option('-g, --generate', 'generate view, page or pattern')
.parse(process.argv);
if (program.build) {
handle_task(spawn_task('build', path.join(__dirname, '../../')));
} else if (program.development) {
handle_task(spawn_task('development', path.join(__dirname, '../../')));
} else if (program.docs) {
handle_task(spawn_task('docs', path.join(__dirname, '../../')));
} else if (program.lint) {
handle_task(spawn_task('lint', path.join(__dirname, '../../')));
} else if (program.test) {
handle_task(spawn_task('test', path.join(__dirname, '../../')));
} else if (program.generate) {
console.log(chalk.underline.cyan.bold('Not yet implemented :('));
} else {
console.error('No command specified. See \'cml-cli --help\':');
program.outputHelp();
process.exit(1);
else if (program.lint) {
handle_task(spawn_task('lint', process.env.HOME));
}
else if (program.test) {
handle_task(spawn_task('test', process.env.HOME));
}
else if (program.generate) {
console.log(chalk.underline.cyan.bold('Not yet implemented :('));
}
else if (program.reset) {
empty_project(process.env.HOME, function () {
console.log(chalk.underline.green.bold('\n\nProject successfully resetted'));
process.exit(1);
});
}
else {
console.error('No command specified. See \'cml-cli --help\':');
program.outputHelp();
process.exit(1);
}
{
"name": "cml-cli",
"version": "0.0.22",
"version": "0.0.23",
"description": "Simple wrapper for build scripts to stabilize API and to scaffold views and common patterns of cml-frontend boilerplate. Not for standalone usage.",

@@ -21,7 +21,9 @@ "bin": {

"dependencies": {
"ansi-rainbow": "0.0.8",
"autocmdr": "~0.0.4",
"chalk": "^1.0.0",
"commander": "~2.0.0"
"commander": "~2.0.0",
"fs-extra": "^0.18.3"
},
"devDependencies": {}
}
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