Skip to content

Commit

Permalink
Divide the monolithic extension into modular extensions
Browse files Browse the repository at this point in the history
The below Extensions are created with this commit:

* qt-core
* qt-official
* qt-ui

qt-core

This extension is the core extension for the Qt extensions.
It provides the basic functionalities for the other extensions to work.

* It handles the communication between the other extensions.
* It provides the basic functionalities and common features for the other extensions.
* The all other extensions depend on this extension.

qt-ui

This extension provides the UI functionalities.

* It communicates with the `qt-core` extension to get information about the Qt Widget Designer.
* It provides syntax highlighting for `.ui` files.

qt-official

This extension has the rest of the previous monolithic extension functionalities.
It should be divided into more extensions in the future.

This commit implements:

* Common functionalities are moved from `qt-official` to `qt-core`.
* `qt-lib` is implemented as a npm module to gather the common code.
* Static analysis tools for every extension are added.
* Updated all `package.json` files to reflect the changes.
* `ci-scripts` is implemented to run the static analysis tools and tests.
* The `common` is created to gather the common code for tools.
* Extension packs are updated.
* The `ThirdPartyNotices.txt` files are generated for every extension.
* The `README.md` files are updated to reflect the changes.
* `.vscode/launch.json`, `.vscode/extensions.json`, and `.vscode/tasks.json` are updated.

Change-Id: Iac9b7e071275e92cdfbb3a47fba24d3ba8e41c89
Reviewed-by: Marcus Tillmanns <[email protected]>
Reviewed-by: Leena Miettinen <[email protected]>
  • Loading branch information
OrkunTokdemir committed Jul 18, 2024
1 parent 0324410 commit c45fc76
Show file tree
Hide file tree
Showing 157 changed files with 21,709 additions and 1,128 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,37 @@ name: Build on Linux
on: [push]

jobs:
build:
build_and_test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ci-scripts
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: "npm"
- run: npm ci
- run: npm run compile
- run: npm run ci-lint
# TODO: Enable unit tests
# - run: xvfb-run -a npm run unitTests
- run: npm run package
- name: Upload package
cache-dependency-path: "**/package-lock.json"
# qt-lib should be built first as it is a dependency for other packages
- run: npm run ci:qt-lib
- run: npm run compile:qt-lib
- run: npm run ci:all
- run: npm run compile:all
- run: npm run ci-lint:all
- run: npm run package:all
- name: Upload qt-official
uses: actions/upload-artifact@v4
with:
name: vsix_package
path: out/*.vsix
name: qt-official-vsix
path: qt-official/out/*.vsix
- name: Upload qt-core
uses: actions/upload-artifact@v4
with:
name: qt-core-vsix
path: qt-core/out/*.vsix
- name: Upload qt-ui
uses: actions/upload-artifact@v4
with:
name: qt-ui-vsix
path: qt-ui/out/*.vsix
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/out/
**/out/
dist
node_modules
/.vscode-test/
Expand Down
4 changes: 2 additions & 2 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Upstream-Name: Qt Extension for Visual Studio Code
Upstream-Contact: The Qt Company Ltd <https://www.qt.io/>
Source: https://github.com/qt-labs/vscodeext

