@hyperdrive.bot/gut 0.1.4 → 0.1.6

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.
Files changed (87) hide show
  1. package/README.md +1 -779
  2. package/bin/run.js +5 -0
  3. package/package.json +10 -10
  4. package/bin/run +0 -5
  5. package/dist/base-command.d.ts +0 -21
  6. package/dist/base-command.js +0 -110
  7. package/dist/commands/add.d.ts +0 -13
  8. package/dist/commands/add.js +0 -73
  9. package/dist/commands/affected.d.ts +0 -23
  10. package/dist/commands/affected.js +0 -326
  11. package/dist/commands/audit.d.ts +0 -33
  12. package/dist/commands/audit.js +0 -593
  13. package/dist/commands/back.d.ts +0 -6
  14. package/dist/commands/back.js +0 -29
  15. package/dist/commands/commit.d.ts +0 -11
  16. package/dist/commands/commit.js +0 -113
  17. package/dist/commands/context.d.ts +0 -6
  18. package/dist/commands/context.js +0 -36
  19. package/dist/commands/contexts.d.ts +0 -7
  20. package/dist/commands/contexts.js +0 -92
  21. package/dist/commands/deps.d.ts +0 -10
  22. package/dist/commands/deps.js +0 -104
  23. package/dist/commands/entity/add.d.ts +0 -16
  24. package/dist/commands/entity/add.js +0 -105
  25. package/dist/commands/entity/clone-all.d.ts +0 -17
  26. package/dist/commands/entity/clone-all.js +0 -135
  27. package/dist/commands/entity/clone.d.ts +0 -15
  28. package/dist/commands/entity/clone.js +0 -109
  29. package/dist/commands/entity/list.d.ts +0 -11
  30. package/dist/commands/entity/list.js +0 -82
  31. package/dist/commands/entity/remove.d.ts +0 -12
  32. package/dist/commands/entity/remove.js +0 -58
  33. package/dist/commands/focus.d.ts +0 -19
  34. package/dist/commands/focus.js +0 -139
  35. package/dist/commands/graph.d.ts +0 -18
  36. package/dist/commands/graph.js +0 -238
  37. package/dist/commands/init.d.ts +0 -11
  38. package/dist/commands/init.js +0 -84
  39. package/dist/commands/insights.d.ts +0 -21
  40. package/dist/commands/insights.js +0 -434
  41. package/dist/commands/patterns.d.ts +0 -40
  42. package/dist/commands/patterns.js +0 -412
  43. package/dist/commands/pull.d.ts +0 -11
  44. package/dist/commands/pull.js +0 -121
  45. package/dist/commands/push.d.ts +0 -11
  46. package/dist/commands/push.js +0 -101
  47. package/dist/commands/quick-setup.d.ts +0 -20
  48. package/dist/commands/quick-setup.js +0 -422
  49. package/dist/commands/recent.d.ts +0 -9
  50. package/dist/commands/recent.js +0 -55
  51. package/dist/commands/related.d.ts +0 -23
  52. package/dist/commands/related.js +0 -257
  53. package/dist/commands/repos.d.ts +0 -14
  54. package/dist/commands/repos.js +0 -185
  55. package/dist/commands/stack.d.ts +0 -10
  56. package/dist/commands/stack.js +0 -83
  57. package/dist/commands/status.d.ts +0 -14
  58. package/dist/commands/status.js +0 -246
  59. package/dist/commands/sync.d.ts +0 -11
  60. package/dist/commands/sync.js +0 -142
  61. package/dist/commands/unfocus.d.ts +0 -6
  62. package/dist/commands/unfocus.js +0 -23
  63. package/dist/commands/used-by.d.ts +0 -10
  64. package/dist/commands/used-by.js +0 -111
  65. package/dist/commands/workspace.d.ts +0 -20
  66. package/dist/commands/workspace.js +0 -365
  67. package/dist/index.d.ts +0 -1
  68. package/dist/index.js +0 -5
  69. package/dist/models/entity.model.d.ts +0 -81
  70. package/dist/models/entity.model.js +0 -2
  71. package/dist/services/config.service.d.ts +0 -34
  72. package/dist/services/config.service.js +0 -230
  73. package/dist/services/entity.service.d.ts +0 -19
  74. package/dist/services/entity.service.js +0 -130
  75. package/dist/services/focus.service.d.ts +0 -70
  76. package/dist/services/focus.service.js +0 -587
  77. package/dist/services/git.service.d.ts +0 -37
  78. package/dist/services/git.service.js +0 -180
  79. package/dist/utils/display.d.ts +0 -25
  80. package/dist/utils/display.js +0 -150
  81. package/dist/utils/filesystem.d.ts +0 -32
  82. package/dist/utils/filesystem.js +0 -220
  83. package/dist/utils/index.d.ts +0 -13
  84. package/dist/utils/index.js +0 -18
  85. package/dist/utils/validation.d.ts +0 -22
  86. package/dist/utils/validation.js +0 -196
  87. package/oclif.manifest.json +0 -1463
