diff --git a/dist/js/class/DirectoryCleaner.js b/dist/js/class/DirectoryCleaner.js index 7e72c80..a5766f2 100644 --- a/dist/js/class/DirectoryCleaner.js +++ b/dist/js/class/DirectoryCleaner.js @@ -18,8 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // Import // ============================================================================ // import { promises as fsPromises } from 'fs'; -const path_1 = __importDefault(require("path")); -const fs_1 = __importDefault(require("fs")); +var path_1 = __importDefault(require("path")); +var fs_1 = __importDefault(require("fs")); // ============================================================================ // Classes // ============================================================================ diff --git a/dist/js/class/DirectoryCopier.js b/dist/js/class/DirectoryCopier.js index 123807e..b3ef303 100644 --- a/dist/js/class/DirectoryCopier.js +++ b/dist/js/class/DirectoryCopier.js @@ -1,14 +1,5 @@ "use strict"; // class/DirectoryCopier.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const path_1 = __importDefault(require("path")); -const fs_1 = require("fs"); +var path_1 = __importDefault(require("path")); +var fs_1 = require("fs"); // ============================================================================ // Classes // ============================================================================ @@ -41,37 +32,33 @@ class DirectoryCopier { * @param destDir The destination directory path. * @throws Will throw an error if copying fails for any file or directory. */ - copyFiles(srcDir, destDir) { - return __awaiter(this, void 0, void 0, function* () { - try { - const resolvedSrcDir = path_1.default.resolve(srcDir); - const resolvedDestDir = path_1.default.resolve(destDir); - yield this.recursiveCopy(resolvedSrcDir, resolvedDestDir); - console.log(`Files copied from ${resolvedSrcDir} to ${resolvedDestDir}`); - } - catch (error) { - console.error('Error copying files:', error); - throw error; - } - }); + 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. */ - recursiveCopy(srcDir, destDir) { - return __awaiter(this, void 0, void 0, function* () { - yield fs_1.promises.mkdir(destDir, { recursive: true }); - const entries = yield 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() ? - yield this.recursiveCopy(srcPath, destPath) : - yield fs_1.promises.copyFile(srcPath, destPath); - } - }); + 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); + } } } // ============================================================================ diff --git a/dist/js/class/DirectoryCreator.js b/dist/js/class/DirectoryCreator.js index 87bb1d7..cc2f63c 100644 --- a/dist/js/class/DirectoryCreator.js +++ b/dist/js/class/DirectoryCreator.js @@ -1,14 +1,5 @@ "use strict"; // class/DirectoryGenerator.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fs_1 = require("fs"); -const path_1 = __importDefault(require("path")); +var fs_1 = require("fs"); +var path_1 = __importDefault(require("path")); // ============================================================================ // Classes // ============================================================================ @@ -46,20 +37,18 @@ class DirectoryCreator { * available before performing file operations. * @throws Will throw an error if directory creation fails. */ - createDirectories(basePath, directories) { - return __awaiter(this, void 0, void 0, function* () { - try { - for (const dir of directories) { - const dirPath = path_1.default.join(basePath, dir); - yield 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; + 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; + } } } // ============================================================================ diff --git a/dist/js/class/FileCopier.js b/dist/js/class/FileCopier.js index ac4d1af..b4f7f8d 100644 --- a/dist/js/class/FileCopier.js +++ b/dist/js/class/FileCopier.js @@ -1,14 +1,5 @@ "use strict"; // class/FileCopier.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fs_1 = __importDefault(require("fs")); -const path_1 = __importDefault(require("path")); +var fs_1 = __importDefault(require("fs")); +var path_1 = __importDefault(require("path")); // ============================================================================ // Classes // ============================================================================ @@ -41,19 +32,17 @@ class FileCopier { * @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, destDir) { - return __awaiter(this, void 0, void 0, function* () { - try { - const fileName = path_1.default.basename(srcFile); - const destFilePath = path_1.default.join(destDir, fileName); - yield 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; - } - }); + 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; + } } } // ============================================================================ diff --git a/dist/js/class/FileRenamer.js b/dist/js/class/FileRenamer.js index 94e67e1..d4607c5 100644 --- a/dist/js/class/FileRenamer.js +++ b/dist/js/class/FileRenamer.js @@ -1,14 +1,5 @@ "use strict"; // class/FileRenamer.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -26,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fs_1 = __importDefault(require("fs")); +var fs_1 = __importDefault(require("fs")); // ============================================================================ // Classes // ============================================================================ @@ -40,17 +31,15 @@ class FileRenamer { * @param targetPath The new path of the file after renaming. * @returns Promise */ - renameFile(srcPath, targetPath) { - return __awaiter(this, void 0, void 0, function* () { - try { - yield 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; - } - }); + 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; + } } } // ============================================================================ diff --git a/dist/js/class/FontGenerator.js b/dist/js/class/FontGenerator.js index ea32783..007146a 100644 --- a/dist/js/class/FontGenerator.js +++ b/dist/js/class/FontGenerator.js @@ -1,14 +1,5 @@ "use strict"; // class/FontGenerator.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); // Copyright 2023 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,98 +14,76 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fantasticon_1 = require("fantasticon"); +var fantasticon_1 = require("fantasticon"); // ============================================================================ // Classes // ============================================================================ class FontGenerator { - generateFonts(sourceDirectory, outputDiectory) { - return __awaiter(this, void 0, void 0, function* () { - const config = { - // RunnerMandatoryOptions - inputDir: sourceDirectory, // (required) - outputDir: outputDiectory, // (required) - // RunnerOptionalOptions - name: 'icon.gl', - 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']`) - // 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, + async generateFonts(sourceDirectory, outputDiectory) { + const config = { + // RunnerMandatoryOptions + inputDir: sourceDirectory, // (required) + outputDir: outputDiectory, // (required) + // RunnerOptionalOptions + name: 'icon.gl', + 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: '...' // }, - // 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' - }; - try { - yield (0, fantasticon_1.generateFonts)(config); - console.log('Fonts generated successfully.'); - } - catch (error) { - console.error('Error generating fonts:', error); - } - }); + // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; + // svg?: SvgOptions; // type SvgOptions = Omit; + json: { indent: 4 } + }, + 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' + }; + try { + await (0, fantasticon_1.generateFonts)(config); + console.log('Fonts generated successfully.'); + } + catch (error) { + console.error('Error generating fonts:', error); + } } } // ============================================================================ diff --git a/dist/js/class/JavaScriptMinifier.js b/dist/js/class/JavaScriptMinifier.js index 142a5dd..1e09568 100644 --- a/dist/js/class/JavaScriptMinifier.js +++ b/dist/js/class/JavaScriptMinifier.js @@ -1,14 +1,5 @@ "use strict"; // class/JavaScriptMinifier.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); // Copyright 2023 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,8 +14,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const terser_1 = require("terser"); -const fs_1 = require("fs"); +var terser_1 = require("terser"); +var fs_1 = require("fs"); // ============================================================================ // Classes // ============================================================================ @@ -45,27 +36,25 @@ class JavaScriptMinifier { * @param {string} outputPath - Path to save the minified output file. * @returns {Promise} - A promise that resolves when minification is complete. */ - minifyFile(inputPath, outputPath) { - return __awaiter(this, void 0, void 0, function* () { - try { - // Read the input file - const inputCode = yield fs_1.promises.readFile(inputPath, 'utf8'); - // Minify the file using Terser - // const result = await minify(inputCode, options); - const result = yield (0, terser_1.minify)(inputCode, this.config); - // If minification is successful, write the output - if (result.code) { - yield fs_1.promises.writeFile(outputPath, result.code); - } - else { - throw new Error('Minification resulted in empty output.'); - } + 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 minify(inputCode, options); + 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); } - catch (error) { - console.error(`Error minifying JavaScript file ${inputPath}:`, error); - throw error; + else { + throw new Error('Minification resulted in empty output.'); } - }); + } + catch (error) { + console.error(`Error minifying JavaScript file ${inputPath}:`, error); + throw error; + } } } // ============================================================================ diff --git a/dist/js/class/NpmCommandRunner.js b/dist/js/class/NpmCommandRunner.js index 9e5e79e..74078df 100644 --- a/dist/js/class/NpmCommandRunner.js +++ b/dist/js/class/NpmCommandRunner.js @@ -1,7 +1,7 @@ "use strict"; // TypeScript Class to Run NPM Commands Object.defineProperty(exports, "__esModule", { value: true }); -const child_process_1 = require("child_process"); +var child_process_1 = require("child_process"); class NpmCommandRunner { /** * Executes an npm command. diff --git a/dist/js/class/PackageCreator.js b/dist/js/class/PackageCreator.js index 06b11ab..51e802f 100644 --- a/dist/js/class/PackageCreator.js +++ b/dist/js/class/PackageCreator.js @@ -1,14 +1,5 @@ "use strict"; // class/PackageCreator.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -26,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fs_1 = __importDefault(require("fs")); -const path_1 = __importDefault(require("path")); +var fs_1 = __importDefault(require("fs")); +var path_1 = __importDefault(require("path")); // ============================================================================ // Classes // ============================================================================ @@ -46,13 +37,11 @@ class PackageCreator { * Creates a package.json file in the specified directory. * @param {string} outputDir - The directory where package.json will be created. */ - createPackageJson(outputDir) { - return __awaiter(this, void 0, void 0, function* () { - const filePath = path_1.default.join(outputDir, 'package.json'); - const data = JSON.stringify(this.packageJson, null, 2); - fs_1.default.writeFileSync(filePath, data, 'utf-8'); - console.log(`package.json created at ${filePath}`); - }); + async createPackageJson(outputDir) { + const filePath = path_1.default.join(outputDir, 'package.json'); + const data = JSON.stringify(this.packageJson, null, 2); + fs_1.default.writeFileSync(filePath, data, 'utf-8'); + console.log(`package.json created at ${filePath}`); } } // ============================================================================ diff --git a/dist/js/class/StyleProcessor.js b/dist/js/class/StyleProcessor.js index 1370acc..af41c47 100644 --- a/dist/js/class/StyleProcessor.js +++ b/dist/js/class/StyleProcessor.js @@ -23,15 +23,6 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -49,11 +40,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const sass = __importStar(require("sass")); -const postcss_1 = __importDefault(require("postcss")); -const fs_1 = __importDefault(require("fs")); -const postcss_config_expanded_js_1 = __importDefault(require("../config/postcss.config.expanded.js")); -const postcss_config_compressed_js_1 = __importDefault(require("../config/postcss.config.compressed.js")); +var sass = __importStar(require("sass")); +var postcss_1 = __importDefault(require("postcss")); +var fs_1 = __importDefault(require("fs")); +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 // ============================================================================ @@ -68,11 +59,9 @@ class StyleProcessor { * @param styleOption The style option, either 'expanded' or 'compressed'. * @returns Processed CSS string. */ - processPostCSS(css, styleOption) { - return __awaiter(this, void 0, void 0, function* () { - const config = styleOption === 'expanded' ? postcss_config_expanded_js_1.default : postcss_config_compressed_js_1.default; - return (0, postcss_1.default)(config.plugins).process(css, { from: undefined, map: { inline: false } }); - }); + async processPostCSS(css, styleOption) { + const config = styleOption === 'expanded' ? postcss_config_expanded_js_1.default : postcss_config_compressed_js_1.default; + return (0, postcss_1.default)(config.plugins).process(css, { from: undefined, map: { inline: false } }); } /** * Compiles SCSS to CSS and processes it using PostCSS. @@ -80,25 +69,23 @@ class StyleProcessor { * @param outputFile Path to the output CSS file. * @param styleOption Style option for the output. */ - processStyles(inputFile, outputFile, styleOption) { - return __awaiter(this, void 0, void 0, function* () { - try { - // Compile SCSS to CSS - const result = yield sass.compileAsync(inputFile, { style: styleOption }); - // Process the compiled CSS with PostCSS and Autoprefixer - const processed = yield this.processPostCSS(result.css, styleOption); - // Write the processed CSS to a file - fs_1.default.writeFileSync(outputFile, processed.css); - // Write the source map file - if (processed.map) { - fs_1.default.writeFileSync(`${outputFile}.map`, processed.map.toString()); - } - } - catch (err) { - // Handle errors in the compilation or processing - console.error(`Error processing styles from ${inputFile}:`, err); + async processStyles(inputFile, outputFile, styleOption) { + try { + // 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_1.default.writeFileSync(outputFile, processed.css); + // Write the source map file + if (processed.map) { + fs_1.default.writeFileSync(`${outputFile}.map`, processed.map.toString()); } - }); + } + catch (err) { + // Handle errors in the compilation or processing + console.error(`Error processing styles from ${inputFile}:`, err); + } } } // ============================================================================ diff --git a/dist/js/class/SvgPackager.js b/dist/js/class/SvgPackager.js index 5a3e0f1..3b70266 100644 --- a/dist/js/class/SvgPackager.js +++ b/dist/js/class/SvgPackager.js @@ -23,15 +23,6 @@ var __importStar = (this && this.__importStar) || function (mod) { __setModuleDefault(result, mod); return result; }; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -49,11 +40,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fs = __importStar(require("fs/promises")); -const path = __importStar(require("path")); -const glob = __importStar(require("glob")); -const svgo_1 = __importDefault(require("svgo")); -const svgo_2 = require("svgo"); +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 // ============================================================================ @@ -75,39 +66,37 @@ class SvgPackager { * @param inputDirectory The directory containing SVG files to process. * @param outputDirectory The directory where optimized SVGs will be output as TypeScript files. */ - processSvgFiles(inputDirectory, outputDirectory, ts_output_directory, json_output_directory) { - return __awaiter(this, void 0, void 0, function* () { - 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 = yield this.readSvgFile(file); - const optimizedSvg = yield 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 - yield this.writeSvgFile( - // file, - iconName, resultSvg, outputDirectory); - // Write the optimized TypeScript file - yield this.writeTypeScriptFile( - // file, - iconName, resultSvg, ts_output_directory); - } - yield 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; + 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; + } } // public async processSvgFiles(directory: string, outputDirectory: string): Promise { // try { @@ -149,10 +138,8 @@ class SvgPackager { // throw error; // } // } - readSvgFile(filePath) { - return __awaiter(this, void 0, void 0, function* () { - return fs.readFile(filePath, 'utf8'); - }); + async readSvgFile(filePath) { + return fs.readFile(filePath, 'utf8'); } /** * Sanitizes a file name to be a valid TypeScript identifier. @@ -166,11 +153,9 @@ class SvgPackager { sanitizeFileName(fileName) { return fileName.replace(/[^a-zA-Z0-9_]/g, '_'); } - writeFiles(iconName, svgContent, outputDirectory) { - return __awaiter(this, void 0, void 0, function* () { - yield this.writeSvgFile(iconName, svgContent, outputDirectory); - yield this.writeTypeScriptFile(iconName, svgContent, outputDirectory); - }); + async writeFiles(iconName, svgContent, outputDirectory) { + await this.writeSvgFile(iconName, svgContent, outputDirectory); + await this.writeTypeScriptFile(iconName, svgContent, outputDirectory); } /** * Optimizes SVG content using SVGO. @@ -195,12 +180,10 @@ class SvgPackager { // throw error; // } // } - optimizeSvg(svgContent) { - return __awaiter(this, void 0, void 0, function* () { - const config = yield (0, svgo_2.loadConfig)(this.svgoConfigPath); - const result = yield svgo_1.default.optimize(svgContent, Object.assign({}, config)); - return result.data.trim(); - }); + 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. @@ -223,12 +206,10 @@ class SvgPackager { // throw error; // } // } - writeTypeScriptFile(iconName, svgContent, outputDirectory) { - return __awaiter(this, void 0, void 0, function* () { - const tsContent = `export const icon_${iconName} = \`${svgContent}\`;\n`; - const outputPath = path.join(outputDirectory, `${iconName}.ts`); - yield fs.writeFile(outputPath, tsContent); - }); + 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. @@ -251,11 +232,9 @@ class SvgPackager { // throw error; // } // } - writeSvgFile(iconName, svgContent, outputDirectory) { - return __awaiter(this, void 0, void 0, function* () { - const outputPath = path.join(outputDirectory, `${iconName}.svg`); - yield fs.writeFile(outputPath, svgContent); - }); + 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. @@ -266,20 +245,18 @@ class SvgPackager { * @param iconNames An array of strings containing the names of the icons. * @param outputDirectory The directory where the JSON file will be saved. */ - writeIconsJson(iconNames, outputDirectory) { - return __awaiter(this, void 0, void 0, function* () { - try { - const jsonContent = JSON.stringify(iconNames, null, 2); - const outputPath = path.join(outputDirectory, 'icons.json'); - // await fs_extra.outputFile(outputPath, jsonContent); - yield fs.writeFile(outputPath, jsonContent); - console.log('Icons JSON file created successfully'); - } - catch (error) { - console.error('Error writing icons JSON file:', error); - throw error; - } - }); + 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; + } } } // ============================================================================ diff --git a/dist/js/class/SvgSpriteGenerator.js b/dist/js/class/SvgSpriteGenerator.js index 739aefc..51939bd 100644 --- a/dist/js/class/SvgSpriteGenerator.js +++ b/dist/js/class/SvgSpriteGenerator.js @@ -1,14 +1,5 @@ "use strict"; // class/SvgSpriteGenerator.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -26,10 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const svg_sprite_1 = __importDefault(require("svg-sprite")); -const fs_1 = __importDefault(require("fs")); -const path_1 = __importDefault(require("path")); -const svgsprite_config_js_1 = __importDefault(require("../config/svgsprite.config.js")); +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 // ============================================================================ @@ -37,54 +28,55 @@ const svgsprite_config_js_1 = __importDefault(require("../config/svgsprite.confi * 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 = Object.assign(Object.assign({}, SvgSpriteGenerator.defaultConfig), 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. */ - generateSprite(sourceDir, outputDir) { - return __awaiter(this, void 0, void 0, function* () { - 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; + 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); } - 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); - } - }); + } + }); + } + catch (err) { + console.error('Error generating SVG sprite:', err); + } } } -/** - * Default configuration for the TypeScript compiler. - */ -SvgSpriteGenerator.defaultConfig = svgsprite_config_js_1.default; // ============================================================================ // Export // ============================================================================ diff --git a/dist/js/class/TypeScriptCompiler.d.ts b/dist/js/class/TypeScriptCompiler.d.ts index 6a4f2fd..86e2421 100644 --- a/dist/js/class/TypeScriptCompiler.d.ts +++ b/dist/js/class/TypeScriptCompiler.d.ts @@ -1,4 +1,3 @@ -import ts from 'typescript'; /** * TypeScriptCompiler class for compiling TypeScript files to JavaScript. */ @@ -13,23 +12,10 @@ declare class TypeScriptCompiler { private static defaultConfig; /** * Constructs an instance with merged configuration of default and custom options. - * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler + * @param {any} customConfig - Optional custom configuration object for TypeScript compiler + // * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler */ - constructor(customConfig?: ts.CompilerOptions); - /** - * Compiles TypeScript files to JavaScript. - * @param filePaths - The paths of TypeScript files to be compiled. - * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. - * This method sets up a TypeScript program with given file paths and compiler options. - * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. - * Compilation errors and diagnostics are logged for debugging purposes. - * The method returns a promise that resolves when compilation is successful or rejects in case of errors. - */ - compile(filePaths: string[], outDir?: string): Promise; - /** - * Formats TypeScript compiler diagnostics for readable output. - * @param diagnostics - Array of TypeScript diagnostics - */ - private formatDiagnostics; + 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 index c7d1a68..71ef003 100644 --- a/dist/js/class/TypeScriptCompiler.js +++ b/dist/js/class/TypeScriptCompiler.js @@ -18,8 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // Import // ============================================================================ // import * as ts from 'typescript'; -const typescript_1 = __importDefault(require("typescript")); -const ts_config_js_1 = __importDefault(require("../config/ts.config.js")); +var typescript_1 = __importDefault(require("typescript")); +var ts_config_js_1 = __importDefault(require("../config/ts.config.js")); // ============================================================================ // Classes // ============================================================================ @@ -28,27 +28,34 @@ const ts_config_js_1 = __importDefault(require("../config/ts.config.js")); * TypeScriptCompiler class for compiling TypeScript files to JavaScript. */ class TypeScriptCompiler { + // 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; // private static defaultConfig: CompilerOptions = tsConfig; /** * Constructs an instance with merged configuration of default and custom options. - * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler + * @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 = Object.assign(Object.assign({}, TypeScriptCompiler.defaultConfig), customConfig); + this.config = { + ...TypeScriptCompiler.defaultConfig, + ...customConfig + }; } - /** - * Compiles TypeScript files to JavaScript. - * @param filePaths - The paths of TypeScript files to be compiled. - * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. - * This method sets up a TypeScript program with given file paths and compiler options. - * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. - * Compilation errors and diagnostics are logged for debugging purposes. - * The method returns a promise that resolves when compilation is successful or rejects in case of errors. - */ compile(filePaths, outDir) { return new Promise((resolve, reject) => { - // Use outDir if provided, else fall back to this.config.outDir or a default - const options = Object.assign(Object.assign({}, this.config), { outDir: outDir || this.config.outDir || 'dist' }); + // 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 @@ -56,36 +63,30 @@ class TypeScriptCompiler { // Emit the compiled JavaScript files const emitResult = program.emit(); // Check for compilation errors - const diagnostics = typescript_1.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); - if (diagnostics.length > 0) { - const diagnosticMessage = this.formatDiagnostics(diagnostics); - console.error(diagnosticMessage); + 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')); - return; } - console.log('Compilation completed successfully.'); - resolve(); }); } - /** - * Formats TypeScript compiler diagnostics for readable output. - * @param diagnostics - Array of TypeScript diagnostics - */ - formatDiagnostics(diagnostics) { - return diagnostics.map(diagnostic => { - if (diagnostic.file) { - const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); - const message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; - } - return typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - }).join('\n'); - } } -/** - * Default configuration for the TypeScript compiler. - */ -TypeScriptCompiler.defaultConfig = ts_config_js_1.default; // ============================================================================ // Export // ============================================================================ diff --git a/dist/js/class/VersionWriter.js b/dist/js/class/VersionWriter.js index 3070397..e8d0827 100644 --- a/dist/js/class/VersionWriter.js +++ b/dist/js/class/VersionWriter.js @@ -1,14 +1,5 @@ "use strict"; // class/VersionWriter.ts -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); // Copyright 2023 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const fs_1 = require("fs"); +var fs_1 = require("fs"); // ============================================================================ // Classes // ============================================================================ @@ -36,16 +27,14 @@ class VersionWriter { * @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, version) { - return __awaiter(this, void 0, void 0, function* () { - try { - yield fs_1.promises.writeFile(filePath, version, 'utf8'); - console.log(`Version ${version} written to ${filePath}`); - } - catch (error) { - console.error(`Error writing version to file: ${error}`); - } - }); + 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}`); + } } } // ============================================================================ diff --git a/dist/js/config/postcss.config.compressed.js b/dist/js/config/postcss.config.compressed.js index 4194598..2d9be8a 100644 --- a/dist/js/config/postcss.config.compressed.js +++ b/dist/js/config/postcss.config.compressed.js @@ -17,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const autoprefixer_1 = __importDefault(require("autoprefixer")); -const cssnano_1 = __importDefault(require("cssnano")); +var autoprefixer_1 = __importDefault(require("autoprefixer")); +var cssnano_1 = __importDefault(require("cssnano")); // ============================================================================ // Constants // ============================================================================ diff --git a/dist/js/config/postcss.config.expanded.js b/dist/js/config/postcss.config.expanded.js index 9e25801..db1bf70 100644 --- a/dist/js/config/postcss.config.expanded.js +++ b/dist/js/config/postcss.config.expanded.js @@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); // ============================================================================ // Import // ============================================================================ -const autoprefixer_1 = __importDefault(require("autoprefixer")); +var autoprefixer_1 = __importDefault(require("autoprefixer")); // ============================================================================ // Constants // ============================================================================ diff --git a/dist/js/config/svgsprite.config.js b/dist/js/config/svgsprite.config.js index 30be997..d83a6b0 100644 --- a/dist/js/config/svgsprite.config.js +++ b/dist/js/config/svgsprite.config.js @@ -18,16 +18,13 @@ const svgspriteConfig = { maxWidth: 2000, // Max. shape width maxHeight: 2000, // Max. shape height precision: 2, // Floating point precision - attributes: false, // Width and height attributes on embedded shapes + attributes: false }, spacing: { padding: 0, // Padding around all shapes box: 'content' // Padding strategy (similar to CSS `box-sizing`) }, - transform: ['svgo'], // List of transformations / optimizations - // meta: null, // Path to YAML file with meta / accessibility data - // align: null, // Path to YAML file with extended alignment data - // dest: null // Output directory for optimized intermediate SVG shapes + transform: ['svgo'] }, svg: { xmlDeclaration: false, // Add XML declaration to SVG sprite @@ -54,8 +51,7 @@ const svgspriteConfig = { // inline: true, // Prepare for inline embedding sprite: "icon.gl.svg" }, - stack: true, // Create a «stack» sprite - // symbol: true // Symbol sprite mode + stack: true } }; // ============================================================================ diff --git a/dist/js/config/ts.config.d.ts b/dist/js/config/ts.config.d.ts index 987b96e..6fe80e6 100644 --- a/dist/js/config/ts.config.d.ts +++ b/dist/js/config/ts.config.d.ts @@ -1,3 +1,13 @@ -import ts from 'typescript'; -declare const tsConfig: ts.CompilerOptions; +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 index 1635d15..0516703 100644 --- a/dist/js/config/ts.config.js +++ b/dist/js/config/ts.config.js @@ -1,28 +1,11 @@ "use strict"; // config/ts.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 -// ============================================================================ -const typescript_1 = __importDefault(require("typescript")); // ============================================================================ // Constants // ============================================================================ +// const tsConfig: ts.CompilerOptions = { const tsConfig = { - // const tsConfig = { // Visit https://aka.ms/tsconfig.json to read more about this file // Projects // ======================================================================== @@ -34,8 +17,8 @@ const tsConfig = { // disableReferencedProjectLoad: true, // boolean // Reduce the number of projects loaded automatically by TypeScript. // Language and Environment // ======================================================================== - target: typescript_1.default.ScriptTarget.ES2015, - // target: "es6", // Specify ECMAScript target version + // target: ts.ScriptTarget.ES2015, + target: "es6", // Specify ECMAScript target version // ES3 = 0, // ES5 = 1, // ES2015 = 2, @@ -68,8 +51,8 @@ const tsConfig = { // moduleResolution?: ModuleResolutionKind; // moduleSuffixes?: string[]; // moduleDetection?: ModuleDetectionKind; - module: typescript_1.default.ModuleKind.CommonJS, - // module: "commonjs", // Specify module code generation + // 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. @@ -154,109 +137,7 @@ const tsConfig = { // ======================================================================== // skipDefaultLibCheck: true, // Skip type checking .d.ts files that are included with TypeScript. // Skip type checking of declaration files - skipLibCheck: true, // Skip type checking all .d.ts files. - // Other - // ======================================================================== - // allowImportingTsExtensions?: boolean; - // allowJs?: boolean; - // allowArbitraryExtensions?: boolean; - // allowSyntheticDefaultImports?: boolean; - // allowUmdGlobalAccess?: boolean; - // allowUnreachableCode?: boolean; - // allowUnusedLabels?: boolean; - // alwaysStrict?: boolean; - // baseUrl?: string; - // charset?: string; - // checkJs?: boolean; - // customConditions?: string[]; - // declaration?: boolean; - // declarationMap?: boolean; - // emitDeclarationOnly?: boolean; - // declarationDir?: string; - // disableSizeLimit?: boolean; - // disableSourceOfProjectReferenceRedirect?: boolean; - // disableSolutionSearching?: boolean; - // disableReferencedProjectLoad?: boolean; - // downlevelIteration?: boolean; - // emitBOM?: boolean; - // emitDecoratorMetadata?: boolean; - // exactOptionalPropertyTypes?: boolean; - // experimentalDecorators?: boolean; - // forceConsistentCasingInFileNames?: boolean; - // ignoreDeprecations?: string; - // importHelpers?: boolean; - // importsNotUsedAsValues?: ImportsNotUsedAsValues; - // inlineSourceMap?: boolean; - // inlineSources?: boolean; - // isolatedModules?: boolean; - // jsx?: JsxEmit; - // keyofStringsOnly?: boolean; - // lib?: string[]; - // locale?: string; - // mapRoot?: string; - // maxNodeModuleJsDepth?: number; - // newLine?: NewLineKind; - // noEmit?: boolean; - // noEmitHelpers?: boolean; - // noEmitOnError?: boolean; - // noErrorTruncation?: boolean; - // noFallthroughCasesInSwitch?: boolean; - // noImplicitAny?: boolean; - // noImplicitReturns?: boolean; - // noImplicitThis?: boolean; - // noStrictGenericChecks?: boolean; - // noUnusedLocals?: boolean; - // noUnusedParameters?: boolean; - // noImplicitUseStrict?: boolean; - // noPropertyAccessFromIndexSignature?: boolean; - // assumeChangesOnlyAffectDirectDependencies?: boolean; - // noLib?: boolean; - // noResolve?: boolean; - // noUncheckedIndexedAccess?: boolean; - // out?: string; - // outDir?: string; - // outFile: 'icon.gl.js' // string; - // paths?: MapLike; - // preserveConstEnums?: boolean; - // noImplicitOverride?: boolean; - // preserveSymlinks?: boolean; - // preserveValueImports?: boolean; - // project?: string; - // reactNamespace?: string; - // jsxFactory?: string; - // jsxFragmentFactory?: string; - // jsxImportSource?: string; - // composite?: boolean; - // incremental?: boolean; - // tsBuildInfoFile?: string; - // removeComments?: boolean; - // resolvePackageJsonExports?: boolean; - // resolvePackageJsonImports?: boolean; - // rootDir?: string; - // rootDirs?: string[]; - // skipLibCheck?: boolean; - // skipDefaultLibCheck?: boolean; - // sourceMap?: boolean; - // sourceRoot?: string; - // strict?: boolean; - // strictFunctionTypes?: boolean; - // strictBindCallApply?: boolean; - // strictNullChecks?: boolean; - // strictPropertyInitialization?: boolean; - // stripInternal?: boolean; - // suppressExcessPropertyErrors?: boolean; - // suppressImplicitAnyIndexErrors?: boolean; - // target?: ScriptTarget; - // traceResolution?: boolean; - // useUnknownInCatchVariables?: boolean; - // resolveJsonModule?: boolean; - // types?: string[]; - // /** Paths used to compute primary types search locations - // typeRoots?: string[]; - // verbatimModuleSyntax?: boolean; - // esModuleInterop?: boolean; - // useDefineForClassFields?: boolean; - // [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; + skipLibCheck: true }; // ============================================================================ // Export diff --git a/dist/js/functions/gl_installer.js b/dist/js/functions/gl_installer.js index a3abf8f..335445a 100644 --- a/dist/js/functions/gl_installer.js +++ b/dist/js/functions/gl_installer.js @@ -1,40 +1,29 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -const NpmCommandRunner_js_1 = __importDefault(require("../class/NpmCommandRunner.js")); +var NpmCommandRunner_js_1 = __importDefault(require("../class/NpmCommandRunner.js")); const runner = new NpmCommandRunner_js_1.default(); // runner.runCommand('install') // .then(output => console.log(output)) // .catch(error => console.error(error)); -function gl_installer() { - return __awaiter(this, void 0, void 0, function* () { - try { - let output = ""; - console.log('Running npm install...'); - output = yield runner.runCommand('install pack.gl@latest --save-dev'); - console.log(output); - console.log('Running npm update...'); - output = yield runner.runCommand('install unit.gl@latest --save-dev'); - console.log(output); - // Add more npm commands as needed - // output = await runner.runCommand('your-next-command'); - // console.log(output); - } - catch (error) { - console.error('An error occurred:', error); - } - }); +async function gl_installer() { + try { + let output = ""; + console.log('Running npm install...'); + output = await runner.runCommand('install pack.gl@latest --save-dev'); + console.log(output); + console.log('Running npm update...'); + output = await runner.runCommand('install unit.gl@latest --save-dev'); + console.log(output); + // Add more npm commands as needed + // output = await runner.runCommand('your-next-command'); + // console.log(output); + } + catch (error) { + console.error('An error occurred:', error); + } } exports.default = gl_installer; // runSampleCommands(); diff --git a/dist/js/index.js b/dist/js/index.js index 103ba9f..9071b96 100644 --- a/dist/js/index.js +++ b/dist/js/index.js @@ -19,34 +19,34 @@ exports.gl_installer = exports.NpmCommandRunner = exports.JavaScriptMinifier = e // Import // ============================================================================ // Import | Utility Classes -const DirectoryCleaner_1 = __importDefault(require("./class/DirectoryCleaner")); +var DirectoryCleaner_1 = __importDefault(require("./class/DirectoryCleaner")); exports.DirectoryCleaner = DirectoryCleaner_1.default; -const DirectoryCopier_1 = __importDefault(require("./class/DirectoryCopier")); +var DirectoryCopier_1 = __importDefault(require("./class/DirectoryCopier")); exports.DirectoryCopier = DirectoryCopier_1.default; -const DirectoryCreator_1 = __importDefault(require("./class/DirectoryCreator")); +var DirectoryCreator_1 = __importDefault(require("./class/DirectoryCreator")); exports.DirectoryCreator = DirectoryCreator_1.default; -const FileCopier_1 = __importDefault(require("./class/FileCopier")); +var FileCopier_1 = __importDefault(require("./class/FileCopier")); exports.FileCopier = FileCopier_1.default; -const FileRenamer_1 = __importDefault(require("./class/FileRenamer")); +var FileRenamer_1 = __importDefault(require("./class/FileRenamer")); exports.FileRenamer = FileRenamer_1.default; // // Import | Internal Classes -const FontGenerator_js_1 = __importDefault(require("./class/FontGenerator.js")); +var FontGenerator_js_1 = __importDefault(require("./class/FontGenerator.js")); exports.FontGenerator = FontGenerator_js_1.default; -const PackageCreator_js_1 = __importDefault(require("./class/PackageCreator.js")); +var PackageCreator_js_1 = __importDefault(require("./class/PackageCreator.js")); exports.PackageCreator = PackageCreator_js_1.default; -const SvgPackager_js_1 = __importDefault(require("./class/SvgPackager.js")); +var SvgPackager_js_1 = __importDefault(require("./class/SvgPackager.js")); exports.SvgPackager = SvgPackager_js_1.default; -const StyleProcessor_js_1 = __importDefault(require("./class/StyleProcessor.js")); +var StyleProcessor_js_1 = __importDefault(require("./class/StyleProcessor.js")); exports.StyleProcessor = StyleProcessor_js_1.default; -const SvgSpriteGenerator_js_1 = __importDefault(require("./class/SvgSpriteGenerator.js")); +var SvgSpriteGenerator_js_1 = __importDefault(require("./class/SvgSpriteGenerator.js")); exports.SvgSpriteGenerator = SvgSpriteGenerator_js_1.default; -const VersionWriter_js_1 = __importDefault(require("./class/VersionWriter.js")); +var VersionWriter_js_1 = __importDefault(require("./class/VersionWriter.js")); exports.VersionWriter = VersionWriter_js_1.default; -const TypeScriptCompiler_js_1 = __importDefault(require("./class/TypeScriptCompiler.js")); +var TypeScriptCompiler_js_1 = __importDefault(require("./class/TypeScriptCompiler.js")); exports.TypeScriptCompiler = TypeScriptCompiler_js_1.default; -const JavaScriptMinifier_js_1 = __importDefault(require("./class/JavaScriptMinifier.js")); +var JavaScriptMinifier_js_1 = __importDefault(require("./class/JavaScriptMinifier.js")); exports.JavaScriptMinifier = JavaScriptMinifier_js_1.default; -const NpmCommandRunner_js_1 = __importDefault(require("./class/NpmCommandRunner.js")); +var NpmCommandRunner_js_1 = __importDefault(require("./class/NpmCommandRunner.js")); exports.NpmCommandRunner = NpmCommandRunner_js_1.default; -const gl_installer_1 = __importDefault(require("./functions/gl_installer")); +var gl_installer_1 = __importDefault(require("./functions/gl_installer")); exports.gl_installer = gl_installer_1.default; diff --git a/dist/ts/class/TypeScriptCompiler.ts b/dist/ts/class/TypeScriptCompiler.ts index a9f94e4..1cae502 100644 --- a/dist/ts/class/TypeScriptCompiler.ts +++ b/dist/ts/class/TypeScriptCompiler.ts @@ -39,20 +39,25 @@ import tsConfig from "../config/ts.config.js" /** * Configuration for the TypeScript compiler. */ - private config: ts.CompilerOptions; + // private config: ts.CompilerOptions; + private config: any; + // private config: { [key: symbol]: any}; /** * Default configuration for the TypeScript compiler. */ - private static defaultConfig: ts.CompilerOptions = tsConfig; - // private static defaultConfig: CompilerOptions = tsConfig; + private static defaultConfig: any = tsConfig; + // private static defaultConfig: ts.CompilerOptions = tsConfig; + // private static defaultConfig: CompilerOptions = tsConfig; /** * Constructs an instance with merged configuration of default and custom options. - * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler + * @param {any} customConfig - Optional custom configuration object for TypeScript compiler + // * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler */ constructor( - customConfig: ts.CompilerOptions = {}, + customConfig: any = {}, + // customConfig: ts.CompilerOptions = {}, ) { this.config = { ...TypeScriptCompiler.defaultConfig, @@ -60,57 +65,107 @@ import tsConfig from "../config/ts.config.js" }; } - /** - * Compiles TypeScript files to JavaScript. - * @param filePaths - The paths of TypeScript files to be compiled. - * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. - * This method sets up a TypeScript program with given file paths and compiler options. - * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. - * Compilation errors and diagnostics are logged for debugging purposes. - * The method returns a promise that resolves when compilation is successful or rejects in case of errors. - */ - compile( + compile( filePaths: string[], - outDir?: string + outDir: string, + // customOptions: ts.CompilerOptions = {} ): Promise { return new Promise((resolve, reject) => { - // Use outDir if provided, else fall back to this.config.outDir or a default - const options = { ...this.config, outDir: outDir || this.config.outDir || 'dist' }; + + // Merge default options with custom options + const options: ts.CompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: ts.ScriptTarget.ES2015, + outDir, + // ...customOptions, // Merges custom compiler options + ...this.config, // Merges custom compiler options + }; + // Create a TypeScript compiler host const host = ts.createCompilerHost(options); + // Create a program with the specified files and options const program = ts.createProgram(filePaths, options, host); + // Emit the compiled JavaScript files const emitResult = program.emit(); // Check for compilation errors - const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); - if (diagnostics.length > 0) { - const diagnosticMessage = this.formatDiagnostics(diagnostics); - console.error(diagnosticMessage); + 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'); + console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + } else { + console.error(ts.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')); - return; } - - console.log('Compilation completed successfully.'); - resolve(); }); } - /** - * Formats TypeScript compiler diagnostics for readable output. - * @param diagnostics - Array of TypeScript diagnostics - */ - private formatDiagnostics(diagnostics: readonly ts.Diagnostic[]): string { - return diagnostics.map(diagnostic => { - if (diagnostic.file) { - const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); - const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; - } - return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - }).join('\n'); - } + + // /** + // * Compiles TypeScript files to JavaScript. + // * @param filePaths - The paths of TypeScript files to be compiled. + // * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. + // * This method sets up a TypeScript program with given file paths and compiler options. + // * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. + // * Compilation errors and diagnostics are logged for debugging purposes. + // * The method returns a promise that resolves when compilation is successful or rejects in case of errors. + // */ + // compile( + // filePaths: string[], + // outDir?: string + // ): Promise { + // return new Promise((resolve, reject) => { + // // Use outDir if provided, else fall back to this.config.outDir or a default + // const options = { ...this.config, outDir: outDir || this.config.outDir || 'dist' }; + // // Create a TypeScript compiler host + // const host = ts.createCompilerHost(options); + // // Create a program with the specified files and options + // const program = ts.createProgram(filePaths, options, host); + // // Emit the compiled JavaScript files + // const emitResult = program.emit(); + + // // Check for compilation errors + // const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + // if (diagnostics.length > 0) { + // const diagnosticMessage = this.formatDiagnostics(diagnostics); + // console.error(diagnosticMessage); + // reject(new Error('TypeScript compilation failed')); + // return; + // } + + // console.log('Compilation completed successfully.'); + // resolve(); + // }); + // } + + // /** + // * Formats TypeScript compiler diagnostics for readable output. + // * @param diagnostics - Array of TypeScript diagnostics + // */ + // private formatDiagnostics(diagnostics: readonly ts.Diagnostic[]): string { + // return diagnostics.map(diagnostic => { + // if (diagnostic.file) { + // const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); + // const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + // return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; + // } + // return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + // }).join('\n'); + // } } diff --git a/dist/ts/config/ts.config.ts b/dist/ts/config/ts.config.ts index f13eb02..e7ffba3 100644 --- a/dist/ts/config/ts.config.ts +++ b/dist/ts/config/ts.config.ts @@ -26,8 +26,8 @@ import ts from 'typescript'; // Constants // ============================================================================ -const tsConfig: ts.CompilerOptions = { -// const tsConfig = { +// const tsConfig: ts.CompilerOptions = { +const tsConfig = { // Visit https://aka.ms/tsconfig.json to read more about this file @@ -47,8 +47,8 @@ const tsConfig: ts.CompilerOptions = { // Language and Environment // ======================================================================== - target: ts.ScriptTarget.ES2015, - // target: "es6", // Specify ECMAScript target version + // target: ts.ScriptTarget.ES2015, + target: "es6", // Specify ECMAScript target version // ES3 = 0, // ES5 = 1, // ES2015 = 2, @@ -86,8 +86,8 @@ const tsConfig: ts.CompilerOptions = { // moduleSuffixes?: string[]; // moduleDetection?: ModuleDetectionKind; - module: ts.ModuleKind.CommonJS, - // module: "commonjs", // Specify module code generation + // 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. diff --git a/package.json b/package.json index f34b8c1..af0364a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pack.gl", "description": "Package Builder.", - "version": "0.0.11", + "version": "0.0.12", "config": { "version_short": "0.0" }, diff --git a/script/js/class/TypeScriptCompiler.d.ts b/script/js/class/TypeScriptCompiler.d.ts index 16d2b99..daa5eb4 100644 --- a/script/js/class/TypeScriptCompiler.d.ts +++ b/script/js/class/TypeScriptCompiler.d.ts @@ -1,6 +1,7 @@ declare class TypeScriptCompiler { private config; - constructor(config: any); + private static defaultConfig; + constructor(customConfig?: any); compile(filePaths: string[], outDir: string): Promise; } export default TypeScriptCompiler; diff --git a/script/js/class/TypeScriptCompiler.js b/script/js/class/TypeScriptCompiler.js index ba15575..823f04f 100644 --- a/script/js/class/TypeScriptCompiler.js +++ b/script/js/class/TypeScriptCompiler.js @@ -1,8 +1,10 @@ import { __assign } from "tslib"; import ts from 'typescript'; +import tsConfig from "../config/ts.config.js"; var TypeScriptCompiler = (function () { - function TypeScriptCompiler(config) { - this.config = config; + function TypeScriptCompiler(customConfig) { + if (customConfig === void 0) { customConfig = {}; } + this.config = __assign(__assign({}, TypeScriptCompiler.defaultConfig), customConfig); } TypeScriptCompiler.prototype.compile = function (filePaths, outDir) { var _this = this; @@ -33,6 +35,7 @@ var TypeScriptCompiler = (function () { } }); }; + TypeScriptCompiler.defaultConfig = tsConfig; return TypeScriptCompiler; }()); export default TypeScriptCompiler; diff --git a/script/js/class/TypeScriptCompiler.js.map b/script/js/class/TypeScriptCompiler.js.map index 36d3aa3..b953ea2 100644 --- a/script/js/class/TypeScriptCompiler.js.map +++ b/script/js/class/TypeScriptCompiler.js.map @@ -1 +1 @@ -{"version":3,"file":"TypeScriptCompiler.js","sourceRoot":"","sources":["../../ts/class/TypeScriptCompiler.ts"],"names":[],"mappings":";AAsBA,OAAO,EAAE,MAAM,YAAY,CAAC;AAU3B;IAQG,4BAAY,MAAW;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAcD,oCAAO,GAAP,UACI,SAAmB,EACnB,MAAc;QAFlB,iBA+CC;QA1CG,OAAO,IAAI,OAAO,CAAC,U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js/config/ts.config.d.ts b/script/js/config/ts.config.d.ts index 06933e2..6fe80e6 100644 --- a/script/js/config/ts.config.d.ts +++ b/script/js/config/ts.config.d.ts @@ -1,13 +1,13 @@ declare const tsConfig: { target: string; + lib: string[]; module: string; + resolveJsonModule: boolean; + declaration: boolean; allowSyntheticDefaultImports: boolean; esModuleInterop: boolean; - declaration: boolean; + forceConsistentCasingInFileNames: boolean; strict: boolean; skipLibCheck: boolean; - forceConsistentCasingInFileNames: boolean; - resolveJsonModule: boolean; - lib: string[]; }; export default tsConfig; diff --git a/script/js/config/ts.config.js b/script/js/config/ts.config.js index 2fb3ea6..281fc4b 100644 --- a/script/js/config/ts.config.js +++ b/script/js/config/ts.config.js @@ -1,14 +1,14 @@ var tsConfig = { target: "es6", + lib: ["es2015", "dom"], module: "commonjs", + resolveJsonModule: true, + declaration: true, allowSyntheticDefaultImports: true, esModuleInterop: true, - declaration: true, + forceConsistentCasingInFileNames: true, strict: true, skipLibCheck: true, - forceConsistentCasingInFileNames: true, - resolveJsonModule: true, - lib: ["es2015", "dom"] }; export default tsConfig; //# sourceMappingURL=ts.config.js.map \ No newline at end of file diff --git a/script/js/config/ts.config.js.map b/script/js/config/ts.config.js.map index a8581b3..f363bb8 100644 --- a/script/js/config/ts.config.js.map +++ b/script/js/config/ts.config.js.map @@ -1 +1 @@ -{"version":3,"file":"ts.config.js","sourceRoot":"","sources":["../../ts/config/ts.config.ts"],"names":[],"mappings":"AAGA,IAAM,QAAQ,GAAG;IACb,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,UAAU;IAClB,4BAA4B,EAAE,IAAI;IAClC,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,IAAI;IACjB,MAAM,EAAE,IAAI;IACZ,YAAY,EAAE,IAAI;IAClB,gCAAgC,EAAE,IAAI;IACtC,iBAAiB,EAAE,IAAI;IACvB,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;CA6GzB,CAAC;AAOF,eAAe,QAAQ,CAAC"} \ No newline at end of file +{"version":3,"file":"ts.config.js","sourceRoot":"","sources":["../../ts/config/ts.config.ts"],"names":[],"mappings":"AA6BA,IAAM,QAAQ,GAAG;IAqBb,MAAM,EAAE,KAAK;IAiBb,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;IAsBtB,MAAM,EAAE,UAAU;IAgBlB,iBAAiB,EAAE,IAAI;IAevB,WAAW,EAAE,IAAI;IAiCjB,4BAA4B,EAAE,IAAI;IAElC,eAAe,EAAE,IAAI;IAGrB,gCAAgC,EAAE,IAAI;IAMtC,MAAM,EAAE,IAAI;IA0BZ,YAAY,EAAE,IAAI;CA2GrB,CAAC;AAOF,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/script/js/index.js b/script/js/index.js index 15fa369..cbb5ee7 100644 --- a/script/js/index.js +++ b/script/js/index.js @@ -1,6 +1,7 @@ import { __awaiter, __generator } from "tslib"; import path from 'path'; -import { DirectoryCleaner, DirectoryCopier, DirectoryCreator, PackageCreator, VersionWriter, TypeScriptCompiler, } from 'pack.gl'; +import { DirectoryCleaner, DirectoryCopier, DirectoryCreator, PackageCreator, VersionWriter, } from 'pack.gl'; +import TypeScriptCompiler from "./class/TypeScriptCompiler.js"; import { CONFIG } from './config/config.js'; import packageConfig from "./config/package.config.js"; var directories = Object.values(CONFIG.path); diff --git a/script/js/index.js.map b/script/js/index.js.map index c8c8caa..8b61535 100644 --- a/script/js/index.js.map +++ b/script/js/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";AAsBA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,kBAAkB,GAErB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,aAAa,MAAM,4BAA4B,CAAA;AAStD,IAAM,W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KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;oBAC/C,CAAC;;;;oBAID,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,OAAK,CAAC,CAAC;;;;;;CAGlD;AAQD,IAAI,EAAE,CAAC"} \ No newline at end of file diff --git a/script/ts/class/TypeScriptCompiler.ts b/script/ts/class/TypeScriptCompiler.ts new file mode 100644 index 0000000..1cae502 --- /dev/null +++ b/script/ts/class/TypeScriptCompiler.ts @@ -0,0 +1,242 @@ +// 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 tsConfig from "../config/ts.config.js" + + +// ============================================================================ +// Classes +// ============================================================================ + +// type CompilerOptions = ts.CompilerOptions | Record; + + +/** + * TypeScriptCompiler class for compiling TypeScript files to JavaScript. + */ + class TypeScriptCompiler { + + /** + * Configuration for the TypeScript compiler. + */ + // private config: ts.CompilerOptions; + private config: any; + // private config: { [key: symbol]: any}; + + /** + * Default configuration for the TypeScript compiler. + */ + private static defaultConfig: any = tsConfig; + // private static defaultConfig: ts.CompilerOptions = tsConfig; + // private static defaultConfig: 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: any = {}, + // customConfig: ts.CompilerOptions = {}, + ) { + this.config = { + ...TypeScriptCompiler.defaultConfig, + ...customConfig + }; + } + + compile( + filePaths: string[], + outDir: string, + // customOptions: ts.CompilerOptions = {} + ): Promise { + return new Promise((resolve, reject) => { + + // Merge default options with custom options + const options: ts.CompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: ts.ScriptTarget.ES2015, + outDir, + // ...customOptions, // Merges custom compiler options + ...this.config, // Merges custom compiler options + }; + + // Create a TypeScript compiler host + const host = ts.createCompilerHost(options); + + // Create a program with the specified files and options + const program = ts.createProgram(filePaths, options, host); + + // Emit the compiled JavaScript files + const emitResult = program.emit(); + + // Check for compilation errors + 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'); + console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + } else { + console.error(ts.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')); + } + }); + } + + + // /** + // * Compiles TypeScript files to JavaScript. + // * @param filePaths - The paths of TypeScript files to be compiled. + // * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. + // * This method sets up a TypeScript program with given file paths and compiler options. + // * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. + // * Compilation errors and diagnostics are logged for debugging purposes. + // * The method returns a promise that resolves when compilation is successful or rejects in case of errors. + // */ + // compile( + // filePaths: string[], + // outDir?: string + // ): Promise { + // return new Promise((resolve, reject) => { + // // Use outDir if provided, else fall back to this.config.outDir or a default + // const options = { ...this.config, outDir: outDir || this.config.outDir || 'dist' }; + // // Create a TypeScript compiler host + // const host = ts.createCompilerHost(options); + // // Create a program with the specified files and options + // const program = ts.createProgram(filePaths, options, host); + // // Emit the compiled JavaScript files + // const emitResult = program.emit(); + + // // Check for compilation errors + // const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + // if (diagnostics.length > 0) { + // const diagnosticMessage = this.formatDiagnostics(diagnostics); + // console.error(diagnosticMessage); + // reject(new Error('TypeScript compilation failed')); + // return; + // } + + // console.log('Compilation completed successfully.'); + // resolve(); + // }); + // } + + // /** + // * Formats TypeScript compiler diagnostics for readable output. + // * @param diagnostics - Array of TypeScript diagnostics + // */ + // private formatDiagnostics(diagnostics: readonly ts.Diagnostic[]): string { + // return diagnostics.map(diagnostic => { + // if (diagnostic.file) { + // const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); + // const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + // return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; + // } + // return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + // }).join('\n'); + // } + +} + + +// ============================================================================ +// Export +// ============================================================================ + +export default TypeScriptCompiler; + + + + + + // /** + // * Compiles TypeScript files to JavaScript. + // * + // * @param {string[]} filePaths - The paths of TypeScript files to be compiled. + // * @param {string} outDir - The directory where the compiled JavaScript files will be saved. + // * @param {ts.CompilerOptions} customOptions - Optional custom TypeScript compiler options. + // * + // * This method sets up a TypeScript program with given file paths and compiler options. + // * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. + // * Compilation errors and diagnostics are logged for debugging purposes. + // * The method returns a promise that resolves when compilation is successful or rejects in case of errors. + // */ + // compile( + // filePaths: string[], + // outDir: string, + // // customOptions: ts.CompilerOptions = {} + // ): Promise { + // return new Promise((resolve, reject) => { + + // // Merge default options with custom options + // const options: ts.CompilerOptions = { + // module: ts.ModuleKind.CommonJS, + // target: ts.ScriptTarget.ES2015, + // outDir, + // // ...customOptions, // Merges custom compiler options + // ...this.config, // Merges custom compiler options + // }; + + // // Create a TypeScript compiler host + // const host = ts.createCompilerHost(options); + + // // Create a program with the specified files and options + // const program = ts.createProgram(filePaths, options, host); + + // // Emit the compiled JavaScript files + // const emitResult = program.emit(); + + // // Check for compilation errors + // 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'); + // console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + // } else { + // console.error(ts.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')); + // } + // }); + // } \ No newline at end of file diff --git a/script/ts/config/ts.config.ts b/script/ts/config/ts.config.ts index 4e6b599..e7ffba3 100644 --- a/script/ts/config/ts.config.ts +++ b/script/ts/config/ts.config.ts @@ -1,22 +1,200 @@ +// config/ts.config.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 ts from 'typescript'; + + +// ============================================================================ +// 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, + + // 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 - allowSyntheticDefaultImports: true, - esModuleInterop: true, // Enables compatibility with Babel imports + // 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 - strict: true, - skipLibCheck: true, // Skip type checking of declaration 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 - resolveJsonModule: true, // Allow importing of .json files - lib: ["es2015", "dom"] // Specify library files to be included in the compilation - // lib: ["es2015"] // Specify library files to be included in the compilation - + // 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, // Skip type checking all .d.ts files. + + + // Other + // ======================================================================== // allowImportingTsExtensions?: boolean; + // allowJs?: boolean; // allowArbitraryExtensions?: boolean; // allowSyntheticDefaultImports?: boolean; @@ -54,10 +232,7 @@ const tsConfig = { // locale?: string; // mapRoot?: string; // maxNodeModuleJsDepth?: number; - // module?: ModuleKind; - // moduleResolution?: ModuleResolutionKind; - // moduleSuffixes?: string[]; - // moduleDetection?: ModuleDetectionKind; + // newLine?: NewLineKind; // noEmit?: boolean; // noEmitHelpers?: boolean; @@ -78,7 +253,7 @@ const tsConfig = { // noUncheckedIndexedAccess?: boolean; // out?: string; // outDir?: string; - // outFile: 'unit.gl.js' // string; + // outFile: 'icon.gl.js' // string; // paths?: MapLike; // preserveConstEnums?: boolean; // noImplicitOverride?: boolean; @@ -114,7 +289,7 @@ const tsConfig = { // useUnknownInCatchVariables?: boolean; // resolveJsonModule?: boolean; // types?: string[]; - // /** Paths used to compute primary types search locations */ + // /** Paths used to compute primary types search locations // typeRoots?: string[]; // verbatimModuleSyntax?: boolean; // esModuleInterop?: boolean; diff --git a/script/ts/index.ts b/script/ts/index.ts index d47ad0a..7e5d252 100644 --- a/script/ts/index.ts +++ b/script/ts/index.ts @@ -27,9 +27,10 @@ import { DirectoryCreator, PackageCreator, VersionWriter, - TypeScriptCompiler, + // TypeScriptCompiler, // JavaScriptMinifier } from 'pack.gl'; +import TypeScriptCompiler from "./class/TypeScriptCompiler.js" // Import necessary configurations import { CONFIG } from './config/config.js'; diff --git a/src/ts/class/TypeScriptCompiler.ts b/src/ts/class/TypeScriptCompiler.ts index a9f94e4..1cae502 100644 --- a/src/ts/class/TypeScriptCompiler.ts +++ b/src/ts/class/TypeScriptCompiler.ts @@ -39,20 +39,25 @@ import tsConfig from "../config/ts.config.js" /** * Configuration for the TypeScript compiler. */ - private config: ts.CompilerOptions; + // private config: ts.CompilerOptions; + private config: any; + // private config: { [key: symbol]: any}; /** * Default configuration for the TypeScript compiler. */ - private static defaultConfig: ts.CompilerOptions = tsConfig; - // private static defaultConfig: CompilerOptions = tsConfig; + private static defaultConfig: any = tsConfig; + // private static defaultConfig: ts.CompilerOptions = tsConfig; + // private static defaultConfig: CompilerOptions = tsConfig; /** * Constructs an instance with merged configuration of default and custom options. - * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler + * @param {any} customConfig - Optional custom configuration object for TypeScript compiler + // * @param {ts.CompilerOptions} customConfig - Optional custom configuration object for TypeScript compiler */ constructor( - customConfig: ts.CompilerOptions = {}, + customConfig: any = {}, + // customConfig: ts.CompilerOptions = {}, ) { this.config = { ...TypeScriptCompiler.defaultConfig, @@ -60,57 +65,107 @@ import tsConfig from "../config/ts.config.js" }; } - /** - * Compiles TypeScript files to JavaScript. - * @param filePaths - The paths of TypeScript files to be compiled. - * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. - * This method sets up a TypeScript program with given file paths and compiler options. - * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. - * Compilation errors and diagnostics are logged for debugging purposes. - * The method returns a promise that resolves when compilation is successful or rejects in case of errors. - */ - compile( + compile( filePaths: string[], - outDir?: string + outDir: string, + // customOptions: ts.CompilerOptions = {} ): Promise { return new Promise((resolve, reject) => { - // Use outDir if provided, else fall back to this.config.outDir or a default - const options = { ...this.config, outDir: outDir || this.config.outDir || 'dist' }; + + // Merge default options with custom options + const options: ts.CompilerOptions = { + module: ts.ModuleKind.CommonJS, + target: ts.ScriptTarget.ES2015, + outDir, + // ...customOptions, // Merges custom compiler options + ...this.config, // Merges custom compiler options + }; + // Create a TypeScript compiler host const host = ts.createCompilerHost(options); + // Create a program with the specified files and options const program = ts.createProgram(filePaths, options, host); + // Emit the compiled JavaScript files const emitResult = program.emit(); // Check for compilation errors - const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); - if (diagnostics.length > 0) { - const diagnosticMessage = this.formatDiagnostics(diagnostics); - console.error(diagnosticMessage); + 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'); + console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + } else { + console.error(ts.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')); - return; } - - console.log('Compilation completed successfully.'); - resolve(); }); } - /** - * Formats TypeScript compiler diagnostics for readable output. - * @param diagnostics - Array of TypeScript diagnostics - */ - private formatDiagnostics(diagnostics: readonly ts.Diagnostic[]): string { - return diagnostics.map(diagnostic => { - if (diagnostic.file) { - const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); - const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; - } - return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); - }).join('\n'); - } + + // /** + // * Compiles TypeScript files to JavaScript. + // * @param filePaths - The paths of TypeScript files to be compiled. + // * @param outDir - Optional. The directory where the compiled JavaScript files will be saved. + // * This method sets up a TypeScript program with given file paths and compiler options. + // * It handles the compilation of TypeScript files into JavaScript, considering any provided custom options. + // * Compilation errors and diagnostics are logged for debugging purposes. + // * The method returns a promise that resolves when compilation is successful or rejects in case of errors. + // */ + // compile( + // filePaths: string[], + // outDir?: string + // ): Promise { + // return new Promise((resolve, reject) => { + // // Use outDir if provided, else fall back to this.config.outDir or a default + // const options = { ...this.config, outDir: outDir || this.config.outDir || 'dist' }; + // // Create a TypeScript compiler host + // const host = ts.createCompilerHost(options); + // // Create a program with the specified files and options + // const program = ts.createProgram(filePaths, options, host); + // // Emit the compiled JavaScript files + // const emitResult = program.emit(); + + // // Check for compilation errors + // const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + // if (diagnostics.length > 0) { + // const diagnosticMessage = this.formatDiagnostics(diagnostics); + // console.error(diagnosticMessage); + // reject(new Error('TypeScript compilation failed')); + // return; + // } + + // console.log('Compilation completed successfully.'); + // resolve(); + // }); + // } + + // /** + // * Formats TypeScript compiler diagnostics for readable output. + // * @param diagnostics - Array of TypeScript diagnostics + // */ + // private formatDiagnostics(diagnostics: readonly ts.Diagnostic[]): string { + // return diagnostics.map(diagnostic => { + // if (diagnostic.file) { + // const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); + // const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + // return `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`; + // } + // return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + // }).join('\n'); + // } } diff --git a/src/ts/config/ts.config.ts b/src/ts/config/ts.config.ts index f13eb02..e7ffba3 100644 --- a/src/ts/config/ts.config.ts +++ b/src/ts/config/ts.config.ts @@ -26,8 +26,8 @@ import ts from 'typescript'; // Constants // ============================================================================ -const tsConfig: ts.CompilerOptions = { -// const tsConfig = { +// const tsConfig: ts.CompilerOptions = { +const tsConfig = { // Visit https://aka.ms/tsconfig.json to read more about this file @@ -47,8 +47,8 @@ const tsConfig: ts.CompilerOptions = { // Language and Environment // ======================================================================== - target: ts.ScriptTarget.ES2015, - // target: "es6", // Specify ECMAScript target version + // target: ts.ScriptTarget.ES2015, + target: "es6", // Specify ECMAScript target version // ES3 = 0, // ES5 = 1, // ES2015 = 2, @@ -86,8 +86,8 @@ const tsConfig: ts.CompilerOptions = { // moduleSuffixes?: string[]; // moduleDetection?: ModuleDetectionKind; - module: ts.ModuleKind.CommonJS, - // module: "commonjs", // Specify module code generation + // 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.