Files: res/lang/qss/*.json
Files: qt-official/res/lang/qss/*.json
Copyright: 2024 The Qt Company Ltd.
License: MIT

Files: res/lang/qml/*.tmLanguage
Files: qt-official/res/lang/qml/*.tmLanguage
Copyright: 2016 Mads Kristensen
License: Apache-2.0
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "ms-vscode.cmake-tools"]
"recommendations": ["dbaeumer.vscode-eslint", "ms-vscode.vscode-typescript-next"]
}
28 changes: 17 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,29 @@
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"name": "Run qt-official Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: watch"
"args": ["--extensionDevelopmentPath=${workspaceFolder}/qt-official"],
"outFiles": ["${workspaceFolder}/qt-official/out/**/*.js"],
"preLaunchTask": "npm qt-official watch"
},
{
"name": "Extension Tests",
"name": "Run qt-core Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "npm: pretest"
"args": ["--extensionDevelopmentPath=${workspaceFolder}/qt-core"],
"outFiles": ["${workspaceFolder}/qt-core/out/**/*.js"],
"preLaunchTask": "npm qt-core watch"
},
{
"name": "Run qt-ui Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}/qt-ui"],
"outFiles": ["${workspaceFolder}/qt-ui/out/**/*.js"],
"cwd": "${workspaceFolder}/qt-ui",
"preLaunchTask": "npm: qt-ui watch"
}
]
}
47 changes: 34 additions & 13 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,55 @@
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"type": "shell",
"label": "npm qt-official watch",
"problemMatcher": "$tsc-watch",
"command": "npm run watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}/qt-official"
}
},
{
"type": "npm",
"script": "compile",
"problemMatcher": "$tsc",
"label": "npm: compile",
"detail": "tsc -p ./",
"type": "shell",
"label": "npm qt-core watch",
"problemMatcher": "$tsc-watch",
"command": "npm run watch",
"isBackground": true,
"presentation": {
"close": true
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}/qt-core"
}
},
{
"type": "npm",
"script": "pretest",
"problemMatcher": [],
"label": "npm: pretest",
"detail": "npm run compile && npm run lint"
"type": "shell",
"label": "npm: qt-ui watch",
"problemMatcher": "$tsc-watch",
"command": "npm run watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}/qt-ui"
}
}
]
}
54 changes: 12 additions & 42 deletions Development.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,30 @@
# Development Guide

## Build on the command line
## Note

- To install dependencies, run `npm ci`
- To compile, run `npm run compile`
All of the commands mentioned below should be run from the `ci-scripts` directory of the project.

## Running the extension from VS Code
## Build on the command line

* Press `F5` to open a new window with your extension loaded.
* You can relaunch the extension from the debug toolbar after changing code.
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load
your changes.
- Since the extension are dependent on `qt-lib`, it should be built first.
- To build `qt-lib`, run `npm run ci:qt-lib && npm run compile:qt-lib`
- To build other extensions, run `npm run ci:all && npm run compile:all`
- To build a specific extension, run `npm run ci:<extension_name> && npm run compile:<extension_name>`

## Pre-Commit

Before every commit, the following commands should be run:

- To trigger [Prettier](https://prettier.io/), run `npm run prettier`
- To trigger [ESLint](https://eslint.org/), run `npx eslint .` or to fix
automatically, run `npx eslint . --fix`

or

- To trigger [Prettier](https://prettier.io/), [ESLint](https://eslint.org/) and
build together, run `npm run pretest`
Before every commit, `npm run ci-lint:all` should be run.

## Package

- To generate installable package, run `npm run package`. This will generate a
`.vsix` file in the `out` folder.
- To generate installable packages, run `npm run package:all`. This will generate
`.vsix` files in the each extension's `out` directory.
- Also `npm run package:<extension_name>` can be used to generate the package for a specific extension.

## Install

- To install the package to vscode, run `code --install-extension <vsix file generated in the previous step>`

## Run tests on the command line

- To run unit tests, run `npm run unitTests`
- To run integration tests, run `npm run integrationTests -- --qt_path="<qt_installation>"`
- To run all tests, run `npm run allTests -- --qt_path="<qt_installation>"`

## Run tests from Visual Studio Code

* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration
dropdown pick `Extension Tests`.
* Press `F5` to run the tests in a new window with your extension loaded.
* See the output of the test result in the debug console.

## Further reading

* Explore the VS Code API by inspecting the file`node_modules/@types/vscode/index.d.ts`.
* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create
extensions that seamlessly integrate with VS Code's native interface and patterns.
- To install all the extensions, run `npm run install:all` or `npm run install:<extension_name>` to install a specific extension.

## Dependencies

- [npm](https://www.npmjs.com/)
- [Prettier](https://prettier.io/)
- [ESLint](https://eslint.org/)
1 change: 1 addition & 0 deletions ci-scripts/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.eslintrc.cjs
11 changes: 11 additions & 0 deletions ci-scripts/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-env node */
module.exports = {
extends: ['../common/.eslintrc.cjs'],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
project: 'tsconfig.json',
tsconfigRootDir: __dirname
}
};
Loading

0 comments on commit c45fc76

Please sign in to comment.