Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
fde3000555 | |||
f065ef0e94 | |||
656f5b7dfb | |||
557c7b2ac5 | |||
233e07040e |
@ -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
|
24
changelog.md
Normal file
24
changelog.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
## 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,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"
|
||||
}
|
||||
}
|
||||
}
|
40
package.json
40
package.json
@ -1,17 +1,37 @@
|
||||
{
|
||||
"name": "beautyfiglet",
|
||||
"version": "1.0.3",
|
||||
"description": "figlet display in nodejs",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"name": "@push.rocks/beautyfiglet",
|
||||
"version": "1.0.4",
|
||||
"description": "A Node.js module for creating figlet text displays.",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(npmts)",
|
||||
"test": "(tstest test/)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tapbundle": "^1.0.13"
|
||||
"dependencies": {
|
||||
"@types/figlet": "^1.7.0",
|
||||
"figlet": "^1.8.0"
|
||||
},
|
||||
"dependencies": {}
|
||||
"homepage": "https://code.foss.global/push.rocks/beautyfiglet",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://code.foss.global/push.rocks/beautyfiglet.git"
|
||||
},
|
||||
"keywords": [
|
||||
"figlet",
|
||||
"text display",
|
||||
"Node.js",
|
||||
"npm module",
|
||||
"typescript"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@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 @@
|
||||
|
357
readme.md
Normal file
357
readme.md
Normal 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
|
||||
|
||||
Let’s 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. Here’s 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 doesn’t support colored text directly, you can use other npm packages like `chalk` to add colors to figlet text. Here’s 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. Here’s 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. Here’s 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`. Here’s 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.
|
33
test/test.ts
33
test/test.ts
@ -1,8 +1,31 @@
|
||||
import { expect, tap } from 'tapbundle';
|
||||
import * as beautyfiglet from '../ts/index';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as beautyfiglet from '../ts/index.js';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(beautyfiglet.standardExport);
|
||||
let testFiglet: typeof beautyfiglet.BeautyFiglet;
|
||||
|
||||
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.4',
|
||||
description: 'A Node.js module for creating figlet text displays.'
|
||||
}
|
@ -1,2 +1,6 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
import figlet, { type Fonts } from 'figlet';
|
||||
|
||||
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