-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add info command and make some corrections (#8)
* feat: add info command and make some corrections * fix: general adjustment * fix: update cli examples * fix: parameters in any position * fix: ui improvements * fix: removed extra consoles * fix: project name, error msg, param dependency * fix: remove pack --------- Co-authored-by: Richard Zampieri <[email protected]>
- Loading branch information
1 parent
bd02a80
commit acb5d3f
Showing
12 changed files
with
197 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ package-lock.json | |
|
||
*.log | ||
expressots.config.ts | ||
|
||
*.tgz |
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { CommandModule } from "yargs"; | ||
import { infoForm } from "./form"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
type CommandModuleArgs = {}; | ||
|
||
const infoProject = (): CommandModule<CommandModuleArgs, any> => { | ||
return { | ||
command: "info", | ||
describe: "Displays project details", | ||
aliases: ["i"], | ||
handler: async () => { | ||
await infoForm(); | ||
}, | ||
}; | ||
}; | ||
|
||
export { infoProject }; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import chalk from "chalk"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
import os from "os"; | ||
import { CLI_VERSION } from "../cli"; | ||
import { printError } from "../utils/cli-ui"; | ||
|
||
function getInfosFromPackage() { | ||
try { | ||
// Get the absolute path of the input directory parameter | ||
const absDirPath = path.resolve(); | ||
// Load the package.json file | ||
const packageJsonPath = path.join(absDirPath, "package.json"); | ||
|
||
const fileContents = fs.readFileSync(packageJsonPath, "utf-8"); | ||
const packageJson = JSON.parse(fileContents); | ||
|
||
console.log(chalk.green("ExpressoTS Project:")); | ||
console.log(chalk.bold(`\tName: ${packageJson.name}`)); | ||
console.log(chalk.bold(`\tDescription: ${packageJson.description}`)); | ||
console.log(chalk.bold(`\tVersion: ${packageJson.version}`)); | ||
console.log(chalk.bold(`\tAuthor: ${packageJson.author}`)); | ||
} catch (error) { | ||
printError("No project information available.", "package.json not found!") | ||
} | ||
} | ||
|
||
const infoForm = async (): Promise<void> => { | ||
console.log(chalk.green("System informations:")); | ||
console.log(chalk.bold(`\tOS Version: ${os.version()}`)); | ||
console.log(chalk.bold(`\tNodeJS version: ${process.version}`)); | ||
|
||
console.log(chalk.green("CLI Version:")); | ||
console.log(chalk.bold(`\tCurrent version: v${CLI_VERSION}`)); | ||
|
||
getInfosFromPackage(); | ||
}; | ||
|
||
export { infoForm }; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./cli" |
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function centerText(text: string): string { | ||
const terminalWidth = process.stdout.columns; | ||
const padding = Math.floor((terminalWidth - text.length) / 2); | ||
const centeredText = ' '.repeat(padding) + text; | ||
|
||
return centeredText; | ||
} | ||
|
||
export { centerText }; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import chalk from "chalk"; | ||
|
||
export function printError(message: string, component: string): void { | ||
console.error(chalk.red(`\n\n😞 ${message}:`,chalk.white(`[${component}]`))); | ||
} |
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