diff --git a/.github/cicd/.vscode/settings.json b/.github/cicd/.vscode/settings.json index 0b4a69a6..554eea51 100644 --- a/.github/cicd/.vscode/settings.json +++ b/.github/cicd/.vscode/settings.json @@ -17,6 +17,7 @@ }, "cSpell.words": [ "CICD", + "indianred", "Kinson", "Velaptor" ], diff --git a/.github/cicd/core/CLI.ts b/.github/cicd/core/CLI.ts deleted file mode 100644 index 57a981df..00000000 --- a/.github/cicd/core/CLI.ts +++ /dev/null @@ -1,38 +0,0 @@ -/** - * A simple CLI command wrapper. - */ -export class CLI { - /** - * Runs the following CLI {@link command}. - * @param command The command to run. - * @returns The output of the command if successful, otherwise an error. - */ - public async runAsync(command: string): Promise { - if (command === undefined || command === null || command === "") { - const errorMsg = "The command parameter cannot be null or empty."; - console.log(errorMsg); - Deno.exit(1); - } - - if (!command.includes(" ")) { - const errorMsg = "The command parameter must include a space."; - console.log(errorMsg); - Deno.exit(1); - } - - const sections: string[] = command.split(" "); - - const app = sections[0]; - const args = sections.slice(1); - - const cmd = new Deno.Command(app, { args: args }); - - const { code, stdout, stderr } = await cmd.output(); - - if (code === 0) { - return new TextDecoder().decode(stdout); - } else { - return new Error(new TextDecoder().decode(stderr)); - } - } -} diff --git a/.github/cicd/core/DefaultDocTool.ts b/.github/cicd/core/DefaultDocTool.ts index ede0012c..aadf1ae5 100644 --- a/.github/cicd/core/DefaultDocTool.ts +++ b/.github/cicd/core/DefaultDocTool.ts @@ -1,7 +1,6 @@ import { existsSync, RepoClient } from "../deps.ts"; import { DotNetToolService } from "./services/DotNetToolService.ts"; import { Utils } from "./Utils.ts"; -import { CLI } from "./CLI.ts"; /** * Provides ability to generate documentation. @@ -39,9 +38,11 @@ export class DefaultDocTool { Utils.isNothing(outputDirPath); Utils.isNothing(configFilePath); - const defaultDocToolRepoVar = (await this.repoClient.getVariables()).find((repoVar) => { - return repoVar.name === this.DEFAULT_DOC_DOTNET_TOOL_VERSION; - }); + const defaultDocToolRepoVar = (await this.repoClient.getVariables()).find( + (repoVar) => { + return repoVar.name === this.DEFAULT_DOC_DOTNET_TOOL_VERSION; + }, + ); if (defaultDocToolRepoVar === undefined) { let errorMsg = `The required repo variable '${this.DEFAULT_DOC_DOTNET_TOOL_VERSION}' was not found.`; @@ -55,7 +56,10 @@ export class DefaultDocTool { ? defaultDocToolRepoVar.value.substring(1) : defaultDocToolRepoVar.value; - await this.dotNetToolService.setupDotNetTools(this.defaultDocToolName, defaultDocToolVersion); + await this.dotNetToolService.setupDotNetTools( + this.defaultDocToolName, + defaultDocToolVersion, + ); if (existsSync(outputDirPath, { isDirectory: true })) { Deno.removeSync(outputDirPath, { recursive: true }); @@ -63,8 +67,6 @@ export class DefaultDocTool { Deno.mkdirSync(outputDirPath, { recursive: true }); - const cli = new CLI(); - const args = [ "--AssemblyFilePath", `${assemblyPath}`, @@ -75,7 +77,7 @@ export class DefaultDocTool { ]; const command = `defaultdocumentation ${args.join(" ")}`; - const commandResult = await cli.runAsync(command); + const commandResult = await this.runAsync(command); if (commandResult instanceof Error) { Utils.printGitHubError(commandResult.message); @@ -84,4 +86,38 @@ export class DefaultDocTool { console.log(commandResult); } + + /** + * Runs the following CLI {@link command}. + * @param command The command to run. + * @returns The output of the command if successful, otherwise an error. + */ + public async runAsync(command: string): Promise { + if (command === undefined || command === null || command === "") { + const errorMsg = "The command parameter cannot be null or empty."; + console.log(errorMsg); + Deno.exit(1); + } + + if (!command.includes(" ")) { + const errorMsg = "The command parameter must include a space."; + console.log(errorMsg); + Deno.exit(1); + } + + const sections: string[] = command.split(" "); + + const app = sections[0]; + const args = sections.slice(1); + + const cmd = new Deno.Command(app, { args: args }); + + const { code, stdout, stderr } = await cmd.output(); + + if (code === 0) { + return new TextDecoder().decode(stdout); + } else { + return new Error(new TextDecoder().decode(stderr)); + } + } } diff --git a/.github/cicd/core/DocProcessor.ts b/.github/cicd/core/DocProcessor.ts index 8b23c801..522f930a 100644 --- a/.github/cicd/core/DocProcessor.ts +++ b/.github/cicd/core/DocProcessor.ts @@ -4,8 +4,7 @@ import { ValidateReleaseService } from "./services/ValidateReleaseService.ts"; import { MarkdownService } from "./services/MarkdownService.ts"; import { DefaultDocTool } from "./DefaultDocTool.ts"; import { Utils } from "./Utils.ts"; -import { Yarn } from "./Yarn.ts"; -import { crayon, existsSync, walkSync } from "../deps.ts"; +import { existsSync, walkSync } from "../deps.ts"; /** * Generates and performs post-processing on Velaptor API documentation. @@ -14,7 +13,6 @@ export class DocProcessor { private readonly cloneService: CloneRepoService; private readonly validateReleaseService: ValidateReleaseService; private readonly defaultDocTool: DefaultDocTool; - private readonly yarn: Yarn; /** * Initializes a new instance of the DocProcessor class. @@ -24,7 +22,6 @@ export class DocProcessor { this.cloneService = new CloneRepoService(); this.validateReleaseService = new ValidateReleaseService(); this.defaultDocTool = new DefaultDocTool(token); - this.yarn = new Yarn(); } /** @@ -34,24 +31,24 @@ export class DocProcessor { */ public async generateFromTag(apiDocsDirPath: string, releaseTag: string): Promise { if (Utils.isNothing(apiDocsDirPath)) { - console.log(crayon.red("The API doc dir path is required.")); + console.log("%cThe API doc dir path is required.", "color: indianred"); Deno.exit(1); } if (Utils.isNothing(releaseTag)) { - console.log(crayon.red("The release tag is required.")); + console.log("%cThe release tag is required.", "color: indianred"); Deno.exit(1); } - console.log(crayon.cyan(`Validating Release '${releaseTag}'. . .`)); + console.log(`%cValidating Release '${releaseTag}'. . .`, "color: cyan"); const isValid = await this.validateReleaseService.releaseExists(releaseTag); if (!isValid) { - console.log(crayon.red(`The release '${releaseTag}' is not valid.`)); + console.log(`%cThe release '${releaseTag}' is not valid.`, "color: indianred"); Deno.exit(1); } - console.log(crayon.cyan(`Release '${releaseTag}' Valid.`)); + console.log(`%cRelease '${releaseTag}' Valid.`, "color: cyan"); await this.run(apiDocsDirPath, releaseTag); } @@ -63,16 +60,16 @@ export class DocProcessor { */ public async generateFromBranch(apiDocDirPath: string, branchName: string): Promise { if (Utils.isNothing(apiDocDirPath)) { - console.log(crayon.red("The API doc dir path is required.")); + console.log("%cThe API doc dir path is required.", "color: indianred"); Deno.exit(1); } if (Utils.isNothing(branchName)) { - console.log(crayon.red("The branch name is required.")); + console.log("%cThe branch name is required.", "color: indianred"); Deno.exit(1); } - console.log(crayon.cyan(`Branch Name '${branchName}' Valid.`)); + console.log(`%cBranch Name '${branchName}' Valid.`, "color: cyan"); await this.run(apiDocDirPath, branchName); } @@ -141,11 +138,11 @@ export class DocProcessor { */ private async runProcess(startMsg: string, process: () => void | Promise, endMsg: string): Promise { console.log("\n-----------------------------------------------------------------\n"); - console.log(crayon.cyan(startMsg)); + console.log(`%c${startMsg}`, "color: indianred"); await process(); - console.log(crayon.cyan(`\n\n${endMsg}`)); + console.log(`%c\n\n${endMsg}`, "color: indianred"); } /** diff --git a/.github/cicd/core/Yarn.ts b/.github/cicd/core/Yarn.ts deleted file mode 100644 index 175b219e..00000000 --- a/.github/cicd/core/Yarn.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { crayon } from "../deps.ts"; - -/** - * Executes yarn commands. - */ -export class Yarn { - /** - * Runs yarn commands. - */ - public async run(commands: string[]): Promise { - if (commands === undefined || commands.length === 0) { - console.log(crayon.red("The commands parameter must not be empty.")); - Deno.exit(); - } - - const yarn = this.getYarnLocation(); - - console.log(crayon.lightBlack(`Running Yarn Command: ${commands.join(" ")}`)); - - const command = new Deno.Command(yarn, { - args: commands, - }); - - const { code, stdout, stderr } = await command.output(); - - if (code === 0) { - console.log(new TextDecoder().decode(stdout)); - } else { - console.log(new TextDecoder().decode(stderr)); - Deno.exit(code); - } - } - - /** - * Returns the system user name. - * @returns The system user name. - */ - private sysUserName(): string { - const envUserName: string | undefined = this.isWindowsEnv() ? Deno.env.get("USERNAME") : Deno.env.get("USER"); - - if (envUserName === undefined) { - console.log(crayon.red("Could not find the system user name.")); - Deno.exit(); - } - - return envUserName; - } - - /** - * Returns the executable location of yarn. - * @returns The executable location of yarn. - */ - private getYarnLocation(): string { - return this.isWindowsEnv() ? `C:/Users/${this.sysUserName()}/AppData/Roaming/npm/yarn.cmd` : "/usr/bin/yarn"; - } - - /** - * Returns a value indicating whether or not the current environment is windows. - * @returns True if the current environment is windows; otherwise false. - */ - private isWindowsEnv(): boolean { - return Deno.build.os === "windows"; - } -} diff --git a/.github/cicd/deps.ts b/.github/cicd/deps.ts index 2a7b3a11..1ff86461 100644 --- a/.github/cicd/deps.ts +++ b/.github/cicd/deps.ts @@ -1,10 +1,9 @@ // THIRD PARTY MODULE IMPORTS -import { copySync, emptyDirSync, ensureDirSync, existsSync, walkSync } from "https://deno.land/std@0.207.0/fs/mod.ts"; -import { basename, dirname, extname, parse, resolve } from "https://deno.land/std@0.207.0/path/mod.ts"; +import { copySync, emptyDirSync, ensureDirSync, existsSync, walkSync } from "https://deno.land/std@0.224.0/fs/mod.ts"; +import { basename, dirname, extname, parse, resolve } from "https://deno.land/std@0.224.0/path/mod.ts"; import { Input, Select } from "https://deno.land/x/cliffy@v1.0.0-rc.4/prompt/mod.ts"; -import { RepoClient, TagClient } from "https://deno.land/x/kd_clients@v1.0.0-preview.5/GitHubClients/mod.ts"; -import { NuGetClient } from "https://deno.land/x/kd_clients@v1.0.0-preview.5/PackageClients/NuGetClient.ts"; -import { crayon } from "https://deno.land/x/crayon@3.3.3/mod.ts"; +import { RepoClient, TagClient } from "https://deno.land/x/kd_clients@v1.0.0-preview.13/GitHubClients/mod.ts"; +import { NuGetClient } from "https://deno.land/x/kd_clients@v1.0.0-preview.13/PackageClients/NuGetClient.ts"; // RAW GITHUB IMPORTS import { Utils } from "https://raw.githubusercontent.com/KinsonDigital/Infrastructure/v13.6.3/cicd/core/Utils.ts"; @@ -16,7 +15,6 @@ export { copySync, emptyDirSync, ensureDirSync, existsSync, walkSync }; export { basename, dirname, extname, parse, resolve }; export { Input, Select }; export { NuGetClient, RepoClient, TagClient }; -export { crayon }; // RAW GITHUB IMPORTS export { Utils }; diff --git a/.github/cicd/playground.ts b/.github/cicd/playground.ts index af43f5ca..56f293dc 100644 --- a/.github/cicd/playground.ts +++ b/.github/cicd/playground.ts @@ -1,2 +1,2 @@ -const _rootRepoDirPath = Deno.args[0]; -const _token = Deno.args[1]; +const _rootRepoDirPath = (Deno.env.get("ROOT_REPO_DIR_PATH") ?? "").trim().replaceAll("\\", "/"); +const _token = (Deno.env.get("GITHUB_TOKEN") ?? ""); diff --git a/.github/cicd/scripts/delete-oldest-api-docs.ts b/.github/cicd/scripts/delete-oldest-api-docs.ts index f081f8bc..622627f6 100644 --- a/.github/cicd/scripts/delete-oldest-api-docs.ts +++ b/.github/cicd/scripts/delete-oldest-api-docs.ts @@ -1,4 +1,3 @@ -import { crayon } from "../deps.ts"; import { Utils } from "../core/Utils.ts"; import { DeleteAPIVersionService } from "../core/services/DeleteAPIVersionService.ts"; import { VersionsFileService } from "../core/services/VersionsFileService.ts"; @@ -8,21 +7,21 @@ import { VersionsFileService } from "../core/services/VersionsFileService.ts"; * to delete the oldest api docs version from the repo. */ -if (Deno.args.length <= 0) { - const errorMsg = "The script requires a single argument of where to start searching for the versions file."; +const versionsFileSearchDirPath = (Deno.env.get("SEARCH_DIR_PATH") ?? "").trim(); + +if (versionsFileSearchDirPath === "") { + const errorMsg = "The environment variable 'SEARCH_DIR_PATH' does not exist."; Utils.printGitHubError(errorMsg); Deno.exit(1); } -const versionsFileSearchDirPath = Deno.args[0].trim(); - const allVersions = new VersionsFileService(versionsFileSearchDirPath).getVersions(); const oldestVersion = Utils.getOldestVersion(allVersions); const versionsFileService: DeleteAPIVersionService = new DeleteAPIVersionService(versionsFileSearchDirPath); -console.log(crayon.cyan(`Deleting '${oldestVersion}' API docs. . .`)); +console.log(`%cDeleting '${oldestVersion}' API docs. . .`, "color: cyan"); versionsFileService.deleteOldestDocs(); -console.log(crayon.cyan(`API docs for version '${oldestVersion}' fully removed.`)); +console.log(`%cAPI docs for version '${oldestVersion}' fully removed.`, "color: cyan"); diff --git a/.github/cicd/scripts/generate-new-api-docs.ts b/.github/cicd/scripts/generate-new-api-docs.ts index 2c866855..dc8f36e7 100644 --- a/.github/cicd/scripts/generate-new-api-docs.ts +++ b/.github/cicd/scripts/generate-new-api-docs.ts @@ -4,28 +4,32 @@ import { Utils } from "../deps.ts"; console.clear(); -if (Deno.args.length < 3) { - let errorMsg = `The required number of arguments is 3 but only '${Deno.args.length}' were given.`; - errorMsg += "\nThe required arguments are:"; - errorMsg += "\n\t1. The path to the directory to generate the API documentation."; - errorMsg += "\n\t2. The tag or branch name to generate the API documentation from."; - errorMsg += "\n\t3. The GitHub token to use for accessing the GitHub API."; - - console.error(`::error::${errorMsg}`); +type GenerateSrcType = "api version" | "branch"; + +const generateOutputDirPath: string = (Deno.env.get("OUTPUT_DIR_PATH") ?? "").trim(); + +if (generateOutputDirPath === "") { + Utils.printAsGitHubError("The environment variable 'OUTPUT_DIR_PATH' does not exist."); Deno.exit(1); } -type GenerateSrcType = "api version" | "branch"; +let tagOrBranch = (Deno.env.get("TAG_OR_BRANCH") ?? "").trim().toLowerCase(); -const generateOutputDirPath: string = Deno.args[0]; -let tagOrBranch = Deno.args[1].trim().toLowerCase(); +if (tagOrBranch === "") { + Utils.printAsGitHubError("The environment variable 'TAG_OR_BRANCH' does not exist."); + Deno.exit(1); +} -const token = Deno.args[2].trim(); +const token = (Deno.env.get("GITHUB_TOKEN") ?? "").trim(); + +if (token === "") { + Utils.printAsGitHubError("The environment variable 'GITHUB_TOKEN' does not exist."); +} -// Optional argument -const isInteractive = Deno.args.length >= 4 && Deno.args[3].trim().toLowerCase() === "true"; +// Optional env variable +const isInteractive = (Deno.env.get("IS_INTERACTIVE") ?? "").trim().toLowerCase() === "true"; -console.log(`Generate Output Dir Path: ${generateOutputDirPath}`); +Utils.printAsGitHubNotice(`Generate Output Dir Path: ${generateOutputDirPath}`); /*NOTE: This script is executed by the 'api-release.yml' workflow. The workflow @@ -54,7 +58,7 @@ if (isInteractive) { if (Utils.isNothing(token)) { const errorMsg = "The environment variable 'CICD_TOKEN' does not exist, is empty, or null."; - console.log(errorMsg); + Utils.printAsGitHubError(errorMsg); Deno.exit(1); } @@ -72,7 +76,7 @@ if (isInteractive) { Deno.exit(); } } else { - console.log(`Version To Generate: ${tagOrBranch}`); + Utils.printAsGitHubNotice(`Version To Generate: ${tagOrBranch}`); tagOrBranch = tagOrBranch.startsWith("v") ? tagOrBranch : `v${tagOrBranch}`; } diff --git a/.github/cicd/scripts/next-versioning.ts b/.github/cicd/scripts/next-versioning.ts deleted file mode 100644 index 86099fc9..00000000 --- a/.github/cicd/scripts/next-versioning.ts +++ /dev/null @@ -1,50 +0,0 @@ -throw new Error("Next versioning has been disabled"); - -// // Check the arguments -// if (Deno.args.length < 2) { -// let errorMsg = "There must be 2 arguments"; -// errorMsg += "Usage: deno run FlagService.ts <[enable | disable]>"; - -// throw Error(errorMsg); -// } - -// const filePath = Deno.args[0].trim(); - -// // Validate the file path argument -// if (!existsSync(filePath, { isFile: true })) { -// throw Error(`The file path '${filePath}' does not exist.`); -// } - -// const setting: "enable" | "disable" = <"enable" | "disable">Deno.args[1]; - -// // Validate the enable disable argument -// if (setting != "enable" && setting != "disable") { -// throw Error(`The third argument must be either 'enable' or 'disable'.`); -// } - -// // const baseDirPath = Deno.cwd(); -// // const docuConfigFileName = "docusaurus.config.ts"; -// // const docuConfigFilePath = `${baseDirPath}/${docuConfigFileName}`; - -// const fileDoesNotExist = !existsSync(filePath, { isFile: true }); - -// if (fileDoesNotExist) { -// const errorMsg = `The file '${filePath}' does not exist.`; -// console.error(errorMsg); -// Deno.exit(1); -// } - -// const settingRegex = /includeCurrentVersion:\s(true|false).*/gm; - -// let fileContent = Deno.readTextFileSync(filePath); - -// if (!settingRegex.test(fileContent)) { -// const errorMsg = `The setting 'includeCurrentVersion' does not exist in the file '${filePath}'.` + -// "\nThe setting is enabled by default if it does not exist."; -// console.error(errorMsg); -// Deno.exit(1); -// } - -// const replacement = setting === "enable" ? "includeCurrentVersion: true" : "includeCurrentVersion: false"; -// fileContent = fileContent.replace(settingRegex, replacement); -// Deno.writeTextFileSync(filePath, fileContent); diff --git a/.github/cicd/scripts/update-tut-links.ts b/.github/cicd/scripts/update-tut-links.ts deleted file mode 100644 index 778cb892..00000000 --- a/.github/cicd/scripts/update-tut-links.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { Utils } from "../core/Utils.ts"; -import { existsSync, Select, TagClient, walkSync } from "../deps.ts"; - -// If no args were passed -if (Deno.args.length < 3) { - const errorMsg = "Please provide 3 arguments to update the guide projects." + - "\n1. The root directory path to start searching for guide projects." + - "\n2. The version number to update the Velaptor NuGet packages to." + - "\n3. The GitHub token."; - - Utils.printGitHubError(errorMsg); - Deno.exit(100); -} - -const rootDirPath = Deno.args[0].trim().replaceAll("\\", "/"); - -// If the directory does not exist, throw and error - -if (!existsSync(rootDirPath, { isDirectory: true })) { - console.log(`::error::The given directory path '${rootDirPath}' does not exist.`); - Deno.exit(200); -} - -const possibleVersion = Deno.args[1].trim().toLowerCase(); -const isInteractive = possibleVersion === "interactive"; - -let newVersion = ""; - -if (isInteractive) { - const token = Deno.args[2].trim(); - const tagClient = new TagClient("KinsonDigital", "Velaptor", token); - - const tags = (await tagClient.getAllTags()).map((tag) => tag.name); - - newVersion = await Select.prompt({ - message: "Select a Velaptor version", - options: tags, - validate: (value: string) => Utils.isPrevOrProdVersion(value), - }); - - console.log(`The tag selected was: ${newVersion}`); -} else { - newVersion = possibleVersion; -} - -newVersion = newVersion.startsWith("v") ? newVersion : `v${newVersion}`; - -const tutCompRegex = - //; - -// Get all the mdx files -const projFileEntries = walkSync(rootDirPath, { - includeDirs: false, - includeFiles: true, - exts: [".mdx"], -}); - -const mdxFiles = [...projFileEntries].map((entry) => entry.path); - -// Replace the tutorial link component with the new one -mdxFiles.forEach((file) => { - const fileData = Deno.readTextFileSync(file); - - const tutCompRefs = tutCompRegex.exec(fileData)?.map((match) => match.toString()) ?? []; - - if (tutCompRefs.length === 0) { - Utils.printGitHubNotice(`The file '${file}' does not contain any tutorial components.`); - return; - } - - const tutCompRef = tutCompRefs.length >= 0 ? tutCompRefs[0] : ""; - const containsTutCompRef = !Utils.isNothing(tutCompRef); - - // If the file contains the tutorial component - if (containsTutCompRef) { - const projName = tutCompRef.split("projectName=")[1].split(" ")[0].replaceAll('"', ""); - const newTutComp = ``; - - const versionRegex = /v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?/; - const oldVersion = versionRegex.exec(tutCompRef)?.map((match) => match.toString())[0] ?? ""; - - const newFileData = fileData.replace(tutCompRegex, newTutComp); - - Deno.writeTextFileSync(file, newFileData); - - const updateFileMsg = `The tutorial component was updated from version` + - `'${oldVersion}' to version '${newVersion}' in the mdx file '${file}`; - - Utils.printGitHubNotice(updateFileMsg); - } -}); diff --git a/.github/cicd/scripts/update-velaptor-nugets.ts b/.github/cicd/scripts/update-velaptor-nugets.ts index fc7ea96a..1d122b21 100644 --- a/.github/cicd/scripts/update-velaptor-nugets.ts +++ b/.github/cicd/scripts/update-velaptor-nugets.ts @@ -1,19 +1,14 @@ import { Utils } from "../core/Utils.ts"; import { existsSync, Select, TagClient, walkSync } from "../deps.ts"; -// If no args were passed -if (Deno.args.length < 3) { - const errorMsg = "Please provide 3 arguments to update the guide projects." + - "\n1. The root directory path to start searching for guide projects." + - "\n2. The version number to update the Velaptor NuGet packages to." + - "\n3. The GitHub token."; +const rootDirPath = (Deno.env.get("ROOT_DIR_PATH") ?? "").trim().replaceAll("\\", "/"); +if (rootDirPath === "") { + const errorMsg = "The environment variable 'ROOT_DIR_PATH' does not exist."; Utils.printGitHubError(errorMsg); - Deno.exit(100); + Deno.exit(1); } -const rootDirPath = Deno.args[0].trim().replaceAll("\\", "/"); - // If the directory does not exist, throw and error if (!existsSync(rootDirPath, { isDirectory: true })) { console.log(`::error::The given directory path '${rootDirPath}' does not exist.`); @@ -22,13 +17,27 @@ if (!existsSync(rootDirPath, { isDirectory: true })) { const tagRegex = /^v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?$/; -const possibleVersion = Deno.args[1].trim().toLowerCase(); +const possibleVersion = (Deno.env.get("VERSION_OR_INTERACTIVE") ?? "").trim().toLowerCase(); + +if (possibleVersion === "") { + const errorMsg = "The environment variable 'VERSION_OR_INTERACTIVE' does not exist."; + Utils.printGitHubError(errorMsg); + Deno.exit(1); +} + const isInteractive = possibleVersion === "interactive"; let newVersion = ""; if (isInteractive) { - const token = Deno.args[2].trim(); + const token = (Deno.env.get("GITHUB_TOKEN") ?? "").trim(); + + if (token === "") { + const errorMsg = "The environment variable 'GITHUB_TOKEN' does not exist."; + Utils.printGitHubError(errorMsg); + Deno.exit(1); + } + const tagClient = new TagClient("KinsonDigital", "Velaptor", token); const tags = (await tagClient.getAllTags()).map((tag) => tag.name); diff --git a/.github/cicd/scripts/velaptor-version-exists.ts b/.github/cicd/scripts/velaptor-version-exists.ts index b451360f..d0d9243a 100644 --- a/.github/cicd/scripts/velaptor-version-exists.ts +++ b/.github/cicd/scripts/velaptor-version-exists.ts @@ -1,37 +1,23 @@ -import { TagClient } from "../deps.ts"; +import { TagClient, Utils } from "../deps.ts"; -if (Deno.args.length < 2) { - const errorMsg = `The required number of arguments is 2 but received ${Deno.args.length}.`; - console.log(`::error::${errorMsg}`); +const version = (Deno.env.get("VERSION") ?? "").trim().toLowerCase(); + +if (version === "") { + Utils.printAsGitHubError("The environment variable 'VERSION' does not exist."); Deno.exit(1); } -const containsPAT = (value: string): boolean => { - const fineGrainedTokenPrefix = "github_pat_"; - const classicTokenPrefix = "ghp_"; - - return value.startsWith(fineGrainedTokenPrefix) || value.startsWith(classicTokenPrefix); -}; - -const versionRegex = /^v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?$/gm; -const version = Deno.args[0].trim().toLowerCase(); -const token = Deno.args[1].trim(); +const token = (Deno.env.get("GITHUB_TOKEN") ?? "").trim(); -if (containsPAT(version)) { - const errorMsg = "The version cannot contain a GitHub PAT."; - console.log(`::error::${errorMsg}`); +if (token === "") { + Utils.printAsGitHubError("The environment variable 'GITHUB_TOKEN' does not exist."); Deno.exit(1); } -if (!containsPAT(token)) { - const errorMsg = "The 2nd argument must be a GitHub PAT."; - console.log(`::error::${errorMsg}`); - Deno.exit(1); -} +const versionRegex = /^v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(-preview\.([1-9]\d*))?$/gm; if (!versionRegex.test(version)) { - const errorMsg = `The version '${version}' is not a valid version.`; - console.log(`::error::${errorMsg}`); + Utils.printAsGitHubError(`The version '${version}' is not a valid version.`); Deno.exit(1); } @@ -43,7 +29,6 @@ const tagClient: TagClient = new TagClient(ownerName, repoName, token); const versionDoesNotExist = !(await tagClient.tagExists(version)); if (versionDoesNotExist) { - const errorMsg = `The Velaptor version '${version}' does not exist.`; - console.log(`::error::${errorMsg}`); + Utils.printAsGitHubError(`The Velaptor version '${version}' does not exist.`); Deno.exit(1); } diff --git a/.github/cicd/workflow-helpers/BranchType.ts b/.github/cicd/workflow-helpers/BranchType.ts deleted file mode 100644 index afbf2b1d..00000000 --- a/.github/cicd/workflow-helpers/BranchType.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum BranchType { - main, - feature, -} diff --git a/.github/cicd/workflow-helpers/BranchValidator.ts b/.github/cicd/workflow-helpers/BranchValidator.ts deleted file mode 100644 index a148d578..00000000 --- a/.github/cicd/workflow-helpers/BranchValidator.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { BranchType } from "./BranchType.ts"; - -export class BranchValidator { - private static readonly featureBranchRegEx = /^(?!.*--)feature\/\d+-[^A-Z]+(? guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: Can you imagine playing Mario Brothers games without the **jump** sound effect? How about playing Metroid with no music diff --git a/docs/guides/guides/input/keyboard-input.mdx b/docs/guides/guides/input/keyboard-input.mdx index 2a22314d..1ce671e8 100644 --- a/docs/guides/guides/input/keyboard-input.mdx +++ b/docs/guides/guides/input/keyboard-input.mdx @@ -20,7 +20,7 @@ to keyboard input are endless. Examples of what you can do with the keyboard are and exiting the game when necessary. :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: diff --git a/docs/guides/guides/input/mouse-input.mdx b/docs/guides/guides/input/mouse-input.mdx index 54447a75..a1f12b37 100644 --- a/docs/guides/guides/input/mouse-input.mdx +++ b/docs/guides/guides/input/mouse-input.mdx @@ -7,7 +7,7 @@ import GuideLink from "@site/src/components/GuideLink"; # Mouse Input :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: As explained in the [Keyboard Input](./keyboard-input) tutorial, being able to interact with a game is very important. diff --git a/docs/guides/guides/project-setup.mdx b/docs/guides/guides/project-setup.mdx index de4a2c1f..11a97d91 100644 --- a/docs/guides/guides/project-setup.mdx +++ b/docs/guides/guides/project-setup.mdx @@ -12,7 +12,7 @@ import Url from "@site/src/components/Url"; This guide will show you the basics of creating a simple, empty Velaptor application. :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: :::note Guide Source Code diff --git a/docs/guides/guides/rendering-atlas-textures.mdx b/docs/guides/guides/rendering-atlas-textures.mdx index 95dd85e4..78748e5d 100644 --- a/docs/guides/guides/rendering-atlas-textures.mdx +++ b/docs/guides/guides/rendering-atlas-textures.mdx @@ -9,7 +9,7 @@ import StaticDownload from "@site/src/components/StaticDownload"; # Rendering With An Atlas Texture :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: Another way to render textures is by using an atlas texture. This guide is a little more diff --git a/docs/guides/guides/rendering-primitives/rendering-circles.mdx b/docs/guides/guides/rendering-primitives/rendering-circles.mdx index 2d7849b5..4144e0d8 100644 --- a/docs/guides/guides/rendering-primitives/rendering-circles.mdx +++ b/docs/guides/guides/rendering-primitives/rendering-circles.mdx @@ -9,7 +9,7 @@ import ClrText from "@site/src/components/ClrText"; # Rendering Circles :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. This guide will show you only some steps relative to the guide project. It will only show you the most essential information related to rendering circles. diff --git a/docs/guides/guides/rendering-primitives/rendering-lines.mdx b/docs/guides/guides/rendering-primitives/rendering-lines.mdx index d5a591ea..11e08671 100644 --- a/docs/guides/guides/rendering-primitives/rendering-lines.mdx +++ b/docs/guides/guides/rendering-primitives/rendering-lines.mdx @@ -9,7 +9,7 @@ import ClrText from "@site/src/components/ClrText"; # Rendering Lines :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. This guide will show you only some steps relative to the guide project. It will only show you the essential information related to rendering lines. diff --git a/docs/guides/guides/rendering-primitives/rendering-rectangles.mdx b/docs/guides/guides/rendering-primitives/rendering-rectangles.mdx index eb84c071..47d76876 100644 --- a/docs/guides/guides/rendering-primitives/rendering-rectangles.mdx +++ b/docs/guides/guides/rendering-primitives/rendering-rectangles.mdx @@ -9,7 +9,7 @@ import ClrText from "@site/src/components/ClrText"; # Rendering Rectangles :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. This guide will show you only some steps relative to the guide project. It will only show you the most essential information related to rendering rectangles. diff --git a/docs/guides/guides/rendering-text.mdx b/docs/guides/guides/rendering-text.mdx index aca44768..2cdcca6a 100644 --- a/docs/guides/guides/rendering-text.mdx +++ b/docs/guides/guides/rendering-text.mdx @@ -9,7 +9,7 @@ import GuideLink from "@site/src/components/GuideLink"; This guide will show you the basics of rendering text to a window using **Velaptor**. :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: diff --git a/docs/guides/guides/rendering-textures.mdx b/docs/guides/guides/rendering-textures.mdx index e949b2c2..27ab53e6 100644 --- a/docs/guides/guides/rendering-textures.mdx +++ b/docs/guides/guides/rendering-textures.mdx @@ -12,7 +12,7 @@ A game cannot be a game without having the ability to render textures. This guid textures to the screen. :::note Guide Source Code -Go to the guide project to see the source code for a fully working example of this guide. +Go to the guide project to see the source code for a fully working example of this guide. ::: diff --git a/docs/guides/guides/scenes/scene-management.mdx b/docs/guides/guides/scenes/scene-management.mdx index 927d9679..f4fe12cc 100644 --- a/docs/guides/guides/scenes/scene-management.mdx +++ b/docs/guides/guides/scenes/scene-management.mdx @@ -14,8 +14,8 @@ import StaticDownload from "@site/src/components/StaticDownload"; :::note Guide Source Code Go to the following links for the source code for fully working examples of managed and unmanaged scenes. -- -- +- +- ::: When it comes to games, how you manage your scenes can impact many aspects of your game. It can improve performance by only loading what