Skip to content

Commit

Permalink
Fix eslint configuration and fix lint issues (#542)
Browse files Browse the repository at this point in the history
Signed-off-by: Deepak Mishra <[email protected]>
  • Loading branch information
deepak-swirlds authored Nov 14, 2023
1 parent 8ce8290 commit 665dcdf
Show file tree
Hide file tree
Showing 25 changed files with 1,994 additions and 2,021 deletions.
5 changes: 5 additions & 0 deletions fullstack-network-manager/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ parserOptions:
ecmaVersion: latest
sourceType: module
rules: {}
overrides:
- files: ["*.mjs"]
parserOptions:
ecmaVersion: latest
sourceType: module
4 changes: 3 additions & 1 deletion fullstack-network-manager/fsnetman.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node
import * as fnm from './src/index.mjs'
const cli = fnm.main(process.argv)

// CLI entry point
fnm.main(process.argv)
7 changes: 3 additions & 4 deletions fullstack-network-manager/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const config = {
verbose: true,
transform: {},
};
verbose: true,
transform: {}
}

export default config

139 changes: 69 additions & 70 deletions fullstack-network-manager/src/commands/base.mjs
Original file line number Diff line number Diff line change
@@ -1,97 +1,96 @@
"use strict"
import * as core from "../core/index.mjs"
import chalk from "chalk";
import {ShellRunner} from "../core/shell_runner.mjs";
'use strict'
import * as core from '../core/index.mjs'
import chalk from 'chalk'
import { ShellRunner } from '../core/shell_runner.mjs'

export class BaseCommand extends ShellRunner {

async checkDep(cmd) {
try {
this.logger.debug(cmd)
await this.run(cmd)
} catch (e) {
this.logger.showUserError(e)
return false
}

return true
async checkDep (cmd) {
try {
this.logger.debug(cmd)
await this.run(cmd)
} catch (e) {
this.logger.showUserError(e)
return false
}

/**
return true
}

/**
* Check if 'kind' CLI program is installed or not
* @returns {Promise<boolean>}
*/
async checkKind() {
return this.checkDep(`${core.constants.KIND} --version`)
}
async checkKind () {
return this.checkDep(`${core.constants.KIND} --version`)
}

/**
/**
* Check if 'helm' CLI program is installed or not
* @returns {Promise<boolean>}
*/
async checkHelm() {
return this.checkDep(`${core.constants.HELM} version`)
}
async checkHelm () {
return this.checkDep(`${core.constants.HELM} version`)
}

/**
/**
* Check if 'kubectl' CLI program is installed or not
* @returns {Promise<boolean>}
*/
async checkKubectl() {
return this.checkDep(`${core.constants.KUBECTL} version --client`)
}
async checkKubectl () {
return this.checkDep(`${core.constants.KUBECTL} version --client`)
}

/**
/**
* Check if all the required dependencies are installed or not
* @param deps is a list of dependencies
* @returns {Promise<boolean>}
*/
async checkDependencies(deps = []) {
this.logger.debug("Checking for required dependencies: %s", deps)

for (let i = 0; i < deps.length; i++) {
const dep = deps[i]
this.logger.debug("Checking for dependency '%s'", dep)
async checkDependencies (deps = []) {
this.logger.debug('Checking for required dependencies: %s', deps)

let status = false
const check = this.checks.get(dep)
if (check) {
status = await check()
}
for (let i = 0; i < deps.length; i++) {
const dep = deps[i]
this.logger.debug("Checking for dependency '%s'", dep)

if (!status) {
this.logger.showUser(chalk.red(`FAIL: '${dep}' is not found`))
return false
}
let status = false
const check = this.checks.get(dep)
if (check) {
status = await check()
}

this.logger.showUser(chalk.green(`OK: '${dep}' is found`))
}
if (!status) {
this.logger.showUser(chalk.red(`FAIL: '${dep}' is not found`))
return false
}

this.logger.debug("All required dependencies are found: %s", deps)

return true
this.logger.showUser(chalk.green(`OK: '${dep}' is found`))
}

constructor(opts) {
if (!opts || !opts.logger) throw new Error('An instance of core/Logger is required')
if (!opts || !opts.kind) throw new Error('An instance of core/Kind is required')
if (!opts || !opts.helm) throw new Error('An instance of core/Helm is required')
if (!opts || !opts.kubectl) throw new Error('An instance of core/Kubectl is required')
if (!opts || !opts.chartManager) throw new Error('An instance of core/ChartManager is required')
if (!opts || !opts.configManager) throw new Error('An instance of core/ConfigManager is required')

super(opts.logger);

this.kind = opts.kind
this.helm = opts.helm
this.kubectl = opts.kubectl
this.chartManager = opts.chartManager
this.configManager = opts.configManager

// map of dependency checks
this.checks = new Map()
.set(core.constants.KIND, () => this.checkKind())
.set(core.constants.HELM, () => this.checkHelm())
.set(core.constants.KUBECTL, () => this.checkKubectl())
}
this.logger.debug('All required dependencies are found: %s', deps)

return true
}

constructor (opts) {
if (!opts || !opts.logger) throw new Error('An instance of core/Logger is required')
if (!opts || !opts.kind) throw new Error('An instance of core/Kind is required')
if (!opts || !opts.helm) throw new Error('An instance of core/Helm is required')
if (!opts || !opts.kubectl) throw new Error('An instance of core/Kubectl is required')
if (!opts || !opts.chartManager) throw new Error('An instance of core/ChartManager is required')
if (!opts || !opts.configManager) throw new Error('An instance of core/ConfigManager is required')

super(opts.logger)

this.kind = opts.kind
this.helm = opts.helm
this.kubectl = opts.kubectl
this.chartManager = opts.chartManager
this.configManager = opts.configManager

// map of dependency checks
this.checks = new Map()
.set(core.constants.KIND, () => this.checkKind())
.set(core.constants.HELM, () => this.checkHelm())
.set(core.constants.KUBECTL, () => this.checkKubectl())
}
}
Loading

0 comments on commit 665dcdf

Please sign in to comment.