update description

This commit is contained in:
Philipp Kunz 2024-05-29 14:10:51 +02:00
parent 557c7b2ac5
commit 656f5b7dfb
5 changed files with 407 additions and 5 deletions

View File

@ -3,5 +3,26 @@
"npmGlobalTools": [
"npmts"
]
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "beautyfiglet",
"description": "A Node.js module for creating figlet text displays.",
"npmPackagename": "@push.rocks/beautyfiglet",
"license": "MIT",
"keywords": [
"figlet",
"text display",
"Node.js",
"npm module",
"typescript"
]
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -1,17 +1,26 @@
{
"name": "@push.rocks/beautyfiglet",
"version": "1.0.3",
"description": "figlet display in nodejs",
"description": "A Node.js module for creating figlet text displays.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(npmts)",
"format": "(gitzone format)"
},
"devDependencies": {
"devDependencies": {},
"dependencies": {},
"homepage": "https://code.foss.global/push.rocks/beautyfiglet",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/beautyfiglet.git"
},
"dependencies": {}
"keywords": [
"figlet",
"text display",
"Node.js",
"npm module",
"typescript"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

357
readme.md Normal file
View File

@ -0,0 +1,357 @@
```markdown
# @push.rocks/beautyfiglet
figlet display in nodejs
## Install
To install `@push.rocks/beautyfiglet`, you need to have Node.js and npm installed on your machine. Then, you can install it via npm:
```sh
npm install @push.rocks/beautyfiglet
```
Alternatively, you can add it as a dependency in your `package.json`:
```json
{
"dependencies": {
"@push.rocks/beautyfiglet": "^1.0.3"
}
}
```
Then run:
```sh
npm install
```
## Usage
The `@push.rocks/beautyfiglet` package is designed to allow you to display figlet text in your nodejs application. Below are instructions and examples on how to use it efficiently in your projects. We will cover all functionalities and illustrate several practical scenarios.
### Basic Usage
First, you'll need to import the package. Here's an example of basic usage:
```typescript
import * as beautyfiglet from '@push.rocks/beautyfiglet';
console.log(beautyfiglet.standardExport); // Outputs: Hi there! :) This is an exported string
```
### Creating Figlet Text
Lets say you want to display custom figlet text. Follow these steps:
1. Import `figlet` from the figlet package, which `@push.rocks/beautyfiglet` might internally use.
2. Use the `figlet` function to create ASCII art.
Here is a simple example:
```typescript
import figlet from 'figlet';
figlet('Hello World', function(err, data) {
if (err) {
console.error('Something went wrong...');
console.dir(err);
return;
}
console.log(data);
});
```
### Using Promises
To work with promises and async/await, you can wrap the `figlet` method within a Promise:
```typescript
import figlet from 'figlet';
const renderFiglet = (text: string): Promise<string> => {
return new Promise((resolve, reject) => {
figlet(text, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};
// Usage example
(async () => {
try {
const figletText = await renderFiglet('Hello World');
console.log(figletText);
} catch (error) {
console.error(error);
}
})();
```
### Customizing Fonts
Figlet allows for a variety of fonts to customize the output text. Here is how you can specify a font:
```typescript
import figlet from 'figlet';
const renderFiglet = (text: string, font: string): Promise<string> => {
return new Promise((resolve, reject) => {
figlet.text(text, { font }, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};
// Usage example
(async () => {
try {
const figletText = await renderFiglet('Hello World', 'Ghost');
console.log(figletText);
} catch (error) {
console.error(error);
}
})();
```
### Available Fonts
To see the list of available fonts, you can use `figlet.fonts` method. Heres how to get a list of all fonts:
```typescript
import figlet from 'figlet';
figlet.fonts((err, fonts) => {
if (err) {
console.error(err);
return;
}
console.log(fonts);
});
```
### Text Layout Options
You can also customize text layout with `horizontalLayout` and `verticalLayout` options:
```typescript
import figlet from 'figlet';
const renderFiglet = (text: string, font: string, hLayout: string, vLayout: string): Promise<string> => {
return new Promise((resolve, reject) => {
figlet.text(text, { font, horizontalLayout: hLayout, verticalLayout: vLayout }, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};
// Usage example
(async () => {
try {
const figletText = await renderFiglet('Hello World', 'Ghost', 'full', 'default');
console.log(figletText);
} catch (error) {
console.error(error);
}
})();
```
### Synchronous Usage
To generate Figlet text synchronously, use `figlet.textSync` method:
```typescript
import figlet from 'figlet';
const figletText = figlet.textSync('Hello World', {
font: 'Ghost',
horizontalLayout: 'default',
verticalLayout: 'default'
});
console.log(figletText);
```
### Styling and Coloring
While `figlet` itself doesnt support colored text directly, you can use other npm packages like `chalk` to add colors to figlet text. Heres an example:
```typescript
import figlet from 'figlet';
import chalk from 'chalk';
const renderFiglet = (text: string, font: string): Promise<string> => {
return new Promise((resolve, reject) => {
figlet.text(text, { font }, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};
// Usage example
(async () => {
try {
const figletText = await renderFiglet('Hello World', 'Ghost');
console.log(chalk.blue(figletText));
} catch (error) {
console.error(error);
}
})();
```
### Error Handling
Handling errors properly is crucial for robust applications. Heres an example of how you can handle errors comprehensively:
```typescript
import figlet from 'figlet';
const renderFiglet = (text: string, font: string): Promise<string> => {
return new Promise((resolve, reject) => {
figlet.text(text, { font }, (err, data) => {
if (err) {
reject(new Error(`Error generating figlet text: ${err.message}`));
} else {
resolve(data);
}
});
});
};
// Usage example
(async () => {
try {
const figletText = await renderFiglet('Hello World', 'InvalidFontName');
console.log(figletText);
} catch (error) {
console.error(error.message); // Output: Error generating figlet text: Font not found
}
})();
```
### Integration with Web Servers
You can integrate `@push.rocks/beautyfiglet` with a Node.js web server like Express. Heres an example:
```typescript
import express from 'express';
import figlet from 'figlet';
const app = express();
const renderFiglet = (text: string, font: string): Promise<string> => {
return new Promise((resolve, reject) => {
figlet.text(text, { font }, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};
app.get('/figlet/:text', async (req, res) => {
const { text } = req.params;
try {
const figletText = await renderFiglet(text, 'Standard');
res.send(`<pre>${figletText}</pre>`);
} catch (error) {
res.status(500).send(error.message);
}
});
app.listen(3000, () => {
console.log('Server started on port 3000');
});
```
### CLI Tool Example
You can also create a command-line tool using `@push.rocks/beautyfiglet`. Heres an example using Node.js:
```typescript
#!/usr/bin/env node
import figlet from 'figlet';
import { program } from 'commander';
program
.version('1.0.0')
.description('A simple Node CLI for generating Figlet text')
.option('-t, --text <text>', 'Text to render as Figlet')
.option('-f, --font <font>', 'Font to use', 'Standard');
program.parse(process.argv);
const options = program.opts();
figlet.text(options.text, { font: options.font }, (err, data) => {
if (err) {
console.error('Something went wrong...');
console.error(err.message);
return;
}
console.log(data);
});
```
To use this script as a CLI tool:
1. Save the script as `figlet-cli.ts`.
2. Add a line to your `package.json` to register this as a bin command:
```json
"bin": {
"figlet-cli": "./path/to/figlet-cli.ts"
}
```
3. Make sure `figlet-cli.ts` is executable:
```sh
chmod +x ./path/to/figlet-cli.ts
```
4. Then you can run:
```sh
npm link
figlet-cli --text "Hello World"
```
This concludes the extensive usage documentation for the @push.rocks/beautyfiglet package, showcasing multiple ways to generate ASCII art using figlet in Node.js. Explore the various options and configurations to best fit your project's needs.
```
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}