chore: remove obsolete files (#10240)
This commit is contained in:
@ -1,21 +0,0 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = function(dir, files) {
|
||||
var filename = 'main_test.dart';
|
||||
var imports = [
|
||||
'@TestOn("browser")',
|
||||
'import "package:guinness2/guinness2.dart";'];
|
||||
var executes = [];
|
||||
|
||||
files.forEach(function(match) {
|
||||
var varName = match.replace(/[\/.]/g, '_');
|
||||
imports.push('import "' + match + '" as ' + varName +';');
|
||||
executes.push(' ' + varName + '.main();');
|
||||
});
|
||||
|
||||
var output = imports.join('\n') + '\n\nmain() {\n' + executes.join('\n') + '\n}';
|
||||
|
||||
fs.writeFileSync(path.join(dir, filename), output);
|
||||
return filename;
|
||||
};
|
@ -1,46 +0,0 @@
|
||||
var which = require('which');
|
||||
var spawnSync = require('child_process').spawnSync;
|
||||
|
||||
module.exports.detect = function(gulp) {
|
||||
var DART_SDK = false;
|
||||
try {
|
||||
which.sync('dart');
|
||||
if (process.platform === 'win32') {
|
||||
DART_SDK = {
|
||||
ANALYZER: 'dartanalyzer.bat',
|
||||
DARTDOCGEN: 'dartdoc.bat',
|
||||
DARTFMT: 'dartfmt.bat',
|
||||
PUB: 'pub.bat',
|
||||
VM: 'dart.exe'
|
||||
};
|
||||
} else {
|
||||
DART_SDK = {
|
||||
ANALYZER: 'dartanalyzer',
|
||||
DARTDOCGEN: 'dartdoc',
|
||||
DARTFMT: 'dartfmt',
|
||||
PUB: 'pub',
|
||||
VM: 'dart'
|
||||
};
|
||||
}
|
||||
console.log('Dart SDK detected:');
|
||||
} catch (e) {
|
||||
console.log('Dart SDK is not available, Dart tasks will be skipped.');
|
||||
var gulpTaskFn = gulp.task.bind(gulp);
|
||||
gulp.task = function (name, deps, fn) {
|
||||
if (name.indexOf('.dart') === -1) {
|
||||
return gulpTaskFn(name, deps, fn);
|
||||
} else {
|
||||
return gulpTaskFn(name, function() {
|
||||
console.log('Dart SDK is not available. Skipping task: ' + name);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
return DART_SDK;
|
||||
}
|
||||
|
||||
module.exports.logVersion = function(dartSdk) {
|
||||
console.log('DART SDK:') ;
|
||||
console.log('- dart: ' + spawnSync(dartSdk.VM, ['--version']).stderr.toString().replace(/\n/g, ''));
|
||||
console.log('- pub: ' + spawnSync(dartSdk.PUB, ['--version']).stdout.toString().replace(/\n/g, ''));
|
||||
}
|
@ -1,235 +0,0 @@
|
||||
var Q = require('q');
|
||||
var readline = require('readline');
|
||||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
var fs = require('fs');
|
||||
var travisFoldStart = require('../travis/travis-fold');
|
||||
var util = require('./util');
|
||||
var yaml = require('js-yaml');
|
||||
|
||||
module.exports = function(gulp, plugins, config) {
|
||||
var travisFoldEnd = travisFoldStart(`dartanalyzer-${config.use_ddc ? 'ddc' : ''}-${config.dest}`);
|
||||
var tempFile = '_analyzer.dart';
|
||||
|
||||
return util.forEachSubDirSequential(config.dest, function(dir) {
|
||||
var pubspecContents = fs.readFileSync(path.join(dir, 'pubspec.yaml'));
|
||||
var pubspec = yaml.safeLoad(pubspecContents);
|
||||
var packageName = pubspec.name;
|
||||
|
||||
var libFiles = [].slice.call(glob.sync('lib/**/*.dart', {cwd: dir}));
|
||||
var webFiles = [].slice.call(glob.sync('web/**/*.dart', {cwd: dir}));
|
||||
var testFiles = [].slice.call(glob.sync('test/**/*_spec.dart', {cwd: dir}));
|
||||
|
||||
var analyzeFile = ['library _analyzer;'];
|
||||
libFiles.concat(testFiles).concat(webFiles).forEach(function(fileName, index) {
|
||||
if (fileName !== tempFile && fileName.indexOf("/packages/") === -1) {
|
||||
if (fileName.indexOf('lib') == 0) {
|
||||
fileName = 'package:' + packageName + '/' +
|
||||
path.relative('lib', fileName).replace(/\\/g, '/');
|
||||
}
|
||||
analyzeFile.push('import "' + fileName + '" as mod' + index + ';');
|
||||
}
|
||||
});
|
||||
fs.writeFileSync(path.join(dir, tempFile), analyzeFile.join('\n'));
|
||||
var defer = Q.defer();
|
||||
if (config.use_ddc) {
|
||||
analyze(dir, defer.makeNodeResolver(), true);
|
||||
} else {
|
||||
analyze(dir, defer.makeNodeResolver());
|
||||
}
|
||||
return defer.promise;
|
||||
}).then(travisFoldEnd);
|
||||
|
||||
function analyze(dirName, done, useDdc) {
|
||||
// TODO remove --package-warnings once dartanalyzer handles transitive libraries
|
||||
var flags = ['--fatal-warnings', '--package-warnings', '--format=machine'];
|
||||
|
||||
if (useDdc) {
|
||||
console.log('Using DDC analyzer to analyze', dirName);
|
||||
flags.push('--strong');
|
||||
}
|
||||
|
||||
var args = flags.concat(tempFile);
|
||||
|
||||
var stream = spawn(config.command, args, {
|
||||
// inherit stdin and stderr, but filter stdout
|
||||
stdio: [process.stdin, process.stdout, 'pipe'],
|
||||
cwd: dirName
|
||||
});
|
||||
// Filter out unused imports from our generated file.
|
||||
// We don't reexports from the generated file
|
||||
// as this could lead to name clashes when two files
|
||||
// export the same thing.
|
||||
var rl =
|
||||
readline.createInterface({input: stream.stderr, output: process.stdout, terminal: false});
|
||||
var hintCount = 0;
|
||||
var errorCount = 0;
|
||||
var warningCount = 0;
|
||||
rl.on('line', function(line) {
|
||||
if (line == "find: > bin [: No such file or directory") {
|
||||
// Skip bad output from Dart SDK .bat files on Windows
|
||||
return;
|
||||
}
|
||||
var parsedLine = _AnalyzerOutputLine.parse(line);
|
||||
if (!parsedLine) {
|
||||
errorCount++;
|
||||
console.log('Unexpected output: ' + line);
|
||||
return;
|
||||
}
|
||||
// TODO remove once dartanalyzer handles transitive libraries
|
||||
// skip errors in third-party packages
|
||||
if (parsedLine.sourcePath.indexOf(dirName) == -1) {
|
||||
return;
|
||||
}
|
||||
if (parsedLine.shouldIgnore()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parsedLine.isHint) {
|
||||
hintCount++;
|
||||
} else if (parsedLine.isWarning) {
|
||||
warningCount++;
|
||||
} else {
|
||||
errorCount++;
|
||||
}
|
||||
console.log(dirName + ':' + parsedLine);
|
||||
});
|
||||
stream.on('close', function() {
|
||||
var error;
|
||||
var report = [];
|
||||
if (errorCount > 0) {
|
||||
report.push(errorCount + ' error(s)');
|
||||
}
|
||||
if (warningCount > 0) {
|
||||
report.push(warningCount + ' warning(s)');
|
||||
}
|
||||
if (hintCount > 0) {
|
||||
report.push(hintCount + ' hint(s)');
|
||||
}
|
||||
if (report.length > 0) {
|
||||
error = 'Dartanalyzer showed ' + report.join(', ');
|
||||
}
|
||||
done(error);
|
||||
});
|
||||
stream.on('error', function(error) { done(error); });
|
||||
}
|
||||
};
|
||||
|
||||
// See https://github.com/dart-lang/analyzer_cli/blob/master/lib/src/error_formatter.dart
|
||||
function _AnalyzerOutputLine(result) {
|
||||
this.severity = result[1];
|
||||
this.errorType = result[2];
|
||||
this.errorCode = result[3];
|
||||
this.sourcePath = result[4];
|
||||
this.lineNum = result[5];
|
||||
this.colNum = result[6];
|
||||
this.asciiLineLength = parseInt(result[7], 10);
|
||||
this.errorMsg = result[8];
|
||||
|
||||
this.isError = Boolean(this.severity.match(/ERROR/i));
|
||||
this.isHint = Boolean(this.severity.match(/INFO/i));
|
||||
this.isWarning = Boolean(this.severity.match(/WARNING/i));
|
||||
}
|
||||
|
||||
_AnalyzerOutputLine.parse = function(line) {
|
||||
var result = _AnalyzerOutputLine._analyzerParseRegExp.exec(line);
|
||||
return result ? new _AnalyzerOutputLine(result) : null;
|
||||
};
|
||||
|
||||
_AnalyzerOutputLine._analyzerParseRegExp =
|
||||
new RegExp('([^\|]+)\\|' + // #1, severity (NONE, INFO, WARNING, ERROR)
|
||||
'([^\|]+)\\|' + // #2, errorCode.type (HINT, *_WARNING, *_ERROR, etc)
|
||||
'([^\|]+)\\|' + // #3, errorCode (UNUSED_IMPORT, UNUSED_CATCH_STACK, etc)
|
||||
'([^\|]+[^\|\\\\])\\|' + // #4, sourcePath with '|' chars backslash-escaped.
|
||||
'([^\|]+)\\|' + // #5, line number
|
||||
'([^\|]+)\\|' + // #6, column number
|
||||
'([^\|]+)\\|' + // #7, length of the ASCII line to draw
|
||||
'(.*)$'); // #8, error message
|
||||
|
||||
/* Maps file path (as string) to file source (an array of strings, one per line). */
|
||||
_AnalyzerOutputLine.cache = {};
|
||||
|
||||
_AnalyzerOutputLine.ERR_NO_SOURCE = '(Could not find source line).';
|
||||
|
||||
_AnalyzerOutputLine.prototype = {
|
||||
toString: function() {
|
||||
var sourceLine = this._getSourceLine();
|
||||
var lineText = _AnalyzerOutputLine.ERR_NO_SOURCE;
|
||||
if (sourceLine) {
|
||||
var repeat = function(str, num) {
|
||||
if (str.repeat) return str.repeat(num);
|
||||
return Array.prototype.join.call({length: num}, str);
|
||||
};
|
||||
|
||||
lineText =
|
||||
'\n' + sourceLine + '\n' + repeat(' ', this.colNum) + repeat('^', this.asciiLineLength);
|
||||
}
|
||||
return '[' + this.severity + '] type: ' + this.errorType + ' ' +
|
||||
this.errorMsg + ' (' + this.sourcePath + ', line ' + this.lineNum +
|
||||
', col ' + this.colNum + ')' + lineText;
|
||||
},
|
||||
|
||||
shouldIgnore: function() {
|
||||
if (this.errorCode.match(/UNUSED_IMPORT/i)) {
|
||||
if (this.sourcePath.match(/_analyzer\.dart/)) {
|
||||
return true;
|
||||
}
|
||||
// TODO remove it once ts2dart properly generates abstract getters
|
||||
if (this.errorMsg.match(/unimplemented/)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.errorCode.match(/DEPRECATED_MEMBER_USE/i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: https://github.com/angular/ts2dart/issues/168
|
||||
if (this.errorCode.match(/UNUSED_CATCH_STACK/i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODOs shouldn't break our build...
|
||||
if (this.errorCode.match(/TODO/i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't worry about hints in generated files.
|
||||
if (this.isHint && this.sourcePath.match(/generated/i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't worry about warnings in external code.
|
||||
if (this.sourcePath.match(/benchmarks_external/i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.errorCode.match(/UNUSED_SHOWN_NAME/i)) {
|
||||
// TODO: Narrow this ignore down to test code only.
|
||||
// See https://github.com/angular/angular/issues/8044
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// Reads the source file for the Analyzer output, caching it for future use.
|
||||
_getSourceLine: function() {
|
||||
var cache = _AnalyzerOutputLine.cache;
|
||||
var sourceLines = null;
|
||||
if (cache.hasOwnProperty(this.sourcePath)) {
|
||||
sourceLines = cache[this.sourcePath];
|
||||
} else {
|
||||
try {
|
||||
sourceLines = String(fs.readFileSync(this.sourcePath));
|
||||
sourceLines = sourceLines.split('\n');
|
||||
} catch (e) {
|
||||
sourceLines = null;
|
||||
} finally {
|
||||
// Even if this fails, cache `null` so we don't try again.
|
||||
cache[this.sourcePath] = sourceLines;
|
||||
}
|
||||
}
|
||||
return sourceLines && this.lineNum <= sourceLines.length ? sourceLines[this.lineNum - 1] : null;
|
||||
}
|
||||
};
|
@ -1,37 +0,0 @@
|
||||
var Q = require('q');
|
||||
var readline = require('readline');
|
||||
var spawn = require('child_process').spawn;
|
||||
var util = require('./util');
|
||||
|
||||
module.exports = function(gulp, plugins, config) {
|
||||
config.output = config.output || 'doc/api';
|
||||
return util.forEachSubDirSequential(config.dest, function(dir) {
|
||||
var defer = Q.defer();
|
||||
var done = defer.makeNodeResolver();
|
||||
|
||||
var supportedModules = [
|
||||
'dist/dart/angular2',
|
||||
'dist/dart/benchpress'
|
||||
];
|
||||
|
||||
if (supportedModules.indexOf(dir) === -1) {
|
||||
done();
|
||||
} else {
|
||||
console.log('INFO: running dartdoc for ', dir);
|
||||
|
||||
var stream = spawn(config.command, ['--output=' + config.output],
|
||||
{stdio: [process.stdin, process.stdout, process.stderr], cwd: dir});
|
||||
|
||||
stream.on('exit', function(code) {
|
||||
if (code !== 0) {
|
||||
done('ERROR: dartdoc exited with non-zero status ' + code);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('error', function(e) { done('ERROR: dartdoc reported error: ' + e); });
|
||||
}
|
||||
return defer.promise;
|
||||
});
|
||||
};
|
@ -1,123 +0,0 @@
|
||||
var fs = require('fs');
|
||||
var glob = require('glob');
|
||||
var hashFiles = require('hash-files');
|
||||
var path = require('path');
|
||||
var protocDetect = require('./protoc').detect;
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
// Hashs all .proto files at `config.dir`, calling `computedCallback` on each
|
||||
// when done with the original file name and its hash.
|
||||
// When all files have been hashed, calls `completeCallback` with no parameters.
|
||||
function _hashProtosTask(config, computedCallback, completeCallback) {
|
||||
var files = glob.sync(path.join(config.dir, '*.proto'));
|
||||
var toUpdate = {};
|
||||
var checkComplete = function() {
|
||||
for (var key in toUpdate) {
|
||||
if (toUpdate.hasOwnProperty(key) && toUpdate[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
files.forEach(function(file) { toUpdate[file] = true; });
|
||||
files.forEach(
|
||||
function(file) {
|
||||
hashFiles({
|
||||
algorithm: config.algorithm || 'sha1',
|
||||
files: [file]
|
||||
}, function(error, hash) {
|
||||
computedCallback(file, hash);
|
||||
toUpdate[file] = false;
|
||||
if (checkComplete()) {
|
||||
completeCallback();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function _toPbDartExtension(path) {
|
||||
return path.replace(/\.proto$/, '.pb.dart');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// Generates `.pb.dart` files from all `.proto` files located at `config.dir`.
|
||||
// This task requires the Dart protoc plugin, which is expected to reside at
|
||||
// the path specified in `config.plugin`.
|
||||
generate: function(config, done) {
|
||||
// Note that while the Dart protoc plugin requires the Dart sdk, this task will be skipped if the
|
||||
// Dart sdk is not available.
|
||||
var protoc = protocDetect();
|
||||
if (!protoc) {
|
||||
done(new Error('Could not detect protoc - failed to rebuild Dart proto code.'));
|
||||
return;
|
||||
}
|
||||
|
||||
var protoPaths = glob.sync(path.join(config.dir, '*.proto'));
|
||||
var spawnArgs = [
|
||||
'--plugin', config.plugin,
|
||||
'--proto_path', config.dir,
|
||||
'--dart_out', config.dir,
|
||||
].concat(protoPaths);
|
||||
var proc = spawn(protoc.bin, spawnArgs, {
|
||||
cwd: '.',
|
||||
stdio: ['ignore', 2, 'inherit']
|
||||
});
|
||||
var failed = false;
|
||||
var failWithError = function(msg) {
|
||||
if (failed) return;
|
||||
failed = true;
|
||||
done(new Error('Failed while generating transformer boilerplate. Check for output above.\n' +
|
||||
'Message: ' + msg + '\n' +
|
||||
'Please run manually: ' + [protoc.bin].concat(spawnArgs).join(' ')));
|
||||
};
|
||||
proc.on('error', function(err) { failWithError(String(err)); });
|
||||
proc.on('exit', function(code, signal) {
|
||||
if (!code) {
|
||||
var protocHash = hashFiles.sync({
|
||||
algorithm: config.algorithm || 'sha1',
|
||||
files: [config.plugin]
|
||||
});
|
||||
var computedCallback = function(fileName, hash) {
|
||||
var pbDartPath = _toPbDartExtension(fileName);
|
||||
var toAppend = '/**\n' +
|
||||
' * Generated with:\n' +
|
||||
' * ' + path.basename(fileName) + ' (' + hash + ')\n' +
|
||||
' * ' + protoc.version + '\n' +
|
||||
' * dart-protoc-plugin (' + protocHash + ')\n' +
|
||||
' */\n';
|
||||
fs.appendFileSync(pbDartPath, toAppend);
|
||||
};
|
||||
return _hashProtosTask(config, computedCallback, function() { done(); });
|
||||
} else {
|
||||
failWithError('Exit code was ' + code);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// Checks that the `.pb.dart` files located at `config.dir` are in sync with
|
||||
// the `proto` files at the same directory.
|
||||
// It does this by computing the hash of the `.proto` files and looking for
|
||||
// that string in the contents of the associated `.pb.dart` file. If one or
|
||||
// more file(s) do not have that hash present, this task will fail with a
|
||||
// descriptive error message.
|
||||
lint: function(config, done) {
|
||||
var missing = [];
|
||||
var computedCallback = function(filePath, hash) {
|
||||
var pbDartPath = _toPbDartExtension(filePath);
|
||||
if (String(fs.readFileSync(pbDartPath)).indexOf(hash) < 0) {
|
||||
missing.push(' ' + hash + ' not found in ' + pbDartPath + '\n');
|
||||
}
|
||||
};
|
||||
var completeCallback = function() {
|
||||
if (missing.length == 0) {
|
||||
done();
|
||||
} else {
|
||||
done(new Error(
|
||||
'Generated Dart protobuf files are out of date. Please run `gulp gen_protos.dart`.\n' +
|
||||
missing.join(''))
|
||||
);
|
||||
}
|
||||
};
|
||||
return _hashProtosTask(config, computedCallback, completeCallback);
|
||||
}
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,18 +0,0 @@
|
||||
var which = require('which');
|
||||
var spawnSync = require('child_process').spawnSync;
|
||||
|
||||
module.exports.detect = function() {
|
||||
var PROTOC = false;
|
||||
try {
|
||||
var bin = 'protoc';
|
||||
which.sync(bin);
|
||||
var version = spawnSync(bin, ['--version']).stdout.toString().replace(/\n/g, '');
|
||||
PROTOC = {
|
||||
bin: bin,
|
||||
version: version
|
||||
};
|
||||
} catch (e) {
|
||||
// Ignore, just return `false` instead of an object.
|
||||
}
|
||||
return PROTOC;
|
||||
};
|
@ -1,78 +0,0 @@
|
||||
var util = require('./util');
|
||||
var Q = require('q');
|
||||
var spawn = require('child_process').spawn;
|
||||
var through2 = require('through2');
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
var fs = require('fs');
|
||||
|
||||
function buildAllWebSubdirs(gulp, plugins, config) {
|
||||
return function() {
|
||||
var webFolders = [].slice.call(glob.sync(path.join(config.src, '*/web')));
|
||||
return nextFolder();
|
||||
|
||||
function nextFolder() {
|
||||
if (!webFolders.length) {
|
||||
return;
|
||||
}
|
||||
var folder = path.resolve(path.join(webFolders.shift(), '..'));
|
||||
var destFolder = path.resolve(path.join(config.dest, path.basename(folder)));
|
||||
|
||||
const nextConfig = {
|
||||
command: config.command,
|
||||
dest: destFolder,
|
||||
mode: config.mode,
|
||||
src: folder
|
||||
};
|
||||
return single(nextConfig).then(function() {
|
||||
return replaceDartWithJsScripts(gulp, destFolder);
|
||||
}).then(function() {
|
||||
return removeWebFolder(gulp, destFolder);
|
||||
}).then(nextFolder);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function single(config) {
|
||||
var pubMode = config.mode || 'release';
|
||||
var pubArgs = ['build', '--mode', pubMode];
|
||||
if (config.dest) {
|
||||
pubArgs = pubArgs.concat(['-o', config.dest]);
|
||||
}
|
||||
|
||||
return util.processToPromise(spawn(config.command, pubArgs, {
|
||||
stdio: 'inherit',
|
||||
cwd: config.src
|
||||
}));
|
||||
}
|
||||
|
||||
function replaceDartWithJsScripts(gulp, folder) {
|
||||
return util.streamToPromise(gulp.src(path.join(folder, '**/*.html'))
|
||||
.pipe(through2.obj(function(file, enc, done) {
|
||||
var content = file.contents.toString();
|
||||
content = content.replace(/\.dart/, '.dart.js');
|
||||
content = content.replace(/application\/dart/, 'text/javascript');
|
||||
file.contents = new Buffer(content);
|
||||
this.push(file);
|
||||
done();
|
||||
}))
|
||||
.pipe(gulp.dest(folder)));
|
||||
}
|
||||
|
||||
function singleWrapper(gulp, plugins, config) {
|
||||
return function() { return single(config); };
|
||||
}
|
||||
|
||||
function removeWebFolder(gulp, folder) {
|
||||
var folders = [].slice.call(glob.sync(path.join(folder, 'web', '*')));
|
||||
folders.forEach(function(subFolder) {
|
||||
fs.renameSync(subFolder, subFolder.replace('/web/', '/'));
|
||||
});
|
||||
fs.rmdirSync(path.join(folder, 'web'));
|
||||
return Q.resolve();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
single: singleWrapper,
|
||||
subdirs: buildAllWebSubdirs
|
||||
};
|
@ -1,36 +0,0 @@
|
||||
var util = require('./util');
|
||||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
var travisFoldStart = require('../travis/travis-fold');
|
||||
|
||||
|
||||
module.exports = {
|
||||
dir: pubGetDir,
|
||||
subDir: pubGetSubDir
|
||||
};
|
||||
|
||||
function pubGetDir(gulp, plugins, config) {
|
||||
return function() {
|
||||
var travisFoldEnd = travisFoldStart(`pubget-${config.dir}`);
|
||||
|
||||
return util.processToPromise(spawn(config.command, ['upgrade'], {
|
||||
stdio: 'inherit',
|
||||
cwd: config.dir
|
||||
})).then(travisFoldEnd);
|
||||
};
|
||||
};
|
||||
|
||||
function pubGetSubDir(gulp, plugins, config) {
|
||||
return function() {
|
||||
var travisFoldEnd = travisFoldStart(`pubget-${config.command}-${config.dir}`);
|
||||
|
||||
// We need to execute pubspec serially as otherwise we can get into trouble
|
||||
// with the pub cache...
|
||||
return util.forEachSubDirSequential(config.dir, function(subDir) {
|
||||
return util.processToPromise(spawn(config.command, ['upgrade'], {
|
||||
stdio: 'inherit',
|
||||
cwd: subDir
|
||||
}));
|
||||
}).then(travisFoldEnd);
|
||||
};
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
var util = require('./util');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
module.exports = function(gulp, plugins, config) {
|
||||
return function() {
|
||||
config.port = config.port || 8080;
|
||||
var pubMode = config.mode || 'debug';
|
||||
var pubArgs = ['serve', '--mode', pubMode, '--port', config.port];
|
||||
return util.streamToPromise(spawn(config.command, pubArgs, {
|
||||
// pub serve is very spammy, and --verbosity flag doesn't fix it
|
||||
cwd: config.path, stdio: 'inherit'
|
||||
}));
|
||||
};
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
var util = require('./util');
|
||||
var spawn = require('child_process').spawn;
|
||||
var glob = require('glob');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var process = require('process');
|
||||
var createTestMain = require('./create_dart_test_main.js')
|
||||
|
||||
function filterExclusiveTestFiles(files, dir) {
|
||||
return files.filter(function(file) {
|
||||
// TODO(juliemr): revisit if readFileSync becomes too slow.
|
||||
// At the moment, this takes <100ms for all of angular2.
|
||||
var text = fs.readFileSync(path.join(dir, file));
|
||||
var iit = text.indexOf('iit(');
|
||||
var ddescribe = text.indexOf('ddescribe(');
|
||||
return (iit !== -1 || ddescribe !== -1);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function(config) {
|
||||
var platform = config.platform || 'dartium';
|
||||
var pubArgs = ['run', 'test', '-p', platform];
|
||||
var env = process.env;
|
||||
var exclusive = false;
|
||||
if (config.dartiumTmpdir) {
|
||||
env['PATH'] = env['PATH'] + ':' + config.dartiumTmpdir;
|
||||
}
|
||||
|
||||
testFiles = glob.sync(path.join(config.files), {cwd: config.dir});
|
||||
|
||||
if (config.useExclusiveTests) {
|
||||
var filtered = filterExclusiveTestFiles(testFiles, config.dir);
|
||||
if (filtered.length) {
|
||||
exclusive = true;
|
||||
pubArgs.push('--tags');
|
||||
pubArgs.push('solo');
|
||||
testFiles = filtered;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.bunchFiles && !exclusive) {
|
||||
var bigFile = createTestMain(config.dir, testFiles);
|
||||
testFiles = [bigFile];
|
||||
}
|
||||
|
||||
pubArgs = pubArgs.concat(testFiles);
|
||||
|
||||
return util.processToPromise(spawn(config.command, pubArgs, {
|
||||
cwd: config.dir, stdio: 'inherit', env: env
|
||||
}));
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
var Q = require('q');
|
||||
var glob = require('glob');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
var util = require('./util');
|
||||
|
||||
module.exports = function(gulp, plugins, config) {
|
||||
return function() {
|
||||
if (config.dir) {
|
||||
return run(config.dir);
|
||||
} else {
|
||||
return util.forEachSubDirSequential(config.dest, run);
|
||||
}
|
||||
};
|
||||
|
||||
function run(dir) {
|
||||
var testFiles = [].slice.call(glob.sync('**/*.server.spec.dart', {
|
||||
cwd: dir
|
||||
}));
|
||||
if (testFiles.length == 0) {
|
||||
// No test files found
|
||||
return Q.resolve();
|
||||
}
|
||||
|
||||
var defer = Q.defer();
|
||||
var done = defer.makeNodeResolver();
|
||||
console.log('start tests:', dir);
|
||||
var processSerial = function() {
|
||||
if (testFiles.length == 0) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
var file = testFiles.shift();
|
||||
util.processToPromise(spawn('dart', ['-c', file], {
|
||||
stdio: 'inherit',
|
||||
cwd: dir
|
||||
})).then(
|
||||
processSerial,
|
||||
function(error) {
|
||||
done(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
processSerial();
|
||||
return defer.promise.then(function() {
|
||||
console.log('end tests');
|
||||
});
|
||||
}
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
var util = require('./util');
|
||||
var Q = require('q');
|
||||
var spawn = require('child_process').spawn;
|
||||
var readline = require('readline');
|
||||
|
||||
module.exports = function(gulp, plugins, config) {
|
||||
return function() {
|
||||
return isInstalled().then(function(installed) {
|
||||
if (!installed) {
|
||||
return util.processToPromise(spawn(config.pub,
|
||||
['global', 'activate', config.packageName, '--no-executables'], {
|
||||
stdio: 'inherit'
|
||||
}));
|
||||
}
|
||||
}).then(function() {
|
||||
return util.processToPromise(spawn(config.pub, ['global', 'run'].concat(config.args), {
|
||||
stdio: 'inherit'
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
function isInstalled() {
|
||||
var subProcess = spawn(config.pub, ['global', 'list'], {
|
||||
// inherit stdin and stderr, but filter stdout
|
||||
stdio: [process.stdin, 'pipe', process.stderr]
|
||||
});
|
||||
var rl = readline.createInterface({
|
||||
input: subProcess.stdout,
|
||||
output: process.stdout,
|
||||
terminal: false
|
||||
});
|
||||
var found = false;
|
||||
rl.on('line', function(line) {
|
||||
if (line.indexOf(config.packageName) !== -1) {
|
||||
found = true;
|
||||
}
|
||||
console.log(line);
|
||||
});
|
||||
return util.processToPromise(subProcess).then( function() {
|
||||
return found;
|
||||
});
|
||||
}
|
||||
|
||||
};
|
Reference in New Issue
Block a user