-
Notifications
You must be signed in to change notification settings - Fork 12
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 f7862f2
Showing
14 changed files
with
290 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,20 @@ | ||
{ | ||
"env": { | ||
"browser": false, | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"no-const-assign": "warn", | ||
"no-this-before-super": "warn", | ||
"no-undef": "warn", | ||
"no-unreachable": "warn", | ||
"no-unused-vars": "warn", | ||
"constructor-super": "warn", | ||
"valid-typeof": "warn" | ||
} | ||
} |
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 @@ | ||
# Set default behavior to automatically normalize line endings. | ||
* text=auto | ||
|
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 @@ | ||
node_modules | ||
.vscode-test/ | ||
*.vsix |
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,7 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} |
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,18 @@ | ||
// A launch configuration that launches the extension inside a new window | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Extension", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": [ | ||
"--extensionDevelopmentPath=${workspaceFolder}" | ||
] | ||
} | ||
] | ||
} |
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 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
} |
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 @@ | ||
.vscode/** | ||
.gitignore | ||
jsconfig.json | ||
.eslintrc.json |
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 @@ | ||
# Change Log | ||
|
||
## Version 1.0.0 | ||
|
||
- Initial release. |
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,69 @@ | ||
# VSCode Extension to Fix Checksums | ||
|
||
An extension to to adjust checksums after changes to core files. | ||
|
||
## Installation | ||
|
||
Follow the instructions in the | ||
[Marketplace](https://marketplace.visualstudio.com/items?itemName=lehni.vscode-fix-checksums), | ||
or run the following in the command palette: | ||
|
||
```shell | ||
ext install lehni.vscode-fix-checksums | ||
``` | ||
|
||
Alternatively, you can run this command in the command line: | ||
|
||
```sh | ||
code --install-extension lehni.vscode-fix-checksums | ||
``` | ||
|
||
## Usage | ||
|
||
The extension adds 2 new commands to the command palette: | ||
|
||
```js | ||
Fix Checksums: Apply // | ||
Fix Checksums: Restore // | ||
``` | ||
|
||
After executing either of these commands, you need to fully restart VSCode in | ||
order to see the extension's effect. Simply reloading the window is not enough. | ||
|
||
See [Disclaimer / A Word of Caution](#disclaimer--a-word-of-caution) for | ||
details. | ||
|
||
## Installing on macOS 10.14 Mojave | ||
|
||
Due to security restrictions on macOS 10.14, VSCode needs to run as root | ||
in order to be able to apply the patches. To do so, open the `Terminal.app` and | ||
run: | ||
|
||
```sh | ||
sudo "/Applications/Visual Studio Code.app/Contents/MacOS/Electron" | ||
``` | ||
|
||
Or this if you're using VSCode Insiders: | ||
|
||
```sh | ||
sudo "/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron" | ||
``` | ||
|
||
Once you ave applied the modifications by executing `Fix Checksums: Apply` as | ||
root, quit VScode and start it normally without root privileges again. | ||
|
||
## Disclaimer / A Word of Caution | ||
|
||
This extension modifies files that are part of the core of VSCode, so use it at | ||
your own risk. | ||
|
||
This extension creates backup files before modifying the core files, and these | ||
can be restored at any time using the `Fix Checksums: Restore` command. | ||
|
||
If anything goes wrong, you can always reinstall VSCode from | ||
[code.visualstudio.com](https://code.visualstudio.com/download) without loosing | ||
any settings or installed extensions. | ||
|
||
## License | ||
|
||
MIT © Jürg Lehni, 2018 |
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,85 @@ | ||
const vscode = require('vscode') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const crypto = require('crypto') | ||
|
||
const appDir = path.dirname(require.main.filename) | ||
const rootDir = path.join(appDir, '..') | ||
|
||
const productFile = path.join(rootDir, 'product.json') | ||
const origFile = `${productFile}.orig.${vscode.version}` | ||
|
||
exports.activate = function activate(context) { | ||
context.subscriptions.push( | ||
vscode.commands.registerCommand('fixChecksums.apply', apply), | ||
vscode.commands.registerCommand('fixChecksums.restore', restore) | ||
) | ||
cleanupOrigFiles() | ||
} | ||
|
||
const messages = { | ||
changed: verb => `Checksums ${verb}. Please restart VSCode to see effect.`, | ||
unchanged: 'No changes to checksums were necessary.', | ||
error: `An error occurred during execution. | ||
Make sure you have write access rights to the VSCode files, see README` | ||
} | ||
|
||
function apply() { | ||
const product = require(productFile) | ||
let changed = false | ||
let message = messages.unchanged | ||
for (const [filePath, curChecksum] of Object.entries(product.checksums)) { | ||
const checksum = computeChecksum(path.join(appDir, ...filePath.split('/'))) | ||
if (checksum !== curChecksum) { | ||
product.checksums[filePath] = checksum | ||
changed = true | ||
} | ||
} | ||
if (changed) { | ||
const json = JSON.stringify(product, null, '\t') | ||
try { | ||
fs.renameSync(productFile, origFile) | ||
fs.writeFileSync(productFile, json, { encoding: 'utf8' }) | ||
message = messages.changed('applied') | ||
} catch (err) { | ||
console.error(err) | ||
message = messages.error | ||
} | ||
} | ||
vscode.window.showInformationMessage(message) | ||
} | ||
|
||
function restore() { | ||
let message = messages.unchanged | ||
try { | ||
if (fs.existsSync(origFile)) { | ||
fs.unlinkSync(productFile) | ||
fs.renameSync(origFile, productFile) | ||
message = messages.changed('restored') | ||
} | ||
} catch (err) { | ||
console.error(err) | ||
message = messages.error | ||
} | ||
vscode.window.showInformationMessage(message) | ||
} | ||
|
||
function computeChecksum(file) { | ||
var contents = fs.readFileSync(file) | ||
return crypto | ||
.createHash('md5') | ||
.update(contents) | ||
.digest('base64') | ||
.replace(/=+$/, '') | ||
} | ||
|
||
function cleanupOrigFiles() { | ||
// Remove all old backup files that aren't related to the current version | ||
// of VSCode anymore. | ||
const oldOrigFiles = fs.readdirSync(rootDir) | ||
.filter(file => /\.orig\./.test(file)) | ||
.filter(file => !file.endsWith(vscode.version)) | ||
for (const file of oldOrigFiles) { | ||
fs.unlinkSync(path.join(rootDir, file)) | ||
} | ||
} |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"checkJs": false, | ||
"lib": [ | ||
"es6" | ||
] | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
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,60 @@ | ||
{ | ||
"name": "vscode-fix-checksums", | ||
"displayName": "Fix VSCode Checksums", | ||
"description": "An extension to adjust checksums after changes to core files", | ||
"icon": "resources/logo.png", | ||
"version": "1.3.1", | ||
"license": "MIT", | ||
"main": "./extension", | ||
"publisher": "lehni", | ||
"author": { | ||
"name": "Jürg Lehni", | ||
"email": "[email protected]" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/lehni/vscode-fix-checksums/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lehni/vscode-fix-checksums" | ||
}, | ||
"engines": { | ||
"vscode": "^1.25.0" | ||
}, | ||
"keywords": [ | ||
"vscode", | ||
"vsc", | ||
"extension", | ||
"fix", | ||
"checksum", | ||
"checksums" | ||
], | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [ | ||
"onCommand:fixChecksums.apply", | ||
"onCommand:fixChecksums.restore" | ||
], | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": "fixChecksums.apply", | ||
"title": "Fix Checksums: Apply" | ||
}, | ||
{ | ||
"command": "fixChecksums.restore", | ||
"title": "Fix Checksums: Restore" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"postinstall": "node ./node_modules/vscode/bin/install" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^7.0.43", | ||
"@types/mocha": "^2.2.42", | ||
"eslint": "^4.11.0", | ||
"vscode": "^1.1.6" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.