mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Rename Cakefile and make it work
This commit is contained in:
parent
1867a3f121
commit
f97c37fe5d
5 changed files with 114 additions and 247 deletions
|
@ -39,5 +39,4 @@ script:
|
||||||
- go vet ./...
|
- go vet ./...
|
||||||
- go test -v -race ./...
|
- go test -v -race ./...
|
||||||
- cd proxy
|
- cd proxy
|
||||||
- npm run-script lint
|
|
||||||
- npm test
|
- npm test
|
||||||
|
|
|
@ -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');
|
|
||||||
});
|
|
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
108
proxy/make.js
Executable file
108
proxy/make.js
Executable file
|
@ -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.');
|
||||||
|
}
|
|
@ -2,17 +2,16 @@
|
||||||
"name": "snowflake-pt",
|
"name": "snowflake-pt",
|
||||||
"version": "0.0.0-git",
|
"version": "0.0.0-git",
|
||||||
"description": "Snowflake is a WebRTC pluggable transport for Tor.",
|
"description": "Snowflake is a WebRTC pluggable transport for Tor.",
|
||||||
"main": "snowflake.coffee",
|
"main": "build/snowflake.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "cake test",
|
"test": "node make.js test",
|
||||||
"lint": "cake lint",
|
"build": "node make.js build",
|
||||||
"build": "cake build",
|
"webext": "node make.js webext",
|
||||||
"webext": "cake webext",
|
"clean": "node make.js clean",
|
||||||
"clean": "cake clean",
|
"prepublish": "node make.js node",
|
||||||
"prepublish": "cake node",
|
|
||||||
"start": "node build/snowflake.js"
|
"start": "node build/snowflake.js"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -21,11 +20,9 @@
|
||||||
"author": "Serene Han",
|
"author": "Serene Han",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"coffeelint": "^1.16.0",
|
|
||||||
"jasmine": "2.5.2"
|
"jasmine": "2.5.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"coffeescript": "^2.4.1",
|
|
||||||
"wrtc": "^0.0.61",
|
"wrtc": "^0.0.61",
|
||||||
"ws": "^3.3.1",
|
"ws": "^3.3.1",
|
||||||
"xmlhttprequest": "^1.8.0"
|
"xmlhttprequest": "^1.8.0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue