Skip to content

Commit

Permalink
VSCode Extension Skeleton - Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thels committed Nov 11, 2024
1 parent e806e6b commit b0e0a8b
Show file tree
Hide file tree
Showing 18 changed files with 10,711 additions and 215 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/calm-vscode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CALM VSCode Extension

on:
pull_request:
branches:
- "main"
paths:
- "plugins/calm-vscode/**"
push:
branches:
- "main"
paths:
- "plugins/calm-vscode/**"

defaults:
run:
working-directory: ./plugins/calm-vscode

jobs:
calm-vscode-extension-tests:
name: Run unit tests and lint on the calm-vscode module.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: v20
- run: npm ci
- run: npm run test
16 changes: 15 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,19 @@
"clearOnRun": "none"
},
"java.compile.nullAnalysis.mode": "automatic",
"java.configuration.updateBuildConfiguration": "automatic"
"java.configuration.updateBuildConfiguration": "automatic",
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/out": true,
"**/bower_components": true,
"**/*.code-search": true
},
"typescript.tsc.autoDetect": "off",
"workbench.tree.indent": 20,
"eslint.workingDirectories": [
"./plugins/calm-vscode",
"./cli",
"./shared"
]
}
39 changes: 39 additions & 0 deletions plugins/calm-vscode/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"env": {
"browser": true,
"es2021": true
},
"ignorePatterns": ["out/", ".vscode-test/"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
5 changes: 5 additions & 0 deletions plugins/calm-vscode/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
});
11 changes: 11 additions & 0 deletions plugins/calm-vscode/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.vscode/**
.vscode-test/**
src/**
.gitignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/eslint.config.mjs
**/*.map
**/*.ts
**/.vscode-test.*
9 changes: 9 additions & 0 deletions plugins/calm-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Change Log

All notable changes to the "calm-vscode" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Ability to validate a CALM document when saving with the extension loaded.
36 changes: 36 additions & 0 deletions plugins/calm-vscode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# calm-vscode

## Commands Added

* `calm-vscode.validate` - Automatically validate any CALM file that we're within. This will run on save and trigger the

## CALM File Detection

Right now the CALM file detection is incredibly rudamentary. It assumes that you're within one of the following;

* Pattern
* Instansiation of a Pattern

This logic will need to be revisisted once [#490](https://github.com/finos/architecture-as-code/issues/490) is tackled.

## Developing for the Extension Locally

Steps are given under the assumption that you're using VSCode.

* Clone down the repository.
* Open the project within VSCode, the `settings.json` / `launch.json` should cover you for what is required.
* Currently `plugins/calm-vscode` depends on other modules internally, so go to shared and run `npm install && npm run watch`.
* `ctrl+shift+d` - select `Run Extension` and hit `F5` to launch a test IDE with the in-development IDE.

### Caveats

#### JSON Formatting

We're using `spectral` and `ajxvs` for JSON schema validation and external rule validation - this applies some formatting when performing validation so line numbers don't always align with the file that is open.

To get around this - before the `validate` command is executed it will first format the document. If we can determine how to stop `spectral` and `ajvxs` from behaving this way we can remove this limitation.

## Known Issues

* Currently validation is only triggered upon saving, this could be improved massively.
* CALM file validation needs to be refactored once the issue mentioned above is addressed.
Loading

0 comments on commit b0e0a8b

Please sign in to comment.