Skip to content
Merged
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm ./src/index.ts",
"start": "node --loader ts-node/esm ./src/index.js",
"startt": "node --loader ts-node/esm ./index.ts",
"startpaths": "node --loader ts-node/esm --require tsconfig-paths/register ./src/index.ts"
},
"devDependencies": {
Expand Down
13 changes: 9 additions & 4 deletions src/api/githubClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@
import { Octokit } from "octokit";
import { createTokenAuth } from "@octokit/auth-token";
import { throttling } from "@octokit/plugin-throttling";
import type { ThrottlingOptions } from "@octokit/plugin-throttling";
// import type { ThrottlingOptions } from "@octokit/plugin-throttling";
import dotenv from 'dotenv';
import type { RequestOptions } from "@octokit/types";
import path from 'path';

dotenv.config({ path: 'src/.env' });

Comment on lines +19 to 20
Copy link

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using path.join or path.resolve (with __dirname) to construct the .env file path for OS-independent path resolution.

Suggested change
dotenv.config({ path: 'src/.env' });
dotenv.config({ path: path.resolve(__dirname, '../../.env') });

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. For now, I'll leave it as is but will create an issue for this to ensure I tackle it eventually.

dotenv.config();
console.log("🔑 Loaded token");
const token = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;

if (!token) throw new Error("❌ GITHUB_PERSONAL_ACCESS_TOKEN not loaded into env");
if (token) {
console.log("🔑 Loaded token");
} else {
throw new Error("❌ GITHUB_PERSONAL_ACCESS_TOKEN not loaded into env");
};

const auth = createTokenAuth(token);
const GITHUB_AUTH_TOKEN = await auth();
Expand Down
3 changes: 2 additions & 1 deletion src/core/batchProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ export async function processOneUser(userName: string) {
contributors: collaborators,
date_started: oneRepo.created_at,
last_activity: oneRepo.updated_at,
last_commit: lastCommit,
};
const PATH_PREFIX = "/Users/figgefenk/Dev/projectTemplater/test/examples/";
const PATH_PREFIX = "/Users/figgefenk/Dev/projectTemplater/test/examples/Nostromos/.cache/";
console.log(`Writing File: ${repo.name}`)
await writeFile(project, PATH_PREFIX)
}
Expand Down
22 changes: 0 additions & 22 deletions src/core/processOneUser.ts

This file was deleted.

25 changes: 12 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import prepareFiles from './cli/readWrite.js';
import cleanUp from './utils/index.js';
// import cleanUp from './utils/index.js';
import { processOneUser } from './core/batchProcessor.js'
// import octokit from './api/githubClient.js';
import octokit from './api/githubClient.js';

const myoc = octokit;

const username = 'Nostromos';

// Example usage of octokit to fetch user details
(async () => {
try {
const { data } = await myoc.rest.users.getByUsername({ username });
console.log(`Fetched user details for ${username}:`, data);
} catch (error) {
console.error(`Failed to fetch user details for ${username}:`, error);
try {
const { data } = await octokit.rest.users.getAuthenticated();
Copy link

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage of top-level await requires that the module is run as an ES module or that the Node.js version supports top-level await. If this code may run in a CommonJS environment, consider wrapping it in an async function.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my prototyping workflow so I will kill this before I go live.

console.log(`✅ Authenticated as ${data.login}`);
} catch (error: unknown) {
if (error instanceof Error) {
console.error("❌ Authentication failed:", error.message);
} else {
console.error("❌ Authentication failed:", error);
}
})();
}
const username = 'Nostromos';

try {
console.log(`Preparing files...`);
Expand Down