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

fabric-cli

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabric-cli - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

config.json

127

index.js

@@ -5,37 +5,118 @@ #!/usr/bin/env node

const program = require('commander');
const inquirer = require('inquirer');
const appRoot = require('app-root-path');
const fs = require('fs');
const figlet = require('figlet');
const chalk = require('chalk');
const exec = require('child_process').exec;
const chalk = require('chalk');
const pkg = require('./package.json');
const cmd = 'grunt';
const prompt = inquirer.createPromptModule();
const buildConfig = require(appRoot + '/config.json');
function trailingSlash(path) {
return path.endsWith('/') ? path : path + '/';
}
function log(data) {
data.stdout.on('data', function (data) {
process.stdout.write(data);
data.stdout.on('data', data => process.stdout.write(data));
data.stderr.on('data', data => process.stdout.write(data));
data.on('close', function (code) {
if (code) console.log('[END] code', code);
if (stdout) console.log('[END] stdout "%s"', stdout);
if (stderr) console.log('[END] stderr "%s"', stderr);
});
}
data.stderr.on('data', function (data) {
process.stdout.write(data);
});
function defaultTask(path) {
return 'rm src/build; ln -s ' + path + ' src/build; grunt';
}
function run(task) {
function argument(task, name, path, basePath) {
const config = readConfig();
let project;
let command;
let buildInfo;
task === 'start' ? command = cmd : command = cmd + ' ' + task;
let fabric = exec(command + ' --colors');
log(fabric);
if (task === 'Connect build') {
command = 'rm src/build; ln -s ' + config.basePath + path + ' src/build; grunt';
buildInfo = require(config.basePath + trailingSlash(path) + 'package.json');
buildConfig.projects.push({ name: buildInfo.name, path: config.basePath + path });
fs.writeFile(appRoot + '/config.json', JSON.stringify(buildConfig, null, 2), err => {
if (err) return console.log(err);
console.log('Build stored!');
});
}
if (task === 'Start build') {
project = config.projects.find(obj => obj.name === name);
command = defaultTask(project.path);
}
if (task === 'Connect base') {
buildConfig.basePath = trailingSlash(basePath);
fs.writeFile(appRoot + '/config.json', JSON.stringify(buildConfig, null, 2), err => {
if (err) return console.log(err);
console.log('Base path stored!');
});
}
return command;
}
program
.version(pkg.version)
.arguments('[task]')
.version(pkg.version)
.description('CLI for Fabric')
.action(function (task) {
run(task);
});
function readConfig() {
return JSON.parse(fs.readFileSync(appRoot + '/config.json', 'utf8'));
}
program.parse(process.argv);
function getBuilds() {
const builds = readConfig();
let projects = new Array();
if (program.args.length === 0) program.help();
projects = Array.from(new Set(builds.projects.map(JSON.stringify))).map(JSON.parse);
return projects;
}
function run(task, name, path, rootPath) {
const command = argument(task, name, path, rootPath);
const fabric = command ? exec(command) : null;
fabric !== null ? log(fabric) : null;
}
const questions = [
{
type: 'list',
name: 'command',
message: 'What would you like to do?',
choices: ['Start build', 'Connect build', 'Connect base'],
},
{
type: 'list',
name: 'build',
message: 'Which build would you like to start?',
choices: getBuilds(),
when: answers => answers.command === 'Start build',
},
{
type: 'input',
name: 'path',
message: 'Enter the build path',
when: answers => answers.command === 'Connect build',
},
{
type: 'input',
name: 'basePath',
message: 'Enter your base path',
when: answers => answers.command === 'Connect base'
},
];
console.log(chalk.yellow(figlet.textSync('Fabric', { horizontalLayout: 'full' })));
prompt(questions).then(answers => {
const { command, build, path, basePath } = answers;
run(command, build, path, basePath);
});

12

package.json
{
"name": "fabric-cli",
"version": "0.0.5",
"description": "A command line tool for fabric",
"version": "0.1.0",
"description": "A command line tool for our internal fabric tooling",
"main": "index.js",

@@ -15,10 +15,14 @@ "author": "Jamie Robertson",

"dependencies": {
"app-root-path": "^2.0.1",
"chalk": "^1.1.3",
"commander": "^2.9.0"
"commander": "^2.9.0",
"figlet": "^1.2.0",
"inquirer": "^6.0.0"
},
"keywords": [
"fabric",
"fabric cli"
"fabric cli",
"cello signal fabric"
],
"license": "MIT"
}

Sorry, the diff of this file is not supported yet

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