Skip to content

Commit

Permalink
Changed esm
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemkosk committed Dec 10, 2023
1 parent 5e187b4 commit 3d0d1da
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 49 deletions.
Binary file added .DS_Store
Binary file not shown.
10 changes: 4 additions & 6 deletions bin/index.ts
@@ -1,15 +1,13 @@
#! /usr/bin/env node
import { Command as CommanderCommand } from 'commander'
import inquirer from 'inquirer'
import inquirerPrompt from 'inquirer-autocomplete-prompt'
import chalk from 'chalk'
import packages from '../package.json' assert { type: 'json' }

import {
CommandInvoker,
type Command,
CommandFactory
} from '../lib/command'

import CommandFactory from '../lib/command/CommandFactory'

Check failure on line 8 in bin/index.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module '../lib/command/CommandFactory' or its corresponding type declarations.
import type Command from '../lib/command/Command'
import CommandInvoker from '../lib/command/CommandInvoker'
import { CommandTypes } from '../lib/const'

const program = new CommanderCommand()
Expand Down
Binary file added lib/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/command/Command.ts
@@ -1,7 +1,7 @@
import { getBaseFolder } from '../handler/fileHandler'
import inquirer from 'inquirer'

export abstract class Command {
export default abstract class Command {
protected readonly baseFolder: string

constructor () {
Expand Down
4 changes: 2 additions & 2 deletions lib/command/CommandInvoker.ts
@@ -1,7 +1,7 @@
import { type Command } from './Command'
import type Command from './Command'

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class CommandInvoker {
export default class CommandInvoker {
static executeCommands (command: Command): any {
return command.execute()
}
Expand Down
20 changes: 9 additions & 11 deletions lib/command/commandFactory.ts
@@ -1,16 +1,14 @@
import { CommandTypes } from '../const'
import {
type Command,
LsCommand,
SyncCommand,
UpdateAllCommand,
CompareCommand,
UpdateCommand,
RevertCommand,
RestoreCommand
} from '.'
import type Command from './Command'
import CompareCommand from './commandTypes/CompareCommand'
import LsCommand from './commandTypes/LsCommand'
import RestoreCommand from './commandTypes/RestoreCommand'
import RevertCommand from './commandTypes/RevertCommand'
import SyncCommand from './commandTypes/SyncCommand'
import UpdateAllCommand from './commandTypes/UpdateAllCommand'
import UpdateCommand from './commandTypes/UpdateCommand'

export class CommandFactory {
export default class CommandFactory {
createCommand (commandType: number): Command | null {
switch (commandType) {
case CommandTypes.LS:
Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/CompareCommand.ts
@@ -1,12 +1,12 @@
import { Command } from '../Command'
import Command from '../Command'
import { compareEnvFiles } from '../../handler/envHandler'
import { getEnvFilesRecursively } from '../../handler/fileHandler'
import Table from 'cli-table3'
import chalk from 'chalk'
import inquirer from 'inquirer'
import { consola } from 'consola'

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

Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/LsCommand.ts
@@ -1,12 +1,12 @@
import { Command } from '../Command'
import Command from '../Command'
import { getValuesInEnv } from '../../handler/envHandler'
import { getEnvFilesRecursively } from '../../handler/fileHandler'
import Table from 'cli-table3'
import chalk from 'chalk'
import inquirer from 'inquirer'
import { consola } from 'consola'

export class LsCommand extends Command {
export default class LsCommand extends Command {
protected async beforeExecute (): Promise<any> {
const files = await getEnvFilesRecursively({ directory: this.baseFolder })

Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/RestoreCommand.ts
@@ -1,9 +1,9 @@
import { Command } from '../Command'
import Command from '../Command'
import { restoreEnvFile } from '../../handler/envHandler'
import chalk from 'chalk'
import { consola } from 'consola'

export class RestoreCommand extends Command {
export default class RestoreCommand extends Command {
protected async beforeExecute (): Promise<any> {
const isConfirmed = await this.askForConfirmation()

Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/RevertCommand.ts
@@ -1,4 +1,4 @@
import { Command } from '../Command'
import Command from '../Command'
import { updateEnvFile, getUniqueEnvNames } from '../../handler/envHandler'
import { getEnvFilesRecursively } from '../../handler/fileHandler'
import { getEnvVersions } from '../../handler/historyHandler'
Expand All @@ -7,7 +7,7 @@ import inquirer from 'inquirer'
import { format } from 'date-fns'
import { consola } from 'consola'

export class RevertCommand extends Command {
export default class RevertCommand extends Command {
protected async beforeExecute (): Promise<any> {
const files = await getEnvFilesRecursively({ directory: this.baseFolder })

Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/SyncCommand.ts
@@ -1,9 +1,9 @@
import { Command } from '../Command'
import Command from '../Command'
import { syncEnvFile } from '../../handler/envHandler'
import chalk from 'chalk'
import { consola } from 'consola'

export class SyncCommand extends Command {
export default class SyncCommand extends Command {
protected async beforeExecute (): Promise<any> {
return await syncEnvFile()
}
Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/UpdateAllCommand.ts
@@ -1,10 +1,10 @@
import { Command } from '../Command'
import Command from '../Command'
import { updateAllEnvFile, promptForEnvVariable } from '../../handler/envHandler'
import chalk from 'chalk'
import inquirer from 'inquirer'
import { consola } from 'consola'

export class UpdateAllCommand extends Command {
export default class UpdateAllCommand extends Command {
protected async beforeExecute (): Promise<any> {
const envOptions = await promptForEnvVariable()

Expand Down
4 changes: 2 additions & 2 deletions lib/command/commandTypes/UpdateCommand.ts
@@ -1,11 +1,11 @@
import { Command } from '../Command'
import Command from '../Command'
import { getUniqueEnvNames, updateEnvFile } from '../../handler/envHandler'
import { getEnvFilesRecursively } from '../../handler/fileHandler'
import chalk from 'chalk'
import inquirer from 'inquirer'
import { consola } from 'consola'

export class UpdateCommand extends Command {
export default class UpdateCommand extends Command {
protected async beforeExecute (): Promise<any> {
const files = await getEnvFilesRecursively({ directory: this.baseFolder })

Expand Down
10 changes: 0 additions & 10 deletions lib/command/index.ts

This file was deleted.

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "tsc",
"lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
"serve": "node --no-warnings --experimental-specifier-resolution=node dist/bin/index.js",
"serve": "node dist/bin/index.js",
"start": "tsc && npm run serve",
"test": "jest --forceExit --verbose --detectOpenHandles --coverage --coverageReporters=text-summary"
},
Expand Down Expand Up @@ -52,6 +52,6 @@
"typescript": "^5.2.2"
},
"bin": {
"envolve": "./dist/index.js"
"envolve": "./dist/bin/index.js"
}
}

0 comments on commit 3d0d1da

Please sign in to comment.