@@ -1,180 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GitService = void 0;
4
- const tslib_1 = require("tslib");
5
- const child_process_1 = require("child_process");
6
- const path = tslib_1.__importStar(require("path"));
7
- class GitService {
8
- async exec(args, options) {
9
- return new Promise((resolve, reject) => {
10
- const gitProcess = (0, child_process_1.spawn)('git', args, {
11
- cwd: options?.cwd || process.cwd(),
12
- env: options?.env || process.env
13
- });
14
- let stdout = '';
15
- let stderr = '';
16
- gitProcess.stdout.on('data', (data) => {
17
- stdout += data.toString();
18
- });
19
- gitProcess.stderr.on('data', (data) => {
20
- stderr += data.toString();
21
- });
22
- gitProcess.on('close', (code) => {
23
- if (code === 0) {
24
- resolve(stdout);
25
- }
26
- else {
27
- reject(new Error(`Git command failed: ${stderr || stdout}`));
28
- }
29
- });
30
- gitProcess.on('error', (error) => {
31
- reject(error);
32
- });
33
- });
34
- }
35
- execSync(args, options) {
36
- try {
37
- return (0, child_process_1.execSync)(`git ${args.join(' ')}`, {
38
- cwd: options?.cwd || process.cwd(),
39
- env: options?.env || process.env,
40
- encoding: 'utf8'
41
- });
42
- }
43
- catch (error) {
44
- throw new Error(`Git command failed: ${error.message}`);
45
- }
46
- }
47
- async getStatus(repoPath) {
48
- const branch = await this.getCurrentBranch(repoPath);
49
- const statusOutput = await this.exec(['status', '--porcelain'], { cwd: repoPath });
50
- const changes = [];
51
- const untracked = [];
52
- statusOutput.split('\n').forEach(line => {
53
- if (line.startsWith('??')) {
54
- untracked.push(line.substring(3));
55
- }
56
- else if (line.trim()) {
57
- changes.push(line);
58
- }
59
- });
60
- // Get ahead/behind info
61
- let ahead = 0;
62
- let behind = 0;
63
- try {
64
- const trackingBranch = await this.exec(['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], { cwd: repoPath });
65
- if (trackingBranch.trim()) {
66
- const aheadBehind = await this.exec(['rev-list', '--left-right', '--count', `${trackingBranch.trim()}...HEAD`], { cwd: repoPath });
67
- const [behindStr, aheadStr] = aheadBehind.trim().split('\t');
68
- behind = parseInt(behindStr) || 0;
69
- ahead = parseInt(aheadStr) || 0;
70
- }
71
- }
72
- catch {
73
- // No tracking branch
74
- }
75
- return {
76
- entity: path.basename(repoPath),
77
- path: repoPath,
78
- branch,
79
- ahead,
80
- behind,
81
- changes,
82
- untracked,
83
- hasChanges: changes.length > 0 || untracked.length > 0
84
- };
85
- }
86
- async getCurrentBranch(repoPath) {
87
- const branch = await this.exec(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: repoPath });
88
- return branch.trim();
89
- }
90
- async add(repoPath, files) {
91
- const args = ['add', ...files];
92
- await this.exec(args, { cwd: repoPath });
93
- }
94
- async commit(repoPath, message, options) {
95
- const args = ['commit'];
96
- if (options?.all) {
97
- args.push('-a');
98
- }
99
- if (options?.amend) {
100
- args.push('--amend');
101
- }
102
- args.push('-m', message);
103
- await this.exec(args, { cwd: repoPath });
104
- }
105
- async push(repoPath, options) {
106
- const args = ['push'];
107
- if (options?.force) {
108
- args.push('--force');
109
- }
110
- if (options?.tags) {
111
- args.push('--tags');
112
- }
113
- if (options?.setUpstream) {
114
- const branch = await this.getCurrentBranch(repoPath);
115
- args.push('--set-upstream', 'origin', branch);
116
- }
117
- await this.exec(args, { cwd: repoPath });
118
- }
119
- async pull(repoPath, options) {
120
- const args = ['pull'];
121
- if (options?.rebase) {
122
- args.push('--rebase');
123
- }
124
- if (options?.noFf) {
125
- args.push('--no-ff');
126
- }
127
- if (options?.strategy) {
128
- args.push('--strategy', options.strategy);
129
- }
130
- await this.exec(args, { cwd: repoPath });
131
- }
132
- async fetch(repoPath) {
133
- await this.exec(['fetch'], { cwd: repoPath });
134
- }
135
- async clone(url, destination, depth) {
136
- const args = ['clone', url, destination];
137
- if (depth) {
138
- args.push('--depth', depth.toString());
139
- }
140
- await this.exec(args);
141
- }
142
- async isRepository(repoPath) {
143
- try {
144
- await this.exec(['rev-parse', '--git-dir'], { cwd: repoPath });
145
- return true;
146
- }
147
- catch {
148
- return false;
149
- }
150
- }
151
- async hasChanges(repoPath) {
152
- const status = await this.getStatus(repoPath);
153
- return status.hasChanges;
154
- }
155
- async getRemoteUrl(repoPath, remote = 'origin') {
156
- try {
157
- const url = await this.exec(['remote', 'get-url', remote], { cwd: repoPath });
158
- return url.trim();
159
- }
160
- catch {
161
- return null;
162
- }
163
- }
164
- async hasRemote(repoPath, remote = 'origin') {
165
- try {
166
- const remotes = await this.exec(['remote'], { cwd: repoPath });
167
- return remotes.split('\n').includes(remote);
168
- }
169
- catch {
170
- return false;
171
- }
172
- }
173
- async addRemote(repoPath, name, url) {
174
- await this.exec(['remote', 'add', name, url], { cwd: repoPath });
175
- }
176
- async init(repoPath) {
177
- await this.exec(['init'], { cwd: repoPath });
178
- }
179
- }
180
- exports.GitService = GitService;
@@ -1,25 +0,0 @@
1
- import { Ora } from 'ora';
2
- export declare class DisplayUtils {
3
- static createSpinner(text?: string): Ora;
4
- static success(message: string): void;
5
- static error(message: string): void;
6
- static warning(message: string): void;
7
- static info(message: string): void;
8
- static createTable(options?: any): any;
9
- static formatSize(bytes: number): string;
10
- static formatDuration(ms: number): string;
11
- static truncate(str: string, maxLength: number): string;
12
- static pluralize(count: number, singular: string, plural?: string): string;
13
- static formatList(items: string[], maxItems?: number): string;
14
- static progressBar(current: number, total: number, width?: number): string;
15
- static formatGitStatus(status: string): string;
16
- static highlight(text: string, pattern: string | RegExp): string;
17
- static formatEntityType(type: string): string;
18
- static printHeader(title: string, width?: number): void;
19
- static printFooter(message?: string, width?: number): void;
20
- static formatCommand(command: string): string;
21
- static formatPath(path: string): string;
22
- static formatTimestamp(date: Date): string;
23
- static formatRelativeTime(date: Date): string;
24
- }
25
- export default DisplayUtils;
@@ -1,150 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DisplayUtils = void 0;
4
- const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
- const ora_1 = tslib_1.__importDefault(require("ora"));
7
- const cli_table3_1 = tslib_1.__importDefault(require("cli-table3"));
8
- class DisplayUtils {
9
- static createSpinner(text) {
10
- return (0, ora_1.default)(text);
11
- }
12
- static success(message) {
13
- console.log(chalk_1.default.green('✓'), message);
14
- }
15
- static error(message) {
16
- console.log(chalk_1.default.red('✗'), message);
17
- }
18
- static warning(message) {
19
- console.log(chalk_1.default.yellow('⚠'), message);
20
- }
21
- static info(message) {
22
- console.log(chalk_1.default.blue('ℹ'), message);
23
- }
24
- static createTable(options) {
25
- return new cli_table3_1.default({
26
- style: { head: [], border: [] },
27
- ...options,
28
- });
29
- }
30
- static formatSize(bytes) {
31
- const units = ['B', 'KB', 'MB', 'GB', 'TB'];
32
- let size = bytes;
33
- let unitIndex = 0;
34
- while (size >= 1024 && unitIndex < units.length - 1) {
35
- size /= 1024;
36
- unitIndex++;
37
- }
38
- return `${size.toFixed(1)}${units[unitIndex]}`;
39
- }
40
- static formatDuration(ms) {
41
- if (ms < 1000)
42
- return `${ms}ms`;
43
- if (ms < 60000)
44
- return `${(ms / 1000).toFixed(1)}s`;
45
- if (ms < 3600000)
46
- return `${(ms / 60000).toFixed(1)}m`;
47
- return `${(ms / 3600000).toFixed(1)}h`;
48
- }
49
- static truncate(str, maxLength) {
50
- if (str.length <= maxLength)
51
- return str;
52
- return str.substring(0, maxLength - 3) + '...';
53
- }
54
- static pluralize(count, singular, plural) {
55
- return count === 1 ? singular : (plural || `${singular}s`);
56
- }
57
- static formatList(items, maxItems = 5) {
58
- if (items.length === 0)
59
- return 'none';
60
- if (items.length <= maxItems)
61
- return items.join(', ');
62
- const shown = items.slice(0, maxItems).join(', ');
63
- const remaining = items.length - maxItems;
64
- return `${shown}, and ${remaining} more`;
65
- }
66
- static progressBar(current, total, width = 20) {
67
- const percentage = Math.min(100, Math.floor((current / total) * 100));
68
- const filled = Math.floor((percentage / 100) * width);
69
- const empty = width - filled;
70
- const bar = '█'.repeat(filled) + '░'.repeat(empty);
71
- return `${bar} ${percentage}%`;
72
- }
73
- static formatGitStatus(status) {
74
- const statusMap = {
75
- 'M': chalk_1.default.yellow('M'), // Modified
76
- 'A': chalk_1.default.green('A'), // Added
77
- 'D': chalk_1.default.red('D'), // Deleted
78
- 'R': chalk_1.default.blue('R'), // Renamed
79
- 'C': chalk_1.default.cyan('C'), // Copied
80
- 'U': chalk_1.default.magenta('U'), // Unmerged
81
- '?': chalk_1.default.gray('?'), // Untracked
82
- '!': chalk_1.default.gray('!'), // Ignored
83
- };
84
- return statusMap[status] || status;
85
- }
86
- static highlight(text, pattern) {
87
- const regex = typeof pattern === 'string'
88
- ? new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi')
89
- : pattern;
90
- return text.replace(regex, match => chalk_1.default.yellow(match));
91
- }
92
- static formatEntityType(type) {
93
- const typeColors = {
94
- 'delivery': chalk_1.default.blue,
95
- 'module': chalk_1.default.green,
96
- 'service': chalk_1.default.yellow,
97
- 'tool': chalk_1.default.magenta,
98
- };
99
- const color = typeColors[type] || chalk_1.default.white;
100
- return color(type);
101
- }
102
- static printHeader(title, width = 50) {
103
- console.log('');
104
- console.log(chalk_1.default.bold(title));
105
- console.log(chalk_1.default.dim('─'.repeat(width)));
106
- }
107
- static printFooter(message, width = 50) {
108
- console.log(chalk_1.default.dim('─'.repeat(width)));
109
- if (message) {
110
- console.log(chalk_1.default.dim(message));
111
- }
112
- console.log('');
113
- }
114
- static formatCommand(command) {
115
- return chalk_1.default.cyan(`\`${command}\``);
116
- }
117
- static formatPath(path) {
118
- return chalk_1.default.dim(path);
119
- }
120
- static formatTimestamp(date) {
121
- return date.toLocaleString();
122
- }
123
- static formatRelativeTime(date) {
124
- const now = Date.now();
125
- const then = date.getTime();
126
- const diff = now - then;
127
- const seconds = Math.floor(diff / 1000);
128
- const minutes = Math.floor(seconds / 60);
129
- const hours = Math.floor(minutes / 60);
130
- const days = Math.floor(hours / 24);
131
- const weeks = Math.floor(days / 7);
132
- const months = Math.floor(days / 30);
133
- const years = Math.floor(days / 365);
134
- if (years > 0)
135
- return `${years} ${this.pluralize(years, 'year')} ago`;
136
- if (months > 0)
137
- return `${months} ${this.pluralize(months, 'month')} ago`;
138
- if (weeks > 0)
139
- return `${weeks} ${this.pluralize(weeks, 'week')} ago`;
140
- if (days > 0)
141
- return `${days} ${this.pluralize(days, 'day')} ago`;
142
- if (hours > 0)
143
- return `${hours} ${this.pluralize(hours, 'hour')} ago`;
144
- if (minutes > 0)
145
- return `${minutes} ${this.pluralize(minutes, 'minute')} ago`;
146
- return 'just now';
147
- }
148
- }
149
- exports.DisplayUtils = DisplayUtils;
150
- exports.default = DisplayUtils;
@@ -1,32 +0,0 @@
1
- export declare class FileSystemUtils {
2
- static ensureDir(dirPath: string): Promise<void>;
3
- static removeDir(dirPath: string): Promise<void>;
4
- static copyDir(src: string, dest: string): Promise<void>;
5
- static copyFile(src: string, dest: string): Promise<void>;
6
- static findFiles(dirPath: string, pattern: RegExp | string, options?: {
7
- recursive?: boolean;
8
- maxDepth?: number;
9
- excludeDirs?: string[];
10
- }): Promise<string[]>;
11
- static readJSON(filePath: string): Promise<any>;
12
- static writeJSON(filePath: string, data: any, pretty?: boolean): Promise<void>;
13
- static exists(filePath: string): Promise<boolean>;
14
- static isDirectory(filePath: string): Promise<boolean>;
15
- static isFile(filePath: string): Promise<boolean>;
16
- static getSize(filePath: string): Promise<number>;
17
- static touch(filePath: string): Promise<void>;
18
- static makeExecutable(filePath: string): Promise<void>;
19
- static resolvePath(...paths: string[]): string;
20
- static relativePath(from: string, to: string): string;
21
- static getExtension(filePath: string): string;
22
- static getBasename(filePath: string, ext?: string): string;
23
- static getDirname(filePath: string): string;
24
- static joinPath(...paths: string[]): string;
25
- static createSymlink(target: string, linkPath: string): Promise<void>;
26
- static isSymlink(filePath: string): Promise<boolean>;
27
- static readSymlink(filePath: string): Promise<string>;
28
- static globToRegex(glob: string): RegExp;
29
- static getModifiedTime(filePath: string): Promise<Date>;
30
- static getCreatedTime(filePath: string): Promise<Date>;
31
- }
32
- export default FileSystemUtils;
@@ -1,220 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileSystemUtils = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs"));
6
- const path = tslib_1.__importStar(require("path"));
7
- const util_1 = require("util");
8
- const readdir = (0, util_1.promisify)(fs.readdir);
9
- const stat = (0, util_1.promisify)(fs.stat);
10
- const readFile = (0, util_1.promisify)(fs.readFile);
11
- const writeFile = (0, util_1.promisify)(fs.writeFile);
12
- const mkdir = (0, util_1.promisify)(fs.mkdir);
13
- const rmdir = (0, util_1.promisify)(fs.rmdir);
14
- const unlink = (0, util_1.promisify)(fs.unlink);
15
- class FileSystemUtils {
16
- static async ensureDir(dirPath) {
17
- try {
18
- await mkdir(dirPath, { recursive: true });
19
- }
20
- catch (error) {
21
- if (error.code !== 'EEXIST') {
22
- throw error;
23
- }
24
- }
25
- }
26
- static async removeDir(dirPath) {
27
- if (!fs.existsSync(dirPath))
28
- return;
29
- const files = await readdir(dirPath);
30
- for (const file of files) {
31
- const filePath = path.join(dirPath, file);
32
- const fileStat = await stat(filePath);
33
- if (fileStat.isDirectory()) {
34
- await this.removeDir(filePath);
35
- }
36
- else {
37
- await unlink(filePath);
38
- }
39
- }
40
- await rmdir(dirPath);
41
- }
42
- static async copyDir(src, dest) {
43
- await this.ensureDir(dest);
44
- const files = await readdir(src);
45
- for (const file of files) {
46
- const srcPath = path.join(src, file);
47
- const destPath = path.join(dest, file);
48
- const fileStat = await stat(srcPath);
49
- if (fileStat.isDirectory()) {
50
- await this.copyDir(srcPath, destPath);
51
- }
52
- else {
53
- await this.copyFile(srcPath, destPath);
54
- }
55
- }
56
- }
57
- static async copyFile(src, dest) {
58
- const destDir = path.dirname(dest);
59
- await this.ensureDir(destDir);
60
- return new Promise((resolve, reject) => {
61
- const readStream = fs.createReadStream(src);
62
- const writeStream = fs.createWriteStream(dest);
63
- readStream.on('error', reject);
64
- writeStream.on('error', reject);
65
- writeStream.on('finish', resolve);
66
- readStream.pipe(writeStream);
67
- });
68
- }
69
- static async findFiles(dirPath, pattern, options = {}) {
70
- const { recursive = true, maxDepth = 10, excludeDirs = ['node_modules', '.git', 'dist', 'build'], } = options;
71
- const results = [];
72
- const regex = typeof pattern === 'string'
73
- ? new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
74
- : pattern;
75
- const search = async (currentPath, depth) => {
76
- if (depth > maxDepth)
77
- return;
78
- try {
79
- const files = await readdir(currentPath);
80
- for (const file of files) {
81
- const filePath = path.join(currentPath, file);
82
- const fileStat = await stat(filePath);
83
- if (fileStat.isDirectory()) {
84
- if (!excludeDirs.includes(file) && recursive) {
85
- await search(filePath, depth + 1);
86
- }
87
- }
88
- else if (regex.test(file)) {
89
- results.push(filePath);
90
- }
91
- }
92
- }
93
- catch (error) {
94
- // Ignore permission errors
95
- }
96
- };
97
- await search(dirPath, 0);
98
- return results;
99
- }
100
- static async readJSON(filePath) {
101
- const content = await readFile(filePath, 'utf-8');
102
- return JSON.parse(content);
103
- }
104
- static async writeJSON(filePath, data, pretty = true) {
105
- const content = pretty
106
- ? JSON.stringify(data, null, 2)
107
- : JSON.stringify(data);
108
- await this.ensureDir(path.dirname(filePath));
109
- await writeFile(filePath, content, 'utf-8');
110
- }
111
- static async exists(filePath) {
112
- try {
113
- await stat(filePath);
114
- return true;
115
- }
116
- catch {
117
- return false;
118
- }
119
- }
120
- static async isDirectory(filePath) {
121
- try {
122
- const fileStat = await stat(filePath);
123
- return fileStat.isDirectory();
124
- }
125
- catch {
126
- return false;
127
- }
128
- }
129
- static async isFile(filePath) {
130
- try {
131
- const fileStat = await stat(filePath);
132
- return fileStat.isFile();
133
- }
134
- catch {
135
- return false;
136
- }
137
- }
138
- static async getSize(filePath) {
139
- const fileStat = await stat(filePath);
140
- if (fileStat.isFile()) {
141
- return fileStat.size;
142
- }
143
- if (fileStat.isDirectory()) {
144
- let totalSize = 0;
145
- const files = await readdir(filePath);
146
- for (const file of files) {
147
- const childPath = path.join(filePath, file);
148
- totalSize += await this.getSize(childPath);
149
- }
150
- return totalSize;
151
- }
152
- return 0;
153
- }
154
- static async touch(filePath) {
155
- const now = new Date();
156
- try {
157
- await fs.promises.utimes(filePath, now, now);
158
- }
159
- catch {
160
- const handle = await fs.promises.open(filePath, 'w');
161
- await handle.close();
162
- }
163
- }
164
- static async makeExecutable(filePath) {
165
- const currentMode = (await stat(filePath)).mode;
166
- const newMode = currentMode | 0o111; // Add execute permission
167
- await fs.promises.chmod(filePath, newMode);
168
- }
169
- static resolvePath(...paths) {
170
- return path.resolve(...paths);
171
- }
172
- static relativePath(from, to) {
173
- return path.relative(from, to);
174
- }
175
- static getExtension(filePath) {
176
- return path.extname(filePath);
177
- }
178
- static getBasename(filePath, ext) {
179
- return path.basename(filePath, ext);
180
- }
181
- static getDirname(filePath) {
182
- return path.dirname(filePath);
183
- }
184
- static joinPath(...paths) {
185
- return path.join(...paths);
186
- }
187
- static async createSymlink(target, linkPath) {
188
- await this.ensureDir(path.dirname(linkPath));
189
- await fs.promises.symlink(target, linkPath);
190
- }
191
- static async isSymlink(filePath) {
192
- try {
193
- const fileStat = await fs.promises.lstat(filePath);
194
- return fileStat.isSymbolicLink();
195
- }
196
- catch {
197
- return false;
198
- }
199
- }
200
- static async readSymlink(filePath) {
201
- return await fs.promises.readlink(filePath);
202
- }
203
- static globToRegex(glob) {
204
- const escaped = glob
205
- .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
206
- .replace(/\\\*/g, '.*')
207
- .replace(/\\\?/g, '.');
208
- return new RegExp(`^${escaped}$`);
209
- }
210
- static async getModifiedTime(filePath) {
211
- const fileStat = await stat(filePath);
212
- return fileStat.mtime;
213
- }
214
- static async getCreatedTime(filePath) {
215
- const fileStat = await stat(filePath);
216
- return fileStat.birthtime;
217
- }
218
- }
219
- exports.FileSystemUtils = FileSystemUtils;
220
- exports.default = FileSystemUtils;
@@ -1,13 +0,0 @@
1
- export * from './display';
2
- export * from './validation';
3
- export * from './filesystem';
4
- import DisplayUtils from './display';
5
- import ValidationUtils from './validation';
6
- import FileSystemUtils from './filesystem';
7
- export { DisplayUtils, ValidationUtils, FileSystemUtils, };
8
- declare const _default: {
9
- display: typeof DisplayUtils;
10
- validation: typeof ValidationUtils;
11
- filesystem: typeof FileSystemUtils;
12
- };
13
- export default _default;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileSystemUtils = exports.ValidationUtils = exports.DisplayUtils = void 0;
4
- const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./display"), exports);
6
- tslib_1.__exportStar(require("./validation"), exports);
7
- tslib_1.__exportStar(require("./filesystem"), exports);
8
- const display_1 = tslib_1.__importDefault(require("./display"));
9
- exports.DisplayUtils = display_1.default;
10
- const validation_1 = tslib_1.__importDefault(require("./validation"));
11
- exports.ValidationUtils = validation_1.default;
12
- const filesystem_1 = tslib_1.__importDefault(require("./filesystem"));
13
- exports.FileSystemUtils = filesystem_1.default;
14
- exports.default = {
15
- display: display_1.default,
16
- validation: validation_1.default,
17
- filesystem: filesystem_1.default,
18
- };
@@ -1,22 +0,0 @@
1
- export declare class ValidationUtils {
2
- static isValidEntityName(name: string): boolean;
3
- static isValidEntityType(type: string): boolean;
4
- static isValidPath(inputPath: string): boolean;
5
- static isGitRepository(dirPath: string): boolean;
6
- static isValidGitUrl(url: string): boolean;
7
- static isValidBranch(branch: string): boolean;
8
- static isNodeProject(dirPath: string): boolean;
9
- static isPythonProject(dirPath: string): boolean;
10
- static isGoProject(dirPath: string): boolean;
11
- static isRustProject(dirPath: string): boolean;
12
- static isJavaProject(dirPath: string): boolean;
13
- static detectProjectType(dirPath: string): string | null;
14
- static validateEntityData(data: any): string[];
15
- static validateFocusEntities(entities: string[], availableEntities: string[]): string[];
16
- static sanitizePath(inputPath: string): string;
17
- static sanitizeGitUrl(url: string): string;
18
- static isEmptyDirectory(dirPath: string): boolean;
19
- static hasUncommittedChanges(dirPath: string): boolean;
20
- static validateConfig(config: any): string[];
21
- }
22
- export default ValidationUtils;