scai 0.1.79 → 0.1.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/ReviewCmd.js +1 -1
- package/dist/config.js +0 -1
- package/dist/github/auth.js +10 -2
- package/dist/github/repo.js +11 -6
- package/dist/github/token.js +2 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -363,9 +363,9 @@ export async function promptChunkReviewMenu() {
|
|
|
363
363
|
// Main command to review PR
|
|
364
364
|
export async function reviewPullRequestCmd(branch = 'main', showAll = false) {
|
|
365
365
|
try {
|
|
366
|
+
const { owner, repo } = await getRepoDetails();
|
|
366
367
|
const token = await ensureGitHubAuth();
|
|
367
368
|
const username = await getGitHubUsername(token);
|
|
368
|
-
const { owner, repo } = await getRepoDetails();
|
|
369
369
|
const prsWithReviewRequested = await getPullRequestsForReview(token, owner, repo, username, branch, !showAll);
|
|
370
370
|
if (prsWithReviewRequested.length === 0)
|
|
371
371
|
return;
|
package/dist/config.js
CHANGED
|
@@ -103,7 +103,6 @@ export const Config = {
|
|
|
103
103
|
console.log(`📦 Database not found. ${chalk.green('Initializing DB')} at ${normalizePath(dbPath)}`);
|
|
104
104
|
getDbForRepo(); // Now DB creation works after config update
|
|
105
105
|
}
|
|
106
|
-
console.log(`✅ Index directory set to: ${normalizePath(absPath)}`);
|
|
107
106
|
},
|
|
108
107
|
/**
|
|
109
108
|
* Set both the scaiRepoRoot for the config and the indexDir (the actual repo root path)
|
package/dist/github/auth.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
1
2
|
import { Config } from '../config.js';
|
|
2
3
|
import { promptForToken } from './token.js';
|
|
3
4
|
export async function ensureGitHubAuth() {
|
|
4
5
|
// First check if the token exists in the config
|
|
5
6
|
let token = Config.getGitHubToken();
|
|
6
7
|
if (token) {
|
|
8
|
+
console.log("🔐 GitHub token found in config.");
|
|
7
9
|
return token; // Token already exists in config, return it
|
|
8
10
|
}
|
|
9
11
|
// Token doesn't exist in config, prompt the user for it
|
|
10
|
-
console.log("🔐 GitHub token not found.");
|
|
12
|
+
console.log(chalk.red("🔐 GitHub token not found."));
|
|
11
13
|
token = await promptForToken();
|
|
14
|
+
// Ensure the token is not empty and has the required format (you can extend this check as needed)
|
|
15
|
+
while (!token || token.trim().length === 0) {
|
|
16
|
+
console.log("❌ Invalid token entered. Please enter a valid GitHub token.");
|
|
17
|
+
token = await promptForToken();
|
|
18
|
+
}
|
|
12
19
|
// Save the token in the config
|
|
13
20
|
Config.setGitHubToken(token.trim());
|
|
14
|
-
|
|
21
|
+
console.log(chalk.green("✅ GitHub token successfully saved."));
|
|
22
|
+
return token.trim(); // Return the trimmed token
|
|
15
23
|
}
|
package/dist/github/repo.js
CHANGED
|
@@ -2,6 +2,7 @@ import path from 'path';
|
|
|
2
2
|
import { execSync } from 'child_process';
|
|
3
3
|
import { Config } from '../config.js';
|
|
4
4
|
import { ensureGitHubAuth } from './auth.js';
|
|
5
|
+
import chalk from 'chalk';
|
|
5
6
|
/**
|
|
6
7
|
* Executes a Git command inside the specified working directory.
|
|
7
8
|
*/
|
|
@@ -43,14 +44,18 @@ function getRepoOwnerAndNameFromIndexDir(indexDir) {
|
|
|
43
44
|
* Prefers Git config, falls back to parsing the path.
|
|
44
45
|
*/
|
|
45
46
|
export async function getRepoDetails() {
|
|
46
|
-
let indexDir = Config.getIndexDir(); // Fetch the current indexDir
|
|
47
|
-
const currentDir = process.cwd(); // Get the current working directory
|
|
47
|
+
let indexDir = path.normalize(Config.getIndexDir()); // Fetch the current indexDir
|
|
48
|
+
const currentDir = path.normalize(process.cwd()); // Get the current working directory
|
|
48
49
|
if (!indexDir) {
|
|
49
|
-
|
|
50
|
+
console.log("❌ indexDir is not configured. Setting up a new index for the current directory...");
|
|
51
|
+
// Automatically set the index directory for the current directory
|
|
52
|
+
await setIndexDirForCurrentDir(currentDir);
|
|
53
|
+
// Now that the indexDir is set, fetch it again
|
|
54
|
+
indexDir = Config.getIndexDir();
|
|
50
55
|
}
|
|
51
|
-
console.log(`📦 Resolving GitHub repo info from indexDir: ${indexDir}`);
|
|
56
|
+
console.log(chalk.yellow(`📦 Resolving GitHub repo info from indexDir: ${indexDir}`));
|
|
52
57
|
// Check if the current directory is the same as the index directory
|
|
53
|
-
if (currentDir !== indexDir) {
|
|
58
|
+
if (path.resolve(currentDir) !== path.resolve(indexDir)) {
|
|
54
59
|
console.log(`🚧 Current directory is not the index directory. Setting up new index...`);
|
|
55
60
|
// Use the existing functionality to set up a new index directory
|
|
56
61
|
await setIndexDirForCurrentDir(currentDir);
|
|
@@ -58,7 +63,7 @@ export async function getRepoDetails() {
|
|
|
58
63
|
indexDir = Config.getIndexDir(); // Re-fetch the updated indexDir
|
|
59
64
|
}
|
|
60
65
|
// Ensure the repository authentication is available
|
|
61
|
-
ensureAuthCredentials();
|
|
66
|
+
await ensureAuthCredentials();
|
|
62
67
|
// Proceed with the normal flow to fetch the repo details
|
|
63
68
|
try {
|
|
64
69
|
return getRepoOwnerAndNameFromGit(indexDir); // Try fetching from Git config
|
package/dist/github/token.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Utility function to prompt for GitHub token
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import readline from 'readline';
|
|
3
4
|
export function promptForToken() {
|
|
4
5
|
return new Promise((resolve) => {
|
|
@@ -6,7 +7,7 @@ export function promptForToken() {
|
|
|
6
7
|
input: process.stdin,
|
|
7
8
|
output: process.stdout,
|
|
8
9
|
});
|
|
9
|
-
rl.question(
|
|
10
|
+
rl.question(`\nPaste your GitHub Personal Access Token:\n${chalk.yellow('(press Control + C to exit)')}\n`, (token) => {
|
|
10
11
|
rl.close();
|
|
11
12
|
resolve(token);
|
|
12
13
|
});
|
package/dist/index.js
CHANGED
|
@@ -153,9 +153,9 @@ index
|
|
|
153
153
|
.description('Index supported files in the configured index directory')
|
|
154
154
|
.action(runIndexCommand);
|
|
155
155
|
index
|
|
156
|
-
.command('set
|
|
156
|
+
.command('set [dir]')
|
|
157
157
|
.description('Set and activate index directory')
|
|
158
|
-
.action((dir) => {
|
|
158
|
+
.action((dir = process.cwd()) => {
|
|
159
159
|
Config.setIndexDir(dir);
|
|
160
160
|
Config.show();
|
|
161
161
|
});
|