Make new version with Settings UI release-ready

feature/search
Kelvin Schoofs 6 years ago
parent b181f14e94
commit c2c64c8e8d

@ -1,8 +1,13 @@
.vscode/**
.vscode-test/**
out/test/**
test/**
src/**
**/*.map
.gitignore
tsconfig.json
**
!.vscodeignore
!package.json
!package-lock.json
!node_modules
!out/*.js
!resources
!media
!webview/build/index.html
!webview/build/static/css/*.css
!webview/build/static/js/*.js

1248
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -209,12 +209,14 @@ export async function alterConfigs(location: ConfigLocation, alterer: ConfigAlte
const inspect = conf.inspect<FileSystemConfig[]>('configs')!;
const array = [[], inspect.globalValue, inspect.workspaceValue, inspect.workspaceFolderValue][location];
if (!array) throw new Error(`Something very unexpected happened...`);
const modified = alterer(array);
let modified = alterer(array);
if (!modified) return;
modified.forEach((config) => {
modified = modified.map((config) => {
const newConfig = { ...config };
for (const key in config) {
if (key[0] === '_') delete config[key];
if (key[0] === '_') delete newConfig[key];
}
return newConfig;
});
await conf.update('configs', modified, location);
Logging.debug(`\tUpdated configs in ${[, 'Global', 'Workspace', 'WorkspaceFolder'][location]} settings.json`);
@ -222,12 +224,14 @@ export async function alterConfigs(location: ConfigLocation, alterer: ConfigAlte
}
if (typeof location !== 'string') throw new Error(`Invalid _location field: ${location}`);
const configs = await readConfigFile(location, true);
const altered = alterer(configs);
let altered = alterer(configs);
if (!altered) return;
altered.forEach((config) => {
altered = altered.map((config) => {
const newConfig = { ...config };
for (const key in config) {
if (key[0] === '_') delete config[key];
if (key[0] === '_') delete newConfig[key];
}
return newConfig;
});
const data = JSON.stringify(altered, null, 4);
await toPromise(cb => writeFile(location, data, cb))
@ -236,6 +240,7 @@ export async function alterConfigs(location: ConfigLocation, alterer: ConfigAlte
throw e;
});
Logging.debug(`\tWritten modified configs to ${location}`);
await loadConfigs();
}
export async function updateConfig(config: FileSystemConfig, oldName = config.name) {

@ -1,7 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import * as request from 'request';
import * as vscode from 'vscode';
import { deleteConfig, loadConfigsRaw, updateConfig } from './config';
import { getLocations } from './fileSystemConfig';
@ -9,7 +8,9 @@ import { Message } from './webviewMessages';
let webviewPanel: vscode.WebviewPanel | undefined;
const DEBUG: number | undefined = 3000;
// Since the Extension Development Host runs with debugger, we can use this to detect if we're debugging
const DEBUG: number | undefined = process.execArgv.find(a => a.includes('--inspect')) ? 3000 : undefined;
if (DEBUG) console.warn('[vscode-sshfs] Detected we are running in debug mode');
export function open(extensionPath: string) {
if (!webviewPanel) {
@ -19,13 +20,18 @@ export function open(extensionPath: string) {
if (DEBUG) {
// webviewPanel.webview.html = `<html><head><script>document.location="http://localhost:${DEBUG}/"</script></head></html>`;
const URL = `http://localhost:${DEBUG}/`;
request.get(URL, (err, res, body) => {
body = body.replace(/\/static\/js\/bundle\.js/, `http://localhost:${DEBUG}/static/js/bundle.js`);
webviewPanel!.webview.html = body; // `<html><head><title>Test</title></head><body>Testing</body></html>`;// body
});
import('request').then(request =>
request.get(URL, (err, res, body) => {
if (err) {
webviewPanel!.webview.html = `<html><body>Did you start the React build server? We're running in debug mode...</body></html>`;
return console.error(err);
}
body = body.replace(/\/static\/js\/bundle\.js/, `http://localhost:${DEBUG}/static/js/bundle.js`);
webviewPanel!.webview.html = body; // `<html><head><title>Test</title></head><body>Testing</body></html>`;// body
}));
} else {
const content = fs.readFileSync(path.resolve(extensionPath, 'resources/settings.html')).toString();
webviewPanel.webview.html = content.replace(/\$ROOT/g, vscode.Uri.file(path.join(extensionPath, 'resources')).with({ scheme: 'vscode-resource' }).toString());
const content = fs.readFileSync(path.resolve(extensionPath, 'webview/build/index.html')).toString();
webviewPanel.webview.html = content.replace(/\/static\//g, vscode.Uri.file(path.join(extensionPath, 'webview/build/static/')).with({ scheme: 'vscode-resource' }).toString());
}
}
webviewPanel.reveal();

Loading…
Cancel
Save