Skip to content

Commit

Permalink
0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Aug 13, 2023
1 parent 0f982e4 commit b38b637
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions Source/Command/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
7 changes: 7 additions & 0 deletions Source/Library/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions Source/Library/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
(
Expand Down
6 changes: 6 additions & 0 deletions Target/Command/Build.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 7 additions & 0 deletions Target/Library/File.d.ts
Original file line number Diff line number Diff line change
@@ -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<any>;
export default _default;
8 changes: 8 additions & 0 deletions Target/Library/JSON.d.ts
Original file line number Diff line number Diff line change
@@ -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<any>;
export default _default;
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -30,5 +32,8 @@
"devDependencies": {
"@types/node": "20.4.10",
"ts-node": "10.9.1"
},
"publishConfig": {
"access": "public"
}
}

0 comments on commit b38b637

Please sign in to comment.