Added NightAlert project for travel kit

This commit is contained in:
2021-06-10 14:39:06 -04:00
commit d38d9e3b7e
308 changed files with 35922 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
module.exports = function (grunt) {
grunt.registerTask('buildClient',
'build cs modules', function () {
var
fs = require('fs'),
S = require('string'),
string = require('string-formatter'),
os = grunt.config('os'),
config = grunt.config('config'),
configuration = grunt.config('msbuild_configuration'),
output_path_base = 'bin\\'+ configuration +'\\',
nuget_builds = grunt.config('nuget_builds'),
tasks = [],
clean_format = os === 'win' ? '{0} start-process ' +
'-NoNewWindow ' +
//'-WindowStyle Normal ' + //-WindowStyle (Hidden | Normal) | -NoNewWindow
'-FilePath {1} ' +
'-ArgumentList \' {2} /t:clean;Rebuild /p:Configuration={3} /p:OutputPath={4} \' ' :
'{0} {1} /t:Rebuild /p:Configuration={2} ',
//build_format = os === 'win' ? '{0} start-process ' +
// '-NoNewWindow ' +
// //'-WindowStyle Normal ' + //-WindowStyle (Hidden | Normal) | -NoNewWindow
// '-FilePath {1} ' +
// '-ArgumentList \' {2} /p:Configuration={3} \' ' :
// '{0} {1} /p:Configuration={2}',
i;
function addBuildWithTitle(title, dir, copyOnly) {
var
dir_path = string.format('{0}/../../Src/{1}/', __dirname, title),
csproj = string.format('{0}{1}.csproj', dir_path, title),
output_path = output_path_base + dir +'\\',
clean = os === 'win' ? string.format(clean_format, config.win.powershell, config.win.msbuild, csproj, configuration, output_path) :
string.format(clean_format, config.linux.msbuild, csproj, configuration),
//build = os === 'win' ? string.format(build_format, config.win.powershell, config.win.msbuild, csproj, configuration ):
// string.format(build_format, config.linux.msbuild, csproj, configuration),
template_file_content = fs.readFileSync('./templates/AssemblyInfo.cs');
//template_file_content = S(template_file_content).replaceAll('@TITLE@', title).s;
template_file_content = S(template_file_content).replaceAll('@VERSION@', config.version).s;
//grunt.log.writeln('template_file_content = "%s"', template_file_content);
fs.writeFileSync(string.format('{0}Properties/AssemblyInfo.cs', dir_path), template_file_content);
if (!copyOnly) {
tasks.push(clean);
}
}
for (i = 0; i < nuget_builds.length; i++) {
if (nuget_builds[i].Name !== 'EngineIoClientDotNet.netstandard1.3') {
addBuildWithTitle(nuget_builds[i].Name, nuget_builds[i].NuGetDir, nuget_builds[i].copyOnly);
}
}
grunt.log.writeln('tasks = %s', JSON.stringify(tasks));
grunt.config('shell.exec.command', tasks.join('&&'));
grunt.task.run('shell');
if (configuration === 'Release') {
//grunt.task.run('clean:release');
if (os === 'win') {
grunt.task.run('copy:release');
} else {
grunt.task.run('copy:release_mono');
}
}
});
};

View File

@@ -0,0 +1,56 @@
module.exports = function (grunt) {
grunt.registerTask('buildTest',
'test modules', function () {
var
fs = require('fs'),
S = require('string'),
string = require('string-formatter'),
os = grunt.config('os'),
config = grunt.config('config'),
configuration = grunt.config('msbuild_configuration'),
tasks = [],
clean_format = os === 'win' ? '{0} start-process ' +
'-NoNewWindow ' +
//'-WindowStyle Normal ' + //-WindowStyle (Hidden | Normal) | -NoNewWindow
'-FilePath {1} ' +
'-ArgumentList \' {2} /t:clean /p:Configuration={3} \' ' :
'{0} {1} /t:clean /p:Configuration={2}',
build_format = os === 'win' ? '{0} start-process ' +
'-NoNewWindow ' +
//'-WindowStyle Normal ' + //-WindowStyle (Hidden | Normal) | -NoNewWindow
'-FilePath {1} ' +
'-ArgumentList \' {2} /p:Configuration={3} \' ' :
'{0} {1} /p:Configuration={2}';
function addBuildWithTitle(title) {
var
dir_path = string.format('{0}/../../Src/{1}/', __dirname,title),
csproj = string.format('{0}{1}.csproj', dir_path, title),
clean = os === 'win' ? string.format(clean_format, config.win.powershell, config.win.msbuild, csproj, configuration ):
string.format(clean_format, config.linux.msbuild, csproj, configuration),
build = os === 'win' ? string.format(build_format, config.win.powershell, config.win.msbuild, csproj, configuration ):
string.format(build_format, config.linux.msbuild, csproj, configuration),
template_file_content = fs.readFileSync('./templates/AssemblyInfo.cs');
template_file_content = S(template_file_content).replaceAll('@VERSION@', config.version).s;
//grunt.log.writeln('template_file_content = "%s"', template_file_content);
fs.writeFileSync(string.format('{0}Properties/AssemblyInfo.cs', dir_path), template_file_content);
tasks.push(clean);
tasks.push(build);
}
if (os === 'win') {
addBuildWithTitle('EngineIoClientDotNet.Tests.net45');
} else {
addBuildWithTitle('EngineIoClientDotNet.Tests.mono');
}
grunt.log.writeln('tasks = %s', JSON.stringify(tasks));
grunt.config('shell.exec.command', tasks.join('&&'));
grunt.task.run('shell');
});
};

