From 5a123af792b70a38513959ab218daeb88a3dac5d Mon Sep 17 00:00:00 2001 From: Documentation Manager Bot <64863757+conmaster2112@users.noreply.github.com> Date: Thu, 10 Oct 2024 16:30:24 +0200 Subject: [PATCH] Fixing as much as possible --- .github/workflows/updater.yml | 18 ++++---- src/flags/changelog.js | 80 ----------------------------------- src/flags/changelog/index.js | 0 src/functions.js | 10 ++--- src/main.js | 3 -- 5 files changed, 13 insertions(+), 98 deletions(-) delete mode 100644 src/flags/changelog.js delete mode 100644 src/flags/changelog/index.js diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index e29771f..8eb27e2 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -1,21 +1,23 @@ -name: Update Docs +name: Update Docs Generator on: - push: - #schedule: - #- cron: '*/20 * * * *' + push: + branches: + main + schedule: + - cron: '*/20 * * * *' permissions: contents: write jobs: - - Updater: + Main-Updater: runs-on: windows-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: "main" + fetch-depth: '0' - name: Setup Node.js environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4.0.4 with: node-version: '22' cache: 'npm' diff --git a/src/flags/changelog.js b/src/flags/changelog.js deleted file mode 100644 index c9f9263..0000000 --- a/src/flags/changelog.js +++ /dev/null @@ -1,80 +0,0 @@ -import { dirname, resolve } from "node:path"; -import { readFile } from "node:fs/promises"; -import { createWriteStream, existsSync, mkdirSync } from "node:fs"; -import { Readable } from "node:stream"; -import { pipeline } from "node:stream/promises"; -import { FileTree } from "../functions.js"; - -const OUTPUT_FOLDER = "./changelog/index.js"; -const description = "The CHANGELOG_GENERATOR flag generator creates TypeScript declaration files from JSON metadata about script modules. It processes JSON files, transforming their content into .d.ts files, which are then stored in the ./script-declarations directory. This ensures that all script modules have accurate TypeScript declarations, making it easier for developers to work with the generated documentation. The process involves reading the JSON files, transforming their content, and writing the output to the appropriate directory, ensuring that all tasks are completed successfully."; - -export default { - method: CHANGELOG_GENERATOR, - flagId: CHANGELOG_GENERATOR.name, - description -}; -/** - * - * @param {string} inputDirPath - * @returns {Promise} - */ -async function CHANGELOG_GENERATOR(inputDirPath) { - // Init - const inputDir = resolve(inputDirPath, "docs/script_modules"); - const tasks = []; - - // Task Factory for each file in the path tree - for (const file of FileTree(inputDir)) tasks.push( - Task(inputDir, file).catch(()=>false) - ); - - // Return Only Succesfull Creations - const results = (await Promise.all(tasks)).filter(s=>s); - - // Check if all tasks has successfully ended. - return tasks.length == results.length; -} -/** - * @param {string} input - * @param {string} fileName - * @returns {Promise} - */ -async function Task(input,fileName) { - - // Transform File content - if(!fileName.endsWith(".json")) return false; - - // Read File - /**@type {Buffer | string | null} */ - let buffer = await readFile(resolve(input, fileName)).catch(()=>null); - - // Check if file was properly readed - if(buffer == null) return false; - - const outFile = resolve(OUTPUT_FOLDER, fileName); - const outDir = dirname(outFile); - - // Has to be sync to be sure we are not about to call mkdir with same directory path - if(!existsSync(outDir)) mkdirSync(outDir, {recursive: true}); - - - const data = ""; - console.log(JSON.parse(buffer.toString())); - /* - const writeStream = createWriteStream(outFile.replace(/.json$/g,".d.ts")); - - - - const readable = PrintScriptModule(buffer); - - const results = await pipeline( - readable, - writeStream - ).then(()=>true, ()=>false);*/ - - if(true) console.log("[CHANGELOG_GENERATOR] Generated: " + fileName); - else console.log("[CHANGELOG_GENERATOR] Generation failed: " + fileName); - - // Returns if file was successfully created - return true; -} \ No newline at end of file diff --git a/src/flags/changelog/index.js b/src/flags/changelog/index.js deleted file mode 100644 index e69de29..0000000 diff --git a/src/functions.js b/src/functions.js index 72f6af5..613b5be 100644 --- a/src/functions.js +++ b/src/functions.js @@ -208,7 +208,7 @@ export async function GithubPostNewBranch(branch) { // Basic checkout command execution - cmd = `git push -u origin ${branch}`; + cmd = `git push -u ${branch}`; result = await ExecuteCommand(cmd); if(result.exitCode != 0) { @@ -244,12 +244,8 @@ export async function GithubChekoutBranch(branch, force) { return false; } - await ExecuteCommand("git remote"); - - await ExecuteCommand("git branch -r -a"); - // Basic checkout command execution - cmd = `git checkout origin/${branch}${force?" -f":""}`; + cmd = `git checkout ${branch}${force?" -f":""}`; result = await ExecuteCommand(cmd); if(result.exitCode != 0) { @@ -300,7 +296,7 @@ export async function GithubCommitAndPush(branch, version, isPreview) { result = await ExecuteCommand(`git commit -m \"New ${branch} v${isPreview?version:GetEngineVersion(version)}\"`); if(result.exitCode != 0) return false; - result = await ExecuteCommand("git push --force origin " + branch); + result = await ExecuteCommand("git push --force " + branch); if(result.exitCode != 0) return false; return true; diff --git a/src/main.js b/src/main.js index f78fe17..8f40e79 100644 --- a/src/main.js +++ b/src/main.js @@ -140,9 +140,6 @@ async function Main(){ await writeFile(FILE_NAME_GITHUB_README, GENERAL_README); - - console.log("End . . ."); - return 0; // Commit changes and force push group("Commit & Push -> " + checkResults.branch); successful = await GithubCommitAndPush(checkResults.branch, checkResults.version, checkResults.isPreview);