-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix eslint configuration and fix lint issues (#542)
Signed-off-by: Deepak Mishra <[email protected]>
- Loading branch information
1 parent
8ce8290
commit 665dcdf
Showing
25 changed files
with
1,994 additions
and
2,021 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} |
Oops, something went wrong.