Skip to content

Commit

Permalink
Update docusaurus monorepo to v3.0.1 (#163)
Browse files Browse the repository at this point in the history
* Update docusaurus monorepo to v3.0.1

| datasource | package                         | from  | to    |
| ---------- | ------------------------------- | ----- | ----- |
| npm        | @docusaurus/core                | 3.0.0 | 3.0.1 |
| npm        | @docusaurus/module-type-aliases | 3.0.0 | 3.0.1 |
| npm        | @docusaurus/preset-classic      | 3.0.0 | 3.0.1 |
| npm        | @docusaurus/theme-mermaid       | 3.0.0 | 3.0.1 |
| npm        | @docusaurus/tsconfig            | 3.0.0 | 3.0.1 |
| npm        | @docusaurus/types               | 3.0.0 | 3.0.1 |

* ide: add word to dictionary

* test

* test

* refactor: replace core.io file and dir operation code with deno api code

* ci,fix: fix and improve doc processing

* ci,fix: fix issue with dir check logic

* ci,fix: fix issue and improve version side bar service

* refactor: improve playground script

* ide: adjust dictionaries

* ide,config: improve and adjust deno settings

* ide: improve launch configs

* refactor: adjust imports

* config: adjust settings and launch config

* deps: update deno json and lock

* ci: updated built status check and improved script

* ci: make simple workflow improvement

* ide: improve and update tasks

* refactor: reformat code using deno fmt

* config: exclude script from formatting

* ide: add words to dictionary

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Calvin Wilkinson <kinsondigital@gmail.com>
  • Loading branch information
renovate[bot] and CalvinWilkinson authored Dec 5, 2023
1 parent f6d6f91 commit 93272ef
Show file tree
Hide file tree
Showing 36 changed files with 706 additions and 851 deletions.
18 changes: 5 additions & 13 deletions .github/cicd/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"deno.enable": true,
"deno.enablePaths": ["${workspaceFolder}/../"],
"[typescript]": {
"editor.insertSpaces": false,
"editor.tabSize": 4,
},
"editor.detectIndentation": false,
"cSpell.words": [
"cicd",
"defaultdocumentation",
"kinsondigital",
"velaptor"
],
"deno.enable": true,
"deno.config": "../deno.json",
"cSpell.words": [
"cicd"
],
}
41 changes: 21 additions & 20 deletions .github/cicd/core/DefaultDocTool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RepoClient } from "../deps.ts";
import { Directory } from "io/Directory.ts";
import { DotNetToolService } from "services/DotNetToolService.ts";
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.
Expand Down Expand Up @@ -57,30 +57,31 @@ export class DefaultDocTool {

await this.dotNetToolService.setupDotNetTools(this.defaultDocToolName, defaultDocToolVersion);

if (Directory.exists(outputDirPath)) {
if (existsSync(outputDirPath)) {
Deno.removeSync(outputDirPath, { recursive: true });
}

Deno.mkdirSync(outputDirPath, { recursive: true });

const command = new Deno.Command("defaultdocumentation", {
args: [
"--AssemblyFilePath",
`${assemblyPath}`,
"--OutputDirectoryPath",
`${outputDirPath}`,
"--ConfigurationFilePath",
`${configFilePath}`,
],
});
const cli = new CLI();

const args = [
"--AssemblyFilePath",
`${assemblyPath}`,
"--OutputDirectoryPath",
`${outputDirPath}`,
"--ConfigurationFilePath",
`${configFilePath}`,
];

const { code, stdout, stderr } = await command.output();
const command = `defaultdocumentation ${args.join(" ")}`;
const commandResult = await cli.runAsync(command);

if (code === 0) {
console.log(new TextDecoder().decode(stdout));
} else {
console.log(new TextDecoder().decode(stderr));
Deno.exit(code);
if (commandResult instanceof Error) {
Utils.printGitHubError(commandResult.message);
Deno.exit(1);
}

console.log(commandResult);
}
}
103 changes: 79 additions & 24 deletions .github/cicd/core/DocProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { CloneRepoService } from "services/CloneRepoService.ts";
import { MarkdownFileContentService } from "services/MarkdownFileContentService.ts";
import { ValidateReleaseService } from "services/ValidateReleaseService.ts";
import { MarkdownService } from "services/MarkdownService.ts";
import { CloneRepoService } from "./services/CloneRepoService.ts";
import { MarkdownFileContentService } from "./services/MarkdownFileContentService.ts";
import { ValidateReleaseService } from "./services/ValidateReleaseService.ts";
import { MarkdownService } from "./services/MarkdownService.ts";
import { DefaultDocTool } from "./DefaultDocTool.ts";
import { Directory } from "io/Directory.ts";
import { File } from "io/File.ts";
import { Path } from "io/Path.ts";
import { Utils } from "./Utils.ts";
import { Yarn } from "./Yarn.ts";
import chalk from "../deps.ts";
import chalk, { existsSync, walkSync } from "../deps.ts";

/**
* Generates and performs post-processing on Velaptor API documentation.
Expand Down Expand Up @@ -86,9 +83,11 @@ export class DocProcessor {
* @param tagOrBranch The Velaptor release tag or branch name.
*/
private async run(apiDocDirPath: string, tagOrBranch: string): Promise<void> {
const cwd = Deno.cwd();
// Remove the RepoSrc directory if it exists.
const repoSrcDirPath = `${Deno.cwd()}/RepoSrc`;
if (Directory.exists(repoSrcDirPath)) {

if (existsSync(repoSrcDirPath)) {
await this.runProcess(
"Cleaning up previous clone and build. . .",
() => Deno.removeSync(repoSrcDirPath, { recursive: true }),
Expand All @@ -114,12 +113,18 @@ export class DocProcessor {
// Generate the documentation.
await this.runProcess(
"Generating Documentation. . .",
() =>
this.defaultDocTool.generateDocumentation(
`${Deno.cwd()}/RepoSrc/BuildOutput/Velaptor.dll`,
`${Deno.cwd()}/docs/api`,
`${Deno.cwd()}/default-doc-config.json`,
),
() => {
const velaptorFilePath = this.findFilePaths(repoSrcDirPath, ["RepoSrc/BuildOutput/Velaptor.dll"])
.filter((filePath) => filePath.endsWith("RepoSrc/BuildOutput/Velaptor.dll"))[0];

const docsApiDirPath = this.findDirPaths(cwd, ["docs/api"])
.filter((dirPath) => dirPath.endsWith("docs/api"))[0];

const defaultDocConfigFilePath = this.findFilePaths(cwd, ["default-doc-config.json"])
.filter((filePath) => filePath.endsWith("default-doc-config.json"))[0];

return this.defaultDocTool.generateDocumentation(docsApiDirPath, velaptorFilePath, defaultDocConfigFilePath);
},
"Documentation Generation Complete.",
);

Expand Down Expand Up @@ -172,50 +177,100 @@ export class DocProcessor {
* @param apiDocDirPath The directory path to the generated API documentation.
*/
private runPostProcessing(apiDocDirPath: string): void {
const baseAPIDirPath: string = Path.normalizeSeparators(apiDocDirPath);
const fileContentService: MarkdownFileContentService = new MarkdownFileContentService();
const markDownService: MarkdownService = new MarkdownService();

try {
const oldNamespaceFilePath = `${baseAPIDirPath}index.md`;
const newNamespaceFilePath = `${baseAPIDirPath}Namespaces.md`;
File.renameFileSync(oldNamespaceFilePath, newNamespaceFilePath);
const oldNamespaceFilePath = `${apiDocDirPath}index.md`;
const newNamespaceFilePath = `${apiDocDirPath}Namespaces.md`;

Deno.renameSync(oldNamespaceFilePath, newNamespaceFilePath);
console.log(`File renamed from '${oldNamespaceFilePath}' to '${newNamespaceFilePath}'.`);

console.log("Performing post-processing on the API documentation. . .");

// Replace the extra table column in the Namespaces.md file
let namespaceFileContent: string = File.readTextFileSync(newNamespaceFilePath);
let namespaceFileContent: string = Deno.readTextFileSync(newNamespaceFilePath);

// Remove the extra column from the header and divider
namespaceFileContent = namespaceFileContent.replace("| Namespaces | |", "| Namespaces |");
namespaceFileContent = namespaceFileContent.replace("| :--- | :--- |", "| :--- |");

// Remove the extra column from each row
namespaceFileContent = namespaceFileContent.replaceAll(") | |", ") |");
File.writeTextFileSync(newNamespaceFilePath, namespaceFileContent);
Deno.writeTextFileSync(newNamespaceFilePath, namespaceFileContent);

const filePathEntries = walkSync(apiDocDirPath, {
includeDirs: false,
includeFiles: true,
exts: [".md"],
});

const filePaths: string[] = Directory.getFiles(baseAPIDirPath, ".md");
const filePaths: string[] = [...filePathEntries].map((entry) => entry.path);

// Go through each file and perform content processing
filePaths.forEach((filePath: string) => {
console.log(`\tProcessing file '${filePath}' . . .`);
fileContentService.processMarkdownFile(filePath);
});

let namespaceContent: string = File.readTextFileSync(newNamespaceFilePath);
let namespaceContent: string = Deno.readTextFileSync(newNamespaceFilePath);
namespaceContent = markDownService.renameHeader(
namespaceContent,
"Velaptor Assembly",
"Velaptor API Namespaces",
);

File.writeTextFileSync(newNamespaceFilePath, namespaceContent);
Deno.writeTextFileSync(newNamespaceFilePath, namespaceContent);

console.log("API documentation post-processing complete.");
} catch (error) {
console.error(error);
throw error;
}
}

private findDirPaths(dirStartPath: string, inclusions: string[]): string[] {
inclusions = inclusions.map((inclusion) => inclusion.trim().replaceAll("\\", "/").replaceAll("/", "(/|\\\\)"));
const matches = inclusions.map((inclusion) => new RegExp(`.*${inclusion}.*`));

const entries = walkSync(dirStartPath, {
includeDirs: true,
includeFiles: false,
match: matches,
});

const result = [...entries].map((entry) => entry.path.replaceAll("\\", "/"));

if (Utils.isNothing(result)) {
const errorMsg = `Could not find the directories relative to the directory '${dirStartPath}'.` +
`\nInclusions: ${inclusions.join(", ")}`;
Utils.printGitHubError(errorMsg);
Deno.exit(1);
}

return result;
}

private findFilePaths(dirStartPath: string, inclusions: string[]): string[] {
inclusions = inclusions.map((inclusion) => inclusion.trim().replaceAll("\\", "/").replaceAll("/", "(/|\\\\)"));
const matches = inclusions.map((inclusion) => new RegExp(`.*${inclusion}.*`));

const entries = walkSync(dirStartPath, {
includeDirs: false,
includeFiles: true,
match: matches,
});

const result = [...entries].map((entry) => entry.path.replaceAll("\\", "/"));

if (Utils.isNothing(result)) {
const errorMsg = `Could not find the files relative to the directory '${dirStartPath}'.` +
`\nInclusions: ${inclusions.join(", ")}`;
Utils.printGitHubError(errorMsg);
Deno.exit(1);
}

return result;
}
}
10 changes: 0 additions & 10 deletions .github/cicd/core/FileLoader.ts

This file was deleted.

16 changes: 16 additions & 0 deletions .github/cicd/core/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,20 @@ export class Utils {

return 0;
}

/**
* Prints the given {@link errorMsg} to the console as a GitHub error.
* @param errorMsg The error message to print.
*/
public static printGitHubError(errorMsg: string): void {
console.log(`::error::${errorMsg}`);
}

/**
* Prints the given {@link errorMsg} to the console as a GitHub notice.
* @param errorMsg The error message to print.
*/
public static printGitHubNotice(errorMsg: string): void {
console.log(`::notice::${errorMsg}`);
}
}
Loading

0 comments on commit 93272ef

Please sign in to comment.