Skip to content

Commit 18db3da

Browse files
feat: add T-SQL formatter extension with profile management and forma… (#1)
* feat: add T-SQL formatter extension with profile management and formatting features - Implemented core formatting logic for T-SQL in `src/formatter/engine.ts`. - Added extension activation and command registration in `src/extension.ts`. - Created profile management functions for saving, loading, exporting, and importing profiles in `src/profiles/profileManager.ts`. - Added SQL sample query for testing in `samples/sample.sql`. - Developed unit tests for formatter functionality in `src/test/formatter.test.ts` and `src/test/formatter.vitest.ts`. - Configured TypeScript settings in `tsconfig.json` and Vitest configuration in `vitest.config.ts`. - Updated extension documentation in `vsc-extension-quickstart.md`. * feat: update CI configuration, enhance profile management, and improve formatting options * Update src/formatter/engine.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/profiles/profileManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/test/formatter.vitest.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/profiles/profileManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/formatter/engine.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/formatter/engine.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: update Node.js version in CI configuration and bump package version to 0.1.0 * fix: streamline alias handling and improve comma placement logic in T-SQL formatting * fix: update default file name format for exported profiles * ci: enable manual workflow_dispatch trigger * fix: add error handling for profile export and import functions * fix: remove unnecessary workflow triggers from CI configuration * fix: add Xvfb installation and update e2e test steps for Linux compatibility * fix: enhance Linux testing setup and update package dependencies test(ci): add vitest v8 coverage provider and use npm coverage script * fix: update Node.js version matrix and VSCode engine compatibility * fix: update Node.js and VSCode version requirements in configuration files * fix: enhance CI configuration for Linux testing and update test command * fix: update coverage report configuration to include JSON and LCOV formats * fix: refine coverage configuration comments for clarity and consistency --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5d597f2 commit 18db3da

34 files changed

+9273
-0
lines changed

.github/copilot-instructions.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->
2+
- [ ] Verify that the copilot-instructions.md file in the .github directory is created.
3+
4+
- [ ] Clarify Project Requirements
5+
<!-- Ask for project type, language, and frameworks if not specified. Skip if already provided. -->
6+
7+
- [ ] Scaffold the Project
8+
<!--
9+
Ensure that the previous step has been marked as completed.
10+
Call project setup tool with projectType parameter.
11+
Run scaffolding command to create project files and folders.
12+
Use '.' as the working directory.
13+
If no appropriate projectType is available, search documentation using available tools.
14+
Otherwise, create the project structure manually using available file creation tools.
15+
-->
16+
17+
- [ ] Customize the Project
18+
<!--
19+
Verify that all previous steps have been completed successfully and you have marked the step as completed.
20+
Develop a plan to modify codebase according to user requirements.
21+
Apply modifications using appropriate tools and user-provided references.
22+
Skip this step for "Hello World" projects.
23+
-->
24+
25+
- [ ] Install Required Extensions
26+
<!-- ONLY install extensions provided mentioned in the get_project_setup_info. Skip this step otherwise and mark as completed. -->
27+
28+
- [ ] Compile the Project
29+
<!--
30+
Verify that all previous steps have been completed.
31+
Install any missing dependencies.
32+
Run diagnostics and resolve any issues.
33+
Check for markdown files in project folder for relevant instructions on how to do this.
34+
-->
35+
36+
- [ ] Create and Run Task
37+
<!--
38+
Verify that all previous steps have been completed.
39+
Check https://code.visualstudio.com/docs/debugtest/tasks to determine if the project needs a task. If so, use the create_and_run_task to create and launch a task based on package.json, README.md, and project structure.
40+
Skip this step otherwise.
41+
-->
42+
43+
- [ ] Launch the Project
44+
<!--
45+
Verify that all previous steps have been completed.
46+
Prompt user for debug mode, launch only if confirmed.
47+
-->
48+
49+
- [ ] Ensure Documentation is Complete
50+
<!--
51+
Verify that all previous steps have been completed.
52+
Verify that README.md and the copilot-instructions.md file in the .github directory exists and contains current project information.
53+
Clean up the copilot-instructions.md file in the .github directory by removing all HTML comments.
54+
-->
55+
56+
<!--
57+
## Execution Guidelines
58+
PROGRESS TRACKING:
59+
- If any tools are available to manage the above todo list, use it to track progress through this checklist.
60+
- After completing each step, mark it complete and add a summary.
61+
- Read current todo list status before starting each new step.
62+
63+
COMMUNICATION RULES:
64+
- Avoid verbose explanations or printing full command outputs.
65+
- If a step is skipped, state that briefly (e.g. "No extensions needed").
66+
- Do not explain project structure unless asked.
67+
- Keep explanations concise and focused.
68+
69+
DEVELOPMENT RULES:
70+
- Use '.' as the working directory unless user specifies otherwise.
71+
- Avoid adding media or external links unless explicitly requested.
72+
- Use placeholders only with a note that they should be replaced.
73+
- Use VS Code API tool only for VS Code extension projects.
74+
- Once the project is created, it is already opened in Visual Studio Code—do not suggest commands to open this project in Visual Studio again.
75+
- If the project setup information has additional rules, follow them strictly.
76+
77+
FOLDER CREATION RULES:
78+
- Always use the current directory as the project root.
79+
- If you are running any terminal commands, use the '.' argument to ensure that the current working directory is used ALWAYS.
80+
- Do not create a new folder unless the user explicitly requests it besides a .vscode folder for a tasks.json file.
81+
- If any of the scaffolding commands mention that the folder name is not correct, let the user know to create a new folder with the correct name and then reopen it again in vscode.
82+
83+
EXTENSION INSTALLATION RULES:
84+
- Only install extension specified by the get_project_setup_info tool. DO NOT INSTALL any other extensions.
85+
86+
PROJECT CONTENT RULES:
87+
- If the user has not specified project details, assume they want a "Hello World" project as a starting point.
88+
- Avoid adding links of any type (URLs, files, folders, etc.) or integrations that are not explicitly required.
89+
- Avoid generating images, videos, or any other media files unless explicitly requested.
90+
- If you need to use any media assets as placeholders, let the user know that these are placeholders and should be replaced with the actual assets later.
91+
- Ensure all generated components serve a clear purpose within the user's requested workflow.
92+
- If a feature is assumed but not confirmed, prompt the user for clarification before including it.
93+
- If you are working on a VS Code extension, use the VS Code API tool with a query to find relevant VS Code API references and samples related to that query.
94+
95+
TASK COMPLETION RULES:
96+
- Your task is complete when:
97+
- Project is successfully scaffolded and compiled without errors
98+
- copilot-instructions.md file in the .github directory exists in the project
99+
- README.md file exists and is up to date
100+
- User is provided with clear instructions to debug/launch the project
101+
102+
Before starting a new task in the above plan, update progress in the plan.
103+
-->
104+
- Work through each checklist item systematically.
105+
- Keep communication concise and focused.
106+
- Follow development best practices.

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: ['20', '22', '24']
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: npm
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Lint
29+
run: npm run lint --if-present
30+
31+
- name: Build
32+
run: npm run compile --if-present
33+
34+
- name: Test (unit)
35+
run: npm run test:unit --if-present
36+
37+
- name: Install Xvfb (Linux)
38+
if: runner.os == 'Linux'
39+
run: sudo apt-get update && sudo apt-get install -y xvfb
40+
41+
- name: Test (e2e, Linux headless)
42+
if: runner.os == 'Linux'
43+
env:
44+
DISPLAY: ":99"
45+
DBUS_SESSION_BUS_ADDRESS: "/dev/null"
46+
ELECTRON_DISABLE_GPU: 1
47+
LIBGL_ALWAYS_SOFTWARE: 1
48+
run: xvfb-run -a -s "-screen 0 1280x1024x24" npm test --if-present
49+
50+
- name: Test (e2e, non-Linux)
51+
if: runner.os != 'Linux'
52+
run: npm test --if-present
53+
54+
- name: Coverage (Vitest)
55+
run: npm run coverage --if-present
56+
57+
- name: Upload coverage to Codecov
58+
uses: codecov/codecov-action@v4
59+
with:
60+
files: ./coverage/lcov.info,./coverage/coverage-final.json
61+
fail_ci_if_error: true
62+
verbose: true

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
out
2+
dist
3+
node_modules
4+
.vscode-test/
5+
*.vsix
6+
7+
# Test artifacts
8+
coverage/
9+
vitest-report.xml
10+
.vscode-test-data/

.vscode-test.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from '@vscode/test-cli';
2+
3+
export default defineConfig({
4+
files: 'out/test/**/*.test.js',
5+
});

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"]
5+
}

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}"
14+
],
15+
"outFiles": [
16+
"${workspaceFolder}/dist/**/*.js"
17+
],
18+
"preLaunchTask": "compile"
19+
}
20+
]
21+
}

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": false, // set this to true to hide the "out" folder with the compiled JS files
5+
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
6+
},
7+
"search.exclude": {
8+
"out": true, // set this to false to include "out" folder in search results
9+
"dist": true // set this to false to include "dist" folder in search results
10+
},
11+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
12+
"typescript.tsc.autoDetect": "off"
13+
}

