@coffeekraken/scripts-stack
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -32,4 +32,6 @@ "use strict"; | ||
const Script = require('./Script').default; | ||
const pkgUp = require('pkg-up'); | ||
const Script = require('./Script'); | ||
class scriptsStack { | ||
@@ -48,8 +50,29 @@ constructor(config) { | ||
if (fs.existsSync(`${process.env.PWD}/package-scripts.js`)) { | ||
this._packageScripts = require(`${process.env.PWD}/package-scripts.js`); | ||
this._packageScripts; | ||
if (fs.existsSync("".concat(process.env.PWD, "/package-scripts.js"))) { | ||
this._packageScripts = require("".concat(process.env.PWD, "/package-scripts.js")); | ||
} // check if we have a packageJson in an upper folder | ||
this._packageUpJson; | ||
const pkgUpPath = pkgUp.sync({ | ||
cwd: process.cwd() + "/../" | ||
}); | ||
if (pkgUpPath) { | ||
const packageUp = require(pkgUpPath); | ||
if (packageUp) { | ||
this._packageUpJson = packageUp; | ||
} | ||
} // set the process name | ||
process.title = `scripts-stack.${this._packageJson.name}`; | ||
process.title = "scripts-stack.".concat(this._packageJson.name); // save the scripts in a global variable | ||
this._scriptsObj = {}; | ||
if (this._packageScripts && this._packageScripts.scripts) this._scriptsObj = this._packageScripts.scripts; | ||
if (this._packageJson && this._packageJson.scripts) this._scriptsObj = this._packageJson.scripts; | ||
if (this._packageUpJson && this._packageUpJson.scripts) this._scriptsObj = this._packageUpJson.scripts; | ||
} | ||
@@ -61,4 +84,6 @@ | ||
this._scriptsIds = Object.keys(flatten(this._packageScripts.scripts)); | ||
} else { | ||
} else if (this._packageJson.scripts) { | ||
this._scriptsIds = Object.keys(this._packageJson.scripts); | ||
} else if (this._packageUpJson.scripts) { | ||
this._scriptsIds = Object.keys(this._packageUpJson.scripts); | ||
} // remove the ignored scripts | ||
@@ -119,5 +144,7 @@ | ||
watchObj = this._packageJson.watch[scriptId]; | ||
} else if (this._packageUpJson.watch && this._packageUpJson.watch[scriptId]) { | ||
watchObj = this._packageUpJson.watch[scriptId]; | ||
} | ||
stack[scriptId] = new Script(scriptId, watchObj, this._packageScripts ? 'nps' : 'npm'); | ||
stack[scriptId] = new Script(scriptId, this._scriptsObj[scriptId], watchObj, 'npm'); | ||
@@ -176,10 +203,10 @@ if (this._config.watch) { | ||
if (this._packageJson.license) { | ||
headerContent.push(chalk.bold.white.bgBlack(` ${this._packageJson.license} `)); | ||
headerContent.push(chalk.bold.white.bgBlack(" ".concat(this._packageJson.license, " "))); | ||
} | ||
headerContent.push(`${chalk.black.bold(this._packageJson.name)} ${chalk.bgWhite.black(' ' + this._packageJson.version + ' ')}`); | ||
headerContent.push("".concat(chalk.black.bold(this._packageJson.name), " ").concat(chalk.bgWhite.black(' ' + this._packageJson.version + ' '))); | ||
screen.$headerBox = blessed.box({ | ||
parent: screen.$container, | ||
width: '100%', | ||
content: `\n ${headerContent.join(' ')}`, | ||
content: "\n ".concat(headerContent.join(' ')), | ||
height: 3, | ||
@@ -253,3 +280,3 @@ style: { | ||
width: '100%', | ||
content: ``, | ||
content: "", | ||
height: 2, | ||
@@ -334,3 +361,3 @@ bottom: 0, | ||
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].forEach(key => { | ||
this.screen.key([`${key}`], (ch, key) => { | ||
this.screen.key(["".concat(key)], (ch, key) => { | ||
keys += key.full; | ||
@@ -367,20 +394,20 @@ clearTimeout(keyTimeout); | ||
const watchColorFn = currentScript.isWatched() ? chalk.bgBlue.black : chalk.bgWhite.black; | ||
footerContent.push(`${chalk.bgWhite.black(' Run (r) ')}`); | ||
footerContent.push(`${chalk.bgWhite.black(' Exit (e) ')}`); | ||
footerContent.push(`${chalk.bgWhite.black(' Copy (c) ')}`); | ||
footerContent.push("".concat(chalk.bgWhite.black(' Run (r) '))); | ||
footerContent.push("".concat(chalk.bgWhite.black(' Exit (e) '))); | ||
footerContent.push("".concat(chalk.bgWhite.black(' Copy (c) '))); | ||
if (currentScript.isWatchable()) { | ||
footerContent.push(`${watchColorFn(' Watch (w) ')}`); | ||
footerContent.push("".concat(watchColorFn(' Watch (w) '))); | ||
} | ||
footerContent.push(`${switchColorFn(' Switch (s) ')}`); // footerContent.push(`${chalk.bgWhite.black(' Exit ')} ${chalk.bold.black('ctrl-c')} `) | ||
footerContent.push("".concat(switchColorFn(' Switch (s) '))); // footerContent.push(`${chalk.bgWhite.black(' Exit ')} ${chalk.bold.black('ctrl-c')} `) | ||
footerContent.push(`\n`); | ||
footerContent.push("\n"); | ||
if (this._packageJson.homepage) { | ||
footerContent.push(`${chalk.bgBlack.white(' Homepage ')} ${chalk.bold.black(this._packageJson.homepage)} `); | ||
footerContent.push("".concat(chalk.bgBlack.white(' Homepage '), " ").concat(chalk.bold.black(this._packageJson.homepage), " ")); | ||
} | ||
if (this._packageJson.author) { | ||
footerContent.push(`${chalk.bgBlack.white(' Author ')} ${chalk.bold.black(this._packageJson.author)}`); | ||
footerContent.push("".concat(chalk.bgBlack.white(' Author '), " ").concat(chalk.bold.black(this._packageJson.author))); | ||
} | ||
@@ -416,3 +443,3 @@ | ||
if (icon) { | ||
iconToDisplay = `${icon} `; | ||
iconToDisplay = "".concat(icon, " "); | ||
} | ||
@@ -427,3 +454,3 @@ | ||
let idx = pad(2, Object.keys(this._scriptsStack).indexOf(scriptId) + 1, '0'); | ||
return ` ${idx}. ${iconToDisplay}${readedIcon}${scriptId}`; | ||
return " ".concat(idx, ". ").concat(iconToDisplay).concat(readedIcon).concat(scriptId); | ||
} | ||
@@ -519,3 +546,3 @@ | ||
const lastSplit = splitedScript[splitedScript.length - 1]; | ||
const icon = icons.indexOf(lastSplit) !== -1 ? `icon-${lastSplit}` : null; | ||
const icon = icons.indexOf(lastSplit) !== -1 ? "icon-".concat(lastSplit) : null; | ||
@@ -527,3 +554,3 @@ if (this._config.notifications) { | ||
message: 'Completed successfuly', | ||
icon: icon ? path.join(__dirname, `../.resources/${icon}.png`) : null, | ||
icon: icon ? path.join(__dirname, "../.resources/".concat(icon, ".png")) : null, | ||
sound: true, | ||
@@ -578,2 +605,3 @@ timeout: 4 | ||
var _default = scriptsStack; | ||
exports.default = _default; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -20,5 +20,8 @@ "use strict"; | ||
const commandExistsSync = require('command-exists').sync; | ||
class Script { | ||
constructor(id, watchOpts = null, runner = 'npm') { | ||
constructor(id, script, watchOpts = null, runner = 'npm') { | ||
this._id = id; | ||
this._script = script; | ||
this._runner = runner; | ||
@@ -38,3 +41,3 @@ this._stack = []; | ||
// reset the stack | ||
this._stack = [`press ${chalk.yellow.bold('r')} to run or ${chalk.red.bold('e')} to exit the ${chalk.bold(this.id)} script`]; | ||
this._stack = ["press ".concat(chalk.yellow.bold('r'), " to run or ").concat(chalk.red.bold('e'), " to exit the ").concat(chalk.bold(this.id), " script")]; | ||
} | ||
@@ -54,5 +57,5 @@ | ||
this._stack.push(chalk.yellow(`${logSymbols.warning} Start ${chalk.bold(this.id)}\n`)); | ||
this._stack.push(chalk.yellow("".concat(logSymbols.warning, " Start ").concat(chalk.bold(this.id), "\n"))); | ||
this._stack.push(chalk.yellow(`----------------------------------------\n`)); // dispatch new data | ||
this._stack.push(chalk.yellow("----------------------------------------\n")); // dispatch new data | ||
@@ -66,11 +69,13 @@ | ||
this._isRunning = true; // build command stack | ||
this._isRunning = true; // manage runner | ||
if (commandExistsSync('ck')) this._runner = 'ck'; // build command stack | ||
const commandArgs = []; | ||
if (this._runner === 'npm') commandArgs.push('run'); | ||
commandArgs.push(this.id); | ||
commandArgs.push('--silent'); // spawn a new process with the runner and commandArgs | ||
if (this._runner === 'npm' || this._runner === 'ck') commandArgs.push('run'); | ||
commandArgs.push(this.id); // spawn a new process with the runner and commandArgs | ||
this._childScript = spawn(this._runner, commandArgs, { | ||
detached: true | ||
detached: true, | ||
cwd: process.cwd() | ||
}); | ||
@@ -108,10 +113,10 @@ | ||
// append that the script has been launched | ||
this._stack.push(chalk.green(`----------------------------------------\n`)); | ||
this._stack.push(chalk.green("----------------------------------------\n")); | ||
this._stack.push(chalk.green(`${logSymbols.success} Completed ${chalk.bold(this.id)} in ${(endTime - startTime) / 1000}s\n`)); | ||
this._stack.push(chalk.green("".concat(logSymbols.success, " Completed ").concat(chalk.bold(this.id), " in ").concat((endTime - startTime) / 1000, "s\n"))); | ||
} else { | ||
// append that the script has been launched | ||
this._stack.push(chalk.red(`----------------------------------------\n`)); | ||
this._stack.push(chalk.red("----------------------------------------\n")); | ||
this._stack.push(chalk.red(`${logSymbols.error} Error in ${chalk.bold(this.id)} after ${(endTime - startTime) / 1000}s\n`)); | ||
this._stack.push(chalk.red("".concat(logSymbols.error, " Error in ").concat(chalk.bold(this.id), " after ").concat((endTime - startTime) / 1000, "s\n"))); | ||
} // dispatch new data | ||
@@ -248,2 +253,6 @@ | ||
get script() { | ||
return this._script; | ||
} | ||
get stack() { | ||
@@ -256,2 +265,3 @@ this.markAsRead(); | ||
exports.default = Script; | ||
exports.default = Script; | ||
module.exports = exports.default; |
{ | ||
"name": "@coffeekraken/scripts-stack", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Nice terminal interface to handle npm/yarn scripts execution as well as watch and run automatically the wanted ones", | ||
"homepage": "https://coffeekraken.io", | ||
"bin": { | ||
"coffeekraken-scripts-stack": "./bin/coffeekraken-scripts-stack" | ||
"coffeekraken-scripts-stack": "./bin/coffeekraken-scripts-stack", | ||
"ck-scripts-stack": "./bin/coffeekraken-scripts-stack" | ||
}, | ||
"scripts": { | ||
"start": "nps start" | ||
}, | ||
"keywords": [ | ||
@@ -34,12 +32,5 @@ "coffee", | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.0.0-beta.36", | ||
"git-changelog": "^1.1.2", | ||
"nps": "^5.9.5", | ||
"nps-utils": "^1.7.0", | ||
"standard": "^10.0.3" | ||
}, | ||
"dependencies": { | ||
"@babel/cli": "^7.0.0-beta.36", | ||
"@babel/core": "^7.0.0-beta.36", | ||
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.36", | ||
"ansi-styles": "^3.2.0", | ||
@@ -50,2 +41,3 @@ "blessed": "^0.1.81", | ||
"clipboardy": "^1.2.3", | ||
"command-exists": "^1.2.8", | ||
"commander": "^2.9.0", | ||
@@ -57,2 +49,3 @@ "create-symlink": "^1.0.0", | ||
"pad": "^2.0.3", | ||
"pkg-up": "^3.1.0", | ||
"remove-blank-lines": "^1.0.8", | ||
@@ -62,3 +55,3 @@ "strip-ansi": "^4.0.0", | ||
}, | ||
"gitHead": "2b8f8ee90dadff470f7743ca5266821e08e24d79" | ||
"gitHead": "439d0eac5d23f6337d3a6afda31f42cefe3ae0ba" | ||
} |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38073
16
1
8
638
1
6
8
+ Addedcommand-exists@^1.2.8
+ Addedpkg-up@^3.1.0
+ Addedcommand-exists@1.2.9(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedpkg-up@3.1.0(transitive)
- Removed@babel/cli@^7.0.0-beta.36
- Removed@babel/core@^7.0.0-beta.36
- Removed@babel/plugin-proposal-class-properties@^7.0.0-beta.36
- Removed@ampproject/remapping@2.3.0(transitive)
- Removed@babel/cli@7.26.4(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/compat-data@7.26.5(transitive)
- Removed@babel/core@7.26.0(transitive)
- Removed@babel/generator@7.26.5(transitive)
- Removed@babel/helper-annotate-as-pure@7.25.9(transitive)
- Removed@babel/helper-compilation-targets@7.26.5(transitive)
- Removed@babel/helper-create-class-features-plugin@7.25.9(transitive)
- Removed@babel/helper-member-expression-to-functions@7.25.9(transitive)
- Removed@babel/helper-module-imports@7.25.9(transitive)
- Removed@babel/helper-module-transforms@7.26.0(transitive)
- Removed@babel/helper-optimise-call-expression@7.25.9(transitive)
- Removed@babel/helper-plugin-utils@7.26.5(transitive)
- Removed@babel/helper-replace-supers@7.26.5(transitive)
- Removed@babel/helper-skip-transparent-expression-wrappers@7.25.9(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/helper-validator-option@7.25.9(transitive)
- Removed@babel/helpers@7.26.0(transitive)
- Removed@babel/parser@7.26.5(transitive)
- Removed@babel/plugin-proposal-class-properties@7.18.6(transitive)
- Removed@babel/template@7.25.9(transitive)
- Removed@babel/traverse@7.26.5(transitive)
- Removed@babel/types@7.26.5(transitive)
- Removed@jridgewell/gen-mapping@0.3.8(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3(transitive)
- Removedanymatch@3.1.3(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbinary-extensions@2.3.0(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@3.0.3(transitive)
- Removedbrowserslist@4.24.4(transitive)
- Removedcaniuse-lite@1.0.30001692(transitive)
- Removedchokidar@3.6.0(transitive)
- Removedcommander@6.2.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconvert-source-map@2.0.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removedelectron-to-chromium@1.5.83(transitive)
- Removedescalade@3.2.0(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfs-readdir-recursive@1.1.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfsevents@2.3.3(transitive)
- Removedgensync@1.0.0-beta.2(transitive)
- Removedglob@7.2.3(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedglobals@11.12.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-binary-path@2.1.0(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjsesc@3.1.0(transitive)
- Removedjson5@2.2.3(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedmake-dir@2.1.0(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedms@2.1.3(transitive)
- Removednode-releases@2.0.19(transitive)
- Removednormalize-path@3.0.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedpify@4.0.1(transitive)
- Removedreaddirp@3.6.0(transitive)
- Removedsemver@6.3.1(transitive)
- Removedslash@2.0.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedupdate-browserslist-db@1.1.2(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyallist@3.1.1(transitive)