@codemieai/code 0.0.25 → 0.0.27
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/bin/codemie.js +20 -1
- package/dist/agents/codemie-code/ui.d.ts.map +1 -1
- package/dist/agents/codemie-code/ui.js +9 -8
- package/dist/agents/codemie-code/ui.js.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +2 -1
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/agents/core/lifecycle-helpers.d.ts +2 -1
- package/dist/agents/core/lifecycle-helpers.d.ts.map +1 -1
- package/dist/agents/core/lifecycle-helpers.js +38 -17
- package/dist/agents/core/lifecycle-helpers.js.map +1 -1
- package/dist/env/manager.d.ts.map +1 -1
- package/dist/env/manager.js +1 -1
- package/dist/env/manager.js.map +1 -1
- package/dist/migrations/001-config-rename.migration.d.ts +33 -0
- package/dist/migrations/001-config-rename.migration.d.ts.map +1 -0
- package/dist/migrations/001-config-rename.migration.js +206 -0
- package/dist/migrations/001-config-rename.migration.js.map +1 -0
- package/dist/migrations/index.d.ts +22 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +26 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/registry.d.ts +28 -0
- package/dist/migrations/registry.d.ts.map +1 -0
- package/dist/migrations/registry.js +35 -0
- package/dist/migrations/registry.js.map +1 -0
- package/dist/migrations/runner.d.ts +26 -0
- package/dist/migrations/runner.d.ts.map +1 -0
- package/dist/migrations/runner.js +117 -0
- package/dist/migrations/runner.js.map +1 -0
- package/dist/migrations/tracker.d.ts +40 -0
- package/dist/migrations/tracker.d.ts.map +1 -0
- package/dist/migrations/tracker.js +114 -0
- package/dist/migrations/tracker.js.map +1 -0
- package/dist/migrations/types.d.ts +54 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations/types.js +6 -0
- package/dist/migrations/types.js.map +1 -0
- package/dist/providers/core/types.d.ts +19 -0
- package/dist/providers/core/types.d.ts.map +1 -1
- package/dist/providers/integration/setup-ui.js +1 -1
- package/dist/providers/integration/setup-ui.js.map +1 -1
- package/dist/providers/plugins/bedrock/bedrock.health.d.ts +4 -0
- package/dist/providers/plugins/bedrock/bedrock.health.d.ts.map +1 -1
- package/dist/providers/plugins/bedrock/bedrock.health.js +23 -0
- package/dist/providers/plugins/bedrock/bedrock.health.js.map +1 -1
- package/dist/providers/plugins/bedrock/bedrock.template.d.ts.map +1 -1
- package/dist/providers/plugins/bedrock/bedrock.template.js +85 -0
- package/dist/providers/plugins/bedrock/bedrock.template.js.map +1 -1
- package/dist/providers/plugins/sso/sso.health.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.health.js +3 -1
- package/dist/providers/plugins/sso/sso.health.js.map +1 -1
- package/dist/providers/plugins/sso/sso.models.d.ts +6 -0
- package/dist/providers/plugins/sso/sso.models.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.models.js +14 -5
- package/dist/providers/plugins/sso/sso.models.js.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.setup-steps.js +11 -3
- package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
- package/dist/providers/plugins/sso/sso.template.d.ts.map +1 -1
- package/dist/providers/plugins/sso/sso.template.js +16 -0
- package/dist/providers/plugins/sso/sso.template.js.map +1 -1
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +10 -31
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/which.d.ts.map +1 -1
- package/dist/utils/which.js +6 -1
- package/dist/utils/which.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Migration, MigrationResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Migration 001: Rename config.json to codemie-cli.config.json
|
|
4
|
+
*
|
|
5
|
+
* Migrates both global and project-local configs
|
|
6
|
+
* Only migrates configs that belong to CodeMie CLI (validates ownership)
|
|
7
|
+
*/
|
|
8
|
+
declare class ConfigRenameMigration implements Migration {
|
|
9
|
+
id: string;
|
|
10
|
+
description: string;
|
|
11
|
+
minVersion: string;
|
|
12
|
+
deprecatedIn: string;
|
|
13
|
+
private readonly GLOBAL_DIR;
|
|
14
|
+
private readonly PROJECT_DIR;
|
|
15
|
+
private readonly OLD_FILENAME;
|
|
16
|
+
private readonly NEW_FILENAME;
|
|
17
|
+
up(): Promise<MigrationResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Migrate config in a specific directory
|
|
20
|
+
*/
|
|
21
|
+
private migrateConfigInDirectory;
|
|
22
|
+
/**
|
|
23
|
+
* Check if config belongs to CodeMie CLI
|
|
24
|
+
* Validates by checking for known CodeMie config fields
|
|
25
|
+
*/
|
|
26
|
+
private isCodeMieConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Check if file exists
|
|
29
|
+
*/
|
|
30
|
+
private fileExists;
|
|
31
|
+
}
|
|
32
|
+
export { ConfigRenameMigration };
|
|
33
|
+
//# sourceMappingURL=001-config-rename.migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"001-config-rename.migration.d.ts","sourceRoot":"","sources":["../../src/migrations/001-config-rename.migration.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAK7D;;;;;GAKG;AACH,cAAM,qBAAsB,YAAW,SAAS;IAC9C,EAAE,SAAuB;IACzB,WAAW,SAAmD;IAC9D,UAAU,SAAW;IACrB,YAAY,SAAW;IAEvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;IAClE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAwC;IAEpE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAC9C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAEpD,EAAE,IAAI,OAAO,CAAC,eAAe,CAAC;IAiDpC;;OAEG;YACW,wBAAwB;IA0FtC;;;OAGG;IACH,OAAO,CAAC,eAAe;IA2CvB;;OAEG;YACW,UAAU;CAQzB;AAMD,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as os from 'os';
|
|
4
|
+
import { MigrationRegistry } from './registry.js';
|
|
5
|
+
import { isMultiProviderConfig, isLegacyConfig } from '../env/types.js';
|
|
6
|
+
import { logger } from '../utils/logger.js';
|
|
7
|
+
/**
|
|
8
|
+
* Migration 001: Rename config.json to codemie-cli.config.json
|
|
9
|
+
*
|
|
10
|
+
* Migrates both global and project-local configs
|
|
11
|
+
* Only migrates configs that belong to CodeMie CLI (validates ownership)
|
|
12
|
+
*/
|
|
13
|
+
class ConfigRenameMigration {
|
|
14
|
+
id = '001-config-rename';
|
|
15
|
+
description = 'Rename config.json to codemie-cli.config.json';
|
|
16
|
+
minVersion = '0.1.0';
|
|
17
|
+
deprecatedIn = '1.0.0';
|
|
18
|
+
GLOBAL_DIR = path.join(os.homedir(), '.codemie');
|
|
19
|
+
PROJECT_DIR = path.join(process.cwd(), '.codemie');
|
|
20
|
+
OLD_FILENAME = 'config.json';
|
|
21
|
+
NEW_FILENAME = 'codemie-cli.config.json';
|
|
22
|
+
async up() {
|
|
23
|
+
logger.info('[001-config-rename] Starting config file rename migration');
|
|
24
|
+
let globalMigrated = false;
|
|
25
|
+
let projectMigrated = false;
|
|
26
|
+
// Migrate global config
|
|
27
|
+
logger.debug('[001-config-rename] Checking global config for migration');
|
|
28
|
+
const globalResult = await this.migrateConfigInDirectory(this.GLOBAL_DIR);
|
|
29
|
+
if (globalResult.success && globalResult.migrated) {
|
|
30
|
+
globalMigrated = true;
|
|
31
|
+
logger.info('[001-config-rename] Global config migrated successfully');
|
|
32
|
+
}
|
|
33
|
+
else if (!globalResult.success) {
|
|
34
|
+
logger.error(`[001-config-rename] Global config migration failed: ${globalResult.reason}`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logger.debug(`[001-config-rename] Global config skipped: ${globalResult.reason}`);
|
|
38
|
+
}
|
|
39
|
+
// Migrate project-local config
|
|
40
|
+
logger.debug('[001-config-rename] Checking project-local config for migration');
|
|
41
|
+
const projectResult = await this.migrateConfigInDirectory(this.PROJECT_DIR);
|
|
42
|
+
if (projectResult.success && projectResult.migrated) {
|
|
43
|
+
projectMigrated = true;
|
|
44
|
+
logger.info('[001-config-rename] Project-local config migrated successfully');
|
|
45
|
+
}
|
|
46
|
+
else if (!projectResult.success) {
|
|
47
|
+
logger.error(`[001-config-rename] Project-local config migration failed: ${projectResult.reason}`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
logger.debug(`[001-config-rename] Project-local config skipped: ${projectResult.reason}`);
|
|
51
|
+
}
|
|
52
|
+
// Determine overall result
|
|
53
|
+
if (globalMigrated || projectMigrated) {
|
|
54
|
+
const details = {
|
|
55
|
+
global: globalMigrated,
|
|
56
|
+
project: projectMigrated
|
|
57
|
+
};
|
|
58
|
+
logger.info('[001-config-rename] Migration completed successfully', details);
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
migrated: true,
|
|
62
|
+
details
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// If neither migrated, return the reason from global (most common)
|
|
66
|
+
logger.debug(`[001-config-rename] No configs migrated: ${globalResult.reason}`);
|
|
67
|
+
return globalResult;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Migrate config in a specific directory
|
|
71
|
+
*/
|
|
72
|
+
async migrateConfigInDirectory(configDir) {
|
|
73
|
+
const oldPath = path.join(configDir, this.OLD_FILENAME);
|
|
74
|
+
const newPath = path.join(configDir, this.NEW_FILENAME);
|
|
75
|
+
logger.debug(`[001-config-rename] Checking ${oldPath}`);
|
|
76
|
+
// Check if old config exists
|
|
77
|
+
if (!await this.fileExists(oldPath)) {
|
|
78
|
+
logger.debug(`[001-config-rename] Old config not found at ${oldPath}`);
|
|
79
|
+
return {
|
|
80
|
+
success: true,
|
|
81
|
+
migrated: false,
|
|
82
|
+
reason: 'no-old-config'
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
logger.debug(`[001-config-rename] Found old config at ${oldPath}`);
|
|
86
|
+
// Check if new config already exists (migration already done)
|
|
87
|
+
if (await this.fileExists(newPath)) {
|
|
88
|
+
logger.debug(`[001-config-rename] New config already exists at ${newPath}`);
|
|
89
|
+
return {
|
|
90
|
+
success: true,
|
|
91
|
+
migrated: false,
|
|
92
|
+
reason: 'already-migrated'
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Read and validate old config
|
|
96
|
+
let oldConfig;
|
|
97
|
+
try {
|
|
98
|
+
const content = await fs.readFile(oldPath, 'utf-8');
|
|
99
|
+
oldConfig = JSON.parse(content);
|
|
100
|
+
logger.debug(`[001-config-rename] Successfully read and parsed config`);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
logger.error(`[001-config-rename] Failed to read/parse config: ${error.message}`);
|
|
104
|
+
return {
|
|
105
|
+
success: false,
|
|
106
|
+
migrated: false,
|
|
107
|
+
reason: 'invalid-json'
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Validate config ownership
|
|
111
|
+
const isOurs = this.isCodeMieConfig(oldConfig);
|
|
112
|
+
logger.debug(`[001-config-rename] Config ownership check: ${isOurs ? 'CodeMie CLI' : 'other tool'}`);
|
|
113
|
+
if (!isOurs) {
|
|
114
|
+
logger.info(`[001-config-rename] Config at ${oldPath} does not belong to CodeMie CLI, skipping`);
|
|
115
|
+
return {
|
|
116
|
+
success: true,
|
|
117
|
+
migrated: false,
|
|
118
|
+
reason: 'not-codemie-config'
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// Perform migration
|
|
122
|
+
try {
|
|
123
|
+
// Ensure directory exists
|
|
124
|
+
await fs.mkdir(configDir, { recursive: true });
|
|
125
|
+
logger.debug(`[001-config-rename] Created/verified directory: ${configDir}`);
|
|
126
|
+
// Write to new location
|
|
127
|
+
await fs.writeFile(newPath, JSON.stringify(oldConfig, null, 2), 'utf-8');
|
|
128
|
+
logger.debug(`[001-config-rename] Wrote new config to ${newPath}`);
|
|
129
|
+
// Delete old config
|
|
130
|
+
await fs.unlink(oldPath);
|
|
131
|
+
logger.debug(`[001-config-rename] Deleted old config at ${oldPath}`);
|
|
132
|
+
logger.info(`[001-config-rename] Successfully migrated ${oldPath} → ${newPath}`);
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
migrated: true
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
logger.error(`[001-config-rename] Migration failed: ${error.message}`, error);
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
migrated: false,
|
|
143
|
+
reason: `migration-failed: ${error.message}`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if config belongs to CodeMie CLI
|
|
149
|
+
* Validates by checking for known CodeMie config fields
|
|
150
|
+
*/
|
|
151
|
+
isCodeMieConfig(config) {
|
|
152
|
+
if (!config || typeof config !== 'object') {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
// Check for multi-provider format (version 2)
|
|
156
|
+
if (isMultiProviderConfig(config)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
// Check for legacy format (version 1)
|
|
160
|
+
if (isLegacyConfig(config)) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
// Check for known CodeMie CLI fields
|
|
164
|
+
// Require at least 2 matching fields to avoid false positives
|
|
165
|
+
const codeMieFields = [
|
|
166
|
+
'provider',
|
|
167
|
+
'baseUrl',
|
|
168
|
+
'apiKey',
|
|
169
|
+
'model',
|
|
170
|
+
'timeout',
|
|
171
|
+
'authMethod',
|
|
172
|
+
'codeMieUrl',
|
|
173
|
+
'codeMieProject',
|
|
174
|
+
'codeMieIntegration',
|
|
175
|
+
'ssoConfig',
|
|
176
|
+
'profiles',
|
|
177
|
+
'activeProfile',
|
|
178
|
+
'version',
|
|
179
|
+
'awsProfile',
|
|
180
|
+
'awsRegion',
|
|
181
|
+
'metrics',
|
|
182
|
+
'debug',
|
|
183
|
+
'allowedDirs',
|
|
184
|
+
'ignorePatterns'
|
|
185
|
+
];
|
|
186
|
+
const matchingFields = codeMieFields.filter(field => field in config);
|
|
187
|
+
return matchingFields.length >= 2;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if file exists
|
|
191
|
+
*/
|
|
192
|
+
async fileExists(filePath) {
|
|
193
|
+
try {
|
|
194
|
+
await fs.access(filePath);
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Auto-register the migration
|
|
203
|
+
MigrationRegistry.register(new ConfigRenameMigration());
|
|
204
|
+
// Export for testing
|
|
205
|
+
export { ConfigRenameMigration };
|
|
206
|
+
//# sourceMappingURL=001-config-rename.migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"001-config-rename.migration.js","sourceRoot":"","sources":["../../src/migrations/001-config-rename.migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,qBAA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IAAI,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,sCAAsC;QACtC,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,qCAAqC;QACrC,8DAA8D;QAC9D,MAAM,aAAa,GAAG;YACpB,UAAU;YACV,SAAS;YACT,QAAQ;YACR,OAAO;YACP,SAAS;YACT,YAAY;YACZ,YAAY;YACZ,gBAAgB;YAChB,oBAAoB;YACpB,WAAW;YACX,UAAU;YACV,eAAe;YACf,SAAS;YACT,YAAY;YACZ,WAAW;YACX,SAAS;YACT,OAAO;YACP,aAAa;YACb,gBAAgB;SACjB,CAAC;QAEF,MAAM,cAAc,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;QACtE,OAAO,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,UAAU,CAAC,QAAgB;QACvC,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAED,8BAA8B;AAC9B,iBAAiB,CAAC,QAAQ,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;AAExD,qBAAqB;AACrB,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration system public API
|
|
3
|
+
*
|
|
4
|
+
* This module provides a database-style migration framework for CodeMie CLI.
|
|
5
|
+
* Migrations are tracked in ~/.codemie/migrations.json and run automatically at CLI startup.
|
|
6
|
+
*
|
|
7
|
+
* To add a new migration:
|
|
8
|
+
* 1. Create a new file: src/migrations/XXX-description.migration.ts
|
|
9
|
+
* 2. Implement the Migration interface
|
|
10
|
+
* 3. Import it below
|
|
11
|
+
*
|
|
12
|
+
* Example:
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import './002-add-analytics.migration.js';
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export { MigrationRunner } from './runner.js';
|
|
18
|
+
export { MigrationRegistry } from './registry.js';
|
|
19
|
+
export { MigrationTracker } from './tracker.js';
|
|
20
|
+
export type { Migration, MigrationResult, MigrationRecord, MigrationHistory } from './types.js';
|
|
21
|
+
import './001-config-rename.migration.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGhG,OAAO,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration system public API
|
|
3
|
+
*
|
|
4
|
+
* This module provides a database-style migration framework for CodeMie CLI.
|
|
5
|
+
* Migrations are tracked in ~/.codemie/migrations.json and run automatically at CLI startup.
|
|
6
|
+
*
|
|
7
|
+
* To add a new migration:
|
|
8
|
+
* 1. Create a new file: src/migrations/XXX-description.migration.ts
|
|
9
|
+
* 2. Implement the Migration interface
|
|
10
|
+
* 3. Import it below
|
|
11
|
+
*
|
|
12
|
+
* Example:
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import './002-add-analytics.migration.js';
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
// Export public API
|
|
18
|
+
export { MigrationRunner } from './runner.js';
|
|
19
|
+
export { MigrationRegistry } from './registry.js';
|
|
20
|
+
export { MigrationTracker } from './tracker.js';
|
|
21
|
+
// Import all migrations (auto-registers them)
|
|
22
|
+
import './001-config-rename.migration.js';
|
|
23
|
+
// Future migrations will be imported here:
|
|
24
|
+
// import './002-add-analytics.migration.js';
|
|
25
|
+
// import './003-restructure-profiles.migration.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/migrations/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,oBAAoB;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,8CAA8C;AAC9C,OAAO,kCAAkC,CAAC;AAE1C,2CAA2C;AAC3C,6CAA6C;AAC7C,oDAAoD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Migration } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Central migration registry
|
|
4
|
+
* Stores all registered migrations and provides access methods
|
|
5
|
+
*/
|
|
6
|
+
export declare class MigrationRegistry {
|
|
7
|
+
private static migrations;
|
|
8
|
+
/**
|
|
9
|
+
* Register a migration
|
|
10
|
+
* Migrations auto-register themselves when imported
|
|
11
|
+
*/
|
|
12
|
+
static register(migration: Migration): void;
|
|
13
|
+
/**
|
|
14
|
+
* Get all migrations sorted by ID
|
|
15
|
+
* Ensures migrations run in predictable order (001, 002, 003, etc.)
|
|
16
|
+
*/
|
|
17
|
+
static getAll(): Migration[];
|
|
18
|
+
/**
|
|
19
|
+
* Get a specific migration by ID
|
|
20
|
+
*/
|
|
21
|
+
static get(id: string): Migration | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all registered migrations
|
|
24
|
+
* Used primarily for testing
|
|
25
|
+
*/
|
|
26
|
+
static clear(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/migrations/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,UAAU,CAAmB;IAE5C;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAI3C;;;OAGG;IACH,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE;IAI5B;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAI7C;;;OAGG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;CAGrB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central migration registry
|
|
3
|
+
* Stores all registered migrations and provides access methods
|
|
4
|
+
*/
|
|
5
|
+
export class MigrationRegistry {
|
|
6
|
+
static migrations = [];
|
|
7
|
+
/**
|
|
8
|
+
* Register a migration
|
|
9
|
+
* Migrations auto-register themselves when imported
|
|
10
|
+
*/
|
|
11
|
+
static register(migration) {
|
|
12
|
+
this.migrations.push(migration);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get all migrations sorted by ID
|
|
16
|
+
* Ensures migrations run in predictable order (001, 002, 003, etc.)
|
|
17
|
+
*/
|
|
18
|
+
static getAll() {
|
|
19
|
+
return [...this.migrations].sort((a, b) => a.id.localeCompare(b.id));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get a specific migration by ID
|
|
23
|
+
*/
|
|
24
|
+
static get(id) {
|
|
25
|
+
return this.migrations.find(m => m.id === id);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Clear all registered migrations
|
|
29
|
+
* Used primarily for testing
|
|
30
|
+
*/
|
|
31
|
+
static clear() {
|
|
32
|
+
this.migrations = [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/migrations/registry.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAC,UAAU,GAAgB,EAAE,CAAC;IAE5C;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAoB;QAClC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,MAAM;QACX,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK;QACV,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration runner
|
|
3
|
+
* Executes pending migrations and displays progress
|
|
4
|
+
*/
|
|
5
|
+
export declare class MigrationRunner {
|
|
6
|
+
/**
|
|
7
|
+
* Run all pending migrations
|
|
8
|
+
* @param options Configuration options
|
|
9
|
+
* @returns Statistics about migrations executed
|
|
10
|
+
*/
|
|
11
|
+
static runPending(options?: {
|
|
12
|
+
silent?: boolean;
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
autoCleanup?: boolean;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
total: number;
|
|
17
|
+
applied: number;
|
|
18
|
+
skipped: number;
|
|
19
|
+
failed: number;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if any migrations are pending
|
|
23
|
+
*/
|
|
24
|
+
static hasPending(): Promise<boolean>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/migrations/runner.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;;;OAIG;WACU,UAAU,CAAC,OAAO,CAAC,EAAE;QAChC,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA2GhF;;OAEG;WACU,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAI5C"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { MigrationTracker } from './tracker.js';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
/**
|
|
5
|
+
* Migration runner
|
|
6
|
+
* Executes pending migrations and displays progress
|
|
7
|
+
*/
|
|
8
|
+
export class MigrationRunner {
|
|
9
|
+
/**
|
|
10
|
+
* Run all pending migrations
|
|
11
|
+
* @param options Configuration options
|
|
12
|
+
* @returns Statistics about migrations executed
|
|
13
|
+
*/
|
|
14
|
+
static async runPending(options) {
|
|
15
|
+
const silent = options?.silent ?? false;
|
|
16
|
+
const dryRun = options?.dryRun ?? false;
|
|
17
|
+
logger.debug('[MigrationRunner] Starting migration check');
|
|
18
|
+
const pending = await MigrationTracker.getPendingMigrations();
|
|
19
|
+
if (pending.length === 0) {
|
|
20
|
+
logger.debug('[MigrationRunner] No pending migrations');
|
|
21
|
+
return { total: 0, applied: 0, skipped: 0, failed: 0 };
|
|
22
|
+
}
|
|
23
|
+
logger.info(`[MigrationRunner] Found ${pending.length} pending migration(s): ${pending.map(m => m.id).join(', ')}`);
|
|
24
|
+
if (!silent) {
|
|
25
|
+
console.log(chalk.bold(`\n🔄 Running ${pending.length} migration(s)...\n`));
|
|
26
|
+
}
|
|
27
|
+
let applied = 0;
|
|
28
|
+
let skipped = 0;
|
|
29
|
+
let failed = 0;
|
|
30
|
+
// Execute each migration in order
|
|
31
|
+
for (const migration of pending) {
|
|
32
|
+
logger.debug(`[MigrationRunner] Starting migration: ${migration.id}`);
|
|
33
|
+
if (!silent) {
|
|
34
|
+
console.log(chalk.cyan(`[${migration.id}]`), chalk.dim(migration.description));
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const result = await migration.up();
|
|
38
|
+
if (result.success) {
|
|
39
|
+
if (result.migrated) {
|
|
40
|
+
// Migration was applied successfully
|
|
41
|
+
applied++;
|
|
42
|
+
logger.info(`[MigrationRunner] Migration ${migration.id} applied successfully`, result.details);
|
|
43
|
+
if (!silent) {
|
|
44
|
+
console.log(chalk.green('✓'), chalk.dim('Applied'));
|
|
45
|
+
}
|
|
46
|
+
if (!dryRun) {
|
|
47
|
+
await MigrationTracker.recordMigration(migration.id, true);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// Migration was skipped (already done or not applicable)
|
|
52
|
+
skipped++;
|
|
53
|
+
logger.debug(`[MigrationRunner] Migration ${migration.id} skipped: ${result.reason}`);
|
|
54
|
+
if (!silent) {
|
|
55
|
+
console.log(chalk.yellow('⊘'), chalk.dim(`Skipped: ${result.reason}`));
|
|
56
|
+
}
|
|
57
|
+
if (!dryRun) {
|
|
58
|
+
// Record as successful (even though skipped) to prevent re-running
|
|
59
|
+
await MigrationTracker.recordMigration(migration.id, true);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Migration failed
|
|
65
|
+
failed++;
|
|
66
|
+
logger.error(`[MigrationRunner] Migration ${migration.id} failed: ${result.reason}`, result.details);
|
|
67
|
+
if (!silent) {
|
|
68
|
+
console.log(chalk.red('✗'), chalk.dim(`Failed: ${result.reason}`));
|
|
69
|
+
}
|
|
70
|
+
// Don't record failed migrations - they can be retried
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
// Unexpected error during migration
|
|
75
|
+
failed++;
|
|
76
|
+
logger.error(`[MigrationRunner] Unexpected error in migration ${migration.id}:`, error);
|
|
77
|
+
if (!silent) {
|
|
78
|
+
console.log(chalk.red('✗'), chalk.dim(`Error: ${error.message}`));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!silent) {
|
|
82
|
+
console.log(); // Empty line between migrations
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!silent && applied > 0) {
|
|
86
|
+
console.log(chalk.dim(`→ ${applied} migration(s) applied\n`));
|
|
87
|
+
}
|
|
88
|
+
// Log summary
|
|
89
|
+
logger.info(`[MigrationRunner] Migration complete: ${applied} applied, ${skipped} skipped, ${failed} failed`);
|
|
90
|
+
// Auto-cleanup deprecated migrations if requested
|
|
91
|
+
if (options?.autoCleanup && !dryRun) {
|
|
92
|
+
try {
|
|
93
|
+
logger.debug('[MigrationRunner] Auto-cleanup requested but not yet implemented');
|
|
94
|
+
// Get package version for cleanup
|
|
95
|
+
// Note: readPackageJson implementation will be needed
|
|
96
|
+
// For now, we'll skip auto-cleanup unless manually invoked
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Ignore cleanup errors
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
total: pending.length,
|
|
104
|
+
applied,
|
|
105
|
+
skipped,
|
|
106
|
+
failed
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Check if any migrations are pending
|
|
111
|
+
*/
|
|
112
|
+
static async hasPending() {
|
|
113
|
+
const pending = await MigrationTracker.getPendingMigrations();
|
|
114
|
+
return pending.length > 0;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/migrations/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,OAIvB;QACC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;QACxC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,KAAK,CAAC;QAExC,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAE3D,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;QAE9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;YACxD,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC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rationRecord } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Migration tracker
|
|
4
|
+
* Manages migration history file and tracks which migrations have been applied
|
|
5
|
+
*/
|
|
6
|
+
export declare class MigrationTracker {
|
|
7
|
+
private static readonly HISTORY_FILE;
|
|
8
|
+
/**
|
|
9
|
+
* Load migration history from file
|
|
10
|
+
* Returns empty history for new installations
|
|
11
|
+
*/
|
|
12
|
+
static loadHistory(): Promise<MigrationHistory>;
|
|
13
|
+
/**
|
|
14
|
+
* Save migration history to file
|
|
15
|
+
*/
|
|
16
|
+
static saveHistory(history: MigrationHistory): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a migration has been applied
|
|
19
|
+
*/
|
|
20
|
+
static hasBeenApplied(migrationId: string): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Record a migration as applied
|
|
23
|
+
*/
|
|
24
|
+
static recordMigration(migrationId: string, success: boolean): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Get pending migrations
|
|
27
|
+
* Returns migrations that haven't been successfully applied yet
|
|
28
|
+
*/
|
|
29
|
+
static getPendingMigrations(): Promise<Migration[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Clean up deprecated migrations from history
|
|
32
|
+
* Removes migrations that are deprecated in versions before current major version
|
|
33
|
+
*/
|
|
34
|
+
static cleanupDeprecated(currentVersion: string): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Get all migration records
|
|
37
|
+
*/
|
|
38
|
+
static getAll(): Promise<MigrationRecord[]>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/migrations/tracker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAI/E;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA0D;IAE9F;;;OAGG;WACU,WAAW,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAgBrD;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlE;;OAEG;WACU,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlE;;OAEG;WACU,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBlF;;;OAGG;WACU,oBAAoB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAgBzD;;;OAGG;WACU,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA8BvE;;OAEG;WACU,MAAM,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAIlD"}
|