.vscode/tasks.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "compile",
9+
"label": "compile",
10+
"group": "build",
11+
"problemMatcher": []
12+
},
13+
{
14+
"label": "watch",
15+
"dependsOn": [
16+
"npm: watch:tsc",
17+
"npm: watch:esbuild"
18+
],
19+
"presentation": {
20+
"reveal": "never"
21+
},
22+
"group": {
23+
"kind": "build",
24+
"isDefault": true
25+
}
26+
},
27+
{
28+
"type": "npm",
29+
"script": "watch:esbuild",
30+
"group": "build",
31+
"problemMatcher": [],
32+
"isBackground": true,
33+
"label": "npm: watch:esbuild",
34+
"presentation": {
35+
"group": "watch",
36+
"reveal": "never"
37+
}
38+
},
39+
{
40+
"type": "npm",
41+
"script": "watch:tsc",
42+
"group": "build",
43+
"problemMatcher": "$tsc-watch",
44+
"isBackground": true,
45+
"label": "npm: watch:tsc",
46+
"presentation": {
47+
"group": "watch",
48+
"reveal": "never"
49+
}
50+
},
51+
{
52+
"type": "npm",
53+
"script": "watch-tests",
54+
"problemMatcher": "$tsc-watch",
55+
"isBackground": true,
56+
"presentation": {
57+
"reveal": "never",
58+
"group": "watchers"
59+
},
60+
"group": "build"
61+
},
62+
{
63+
"label": "tasks: watch-tests",
64+
"dependsOn": [
65+
"npm: watch",
66+
"npm: watch-tests"
67+
],
68+
"problemMatcher": []
69+
}
70+
]
71+
}

.vscodeignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.vscode/**
2+
.vscode-test/**
3+
out/**
4+
node_modules/**
5+
src/**
6+
.gitignore
7+
.yarnrc
8+
esbuild.js
9+
vsc-extension-quickstart.md
10+
**/tsconfig.json
11+
**/eslint.config.mjs
12+
**/*.map
13+
**/*.ts
14+
**/.vscode-test.*

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
All notable changes to the "tsqlformatter" extension will be documented in this file.
4+
5+
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6+
7+
## [Unreleased]
8+
9+
- Initial release

0 commit comments

Comments
 (0)