Browse Source

Elxr standalone + New cmd to clean

master
anish 3 years ago
parent
commit
33ab94d904
2 changed files with 27 additions and 14 deletions
  1. 21
    12
      index.js
  2. 6
    2
      package.json

+ 21
- 12
index.js View File



var ENV = Object.assign({}, process.env); // Shallow clone it. var ENV = Object.assign({}, process.env); // Shallow clone it.


const { readdir } = require("fs").promises

// Directory shallow walk and do perform on each dir.
const dirs = async (perform, path) => {
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
if (dir.isDirectory()) perform(dir)
}
}

var getShellTask = (command, args, options) => { var getShellTask = (command, args, options) => {
options = options || {} options = options || {}
return () => { return () => {


// elxr cli operations // elxr cli operations
var op = { var op = {
'h': () => { console.log(elxr.info()); return '-h' }
'h': () => { console.log(elxr.help()); return '-h' }
, 'clean' : () => {
// delete all node_module folders and links.
var tasklist = [];
dirs( (repodir)=> tasklist.push(getShellTask('rm',['-rf', 'node_modules'], { cwd : instanceroot + '/' + repodir.name })()), instanceroot )
return Promise.all(tasklist)
}
, 'undefined': () => { return op.h(); } , 'undefined': () => { return op.h(); }
, 'reset': () => { , 'reset': () => {


}) })
} }


const { readdir } = require("fs").promises

const dirs = async (perform, path) => {
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
if (dir.isDirectory()) perform(dir)
}
}

dirs(perform_git_seturl) dirs(perform_git_seturl)
} }
, 'add': (remotename, url, branch) => { , 'add': (remotename, url, branch) => {
}) })




// PB : TODO -- npm i for client is for some reason not complete so bower doesn't get installed !!!
// Second time try also doesnt work.
// repotasks.push( // repotasks.push(
// () => { // () => {
// console.log(`--------------------second time npm i for client--------------------`) // console.log(`--------------------second time npm i for client--------------------`)
// Built version. // Built version.
// check if we have a elxr subfolder. // check if we have a elxr subfolder.
if (fs.existsSync(launchpath + '/..' + path.normalize('/elxr'))) { if (fs.existsSync(launchpath + '/..' + path.normalize('/elxr'))) {
// Probably in the right place.
// Probably in the right place.
root = path.normalize(launchpath + '/..'); root = path.normalize(launchpath + '/..');
} }
else { else {
} }
catch (e) { catch (e) {
console.error(e) console.error(e)
console.error('No local instances found in current root = ' + selectedinstance.root);
console.log('We will create a new one with the instance and environment chosen...')
console.error('No local instances config found in current root = ' + selectedinstance.root);
console.log('A config will be createed with the instance and environment chosen...')
} }
finally { finally {

+ 6
- 2
package.json View File

"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build-commented": "rollup index.js --format cjs --file elxr.js", "build-commented": "rollup index.js --format cjs --file elxr.js",
"build": "rollup -c"
"build": "rollup -c",
"index": "SET FORCE_COLOR=true && node index"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"bbhverse": "file:../bbhverse",
"bbhverse": "git+http://git.bbh/chess/bbhverse",
"global-this": "git+http://git.bbh/chess/global-this",
"moment": "^2.27.0",
"crossfilter2": "^1.5.4",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"glob": "^7.1.2", "glob": "^7.1.2",
"tree-kill": "^1.2.2" "tree-kill": "^1.2.2"

Loading…
Cancel
Save