Skip to content
Merged
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
Binary file added .DS_Store
Binary file not shown.
5 changes: 0 additions & 5 deletions .editorconfig

This file was deleted.

3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set default behavior to automatically normalize line endings.
* text=auto

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage
out
node_modules
.vscode-test
coverage/
.vscode-test/
*.vsix
15 changes: 15 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"parser": "typescript",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve"
}
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo: false
language: node_js
cache: yarn
cache: npm
node_js:
- '8'
os:
Expand All @@ -9,8 +9,8 @@ before_install:
- if [ $TRAVIS_OS_NAME == "linux" ]; then export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0;
sh -e /etc/init.d/xvfb start; sleep 3; fi
install:
- yarn
- yarn vscode:prepublish
- npm install
- npm run vscode:prepublish
script:
- yarn test:coverage
- npm run test
- node_modules/.bin/coveralls < coverage/lcov.info;
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"eg2.tslint"
]
}
87 changes: 50 additions & 37 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
// 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.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/src/**/*.js"],
"preLaunchTask": "build"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/test/**/*.js"],
"preLaunchTask": "build"
},
{
"name": "Launch Code Coverage",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/test/**/*.js"],
"preLaunchTask": "coverage"
}
]
}
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--runInBand"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--debug"
],
"env": {
"DEBUG": "true"
},
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
}
17 changes: 8 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +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
},
"typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version
"tslint.configFile": "./tslint.json",
"lcov.path": ["coverage/lcov.info"]
"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"
}
36 changes: 19 additions & 17 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "npm",
"script": "build",
"problemMatcher": "$tsc-watch",
"isBackground": true
},
{
"label": "coverage",
"type": "npm",
"script": "coverage",
"problemMatcher": "$tsc"
}
]
// 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
}
}
]
}
18 changes: 9 additions & 9 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.vscode/**
.vscode-test/**
typings/**
out/test/**
test/**
src/**
**/*.map
.gitignore
tsconfig.json
.vscode/**
.vscode-test/**
out/test/**
out/**/*.map
src/**
.gitignore
tsconfig.json
vsc-extension-quickstart.md
tslint.json
78 changes: 78 additions & 0 deletions __mocks__/@octokit/rest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// tslint:disable:no-any no-unsafe-any
jest.genMockFromModule<object>('@octokit/rest');

const gistsResponseData = [
{
created_at: new Date().toString(),
description: 'gist one',
files: {
'one.md': {
filename: 'one.md',
language: 'markdown',
raw_url: 'https://foo.bar/api/test123/1',
size: '11111',
type: 'text'
},
'two.md': {
filename: 'two.md',
language: 'markdown',
raw_url: 'https://foo.bar/api/test123/2',
size: '22222',
type: 'text'
}
},
id: 'test123',
updated_at: new Date().toString()
},
{
created_at: new Date().toString(),
description: 'gist two',
files: {
'one.md': {
filename: 'one.md',
language: 'markdown',
raw_url: 'https://foo.bar/api/test123/1',
size: '11111',
type: 'text'
},
'two.md': {
filename: 'two.md',
language: 'markdown',
raw_url: 'https://foo.bar/api/test123/2',
size: '22222',
type: 'text'
}
},
id: 'test123',
updated_at: new Date().toString()
}
];

const gistsResponse = (): Promise<any> =>
Promise.resolve({
data: gistsResponseData
});

const mockedGists = {
edit: jest.fn((options) =>
Promise.resolve({
data: {
...gistsResponseData[0],
files: {
...gistsResponseData[0].files,
...options.files
},
id: options.gist_id || gistsResponseData[0].id
}
})
),
get: jest.fn((options) =>
Promise.resolve({
data: { ...gistsResponseData[0], id: options.gist_id }
})
),
getAll: jest.fn(gistsResponse),
getStarred: jest.fn(gistsResponse)
};

module.exports = jest.fn(() => ({ gists: mockedGists }));
3 changes: 3 additions & 0 deletions __mocks__/fs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
writeFileSync: jest.fn()
};
6 changes: 6 additions & 0 deletions __mocks__/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// tslint:disable:no-any no-unsafe-any
module.exports = {
dirname: jest.fn((input) => input),
join: jest.fn((...paths) => ['var', 'T', 'tmp', ...paths].join('/')),
sep: '/'
};
11 changes: 11 additions & 0 deletions __mocks__/tmp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// tslint:disable:no-any ban no-magic-numbers no-unsafe-any
const randomString = (): string =>
Math.random()
.toString(36)
.substring(7);

module.exports = {
dirSync: jest.fn(
(input: any): any => ({ name: `${input.prefix}${randomString()}` })
)
};
7 changes: 7 additions & 0 deletions __mocks__/vscode-extension-telemetry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// tslint:disable:no-any no-unsafe-any
const mockedImplementation = {
sendTelemetryEvent: jest.fn()
};

// tslint:disable-next-line:no-default-export
export default jest.fn(() => mockedImplementation);
21 changes: 21 additions & 0 deletions __mocks__/vscode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// tslint:disable:no-any
module.exports = {
commands: {
executeCommand: jest.fn()
},
env: {
language: 'en-US'
},
extensions: {
getExtension: jest.fn(() => '1.0.0')
},
window: {
showErrorMessage: jest.fn(),
showInformationMessage: jest.fn(),
showQuickPick: jest.fn(),
showTextDocument: jest.fn()
},
workspace: {
openTextDocument: jest.fn()
}
};
7 changes: 0 additions & 7 deletions coverconfig.json

This file was deleted.

Loading