Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
947bd03223 | |||
95e6295feb | |||
e294710a0f | |||
81228d1972 | |||
e40c6bb713 | |||
135a9bcf08 | |||
6b8d951024 | |||
75f8877356 | |||
fde3000555 | |||
f065ef0e94 | |||
656f5b7dfb | |||
557c7b2ac5 | |||
233e07040e |
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,5 +1,19 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
#------# custom
|
@ -1,95 +0,0 @@
|
|||||||
# gitzone standard
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .yarn/
|
|
||||||
key: "$CI_BUILD_STAGE"
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- trigger
|
|
||||||
- pages
|
|
||||||
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
snyk:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci command yarn global add snyk
|
|
||||||
- npmci command yarn install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: trigger
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: pages
|
|
||||||
script:
|
|
||||||
- npmci command yarn global add npmpage
|
|
||||||
- npmci command npmpage
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
50
changelog.md
Normal file
50
changelog.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-01-14 - 1.0.8 - fix(documentation)
|
||||||
|
Update README to reflect recent changes
|
||||||
|
|
||||||
|
- Updated package description for accuracy.
|
||||||
|
- Adjusted installation instructions for clarity.
|
||||||
|
- Added a new command-line interface example.
|
||||||
|
- Enhanced section on error handling with illustrative examples.
|
||||||
|
- Simplified integration guidelines with web servers using Express.
|
||||||
|
|
||||||
|
## 2025-01-14 - 1.0.7 - fix(core)
|
||||||
|
Improve error messages in renderText and listFonts methods
|
||||||
|
|
||||||
|
- Improved error handling in renderText and listFonts methods
|
||||||
|
- Ensure proper rejection messages during errors
|
||||||
|
|
||||||
|
## 2025-01-14 - 1.0.6 - fix(core)
|
||||||
|
Update .gitignore to improve ignored paths
|
||||||
|
|
||||||
|
- Ignored various build and cache directories to reduce clutter in the repository.
|
||||||
|
- Refactored .gitignore to categorize ignored paths for better readability and maintenance.
|
||||||
|
|
||||||
|
## 2025-01-14 - 1.0.5 - fix(package)
|
||||||
|
Fix scripts section in package.json by adding missing comma
|
||||||
|
|
||||||
|
- Corrected the JSON format in the scripts section by adding a missing comma between format and build scripts.
|
||||||
|
|
||||||
|
## 2025-01-14 - 1.0.4 - fix(core)
|
||||||
|
Removed unnecessary files and updated dependencies
|
||||||
|
|
||||||
|
- Removed .gitlab-ci.yml to streamline the CI/CD process
|
||||||
|
- Updated and fixed TypeScript files to align with ES Module syntax
|
||||||
|
- Removed obsolete dist files for a cleaner build
|
||||||
|
- Updated package.json to reflect current project configurations, including dependencies and scripts
|
||||||
|
|
||||||
|
## 2024-05-29 - 1.0.3 - Enhancements
|
||||||
|
Finalizing updates under version 1.0.3
|
||||||
|
|
||||||
|
- Updated project description
|
||||||
|
|
||||||
|
## 2023-07-10 to 2024-05-29 - 1.0.3 - Organizational Changes
|
||||||
|
Implemented significant organizational changes
|
||||||
|
|
||||||
|
- Switched to a new organizational scheme
|
||||||
|
|
||||||
|
## 2018-03-05 - 1.0.2 to 1.0.3 - Maintenance and Format Updates
|
||||||
|
Streamlined maintenance and formatting
|
||||||
|
|
||||||
|
- Updated code formatting for consistency
|
2
dist/beautyfiglet.plugins.d.ts
vendored
2
dist/beautyfiglet.plugins.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
declare const removeme: {};
|
|
||||||
export { removeme };
|
|
5
dist/beautyfiglet.plugins.js
vendored
5
dist/beautyfiglet.plugins.js
vendored
@ -1,5 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const removeme = {};
|
|
||||||
exports.removeme = removeme;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5ZmlnbGV0LnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9iZWF1dHlmaWdsZXQucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLE1BQU0sUUFBUSxHQUFHLEVBQUUsQ0FBQztBQUVsQiw0QkFBUSJ9
|
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare let standardExport: string;
|
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -1,4 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.standardExport = 'Hi there! :) This is an exported string';
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUVXLFFBQUEsY0FBYyxHQUFHLHlDQUF5QyxDQUFDIn0=
|
|
19
license
Normal file
19
license
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2014 Task Venture Capital GmbH (hello@lossless.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -3,5 +3,31 @@
|
|||||||
"npmGlobalTools": [
|
"npmGlobalTools": [
|
||||||
"npmts"
|
"npmts"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "beautyfiglet",
|
||||||
|
"description": "A Node.js module that facilitates the creation of ASCII art using figlet with customizable fonts and layouts.",
|
||||||
|
"npmPackagename": "@push.rocks/beautyfiglet",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"ASCII art",
|
||||||
|
"figlet",
|
||||||
|
"text rendering",
|
||||||
|
"Node.js module",
|
||||||
|
"typescript",
|
||||||
|
"font customization",
|
||||||
|
"command-line interface",
|
||||||
|
"error handling",
|
||||||
|
"web integration",
|
||||||
|
"npm package"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
48
package.json
48
package.json
@ -1,17 +1,43 @@
|
|||||||
{
|
{
|
||||||
"name": "beautyfiglet",
|
"name": "@push.rocks/beautyfiglet",
|
||||||
"version": "1.0.3",
|
"version": "1.0.8",
|
||||||
"description": "figlet display in nodejs",
|
"description": "A Node.js module that facilitates the creation of ASCII art using figlet with customizable fonts and layouts.",
|
||||||
"main": "dist/index.js",
|
"exports": {
|
||||||
"typings": "dist/index.d.ts",
|
".": "./dist_ts/index.js"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(tstest test/)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/figlet": "^1.7.0",
|
||||||
|
"figlet": "^1.8.0"
|
||||||
|
},
|
||||||
|
"homepage": "https://code.foss.global/push.rocks/beautyfiglet",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.foss.global/push.rocks/beautyfiglet.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"ASCII art",
|
||||||
|
"figlet",
|
||||||
|
"text rendering",
|
||||||
|
"Node.js module",
|
||||||
|
"typescript",
|
||||||
|
"font customization",
|
||||||
|
"command-line interface",
|
||||||
|
"error handling",
|
||||||
|
"web integration",
|
||||||
|
"npm package"
|
||||||
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tapbundle": "^1.0.13"
|
"@git.zone/tsbuild": "^2.2.0",
|
||||||
},
|
"@git.zone/tsbundle": "^2.1.0",
|
||||||
"dependencies": {}
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
|
"@git.zone/tstest": "^1.0.90",
|
||||||
|
"@push.rocks/tapbundle": "^5.5.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
9737
pnpm-lock.yaml
generated
Normal file
9737
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
250
readme.md
Normal file
250
readme.md
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
# @push.rocks/beautyfiglet
|
||||||
|
A Node.js module for creating figlet text displays.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
To install `@push.rocks/beautyfiglet`, you should have Node.js and npm installed on your machine. Once you have these prerequisites, you can install the package via npm by running the following command in your terminal:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @push.rocks/beautyfiglet
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can include it as a dependency in your `package.json` file:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"@push.rocks/beautyfiglet": "^1.0.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then execute:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
`@push.rocks/beautyfiglet` is a versatile Node.js module that lets you generate figlet-style ASCII art easily. Below, we will explore its functionalities with detailed examples, encompassing various scenarios to showcase how you can leverage this module in your projects.
|
||||||
|
|
||||||
|
### Basic Initialization
|
||||||
|
|
||||||
|
Begin by importing the `BeautyFiglet` class into your TypeScript file. You can access its methods to create ASCII art from text strings.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { BeautyFiglet } from '@push.rocks/beautyfiglet';
|
||||||
|
|
||||||
|
// A simple demonstration of using the standard export
|
||||||
|
console.log('Welcome to BeautyFiglet!'); // Outputs: Welcome to BeautyFiglet!
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rendering Text with Figlet
|
||||||
|
|
||||||
|
Figlet is immensely popular for turning strings into ASCII banners. The following code illustrates how to convert text into a figlet display using `BeautyFiglet`.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
const figletText = await BeautyFiglet.renderDefault('Hello, World!');
|
||||||
|
console.log(figletText);
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customizing Font
|
||||||
|
|
||||||
|
`BeautyFiglet` not only supports different versions of text layouts, but it also allows you to specify fonts, making your output unique.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
const customFiglet = await BeautyFiglet.renderText('Beautiful Text', 'Ghost');
|
||||||
|
console.log(customFiglet);
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fetching Available Fonts
|
||||||
|
|
||||||
|
Understanding what fonts are available can help in making aesthetic decisions for your text.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
const fontsList = await BeautyFiglet.listFonts();
|
||||||
|
console.log('Available Fonts:');
|
||||||
|
console.log(fontsList.join(', '));
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using Custom Layouts
|
||||||
|
|
||||||
|
In addition to fonts, the layout of the text can be altered. You can specify both horizontal and vertical layouts.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import figlet from 'figlet';
|
||||||
|
|
||||||
|
const renderCustomLayout = (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(`Error: ${err.message}`);
|
||||||
|
else resolve(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Example usage
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const customLayoutText = await renderCustomLayout('Creative Layout', 'Ghost', 'full', 'full');
|
||||||
|
console.log(customLayoutText);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Synchronous Text Rendering
|
||||||
|
|
||||||
|
For situations requiring synchronous execution such as small scripts and testing scenarios, `textSync` comes in handy.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { figlet } from '@push.rocks/beautyfiglet.plugins';
|
||||||
|
|
||||||
|
const artwork = figlet.textSync('Synchronicity!', {
|
||||||
|
font: 'Standard',
|
||||||
|
horizontalLayout: 'default',
|
||||||
|
verticalLayout: 'default'
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(artwork);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Enhancing Output with Color
|
||||||
|
|
||||||
|
To add more flair to your text displays, consider integrating popular color-coordinating libraries like `chalk`.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import figlet from 'figlet';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const colorizedText = await BeautyFiglet.renderText('Color Me Beautiful', 'Standard');
|
||||||
|
console.log(chalk.magentaBright(colorizedText));
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Robust Error Handling
|
||||||
|
|
||||||
|
Error handling is paramount in any application. This becomes even more pronounced when fonts or integrations might fail.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const result = await BeautyFiglet.renderText('Error Test', 'NonExistentFont');
|
||||||
|
console.log(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Caught an error: ${error}`);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Web Server Integration
|
||||||
|
|
||||||
|
The module can effectively serve dynamically generated ASCII text over HTTP. Here's a simple example using Express:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import express from 'express';
|
||||||
|
import { BeautyFiglet } from '@push.rocks/beautyfiglet';
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.get('/api/art/:text', async (req, res) => {
|
||||||
|
const textToRender = req.params.text;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const asciiArt = await BeautyFiglet.renderDefault(textToRender);
|
||||||
|
res.send(`<pre>${asciiArt}</pre>`);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).send(`Error: ${error.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(4000, () => {
|
||||||
|
console.log('Server running at http://localhost:4000/');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Command-Line Interface (CLI)
|
||||||
|
|
||||||
|
Expand the utility of `BeautyFiglet` by creating a CLI tool for generating ASCII art directly from the command line.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
import { BeautyFiglet } from '@push.rocks/beautyfiglet';
|
||||||
|
import { Command } from 'commander';
|
||||||
|
|
||||||
|
const program = new Command();
|
||||||
|
program.version('1.0.7');
|
||||||
|
|
||||||
|
program
|
||||||
|
.option('-t, --text <text>', 'Text to render')
|
||||||
|
.option('-f, --font <font>', 'Font for rendering', 'Standard')
|
||||||
|
.action(async (cmd) => {
|
||||||
|
try {
|
||||||
|
const asciiArt = await BeautyFiglet.renderText(cmd.text, cmd.font);
|
||||||
|
console.log(asciiArt);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error: ${error}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
program.parse(process.argv);
|
||||||
|
```
|
||||||
|
|
||||||
|
Running this tool involves these steps:
|
||||||
|
|
||||||
|
1. Save the script as `beautyfiglet-cli.ts`.
|
||||||
|
2. Ensure it is marked as executable:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
chmod +x ./beautyfiglet-cli.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Link via npm:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm link
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Execute with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
beautyfiglet-cli --text "Hello World" --font "Ghost"
|
||||||
|
```
|
||||||
|
|
||||||
|
This command-line example showcases flexibility and enhanced usability for developers integrating the module seamlessly into their workflow.
|
||||||
|
|
||||||
|
### Summary of Best Practices
|
||||||
|
|
||||||
|
The extensive usage of `@push.rocks/beautyfiglet` demonstrates the importance of proper setup and thorough understanding of available options. From simple implementations to elaborate, colorful arrangements, this module empowers developers to unleash creativity with text in aesthetic and programmable ways.
|
||||||
|
|
||||||
|
Delve deeper into font choices and optional configurations to fully capitalize on this versatile tool for crafting meaningful ASCII text displays, all the while ensuring continuous learning of new patterns and module updates. With vigilant error management and the integration of expressive styles, your applications can achieve a blend of functionality and flair unmatched by basic textual representation.
|
||||||
|
|
||||||
|
This concludes the elaborate coverage of the `@push.rocks/beautyfiglet` module and its extensive capabilities within Node.js projects.
|
||||||
|
|
||||||
|
## 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.
|
33
test/test.ts
33
test/test.ts
@ -1,8 +1,31 @@
|
|||||||
import { expect, tap } from 'tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as beautyfiglet from '../ts/index';
|
import * as beautyfiglet from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
let testFiglet: typeof beautyfiglet.BeautyFiglet;
|
||||||
console.log(beautyfiglet.standardExport);
|
|
||||||
|
tap.test('setup', async () => {
|
||||||
|
testFiglet = beautyfiglet.BeautyFiglet;
|
||||||
|
expect(testFiglet).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.test('should render text with the default font', async () => {
|
||||||
|
const text = "Hello, World!";
|
||||||
|
const result = await testFiglet.renderDefault(text);
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should render text with a specific font', async () => {
|
||||||
|
const text = "Fancy Text";
|
||||||
|
const font = "Ghost";
|
||||||
|
const result = await testFiglet.renderText(text, font);
|
||||||
|
expect(result).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should list available fonts', async () => {
|
||||||
|
const fonts = await testFiglet.listFonts();
|
||||||
|
expect(Array.isArray(fonts)).toBeTrue();
|
||||||
|
expect(fonts.length).toBeGreaterThan(0);
|
||||||
|
expect(fonts).toContain("Standard"); // Ensure "Standard" is in the font list
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/beautyfiglet',
|
||||||
|
version: '1.0.8',
|
||||||
|
description: 'A Node.js module that facilitates the creation of ASCII art using figlet with customizable fonts and layouts.'
|
||||||
|
}
|
@ -1,2 +1,6 @@
|
|||||||
const removeme = {};
|
import figlet, { type Fonts } from 'figlet';
|
||||||
export { removeme };
|
|
||||||
|
export {
|
||||||
|
figlet,
|
||||||
|
type Fonts,
|
||||||
|
}
|
47
ts/index.ts
47
ts/index.ts
@ -1,3 +1,46 @@
|
|||||||
import * as plugins from './beautyfiglet.plugins';
|
import * as plugins from './beautyfiglet.plugins.js';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
export class BeautyFiglet {
|
||||||
|
/**
|
||||||
|
* Render text with a specific figlet font.
|
||||||
|
* @param text - The text to render.
|
||||||
|
* @param font - The font to use (optional).
|
||||||
|
* @returns A promise that resolves to the rendered ASCII art.
|
||||||
|
*/
|
||||||
|
static async renderText(text: string, font: plugins.figlet.Fonts = "Standard"): Promise<string> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
plugins.figlet.text(text, { font }, (err, result) => {
|
||||||
|
if (err) {
|
||||||
|
reject(`Error rendering text: ${err.message}`);
|
||||||
|
} else {
|
||||||
|
resolve(result || "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of all available fonts in figlet.
|
||||||
|
* @returns A promise that resolves to an array of font names.
|
||||||
|
*/
|
||||||
|
static async listFonts(): Promise<string[]> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
plugins.figlet.fonts((err, fonts) => {
|
||||||
|
if (err) {
|
||||||
|
reject(`Error fetching fonts: ${err.message}`);
|
||||||
|
} else {
|
||||||
|
resolve(fonts || []);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render text with a default font (Standard).
|
||||||
|
* @param text - The text to render.
|
||||||
|
* @returns A promise that resolves to the rendered ASCII art.
|
||||||
|
*/
|
||||||
|
static async renderDefault(text: string): Promise<string> {
|
||||||
|
return this.renderText(text, "Standard");
|
||||||
|
}
|
||||||
|
}
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
194
yarn.lock
194
yarn.lock
@ -1,194 +0,0 @@
|
|||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
"@types/code@^4.0.3":
|
|
||||||
version "4.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/code/-/code-4.0.4.tgz#527fbdbb487dabc4346b8a2ccca3496d8198bae7"
|
|
||||||
|
|
||||||
"@types/node@^8.0.33":
|
|
||||||
version "8.9.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.9.4.tgz#dfd327582a06c114eb6e0441fa3d6fab35edad48"
|
|
||||||
|
|
||||||
ansi-256-colors@^1.1.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
|
|
||||||
|
|
||||||
beautycolor@^1.0.7:
|
|
||||||
version "1.0.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.11.tgz#71c5568d5a7ed5c144d3a54f753ad1b08862aea5"
|
|
||||||
dependencies:
|
|
||||||
ansi-256-colors "^1.1.0"
|
|
||||||
typings-global "^1.0.14"
|
|
||||||
|
|
||||||
bindings@^1.2.1:
|
|
||||||
version "1.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
|
|
||||||
|
|
||||||
code@^5.1.0:
|
|
||||||
version "5.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/code/-/code-5.2.0.tgz#fb3a5e247afc17e3d65c49e7ce0f69ebe51a75b5"
|
|
||||||
dependencies:
|
|
||||||
hoek "5.x.x"
|
|
||||||
|
|
||||||
define-properties@^1.1.2:
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
|
|
||||||
dependencies:
|
|
||||||
foreach "^2.0.5"
|
|
||||||
object-keys "^1.0.8"
|
|
||||||
|
|
||||||
early@^2.1.1:
|
|
||||||
version "2.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
|
|
||||||
dependencies:
|
|
||||||
beautycolor "^1.0.7"
|
|
||||||
smartq "^1.1.1"
|
|
||||||
typings-global "^1.0.16"
|
|
||||||
|
|
||||||
es-abstract@^1.5.1:
|
|
||||||
version "1.10.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
|
|
||||||
dependencies:
|
|
||||||
es-to-primitive "^1.1.1"
|
|
||||||
function-bind "^1.1.1"
|
|
||||||
has "^1.0.1"
|
|
||||||
is-callable "^1.1.3"
|
|
||||||
is-regex "^1.0.4"
|
|
||||||
|
|
||||||
es-to-primitive@^1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
|
|
||||||
dependencies:
|
|
||||||
is-callable "^1.1.1"
|
|
||||||
is-date-object "^1.0.1"
|
|
||||||
is-symbol "^1.0.1"
|
|
||||||
|
|
||||||
es6-error@^4.0.2:
|
|
||||||
version "4.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
|
|
||||||
|
|
||||||
foreach@^2.0.5:
|
|
||||||
version "2.0.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
|
|
||||||
|
|
||||||
function-bind@^1.0.2, function-bind@^1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
|
|
||||||
|
|
||||||
has@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
|
|
||||||
dependencies:
|
|
||||||
function-bind "^1.0.2"
|
|
||||||
|
|
||||||
hoek@5.x.x:
|
|
||||||
version "5.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.3.tgz#b71d40d943d0a95da01956b547f83c4a5b4a34ac"
|
|
||||||
|
|
||||||
is-callable@^1.1.1, is-callable@^1.1.3:
|
|
||||||
version "1.1.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
|
|
||||||
|
|
||||||
is-date-object@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
|
|
||||||
|
|
||||||
is-regex@^1.0.4:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
|
|
||||||
dependencies:
|
|
||||||
has "^1.0.1"
|
|
||||||
|
|
||||||
is-symbol@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
|
|
||||||
|
|
||||||
leakage@^0.3.0:
|
|
||||||
version "0.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/leakage/-/leakage-0.3.0.tgz#15d698abdc76bbc6439601f4f3020e77e2d50c39"
|
|
||||||
dependencies:
|
|
||||||
es6-error "^4.0.2"
|
|
||||||
left-pad "^1.1.3"
|
|
||||||
memwatch-next "^0.3.0"
|
|
||||||
minimist "^1.2.0"
|
|
||||||
pretty-bytes "^4.0.2"
|
|
||||||
|
|
||||||
left-pad@^1.1.3:
|
|
||||||
version "1.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
|
|
||||||
|
|
||||||
memwatch-next@^0.3.0:
|
|
||||||
version "0.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/memwatch-next/-/memwatch-next-0.3.0.tgz#2111050f9a906e0aa2d72a4ec0f0089c78726f8f"
|
|
||||||
dependencies:
|
|
||||||
bindings "^1.2.1"
|
|
||||||
nan "^2.3.2"
|
|
||||||
|
|
||||||
minimist@^1.2.0:
|
|
||||||
version "1.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
|
||||||
|
|
||||||
nan@^2.3.2:
|
|
||||||
version "2.9.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.9.2.tgz#f564d75f5f8f36a6d9456cca7a6c4fe488ab7866"
|
|
||||||
|
|
||||||
object-keys@^1.0.8:
|
|
||||||
version "1.0.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
|
|
||||||
|
|
||||||
object.getownpropertydescriptors@^2.0.3:
|
|
||||||
version "2.0.3"
|
|
||||||
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
|
|
||||||
dependencies:
|
|
||||||
define-properties "^1.1.2"
|
|
||||||
es-abstract "^1.5.1"
|
|
||||||
|
|
||||||
pretty-bytes@^4.0.2:
|
|
||||||
version "4.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
|
|
||||||
|
|
||||||
smartchai@^1.0.3:
|
|
||||||
version "1.0.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-1.0.8.tgz#a074836f4ddd4b98c50f1e7ae9e8e8ad9f6f1902"
|
|
||||||
dependencies:
|
|
||||||
"@types/code" "^4.0.3"
|
|
||||||
code "^5.1.0"
|
|
||||||
typings-global "^1.0.20"
|
|
||||||
|
|
||||||
smartdelay@^1.0.3:
|
|
||||||
version "1.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartdelay/-/smartdelay-1.0.4.tgz#791c1a4ee6770494064c10b1d2d2b8e6f3105b82"
|
|
||||||
dependencies:
|
|
||||||
smartq "^1.1.1"
|
|
||||||
typings-global "^1.0.16"
|
|
||||||
|
|
||||||
smartq@^1.1.1:
|
|
||||||
version "1.1.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
|
|
||||||
dependencies:
|
|
||||||
typings-global "^1.0.19"
|
|
||||||
util.promisify "^1.0.0"
|
|
||||||
|
|
||||||
tapbundle@^1.0.13:
|
|
||||||
version "1.1.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-1.1.8.tgz#e08aee0e100a830d8a26a583a85d37ce53312e02"
|
|
||||||
dependencies:
|
|
||||||
"@types/node" "^8.0.33"
|
|
||||||
early "^2.1.1"
|
|
||||||
leakage "^0.3.0"
|
|
||||||
smartchai "^1.0.3"
|
|
||||||
smartdelay "^1.0.3"
|
|
||||||
smartq "^1.1.1"
|
|
||||||
typings-global "^1.0.19"
|
|
||||||
|
|
||||||
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19, typings-global@^1.0.20:
|
|
||||||
version "1.0.28"
|
|
||||||
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.28.tgz#e28cc965476564cbc00e438739e0aa0735d323d4"
|
|
||||||
|
|
||||||
util.promisify@^1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
|
|
||||||
dependencies:
|
|
||||||
define-properties "^1.1.2"
|
|
||||||
object.getownpropertydescriptors "^2.0.3"
|
|
Reference in New Issue
Block a user