-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: move prompts to json in .sfdx folder * chore: sort imports * chore: diagnosticCollection * chore: use yaml instead of json
- Loading branch information
1 parent
c354881
commit ed5f2c1
Showing
7 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/salesforcedx-vscode-apex/src/oas/generationStrategy/promptsHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2025, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { parse, stringify } from 'yaml'; | ||
import { Prompts } from '../schemas'; | ||
import { sourcePrompts } from './prompts'; | ||
|
||
const PROMPTS_DIR = path.join('.sfdx', 'oas_prompts'); | ||
const PROMPTS_FILE = path.join(PROMPTS_DIR, 'prompts.yaml'); | ||
|
||
const getPromptsFromSource = (): Record<string, any> => { | ||
return sourcePrompts; | ||
}; | ||
|
||
export const ensurePromptsExist = (): void => { | ||
if (!fs.existsSync(PROMPTS_DIR)) { | ||
fs.mkdirSync(PROMPTS_DIR, { recursive: true }); | ||
} | ||
|
||
if (!fs.existsSync(PROMPTS_FILE)) { | ||
const extractedPrompts = getPromptsFromSource(); | ||
fs.writeFileSync(PROMPTS_FILE, stringify(extractedPrompts), 'utf8'); | ||
} | ||
}; | ||
|
||
export const getPrompts = (): Prompts => { | ||
ensurePromptsExist(); | ||
const data = fs.readFileSync(PROMPTS_FILE, 'utf8'); | ||
return parse(data) as Prompts; | ||
}; | ||
|
||
// For future use cases (if needed) | ||
export const updatePrompts = (newPrompts: Record<string, any>): void => { | ||
fs.writeFileSync(PROMPTS_FILE, stringify(newPrompts, null, 2), 'utf8'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters