@emaenriquez/projectmanager-cli 0.1.0

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 (174) hide show
  1. package/README.md +98 -0
  2. package/dist/application/ConfigManager.d.ts +73 -0
  3. package/dist/application/ConfigManager.d.ts.map +1 -0
  4. package/dist/application/ConfigManager.js +253 -0
  5. package/dist/application/ConfigManager.js.map +1 -0
  6. package/dist/application/errors/ErrorHandler.d.ts +27 -0
  7. package/dist/application/errors/ErrorHandler.d.ts.map +1 -0
  8. package/dist/application/errors/ErrorHandler.js +88 -0
  9. package/dist/application/errors/ErrorHandler.js.map +1 -0
  10. package/dist/application/state/StateManager.d.ts +26 -0
  11. package/dist/application/state/StateManager.d.ts.map +1 -0
  12. package/dist/application/state/StateManager.js +114 -0
  13. package/dist/application/state/StateManager.js.map +1 -0
  14. package/dist/application/use_cases/AddProjectUseCase.d.ts +9 -0
  15. package/dist/application/use_cases/AddProjectUseCase.d.ts.map +1 -0
  16. package/dist/application/use_cases/AddProjectUseCase.js +85 -0
  17. package/dist/application/use_cases/AddProjectUseCase.js.map +1 -0
  18. package/dist/application/use_cases/ListProjectsUseCase.d.ts +7 -0
  19. package/dist/application/use_cases/ListProjectsUseCase.d.ts.map +1 -0
  20. package/dist/application/use_cases/ListProjectsUseCase.js +14 -0
  21. package/dist/application/use_cases/ListProjectsUseCase.js.map +1 -0
  22. package/dist/application/use_cases/OpenProjectUseCase.d.ts +10 -0
  23. package/dist/application/use_cases/OpenProjectUseCase.d.ts.map +1 -0
  24. package/dist/application/use_cases/OpenProjectUseCase.js +168 -0
  25. package/dist/application/use_cases/OpenProjectUseCase.js.map +1 -0
  26. package/dist/application/use_cases/RemoveProjectUseCase.d.ts +7 -0
  27. package/dist/application/use_cases/RemoveProjectUseCase.d.ts.map +1 -0
  28. package/dist/application/use_cases/RemoveProjectUseCase.js +24 -0
  29. package/dist/application/use_cases/RemoveProjectUseCase.js.map +1 -0
  30. package/dist/application/use_cases/ScanProjectsUseCase.d.ts +13 -0
  31. package/dist/application/use_cases/ScanProjectsUseCase.d.ts.map +1 -0
  32. package/dist/application/use_cases/ScanProjectsUseCase.js +57 -0
  33. package/dist/application/use_cases/ScanProjectsUseCase.js.map +1 -0
  34. package/dist/application/use_cases/SyncProjectsUseCase.d.ts +12 -0
  35. package/dist/application/use_cases/SyncProjectsUseCase.d.ts.map +1 -0
  36. package/dist/application/use_cases/SyncProjectsUseCase.js +74 -0
  37. package/dist/application/use_cases/SyncProjectsUseCase.js.map +1 -0
  38. package/dist/application/use_cases/SystemDiagnostics.d.ts +16 -0
  39. package/dist/application/use_cases/SystemDiagnostics.d.ts.map +1 -0
  40. package/dist/application/use_cases/SystemDiagnostics.js +35 -0
  41. package/dist/application/use_cases/SystemDiagnostics.js.map +1 -0
  42. package/dist/application/use_cases/TagProjectUseCase.d.ts +9 -0
  43. package/dist/application/use_cases/TagProjectUseCase.d.ts.map +1 -0
  44. package/dist/application/use_cases/TagProjectUseCase.js +41 -0
  45. package/dist/application/use_cases/TagProjectUseCase.js.map +1 -0
  46. package/dist/domain/patterns/ProjectPatterns.d.ts +47 -0
  47. package/dist/domain/patterns/ProjectPatterns.d.ts.map +1 -0
  48. package/dist/domain/patterns/ProjectPatterns.js +200 -0
  49. package/dist/domain/patterns/ProjectPatterns.js.map +1 -0
  50. package/dist/domain/services/GitService.d.ts +23 -0
  51. package/dist/domain/services/GitService.d.ts.map +1 -0
  52. package/dist/domain/services/GitService.js +155 -0
  53. package/dist/domain/services/GitService.js.map +1 -0
  54. package/dist/domain/services/IgnoreFileParser.d.ts +55 -0
  55. package/dist/domain/services/IgnoreFileParser.d.ts.map +1 -0
  56. package/dist/domain/services/IgnoreFileParser.js +200 -0
  57. package/dist/domain/services/IgnoreFileParser.js.map +1 -0
  58. package/dist/domain/services/ProjectScanner.d.ts +65 -0
  59. package/dist/domain/services/ProjectScanner.d.ts.map +1 -0
  60. package/dist/domain/services/ProjectScanner.js +207 -0
  61. package/dist/domain/services/ProjectScanner.js.map +1 -0
  62. package/dist/domain/services/TechnologyDetector.d.ts +78 -0
  63. package/dist/domain/services/TechnologyDetector.d.ts.map +1 -0
  64. package/dist/domain/services/TechnologyDetector.js +633 -0
  65. package/dist/domain/services/TechnologyDetector.js.map +1 -0
  66. package/dist/domain/services/ToolDetector.d.ts +74 -0
  67. package/dist/domain/services/ToolDetector.d.ts.map +1 -0
  68. package/dist/domain/services/ToolDetector.js +344 -0
  69. package/dist/domain/services/ToolDetector.js.map +1 -0
  70. package/dist/domain/services/index.d.ts +5 -0
  71. package/dist/domain/services/index.d.ts.map +1 -0
  72. package/dist/domain/services/index.js +12 -0
  73. package/dist/domain/services/index.js.map +1 -0
  74. package/dist/domain/types/Config.d.ts +37 -0
  75. package/dist/domain/types/Config.d.ts.map +1 -0
  76. package/dist/domain/types/Config.js +6 -0
  77. package/dist/domain/types/Config.js.map +1 -0
  78. package/dist/index.d.ts +6 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +17 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/infrastructure/database/DatabaseConnection.d.ts +88 -0
  83. package/dist/infrastructure/database/DatabaseConnection.d.ts.map +1 -0
  84. package/dist/infrastructure/database/DatabaseConnection.js +318 -0
  85. package/dist/infrastructure/database/DatabaseConnection.js.map +1 -0
  86. package/dist/infrastructure/database/DatabaseValidator.d.ts +154 -0
  87. package/dist/infrastructure/database/DatabaseValidator.d.ts.map +1 -0
  88. package/dist/infrastructure/database/DatabaseValidator.js +583 -0
  89. package/dist/infrastructure/database/DatabaseValidator.js.map +1 -0
  90. package/dist/infrastructure/database/index.d.ts +8 -0
  91. package/dist/infrastructure/database/index.d.ts.map +1 -0
  92. package/dist/infrastructure/database/index.js +14 -0
  93. package/dist/infrastructure/database/index.js.map +1 -0
  94. package/dist/infrastructure/database/migrations/001_initial.d.ts +24 -0
  95. package/dist/infrastructure/database/migrations/001_initial.d.ts.map +1 -0
  96. package/dist/infrastructure/database/migrations/001_initial.js +109 -0
  97. package/dist/infrastructure/database/migrations/001_initial.js.map +1 -0
  98. package/dist/infrastructure/database/migrations/Migration.d.ts +27 -0
  99. package/dist/infrastructure/database/migrations/Migration.d.ts.map +1 -0
  100. package/dist/infrastructure/database/migrations/Migration.js +3 -0
  101. package/dist/infrastructure/database/migrations/Migration.js.map +1 -0
  102. package/dist/infrastructure/database/migrations/MigrationRunner.d.ts +52 -0
  103. package/dist/infrastructure/database/migrations/MigrationRunner.d.ts.map +1 -0
  104. package/dist/infrastructure/database/migrations/MigrationRunner.js +167 -0
  105. package/dist/infrastructure/database/migrations/MigrationRunner.js.map +1 -0
  106. package/dist/infrastructure/database/migrations/index.d.ts +10 -0
  107. package/dist/infrastructure/database/migrations/index.d.ts.map +1 -0
  108. package/dist/infrastructure/database/migrations/index.js +22 -0
  109. package/dist/infrastructure/database/migrations/index.js.map +1 -0
  110. package/dist/infrastructure/filesystem/DirectoryManager.d.ts +50 -0
  111. package/dist/infrastructure/filesystem/DirectoryManager.d.ts.map +1 -0
  112. package/dist/infrastructure/filesystem/DirectoryManager.js +143 -0
  113. package/dist/infrastructure/filesystem/DirectoryManager.js.map +1 -0
  114. package/dist/infrastructure/filesystem/index.d.ts +2 -0
  115. package/dist/infrastructure/filesystem/index.d.ts.map +1 -0
  116. package/dist/infrastructure/filesystem/index.js +6 -0
  117. package/dist/infrastructure/filesystem/index.js.map +1 -0
  118. package/dist/infrastructure/logging/LogRotator.d.ts +43 -0
  119. package/dist/infrastructure/logging/LogRotator.d.ts.map +1 -0
  120. package/dist/infrastructure/logging/LogRotator.js +172 -0
  121. package/dist/infrastructure/logging/LogRotator.js.map +1 -0
  122. package/dist/infrastructure/logging/Logger.d.ts +59 -0
  123. package/dist/infrastructure/logging/Logger.d.ts.map +1 -0
  124. package/dist/infrastructure/logging/Logger.js +182 -0
  125. package/dist/infrastructure/logging/Logger.js.map +1 -0
  126. package/dist/infrastructure/logging/index.d.ts +3 -0
  127. package/dist/infrastructure/logging/index.d.ts.map +1 -0
  128. package/dist/infrastructure/logging/index.js +8 -0
  129. package/dist/infrastructure/logging/index.js.map +1 -0
  130. package/dist/infrastructure/repositories/ProjectRepository.d.ts +20 -0
  131. package/dist/infrastructure/repositories/ProjectRepository.d.ts.map +1 -0
  132. package/dist/infrastructure/repositories/ProjectRepository.js +61 -0
  133. package/dist/infrastructure/repositories/ProjectRepository.js.map +1 -0
  134. package/dist/infrastructure/repositories/QueryBuilder.d.ts +24 -0
  135. package/dist/infrastructure/repositories/QueryBuilder.d.ts.map +1 -0
  136. package/dist/infrastructure/repositories/QueryBuilder.js +92 -0
  137. package/dist/infrastructure/repositories/QueryBuilder.js.map +1 -0
  138. package/dist/infrastructure/repositories/TagRepository.d.ts +18 -0
  139. package/dist/infrastructure/repositories/TagRepository.d.ts.map +1 -0
  140. package/dist/infrastructure/repositories/TagRepository.js +66 -0
  141. package/dist/infrastructure/repositories/TagRepository.js.map +1 -0
  142. package/dist/infrastructure/repositories/TechnologyRepository.d.ts +16 -0
  143. package/dist/infrastructure/repositories/TechnologyRepository.d.ts.map +1 -0
  144. package/dist/infrastructure/repositories/TechnologyRepository.js +46 -0
  145. package/dist/infrastructure/repositories/TechnologyRepository.js.map +1 -0
  146. package/dist/infrastructure/repositories/TransactionManager.d.ts +11 -0
  147. package/dist/infrastructure/repositories/TransactionManager.d.ts.map +1 -0
  148. package/dist/infrastructure/repositories/TransactionManager.js +21 -0
  149. package/dist/infrastructure/repositories/TransactionManager.js.map +1 -0
  150. package/dist/infrastructure/ui/ScreenManager.d.ts +11 -0
  151. package/dist/infrastructure/ui/ScreenManager.d.ts.map +1 -0
  152. package/dist/infrastructure/ui/ScreenManager.js +69 -0
  153. package/dist/infrastructure/ui/ScreenManager.js.map +1 -0
  154. package/dist/ui/cli/CLI.d.ts +9 -0
  155. package/dist/ui/cli/CLI.d.ts.map +1 -0
  156. package/dist/ui/cli/CLI.js +211 -0
  157. package/dist/ui/cli/CLI.js.map +1 -0
  158. package/dist/ui/components/DetailsPanel.d.ts +11 -0
  159. package/dist/ui/components/DetailsPanel.d.ts.map +1 -0
  160. package/dist/ui/components/DetailsPanel.js +181 -0
  161. package/dist/ui/components/DetailsPanel.js.map +1 -0
  162. package/dist/ui/components/ProjectListView.d.ts +15 -0
  163. package/dist/ui/components/ProjectListView.d.ts.map +1 -0
  164. package/dist/ui/components/ProjectListView.js +122 -0
  165. package/dist/ui/components/ProjectListView.js.map +1 -0
  166. package/dist/ui/tui/TUIApplication.d.ts +17 -0
  167. package/dist/ui/tui/TUIApplication.d.ts.map +1 -0
  168. package/dist/ui/tui/TUIApplication.js +532 -0
  169. package/dist/ui/tui/TUIApplication.js.map +1 -0
  170. package/dist/ui/tui/Theme.d.ts +25 -0
  171. package/dist/ui/tui/Theme.d.ts.map +1 -0
  172. package/dist/ui/tui/Theme.js +62 -0
  173. package/dist/ui/tui/Theme.js.map +1 -0
  174. package/package.json +56 -0
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitialMigration = void 0;
4
+ const DatabaseConnection_1 = require("../DatabaseConnection");
5
+ /**
6
+ * Initial migration: Creates all base tables for Project Hub
7
+ * - projects: Stores project information
8
+ * - tags: Stores available tags
9
+ * - project_tags: Join table for many-to-many relationship between projects and tags
10
+ * - technologies: Stores detected technologies for projects
11
+ */
12
+ class InitialMigration {
13
+ constructor() {
14
+ this.id = '001';
15
+ this.name = 'initial';
16
+ this.db = DatabaseConnection_1.DatabaseConnection.getInstance();
17
+ }
18
+ /**
19
+ * Create all necessary tables
20
+ */
21
+ up() {
22
+ try {
23
+ // Create projects table
24
+ this.db.execute(`
25
+ CREATE TABLE IF NOT EXISTS projects (
26
+ id TEXT PRIMARY KEY,
27
+ name TEXT NOT NULL,
28
+ path TEXT NOT NULL UNIQUE,
29
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
30
+ last_opened DATETIME,
31
+ is_favorite BOOLEAN DEFAULT 0,
32
+ default_tool TEXT,
33
+ notes TEXT
34
+ )
35
+ `);
36
+ // Create tags table
37
+ this.db.execute(`
38
+ CREATE TABLE IF NOT EXISTS tags (
39
+ id TEXT PRIMARY KEY,
40
+ name TEXT NOT NULL UNIQUE,
41
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP
42
+ )
43
+ `);
44
+ // Create project_tags join table for many-to-many relationship
45
+ this.db.execute(`
46
+ CREATE TABLE IF NOT EXISTS project_tags (
47
+ project_id TEXT NOT NULL,
48
+ tag_id TEXT NOT NULL,
49
+ added_at DATETIME DEFAULT CURRENT_TIMESTAMP,
50
+ PRIMARY KEY (project_id, tag_id),
51
+ FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
52
+ FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
53
+ )
54
+ `);
55
+ // Create technologies table
56
+ this.db.execute(`
57
+ CREATE TABLE IF NOT EXISTS technologies (
58
+ id TEXT PRIMARY KEY,
59
+ project_id TEXT NOT NULL,
60
+ name TEXT NOT NULL,
61
+ version TEXT,
62
+ category TEXT,
63
+ detected_at DATETIME DEFAULT CURRENT_TIMESTAMP,
64
+ FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE
65
+ )
66
+ `);
67
+ // Create indexes on frequently queried fields
68
+ this.db.execute(`
69
+ CREATE INDEX IF NOT EXISTS idx_projects_name ON projects(name)
70
+ `);
71
+ this.db.execute(`
72
+ CREATE INDEX IF NOT EXISTS idx_projects_path ON projects(path)
73
+ `);
74
+ this.db.execute(`
75
+ CREATE INDEX IF NOT EXISTS idx_project_tags_project_id ON project_tags(project_id)
76
+ `);
77
+ this.db.execute(`
78
+ CREATE INDEX IF NOT EXISTS idx_project_tags_tag_id ON project_tags(tag_id)
79
+ `);
80
+ this.db.execute(`
81
+ CREATE INDEX IF NOT EXISTS idx_technologies_project_id ON technologies(project_id)
82
+ `);
83
+ this.db.execute(`
84
+ CREATE INDEX IF NOT EXISTS idx_technologies_name ON technologies(name)
85
+ `);
86
+ }
87
+ catch (error) {
88
+ throw new Error(`Failed to run initial migration: ${error instanceof Error ? error.message : String(error)}`);
89
+ }
90
+ }
91
+ /**
92
+ * Drop all tables created by this migration
93
+ * WARNING: This will delete all data
94
+ */
95
+ down() {
96
+ try {
97
+ // Drop tables in reverse order of creation (to respect foreign keys)
98
+ this.db.execute('DROP TABLE IF EXISTS technologies');
99
+ this.db.execute('DROP TABLE IF EXISTS project_tags');
100
+ this.db.execute('DROP TABLE IF EXISTS tags');
101
+ this.db.execute('DROP TABLE IF EXISTS projects');
102
+ }
103
+ catch (error) {
104
+ throw new Error(`Failed to rollback initial migration: ${error instanceof Error ? error.message : String(error)}`);
105
+ }
106
+ }
107
+ }
108
+ exports.InitialMigration = InitialMigration;
109
+ //# sourceMappingURL=001_initial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"001_initial.js","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/001_initial.ts"],"names":[],"mappings":";;;AAAA,8DAA2D;AAG3D;;;;;;GAMG;AACH,MAAa,gBAAgB;IAK3B;QAJA,OAAE,GAAG,KAAK,CAAC;QACX,SAAI,GAAG,SAAS,CAAC;QAIf,IAAI,CAAC,EAAE,GAAG,uCAAkB,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,EAAE;QACA,IAAI,CAAC;YACH,wBAAwB;YACxB,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;;OAWf,CAAC,CAAC;YAEH,oBAAoB;YACpB,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;;;OAMf,CAAC,CAAC;YAEH,+DAA+D;YAC/D,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;;;;;;OASf,CAAC,CAAC;YAEH,4BAA4B;YAC5B,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;OAUf,CAAC,CAAC;YAEH,8CAA8C;YAC9C,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;OAEf,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;OAEf,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;OAEf,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;OAEf,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;OAEf,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;OAEf,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,IAAI;QACF,IAAI,CAAC;YACH,qEAAqE;YACrE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;YACrD,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC;YACrD,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;YAC7C,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrH,CAAC;IACH,CAAC;CACF;AA1GD,4CA0GC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Migration interface defines the structure for database schema migrations
3
+ * Each migration must implement this interface to be executable by MigrationRunner
4
+ */
5
+ export interface Migration {
6
+ /**
7
+ * Unique identifier for the migration
8
+ * Format: timestamp or sequential number (e.g., "001", "20240101120000")
9
+ */
10
+ id: string;
11
+ /**
12
+ * Human-readable name describing the migration
13
+ * Example: "create_projects_table", "add_tags_support"
14
+ */
15
+ name: string;
16
+ /**
17
+ * Execute the migration (apply changes forward)
18
+ * Should contain SQL statements that modify the schema
19
+ */
20
+ up(): void;
21
+ /**
22
+ * Rollback the migration (revert changes)
23
+ * Should contain SQL statements that revert the changes from up()
24
+ */
25
+ down(): void;
26
+ }
27
+ //# sourceMappingURL=Migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/Migration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,EAAE,IAAI,IAAI,CAAC;IAEX;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAC;CACd"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration.js","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/Migration.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import { Migration } from './Migration';
2
+ /**
3
+ * MigrationRunner manages the execution of database migrations
4
+ * Tracks migration history in migrations_history table
5
+ * Supports running pending migrations and rolling back migrations
6
+ */
7
+ export declare class MigrationRunner {
8
+ private db;
9
+ constructor();
10
+ /**
11
+ * Initialize the migrations_history table if it doesn't exist
12
+ * This table tracks which migrations have been applied
13
+ */
14
+ initializeMigrationHistory(): void;
15
+ /**
16
+ * Get all migrations that have been applied
17
+ */
18
+ private getAppliedMigrations;
19
+ /**
20
+ * Run all pending migrations
21
+ * Executes migrations that haven't been applied yet
22
+ */
23
+ runPending(migrations: Migration[]): {
24
+ applied: Migration[];
25
+ skipped: Migration[];
26
+ };
27
+ /**
28
+ * Rollback the most recent migration
29
+ */
30
+ rollback(): Migration | null;
31
+ /**
32
+ * Rollback a specific number of migrations
33
+ */
34
+ rollbackN(n: number): Migration[];
35
+ /**
36
+ * Get migration status - which migrations are applied and which are pending
37
+ */
38
+ getMigrationStatus(migrations: Migration[]): {
39
+ applied: Migration[];
40
+ pending: Migration[];
41
+ };
42
+ /**
43
+ * Get all migration history records
44
+ */
45
+ getHistory(): Array<{
46
+ id: string;
47
+ name: string;
48
+ applied_at: string;
49
+ rolled_back_at: string | null;
50
+ }>;
51
+ }
52
+ //# sourceMappingURL=MigrationRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationRunner.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/MigrationRunner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,EAAE,CAAqB;;IAM/B;;;OAGG;IACI,0BAA0B,IAAI,IAAI;IAgBzC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;;OAGG;IACI,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG;QAAE,OAAO,EAAE,SAAS,EAAE,CAAC;QAAC,OAAO,EAAE,SAAS,EAAE,CAAA;KAAE;IAmC1F;;OAEG;IACI,QAAQ,IAAI,SAAS,GAAG,IAAI;IA4CnC;;OAEG;IACI,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE;IAaxC;;OAEG;IACI,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG;QAClD,OAAO,EAAE,SAAS,EAAE,CAAC;QACrB,OAAO,EAAE,SAAS,EAAE,CAAC;KACtB;IAqBD;;OAEG;IACI,UAAU,IAAI,KAAK,CAAC;QACzB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC;CASH"}
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MigrationRunner = void 0;
4
+ const DatabaseConnection_1 = require("../DatabaseConnection");
5
+ /**
6
+ * MigrationRunner manages the execution of database migrations
7
+ * Tracks migration history in migrations_history table
8
+ * Supports running pending migrations and rolling back migrations
9
+ */
10
+ class MigrationRunner {
11
+ constructor() {
12
+ this.db = DatabaseConnection_1.DatabaseConnection.getInstance();
13
+ }
14
+ /**
15
+ * Initialize the migrations_history table if it doesn't exist
16
+ * This table tracks which migrations have been applied
17
+ */
18
+ initializeMigrationHistory() {
19
+ try {
20
+ // Create migrations_history table if not exists
21
+ this.db.execute(`
22
+ CREATE TABLE IF NOT EXISTS migrations_history (
23
+ id TEXT PRIMARY KEY,
24
+ name TEXT NOT NULL,
25
+ applied_at DATETIME DEFAULT CURRENT_TIMESTAMP,
26
+ rolled_back_at DATETIME
27
+ )
28
+ `);
29
+ }
30
+ catch (error) {
31
+ throw new Error(`Failed to initialize migrations_history table: ${error instanceof Error ? error.message : String(error)}`);
32
+ }
33
+ }
34
+ /**
35
+ * Get all migrations that have been applied
36
+ */
37
+ getAppliedMigrations() {
38
+ try {
39
+ const applied = this.db.query('SELECT id, name, applied_at FROM migrations_history WHERE rolled_back_at IS NULL ORDER BY applied_at ASC');
40
+ const map = new Map();
41
+ for (const migration of applied) {
42
+ map.set(migration.id, {
43
+ name: migration.name,
44
+ applied_at: migration.applied_at,
45
+ });
46
+ }
47
+ return map;
48
+ }
49
+ catch (error) {
50
+ throw new Error(`Failed to get applied migrations: ${error instanceof Error ? error.message : String(error)}`);
51
+ }
52
+ }
53
+ /**
54
+ * Run all pending migrations
55
+ * Executes migrations that haven't been applied yet
56
+ */
57
+ runPending(migrations) {
58
+ try {
59
+ // Initialize migration history table
60
+ this.initializeMigrationHistory();
61
+ const applied = [];
62
+ const skipped = [];
63
+ const appliedMigrations = this.getAppliedMigrations();
64
+ for (const migration of migrations) {
65
+ if (appliedMigrations.has(migration.id)) {
66
+ skipped.push(migration);
67
+ continue;
68
+ }
69
+ // Execute migration within a transaction
70
+ this.db.transaction(() => {
71
+ migration.up();
72
+ // Record migration in history
73
+ this.db.execute('INSERT INTO migrations_history (id, name, applied_at) VALUES (?, ?, CURRENT_TIMESTAMP)', [migration.id, migration.name]);
74
+ });
75
+ applied.push(migration);
76
+ }
77
+ return { applied, skipped };
78
+ }
79
+ catch (error) {
80
+ throw new Error(`Failed to run pending migrations: ${error instanceof Error ? error.message : String(error)}`);
81
+ }
82
+ }
83
+ /**
84
+ * Rollback the most recent migration
85
+ */
86
+ rollback() {
87
+ try {
88
+ this.initializeMigrationHistory();
89
+ const lastApplied = this.db.queryOne('SELECT id, name, applied_at FROM migrations_history WHERE rolled_back_at IS NULL ORDER BY applied_at DESC LIMIT 1');
90
+ if (!lastApplied) {
91
+ return null;
92
+ }
93
+ // Find the migration object to rollback
94
+ // Note: This requires the caller to provide migration instances
95
+ // For now, we'll just track the history
96
+ const migrationId = lastApplied.id;
97
+ this.db.transaction(() => {
98
+ // Mark migration as rolled back
99
+ this.db.execute('UPDATE migrations_history SET rolled_back_at = CURRENT_TIMESTAMP WHERE id = ?', [migrationId]);
100
+ });
101
+ return {
102
+ id: lastApplied.id,
103
+ name: lastApplied.name,
104
+ up: () => {
105
+ // Placeholder - actual up() is in the migration instance
106
+ },
107
+ down: () => {
108
+ // Placeholder - actual down() is in the migration instance
109
+ },
110
+ };
111
+ }
112
+ catch (error) {
113
+ throw new Error(`Failed to rollback migration: ${error instanceof Error ? error.message : String(error)}`);
114
+ }
115
+ }
116
+ /**
117
+ * Rollback a specific number of migrations
118
+ */
119
+ rollbackN(n) {
120
+ const rolledBack = [];
121
+ for (let i = 0; i < n; i++) {
122
+ const result = this.rollback();
123
+ if (result) {
124
+ rolledBack.push(result);
125
+ }
126
+ else {
127
+ break;
128
+ }
129
+ }
130
+ return rolledBack;
131
+ }
132
+ /**
133
+ * Get migration status - which migrations are applied and which are pending
134
+ */
135
+ getMigrationStatus(migrations) {
136
+ try {
137
+ const appliedMigrations = this.getAppliedMigrations();
138
+ const applied = [];
139
+ const pending = [];
140
+ for (const migration of migrations) {
141
+ if (appliedMigrations.has(migration.id)) {
142
+ applied.push(migration);
143
+ }
144
+ else {
145
+ pending.push(migration);
146
+ }
147
+ }
148
+ return { applied, pending };
149
+ }
150
+ catch (error) {
151
+ throw new Error(`Failed to get migration status: ${error instanceof Error ? error.message : String(error)}`);
152
+ }
153
+ }
154
+ /**
155
+ * Get all migration history records
156
+ */
157
+ getHistory() {
158
+ try {
159
+ return this.db.query('SELECT id, name, applied_at, rolled_back_at FROM migrations_history ORDER BY applied_at DESC');
160
+ }
161
+ catch (error) {
162
+ throw new Error(`Failed to get migration history: ${error instanceof Error ? error.message : String(error)}`);
163
+ }
164
+ }
165
+ }
166
+ exports.MigrationRunner = MigrationRunner;
167
+ //# sourceMappingURL=MigrationRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationRunner.js","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/MigrationRunner.ts"],"names":[],"mappings":";;;AAAA,8DAA2D;AAG3D;;;;GAIG;AACH,MAAa,eAAe;IAG1B;QACE,IAAI,CAAC,EAAE,GAAG,uCAAkB,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACI,0BAA0B;QAC/B,IAAI,CAAC;YACH,gDAAgD;YAChD,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;;;;OAOf,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,kDAAkD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAA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C,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/G,CAAC;IACH,CAAC;IAED;;OAEG;IACI,UAAU;QAMf,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAClB,8FAA8F,CAC/F,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;CACF;AAnMD,0CAmMC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Migrations Module
3
+ * Exports all migrations and migration infrastructure
4
+ */
5
+ export { Migration } from './Migration';
6
+ export { MigrationRunner } from './MigrationRunner';
7
+ export { InitialMigration } from './001_initial';
8
+ import { Migration } from './Migration';
9
+ export declare const getAllMigrations: () => Migration[];
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,gBAAgB,QAAO,SAAS,EAK5C,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Migrations Module
4
+ * Exports all migrations and migration infrastructure
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getAllMigrations = exports.InitialMigration = exports.MigrationRunner = void 0;
8
+ var MigrationRunner_1 = require("./MigrationRunner");
9
+ Object.defineProperty(exports, "MigrationRunner", { enumerable: true, get: function () { return MigrationRunner_1.MigrationRunner; } });
10
+ var _001_initial_1 = require("./001_initial");
11
+ Object.defineProperty(exports, "InitialMigration", { enumerable: true, get: function () { return _001_initial_1.InitialMigration; } });
12
+ // Array of all available migrations in order
13
+ // New migrations should be added to this array
14
+ const _001_initial_2 = require("./001_initial");
15
+ const getAllMigrations = () => {
16
+ return [
17
+ new _001_initial_2.InitialMigration(),
18
+ // Add new migrations here in order
19
+ ];
20
+ };
21
+ exports.getAllMigrations = getAllMigrations;
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/infrastructure/database/migrations/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,8CAAiD;AAAxC,gHAAA,gBAAgB,OAAA;AAEzB,6CAA6C;AAC7C,+CAA+C;AAC/C,gDAAiD;AAG1C,MAAM,gBAAgB,GAAG,GAAgB,EAAE;IAChD,OAAO;QACL,IAAI,+BAAgB,EAAE;QACtB,mCAAmC;KACpC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,gBAAgB,oBAK3B"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * DirectoryManager handles the creation and initialization of application directories.
3
+ * Manages directory structure for Project Hub, including logs and database directories.
4
+ */
5
+ export declare class DirectoryManager {
6
+ private readonly appDir;
7
+ private readonly logsDir;
8
+ private readonly dbDir;
9
+ constructor();
10
+ /**
11
+ * Initializes the application directory structure.
12
+ * Creates ~/.project-hub/, ~/.project-hub/logs/, and ~/.project-hub/db/ directories.
13
+ * Sets appropriate permissions (700 on Unix systems).
14
+ *
15
+ * @throws Error if directory creation fails
16
+ */
17
+ initializeAppDirectories(): void;
18
+ /**
19
+ * Returns the application directory path.
20
+ */
21
+ getAppDir(): string;
22
+ /**
23
+ * Returns the logs directory path.
24
+ */
25
+ getLogsDir(): string;
26
+ /**
27
+ * Returns the database directory path.
28
+ */
29
+ getDbDir(): string;
30
+ /**
31
+ * Ensures a directory exists. Creates it if it doesn't.
32
+ *
33
+ * @param dirPath - Path to the directory
34
+ */
35
+ private ensureDirectoryExists;
36
+ /**
37
+ * Sets directory permissions to 700 (rwx------) on Unix systems.
38
+ * On Windows, this operation is silently ignored as Windows uses ACLs instead.
39
+ *
40
+ * @param dirPath - Path to the directory
41
+ */
42
+ private setDirectoryPermissions;
43
+ /**
44
+ * Verifies that all required directories exist and have correct permissions.
45
+ *
46
+ * @returns true if all directories exist and are accessible
47
+ */
48
+ verifyDirectoriesExist(): boolean;
49
+ }
50
+ //# sourceMappingURL=DirectoryManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DirectoryManager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/filesystem/DirectoryManager.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;;IAS/B;;;;;;OAMG;IACI,wBAAwB,IAAI,IAAI;IAgBvC;;OAEG;IACI,SAAS,IAAI,MAAM;IAI1B;;OAEG;IACI,UAAU,IAAI,MAAM;IAI3B;;OAEG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAM7B;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;OAIG;IACI,sBAAsB,IAAI,OAAO;CAezC"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DirectoryManager = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const os = __importStar(require("os"));
40
+ /**
41
+ * DirectoryManager handles the creation and initialization of application directories.
42
+ * Manages directory structure for Project Hub, including logs and database directories.
43
+ */
44
+ class DirectoryManager {
45
+ constructor() {
46
+ const homeDir = os.homedir();
47
+ this.appDir = path.join(homeDir, '.project-hub');
48
+ this.logsDir = path.join(this.appDir, 'logs');
49
+ this.dbDir = path.join(this.appDir, 'db');
50
+ }
51
+ /**
52
+ * Initializes the application directory structure.
53
+ * Creates ~/.project-hub/, ~/.project-hub/logs/, and ~/.project-hub/db/ directories.
54
+ * Sets appropriate permissions (700 on Unix systems).
55
+ *
56
+ * @throws Error if directory creation fails
57
+ */
58
+ initializeAppDirectories() {
59
+ try {
60
+ this.ensureDirectoryExists(this.appDir);
61
+ this.ensureDirectoryExists(this.logsDir);
62
+ this.ensureDirectoryExists(this.dbDir);
63
+ // Set permissions to 700 (rwx------) on Unix systems (Windows ignores this)
64
+ this.setDirectoryPermissions(this.appDir);
65
+ this.setDirectoryPermissions(this.logsDir);
66
+ this.setDirectoryPermissions(this.dbDir);
67
+ }
68
+ catch (error) {
69
+ const message = error instanceof Error ? error.message : String(error);
70
+ throw new Error(`Failed to initialize application directories: ${message}`);
71
+ }
72
+ }
73
+ /**
74
+ * Returns the application directory path.
75
+ */
76
+ getAppDir() {
77
+ return this.appDir;
78
+ }
79
+ /**
80
+ * Returns the logs directory path.
81
+ */
82
+ getLogsDir() {
83
+ return this.logsDir;
84
+ }
85
+ /**
86
+ * Returns the database directory path.
87
+ */
88
+ getDbDir() {
89
+ return this.dbDir;
90
+ }
91
+ /**
92
+ * Ensures a directory exists. Creates it if it doesn't.
93
+ *
94
+ * @param dirPath - Path to the directory
95
+ */
96
+ ensureDirectoryExists(dirPath) {
97
+ if (!fs.existsSync(dirPath)) {
98
+ fs.mkdirSync(dirPath, { recursive: true });
99
+ }
100
+ }
101
+ /**
102
+ * Sets directory permissions to 700 (rwx------) on Unix systems.
103
+ * On Windows, this operation is silently ignored as Windows uses ACLs instead.
104
+ *
105
+ * @param dirPath - Path to the directory
106
+ */
107
+ setDirectoryPermissions(dirPath) {
108
+ // Only set permissions on Unix-like systems
109
+ if (process.platform !== 'win32') {
110
+ try {
111
+ fs.chmodSync(dirPath, 0o700);
112
+ }
113
+ catch (error) {
114
+ // Log but don't throw - permissions might fail on some filesystems
115
+ const message = error instanceof Error ? error.message : String(error);
116
+ console.warn(`Warning: Could not set directory permissions for ${dirPath}: ${message}`);
117
+ }
118
+ }
119
+ }
120
+ /**
121
+ * Verifies that all required directories exist and have correct permissions.
122
+ *
123
+ * @returns true if all directories exist and are accessible
124
+ */
125
+ verifyDirectoriesExist() {
126
+ try {
127
+ const directories = [this.appDir, this.logsDir, this.dbDir];
128
+ for (const dir of directories) {
129
+ if (!fs.existsSync(dir)) {
130
+ return false;
131
+ }
132
+ // Verify read/write access
133
+ fs.accessSync(dir, fs.constants.R_OK | fs.constants.W_OK);
134
+ }
135
+ return true;
136
+ }
137
+ catch (error) {
138
+ return false;
139
+ }
140
+ }
141
+ }
142
+ exports.DirectoryManager = DirectoryManager;
143
+ //# sourceMappingURL=DirectoryManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DirectoryManager.js","sourceRoot":"","sources":["../../../src/infrastructure/filesystem/DirectoryManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB;;;GAGG;AACH,MAAa,gBAAgB;IAK3B;QACE,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACI,wBAAwB;QAC7B,IAAI,CAAC;YACH,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEvC,4EAA4E;YAC5E,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,KA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YACH,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5D,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;gBAC9B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACxB,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,2BAA2B;gBAC3B,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC5D,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AA1GD,4CA0GC"}
@@ -0,0 +1,2 @@
1
+ export { DirectoryManager } from './DirectoryManager';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/filesystem/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DirectoryManager = void 0;
4
+ var DirectoryManager_1 = require("./DirectoryManager");
5
+ Object.defineProperty(exports, "DirectoryManager", { enumerable: true, get: function () { return DirectoryManager_1.DirectoryManager; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/infrastructure/filesystem/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}