diff --git a/.github/cicd/scripts/deno-build.ts b/.github/cicd/scripts/deno-build.ts deleted file mode 100644 index 3e9caec..0000000 --- a/.github/cicd/scripts/deno-build.ts +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env -S deno run --allow-read --allow-run - -import { existsSync } from "https://deno.land/std@0.224.0/fs/exists.ts"; -import { Guards } from "../../../src/core/guards.ts"; -import { DenoBuildSettings } from "./deno-build-settings.ts"; -import { checkAll } from "./deno-check.ts"; -import { ConsoleLogColor } from "../../../src/core/console-log-color.ts"; - -let arg = (Deno.args[0] ?? "").trim(); - -let settingsFilePath = arg === "" ? "./deno-build-settings.json" : arg; -settingsFilePath = settingsFilePath.replace(/\\/gm, "/"); - - -/** - * Gets the settings if a 'prepare-release-settings.json' file exists in the current working directory. - * @returns The settings. - */ -const getSettings = (settingsFilePath: string): DenoBuildSettings | undefined=> { - if (!existsSync(settingsFilePath, { isFile: true })) { - return undefined; - } - - const settingJsonData = Deno.readTextFileSync(settingsFilePath); - - try { - const settings = JSON.parse(settingJsonData); - - return validSettingsObj(settings) ? settings : undefined; - } catch (error) { - const errorMsg = `There was a problem parsing the file '${settingsFilePath}'.\n${error.message}`; - console.log(errorMsg); - Deno.exit(1); - } -} - -const validSettingsObj = (settingsObj: unknown): settingsObj is DenoBuildSettings => { - if (settingsObj === null || typeof settingsObj === undefined || typeof settingsObj !== "object") { - return false; - } - - const propsExists = 'ignoreExpressions' in settingsObj; - - if (propsExists) { - return Guards.isNotNothing(settingsObj.ignoreExpressions) && - Array.isArray(settingsObj.ignoreExpressions) && - settingsObj.ignoreExpressions.every((b) => Guards.isString(b)); - } - - return false; -} - -const settings = getSettings(settingsFilePath); - -const ignores = settings?.ignoreExpressions.map((expression) => new RegExp(expression)); - -ConsoleLogColor.cyan(`Checking all files in '${Deno.cwd()}' . . .\n`); - -const results = await checkAll(Deno.cwd(), { - noNpm: false, - noLock: true, - skip: ignores, -}); - -const isFailure = results.some((result) => !result.hasPassed); - -if (isFailure) { - Deno.exit(1); -} diff --git a/.github/cicd/scripts/deno-check.ts b/.github/cicd/scripts/deno-check.ts deleted file mode 100644 index 8d100ac..0000000 --- a/.github/cicd/scripts/deno-check.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { walkSync } from "https://deno.land/std@0.216.0/fs/walk.ts"; -import { crayon } from "https://deno.land/x/crayon@3.3.3/mod.ts"; -import { Guards } from "../../../src/core/guards.ts"; -import { CheckOptions } from "./check-options.ts"; -import { CheckResult } from "./check-result.ts"; -import { toText } from "https://deno.land/std@0.224.0/streams/to_text.ts"; - -/** - * Checks a file using deno check. - * @param file The file to check. - * @param noNpm Whether to resolve npm modules. - * @param noNpm Disable auto discovery of the lock file. - * @returns A promise that resolves to a CheckResult. - */ -export async function checkFile(file: string, noNpm?: boolean, noLock?: boolean): Promise { - Guards.isNothing(file); - - const checkResult: CheckResult = { - file: file, - result: "", - hasPassed: true, // Default to passed - }; - - checkResult.result += `Checking ${file}`; - - const args = ["check"]; - - if (noNpm === true) { - args.push("--no-npm"); - } - - if (noLock === false) { - args.push("--lock"); - args.push("deno.lock"); - } - - args.push(file); - - const denoCheckCmd = new Deno.Command("deno", { args: args, stdout: "piped", stderr: "piped" }); - - const subProcess = denoCheckCmd.spawn(); - - const successMsg = await toText(subProcess.stdout); - const errorMsg = await toText(subProcess.stderr); - const status = await subProcess.status; - - if (status.success) { - checkResult.result += crayon.lightBlack(successMsg); - checkResult.result += crayon.lightBlack("✅\n"); - } else { - checkResult.result += crayon.lightBlack("❌\n"); - checkResult.result += crayon.lightBlack(` ${errorMsg}`); - checkResult.hasPassed = false; - } - - return checkResult; -} - -/** - * Performs a deno check against all of the given {@link files}. - * @param files All of the files to run deno check against. - * @param options The options to use when checking the file. - * @returns A promise that resolves to an array of {@link CheckResult}'s that contain the result for each file. - */ -export async function checkFiles(files: string[], options?: CheckOptions): Promise { - Guards.isNothing(files); - - const filesToCheck: Promise[] = []; - - // Perform a deno check on all of the files - for await (const file of files) { - filesToCheck.push(checkFile(file, options?.noNpm, options?.noLock)); - } - - // Wait for all of the checks to complete - const allCheckResults = await Promise.all(filesToCheck); - - // Print all of the results - allCheckResults.forEach((checkResult) => { - Deno.stdout.writeSync(new TextEncoder().encode(crayon.lightBlack(checkResult.result))); - }); - - // Collect the total number of passed and failed checks - const totalPassed = allCheckResults.filter((r) => r.hasPassed).length; - const totalFailed = allCheckResults.filter((r) => !r.hasPassed).length; - - const resultsMsg = new TextEncoder().encode(crayon.cyan(`\nTotal Passed(✅): ${totalPassed}\nTotal Failed(❌): ${totalFailed}\n`)); - Deno.stdout.writeSync(resultsMsg); - - return allCheckResults; -} - -/** - * Checks all of the files in the given {@link directory} including all of it's subdirectories. - * @param directory The directory and its subdirectories to check. - * @param options The options to use when checking the file. - * @returns A promise that resolves to an array of {@link CheckResult}'s that contain the result for each file. - */ -export async function checkAll(directory: string, options?: CheckOptions): Promise { - Guards.isNothing(directory); - - const files = [...walkSync(directory, { - includeDirs: false, - exts: [".ts", ".tsx"], - skip: options?.skip, - })].map((entry) => entry.path); - - return await checkFiles(files); -} diff --git a/.github/workflows/build-status-check.yml b/.github/workflows/build-status-check.yml index 0e675e8..123912b 100644 --- a/.github/workflows/build-status-check.yml +++ b/.github/workflows/build-status-check.yml @@ -1,5 +1,5 @@ -name: ✅Build Status Check -run-name: ✅Build Status Check (${{ github.base_ref }} branch) +name: ✅Check Status Check +run-name: ✅Check Status Check (${{ github.base_ref }} branch) defaults: @@ -29,6 +29,5 @@ jobs: with: deno-version: ${{ vars.DENO_VERSION }} - - name: Run Build - run: | - deno run --allow-read --allow-run "./.github/cicd/scripts/deno-build.ts"; + - name: Run Check + run: deno check **/*/*.ts; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e596131..6daf168 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,7 @@ jobs: run: | $scriptPath = "${{ github.workspace }}/.github/cicd/scripts/get-version.ts"; - deno run --allow-read --allow-write --allow-env "$scriptPath"; + deno run -R -W -E "$scriptPath"; validate_release: @@ -90,7 +90,10 @@ jobs: run: | $scriptPath = "${{ github.workspace }}/.github/cicd/scripts/version-checker.ts"; - deno run --allow-env --allow-net --allow-read "$scriptPath"; + deno run ` + -E ` + -N=raw.githubusercontent.com,github.com ` + -R "$scriptPath"; - name: Release Notes Exist env: @@ -99,7 +102,7 @@ jobs: run: | $scriptPath = "${{ github.workspace }}/.github/cicd/scripts/check-release-notes.ts"; - deno run --allow-env --allow-read "$scriptPath"; + deno run -E -R "$scriptPath"; release: @@ -115,14 +118,14 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Run Build - run: deno run --allow-read --allow-run ./.github/cicd/scripts/deno-build.ts + - name: Run Check + run: deno check **/*/*.ts; - name: Run Lint run: deno lint - name: Run Tests - run: deno test --allow-read ./tests/*Tests.ts; + run: deno test -R ./tests/*Tests.ts; - name: Create GitHub Release ${{ inputs.dry-run == true && '(Dry Run)' || '' }} if: ${{ inputs.dry-run == false }} @@ -171,7 +174,8 @@ jobs: 3. PAT #> deno run ` - --allow-read --allow-net ` + -R ` + -N=raw.githubusercontent.com,github.com ` "$scriptUrl" ` "${{ vars.PROJECT_NAME }}" ` "${{ needs.get_version.outputs.version }}" ` diff --git a/.github/workflows/sync-bot.yml b/.github/workflows/sync-bot.yml index eb8056a..5ae56d1 100644 --- a/.github/workflows/sync-bot.yml +++ b/.github/workflows/sync-bot.yml @@ -44,7 +44,7 @@ jobs: 5. PAT #> deno run ` - --allow-net ` + -N=raw.githubusercontent.com,github.com ` "$scriptUrl" ` "${{ vars.ORGANIZATION_NAME }}" ` "${{ vars.PROJECT_NAME }}" ` diff --git a/.github/workflows/sync-status-check.yml b/.github/workflows/sync-status-check.yml index 2e7bad5..953a37e 100644 --- a/.github/workflows/sync-status-check.yml +++ b/.github/workflows/sync-status-check.yml @@ -44,7 +44,7 @@ jobs: 5. PAT #> deno run ` - --allow-net ` + -N=raw.githubusercontent.com,github.com ` "$scriptUrl" ` "${{ vars.ORGANIZATION_NAME }}" ` "${{ vars.PROJECT_NAME }}" ` diff --git a/.github/workflows/test-status-check.yml b/.github/workflows/test-status-check.yml index a0a88f7..8fa54a8 100644 --- a/.github/workflows/test-status-check.yml +++ b/.github/workflows/test-status-check.yml @@ -29,4 +29,4 @@ jobs: deno-version: ${{ vars.DENO_VERSION }} - name: Run Tests - run: deno test --allow-read ./tests/*Tests.ts; + run: deno test -R ./tests/*Tests.ts; diff --git a/.vscode/launch.json b/.vscode/launch.json index b0edde0..a490d17 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -44,9 +44,9 @@ }, "runtimeArgs": [ "run", - "--allow-env", - "--allow-read", - "--allow-net", + "-E", + "-R", + "-N", "--inspect-wait", ], "args": [ @@ -69,10 +69,10 @@ }, "runtimeArgs": [ "run", - "--allow-env", - "--allow-read", - "--allow-write", - "--allow-net", + "-E", + "-R", + "-W", + "-N", "--allow-run", "--inspect-wait", ], @@ -120,9 +120,9 @@ "runtimeArgs": [ "run", "--inspect-wait", - "--allow-read", - "--allow-write", - "--allow-env", + "-R", + "-W", + "-E", ], "attachSimplePort": 9229, }, @@ -144,8 +144,8 @@ }, "runtimeArgs": [ "run", - "--allow-env", - "--allow-read", + "-E", + "-R", "--inspect-wait", ], "attachSimplePort": 9229, @@ -164,9 +164,9 @@ }, "runtimeArgs": [ "run", - "--allow-read", - "--allow-write", - "--allow-net", + "-R", + "-W", + "-N", "--allow-run", "--inspect-wait", ], @@ -190,9 +190,9 @@ }, "runtimeArgs": [ "run", - "--allow-read", - "--allow-write", - "--allow-net", + "-R", + "-W", + "-N", "--inspect-wait", ], "args": [ diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7b63abe..ad70e81 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -37,87 +37,6 @@ }, "group": "build" }, - { // BUILD - "label": "build", - "detail": "Builds the project by running deno check.", - "dependsOn": [ - "clear-screen" - ], - "command": "deno", - "type": "shell", - "args": [ - "run", - "--allow-read", - "--allow-run", - "--allow-sys", - "${workspaceFolder}/.github/cicd/scripts/deno-check.ts" - ], - "problemMatcher": [ - "$tsc" - ], - "presentation": { - "reveal": "always" - }, - "group": "build" - }, - { // LINT - "label": "lint", - "detail": "Performs linting on the project source code.", - "dependsOn": [ - "clear-screen" - ], - "command": "deno", - "type": "shell", - "args": [ - "lint", - ], - "problemMatcher": [ - "$tsc" - ], - "presentation": { - "reveal": "always" - }, - "group": "build" - }, - { // FORMAT - "label": "format", - "detail": "Performs formatting on the project source code.", - "dependsOn": [ - "clear-screen" - ], - "command": "deno", - "type": "shell", - "args": [ - "fmt", - ], - "problemMatcher": [ - "$tsc" - ], - "presentation": { - "reveal": "always" - }, - "group": "build" - }, - { // CACHE DEPENDENCIES - "label": "cache-dependencies", - "detail": "Cache dependencies for the project.", - "dependsOn": [ - "clear-screen" - ], - "command": "deno", - "type": "shell", - "args": [ - "cache", - "./deps.ts" - ], - "problemMatcher": [ - "$tsc" - ], - "presentation": { - "reveal": "always" - }, - "group": "build" - }, { // COMPILE ALL PLATFORMS "label": "compile-all", "detail": "Compiles the project into an executable.", diff --git a/deno.json b/deno.json index 9fb5372..c44ba34 100644 --- a/deno.json +++ b/deno.json @@ -1,9 +1,9 @@ { "version": "v1.0.0-preview.4", "tasks": { - "build": "./.github/cicd/scripts/deno-build.ts", + "check": "deno check **/*/*.ts", "tests": "deno test ./Tests/*Tests.ts", - "reload-cache": "deno cache --reload --lock=deno.lock --lock-write \"./deps.ts\"" + "reload-cache": "deno cache --reload --lock=deno.lock \"*/**/*.ts\"" }, "lint": { "include": [ diff --git a/deno.lock b/deno.lock index 02972d3..69396f8 100644 --- a/deno.lock +++ b/deno.lock @@ -18,6 +18,33 @@ } }, "remote": { + "https://deno.land/std@0.216.0/assert/assert.ts": "bec068b2fccdd434c138a555b19a2c2393b71dfaada02b7d568a01541e67cdc5", + "https://deno.land/std@0.216.0/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8", + "https://deno.land/std@0.216.0/fs/_create_walk_entry.ts": "5d9d2aaec05bcf09a06748b1684224d33eba7a4de24cf4cf5599991ca6b5b412", + "https://deno.land/std@0.216.0/fs/_to_path_string.ts": "29bfc9c6c112254961d75cbf6ba814d6de5349767818eb93090cecfa9665591e", + "https://deno.land/std@0.216.0/fs/walk.ts": "78e1d01a9f75715614bf8d6e58bd77d9fafb1222c41194e607cd3849d7a0e771", + "https://deno.land/std@0.216.0/path/_common/assert_path.ts": "2ca275f36ac1788b2acb60fb2b79cb06027198bc2ba6fb7e163efaedde98c297", + "https://deno.land/std@0.216.0/path/_common/basename.ts": "569744855bc8445f3a56087fd2aed56bdad39da971a8d92b138c9913aecc5fa2", + "https://deno.land/std@0.216.0/path/_common/constants.ts": "dc5f8057159f4b48cd304eb3027e42f1148cf4df1fb4240774d3492b5d12ac0c", + "https://deno.land/std@0.216.0/path/_common/from_file_url.ts": "d672bdeebc11bf80e99bf266f886c70963107bdd31134c4e249eef51133ceccf", + "https://deno.land/std@0.216.0/path/_common/normalize.ts": "684df4aa71a04bbcc346c692c8485594fc8a90b9408dfbc26ff32cf3e0c98cc8", + "https://deno.land/std@0.216.0/path/_common/normalize_string.ts": "dfdf657a1b1a7db7999f7c575ee7e6b0551d9c20f19486c6c3f5ff428384c965", + "https://deno.land/std@0.216.0/path/_common/strip_trailing_separators.ts": "7024a93447efcdcfeaa9339a98fa63ef9d53de363f1fbe9858970f1bba02655a", + "https://deno.land/std@0.216.0/path/_os.ts": "8fb9b90fb6b753bd8c77cfd8a33c2ff6c5f5bc185f50de8ca4ac6a05710b2c15", + "https://deno.land/std@0.216.0/path/basename.ts": "5d341aadb7ada266e2280561692c165771d071c98746fcb66da928870cd47668", + "https://deno.land/std@0.216.0/path/from_file_url.ts": "911833ae4fd10a1c84f6271f36151ab785955849117dc48c6e43b929504ee069", + "https://deno.land/std@0.216.0/path/join.ts": "ae2ec5ca44c7e84a235fd532e4a0116bfb1f2368b394db1c4fb75e3c0f26a33a", + "https://deno.land/std@0.216.0/path/normalize.ts": "4155743ccceeed319b350c1e62e931600272fad8ad00c417b91df093867a8352", + "https://deno.land/std@0.216.0/path/posix/_util.ts": "1e3937da30f080bfc99fe45d7ed23c47dd8585c5e473b2d771380d3a6937cf9d", + "https://deno.land/std@0.216.0/path/posix/basename.ts": "39ee27a29f1f35935d3603ccf01d53f3d6e0c5d4d0f84421e65bd1afeff42843", + "https://deno.land/std@0.216.0/path/posix/from_file_url.ts": "951aee3a2c46fd0ed488899d024c6352b59154c70552e90885ed0c2ab699bc40", + "https://deno.land/std@0.216.0/path/posix/join.ts": "aef88d5fa3650f7516730865dbb951594d1a955b785e2450dbee93b8e32694f3", + "https://deno.land/std@0.216.0/path/posix/normalize.ts": "baeb49816a8299f90a0237d214cef46f00ba3e95c0d2ceb74205a6a584b58a91", + "https://deno.land/std@0.216.0/path/windows/_util.ts": "d5f47363e5293fced22c984550d5e70e98e266cc3f31769e1710511803d04808", + "https://deno.land/std@0.216.0/path/windows/basename.ts": "e2dbf31d1d6385bfab1ce38c333aa290b6d7ae9e0ecb8234a654e583cf22f8fe", + "https://deno.land/std@0.216.0/path/windows/from_file_url.ts": "ced2d587b6dff18f963f269d745c4a599cf82b0c4007356bd957cb4cb52efc01", + "https://deno.land/std@0.216.0/path/windows/join.ts": "e0b3356615c1a75c56ebb6a7311157911659e11fd533d80d724800126b761ac3", + "https://deno.land/std@0.216.0/path/windows/normalize.ts": "78126170ab917f0ca355a9af9e65ad6bfa5be14d574c5fb09bb1920f52577780", "https://deno.land/std@0.218.2/assert/assert.ts": "bec068b2fccdd434c138a555b19a2c2393b71dfaada02b7d568a01541e67cdc5", "https://deno.land/std@0.218.2/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8", "https://deno.land/std@0.218.2/bytes/concat.ts": "9cac3b4376afbef98ff03588eb3cf948e0d1eb6c27cfe81a7651ab6dd3adc54a", @@ -171,6 +198,8 @@ "https://deno.land/std@0.224.0/assert/mod.ts": "48b8cb8a619ea0b7958ad7ee9376500fe902284bb36f0e32c598c3dc34cbd6f3", "https://deno.land/std@0.224.0/assert/unimplemented.ts": "8c55a5793e9147b4f1ef68cd66496b7d5ba7a9e7ca30c6da070c1a58da723d73", "https://deno.land/std@0.224.0/assert/unreachable.ts": "5ae3dbf63ef988615b93eb08d395dda771c96546565f9e521ed86f6510c29e19", + "https://deno.land/std@0.224.0/bytes/concat.ts": "86161274b5546a02bdb3154652418efe7af8c9310e8d54107a68aaa148e0f5ed", + "https://deno.land/std@0.224.0/bytes/copy.ts": "08d85062240a7223e6ec4e2af193ad1a50c59a43f0d86ac3a7b16f3e0d77c028", "https://deno.land/std@0.224.0/encoding/_util.ts": "beacef316c1255da9bc8e95afb1fa56ed69baef919c88dc06ae6cb7a6103d376", "https://deno.land/std@0.224.0/encoding/base64.ts": "dd59695391584c8ffc5a296ba82bcdba6dd8a84d41a6a539fbee8e5075286eaf", "https://deno.land/std@0.224.0/fmt/colors.ts": "508563c0659dd7198ba4bbf87e97f654af3c34eb56ba790260f252ad8012e1c5", @@ -194,6 +223,15 @@ "https://deno.land/std@0.224.0/internal/diff.ts": "6234a4b493ebe65dc67a18a0eb97ef683626a1166a1906232ce186ae9f65f4e6", "https://deno.land/std@0.224.0/internal/format.ts": "0a98ee226fd3d43450245b1844b47003419d34d210fa989900861c79820d21c2", "https://deno.land/std@0.224.0/internal/mod.ts": "534125398c8e7426183e12dc255bb635d94e06d0f93c60a297723abe69d3b22e", + "https://deno.land/std@0.224.0/io/_common.ts": "36705cdb4dfcd338d6131bca1b16e48a4d5bf0d1dada6ce397268e88c17a5835", + "https://deno.land/std@0.224.0/io/_constants.ts": "3c7ad4695832e6e4a32e35f218c70376b62bc78621ef069a4a0a3d55739f8856", + "https://deno.land/std@0.224.0/io/buffer.ts": "4d1f805f350433e418002accec798bc6c33ce18f614afa65f987c202d7b2234e", + "https://deno.land/std@0.224.0/io/iterate_reader.ts": "1e5e4fea22d8965afb7df4ee9ab9adda0a0fc581adbea31bc2f2d25453f8a6e9", + "https://deno.land/std@0.224.0/io/reader_from_stream_reader.ts": "a75bbc93f39df8b0e372cc1fbdc416a7cbf2a39fc4c09ddb057f1241100191c5", + "https://deno.land/std@0.224.0/io/to_readable_stream.ts": "ed03a44a1ec1cc55a85a857acf6cac472035298f6f3b6207ea209f93b4aefb39", + "https://deno.land/std@0.224.0/io/to_writable_stream.ts": "ef422e0425963c8a1e0481674e66c3023da50f0acbe5ef51ec9789efc3c1e2ed", + "https://deno.land/std@0.224.0/io/types.ts": "acecb3074c730b5ff487ba4fe9ce51e67bd982aa07c95e5f5679b7b2f24ad129", + "https://deno.land/std@0.224.0/io/write_all.ts": "24aac2312bb21096ae3ae0b102b22c26164d3249dff96dbac130958aa736f038", "https://deno.land/std@0.224.0/path/_common/assert_path.ts": "dbdd757a465b690b2cc72fc5fb7698c51507dec6bfafce4ca500c46b76ff7bd8", "https://deno.land/std@0.224.0/path/_common/basename.ts": "569744855bc8445f3a56087fd2aed56bdad39da971a8d92b138c9913aecc5fa2", "https://deno.land/std@0.224.0/path/_common/common.ts": "ef73c2860694775fe8ffcbcdd387f9f97c7a656febf0daa8c73b56f4d8a7bd4c", @@ -271,6 +309,29 @@ "https://deno.land/std@0.224.0/path/windows/resolve.ts": "8dae1dadfed9d46ff46cc337c9525c0c7d959fb400a6308f34595c45bdca1972", "https://deno.land/std@0.224.0/path/windows/to_file_url.ts": "40e560ee4854fe5a3d4d12976cef2f4e8914125c81b11f1108e127934ced502e", "https://deno.land/std@0.224.0/path/windows/to_namespaced_path.ts": "4ffa4fb6fae321448d5fe810b3ca741d84df4d7897e61ee29be961a6aac89a4c", + "https://deno.land/std@0.224.0/streams/_common.ts": "948735ef6d140cd6916dca861197b88fc57db52c2f923c392b7a14033d8fed4b", + "https://deno.land/std@0.224.0/streams/buffer.ts": "e012de72a53ad17c56512488e9afb6f4b6ed046b32fc1415ae7a4e6fc0efce38", + "https://deno.land/std@0.224.0/streams/byte_slice_stream.ts": "5bbdcadb118390affa9b3d0a0f73ef8e83754f59bb89df349add669dd9369713", + "https://deno.land/std@0.224.0/streams/delimiter_stream.ts": "4e4050740ff27a8824defa6c96126229ef9d794c4ace4ef9cabb10b5ad4a5d14", + "https://deno.land/std@0.224.0/streams/early_zip_readable_streams.ts": "21f5cf6dd36381c6a50c31a7727b5bd219f6382bbb7a413418595c3e466c4d14", + "https://deno.land/std@0.224.0/streams/iterate_reader.ts": "a8e698d16373d49821172f90ec7ac011ef1aae7a4036ae4bace284ff99e2bc92", + "https://deno.land/std@0.224.0/streams/limited_bytes_transform_stream.ts": "b22a45a337374e863c4eb1867ec6b8ad3e68620a6c52fe837746060ea610e6f1", + "https://deno.land/std@0.224.0/streams/limited_transform_stream.ts": "4c47da5ca38a30fa9f33b0f1a61d4548e7f52a9a58c294b0f430f680e44cc543", + "https://deno.land/std@0.224.0/streams/merge_readable_streams.ts": "73eed8ff54c9111b8b974b11a5a11c1ed0b7800e0157c39277ccac3ed14721e2", + "https://deno.land/std@0.224.0/streams/mod.ts": "d56624832b9649b680c74ab9c77e746e8be81ae1a24756cc04623e25a0d43ce9", + "https://deno.land/std@0.224.0/streams/readable_stream_from_reader.ts": "64943452485bcba48e203fa8ae61c195aed9ab8b2a178e2fc6a383f761ce010a", + "https://deno.land/std@0.224.0/streams/reader_from_iterable.ts": "e7b064142b2a97bb562d958c2e4b4d129e923e9c9f2f6e003a4e16cbdcd62570", + "https://deno.land/std@0.224.0/streams/reader_from_stream_reader.ts": "b3519118ed2a32e3fb6201a4c257d5c4e58c38b5918bdc505a45fccbfa0a53f9", + "https://deno.land/std@0.224.0/streams/text_delimiter_stream.ts": "94dfc900204e306496c1b58c80473db57b6097afdcb8ea9eaff453a193a659f1", + "https://deno.land/std@0.224.0/streams/text_line_stream.ts": "21f33d3922e019ec1a1676474beb543929cb564ec99b69cd2654e029e0f45bd5", + "https://deno.land/std@0.224.0/streams/to_array_buffer.ts": "1a9c07c4a396ce557ab205c44415815ab13b614fed94a12f62b80f8e650c726d", + "https://deno.land/std@0.224.0/streams/to_blob.ts": "bf5daaae50fa8f57e0c8bfd7474ebac16ac09e130e3d01ef2947ae5153912b4a", + "https://deno.land/std@0.224.0/streams/to_json.ts": "b6a908d0da7cd30956e5fbbfa7460747e50b8f307d1041282ed6fe9070d579ee", + "https://deno.land/std@0.224.0/streams/to_text.ts": "6f93593bdfc2cea5cca39755ea5caf0d4092580c0a713dfe04a1e85c60df331f", + "https://deno.land/std@0.224.0/streams/to_transform_stream.ts": "4c4836455ef89bab9ece55975ee3a819f07d3d8b0e43101ec7f4ed033c8a2b61", + "https://deno.land/std@0.224.0/streams/writable_stream_from_writer.ts": "527fc1b136fc53a9f0b32641f04a4522c72617fa7ca3778d27ed064f9cd98932", + "https://deno.land/std@0.224.0/streams/writer_from_stream_writer.ts": "22cba4e5162fc443c7e5ef62f2054674cd6a20f5d7519a62db8d201496463931", + "https://deno.land/std@0.224.0/streams/zip_readable_streams.ts": "53eb10d7557539b489bd858907aab6dd28247f074b3446573801de3150cb932e", "https://deno.land/std@0.224.0/testing/mock.ts": "a963181c2860b6ba3eb60e08b62c164d33cf5da7cd445893499b2efda20074db", "https://deno.land/x/cliffy@v1.0.0-rc.4/ansi/ansi_escapes.ts": "193b3c3a4e520274bd8322ca4cab1c3ce38070bed1898cb2ade12a585dddd7c9", "https://deno.land/x/cliffy@v1.0.0-rc.4/ansi/chain.ts": "eca61b1b64cad7b9799490c12c7aa5538d0f63ac65a73ddb6acac8b35f0a5323", @@ -356,6 +417,11 @@ "https://deno.land/x/cliffy@v1.0.0-rc.4/table/deps.ts": "cbb896e8d7a6b5e3c2b9dda7d16638c202d9b46eb738c2dae1fa9480d8091486", "https://deno.land/x/cliffy@v1.0.0-rc.4/table/row.ts": "79eb1468aafdd951e5963898cdafe0752d4ab4c519d5f847f3d8ecb8fe857d4f", "https://deno.land/x/cliffy@v1.0.0-rc.4/table/table.ts": "298671e72e61f1ab18b42ae36643181993f79e29b39dc411fdc6ffd53aa04684", + "https://deno.land/x/crayon@3.3.3/mod.ts": "82ad225583a483c4837577971629cddaa22614093af8353da6426b9366de9780", + "https://deno.land/x/crayon@3.3.3/src/conversions.ts": "9bfd3b1fbe412bcba092890ac558b6beaad4c3aa399cd99d45fadb324d28afd6", + "https://deno.land/x/crayon@3.3.3/src/crayon.ts": "6b237baa08a31c903436e040afd2228a7fffaa5d11dddc58e3c402f79b3c1d04", + "https://deno.land/x/crayon@3.3.3/src/styles.ts": "aa588b57b2c0482dc5c6f53109b4287831a9827c0aeef9a88129beae1172c1ee", + "https://deno.land/x/crayon@3.3.3/src/util.ts": "af8884a917488de76ac0c2b92482093ade74514ece77a4c64e5eb5b0f6ed68e6", "https://deno.land/x/kd_clients@v1.0.0-preview.13/GitHubClients/Errors/AuthError.ts": "bcc54cec31e2b14db5a9b420ac4c1dd06c079a1910e2f46e4c6e9106d405d932", "https://deno.land/x/kd_clients@v1.0.0-preview.13/GitHubClients/Errors/GitError.ts": "e32a1754ef85c9cfcf88e92ca1e44338f1a521c0ab04f3210f6c2297408339d1", "https://deno.land/x/kd_clients@v1.0.0-preview.13/GitHubClients/Errors/IssueError.ts": "3cb02e326067366857ecacefdf256ff8afb5981264a53ac50a31d74719801556", diff --git a/deps.ts b/deps.ts index e803eac..51213f6 100644 --- a/deps.ts +++ b/deps.ts @@ -5,7 +5,7 @@ import { existsSync, walkSync } from "https://deno.land/std@0.224.0/fs/mod.ts"; import { extname, resolve } from "https://deno.land/std@0.224.0/path/mod.ts"; import { assert, assertEquals, assertThrows, assertRejects, equal } from "https://deno.land/std@0.224.0/assert/mod.ts"; import { assertSpyCall, assertSpyCalls, spy, stub, returnsNext, returnsArg } from "https://deno.land/std@0.224.0/testing/mock.ts"; -import { toText } from "https://deno.land/std@0.218.2/streams/mod.ts"; +import { toText } from "https://deno.land/std@0.224.0/streams/mod.ts"; // Third Party Deno Modules import { RepoClient, TagClient, UsersClient, PullRequestClient, IssueClient, diff --git a/schemas/create-pr-schema.json b/schemas/create-pr-schema.json index fed7fa7..5dbff3f 100644 --- a/schemas/create-pr-schema.json +++ b/schemas/create-pr-schema.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft-07/schema", "type": "object", "properties": { "ownerName": { @@ -24,5 +24,10 @@ } } }, - "required": ["ownerName", "repoName", "githubTokenEnvVarName", "baseBranches"] + "required": [ + "ownerName", + "repoName", + "githubTokenEnvVarName", + "baseBranches" + ] } diff --git a/schemas/gen-release-notes-schema.json b/schemas/gen-release-notes-schema.json index d5c6914..95f3454 100644 --- a/schemas/gen-release-notes-schema.json +++ b/schemas/gen-release-notes-schema.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft-07/schema", "type": "object", "properties": { "ownerName": { @@ -22,13 +22,23 @@ "type": "string", "description": "The header of the release notes. Can use the `${REPONAME}`, `${RELEASETYPE}`, and '${VERSION}' placeholders." }, + "wordReplacements": { + "type": "object", + "description": "The word replacements to apply to the release notes.", + "minProperties": 1, + "patternProperties": { + ".+": { + "type": "string" + } + } + }, "releaseType": { "type": "string", - "description": "The type of release. Example: Preview, Production, etc." + "description": "The type of release. Example: Preview, Production, etc. (Optional)" }, "extraInfo": { "type": "object", - "description": "Extra information to include at the top of the release notes below the header.", + "description": "Extra information to include at the top of the release notes below the header. (Optional)", "required": ["title", "text"], "minProperties": 2, "maxProperties": 2, @@ -45,7 +55,7 @@ }, "emojisToRemoveFromTitle": { "type": "array", - "description": "The emojis to remove from the title of each release note item.", + "description": "The emojis to remove from the title of each release note item. (Optional)", "minItems": 1, "items": { "type": "string" @@ -53,7 +63,7 @@ }, "issueCategoryLabelMappings": { "type": "object", - "description": "The mappings between categories and issues labels.", + "description": "The mappings between categories and issues labels. (Optional)", "minProperties": 1, "patternProperties": { ".+": { @@ -63,7 +73,7 @@ }, "prCategoryLabelMappings": { "type": "object", - "description": "The mappings between categories and pull request labels.", + "description": "The mappings between categories and pull request labels. (Optional)", "minProperties": 1, "patternProperties": { ".+": { @@ -73,25 +83,15 @@ }, "ignoreLabels": { "type": "array", - "description": "The emojis to remove from the title of each release note item.", + "description": "The emojis to remove from the title of each release note item. (Optional)", "minItems": 1, "items": { "type": "string" } }, - "wordReplacements": { - "type": "object", - "description": "The word replacements to apply to the release notes.", - "minProperties": 1, - "patternProperties": { - ".+": { - "type": "string" - } - } - }, "firstWordReplacements": { "type": "object", - "description": "The word replacements to apply to the release notes.", + "description": "The word replacements to apply to the release notes. (Optional)", "minProperties": 1, "patternProperties": { ".+": { @@ -101,15 +101,15 @@ }, "boldedVersions": { "type": "boolean", - "description": "Whether to bold the versions in the release notes." + "description": "Whether to bold the versions in the release notes (Optional)." }, "italicVersions": { "type": "boolean", - "description": "Whether to italicize the versions in the release notes." + "description": "Whether to italicize the versions in the release notes (Optional)." }, "otherCategoryName": { "type": "string", - "description": "The name of the category for issues and pull requests that do not have a category label." + "description": "The name of the category for issues and pull requests that do not have a category label (Optional)." } }, "required": [ diff --git a/schemas/prepare-release-schema.json b/schemas/prepare-release-schema.json index 2e8165d..e3bd043 100644 --- a/schemas/prepare-release-schema.json +++ b/schemas/prepare-release-schema.json @@ -1,5 +1,5 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft-07/schema", "type": "object", "properties": { "ownerName": { @@ -10,10 +10,6 @@ "type": "string", "description": "The name of the GitHub repository." }, - "orgProjectName": { - "type": "string", - "description": "The name of the GitHub organization project. This is a V2 project." - }, "releaseTypes": { "type": "array", "description": "The list of release types. Example: preview or production.", @@ -26,13 +22,21 @@ "type": "string", "description": "The name of the environment variable that contains the GitHub token." }, + "orgProjectName": { + "type": "string", + "description": "The name of the GitHub organization project. This is a V2 project. (Optional)" + }, "versionFilePath": { "type": "string", - "description": "The relative path to the file that contains the version number. Both JSON and csproj files are supported." + "description": "The relative path to the file that contains the version number. Both JSON and csproj files are supported. (Optional)" }, "versionJSONKeyPath": { "type": "string", - "description": "The path to the version number in the JSON file. Only used if the file is a JSON file." + "description": "The path to the version number in the JSON file. Only used if the file is a JSON file. (Optional)" + }, + "releaseNotesFilePrefix": { + "type": "string", + "description": "The path to the version number in the JSON file. Only used if the file is a JSON file. (Optional)" } }, "required": ["ownerName", "repoName", "releaseTypes", "githubTokenEnvVarName"] diff --git a/schemas/release-type-schema.json b/schemas/release-type-schema.json index f6a87b5..7322a15 100644 --- a/schemas/release-type-schema.json +++ b/schemas/release-type-schema.json @@ -1,19 +1,11 @@ { - "$schema": "https://json-schema.org/draft/2020-12/schema", + "$schema": "https://json-schema.org/draft-07/schema", "type": "object", "properties": { "name": { "type": "string", "description": "The name of the release type." }, - "reviewer": { - "type": "string", - "description": "The pull request reviewer." - }, - "assignee": { - "type": "string", - "description": "The pull request assignee." - }, "headBranch": { "type": "string", "description": "The head branch of the pull request." @@ -22,10 +14,6 @@ "type": "string", "description": "The base branch of the pull request." }, - "genReleaseSettingsFilePath": { - "type": "string", - "description": "The relative path to the generate release notes settings file." - }, "releaseNotesDirPath": { "type": "string", "description": "The relative path to the release notes directory." @@ -42,7 +30,31 @@ "items": { "type": "string" } + }, + "prTitle": { + "type": "string", + "description": "The title of the pull request." + }, + "reviewer": { + "type": "string", + "description": "The pull request reviewer. (Optional)" + }, + "assignee": { + "type": "string", + "description": "The pull request assignee. (Optional)" + }, + "genReleaseSettingsFilePath": { + "type": "string", + "description": "The relative path to the generate release notes settings file. (Optional)" } }, - "required": ["name", "headBranch", "baseBranch", "releaseNotesDirPath", "releasePrTemplateFilePath", "releaseLabels", "prTitle"] + "required": [ + "name", + "headBranch", + "baseBranch", + "releaseNotesDirPath", + "releasePrTemplateFilePath", + "releaseLabels", + "prTitle" + ] } diff --git a/src/generator-settings.ts b/src/generator-settings.ts index 43db888..19ba8f7 100644 --- a/src/generator-settings.ts +++ b/src/generator-settings.ts @@ -7,6 +7,7 @@ export interface GeneratorSettings { githubTokenEnvVarName: string; milestoneName: string; headerText: string; + wordReplacements: Record; version?: string; releaseType?: string; extraInfo?: { title: string; text: string }; @@ -14,7 +15,6 @@ export interface GeneratorSettings { issueCategoryLabelMappings?: Record; prCategoryLabelMappings?: Record; ignoreLabels?: string[]; - wordReplacements: Record; firstWordReplacements?: Record; styleWordsList?: Record; boldedVersions?: boolean; diff --git a/src/prepare-release-settings.ts b/src/prepare-release-settings.ts index 646ef4a..ac5e249 100644 --- a/src/prepare-release-settings.ts +++ b/src/prepare-release-settings.ts @@ -14,11 +14,6 @@ export interface PrepareReleaseSettings { */ repoName: string; - /** - * Gets the name of the organization project. - */ - orgProjectName?: string; - /** * Gets the list of release types. */ @@ -29,6 +24,11 @@ export interface PrepareReleaseSettings { */ githubTokenEnvVarName: string; + /** + * Gets the name of the organization project. + */ + orgProjectName?: string; + /** * Gets the full or relative file path to the version file. * @remarks If undefined, null, or empty, then the version will not be updated. @@ -39,4 +39,9 @@ export interface PrepareReleaseSettings { * Gets the dot separated path to the JSON key that contains the version. */ versionJSONKeyPath?: string; + + /** + * Gets the value to prefix the release notes file name with. + */ + releaseNotesFilePrefix?: string; } diff --git a/src/release-prepper.ts b/src/release-prepper.ts index e58ccc7..5a38768 100644 --- a/src/release-prepper.ts +++ b/src/release-prepper.ts @@ -154,7 +154,12 @@ export class ReleasePrepper { } // Generate the release notes - const newNotesFilePath = await this.createReleaseNotes(chosenReleaseType, chosenVersion, settings.githubTokenEnvVarName); + const newNotesFilePath = await this.createReleaseNotes( + chosenReleaseType, + chosenVersion, + settings.githubTokenEnvVarName, + settings.releaseNotesFilePrefix, + ); // If release notes were generated, stage and commit them. if (newNotesFilePath !== undefined) { @@ -447,16 +452,24 @@ export class ReleasePrepper { } } + /** + * Creates release notes based on the given {@link releaseType} and {@link chosenVersion}. + * @param releaseType The type of release. + * @param chosenVersion The version. + * @param tokenEnvVarName The name of the environment variable that contains the GitHub token. + * @param fileNamePrefix The value to prefix the notes file name with. + * @returns The release notes. + */ private async createReleaseNotes( releaseType: ReleaseType, chosenVersion: string, tokenEnvVarName: string, + fileNamePrefix?: string, ): Promise { ConsoleLogColor.gray(" ⏳Creating release notes."); // Trim the notes dir path and replace all '\' with '/' - let notesDirPath = releaseType.releaseNotesDirPath.trim() - .replace(/\\/g, "/"); + let notesDirPath = releaseType.releaseNotesDirPath.trim().replace(/\\/g, "/"); notesDirPath = notesDirPath.endsWith("/") ? notesDirPath.slice(0, -1) : notesDirPath; @@ -475,7 +488,9 @@ export class ReleasePrepper { Deno.mkdirSync(notesDirPath, { recursive: true }); } - const newNotesFilePath = `${notesDirPath}/Release-Notes-${chosenVersion}.md`; + const prefix = Guards.isNothing(fileNamePrefix) ? "" : fileNamePrefix; + + const newNotesFilePath = `${notesDirPath}/${prefix}${chosenVersion}.md`; Deno.writeTextFileSync(newNotesFilePath, releaseNotesFileContent, { create: true });