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

devcycle

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devcycle - npm Package Compare versions

Comparing version 0.1.7 to 0.1.11

441

devcycle.js

@@ -1,40 +0,131 @@

var program = require('commander');
var nodefs = require('node-fs');
var colorize = require('colorize');
var cconsole = colorize.console;
var program = require('commander');
var nodefs = require('node-fs');
var colorize = require('colorize');
var cconsole = colorize.console;
var fs = require('fs');
var wrench = require('wrench');
var util = require('util');
var dateFormat = require('dateformat');
var folderDevelopment = "development";
var folderTesting = "testing";
var folderDeployment = "production";
var folderRepository = "repository";
//.option('-c, --create', 'create folders: development, testing, production and repositories')
program
.version('0.1.7')
.option('-c, --create', 'Create Folder')
.option('-t, --test', 'Move To Testing')
.option('-d, --deploy', 'Move To Deployment')
.option('-l, --list', 'List Files')
.parse(process.argv);
.version('0.1.11')
//.option('-v, --version', 'output the version number')
program
.command('init')
.description('initialize project configuration')
.action(function(){
echo('initialize project configuration');
init();
});
if (program.create){
console.log('Create Folders');
createFolders();
}
if (program.list){
console.log('List Files');
//createFolders();
}
else if (program.test){
console.log('Move to Testing');
}
else if (program.deploy){
console.log('Move to Deployment');
}
else{
console.log('Please especiafy a parameter. Nothing done');
}
program
.command('list')
.description('list files in the development folder')
.action(function(){
echo('List files in the development folder');
listFiles(folderDevelopment, false);
});
program
.command('stats')
.description('count files in each main folder')
.action(function(){
echo('Count Files in each main folder');
listFiles(folderDevelopment, true);
listFiles(folderTesting, true);
listFiles(folderDeployment, true);
listRepositories(true);
terminate(false);
});
program
.command('copyto [action]')
.description('copy files between folders. Valid actions are "test" and "prod"')
.action(function(to){
echo('Copy files between folders');
if (action === 'test'){
echo('Copy files from #bold[development] to testing');
echo('#red[Files in Testing will be overwritten]');
}
else if (action === 'prod'){
echo('Copy files from #bold[testing] to deployment');
echo('#red[Files in Development will be overwritten]');
}
else{
echo('No valid action received.');
//echo('No valid action received.');
terminate(true);
return;
}
// interactive user input
program.confirm('continue? ', function(ok){
if(ok){
if (action === 'test')
copyFilesTo(folderTesting);
else if (action === 'prod')
copyFilesTo(folderDeployment);
}
else{
echo('#red[Operation Aborted by user. Nothing done]');
terminate(false);
}
});
//terminate(false);
});
program
.command('repo [action]')
.description('perform operations on local repository. Valid actions are "add" and "list"')
.action(function(action){
//echo('Repo -> ' + action);
if(action === 'add'){
echo('Add current development files to a new local repository entry');
addRepositoryEntry();
terminate(false);
}
else if(action === 'list'){
echo('list local repositories');
var r = listRepositories(false);
terminate(!r);
}
else{
echo('No valid action received.');
terminate(true);
}
});
program
.command('*')
.action(function(env){
//console.log('deploying "%s"', env);
echo('#red[Please especify a valid command. Nothing done]');
terminate(true);
});
program.parse(process.argv);
/*

@@ -44,21 +135,229 @@ Main Functions

function init()
{
/*
createConfigurationFile( function(result){
echo('Result ' + result);
});
*/
/*
program.confirm('continue? ', function(ok){
if(ok){
}
else{
}
});
*/
createFolders();
}
function createFolders()
{
createFolder(folderDevelopment, function(result){
if(result){
createFolder(folderTesting, function(result2){
if(result2){
createFolder(folderDeployment, function(result3){
if(result3){
echo('#green[All Folder Created!]');
}
})
}
})
var n = 0;
if( folderExists(folderDevelopment) === false ){
createFolder(folderDevelopment, function(result){
n++;
if(result){
echo('#green[#bold[Development] Folder Created]');
}
else{
echo('#red[#bold[Development] folder could not be created.]');
}
if(n === 4) terminate(false);
});
}
else{
echo('#yellow[#bold[Development] Folder already exists. Skipped]');
}
if( folderExists(folderTesting) === false ){
createFolder(folderTesting, function(result2){
n++;
if(result2){
echo('#green[#bold[Testing] Folder Created]');
}
else{
echo('#red[#bold[Testing] folder could not be created.]');
}
if(n === 4) terminate(false);
});
}
else{
echo('#yellow[#bold[Testing] Folder already exists. Skipped]');
}
if( folderExists(folderDeployment) === false ){
createFolder(folderDeployment, function(result3){
n++;
if(result3){
echo('#green[#bold[Deployment] Folder Created]');
}
else{
echo('#red[#bold[Deployment] folder could not be created.]');
}
if(n === 4) terminate(false);
})
}
else{
echo('#yellow[#bold[Deployment] Folder already exists. Skipped]');
}
if( folderExists(folderRepository) === false ){
createFolder(folderRepository, function(result3){
n++;
if(result3){
echo('#green[#bold[Repository] Folder Created]');
}
else{
echo('#red[#bold[Repository] folder could not be created.]');
}
if(n === 4) terminate(false);
})
}
else{
echo('#yellow[#bold[Repository] Folder already exists. Skipped]');
}
}
function createConfigurationFile(callback)
{
var config = {
id: 1,
lastName: "last name",
firstName: "first name"
};
var text = JSON.stringify(config);
fs.writeFile("devcycle-config.json", text, function(err) {
if(err) {
echo('$red['+err+']');
callback('error');
} else {
echo("#green[Configuration file was created]");
callback('ok');
}
})
});
}
function listFiles(folder, onlyTotals)
{
var r = folderExists(folder);
if(r){
var fl = wrench.readdirSyncRecursive(folder);
echo('Files Found in #green["' + folder + '"]: #bold['+ fl.length + ']');
if(onlyTotals === false){
for( var i = 0; i < fl.length; i++ ) {
echo('- #green["' + fl[i] + '"]');
}
}
}
else{
// folder does not exist
echo('#red[Folder #bold["' + folder + '"] does not exist]');
}
}
function listRepositories(onlyTotals)
{
if( folderExists(folderRepository) ){
var fl = fs.readdirSync(folderRepository);
echo('Repository Entries Found: #bold['+ fl.length + ']');
if(onlyTotals === false){
for( var i = 0; i < fl.length; i++ ) {
echo((i+1) + ' #green["' + fl[i] + '"]');
}
}
//if(fl.length == 0)
// echo('#yellow[No Repository entries found]');
return true;
}
else{
echo('#red[#bold[Repository] folder does not exist]');
return false;
}
}
function copyFilesTo(to)
{
var fl;
if(to == folderTesting){
var foldersExist = checkSourceDestinationFolders(folderDevelopment, folderTesting);
if(foldersExist === false){
terminate(true);
return;
}
else{
wrench.copyDirSyncRecursive(folderDevelopment, folderTesting);
listFiles(folderDevelopment, true);
listFiles(folderTesting, true);
}
}
else if(to == folderDeployment){
var foldersExist = checkSourceDestinationFolders(folderTesting, folderDeployment);
if(foldersExist === false){
terminate(true);
return;
}
else{
wrench.copyDirSyncRecursive(folderTesting, folderDeployment);
listFiles(folderTesting, true);
listFiles(folderDeployment, true);
}
}
else{
echo("#red[Invalid Destinastion folder for copyFiles operation.]");
terminate(true);// terminate with error
return;
}
terminate(false);
}
function addRepositoryEntry()
{
var foldersExist = checkSourceDestinationFolders(folderDevelopment, folderRepository);
if(foldersExist === false){
terminate(true);
return;
}
else{
// create folder
var now = new Date();
var folderName = folderRepository + '/' + dateFormat(now, "yyyy-mm-dd 'T' HHMMss");
//echo('===>>> ' + folderName);
wrench.mkdirSyncRecursive( folderName, 0777);
wrench.copyDirSyncRecursive(folderDeployment, folderName);
listFiles(folderDeployment, true);
listFiles(folderName, true);
}
}
/*

@@ -68,17 +367,10 @@ Util Function

function checkFolders()
{
return "ok-f";
}
function createFolder(folder, callback)
{
echo('create folder: ' + folder);
//echo('create folder: ' + folder);
nodefs.mkdir(folder, 0777, function (err) {
if (err) {
echo('#red[Directory Error]: [' + err + ']');
if(err){
callback(false);
}
else {
echo('++ Directory created: [' + folder + ']');
else{
callback(true);

@@ -89,4 +381,49 @@ }

function folderExists(path)
{
try {
var r = fs.statSync(path).isDirectory();
//echo('1r: ' + r);
return r
}
catch(er){
//echo('2r: ' + er);
return false
}
}
function checkSourceDestinationFolders(source, destination)
{
var foldersExist = true;
if( folderExists(source) === false ){
echo('#red[#bold['+source+'] folder does not exist]');
foldersExist = false;
}
if( folderExists(destination) === false ){
echo('#red[#bold['+destination+'] folder does not exist]');
foldersExist = false;
}
return foldersExist;
}
function echo(msg){
cconsole.log('#yellow[Assistant]: ' + msg);
}
if(msg === ''){
console.log(' ');
return;
}
cconsole.log('#bold[devcycle]: ' + msg);
}
function terminate(error){
if(error)
echo('#red[Error. Task was not completed]');
else
echo('#blue[Task completed. Exit]');
echo('');
process.exit();
}

5

package.json
{
"name": "devcycle",
"version": "0.1.7",
"version": "0.1.11",
"description": "devcycle is command line interface that helps to move files from development to testing and testing to production",

@@ -9,3 +9,4 @@ "main": "devcycle.js",

"node-fs": ">= 0.1.4",
"colorize": ">= 0.1.0"
"colorize": ">= 0.1.0",
"dateformat": ">= 1.0.2"
},

@@ -12,0 +13,0 @@ "scripts": {

@@ -1,12 +0,23 @@

## DevCyle
## DevCycle
devcycle is command line interface that helps to move files from development
to testing and testing to production
Right now, the following operations are supported:
Right now, the following comands are supported:
** * Create folder
** * Move to Testing folder
** * Move to Deployment folder
** * List all file in testing folders
**init:
initialize project configuration
**list
list files in the development folder
**stats
count files in each main folder
**copyto [action]
copy files between folders. Valid actions are "test" and "prod"
**repo [action]
perform operations on local repository. Valid actions are "add" and "list"
This CLI uses as default the following names for your folders:

@@ -17,5 +28,6 @@

** production
** repository
It's also under the assumtion that you will have all 3 folders under the same
folder, for instance if you application ame is "my-app", your folder estructure
It's also under the assumtion that you will have all 4 folders under the same
folder, for instance if you application's name is "my-app", your folder estructure
will look like this:

@@ -26,2 +38,3 @@

../my-app/production
../my-app/repository

@@ -28,0 +41,0 @@ Type "devcycle -h" for an overview of the supported arguments.

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