<commit_before>/* eslint-env node */
/* eslint-disable no-console */
'use strict';

const argv = require('yargs').argv;
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const WebpackDevServer = require('webpack-dev-server');

const port = 9000;
const drone = {
  scheme: argv.scheme,
  host: argv.host,
  server: `${argv.scheme}://${argv.host}`,
  token: argv.token
};

const config = require('./webpack.config.js');
config.entry.app.unshift(`webpack-dev-server/client?http://localhost:${port}/`, 'webpack/hot/dev-server');
config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
const compiler = webpack(webpackConfig);
const server = new WebpackDevServer(compiler, {
  hot: true,
  inline: true,
  historyApiFallback: true,
  proxy: {
    // proxy to drone
    '/api/*': {
      target: drone.server,
      headers: {
        'Authorization': `Bearer ${drone.token}`
      },
      xfwd: true,
      changeOrigin: true
    },
    // proxy to drone websockets
    '/ws/*': {
      target: drone.server,
      headers: {
        'Authorization': `Bearer ${drone.token}`
      },
      xfwd: true,
      ws: true,
      changeOrigin: true
    }
  },
  // reduce the console noise
  stats: {
    assets: false,
    colors: true,
    version: false,
    modules: false,
    hash: false,
    timings: false,
    chunks: false,
    chunkModules: false,
    reasons: false,
    cached: true,
    chunkOrigins: true,
    children: false
  }
});
server.listen(9000, (err) => {
  if (err) return console.err(err);
  console.log(`Now listening on http://localhost:${port}`);
});<commit_msg>fix websocket proxying for dev<commit_after>/* eslint-env node */
/* eslint-disable no-console */
'use strict';

const argv = require('yargs').argv;
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
const WebpackDevServer = require('webpack-dev-server');

const proxy = require('http-proxy').createProxyServer();
const port = 9000;
const drone = {
  scheme: argv.scheme,
  host: argv.host,
  server: `${argv.scheme}://${argv.host}`,
  wsServer: `${argv.scheme === 'https' ? 'wss' : 'ws'}://${argv.host}`,
  token: argv.token
};

const config = require('./webpack.config.js');
config.entry.app.unshift(`webpack-dev-server/client?http://localhost:${port}/`, 'webpack/hot/dev-server');
config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
const compiler = webpack(webpackConfig);
const server = new WebpackDevServer(compiler, {
  hot: true,
  inline: true,
  historyApiFallback: true,
  proxy: {
    // proxy to drone
    '/api/*': {
      target: drone.server,
      headers: {
        'Authorization': `Bearer ${drone.token}`
      },
      xfwd: true,
      changeOrigin: true
    }
  },
  // reduce the console noise
  stats: {
    assets: false,
    colors: true,
    version: false,
    modules: false,
    hash: false,
    timings: false,
    chunks: false,
    chunkModules: false,
    reasons: false,
    cached: true,
    chunkOrigins: true,
    children: false
  }
});

// proxy to drone websocket
server.listeningApp.on('upgrade', function (req, socket) {
  if (req.url.match(/^\/ws\//)) {
    proxy.ws(req, socket, {
      target: `${drone.wsServer}${req.url}?access_token=${drone.token}`,
      ws: true,
      changeOrigin: true
    });
  }
});

server.listen(9000, (err) => {
  if (err) return console.err(err);
  console.log(`Now listening on http://localhost:${port}`);
});
{'fraction_non_alphanumeric': 0.16849078341013826, 'fraction_numerical': 0.004608294930875576, 'mean_word_length': 3.2665847665847667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6572491', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1133, 'n_words': 259}