Skip to content

Commit

Permalink
Merge pull request #1 from HiDeoo/hd-init-extension
Browse files Browse the repository at this point in the history
Setup basic extension
  • Loading branch information
HiDeoo committed Sep 5, 2021
2 parents c3141a5 + 853d86b commit 5ac2f0d
Show file tree
Hide file tree
Showing 20 changed files with 2,151 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
43 changes: 43 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: integration

on: [push, pull_request]

jobs:
lint_and_test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
# Run on external PRs, but not on internal PRs as they'll be run by the push event to the branch.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn

- name: Lint
run: yarn lint

- name: Test
uses: GabrielBB/xvfb-action@v1.0
with:
run: yarn test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.vscode-test
yarn-error.log
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"semi": false,
"singleQuote": true
}
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions
{
"recommendations": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Test Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/dist/tests/run",
"--disable-extensions"
],
"outFiles": ["${workspaceFolder}/dist/tests/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://code.visualstudio.com/docs/getstarted/settings
{
"typescript.tsc.autoDetect": "off"
}
19 changes: 19 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// https://code.visualstudio.com/docs/editor/tasks#_custom-tasks
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "never"
}
}
]
}
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Typedown
# Typedown
59 changes: 59 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "typedown",
"version": "0.0.1",
"author": "HiDeoo",
"license": "MIT",
"engines": {
"vscode": "^1.60.0"
},
"activationEvents": [
"onCommand:typedown.tsToMd"
],
"contributes": {
"commands": [
{
"command": "typedown.tsToMd",
"title": "TypeScript to Markdown"
}
]
},
"main": "dist",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc -p .",
"watch": "tsc -w -p .",
"lint": "yarn lint:prettier && yarn lint:eslint",
"lint:prettier": "prettier --check .",
"lint:eslint": "eslint --max-warnings=0 --ext ts src",
"pretest": "yarn build",
"test": "node dist/tests",
"prepare": "husky install"
},
"devDependencies": {
"@types/glob": "7.1.4",
"@types/mocha": "9.0.0",
"@types/node": "14.17.4",
"@types/vscode": "1.60.0",
"@typescript-eslint/eslint-plugin": "4.30.0",
"@typescript-eslint/parser": "4.30.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"glob": "7.1.7",
"husky": "7.0.2",
"lint-staged": "11.1.2",
"mocha": "9.1.1",
"prettier": "2.3.2",
"rimraf": "3.0.2",
"typescript": "4.4.2",
"vscode-test": "1.6.1"
},
"lint-staged": {
"*.ts": "yarn lint:eslint",
"**/*": "prettier --write --ignore-unknown"
},
"resolutions": {
"@types/node": "14.17.4"
},
"repository": "https://github.com/HiDeoo/Typedown",
"private": true
}
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { commands, ExtensionContext, window } from 'vscode'

export function activate(context: ExtensionContext): void {
context.subscriptions.push(commands.registerCommand('typedown.tsToMd', tsToMd))
}

function tsToMd() {
window.showInformationMessage('Hello World from Typedown!')
}
7 changes: 7 additions & 0 deletions src/tests/extension.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import assert from 'assert'

describe('extension', () => {
it('test', () => {
assert.strictEqual(1, 1)
})
})
16 changes: 16 additions & 0 deletions src/tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import path from 'path'
import { runTests } from 'vscode-test'

async function main() {
try {
const extensionDevelopmentPath = path.resolve(__dirname, '../..')
const extensionTestsPath = path.resolve(__dirname, 'run')

await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: ['--disable-extensions'] })
} catch (err) {
console.error('Failed to run tests.')
process.exit(1)
}
}

main()
35 changes: 35 additions & 0 deletions src/tests/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import glob from 'glob'
import Mocha from 'mocha'
import path from 'path'

export function run(): Promise<void> {
return new Promise((resolve, reject) => {
const mocha = new Mocha({
ui: 'bdd',
color: true,
})

const testsRoot = path.resolve(__dirname, '..')

glob('**/**.test.js', { cwd: testsRoot }, (globError, files) => {
if (globError) {
return reject(globError)
}

files.forEach((file) => mocha.addFile(path.resolve(testsRoot, file)))

try {
mocha.run((failures) => {
if (failures > 0) {
reject(new Error(`${failures} tests failed.`))
} else {
resolve()
}
})
} catch (error) {
console.error(error)
reject(error)
}
})
})
}
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"target": "es6",
"module": "commonjs",
"lib": ["es6"],
"sourceMap": true,
"esModuleInterop": true,
"strict": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true
}
}

0 comments on commit 5ac2f0d

Please sign in to comment.