From e2186ecbc05fb22e5ae26b2f7dd38e148c4006ec Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Wed, 4 Dec 2024 10:30:55 +0200 Subject: [PATCH] --- CHANGELOG.md | 209 ++++++++++++++++----------------- Source/Function/Build.ts | 79 +++++++++++++ Source/Function/Exec.ts | 22 ++++ Source/Interface/Build.ts | 29 +++++ Source/Interface/Merge/Into.ts | 24 ++++ 5 files changed, 258 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ca9062e..e0ecc217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,241 +2,240 @@ ### Changed -- Updated version to 0.1.9 -- Updated email in package.json from "Source/Open@PlayForm.Cloud" to - "Source/Open@PlayForm.LTD" -- Updated URL in package.json from "HTTPS://PlayForm.Cloud" to - "HTTPS://PlayForm.LTD" -- Updated @types/node from version 22.7.7 to 22.9.0 +- Updated version to 0.1.9 +- Updated email in package.json from "Source/Open@PlayForm.Cloud" to + "Source/Open@PlayForm.LTD" +- Updated URL in package.json from "HTTPS://PlayForm.Cloud" to + "HTTPS://PlayForm.LTD" +- Updated @types/node from version 22.7.7 to 22.9.0 ## 0.1.8 ### Changed -- Updated dependencies. -- Migrated from `deepmerge-ts`'s `deepmergeCustom` to a custom merge function - for more control. -- Improved the merging logic for `entryPoints` in the - [ESBuild](https://esbuild.github.io/api/#plugins) configuration to prevent - unwanted array flattening. +- Updated dependencies. +- Migrated from `deepmerge-ts`'s `deepmergeCustom` to a custom merge function + for more control. +- Improved the merging logic for `entryPoints` in the + [ESBuild](https://esbuild.github.io/api/#plugins) configuration to prevent + unwanted array flattening. ## 0.1.7 ### Changed -- Updated dependencies. -- Simplified documentation folder structure. +- Updated dependencies. +- Simplified documentation folder structure. ## 0.1.6 ### Changed -- Simplified build process to improve performance. -- Updated dependencies. +- Simplified build process to improve performance. +- Updated dependencies. ## 0.1.5 ### Changed -- Updated @types/node to version 22.5.4 -- Improved build process to include CSS files. -- Enhanced file path handling in the build process using path module - functions. -- Updated dependencies: - - esbuild - - ts-node +- Updated @types/node to version 22.5.4 +- Improved build process to include CSS files. +- Enhanced file path handling in the build process using path module functions. +- Updated dependencies: + - esbuild + - ts-node ### Added -- Added the ability to exclude files/folders from the build process. -- Added `ignore` option to the Build interface. +- Added the ability to exclude files/folders from the build process. +- Added `ignore` option to the Build interface. ## 0.1.4 ### Changed -- Updated `@types/node` to version 22.5.0 -- Updated `esbuild` to version 0.23.1 -- Updated `typescript` to version 5.5.4 -- Reverted `ts-node` to version 10.9.2 -- Improved file path handling in the build process. +- Updated `@types/node` to version 22.5.0 +- Updated `esbuild` to version 0.23.1 +- Updated `typescript` to version 5.5.4 +- Reverted `ts-node` to version 10.9.2 +- Improved file path handling in the build process. ### Added -- Added `experimentalDecorators` option to tsconfig.json +- Added `experimentalDecorators` option to tsconfig.json ## 0.1.3 ### Changed -- Updated version to 0.1.3 -- Updated dependencies: - - @types/node from 20.14.12 to 22.0.2 -- Minor code formatting changes +- Updated version to 0.1.3 +- Updated dependencies: + - @types/node from 20.14.12 to 22.0.2 +- Minor code formatting changes ### Added -- Added `provenance: true` to publishConfig in package.json -- Added `access: public` to publishConfig in package.json +- Added `provenance: true` to publishConfig in package.json +- Added `access: public` to publishConfig in package.json ## 0.1.2 ### Changed -- Updated version to 0.1.2 -- Updated dependencies: - - @types/node to 20.14.12 - - deepmerge-ts to 7.1.0 - - typescript to "\*" (latest) -- Updated devDependencies: - - ts-node to 11.0.0-beta.1 -- Improved error handling in Exec function +- Updated version to 0.1.2 +- Updated dependencies: + - @types/node to 20.14.12 + - deepmerge-ts to 7.1.0 + - typescript to "\*" (latest) +- Updated devDependencies: + - ts-node to 11.0.0-beta.1 +- Improved error handling in Exec function ### Added -- Added `provenance: true` to publishConfig in package.json +- Added `provenance: true` to publishConfig in package.json ## 0.1.1 ### Changed -- Updated version to 0.1.1 -- Updated "Run" script to include "--Watch" option instead of "-W" +- Updated version to 0.1.1 +- Updated "Run" script to include "--Watch" option instead of "-W" ## 0.1.0 ### Changed -- Updated version to 0.1.0 -- Updated dependencies -- Modified Build function to support watch mode -- Updated TypeScript configuration -- Updated command-line interface with clearer descriptions. -- Expanded README.md with detailed usage instructions and examples. +- Updated version to 0.1.0 +- Updated dependencies +- Modified Build function to support watch mode +- Updated TypeScript configuration +- Updated command-line interface with clearer descriptions. +- Expanded README.md with detailed usage instructions and examples. ### Added -- Added Watch option to Build command +- Added Watch option to Build command ### Removed -- Removed peerDependencies +- Removed peerDependencies ## 0.0.11 ### Changed -- Updated dependencies +- Updated dependencies ## 0.0.10 ### Changed -- Removed Document script -- Updated dependencies +- Removed Document script +- Updated dependencies ## 0.0.9 ### Changed -- Updated version to 0.0.9 -- Updated package.json metadata -- Updated dependencies -- Modified package.json structure +- Updated version to 0.0.9 +- Updated package.json metadata +- Updated dependencies +- Modified package.json structure ### Added -- Added peerDependencies -- Added peerDependenciesMeta for optional dependencies +- Added peerDependencies +- Added peerDependenciesMeta for optional dependencies ## 0.0.8 ### Changed -- Updated version to 0.0.8 -- Updated package description and keywords -- Updated homepage and repository URLs -- Updated repository and author information -- Updated dependencies -- Improved command-line interface descriptions. +- Updated version to 0.0.8 +- Updated package description and keywords +- Updated homepage and repository URLs +- Updated repository and author information +- Updated dependencies +- Improved command-line interface descriptions. ## 0.0.7 ### Changed -- Updated version to 0.0.7 -- Updated repository URLs to use HTTPS +- Updated version to 0.0.7 +- Updated repository URLs to use HTTPS ## 0.0.6 ### Changed -- Updated version to 0.0.6 -- Updated package description -- Updated author information -- Updated dependencies -- Removed @playform/document from devDependencies +- Updated version to 0.0.6 +- Updated package description +- Updated author information +- Updated dependencies +- Removed @playform/document from devDependencies ## 0.0.5 ### Changed -- Updated version to 0.0.5 -- Updated package.json scripts +- Updated version to 0.0.5 +- Updated package.json scripts ### Added -- Added @playform/document as a peer dependency +- Added @playform/document as a peer dependency ## 0.0.4 ### Changed -- Updated version to 0.0.4 (corrected from 0.0.5 in the summary) -- Added "Document" script -- Updated peerDependencies -- Minor code formatting changes +- Updated version to 0.0.4 (corrected from 0.0.5 in the summary) +- Added "Document" script +- Updated peerDependencies +- Minor code formatting changes ## 0.0.3 ### Changed -- Updated version to 0.0.3 -- Updated dependencies -- Modified Build function to incorporate `tsc-alias`. -- Set `logLevel` in ESBuild configuration to "debug" for enhanced debugging. +- Updated version to 0.0.3 +- Updated dependencies +- Modified Build function to incorporate `tsc-alias`. +- Set `logLevel` in ESBuild configuration to "debug" for enhanced debugging. ### Added -- Added `tsc-alias` to dependencies +- Added `tsc-alias` to dependencies ## 0.0.2 ### Changed -- Major refactoring and restructuring of the project. -- Updated package name to "@playform/build". -- Updated version to 0.0.2. -- Updated package description, keywords, and metadata. -- Updated dependencies. -- Modified source files structure and content. -- Changed main and types file paths. -- Updated scripts in package.json. -- Simplified configuration by integrating `TypeScript.json` settings into - `tsconfig.json`. -- Removed `esbuild-plugin-copy`. +- Major refactoring and restructuring of the project. +- Updated package name to "@playform/build". +- Updated version to 0.0.2. +- Updated package description, keywords, and metadata. +- Updated dependencies. +- Modified source files structure and content. +- Changed main and types file paths. +- Updated scripts in package.json. +- Simplified configuration by integrating `TypeScript.json` settings into + `tsconfig.json`. +- Removed `esbuild-plugin-copy`. ### Added -- Added new source files and interfaces. +- Added new source files and interfaces. ### Removed -- Removed several old source files and configurations. -- Removed `TypeScriptESBuild.ts` and shifted core logic to `Build.ts`. +- Removed several old source files and configurations. +- Removed `TypeScriptESBuild.ts` and shifted core logic to `Build.ts`. ## 0.0.1 ### Added -- Initial release +- Initial release diff --git a/Source/Function/Build.ts b/Source/Function/Build.ts index e69de29b..1b2d2d26 100644 --- a/Source/Function/Build.ts +++ b/Source/Function/Build.ts @@ -0,0 +1,79 @@ +import type Interface from "../Interface/Build.js"; + +/** + * @module Build + * + */ +export default (async (...[File, Option]) => { + for (const _File of File) { + for (const __File of await ( + await import("fast-glob") + ).default(_File.replaceAll("'", "").replaceAll('"', ""), { + ignore: Option?.Exclude ?? [], + })) { + Pipe.push(__File); + } + } + + Pipe.reverse(); + + const Configuration = (await import("../Variable/ESBuild.js")).default; + + Merge(Configuration, { + entryPoints: Pipe, + }); + + if (Option?.ESBuild) { + Merge( + Configuration, + await (await import("@Function/File.js")).default(Option.ESBuild), + ); + } + + Merge(Configuration, { + tsconfig: Option?.TypeScript ?? "tsconfig.json", + }); + + if (!Configuration.plugins && !Array.isArray(Configuration.plugins)) { + Configuration.plugins = []; + } + + Configuration.plugins?.push({ + name: "TypeScript", + setup({ onEnd }) { + onEnd(async () => { + await Exec(`tsc -p ${Configuration.tsconfig}`); + await Exec(`tsc-alias -f -p ${Configuration.tsconfig}`); + }); + }, + }); + + if (Option?.Watch) { + await (await (await import("esbuild")).context(Configuration)).watch(); + } else { + console.log( + await ( + await import("esbuild") + ).analyzeMetafile( + (await (await import("esbuild")).build(Configuration)) + ?.metafile ?? "", + { + verbose: true, + }, + ), + ); + } +}) satisfies Interface as Interface; + +export const { default: Exec } = await import("../Function/Exec.js"); + +export const { default: Merge } = await import("../Function/Merge.js"); + +export const Pipe: string[] = []; + +export const { extname, basename, relative, dirname, normalize, sep } = + await import("path"); + +export const Current = (await import("url")).fileURLToPath( + dirname(import.meta.url), +); diff --git a/Source/Function/Exec.ts b/Source/Function/Exec.ts index e69de29b..e83f7ca4 100644 --- a/Source/Function/Exec.ts +++ b/Source/Function/Exec.ts @@ -0,0 +1,22 @@ +import type Interface from "../Interface/Exec.js"; + +/** + * @module Exec + * + */ +export default (async ( + ...[Command, Echo = async (Return) => console.log(Return)] +) => { + try { + const { stdout, stderr } = (await import("child_process")).exec( + Command, + ); + + if (typeof Echo === "function") { + stdout?.on("data", async (Data) => await Echo(Data.trim())); + stderr?.on("data", async (Data) => await Echo(Data.trim(), true)); + } + } catch (_Error) { + console.log(_Error); + } +}) satisfies Interface as Interface; diff --git a/Source/Interface/Build.ts b/Source/Interface/Build.ts index e69de29b..478edd17 100644 --- a/Source/Interface/Build.ts +++ b/Source/Interface/Build.ts @@ -0,0 +1,29 @@ +import type { Pattern } from "fast-glob"; + +/** + * @module Build + * + */ +export default interface Interface { + /** + * Represents a function that processes file patterns. + * + * @param File - An array of file patterns to be processed. Each pattern can include wildcards (*) to match multiple files. + * + * @param Option - An optional object that can contain two properties. + * + * @param Option.ESBuild - A string representing the ESBuild option. + * + * @param Option.TypeScript - A string representing the TypeScript option. + * + */ + ( + File: Pattern[], + Option?: { + ESBuild?: string; + TypeScript?: string; + Watch?: boolean; + Exclude?: Pattern[]; + }, + ): Promise; +} diff --git a/Source/Interface/Merge/Into.ts b/Source/Interface/Merge/Into.ts index e69de29b..109dbe56 100644 --- a/Source/Interface/Merge/Into.ts +++ b/Source/Interface/Merge/Into.ts @@ -0,0 +1,24 @@ +import type { + DeepMergeBuiltInMetaData, + DeepMergeFunctionsDefaultURIs, + DeepMergeHKT, +} from "deepmerge-ts"; + +export default interface Interface { + >( + target: Target, + ...objects: Ts + ): asserts target is Target & + DeepMergeHKT< + [Target, ...Ts], + { + DeepMergeArraysURI: DeepMergeFunctionsDefaultURIs["DeepMergeArraysURI"]; + DeepMergeFilterValuesURI: DeepMergeFunctionsDefaultURIs["DeepMergeFilterValuesURI"]; + DeepMergeMapsURI: DeepMergeFunctionsDefaultURIs["DeepMergeMapsURI"]; + DeepMergeOthersURI: DeepMergeFunctionsDefaultURIs["DeepMergeOthersURI"]; + DeepMergeRecordsURI: DeepMergeFunctionsDefaultURIs["DeepMergeRecordsURI"]; + DeepMergeSetsURI: DeepMergeFunctionsDefaultURIs["DeepMergeSetsURI"]; + }, + DeepMergeBuiltInMetaData + >; +}