-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧Replace client code with library (#183)
* config: add import maps * refactor: update imports to use import maps * ide: remove extension recommendation * deps: setup deps.ts file with imports and exports * refactor: update add item to project runner to use kd_clients * ci: update cicd script to use kd_clients * refactor: update prepare release runner to use kd clients * chore: improve and move Directory class * ci: create class to simplify cli command execution * ci: set up deno build status check with local task setup * ci: move script to different folder * ci: move script to different folder * ci,deps: improve core deps and fix imports * refactor: update cs proj resolve runner to use kd_clients * refactor: update sync bot status check runner to use kd_clients * refactor: update sync pr to issue runner to use kd_clients * refactor: update imports for transpile readme runner * refactor: update imports for resolve cs proj runner * refactor: update the lose milestone script to use kd_clients * refactor: update validate github release script to use kd_clients * refactor: update label if head branch script to use kd_clients * refactor: update nuget pkg does not exist script to use kd_clients * refactor: update validate tag script to use kd_clients * refactor: update release tweet builder to use kd_clients * refactor: update csharp version service script to use kd_client * refactor: update the milestone-exists script to use kd_clients * refactor: update the github var service to use kd_clients * refactor: update prepare release runner to use kd_clients * fix: fix other build issues * cleanup: remove all of the old used clients * cleanup: remove unused types * chore: pull in models to replace locally deleted ones * cleanup: remove unused types * ide: remove config files for unused vscode extension * chore: update add item to project runner * refactor: change name of utils function * refactor: refactor scripts to be imported into a single module * ci: improve deno check process by running checks async * cleanup: refactor code to meet deno formatting rules * deps: update deno lock * ci: update reusable workflow versions * deps: update kd_clients from v1.0.0-preview.4 to v1.0.0-preview.5 * fix: update imports to use deps.ts instead of import maps * ci: add deno permission to sync workflow * fix: fix issue with missing arg with org client * ci: add allow -read permission to workflow * ide: update tasks file
- Loading branch information
1 parent
9af4e2b
commit bdf6ff6
Showing
121 changed files
with
1,703 additions
and
5,704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Directory, CLI } from "../../../deps.ts"; | ||
|
||
const ignoreDirectories = [ | ||
"./vendor/", | ||
"./node_modules/" | ||
]; | ||
|
||
const files: string[] = Directory | ||
.getFiles("/", true) | ||
.filter(f => { | ||
const isTypeScriptFile = f.endsWith(".ts"); | ||
|
||
const shouldNotIgnore = ignoreDirectories.every(ignoreDir => !f.startsWith(ignoreDir)) | ||
|
||
return isTypeScriptFile && shouldNotIgnore; | ||
}); | ||
|
||
const cli: CLI = new CLI(); | ||
let failed = false; | ||
|
||
console.clear(); | ||
console.log(`Checking ${files.length} files . . .`); | ||
|
||
/** | ||
* Represents the result of checking a file. | ||
*/ | ||
interface CheckResult { | ||
file: string; | ||
result: string; | ||
hasPassed: boolean; | ||
} | ||
|
||
/** | ||
* Checks a file using deno check. | ||
* @param file The file to check. | ||
* @returns A promise that resolves to a CheckResult. | ||
*/ | ||
const checkFile = async (file: string): Promise<CheckResult> => { | ||
let checkResult: CheckResult = { | ||
file: file, | ||
result: "", | ||
hasPassed: true // Default to passed | ||
}; | ||
|
||
checkResult.result += `Checking ${file}`; | ||
|
||
const result = await cli.runAsync(`deno check ${file}`); | ||
|
||
let commandResult = ""; | ||
|
||
// If the result is an error type | ||
if (result instanceof Error) | ||
{ | ||
checkResult.hasPassed = false; | ||
commandResult = "❌\n"; | ||
|
||
const lines = result.message.split("\n"); | ||
|
||
// Prefix each command output line with 3 spaces | ||
lines.forEach(line => { | ||
commandResult += ` ${line}\n`; | ||
}); | ||
} else { | ||
commandResult = "✅\n"; | ||
} | ||
|
||
checkResult.result += commandResult; | ||
|
||
return checkResult; | ||
} | ||
|
||
const filesToCheck: Promise<CheckResult>[] = []; | ||
|
||
// Perform a deno check on all of the files | ||
for await (let file of files) { | ||
filesToCheck.push(checkFile(file)); | ||
}; | ||
|
||
// 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(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(`\nTotal Checks Passed✅: ${totalPassed}\nTotal Checks Failed❌: ${totalFailed}\n`); | ||
Deno.stdout.writeSync(resultsMsg); | ||
|
||
if (failed) { | ||
Deno.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import { Input } from "https://deno.land/x/[email protected]/prompt/input.ts"; | ||
import chalk from "npm:[email protected]"; | ||
import { TagClient } from "../../cicd/clients/TagClient.ts"; | ||
import { Directory } from "../../cicd/core/Directory.ts"; | ||
import { File } from "../../cicd/core/File.ts"; | ||
import { Utils } from "../../cicd/core/Utils.ts"; | ||
import { RepoClient } from "../../cicd/clients/RepoClient.ts"; | ||
import { | ||
TagClient, RepoClient, Directory, Input | ||
} from "../../../deps.ts"; | ||
import chalk from "../../../deps.ts"; | ||
import { File } from "../../../cicd/core/File.ts"; | ||
import { Utils } from "../../../cicd/core/Utils.ts"; | ||
|
||
if (Deno.args.length != 2) { | ||
let errorMsg = "Invalid number of arguments."; | ||
|
@@ -43,12 +42,14 @@ const newVersion = await Input.prompt({ | |
} | ||
}); | ||
|
||
const ownerName = "KinsonDigital"; | ||
const repoName = "Infrastructure"; | ||
const allFiles = Directory.getFiles(baseDirPath, true); | ||
|
||
const yamlFiles = allFiles.filter((file) => file.toLowerCase().endsWith(".yaml") || file.toLowerCase().endsWith(".yml")); | ||
const tagClient: TagClient = new TagClient(token); | ||
const allTags = (await tagClient.getAllTags(repoName)).map((t) => t.name); | ||
const tagClient: TagClient = new TagClient(ownerName, repoName, token); | ||
|
||
const allTags = (await tagClient.getAllTags()).map((t) => t.name); | ||
|
||
// If the new tag already exists, throw an error | ||
if (allTags.includes(newVersion)) { | ||
|
@@ -106,15 +107,15 @@ if (noFilesUpdated) { | |
} | ||
|
||
const repoVarName = "CICD_SCRIPTS_VERSION"; | ||
const repoClient = new RepoClient(token); | ||
const repoClient = new RepoClient(ownerName, repoName, token); | ||
|
||
if (!(await repoClient.repoVariableExists(repoName, repoVarName))) { | ||
if (!(await repoClient.repoVariableExists(repoVarName))) { | ||
console.log(chalk.red(`The repository variable '${repoVarName}' does not exist.`)); | ||
Deno.exit(0); | ||
} | ||
|
||
const scriptVersionVar = (await repoClient.getVariables(repoName)).find((v) => v.name == repoVarName); | ||
const scriptVersionVar = (await repoClient.getVariables()).find((v) => v.name == repoVarName); | ||
|
||
await repoClient.updateVariable(repoName, repoVarName, newVersion); | ||
await repoClient.updateVariable(repoVarName, newVersion); | ||
|
||
console.log(chalk.cyan(`Updated repository variable '${repoVarName}' from version '${scriptVersionVar?.value}' to '${newVersion}'.`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: ✅Build Status Check | ||
run-name: ✅Build Status Check (${{ github.base_ref }} branch) | ||
|
||
|
||
defaults: | ||
run: | ||
shell: pwsh | ||
|
||
|
||
on: | ||
pull_request_target: | ||
branches: main | ||
|
||
|
||
jobs: | ||
build_status_check: | ||
name: Build Status Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.repository }} | ||
ref: ${{ github.ref }} | ||
|
||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: ${{ vars.DENO_VERSION }} | ||
|
||
- name: Run Build | ||
run: | | ||
deno run --allow-read --allow-run "./.github/internal-cicd/scripts/deno-check.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.