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

dek

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dek - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

3

cli.js
import Event from './SystemEvents'
import dotenv from 'dotenv'
dotenv.config({ path: `${process.cwd()}/.env` })
Event.emit('loadCli',process.cwd())

@@ -12,7 +12,7 @@ import Event from './SystemEvents'

export let o = Organized
export let success = log.success
export let danger = log.danger
export let warning = log.warning
export let info = log.info
export let error = log.error
export let add = (item, index) => {

@@ -19,0 +19,0 @@ load(item, index)

import glob from 'glob'
import debug from 'debug'
import colors from 'colors/safe'
import minimist from 'minimist'
import clone from 'git-clone'
var argv = minimist(process.argv.slice(2))
var Organized = {}
let success = (text) => {
if(process.env.DEBUG == 'true')
console.log(colors.green(text))
}
export default Organized
let error = (text) => {
if(process.env.DEBUG == 'true')
console.log(colors.red(text))
}
export let generator = {}
export let log = {
success:success,
error:error
success:(text) => {
console.log(colors.black.bgGreen(' '),colors.bold.green('-> '+text))
console.log('')
},
danger:(text) => {
console.log(colors.black.bgRed(' '), colors.bold.red('-> '+text))
console.log('')
},
warning:(text) => {
console.log(colors.black.bgYellow(' '),colors.bold.yellow('-> '+text))
console.log('')
},
info:(text) => {
console.log(colors.black.bgCyan(' '), colors.bold.cyan('-> '+text))
console.log('')
}
}
export default Organized
export let generator = {}
export function load(index, item) {
export let load = (index, item) => {
Organized[index] = item
}
export function loadGenerator(index, item) {
export let loadGenerator = (index, item) => {
generator[index] = item
}
export function installPackages(packages){
export let installPackages = (packages) => {
var child_process = require('child_process');

@@ -42,5 +49,6 @@

}
var module = modules.shift();
var moduleName = modules.join(" ");
child_process.exec(
'npm install ' + module,
'npm install ' + moduleName,
{},

@@ -54,3 +62,3 @@ function(error, stdout, stderr) {

else {
install(modules, callback);
if(callback) callback();
}

@@ -62,3 +70,3 @@ });

export async function loadAll(folders,cb){
export let loadAll = async (folders,cb) => {

@@ -94,40 +102,42 @@ let listFiles = async (dir) => {

let listOfFiles = {}
if(files.length > 0){
for(let i in files){
for(let i in files){
let file = files[i]
const routerFile = require(file)
order[routerFile.name] = routerFile.dependencies
listOfFiles[routerFile.name] = routerFile
if(files.length - 1 == i){
let file = files[i]
const routerFile = require(file)
order[routerFile.name] = routerFile.dependencies
listOfFiles[routerFile.name] = routerFile
let orderOfPlugins = resolve(order)
for(let j in orderOfPlugins){
if(files.length - 1 == i){
let plugin = orderOfPlugins[j]
if(typeof routerFile == 'object' && routerFile.hasOwnProperty('default'))
await listOfFiles[plugin].default(Organized)
else if(typeof routerFile == 'function')
await listOfFiles[plugin](Organized)
if(orderOfPlugins.length - 1 == j){
if(cb) cb()
}
let orderOfPlugins = resolve(order)
for(let j in orderOfPlugins){
let plugin = orderOfPlugins[j]
if(typeof routerFile == 'object' && routerFile.hasOwnProperty('default'))
await listOfFiles[plugin].default(Organized)
else if(typeof routerFile == 'function')
await listOfFiles[plugin](Organized)
if(orderOfPlugins.length - 1 == j){
if(cb) cb()
}
}
}
}
}
}else{
if(cb) cb()
}
}
var argv = require('minimist')(process.argv.slice(2));
export let loadCli = async (folders,cb) => {
export async function loadCli(folders,cb){
let listFiles = async (dir) => {

@@ -179,3 +189,3 @@ return new Promise((acc, rej) => {

let cliService = process.argv[2]
success(plugin)
log.success(plugin)
if(listOfFiles[plugin].hasOwnProperty('cli') && plugin == cliService){

@@ -198,3 +208,3 @@ await listOfFiles[plugin].cli(argv)

export async function loadNpmDependencies(folders,cb){
export let loadNpmDependencies = async (folders,cb) => {

@@ -252,3 +262,20 @@ let listFiles = async (dir) => {

function resolve(graph) {
export let cloneRepositoryList = async (list,cb) => {
let getRepositoryName = (name) => name.replace('https://github.com/','').split("/")
let repository = list.shift()
let repositoryName = getRepositoryName(repository)[1]
clone(repository, `${process.cwd()}/plugins/${repositoryName}`, (err) => {
if(err)
log.warning(`Repositório ${repositoryName} já foi instalado anteriormente!`)
else
log.warning(`Repositório ${repositoryName} instalado com sucesso!`)
if(list.length > 0)
cloneRepositoryList(list, cb)
else
if(cb) cb()
})
}
let resolve = (graph) => {
var sorted = [], // sorted list of IDs ( returned value )

@@ -255,0 +282,0 @@ visited = {}; // hash: id of already visited node => true

{
"name": "dek",
"version": "0.1.0",
"version": "0.2.0",
"description": "",

@@ -15,3 +15,4 @@ "main": "entry.js",

"dotenv": "^6.2.0",
"esm": "^3.0.84"
"esm": "^3.0.84",
"git-clone": "^0.1.0"
},

@@ -18,0 +19,0 @@ "bin": {

import EventEmitter from 'events'
import oz, {load, loadAll, loadCli, generator, log, installPackages, loadNpmDependencies} from './Organized'
import {loadAll, loadCli, generator, log, installPackages, loadNpmDependencies, cloneRepositoryList} from './Organized'
import minimist from 'minimist'

@@ -36,6 +36,11 @@

let generatorFunc = argv['_'].hasOwnProperty(1) ? argv['_'][1] : false
if(cliFunc && cliFunc == 'install'){
log.info('Instalando dependências')
let list = require(`${process.cwd()}/dependencies.json`)
if(cliFunc && cliFunc == 'install'){
console.log('Buscando dependências')
loadNpmDependencies([dir + '/plugins/*/npm.js'])
cloneRepositoryList(list.plugins,() => {
loadNpmDependencies([dir + '/plugins/*/npm.js'])
})
}else{

@@ -42,0 +47,0 @@ loadAll([dir + '/plugins/*/main.js'], async () => {

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