Skip to content

Commit 8893472

Browse files
committed
feat: Add constant, better error handling, new path for prompts
1 parent 1173bd7 commit 8893472

File tree

6 files changed

+78
-14
lines changed

6 files changed

+78
-14
lines changed

.github/workflows/ci-cd.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- production-release
7+
pull_request:
8+
branches:
9+
- production-release
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: '14'
23+
24+
- name: Install dependencies
25+
run: npm install
26+
27+
- name: Build the extension
28+
run: npm run build
29+
30+
- name: Package the extension
31+
run: npm run package
32+
33+
deploy:
34+
runs-on: ubuntu-latest
35+
needs: build
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v2
40+
41+
- name: Upload VSIX file
42+
uses: actions/upload-artifact@v2
43+
with:
44+
name: vscode-extension
45+
path: path/to/your/package.vsix
46+
47+
- name: Deploy to Marketplace
48+
run: |
49+
echo "Deploying to the marketplace..."
50+
# Add your deployment script or command here
51+
# For example, using vsce to publish the extension
52+
npx vsce publish --pat ${{ secrets.VSCE_PAT }}

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"outFiles": [
1212
"${workspaceFolder}/out/**/*.js"
1313
],
14+
"preLaunchTask": "npm: compile",
1415
}
1516
]
1617
}

src/configManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ConfigManager {
3939
}
4040

4141
get branch(): string {
42-
return vscode.workspace.getConfiguration('promptsSync').get('branch', 'master');
42+
return vscode.workspace.getConfiguration('promptsSync').get('branch', 'main');
4343
}
4444

4545
get syncOnStartup(): boolean {
@@ -59,7 +59,7 @@ export class ConfigManager {
5959
}
6060

6161
get syncInstructions(): boolean {
62-
return vscode.workspace.getConfiguration('promptsSync').get('syncInstructions', true);
62+
return vscode.workspace.getConfiguration('promptsSync').get('syncInstructions', false);
6363
}
6464

6565
get syncPrompt(): boolean {

src/constant.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export const REPO_ROOT_PROMPT_PATH = 'prompts/';
2-
export const REPO_SYNC_CHAT_MODE_PATH = `${REPO_ROOT_PROMPT_PATH}chatmode/`;
3-
export const REPO_SYNC_INSTRUCTIONS_PATH = `${REPO_ROOT_PROMPT_PATH}instructions/`;
4-
export const REPO_SYNC_PROMPT_PATH = `${REPO_ROOT_PROMPT_PATH}prompt/`;
1+
export const REPO_SYNC_CHAT_MODE_PATH = `chatmode/`;
2+
export const REPO_SYNC_INSTRUCTIONS_PATH = `instructions/`;
3+
export const REPO_SYNC_PROMPT_PATH = `prompts/`;

src/syncManager.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export class SyncManager {
148148
if (this.config.syncPrompt) {
149149
allowedPaths.push(REPO_SYNC_PROMPT_PATH);
150150
}
151+
console.log('Allowed paths for sync:', allowedPaths);
151152

152153
// If no types are selected, return empty array
153154
if (allowedPaths.length === 0) {
@@ -159,7 +160,7 @@ export class SyncManager {
159160
if (item.type !== 'blob') {
160161
return false;
161162
}
162-
163+
163164
return allowedPaths.some(path => item.path.startsWith(path)) &&
164165
(item.path.endsWith('.md') || item.path.endsWith('.txt'));
165166
});
@@ -172,17 +173,28 @@ export class SyncManager {
172173
let itemsUpdated = 0;
173174

174175
for (const file of files) {
176+
this.logger.debug(`Syncing file: ${file.path}`);
177+
let content = null;
178+
179+
try {
180+
content = await this.github.getFileContent(owner, repo, file.path, this.config.branch);
181+
} catch (error) {
182+
// An error occured will retrieving file content, Return here
183+
this.logger.warn(`Failed to fetch content for ${file.path}: ${error}`);
184+
this.notifications.showSyncError(`Failed to fetch content for ${file.path}: ${error}. Make sure that the correct is set. Current branch: ${this.config.branch}`);
185+
return itemsUpdated;
186+
}
187+
175188
try {
176-
this.logger.debug(`Syncing file: ${file.path}`);
177-
178-
// Get file content from GitHub
179-
const content = await this.github.getFileContent(owner, repo, file.path, this.config.branch);
180-
181189
// Flatten the structure - extract just the filename and place directly in prompts directory
182190
const fileName = this.fileSystem.getBasename(file.path);
183191
const localPath = this.fileSystem.joinPath(promptsDir, fileName);
184192

185193
// Check if file needs updating
194+
if(!content) {
195+
this.logger.warn(`No content retrieved for ${file.path}, skipping`);
196+
continue;
197+
}
186198
const needsUpdate = await this.shouldUpdateFile(localPath, content);
187199

188200
if (needsUpdate) {
@@ -221,7 +233,7 @@ export class SyncManager {
221233

222234
// Filter relevant files
223235
const relevantFiles = this.filterRelevantFiles(tree.tree);
224-
236+
225237
if(relevantFiles.length === 0) {
226238
this.logger.warn(`No relevant files found to sync in ${repoUrl} based on current settings`);
227239
const promptLocation = `${REPO_SYNC_CHAT_MODE_PATH}, ${REPO_SYNC_INSTRUCTIONS_PATH}, ${REPO_SYNC_PROMPT_PATH}`;

src/utils/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class GitHubApiManager {
8888
if (!session) {
8989
throw new Error('GitHub authentication required');
9090
}
91-
91+
console.log(`Fetching file content from ${owner}/${repo}/${path} on branch ${branch}`);
9292
const response = await fetch(`${this.baseUrl}/repos/${owner}/${repo}/contents/${path}?ref=${branch}`, {
9393
headers: {
9494
'Authorization': `Bearer ${session.accessToken}`,

0 commit comments

Comments
 (0)