From b38b63755f6d895ac02f3adc5461cd655fce8a00 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 13 Aug 2023 04:18:44 +0300 Subject: [PATCH] 0.1.2 --- README.md | 6 ++++-- Source/Command/Build.ts | 6 ++++++ Source/Library/File.ts | 7 +++++++ Source/Library/JSON.ts | 8 ++++++++ Target/Command/Build.d.ts | 6 ++++++ Target/Library/File.d.ts | 7 +++++++ Target/Library/JSON.d.ts | 8 ++++++++ package.json | 5 +++++ 8 files changed, 51 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a864bf11..0cabe743 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Build scripts and configuration +# [TypeScript Build] 🧑🏻‍💻 + +This utility deletes all deployments older than 7 days in your Cloudflare Pages account. ## Installation @@ -51,5 +53,5 @@ npm install -D -E typescriptbuild The script will now automatically compile your build files with [esbuild] and add TypeScript types. -[typescriptbuild]: https://npmjs.org/typescriptbuild +[TypeScript Build]: https://npmjs.org/typescriptbuild [esbuild]: https://npmjs.org/esbuild diff --git a/Source/Command/Build.ts b/Source/Command/Build.ts index cf508858..21cdb445 100644 --- a/Source/Command/Build.ts +++ b/Source/Command/Build.ts @@ -9,6 +9,12 @@ import File from "../Library/File.js"; export type Pipe = string[]; +/** + * The `Build` function compiles and builds TypeScript files using esbuild and TypeScript compiler. + * @param {Pattern[]} Files - An array of file patterns to be processed. Each pattern can include + * wildcards (*) to match multiple files. + * @param [Options] - The `Options` parameter is an optional object that can contain two properties: + */ export default async ( Files: Pattern[], Options?: { esbuild?: string; TypeScript?: string } diff --git a/Source/Library/File.ts b/Source/Library/File.ts index 10a0928f..f151f6d9 100644 --- a/Source/Library/File.ts +++ b/Source/Library/File.ts @@ -3,6 +3,13 @@ import TypeScript from "typescript"; import { pathToFileURL as URL } from "url"; import _JSON from "./JSON.js"; +/** + * The function takes a file path as input, checks if it is a TypeScript file, converts the TypeScript + * code to JavaScript, and then imports and returns the default export of the JavaScript file. + * @param {string} Path - The `Path` parameter is a string that represents the file path of the file + * you want to process. + * @returns the default export of the module that is imported using the provided `Path`. + */ export default async (Path: string) => { if (Path.split(".").pop() === "ts") { const { options } = TypeScript.convertCompilerOptionsFromJson( diff --git a/Source/Library/JSON.ts b/Source/Library/JSON.ts index 0b31dd5f..826a6770 100644 --- a/Source/Library/JSON.ts +++ b/Source/Library/JSON.ts @@ -2,6 +2,14 @@ import { readFile as _File } from "fs/promises"; import { dirname as Dir } from "path"; import { fileURLToPath as Path } from "url"; +/** + * The function `JSON` is a TypeScript function that reads a JSON file and returns its parsed content. + * @param {string} File - The `File` parameter is a string that represents the name or path of the JSON + * file that you want to parse. + * @param {string} From - The `From` parameter is a string that represents the source URL or file path + * from which the JSON file will be loaded. It is set to `import.meta.url` by default, which refers to + * the URL of the current module. However, if a different source URL or file path is provided, + */ export default async (File: string, From: string = import.meta.url) => JSON.parse( ( diff --git a/Target/Command/Build.d.ts b/Target/Command/Build.d.ts index 5f5bdab3..4614a504 100644 --- a/Target/Command/Build.d.ts +++ b/Target/Command/Build.d.ts @@ -1,5 +1,11 @@ import type { Pattern } from "fast-glob"; export type Pipe = string[]; +/** + * The `Build` function compiles and builds TypeScript files using esbuild and TypeScript compiler. + * @param {Pattern[]} Files - An array of file patterns to be processed. Each pattern can include + * wildcards (*) to match multiple files. + * @param [Options] - The `Options` parameter is an optional object that can contain two properties: + */ declare const _default: (Files: Pattern[], Options?: { esbuild?: string; TypeScript?: string; diff --git a/Target/Library/File.d.ts b/Target/Library/File.d.ts index dab01a91..5614969b 100644 --- a/Target/Library/File.d.ts +++ b/Target/Library/File.d.ts @@ -1,2 +1,9 @@ +/** + * The function takes a file path as input, checks if it is a TypeScript file, converts the TypeScript + * code to JavaScript, and then imports and returns the default export of the JavaScript file. + * @param {string} Path - The `Path` parameter is a string that represents the file path of the file + * you want to process. + * @returns the default export of the module that is imported using the provided `Path`. + */ declare const _default: (Path: string) => Promise; export default _default; diff --git a/Target/Library/JSON.d.ts b/Target/Library/JSON.d.ts index dbbd59fc..c5dbfdf4 100644 --- a/Target/Library/JSON.d.ts +++ b/Target/Library/JSON.d.ts @@ -1,2 +1,10 @@ +/** + * The function `JSON` is a TypeScript function that reads a JSON file and returns its parsed content. + * @param {string} File - The `File` parameter is a string that represents the name or path of the JSON + * file that you want to parse. + * @param {string} From - The `From` parameter is a string that represents the source URL or file path + * from which the JSON file will be loaded. It is set to `import.meta.url` by default, which refers to + * the URL of the current module. However, if a different source URL or file path is provided, + */ declare const _default: (File: string, From?: string) => Promise; export default _default; diff --git a/package.json b/package.json index 2675fb12..b8ba5f95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,8 @@ { "name": "typescriptbuild", "version": "0.1.2", + "private": false, + "description": "🧑🏻‍💻 Builds all TypeScript files within a given directory with esbuild.", "homepage": "https://github.com/NikolaRHristov/TypeScriptBuild#readme", "bugs": { "url": "https://github.com/NikolaRHristov/TypeScriptBuild/issues" @@ -30,5 +32,8 @@ "devDependencies": { "@types/node": "20.4.10", "ts-node": "10.9.1" + }, + "publishConfig": { + "access": "public" } }