@escape.tech/mookme
Advanced tools
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.FancyRenderer = void 0; | ||
| const chalk_1 = __importDefault(require("chalk")); | ||
| const status_types_1 = require("../../types/status.types"); | ||
| const writer_1 = require("../writer"); | ||
| const stepDisplayedStatuses = { | ||
| [status_types_1.ExecutionStatus.CREATED]: '🗓 Created', | ||
| [status_types_1.ExecutionStatus.RUNNING]: '🦾 Running', | ||
| [status_types_1.ExecutionStatus.FAILURE]: '❌ Error.', | ||
| [status_types_1.ExecutionStatus.SUCCESS]: '✅ Done.', | ||
| [status_types_1.ExecutionStatus.SKIPPED]: '⏩ Skipped.', | ||
| }; | ||
| class FancyRenderer { | ||
| constructor(canvas) { | ||
| this.dots = ['.. ', '. .', ' ..']; | ||
| this.currentDotIndex = 0; | ||
| this.writer = canvas || new writer_1.ConsoleCanvas(); | ||
| this.interval = setInterval(() => { | ||
| this.currentDotIndex = (this.currentDotIndex + 1) % 3; | ||
| this.currentPackages && this.render(this.currentPackages); | ||
| }, 100); | ||
| } | ||
| stop() { | ||
| this.interval && clearInterval(this.interval); | ||
| } | ||
| _renderStep(step) { | ||
| let displayedCommand = step.command; | ||
| if (step.command.length > process.stdout.columns - (step.name.length + 10)) { | ||
| displayedCommand = step.command.substring(0, process.stdout.columns - step.name.length - 15) + '...'; | ||
| } | ||
| this.writer.write(`→ ${chalk_1.default.bold(step.name)} > ${displayedCommand} `); | ||
| if (step.status === status_types_1.ExecutionStatus.RUNNING) { | ||
| this.writer.write(`${stepDisplayedStatuses[step.status]}${this.dots[this.currentDotIndex]} `); | ||
| } | ||
| else { | ||
| this.writer.write(`${stepDisplayedStatuses[step.status]} `); | ||
| } | ||
| } | ||
| _renderPacakage(pkg) { | ||
| this.writer.write(); | ||
| let message; | ||
| switch (pkg.status) { | ||
| case status_types_1.ExecutionStatus.CREATED: | ||
| message = ` Created${this.dots[this.currentDotIndex]} `; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bold.inverse(message)}`); | ||
| break; | ||
| case status_types_1.ExecutionStatus.RUNNING: | ||
| message = ` Running${this.dots[this.currentDotIndex]} `; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bgBlueBright.bold(message)}`); | ||
| break; | ||
| case status_types_1.ExecutionStatus.SUCCESS: | ||
| message = ' Done ✓ '; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bgGreen.bold(message)}`); | ||
| break; | ||
| case status_types_1.ExecutionStatus.FAILURE: | ||
| message = ' Error × '; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bgRed.bold(message)}`); | ||
| break; | ||
| } | ||
| for (const step of pkg.steps) { | ||
| this._renderStep(step); | ||
| } | ||
| } | ||
| render(packages) { | ||
| this.writer.clear(); | ||
| for (const pkg of packages) { | ||
| this._renderPacakage(pkg); | ||
| } | ||
| this.currentPackages = packages; | ||
| } | ||
| } | ||
| exports.FancyRenderer = FancyRenderer; |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.NoClearRenderer = void 0; | ||
| const chalk_1 = __importDefault(require("chalk")); | ||
| const status_types_1 = require("../../types/status.types"); | ||
| const writer_1 = require("../writer"); | ||
| const randColorHexFactory = () => { | ||
| const color = chalk_1.default.hex('#' + ((Math.random() * 0xffffff) << 0).toString(16)); | ||
| return (msg) => color(msg); | ||
| }; | ||
| const stepDisplayedStatuses = { | ||
| [status_types_1.ExecutionStatus.CREATED]: 'created', | ||
| [status_types_1.ExecutionStatus.RUNNING]: 'running', | ||
| [status_types_1.ExecutionStatus.FAILURE]: 'error', | ||
| [status_types_1.ExecutionStatus.SUCCESS]: 'done', | ||
| [status_types_1.ExecutionStatus.SKIPPED]: 'skipped', | ||
| }; | ||
| class NoClearRenderer { | ||
| constructor(canvas) { | ||
| this.packagesColorizers = new Map(); | ||
| this.writer = canvas || new writer_1.ConsoleCanvas(); | ||
| } | ||
| stop() { | ||
| return; | ||
| } | ||
| get packagesStatusMap() { | ||
| const packagesStatusMap = new Map(); | ||
| for (const pkg of this.currentPackages || []) { | ||
| const stepsStatusMap = new Map(); | ||
| for (const step of pkg.steps) { | ||
| stepsStatusMap.set(step.name, step.status); | ||
| } | ||
| packagesStatusMap.set(pkg.name, { | ||
| status: pkg.status, | ||
| steps: stepsStatusMap, | ||
| }); | ||
| } | ||
| return packagesStatusMap; | ||
| } | ||
| render(packages) { | ||
| for (const pkg of packages) { | ||
| if (!this.packagesColorizers.has(pkg.name)) | ||
| this.packagesColorizers.set(pkg.name, randColorHexFactory()); | ||
| const colorizer = this.packagesColorizers.get(pkg.name); | ||
| const pkgStatusMap = this.packagesStatusMap.get(pkg.name); | ||
| if (!pkgStatusMap) { | ||
| const pkgLine = colorizer(`${pkg.name}:${stepDisplayedStatuses[pkg.status]}`); | ||
| this.writer.write(pkgLine); | ||
| for (const step of pkg.steps) { | ||
| const stepLine = colorizer(`${pkg.name}:${step.name}:${stepDisplayedStatuses[pkg.status]}`); | ||
| this.writer.write(stepLine); | ||
| } | ||
| continue; | ||
| } | ||
| if (pkgStatusMap.status !== pkg.status) { | ||
| const pkgLine = colorizer(`${pkg.name}:${stepDisplayedStatuses[pkg.status]}`); | ||
| this.writer.write(pkgLine); | ||
| } | ||
| for (const step of pkg.steps) { | ||
| if (pkgStatusMap.steps.get(step.name) !== step.status) { | ||
| const stepLine = colorizer(`${pkg.name}:${step.name}:${stepDisplayedStatuses[pkg.status]}`); | ||
| this.writer.write(stepLine); | ||
| } | ||
| } | ||
| } | ||
| this.currentPackages = packages.map((pkg) => ({ | ||
| ...pkg, | ||
| steps: pkg.steps.map((step) => ({ | ||
| ...step, | ||
| })), | ||
| })); | ||
| } | ||
| } | ||
| exports.NoClearRenderer = NoClearRenderer; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -13,2 +13,4 @@ "use strict"; | ||
| const debug_1 = __importDefault(require("debug")); | ||
| const noclear_renderer_1 = require("../ui/renderers/noclear-renderer"); | ||
| const fancy_renderer_1 = require("../ui/renderers/fancy-renderer"); | ||
| const debug = (0, debug_1.default)('mookme'); | ||
@@ -25,6 +27,6 @@ function addRun(program) { | ||
| debug('Running run command with options', opts); | ||
| const ui = new ui_1.MookmeUI(false); | ||
| const git = new git_1.GitToolkit(); | ||
| const config = new config_1.Config(git.rootDir); | ||
| const ui = new ui_1.MookmeUI(false, config.noClearRenderer ? new noclear_renderer_1.NoClearRenderer() : new fancy_renderer_1.FancyRenderer()); | ||
| const resolver = new hooks_resolver_1.HooksResolver(git, opts.type, { useAllFiles: opts.all, from: opts.from, to: opts.to }); | ||
| const config = new config_1.Config(git.rootDir); | ||
| const runner = new run_1.RunRunner(ui, config, git, resolver); | ||
@@ -31,0 +33,0 @@ await runner.run(opts); |
@@ -13,2 +13,3 @@ "use strict"; | ||
| constructor(rootDir) { | ||
| this.noClearRenderer = false; | ||
| const configFilePath = path_1.default.join(rootDir, '.mookme.json'); | ||
@@ -24,2 +25,3 @@ if (!fs_1.default.existsSync(configFilePath)) { | ||
| : types_1.ADDED_BEHAVIORS.ADD_AND_COMMIT; | ||
| this.noClearRenderer = configFromFile.noClearRenderer || false; | ||
| } | ||
@@ -26,0 +28,0 @@ } |
+2
-2
@@ -9,4 +9,4 @@ "use strict"; | ||
| const status_types_1 = require("../types/status.types"); | ||
| const renderer_1 = require("./renderer"); | ||
| const debug_1 = __importDefault(require("debug")); | ||
| const fancy_renderer_1 = require("./renderers/fancy-renderer"); | ||
| const debug = (0, debug_1.default)('mookme:ui'); | ||
@@ -17,3 +17,3 @@ class MookmeUI { | ||
| this.started = true; | ||
| this.renderer = renderer || new renderer_1.Renderer(); | ||
| this.renderer = renderer || new fancy_renderer_1.FancyRenderer(); | ||
| this.started = start; | ||
@@ -20,0 +20,0 @@ events_1.bus.on(events_1.EventType.PackageRegistered, [this.onPackageRegistered.bind(this), this.render.bind(this)]); |
+1
-1
| { | ||
| "name": "@escape.tech/mookme", | ||
| "version": "2.2.0-beta.5", | ||
| "version": "2.2.0-beta.6", | ||
| "description": "A git hook manager designed for monorepos", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Renderer = void 0; | ||
| const chalk_1 = __importDefault(require("chalk")); | ||
| const status_types_1 = require("../types/status.types"); | ||
| const writer_1 = require("./writer"); | ||
| const stepDisplayedStatuses = { | ||
| [status_types_1.ExecutionStatus.CREATED]: '🗓 Created', | ||
| [status_types_1.ExecutionStatus.RUNNING]: '🦾 Running', | ||
| [status_types_1.ExecutionStatus.FAILURE]: '❌ Error.', | ||
| [status_types_1.ExecutionStatus.SUCCESS]: '✅ Done.', | ||
| [status_types_1.ExecutionStatus.SKIPPED]: '⏩ Skipped.', | ||
| }; | ||
| class Renderer { | ||
| constructor(canvas) { | ||
| this.dots = ['.. ', '. .', ' ..']; | ||
| this.currentDotIndex = 0; | ||
| this.writer = canvas || new writer_1.ConsoleCanvas(); | ||
| this.interval = setInterval(() => { | ||
| this.currentDotIndex = (this.currentDotIndex + 1) % 3; | ||
| this.currentPackages && this.render(this.currentPackages); | ||
| }, 100); | ||
| } | ||
| stop() { | ||
| this.interval && clearInterval(this.interval); | ||
| } | ||
| _renderStep(step) { | ||
| let displayedCommand = step.command; | ||
| if (step.command.length > process.stdout.columns - (step.name.length + 10)) { | ||
| displayedCommand = step.command.substring(0, process.stdout.columns - step.name.length - 15) + '...'; | ||
| } | ||
| this.writer.write(`→ ${chalk_1.default.bold(step.name)} > ${displayedCommand} `); | ||
| if (step.status === status_types_1.ExecutionStatus.RUNNING) { | ||
| this.writer.write(`${stepDisplayedStatuses[step.status]}${this.dots[this.currentDotIndex]} `); | ||
| } | ||
| else { | ||
| this.writer.write(`${stepDisplayedStatuses[step.status]} `); | ||
| } | ||
| } | ||
| _renderPacakage(pkg) { | ||
| this.writer.write(); | ||
| let message; | ||
| switch (pkg.status) { | ||
| case status_types_1.ExecutionStatus.CREATED: | ||
| message = ` Created${this.dots[this.currentDotIndex]} `; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bold.inverse(message)}`); | ||
| break; | ||
| case status_types_1.ExecutionStatus.RUNNING: | ||
| message = ` Running${this.dots[this.currentDotIndex]} `; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bgBlueBright.bold(message)}`); | ||
| break; | ||
| case status_types_1.ExecutionStatus.SUCCESS: | ||
| message = ' Done ✓ '; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bgGreen.bold(message)}`); | ||
| break; | ||
| case status_types_1.ExecutionStatus.FAILURE: | ||
| message = ' Error × '; | ||
| this.writer.write(`${chalk_1.default.bold.inverse(` Hooks : ${pkg.name} `)}${chalk_1.default.bgRed.bold(message)}`); | ||
| break; | ||
| } | ||
| for (const step of pkg.steps) { | ||
| this._renderStep(step); | ||
| } | ||
| } | ||
| render(packages) { | ||
| this.writer.clear(); | ||
| for (const pkg of packages) { | ||
| this._renderPacakage(pkg); | ||
| } | ||
| this.currentPackages = packages; | ||
| } | ||
| } | ||
| exports.Renderer = Renderer; |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
66759
5.67%42
5%1482
5.93%