Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.vscode
node_modules
dist
*.db-journal
package-lock.json
DatabaseUtils\bin
DatabaseUtils\obj
build
./src/assets/dbUtil
.vs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Microsoft.Data.Sqlite;
using MongoDB.Bson;
using MongoDB.Driver;
using MySql.Data.MySqlClient;
using Npgsql;
using System;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;

namespace DatabaseUtils
{
/// <summary>
/// Database utility functions
/// </summary>
public static class DatabaseUtils {
/// <summary>
/// Test connection string is correct
/// </summary>
/// <param name="database">Database</param>
/// <param name="connectionString">Connection string</param>
public static void TestConnectionString(string database, string connectionString) {
if (string.Compare(database, "MSSQL", true, CultureInfo.InvariantCulture) == 0) {
using (var connection = new SqlConnection(connectionString)) {
connection.Open();
}
} else if (string.Compare(database, "MySQL", true, CultureInfo.InvariantCulture) == 0) {
using (var connection = new MySqlConnection(connectionString)) {
connection.Open();
}
} else if (string.Compare(database, "PostgreSQL", true, CultureInfo.InvariantCulture) == 0) {
using (var connection = new NpgsqlConnection(connectionString)) {
connection.Open();
}
} else if (string.Compare(database, "SQLite", true, CultureInfo.InvariantCulture) == 0) {
var tempDir = Path.GetDirectoryName(Path.GetTempPath());
connectionString = connectionString.Replace("{{App_Data}}", tempDir);
using (var connection = new SqliteConnection(connectionString)) {
connection.Open();
}
} else if (string.Compare(database, "InMemory", true, CultureInfo.InvariantCulture) == 0) {
// Do nothing
} else if (string.Compare(database, "MongoDB", true, CultureInfo.InvariantCulture) == 0) {
var mongoUrl = new MongoUrl(connectionString);
var mongoDatabase = new MongoClient(mongoUrl).GetDatabase(mongoUrl.DatabaseName);
mongoDatabase.ListCollections().ToBsonDocument();
} else {
throw new ArgumentException(
$"Unsupported database {database}, please check it yourself");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.0.1" />
<PackageReference Include="MongoDB.Driver" Version="2.5.0" />
<PackageReference Include="MySql.Data" Version="6.10.6" />
<PackageReference Include="Npgsql" Version="3.2.7" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DatabaseUtils
{
static class Program
{
static void Main(string[] args)
{
if (args.Length==2)
{
var dbtype = args[0];
var connectionString = args[1];
DatabaseUtils.TestConnectionString(dbtype, connectionString);
}
else
{
throw new ArgumentException();
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var path = require("path");
var _root = path.resolve(__dirname, "..");

function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
}

exports.root = root;
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Error.stackTraceLimit = Infinity;

require("core-js/es6");
require("core-js/es7/reflect");

require("zone.js/dist/zone");
require("zone.js/dist/long-stack-trace-zone");
require("zone.js/dist/proxy");
require("zone.js/dist/sync-test");
require("zone.js/dist/jasmine-patch");
require("zone.js/dist/async-test");
require("zone.js/dist/fake-async-test");

var appContext = require.context("../src", true, /\.spec\.ts/);

appContext.keys().forEach(appContext);

var testing = require("@angular/core/testing");
var browser = require("@angular/platform-browser-dynamic/testing");

testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule, browser.platformBrowserDynamicTesting());
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var webpackConfig = require("./webpack.test");

module.exports = function (config) {
var _config = {
basePath: "",

frameworks: ["jasmine"],
browserNoActivityTimeout: 0,

files: [
{ pattern: "./karma-dummy.js", watched: false }, // For some reason an empty file is required
{ pattern: "./karma-test-shim.js", watched: false },
],

preprocessors: {
"./karma-dummy.js": ["electron"], // And dummy file must be preprocessed too
"./karma-test-shim.js": ["electron", "webpack", "sourcemap"],
},

webpack: webpackConfig,

webpackMiddleware: {
stats: "errors-only"
},

webpackServer: {
noInfo: true
},

reporters: ["spec"],
specReporter: {
maxLogLines: 3, // limit number of lines logged per test
suppressErrorSummary: true, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: false, // do not print information about skipped tests
showSpecTiming: false // print the time elapsed for each spec
},

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ["Electron"],
singleRun: true,
client: {
useIframe: false,
},
};

config.set(_config);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var CopyWebpackPlugin = require("copy-webpack-plugin");
var helpers = require("./helpers");

module.exports = {
entry: {
"polyfills": "./src/polyfills.ts",
"vendor": "./src/vendor.ts",
"app": "./src/main.ts"
},

resolve: {
extensions: [".ts", ".js"]
},

externals: {
sqlite3: "commonjs sqlite3",
},

module: {
rules: [
{
test: /\.ts$/,
exclude: /\.spec\.ts$/,
use: ["awesome-typescript-loader", "angular2-template-loader"]
},
{
test: /\.html$/,
use: [
{
loader: "html-loader"
},
]
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
use: "file-loader?name=assets/images/[name].[ext]"
},
{
test: /\.scss$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader"
},
{
loader: "postcss-loader", // Run post css actions
options: {
plugins: function () { // post css plugins, can be exported to postcss.config.js
return [
require("precss"),
require("autoprefixer")
];
}
}
},
{
loader: "sass-loader",
options: {
includePaths: [
path.resolve(__dirname, "../src/assets/sass"),
path.resolve(__dirname, "../node_modules/bootstrap/scss"),
]
}
}
]
},
{
test: /\.css$/,
exclude: helpers.root("src", "app"),
use: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" })
},
{
test: /\.css$/,
include: helpers.root("src", "app"),
use: "raw-loader"
}
]
},

plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Popper: ["popper.js", "default"],
}),
new webpack.optimize.CommonsChunkPlugin({name: ["app", "vendor", "polyfills"]}),
new HtmlWebpackPlugin({template: "src/index.html"}),
new CopyWebpackPlugin([
{
from: "src/assets",
to: "assets",
toType: "dir"
},
]),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(@angular|esm5)/,
path.resolve(__dirname, "../src")
),
],

target:"electron-renderer",
node: {
__dirname: true
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var webpackMerge = require("webpack-merge");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var commonConfig = require("./webpack.common.js");
var helpers = require("./helpers");

module.exports = webpackMerge(commonConfig, {
devtool: "cheap-module-source-map",

output: {
path: helpers.root("dist"),
publicPath: "./",
filename: "[name].js",
chunkFilename: "[id].chunk.js"
},

plugins: [
new ExtractTextPlugin("[name].css")
],

devServer: {
historyApiFallback: true,
stats: "minimal"
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var webpack = require("webpack");
var webpackMerge = require("webpack-merge");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
const Uglify = require("uglifyjs-webpack-plugin");
var commonConfig = require("./webpack.common.js");
var helpers = require("./helpers");

const ENV = process.env.NODE_ENV = process.env.ENV = "production";

module.exports = webpackMerge(commonConfig, {
devtool: "source-map",

output: {
path: helpers.root("dist"),
publicPath: "./",
filename: "[name].[hash].js",
chunkFilename: "[id].[hash].chunk.js"
},

plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new Uglify({
uglifyOptions:{
keep_fnames: true
}
}),
new ExtractTextPlugin("[name].[hash].css"),
new webpack.DefinePlugin({
"process.env": {
"ENV": JSON.stringify(ENV)
}
}),
new webpack.LoaderOptionsPlugin({
htmlLoader: {
minimize: false // workaround for ng2
}
})
]
});
Loading