Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Use typescript except test codes (#17)
Browse files Browse the repository at this point in the history
* Install typescript dependencies

* Enable typescript for extensions

But ESM is restricted in microsoft/vscode#130367

* Fix merge miss

* Follow out dir in package.json

* Commit out dir

* Revert "Commit out dir"

This reverts commit e72912f.

* Transpile just before package

* Fix step position after npm ci
  • Loading branch information
kachick committed May 13, 2024
1 parent 2e960ba commit 70417fa
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
- name: Install dependencies
run: npm ci --ignore-scripts

- run: npx tsc

- name: Run dummy tests
run: xvfb-run -a npm test
continue-on-error: true
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
- name: Install dependencies
run: npm ci --ignore-scripts

- run: npx tsc

- name: Make sure to be possible to create package
run: npx vsce package --out 'yamlfmt.vsix'

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
.env
*.vsix
.direnv/
out
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ test/**
.yamlfmt
.yarnrc
CONTRIBUTING.md
**/jsconfig.json
**/tsconfig.json
**/*.map
dprint.json
deno.jsonc
**/*.sh
**.ts
12 changes: 6 additions & 6 deletions extension.js → extension.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const { spawnSync } = require("node:child_process");
const { dirname } = require("node:path");
const vscode = require("vscode");
import { spawnSync } from "node:child_process";
import { dirname } from "node:path";
import * as vscode from "vscode";

const yamlformattedLanguages = [
"yaml",
"github-actions-workflow", // Provided in https://github.com/github/vscode-github-actions
];
const provider = {
provideDocumentFormattingEdits(document) {
provideDocumentFormattingEdits(document: vscode.TextDocument) {
const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);
const config = vscode.workspace.getConfiguration("", document.uri);

const args = config.get("yamlfmt.args", []).filter(arg => arg !== "-in");
args.push("-in");
const baseArgs = config.get("yamlfmt.args", []).filter(arg => arg !== "-in");
const args = [...baseArgs, "-in"];

const result = spawnSync("yamlfmt", args, {
cwd: workspaceFolder ? workspaceFolder.uri.fsPath : dirname(document.uri.fsPath),
Expand Down
13 changes: 0 additions & 13 deletions jsconfig.json

This file was deleted.

143 changes: 126 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"onLanguage:yaml",
"onLanguage:github-actions-workflow"
],
"main": "./extension.js",
"main": "./out/extension.js",
"contributes": {
"configuration": {
"title": "yamlfmt",
Expand All @@ -49,10 +49,14 @@
},
"devDependencies": {
"@types/mocha": "^10.0.6",
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"@types/node": "^20.12.11",
"@types/vscode": "^1.89.0",
"@vscode/test-electron": "^2.3.9",
"@vscode/vsce": "^2.26.1",
"mocha": "^10.2.0"
"mocha": "^10.2.0",
"tsx": "^4.9.3",
"typescript": "^5.4.5"
}
}
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": ["@tsconfig/strictest/tsconfig", "@tsconfig/node20/tsconfig"],
"compilerOptions": {
"outDir": "out",
"noUnusedLocals": false
},
"include": ["**/*.ts"]
}

0 comments on commit 70417fa

Please sign in to comment.