chore: initial commit

This commit is contained in:
iCrawl 2017-11-23 14:06:21 +01:00
commit e5736fc092
No known key found for this signature in database
GPG key ID: E41A6DB922EC2CFE
10 changed files with 2089 additions and 0 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
* text=auto eol=lf

21
.gitignore vendored Normal file
View file

@ -0,0 +1,21 @@
# Packages
node_modules/
# Log files
logs/
*.log
# Authentication
# Test files
test/
!test/**/*.ts
# Miscellaneous
.tmp/
.vscode/bookmarks.json
!.vscode/launch.json
!.vscode/tasks.json
dist/
out/
package-lock.json

28
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,28 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"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": "npm"
},
{
"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": "npm"
}
]
}

30
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,30 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],
// The tsc compiler is started in watching mode
"isBackground": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}

23
README.md Normal file
View file

@ -0,0 +1,23 @@
# discord-vscode
> Update your discord status with the newly added rich presence.
<div align="center">
<p>
<a href="https://discord.gg/tADcnuY"><img src="https://discordapp.com/api/guilds/304034982475595776/embed.png" alt="Discord server" /></a>
</p>
</div>
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
## Author
**discord-vscode** © [iCrawl](https://github.com/iCrawl).<br>
Authored and maintained by iCrawl.
> GitHub [@iCrawl](https://github.com/iCrawl)

35
package.json Normal file
View file

@ -0,0 +1,35 @@
{
"name": "discord-vscode",
"displayName": "Discord VSCode",
"version": "0.1.0",
"description": "Update your discord status with the newly added rich presence.",
"author": {
"name": "iCrawl",
"email": "icrawltogo@gmail.com"
},
"publisher": "icrawl",
"license": "MIT",
"main": "./out/src/extension",
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test",
"lint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'"
},
"activationEvents": [
"*"
],
"dependencies": {
"discord-rpc": "^3.0.0-beta.2"
},
"devDependencies": {
"@types/node": "^8.0.0",
"tslint": "^5.0.0",
"typescript": "^2.0.0",
"vscode": "^1.0.0"
},
"engines": {
"vscode": "^1.15.0"
}
}

37
src/extension.ts Normal file
View file

@ -0,0 +1,37 @@
import { Client } from 'discord-rpc';
import { basename, extname } from 'path';
import { ExtensionContext, commands, window, workspace, Uri, TextDocumentChangeEvent } from 'vscode';
export function activate(context: ExtensionContext) {
const rpc = new Client({ transport: 'ipc' });
rpc.once('ready', () => {
setActivity(rpc);
workspace.onDidChangeTextDocument((e: TextDocumentChangeEvent) => {
setActivity(rpc);
});
});
rpc.login('').catch(error =>
window.showErrorMessage(`Could not connect to discord via rpc: ${error.message}`)
);
}
export function deactivate(context: ExtensionContext) {}
function setActivity(rpc: Client): void {
if (!rpc) return;
const startTimestamp = Date.now();
const activity = {
details: window.activeTextEditor ? `${basename(window.activeTextEditor.document.fileName)}` : 'Idle.',
state: 'No idea.',
startTimestamp,
largeImageKey: 'vscode-big',
largeImageText: 'No really, nothing yet',
smallImageKey: 'vscode',
smallImageText: 'What did you expect?',
instance: false
};
rpc.setActivity(activity).catch(error =>
window.showErrorMessage(`DiscordRPC: ${error.message}`)
);
}

20
tsconfig.json Normal file
View file

@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"esnext",
"esnext.asynciterable"
],
"outDir": "out",
"rootDir": ".",
"declaration": true,
"sourceMap": true,
"removeComments": false,
"experimentalDecorators": true
},
"exclude": [
"node_modules",
".vscode-test"
]
}

111
tslint.json Normal file
View file

@ -0,0 +1,111 @@
{
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": false,
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs"
],
"import-spacing": true,
"indent": [
true,
"tabs"
],
"interface-over-type-literal": false,
"label-position": true,
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}

1783
yarn.lock Normal file

File diff suppressed because it is too large Load diff