[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Rename Cakefile and make it work



commit f97c37fe5d98ad2df5f2e8cd6aac5a79882def65
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date:   Sat Jul 6 15:48:33 2019 +0200

    Rename Cakefile and make it work
---
 .travis.yml           |   1 -
 proxy/Cakefile.js     | 102 --------------------------------------
 proxy/coffeelint.json | 135 --------------------------------------------------
 proxy/make.js         | 108 ++++++++++++++++++++++++++++++++++++++++
 proxy/package.json    |  15 +++---
 5 files changed, 114 insertions(+), 247 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 3037f5a..29d6525 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,5 +39,4 @@ script:
     - go vet ./...
     - go test -v -race ./...
     - cd proxy
-    - npm run-script lint
     - npm test
diff --git a/proxy/Cakefile.js b/proxy/Cakefile.js
deleted file mode 100644
index 91ceea4..0000000
--- a/proxy/Cakefile.js
+++ /dev/null
@@ -1,102 +0,0 @@
-
-var fs = require('fs');
-var { exec, spawn, execSync } = require('child_process');
-
-// All coffeescript files required.
-var FILES = [
-  'broker.coffee',
-  'config.coffee',
-  'proxypair.coffee',
-  'snowflake.coffee',
-  'ui.coffee',
-  'util.coffee',
-  'websocket.coffee',
-  'shims.coffee'
-];
-
-var INITS = [
-  'init-badge.coffee',
-  'init-node.coffee',
-  'init-webext.coffee'
-];
-
-var FILES_SPEC = [
-  'spec/broker.spec.coffee',
-  'spec/init.spec.coffee',
-  'spec/proxypair.spec.coffee',
-  'spec/snowflake.spec.coffee',
-  'spec/ui.spec.coffee',
-  'spec/util.spec.coffee',
-  'spec/websocket.spec.coffee'
-];
-
-var OUTFILE = 'snowflake.js';
-
-var STATIC = 'static';
-
-var copyStaticFiles = function() {
-  return exec('cp ' + STATIC + '/* build/');
-};
-
-var compileCoffee = function(outDir, init) {
-  var files;
-  files = FILES.concat('init-' + init + '.coffee');
-  return exec('cat ' + files.join(' ') + ' | coffee -cs > ' + outDir + '/' + OUTFILE, function(err, stdout, stderr) {
-    if (err) {
-      throw err;
-    }
-  });
-};
-
-task('test', 'snowflake unit tests', function() {
-  var jasmineFiles, outFile, proc;
-  exec('mkdir -p test');
-  exec('jasmine init >&-');
-  // Simply concat all the files because we're not using node exports.
-  jasmineFiles = FILES.concat('init-badge.coffee', FILES_SPEC);
-  outFile = 'test/bundle.spec.coffee';
-  exec('echo "TESTING = true" > ' + outFile);
-  exec('cat ' + jasmineFiles.join(' ') + ' | cat >> ' + outFile);
-  execSync('coffee -cb ' + outFile);
-  proc = spawn('jasmine', ['test/bundle.spec.js'], {
-    stdio: 'inherit'
-  });
-  return proc.on("exit", function(code) {
-    return process.exit(code);
-  });
-});
-
-task('build', 'build the snowflake proxy', function() {
-  exec('mkdir -p build');
-  copyStaticFiles();
-  compileCoffee('build', 'badge');
-  return console.log('Snowflake prepared.');
-});
-
-task('webext', 'build the webextension', function() {
-  exec('mkdir -p webext');
-  compileCoffee('webext', 'webext');
-  return console.log('Webextension prepared.');
-});
-
-task('node', 'build the node binary', function() {
-  exec('mkdir -p build');
-  compileCoffee('build', 'node');
-  return console.log('Node prepared.');
-});
-
-task('lint', 'ensure idiomatic coffeescript', function() {
-  var filesAll, proc;
-  filesAll = FILES.concat(INITS, FILES_SPEC);
-  proc = spawn('coffeelint', filesAll, {
-    file: 'coffeelint.json',
-    stdio: 'inherit'
-  });
-  return proc.on("exit", function(code) {
-    return process.exit(code);
-  });
-});
-
-task('clean', 'remove all built files', function() {
-  return exec('rm -r build');
-});
diff --git a/proxy/coffeelint.json b/proxy/coffeelint.json
deleted file mode 100644
index 239092c..0000000
--- a/proxy/coffeelint.json
+++ /dev/null
@@ -1,135 +0,0 @@
-{
-  "arrow_spacing": {
-    "level": "error"
-  },
-  "braces_spacing": {
-    "level": "error",
-    "spaces": 1,
-    "empty_object_spaces": 0
-  },
-  "camel_case_classes": {
-    "level": "error"
-  },
-  "coffeescript_error": {
-    "level": "error"
-  },
-  "colon_assignment_spacing": {
-    "level": "ignore",
-    "spacing": {
-      "left": 0,
-      "right": 0
-    }
-  },
-  "cyclomatic_complexity": {
-    "level": "ignore",
-    "value": 10
-  },
-  "duplicate_key": {
-    "level": "error"
-  },
-  "empty_constructor_needs_parens": {
-    "level": "ignore"
-  },
-  "ensure_comprehensions": {
-    "level": "warn"
-  },
-  "eol_last": {
-    "level": "ignore"
-  },
-  "indentation": {
-    "value": 2,
-    "level": "error"
-  },
-  "line_endings": {
-    "level": "ignore",
-    "value": "unix"
-  },
-  "max_line_length": {
-    "value": 80,
-    "level": "warn",
-    "limitComments": true
-  },
-  "missing_fat_arrows": {
-    "level": "ignore",
-    "is_strict": false
-  },
-  "newlines_after_classes": {
-    "value": 3,
-    "level": "ignore"
-  },
-  "no_backticks": {
-    "level": "error"
-  },
-  "no_debugger": {
-    "level": "warn",
-    "console": false
-  },
-  "no_empty_functions": {
-    "level": "ignore"
-  },
-  "no_empty_param_list": {
-    "level": "ignore"
-  },
-  "no_implicit_braces": {
-    "level": "ignore",
-    "strict": true
-  },
-  "no_implicit_parens": {
-    "level": "ignore",
-    "strict": true
-  },
-  "no_interpolation_in_single_quotes": {
-    "level": "ignore"
-  },
-  "no_nested_string_interpolation": {
-    "level": "warn"
-  },
-  "no_plusplus": {
-    "level": "ignore"
-  },
-  "no_private_function_fat_arrows": {
-    "level": "warn"
-  },
-  "no_stand_alone_at": {
-    "level": "error"
-  },
-  "no_tabs": {
-    "level": "error"
-  },
-  "no_this": {
-    "level": "error"
-  },
-  "no_throwing_strings": {
-    "level": "error"
-  },
-  "no_trailing_semicolons": {
-    "level": "error"
-  },
-  "no_trailing_whitespace": {
-    "level": "error",
-    "allowed_in_comments": false,
-    "allowed_in_empty_lines": false
-  },
-  "no_unnecessary_double_quotes": {
-    "level": "ignore"
-  },
-  "no_unnecessary_fat_arrows": {
-    "level": "warn"
-  },
-  "non_empty_constructor_needs_parens": {
-    "level": "ignore"
-  },
-  "prefer_english_operator": {
-    "level": "ignore",
-    "doubleNotLevel": "ignore"
-  },
-  "space_operators": {
-    "level": "ignore"
-  },
-  "spacing_after_comma": {
-    "level": "ignore"
-  },
-  "transform_messes_up_line_numbers": {
-    "level": "warn"
-  }
-}
diff --git a/proxy/make.js b/proxy/make.js
new file mode 100755
index 0000000..f5f1c0a
--- /dev/null
+++ b/proxy/make.js
@@ -0,0 +1,108 @@
+#!/usr/bin/env node
+
+var fs = require('fs');
+var { exec, spawn, execSync } = require('child_process');
+
+// All files required.
+var FILES = [
+  'broker.js',
+  'config.js',
+  'proxypair.js',
+  'snowflake.js',
+  'ui.js',
+  'util.js',
+  'websocket.js',
+  'shims.js'
+];
+
+var INITS = [
+  'init-badge.js',
+  'init-node.js',
+  'init-webext.js'
+];
+
+var FILES_SPEC = [
+  'spec/broker.spec.js',
+  'spec/init.spec.js',
+  'spec/proxypair.spec.js',
+  'spec/snowflake.spec.js',
+  'spec/ui.spec.js',
+  'spec/util.spec.js',
+  'spec/websocket.spec.js'
+];
+
+var OUTFILE = 'snowflake.js';
+
+var STATIC = 'static';
+
+var copyStaticFiles = function() {
+  exec('cp ' + STATIC + '/* build/');
+};
+
+var concatJS = function(outDir, init) {
+  var files;
+  files = FILES.concat(`init-${init}.js`);
+  return exec(`cat ${files.join(' ')} > ${outDir}/${OUTFILE}`, function(err, stdout, stderr) {
+    if (err) {
+      throw err;
+    }
+  });
+};
+
+var tasks = new Map();
+
+var task = function(key, msg, func) {
+  tasks.set(key, {
+    msg, func
+  });
+};
+
+task('test', 'snowflake unit tests', function() {
+  var jasmineFiles, outFile, proc;
+  exec('mkdir -p test');
+  exec('jasmine init >&-');
+  // Simply concat all the files because we're not using node exports.
+  jasmineFiles = FILES.concat('init-badge.js', FILES_SPEC);
+  outFile = 'test/bundle.spec.js';
+  exec('echo "TESTING = true" > ' + outFile);
+  exec('cat ' + jasmineFiles.join(' ') + ' | cat >> ' + outFile);
+  proc = spawn('jasmine', ['test/bundle.spec.js'], {
+    stdio: 'inherit'
+  });
+  proc.on("exit", function(code) {
+    process.exit(code);
+  });
+});
+
+task('build', 'build the snowflake proxy', function() {
+  exec('mkdir -p build');
+  copyStaticFiles();
+  concatJS('build', 'badge');
+  console.log('Snowflake prepared.');
+});
+
+task('webext', 'build the webextension', function() {
+  exec('mkdir -p webext');
+  concatJS('webext', 'webext');
+  console.log('Webextension prepared.');
+});
+
+task('node', 'build the node binary', function() {
+  exec('mkdir -p build');
+  concatJS('build', 'node');
+  console.log('Node prepared.');
+});
+
+task('clean', 'remove all built files', function() {
+  exec('rm -r build test spec/support');
+});
+
+var cmd = process.argv[2];
+
+if (tasks.has(cmd)) {
+  var t = tasks.get(cmd);
+  console.log(t.msg);
+  t.func();
+} else {
+  console.error('Command not supported.');
+}
diff --git a/proxy/package.json b/proxy/package.json
index c907fed..ca13a52 100644
--- a/proxy/package.json
+++ b/proxy/package.json
@@ -2,17 +2,16 @@
   "name": "snowflake-pt",
   "version": "0.0.0-git",
   "description": "Snowflake is a WebRTC pluggable transport for Tor.",
-  "main": "snowflake.coffee",
+  "main": "build/snowflake.js",
   "directories": {
     "test": "test"
   },
   "scripts": {
-    "test": "cake test",
-    "lint": "cake lint",
-    "build": "cake build",
-    "webext": "cake webext",
-    "clean": "cake clean",
-    "prepublish": "cake node",
+    "test": "node make.js test",
+    "build": "node make.js build",
+    "webext": "node make.js webext",
+    "clean": "node make.js clean",
+    "prepublish": "node make.js node",
     "start": "node build/snowflake.js"
   },
   "bin": {
@@ -21,11 +20,9 @@
   "author": "Serene Han",
   "license": "BSD-3-Clause",
   "devDependencies": {
-    "coffeelint": "^1.16.0",
     "jasmine": "2.5.2"
   },
   "dependencies": {
-    "coffeescript": "^2.4.1",
     "wrtc": "^0.0.61",
     "ws": "^3.3.1",
     "xmlhttprequest": "^1.8.0"



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits