Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

feat: Add VSCode extension #22

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files.exclude": {
"**/.husky": true,
"**/.vscode": true,
".vscode": true,
"**/.yarn": true,
"**/coverage": true,
"**/dist": true,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@codecharacter-2022/client": "workspace:packages/client",
"@codecharacter-2022/extension": "workspace:packages/extension",
"@codecharacter-2022/map-designer": "workspace:packages/map-designer",
"@codecharacter-2022/renderer": "workspace:packages/renderer",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
Expand Down Expand Up @@ -133,7 +134,8 @@
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node"
"testEnvironment": "node",
"testRegex": "/__tests__/.*test.[jt]sx?$"
},
"lint-staged": {
"*.{ts,.tsx}": [
Expand Down
18 changes: 18 additions & 0 deletions packages/extension/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
}
4 changes: 4 additions & 0 deletions packages/extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vscode-test
dist
out
src/config/config.ts
5 changes: 5 additions & 0 deletions packages/extension/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"]
}
31 changes: 31 additions & 0 deletions packages/extension/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js",
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "tasks: watch-tests"
}
]
}
13 changes: 13 additions & 0 deletions packages/extension/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
37 changes: 37 additions & 0 deletions packages/extension/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"],
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "watch-tests",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never",
"group": "watchers"
},
"group": "build"
},
{
"label": "tasks: watch-tests",
"dependsOn": ["npm: watch", "npm: watch-tests"],
"problemMatcher": []
}
]
}
13 changes: 13 additions & 0 deletions packages/extension/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.vscode/**
.vscode-test/**
out/**
node_modules/**
src/**
.gitignore
.yarnrc
webpack.config.js
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
1 change: 1 addition & 0 deletions packages/extension/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
16 changes: 16 additions & 0 deletions packages/extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CodeCharacter 2022 VSCode Extension

An extension for VSCode that allows players to play CodeCharacter from the comfort of their IDE.

## Testing the extension locally

1. Open just the `packages/extension` folder in VSCode.
2. Run `yarn install`
3. Open the run panel from the left sidebar or do <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>D</kbd>
4. Click the run button or press <kbd>F5</kbd> to start the extension. (Wait for the webpack compilation to get over - might take a couple of minutes and refresh it)

In the extension:

1. The extension will be available in the last entry of the left sidebar.
2. Create and save some maps/source files.
3. Use files from [here](https://gist.github.com/CaptainIRS/9d8d162e2a7b7b62ae1ffa13b23a18fa) for testing renderer.
1 change: 1 addition & 0 deletions packages/extension/assets
66 changes: 66 additions & 0 deletions packages/extension/media/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 150 additions & 0 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"name": "@codecharacter-2022/extension",
"displayName": "CodeCharacter 2022",
"description": "An extension for simulating code for CodeCharacter 2022 locally",
"version": "2022.0.1",
"engines": {
"vscode": "^1.63.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onView:codecharacter-2022-codes"
],
"main": "./dist/extension.js",
"contributes": {
"commands": [
{
"command": "codecharacter-2022.helloWorld",
"title": "Hello World"
},
{
"command": "codecharacter-2022.addMapFile",
"title": "Add Map File",
"icon": "$(add)"
},
{
"command": "codecharacter-2022.deleteMapFile",
"title": "Delete Map File",
"icon": "$(trash)"
},
{
"command": "codecharacter-2022.runCode",
"title": "Run Code",
"icon": "media/icon.svg"
},
{
"command": "codecharacter-2022.deleteCodeFile",
"title": "Delete Code",
"icon": "$(trash)"
},
{
"command": "codecharacter-2022.addCodeFile",
"title": "Add Code",
"icon": "$(add)"
}
],
"viewsContainers": {
"activitybar": [
{
"id": "codecharacter-2022",
"title": "CodeCharacter 2022",
"icon": "media/icon.svg"
}
]
},
"menus": {
"editor/title": [
{
"command": "codecharacter-2022.runCode",
"group": "navigation",
"when": "resourceFilename =~ /\\.(c|cpp|js|py|java)$/ && resourcePath =~ /codes/ && editorFocus"
}
],
"view/title": [
{
"command": "codecharacter-2022.addMapFile",
"when": "view == codecharacter-2022-maps",
"group": "navigation"
}
],
"view/item/context": [
{
"command": "codecharacter-2022.deleteCodeFile",
"when": "view == codecharacter-2022-codes && viewItem == sourceFile",
"group": "inline"
},
{
"command": "codecharacter-2022.deleteMapFile",
"when": "view == codecharacter-2022-maps && viewItem == map",
"group": "inline"
},
{
"command": "codecharacter-2022.addCodeFile",
"when": "view == codecharacter-2022-codes && viewItem == sourceFolder",
"group": "inline"
}
]
},
"views": {
"codecharacter-2022": [
{
"id": "codecharacter-2022-codes",
"name": "Local Source Code Files",
"icon": "media/icons.svg",
"contextualTitle": "Source Code Files"
},
{
"id": "codecharacter-2022-maps",
"name": "Local Maps",
"icon": "media/icons.svg",
"contextualTitle": "Map Files"
}
]
},
"viewsWelcome": [
{
"view": "codecharacter-2022-codes",
"contents": "No local source file found.\n[Add Source File](command:codecharacter-2022.addSourceFile)"
},
{
"view": "codecharacter-2022-maps",
"contents": "No local map found.\n[Add Map File](command:codecharacter-2022.addMapFile)"
}
]
},
"scripts": {
"vscode:prepublish": "yarn run package",
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "yarn run compile-tests && yarn run compile && yarn run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.0.0",
"@types/node": "14.x",
"@types/rimraf": "^3.0.2",
"@types/vscode": "^1.63.0",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@vscode/test-electron": "^2.0.3",
"eslint": "^8.6.0",
"glob": "^7.2.0",
"mocha": "^9.1.3",
"ts-loader": "^9.2.6",
"typescript": "^4.5.4",
"webpack": "^5.66.0",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"@codecharacter-2022/map-designer": "workspace:^",
"@codecharacter-2022/renderer": "workspace:^",
"rimraf": "^3.0.2"
}
}
Loading