diff --git a/dist/README.md b/dist/README.md index a2e93f5..341908c 100644 --- a/dist/README.md +++ b/dist/README.md @@ -1,48 +1,31 @@
-[![GitHub License](https://img.shields.io/github/license/scape-agency/pack.gl?style=flat-square&logo=readthedocs&logoColor=FFFFFF&label=&labelColor=%23041B26&color=%23041B26&link=LICENSE)](https://github.com/scape-agency/pack.gl/blob/main/LICENSE) -[![devContainer](https://img.shields.io/badge/Container-Remote?style=flat-square&logo=visualstudiocode&logoColor=%23FFFFFF&label=Remote&labelColor=%23041B26&color=%23041B26)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/scape-agency/pack.gl) +[![GitHub License](https://img.shields.io/github/license/stylescape/pack.gl?style=flat-square&logo=readthedocs&logoColor=FFFFFF&label=&labelColor=%23041B26&color=%23041B26&link=LICENSE)](https://github.com/stylescape/pack.gl/blob/main/LICENSE) +[![devContainer](https://img.shields.io/badge/devContainer-23041B26?style=flat-square&logo=Docker&logoColor=%23FFFFFF&labelColor=%23041B26&color=%23041B26)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/stylescape/pack.gl) +[![StackBlitz](https://img.shields.io/badge/StackBlitz-23041B26?style=flat-square&logo=StackBlitz&logoColor=%23FFFFFF&labelColor=%23041B26&color=%23041B26)](https://stackblitz.com/github/stylescape/pack.gl/tree/main?file=src%2Findex.html)
---- - -
- pack.gl logo -

pack.gl

-

Package Builder

-
- ---- - -pack.gl cover - -### Contents - -- [Introduction](#introduction) -- [Features](#features) -- [Installation](#installation) -- [Usage](#usage) -- [Colophon](#colophon) - -
+

+ Stylescape Logo +

+

pack.gl

+

Package Pipeline Manager

---
-[![Report a Bug](https://img.shields.io/badge/Report%20a%20Bug-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/scape-agency/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=bug_report.yml) -[![Request a Feature](https://img.shields.io/badge/Request%20a%20Feature-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/scape-agency/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=feature_request.yml) -[![Ask a Question](https://img.shields.io/badge/Ask%20a%20Question-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/scape-agency/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=question.yml) -[![Make a Suggestion](https://img.shields.io/badge/Make%20a%20Suggestion-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/scape-agency/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=suggestion.yml) -[![Start a Discussion](https://img.shields.io/badge/Start%20a%20Discussion-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/scape-agency/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=discussion.yml) +[![Report a Bug](https://img.shields.io/badge/Report%20a%20Bug-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/stylescape/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=bug_report.yml) +[![Request a Feature](https://img.shields.io/badge/Request%20a%20Feature-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/stylescape/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=feature_request.yml) +[![Ask a Question](https://img.shields.io/badge/Ask%20a%20Question-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/stylescape/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=question.yml) +[![Make a Suggestion](https://img.shields.io/badge/Make%20a%20Suggestion-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/stylescape/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=suggestion.yml) +[![Start a Discussion](https://img.shields.io/badge/Start%20a%20Discussion-GitHub?style=flat-square&&logoColor=%23FFFFFF&color=%23E1E4E5)](https://github.com/stylescape/pack.gl/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=discussion.yml)
**Package Builder for the `.gl`-libraries of Scape Agency and its affiliates.** -## Introduction - `pack.gl` is an advanced package builder designed to enhance the efficiency and organization of software development projects. It offers an intuitive interface and robust features tailored for managing and building a wide range of software packages. `pack.gl` stands as a cutting-edge package builder, meticulously crafted to revolutionize the efficiency and organization of software development projects. It emerges as a powerful tool in the realm of package management, offering a seamless and user-friendly interface coupled with a suite of robust features. Designed to cater to the diverse needs of modern software development, `pack.gl` simplifies and streamlines the process of managing and constructing various types of software packages. @@ -51,14 +34,6 @@ At its core, `pack.gl` is engineered to address the complexities and challenges Key to its design philosophy is the adaptability to various development workflows, making it an ideal companion for a range of projects from small-scale personal endeavors to large, complex enterprise applications. `pack.gl` stands not just as a tool but as a partner in the software development journey, enhancing productivity, reducing overhead, and bringing clarity and ease to the package management process. -In essence, `pack.gl` is more than a package builder; it's a catalyst for innovation and efficiency, empowering developers to focus on what they do best — creating remarkable software solutions. - -## Features - -- **Streamlined Integration**: Easily integrates with various software development workflows. -- **Customizable Builds**: Provides a range of build options customizable to different project requirements. -- **Effective Management**: Organizes and manages package dependencies, streamlining the development process. - ## Installation ### HTML Script Tag @@ -81,11 +56,6 @@ Here's how to get started with `pack.gl`: // Sample code to demonstrate basic usage ``` -## Links - -- [Website](https://www.pack.gl) -- [NPM](https://www.npmjs.com/package/pack.gl) - --- ## Colophon @@ -99,7 +69,13 @@ Here's how to get started with `pack.gl`: Scape Agency is a spatial innovation collective that dreams, discovers and designs the everyday of tomorrow. We blend design thinking with emerging technologies to create a brighter perspective for people and planet. Our products and services naturalise technology in liveable and sustainable –scapes that spark the imagination and inspire future generations. - website: [scape.agency](https://www.scape.agency "Scape Agency website") -- github: [github.com/scape-agency](https://github.com/scape-agency "Scape Agency GitHub") +- github: [github.com/stylescape](https://github.com/stylescape "Scape Agency GitHub") + +### Links + +- [Website](https://www.pack.gl) +- [NPM](https://www.npmjs.com/package/pack.gl) + ### Development Resources @@ -112,7 +88,7 @@ Please refer to the [contribution guidelines](.github/CONTRIBUTING.md) for infor #### Copyright -Copyright © 2023 [Scape Agency BV](https://www.scape.agency/ "Scape Agency website"). All Rights Reserved. +Copyright © 2024 [Scape Agency BV](https://www.scape.agency/ "Scape Agency website"). All Rights Reserved. #### License @@ -120,7 +96,7 @@ Except as otherwise noted, the content in this repository is licensed under the [Creative Commons Attribution 4.0 International (CC BY 4.0) License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0). -Also see [LICENSE](https://github.com/scape-agency/community/blob/master/src/LICENSE) and [LICENSE-CODE](https://github.com/scape-agency/community/blob/master/src/LICENSE-CODE). +Also see [LICENSE](https://github.com/stylescape/community/blob/master/src/LICENSE) and [LICENSE-CODE](https://github.com/stylescape/community/blob/master/src/LICENSE-CODE). #### Disclaimer diff --git a/dist/js/class/CodeLinter.d.ts b/dist/js/class/CodeLinter.d.ts deleted file mode 100644 index 1340e5f..0000000 --- a/dist/js/class/CodeLinter.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ESLint } from 'eslint'; -declare class CodeLinter { - private eslint; - private projectRoot; - constructor(projectRoot: string); - /** - * Runs ESLint on the specified files or directories. - * @param targetFiles Array of file or directory paths to lint. - * @returns A promise that resolves with the linting results. - */ - lintFiles(targetFiles: string[]): Promise; -} -export default CodeLinter; diff --git a/dist/js/class/CodeLinter.js b/dist/js/class/CodeLinter.js deleted file mode 100644 index 105dfc8..0000000 --- a/dist/js/class/CodeLinter.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -// class/CodeLinter.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var eslint_1 = require("eslint"); -// ============================================================================ -// Classes -// ============================================================================ -class CodeLinter { - constructor(projectRoot) { - this.projectRoot = projectRoot; - this.eslint = new eslint_1.ESLint({ cwd: projectRoot }); - } - /** - * Runs ESLint on the specified files or directories. - * @param targetFiles Array of file or directory paths to lint. - * @returns A promise that resolves with the linting results. - */ - async lintFiles(targetFiles) { - try { - const results = await this.eslint.lintFiles(targetFiles); - await eslint_1.ESLint.outputFixes(results); - const formatter = await this.eslint.loadFormatter('stylish'); - const resultText = formatter.format(results); - console.log(resultText); - return results; - } - catch (error) { - console.error('Error occurred while linting:', error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = CodeLinter; -// import CodeLinter from './CodeLinter'; -// const linter = new CodeLinter(process.cwd()); -// linter.lintFiles(['src/**/*.ts']) -// .then(results => { -// console.log('Linting completed. Results:', results); -// }) -// .catch(error => { -// console.error('Linting error:', error); -// }); diff --git a/dist/js/class/DirectoryCleaner.d.ts b/dist/js/class/DirectoryCleaner.d.ts deleted file mode 100644 index cd57e79..0000000 --- a/dist/js/class/DirectoryCleaner.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare class DirectoryCleaner { - /** - * Recursively deletes all contents of the directory. - * @param dirPath The path to the directory to clean. - */ - cleanDirectory(dirPath: string): void; -} -export default DirectoryCleaner; diff --git a/dist/js/class/DirectoryCleaner.js b/dist/js/class/DirectoryCleaner.js deleted file mode 100644 index 94181c4..0000000 --- a/dist/js/class/DirectoryCleaner.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; -// class/DirectoryCleaner.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -// import { promises as fsPromises } from 'fs'; -var path_1 = __importDefault(require("path")); -var fs_1 = __importDefault(require("fs")); -// ============================================================================ -// Classes -// ============================================================================ -class DirectoryCleaner { - /** - * Recursively deletes all contents of the directory. - * @param dirPath The path to the directory to clean. - */ - cleanDirectory(dirPath) { - if (fs_1.default.existsSync(dirPath)) { - fs_1.default.readdirSync(dirPath).forEach(file => { - const curPath = path_1.default.join(dirPath, file); - if (fs_1.default.lstatSync(curPath).isDirectory()) { // Recurse - this.cleanDirectory(curPath); - } - else { // Delete file - fs_1.default.unlinkSync(curPath); - } - }); - fs_1.default.rmdirSync(dirPath); - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = DirectoryCleaner; diff --git a/dist/js/class/DirectoryCopier.d.ts b/dist/js/class/DirectoryCopier.d.ts deleted file mode 100644 index ba4361a..0000000 --- a/dist/js/class/DirectoryCopier.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * A class for copying files from one directory to another. - */ -declare class DirectoryCopier { - /** - * Copies all files and subdirectories from a source directory to a destination directory. - * @param srcDir The source directory path. - * @param destDir The destination directory path. - * @throws Will throw an error if copying fails for any file or directory. - */ - copyFiles(srcDir: string, destDir: string): Promise; - /** - * Recursively copies files and directories. - * @param srcDir Source directory. - * @param destDir Destination directory. - */ - recursiveCopy(srcDir: string, destDir: string): Promise; -} -export default DirectoryCopier; diff --git a/dist/js/class/DirectoryCopier.js b/dist/js/class/DirectoryCopier.js deleted file mode 100644 index b3ef303..0000000 --- a/dist/js/class/DirectoryCopier.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -// class/DirectoryCopier.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var path_1 = __importDefault(require("path")); -var fs_1 = require("fs"); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for copying files from one directory to another. - */ -class DirectoryCopier { - /** - * Copies all files and subdirectories from a source directory to a destination directory. - * @param srcDir The source directory path. - * @param destDir The destination directory path. - * @throws Will throw an error if copying fails for any file or directory. - */ - async copyFiles(srcDir, destDir) { - try { - const resolvedSrcDir = path_1.default.resolve(srcDir); - const resolvedDestDir = path_1.default.resolve(destDir); - await this.recursiveCopy(resolvedSrcDir, resolvedDestDir); - console.log(`Files copied from ${resolvedSrcDir} to ${resolvedDestDir}`); - } - catch (error) { - console.error('Error copying files:', error); - throw error; - } - } - /** - * Recursively copies files and directories. - * @param srcDir Source directory. - * @param destDir Destination directory. - */ - async recursiveCopy(srcDir, destDir) { - await fs_1.promises.mkdir(destDir, { recursive: true }); - const entries = await fs_1.promises.readdir(srcDir, { withFileTypes: true }); - for (let entry of entries) { - const srcPath = path_1.default.join(srcDir, entry.name); - const destPath = path_1.default.join(destDir, entry.name); - entry.isDirectory() ? - await this.recursiveCopy(srcPath, destPath) : - await fs_1.promises.copyFile(srcPath, destPath); - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = DirectoryCopier; diff --git a/dist/js/class/DirectoryCreator.d.ts b/dist/js/class/DirectoryCreator.d.ts deleted file mode 100644 index 27b5b63..0000000 --- a/dist/js/class/DirectoryCreator.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * A class for creating directories. - */ -declare class DirectoryCreator { - /** - * Creates directories at the specified locations asynchronously. - * @param basePath The base path where directories will be created. - * @param directories An array of directory paths to create. - * @description This method iterates over the provided array of directory paths, - * creating each directory at the specified location within the base path. - * If a directory already exists, it skips creation. This is useful for - * setting up a project structure or ensuring necessary directories are - * available before performing file operations. - * @throws Will throw an error if directory creation fails. - */ - createDirectories(basePath: string, directories: string[]): Promise; -} -export default DirectoryCreator; diff --git a/dist/js/class/DirectoryCreator.js b/dist/js/class/DirectoryCreator.js deleted file mode 100644 index 256e523..0000000 --- a/dist/js/class/DirectoryCreator.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -// class/DirectoryGenerator.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs_1 = require("fs"); -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for creating directories. - */ -class DirectoryCreator { - /** - * Creates directories at the specified locations asynchronously. - * @param basePath The base path where directories will be created. - * @param directories An array of directory paths to create. - * @description This method iterates over the provided array of directory paths, - * creating each directory at the specified location within the base path. - * If a directory already exists, it skips creation. This is useful for - * setting up a project structure or ensuring necessary directories are - * available before performing file operations. - * @throws Will throw an error if directory creation fails. - */ - async createDirectories(basePath, directories) { - try { - for (const dir of directories) { - const dirPath = path_1.default.join(basePath, dir); - await fs_1.promises.mkdir(dirPath, { recursive: true }); - // console.log(`Directory created or already exists: ${dirPath}`); - } - } - catch (error) { - console.error(`Error creating directories: ${error}`); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = DirectoryCreator; diff --git a/dist/js/class/DirectoryScanner.d.ts b/dist/js/class/DirectoryScanner.d.ts deleted file mode 100644 index 5b487d1..0000000 --- a/dist/js/class/DirectoryScanner.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare class DirectoryScanner { - /** - * Scans a directory and returns a list of file paths. - * Can optionally scan directories recursively. - * @param dirPath The directory to scan. - * @param recursive Whether to scan directories recursively. - * @returns A promise that resolves to an array of file paths. - */ - scanDirectory(dirPath: string, recursive?: boolean): Promise; -} -export default DirectoryScanner; diff --git a/dist/js/class/DirectoryScanner.js b/dist/js/class/DirectoryScanner.js deleted file mode 100644 index e7c4e04..0000000 --- a/dist/js/class/DirectoryScanner.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -// class/DirectoryScanner.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var promises_1 = __importDefault(require("fs/promises")); -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Classes -// ============================================================================ -class DirectoryScanner { - /** - * Scans a directory and returns a list of file paths. - * Can optionally scan directories recursively. - * @param dirPath The directory to scan. - * @param recursive Whether to scan directories recursively. - * @returns A promise that resolves to an array of file paths. - */ - async scanDirectory(dirPath, recursive = false) { - try { - const entries = await promises_1.default.readdir(dirPath, { withFileTypes: true }); - const files = await Promise.all(entries.map(async (entry) => { - const resolvedPath = path_1.default.resolve(dirPath, entry.name); - return entry.isDirectory() && recursive - ? this.scanDirectory(resolvedPath, true) - : resolvedPath; - })); - return files.flat(); - } - catch (error) { - console.error(`Error scanning directory: ${dirPath}`, error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = DirectoryScanner; diff --git a/dist/js/class/DocumentationGenerator.d.ts b/dist/js/class/DocumentationGenerator.d.ts deleted file mode 100644 index 109b638..0000000 --- a/dist/js/class/DocumentationGenerator.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare class DocumentationGenerator { - private sourcePath; - private outputPath; - private generatorCommand; - constructor(sourcePath: string, outputPath: string, generatorCommand: string); - /** - * Generates documentation based on the provided configuration. - * @returns A promise that resolves when the documentation generation is complete. - */ - generate(): Promise; -} -export default DocumentationGenerator; diff --git a/dist/js/class/DocumentationGenerator.js b/dist/js/class/DocumentationGenerator.js deleted file mode 100644 index d4e8389..0000000 --- a/dist/js/class/DocumentationGenerator.js +++ /dev/null @@ -1,67 +0,0 @@ -"use strict"; -// class/DocumentationGenerator.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var child_process_1 = require("child_process"); -var util_1 = __importDefault(require("util")); -const execAsync = util_1.default.promisify(child_process_1.exec); -// ============================================================================ -// Classes -// ============================================================================ -class DocumentationGenerator { - constructor(sourcePath, outputPath, generatorCommand) { - this.sourcePath = sourcePath; - this.outputPath = outputPath; - this.generatorCommand = generatorCommand; - } - /** - * Generates documentation based on the provided configuration. - * @returns A promise that resolves when the documentation generation is complete. - */ - async generate() { - try { - // Here, you can add any pre-generation logic if necessary - // Execute the documentation generation command - const { stdout, stderr } = await execAsync(`${this.generatorCommand} -c ${this.sourcePath} -o ${this.outputPath}`); - if (stderr) { - throw new Error(`Documentation generation failed: ${stderr}`); - } - console.log(stdout); - console.log('Documentation generated successfully.'); - // Here, you can add any post-generation logic if necessary - } - catch (error) { - console.error('Error occurred while generating documentation:', error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = DocumentationGenerator; -// Usage Example -// To use the DocumentationGenerator class, you would instantiate it with the path to your source files, the output directory for the documentation, and the command for your documentation tool. For instance, using JSDoc: -// import DocumentationGenerator from './DocumentationGenerator'; -// const sourcePath = './src'; -// const outputPath = './docs'; -// const generatorCommand = 'jsdoc'; // Ensure JSDoc is installed and available in your environment -// const docGenerator = new DocumentationGenerator(sourcePath, outputPath, generatorCommand); -// docGenerator.generate() -// .then(() => console.log('Documentation generation completed.')) -// .catch(error => console.error(error)); diff --git a/dist/js/class/FileCopier.d.ts b/dist/js/class/FileCopier.d.ts deleted file mode 100644 index 4d170c4..0000000 --- a/dist/js/class/FileCopier.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * A class for copying files from one location to another. - */ -declare class FileCopier { - /** - * Copies a single file to a specified destination directory. - * @param {string} srcFile - The path of the source file to copy. - * @param {string} destDir - The destination directory where the file should be copied. - * @throws Will throw an error if the file copy operation fails. - */ - copyFileToDirectory(srcFile: string, destDir: string): Promise; -} -export default FileCopier; diff --git a/dist/js/class/FileCopier.js b/dist/js/class/FileCopier.js deleted file mode 100644 index b4f7f8d..0000000 --- a/dist/js/class/FileCopier.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -// class/FileCopier.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs_1 = __importDefault(require("fs")); -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for copying files from one location to another. - */ -class FileCopier { - /** - * Copies a single file to a specified destination directory. - * @param {string} srcFile - The path of the source file to copy. - * @param {string} destDir - The destination directory where the file should be copied. - * @throws Will throw an error if the file copy operation fails. - */ - async copyFileToDirectory(srcFile, destDir) { - try { - const fileName = path_1.default.basename(srcFile); - const destFilePath = path_1.default.join(destDir, fileName); - await fs_1.default.promises.copyFile(srcFile, destFilePath); - console.log(`File copied from ${srcFile} to ${destFilePath}`); - } - catch (error) { - console.error('Error copying file:', error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = FileCopier; diff --git a/dist/js/class/FileRenamer.d.ts b/dist/js/class/FileRenamer.d.ts deleted file mode 100644 index 4fc63ac..0000000 --- a/dist/js/class/FileRenamer.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * A class for renaming files. - */ -declare class FileRenamer { - /** - * Renames a file from the source path to the target path. - * @param srcPath The current path of the file. - * @param targetPath The new path of the file after renaming. - * @returns Promise - */ - renameFile(srcPath: string, targetPath: string): Promise; -} -export default FileRenamer; diff --git a/dist/js/class/FileRenamer.js b/dist/js/class/FileRenamer.js deleted file mode 100644 index d4607c5..0000000 --- a/dist/js/class/FileRenamer.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; -// class/FileRenamer.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs_1 = __importDefault(require("fs")); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for renaming files. - */ -class FileRenamer { - /** - * Renames a file from the source path to the target path. - * @param srcPath The current path of the file. - * @param targetPath The new path of the file after renaming. - * @returns Promise - */ - async renameFile(srcPath, targetPath) { - try { - await fs_1.default.promises.rename(srcPath, targetPath); - console.log(`File renamed from ${srcPath} to ${targetPath}`); - } - catch (error) { - console.error('Error renaming file:', error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = FileRenamer; diff --git a/dist/js/class/FilenameExtractor.d.ts b/dist/js/class/FilenameExtractor.d.ts deleted file mode 100644 index b17b860..0000000 --- a/dist/js/class/FilenameExtractor.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare class FilenameExtractor { - /** - * Extracts the filename without its extension from a file path. - * @param filePath The full path of the file. - * @returns The filename without its extension. - */ - getFilenameWithoutExtension(filePath: string): string; -} -export default FilenameExtractor; diff --git a/dist/js/class/FilenameExtractor.js b/dist/js/class/FilenameExtractor.js deleted file mode 100644 index 321c92d..0000000 --- a/dist/js/class/FilenameExtractor.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -// class/FilenameExtractor.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Classes -// ============================================================================ -class FilenameExtractor { - /** - * Extracts the filename without its extension from a file path. - * @param filePath The full path of the file. - * @returns The filename without its extension. - */ - getFilenameWithoutExtension(filePath) { - return path_1.default.basename(filePath, path_1.default.extname(filePath)); - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = FilenameExtractor; diff --git a/dist/js/class/FontGenerator.d.ts b/dist/js/class/FontGenerator.d.ts deleted file mode 100644 index e15b71e..0000000 --- a/dist/js/class/FontGenerator.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare class FontGenerator { - /** - * Configuration for the TypeScript compiler. - */ - private config; - /** - * Default configuration for the TypeScript compiler. - */ - private static defaultConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. - */ - constructor(customConfig?: any); - generateFonts(sourceDirectory: string, outputDiectory: string, options?: {}): Promise; -} -export default FontGenerator; diff --git a/dist/js/class/FontGenerator.js b/dist/js/class/FontGenerator.js deleted file mode 100644 index 8e33fcb..0000000 --- a/dist/js/class/FontGenerator.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -// class/FontGenerator.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fantasticon_1 = require("fantasticon"); -var fantasticon_config_js_1 = __importDefault(require("../config/fantasticon.config.js")); -// ============================================================================ -// Classes -// ============================================================================ -class FontGenerator { - /** - * Default configuration for the TypeScript compiler. - */ - static { this.defaultConfig = fantasticon_config_js_1.default; } - // private static defaultConfig: CompilerOptions = tsConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. - */ - constructor(customConfig = {}) { - this.config = { - ...FontGenerator.defaultConfig, - ...customConfig - }; - } - async generateFonts(sourceDirectory, outputDiectory, options) { - const config = { - ...this.config, - // RunnerMandatoryOptions - inputDir: sourceDirectory, // (required) - outputDir: outputDiectory, // (required) - ...options - }; - try { - await (0, fantasticon_1.generateFonts)(config); - console.log('Fonts generated successfully.'); - } - catch (error) { - console.error('Error generating fonts:', error); - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = FontGenerator; diff --git a/dist/js/class/JSONLoader.d.ts b/dist/js/class/JSONLoader.d.ts deleted file mode 100644 index 8f99157..0000000 --- a/dist/js/class/JSONLoader.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -declare class JSONLoader { - /** - * Asynchronously loads JSON data from a file and returns it as an object. - * @param filePath The path to the JSON file. - * @returns A promise that resolves to an object containing the JSON data. - */ - loadJSON(filePath: string): Promise; - /** - * Asynchronously loads all JSON files from a given directory. - * @param dirPath The path to the directory containing JSON files. - * @returns A promise that resolves to an array of objects containing the JSON data. - */ - loadJSONFromDirectory(dirPath: string): Promise; - /** - * Merges an array of objects into a single object. - * @param objects An array of objects to merge. - * @returns A single object containing all properties from the input objects. - */ - mergeJSONObjects(objects: T[]): Promise; -} -export default JSONLoader; diff --git a/dist/js/class/JSONLoader.js b/dist/js/class/JSONLoader.js deleted file mode 100644 index 9cd9caa..0000000 --- a/dist/js/class/JSONLoader.js +++ /dev/null @@ -1,70 +0,0 @@ -"use strict"; -// class/JSONLoader.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs_1 = require("fs"); -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Classes -// ============================================================================ -class JSONLoader { - /** - * Asynchronously loads JSON data from a file and returns it as an object. - * @param filePath The path to the JSON file. - * @returns A promise that resolves to an object containing the JSON data. - */ - async loadJSON(filePath) { - try { - const data = await fs_1.promises.readFile(filePath, 'utf8'); - return JSON.parse(data); - } - catch (error) { - console.error(`Error reading JSON file: ${filePath}`, error); - throw error; - } - } - /** - * Asynchronously loads all JSON files from a given directory. - * @param dirPath The path to the directory containing JSON files. - * @returns A promise that resolves to an array of objects containing the JSON data. - */ - async loadJSONFromDirectory(dirPath) { - try { - const files = await fs_1.promises.readdir(dirPath); - const jsonFiles = files.filter(file => file.endsWith('.json')); - const jsonData = await Promise.all(jsonFiles.map(file => this.loadJSON(path_1.default.join(dirPath, file)))); - return jsonData; - } - catch (error) { - console.error(`Error reading JSON files from directory: ${dirPath}`, error); - throw error; - } - } - /** - * Merges an array of objects into a single object. - * @param objects An array of objects to merge. - * @returns A single object containing all properties from the input objects. - */ - async mergeJSONObjects(objects) { - return objects.reduce((acc, obj) => ({ ...acc, ...obj }), {}); - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = JSONLoader; diff --git a/dist/js/class/JavaScriptMinifier.d.ts b/dist/js/class/JavaScriptMinifier.d.ts deleted file mode 100644 index 805749c..0000000 --- a/dist/js/class/JavaScriptMinifier.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Class to minify JavaScript files using Terser. - */ -declare class JavaScriptMinifier { - /** - * Configuration for the JavaScript compiler. - */ - private config; - /** - * Default configuration for the JavaScript compiler. - */ - private static defaultConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {any} customConfig - OptionalConfiguration object - minification options for Terser. - */ - constructor(customConfig?: any); - /** - * Minifies a JavaScript file. - * @param {string} inputPath - Path to the input JavaScript file. - * @param {string} outputPath - Path to save the minified output file. - * @returns {Promise} - A promise that resolves when minification is complete. - */ - minifyFile(inputPath: string, outputPath: string): Promise; -} -export default JavaScriptMinifier; diff --git a/dist/js/class/JavaScriptMinifier.js b/dist/js/class/JavaScriptMinifier.js deleted file mode 100644 index c43f900..0000000 --- a/dist/js/class/JavaScriptMinifier.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; -// class/JavaScriptMinifier.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var terser_1 = require("terser"); -var fs_1 = require("fs"); -var terser_config_js_1 = __importDefault(require("../config/terser.config.js")); -// ============================================================================ -// Classes -// ============================================================================ -/** - * Class to minify JavaScript files using Terser. - */ -class JavaScriptMinifier { - /** - * Default configuration for the JavaScript compiler. - */ - static { this.defaultConfig = terser_config_js_1.default; } - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {any} customConfig - OptionalConfiguration object - minification options for Terser. - */ - constructor(customConfig = {}) { - this.config = { - ...JavaScriptMinifier.defaultConfig, - ...customConfig - }; - } - /** - * Minifies a JavaScript file. - * @param {string} inputPath - Path to the input JavaScript file. - * @param {string} outputPath - Path to save the minified output file. - * @returns {Promise} - A promise that resolves when minification is complete. - */ - async minifyFile(inputPath, outputPath) { - try { - // Read the input file - const inputCode = await fs_1.promises.readFile(inputPath, 'utf8'); - // Minify the file using Terser - const result = await (0, terser_1.minify)(inputCode, this.config); - // If minification is successful, write the output - if (result.code) { - await fs_1.promises.writeFile(outputPath, result.code); - } - else { - throw new Error('Minification resulted in empty output.'); - } - } - catch (error) { - console.error(`Error minifying JavaScript file ${inputPath}:`, error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = JavaScriptMinifier; diff --git a/dist/js/class/NpmCommandRunner.d.ts b/dist/js/class/NpmCommandRunner.d.ts deleted file mode 100644 index c580759..0000000 --- a/dist/js/class/NpmCommandRunner.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare class NpmCommandRunner { - /** - * Executes an npm command. - * @param command The npm command to run. - * @returns A promise that resolves with the command output or rejects with an error. - */ - runCommand(command: string): Promise; -} -export default NpmCommandRunner; diff --git a/dist/js/class/NpmCommandRunner.js b/dist/js/class/NpmCommandRunner.js deleted file mode 100644 index 6d6b4e0..0000000 --- a/dist/js/class/NpmCommandRunner.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; -// class/NpmCommandRunner.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var child_process_1 = require("child_process"); -// ============================================================================ -// Classes -// ============================================================================ -/// TypeScript Class to Run NPM Commands -class NpmCommandRunner { - /** - * Executes an npm command. - * @param command The npm command to run. - * @returns A promise that resolves with the command output or rejects with an error. - */ - runCommand(command) { - return new Promise((resolve, reject) => { - (0, child_process_1.exec)(`npm ${command}`, (error, stdout, stderr) => { - if (error) { - reject(`error: ${error.message}`); - return; - } - if (stderr) { - reject(`stderr: ${stderr}`); - return; - } - resolve(stdout); - }); - }); - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = NpmCommandRunner; diff --git a/dist/js/class/PackageCreator.d.ts b/dist/js/class/PackageCreator.d.ts deleted file mode 100644 index fd9c1d6..0000000 --- a/dist/js/class/PackageCreator.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * A class for creating a package.json file for a project. - */ -declare class PackageCreator { - /** - * Configuration for the Package.json. - */ - config: any; - /** - * Default configuration for Package.json. - */ - private static defaultConfig; - /** - * Initializes a new instance of the PackageCreator class. - * @param {PackageJson} customConfig - The content to be written into package.json. - */ - constructor(customConfig?: any); - /** - * Creates a package.json file in the specified directory. - * Creates the directory if it does not exist. - * @param outputDir - The directory where package.json will be created. - */ - createPackageJson(outputDir: string): Promise; - /** - * Ensures that the given directory exists. Creates it if it does not exist. - * @param dirPath - The path of the directory to check and create. - */ - private ensureDirectoryExists; -} -export default PackageCreator; diff --git a/dist/js/class/PackageCreator.js b/dist/js/class/PackageCreator.js deleted file mode 100644 index 61bea2e..0000000 --- a/dist/js/class/PackageCreator.js +++ /dev/null @@ -1,99 +0,0 @@ -"use strict"; -// class/PackageCreator.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var promises_1 = __importDefault(require("fs/promises")); -var path_1 = __importDefault(require("path")); -var package_config_js_1 = __importDefault(require("../config/package.config.js")); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for creating a package.json file for a project. - */ -class PackageCreator { - // private config: ts.CompilerOptions; - // private config: { [key: symbol]: any}; - /** - * Default configuration for Package.json. - */ - static { this.defaultConfig = package_config_js_1.default; } - /** - * Initializes a new instance of the PackageCreator class. - * @param {PackageJson} customConfig - The content to be written into package.json. - */ - constructor(customConfig = {}) { - let newConfig = { - // Populate with necessary fields from packageData - name: customConfig.name, - version: customConfig.version, - description: customConfig.description, - keywords: customConfig.keywords, - author: customConfig.author, - contributors: customConfig.contributors, - license: customConfig.license, - homepage: customConfig.homepage, - repository: customConfig.repository, - funding: customConfig.funding, - dependencies: customConfig.dependencies - }; - this.config = { - ...PackageCreator.defaultConfig, - ...newConfig - }; - } - /** - * Creates a package.json file in the specified directory. - * Creates the directory if it does not exist. - * @param outputDir - The directory where package.json will be created. - */ - async createPackageJson(outputDir) { - const filePath = path_1.default.join(outputDir, 'package.json'); - const data = JSON.stringify(this.config, null, 2); - try { - // Ensure the output directory exists - await this.ensureDirectoryExists(outputDir); - // Write the package.json file - await promises_1.default.writeFile(filePath, data, 'utf-8'); - console.log(`package.json created at ${filePath}`); - } - catch (error) { - console.error(`Error creating package.json: ${error}`); - throw error; - } - } - /** - * Ensures that the given directory exists. Creates it if it does not exist. - * @param dirPath - The path of the directory to check and create. - */ - async ensureDirectoryExists(dirPath) { - try { - await promises_1.default.mkdir(dirPath, { recursive: true }); - } - catch (error) { - // Check if error is an instance of NodeJS.ErrnoException - if (error instanceof Error && error.code !== 'EEXIST') { - throw error; // Rethrow if it's not a 'directory exists' error - } - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = PackageCreator; diff --git a/dist/js/class/StyleProcessor.d.ts b/dist/js/class/StyleProcessor.d.ts deleted file mode 100644 index 3d57f7c..0000000 --- a/dist/js/class/StyleProcessor.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -declare class StyleProcessor { - /** - * Processes the given CSS with PostCSS based on the provided style option. - * @param css The CSS string to process. - * @param styleOption The style option, either 'expanded' or 'compressed'. - * @returns Processed CSS string. - */ - processPostCSS(css: string, styleOption: 'expanded' | 'compressed'): Promise; - /** - * Ensures that the given directory exists. Creates it if it does not exist. - * @param dirPath - The path of the directory to check and create. - */ - private ensureDirectoryExists; - /** - * Compiles SCSS to CSS and processes it using PostCSS. - * @param inputFile Path to the input SCSS file. - * @param outputFile Path to the output CSS file. - * @param styleOption Style option for the output. - */ - processStyles(inputFile: string, outputFile: string, styleOption: 'expanded' | 'compressed'): Promise; -} -export default StyleProcessor; diff --git a/dist/js/class/StyleProcessor.js b/dist/js/class/StyleProcessor.js deleted file mode 100644 index dab52d6..0000000 --- a/dist/js/class/StyleProcessor.js +++ /dev/null @@ -1,185 +0,0 @@ -"use strict"; -// class/StyleProcessor.ts -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -// import * as sass from 'sass'; -// import postcss from 'postcss'; -// import fs from 'fs'; -// import { promises as fsPromises } from 'fs'; -// import path from 'path'; -var sass = __importStar(require("sass")); -var postcss_1 = __importDefault(require("postcss")); -var fs_1 = require("fs"); -var path_1 = __importDefault(require("path")); -var postcss_config_expanded_js_1 = __importDefault(require("../config/postcss.config.expanded.js")); -var postcss_config_compressed_js_1 = __importDefault(require("../config/postcss.config.compressed.js")); -// ============================================================================ -// Classes -// ============================================================================ -class StyleProcessor { - /** - * Processes the given CSS with PostCSS based on the provided style option. - * @param css The CSS string to process. - * @param styleOption The style option, either 'expanded' or 'compressed'. - * @returns Processed CSS string. - */ - async processPostCSS(css, styleOption) { - const config = styleOption === 'expanded' ? postcss_config_expanded_js_1.default : postcss_config_compressed_js_1.default; - const result = await (0, postcss_1.default)(config.plugins).process(css, { from: undefined, map: { inline: false } }); - return result.css; - } - /** - * Ensures that the given directory exists. Creates it if it does not exist. - * @param dirPath - The path of the directory to check and create. - */ - async ensureDirectoryExists(dirPath) { - try { - await fs_1.promises.mkdir(dirPath, { recursive: true }); - } - catch (error) { - if (error instanceof Error) { - const nodeError = error; - if (nodeError.code !== 'EEXIST') { - throw nodeError; // Rethrow if it's not a 'directory exists' error - } - } - else { - throw error; // Rethrow if it's not an Error instance - } - } - } - /** - * Compiles SCSS to CSS and processes it using PostCSS. - * @param inputFile Path to the input SCSS file. - * @param outputFile Path to the output CSS file. - * @param styleOption Style option for the output. - */ - async processStyles(inputFile, outputFile, styleOption) { - try { - // Ensure the output directory exists - const outputDir = path_1.default.dirname(outputFile); - await this.ensureDirectoryExists(outputDir); - // Compile SCSS to CSS - const result = await sass.compileAsync(inputFile, { style: styleOption }); - // Process the compiled CSS with PostCSS - const processedCss = await this.processPostCSS(result.css, styleOption); - // Write the processed CSS to a file - await fs_1.promises.writeFile(outputFile, processedCss, 'utf-8'); - // Optionally handle source maps - // ... - } - catch (err) { - console.error(`Error processing styles from ${inputFile}:`, err); - throw err; // Re-throw the error for further handling if necessary - } - } -} -// /** -// * Class responsible for processing styles, including compiling SCSS and -// * applying PostCSS transformations. -// */ -// class StyleProcessor { -// /** -// * Processes the given CSS with PostCSS based on the provided style option. -// * @param css The CSS string to process. -// * @param styleOption The style option, either 'expanded' or 'compressed'. -// * @returns Processed CSS string. -// */ -// async processPostCSS( -// css: string, -// styleOption: 'expanded' | 'compressed' -// ) { -// const config = styleOption === 'expanded' ? postcssConfigExpanded : postcssConfigCompressed; -// return postcss(config.plugins).process(css, { from: undefined, map: { inline: false } }); -// } -// /** -// * Ensures that the given directory exists. Creates it if it does not exist. -// * @param dirPath - The path of the directory to check and create. -// */ -// private async ensureDirectoryExists(dirPath: string): Promise { -// try { -// await fsPromises.mkdir(dirPath, { recursive: true }); -// } catch (error) { -// if (error.code !== 'EEXIST') { -// throw error; -// } -// } -// } -// /** -// * Compiles SCSS to CSS and processes it using PostCSS. -// * @param inputFile Path to the input SCSS file. -// * @param outputFile Path to the output CSS file. -// * @param styleOption Style option for the output. -// */ -// async processStyles( -// inputFile: string, -// outputFile: fs.PathOrFileDescriptor, -// styleOption: 'expanded' | 'compressed' -// ) { -// try { -// // Ensure the output directory exists -// const outputDir = path.dirname(outputFile as string); -// await this.ensureDirectoryExists(outputDir); -// // Compile SCSS to CSS -// const result = await sass.compileAsync( -// inputFile, { style: styleOption } -// ); -// // Process the compiled CSS with PostCSS and Autoprefixer -// const processed = await this.processPostCSS( -// result.css, -// styleOption -// ); -// // Write the processed CSS to a file -// fs.writeFileSync(outputFile, processed.css); -// // Write the source map file -// if (processed.map) { -// fs.writeFileSync(`${outputFile}.map`, processed.map.toString()); -// } -// } catch (err) { -// // Handle errors in the compilation or processing -// console.error(`Error processing styles from ${inputFile}:`, err); -// } -// } -// } -// ============================================================================ -// Export -// ============================================================================ -exports.default = StyleProcessor; diff --git a/dist/js/class/StylizedLogger.d.ts b/dist/js/class/StylizedLogger.d.ts deleted file mode 100644 index caf6c42..0000000 --- a/dist/js/class/StylizedLogger.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare class StylizedLogger { - private styles; - log(message: string, fgColor: keyof typeof this.styles.fg, bgColor?: keyof typeof this.styles.bg): void; - header(message: string): void; - error(message: string): void; - body(message: string): void; -} -export default StylizedLogger; diff --git a/dist/js/class/StylizedLogger.js b/dist/js/class/StylizedLogger.js deleted file mode 100644 index 8aae27e..0000000 --- a/dist/js/class/StylizedLogger.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; -// class/StylizedLogger.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -// ============================================================================ -// Classes -// ============================================================================ -class StylizedLogger { - constructor() { - this.styles = { - reset: "\x1b[0m", - fg: { - black: "\x1b[30m", - red: "\x1b[31m", - green: "\x1b[32m", - yellow: "\x1b[33m", - blue: "\x1b[34m", - magenta: "\x1b[35m", - cyan: "\x1b[36m", - white: "\x1b[37m" - }, - bg: { - black: "\x1b[40m", - red: "\x1b[41m", - green: "\x1b[42m", - yellow: "\x1b[43m", - blue: "\x1b[44m", - magenta: "\x1b[45m", - cyan: "\x1b[46m", - white: "\x1b[47m" - } - }; - } - log(message, fgColor, bgColor = 'black') { - console.log(`${this.styles.fg[fgColor]}${this.styles.bg[bgColor]}%s${this.styles.reset}`, message); - } - header(message) { - this.log(message, 'white', 'blue'); - } - error(message) { - this.log(message, 'white', 'red'); - } - body(message) { - this.log(message, 'black', 'white'); - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = StylizedLogger; diff --git a/dist/js/class/SvgPackager.d.ts b/dist/js/class/SvgPackager.d.ts deleted file mode 100644 index de0ac47..0000000 --- a/dist/js/class/SvgPackager.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Class for packaging SVG files. - * This class reads SVG files from a specified directory, optimizes them, - * and creates corresponding TypeScript files. - */ -declare class SvgPackager { - private svgoConfigPath; - /** - * Constructor for SvgPackager class. - * Optionally accepts configurations or dependencies. - */ - constructor(svgoConfigPath: string); - /** - * Processes all SVG files in a given directory. - * @param inputDirectory The directory containing SVG files to process. - * @param outputDirectory The directory where optimized SVGs will be output as TypeScript files. - */ - processSvgFiles(inputDirectory: string, outputDirectory: string, ts_output_directory: string, json_output_directory: string): Promise; - /** - * Reads the content of an SVG file. - * @param filePath The path to the SVG file. - * @returns The content of the SVG file. - */ - private readSvgFile; - /** - * Sanitizes a file name to be a valid TypeScript identifier. - * @param fileName The original file name. - * @returns A sanitized version of the file name. - */ - private sanitizeFileName; - private writeFiles; - /** - * Optimizes SVG content using SVGO. - * @param svgContent The raw SVG content. - * @returns The optimized SVG content. - */ - private optimizeSvg; - /** - * Creates a TypeScript file from SVG content. - * @param filePath The path of the SVG file. - * @param svgContent The optimized SVG content. - * @param outputDirectory The directory to output the TypeScript file. - */ - private writeTypeScriptFile; - /** - * Writes the SVG content to a file. - * @param filePath The original file path of the SVG. - * @param svgContent The SVG content to be written. - * @param outputDirectory The directory to output the SVG file. - */ - private writeSvgFile; - /** - * Writes a JSON file containing the names of processed icons. - * This method creates a JSON file that lists all icon names which have - * been processed, making it easier to reference or index these icons in - * other parts of an application. - * - * @param iconNames An array of strings containing the names of the icons. - * @param outputDirectory The directory where the JSON file will be saved. - */ - private writeIconsJson; -} -export default SvgPackager; diff --git a/dist/js/class/SvgPackager.js b/dist/js/class/SvgPackager.js deleted file mode 100644 index c67eaf2..0000000 --- a/dist/js/class/SvgPackager.js +++ /dev/null @@ -1,240 +0,0 @@ -"use strict"; -// class/SvgPackager.ts -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs = __importStar(require("fs/promises")); -var path = __importStar(require("path")); -var glob = __importStar(require("glob")); -var svgo_1 = __importDefault(require("svgo")); -var svgo_2 = require("svgo"); -// ============================================================================ -// Classes -// ============================================================================ -/** - * Class for packaging SVG files. - * This class reads SVG files from a specified directory, optimizes them, - * and creates corresponding TypeScript files. - */ -class SvgPackager { - /** - * Constructor for SvgPackager class. - * Optionally accepts configurations or dependencies. - */ - constructor(svgoConfigPath) { - this.svgoConfigPath = svgoConfigPath; - } - /** - * Processes all SVG files in a given directory. - * @param inputDirectory The directory containing SVG files to process. - * @param outputDirectory The directory where optimized SVGs will be output as TypeScript files. - */ - async processSvgFiles(inputDirectory, outputDirectory, ts_output_directory, json_output_directory) { - const iconNames = []; - try { - console.log(`Processing directory: ${inputDirectory}`); - const svgFiles = glob.sync(`${inputDirectory}/**/*.svg`); - for (const file of svgFiles) { - console.log(`Processing file: ${file}`); - const iconName = this.sanitizeFileName(path.basename(file, '.svg')); - iconNames.push(iconName); - console.log(`Processing icon: ${iconName}`); - const svgContent = await this.readSvgFile(file); - const optimizedSvg = await this.optimizeSvg(svgContent); - // const optimizedSvg = await this.optimizeSvg(file, svgContent); - // svgo will always add a final newline when in pretty mode - const resultSvg = optimizedSvg.trim(); - // Write the optimized SVG file - await this.writeSvgFile( - // file, - iconName, resultSvg, outputDirectory); - // Write the optimized TypeScript file - await this.writeTypeScriptFile( - // file, - iconName, resultSvg, ts_output_directory); - } - await this.writeIconsJson(iconNames, json_output_directory); - console.log(`Successfully processed ${svgFiles.length} SVG files.`); - } - catch (error) { - console.error('Error processing SVG files:', error); - throw error; - } - } - /** - * Reads the content of an SVG file. - * @param filePath The path to the SVG file. - * @returns The content of the SVG file. - */ - // private async readSvgFile(filePath: string): Promise { - // try { - // const absolutePath = path.resolve(filePath); - // const svgContent = await fs.readFile(absolutePath, 'utf8'); - // return svgContent; - // } catch (error) { - // console.error('Error reading file:', filePath, error); - // throw error; - // } - // } - async readSvgFile(filePath) { - return fs.readFile(filePath, 'utf8'); - } - /** - * Sanitizes a file name to be a valid TypeScript identifier. - * @param fileName The original file name. - * @returns A sanitized version of the file name. - */ - // private sanitizeFileName(fileName: string): string { - // // Implement more robust sanitization logic if necessary - // return fileName.replace(/[^a-zA-Z0-9_]/g, '_'); - // } - sanitizeFileName(fileName) { - return fileName.replace(/[^a-zA-Z0-9_]/g, '_'); - } - async writeFiles(iconName, svgContent, outputDirectory) { - await this.writeSvgFile(iconName, svgContent, outputDirectory); - await this.writeTypeScriptFile(iconName, svgContent, outputDirectory); - } - /** - * Optimizes SVG content using SVGO. - * @param svgContent The raw SVG content. - * @returns The optimized SVG content. - */ - // private async optimizeSvg( - // filePath: string, - // svgContent: string - // ): Promise { - // try { - // const config = await loadConfig( - // path.join(__dirname, '../config/svgo.config.js') - // ) - // const result = await SVGO.optimize( - // svgContent, - // { path: filePath, ...config } // Add SVGO options if needed - // ); - // return result.data; - // } catch (error) { - // console.error('Error optimizing SVG:', error); - // throw error; - // } - // } - async optimizeSvg(svgContent) { - const config = await (0, svgo_2.loadConfig)(this.svgoConfigPath); - const result = await svgo_1.default.optimize(svgContent, { ...config }); - return result.data.trim(); - } - /** - * Creates a TypeScript file from SVG content. - * @param filePath The path of the SVG file. - * @param svgContent The optimized SVG content. - * @param outputDirectory The directory to output the TypeScript file. - */ - // private async writeTypeScriptFile( - // filePath: string, - // iconName: string, - // svgContent: string, - // outputDirectory: string - // ): Promise { - // try { - // const tsContent = `export const icon_${iconName} = \`${svgContent}\`;\n`; - // const outputPath = path.join(outputDirectory, `${iconName}.ts`); - // await fs.writeFile(outputPath, tsContent); - // } catch (error) { - // console.error(`Error creating TypeScript file for ${filePath}:`, error); - // throw error; - // } - // } - async writeTypeScriptFile(iconName, svgContent, outputDirectory) { - const tsContent = `export const icon_${iconName} = \`${svgContent}\`;\n`; - const outputPath = path.join(outputDirectory, `${iconName}.ts`); - await fs.writeFile(outputPath, tsContent); - } - /** - * Writes the SVG content to a file. - * @param filePath The original file path of the SVG. - * @param svgContent The SVG content to be written. - * @param outputDirectory The directory to output the SVG file. - */ - // private async writeSvgFile( - // filePath: string, - // iconName: string, - // svgContent: string, - // outputDirectory: string - // ): Promise { - // try { - // const outputPath = path.join(outputDirectory, `${iconName}.svg`); - // await fs_extra.outputFile(outputPath, svgContent); - // console.log(`SVG file written successfully for ${iconName}`); - // } catch (error) { - // console.error(`Error writing SVG file for ${iconName}:`, error); - // throw error; - // } - // } - async writeSvgFile(iconName, svgContent, outputDirectory) { - const outputPath = path.join(outputDirectory, `${iconName}.svg`); - await fs.writeFile(outputPath, svgContent); - } - /** - * Writes a JSON file containing the names of processed icons. - * This method creates a JSON file that lists all icon names which have - * been processed, making it easier to reference or index these icons in - * other parts of an application. - * - * @param iconNames An array of strings containing the names of the icons. - * @param outputDirectory The directory where the JSON file will be saved. - */ - async writeIconsJson(iconNames, outputDirectory) { - try { - const jsonContent = JSON.stringify(iconNames, null, 2); - const outputPath = path.join(outputDirectory, 'icons.json'); - // await fs_extra.outputFile(outputPath, jsonContent); - await fs.writeFile(outputPath, jsonContent); - console.log('Icons JSON file created successfully'); - } - catch (error) { - console.error('Error writing icons JSON file:', error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = SvgPackager; diff --git a/dist/js/class/SvgReader.d.ts b/dist/js/class/SvgReader.d.ts deleted file mode 100644 index fcfd961..0000000 --- a/dist/js/class/SvgReader.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare class SvgReader { - /** - * Reads the content of an SVG file asynchronously. - * @param filePath The path to the SVG file. - * @returns A promise that resolves to the content of the SVG file. - */ - readSVG(filePath: string): Promise; -} -export default SvgReader; diff --git a/dist/js/class/SvgReader.js b/dist/js/class/SvgReader.js deleted file mode 100644 index 0ed84d8..0000000 --- a/dist/js/class/SvgReader.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -// class/SvgReader.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs_1 = require("fs"); -// ============================================================================ -// Classes -// ============================================================================ -class SvgReader { - /** - * Reads the content of an SVG file asynchronously. - * @param filePath The path to the SVG file. - * @returns A promise that resolves to the content of the SVG file. - */ - async readSVG(filePath) { - try { - const data = await fs_1.promises.readFile(filePath, 'utf-8'); - return data; - } - catch (error) { - console.error(`Error reading SVG file: ${filePath}`, error); - throw error; // Rethrow the error for further handling if necessary - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = SvgReader; diff --git a/dist/js/class/SvgSpriteGenerator.d.ts b/dist/js/class/SvgSpriteGenerator.d.ts deleted file mode 100644 index b601d14..0000000 --- a/dist/js/class/SvgSpriteGenerator.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import svgSprite from 'svg-sprite'; -/** - * A class for generating SVG sprites from individual SVG files. - */ -declare class SvgSpriteGenerator { - /** - * Constructs an instance of SvgSpriteGenerator with the provided configuration. - * @param {svgSprite.Config} config - Configuration object for svg-sprite. - */ - /** - * Configuration for the TypeScript compiler. - */ - private config; - /** - * Default configuration for the TypeScript compiler. - */ - private static defaultConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. - */ - constructor(customConfig?: svgSprite.Config); - /** - * Generates an SVG sprite from SVG files in a specified directory. - * @param {string} sourceDir - Directory containing source SVG files. - * @param {string} outputDir - Directory where the generated sprite will be saved. - */ - generateSprite(sourceDir: string, outputDir: string): Promise; -} -export default SvgSpriteGenerator; diff --git a/dist/js/class/SvgSpriteGenerator.js b/dist/js/class/SvgSpriteGenerator.js deleted file mode 100644 index 51939bd..0000000 --- a/dist/js/class/SvgSpriteGenerator.js +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; -// class/SvgSpriteGenerator.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var svg_sprite_1 = __importDefault(require("svg-sprite")); -var fs_1 = __importDefault(require("fs")); -var path_1 = __importDefault(require("path")); -var svgsprite_config_js_1 = __importDefault(require("../config/svgsprite.config.js")); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for generating SVG sprites from individual SVG files. - */ -class SvgSpriteGenerator { - /** - * Default configuration for the TypeScript compiler. - */ - static { this.defaultConfig = svgsprite_config_js_1.default; } - // private static defaultConfig: CompilerOptions = tsConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. - */ - constructor(customConfig = {}) { - this.config = { - ...SvgSpriteGenerator.defaultConfig, - ...customConfig - }; - } - /** - * Generates an SVG sprite from SVG files in a specified directory. - * @param {string} sourceDir - Directory containing source SVG files. - * @param {string} outputDir - Directory where the generated sprite will be saved. - */ - async generateSprite(sourceDir, outputDir) { - try { - const files = fs_1.default.readdirSync(sourceDir); - const sprite = new svg_sprite_1.default(this.config); - files.forEach(file => { - if (path_1.default.extname(file) === '.svg') { - const svgPath = path_1.default.resolve(sourceDir, file); - const content = fs_1.default.readFileSync(svgPath, 'utf8'); - sprite.add(svgPath, null, content); - } - }); - sprite.compile((error, result) => { - if (error) { - throw error; - } - for (const mode in result) { - for (const resource in result[mode]) { - const outputPath = path_1.default.resolve(outputDir, result[mode][resource].path); - fs_1.default.mkdirSync(path_1.default.dirname(outputPath), { recursive: true }); - fs_1.default.writeFileSync(outputPath, result[mode][resource].contents); - } - } - }); - } - catch (err) { - console.error('Error generating SVG sprite:', err); - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = SvgSpriteGenerator; diff --git a/dist/js/class/SvgToPngConverter.d.ts b/dist/js/class/SvgToPngConverter.d.ts deleted file mode 100644 index ac3a304..0000000 --- a/dist/js/class/SvgToPngConverter.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare class SvgToPngConverter { - convert(svgContent: string, outputPath: string, width?: number, height?: number): Promise; -} -export default SvgToPngConverter; diff --git a/dist/js/class/SvgToPngConverter.js b/dist/js/class/SvgToPngConverter.js deleted file mode 100644 index 082016f..0000000 --- a/dist/js/class/SvgToPngConverter.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -// class/SvgToPngConverter.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var sharp_1 = __importDefault(require("sharp")); -var jsdom_1 = require("jsdom"); -var fs_1 = __importDefault(require("fs")); -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Classes -// ============================================================================ -class SvgToPngConverter { - async convert(svgContent, outputPath, width, height) { - try { - // Ensure the output directory exists - const outputDir = path_1.default.dirname(outputPath); - if (!fs_1.default.existsSync(outputDir)) { - fs_1.default.mkdirSync(outputDir, { recursive: true }); - } - // Create a JSDOM instance to parse the SVG - const dom = new jsdom_1.JSDOM(svgContent); - const svgElement = dom.window.document.querySelector('svg'); - if (!svgElement) { - throw new Error('Invalid SVG content'); - } - if (width) { - svgElement.setAttribute('width', width.toString()); - } - if (height) { - svgElement.setAttribute('height', height.toString()); - } - const updatedSvgContent = svgElement.outerHTML; - const pngBuffer = await (0, sharp_1.default)(Buffer.from(updatedSvgContent)).png().toBuffer(); - await (0, sharp_1.default)(pngBuffer).toFile(outputPath); - } - catch (error) { - console.error(`Error converting SVG to PNG: ${error}`); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = SvgToPngConverter; diff --git a/dist/js/class/TemplateWriter.d.ts b/dist/js/class/TemplateWriter.d.ts deleted file mode 100644 index 38532aa..0000000 --- a/dist/js/class/TemplateWriter.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -declare class TemplateWriter { - context: {}; - /** - * Configuration for the Nunjucks writer compiler. - */ - private config; - /** - * Default configuration for the TypeScript compiler. - */ - private static defaultConfig; - /** - * Constructs a TemplateWriter instance. - * @param templatesDir - Directory for Nunjucks templates. - */ - constructor(templatesDir: string, context: {}, customConfig?: any); - /** - * Generates a template using the provided template file and context. - * @param template - The template file name. - * @returns The rendered template as a string. - */ - generateTemplate(template: string): Promise; - /** - * Writes the rendered template content to a file. - * @param template - The template file name. - * @param outputFile - The output file path. - */ - generateToFile(template: string, outputFile: string): Promise; -} -export default TemplateWriter; diff --git a/dist/js/class/TemplateWriter.js b/dist/js/class/TemplateWriter.js deleted file mode 100644 index dd37667..0000000 --- a/dist/js/class/TemplateWriter.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; -// class/TemplateWriter.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var promises_1 = __importDefault(require("fs/promises")); -var path_1 = __importDefault(require("path")); -var nunjucks_1 = __importDefault(require("nunjucks")); -var nunjucks_config_js_1 = __importDefault(require("../config/nunjucks.config.js")); -// ============================================================================ -// Classes -// ============================================================================ -class TemplateWriter { - /** - * Default configuration for the TypeScript compiler. - */ - static { this.defaultConfig = nunjucks_config_js_1.default; } - /** - * Constructs a TemplateWriter instance. - * @param templatesDir - Directory for Nunjucks templates. - */ - constructor(templatesDir, context, customConfig = {}) { - this.context = context; - this.config = { - ...TemplateWriter.defaultConfig, - ...customConfig - }; - nunjucks_1.default.configure(templatesDir, this.config); - } - /** - * Generates a template using the provided template file and context. - * @param template - The template file name. - * @returns The rendered template as a string. - */ - async generateTemplate(template) { - try { - return nunjucks_1.default.render(template, this.context); - } - catch (error) { - console.error(`Error generating template: ${error}`); - // throw error; - throw new Error('Template generation failed'); - } - } - /** - * Writes the rendered template content to a file. - * @param template - The template file name. - * @param outputFile - The output file path. - */ - async generateToFile(template, outputFile) { - try { - const content = await this.generateTemplate(template); - const dir = path_1.default.dirname(outputFile); - // Ensure the directory exists - await promises_1.default.mkdir(dir, { recursive: true }); - // Write the file - await promises_1.default.writeFile(outputFile, content, 'utf-8'); - } - catch (error) { - console.error(`Error writing to file: ${error}`); - throw new Error('File writing failed'); - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = TemplateWriter; diff --git a/dist/js/class/TestRunner.d.ts b/dist/js/class/TestRunner.d.ts deleted file mode 100644 index a756840..0000000 --- a/dist/js/class/TestRunner.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -declare class TestRunner { - private testCommand; - constructor(testCommand: string); - /** - * Runs the tests using the specified test command. - * @returns A promise that resolves with the test results. - */ - runTests(): Promise; -} -export default TestRunner; diff --git a/dist/js/class/TestRunner.js b/dist/js/class/TestRunner.js deleted file mode 100644 index 8bbbcee..0000000 --- a/dist/js/class/TestRunner.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; -// class/TestRunner.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var child_process_1 = require("child_process"); -var util_1 = __importDefault(require("util")); -const execAsync = util_1.default.promisify(child_process_1.exec); -// ============================================================================ -// Classes -// ============================================================================ -class TestRunner { - constructor(testCommand) { - this.testCommand = testCommand; - } - /** - * Runs the tests using the specified test command. - * @returns A promise that resolves with the test results. - */ - async runTests() { - try { - const { stdout, stderr } = await execAsync(this.testCommand); - if (stderr) { - throw new Error(stderr); - } - return stdout; - } - catch (error) { - console.error('Error occurred while running tests:', error); - throw error; - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = TestRunner; -// Usage Example -// Here's an example of how you might use the TestRunner class in a project: -// import TestRunner from './TestRunner'; -// const runner = new TestRunner('npm test'); // Replace 'npm test' with your actual test command -// runner.runTests() -// .then(results => { -// console.log('Test Results:', results); -// }) -// .catch(error => { -// console.error('Test Runner Error:', error); -// }); diff --git a/dist/js/class/TypeScriptCompiler.d.ts b/dist/js/class/TypeScriptCompiler.d.ts deleted file mode 100644 index 86e2421..0000000 --- a/dist/js/class/TypeScriptCompiler.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * TypeScriptCompiler class for compiling TypeScript files to JavaScript. - */ -declare class TypeScriptCompiler { - /** - * Configuration for the TypeScript compiler. - */ - private config; - /** - * Default configuration for the TypeScript compiler. - */ - private static defaultConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {any} customConfig - Optional custom configuration object for TypeScript compiler - // * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler - */ - constructor(customConfig?: any); - compile(filePaths: string[], outDir: string): Promise; -} -export default TypeScriptCompiler; diff --git a/dist/js/class/TypeScriptCompiler.js b/dist/js/class/TypeScriptCompiler.js deleted file mode 100644 index ce9eb4f..0000000 --- a/dist/js/class/TypeScriptCompiler.js +++ /dev/null @@ -1,93 +0,0 @@ -"use strict"; -// class/TypeScriptCompiler.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -// import * as ts from 'typescript'; -var typescript_1 = __importDefault(require("typescript")); -var ts_config_js_1 = __importDefault(require("../config/ts.config.js")); -// type CompilerOptions = ts.CompilerOptions | Record; -// ============================================================================ -// Classes -// ============================================================================ -/** - * TypeScriptCompiler class for compiling TypeScript files to JavaScript. - */ -class TypeScriptCompiler { - // private config: ts.CompilerOptions; - // private config: { [key: symbol]: any}; - /** - * Default configuration for the TypeScript compiler. - */ - static { this.defaultConfig = ts_config_js_1.default; } - // private static defaultConfig: ts.CompilerOptions = tsConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {any} customConfig - Optional custom configuration object for TypeScript compiler - // * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler - */ - constructor(customConfig = {}) { - this.config = { - ...TypeScriptCompiler.defaultConfig, - ...customConfig - }; - } - compile(filePaths, outDir) { - return new Promise((resolve, reject) => { - // Merge default options with custom options - const options = { - module: typescript_1.default.ModuleKind.CommonJS, - target: typescript_1.default.ScriptTarget.ES2015, - outDir, - // ...customOptions, // Merges custom compiler options - ...this.config - }; - // Create a TypeScript compiler host - const host = typescript_1.default.createCompilerHost(options); - // Create a program with the specified files and options - const program = typescript_1.default.createProgram(filePaths, options, host); - // Emit the compiled JavaScript files - const emitResult = program.emit(); - // Check for compilation errors - const allDiagnostics = typescript_1.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); - allDiagnostics.forEach(diagnostic => { - // Handle and print diagnostics - if (diagnostic.file) { - const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); - const message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); - } - else { - console.error(typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, '\n')); - } - }); - const exitCode = emitResult.emitSkipped ? 1 : 0; - if (exitCode === 0) { - console.log('Compilation completed successfully.'); - resolve(); - } - else { - console.error('Compilation failed.'); - reject(new Error('TypeScript compilation failed')); - } - }); - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = TypeScriptCompiler; diff --git a/dist/js/class/VersionManager.d.ts b/dist/js/class/VersionManager.d.ts deleted file mode 100644 index 924960b..0000000 --- a/dist/js/class/VersionManager.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import semver from 'semver'; -declare class VersionManager { - private currentVersion; - constructor(currentVersion: string); - updateVersion(releaseType: semver.ReleaseType): Promise; - generateChangelog(): Promise; - createGitTag(): Promise; -} -export default VersionManager; diff --git a/dist/js/class/VersionManager.js b/dist/js/class/VersionManager.js deleted file mode 100644 index 94d85e2..0000000 --- a/dist/js/class/VersionManager.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; -// class/VersionManager.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var semver_1 = __importDefault(require("semver")); -var child_process_1 = require("child_process"); -var util_1 = __importDefault(require("util")); -const execAsync = util_1.default.promisify(child_process_1.exec); -// ============================================================================ -// Classes -// ============================================================================ -class VersionManager { - constructor(currentVersion) { - if (!semver_1.default.valid(currentVersion)) { - throw new Error('Invalid initial version'); - } - this.currentVersion = currentVersion; - } - async updateVersion(releaseType) { - const newVersion = semver_1.default.inc(this.currentVersion, releaseType); - if (!newVersion) { - throw new Error('Version increment failed'); - } - this.currentVersion = newVersion; - return newVersion; - } - async generateChangelog() { - // Implement changelog generation logic - // This could be as simple as running a script or using a tool like 'conventional-changelog' - console.log('Changelog generation logic goes here'); - } - async createGitTag() { - try { - await execAsync(`git tag v${this.currentVersion}`); - await execAsync('git push --tags'); - console.log(`Tag v${this.currentVersion} created and pushed`); - } - catch (error) { - console.error('Error creating Git tag:', error); - throw error; - } - } -} -exports.default = VersionManager; -// import VersionManager from './VersionManager'; -// const versionManager = new VersionManager('1.0.0'); // Replace '1.0.0' with the current version of your package -// versionManager.updateVersion('minor') // 'major', 'minor', or 'patch' -// .then(newVersion => { -// console.log(`Version updated to: ${newVersion}`); -// return versionManager.generateChangelog(); -// }) -// .then(() => versionManager.createGitTag()) -// .catch(error => console.error(error)); diff --git a/dist/js/class/VersionWriter.d.ts b/dist/js/class/VersionWriter.d.ts deleted file mode 100644 index 7650627..0000000 --- a/dist/js/class/VersionWriter.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * A class for writing version information to a file. - */ -declare class VersionWriter { - /** - * Writes the specified version string to a file. - * @param {string} filePath - The file path where the version will be written. - * @param {string} version - The version string to write to the file. - */ - writeVersionToFile(filePath: string, version: string): Promise; -} -export default VersionWriter; diff --git a/dist/js/class/VersionWriter.js b/dist/js/class/VersionWriter.js deleted file mode 100644 index e8d0827..0000000 --- a/dist/js/class/VersionWriter.js +++ /dev/null @@ -1,43 +0,0 @@ -"use strict"; -// class/VersionWriter.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fs_1 = require("fs"); -// ============================================================================ -// Classes -// ============================================================================ -/** - * A class for writing version information to a file. - */ -class VersionWriter { - /** - * Writes the specified version string to a file. - * @param {string} filePath - The file path where the version will be written. - * @param {string} version - The version string to write to the file. - */ - async writeVersionToFile(filePath, version) { - try { - await fs_1.promises.writeFile(filePath, version, 'utf8'); - console.log(`Version ${version} written to ${filePath}`); - } - catch (error) { - console.error(`Error writing version to file: ${error}`); - } - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = VersionWriter; diff --git a/dist/js/config/fantasticon.config.d.ts b/dist/js/config/fantasticon.config.d.ts deleted file mode 100644 index c6798ab..0000000 --- a/dist/js/config/fantasticon.config.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare const fantasticonConfig: any; -export default fantasticonConfig; diff --git a/dist/js/config/fantasticon.config.js b/dist/js/config/fantasticon.config.js deleted file mode 100644 index de5602d..0000000 --- a/dist/js/config/fantasticon.config.js +++ /dev/null @@ -1,159 +0,0 @@ -"use strict"; -// config/fantasticon.config.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var fantasticon_1 = require("fantasticon"); -const fantasticonConfig = { - // RunnerOptionalOptions - name: 'icon', - fontTypes: [ - fantasticon_1.FontAssetType.TTF, // TTF = "ttf" - fantasticon_1.FontAssetType.WOFF, // WOFF = "woff" - fantasticon_1.FontAssetType.WOFF2, // WOFF2 = "woff2" - fantasticon_1.FontAssetType.EOT, // EOT = "eot" - fantasticon_1.FontAssetType.SVG, // SVG = "svg" - ], - assetTypes: [ - fantasticon_1.OtherAssetType.CSS, // CSS = "css", - fantasticon_1.OtherAssetType.SCSS, // SCSS = "scss", - fantasticon_1.OtherAssetType.SASS, // SASS = "sass", - fantasticon_1.OtherAssetType.HTML, // HTML = "html", - fantasticon_1.OtherAssetType.JSON, // JSON = "json", - fantasticon_1.OtherAssetType.TS, // TS = "ts" - ], - formatOptions: { - // woff: { - // // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata - // // metadata: '...' - // // }, - // // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; - // // svg?: SvgOptions; // type SvgOptions = Omit; - json: { indent: 4 }, - ts: { - // select what kind of types you want to generate - // (default `['enum', 'constant', 'literalId', 'literalKey']`) - // render the types with `'` instead of `"` (default is `"`) - singleQuotes: false, - enumName: 'icon_gl', - // customise names used for the generated types and constants - constantName: 'MY_CODEPOINTS' - // literalIdName: 'IconId', - } - }, - pathOptions: { - json: './dist/font/icon.gl.json', - css: './dist/font/icon.gl.css', - scss: './dist/font/icon.gl.scss', - woff: './dist/font/icon.gl.woff', - woff2: './dist/font/icon.gl.woff2' - }, - codepoints: { - 'chevron-left': 57344, // decimal representation of 0xe000 - 'chevron-right': 57345, - 'thumbs-up': 57358, - 'thumbs-down': 57359 - }, - // fontHeight: number; - // descent: number; - // normalize: boolean; - // round: number; - selector: '.i', - // tag: string; - // Use our custom Handlebars templates - // templates: { - // css: './build/font/icon.gl.css.hbs', - // scss: './build/font/icon.gl.scss.hbs' - // }, - prefix: 'icon', - fontsUrl: './fonts' -}; -exports.default = fantasticonConfig; -// export const fontConfig = { -// // RunnerMandatoryOptions -// inputDir: sourceDirectory, // (required) -// outputDir: outputDiectory, // (required) -// // RunnerOptionalOptions -// name: 'icon.gl', -// fontTypes: [ -// FontAssetType.TTF, // TTF = "ttf" -// FontAssetType.WOFF, // WOFF = "woff" -// FontAssetType.WOFF2, // WOFF2 = "woff2" -// FontAssetType.EOT, // EOT = "eot" -// FontAssetType.SVG, // SVG = "svg" -// ], -// assetTypes: [ -// OtherAssetType.CSS, // CSS = "css", -// OtherAssetType.SCSS, // SCSS = "scss", -// OtherAssetType.SASS, // SASS = "sass", -// OtherAssetType.HTML, // HTML = "html", -// OtherAssetType.JSON, // JSON = "json", -// OtherAssetType.TS, // TS = "ts" -// ], -// formatOptions: { -// // woff: { -// // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata -// // metadata: '...' -// // }, -// // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; -// // svg?: SvgOptions; // type SvgOptions = Omit; -// json: { indent: 4 } , -// // ts: { -// // // select what kind of types you want to generate -// // // (default `['enum', 'constant', 'literalId', 'literalKey']`) -// // types: ['enum', 'constant', 'literalId', 'literalKey'], -// // // render the types with `'` instead of `"` (default is `"`) -// // singleQuotes: false, -// // // customise names used for the generated types and constants -// // enumName: 'icon_gl', -// // constantName: 'MY_CODEPOINTS' -// // // literalIdName: 'IconId', -// // // literalKeyName: 'IconKey' -// // } -// }, -// pathOptions: { -// json: './dist/font/icon.gl.json', -// css: './dist/font/icon.gl.css', -// scss: './dist/font/icon.gl.scss', -// woff: './dist/font/icon.gl.woff', -// woff2: './dist/font/icon.gl.woff2', -// }, -// // codepoints: { -// // 'chevron-left': 57344, // decimal representation of 0xe000 -// // 'chevron-right': 57345, -// // 'thumbs-up': 57358, -// // 'thumbs-down': 57359, -// // }, -// // fontHeight: number; -// // descent: number; -// // normalize: boolean; -// // round: number; -// selector: '.igl', -// // tag: string; -// // Use our custom Handlebars templates -// // templates: { -// // css: './build/font/icon.gl.css.hbs', -// // scss: './build/font/icon.gl.scss.hbs' -// // }, -// prefix: 'igl', -// fontsUrl: './fonts', -// // Customize generated icon IDs (unavailable with `.json` config file) -// // getIconId: ({ -// // basename, // `string` - Example: 'foo'; -// // relativeDirPath, // `string` - Example: 'sub/dir/foo.svg' -// // absoluteFilePath, // `string` - Example: '/var/icons/sub/dir/foo.svg' -// // relativeFilePath, // `string` - Example: 'foo.svg' -// // index // `number` - Example: `0` -// // }) => [index, basename].join('_') // '0_foo' -// }; diff --git a/dist/js/config/nunjucks.config.d.ts b/dist/js/config/nunjucks.config.d.ts deleted file mode 100644 index f98f816..0000000 --- a/dist/js/config/nunjucks.config.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare const nunjucksConfig: { - autoescape: boolean; - throwOnUndefined: boolean; - trimBlocks: boolean; - lstripBlocks: boolean; - noCache: boolean; -}; -export default nunjucksConfig; diff --git a/dist/js/config/nunjucks.config.js b/dist/js/config/nunjucks.config.js deleted file mode 100644 index 2b84ea8..0000000 --- a/dist/js/config/nunjucks.config.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -// config/nunjucks.config.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// ============================================================================ -// Constants -// ============================================================================ -const nunjucksConfig = { - autoescape: true, // Controls if output with dangerous characters are escaped automatically - throwOnUndefined: false, // Throw errors when outputting a null/undefined value - trimBlocks: true, // Automatically remove trailing newlines from a block/tag - lstripBlocks: true, // Automatically remove leading whitespace from a block/tag - noCache: true -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = nunjucksConfig; diff --git a/dist/js/config/package.config.d.ts b/dist/js/config/package.config.d.ts deleted file mode 100644 index 2aa668d..0000000 --- a/dist/js/config/package.config.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -declare const packageConfig: { - name: string; - version: string; - description: string; - keywords: string; - license: string; - homepage: string; - funding: { - type: string; - url: string; - }[]; - type: string; - main: string; - types: string; - files: string[]; -}; -export default packageConfig; diff --git a/dist/js/config/package.config.js b/dist/js/config/package.config.js deleted file mode 100644 index e507e7d..0000000 --- a/dist/js/config/package.config.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -// config/package.config.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Constants -// ============================================================================ -const packageConfig = { - name: "", - version: "", - description: "", - keywords: "", - license: "Apache-2.0", - homepage: "https://www.scape.agency", - funding: [ - { - "type": "github", - "url": "https://github.com/sponsors/scape-foundation" - } - ], - type: "module", - main: "js/index", - // main: "js/index.js", - types: "js/index", - // types: "js/index.d.ts", - // "module": "dist/js/unit.gl.js", - // "style": "dist/css/unit.gl.css", - // "sass": "src/scss/index.scss", - // main: 'index.js', - files: [ - "code-snippets/**/*.code-snippets", - "css/**/*.{css,map}", - "font/**/*.{eot,otf,ttf,woff,woff2}", - "inkscape/**/*.inkscape", - "jinja/**/*.jinja", - "js/**/*.d.ts", - "js/**/*.{js,map}", - "less/**/*.less", - "md/**/*.md", - "oco/**/*.oco", - "png/**/*.png", - "py/**/*.py", - "rcpx/**/*.rcpx", - "scss/**/*.scss", - "sketchpalette/**/*.sketchpalette", - "styl/**/*.styl", - "svg/**/*.svg", - "tex/**/*.tex", - "ts/**/*.ts", - "!.DS_Store" - ] -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = packageConfig; diff --git a/dist/js/config/postcss.config.compressed.d.ts b/dist/js/config/postcss.config.compressed.d.ts deleted file mode 100644 index 8fb398c..0000000 --- a/dist/js/config/postcss.config.compressed.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import autoprefixer from 'autoprefixer'; -declare const postcssConfigCompressed: { - plugins: (typeof autoprefixer | import("postcss/lib/processor").default)[]; -}; -export default postcssConfigCompressed; diff --git a/dist/js/config/postcss.config.compressed.js b/dist/js/config/postcss.config.compressed.js deleted file mode 100644 index 2d9be8a..0000000 --- a/dist/js/config/postcss.config.compressed.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -// config/postcss.config.compressed.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var autoprefixer_1 = __importDefault(require("autoprefixer")); -var cssnano_1 = __importDefault(require("cssnano")); -// ============================================================================ -// Constants -// ============================================================================ -const postcssConfigCompressed = { - plugins: [ - autoprefixer_1.default, - // Minification for compressed output - (0, cssnano_1.default)({ - preset: 'default' - }), - ] -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = postcssConfigCompressed; diff --git a/dist/js/config/postcss.config.expanded.d.ts b/dist/js/config/postcss.config.expanded.d.ts deleted file mode 100644 index 87e1a69..0000000 --- a/dist/js/config/postcss.config.expanded.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import autoprefixer from 'autoprefixer'; -declare const postcssConfigExpanded: { - plugins: (typeof autoprefixer)[]; -}; -export default postcssConfigExpanded; diff --git a/dist/js/config/postcss.config.expanded.js b/dist/js/config/postcss.config.expanded.js deleted file mode 100644 index db1bf70..0000000 --- a/dist/js/config/postcss.config.expanded.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -// config/postcss.config.expanded.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var autoprefixer_1 = __importDefault(require("autoprefixer")); -// ============================================================================ -// Constants -// ============================================================================ -const postcssConfigExpanded = { - plugins: [ - autoprefixer_1.default, - // Include other plugins suited for the expanded output - ] -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = postcssConfigExpanded; diff --git a/dist/js/config/svgsprite.config.d.ts b/dist/js/config/svgsprite.config.d.ts deleted file mode 100644 index 13ea770..0000000 --- a/dist/js/config/svgsprite.config.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import svgSprite from "svg-sprite"; -declare const svgspriteConfig: svgSprite.Config; -export default svgspriteConfig; diff --git a/dist/js/config/svgsprite.config.js b/dist/js/config/svgsprite.config.js deleted file mode 100644 index d83a6b0..0000000 --- a/dist/js/config/svgsprite.config.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -// config/svg-sprite.config.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// ============================================================================ -// Constants -// ============================================================================ -const svgspriteConfig = { - dest: './dist/sprite', // Main output directory - // log: null, // Logging verbosity (default: no logging) - shape: { - id: { - separator: '--', // Separator for directory name traversal - generator: 'icon-%s', - // generator: function () { /*...*/ }, // SVG shape ID generator callback - pseudo: '~' // File name separator for shape states (e.g. ':hover') - }, - dimension: { - maxWidth: 2000, // Max. shape width - maxHeight: 2000, // Max. shape height - precision: 2, // Floating point precision - attributes: false - }, - spacing: { - padding: 0, // Padding around all shapes - box: 'content' // Padding strategy (similar to CSS `box-sizing`) - }, - transform: ['svgo'] - }, - svg: { - xmlDeclaration: false, // Add XML declaration to SVG sprite - // xmlDeclaration: true, // Add XML declaration to SVG sprite - doctypeDeclaration: true, // Add DOCTYPE declaration to SVG sprite - namespaceIDs: true, // Add namespace token to all IDs in SVG shapes - // namespaceIDPrefix: '', // Add a prefix to the automatically generated namespaceIDs - // namespaceClassnames: true, // Add namespace token to all CSS class names in SVG shapes - namespaceClassnames: false, // Add namespace token to all CSS class names in SVG shapes - dimensionAttributes: true // Width and height attributes on the sprite - }, - variables: {}, // Custom Mustache templating variables and functions - mode: { - css: { - render: { - css: true // Render CSS stylesheet - } - }, - view: true, // Create a «view» sprite - defs: true, // Create a «defs» sprite - // symbol: true, // Create a «symbol» sprite - symbol: { - // dest: ".", - // inline: true, // Prepare for inline embedding - sprite: "icon.gl.svg" - }, - stack: true - } -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = svgspriteConfig; -// "svgo": { -// "multipass": true, -// "plugins": [ -// { -// "name": "preset-default", -// "params": { -// "overrides": { -// "removeUnknownsAndDefaults": { -// "keepDataAttrs": false, -// "keepRoleAttr": true -// }, -// "removeViewBox": false -// } -// } -// }, -// "cleanupListOfValues", -// "removeXMLNS", -// { -// "name": "removeAttrs", -// "params": { -// "attrs": [ -// "clip-rule", -// "fill" -// ] -// } -// } -// ] -// } -// : { -// dest: "", // Mode specific output directory -// prefix: "svg-%s", // Prefix for CSS selectors -// dimensions: "-dims", // Suffix for dimension CSS selectors -// sprite: "svg/sprite..svg", // Sprite path and name -// bust: true || false, // Cache busting (mode dependent default value) -// render: { // Stylesheet rendering definitions -// /* ------------------------------------------- -// css: false, // CSS stylesheet options -// scss: false, // Sass stylesheet options -// less: false, // LESS stylesheet options -// styl: false, // Stylus stylesheet options -// : ... // Custom stylesheet options -// ------------------------------------------- */ -// }, -// example: false // Create an HTML example document -// } diff --git a/dist/js/config/terser.config.d.ts b/dist/js/config/terser.config.d.ts deleted file mode 100644 index da1e75b..0000000 --- a/dist/js/config/terser.config.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -declare const terserConfig: { - parse: {}; - compress: { - drop_console: boolean; - drop_debugger: boolean; - pure_funcs: string[]; - arrows: boolean; - }; - mangle: { - properties: boolean; - }; - format: { - comments: boolean; - beautify: boolean; - }; - sourceMap: {}; - ecma: number; - enclose: boolean; - keep_classnames: boolean; - keep_fnames: boolean; - ie8: boolean; - module: boolean; - nameCache: null; - safari10: boolean; - toplevel: boolean; -}; -export default terserConfig; diff --git a/dist/js/config/terser.config.js b/dist/js/config/terser.config.js deleted file mode 100644 index 378dc87..0000000 --- a/dist/js/config/terser.config.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; -// config/terser.config.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -// ============================================================================ -// Constants -// ============================================================================ -// https://terser.org/docs/api-reference/ -const terserConfig = { - parse: { - // parse options - }, - compress: { - // compress options - drop_console: true, // Remove console.log statements - drop_debugger: true, // Remove debugger statements - pure_funcs: ['console.info', 'console.debug', 'console.warn'], // Remove specific console functions - // defaults (default: true) -- Pass false to disable most default enabled compress transforms. Useful when you only want to enable a few compress options while disabling the rest. - // Class and object literal methods are converted will also be - // converted to arrow expressions if the resultant code is shorter: - // m(){return x} becomes m:()=>x. To do this to regular ES5 functions - // which don't use this or arguments, see unsafe_arrows. - arrows: true - }, - mangle: { - // mangle options - // Mangle names for obfuscation and size reduction - properties: true - }, - format: { - // format options (can also use `output` for backwards compatibility) - comments: false, // Remove comments to reduce file size - beautify: false - }, - sourceMap: { - // source map options - }, - // Define ECMAScript target version - ecma: 5, // specify one of: 5, 2015, 2016, etc. - enclose: false, // or specify true, or "args:values" - keep_classnames: false, // Remove class names - keep_fnames: false, // Remove function names - ie8: false, - module: false, - nameCache: null, // or specify a name cache object - safari10: false, - toplevel: true -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = terserConfig; diff --git a/dist/js/config/ts.config.d.ts b/dist/js/config/ts.config.d.ts deleted file mode 100644 index 6fe80e6..0000000 --- a/dist/js/config/ts.config.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -declare const tsConfig: { - target: string; - lib: string[]; - module: string; - resolveJsonModule: boolean; - declaration: boolean; - allowSyntheticDefaultImports: boolean; - esModuleInterop: boolean; - forceConsistentCasingInFileNames: boolean; - strict: boolean; - skipLibCheck: boolean; -}; -export default tsConfig; diff --git a/dist/js/config/ts.config.js b/dist/js/config/ts.config.js deleted file mode 100644 index 63248c9..0000000 --- a/dist/js/config/ts.config.js +++ /dev/null @@ -1,146 +0,0 @@ -"use strict"; -// config/ts.config.ts -Object.defineProperty(exports, "__esModule", { value: true }); -// ============================================================================ -// Constants -// ============================================================================ -// const tsConfig: ts.CompilerOptions = { -const tsConfig = { - // Visit https://aka.ms/tsconfig.json to read more about this file - // Projects - // ======================================================================== - // incremental: true, // boolean // Enable incremental compilation - // composite: true, // boolean // Enable constraints that allow a TypeScript project to be used with project references. - // tsBuildInfoFile: "./", // Specify the folder for .tsbuildinfo incremental compilation files. - // disableSourceOfProjectReferenceRedirect: true, // boolean // Disable preferring source files instead of declaration files when referencing composite projects - // disableSolutionSearching: true, // boolean // Opt a project out of multi-project reference checking when editing. - // disableReferencedProjectLoad: true, // boolean // Reduce the number of projects loaded automatically by TypeScript. - // Language and Environment - // ======================================================================== - // target: ts.ScriptTarget.ES2015, - target: "es6", // Specify ECMAScript target version - // ES3 = 0, - // ES5 = 1, - // ES2015 = 2, - // ES2016 = 3, - // ES2017 = 4, - // ES2018 = 5, - // ES2019 = 6, - // ES2020 = 7, - // ES2021 = 8, - // ES2022 = 9, - // ESNext = 99, - // JSON = 100, - // Latest = 99,\ - lib: ["es2015", "dom"], - // target: "es2015", // Set the JavaScript language version for emitted JavaScript and include compatible library declarations. - // lib: ["esnext", "es2017`", "ES2015", "dom"], // Specify a set of bundled library declaration files that describe the target runtime environment. - // lib: ["es2015", "dom"], // Specify library files to be included in the compilation - // lib: ["es2015"], // Specify library files to be included in the compilation - // jsx: "preserve", // Specify what JSX code is generated. - // experimentalDecorators: true, // Enable experimental support for TC39 stage 2 draft decorators. - // emitDecoratorMetadata: true, // Emit design-type metadata for decorated declarations in source files. - // jsxFactory: "", // Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' - // jsxFragmentFactory: "", // Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. - // jsxImportSource: "", // Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` - // reactNamespace: "", // Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. - // noLib: true, // Disable including any library files, including the default lib.d.ts. - // useDefineForClassFields: true, // Emit ECMAScript-standard-compliant class fields. - // Modules - // ======================================================================== - // module?: ModuleKind; - // moduleResolution?: ModuleResolutionKind; - // moduleSuffixes?: string[]; - // moduleDetection?: ModuleDetectionKind; - // module: ts.ModuleKind.CommonJS, - module: "commonjs", // Specify module code generation - // module: "CommonJS", - // module: "esnext", // Specify what module code is generated. - // rootDir: ".", // Specify the root folder within your source files. - // moduleResolution: "node", // Specify how TypeScript looks up a file from a given module specifier. - // baseUrl: "src" // Specify the base directory to resolve non-relative module names., - // paths: { - // "@/*: ["./*"], - // "#/*: ["./*"] - // }, - // rootDirs: [], // Allow multiple folders to be treated as one when resolving modules. - // typeRoots: [ // Specify multiple folders that act like `./node_modules/@types`. - // "node_modules/@types" - // ], - // types: [], // Specify type package names to be included without being referenced in a source file. - // allowUmdGlobalAccess: true, // Allow accessing UMD globals from modules. - resolveJsonModule: true, // Enable importing .json files - // noResolve: true, // Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. - // JavaScript Support - // ======================================================================== - // allowJs: true boolean // Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files., - // checkJs: false // Enable error reporting in type-checked JavaScript files., - // maxNodeModuleJsDepth: 1, // Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. - // Emit - // ======================================================================== - declaration: true, // Enables generation of .d.ts files - // "declaration: true, // Generate .d.ts files from TypeScript and JavaScript files in your project. - // "declarationMap: true, // Create sourcemaps for d.ts files. - // emitDeclarationOnly: true, // Only output d.ts files and not JavaScript files. - // sourceMap: true, // Create source map files for emitted JavaScript files. - // outFile: "./", // Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. - // outDir: "./dist", // Specify an output folder for all emitted files. - // removeComments: true, // Disable emitting comments. - // noEmit: true, // Disable emitting files from a compilation. - // noImplicitReturns: true, - // was true, maar es5/6 trekt dat niet - // importHelpers: true, // Allow importing helper functions from tslib once per project, instead of including them per-file. - // importsNotUsedAsValues: "remove", // Specify emit/checking behavior for imports that are only used for types - // downlevelIteration: false, // Emit more compliant, but verbose and less performant JavaScript for iteration. - // sourceRoot: "", // Specify the root path for debuggers to find the reference source code. - // mapRoot: "", // Specify the location where debugger should locate map files instead of generated locations. - // inlineSourceMap: true, // Include sourcemap files inside the emitted JavaScript. - // inlineSources: true, // Include source code in the sourcemaps inside the emitted JavaScript. - // emitBOM: true, // Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. - // newLine: "crlf", // Set the newline character for emitting files. - // stripInternal: true, // Disable emitting declarations that have `@internal` in their JSDoc comments. - // noEmitHelpers: true, // Disable generating custom helper functions like `__extends` in compiled output. - // noEmitOnError: false, // Disable emitting files if any type checking errors are reported. - // preserveConstEnums: true, // Disable erasing `const enum` declarations in generated code. - // declarationDir: "./", // Specify the output directory for generated declaration files. - // preserveValueImports: true, // Preserve unused imported values in the JavaScript output that would otherwise be removed. - // Interop Constraints - // ======================================================================== - // isolatedModules: true, // Ensure that each file can be safely transpiled without relying on other imports. - allowSyntheticDefaultImports: true, // Allow 'import x from y' when a module doesn't have a default export. - // Enables compatibility with Babel imports - esModuleInterop: true, // Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. - // preserveSymlinks: true, // Disable resolving symlinks to their realpath. This correlates to the same flag in node. - // forceConsistentCasingInFileNames: true, // Ensure that casing is correct in imports. - forceConsistentCasingInFileNames: true, // Disallow inconsistently-cased references - // Type Checking - // ======================================================================== - strict: true, // Enable all strict type-checking options., - // noImplicitAny: true, // Enable error reporting for expressions and declarations with an implied `any` type.. - // strictNullChecks: true, // When type checking, take into account `null` and `undefined`. - // strictFunctionTypes: true, // When assigning functions, check to ensure parameters and the return values are subtype-compatible. - // strictBindCallApply: true, // Check that the arguments for `bind`, `call`, and `apply` methods match the original function. - // strictPropertyInitialization: true, // Check for class properties that are declared but not set in the constructor. - // noImplicitThis: true, // Enable error reporting when `this` is given the type `any`. - // useUnknownInCatchVariables: true, // Type catch clause variables as 'unknown' instead of 'any'. - // alwaysStrict: true, // Ensure 'use strict' is always emitted. - // noUnusedLocals: true, // Enable error reporting when a local variables aren't read. - // noUnusedParameters: true, // Raise an error when a function parameter isn't read - // exactOptionalPropertyTypes: true, // Interpret optional property types as written, rather than adding 'undefined'. - // noImplicitReturns: true, // Enable error reporting for codepaths that do not explicitly return in a function. - // noFallthroughCasesInSwitch: true, // Enable error reporting for fallthrough cases in switch statements. - // noUncheckedIndexedAccess: true, // Include 'undefined' in index signature results - // noImplicitOverride: true, // Ensure overriding members in derived classes are marked with an override modifier. - // noPropertyAccessFromIndexSignature: true, // Enforces using indexed accessors for keys declared using an indexed type - // allowUnusedLabels: true, // Disable error reporting for unused labels. - // allowUnreachableCode: true, // Disable error reporting for unreachable code. - // Completeness - // ======================================================================== - // skipDefaultLibCheck: true, // Skip type checking .d.ts files that are included with TypeScript. - // Skip type checking of declaration files - skipLibCheck: true -}; -// ============================================================================ -// Export -// ============================================================================ -exports.default = tsConfig; diff --git a/dist/js/function/clean_directory.d.ts b/dist/js/function/clean_directory.d.ts deleted file mode 100644 index 6abaa1c..0000000 --- a/dist/js/function/clean_directory.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Cleans a specified directory and logs the process. - * @param directoryPath - The path of the directory to clean. - */ -declare function cleanDirectory(directoryPath: string): Promise; -export default cleanDirectory; diff --git a/dist/js/function/clean_directory.js b/dist/js/function/clean_directory.js deleted file mode 100644 index e559bbb..0000000 --- a/dist/js/function/clean_directory.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -// config/fantasticon.config.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var DirectoryCleaner_js_1 = __importDefault(require("../class/DirectoryCleaner.js")); -var StylizedLogger_js_1 = __importDefault(require("../class/StylizedLogger.js")); -// ============================================================================ -// Constants -// ============================================================================ -const directoryCleaner = new DirectoryCleaner_js_1.default(); -const logger = new StylizedLogger_js_1.default(); -// ============================================================================ -// Functions -// ============================================================================ -/** - * Cleans a specified directory and logs the process. - * @param directoryPath - The path of the directory to clean. - */ -async function cleanDirectory(directoryPath) { - try { - logger.header('Clean Directories'); - await directoryCleaner.cleanDirectory(directoryPath); - logger.body(`Directory cleaned: ${directoryPath}`); - } - catch (error) { - logger.error(`Error cleaning directory: ${error}`); - throw error; // Rethrow the error for further handling if necessary - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = cleanDirectory; -// Usage example -// cleanAndLogDirectory(CONFIG.path.dist) -// .then(() => console.log('Directory cleaning completed.')) -// .catch(error => console.error(error)); diff --git a/dist/js/function/gl_installer.d.ts b/dist/js/function/gl_installer.d.ts deleted file mode 100644 index dd4cbf1..0000000 --- a/dist/js/function/gl_installer.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Installs a list of specified npm packages. - * This function automates the process of installing multiple npm packages, - * logging the progress and any errors that may occur during the installation. - * - * It uses the NpmCommandRunner class to run npm install commands for each package. - * Each package is installed with the latest version and saved as a development dependency. - */ -declare function gl_installer(): Promise; -export default gl_installer; diff --git a/dist/js/function/gl_installer.js b/dist/js/function/gl_installer.js deleted file mode 100644 index 2e5b6b3..0000000 --- a/dist/js/function/gl_installer.js +++ /dev/null @@ -1,65 +0,0 @@ -"use strict"; -// function/SvgPackager.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var NpmCommandRunner_js_1 = __importDefault(require("../class/NpmCommandRunner.js")); -var StylizedLogger_js_1 = __importDefault(require("../class/StylizedLogger.js")); -// ============================================================================ -// Constants -// ============================================================================ -const runner = new NpmCommandRunner_js_1.default(); -const logger = new StylizedLogger_js_1.default(); -// ============================================================================ -// Functions -// ============================================================================ -/** - * Installs a list of specified npm packages. - * This function automates the process of installing multiple npm packages, - * logging the progress and any errors that may occur during the installation. - * - * It uses the NpmCommandRunner class to run npm install commands for each package. - * Each package is installed with the latest version and saved as a development dependency. - */ -async function gl_installer() { - const packages = [ - 'pack.gl', - 'unit.gl', - 'hue.gl', - 'page.gl', - 'grid.gl', - 'block.gl', - 'deep.gl', - 'icon.gl', - 'loop.gl', - ]; - try { - logger.header('Install .gl libraries'); - for (const pkg of packages) { - logger.body(`Running npm install for ${pkg}...`); - const output = await runner.runCommand(`install ${pkg}@latest --save-dev`); - logger.body(output); - } - } - catch (error) { - console.error('An error occurred:', error); - } -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = gl_installer; diff --git a/dist/js/function/readPackageJson.d.ts b/dist/js/function/readPackageJson.d.ts deleted file mode 100644 index bf8e1d8..0000000 --- a/dist/js/function/readPackageJson.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Reads and parses the package.json file. - * @param packageJsonPath - The path to the package.json file. - * @returns The parsed package.json object. - */ -declare function readPackageJson(packageJsonPath: string): Promise; -export default readPackageJson; diff --git a/dist/js/function/readPackageJson.js b/dist/js/function/readPackageJson.js deleted file mode 100644 index 8b27178..0000000 --- a/dist/js/function/readPackageJson.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; -// function/readPackageJson.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -var promises_1 = __importDefault(require("fs/promises")); -var path_1 = __importDefault(require("path")); -// ============================================================================ -// Functions -// ============================================================================ -/** - * Reads and parses the package.json file. - * @param packageJsonPath - The path to the package.json file. - * @returns The parsed package.json object. - */ -async function readPackageJson(packageJsonPath) { - const fullPath = path_1.default.resolve(packageJsonPath); - const fileContent = await promises_1.default.readFile(fullPath, 'utf-8'); - return JSON.parse(fileContent); -} -// ============================================================================ -// Export -// ============================================================================ -exports.default = readPackageJson; diff --git a/dist/js/index.d.ts b/dist/js/index.d.ts deleted file mode 100644 index 809c409..0000000 --- a/dist/js/index.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import DirectoryScanner from './class/DirectoryScanner'; -import DirectoryCleaner from './class/DirectoryCleaner'; -import DirectoryCopier from './class/DirectoryCopier'; -import DirectoryCreator from './class/DirectoryCreator'; -import FileCopier from './class/FileCopier'; -import FileRenamer from './class/FileRenamer'; -import FilenameExtractor from './class/FilenameExtractor'; -import FontGenerator from './class/FontGenerator.js'; -import PackageCreator from './class/PackageCreator.js'; -import StyleProcessor from "./class/StyleProcessor.js"; -import VersionManager from './class/VersionManager.js'; -import VersionWriter from './class/VersionWriter.js'; -import TypeScriptCompiler from './class/TypeScriptCompiler.js'; -import JavaScriptMinifier from './class/JavaScriptMinifier.js'; -import NpmCommandRunner from './class/NpmCommandRunner.js'; -import StylizedLogger from './class/StylizedLogger.js'; -import TemplateWriter from './class/TemplateWriter.js'; -import SvgReader from './class/SvgReader.js'; -import SvgToPngConverter from './class/SvgToPngConverter.js'; -import SvgSpriteGenerator from "./class/SvgSpriteGenerator.js"; -import SvgPackager from "./class/SvgPackager.js"; -import TestRunner from './class/TestRunner.js'; -import DocumentationGenerator from './class/DocumentationGenerator.js'; -import CodeLinter from './class/CodeLinter.js'; -import JSONLoader from './class/JSONLoader.js'; -import gl_installer from './function/gl_installer'; -import cleanDirectory from './function/clean_directory'; -import readPackageJson from "./function/readPackageJson.js"; -export { DirectoryScanner, DirectoryCleaner, DirectoryCopier, DirectoryCreator, FileCopier, FileRenamer, FilenameExtractor, FontGenerator, PackageCreator, StyleProcessor, VersionWriter, VersionManager, TypeScriptCompiler, JavaScriptMinifier, NpmCommandRunner, StylizedLogger, TemplateWriter, TestRunner, DocumentationGenerator, CodeLinter, JSONLoader, SvgReader, SvgToPngConverter, SvgSpriteGenerator, SvgPackager, gl_installer, cleanDirectory, readPackageJson, }; diff --git a/dist/js/index.js b/dist/js/index.js deleted file mode 100644 index 6623871..0000000 --- a/dist/js/index.js +++ /dev/null @@ -1,79 +0,0 @@ -"use strict"; -// index.ts -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.readPackageJson = exports.cleanDirectory = exports.gl_installer = exports.SvgPackager = exports.SvgSpriteGenerator = exports.SvgToPngConverter = exports.SvgReader = exports.JSONLoader = exports.CodeLinter = exports.DocumentationGenerator = exports.TestRunner = exports.TemplateWriter = exports.StylizedLogger = exports.NpmCommandRunner = exports.JavaScriptMinifier = exports.TypeScriptCompiler = exports.VersionManager = exports.VersionWriter = exports.StyleProcessor = exports.PackageCreator = exports.FontGenerator = exports.FilenameExtractor = exports.FileRenamer = exports.FileCopier = exports.DirectoryCreator = exports.DirectoryCopier = exports.DirectoryCleaner = exports.DirectoryScanner = void 0; -// Copyright 2023 Scape Agency BV -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ============================================================================ -// Import -// ============================================================================ -// Import | Utility Classes -var DirectoryScanner_1 = __importDefault(require("./class/DirectoryScanner")); -exports.DirectoryScanner = DirectoryScanner_1.default; -var DirectoryCleaner_1 = __importDefault(require("./class/DirectoryCleaner")); -exports.DirectoryCleaner = DirectoryCleaner_1.default; -var DirectoryCopier_1 = __importDefault(require("./class/DirectoryCopier")); -exports.DirectoryCopier = DirectoryCopier_1.default; -var DirectoryCreator_1 = __importDefault(require("./class/DirectoryCreator")); -exports.DirectoryCreator = DirectoryCreator_1.default; -var FileCopier_1 = __importDefault(require("./class/FileCopier")); -exports.FileCopier = FileCopier_1.default; -var FileRenamer_1 = __importDefault(require("./class/FileRenamer")); -exports.FileRenamer = FileRenamer_1.default; -var FilenameExtractor_1 = __importDefault(require("./class/FilenameExtractor")); -exports.FilenameExtractor = FilenameExtractor_1.default; -// Import | Internal Classes -var FontGenerator_js_1 = __importDefault(require("./class/FontGenerator.js")); -exports.FontGenerator = FontGenerator_js_1.default; -var PackageCreator_js_1 = __importDefault(require("./class/PackageCreator.js")); -exports.PackageCreator = PackageCreator_js_1.default; -var StyleProcessor_js_1 = __importDefault(require("./class/StyleProcessor.js")); -exports.StyleProcessor = StyleProcessor_js_1.default; -var VersionManager_js_1 = __importDefault(require("./class/VersionManager.js")); -exports.VersionManager = VersionManager_js_1.default; -var VersionWriter_js_1 = __importDefault(require("./class/VersionWriter.js")); -exports.VersionWriter = VersionWriter_js_1.default; -var TypeScriptCompiler_js_1 = __importDefault(require("./class/TypeScriptCompiler.js")); -exports.TypeScriptCompiler = TypeScriptCompiler_js_1.default; -var JavaScriptMinifier_js_1 = __importDefault(require("./class/JavaScriptMinifier.js")); -exports.JavaScriptMinifier = JavaScriptMinifier_js_1.default; -var NpmCommandRunner_js_1 = __importDefault(require("./class/NpmCommandRunner.js")); -exports.NpmCommandRunner = NpmCommandRunner_js_1.default; -var StylizedLogger_js_1 = __importDefault(require("./class/StylizedLogger.js")); -exports.StylizedLogger = StylizedLogger_js_1.default; -var TemplateWriter_js_1 = __importDefault(require("./class/TemplateWriter.js")); -exports.TemplateWriter = TemplateWriter_js_1.default; -var SvgReader_js_1 = __importDefault(require("./class/SvgReader.js")); -exports.SvgReader = SvgReader_js_1.default; -var SvgToPngConverter_js_1 = __importDefault(require("./class/SvgToPngConverter.js")); -exports.SvgToPngConverter = SvgToPngConverter_js_1.default; -var SvgSpriteGenerator_js_1 = __importDefault(require("./class/SvgSpriteGenerator.js")); -exports.SvgSpriteGenerator = SvgSpriteGenerator_js_1.default; -var SvgPackager_js_1 = __importDefault(require("./class/SvgPackager.js")); -exports.SvgPackager = SvgPackager_js_1.default; -var TestRunner_js_1 = __importDefault(require("./class/TestRunner.js")); -exports.TestRunner = TestRunner_js_1.default; -var DocumentationGenerator_js_1 = __importDefault(require("./class/DocumentationGenerator.js")); -exports.DocumentationGenerator = DocumentationGenerator_js_1.default; -var CodeLinter_js_1 = __importDefault(require("./class/CodeLinter.js")); -exports.CodeLinter = CodeLinter_js_1.default; -var JSONLoader_js_1 = __importDefault(require("./class/JSONLoader.js")); -exports.JSONLoader = JSONLoader_js_1.default; -// Import | Internal Functions -var gl_installer_1 = __importDefault(require("./function/gl_installer")); -exports.gl_installer = gl_installer_1.default; -var clean_directory_1 = __importDefault(require("./function/clean_directory")); -exports.cleanDirectory = clean_directory_1.default; -var readPackageJson_js_1 = __importDefault(require("./function/readPackageJson.js")); -exports.readPackageJson = readPackageJson_js_1.default; diff --git a/dist/package.json b/dist/package.json index 75b492d..202a53b 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,6 +1,6 @@ { "name": "pack.gl", - "version": "0.0.39", + "version": "0.0.41", "description": "Package Builder.", "keywords": [ "pack.gl", @@ -14,7 +14,7 @@ "framework", "web" ], - "license": "Apache-2.0", + "license": "MIT", "homepage": "https://www.pack.gl/", "main": "js/index", "types": "js/index", @@ -35,22 +35,22 @@ "@types/fs-extra": "^11.0.4", "@types/glob": "^8.1.0", "@types/jsdom": "^21.1.6", - "@types/node": "^20.10.5", + "@types/node": "^22.1.0", "@types/nunjucks": "^3.2.6", - "@types/svg-sprite": "^0.0.38", + "@types/svg-sprite": "^0.0.39", "autoprefixer": "^10.4.16", - "cssnano": "^6.0.3", + "cssnano": "^7.0.4", "del": "^7.1.0", - "eslint": "^8.56.0", + "eslint": "^9.9.0", "eslint-config-prettier": "^9.0.0", - "fantasticon": "^2.0.0", + "fantasticon": "^3.0.0", "fs-extra": "^11.2.0", - "glob": "^10.3.10", - "jsdom": "^23.0.1", + "glob": "^11.0.0", + "jsdom": "^25.0.0", "lodash": "^4.17.21", "nunjucks": "^3.2.4", "postcss": "^8.4.32", - "postcss-preset-env": "^9.3.0", + "postcss-preset-env": "^10.0.0", "prettier": "^3.0.3", "sass": "^1.69.7", "semver": "^7.5.4", diff --git a/dist/ts/class/CodeLinter.ts b/dist/ts/class/CodeLinter.ts index 1933fdb..94e06c6 100644 --- a/dist/ts/class/CodeLinter.ts +++ b/dist/ts/class/CodeLinter.ts @@ -1,58 +1,61 @@ // class/CodeLinter.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - // ============================================================================ // Import // ============================================================================ - -import { ESLint } from 'eslint'; -import path from 'path'; +import { ESLint } from "eslint"; // ============================================================================ // Classes // ============================================================================ +/** + * A class responsible for setting up and running linting tasks using ESLint. + * This class encapsulates all necessary configurations and methods to perform + * linting of TypeScript files within a given project root directory. + */ class CodeLinter { + private eslint: ESLint; private projectRoot: string; + /** + * Initializes a new instance of the CodeLinter class with a specified + * project root. + * + * @param projectRoot The root directory of the project where linting will + * be performed. + */ constructor(projectRoot: string) { this.projectRoot = projectRoot; this.eslint = new ESLint({ cwd: projectRoot }); } /** - * Runs ESLint on the specified files or directories. + * Runs ESLint on the specified files or directories and fixes fixable + * issues. + * * @param targetFiles Array of file or directory paths to lint. - * @returns A promise that resolves with the linting results. + * @returns A promise that resolves with the linting results, including + * any fixes applied. + * @throws An error if linting fails due to configuration issues or file + * reading problems. */ async lintFiles(targetFiles: string[]): Promise { try { const results = await this.eslint.lintFiles(targetFiles); await ESLint.outputFixes(results); - const formatter = await this.eslint.loadFormatter('stylish'); - const resultText = formatter.format(results); + const formatter = await this.eslint.loadFormatter("stylish"); + const resultText = formatter.format(results); console.log(resultText); + return results; + } catch (error) { - console.error('Error occurred while linting:', error); + console.error("Error occurred while linting:", error); throw error; } } @@ -66,16 +69,18 @@ class CodeLinter { export default CodeLinter; +// ============================================================================ +// Example +// ============================================================================ - -// import CodeLinter from './CodeLinter'; +// import CodeLinter from "./CodeLinter"; // const linter = new CodeLinter(process.cwd()); -// linter.lintFiles(['src/**/*.ts']) +// linter.lintFiles(["src/**/*.ts"]) // .then(results => { -// console.log('Linting completed. Results:', results); +// console.log("Linting completed. Results:", results); // }) // .catch(error => { -// console.error('Linting error:', error); +// console.error("Linting error:", error); // }); diff --git a/dist/ts/class/DirectoryCleaner.ts b/dist/ts/class/DirectoryCleaner.ts index a23e140..8791064 100644 --- a/dist/ts/class/DirectoryCleaner.ts +++ b/dist/ts/class/DirectoryCleaner.ts @@ -1,37 +1,34 @@ // class/DirectoryCleaner.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -// import { promises as fsPromises } from 'fs'; -import path from 'path'; -import fs from 'fs'; +// import { promises as fsPromises } from "fs"; +import path from "path"; +import fs from "fs"; // ============================================================================ // Classes // ============================================================================ +/** + * Provides functionality to clean directories by recursively deleting their + * contents. + * This includes all files and subdirectories contained within. + */ class DirectoryCleaner { /** - * Recursively deletes all contents of the directory. - * @param dirPath The path to the directory to clean. + * Recursively deletes all contents of a specified directory, including all + * subdirectories and files. + * The method first checks if the directory exists before proceeding. + * If the directory does not exist, the method does nothing. + * + * @param dirPath The absolute or relative path to the directory to be + * cleaned. + * @throws {Error} Throws an error if deleting any file or directory fails. */ public cleanDirectory(dirPath: string): void { if (fs.existsSync(dirPath)) { @@ -56,3 +53,19 @@ class DirectoryCleaner { // ============================================================================ export default DirectoryCleaner; + + +// ============================================================================ +// Example +// ============================================================================ + +// import DirectoryCleaner from "./DirectoryCleaner"; + +// const cleaner = new DirectoryCleaner(); + +// try { +// cleaner.cleanDirectory("./path/to/directory"); +// console.log("Directory cleaned successfully."); +// } catch (error) { +// console.error("Failed to clean directory:", error); +// } diff --git a/dist/ts/class/DirectoryCopier.ts b/dist/ts/class/DirectoryCopier.ts index 633f96f..323046e 100644 --- a/dist/ts/class/DirectoryCopier.ts +++ b/dist/ts/class/DirectoryCopier.ts @@ -1,26 +1,12 @@ // class/DirectoryCopier.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import path from 'path'; -import { promises as fsPromises } from 'fs'; +import path from "path"; +import { promises as fsPromises } from "fs"; // ============================================================================ @@ -28,36 +14,50 @@ import { promises as fsPromises } from 'fs'; // ============================================================================ /** - * A class for copying files from one directory to another. + * Provides functionality to copy all files and subdirectories from one + * directory to another, including handling of nested directories. This class + * uses asynchronous operations to handle file operations efficiently. */ class DirectoryCopier { /** - * Copies all files and subdirectories from a source directory to a destination directory. - * @param srcDir The source directory path. - * @param destDir The destination directory path. - * @throws Will throw an error if copying fails for any file or directory. + * Asynchronously copies all files and subdirectories from the source + * directory to the destination directory. If the destination directory + * does not exist, it will be created. + * + * @param srcDir The path of the source directory. + * @param destDir The path of the destination directory. + * @throws {Error} If any file or directory could not be copied. */ async copyFiles(srcDir: string, destDir: string): Promise { try { const resolvedSrcDir = path.resolve(srcDir); const resolvedDestDir = path.resolve(destDir); await this.recursiveCopy(resolvedSrcDir, resolvedDestDir); - console.log(`Files copied from ${resolvedSrcDir} to ${resolvedDestDir}`); + console.log( + `Files copied from ${resolvedSrcDir} to ${resolvedDestDir}` + ); } catch (error) { - console.error('Error copying files:', error); + console.error("Error copying files:", error); throw error; } } /** - * Recursively copies files and directories. + * Recursively copies files and directories from the source to the + * destination directory. + * This method creates the destination directory if it does not exist and + * recursively copies all nested files and directories. + * * @param srcDir Source directory. * @param destDir Destination directory. */ async recursiveCopy(srcDir: string, destDir: string): Promise { await fsPromises.mkdir(destDir, { recursive: true }); - const entries = await fsPromises.readdir(srcDir, { withFileTypes: true }); + const entries = await fsPromises.readdir( + srcDir, + { withFileTypes: true } + ); for (let entry of entries) { const srcPath = path.join(srcDir, entry.name); @@ -77,3 +77,16 @@ class DirectoryCopier { // ============================================================================ export default DirectoryCopier; + + +// ============================================================================ +// Example +// ============================================================================ + +// import DirectoryCopier from "./DirectoryCopier"; + +// const copier = new DirectoryCopier(); + +// copier.copyFiles("./path/to/source", "./path/to/destination") +// .then(() => console.log("Copying completed successfully.")) +// .catch(error => console.error("Copying failed:", error)); diff --git a/dist/ts/class/DirectoryCreator.ts b/dist/ts/class/DirectoryCreator.ts index e784c7a..216742c 100644 --- a/dist/ts/class/DirectoryCreator.ts +++ b/dist/ts/class/DirectoryCreator.ts @@ -1,26 +1,12 @@ // class/DirectoryGenerator.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { promises as fsPromises } from 'fs'; -import path from 'path'; +import { promises as fsPromises } from "fs"; +import path from "path"; // ============================================================================ @@ -28,20 +14,24 @@ import path from 'path'; // ============================================================================ /** - * A class for creating directories. + * Provides functionality for creating directory structures within a given + * base path. This class helps in setting up directories for new projects or + * ensuring that necessary directory structures are in place for file + * operations. */ - class DirectoryCreator { + /** - * Creates directories at the specified locations asynchronously. - * @param basePath The base path where directories will be created. - * @param directories An array of directory paths to create. - * @description This method iterates over the provided array of directory paths, - * creating each directory at the specified location within the base path. - * If a directory already exists, it skips creation. This is useful for - * setting up a project structure or ensuring necessary directories are - * available before performing file operations. - * @throws Will throw an error if directory creation fails. + * Asynchronously creates multiple directories based on a provided list of + * paths. Directories are created within a specified base path. If + * directories already exist, the operation skips those directories, + * preventing any disruption of existing content. + * + * @param basePath The base path where directories will be created, relative or absolute. + * @param directories An array of directory paths to create relative to the base path. + * @description Each directory is processed individually to ensure creation or validate existence. + * This method uses the "recursive" option to create all necessary parent directories. + * @throws {Error} An error is thrown if there is a failure in creating any directory. */ async createDirectories(basePath: string, directories: string[]): Promise { try { @@ -62,4 +52,19 @@ import path from 'path'; // Export // ============================================================================ -export default DirectoryCreator; \ No newline at end of file +export default DirectoryCreator; + + +// ============================================================================ +// Example +// ============================================================================ + +// import DirectoryCreator from "./DirectoryGenerator"; + +// const directoryCreator = new DirectoryCreator(); +// const basePath = "./project"; +// const directories = ["src", "src/assets", "docs"]; + +// directoryCreator.createDirectories(basePath, directories) +// .then(() => console.log("All specified directories have been created.")) +// .catch(error => console.error("Failed to create directories:", error)); \ No newline at end of file diff --git a/dist/ts/class/DirectoryScanner.ts b/dist/ts/class/DirectoryScanner.ts index a998549..4ffda40 100644 --- a/dist/ts/class/DirectoryScanner.ts +++ b/dist/ts/class/DirectoryScanner.ts @@ -1,40 +1,38 @@ // class/DirectoryScanner.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import fs from 'fs/promises'; -import path from 'path'; +import fs from "fs/promises"; +import path from "path"; // ============================================================================ // Classes // ============================================================================ +/** + * Provides methods to scan directories and list contents, with the option to + * include subdirectories recursively. Useful for applications that need to + * process files dynamically or monitor directory changes. + */ class DirectoryScanner { /** - * Scans a directory and returns a list of file paths. - * Can optionally scan directories recursively. - * @param dirPath The directory to scan. - * @param recursive Whether to scan directories recursively. - * @returns A promise that resolves to an array of file paths. + * Scans the specified directory and returns an array of file paths. It + * can scan directories recursively to retrieve paths of all files within + * the directory tree. + * + * @param dirPath The path to the directory to be scanned. + * @param recursive Optional. If set to true, the method scans all subdirectories recursively. + * Defaults to false. + * @returns A promise that resolves with an array of file paths (strings), representing + * all files within the directory, or within the entire directory tree if recursive + * scanning is enabled. + * @throws An error if the directory cannot be read, including permissions errors or if the + * directory does not exist. */ async scanDirectory( dirPath: string, @@ -58,8 +56,25 @@ class DirectoryScanner { } + // ============================================================================ // Export // ============================================================================ export default DirectoryScanner; + + +// ============================================================================ +// Example +// ============================================================================ + +// import DirectoryScanner from "./DirectoryScanner"; + +// const scanner = new DirectoryScanner(); +// scanner.scanDirectory("./path/to/directory", true) +// .then(files => { +// console.log("Scanned files:", files); +// }) +// .catch(error => { +// console.error("Failed to scan directory:", error); +// }); \ No newline at end of file diff --git a/dist/ts/class/DocumentationGenerator.ts b/dist/ts/class/DocumentationGenerator.ts index 5089458..1f56a60 100644 --- a/dist/ts/class/DocumentationGenerator.ts +++ b/dist/ts/class/DocumentationGenerator.ts @@ -1,27 +1,12 @@ // class/DocumentationGenerator.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ - -import { exec } from 'child_process'; -import util from 'util'; +import { exec } from "child_process"; +import util from "util"; const execAsync = util.promisify(exec); @@ -30,11 +15,24 @@ const execAsync = util.promisify(exec); // Classes // ============================================================================ +/** + * Automates the process of generating documentation for software projects. + * This class allows for flexible configuration of source paths, output paths, + * and the specific documentation generation command to be used. + */ class DocumentationGenerator { + private sourcePath: string; private outputPath: string; private generatorCommand: string; + /** + * Initializes a new instance of the DocumentationGenerator. + * + * @param sourcePath Path to the source files for which documentation should be generated. + * @param outputPath Path where the generated documentation will be placed. + * @param generatorCommand The command-line tool used for generating documentation (e.g., "jsdoc"). + */ constructor(sourcePath: string, outputPath: string, generatorCommand: string) { this.sourcePath = sourcePath; this.outputPath = outputPath; @@ -42,8 +40,12 @@ class DocumentationGenerator { } /** - * Generates documentation based on the provided configuration. - * @returns A promise that resolves when the documentation generation is complete. + * Executes the documentation generation process using the specified command-line tool. + * Handles both the execution of the command and the management of output, including logging + * and error reporting. + * + * @returns A promise that resolves when documentation generation is successfully completed, + * or rejects with an error if the process fails. */ async generate(): Promise { try { @@ -57,11 +59,11 @@ class DocumentationGenerator { } console.log(stdout); - console.log('Documentation generated successfully.'); + console.log("Documentation generated successfully."); // Here, you can add any post-generation logic if necessary } catch (error) { - console.error('Error occurred while generating documentation:', error); + console.error("Error occurred while generating documentation:", error); throw error; } } @@ -75,22 +77,18 @@ class DocumentationGenerator { export default DocumentationGenerator; +// ============================================================================ +// Example +// ============================================================================ +// import DocumentationGenerator from "./DocumentationGenerator"; -// Usage Example -// To use the DocumentationGenerator class, you would instantiate it with the path to your source files, the output directory for the documentation, and the command for your documentation tool. For instance, using JSDoc: - - -// import DocumentationGenerator from './DocumentationGenerator'; - -// const sourcePath = './src'; -// const outputPath = './docs'; -// const generatorCommand = 'jsdoc'; // Ensure JSDoc is installed and available in your environment +// const sourcePath = "./src"; +// const outputPath = "./docs"; +// const generatorCommand = "jsdoc"; // Ensure JSDoc is installed and available in your environment // const docGenerator = new DocumentationGenerator(sourcePath, outputPath, generatorCommand); // docGenerator.generate() -// .then(() => console.log('Documentation generation completed.')) -// .catch(error => console.error(error)); - - +// .then(() => console.log("Documentation generation completed.")) +// .catch(error => console.error(error)); \ No newline at end of file diff --git a/dist/ts/class/FileCopier.ts b/dist/ts/class/FileCopier.ts index 58179aa..b7caa04 100644 --- a/dist/ts/class/FileCopier.ts +++ b/dist/ts/class/FileCopier.ts @@ -1,26 +1,12 @@ // class/FileCopier.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import fs from 'fs'; -import path from 'path'; +import fs from "fs"; +import path from "path"; // ============================================================================ @@ -28,15 +14,21 @@ import path from 'path'; // ============================================================================ /** - * A class for copying files from one location to another. + * Handles the copying of files from one location to another, ensuring that + * the operation is both safe and efficient. This class is particularly useful + * for applications requiring file management capabilities, such as backup + * systems or content management systems. */ class FileCopier { /** - * Copies a single file to a specified destination directory. - * @param {string} srcFile - The path of the source file to copy. - * @param {string} destDir - The destination directory where the file should be copied. - * @throws Will throw an error if the file copy operation fails. + * Copies a file from a specified source to a destination directory. This method takes care of + * file path resolution and checks for existing files in the destination, replacing them if necessary. + * + * @param {string} srcFile - The path of the source file to be copied. + * @param {string} destDir - The destination directory where the file should be placed. + * @returns {Promise} A promise that resolves when the file has been successfully copied. + * @throws {Error} If the file cannot be copied, including due to permission errors or the source file not existing. */ async copyFileToDirectory( srcFile: string, @@ -48,7 +40,7 @@ import path from 'path'; await fs.promises.copyFile(srcFile, destFilePath); console.log(`File copied from ${srcFile} to ${destFilePath}`); } catch (error) { - console.error('Error copying file:', error); + console.error("Error copying file:", error); throw error; } } @@ -61,3 +53,18 @@ import path from 'path'; // ============================================================================ export default FileCopier; + + +// ============================================================================ +// Example +// ============================================================================ + +// import FileCopier from "./FileCopier"; + +// const copier = new FileCopier(); +// const sourceFile = "./path/to/source/file.txt"; +// const destinationDir = "./path/to/destination"; + +// copier.copyFileToDirectory(sourceFile, destinationDir) +// .then(() => console.log("File copying completed successfully.")) +// .catch(error => console.error("Failed to copy file:", error)); \ No newline at end of file diff --git a/dist/ts/class/FileRenamer.ts b/dist/ts/class/FileRenamer.ts index aea4669..e788f68 100644 --- a/dist/ts/class/FileRenamer.ts +++ b/dist/ts/class/FileRenamer.ts @@ -1,26 +1,12 @@ // class/FileRenamer.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import fs from 'fs'; -import path from 'path'; +import fs from "fs"; +import path from "path"; // ============================================================================ @@ -28,22 +14,29 @@ import path from 'path'; // ============================================================================ /** - * A class for renaming files. + * Provides functionality for renaming files within the file system. This + * class ensures that file renaming operations are handled smoothly and + * includes comprehensive error management to address + * potential issues such as file accessibility or conflicts. */ class FileRenamer { /** - * Renames a file from the source path to the target path. - * @param srcPath The current path of the file. - * @param targetPath The new path of the file after renaming. - * @returns Promise + * Renames a file from its current path to a new path. This operation is + * atomic on most file systems, which means it is either completed fully + * or not done at all, preventing partial updates. + * + * @param srcPath The current path of the file to be renamed. + * @param targetPath The new path where the file will be renamed. + * @returns A Promise that resolves when the file has been successfully renamed, or rejects if an error occurs. + * @throws {Error} Errors could include "ENOENT" if the source file does not exist, or "EACCES" if permission is denied. */ - async renameFile(srcPath: string, targetPath: string): Promise { + async renameFile(srcPath: string, targetPath: string): Promise { try { await fs.promises.rename(srcPath, targetPath); console.log(`File renamed from ${srcPath} to ${targetPath}`); } catch (error) { - console.error('Error renaming file:', error); + console.error("Error renaming file:", error); throw error; } } @@ -56,3 +49,19 @@ import path from 'path'; // ============================================================================ export default FileRenamer; + + +// ============================================================================ +// Example +// ============================================================================ + +// import FileRenamer from "./FileRenamer"; + +// const renamer = new FileRenamer(); +// const srcPath = "./path/to/original/file.txt"; +// const targetPath = "./path/to/new/file.txt"; + +// renamer.renameFile(srcPath, targetPath) +// .then(() => console.log("File successfully renamed.")) +// .catch(error => console.error("Failed to rename file:", error)); + diff --git a/dist/ts/class/FilenameExtractor.ts b/dist/ts/class/FilenameExtractor.ts index 51c8100..f749021 100644 --- a/dist/ts/class/FilenameExtractor.ts +++ b/dist/ts/class/FilenameExtractor.ts @@ -1,19 +1,5 @@ // class/FilenameExtractor.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import @@ -26,12 +12,23 @@ import path from 'path'; // Classes // ============================================================================ +/** + * Provides methods to extract filenames and components from paths, focusing + * on removing file extensions. This class can be particularly useful in + * applications where file handling is a common task, such as in data + * processing, file management systems, or when generating output files with + * modified names. + */ class FilenameExtractor { /** - * Extracts the filename without its extension from a file path. - * @param filePath The full path of the file. - * @returns The filename without its extension. + * Retrieves the file name from a full file path, excluding the file + * extension. This method utilizes the Node.js `path` module to parse and + * extract the file name, ensuring compatibility with various file system + * path formats. + * + * @param filePath The full path of the file from which the name should be extracted. + * @returns The file name without its extension, as a string. */ getFilenameWithoutExtension(filePath: string): string { return path.basename(filePath, path.extname(filePath)); @@ -45,3 +42,16 @@ class FilenameExtractor { // ============================================================================ export default FilenameExtractor; + + +// ============================================================================ +// Example +// ============================================================================ + +// import FilenameExtractor from './FilenameExtractor'; + +// const extractor = new FilenameExtractor(); +// const filePath = '/path/to/file.txt'; +// const filename = extractor.getFilenameWithoutExtension(filePath); + +// console.log('Filename without extension:', filename); diff --git a/dist/ts/class/FontGenerator.ts b/dist/ts/class/FontGenerator.ts index 9454837..6f7c31c 100644 --- a/dist/ts/class/FontGenerator.ts +++ b/dist/ts/class/FontGenerator.ts @@ -1,26 +1,17 @@ // class/FontGenerator.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { generateFonts, FontAssetType, OtherAssetType, RunnerOptions, } from 'fantasticon'; -import RunnerOptionalOptions from 'fantasticon'; +import { + generateFonts, + // FontAssetType, + // OtherAssetType, + RunnerOptions, + // RunnerOptionalOptions, +} from "fantasticon"; import fantasticonConfig from "../config/fantasticon.config.js" @@ -28,32 +19,54 @@ import fantasticonConfig from "../config/fantasticon.config.js" // Classes // ============================================================================ +/** + * Handles the generation of font files from SVG icons or other vector graphic + * formats. This class utilizes the "fantasticon" library to convert a + * directory of SVG files into various font formats. Users can customize the + * font generation process via configuration options. + */ class FontGenerator { /** * Configuration for the TypeScript compiler. */ - private config: any; + // private config: any; + private config: RunnerOptions; - /** - * Default configuration for the TypeScript compiler. - */ - private static defaultConfig: any = fantasticonConfig; - // private static defaultConfig: CompilerOptions = tsConfig; + /** + * Default configuration derived from an external configuration file. + */ + // private static defaultConfig: any = fantasticonConfig; + private static defaultConfig: RunnerOptions = fantasticonConfig; + /** * Constructs an instance with merged configuration of default and custom options. * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. */ - constructor( - customConfig: any = {}, - ) { + /** + * Constructs an instance of FontGenerator, merging default configuration with optional custom settings. + * + * @param {RunnerOptions} customConfig Optional custom configuration to override the defaults. + */ + constructor( + // customConfig: any = {}, + customConfig: Partial = {}, + ) { this.config = { ...FontGenerator.defaultConfig, ...customConfig }; } + /** + * Generates font assets from SVG icons located in the specified source directory, + * and outputs them to the specified output directory. + * + * @param {string} sourceDirectory The directory containing SVG files to be converted. + * @param {string} outputDirectory The directory where the generated font files will be stored. + * @param {Partial} options Additional options to customize the font generation process. + */ async generateFonts( sourceDirectory: string, outputDiectory: string, @@ -71,9 +84,9 @@ class FontGenerator { try { await generateFonts(config); - console.log('Fonts generated successfully.'); + console.log("Fonts generated successfully."); } catch (error) { - console.error('Error generating fonts:', error); + console.error("Error generating fonts:", error); } } @@ -85,3 +98,18 @@ class FontGenerator { // ============================================================================ export default FontGenerator; + + +// ============================================================================ +// Example +// ============================================================================ + +// import FontGenerator from "./FontGenerator"; + +// const fontGenerator = new FontGenerator(); +// const sourceDirectory = "./path/to/svg/icons"; +// const outputDirectory = "./path/to/output/fonts"; + +// fontGenerator.generateFonts(sourceDirectory, outputDirectory) +// .then(() => console.log("Font generation completed successfully.")) +// .catch(error => console.error("Failed to generate fonts:", error)); \ No newline at end of file diff --git a/dist/ts/class/JSONLoader.ts b/dist/ts/class/JSONLoader.ts index 4435f56..db861a0 100644 --- a/dist/ts/class/JSONLoader.ts +++ b/dist/ts/class/JSONLoader.ts @@ -1,19 +1,5 @@ // class/JSONLoader.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import @@ -27,11 +13,21 @@ import path from 'path'; // Classes // ============================================================================ +/** + * Provides functionality to load and manipulate JSON data from files and + * directories. This class can be used in scenarios where configurations, + * data storage, or inter-process communication involves JSON files. + */ class JSONLoader { + /** - * Asynchronously loads JSON data from a file and returns it as an object. + * Asynchronously loads JSON data from a file and returns it as a typed + * object. This method parses the JSON file content into a TypeScript + * type or interface. + * * @param filePath The path to the JSON file. - * @returns A promise that resolves to an object containing the JSON data. + * @returns A promise that resolves to an object containing the parsed JSON data. + * @throws {Error} If the file cannot be read or the data cannot be parsed as JSON. */ async loadJSON(filePath: string): Promise { try { @@ -44,11 +40,15 @@ class JSONLoader { } /** - * Asynchronously loads all JSON files from a given directory. + * Asynchronously loads all JSON files from a specified directory and + * returns an array of typed objects. Useful for loading batches of + * configuration files or similar datasets. + * * @param dirPath The path to the directory containing JSON files. - * @returns A promise that resolves to an array of objects containing the JSON data. + * @returns A promise that resolves to an array of objects containing the parsed JSON data. + * @throws {Error} If the directory cannot be read or if there's an error parsing any of the files. */ - async loadJSONFromDirectory(dirPath: string): Promise { + async loadJSONFromDirectory(dirPath: string): Promise { try { const files = await fs.readdir(dirPath); const jsonFiles = files.filter(file => file.endsWith('.json')); @@ -67,7 +67,10 @@ class JSONLoader { } /** - * Merges an array of objects into a single object. + * Merges an array of objects into a single object. This method is + * particularly useful when combining settings or configurations from + * multiple JSON files into a single configuration object. + * * @param objects An array of objects to merge. * @returns A single object containing all properties from the input objects. */ @@ -81,4 +84,27 @@ class JSONLoader { // Export // ============================================================================ -export default JSONLoader; \ No newline at end of file +export default JSONLoader; + + +// ============================================================================ +// Example +// ============================================================================ + +// import JSONLoader from './JSONLoader'; + +// const loader = new JSONLoader(); +// const filePath = './config/settings.json'; +// const dirPath = './configs'; + +// loader.loadJSON(filePath) +// .then(config => console.log('Loaded JSON:', config)) +// .catch(error => console.error('Failed to load JSON file:', error)); + +// loader.loadJSONFromDirectory(dirPath) +// .then(configs => { +// console.log('Loaded multiple JSON configurations:', configs); +// return loader.mergeJSONObjects(configs); +// }) +// .then(mergedConfig => console.log('Merged Configuration:', mergedConfig)) +// .catch(error => console.error('Failed to load or merge configurations:', error)); \ No newline at end of file diff --git a/dist/ts/class/JavaScriptMinifier.ts b/dist/ts/class/JavaScriptMinifier.ts index b6570ce..80accdc 100644 --- a/dist/ts/class/JavaScriptMinifier.ts +++ b/dist/ts/class/JavaScriptMinifier.ts @@ -1,26 +1,12 @@ // class/JavaScriptMinifier.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { minify } from 'terser'; -import { promises as fs } from 'fs'; +import { minify } from "terser"; +import { promises as fs } from "fs"; import terserConfig from "../config/terser.config.js" @@ -29,38 +15,47 @@ import terserConfig from "../config/terser.config.js" // ============================================================================ /** - * Class to minify JavaScript files using Terser. + * Facilitates the minification of JavaScript files using the Terser library. + * This class allows for flexible configuration of minification settings and + * aims to produce optimized output files that are significantly reduced in + * size. */ - class JavaScriptMinifier { +class JavaScriptMinifier { /** - * Configuration for the JavaScript compiler. + * Configuration for the Terser minification process. */ - private config: any; + private config: any; - /** - * Default configuration for the JavaScript compiler. - */ - private static defaultConfig: any = terserConfig; + /** + * Default configuration for the Terser minification, loaded from an + * external configuration file. + */ + private static defaultConfig: any = terserConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {any} customConfig - OptionalConfiguration object - minification options for Terser. - */ - constructor( - customConfig: any = {}, - ) { - this.config = { - ...JavaScriptMinifier.defaultConfig, - ...customConfig - }; - } + /** + * Constructs an instance with merged configuration of default and + * optionally provided custom settings. + * + * @param {any} customConfig Optional. Custom configuration object to + * override or extend the default Terser options. + */ + constructor( + customConfig: any = {}, + ) { + this.config = { + ...JavaScriptMinifier.defaultConfig, + ...customConfig + }; + } /** - * Minifies a JavaScript file. - * @param {string} inputPath - Path to the input JavaScript file. - * @param {string} outputPath - Path to save the minified output file. - * @returns {Promise} - A promise that resolves when minification is complete. + * Minifies a JavaScript file using the configured Terser settings. + * + * @param {string} inputPath Path to the input JavaScript file. + * @param {string} outputPath Path where the minified file will be saved. + * @returns {Promise} A promise that resolves when the minification process is complete, or rejects with an error. + * @throws {Error} An error is thrown if there are issues reading the input file, the minification fails, or the output file cannot be written. */ async minifyFile( inputPath: string, @@ -70,14 +65,14 @@ import terserConfig from "../config/terser.config.js" try { // Read the input file - const inputCode = await fs.readFile(inputPath, 'utf8'); + const inputCode = await fs.readFile(inputPath, "utf8"); // Minify the file using Terser const result = await minify(inputCode, this.config); // If minification is successful, write the output if (result.code) { await fs.writeFile(outputPath, result.code); } else { - throw new Error('Minification resulted in empty output.'); + throw new Error("Minification resulted in empty output."); } } catch (error) { console.error(`Error minifying JavaScript file ${inputPath}:`, error); @@ -93,3 +88,19 @@ import terserConfig from "../config/terser.config.js" // ============================================================================ export default JavaScriptMinifier; + + +// ============================================================================ +// Example +// ============================================================================ + + +// import JavaScriptMinifier from "./JavaScriptMinifier"; + +// const minifier = new JavaScriptMinifier(); +// const inputPath = "./path/to/source/file.js"; +// const outputPath = "./path/to/minified/file.min.js"; + +// minifier.minifyFile(inputPath, outputPath) +// .then(() => console.log("JavaScript file has been minified successfully.")) +// .catch(error => console.error("Failed to minify JavaScript file:", error)); \ No newline at end of file diff --git a/dist/ts/class/NodemonServer.ts b/dist/ts/class/NodemonServer.ts index fb1d7a6..f883293 100644 --- a/dist/ts/class/NodemonServer.ts +++ b/dist/ts/class/NodemonServer.ts @@ -1,34 +1,22 @@ // class/NodemonServer.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // ============================================================================ // Import // ============================================================================ - - // import express from 'express'; // import path from 'path'; - // ============================================================================ // Classes // ============================================================================ +/** + * Encapsulates server configuration and initialization, serving static files and additional routes. + * This class can be extended or instantiated directly to set up a server quickly. + */ // class CustomServer { // private app: express.Application; @@ -37,36 +25,54 @@ // this.configureRoutes(); // } -// private configureRoutes() { -// // Serve static files from 'public' directory (or any other directory of your choice) +// /** +// * Configures the server routes including static files and any additional API endpoints. +// */ +// private configureRoutes(): void { +// // Serve static files from the 'public' directory // this.app.use(express.static(path.join(__dirname, 'public'))); -// // Define additional routes here if needed +// // Additional routes can be configured here +// this.app.get('/', (req, res) => { +// res.send('Hello, world!'); +// }); // } -// public listen(port: number) { +// /** +// * Starts the server on the specified port. +// * @param port The port number on which the server should listen. +// */ +// public listen(port: number): void { // this.app.listen(port, () => { // console.log(`Server listening on port ${port}`); // }); // } // } - // ============================================================================ // Export // ============================================================================ // export default CustomServer; - +// ============================================================================ +// Nodemon Configuration Example (package.json) +// ============================================================================ // "scripts": { // "start": "nodemon --watch src --ext ts,js,json --exec ts-node src/index.ts" // } +// ============================================================================ +// Example +// ============================================================================ -// import CustomServer from './CustomServer'; - -// const server = new CustomServer(); -// server.listen(3000); // Listen on port 3000 +/** + * Usage Example: + * + * import CustomServer from './CustomServer'; + * + * const server = new CustomServer(); + * server.listen(3000); // Listen on port 3000 + */ diff --git a/dist/ts/class/NpmCommandRunner.ts b/dist/ts/class/NpmCommandRunner.ts index 0b72ddc..a3d4e14 100644 --- a/dist/ts/class/NpmCommandRunner.ts +++ b/dist/ts/class/NpmCommandRunner.ts @@ -1,38 +1,37 @@ // class/NpmCommandRunner.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { exec } from 'child_process'; +import { exec } from "child_process"; // ============================================================================ // Classes // ============================================================================ -/// TypeScript Class to Run NPM Commands +/** + * Provides a method to execute npm commands programmatically within a Node.js + * application. This class is particularly useful for automating tasks that + * involve npm operations, such as installing packages, running scripts, or + * updating dependencies. + */ class NpmCommandRunner { /** - * Executes an npm command. - * @param command The npm command to run. - * @returns A promise that resolves with the command output or rejects with an error. + * Executes a given npm command and handles its output or errors. + * + * @param command The npm command to be executed, such as "install", "update", or a custom script. + * @returns A promise that resolves with the standard output of the command, or rejects with an error message. + * + * @example + * // Example usage: + * const runner = new NpmCommandRunner(); + * runner.runCommand("install express") + * .then(output => console.log("NPM Install Output:", output)) + * .catch(error => console.error("NPM Command Error:", error)); */ runCommand(command: string): Promise { return new Promise((resolve, reject) => { @@ -58,3 +57,8 @@ class NpmCommandRunner { // ============================================================================ export default NpmCommandRunner; + + +// ============================================================================ +// Example +// ============================================================================ diff --git a/dist/ts/class/PackageCreator.ts b/dist/ts/class/PackageCreator.ts index d5ac02b..bd48b6f 100644 --- a/dist/ts/class/PackageCreator.ts +++ b/dist/ts/class/PackageCreator.ts @@ -1,19 +1,5 @@ // class/PackageCreator.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import @@ -29,30 +15,34 @@ import packageConfig from "../config/package.config.js" // ============================================================================ /** - * A class for creating a package.json file for a project. + * Provides functionality to programmatically create and write package.json + * files using a flexible configuration. This class is ideal for automating + * the setup of Node.js projects or managing configurations dynamically. */ class PackageCreator { /** * Configuration for the Package.json. */ - public config: any; + public config: any; // private config: ts.CompilerOptions; // private config: { [key: symbol]: any}; - /** - * Default configuration for Package.json. - */ - private static defaultConfig: any = packageConfig; + /** + * Default configuration sourced from an external configuration file. + */ + private static defaultConfig: any = packageConfig; /** - * Initializes a new instance of the PackageCreator class. - * @param {PackageJson} customConfig - The content to be written into package.json. + * Constructs an instance with merged default and custom configuration + * settings for package.json. + * + * @param customConfig Custom settings to override or augment the default package configuration. */ - constructor( + constructor( customConfig: any = {}, // customConfig: ts.CompilerOptions = {}, - ) { + ) { let newConfig = { // Populate with necessary fields from packageData name: customConfig.name, @@ -66,6 +56,7 @@ import packageConfig from "../config/package.config.js" repository: customConfig.repository, funding: customConfig.funding, dependencies: customConfig.dependencies, + exports: customConfig.exports, } this.config = { ...PackageCreator.defaultConfig, @@ -74,11 +65,14 @@ import packageConfig from "../config/package.config.js" } /** - * Creates a package.json file in the specified directory. - * Creates the directory if it does not exist. - * @param outputDir - The directory where package.json will be created. + * Creates a package.json file with the stored configuration in the + * specified directory. If the directory does not exist, it will be + * created. + * + * @param outputDir The directory where the package.json will be created. + * @returns A promise that resolves when the file has been successfully written. */ - async createPackageJson(outputDir: string): Promise { + async createPackageJson(outputDir: string): Promise { const filePath = path.join(outputDir, 'package.json'); const data = JSON.stringify(this.config, null, 2); try { @@ -94,10 +88,11 @@ import packageConfig from "../config/package.config.js" } /** - * Ensures that the given directory exists. Creates it if it does not exist. - * @param dirPath - The path of the directory to check and create. + * Ensures the specified directory exists. If it does not, it will be created. + * + * @param dirPath The path of the directory to verify or create. */ - private async ensureDirectoryExists(dirPath: string): Promise { + private async ensureDirectoryExists(dirPath: string): Promise { try { await fs.mkdir(dirPath, { recursive: true }); } catch (error) { @@ -116,3 +111,24 @@ import packageConfig from "../config/package.config.js" // ============================================================================ export default PackageCreator; + + +// ============================================================================ +// Example +// ============================================================================ + +// import PackageCreator from './PackageCreator'; + +// const customConfig = { +// name: "my-new-project", +// version: "1.0.0", +// description: "A new Node.js project", +// author: "Developer Name" +// }; + +// const packageCreator = new PackageCreator(customConfig); +// const outputDirectory = "./path/to/project"; + +// packageCreator.createPackageJson(outputDirectory) +// .then(() => console.log("Package.json has been successfully created.")) +// .catch(error => console.error("Error creating package.json:", error)); \ No newline at end of file diff --git a/dist/ts/class/SVGReader.ts b/dist/ts/class/SVGReader.ts index 985fc20..6fc342f 100644 --- a/dist/ts/class/SVGReader.ts +++ b/dist/ts/class/SVGReader.ts @@ -1,41 +1,37 @@ // class/SvgReader.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { promises as fs } from 'fs'; +import { promises as fs } from "fs"; // ============================================================================ // Classes // ============================================================================ +/** + * Handles reading SVG files from the filesystem. This class can be used in applications + * that need to process or analyze SVG content programmatically, such as in graphics + * processing tools, web servers, or content management systems. + */ class SvgReader { /** * Reads the content of an SVG file asynchronously. + * This method is useful for applications that need to load and manipulate SVG graphics, + * perhaps for rendering or further processing. + * * @param filePath The path to the SVG file. - * @returns A promise that resolves to the content of the SVG file. + * @returns A promise that resolves to the content of the SVG file as a string. + * @throws Throws an error if the file cannot be read, which might occur due to issues + * like file not existing or access permissions. */ async readSVG(filePath: string): Promise { try { - const data = await fs.readFile(filePath, 'utf-8'); + const data = await fs.readFile(filePath, "utf-8"); return data; } catch (error) { console.error(`Error reading SVG file: ${filePath}`, error); @@ -51,3 +47,19 @@ class SvgReader { // ============================================================================ export default SvgReader; + + +// ============================================================================ +// Example +// ============================================================================ + +// import SvgReader from "./SvgReader"; + +// const reader = new SvgReader(); +// reader.readSVG("path/to/your/svg/file.svg") +// .then(content => { +// console.log("SVG Content:", content); +// }) +// .catch(error => { +// console.error("Failed to read SVG:", error); +// }); \ No newline at end of file diff --git a/dist/ts/class/SassDocGenerator.ts b/dist/ts/class/SassDocGenerator.ts new file mode 100644 index 0000000..7b664df --- /dev/null +++ b/dist/ts/class/SassDocGenerator.ts @@ -0,0 +1,78 @@ +// class/SassDocGenerator.ts + + +// ============================================================================ +// Imports +// ============================================================================ + +import * as sassdoc from "sassdoc"; +import path from "path"; + + +// ============================================================================ +// Class: SassDocGenerator +// ============================================================================ + +/** + * SassDocGenerator is responsible for generating SASS documentation using SassDoc. + * It provides methods to configure and execute the documentation generation process. + */ +class SassDocGenerator { + + /** + * Generates SASS documentation for the specified source files or directories. + * @param sourcePaths - Array of file or directory paths to generate documentation for. + * @param destDir - The directory where the generated documentation should be saved. + * @param options - Additional options for SassDoc configuration. + * @returns A promise that resolves when documentation generation is complete. + */ + public async generateDocumentation( + sourcePaths: string[], + destDir: string, + options: sassdoc.Options = {} + ): Promise { + try { + // Merge custom options with default options + const config: sassdoc.Options = { + dest: path.resolve(destDir), + verbose: true, + ...options + }; + + // Run SassDoc to generate the documentation + await sassdoc(sourcePaths, config); + + console.log(`SASS documentation successfully generated at: ${config.dest}`); + } catch (error) { + console.error( + "An error occurred while generating SASS documentation:", + error + ); + throw error; + } + } +} + + +// ============================================================================ +// Exports +// ============================================================================ + +export default SassDocGenerator; + + +// ============================================================================ +// Example Usage +// ============================================================================ + +// import SassDocGenerator from "./SassDocGenerator"; + +// const sassDocGenerator = new SassDocGenerator(); + +// sassDocGenerator.generateDocumentation(["src/styles"], "docs/sass") +// .then(() => { +// console.log("Documentation generation complete."); +// }) +// .catch(error => { +// console.error("Error generating documentation:", error); +// }); \ No newline at end of file diff --git a/dist/ts/class/StyleProcessor.ts b/dist/ts/class/StyleProcessor.ts index 18f27cc..328f61b 100644 --- a/dist/ts/class/StyleProcessor.ts +++ b/dist/ts/class/StyleProcessor.ts @@ -1,73 +1,57 @@ // class/StyleProcessor.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -// import * as sass from 'sass'; -// import postcss from 'postcss'; -// import fs from 'fs'; -// import { promises as fsPromises } from 'fs'; -// import path from 'path'; +import * as sass from "sass"; +import postcss from "postcss"; +import { promises as fs } from "fs"; +import path from "path"; -import * as sass from 'sass'; -import postcss from 'postcss'; -import { promises as fs } from 'fs'; -import path from 'path'; - - -import postcssConfigExpanded from '../config/postcss.config.expanded.js'; -import postcssConfigCompressed from '../config/postcss.config.compressed.js'; +import postcssConfigExpanded from "../config/postcss.config.expanded.js"; +import postcssConfigCompressed from "../config/postcss.config.compressed.js"; // ============================================================================ // Classes // ============================================================================ - +/** + * Class responsible for processing styles, including compiling SCSS and + * applying PostCSS transformations. It can be configured to output either + * expanded or compressed CSS, making it flexible for different environments. + */ class StyleProcessor { + /** * Processes the given CSS with PostCSS based on the provided style option. * @param css The CSS string to process. - * @param styleOption The style option, either 'expanded' or 'compressed'. + * @param styleOption The style option, either "expanded" or "compressed". * @returns Processed CSS string. */ - async processPostCSS(css: string, styleOption: 'expanded' | 'compressed') { - const config = styleOption === 'expanded' ? postcssConfigExpanded : postcssConfigCompressed; + async processPostCSS(css: string, styleOption: "expanded" | "compressed") { + const config = styleOption === "expanded" ? postcssConfigExpanded : postcssConfigCompressed; const result = await postcss(config.plugins).process(css, { from: undefined, map: { inline: false } }); return result.css; } /** * Ensures that the given directory exists. Creates it if it does not exist. - * @param dirPath - The path of the directory to check and create. + * @param dirPath The path of the directory to check and create. */ - private async ensureDirectoryExists(dirPath: string): Promise { + private async ensureDirectoryExists(dirPath: string): Promise { try { await fs.mkdir(dirPath, { recursive: true }); } catch (error) { if (error instanceof Error) { const nodeError = error as NodeJS.ErrnoException; - if (nodeError.code !== 'EEXIST') { - throw nodeError; // Rethrow if it's not a 'directory exists' error + if (nodeError.code !== "EEXIST") { + throw nodeError; // Rethrow if it"s not a "directory exists" error } } else { - throw error; // Rethrow if it's not an Error instance + throw error; // Rethrow if it"s not an Error instance } } } @@ -76,9 +60,9 @@ class StyleProcessor { * Compiles SCSS to CSS and processes it using PostCSS. * @param inputFile Path to the input SCSS file. * @param outputFile Path to the output CSS file. - * @param styleOption Style option for the output. + * @param styleOption Style option for the output, either "expanded" or "compressed". */ - async processStyles(inputFile: string, outputFile: string, styleOption: 'expanded' | 'compressed') { + async processStyles(inputFile: string, outputFile: string, styleOption: "expanded" | "compressed") { try { // Ensure the output directory exists const outputDir = path.dirname(outputFile); @@ -91,7 +75,7 @@ class StyleProcessor { const processedCss = await this.processPostCSS(result.css, styleOption); // Write the processed CSS to a file - await fs.writeFile(outputFile, processedCss, 'utf-8'); + await fs.writeFile(outputFile, processedCss, "utf-8"); // Optionally handle source maps // ... @@ -113,14 +97,14 @@ class StyleProcessor { // /** // * Processes the given CSS with PostCSS based on the provided style option. // * @param css The CSS string to process. -// * @param styleOption The style option, either 'expanded' or 'compressed'. +// * @param styleOption The style option, either "expanded" or "compressed". // * @returns Processed CSS string. // */ // async processPostCSS( // css: string, -// styleOption: 'expanded' | 'compressed' +// styleOption: "expanded" | "compressed" // ) { -// const config = styleOption === 'expanded' ? postcssConfigExpanded : postcssConfigCompressed; +// const config = styleOption === "expanded" ? postcssConfigExpanded : postcssConfigCompressed; // return postcss(config.plugins).process(css, { from: undefined, map: { inline: false } }); // } @@ -132,7 +116,7 @@ class StyleProcessor { // try { // await fsPromises.mkdir(dirPath, { recursive: true }); // } catch (error) { -// if (error.code !== 'EEXIST') { +// if (error.code !== "EEXIST") { // throw error; // } // } @@ -147,7 +131,7 @@ class StyleProcessor { // async processStyles( // inputFile: string, // outputFile: fs.PathOrFileDescriptor, -// styleOption: 'expanded' | 'compressed' +// styleOption: "expanded" | "compressed" // ) { // try { @@ -186,3 +170,18 @@ class StyleProcessor { // ============================================================================ export default StyleProcessor; + + +// ============================================================================ +// Example +// ============================================================================ + +// import StyleProcessor from "./StyleProcessor"; + +// const styleProcessor = new StyleProcessor(); +// const inputFile = "./src/styles/main.scss"; +// const outputFile = "./dist/styles/main.css"; + +// styleProcessor.processStyles(inputFile, outputFile, "compressed") +// .then(() => console.log("Styles processed successfully.")) +// .catch(error => console.error("Failed to process styles:", error)); \ No newline at end of file diff --git a/dist/ts/class/StylizedLogger.ts b/dist/ts/class/StylizedLogger.ts index fb8a6c2..c6fa2fd 100644 --- a/dist/ts/class/StylizedLogger.ts +++ b/dist/ts/class/StylizedLogger.ts @@ -1,18 +1,5 @@ // class/StylizedLogger.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. // ============================================================================ @@ -26,6 +13,11 @@ class StylizedLogger { + /** + * A utility class for stylized console logging with foreground and + * background colors. This class utilizes ANSI escape codes to provide + * colored logging functionality. + */ private styles = { reset: "\x1b[0m", fg: { @@ -50,20 +42,45 @@ class StylizedLogger { } }; - log(message: string, fgColor: keyof typeof this.styles.fg, bgColor: keyof typeof this.styles.bg = 'black'): void { - console.log(`${this.styles.fg[fgColor]}${this.styles.bg[bgColor]}%s${this.styles.reset}`, message); + /** + * Logs a message with specified foreground and background colors. + * @param message The message to log. + * @param fgColor The foreground color, selected from predefined colors. + * @param bgColor The background color, selected from predefined colors. Defaults to "black". + */ + log( + message: string, + fgColor: keyof typeof this.styles.fg, + bgColor: keyof typeof this.styles.bg = "black" + ): void { + console.log( + `${this.styles.fg[fgColor]}${this.styles.bg[bgColor]}%s${this.styles.reset}`, + message + ); } + /** + * Logs a header-styled message, commonly used for titles or important notices. + * @param message The message to log. + */ header(message: string): void { - this.log(message, 'white', 'blue'); + this.log(message, "white", "blue"); } + /** + * Logs an error-styled message, commonly used for errors or critical warnings. + * @param message The message to log. + */ error(message: string): void { - this.log(message, 'white', 'red'); + this.log(message, "white", "red"); } + /** + * Logs a body-styled message, commonly used for standard information. + * @param message The message to log. + */ body(message: string): void { - this.log(message, 'black', 'white'); + this.log(message, "black", "white"); } } @@ -73,3 +90,15 @@ class StylizedLogger { // ============================================================================ export default StylizedLogger; + + +// ============================================================================ +// Example +// ============================================================================ + +// import StylizedLogger from "./StylizedLogger"; + +// const logger = new StylizedLogger(); +// logger.header("Header: This is a header"); +// logger.error("Error: Something went wrong"); +// logger.body("Body: Here is some detailed information"); \ No newline at end of file diff --git a/dist/ts/class/SvgPackager.ts b/dist/ts/class/SvgPackager.ts index 10aa8e6..e54a485 100644 --- a/dist/ts/class/SvgPackager.ts +++ b/dist/ts/class/SvgPackager.ts @@ -1,19 +1,5 @@ // class/SvgPackager.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import @@ -31,9 +17,9 @@ import { loadConfig } from 'svgo'; // ============================================================================ /** - * Class for packaging SVG files. - * This class reads SVG files from a specified directory, optimizes them, - * and creates corresponding TypeScript files. + * Provides functionality to optimize and package SVG files into various formats. + * It reads SVG files from a specified directory, optimizes them using SVGO, + * and then outputs them as TypeScript files and JSON indexes. */ class SvgPackager { @@ -46,7 +32,9 @@ class SvgPackager { /** * Processes all SVG files in a given directory. * @param inputDirectory The directory containing SVG files to process. - * @param outputDirectory The directory where optimized SVGs will be output as TypeScript files. + * @param outputDirectory The directory where optimized SVGs will be output. + * @param tsOutputDirectory The directory where TypeScript files will be saved. + * @param jsonOutputDirectory The directory where a JSON index of icons will be saved. */ public async processSvgFiles( inputDirectory: string, @@ -58,15 +46,15 @@ class SvgPackager { const iconNames: string[] = []; try { - console.log(`Processing directory: ${inputDirectory}`); + // console.log(`Processing directory: ${inputDirectory}`); const svgFiles = glob.sync(`${inputDirectory}/**/*.svg`); for (const file of svgFiles) { - console.log(`Processing file: ${file}`); + // console.log(`Processing file: ${file}`); const iconName = this.sanitizeFileName(path.basename(file, '.svg')); iconNames.push(iconName); - console.log(`Processing icon: ${iconName}`); + // console.log(`Processing icon: ${iconName}`); const svgContent = await this.readSvgFile(file); const optimizedSvg = await this.optimizeSvg(svgContent); // const optimizedSvg = await this.optimizeSvg(file, svgContent); @@ -253,3 +241,15 @@ class SvgPackager { // ============================================================================ export default SvgPackager; + + +// ============================================================================ +// Example +// ============================================================================ + +// import SvgPackager from './SvgPackager'; + +// const packager = new SvgPackager('./config/svgo.config.js'); +// packager.processSvgFiles('./src/icons', './dist/icons', './dist/ts', './dist') +// .then(() => console.log('SVG packaging completed.')) +// .catch(error => console.error('Error packaging SVGs:', error)); \ No newline at end of file diff --git a/dist/ts/class/SvgSpriteGenerator.ts b/dist/ts/class/SvgSpriteGenerator.ts index 43bb004..7de6860 100644 --- a/dist/ts/class/SvgSpriteGenerator.ts +++ b/dist/ts/class/SvgSpriteGenerator.ts @@ -1,27 +1,13 @@ // class/SvgSpriteGenerator.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import svgSprite from 'svg-sprite'; -import fs from 'fs'; -import path from 'path'; +import svgSprite from "svg-sprite"; +import fs from "fs"; +import path from "path"; import svgspriteConfig from "../config/svgsprite.config.js" @@ -30,7 +16,9 @@ import svgspriteConfig from "../config/svgsprite.config.js" // ============================================================================ /** - * A class for generating SVG sprites from individual SVG files. + * Facilitates the generation of SVG sprites from individual SVG files. + * This class uses svg-sprite to compile multiple SVG files into a single sprite sheet, + * which is useful for efficiently managing and using graphics in web projects. */ class SvgSpriteGenerator { @@ -43,19 +31,19 @@ class SvgSpriteGenerator { /** * Configuration for the TypeScript compiler. */ - private config: svgSprite.Config; + private config: svgSprite.Config; - /** - * Default configuration for the TypeScript compiler. - */ - private static defaultConfig: svgSprite.Config = svgspriteConfig; + /** + * Default configuration for the TypeScript compiler. + */ + private static defaultConfig: svgSprite.Config = svgspriteConfig; // private static defaultConfig: CompilerOptions = tsConfig; - /** - * Constructs an instance with merged configuration of default and custom options. - * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. - */ - constructor( + /** + * Constructs an instance with a merged configuration of default settings and optional customizations. + * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. + */ + constructor( customConfig: svgSprite.Config = {}, ) { this.config = { @@ -76,9 +64,9 @@ class SvgSpriteGenerator { const sprite = new svgSprite(this.config); files.forEach(file => { - if (path.extname(file) === '.svg') { + if (path.extname(file) === ".svg") { const svgPath = path.resolve(sourceDir, file); - const content = fs.readFileSync(svgPath, 'utf8'); + const content = fs.readFileSync(svgPath, "utf8"); sprite.add(svgPath, null, content); } }); @@ -107,7 +95,7 @@ class SvgSpriteGenerator { }); } catch (err) { - console.error('Error generating SVG sprite:', err); + console.error("Error generating SVG sprite:", err); } } @@ -119,3 +107,19 @@ class SvgSpriteGenerator { // ============================================================================ export default SvgSpriteGenerator; + + +// ============================================================================ +// Example +// ============================================================================ + + +// import SvgSpriteGenerator from "./SvgSpriteGenerator"; + +// const spriteGenerator = new SvgSpriteGenerator(); +// const sourceDirectory = "path/to/source/svg/files"; +// const outputDirectory = "path/to/output/sprites"; + +// spriteGenerator.generateSprite(sourceDirectory, outputDirectory) +// .then(() => console.log("SVG sprite has been successfully generated.")) +// .catch(error => console.error("Failed to generate SVG sprite:", error)); \ No newline at end of file diff --git a/dist/ts/class/SvgToPngConverter.ts b/dist/ts/class/SvgToPngConverter.ts index 0e38d3d..57c0284 100644 --- a/dist/ts/class/SvgToPngConverter.ts +++ b/dist/ts/class/SvgToPngConverter.ts @@ -1,35 +1,36 @@ // class/SvgToPngConverter.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import sharp from 'sharp'; -import { JSDOM } from 'jsdom'; -import fs from 'fs'; -import path from 'path'; +import sharp from "sharp"; +import { JSDOM } from "jsdom"; +import fs from "fs"; +import path from "path"; // ============================================================================ // Classes // ============================================================================ +/** + * A utility class for converting SVG images to PNG format. This class uses the `sharp` library + * for image conversion and `jsdom` to manipulate SVG elements. + */ class SvgToPngConverter { + + /** + * Converts SVG content to a PNG file. + * Optionally resizes the image to the specified width and height. + * + * @param {string} svgContent The SVG content to be converted. + * @param {string} outputPath The filesystem path where the PNG should be saved. + * @param {number} [width] Optional width to resize the resulting PNG. + * @param {number} [height] Optional height to resize the resulting PNG. + * @throws {Error} Throws an error if the conversion process fails. + */ async convert( svgContent: string, outputPath: string, @@ -46,24 +47,31 @@ class SvgToPngConverter { // Create a JSDOM instance to parse the SVG const dom = new JSDOM(svgContent); - const svgElement = dom.window.document.querySelector('svg'); + const svgElement = dom.window.document.querySelector("svg"); if (!svgElement) { - throw new Error('Invalid SVG content'); + throw new Error("Invalid SVG content"); } if (width) { - svgElement.setAttribute('width', width.toString()); + svgElement.setAttribute("width", width.toString()); } if (height) { - svgElement.setAttribute('height', height.toString()); + svgElement.setAttribute("height", height.toString()); } + // Serialize the updated SVG content const updatedSvgContent = svgElement.outerHTML; - const pngBuffer = await sharp(Buffer.from(updatedSvgContent)).png().toBuffer(); - + + // Convert SVG to PNG using Sharp + const pngBuffer = await sharp( + Buffer.from(updatedSvgContent) + ).png().toBuffer(); await sharp(pngBuffer).toFile(outputPath); + + console.log(`PNG file has been saved to ${outputPath}`); + } catch (error) { console.error(`Error converting SVG to PNG: ${error}`); throw error; @@ -78,3 +86,18 @@ class SvgToPngConverter { // ============================================================================ export default SvgToPngConverter; + + +// ============================================================================ +// Example +// ============================================================================ + +// import SvgToPngConverter from "./SvgToPngConverter"; + +// const converter = new SvgToPngConverter(); +// const svgContent = "..."; +// const outputPath = "./output/image.png"; + +// converter.convert(svgContent, outputPath, 100, 100) +// .then(() => console.log("SVG has been successfully converted to PNG.")) +// .catch(error => console.error("Failed to convert SVG to PNG:", error)); diff --git a/dist/ts/class/TemplateWriter.ts b/dist/ts/class/TemplateWriter.ts index 6ce935b..8dc4684 100644 --- a/dist/ts/class/TemplateWriter.ts +++ b/dist/ts/class/TemplateWriter.ts @@ -1,27 +1,13 @@ // class/TemplateWriter.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import fs from 'fs/promises'; -import path from 'path'; -import nunjucks from 'nunjucks'; +import fs from "fs/promises"; +import path from "path"; +import nunjucks from "nunjucks"; import nunjucksConfig from "../config/nunjucks.config.js" @@ -29,6 +15,11 @@ import nunjucksConfig from "../config/nunjucks.config.js" // Classes // ============================================================================ +/** + * Class designed for rendering and writing HTML or text files from Nunjucks templates. + * It encapsulates configuration and rendering logic, making it simple to produce files + * from templates for various uses such as email templates, web pages, or configuration files. + */ class TemplateWriter { context: {}; @@ -44,8 +35,10 @@ class TemplateWriter { private static defaultConfig: any = nunjucksConfig; /** - * Constructs a TemplateWriter instance. - * @param templatesDir - Directory for Nunjucks templates. + * Constructs a TemplateWriter instance with specified settings. + * @param {string} templatesDir The directory containing Nunjucks templates. + * @param {object} context Global data object that will be available to all templates. + * @param {object} customConfig Custom configuration settings for Nunjucks. */ constructor( templatesDir: string, @@ -64,9 +57,10 @@ class TemplateWriter { } /** - * Generates a template using the provided template file and context. - * @param template - The template file name. - * @returns The rendered template as a string. + * Generates content from a Nunjucks template file. + * @param {string} template The template file name. + * @returns {Promise} The rendered template as a string. + * @throws {Error} If there is an error in rendering the template. */ async generateTemplate(template: string): Promise { try { @@ -77,14 +71,15 @@ class TemplateWriter { } catch (error) { console.error(`Error generating template: ${error}`); // throw error; - throw new Error('Template generation failed'); + throw new Error("Template generation failed"); } } /** - * Writes the rendered template content to a file. - * @param template - The template file name. - * @param outputFile - The output file path. + * Writes the rendered template content to a specified file path. + * @param {string} template The template file name. + * @param {string} outputFile The output file path where content will be written. + * @throws {Error} If there is an error in writing the file. */ async generateToFile(template: string, outputFile: string): Promise { try { @@ -93,10 +88,10 @@ class TemplateWriter { // Ensure the directory exists await fs.mkdir(dir, { recursive: true }); // Write the file - await fs.writeFile(outputFile, content, 'utf-8'); + await fs.writeFile(outputFile, content, "utf-8"); } catch (error) { console.error(`Error writing to file: ${error}`); - throw new Error('File writing failed'); + throw new Error("File writing failed"); } } @@ -108,3 +103,16 @@ class TemplateWriter { // ============================================================================ export default TemplateWriter; + + +// ============================================================================ +// Example +// ============================================================================ + + +// import TemplateWriter from "./TemplateWriter"; + +// const writer = new TemplateWriter("./path/to/templates", { name: "John Doe" }); +// writer.generateToFile("emailTemplate.njk", "./output/email.html") +// .then(() => console.log("Email template has been successfully generated and saved.")) +// .catch(error => console.error("Failed to generate email template:", error)); \ No newline at end of file diff --git a/dist/ts/class/TestRunner.ts b/dist/ts/class/TestRunner.ts index 397fe08..cf53089 100644 --- a/dist/ts/class/TestRunner.ts +++ b/dist/ts/class/TestRunner.ts @@ -1,26 +1,12 @@ // class/TestRunner.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { exec } from 'child_process'; -import util from 'util'; +import { exec } from "child_process"; +import util from "util"; const execAsync = util.promisify(exec); @@ -29,16 +15,28 @@ const execAsync = util.promisify(exec); // Classes // ============================================================================ +/** + * A utility class for running tests from Node.js applications. It simplifies the process of + * executing shell commands for testing by providing a wrapper around the child_process module. + */ class TestRunner { + private testCommand: string; + /** + * Constructs a TestRunner with a specific test command. + * @param {string} testCommand - The command used to run tests (e.g., "npm test"). + */ constructor(testCommand: string) { this.testCommand = testCommand; } /** - * Runs the tests using the specified test command. - * @returns A promise that resolves with the test results. + * Executes the test command in a child process and returns the results. + * This method captures both stdout and stderr streams, handling any errors by re-throwing them. + * + * @returns {Promise} A promise that resolves with the test results as a string if successful. + * @throws {Error} Throws an error if the test command fails or if stderr captures any error output. */ async runTests(): Promise { try { @@ -50,7 +48,7 @@ class TestRunner { return stdout; } catch (error) { - console.error('Error occurred while running tests:', error); + console.error("Error occurred while running tests:", error); throw error; } } @@ -64,18 +62,17 @@ class TestRunner { export default TestRunner; +// ============================================================================ +// Example +// ============================================================================ -// Usage Example -// Here's an example of how you might use the TestRunner class in a project: - -// import TestRunner from './TestRunner'; - -// const runner = new TestRunner('npm test'); // Replace 'npm test' with your actual test command +// import TestRunner from "./TestRunner"; +// const runner = new TestRunner("npm test"); // Replace "npm test" with your actual test command // runner.runTests() // .then(results => { -// console.log('Test Results:', results); +// console.log("Test Results:", results); // }) // .catch(error => { -// console.error('Test Runner Error:', error); -// }); +// console.error("Test Runner Error:", error); +// }); \ No newline at end of file diff --git a/dist/ts/class/TypeScriptCompiler.ts b/dist/ts/class/TypeScriptCompiler.ts index ae46da7..ce03670 100644 --- a/dist/ts/class/TypeScriptCompiler.ts +++ b/dist/ts/class/TypeScriptCompiler.ts @@ -1,26 +1,12 @@ // class/TypeScriptCompiler.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -// import * as ts from 'typescript'; -import ts from 'typescript'; +// import * as ts from "typescript"; +import ts from "typescript"; import tsConfig from "../config/ts.config.js" // type CompilerOptions = ts.CompilerOptions | Record; @@ -31,7 +17,9 @@ import tsConfig from "../config/ts.config.js" // ============================================================================ /** - * TypeScriptCompiler class for compiling TypeScript files to JavaScript. + * A utility class to compile TypeScript files into JavaScript based on configurable options. + * It leverages the TypeScript compiler API to perform the compilation, providing a flexible + * integration point for projects needing to automate their TypeScript to JavaScript builds. */ class TypeScriptCompiler { @@ -49,9 +37,8 @@ import tsConfig from "../config/ts.config.js" // private static defaultConfig: ts.CompilerOptions = tsConfig; /** - * Constructs an instance with merged configuration of default and custom options. - * @param {any} customConfig - Optional custom configuration object for TypeScript compiler - // * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler + * Initializes a new instance of the TypeScriptCompiler with optional custom configuration. + * @param customConfig Custom configuration settings for the TypeScript compiler. */ constructor( customConfig: any = {}, @@ -63,6 +50,13 @@ import tsConfig from "../config/ts.config.js" }; } + /** + * Compiles an array of TypeScript files into JavaScript. + * @param filePaths An array of paths to TypeScript files to be compiled. + * @param outDir The directory to output the compiled JavaScript files. + * @returns A promise that resolves if the compilation is successful, or rejects if it fails. + */ + // async compile( compile( filePaths: string[], outDir: string, @@ -89,25 +83,28 @@ import tsConfig from "../config/ts.config.js" const emitResult = program.emit(); // Check for compilation errors - const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + const allDiagnostics = ts.getPreEmitDiagnostics( + program + ).concat(emitResult.diagnostics); + allDiagnostics.forEach(diagnostic => { // Handle and print diagnostics if (diagnostic.file) { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); - const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { - console.error(ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')); + console.error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")); } }); const exitCode = emitResult.emitSkipped ? 1 : 0; if (exitCode === 0) { - console.log('Compilation completed successfully.'); + console.log("Compilation completed successfully."); resolve(); } else { - console.error('Compilation failed.'); - reject(new Error('TypeScript compilation failed')); + console.error("Compilation failed."); + reject(new Error("TypeScript compilation failed")); } }); } @@ -120,3 +117,18 @@ import tsConfig from "../config/ts.config.js" // ============================================================================ export default TypeScriptCompiler; + + +// ============================================================================ +// Example +// ============================================================================ + +// import TypeScriptCompiler from "./TypeScriptCompiler"; + +// const compiler = new TypeScriptCompiler({ noImplicitAny: true }); +// const filePaths = ["./src/index.ts", "./src/app.ts"]; +// const outputDirectory = "./dist"; + +// compiler.compile(filePaths, outputDirectory) +// .then(() => console.log("Compilation successful")) +// .catch(error => console.error("Compilation errors:", error)); \ No newline at end of file diff --git a/dist/ts/class/VersionManager.ts b/dist/ts/class/VersionManager.ts index 21a4afe..60f898d 100644 --- a/dist/ts/class/VersionManager.ts +++ b/dist/ts/class/VersionManager.ts @@ -1,27 +1,13 @@ // class/VersionManager.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import semver from 'semver'; -import { exec } from 'child_process'; -import util from 'util'; +import semver from "semver"; +import { exec } from "child_process"; +import util from "util"; const execAsync = util.promisify(exec); @@ -30,38 +16,62 @@ const execAsync = util.promisify(exec); // Classes // ============================================================================ +/** + * Manages software versioning using semantic versioning principles. Provides methods + * to update the version, generate changelogs, and manage version tags in source control. + */ class VersionManager { + private currentVersion: string; + /** + * Initializes the version manager with a valid semantic version. + * @param {string} currentVersion - The current semantic version. + * @throws {Error} If the initial version is not a valid semantic version. + */ constructor(currentVersion: string) { if (!semver.valid(currentVersion)) { - throw new Error('Invalid initial version'); + throw new Error("Invalid initial version"); } this.currentVersion = currentVersion; } + /** + * Updates the current version based on the specified release type. + * @param {semver.ReleaseType} releaseType - The type of version update (major, minor, patch). + * @returns {Promise} The new version. + * @throws {Error} If the version increment fails. + */ async updateVersion(releaseType: semver.ReleaseType): Promise { const newVersion = semver.inc(this.currentVersion, releaseType); if (!newVersion) { - throw new Error('Version increment failed'); + throw new Error("Version increment failed"); } this.currentVersion = newVersion; return newVersion; } + /** + * Generates a changelog based on commits since the last version. + * Placeholder function to be implemented with actual logic. + */ async generateChangelog() { // Implement changelog generation logic - // This could be as simple as running a script or using a tool like 'conventional-changelog' - console.log('Changelog generation logic goes here'); + // This could be as simple as running a script or using a tool like "conventional-changelog" + console.log("Changelog generation logic goes here"); } + /** + * Creates a new Git tag for the current version and pushes it to the remote repository. + * @throws {Error} If creating or pushing the tag fails. + */ async createGitTag() { try { await execAsync(`git tag v${this.currentVersion}`); - await execAsync('git push --tags'); + await execAsync("git push --tags"); console.log(`Tag v${this.currentVersion} created and pushed`); } catch (error) { - console.error('Error creating Git tag:', error); + console.error("Error creating Git tag:", error); throw error; } } @@ -70,17 +80,19 @@ class VersionManager { export default VersionManager; +// ============================================================================ +// Example +// ============================================================================ +// Here is an example of how you might use the VersionManager class in a project: +// import VersionManager from "./VersionManager"; -// import VersionManager from './VersionManager'; - -// const versionManager = new VersionManager('1.0.0'); // Replace '1.0.0' with the current version of your package - -// versionManager.updateVersion('minor') // 'major', 'minor', or 'patch' +// const versionManager = new VersionManager("1.0.0"); +// versionManager.updateVersion("patch") // .then(newVersion => { // console.log(`Version updated to: ${newVersion}`); -// return versionManager.generateChangelog(); +// return versionManager.createGitTag(); // }) -// .then(() => versionManager.createGitTag()) -// .catch(error => console.error(error)); +// .then(() => versionManager.generateChangelog()) +// .catch(error => console.error("Version management error:", error)); \ No newline at end of file diff --git a/dist/ts/class/VersionWriter.ts b/dist/ts/class/VersionWriter.ts index 0bf817b..a0be411 100644 --- a/dist/ts/class/VersionWriter.ts +++ b/dist/ts/class/VersionWriter.ts @@ -1,25 +1,11 @@ // class/VersionWriter.ts -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - // ============================================================================ // Import // ============================================================================ -import { promises as fs } from 'fs'; +import { promises as fs } from "fs"; // ============================================================================ @@ -27,21 +13,27 @@ import { promises as fs } from 'fs'; // ============================================================================ /** - * A class for writing version information to a file. + * A utility class for writing version information to a specified file, + * commonly used in software development for managing and tracking software + * version releases. */ - class VersionWriter { +class VersionWriter { /** - * Writes the specified version string to a file. - * @param {string} filePath - The file path where the version will be written. - * @param {string} version - The version string to write to the file. + * Writes a version string to a specified file path. This method is asynchronous + * and uses Node.js"s filesystem promises to handle the file writing operation. + * + * @param {string} filePath The file path where the version information should be written. + * @param {string} version The version string to be written to the file. + * @returns {Promise} A promise that resolves when the version has been successfully written. + * @throws {Error} Throws an error if the file writing operation fails. */ async writeVersionToFile( filePath: string, version: string, ): Promise { try { - await fs.writeFile(filePath, version, 'utf8'); + await fs.writeFile(filePath, version, "utf8"); console.log(`Version ${version} written to ${filePath}`); } catch (error) { console.error(`Error writing version to file: ${error}`); @@ -56,3 +48,21 @@ import { promises as fs } from 'fs'; // ============================================================================ export default VersionWriter; + + +// ============================================================================ +// Example +// ============================================================================ + + +// Here is an example of how you might use the VersionWriter class: + +// import VersionWriter from "./VersionWriter"; + +// const versionWriter = new VersionWriter(); +// const filePath = "./VERSION.txt"; +// const version = "1.0.3"; + +// versionWriter.writeVersionToFile(filePath, version) +// .then(() => console.log("Version information updated.")) +// .catch(error => console.error("Failed to update version information:", error)); \ No newline at end of file diff --git a/dist/ts/config/config.ts b/dist/ts/config/config.ts index 037aee0..cd858fc 100644 --- a/dist/ts/config/config.ts +++ b/dist/ts/config/config.ts @@ -1,6 +1,6 @@ // config/config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -20,26 +20,40 @@ // ============================================================================ -export const CONFIG = { - path: { - src: './src', - dist: './dist', - - svg_input: './src/svg', - svg_output: './dist/svg', - sprite_input: './dist/svg', - sprite_output: './dist/sprite', - font_input: './dist/svg', - font_output: './dist/font', - scss_input: './src/scss', - scss_output: './dist/scss', - css_output: './dist/css', - json_output: './dist', - ts_input: './src/ts', - ts_output: './dist/ts', - ts_output_icons: './src/ts/icons', - js_output: './dist/js', +// ============================================================================ +// Constants +// ============================================================================ +/** + * Central configuration object for managing paths used across various build and development processes. + * This object helps in routing inputs and outputs to correct locations, ensuring a seamless build experience. + */ +const CONFIG = { + path: { + src: './src', // Source directory for raw files + dist: './dist', // Distribution directory for built files + + svg_input: './src/svg', // Input directory for SVG files + svg_output: './dist/svg', // Output directory for processed SVG files + sprite_input: './dist/svg', // Input directory for generating sprites + sprite_output: './dist/sprite', // Output directory for generated sprites + font_input: './dist/svg', // Input directory for font generation + font_output: './dist/font', // Output directory for generated fonts + scss_input: './src/scss', // Input directory for SCSS files + scss_output: './dist/scss', // Output directory for compiled SCSS files + css_output: './dist/css', // Output directory for final CSS files + json_output: './dist', // Directory for output JSON files + ts_input: './src/ts', // Input directory for TypeScript files + ts_output: './dist/ts', // Output directory for compiled TypeScript files + ts_output_icons: './src/ts/icons', // Output directory for TypeScript icon components + js_output: './dist/js', // Output directory for JavaScript files }, -}; \ No newline at end of file +}; + + +// ============================================================================ +// Export +// ============================================================================ + +export default CONFIG; diff --git a/dist/ts/config/fantasticon.config.ts b/dist/ts/config/fantasticon.config.ts index e939dc5..509f46a 100644 --- a/dist/ts/config/fantasticon.config.ts +++ b/dist/ts/config/fantasticon.config.ts @@ -1,6 +1,6 @@ // config/fantasticon.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,14 +19,24 @@ // Import // ============================================================================ +import { + // generateFonts, + FontAssetType, + OtherAssetType, + // RunnerOptions, + // RunnerOptionalOptions, +} from 'fantasticon'; -import { generateFonts, FontAssetType, OtherAssetType, RunnerOptions, } from 'fantasticon'; -import RunnerOptionalOptions from 'fantasticon'; +// ============================================================================ +// Constants +// ============================================================================ +// Configuration for the Fantasticon tool to generate icon fonts from SVG files. const fantasticonConfig: any = { // RunnerOptionalOptions + // Basic naming and type setup for font generation name: 'icon', fontTypes: [ FontAssetType.TTF, // TTF = "ttf" @@ -105,6 +115,9 @@ const fantasticonConfig: any = { }; +// ============================================================================ +// Export +// ============================================================================ export default fantasticonConfig; diff --git a/dist/ts/config/nunjucks.config.ts b/dist/ts/config/nunjucks.config.ts index d55dc88..dbaca21 100644 --- a/dist/ts/config/nunjucks.config.ts +++ b/dist/ts/config/nunjucks.config.ts @@ -1,6 +1,6 @@ // config/nunjucks.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ // Import // ============================================================================ +// Importing path for potential future use in specifying template directories or other file paths import path from 'node:path' @@ -26,6 +27,11 @@ import path from 'node:path' // Constants // ============================================================================ +/** + * Configuration options for Nunjucks to ensure safe and efficient template rendering. + * This setup is ideal for both development and production environments, providing a balance + * between performance optimizations and security best practices. + */ const nunjucksConfig = { autoescape: true, // Controls if output with dangerous characters are escaped automatically @@ -42,3 +48,11 @@ const nunjucksConfig = { // ============================================================================ export default nunjucksConfig; + + +// ============================================================================ +// Notes +// ============================================================================ + +// This configuration is tailored to a typical web application setup. Adjust the `noCache` option +// according to your caching strategy for production environments to optimize performance. \ No newline at end of file diff --git a/dist/ts/config/package.config.ts b/dist/ts/config/package.config.ts index b777f2f..a9ff6ab 100644 --- a/dist/ts/config/package.config.ts +++ b/dist/ts/config/package.config.ts @@ -1,6 +1,6 @@ // config/package.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,6 +19,10 @@ // Constants // ============================================================================ +/** + * Configuration object for package.json properties, used to define metadata, + * file inclusions, and other necessary project configurations. + */ const packageConfig = { name: "", version: "", @@ -63,6 +67,13 @@ const packageConfig = { "ts/**/*.ts", "!.DS_Store" ], + exports: { + ".": { + "sass": "./src/scss/index.scss", + "import": "./dist/js/index.mjs", + "default": "./dist/js/index.js" + } + } // repository: { // type: pack.repository.type, // url: pack.repository.url, diff --git a/dist/ts/config/postcss.config.compressed.ts b/dist/ts/config/postcss.config.compressed.ts index 151beb2..7f634ea 100644 --- a/dist/ts/config/postcss.config.compressed.ts +++ b/dist/ts/config/postcss.config.compressed.ts @@ -1,6 +1,6 @@ // config/postcss.config.compressed.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,23 +19,25 @@ // Import // ============================================================================ -import autoprefixer from 'autoprefixer'; -import cssnano from 'cssnano'; +import autoprefixer from 'autoprefixer'; // Handles CSS vendor prefixing automatically +import cssnano from 'cssnano'; // A PostCSS plugin for CSS minimization // ============================================================================ // Constants // ============================================================================ +/** + * Configuration object for PostCSS that includes plugins for optimization and compression + * of CSS. This setup is typically used for production builds where minimized CSS is preferred + * to reduce file size and improve loading times. + */ const postcssConfigCompressed = { plugins: [ - autoprefixer, - // Minification for compressed output - cssnano( - { - preset: 'default' - }, - ), + autoprefixer, // Automatically adds vendor prefixes to CSS rules + cssnano({ // Compresses CSS output + preset: 'default' // Uses the default settings for compression + }), ] }; diff --git a/dist/ts/config/postcss.config.expanded.ts b/dist/ts/config/postcss.config.expanded.ts index c4c1d3f..63e1dc8 100644 --- a/dist/ts/config/postcss.config.expanded.ts +++ b/dist/ts/config/postcss.config.expanded.ts @@ -1,6 +1,6 @@ // config/postcss.config.expanded.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,19 +19,36 @@ // Import // ============================================================================ -import autoprefixer from 'autoprefixer'; +import autoprefixer from 'autoprefixer'; // Automatically adds vendor prefixes to CSS rules import cssnano from 'cssnano'; +// import postcssSimpleVars from 'postcss-simple-vars'; // Plugin to handle CSS variables +// import postcssNested from 'postcss-nested'; // Plugin to allow nesting of CSS rules +// import postcssImport from 'postcss-import'; // Plugin to inline import CSS files into a single CSS // ============================================================================ // Constants // ============================================================================ +/** + * Configuration object for PostCSS that focuses on generating expanded, readable CSS + * for development environments. Includes plugins that enhance CSS handling like nesting, + * variable support, and import inlining, alongside autoprefixer for browser compatibility. + */ const postcssConfigExpanded = { plugins: [ autoprefixer, // Include other plugins suited for the expanded output ] + // plugins: [ + // postcssImport(), // Allows importing of other CSS files within a CSS file + // autoprefixer(), // Adds vendor prefixes to CSS, using data from Can I Use + // postcssSimpleVars(), // Enables the use of Sass-like variables in CSS + // postcssNested(), // Process nested rules, which is similar to how Sass handles nesting + // // cssnano({ + // // preset: 'default', // Optionally include for light compression or reformatting + // // }), + // ] }; @@ -40,3 +57,11 @@ const postcssConfigExpanded = { // ============================================================================ export default postcssConfigExpanded; + + +/** + * Note: This configuration is intended for development use where extended readability + * and ease of debugging are critical. The cssnano plugin is commented out by default + * to keep the output CSS as clean and readable as possible; it can be enabled for + * environments that require slightly more optimized output without full minification. + */ \ No newline at end of file diff --git a/dist/ts/config/svgo.config.ts b/dist/ts/config/svgo.config.ts index 436060e..fea0e03 100644 --- a/dist/ts/config/svgo.config.ts +++ b/dist/ts/config/svgo.config.ts @@ -1,6 +1,6 @@ // config/svgo.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,13 +26,17 @@ import path from 'node:path' // Constants // ============================================================================ +/** + * Configuration for optimizing SVG files using SVGO. + * It includes multiple passes to ensure thorough optimization and custom plugins for specific attribute management. + */ const svgoConfig = { - multipass: true, + multipass: true, // Optimize SVG files multiple times until no further optimizations can be made. js2svg: { - pretty: true, - indent: 2, - eol: 'lf' + pretty: true, // Make output more readable by formatting it. + indent: 2, // Number of spaces used for indentation of the resulting SVG file. + eol: 'lf' // End of line character, use 'lf' for UNIX-style line endings. }, plugins: [ { @@ -41,31 +45,28 @@ const svgoConfig = { overrides: { removeUnknownsAndDefaults: { // remove all `data` attributes - keepDataAttrs: false, + keepDataAttrs: false, // Do not keep data-* attributes since they are often not needed for display. // keep the `role` attribute - keepRoleAttr: true, + keepRoleAttr: true // Keep role attributes to maintain accessibility. }, // keep the `viewBox` attribute - removeViewBox: false, + removeViewBox: false, // Do not remove the viewBox attribute which is important for scaling. // customize the params of a default plugin inlineStyles: { - onlyMatchedOnce: false, + onlyMatchedOnce: false, // Apply styles even if matching elements occur more than once. } } } }, // The next plugins are included in svgo but are not part of preset-default, // so we need to explicitly enable them - 'cleanupListOfValues', + 'cleanupListOfValues', // Clean up values in attributes that take a list of numbers (like viewBox or enable-background). { name: 'removeAttrs', params: { - attrs: [ - 'clip-rule', - 'fill' - ] + attrs: ['clip-rule', 'fill'] // Remove these attributes as they are often unnecessary and can be controlled via CSS. } }, // Custom plugin which resets the SVG attributes to explicit values @@ -77,9 +78,9 @@ const svgoConfig = { xmlns: 'http://www.w3.org/2000/svg', width: '16', height: '16', - fill: 'currentColor', - class: '', // We replace the class with the correct one based on filename later - viewBox: '0 0 16 16' + fill: 'currentColor', // Use 'currentColor' to allow SVG color to be specified by the color of the text. + class: '', // Base class attribute which will be extended dynamically. + viewBox: '0 0 16 16' // Default viewBox for all icons. } }, fn(_root: any, params: { attributes: { [s: string]: unknown; } | ArrayLike; }, info: { path: string; }) { diff --git a/dist/ts/config/svgsprite.config.ts b/dist/ts/config/svgsprite.config.ts index c459206..645c1a5 100644 --- a/dist/ts/config/svgsprite.config.ts +++ b/dist/ts/config/svgsprite.config.ts @@ -1,6 +1,6 @@ // config/svg-sprite.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dist/ts/config/terser.config.ts b/dist/ts/config/terser.config.ts index 85df357..b417318 100644 --- a/dist/ts/config/terser.config.ts +++ b/dist/ts/config/terser.config.ts @@ -1,6 +1,6 @@ // config/terser.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dist/ts/config/ts.config.ts b/dist/ts/config/ts.config.ts index 32ead00..a7ae661 100644 --- a/dist/ts/config/ts.config.ts +++ b/dist/ts/config/ts.config.ts @@ -1,6 +1,6 @@ // config/ts.config.ts -// Copyright 2023 Scape Agency BV +// Copyright 2024 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/dist/ts/function/clean_directory.ts b/dist/ts/function/clean_directory.ts index 39c7196..f4b887a 100644 --- a/dist/ts/function/clean_directory.ts +++ b/dist/ts/function/clean_directory.ts @@ -1,4 +1,4 @@ -// config/fantasticon.config.ts +// function/clean_directory.ts // Copyright 2023 Scape Agency BV @@ -27,6 +27,7 @@ import StylizedLogger from '../class/StylizedLogger.js'; // Constants // ============================================================================ +// Create instances of DirectoryCleaner and StylizedLogger const directoryCleaner = new DirectoryCleaner(); const logger = new StylizedLogger(); @@ -36,8 +37,11 @@ const logger = new StylizedLogger(); // ============================================================================ /** - * Cleans a specified directory and logs the process. - * @param directoryPath - The path of the directory to clean. + * Cleans the specified directory and logs the operation. + * This function is asynchronous and will log details about the cleaning process, + * including any errors that occur. + * + * @param directoryPath - The file system path to the directory to be cleaned. */ async function cleanDirectory(directoryPath: string): Promise { try { @@ -58,7 +62,10 @@ async function cleanDirectory(directoryPath: string): Promise { export default cleanDirectory; -// Usage example -// cleanAndLogDirectory(CONFIG.path.dist) -// .then(() => console.log('Directory cleaning completed.')) -// .catch(error => console.error(error)); +// ============================================================================ +// Example +// ============================================================================ + +// cleanDirectory('path/to/directory') +// .then(() => console.log('Directory cleaning completed successfully.')) +// .catch(error => console.error('Directory cleaning failed:', error)); \ No newline at end of file diff --git a/dist/ts/function/gl_installer.ts b/dist/ts/function/gl_installer.ts index 7881f44..5f0205a 100644 --- a/dist/ts/function/gl_installer.ts +++ b/dist/ts/function/gl_installer.ts @@ -1,4 +1,4 @@ -// function/SvgPackager.ts +// function/gl_installer.ts // Copyright 2023 Scape Agency BV @@ -78,3 +78,10 @@ async function gl_installer() { // ============================================================================ export default gl_installer; + + +// ============================================================================ +// Example +// ============================================================================ + +// gl_installer().catch(error => console.error('Installation process encountered an error:', error)); diff --git a/dist/ts/function/readPackageJson.ts b/dist/ts/function/readPackageJson.ts index 60201d4..eb4f53c 100644 --- a/dist/ts/function/readPackageJson.ts +++ b/dist/ts/function/readPackageJson.ts @@ -28,15 +28,34 @@ import path from 'path'; // ============================================================================ /** - * Reads and parses the package.json file. - * @param packageJsonPath - The path to the package.json file. - * @returns The parsed package.json object. + * Reads and parses the package.json file located at the specified path. + * This function is designed to handle errors gracefully, such as file not found or JSON parsing errors. + * + * @param packageJsonPath - The relative or absolute path to the package.json file. + * @returns {Promise} A promise that resolves to the parsed JSON object from the package.json file. + * @throws {Error} Throws an error if the file cannot be read or if the content is not valid JSON. */ -async function readPackageJson(packageJsonPath: string) { - const fullPath = path.resolve(packageJsonPath); - const fileContent = await fs.readFile(fullPath, 'utf-8'); - return JSON.parse(fileContent); +async function readPackageJson(packageJsonPath: string): Promise { + try { + const fullPath = path.resolve(packageJsonPath); // Ensures the path is absolute + const fileContent = await fs.readFile(fullPath, 'utf-8'); + return JSON.parse(fileContent); + } catch (error) { + // Customize error message based on the error type + if (error.code === 'ENOENT') { + throw new Error(`The file at ${packageJsonPath} was not found.`); + } else if (error instanceof SyntaxError) { + throw new Error(`Error parsing JSON from ${packageJsonPath}: ${error.message}`); + } else { + throw new Error(`An unexpected error occurred while reading ${packageJsonPath}: ${error.message}`); + } + } } +// async function readPackageJson(packageJsonPath: string) { +// const fullPath = path.resolve(packageJsonPath); +// const fileContent = await fs.readFile(fullPath, 'utf-8'); +// return JSON.parse(fileContent); +// } // ============================================================================ @@ -44,3 +63,17 @@ async function readPackageJson(packageJsonPath: string) { // ============================================================================ export default readPackageJson; + + +// ============================================================================ +// Example +// ============================================================================ + +// (async () => { +// try { +// const packageJson = await readPackageJson('./path/to/package.json'); +// console.log('Package JSON:', packageJson); +// } catch (error) { +// console.error('Failed to read package.json:', error); +// } +// })(); \ No newline at end of file diff --git a/dist/ts/index.ts b/dist/ts/index.ts index 8357035..79c1d9c 100644 --- a/dist/ts/index.ts +++ b/dist/ts/index.ts @@ -1,20 +1,3 @@ -// index.ts - -// Copyright 2023 Scape Agency BV - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - // ============================================================================ // Import // ============================================================================ @@ -42,7 +25,7 @@ import NpmCommandRunner from './class/NpmCommandRunner.js'; import StylizedLogger from './class/StylizedLogger.js'; import TemplateWriter from './class/TemplateWriter.js'; -import SvgReader from './class/SvgReader.js'; +import SvgReader from './class/SVGReader.js'; import SvgToPngConverter from './class/SvgToPngConverter.js'; import SvgSpriteGenerator from "./class/SvgSpriteGenerator.js"; import SvgPackager from "./class/SvgPackager.js"; diff --git a/dist/ts/interface/File.ts b/dist/ts/interface/File.ts index dde876f..378f5f9 100644 --- a/dist/ts/interface/File.ts +++ b/dist/ts/interface/File.ts @@ -19,7 +19,23 @@ // Interfaces // ============================================================================ +/** + * Interface for representing a file within the system. + * This interface is used to define the structure of file data objects + * that include both the file path and its source content. + */ export interface File { + + /** + * The full path to the file. + * This should include the complete directory path and the file name with its extension. + */ filepath: string; + + /** + * The source content of the file. + * This could be any form of text, such as code, configuration, or plain text. + */ source: string; + } \ No newline at end of file diff --git a/dist/ts/interface/PackageJson.ts b/dist/ts/interface/PackageJson.ts index af07a3c..0700884 100644 --- a/dist/ts/interface/PackageJson.ts +++ b/dist/ts/interface/PackageJson.ts @@ -15,73 +15,88 @@ // limitations under the License. +// ============================================================================ +// Import +// ============================================================================ + +// import { Record, string, optional, array, union } from 'runtypes'; + + // ============================================================================ // Interfaces // ============================================================================ +/** + * TypeScript interface describing the structure of a package.json file. + * This interface includes all standard fields used by npm, as well as common fields + * used by related tools like Yarn, and can be extended with custom fields as needed. + */ export interface PackageJson { - name: string; - version: string; - description?: string; - main?: string; - scripts?: Record; - dependencies?: Record; - devDependencies?: Record; - repository?: { + + name: string; // The name of the package. + version: string; // The version of the package. + description?: string; // A brief description of the package. + main?: string; // The entry point for the package. + scripts?: Record; // Scripts that can be executed with npm/yarn. + dependencies?: Record; // Production dependencies of the package. + devDependencies?: Record; // Development dependencies of the package. + repository?: { // Repository information for the package. type: string; url: string; }; - keywords?: string[]; - author?: string | { + keywords?: string[]; // Keywords associated with the package. + author?: string | { // The author of the package. name: string; email?: string; url?: string; }; - license?: string; - bugs?: { + license?: string; // The license under which the package is provided. + bugs?: { // Links to the package bug tracker. url?: string; email?: string; }; - homepage?: string; - private?: boolean; - peerDependencies?: Record; - engines?: { + homepage?: string; // The URL to the homepage of the package. + private?: boolean; // Indicates if the package should be published. + peerDependencies?: Record; // Peer dependencies of the package. + engines?: { // Engine requirements for the package. node?: string; npm?: string; }; - bin?: Record; - types?: string; - contributors?: Array; // Executable files included with the package. + types?: string; // Path to the TypeScript declaration files. + contributors?: Array; - funding?: string | { + funding?: string | { // Funding information for the package. type: string; url: string; }; - files?: string[]; - browserslist?: string[] | Record; - publishConfig?: Record; - config?: Record; - typings?: string; - exports?: Record; - module?: string; - sideEffects?: boolean | string[]; + files?: string[]; // An array of file patterns included in the package. + browserslist?: string[] | Record; // Target browsers/environments for tools like Babel. + publishConfig?: Record; // Configuration for publishing the package. + config?: Record; // Configuration parameters used in scripts. + typings?: string; // Alternative to "types", path to TypeScript declaration files. + exports?: Record; // Define export map for submodules and conditions. + module?: string; // Specify an ES module entry point. + sideEffects?: boolean | string[]; // Indicate which modules in the package have side effects. - optionalDependencies?: Record; - bundledDependencies?: string[]; // or bundleDependencies - peerDependenciesMeta?: Record; - resolutions?: Record; - workspaces?: string[] | { + optionalDependencies?: Record; // Optional dependencies. + bundledDependencies?: string[]; // Dependencies to be bundled with the package. + peerDependenciesMeta?: Record; // Metadata for peer dependencies. + resolutions?: Record; // Dependency resolution hints for yarn. + workspaces?: string[] | { // Workspace configuration for managing multiple packages. packages: string[]; }; - eslintConfig?: Record; - babel?: Record; - prettier?: Record; - husky?: Record; - jest?: Record; - enginesStrict?: boolean; - os?: string[]; - cpu?: string[]; + eslintConfig?: Record; // ESLint configuration embedded in package.json. + babel?: Record; // Babel configuration embedded in package.json. + prettier?: Record; // Prettier configuration embedded in package.json. + husky?: Record; // Husky configuration for Git hooks. + jest?: Record; // Jest configuration for unit tests. + enginesStrict?: boolean; // Enforce engine requirements strictly. + os?: string[]; // Specify OS compatibility. + cpu?: string[]; // Specify CPU architecture compatibility. + + } diff --git a/dist/ts/interface/SVG.ts b/dist/ts/interface/SVG.ts index f5b948e..06e6607 100644 --- a/dist/ts/interface/SVG.ts +++ b/dist/ts/interface/SVG.ts @@ -20,12 +20,67 @@ // ============================================================================ -// Assuming the structure of your SVG object, you might need to adjust these types + +// export interface Svg { +// metadata: { +// name: string; +// // ... other metadata properties +// }; +// source: string; +// // ... other Svg properties +// } + + +/** + * Represents the metadata associated with an SVG graphic. + */ + interface SvgMetadata { + name: string; // The name of the SVG graphic. + creator?: string; // Optional creator of the SVG graphic. + description?: string; // Optional description of the SVG graphic. + license?: string; // Optional license information for the SVG graphic. +} + +/** + * Represents an SVG (Scalable Vector Graphics) object. + */ export interface Svg { + metadata: SvgMetadata; // Metadata associated with the SVG. + source: string; // The SVG content as a string. + width?: number; // Optional width of the SVG graphic. + height?: number; // Optional height of the SVG graphic. + viewBox?: string; // Optional 'viewBox' attribute that defines the position and dimension, in user space, of an SVG viewport. + paths?: SvgPath[]; // Optional array of path data (for more detailed manipulation or data extraction). +} + +/** + * Represents the path element within an SVG, detailing its specific properties. + */ +interface SvgPath { + d: string; // Path data (the "d" attribute). + fill?: string; // Optional fill color. + stroke?: string; // Optional stroke color. + strokeWidth?: number; // Optional stroke width. +} + +/** + * Example usage of the Svg interface. + */ +const exampleSvg: Svg = { metadata: { - name: string; - // ... other metadata properties - }; - source: string; - // ... other Svg properties -} \ No newline at end of file + name: "Example SVG", + creator: "Example Creator", + description: "A sample SVG file", + license: "MIT" + }, + source: '...', + width: 100, + height: 100, + viewBox: "0 0 100 100", + paths: [{ + d: "M10 10 H 90 V 90 H 10 L 10 10", + fill: "none", + stroke: "black", + strokeWidth: 2 + }] +}; \ No newline at end of file