Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to direct git access #49

Open
wants to merge 4 commits into
base: feature/eliza-introspector-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,52 @@ ton_nft_metadata/
ton_nft_metadata/*

ton_nft_images/
ton_nft_images/*
ton_nft_images/*# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# cask packages
.cask/
dist/

# Flycheck
flycheck_*.el

# server auth directory
/server/

# projectiles files
.projectile

# directory configuration
.dir-locals.el

# network security
/network-security.data

2 changes: 1 addition & 1 deletion scripts/jsdoc-automation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dbg": "node --inspect-brk --loader ts-node/esm src/index.ts",
"dbg2": "node --inspect --loader ts-node/esm src/index.ts",
"dbg3": "npx --node-options=--inspect-brk tsx ./src/index",
"ts": "NODE_ENV=development VERBOSE=true DEFAULT_LOG_LEVEL=debug DEBUG=eliza:* npx tsx src/index",
"ts": "npx tsx src/index",
"clean": "rm -rf node_modules dist"
},
"keywords": [],
Expand Down
111 changes: 69 additions & 42 deletions scripts/jsdoc-automation/src/DirectoryTraversal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import * as fs from "fs";
//import { promises as fs } from "fs";
import * as path from "path";
import type { Configuration } from "./Configuration.js";

export interface FileChange {
filename: string;
status: string;
additions: number;
deletions: number;
changes: number;
contents_url?: string;
}

/**
* DirectoryTraversal class for traversing through directories and files.
* @class DirectoryTraversal
Expand Down Expand Up @@ -30,15 +39,19 @@ export class DirectoryTraversal {
"static",
];

private fileChanges: Map<string, FileChange>;

/**
* Constructor for directory traversal
* @param {Configuration} config - Configuration object containing paths and exclusions
* @param {string[]} [prFiles=[]] - PR files to process
* @param {FileChange[]} [changes=[]] - Array of file changes from git diff
*/
constructor(
private config: Configuration,
public prFiles: string[] = []
) {}
changes: FileChange[] = []
) {
this.fileChanges = new Map(changes.map(change => [change.filename, change]));
}

/**
* Gets the absolute path for a file
Expand All @@ -55,62 +68,76 @@ export class DirectoryTraversal {
}

/**
* Traverses the directory based on PRFiles or all files in the root directory.
* If PRFiles are detected, processes only files from the PR.
* Gets the file change information for a given file
* @param {string} filePath - The path to the file
* @returns {FileChange | undefined} The file change information if available
*/
public getFileChange(filePath: string): FileChange | undefined {
const relativePath = this.getRelativePath(filePath);
return this.fileChanges.get(relativePath);
}

/**
* Traverses the directory based on file changes from git diff.
* If changes are detected, processes only changed files.
* Otherwise, scans all files in the root directory for TypeScript files.
*
*
* @returns An array of string containing the files to process.
*/
public traverse(): string[] {
if (this.prFiles.length > 0) {
console.log("Detected PR Files:", this.prFiles);
if (this.fileChanges.size > 0) {
console.log("Detected Changes:", Array.from(this.fileChanges.values()));

// Changes are already relative to repo root, filter and convert to absolute paths
const files = Array.from(this.fileChanges.entries())
.filter(([file, change]: [string, FileChange]) => {
// Skip deleted files
if (change.status === 'deleted') {
return false;
}

// PR files are already relative to repo root, filter and convert to absolute paths
const files = this.prFiles
.filter((file) => {
// Convert PR file (repo-relative) to absolute path
// Convert file (repo-relative) to absolute path
const absolutePath = this.config.toAbsolutePath(file);

// Check if the file is within our target directory
const isInTargetDir = absolutePath.startsWith(
this.config.absolutePath
);

return (
isInTargetDir &&
fs.existsSync(absolutePath) &&
!this.isExcluded(absolutePath) &&
path.extname(file) === ".ts"
);
// // Check if the file is within our target directory
// const isInTargetDir = absolutePath.startsWith(
// this.config.absolutePath
// );

// return (
// isInTargetDir &&
// fs.existsSync(absolutePath) &&
// !this.isExcluded(absolutePath) &&
// path.extname(file) === ".ts"
// );
})
.map((file) => this.config.toAbsolutePath(file));
.map(([file]) => this.config.toAbsolutePath(file));

console.log("Files to process:", files);
return files;
} else {
console.log(
"No PR Files Detected, Scanning all files in root directory"
"No Changes Detected, Scanning all files in root directory"
);
const typeScriptFiles: string[] = [];

const traverseDirectory = (currentDirectory: string) => {
const files = fs.readdirSync(currentDirectory);

files.forEach((file) => {
const filePath = path.join(currentDirectory, file);
const stats = fs.statSync(filePath);

if (stats.isDirectory()) {
if (!this.isExcluded(filePath)) {
traverseDirectory(filePath);
}
} else if (stats.isFile() && !this.isExcluded(filePath)) {
if (path.extname(file) === ".ts") {
typeScriptFiles.push(filePath);
}
}
});
// const files = fs.readdirSync(currentDirectory);

// files.forEach((file) => {
// const filePath = path.join(currentDirectory, file);
// const stats = fs.statSync(filePath);

// if (stats.isDirectory()) {
// if (!this.isExcluded(filePath)) {
// traverseDirectory(filePath);
// }
// } else if (stats.isFile() && !this.isExcluded(filePath)) {
// if (path.extname(file) === ".ts") {
// typeScriptFiles.push(filePath);
// }
// }
// });
};

traverseDirectory(this.config.absolutePath);
Expand Down
Loading