Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/sentry#80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 7 commits intomasterfromfeature/sentry
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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
1,223 changes: 354 additions & 869 deletionspackage-lock.json
View file
Open in desktop

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,8 @@
"watch":"tsc -watch -p ./"
},
"dependencies": {
"@sentry/electron":"^1.2.0",
"@sentry/node":"^5.11.0",
"chokidar":"^3.3.0",
"dotenv":"^8.2.0",
"jsdom":"^15.2.1"
Expand All@@ -48,6 +50,7 @@
"eslint":"^6.8.0",
"eslint-config-prettier":"^6.9.0",
"eslint-plugin-prettier":"^3.1.2",
"graphql":"^14.5.8",
"prettier":"^1.19.1",
"ts-jest":"^24.3.0",
"typescript":"^3.7.4",
Expand Down
5 changes: 3 additions & 2 deletionssrc/actions/setupActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import * as git from '../services/git'
import loadWatchers from './utils/loadWatchers'
import openFiles from './utils/openFiles'
import runCommands from './utils/runCommands'
import onError from '../services/sentry/onError'

const setupActions = async (
workspaceRoot: vscode.WorkspaceFolder,
Expand All@@ -16,7 +17,7 @@ const setupActions = async (
if (commits) {
for (const commit of commits) {
// TODO handle git errors
await git.loadCommit(commit)
await git.loadCommit(commit).catch(onError)
}
}

Expand All@@ -27,7 +28,7 @@ const setupActions = async (
loadWatchers(watchers || [], workspaceRoot.uri)

// 4. run command
await runCommands(commands || [], send)
await runCommands(commands || [], send).catch(onError)
}

export default setupActions
3 changes: 2 additions & 1 deletionsrc/actions/solutionActions.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,14 +2,15 @@ import * as T from 'typings'
import*asvscodefrom'vscode'
import*asgitfrom'../services/git'
importsetupActionsfrom'./setupActions'
importonErrorfrom'../services/sentry/onError'

constsolutionActions=async(
workspaceRoot:vscode.WorkspaceFolder,
stepActions:T.StepActions,
send:(action:T.Action)=>void,
):Promise<void>=>{
awaitgit.clear()
returnsetupActions(workspaceRoot,stepActions,send)
returnsetupActions(workspaceRoot,stepActions,send).catch(onError)
}

exportdefaultsolutionActions
9 changes: 6 additions & 3 deletionssrc/actions/tutorialConfig.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import * as vscode from 'vscode'
import{COMMANDS}from'../editor/commands'
importlanguageMapfrom'../editor/languageMap'
import*asgitfrom'../services/git'
importonErrorfrom'../services/sentry/onError'

interfaceTutorialConfigParams{
config:T.TutorialConfig
Expand All@@ -13,13 +14,14 @@ interface TutorialConfigParams {

consttutorialConfig=async(
{ config, alreadyConfigured}:TutorialConfigParams,
onError:(msg:T.ErrorMessage)=>void,
handleError:(msg:T.ErrorMessage)=>void,
)=>{
if(!alreadyConfigured){
// setup git, add remote
awaitgit.initIfNotExists().catch(error=>{
onError(newError('Git not found'))
// failed to setup git
onError({
handleError({
title:error.message,
description:
'Be sure you install Git. See the docs for help https://git-scm.com/book/en/v2/Getting-Started-Installing-Git',
Expand All@@ -28,7 +30,8 @@ const tutorialConfig = async (

// TODO if remote not already set
awaitgit.setupRemote(config.repo.uri).catch(error=>{
onError({title:error.message,description:'Remove your current Git project and restarting'})
onError(error)
handleError({title:error.message,description:'Remove your current Git project and restarting'})
})
}

Expand Down
4 changes: 4 additions & 0 deletionssrc/environment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,10 +3,14 @@ require('dotenv').config({
})

interfaceEnvironment{
VERSION:string
NODE_ENV:string
LOG:boolean
}

constenvironment:Environment={
VERSION:process.env.VERSION||'unknown',
NODE_ENV:process.env.NODE_ENV||'production',
LOG:(process.env.LOG||'').toLowerCase()==='true',
}

Expand Down
3 changes: 3 additions & 0 deletionssrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
// init error logging
import'./services/sentry/init'

importEditorfrom'./editor'

// vscode editor
Expand Down
10 changes: 8 additions & 2 deletionssrc/services/git/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
importnodefrom'../node'
importloggerfrom'../logger'
importonErrorfrom'../sentry/onError'

constgitOrigin='coderoad'

Expand DownExpand Up@@ -76,13 +77,18 @@ export async function version(): Promise<string | boolean> {
return`${major}${minor}${patch}`
}
}
thrownewError('Git not installed. Please install Git')
constmessage='Git not installed. Please install Git'
consterror=newError(message)
onError(error)
throwerror
}

asyncfunctioninit():Promise<void>{
const{ stderr}=awaitnode.exec('git init')
if(stderr){
thrownewError('Error initializing Git')
consterror=newError('Error initializing Git')
onError(error)
throwerror
}
}

Expand Down
5 changes: 4 additions & 1 deletionsrc/services/node/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import * as fs from 'fs'
import{join}from'path'
import{promisify}from'util'
import*asvscodefrom'vscode'
importonErrorfrom'../sentry/onError'

constasyncExec=promisify(cpExec)

Expand All@@ -12,7 +13,9 @@ class Node {
// set workspace root for node executions
constworkspaceRoots:vscode.WorkspaceFolder[]|undefined=vscode.workspace.workspaceFolders
if(!workspaceRoots||!workspaceRoots.length){
thrownewError('No workspace root path')
consterror=newError('No workspace root path')
onError(error)
throwerror
}
constworkspaceRoot:vscode.WorkspaceFolder=workspaceRoots[0]
this.workspaceRootPath=workspaceRoot.uri.path
Expand Down
7 changes: 7 additions & 0 deletionssrc/services/sentry/init.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
import{init}from'@sentry/node'
importenvironmentfrom'../../environment'

init({
dsn:'https://df4a6ae19e8b44ed9a87ae4432dab9df@sentry.io/1889368',
environment:environment.NODE_ENV,
})
19 changes: 19 additions & 0 deletionssrc/services/sentry/onError.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
import*assentryfrom'@sentry/node'
// import { Scope } from '@sentry/hub'
importenvironmentfrom'../../environment'

constonError=(error:Error)=>{
// set user scope https://docs.sentry.io/enriching-error-data/scopes/?platform=node
sentry.withScope((scope:any)=>{
scope.setTag('VERSION',environment.VERSION)
// if (user) {
// scope.setUser({
// id: user.id,
// email: user.email || 'unknown',
// })
// }
sentry.captureException(error)
})
}

exportdefaultonError
2 changes: 2 additions & 0 deletionssrc/services/testRunner/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import node from '../../services/node'
importloggerfrom'../../services/logger'
importparserfrom'./parser'
import{debounce,throttle}from'./throttle'
importonErrorfrom'../sentry/onError'

exportinterfacePayload{
stepId:string
Expand DownExpand Up@@ -76,6 +77,7 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
}
}else{
// should never get here
onError(newError(`Error with running test${JSON.stringify(payload)}`))
callbacks.onError(payload)
}
}
Expand Down
124 changes: 68 additions & 56 deletionssrc/webview/render.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import{JSDOM}from'jsdom'
import*aspathfrom'path'
import*asvscodefrom'vscode'
importonErrorfrom'../services/sentry/onError'

constgetNonce=():string=>{
lettext=''
Expand All@@ -12,74 +13,85 @@ const getNonce = (): string => {
}

asyncfunctionrender(panel:vscode.WebviewPanel,rootPath:string){
// load copied index.html from web app build
constdom=awaitJSDOM.fromFile(path.join(rootPath,'index.html'))
const{ document}=dom.window
try{
// load copied index.html from web app build
constdom=awaitJSDOM.fromFile(path.join(rootPath,'index.html'))
const{ document}=dom.window

// set base href
constbase:HTMLBaseElement=document.createElement('base')
base.href=`vscode-resource:${rootPath}/`
// set base href
constbase:HTMLBaseElement=document.createElement('base')
base.href=`vscode-resource:${rootPath}/`

document.head.appendChild(base)
document.head.appendChild(base)

// used for CSP
constnonces:string[]=[]
// used for CSP
constnonces:string[]=[]

// generate vscode-resource build path uri
constcreateUri=(filePath:string):any=>{
returnpanel.webview
.asWebviewUri(vscode.Uri.file(filePath))
.toString()
.replace(/^\/+/g,'')// remove leading '/'
.replace('/vscode-resource%3A',rootPath)// replace mangled resource path with root
}
// generate vscode-resource build path uri
constcreateUri=(filePath:string):any=>{
return(
panel.webview
//@ts-ignore
.asWebviewUri(vscode.Uri.file(filePath))
.toString()
.replace(/^\/+/g,'')// remove leading '/'
.replace('/vscode-resource%3A',rootPath)
)// replace mangled resource path with root
}

// fix paths for scripts
constscripts:HTMLScriptElement[]=Array.from(document.getElementsByTagName('script'))
for(constscriptofscripts){
if(script.src){
constnonce:string=getNonce()
nonces.push(nonce)
script.nonce=nonce
script.src=createUri(script.src)
// fix paths for scripts
constscripts:HTMLScriptElement[]=Array.from(document.getElementsByTagName('script'))
for(constscriptofscripts){
if(script.src){
constnonce:string=getNonce()
nonces.push(nonce)
script.nonce=nonce
script.src=createUri(script.src)
}
}
}

// add run-time script from webpack
construnTimeScript=document.createElement('script')
runTimeScript.nonce=getNonce()
nonces.push(runTimeScript.nonce)
constmanifest=awaitimport(path.join(rootPath,'asset-manifest.json'))
runTimeScript.src=createUri(path.join(rootPath,manifest.files['runtime-main.js']))
document.body.appendChild(runTimeScript)
// add run-time script from webpack
construnTimeScript=document.createElement('script')
runTimeScript.nonce=getNonce()
nonces.push(runTimeScript.nonce)
constmanifest=awaitimport(path.join(rootPath,'asset-manifest.json'))
runTimeScript.src=createUri(path.join(rootPath,manifest.files['runtime-main.js']))
document.body.appendChild(runTimeScript)

// fix paths for links
conststyles:HTMLLinkElement[]=Array.from(document.getElementsByTagName('link'))
for(conststyleofstyles){
if(style.href){
style.href=createUri(style.href)
// fix paths for links
conststyles:HTMLLinkElement[]=Array.from(document.getElementsByTagName('link'))
for(conststyleofstyles){
if(style.href){
style.href=createUri(style.href)
}
}
}

// set CSP (content security policy) to grant permission to local files
constcspMeta:HTMLMetaElement=document.createElement('meta')
cspMeta.httpEquiv='Content-Security-Policy'
cspMeta.content=
[
`default-src 'self'`,
`connect-src https: http:`,
`font-src${panel.webview.cspSource} http: https: data:`,
`img-src${panel.webview.cspSource} https:`,
`script-src${nonces.map(nonce=>`'nonce-${nonce}'`).join(' ')} data:`,
`style-src${panel.webview.cspSource} https: 'self' 'unsafe-inline'`,
].join('; ')+';'
document.head.appendChild(cspMeta)
// set CSP (content security policy) to grant permission to local files
constcspMeta:HTMLMetaElement=document.createElement('meta')
cspMeta.httpEquiv='Content-Security-Policy'
cspMeta.content=
[
`default-src 'self'`,
`connect-src https: http:`,
//@ts-ignore
`font-src${panel.webview.cspSource} http: https: data:`,
//@ts-ignore
`img-src${panel.webview.cspSource} https:`,
`script-src${nonces.map(nonce=>`'nonce-${nonce}'`).join(' ')} data:`,
//@ts-ignore
`style-src${panel.webview.cspSource} https: 'self' 'unsafe-inline'`,
].join('; ')+';'
document.head.appendChild(cspMeta)

// stringify dom
consthtml=dom.serialize()
// stringify dom
consthtml=dom.serialize()

// set view
panel.webview.html=html
// set view
panel.webview.html=html
}catch(error){
onError(error)
console.error(error)
}
}

exportdefaultrender
Loading

[8]ページ先頭

©2009-2025 Movatter.jp