|
| 1 | +import * as vscode from 'vscode' |
| 2 | +import { Logger } from '@shared/utils/logger' |
| 3 | + |
| 4 | +const MIGRATION_ID = 'prompt-templates-suffixes-migration-20260702' |
| 5 | + |
| 6 | +export async function migrate_prompt_templates_suffixes( |
| 7 | + context: vscode.ExtensionContext |
| 8 | +): Promise<void> { |
| 9 | + try { |
| 10 | + if (context.globalState.get(MIGRATION_ID)) { |
| 11 | + return |
| 12 | + } |
| 13 | + |
| 14 | + const config = vscode.workspace.getConfiguration('codeWebChat') |
| 15 | + |
| 16 | + const mappings = [ |
| 17 | + { |
| 18 | + old: 'promptTemplatesForEditContext', |
| 19 | + new: 'promptTemplatesForEditFiles' |
| 20 | + }, |
| 21 | + { |
| 22 | + old: 'promptTemplatesForAskAboutContext', |
| 23 | + new: 'promptTemplatesForAskAboutFiles' |
| 24 | + }, |
| 25 | + { |
| 26 | + old: 'promptTemplatesForNoContext', |
| 27 | + new: 'promptTemplatesForWithoutFiles' |
| 28 | + } |
| 29 | + ] |
| 30 | + |
| 31 | + for (const mapping of mappings) { |
| 32 | + const inspect = config.inspect<any[]>(mapping.old) |
| 33 | + |
| 34 | + if (inspect?.globalValue !== undefined) { |
| 35 | + await config.update( |
| 36 | + mapping.new, |
| 37 | + inspect.globalValue, |
| 38 | + vscode.ConfigurationTarget.Global |
| 39 | + ) |
| 40 | + await config.update( |
| 41 | + mapping.old, |
| 42 | + undefined, |
| 43 | + vscode.ConfigurationTarget.Global |
| 44 | + ) |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + await context.globalState.update(MIGRATION_ID, true) |
| 49 | + Logger.info({ |
| 50 | + function_name: 'migrate_prompt_templates_suffixes', |
| 51 | + message: 'Successfully migrated prompt templates suffixes' |
| 52 | + }) |
| 53 | + } catch (error) { |
| 54 | + Logger.error({ |
| 55 | + function_name: 'migrate_prompt_templates_suffixes', |
| 56 | + message: 'Error migrating prompt templates suffixes', |
| 57 | + data: error instanceof Error ? error.message : String(error) |
| 58 | + }) |
| 59 | + } |
| 60 | +} |
0 commit comments