Skip to content

Commit

Permalink
feat: set up skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Dec 2, 2019
1 parent 4a2a48f commit df4bc87
Show file tree
Hide file tree
Showing 22 changed files with 802 additions and 88 deletions.
11 changes: 2 additions & 9 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ module.exports = function(api) {
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-runtime',
]
const presets = [
[
'@babel/preset-env',
api.env('es5')
? { forceAllTransforms: true }
: { targets: { node: 'current' } },
],
['@babel/preset-env', { targets: { node: 10 } }],
'@babel/preset-typescript',
]

if (api.env(['test', 'coverage', 'es5'])) {
plugins.push('@babel/plugin-transform-runtime')
}
if (api.env('coverage')) {
plugins.push('babel-plugin-istanbul')
}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
coverage
.nyc_output
.vscode-test/
node_modules
es
out
.eslintcache
/*.js
/*.js.flow
/*.d.ts
!/.babelrc.js
*.vsix
12 changes: 0 additions & 12 deletions .npmignore

This file was deleted.

5 changes: 5 additions & 0 deletions .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": ["ms-vscode.vscode-typescript-tslint-plugin"]
}
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
10 changes: 10 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.vscode/**
.vscode-test/**
out/test/
**src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/tslint.json
**/*.map
**/*.ts
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# typescript-library-skeleton
# vscode-extension-skeleton

[![CircleCI](https://circleci.com/gh/jedwards1211/typescript-library-skeleton.svg?style=svg)](https://circleci.com/gh/jedwards1211/typescript-library-skeleton)
[![Coverage Status](https://codecov.io/gh/jedwards1211/typescript-library-skeleton/branch/master/graph/badge.svg)](https://codecov.io/gh/jedwards1211/typescript-library-skeleton)
[![CircleCI](https://circleci.com/gh/jedwards1211/vscode-extension-skeleton.svg?style=svg)](https://circleci.com/gh/jedwards1211/vscode-extension-skeleton)
[![Coverage Status](https://codecov.io/gh/jedwards1211/vscode-extension-skeleton/branch/master/graph/badge.svg)](https://codecov.io/gh/jedwards1211/vscode-extension-skeleton)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![npm version](https://badge.fury.io/js/typescript-library-skeleton.svg)](https://badge.fury.io/js/typescript-library-skeleton)
[![npm version](https://badge.fury.io/js/vscode-extension-skeleton.svg)](https://badge.fury.io/js/vscode-extension-skeleton)

This is my personal skeleton for creating an typescript library npm package. You are welcome to use it.
my personal skeleton for a VSCode extension

## Quick start

```sh
npx 0-60 clone https://github.com/jedwards1211/typescript-library-skeleton.git
npx 0-60 clone https://github.com/jedwards1211/vscode-extension-skeleton.git
```

## Tools used
Expand Down
84 changes: 61 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,62 @@
{
"name": "typescript-library-skeleton",
"name": "vscode-extension-skeleton",
"version": "0.0.0-development",
"description": "my personal ES2015 library project skeleton",
"main": "index.js",
"sideEffects": false,
"displayName": "Dude, Where's My Module?",
"description": "my personal skeleton for a VSCode extension",
"engines": {
"vscode": "^1.40.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.helloWorld"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "extension.helloWorld",
"title": "Hello World"
}
]
},
"scripts": {
"lint": "eslint $npm_package_config_lint",
"lint:fix": "eslint $npm_package_config_lint",
"lint:watch": "esw --watch $npm_package_config_lint",
"prettier": "prettier --write .babelrc.js *.json *.md *.ts '{src,test}/**/*.{js,ts}'",
"prettier:check": "prettier --list-different .babelrc.js *.json *.md *.ts '{src,test}/**/*.{js,ts}'",
"tsc": "tsc --noEmit",
"tsc:watch": "npm run tsc -- --watch",
"clean": "rimraf es lib $(cd src; ls) *.js *.d.ts",
"build": "npm run clean && npm run build:types && npm run build:js",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir es --extensions \".ts\" --source-maps inline && cross-env BABEL_ENV=es5 babel src --out-dir . --extensions \".ts\"",
"test": "cross-env NODE_ENV=test BABEL_ENV=es5 mocha $npm_package_config_mocha && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --reporter=text mocha $npm_package_config_mocha",
"test:watch": "cross-env NODE_ENV=test BABEL_ENV=test mocha $npm_package_config_mocha --watch --watch-extensions js,ts",
"test:debug": "cross-env NODE_ENV=test BABEL_ENV=test mocha --inspect-brk $npm_package_config_mocha",
"prettier": "prettier --write .babelrc.js *.json *.md *.ts 'src/**/*.{js,ts}'",
"prettier:check": "prettier --list-different .babelrc.js *.json *.md *.ts 'src/**/*.{js,ts}'",
"tsc": "tsc -p ./",
"tsc:watch": "tsc -watch -p ./",
"clean": "rimraf out",
"build": "babel src --out-dir out --extensions \".js,.ts\"",
"pretest": "BABEL_ENV=coverage npm run build",
"test": "node ./out/test/runTest.js; nyc report; nyc report --reporter=lcov",
"codecov": "nyc report --reporter=text-lcov > coverage.lcov; codecov",
"prepublishOnly": "npm run clean && npm run prettier:check && npm run lint && npm test && npm run build",
"vscode:prepublish": "npm run clean && npm run prettier:check && npm run lint && npm test && npm run build",
"open:coverage": "open coverage/lcov-report/index.html",
"semantic-release": "semantic-release"
},
"release": {
"verifyConditions": [
"semantic-release-vsce",
"@semantic-release/github"
],
"prepare": {
"path": "semantic-release-vsce",
"packageVsix": "your-extension.vsix"
},
"publish": [
"semantic-release-vsce",
{
"path": "@semantic-release/github",
"assets": "your-extension.vsix"
}
]
},
"config": {
"lint": "--cache --ext .js,.ts src test",
"mocha": "test/configure.js 'src/**/*.spec.ts'",
"lint": "--cache --ext .js,.ts src",
"commitizen": {
"path": "cz-conventional-changelog"
}
Expand Down Expand Up @@ -69,20 +99,22 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jedwards1211/typescript-library-skeleton.git"
"url": "https://github.com/jedwards1211/vscode-extension-skeleton.git"
},
"keywords": [
"typescript"
"vscode",
"extension"
],
"author": "Andy Edwards",
"license": "MIT",
"bugs": {
"url": "https://github.com/jedwards1211/typescript-library-skeleton/issues"
"url": "https://github.com/jedwards1211/vscode-extension-skeleton/issues"
},
"homepage": "https://github.com/jedwards1211/typescript-library-skeleton#readme",
"homepage": "https://github.com/jedwards1211/vscode-extension-skeleton#readme",
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/node": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
Expand All @@ -97,8 +129,10 @@
"@jedwards1211/commitlint-config": "^1.0.0",
"@jedwards1211/eslint-config": "^2.0.0",
"@types/chai": "^4.2.0",
"@types/glob": "^7.1.1",
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.6",
"@types/vscode": "^1.40.0",
"@typescript-eslint/eslint-plugin": "^2.6.1",
"@typescript-eslint/parser": "^2.6.1",
"@typescript-eslint/typescript-estree": "^2.6.1",
Expand All @@ -111,6 +145,8 @@
"eslint": "^5.9.0",
"eslint-config-prettier": "^3.3.0",
"eslint-watch": "^4.0.2",
"fs-extra": "^8.1.0",
"glob": "^7.1.6",
"husky": "^1.1.4",
"istanbul": "^0.4.5",
"lint-staged": "^8.0.4",
Expand All @@ -120,7 +156,9 @@
"prettier-eslint": "^8.8.2",
"rimraf": "^2.6.0",
"semantic-release": "^15.1.4",
"typescript": "^3.7.2"
"semantic-release-vsce": "^2.2.8",
"typescript": "^3.7.2",
"vscode-test": "^1.2.3"
},
"dependencies": {
"@babel/runtime": "^7.1.5"
Expand Down
33 changes: 33 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode'

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext): void {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
/* eslint-disable no-console */
console.log(
'Congratulations, your extension "vscode-dude-wheres-my-module" is now active!'
)
/* eslint-enable no-console */

// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
const disposable = vscode.commands.registerCommand(
'extension.helloWorld',
() => {
// The code you place here will be executed every time your command is executed

// Display a message box to the user
vscode.window.showInformationMessage('Hello World!')
}
)

context.subscriptions.push(disposable)
}

// this method is called when your extension is deactivated
export function deactivate(): void {} // eslint-disable-line @typescript-eslint/no-empty-function
5 changes: 0 additions & 5 deletions src/index.spec.ts

This file was deleted.

Empty file removed src/index.ts
Empty file.
26 changes: 26 additions & 0 deletions src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as path from 'path'

import { runTests } from 'vscode-test'

async function main(): Promise<void> {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../')

// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index')

// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
})
} catch (err) {
console.error('Failed to run tests') // eslint-disable-line no-console
process.exit(1)
}
}

main()
11 changes: 11 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode'

suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.')

test('extension.helloWorld command', async function() {
await vscode.commands.executeCommand('extension.helloWorld')
})
})

0 comments on commit df4bc87

Please sign in to comment.