Compare commits

...

3 Commits

Author SHA1 Message Date
d9e44b78ce Merge pull request 'sorting-files' (#2) from sorting-files into main
Some checks failed
Release VSCode Extension / release (push) Failing after 1m22s
Reviewed-on: #2
2025-03-27 07:10:17 +00:00
4b38333d23 Release workflow 2025-03-27 07:08:29 +00:00
bea2ea2a0f Sort folders first then files 2025-03-27 06:28:16 +00:00
3 changed files with 101 additions and 3 deletions

View File

@@ -0,0 +1,84 @@
name: Release VSCode Extension
run-name: ${{ gitea.actor }} is releasing a new version 🚀
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
release:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
# Step 3: Install jq for JSON parsing
- name: Install jq
run: sudo apt-get install -y jq
# Step 4: Install project dependencies inside prompter directory
- name: Install dependencies
run: npm install
# Step 5: Install vsce globally
- name: Install vsce globally
run: npm install -g vsce
# Step 6: Install additional dev dependencies for building inside prompter directory
- name: Install build tools
run: npm install --save-dev webpack webpack-cli ts-loader
# Step 7: Build the extension inside prompter directory
- name: Build the extension
run: npm run webpack:prod
# Step 8: Package the extension into a VSIX file inside prompter directory
- name: Package the extension
run: vsce package
# Step 9: Extract the tag name from gitea.ref
- name: Extract tag name
run: |
TAG_NAME=$(echo "${{ gitea.ref }}" | sed 's/refs\/tags\///')
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
# Step 10: Determine the VSIX file name from package.json inside prompter directory
- name: Get VSIX file name
run: |
NAME=$(jq -r .name package.json)
VERSION=$(jq -r .version package.json)
VSIX_FILE="${NAME}-${VERSION}.vsix"
echo "VSIX_FILE=$VSIX_FILE" >> $GITHUB_ENV
# Step 11: Create a new release in Gitea
- name: Create release
run: |
curl -X POST \
-H "Authorization: token ${{ gitea.token }}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"Release $TAG_NAME\", \"body\": \"Automated release for version $TAG_NAME\"}" \
https://git.bhakat.dev/api/v1/repos/abhishekbhakat/Prompter/releases
# Step 12: Retrieve the release ID
- name: Get release ID
run: |
RELEASE_ID=$(curl -s -H "Authorization: token ${{ gitea.token }}" \
https://git.bhakat.dev/api/v1/repos/abhishekbhakat/Prompter/releases/tags/$TAG_NAME | jq .id)
echo "RELEASE_ID=$RELEASE_ID" >> $GITHUB_ENV
# Step 13: Upload the VSIX file as a release asset (from prompter directory)
- name: Upload VSIX to release
run: |
curl -X POST \
-H "Authorization: token ${{ gitea.token }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"prompter/$VSIX_FILE" \
https://git.bhakat.dev/api/v1/repos/abhishekbhakat/Prompter/releases/$RELEASE_ID/assets?name=$VSIX_FILE

View File

@@ -2,9 +2,9 @@
"name": "prompter", "name": "prompter",
"displayName": "Prompter", "displayName": "Prompter",
"description": "Easy prompt generation and apply edits using prompter.", "description": "Easy prompt generation and apply edits using prompter.",
"version": "0.0.1", "version": "0.0.2",
"publisher": "abhishekbhakat", "publisher": "abhishekbhakat",
"repository": "https://github.com/abhishekbhakat/prompter", "repository": "https://git.bhakat.dev/abhishekbhakat/Prompter",
"engines": { "engines": {
"vscode": "^1.98.0" "vscode": "^1.98.0"
}, },

View File

@@ -85,7 +85,21 @@ export class PrompterTreeProvider implements vscode.TreeDataProvider<FileTreeIte
try { try {
const files = await vscode.workspace.fs.readDirectory(vscode.Uri.file(dirPath)); const files = await vscode.workspace.fs.readDirectory(vscode.Uri.file(dirPath));
return files.map(([name, type]) => { // Sort by type first (directories first), then alphabetically by name
const sortedFiles = [...files].sort((a, b) => {
const [nameA, typeA] = a;
const [nameB, typeB] = b;
// If types are different, directories (type 2) come before files (type 1)
if (typeA !== typeB) {
return typeB - typeA; // Descending order by type puts directories first
}
// If types are the same, sort alphabetically by name
return nameA.localeCompare(nameB, undefined, { sensitivity: 'base' });
});
return sortedFiles.map(([name, type]) => {
const filePath = path.join(dirPath, name); const filePath = path.join(dirPath, name);
const uri = vscode.Uri.file(filePath); const uri = vscode.Uri.file(filePath);