Skip to content

Commit 42719d0

Browse files
authored
Merge pull request coderoad#102 from ShMcK/feature/notify
Icons, Fonts & Notifications
2 parents bac9dc8 + be1e1db commit 42719d0

34 files changed

+461
-156
lines changed

package-lock.json

Lines changed: 0 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build": "rm -rf build && npm run build:ext && npm run build:web",
2121
"build:ext": "tsc -p ./",
2222
"build:web": "cd web-app && npm run build",
23-
"postbuild:web": "cp -R ./web-app/build/ ./build/",
23+
"postbuild:web": "cp -R ./web-app/build/ ./build/ && node scripts/fixFontPaths.js",
2424
"postinstall": "node ./node_modules/vscode/bin/install",
2525
"lint": "eslint src/**/*ts",
2626
"machine": "node ./out/state/index.js",
@@ -41,7 +41,6 @@
4141
"@types/assert": "^1.4.5",
4242
"@types/chokidar": "^2.1.3",
4343
"@types/dotenv": "^8.2.0",
44-
"@types/glob": "^7.1.1",
4544
"@types/jest": "^25.1.1",
4645
"@types/jsdom": "^12.2.4",
4746
"@types/node": "^13.5.3",

resources/public/favicon.ico

-3.78 KB
Binary file not shown.

resources/public/index.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

resources/public/manifest.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

scripts/fixFontPaths.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* css url font paths do not match up from the web-app as it is moved inside of build
3+
* in order to load fonts and icons, these paths must be reconciled.
4+
*/
5+
const fs = require('fs') // eslint-disable-line
6+
7+
// find the generated main css file
8+
const getMainCSSFile = () => {
9+
const regex = /^main.[a-z0-9]+.chunk.css$/
10+
const mainCss = fs.readdirSync('build/static/css').filter(filename => filename.match(regex))
11+
if (!mainCss.length) {
12+
throw new Error('No main.css file found in build/static/css')
13+
}
14+
return mainCss[0]
15+
}
16+
17+
// remap the font paths from the borken /fonts/ => ../../fonts/
18+
const remapFontPaths = () => {
19+
const mainCSSFile = getMainCSSFile()
20+
const file = fs.readFileSync(`build/static/css/${mainCSSFile}`, 'utf8')
21+
const fontUrlRegex = /url\(\/fonts\//g
22+
const remappedFile = file.replace(fontUrlRegex, 'url(../../fonts/')
23+
fs.writeFileSync(`build/static/css/${mainCSSFile}`, remappedFile)
24+
}
25+
26+
remapFontPaths()

src/editor/commands.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,11 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
5757
testRunner = createTestRunner(config, {
5858
onSuccess: (payload: Payload) => {
5959
// send test pass message back to client
60-
notify({ message: 'PASS' })
6160
webview.send({ type: 'TEST_PASS', payload })
62-
// update local storage
6361
},
6462
onFail: (payload: Payload, message: string) => {
65-
// send test fail message back to client
66-
notify({ message: `FAIL ${message}` })
67-
webview.send({ type: 'TEST_FAIL', payload })
63+
// send test fail message back to client with failure message
64+
webview.send({ type: 'TEST_FAIL', payload: { ...payload, message } })
6865
},
6966
onError: (payload: Payload) => {
7067
// send test error message back to client

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@
2525
"allowJs": true,
2626
"removeComments": true
2727
},
28-
"exclude": ["node_modules", ".vscode-test", "build", "resources", "web-app", "*.js", "*.test.ts"]
28+
"exclude": ["node_modules", ".vscode-test", "build", "resources", "web-app", "*.js", "*.test.ts", "scripts"]
2929
}

typings/index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ export interface ErrorMessage {
4242
description?: string
4343
}
4444

45+
export interface TestStatus {
46+
type: 'success' | 'warning' | 'error' | 'loading'
47+
title: string
48+
content?: string
49+
}
50+
4551
export interface MachineContext {
4652
env: Environment
4753
error: ErrorMessage | null
4854
tutorial: G.Tutorial | null
4955
position: Position
5056
progress: Progress
5157
processes: ProcessEvent[]
58+
testStatus: TestStatus | null
5259
}
5360

5461
export interface MachineEvent {
@@ -83,7 +90,6 @@ export interface MachineStateSchema {
8390
TestRunning: {}
8491
TestPass: {}
8592
TestFail: {}
86-
TestError: {}
8793
StepNext: {}
8894
LevelComplete: {}
8995
}

web-app/config-overrides.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2-
const path = require('path')
3-
const { addBabelPreset, addBabelPlugin, addWebpackModuleRule } = require('customize-cra')
2+
const { addBabelPreset, addWebpackModuleRule, addBabelPlugin } = require('customize-cra')
43

54
module.exports = function override(config) {
65
addWebpackModuleRule({

0 commit comments

Comments
 (0)