Skip to content

Commit

Permalink
Changed compare command to diff command
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemkosk committed Jan 30, 2024
1 parent 6052d23 commit 76634da
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions bin/index.ts
Expand Up @@ -49,11 +49,11 @@ program
})

program
.command('compare')
.command('diff')
.description(`${chalk.yellow('COMPARE')} command is a handy utility for differences in two different files with the same variable.`)
.alias('comp')
.alias('d')
.action(async () => {
const command: Command | null = factory.createCommand(CommandTypes.COMPARE)
const command: Command | null = factory.createCommand(CommandTypes.DIFF)
command !== null && CommandInvoker.executeCommands(command)
})

Expand Down
6 changes: 3 additions & 3 deletions lib/command/commandFactory.ts
@@ -1,6 +1,6 @@
import { CommandTypes } from '../const'
import type Command from './command'
import CompareCommand from './commandTypes/compareCommand'
import DiffCommand from './commandTypes/diffCommand'
import LsCommand from './commandTypes/lsCommand'
import RestoreCommand from './commandTypes/restoreCommand'
import RevertCommand from './commandTypes/revertCommand'
Expand All @@ -16,8 +16,8 @@ export default class CommandFactory {
return new LsCommand(params)
case CommandTypes.SYNC:
return new SyncCommand(params)
case CommandTypes.COMPARE:
return new CompareCommand(params)
case CommandTypes.DIFF:
return new DiffCommand(params)
case CommandTypes.UPDATE:
return new UpdateCommand(params)
case CommandTypes.UPDATE_ALL:
Expand Down
Expand Up @@ -6,7 +6,7 @@ import chalk from 'chalk'
import inquirer from 'inquirer'
import { consola } from 'consola'

export default class CompareCommand extends Command {
export default class DiffCommand extends Command {
protected async beforeExecute (): Promise<any> {
const files: string [] = await getEnvFilesRecursively(this.baseFolder)

Expand Down Expand Up @@ -47,11 +47,13 @@ export default class CompareCommand extends Command {
destinationServiceName
} = await compareEnvFiles(source, destination)

const terminalWidth = process.stdout.columns

const table = new Table({
head: ['VALUES', sourceServiceName, destinationServiceName],
wordWrap: true,
colWidths: [20, 30, 30],
wrapOnWordBoundary: false
colWidths: [Math.floor(terminalWidth / 3 - 5), Math.floor(terminalWidth / 3 - 5), Math.floor(terminalWidth / 3 - 5)],
wrapOnWordBoundary: false,
wordWrap: true
})

differentVariables.forEach(row => {
Expand Down
2 changes: 1 addition & 1 deletion lib/const.ts
Expand Up @@ -2,7 +2,7 @@ export enum CommandTypes {
LS = 1,
SYNC = 2,
UPDATE_ALL = 3,
COMPARE = 4,
DIFF = 4,
UPDATE = 5,
REVERT = 6,
RESTORE_ENV = 7,
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "envolve",
"version": "1.2.3",
"version": "1.2.4",
"description": "Envolve CLI is a powerful tool for managing environment variables in your projects. It allows you to easily create, update, compare, and sync environment files across different services.",
"main": "index.ts",
"scripts": {
Expand Down

0 comments on commit 76634da

Please sign in to comment.