-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a548e9e
Showing
26 changed files
with
6,909 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[*] | ||
insert_final_newline = true | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{json,js,yml}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
coverage/ | ||
.nyc_output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package.json | ||
package-lock.json | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
language: node_js | ||
node_js: '10' | ||
cache: yarn | ||
env: | ||
global: | ||
- FORCE_COLOR=1 | ||
install: | ||
- yarn | ||
jobs: | ||
include: | ||
- stage: test | ||
script: | ||
- yarn run prettier-check | ||
- yarn run tslint | ||
- yarn run build | ||
- yarn test | ||
- nyc report --reporter json | ||
- 'bash <(curl -s https://codecov.io/bash)' | ||
- stage: release | ||
script: | ||
- yarn run build | ||
- yarn run semantic-release | ||
stages: | ||
- test | ||
- name: release | ||
if: branch = master AND type = push AND fork = false | ||
branches: | ||
only: | ||
- master | ||
- /^renovate\// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Sourcegraph | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# @sourcegraph/extension-api-classes | ||
|
||
[](https://www.npmjs.com/package/@sourcegraph/extension-api-classes) | ||
[](https://www.npmjs.com/package/@sourcegraph/extension-api-classes) | ||
[](https://travis-ci.org/sourcegraph/extension-api-classes) | ||
[](https://codecov.io/gh/sourcegraph/extension-api-classes) | ||
[](https://github.com/prettier/prettier) | ||
[](https://github.com/semantic-release/semantic-release) | ||
|
||
Classes used by the Sourcegraph extension API | ||
|
||
## Install | ||
|
||
``` | ||
npm install @sourcegraph/extension-api-classes | ||
# or | ||
yarn add @sourcegraph/extension-api-classes | ||
``` | ||
|
||
## Build | ||
|
||
``` | ||
yarn | ||
yarn build | ||
``` | ||
|
||
## Test | ||
|
||
``` | ||
yarn test | ||
``` | ||
|
||
## Release | ||
|
||
Releases are done automatically in CI when commits are merged into master by analyzing [Conventional Commit Messages](https://conventionalcommits.org/). | ||
After running `yarn`, commit messages will be linted automatically when committing though a git hook. | ||
The git hook can be circumvented for fixup commits with [git's `fixup!` autosquash feature](https://fle.github.io/git-tip-keep-your-branch-clean-with-fixup-and-autosquash.html), or by passing `--no-verify` to `git commit`. | ||
You may have to rebase a branch before merging to ensure it has a proper commit history, or squash merge with a manually edited commit message that conforms to the convention. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"name": "@sourcegraph/extension-api-classes", | ||
"description": "Classes used by the Sourcegraph extension API", | ||
"version": "0.0.0-DEVELOPMENT", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/sourcegraph/extension-api-classes.git" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"test": "nyc mocha", | ||
"semantic-release": "semantic-release", | ||
"prettier": "prettier '**/{*.{js?(on),ts?(x),scss},.*.js?(on)}' --write --list-different", | ||
"prettier-check": "npm run prettier -- --write=false", | ||
"tslint": "tslint -c tslint.json -p tsconfig.json './src/*.ts?(x)' './*.ts?(x)'", | ||
"build": "tsc -p .", | ||
"watch": "tsc -p . -w" | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"mocha": { | ||
"require": "ts-node/register", | ||
"spec": "src/**/*.test.ts", | ||
"ui": "tdd" | ||
}, | ||
"nyc": { | ||
"include": [ | ||
"src/**/*.ts?(x)" | ||
], | ||
"exclude": [ | ||
"**/*.test.ts?(x)" | ||
], | ||
"extension": [ | ||
".tsx", | ||
".ts" | ||
] | ||
}, | ||
"peerDependencies": { | ||
"sourcegraph": "*" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^7.5.2", | ||
"@commitlint/config-conventional": "^7.5.0", | ||
"@sourcegraph/extension-api-types": "^2.0.0", | ||
"@sourcegraph/prettierrc": "^2.2.0", | ||
"@sourcegraph/tsconfig": "^4.0.0", | ||
"@sourcegraph/tslint-config": "^13.1.0", | ||
"@types/mocha": "^5.2.6", | ||
"husky": "^2.1.0", | ||
"mocha": "^6.1.4", | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.17.0", | ||
"semantic-release": "^15.13.3", | ||
"sourcegraph": "^23.0.0", | ||
"ts-node": "^8.1.0", | ||
"tslint": "^5.16.0", | ||
"typescript": "^3.4.5" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@sourcegraph/prettierrc') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["github>sourcegraph/renovate-config"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* istanbul ignore file */ | ||
// tslint:disable: no-object-literal-type-assertion https://github.com/palantir/tslint/issues/4628 | ||
|
||
import * as sourcegraph from 'sourcegraph' | ||
|
||
export const MarkupKind: typeof sourcegraph.MarkupKind = { | ||
PlainText: 'plaintext' as sourcegraph.MarkupKind.PlainText, | ||
Markdown: 'markdown' as sourcegraph.MarkupKind.Markdown, | ||
} as const | ||
|
||
export const NotificationType = { | ||
Error: 1, | ||
Warning: 2, | ||
Info: 3, | ||
Log: 4, | ||
Success: 5, | ||
} as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function illegalArgument(name?: string): Error { | ||
if (name) { | ||
return new Error(`Illegal argument: ${name}`) | ||
} | ||
return new Error('Illegal argument') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './location' | ||
export * from './position' | ||
export * from './range' | ||
export * from './selection' | ||
export * from './enums' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Location } from './location' | ||
import { Position } from './position' | ||
import { Range } from './range' | ||
import { assertToJSON } from './testHelpers' | ||
|
||
suite('Location', () => { | ||
test('toJSON', () => { | ||
assertToJSON(new Location(new URL('file:///u.ts'), new Position(3, 4)), { | ||
uri: 'file:///u.ts', | ||
range: { start: { line: 3, character: 4 }, end: { line: 3, character: 4 } }, | ||
}) | ||
assertToJSON(new Location(new URL('file:///u.ts'), new Range(1, 2, 3, 4)), { | ||
uri: 'file:///u.ts', | ||
range: { start: { line: 1, character: 2 }, end: { line: 3, character: 4 } }, | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as sourcegraph from 'sourcegraph' | ||
import { Position } from './position' | ||
import { Range } from './range' | ||
import { isURL } from './url' | ||
|
||
export class Location implements sourcegraph.Location { | ||
public static isLocation(thing: any): thing is sourcegraph.Location { | ||
if (thing instanceof Location) { | ||
return true | ||
} | ||
if (!thing) { | ||
return false | ||
} | ||
return Range.isRange((thing as Location).range) && isURL((thing as Location).uri) | ||
} | ||
|
||
public readonly range?: sourcegraph.Range | ||
|
||
constructor(public readonly uri: URL, rangeOrPosition?: sourcegraph.Range | sourcegraph.Position) { | ||
if (!rangeOrPosition) { | ||
// that's OK | ||
} else if (rangeOrPosition instanceof Range) { | ||
this.range = rangeOrPosition | ||
} else if (rangeOrPosition instanceof Position) { | ||
this.range = new Range(rangeOrPosition, rangeOrPosition) | ||
} else { | ||
throw new Error('Illegal argument') | ||
} | ||
} | ||
|
||
public toJSON(): any { | ||
return { | ||
uri: this.uri, | ||
range: this.range, | ||
} | ||
} | ||
} |
Oops, something went wrong.