View File

@@ -0,0 +1,98 @@
module.exports = function (grunt) {
grunt.registerTask('createNugetPackage',
'create package ', function () {
var
fs = require('fs'),
S = require('string'),
string = require('string-formatter'),
os = grunt.config('os'),
config = grunt.config('config'),
working_path = grunt.config('working_path'),
package_path = working_path + '/NuGet/',
package_lib_path = working_path + '/NuGet/lib/',
//configuration = grunt.config('msbuild_configuration'),
configuration = grunt.config('msbuild_configuration'),
output_path_base = 'bin\\' + configuration + '\\',
nuget_builds = grunt.config('nuget_builds'),
nuget_path = os === 'win' ?
config.win.nuget : config.linux.nuget,
dst_path,
template_file_content,
i,
tasks = [];
//function createPackageWithTitle(title) {
// var
// dir_path = string.format('{0}/../../{1}/', __dirname, title),
// csproj = string.format('{0}{1}.csproj', dir_path, title),
// pack = string.format('{0} pack {1}', nuget_path, csproj);
// tasks.push(pack);
//}
if (os !== 'win') {
return;
}
if (configuration !== 'Release') {
grunt.log.writeln('wrong configuration = ' + configuration);
return;
}
//createPackageWithTitle('EngineIoClientDotNet');
if (! fs.existsSync(working_path)) {
fs.mkdirSync(working_path);
fs.mkdirSync(package_path);
fs.mkdirSync(package_lib_path);
}
if (!fs.existsSync(package_path)) {
fs.mkdirSync(package_path);
fs.mkdirSync(package_lib_path);
}
if (!fs.existsSync(package_lib_path)) {
fs.mkdirSync(package_lib_path);
}
for (i = 0; i < nuget_builds.length; i++) {
dst_path = package_lib_path + nuget_builds[i].NuGetDir + '/';
//files = fs.readdirSync(dst_path);
grunt.log.writeln(string.format('dst_path={0}', dst_path));
fs.mkdirSync(dst_path);
}
template_file_content = fs.readFileSync('./templates/EngineIoClientDotNet.nuspec');
template_file_content = S(template_file_content).replaceAll('@VERSION@', config.version).s;
fs.writeFileSync(string.format('{0}EngineIoClientDotNet.nuspec', package_path), template_file_content);
function addBuildWithTitle(title, destsubdir, srcsubdir) {
var src_path = string.format('{0}/../../Src/{1}/{2}{3}/', __dirname, title, output_path_base, srcsubdir);
var dst_path = package_lib_path + destsubdir + '/';
var filename = 'EngineIoClientDotNet.dll';
var src_file = string.format('{0}{1}', src_path, filename);
var dst_file = string.format('{0}EngineIoClientDotNet.dll', dst_path);
grunt.log.writeln(string.format('src_file={0} dst_file={1}', src_file, dst_file));
fs.writeFileSync(dst_file, fs.readFileSync(src_file));
//src_file = src_path + string.format('{0}.xml', title);
//dst_file = string.format('{0}EngineIoClientDotNet.xml', dst_path);
//grunt.log.writeln(string.format('src_file={0} dst_file={1}', src_file, dst_file));
//fs.writeFileSync(dst_file, fs.readFileSync(src_file));
}
for (i = 0; i < nuget_builds.length; i++) {
addBuildWithTitle(nuget_builds[i].Name, nuget_builds[i].NuGetDir, nuget_builds[i].SourceDir);
}
tasks.push('C:/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe pwd');
tasks.push(string.format('{0} pack EngineIoClientDotNet.nuspec', config.win.nuget));
grunt.log.writeln('tasks = %s', JSON.stringify(tasks));
grunt.config('shell.exec.options.execOptions.cwd', package_path);
grunt.config('shell.exec.command', tasks.join('&&'));
grunt.task.run('shell');
});
};

