Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Sep 22, 2023
1 parent 98b3302 commit ec73955
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 54 deletions.
5 changes: 3 additions & 2 deletions Script/Configuration/ESBuild.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PluginBuild as Build, BuildOptions as Option } from "esbuild";
import type { PluginBuild as Build, BuildOptions as Type } from "esbuild";

import { copy as Copy } from "esbuild-plugin-copy";
import {
access as Access,
Expand Down Expand Up @@ -49,4 +50,4 @@ export default {
],
}),
],
} satisfies Option;
} satisfies Type as Type;
14 changes: 8 additions & 6 deletions Script/Source/Command/Cloudflare.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { constants as Constant } from "fs";
import { access, mkdir, rm, writeFile } from "fs/promises";
import { dirname as Dir } from "path";
import gitDirectories from "../Library/Directory.js";
import type { Type as Files } from "../Interface/Files.js";

import Directory from "../Library/Directory.js";
import Package from "../Library/Package.js";
import Type from "../Library/Type.js";
import Cloudflare from "../Option/Cloudflare.js";
import type { Files } from "../Option/Index.js";

import { constants as Constant } from "fs";
import { access, mkdir, rm, writeFile } from "fs/promises";
import { dirname as Dir } from "path";

/**
* The function `Workflow` iterates through a list of files, checks if a specific file exists, and
Expand All @@ -15,7 +17,7 @@ import type { Files } from "../Option/Index.js";
*/
const Workflow = async (files: Files) => {
for (const { Path, Name, File } of files) {
for (const [directory, packageFiles] of await gitDirectories(
for (const [directory, packageFiles] of await Directory(
await Package("Cloudflare")
)) {
const githubDir = `${directory}/.github`;
Expand Down
12 changes: 7 additions & 5 deletions Script/Source/Command/Dependabot.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import type { Type as Files } from "../Interface/Files.js";

import DirsGit from "../Library/Directory.js";
import Packages from "../Library/Package.js";
import Types from "../Library/Type.js";
import Dependabot from "../Option/Dependabot.js";

import { constants as Constant } from "fs";
import {
access as Access,
Expand All @@ -6,11 +13,6 @@ import {
writeFile as _File,
} from "fs/promises";
import { dirname as Dir } from "path";
import DirsGit from "../Library/Directory.js";
import Packages from "../Library/Package.js";
import Types from "../Library/Type.js";
import Dependabot from "../Option/Dependabot.js";
import type { Files } from "../Option/Index.js";

/**
* It creates a `dependabot.yml` file in each `.github` directory of each repository in the current
Expand Down
20 changes: 14 additions & 6 deletions Script/Source/Command/NPM.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { constants as Constant } from "fs";
import { access as Access, mkdir as Dir, rm as Remove, readFile as _File, writeFile as __File } from "fs/promises";
import { dirname } from "path";
import gitDirectories from "../Library/Directory.js";
import type { Type as Files } from "../Interface/Files.js";

import Directory from "../Library/Directory.js";
import Package from "../Library/Package.js";
import Type from "../Library/Type.js";
import type { Files } from "../Option/Index.js";
import NPM from "../Option/NPM.js";

import { constants as Constant } from "fs";
import {
access as Access,
mkdir as Dir,
rm as Remove,
readFile as _File,
writeFile as __File,
} from "fs/promises";
import { dirname } from "path";

/**
* This function writes workflows for npm packages based on their package.json files.
* @param {Files} Files - The `files` parameter is an array of objects containing information
* about the files to be processed. Each object has the following properties:
*/
const Workflow = async (Files: Files) => {
for (const { Path, Name, File } of Files) {
for (const [directory, packageFiles] of await gitDirectories(
for (const [directory, packageFiles] of await Directory(
await Package("NPM")
)) {
const githubDir = `${directory}/.github`;
Expand Down
14 changes: 8 additions & 6 deletions Script/Source/Command/Node.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { constants as Constant } from "fs";
import { access, mkdir, readFile, rm, writeFile } from "fs/promises";
import { dirname as Dir } from "path";
import gitDirectories from "../Library/Directory.js";
import type { Type as Files } from "../Interface/Files.js";

import Directory from "../Library/Directory.js";
import Package from "../Library/Package.js";
import Type from "../Library/Type.js";
import Node from "../Option/Node.js";
import type { Files } from "../Option/Index.js";

import { constants as Constant } from "fs";
import { access, mkdir, readFile, rm, writeFile } from "fs/promises";
import { dirname as Dir } from "path";

/**
* It takes a list of files, and for each file, it checks if the file is a workflow file, and if it is,
Expand All @@ -16,7 +18,7 @@ import type { Files } from "../Option/Index.js";
*/
const Workflow = async (files: Files) => {
for (const { Path, Name, File } of files) {
for (const [directory, packageFiles] of await gitDirectories(
for (const [directory, packageFiles] of await Directory(
await Package("NPM")
)) {
const githubDir = `${directory}/.github`;
Expand Down
16 changes: 9 additions & 7 deletions Script/Source/Command/Rust.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import type { Type as Files } from "../Interface/Files.js";

import Directory from "../Library/Directory.js";
import Packages from "../Library/Package.js";
import Types from "../Library/Type.js";
import Rust from "../Option/Rust.js";

import { constants as Constant } from "fs";
import {
access as Access,
writeFile as _File,
mkdir as Dir,
rm as Remove,
writeFile as _File,
} from "fs/promises";
import { basename, dirname } from "path";
import gitDirectories from "../Library/Directory.js";
import Packages from "../Library/Package.js";
import Types from "../Library/Type.js";
import Rust from "../Option/Rust.js";
import type { Files } from "../Option/Index.js";

/**
* It takes a list of files, and for each file, it checks if the file is a workflow file, and if it is,
Expand All @@ -21,7 +23,7 @@ import type { Files } from "../Option/Index.js";
*/
const Workflow = async (Files: Files) => {
for (const { Path, Name, File } of Files) {
for (const [directory, packageFiles] of await gitDirectories(
for (const [directory, packageFiles] of await Directory(
await Packages("Cargo")
)) {
const githubDir = `${directory}/.github`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Files = Set<{
export type Type = Set<{
Path: string;
Name: string;
File: () => Promise<Set<string>>;
Expand Down
11 changes: 11 additions & 0 deletions Script/Source/Library/Directory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import WalkUntilGit from "./WalkUntilGit.js";

/**
* The function `Directory` takes a set of file globs, walks through the directories
* until it finds a Git repository, and returns a map where the keys are the directories
* and the values are sets of globs associated with each directory.
* @param Globs - Globs is a Set of strings representing file globs. A file glob is a
* pattern used to match file paths. For example, "*.js" would match all JavaScript
* files in a directory. The Globs parameter is a set of these file globs that will be
* used to search for files in
* @returns The function `Directory` returns a `Map` object where the keys are directory
* paths and the values are sets of glob patterns associated with each directory.
*/
export default async (Globs: Set<string>) => {
const Results = new Map();

Expand Down
8 changes: 5 additions & 3 deletions Script/Source/Library/Package.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Glob from "fast-glob";
import type { Type } from "./Type.js";

import Environment from "./Environment.js";
import Types from "./Type.js";
import type { Filter } from "./Type.js";

export default async (Filter: Filter = false) =>
import Glob from "fast-glob";

export default async (Filter: Type = false) =>
new Set<string>(
[
...(await Glob(
Expand Down
6 changes: 4 additions & 2 deletions Script/Source/Library/Request.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Octokit } from "@octokit/core";
import type { OctokitResponse } from "@octokit/types";

import Environment from "../Library/Environment.js";

import { Octokit } from "@octokit/core";
import { deepmerge as Merge } from "deepmerge-ts";
import Tag from "etag";
import Environment from "../Library/Environment.js";

const OCTOKIT = new Octokit({
auth: Environment.Token,
Expand Down
6 changes: 3 additions & 3 deletions Script/Source/Library/Type.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export type Filter =
export type Type =
| "NPM"
| "Cargo"
| "Composer"
| "Nuget"
| "Cloudflare"
| false;

export default async (Filter: Filter = false) => {
const Result = new Map<string, Filter>();
export default async (Filter: Type = false) => {
const Result = new Map<string, Type>();

Result.set("package.json", "NPM");
Result.set("Cargo.toml", "Cargo");
Expand Down
5 changes: 3 additions & 2 deletions Script/Source/Option/Cloudflare.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Type as Files } from "../Interface/Files.js";

import { readFile as File } from "fs/promises";
import { dirname as Dir, resolve as Resolve } from "path";
import { fileURLToPath as Path } from "url";
import type { Files } from "./Index.js";

export default new Set([
{
Expand All @@ -21,4 +22,4 @@ export default new Set([
).toString(),
]),
},
]) satisfies Files;
]) satisfies Files as Files;
6 changes: 4 additions & 2 deletions Script/Source/Option/Command.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { CommandOptions as Options } from "commander";
import type { CommandOptions as Type } from "commander";

/* The `Commands` variable is a set of objects representing different commands that can be executed in
a program. Each object in the set has the following properties: */
const Commands: Set<{
Name: string;
Opts?: Options;
Opts?: Type;
Type?: "Workflow";
Description?: string;
Arguments?: Set<{
Expand Down
6 changes: 3 additions & 3 deletions Script/Source/Option/Dependabot.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Type as Files } from "../Interface/Files.js";

import { readFile as File } from "fs/promises";
import { dirname as Dir, resolve as Resolve } from "path";

import { fileURLToPath as Path } from "url";
import type { Files } from "./Index.js";

export default new Set([
{
Expand Down Expand Up @@ -39,4 +39,4 @@ export default new Set([
).toString(),
]),
},
]) satisfies Files;
]) satisfies Files as Files;
5 changes: 3 additions & 2 deletions Script/Source/Option/NPM.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Type as Files } from "../Interface/Files.js";

import { readFile as File } from "fs/promises";
import { dirname as Dir, resolve as Resolve } from "path";
import { fileURLToPath as Path } from "url";
import type { Files } from "./Index.js";

export default new Set([
{
Expand All @@ -21,4 +22,4 @@ export default new Set([
).toString(),
]),
},
]) satisfies Files;
]) satisfies Files as Files;
5 changes: 3 additions & 2 deletions Script/Source/Option/Node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Type as Files } from "../Interface/Files.js";

import { readFile as File } from "fs/promises";
import { dirname as Dir, resolve as Resolve } from "path";
import { fileURLToPath as Path } from "url";
import type { Files } from "./Index.js";

export default new Set([
{
Expand All @@ -21,4 +22,4 @@ export default new Set([
).toString(),
]),
},
]) satisfies Files;
]) satisfies Files as Files;
5 changes: 3 additions & 2 deletions Script/Source/Option/Rust.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Type as Files } from "../Interface/Files.js";

import { readFile as File } from "fs/promises";
import { dirname as Dir, resolve as Resolve } from "path";
import { fileURLToPath as Path } from "url";
import type { Files } from "./Index.js";

export default new Set([
{
Expand All @@ -21,4 +22,4 @@ export default new Set([
).toString(),
]),
},
]) satisfies Files;
]) satisfies Files as Files;

0 comments on commit ec73955

Please sign in to comment.