Skip to content

Commit fb43931

Browse files
author
Damian Sznajder
committed
chore: update extension packages
1 parent d6f5622 commit fb43931

File tree

3 files changed

+55
-63
lines changed

3 files changed

+55
-63
lines changed

extension/index.ts

+37-46
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// The module 'vscode' contains the VS Code extensibility API
2-
// Import the module and reference it with the alias vscode in your code below
31
import * as vscode from 'vscode'
42

53
const jsSnippets = require('../snippets/snippets.json')
@@ -14,60 +12,53 @@ type Snippet = {
1412
const convertSnippetArrayToString = (snippetArray: Array<string>): string =>
1513
snippetArray.join('\n')
1614

17-
// this method is called when your extension is activated
18-
// your extension is activated the very first time the command is executed
1915
export function activate(context: vscode.ExtensionContext) {
20-
// Use the console to output diagnostic information (console.log) and errors (console.error)
21-
// This line of code will only be executed once when your extension is activated
22-
console.log('Congratulations, your extension "snippet-search" is now active!')
16+
const {
17+
commands: { registerCommand },
18+
window: { showQuickPick, activeTextEditor },
19+
} = vscode
2320

24-
// The command has been defined in the package.json file
25-
// Now provide the implementation of the command with registerCommand
26-
// The commandId parameter must match the command field in package.json
27-
const disposable = vscode.commands.registerCommand(
28-
'extension.snippetSearch',
29-
async () => {
30-
const javascriptSnippets = Object.entries(jsSnippets as Array<Snippet>)
31-
const typescriptSnippets = Object.entries(tsSnippets as Array<Snippet>)
32-
const snippetsArray: Array<[string, Snippet]> = javascriptSnippets.concat(
33-
typescriptSnippets
34-
)
21+
const disposable = registerCommand('extension.snippetSearch', async () => {
22+
const javascriptSnippets = Object.entries(jsSnippets as Array<Snippet>)
23+
const typescriptSnippets = Object.entries(tsSnippets as Array<Snippet>)
24+
const snippetsArray: Array<[string, Snippet]> =
25+
javascriptSnippets.concat(typescriptSnippets)
3526

36-
const items = snippetsArray.map(
37-
([shortDescription, { prefix, body, description }], index) => {
38-
const value = typeof prefix === 'string' ? prefix : prefix[0]
27+
const items = snippetsArray.map(
28+
([shortDescription, { prefix, body, description }], index) => {
29+
const value = typeof prefix === 'string' ? prefix : prefix[0]
3930

40-
return {
41-
id: index,
42-
description: description || shortDescription,
43-
label: value,
44-
value,
45-
body,
46-
}
31+
return {
32+
id: index,
33+
description: description || shortDescription,
34+
label: value,
35+
value,
36+
body,
4737
}
48-
)
49-
50-
const options = {
51-
matchOnDescription: true,
52-
matchOnDetail: true,
53-
placeHolder: 'Search snippet',
5438
}
39+
)
5540

56-
const snippet = (await vscode.window.showQuickPick(items, options)) || {
57-
body: '',
58-
}
59-
const activeTextEditor = vscode.window.activeTextEditor
60-
const body =
61-
typeof snippet.body === 'string'
62-
? snippet.body
63-
: convertSnippetArrayToString(snippet.body)
64-
activeTextEditor &&
65-
activeTextEditor.insertSnippet(new vscode.SnippetString(body))
41+
const options = {
42+
matchOnDescription: true,
43+
matchOnDetail: true,
44+
placeHolder: 'Search snippet',
45+
}
46+
47+
const snippet = (await showQuickPick(items, options)) || {
48+
body: '',
49+
}
50+
51+
const body =
52+
typeof snippet.body === 'string'
53+
? snippet.body
54+
: convertSnippetArrayToString(snippet.body)
55+
56+
if (activeTextEditor) {
57+
activeTextEditor.insertSnippet(new vscode.SnippetString(body))
6658
}
67-
)
59+
})
6860

6961
context.subscriptions.push(disposable)
7062
}
7163

72-
// this method is called when your extension is deactivated
7364
export function deactivate() {}

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "es7-react-js-snippets",
33
"displayName": "ES7 React/Redux/GraphQL/React-Native snippets",
44
"description": "Simple extensions for React, Redux and Graphql in JS/TS with ES7 syntax",
5-
"version": "3.1.1",
5+
"version": "3.2.0",
66
"publisher": "dsznajder",
77
"icon": "images/logo.png",
88
"keywords": [
@@ -77,11 +77,12 @@
7777
"scripts": {
7878
"vscode:prepublish": "yarn run compile",
7979
"compile": "tsc -p ./",
80-
"watch": "tsc -watch -p ./"
80+
"watch": "tsc -watch -p ./",
81+
"typescript": "tsc --noEmit"
8182
},
8283
"devDependencies": {
83-
"typescript": "3.9.6",
84-
"@types/vscode": "^1.45.0",
85-
"@types/node": "^14.0.14"
84+
"typescript": "4.3.5",
85+
"@types/vscode": "1.58.1",
86+
"@types/node": "16.4.7"
8687
}
8788
}

yarn.lock

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# yarn lockfile v1
33

44

5-
"@types/node@^14.0.14":
6-
version "14.0.14"
7-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.14.tgz#24a0b5959f16ac141aeb0c5b3cd7a15b7c64cbce"
8-
integrity sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ==
5+
"@types/node@16.4.7":
6+
version "16.4.7"
7+
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.7.tgz#f7afa78769d4b477f5092d7c3468e2e8653d779c"
8+
integrity sha512-aDDY54sst8sx47CWT6QQqIZp45yURq4dic0+HCYfYNcY5Ejlb/CLmFnRLfy3wQuYafOeh3lB/DAKaqRKBtcZmA==
99

10-
"@types/vscode@^1.45.0":
11-
version "1.46.0"
12-
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.46.0.tgz#53f2075986e901ed25cd1ec5f3ffa5db84a111b3"
13-
integrity sha512-8m9wPEB2mcRqTWNKs9A9Eqs8DrQZt0qNFO8GkxBOnyW6xR//3s77SoMgb/nY1ctzACsZXwZj3YRTDsn4bAoaUw==
10+
"@types/vscode@1.58.1":
11+
version "1.58.1"
12+
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.58.1.tgz#7deae08792adc73fa57383244a0c79d3530df4f7"
13+
integrity sha512-sa76rDXiSif09he8KoaWWUQxsuBr2+uND0xn1GUbEODkuEjp2p7Rqd3t5qlvklfmAedLFdL7MdnsPa57uzwcOw==
1414

15-
typescript@3.9.6:
16-
version "3.9.6"
17-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.6.tgz#8f3e0198a34c3ae17091b35571d3afd31999365a"
18-
integrity sha512-Pspx3oKAPJtjNwE92YS05HQoY7z2SFyOpHo9MqJor3BXAGNaPUs83CuVp9VISFkSjyRfiTpmKuAYGJB7S7hOxw==
15+
typescript@4.3.5:
16+
version "4.3.5"
17+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
18+
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==

0 commit comments

Comments
 (0)