View File

@@ -0,0 +1,32 @@
module.exports = function (grunt) {
grunt.registerTask('installNpm',
'install node modules', function () {
var
string = require('string-formatter'),
server_path2 = grunt.config('server_path'),
os = grunt.config('os'),
config = grunt.config('config'),
win_pwd_command = string.format('{0} pwd', config.win.powershell);
grunt.log.writeln('server_path = "%s"', server_path2);
grunt.log.writeln('win_pwd_command = "%s"', win_pwd_command);
if (os === 'win') {
grunt.config('shell.exec.options.execOptions.cwd', '<%= server_path %>');
grunt.config('shell.exec.command', [win_pwd_command,
'npm install'].join('&&'));
grunt.task.run('shell');
} else {
grunt.config('shell.exec.options.execOptions.cwd', '<%= server_path %>');
grunt.config('shell.exec.command', ['pwd', 'npm install'].join('&&'));
grunt.task.run('shell');
}
});
};

View File

@@ -0,0 +1,40 @@
module.exports = function (grunt) {
grunt.registerTask('nuget',
'get nuget assemblies', function () {
var
//fs = require('fs'),
//S = require('string'),
string = require('string-formatter'),
os = grunt.config('os'),
config = grunt.config('config'),
//configuration = grunt.config('msbuild_configuration'),
nuget_builds = grunt.config('nuget_builds'),
nuget_path = os === 'win' ?
config.win.nuget : config.linux.nuget,
format_str = os === 'win' ?
'{0} restore "{1}"' :
'mono --runtime=v4.0.30319 {0} restore {1}',
tasks = [],
i;
function restorePackagesWithTitle(title) {
var
sln = string.format('{0}/../../Src/{1}/{2}.sln',__dirname, title,title),
restore = string.format(format_str, nuget_path, sln);
tasks.push(restore);
}
if (os === 'win') {
for (i = 0; i < nuget_builds.length; i++) {
restorePackagesWithTitle(nuget_builds[i].Name);
}
}
grunt.log.writeln('tasks = %s', JSON.stringify(tasks));
grunt.config('shell.exec.command', tasks.join('&&'));
grunt.task.run('shell');
});
};

View File

@@ -0,0 +1,44 @@
module.exports = function (grunt) {
grunt.registerTask('startServer',
'install node modules', function () {
var
server_path = grunt.config('server_path'),
os = grunt.config('os'),
string = require('string-formatter'),
config = grunt.config('config'),
tasks = [],
start,
pwd;
grunt.log.writeln('server_path = "%s"', server_path);
if (os === 'win') {
start = '{0} start-process ' +
'-NoNewWindow ' +
//'-WindowStyle Normal ' + //-WindowStyle (Hidden | Normal) | -NoNewWindow
'-FilePath node ' +
'-ArgumentList \' server.js \' ';
start = string.format(start, config.win.powershell);
pwd = string.format('{0} pwd',config.win.powershell);
tasks.push(pwd);
tasks.push(start);
grunt.log.writeln('tasks = %s', JSON.stringify(tasks));
grunt.config('shell.exec.options.execOptions.cwd', '<%= server_path %>');
grunt.config('shell.exec.command', tasks.join('&&'));
grunt.task.run('shell');
} else {
grunt.config('shell.exec.options.execOptions.cwd', '<%= server_path %>');
grunt.config('shell.exec.command', ['pwd', 'node server.js'].join('&&'));
grunt.task.run('shell');
}
});
};

View File

@@ -0,0 +1,39 @@
module.exports = function (grunt) {
grunt.registerTask('testClient',
'test cs', function () {
var
string = require('string-formatter'),
os = grunt.config('os'),
config = grunt.config('config'),
tasks = [],
configuration = grunt.config('msbuild_configuration'),
test_format_str = os === 'win' ?
'{0}/xunit.console.exe {1} -nunit test.xml -parallel none' :
'mono {0}/xunit.console.clr4.exe {1}',
xunit_path = os === 'win' ?
config.win.xunit_path : config.linux.xunit_path;
function addTestDllWithTitle(title) {
var
dir_path = string.format('{0}/../../Src/{1}/', __dirname, title),
test_dll = string.format('{0}bin/{1}/{2}.dll', dir_path, configuration, title);
tasks.push( string.format(test_format_str,xunit_path, test_dll) );
}
if (os === 'win') {
addTestDllWithTitle('EngineIoClientDotNet.Tests.net45');
} else {
addTestDllWithTitle('EngineIoClientDotNet.Tests.mono');
}
grunt.log.writeln('tasks = %s', JSON.stringify(tasks));
grunt.config('shell.exec.command', tasks.join('&&'));
grunt.task.run('shell');
});
};