@braingrid/cli 0.2.0 → 0.2.1
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/CHANGELOG.md +32 -0
- package/README.md +54 -38
- package/dist/chunk-KNVWIF3L.js +401 -0
- package/dist/chunk-KNVWIF3L.js.map +1 -0
- package/dist/cli.js +6236 -245
- package/dist/cli.js.map +1 -1
- package/dist/gh-installer-B65ZOOC4.js +13 -0
- package/dist/gh-installer-B65ZOOC4.js.map +1 -0
- package/package.json +19 -11
- package/dist/build-config.d.ts +0 -26
- package/dist/build-config.d.ts.map +0 -1
- package/dist/build-config.js +0 -45
- package/dist/build-config.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/handlers/auth.handlers.d.ts +0 -13
- package/dist/handlers/auth.handlers.d.ts.map +0 -1
- package/dist/handlers/auth.handlers.js +0 -111
- package/dist/handlers/auth.handlers.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -13
- package/dist/handlers/index.d.ts.map +0 -1
- package/dist/handlers/index.js +0 -13
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/init.handlers.d.ts +0 -10
- package/dist/handlers/init.handlers.d.ts.map +0 -1
- package/dist/handlers/init.handlers.js +0 -638
- package/dist/handlers/init.handlers.js.map +0 -1
- package/dist/handlers/project.handlers.d.ts +0 -36
- package/dist/handlers/project.handlers.d.ts.map +0 -1
- package/dist/handlers/project.handlers.js +0 -309
- package/dist/handlers/project.handlers.js.map +0 -1
- package/dist/handlers/requirement.handlers.d.ts +0 -32
- package/dist/handlers/requirement.handlers.d.ts.map +0 -1
- package/dist/handlers/requirement.handlers.js +0 -264
- package/dist/handlers/requirement.handlers.js.map +0 -1
- package/dist/handlers/status.handlers.d.ts +0 -12
- package/dist/handlers/status.handlers.d.ts.map +0 -1
- package/dist/handlers/status.handlers.js +0 -212
- package/dist/handlers/status.handlers.js.map +0 -1
- package/dist/handlers/task.handlers.d.ts +0 -29
- package/dist/handlers/task.handlers.d.ts.map +0 -1
- package/dist/handlers/task.handlers.js +0 -326
- package/dist/handlers/task.handlers.js.map +0 -1
- package/dist/handlers/types.d.ts +0 -10
- package/dist/handlers/types.d.ts.map +0 -1
- package/dist/handlers/types.js +0 -5
- package/dist/handlers/types.js.map +0 -1
- package/dist/handlers/update.handlers.d.ts +0 -16
- package/dist/handlers/update.handlers.d.ts.map +0 -1
- package/dist/handlers/update.handlers.js +0 -119
- package/dist/handlers/update.handlers.js.map +0 -1
- package/dist/services/auth.d.ts +0 -59
- package/dist/services/auth.d.ts.map +0 -1
- package/dist/services/auth.js +0 -549
- package/dist/services/auth.js.map +0 -1
- package/dist/services/claude.d.ts +0 -18
- package/dist/services/claude.d.ts.map +0 -1
- package/dist/services/claude.js +0 -164
- package/dist/services/claude.js.map +0 -1
- package/dist/services/credential-store.d.ts +0 -47
- package/dist/services/credential-store.d.ts.map +0 -1
- package/dist/services/credential-store.js +0 -89
- package/dist/services/credential-store.js.map +0 -1
- package/dist/services/internal/github-service.d.ts +0 -67
- package/dist/services/internal/github-service.d.ts.map +0 -1
- package/dist/services/internal/github-service.js +0 -81
- package/dist/services/internal/github-service.js.map +0 -1
- package/dist/services/internal/repository-service.d.ts +0 -79
- package/dist/services/internal/repository-service.d.ts.map +0 -1
- package/dist/services/internal/repository-service.js +0 -88
- package/dist/services/internal/repository-service.js.map +0 -1
- package/dist/services/oauth2-auth.d.ts +0 -76
- package/dist/services/oauth2-auth.d.ts.map +0 -1
- package/dist/services/oauth2-auth.js +0 -451
- package/dist/services/oauth2-auth.js.map +0 -1
- package/dist/services/project-service.d.ts +0 -24
- package/dist/services/project-service.d.ts.map +0 -1
- package/dist/services/project-service.js +0 -60
- package/dist/services/project-service.js.map +0 -1
- package/dist/services/requirement-service.d.ts +0 -32
- package/dist/services/requirement-service.d.ts.map +0 -1
- package/dist/services/requirement-service.js +0 -91
- package/dist/services/requirement-service.js.map +0 -1
- package/dist/services/task-service.d.ts +0 -22
- package/dist/services/task-service.d.ts.map +0 -1
- package/dist/services/task-service.js +0 -52
- package/dist/services/task-service.js.map +0 -1
- package/dist/types/api.d.ts +0 -16
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/api.js +0 -5
- package/dist/types/api.js.map +0 -1
- package/dist/types/auth.d.ts +0 -73
- package/dist/types/auth.d.ts.map +0 -1
- package/dist/types/auth.js +0 -2
- package/dist/types/auth.js.map +0 -1
- package/dist/types/claude.d.ts +0 -22
- package/dist/types/claude.d.ts.map +0 -1
- package/dist/types/claude.js +0 -2
- package/dist/types/claude.js.map +0 -1
- package/dist/types/github.d.ts +0 -105
- package/dist/types/github.d.ts.map +0 -1
- package/dist/types/github.js +0 -6
- package/dist/types/github.js.map +0 -1
- package/dist/types/local-project.d.ts +0 -30
- package/dist/types/local-project.d.ts.map +0 -1
- package/dist/types/local-project.js +0 -24
- package/dist/types/local-project.js.map +0 -1
- package/dist/types/project.d.ts +0 -56
- package/dist/types/project.d.ts.map +0 -1
- package/dist/types/project.js +0 -5
- package/dist/types/project.js.map +0 -1
- package/dist/types/requirement.d.ts +0 -69
- package/dist/types/requirement.d.ts.map +0 -1
- package/dist/types/requirement.js +0 -5
- package/dist/types/requirement.js.map +0 -1
- package/dist/types/task.d.ts +0 -44
- package/dist/types/task.d.ts.map +0 -1
- package/dist/types/task.js +0 -5
- package/dist/types/task.js.map +0 -1
- package/dist/utils/axios-retry.d.ts +0 -25
- package/dist/utils/axios-retry.d.ts.map +0 -1
- package/dist/utils/axios-retry.js +0 -174
- package/dist/utils/axios-retry.js.map +0 -1
- package/dist/utils/axios-with-auth.d.ts +0 -10
- package/dist/utils/axios-with-auth.d.ts.map +0 -1
- package/dist/utils/axios-with-auth.js +0 -118
- package/dist/utils/axios-with-auth.js.map +0 -1
- package/dist/utils/cli-tools.d.ts +0 -30
- package/dist/utils/cli-tools.d.ts.map +0 -1
- package/dist/utils/cli-tools.js +0 -199
- package/dist/utils/cli-tools.js.map +0 -1
- package/dist/utils/command-execution.d.ts +0 -30
- package/dist/utils/command-execution.d.ts.map +0 -1
- package/dist/utils/command-execution.js +0 -264
- package/dist/utils/command-execution.js.map +0 -1
- package/dist/utils/command-parser.d.ts +0 -85
- package/dist/utils/command-parser.d.ts.map +0 -1
- package/dist/utils/command-parser.js +0 -287
- package/dist/utils/command-parser.js.map +0 -1
- package/dist/utils/config.d.ts +0 -10
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -77
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/error-formatter.d.ts +0 -17
- package/dist/utils/error-formatter.d.ts.map +0 -1
- package/dist/utils/error-formatter.js +0 -115
- package/dist/utils/error-formatter.js.map +0 -1
- package/dist/utils/formatting.d.ts +0 -10
- package/dist/utils/formatting.d.ts.map +0 -1
- package/dist/utils/formatting.js +0 -122
- package/dist/utils/formatting.js.map +0 -1
- package/dist/utils/gh-installer.d.ts +0 -31
- package/dist/utils/gh-installer.d.ts.map +0 -1
- package/dist/utils/gh-installer.js +0 -296
- package/dist/utils/gh-installer.js.map +0 -1
- package/dist/utils/git-installer.d.ts +0 -31
- package/dist/utils/git-installer.d.ts.map +0 -1
- package/dist/utils/git-installer.js +0 -290
- package/dist/utils/git-installer.js.map +0 -1
- package/dist/utils/git.d.ts +0 -60
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js +0 -144
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/github-repo.d.ts +0 -43
- package/dist/utils/github-repo.d.ts.map +0 -1
- package/dist/utils/github-repo.js +0 -113
- package/dist/utils/github-repo.js.map +0 -1
- package/dist/utils/id-normalization.d.ts +0 -26
- package/dist/utils/id-normalization.d.ts.map +0 -1
- package/dist/utils/id-normalization.js +0 -45
- package/dist/utils/id-normalization.js.map +0 -1
- package/dist/utils/jwt.d.ts +0 -45
- package/dist/utils/jwt.d.ts.map +0 -1
- package/dist/utils/jwt.js +0 -64
- package/dist/utils/jwt.js.map +0 -1
- package/dist/utils/local-store.d.ts +0 -36
- package/dist/utils/local-store.d.ts.map +0 -1
- package/dist/utils/local-store.js +0 -94
- package/dist/utils/local-store.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -36
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -176
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/package-manager-installer.d.ts +0 -36
- package/dist/utils/package-manager-installer.d.ts.map +0 -1
- package/dist/utils/package-manager-installer.js +0 -106
- package/dist/utils/package-manager-installer.js.map +0 -1
- package/dist/utils/package-manager.d.ts +0 -31
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js +0 -133
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/projects.d.ts +0 -23
- package/dist/utils/projects.d.ts.map +0 -1
- package/dist/utils/projects.js +0 -36
- package/dist/utils/projects.js.map +0 -1
- package/dist/utils/repository-access.d.ts +0 -89
- package/dist/utils/repository-access.d.ts.map +0 -1
- package/dist/utils/repository-access.js +0 -132
- package/dist/utils/repository-access.js.map +0 -1
- package/dist/utils/requirements.d.ts +0 -43
- package/dist/utils/requirements.d.ts.map +0 -1
- package/dist/utils/requirements.js +0 -79
- package/dist/utils/requirements.js.map +0 -1
- package/dist/utils/spinner.d.ts +0 -47
- package/dist/utils/spinner.d.ts.map +0 -1
- package/dist/utils/spinner.js +0 -101
- package/dist/utils/spinner.js.map +0 -1
- package/dist/utils/status-parser.d.ts +0 -95
- package/dist/utils/status-parser.d.ts.map +0 -1
- package/dist/utils/status-parser.js +0 -205
- package/dist/utils/status-parser.js.map +0 -1
- package/dist/utils/tasks.d.ts +0 -21
- package/dist/utils/tasks.d.ts.map +0 -1
- package/dist/utils/tasks.js +0 -63
- package/dist/utils/tasks.js.map +0 -1
- package/dist/utils/workspace-manager.d.ts +0 -65
- package/dist/utils/workspace-manager.d.ts.map +0 -1
- package/dist/utils/workspace-manager.js +0 -98
- package/dist/utils/workspace-manager.js.map +0 -1
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package Manager Detection Utilities
|
|
3
|
-
*
|
|
4
|
-
* Detects package managers on different platforms:
|
|
5
|
-
* - Homebrew on macOS
|
|
6
|
-
* - winget on Windows (typically pre-installed on Windows 10+)
|
|
7
|
-
* - apt/dnf/pacman on Linux
|
|
8
|
-
*/
|
|
9
|
-
import { exec } from 'child_process';
|
|
10
|
-
import { promisify } from 'util';
|
|
11
|
-
const execAsync = promisify(exec);
|
|
12
|
-
/**
|
|
13
|
-
* Check if Homebrew is installed (macOS)
|
|
14
|
-
*/
|
|
15
|
-
export async function isHomebrewInstalled() {
|
|
16
|
-
if (process.platform !== 'darwin') {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
await execAsync('which brew', { timeout: 2000 });
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Check if winget is available (Windows)
|
|
29
|
-
* winget is pre-installed on Windows 10 (version 1809+) and Windows 11
|
|
30
|
-
*/
|
|
31
|
-
export async function isWingetAvailable() {
|
|
32
|
-
if (process.platform !== 'win32') {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
await execAsync('winget --version', { timeout: 2000 });
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Detect available package manager on Linux
|
|
45
|
-
* Returns the first available package manager found
|
|
46
|
-
*/
|
|
47
|
-
export async function detectLinuxPackageManager() {
|
|
48
|
-
if (process.platform !== 'linux') {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const packageManagers = [
|
|
52
|
-
{ name: 'apt', command: 'apt-get', available: false },
|
|
53
|
-
{ name: 'dnf', command: 'dnf', available: false },
|
|
54
|
-
{ name: 'yum', command: 'yum', available: false },
|
|
55
|
-
{ name: 'pacman', command: 'pacman', available: false },
|
|
56
|
-
];
|
|
57
|
-
for (const pm of packageManagers) {
|
|
58
|
-
try {
|
|
59
|
-
await execAsync(`which ${pm.command}`, { timeout: 2000 });
|
|
60
|
-
return { ...pm, available: true };
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
// Package manager not found, continue checking
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get the appropriate package manager for the current platform
|
|
70
|
-
*/
|
|
71
|
-
export async function detectPackageManager() {
|
|
72
|
-
const platform = process.platform;
|
|
73
|
-
switch (platform) {
|
|
74
|
-
case 'darwin': {
|
|
75
|
-
const hasHomebrew = await isHomebrewInstalled();
|
|
76
|
-
return {
|
|
77
|
-
platform: 'macOS',
|
|
78
|
-
packageManager: 'brew',
|
|
79
|
-
available: hasHomebrew,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
case 'win32': {
|
|
83
|
-
const hasWinget = await isWingetAvailable();
|
|
84
|
-
return {
|
|
85
|
-
platform: 'Windows',
|
|
86
|
-
packageManager: 'winget',
|
|
87
|
-
available: hasWinget,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
case 'linux': {
|
|
91
|
-
const linuxPM = await detectLinuxPackageManager();
|
|
92
|
-
return {
|
|
93
|
-
platform: 'Linux',
|
|
94
|
-
packageManager: linuxPM?.name || null,
|
|
95
|
-
available: linuxPM !== null,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
default:
|
|
99
|
-
return {
|
|
100
|
-
platform: platform,
|
|
101
|
-
packageManager: null,
|
|
102
|
-
available: false,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=package-manager-installer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-installer.js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AE,OAAO,KAAK,IAAI;aAC3B,CAAC;QACH,CAAC;QAED;YACC,OAAO;gBACN,QAAQ,EAAE,QAAQ;gBAClB,cAAc,EAAE,IAAI;gBACpB,SAAS,EAAE,KAAK;aAChB,CAAC;IACJ,CAAC;AACF,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package Manager Detection Utility
|
|
3
|
-
*
|
|
4
|
-
* Detects which package manager (npm, pnpm, yarn) was used to install the CLI
|
|
5
|
-
* by checking global installation directories.
|
|
6
|
-
*/
|
|
7
|
-
export type PackageManager = 'npm' | 'pnpm' | 'yarn';
|
|
8
|
-
interface PackageManagerInfo {
|
|
9
|
-
name: PackageManager;
|
|
10
|
-
installed: boolean;
|
|
11
|
-
hasPackage: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get information about available package managers and whether they have the CLI installed
|
|
15
|
-
*/
|
|
16
|
-
export declare function getPackageManagerInfo(packageName: string): Promise<PackageManagerInfo[]>;
|
|
17
|
-
/**
|
|
18
|
-
* Detect which package manager was used to install the CLI
|
|
19
|
-
* Returns the detected package manager or prompts the user if detection fails
|
|
20
|
-
*/
|
|
21
|
-
export declare function detectPackageManager(packageName: string): Promise<PackageManager>;
|
|
22
|
-
/**
|
|
23
|
-
* Get the update command for a specific package manager
|
|
24
|
-
*/
|
|
25
|
-
export declare function getUpdateCommand(pm: PackageManager, packageName: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Execute the update command
|
|
28
|
-
*/
|
|
29
|
-
export declare function executeUpdate(pm: PackageManager, packageName: string): void;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/utils/package-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD,UAAU,kBAAkB;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACpB;AAyDD;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAW9F;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA+BvF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAYhF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAa3E"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package Manager Detection Utility
|
|
3
|
-
*
|
|
4
|
-
* Detects which package manager (npm, pnpm, yarn) was used to install the CLI
|
|
5
|
-
* by checking global installation directories.
|
|
6
|
-
*/
|
|
7
|
-
import { execSync } from 'child_process';
|
|
8
|
-
import { select } from '@inquirer/prompts';
|
|
9
|
-
/**
|
|
10
|
-
* Check if a package manager is installed on the system
|
|
11
|
-
*/
|
|
12
|
-
function isPackageManagerInstalled(pm) {
|
|
13
|
-
try {
|
|
14
|
-
execSync(`which ${pm}`, { stdio: 'ignore', timeout: 2000 });
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check if the CLI package is installed globally with a specific package manager
|
|
23
|
-
*/
|
|
24
|
-
function checkGlobalInstallation(pm, packageName) {
|
|
25
|
-
try {
|
|
26
|
-
let command;
|
|
27
|
-
switch (pm) {
|
|
28
|
-
case 'npm': {
|
|
29
|
-
command = `npm list -g ${packageName} 2>&1`;
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case 'pnpm': {
|
|
33
|
-
command = `pnpm list -g ${packageName} 2>&1`;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case 'yarn': {
|
|
37
|
-
command = `yarn global list 2>&1`;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const output = execSync(command, {
|
|
42
|
-
encoding: 'utf-8',
|
|
43
|
-
timeout: 5000,
|
|
44
|
-
});
|
|
45
|
-
// For npm and pnpm, check if output contains the package name and not "(empty)"
|
|
46
|
-
if (pm === 'npm' || pm === 'pnpm') {
|
|
47
|
-
return output.includes(packageName) && !output.includes('(empty)');
|
|
48
|
-
}
|
|
49
|
-
// For yarn, check if package is in the list
|
|
50
|
-
if (pm === 'yarn') {
|
|
51
|
-
return output.includes(packageName);
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get information about available package managers and whether they have the CLI installed
|
|
61
|
-
*/
|
|
62
|
-
export async function getPackageManagerInfo(packageName) {
|
|
63
|
-
const packageManagers = ['npm', 'pnpm', 'yarn'];
|
|
64
|
-
return packageManagers.map(pm => {
|
|
65
|
-
const installed = isPackageManagerInstalled(pm);
|
|
66
|
-
return {
|
|
67
|
-
name: pm,
|
|
68
|
-
installed,
|
|
69
|
-
hasPackage: installed ? checkGlobalInstallation(pm, packageName) : false,
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Detect which package manager was used to install the CLI
|
|
75
|
-
* Returns the detected package manager or prompts the user if detection fails
|
|
76
|
-
*/
|
|
77
|
-
export async function detectPackageManager(packageName) {
|
|
78
|
-
const pmInfo = await getPackageManagerInfo(packageName);
|
|
79
|
-
// First, check if any package manager has the package installed
|
|
80
|
-
const installedWith = pmInfo.find(pm => pm.hasPackage);
|
|
81
|
-
if (installedWith) {
|
|
82
|
-
return installedWith.name;
|
|
83
|
-
}
|
|
84
|
-
// If detection failed, check which package managers are available and prompt
|
|
85
|
-
const availablePMs = pmInfo.filter(pm => pm.installed);
|
|
86
|
-
if (availablePMs.length === 0) {
|
|
87
|
-
throw new Error('No package manager found. Please install npm, pnpm, or yarn.');
|
|
88
|
-
}
|
|
89
|
-
if (availablePMs.length === 1) {
|
|
90
|
-
return availablePMs[0].name;
|
|
91
|
-
}
|
|
92
|
-
// Multiple package managers available, prompt user
|
|
93
|
-
const selected = await select({
|
|
94
|
-
message: 'Unable to detect which package manager was used. Please select one:',
|
|
95
|
-
choices: availablePMs.map(pm => ({
|
|
96
|
-
name: pm.name,
|
|
97
|
-
value: pm.name,
|
|
98
|
-
})),
|
|
99
|
-
});
|
|
100
|
-
return selected;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get the update command for a specific package manager
|
|
104
|
-
*/
|
|
105
|
-
export function getUpdateCommand(pm, packageName) {
|
|
106
|
-
switch (pm) {
|
|
107
|
-
case 'npm': {
|
|
108
|
-
return `npm install -g ${packageName}@latest`;
|
|
109
|
-
}
|
|
110
|
-
case 'pnpm': {
|
|
111
|
-
return `pnpm add -g ${packageName}@latest`;
|
|
112
|
-
}
|
|
113
|
-
case 'yarn': {
|
|
114
|
-
return `yarn global add ${packageName}@latest`;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Execute the update command
|
|
120
|
-
*/
|
|
121
|
-
export function executeUpdate(pm, packageName) {
|
|
122
|
-
const command = getUpdateCommand(pm, packageName);
|
|
123
|
-
try {
|
|
124
|
-
execSync(command, {
|
|
125
|
-
stdio: 'inherit',
|
|
126
|
-
timeout: 120000, // 2 minutes timeout
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
throw new Error(`Failed to update package: ${error instanceof Error ? error.message : String(error)}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=package-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.js","sourceRoot":"","sources":["../../src/utils/package-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAU3C;;GAEG;AACH,SAAS,yBAAyB,CAAC,EAAkB;IACpD,IAAI,CAAC;QACJ,QAAQ,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,EAAkB,EAAE,WAAmB;IACvE,IAAI,CAAC;QACJ,IAAI,OAAe,CAAC;QAEpB,QAAQ,EAAE,EAAE,CAAC;YACZ,KAAK,KAAK,CAAC,CAAC,CAAC;gBACZ,OAAO,GAAG,eAAe,WAAW,OAAO,CAAC;gBAC5C,MAAM;YACP,CAAC;YACD,KAAK,MAAM,CAAC,CAAC,CAAC;gBACb,OAAO,GAAG,gBAAgB,WAAW,OAAO,CAAC;gBAC7C,MAAM;YACP,CAAC;YACD,KAAK,MAAM,CAAC,CAAC,CAAC;gBACb,OAAO,GAAG,uBAAuB,CAAC;gBAClC,MAAM;YACP,CAAC;QACF,CAAC;QAED,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE;YAChC,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,gFAAgF;QAChF,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;YACnC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AA6B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACrF,CAAC;IACH,CAAC;AACF,CAAC"}
|
package/dist/utils/projects.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Project } from '../types/project.js';
|
|
2
|
-
/**
|
|
3
|
-
* Format a project with friendly PROJ-<number> format
|
|
4
|
-
* Note: short_id already contains "PROJ-123" format
|
|
5
|
-
*/
|
|
6
|
-
export declare function formatProjectId(project: Project): string;
|
|
7
|
-
/**
|
|
8
|
-
* Normalize project ID from various formats to API-compatible format:
|
|
9
|
-
* - "PROJ-123" -> "PROJ-123" (already normalized)
|
|
10
|
-
* - "proj-123" -> "PROJ-123" (uppercase)
|
|
11
|
-
* - "PROJ 123" -> "PROJ-123" (add dash, uppercase)
|
|
12
|
-
* - "proj 123" -> "PROJ-123" (add dash, uppercase)
|
|
13
|
-
* - "123" -> "PROJ-123" (add prefix)
|
|
14
|
-
* - "uuid-string" -> "uuid-string" (UUID, return as-is)
|
|
15
|
-
*
|
|
16
|
-
* This function takes user input and returns the ID that should be used in API calls
|
|
17
|
-
*/
|
|
18
|
-
export declare function parseProjectId(input: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Find a project by either short_id or UUID
|
|
21
|
-
*/
|
|
22
|
-
export declare function findProjectById(projects: Project[], identifier: string): Project | undefined;
|
|
23
|
-
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/utils/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAExD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAW5F"}
|
package/dist/utils/projects.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { normalizeId } from './id-normalization.js';
|
|
2
|
-
/**
|
|
3
|
-
* Format a project with friendly PROJ-<number> format
|
|
4
|
-
* Note: short_id already contains "PROJ-123" format
|
|
5
|
-
*/
|
|
6
|
-
export function formatProjectId(project) {
|
|
7
|
-
return project.short_id;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Normalize project ID from various formats to API-compatible format:
|
|
11
|
-
* - "PROJ-123" -> "PROJ-123" (already normalized)
|
|
12
|
-
* - "proj-123" -> "PROJ-123" (uppercase)
|
|
13
|
-
* - "PROJ 123" -> "PROJ-123" (add dash, uppercase)
|
|
14
|
-
* - "proj 123" -> "PROJ-123" (add dash, uppercase)
|
|
15
|
-
* - "123" -> "PROJ-123" (add prefix)
|
|
16
|
-
* - "uuid-string" -> "uuid-string" (UUID, return as-is)
|
|
17
|
-
*
|
|
18
|
-
* This function takes user input and returns the ID that should be used in API calls
|
|
19
|
-
*/
|
|
20
|
-
export function parseProjectId(input) {
|
|
21
|
-
return normalizeId('PROJ', input);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Find a project by either short_id or UUID
|
|
25
|
-
*/
|
|
26
|
-
export function findProjectById(projects, identifier) {
|
|
27
|
-
const normalized = parseProjectId(identifier);
|
|
28
|
-
// Try to find by short_id first (handles PROJ-X format)
|
|
29
|
-
const byShortId = projects.find(proj => proj.short_id === normalized);
|
|
30
|
-
if (byShortId) {
|
|
31
|
-
return byShortId;
|
|
32
|
-
}
|
|
33
|
-
// Try to find by UUID
|
|
34
|
-
return projects.find(proj => proj.id === normalized);
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=projects.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/utils/projects.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC/C,OAAO,OAAO,CAAC,QAAQ,CAAC;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC3C,OAAO,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAmB,EAAE,UAAkB;IACtE,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAE9C,wDAAwD;IACxD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;IACtE,IAAI,SAAS,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,sBAAsB;IACtB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository Access Utility
|
|
3
|
-
*
|
|
4
|
-
* Helpers for checking GitHub installation and repository access during project initialization.
|
|
5
|
-
* Handles detection of owner-specific installations and repository visibility in BrainGrid.
|
|
6
|
-
*/
|
|
7
|
-
import { GitHubInstallation } from '../types/github.js';
|
|
8
|
-
import { RepositoryService } from '../services/internal/repository-service.js';
|
|
9
|
-
/**
|
|
10
|
-
* Find a GitHub installation for a specific repository owner
|
|
11
|
-
*
|
|
12
|
-
* @param owner - The GitHub repository owner (org or user)
|
|
13
|
-
* @param installations - List of GitHub installations to search
|
|
14
|
-
* @returns The matching installation or null if not found
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const installation = findInstallationForOwner('myorg', installations);
|
|
19
|
-
* if (installation) {
|
|
20
|
-
* console.log(`Found installation for ${installation.account_name}`);
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function findInstallationForOwner(owner: string, installations: GitHubInstallation[]): GitHubInstallation | null;
|
|
25
|
-
/**
|
|
26
|
-
* Check if a repository is accessible in BrainGrid
|
|
27
|
-
*
|
|
28
|
-
* Queries the repository API to see if the specific owner/name combination
|
|
29
|
-
* is visible to the authenticated user's organization.
|
|
30
|
-
*
|
|
31
|
-
* @param repositoryService - Repository service instance
|
|
32
|
-
* @param owner - GitHub repository owner
|
|
33
|
-
* @param name - GitHub repository name
|
|
34
|
-
* @returns True if repository is accessible, false otherwise
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const hasAccess = await checkRepositoryAccess(repoService, 'myorg', 'myrepo');
|
|
39
|
-
* if (hasAccess) {
|
|
40
|
-
* console.log('Repository is accessible in BrainGrid');
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export declare function checkRepositoryAccess(repositoryService: RepositoryService, owner: string, name: string): Promise<boolean>;
|
|
45
|
-
/**
|
|
46
|
-
* Poll for repository access with timeout
|
|
47
|
-
*
|
|
48
|
-
* Continuously checks if a repository becomes accessible in BrainGrid.
|
|
49
|
-
* Useful when waiting for a user to grant access through the web UI.
|
|
50
|
-
*
|
|
51
|
-
* @param repositoryService - Repository service instance
|
|
52
|
-
* @param owner - GitHub repository owner
|
|
53
|
-
* @param name - GitHub repository name
|
|
54
|
-
* @param intervalMs - Polling interval in milliseconds (default: 3000)
|
|
55
|
-
* @param maxAttempts - Maximum number of polling attempts (default: 60 = 3 minutes at 3s interval)
|
|
56
|
-
* @returns Promise that resolves to true if access is granted, false if timeout
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* const granted = await pollForRepositoryAccess(repoService, 'myorg', 'myrepo');
|
|
61
|
-
* if (granted) {
|
|
62
|
-
* console.log('Access granted!');
|
|
63
|
-
* } else {
|
|
64
|
-
* console.log('Timeout - access not granted within 3 minutes');
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function pollForRepositoryAccess(repositoryService: RepositoryService, owner: string, name: string, intervalMs?: number, maxAttempts?: number): Promise<boolean>;
|
|
69
|
-
/**
|
|
70
|
-
* Get repository ID from BrainGrid API
|
|
71
|
-
*
|
|
72
|
-
* Fetches the repository details to get its BrainGrid UUID, which is needed
|
|
73
|
-
* for linking repositories to projects.
|
|
74
|
-
*
|
|
75
|
-
* @param repositoryService - Repository service instance
|
|
76
|
-
* @param owner - GitHub repository owner
|
|
77
|
-
* @param name - GitHub repository name
|
|
78
|
-
* @returns Repository UUID or null if not found
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* const repoId = await getRepositoryId(repoService, 'myorg', 'myrepo');
|
|
83
|
-
* if (repoId) {
|
|
84
|
-
* await projectService.createProject({ name: 'My Project', repository_ids: [repoId] });
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare function getRepositoryId(repositoryService: RepositoryService, owner: string, name: string): Promise<string | null>;
|
|
89
|
-
//# sourceMappingURL=repository-access.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository-access.d.ts","sourceRoot":"","sources":["../../src/utils/repository-access.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAE/E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,kBAAkB,EAAE,GACjC,kBAAkB,GAAG,IAAI,CAK3B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,qBAAqB,CAC1C,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC,CAclB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,uBAAuB,CAC5C,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAAa,EACzB,WAAW,GAAE,MAAW,GACtB,OAAO,CAAC,OAAO,CAAC,CAelB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,eAAe,CACpC,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBxB"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Repository Access Utility
|
|
3
|
-
*
|
|
4
|
-
* Helpers for checking GitHub installation and repository access during project initialization.
|
|
5
|
-
* Handles detection of owner-specific installations and repository visibility in BrainGrid.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Find a GitHub installation for a specific repository owner
|
|
9
|
-
*
|
|
10
|
-
* @param owner - The GitHub repository owner (org or user)
|
|
11
|
-
* @param installations - List of GitHub installations to search
|
|
12
|
-
* @returns The matching installation or null if not found
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* const installation = findInstallationForOwner('myorg', installations);
|
|
17
|
-
* if (installation) {
|
|
18
|
-
* console.log(`Found installation for ${installation.account_name}`);
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export function findInstallationForOwner(owner, installations) {
|
|
23
|
-
// Case-insensitive match on account_name
|
|
24
|
-
const normalizedOwner = owner.toLowerCase();
|
|
25
|
-
return installations.find(inst => inst.account_name.toLowerCase() === normalizedOwner) || null;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Check if a repository is accessible in BrainGrid
|
|
29
|
-
*
|
|
30
|
-
* Queries the repository API to see if the specific owner/name combination
|
|
31
|
-
* is visible to the authenticated user's organization.
|
|
32
|
-
*
|
|
33
|
-
* @param repositoryService - Repository service instance
|
|
34
|
-
* @param owner - GitHub repository owner
|
|
35
|
-
* @param name - GitHub repository name
|
|
36
|
-
* @returns True if repository is accessible, false otherwise
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const hasAccess = await checkRepositoryAccess(repoService, 'myorg', 'myrepo');
|
|
41
|
-
* if (hasAccess) {
|
|
42
|
-
* console.log('Repository is accessible in BrainGrid');
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export async function checkRepositoryAccess(repositoryService, owner, name) {
|
|
47
|
-
try {
|
|
48
|
-
const response = await repositoryService.listRepositories({
|
|
49
|
-
owner,
|
|
50
|
-
name,
|
|
51
|
-
limit: 1,
|
|
52
|
-
});
|
|
53
|
-
// If we get results, the repository is accessible
|
|
54
|
-
return response.repositories.length > 0;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
// If the API call fails, assume no access
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Poll for repository access with timeout
|
|
63
|
-
*
|
|
64
|
-
* Continuously checks if a repository becomes accessible in BrainGrid.
|
|
65
|
-
* Useful when waiting for a user to grant access through the web UI.
|
|
66
|
-
*
|
|
67
|
-
* @param repositoryService - Repository service instance
|
|
68
|
-
* @param owner - GitHub repository owner
|
|
69
|
-
* @param name - GitHub repository name
|
|
70
|
-
* @param intervalMs - Polling interval in milliseconds (default: 3000)
|
|
71
|
-
* @param maxAttempts - Maximum number of polling attempts (default: 60 = 3 minutes at 3s interval)
|
|
72
|
-
* @returns Promise that resolves to true if access is granted, false if timeout
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const granted = await pollForRepositoryAccess(repoService, 'myorg', 'myrepo');
|
|
77
|
-
* if (granted) {
|
|
78
|
-
* console.log('Access granted!');
|
|
79
|
-
* } else {
|
|
80
|
-
* console.log('Timeout - access not granted within 3 minutes');
|
|
81
|
-
* }
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
export async function pollForRepositoryAccess(repositoryService, owner, name, intervalMs = 3000, maxAttempts = 60) {
|
|
85
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
86
|
-
const hasAccess = await checkRepositoryAccess(repositoryService, owner, name);
|
|
87
|
-
if (hasAccess) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
// Wait before next attempt (unless this was the last attempt)
|
|
91
|
-
if (attempt < maxAttempts - 1) {
|
|
92
|
-
await new Promise(resolve => setTimeout(resolve, intervalMs));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get repository ID from BrainGrid API
|
|
99
|
-
*
|
|
100
|
-
* Fetches the repository details to get its BrainGrid UUID, which is needed
|
|
101
|
-
* for linking repositories to projects.
|
|
102
|
-
*
|
|
103
|
-
* @param repositoryService - Repository service instance
|
|
104
|
-
* @param owner - GitHub repository owner
|
|
105
|
-
* @param name - GitHub repository name
|
|
106
|
-
* @returns Repository UUID or null if not found
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const repoId = await getRepositoryId(repoService, 'myorg', 'myrepo');
|
|
111
|
-
* if (repoId) {
|
|
112
|
-
* await projectService.createProject({ name: 'My Project', repository_ids: [repoId] });
|
|
113
|
-
* }
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
export async function getRepositoryId(repositoryService, owner, name) {
|
|
117
|
-
try {
|
|
118
|
-
const response = await repositoryService.listRepositories({
|
|
119
|
-
owner,
|
|
120
|
-
name,
|
|
121
|
-
limit: 1,
|
|
122
|
-
});
|
|
123
|
-
if (response.repositories.length === 0) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
return response.repositories[0].id;
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=repository-access.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repository-access.js","sourceRoot":"","sources":["../../src/utils/repository-access.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB,CACvC,KAAa,EACb,aAAmC;IAEnC,yCAAyC;IACzC,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAE5C,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,IAAI,IAAI,CAAC;AAChG,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,iBAAoC,EACpC,KAAa,EACb,IAAY;IAEZ,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,CAAC;YACzD,KAAK;YACL,IAAI;YACJ,KAAK,EAAE,CAAC;SACR,CAAC,CAAC;QAEH,kDAAkD;QAClD,OAAO,QAAQ,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACR,0CAA0C;QAC1C,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;;;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
* Note: short_id already contains "REQ-123" format
|
|
5
|
-
*/
|
|
6
|
-
export declare function formatRequirementId(requirement: Requirement): string;
|
|
7
|
-
/**
|
|
8
|
-
* Normalize requirement ID from various formats to API-compatible format:
|
|
9
|
-
* - "REQ-123" -> "REQ-123" (already normalized)
|
|
10
|
-
* - "req-123" -> "REQ-123" (uppercase)
|
|
11
|
-
* - "REQ 123" -> "REQ-123" (add dash, uppercase)
|
|
12
|
-
* - "req 123" -> "REQ-123" (add dash, uppercase)
|
|
13
|
-
* - "123" -> "REQ-123" (add prefix)
|
|
14
|
-
* - "uuid-string" -> "uuid-string" (UUID, return as-is)
|
|
15
|
-
*
|
|
16
|
-
* This function takes user input and returns the ID that should be used in API calls
|
|
17
|
-
*/
|
|
18
|
-
export declare function normalizeRequirementId(input: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Parse a requirement ID from various formats:
|
|
21
|
-
* - "REQ-123" -> { type: 'req_id', value: 123 }
|
|
22
|
-
* - "req-123" -> { type: 'req_id', value: 123 }
|
|
23
|
-
* - "REQ 123" -> { type: 'req_id', value: 123 }
|
|
24
|
-
* - "req 123" -> { type: 'req_id', value: 123 }
|
|
25
|
-
* - "123" -> { type: 'req_id', value: 123 }
|
|
26
|
-
* - "uuid-string" -> { type: 'uuid', value: 'uuid-string' }
|
|
27
|
-
*/
|
|
28
|
-
export declare function parseRequirementId(input: string): {
|
|
29
|
-
type: 'req_id' | 'uuid';
|
|
30
|
-
value: string | number;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Find a requirement by either req_id or UUID
|
|
34
|
-
*/
|
|
35
|
-
export declare function findRequirementById(requirements: Requirement[], identifier: string): Requirement | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Get query parameters for API calls based on identifier type
|
|
38
|
-
* Note: API doesn't support req_id parameter, so we only return id for UUIDs
|
|
39
|
-
*/
|
|
40
|
-
export declare function getRequirementQueryParams(identifier: string): {
|
|
41
|
-
id?: string;
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=requirements.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requirements.d.ts","sourceRoot":"","sources":["../../src/utils/requirements.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAEpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IAClD,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAwBA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,WAAW,EAAE,EAC3B,UAAU,EAAE,MAAM,GAChB,WAAW,GAAG,SAAS,CAQzB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAS7E"}
|